@appstorys/react-web 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var yr=Object.create;var mo=Object.defineProperty;var hr=Object.getOwnPropertyDescriptor;var br=Object.getOwnPropertyNames;var xr=Object.getPrototypeOf,Sr=Object.prototype.hasOwnProperty;var Re=(t,e)=>()=>(t&&(e=t(t=0)),e);var Pn=(t,e)=>{for(var o in e)mo(t,o,{get:e[o],enumerable:!0})},$n=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of br(e))!Sr.call(t,n)&&n!==o&&mo(t,n,{get:()=>e[n],enumerable:!(i=hr(e,n))||i.enumerable});return t};var ae=(t,e,o)=>(o=t!=null?yr(xr(t)):{},$n(e||!t||!t.__esModule?mo(o,"default",{value:t,enumerable:!0}):o,t)),Cr=t=>$n(mo({},"__esModule",{value:!0}),t);var pt,$e=Re(()=>{"use strict";pt=class{static async getItem(e){try{return localStorage.getItem(e)}catch{return null}}static async setItem(e,o){try{localStorage.setItem(e,o)}catch{}}static async removeItem(e){try{localStorage.removeItem(e)}catch{}}}});function Yt(){return $o.getState().userId}async function bt(){return pt.getItem("access_token")}function On(t){if(!t)return;let e=String(t||"").trim();if(e)return $o.getState().variantMappings?.[e]}var Wn,$o,A,rt=Re(()=>{"use strict";Wn=require("zustand");$e();$o=(0,Wn.create)(t=>({userId:"",appId:"",accountId:"",currentScreen:"",campaigns:[],allCampaigns:[],campaignVersion:2,trackedEvents:[],trackedEventMetadata:{},isVisible:!0,isAnonymousUser:!1,variantMappings:{},personalizationData:{},screenCaptureEnabled:!1,baseUrl:void 0,trackingUrl:void 0,saveCampaigns:e=>t({campaigns:e}),saveAllCampaigns:e=>t({allCampaigns:e}),setCampaignVersion:e=>t({campaignVersion:e}),setUserId:e=>t({userId:e}),setAppId:e=>t({appId:e}),setAccountId:e=>t({accountId:e}),setCurrentScreen:e=>t({currentScreen:e}),setAttributes:e=>t({attributes:e}),setTrackedEvents:e=>t({trackedEvents:e}),setTrackedEventMetadata:e=>t({trackedEventMetadata:e}),setVisibility:e=>t({isVisible:e}),setIsAnonymousUser:e=>t({isAnonymousUser:e}),setVariantMappings:e=>t({variantMappings:e}),setPersonalizationData:e=>t({personalizationData:e}),setScreenCaptureEnabled:e=>t({screenCaptureEnabled:e}),setBaseUrl:e=>t({baseUrl:e}),setTrackingUrl:e=>t({trackingUrl:e})}));A=$o});async function Te(){try{return{browser:navigator.userAgent,language:navigator.language,platform:"web",screen_width_px:window.innerWidth,screen_height_px:window.innerHeight,screen_density:window.devicePixelRatio,orientation:window.innerWidth<window.innerHeight?"portrait":"landscape",timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}}catch(t){return console.error("Error fetching device info:",t),{}}}var ho=Re(()=>{"use strict"});async function le(t,e,o){try{let i={account_id:t,app_id:e,user_id:o};if(await pt.getItem(Un))console.log("Device info already sent previously - skipping");else{let c=await Te();i.attributes={...c},console.log("First time verification - including device info in attributes")}let l=A.getState().baseUrl||"https://users.appstorys.co",d=await fetch(`${l}/${t}/validate-account`,{method:"POST",body:JSON.stringify(i),headers:{Accept:"application/json","Content-Type":"application/json"}});if(console.log("Verify account body",i),console.log("Verifying account",d.status,d.statusText),d.ok){let c=await d.json();console.log("Account verified",c);let{access_token:y,refresh_token:b}=c;if(y&&b)return await pt.setItem("access_token",y),await pt.setItem("refresh_token",b),i.attributes&&(await pt.setItem(Un,"true"),console.log("Device info sent flag set")),!0}return!1}catch(i){return console.error("Error when verifying AppStorys account",i),!1}}var Un,bo=Re(()=>{"use strict";$e();ho();rt();Un="device_info_sent"});async function Eo(t,e){if(!e||e.length===0){console.info("AppStorys: identifyWidgetPositions called with empty positionList; skipping");return}let o=await bt();if(!o){console.error("AppStorys: identifyWidgetPositions - access token not found");return}try{let i="https://backend.appstorys.co/api/v2/appinfo/identify-positions/";console.info("AppStorys: identifyWidgetPositions payload",{screen_name:t,position_list:e});let n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,Accept:"application/json"},body:JSON.stringify({screen_name:t,position_list:e})});n.ok?console.info("AppStorys: identifyWidgetPositions OK"):console.error("AppStorys: identifyWidgetPositions failed",n.status,await n.text())}catch(i){console.error("AppStorys: identifyWidgetPositions error",i)}}var lr=Re(()=>{"use strict";rt()});function Do(t){return t&&(t.startsWith("widget_")?t:`widget_${t}`)}function Bs(){try{let t=A.getState().allCampaigns||[],e=[];return t.forEach(o=>{o&&o.position&&typeof o.position=="string"&&e.push(String(o.position));try{if(o&&o.campaign_type==="WID"&&o.details){let i=o.details;typeof i=="object"&&(i.id&&typeof i.id=="string"&&e.push(String(i.id)),i.variants&&typeof i.variants=="object"&&Object.values(i.variants).forEach(n=>{n&&n.id&&typeof n.id=="string"&&e.push(String(n.id))}))}}catch{}}),e.filter(o=>!!o).map(o=>Do(String(o))).filter(o=>!!o)}catch{return[]}}function Ls(t){try{let e=Bs();if(!e||e.length===0)return[];let o=[];return e.forEach(i=>{let n=i.replace(/^widget_/,""),r=[`[data-as-id="${n}"]`,`#${n}`,`.${n}`,`[data-widget="${n}"]`],l=null;for(let d of r)if(l=document.querySelector(d),l)break;if(l){let d=l.getBoundingClientRect(),c={x:Math.round(d.left),y:Math.round(d.top),width:Math.round(d.width),height:Math.round(d.height),screenWidth:window.innerWidth,screenHeight:window.innerHeight};Ae.addLayoutInfo(t,n,c),o.push(n)}}),console.info("AppStorys: mapServerPositionsToDOM mapped",o.length,"server positions to DOM elements",o),o}catch(e){return console.warn("AppStorys: mapServerPositionsToDOM error",e),[]}}function Ms(t){return uo[t]||(uo[t]=[]),uo[t]}function dr(t,e,o,i){let n=new FormData,r=t.replace(/[^a-z0-9]/gi,"_"),l=`screenshot_${e}_${r}_${Date.now()}.png`,d=new File([i],l,{type:"image/png"});n.append("screenName",t),n.append("user_id",e),n.append("children",o),n.append("screenshot",d);try{console.groupCollapsed("AppStorys: FormData Payload Diagnostic"),console.info(" screenName:",t),console.info(" user_id:",e),console.info(" children:",JSON.parse(o)),console.info(" screenshot:",d.name,`(${d.size} bytes)`),console.groupEnd()}catch(c){console.warn("AppStorys: Could not run FormData diagnostics",c)}return n}var uo,Ae,cr=Re(()=>{"use strict";rt();bo();lr();rt();uo={};Ae=class{static setup(e,o){let i=A.getState();i.setScreenCaptureEnabled(o),i.setCurrentScreen(e)}static addLayoutInfo(e,o,i){let n=Ms(e),r=n.findIndex(c=>c.id===o),l={...i,screenWidth:i.screenWidth||window.innerWidth,screenHeight:i.screenHeight||window.innerHeight},d={id:o,frame:l};r>=0?n[r]=d:n.push(d)}static collectElements(e){this.clearLayoutData(e);let o=document.querySelectorAll("[data-as-id]"),i=window.innerWidth,n=window.innerHeight,r=[];o.forEach(l=>{let d=l.getAttribute("data-as-id");if(d){r.push(d);let c=l.getBoundingClientRect();this.addLayoutInfo(e,d,{x:Math.round(c.left),y:Math.round(c.top),width:Math.round(c.width),height:Math.round(c.height),screenWidth:i,screenHeight:n})}}),console.info(`AppStorys: Identified ${o.length} elements:`,r)}static clearLayoutData(e){uo[e]=[]}static getLayoutData(e){return uo[e]||[]}static async takeScreenshot(e,o){try{if(!e)return console.error("AppStorys: Screen name is required"),!1;console.info("AppStorys: Starting takeScreenshot for",e),A.getState().setCurrentScreen(e),this.collectElements(e);try{let f=Ls(e);f&&f.length>0&&console.info("AppStorys: mapServerPositionsToDOM added",f.length,"elements")}catch{}await new Promise(f=>setTimeout(f,100));let n=window,r=null;if(typeof n.html2canvas!="function")try{await new Promise((f,v)=>{let S=document.createElement("script");S.src="https://html2canvas.hertzen.com/dist/html2canvas.min.js",S.onload=()=>f(),S.onerror=()=>v(new Error("Failed to load html2canvas")),document.head.appendChild(S)})}catch(f){console.warn("AppStorys: html2canvas load error",f)}if(typeof n.html2canvas=="function")try{let f=await n.html2canvas(document.documentElement,{useCORS:!0,allowTaint:!0,logging:!1,scale:window.devicePixelRatio||1});r=await new Promise(v=>f.toBlob(S=>v(S),"image/png"))}catch(f){console.warn("AppStorys: html2canvas capture failed (falling back to getDisplayMedia)",f),r=null}if(!r&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)try{let f=await navigator.mediaDevices.getDisplayMedia({video:!0}),v=document.createElement("video");v.srcObject=f,await v.play();let S=document.createElement("canvas");S.width=v.videoWidth||window.innerWidth,S.height=v.videoHeight||window.innerHeight;let u=S.getContext("2d");u&&u.drawImage(v,0,0,S.width,S.height),r=await new Promise(m=>S.toBlob(g=>m(g),"image/png")),v.pause(),f.getTracks().forEach(m=>m.stop())}catch(f){console.warn("AppStorys: getDisplayMedia capture failed",f)}if(!r)return console.warn("AppStorys: Capture failed \u2014 no blob generated"),!1;let l=await bt(),d=Yt();if(!d)return console.warn("AppStorys: No userId"),!1;if(!l){let f=A.getState();f.accountId&&f.appId&&f.userId&&await le(f.accountId,f.appId,f.userId)&&(l=await bt())}if(!l)return console.warn("AppStorys: No token available"),!1;let c="https://backend.appstorys.co/api/v1/appinfo/identify-elements/",y=JSON.stringify(this.getLayoutData(e)||[]),b=dr(e,d,y,r);console.info("AppStorys: Sending identify-elements with payload size:",y.length);let h=await fetch(c,{method:"POST",headers:{Authorization:`Bearer ${l}`,Accept:"application/json"},body:b});if(h.status===401){console.warn("AppStorys: 401 response \u2014 retrying once");let f=A.getState();if(f.accountId&&f.appId&&f.userId&&await le(f.accountId,f.appId,f.userId)){let S=await bt();S&&(h=await fetch(c,{method:"POST",headers:{Authorization:`Bearer ${S}`,Accept:"application/json"},body:dr(e,d,y,r)}))}}if(!h.ok){let f=await h.text();return console.error("AppStorys: identify-elements failed",h.status,f),!1}console.info("AppStorys: identify-elements success \u2713");try{let f=o,v=[];!f||f.length===0?v=(this.getLayoutData(e)||[]).map(u=>Do(u.id)).filter(u=>!!u):v=f.map(S=>Do(S)).filter(S=>!!S),console.info("AppStorys: identifyWidgetPositions will send",v.length,"positions (DOM-verified)",v),await Eo(e,v)}catch(f){console.warn("AppStorys: identifyWidgetPositions failed",f)}return!0}catch(i){return console.error("AppStorys: takeScreenshot error",i),!1}}};(function(){try{let e=window;e.AppStorysForceIdentifyPositions=async o=>{let i=A.getState(),n=o||i.currentScreen;if(!n){console.warn("AppStorys: AppStorysForceIdentifyPositions - no screen name available");return}let l=(Ae.getLayoutData(n)||[]).map(d=>Do(d.id)).filter(d=>!!d);console.info("AppStorys: AppStorysForceIdentifyPositions sending",l.length,"positions for",n,l);try{await Eo(n,l),console.info("AppStorys: AppStorysForceIdentifyPositions completed")}catch(d){console.error("AppStorys: AppStorysForceIdentifyPositions error",d)}}}catch{}})()});var pr={};Pn(pr,{mountScreenCaptureButton:()=>ur});function As(){if(document.getElementById("appstorys-capture-styles"))return;let t=document.createElement("style");t.id="appstorys-capture-styles",t.innerHTML=`
1
+ "use strict";var Ur=Object.create;var jo=Object.defineProperty;var Yr=Object.getOwnPropertyDescriptor;var Gr=Object.getOwnPropertyNames;var Qr=Object.getPrototypeOf,Xr=Object.prototype.hasOwnProperty;var Ge=(t,e)=>()=>(t&&(e=t(t=0)),e);var ei=(t,e)=>{for(var o in e)jo(t,o,{get:e[o],enumerable:!0})},oi=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Gr(e))!Xr.call(t,i)&&i!==o&&jo(t,i,{get:()=>e[i],enumerable:!(n=Yr(e,i))||n.enumerable});return t};var ge=(t,e,o)=>(o=t!=null?Ur(Qr(t)):{},oi(e||!t||!t.__esModule?jo(o,"default",{value:t,enumerable:!0}):o,t)),Jr=t=>oi(jo({},"__esModule",{value:!0}),t);var kt,io=Ge(()=>{"use strict";kt=class{static async getItem(e){try{return localStorage.getItem(e)}catch{return null}}static async setItem(e,o){try{localStorage.setItem(e,o)}catch{}}static async removeItem(e){try{localStorage.removeItem(e)}catch{}}}});function fe(){return mn.getState().userId}async function At(){return kt.getItem("access_token")}function ii(t){if(!t)return;let e=String(t||"").trim();if(e)return mn.getState().variantMappings?.[e]}var ni,mn,P,bt=Ge(()=>{"use strict";ni=require("zustand");io();mn=(0,ni.create)(t=>({userId:"",appId:"",accountId:"",currentScreen:"",campaigns:[],allCampaigns:[],campaignVersion:2,trackedEvents:[],trackedEventMetadata:{},isVisible:!0,isAnonymousUser:!1,variantMappings:{},personalizationData:{},screenCaptureEnabled:!1,baseUrl:void 0,trackingUrl:void 0,saveCampaigns:e=>t({campaigns:e}),saveAllCampaigns:e=>t({allCampaigns:e}),setCampaignVersion:e=>t({campaignVersion:e}),setUserId:e=>t({userId:e}),setAppId:e=>t({appId:e}),setAccountId:e=>t({accountId:e}),setCurrentScreen:e=>t({currentScreen:e}),setAttributes:e=>t({attributes:e}),setTrackedEvents:e=>t({trackedEvents:e}),setTrackedEventMetadata:e=>t({trackedEventMetadata:e}),setVisibility:e=>t({isVisible:e}),setIsAnonymousUser:e=>t({isAnonymousUser:e}),setVariantMappings:e=>t({variantMappings:e}),setPersonalizationData:e=>t({personalizationData:e}),setScreenCaptureEnabled:e=>t({screenCaptureEnabled:e}),setBaseUrl:e=>t({baseUrl:e}),setTrackingUrl:e=>t({trackingUrl:e})}));P=mn});async function Qe(){try{return{browser:navigator.userAgent,language:navigator.language,platform:"web",screen_width_px:window.innerWidth,screen_height_px:window.innerHeight,screen_density:window.devicePixelRatio,orientation:window.innerWidth<window.innerHeight?"portrait":"landscape",timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}}catch(t){return console.error("Error fetching device info:",t),{}}}var Ho=Ge(()=>{"use strict"});async function Ae(t,e,o){try{let n={account_id:t,app_id:e,user_id:o};if(await kt.getItem(ci))console.log("Device info already sent previously - skipping");else{let d=await Qe();n.attributes={...d},console.log("First time verification - including device info in attributes")}let l=P.getState().baseUrl||"https://users.appstorys.co",c=await fetch(`${l}/${t}/validate-account`,{method:"POST",body:JSON.stringify(n),headers:{Accept:"application/json","Content-Type":"application/json"}});if(console.log("Verify account body",n),console.log("Verifying account",c.status,c.statusText),c.ok){let d=await c.json();console.log("Account verified",d);let{access_token:S,refresh_token:p}=d;if(S&&p)return await kt.setItem("access_token",S),await kt.setItem("refresh_token",p),n.attributes&&(await kt.setItem(ci,"true"),console.log("Device info sent flag set")),!0}return!1}catch(n){return console.error("Error when verifying AppStorys account",n),!1}}var ci,Vo=Ge(()=>{"use strict";io();Ho();bt();ci="device_info_sent"});async function cn(t,e){if(!e||e.length===0){console.info("AppStorys: identifyWidgetPositions called with empty positionList; skipping");return}let o=await At();if(!o){console.error("AppStorys: identifyWidgetPositions - access token not found");return}try{let n="https://backend.appstorys.co/api/v2/appinfo/identify-positions/";console.info("AppStorys: identifyWidgetPositions payload",{screen_name:t,position_list:e});let i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,Accept:"application/json"},body:JSON.stringify({screen_name:t,position_list:e})});i.ok?console.info("AppStorys: identifyWidgetPositions OK"):console.error("AppStorys: identifyWidgetPositions failed",i.status,await i.text())}catch(n){console.error("AppStorys: identifyWidgetPositions error",n)}}var $r=Ge(()=>{"use strict";bt()});function un(t){return t&&(t.startsWith("widget_")?t:`widget_${t}`)}function la(){try{let t=P.getState().allCampaigns||[],e=[];return t.forEach(o=>{o&&o.position&&typeof o.position=="string"&&e.push(String(o.position));try{if(o&&o.campaign_type==="WID"&&o.details){let n=o.details;typeof n=="object"&&(n.id&&typeof n.id=="string"&&e.push(String(n.id)),n.variants&&typeof n.variants=="object"&&Object.values(n.variants).forEach(i=>{i&&i.id&&typeof i.id=="string"&&e.push(String(i.id))}))}}catch{}}),e.filter(o=>!!o).map(o=>un(String(o))).filter(o=>!!o)}catch{return[]}}function da(t){try{let e=la();if(!e||e.length===0)return[];let o=[];return e.forEach(n=>{let i=n.replace(/^widget_/,""),s=[`[data-as-id="${i}"]`,`#${i}`,`.${i}`,`[data-widget="${i}"]`],l=null;for(let c of s)if(l=document.querySelector(c),l)break;if(l){let c=l.getBoundingClientRect(),d={x:Math.round(c.left),y:Math.round(c.top),width:Math.round(c.width),height:Math.round(c.height),screenWidth:window.innerWidth,screenHeight:window.innerHeight};eo.addLayoutInfo(t,i,d),o.push(i)}}),console.info("AppStorys: mapServerPositionsToDOM mapped",o.length,"server positions to DOM elements",o),o}catch(e){return console.warn("AppStorys: mapServerPositionsToDOM error",e),[]}}function ca(t){return No[t]||(No[t]=[]),No[t]}function Nr(t,e,o,n){let i=new FormData,s=t.replace(/[^a-z0-9]/gi,"_"),l=`screenshot_${e}_${s}_${Date.now()}.png`,c=new File([n],l,{type:"image/png"});i.append("screenName",t),i.append("user_id",e),i.append("children",o),i.append("screenshot",c);try{console.groupCollapsed("AppStorys: FormData Payload Diagnostic"),console.info(" screenName:",t),console.info(" user_id:",e),console.info(" children:",JSON.parse(o)),console.info(" screenshot:",c.name,`(${c.size} bytes)`),console.groupEnd()}catch(d){console.warn("AppStorys: Could not run FormData diagnostics",d)}return i}var No,eo,Or=Ge(()=>{"use strict";bt();Vo();$r();bt();No={};eo=class{static setup(e,o){let n=P.getState();n.setScreenCaptureEnabled(o),n.setCurrentScreen(e)}static addLayoutInfo(e,o,n){let i=ca(e),s=i.findIndex(d=>d.id===o),l={...n,screenWidth:n.screenWidth||window.innerWidth,screenHeight:n.screenHeight||window.innerHeight},c={id:o,frame:l};s>=0?i[s]=c:i.push(c)}static collectElements(e){this.clearLayoutData(e);let o=document.querySelectorAll("[data-as-id]"),n=window.innerWidth,i=window.innerHeight,s=[];o.forEach(l=>{let c=l.getAttribute("data-as-id");if(c){s.push(c);let d=l.getBoundingClientRect();this.addLayoutInfo(e,c,{x:Math.round(d.left),y:Math.round(d.top),width:Math.round(d.width),height:Math.round(d.height),screenWidth:n,screenHeight:i})}}),console.info(`AppStorys: Identified ${o.length} elements:`,s)}static clearLayoutData(e){No[e]=[]}static getLayoutData(e){return No[e]||[]}static async takeScreenshot(e,o){try{if(!e)return console.error("AppStorys: Screen name is required"),!1;console.info("AppStorys: Starting takeScreenshot for",e),P.getState().setCurrentScreen(e),this.collectElements(e);try{let u=da(e);u&&u.length>0&&console.info("AppStorys: mapServerPositionsToDOM added",u.length,"elements")}catch{}await new Promise(u=>setTimeout(u,100));let i=window,s=null;if(typeof i.html2canvas!="function")try{await new Promise((u,C)=>{let h=document.createElement("script");h.src="https://html2canvas.hertzen.com/dist/html2canvas.min.js",h.onload=()=>u(),h.onerror=()=>C(new Error("Failed to load html2canvas")),document.head.appendChild(h)})}catch(u){console.warn("AppStorys: html2canvas load error",u)}if(typeof i.html2canvas=="function")try{let u=await i.html2canvas(document.documentElement,{useCORS:!0,allowTaint:!0,logging:!1,scale:window.devicePixelRatio||1});s=await new Promise(C=>u.toBlob(h=>C(h),"image/png"))}catch(u){console.warn("AppStorys: html2canvas capture failed (falling back to getDisplayMedia)",u),s=null}if(!s&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)try{let u=await navigator.mediaDevices.getDisplayMedia({video:!0}),C=document.createElement("video");C.srcObject=u,await C.play();let h=document.createElement("canvas");h.width=C.videoWidth||window.innerWidth,h.height=C.videoHeight||window.innerHeight;let g=h.getContext("2d");g&&g.drawImage(C,0,0,h.width,h.height),s=await new Promise(b=>h.toBlob(m=>b(m),"image/png")),C.pause(),u.getTracks().forEach(b=>b.stop())}catch(u){console.warn("AppStorys: getDisplayMedia capture failed",u)}if(!s)return console.warn("AppStorys: Capture failed \u2014 no blob generated"),!1;let l=await At(),c=fe();if(!c)return console.warn("AppStorys: No userId"),!1;if(!l){let u=P.getState();u.accountId&&u.appId&&u.userId&&await Ae(u.accountId,u.appId,u.userId)&&(l=await At())}if(!l)return console.warn("AppStorys: No token available"),!1;let d="https://backend.appstorys.co/api/v1/appinfo/identify-elements/",S=JSON.stringify(this.getLayoutData(e)||[]),p=Nr(e,c,S,s);console.info("AppStorys: Sending identify-elements with payload size:",S.length);let y=await fetch(d,{method:"POST",headers:{Authorization:`Bearer ${l}`,Accept:"application/json"},body:p});if(y.status===401){console.warn("AppStorys: 401 response \u2014 retrying once");let u=P.getState();if(u.accountId&&u.appId&&u.userId&&await Ae(u.accountId,u.appId,u.userId)){let h=await At();h&&(y=await fetch(d,{method:"POST",headers:{Authorization:`Bearer ${h}`,Accept:"application/json"},body:Nr(e,c,S,s)}))}}if(!y.ok){let u=await y.text();return console.error("AppStorys: identify-elements failed",y.status,u),!1}console.info("AppStorys: identify-elements success \u2713");try{let u=o,C=[];!u||u.length===0?C=(this.getLayoutData(e)||[]).map(g=>un(g.id)).filter(g=>!!g):C=u.map(h=>un(h)).filter(h=>!!h),console.info("AppStorys: identifyWidgetPositions will send",C.length,"positions (DOM-verified)",C),await cn(e,C)}catch(u){console.warn("AppStorys: identifyWidgetPositions failed",u)}return!0}catch(n){return console.error("AppStorys: takeScreenshot error",n),!1}}};(function(){try{let e=window;e.AppStorysForceIdentifyPositions=async o=>{let n=P.getState(),i=o||n.currentScreen;if(!i){console.warn("AppStorys: AppStorysForceIdentifyPositions - no screen name available");return}let l=(eo.getLayoutData(i)||[]).map(c=>un(c.id)).filter(c=>!!c);console.info("AppStorys: AppStorysForceIdentifyPositions sending",l.length,"positions for",i,l);try{await cn(i,l),console.info("AppStorys: AppStorysForceIdentifyPositions completed")}catch(c){console.error("AppStorys: AppStorysForceIdentifyPositions error",c)}}}catch{}})()});var qr={};ei(qr,{mountScreenCaptureButton:()=>jr});function ua(){if(document.getElementById("appstorys-capture-styles"))return;let t=document.createElement("style");t.id="appstorys-capture-styles",t.innerHTML=`
2
2
  @keyframes appstorys-spin {
3
3
  0% { transform: rotate(0deg); }
4
4
  100% { transform: rotate(360deg); }
@@ -11,7 +11,7 @@
11
11
  border-radius: 50%;
12
12
  animation: appstorys-spin 0.8s linear infinite;
13
13
  }
14
- `,document.head.appendChild(t)}function Es(){As();let t=document.createElement("button");return t.id="appstorys-screen-capture-btn",t.title="Capture screen",Object.assign(t.style,{position:"fixed",left:"16px",bottom:"16px",width:"100px",height:"56px",borderRadius:"28px",background:"#ff6a00",color:"#fff",border:"none",boxShadow:"0 6px 18px rgba(0,0,0,0.2)",zIndex:"2147483647",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",fontWeight:"600",fontFamily:"sans-serif",transition:"all 0.2s ease"}),t.innerText="Capture",t}function ur(){try{let t=A.getState(),o=!!window.__APPSTORYS_DEBUG_CAPTURE;if(console.info("AppStorys: mountScreenCaptureButton called, screenCaptureEnabled=",t.screenCaptureEnabled,"debugForce=",o),!t.screenCaptureEnabled&&!o||document.getElementById("appstorys-screen-capture-btn"))return null;let i=Es();return i.addEventListener("click",async()=>{i.disabled=!0;let n=i.innerText;i.innerHTML='<div class="appstorys-spinner"></div>';let l=A.getState().currentScreen||(typeof window<"u"?window.location.pathname:"");try{await Ae.takeScreenshot(l)}catch(d){console.error("CaptureService error",d)}i.disabled=!1,i.innerText=n,i.animate([{transform:"scale(1.0)"},{transform:"scale(1.05)"},{transform:"scale(1.0)"}],{duration:300})}),document.body.appendChild(i),console.info("AppStorys: screen capture button mounted"),i}catch(t){return console.error("mountScreenCaptureButton error",t),null}}var gr=Re(()=>{"use strict";rt();cr();try{window.AppStorysMountCapture=function(){try{return ur()}catch(t){return console.error("AppStorysMountCapture failed",t),null}}}catch{}try{window.AppStorysDebugState=function(){try{let t=A.getState();return console.info("AppStorys store state:",t),t}catch(t){return console.error("AppStorysDebugState failed",t),null}}}catch{}try{window.AppStorysDebugToken=function(){try{let t=localStorage.getItem("access_token")||"",e=t.length,o=t?t.slice(0,20)+"..."+t.slice(-10):"(none)";if(console.info("Token length:",e,"masked:",o),t&&t.includes("."))try{let i=t.split(".");if(i.length===3){let n=JSON.parse(atob(i[1]));if(console.info("Token payload:",n),n.exp){let r=new Date(n.exp*1e3),l=new Date;console.info("Token expires:",r.toISOString(),"Expired:",l>r)}}}catch(i){console.warn("Could not decode JWT:",i)}return t?"Token present":"No token"}catch(t){return console.error("AppStorysDebugToken failed",t),null}}}catch{}});var _s={};Pn(_s,{AppStorys:()=>Ds,Banner:()=>Kn,BottomSheet:()=>Gi,Csat:()=>Ji,Floater:()=>ii,Modal:()=>rr,Pip:()=>oi,SdkState:()=>Po,Story:()=>Hi,Survey:()=>er,Tooltip:()=>Qi,Trackable:()=>sr,Widget:()=>Yi,getCampaignVariantId:()=>kr,getVariantId:()=>Wo,hasVariants:()=>to,personalizeText:()=>de,resolveCampaignVariant:()=>Ft,selectVariantByWeight:()=>Hn});module.exports=Cr(_s);var Po=(n=>(n.uninitialized="uninitialized",n.initializing="initializing",n.initialized="initialized",n.error="error",n))(Po||{});var Qt=require("react"),We=ae(require("lottie-react"));rt();var Vn=require("react");rt();rt();var Nn="appstorys_variant_mappings",Ze={};function vr(t){let e=0;for(let o=0;o<t.length;o++){let i=t.charCodeAt(o);e=(e<<5)-e+i,e|=0}return Math.abs(e)}function jn(){if(typeof window>"u")return{};try{let t=localStorage.getItem(Nn);if(t)return JSON.parse(t)}catch{}return{}}function wr(t,e){if(!(!t||!e)){Ze[t]=e;try{let o=A.getState(),i=o.variantMappings||{};i[t]!==e&&o.setVariantMappings({...i,[t]:e})}catch{}if(typeof window<"u")try{let o=jn();o[t]=e,localStorage.setItem(Nn,JSON.stringify(o))}catch{}}}var Wo=t=>{if(!t)return;if(Ze[t])return Ze[t];let e=A.getState().variantMappings?.[t];if(e)return Ze[t]=e,e;let o=jn();if(o[t]){Ze[t]=o[t];try{A.getState().setVariantMappings({...A.getState().variantMappings||{},[t]:o[t]})}catch{}return o[t]}};function to(t){if(!t)return!1;if(t.hasVariants===!0||t.variants&&typeof t.variants=="object"&&Object.keys(t.variants).length>0)return!0;if(t.details&&typeof t.details=="object"&&t.details.variants){let e=t.details.variants;if(typeof e=="object"&&Object.keys(e).length>0)return!0}return!1}function Hn(t,e){let o=Object.keys(t);if(o.length===0)return;let i=o.filter(l=>t[l]&&t[l].isActive!==!1),n=i.length>0?i:o,r=n.reduce((l,d)=>l+(Number(t[d]?.weight)||0),0);if(r>0){let l=A.getState().userId||"default",d=`${e||"campaign"}_${l}`,y=vr(d)%1e4/1e4*r;for(let b of n){let h=Number(t[b]?.weight)||0;if(y<h)return b;y-=h}}return n[0]}function Ft(t){if(!t||!to(t))return t;let e=t,o=e.variants||e.details?.variants;if(!o||typeof o!="object"||Object.keys(o).length===0)return t;let i=Wo(e.id||"");if((!i||!o[i])&&(i=Hn(o,e.id),e.id&&i&&wr(e.id,i)),!i||!o[i])return t;let n=o[i],l={...e.details&&typeof e.details=="object"?Object.fromEntries(Object.entries(e.details).filter(([d])=>d!=="variants")):{},...n};return{...t,details:l,_variantId:i}}function kr(t){if(t){if("_variantId"in t)return t._variantId;if(to(t))return Wo(t.id||"")}}var yo="__back_press_triggered__";function qn(t){return(t||"").trim().toLowerCase()}function Rr(t,e){let o=qn(t),i=qn(e);return!o||o===i}function Tr(t,e,o){let i=Number(t),n=Number(o),r=!isNaN(i)&&!isNaN(n);switch(e){case"eq":return r?i===n:t===o;case"neq":return r?i!==n:t!==o;case"gt":return r?i>n:t>o;case"gte":return r?i>=n:t>=o;case"lt":return r?i<n:t<o;case"lte":return r?i<=n:t<=o;default:return!1}}function Fr(t,e){let o=t.filter(i=>i.back_press==null);return o.length===0?!0:e.some(i=>o.every(n=>{let r=i[n.key];return r==null?!1:Tr(String(r),n.operator,n.value)}))}function zr(t,e,o){let i=t,n=i.trigger_event??i.trigger,r=t.id;return!n}function Oo(){let{campaigns:t,trackedEvents:e,trackedEventMetadata:o,currentScreen:i}=A.getState();return t.some(n=>{if(n.screen&&n.screen!==i)return!1;let r=n.trigger_event;if(!r||typeof r=="string")return!1;let{event:l,event_config:d}=r;if(!(d??[]).some(b=>b.back_press===!0)||e.includes(yo)||!e.includes(l))return!1;let c=(d??[]).filter(b=>b.back_press==null);if(c.length===0)return!0;let y=o[l]||[];return Fr(c,y)})}function xt(t,e){let o=A(c=>c.currentScreen),i=A(c=>c.campaigns),n=A(c=>c.allCampaigns),r=A(c=>c.trackedEvents),l=A(c=>c.trackedEventMetadata),d=A(c=>c.variantMappings);return(0,Vn.useMemo)(()=>{let c=h=>h.find(f=>Rr(f.screen,o)&&f.campaign_type===t&&(e?.position?f.position===e.position:!0)&&zr(f,r,l)),b=(i&&i.length>0?c(i):void 0)??c(n||[]);if(b)return Ft(b)},[i,n,r,l,d,t,e,o])}rt();ho();$e();rt();bo();var Yn="appstorys_offline_queue";async function Qn(){let t=await pt.getItem(Yn);return t?JSON.parse(t):[]}async function Gn(t){await pt.setItem(Yn,JSON.stringify(t))}function Ir(t){return Math.min(3e4*Math.pow(2,t),12e4)}function Br(t){let o=t.retryCount||0,i=t.lastAttempt||0,n=Ir(o);return o<3&&Date.now()-i>=n}async function Lr(){let t=A.getState();return!t.accountId||!t.appId?!1:await le(t.accountId,t.appId,t.userId)}async function Xn(t,e){if(await Lr()){let i=await pt.getItem("access_token");i&&(t.headers={...t.headers,Authorization:`Bearer ${i}`}),t.authRetried=!0,t.lastAttempt=Date.now(),e(t)}}async function So(t,e){let o=(t.retryCount||0)+1;o<=3&&(t.retryCount=o,t.lastAttempt=Date.now(),e(t))}async function xo(t){let e=await Qn();e.push(t),await Gn(e)}async function Mr(){let t=await Qn();if(t.length===0)return;let e=[];for(let o of t){if(!Br(o)){e.push(o);continue}try{let i=await fetch(o.url,{method:o.method,headers:o.headers,body:JSON.stringify(o.body)});if(i.ok)continue;i.status===401||i.status===403?o.authRetried||await Xn(o,n=>e.push(n)):i.status>=500&&await So(o,n=>e.push(n))}catch{await So(o,n=>e.push(n))}}await Gn(e)}async function Co(t){if(!navigator.onLine){await xo(t);return}await Mr();try{let e=await fetch(t.url,{method:t.method,headers:t.headers,body:JSON.stringify(t.body)});return e.ok||(e.status===401||e.status===403?await Xn(t,xo):e.status>=500&&await So(t,xo)),e}catch{await So(t,xo);return}}async function X(t,e,o){try{if(!t)return;let i=await bt(),n=A.getState(),r=["viewed","clicked","csat captured","survey captured","shared"];if(!r.includes(t)){let y=n.trackedEvents;if(!y.includes(t))n.setTrackedEvents([...y,t]);else{let b=y.filter(h=>h!==t);b.push(t),n.setTrackedEvents(b)}if(o&&Object.keys(o).length>0){let b=n.trackedEventMetadata||{},h=b[t]||[];n.setTrackedEventMetadata({...b,[t]:[...h,o]})}}let l={...o||{}};if(!r.includes(t)){let y=await Te();l={...l,...y}}if(e&&String(e).trim()!==""){let y=o?.variant_id||On(e);y&&(l.variant_id=y)}let d={user_id:Yt(),event:t,metadata:l};e&&(d.campaign_id=e);let c=n.trackingUrl||"https://tracking.appstorys.co";i&&await Co({url:`${c}/capture-event`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:d})}catch(i){console.error("Error in trackEvent",i)}}rt();function kt(t){if(!t)return!1;let e=A.getState(),o=e.allCampaigns||[],i=e.campaigns||[],n=String(t).trim(),r=o.find(c=>{if(!c)return!1;let y=String(c.id||"").trim(),b=c.details||{},h=String(b.campaign||b.id||"").trim();return!!(y&&y===n||h&&h===n||y&&n.includes(y)||h&&n.includes(h))});if(!r)return!1;let l={...r};delete l.trigger_event,delete l.trigger,l.display_trigger=!0;let d=i.findIndex(c=>String(c.id||"")===String(l.id||""));if(d===-1)e.saveCampaigns([l,...i]);else{let c=i[d];if(!!(c.trigger_event??c.trigger)){let b=[...i];b[d]=l,e.saveCampaigns(b)}}return!0}var Fe=require("react/jsx-runtime"),Ar=({config:t,onPress:e,style:o,ignoreSizeAndMargin:i=!1})=>{if(!t||!t.enabled)return null;let n=t.size,r=t.margin,l=t.color,d=t.image,c=t.selectedStyle,y=n!=null&&n>=0?n:18,b=i?40:y,h=r?.top!==void 0&&r?.top!==null&&r.top>=0?r.top:0,f=r?.bottom!==void 0&&r?.bottom!==null&&r.bottom>=0?r.bottom:0,v=r?.left!==void 0&&r?.left!==null&&r.left>=0?r.left:0,S=r?.right!==void 0&&r?.right!==null&&r.right>=0?r.right:0,u={marginTop:i?0:h,marginBottom:i?0:f,marginLeft:i?0:v,marginRight:i?0:S,width:b,height:b,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||"transparent",borderWidth:b*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:l?.stroke?"solid":"none",...o},m=()=>{let g=l?.cross||"#ffffff";return(0,Fe.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Fe.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"}),(0,Fe.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,Fe.jsx)("button",{type:"button",onClick:g=>{g.stopPropagation(),g.preventDefault(),e(g)},style:u,title:c||"",children:d&&d.trim()!==""?(0,Fe.jsx)("img",{src:d,style:{width:b,height:b,objectFit:"contain"},alt:"close"}):m()})},At=Ar;var ze=require("react/jsx-runtime"),Jn=We.default?.default??We.default??We.Lottie??We,Kn=()=>{let t=xt("BAN"),e=A(a=>a.isVisible),[o,i]=(0,Qt.useState)(!1),[n,r]=(0,Qt.useState)(null),[l,d]=(0,Qt.useState)(null),c=(0,Qt.useRef)(null),[y,b]=(0,Qt.useState)(0),h=(0,Qt.useRef)(null);if((0,Qt.useEffect)(()=>{t?.id&&h.current!==t.id&&(h.current=t.id,i(!1),X("viewed",t.id),t.details?.lottie_data&&fetch(t.details.lottie_data).then(a=>a.json()).then(a=>{r(a),a.w&&a.h&&d(a.h/a.w)}).catch(a=>console.error("Error loading Lottie:",a)))},[t?.id]),(0,Qt.useEffect)(()=>{let a=()=>{c.current&&b(c.current.offsetWidth)};return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[t,o]),!t||o||!e)return null;let{details:f}=t,v=f.styling||{},S=f.height||"auto";l&&y&&(S=y*l);let u=parseFloat(String(f.height)),m=parseFloat(String(f.originalWidth??f.styling?.originalWidth)),g=parseFloat(String(f.originalHeight??f.styling?.originalHeight)),C=Number.isFinite(u)&&u>0&&Number.isFinite(m)&&m>0&&Number.isFinite(g)&&g>0?u*(m/g):null,I=C!==null?`${C}px`:void 0,z=typeof S=="number"?`${S}px`:S||void 0,E=Number(v.marginRight),w=Number(v.marginBottom),_={position:"fixed",right:Number.isFinite(E)?`${E}px`:"0px",bottom:Number.isFinite(w)?`${w}px`:"0px",zIndex:9999,display:"block",cursor:f.link?"pointer":"default"},P={position:"relative",width:I||"100%",height:z||"auto",backgroundColor:"transparent",borderRadius:`${v.topRightRadius||0}px ${v.topLeftRadius||0}px ${v.bottomRightRadius||0}px ${v.bottomLeftRadius||0}px`,overflow:"hidden"},$={width:"100%",height:"100%",display:"block",objectFit:"contain"},q=a=>{a.stopPropagation(),i(!0),X("banner_closed",t.id)};return(0,ze.jsx)("div",{ref:c,style:_,onClick:()=>{if(f.link)if(X("clicked",t.id),f.link.startsWith("http"))window.open(f.link,"_blank");else{try{if(kt(f.link))return}catch(a){console.warn("revealCampaignFromLink error",a)}console.log("Internal link:",f.link)}},children:(0,ze.jsxs)("div",{style:P,children:[n?(()=>{let a=Jn.default||Jn;return(0,ze.jsx)(a,{animationData:n,loop:!0,autoplay:e,style:$})})():f.image?(0,ze.jsx)("img",{src:f.image,alt:"Campaign Banner",style:$}):null,v.crossButton?.enabled&&(0,ze.jsx)(At,{config:v.crossButton,onPress:q,style:{top:v.crossButton?.margin?.top!==void 0?0:5,right:v.crossButton?.margin?.right!==void 0?0:5}})]})})};var Rt=require("react");rt();function wo(t){let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")}function Zn(t){try{let o=new URL(t).pathname.split("/").pop()||t;return o.split("?")[0].replace(/\.[^.]+$/,"")||`font_${o.length}`}catch{return(t.split("/").pop()??t).split("?")[0].replace(/\.[^.]+$/,"")||`font_${t.length}`}}function ti(t,e){if(typeof document>"u")return;let o=`appstorys-font-${t}`;if(document.getElementById(o))return;let i=document.createElement("style");i.id=o,i.type="text/css",i.textContent=`@font-face{font-family:"${t}";src:url("${e}");font-style:normal;font-weight:normal;font-display:swap;}`,document.head.appendChild(i)}var vo=new Map;async function Er(t,e){try{ti(e.name,t);let o=globalThis.FontFace;if(typeof document<"u"&&o&&document.fonts?.add){let i=new o(e.name,`url(${t})`);await i.load(),document.fonts.add(i)}else typeof document<"u"&&document.fonts?.load&&await document.fonts.load(`1em "${e.name}"`);e.status="loaded",e.listeners.forEach(i=>i(e.name))}catch(o){console.warn(`[FontManager] Failed to load font from "${t}":`,o),e.status="failed",e.listeners.forEach(i=>i(void 0))}finally{e.listeners=[]}}var No={async load(t){if(!t||!wo(t))return;let e=vo.get(t);if(e)return e.status==="loaded"?e.name:e.status==="failed"?void 0:new Promise(r=>e.listeners.push(r));let i={status:"pending",name:Zn(t),listeners:[]};vo.set(t,i);let n=new Promise(r=>i.listeners.push(r));return Er(t,i),n},ensure(t){if(!t||!wo(t))return;let e=Zn(t);return ti(e,t),No.load(t),e},getSync(t){if(!t)return;let e=vo.get(t);return e?.status==="loaded"?e.name:void 0},_clearCache(){vo.clear()}};function mt(t){if(t)return wo(t)?No.ensure(t):t}function Dr(t){let e=new Set,o=new WeakSet,i=n=>{if(n!=null&&typeof n!="string"){if(Array.isArray(n)){for(let r of n)i(r);return}if(typeof n=="object"){if(o.has(n))return;o.add(n);for(let[r,l]of Object.entries(n))r==="fontFamily"&&typeof l=="string"&&wo(l)&&e.add(l),i(l)}}};return i(t),Array.from(e)}async function ei(t){let e=new Set;for(let o of t)Dr(o).forEach(i=>e.add(i));await Promise.all(Array.from(e).map(o=>No.load(o)))}var it=require("react/jsx-runtime"),jo=t=>(t||"").trim().toLowerCase(),Zt=(t,e)=>{let o=Number(t);return Number.isFinite(o)?o:e},_r=t=>{if(t===!0||t===1)return!0;if(t===!1||t===0||t==null||t==="")return!1;let e=String(t).trim().toLowerCase();return e==="yes"||e==="true"||e==="1"};function Pr({iconType:t,color:e}){let o=e||"#FFFFFF";return t==="close"?(0,it.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,it.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:o,strokeWidth:"2.2",strokeLinecap:"round"}),(0,it.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:o,strokeWidth:"2.2",strokeLinecap:"round"})]}):t==="expand"?(0,it.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,it.jsx)("polyline",{points:"8,3 3,3 3,8",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,it.jsx)("line",{x1:"3",y1:"3",x2:"9",y2:"9",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,it.jsx)("polyline",{points:"16,21 21,21 21,16",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,it.jsx)("line",{x1:"15",y1:"15",x2:"21",y2:"21",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):t==="minimize"?(0,it.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,it.jsx)("polyline",{points:"9,9 3,9 3,3",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,it.jsx)("line",{x1:"3",y1:"9",x2:"9",y2:"3",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,it.jsx)("polyline",{points:"15,15 21,15 21,21",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,it.jsx)("line",{x1:"15",y1:"21",x2:"21",y2:"15",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):t==="mute"?(0,it.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,it.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:o,strokeWidth:"2",strokeLinejoin:"round"}),(0,it.jsx)("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,it.jsx)("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):(0,it.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,it.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:o,strokeWidth:"2",strokeLinejoin:"round"}),(0,it.jsx)("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,it.jsx)("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]})}function Ho({iconType:t,config:e,imageOverride:o,onClick:i}){let n=Zt(e?.size,18),r=Math.max(24,n+10),l=e?.margin||{},d=o||e?.image,c=e?.color?.cross||"#FFFFFF",y=e?.color?.fill||"rgba(0,0,0,0.55)",b=e?.color?.stroke||"rgba(255,255,255,0.35)";return(0,it.jsx)("button",{"data-control-button":"true",type:"button",onPointerDown:h=>{h.preventDefault(),h.stopPropagation()},onPointerUp:h=>{h.preventDefault(),h.stopPropagation()},onMouseDown:h=>{h.preventDefault(),h.stopPropagation()},onTouchStart:h=>{h.preventDefault(),h.stopPropagation()},onClick:h=>{h.preventDefault(),h.stopPropagation(),i()},title:e?.selectedStyle||t,style:{width:r,height:r,borderRadius:999,pointerEvents:"auto",zIndex:10030,position:"relative",border:`1px solid ${b}`,background:y,color:c,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,marginTop:Zt(l.top,0),marginRight:Zt(l.right,0),marginBottom:Zt(l.bottom,0),marginLeft:Zt(l.left,0)},children:d?(0,it.jsx)("img",{src:d,alt:t,style:{width:n,height:n,objectFit:"contain"}}):(0,it.jsx)(Pr,{iconType:t,color:c})})}var oi=()=>{let t=xt("PIP"),e=A(O=>O.campaigns),o=A(O=>O.allCampaigns),i=A(O=>O.currentScreen),n=A(O=>O.isVisible),[r,l]=(0,Rt.useState)(!1),[d,c]=(0,Rt.useState)(!1),[y,b]=(0,Rt.useState)(!0),[h,f]=(0,Rt.useState)(!1),[v,S]=(0,Rt.useState)(null),u=(0,Rt.useRef)({x:0,y:0}),m=(0,Rt.useRef)(null),g=(0,Rt.useRef)({x:0,y:0}),C=(0,Rt.useRef)(!1),I=(0,Rt.useMemo)(()=>{if(t)return t;let O=jo(i),et=Ct=>Ct.find(yt=>{let dt=yt,Bt=dt.campaign_type==="PIP",Pt=!jo(dt.screen)||jo(dt.screen)===O,Ee=!!(dt.trigger_event??dt.trigger),ge=dt.display_trigger!==!1&&!Ee;return Bt&&Pt&&ge}),ut=et(e)??et(o);return ut?Ft(ut):void 0},[t,e,o,i]),z=(0,Rt.useMemo)(()=>I,[I?.id,I?.details?.id]);if((0,Rt.useEffect)(()=>{if(!z)return;let O=z.details||{},et=O?.styling?.soundToggle?.defaultSound||O?.styling?.appearance?.defaultSound||"yes";b(String(et).toLowerCase()!=="yes"),l(!1),c(!1),S(null),X("viewed",z.id)},[z]),(0,Rt.useEffect)(()=>{m.current&&(m.current.muted=y)},[y]),(0,Rt.useEffect)(()=>{if(!h)return;let O=ut=>{let Ct=ut.clientX-g.current.x,yt=ut.clientY-g.current.y;(Math.abs(Ct)>4||Math.abs(yt)>4)&&(C.current=!0);let dt=ut.clientX-u.current.x,Bt=ut.clientY-u.current.y;S({x:Math.max(0,dt),y:Math.max(0,Bt)})},et=()=>{f(!1)};return window.addEventListener("mousemove",O),window.addEventListener("mouseup",et),()=>{window.removeEventListener("mousemove",O),window.removeEventListener("mouseup",et)}},[h]),!z||!z.details||r||!n)return null;let E=z.details,w=E.styling||{},_=w.appearance||{},P=Zt(E.width??_.pipWidth,150),$=Zt(E.height??_.pipHeight,300),q=P,B=$,a=w.cta?.container||{},x=w.cta?.text||{},s=!!(E.button_text&&E.button_text.trim().length>0),p=Zt(w.cta?.container?.height,42),M=s?p+24:0,T=Zt(w.pipBottomPadding,20),R=Zt(w.pipTopPadding,0),W=d?E.large_video||E.small_video:E.small_video||E.large_video,H=(E.position||z.position||"right").toLowerCase(),U=!!w.isMovable,j=w.soundToggle?.enabled!==!1,V=w.crossButton?.enabled!==!1,tt=w.expandablePip??E.expandablePip??E.expandable_pip,at=tt!=null&&tt!==""?_r(tt):w.expandControls?.enabled!==!1,nt=w.crossButton,lt=d?w.expandControls?.minimise:w.expandControls?.maximise,k=y?w.soundToggle?.mute:w.soundToggle?.unmute,L=()=>{c(O=>{let et=!O;return et&&z?.id&&(X("viewed",z.id),X("analyze",z.id)),et})},J={position:"fixed",zIndex:10020,width:d?"auto":q,height:d?"auto":B,borderRadius:0,overflow:"hidden",background:"#000",boxShadow:"0 16px 40px rgba(0,0,0,0.35)",cursor:h?"grabbing":U&&!d?"grab":"default",transition:h?"none":"width 180ms ease, height 180ms ease, transform 180ms ease"};v&&!d?(J.left=v.x,J.top=v.y):d?(J.left=0,J.top=0,J.right=0,J.bottom=0):(H==="left"?J.left=24:J.right=24,R>0?J.top=R:J.bottom=T+20);let ht=O=>{if(!U||d||O.target.closest("[data-control-button='true']"))return;let ut=O.currentTarget.getBoundingClientRect();u.current={x:O.clientX-ut.left,y:O.clientY-ut.top},g.current={x:O.clientX,y:O.clientY},C.current=!1,S({x:ut.left,y:ut.top}),f(!0)},Y=()=>{if(!E.link)return;X("clicked",z.id);let O=String(E.link).trim();try{let et=A.getState(),ut=et.allCampaigns||[],Ct=et.campaigns||[],yt=ut.find(dt=>dt.id===O);if(console.log("[Pip] clicked link=",O,"allCount=",ut.length,"visibleCount=",Ct.length,"referenced=",!!yt),yt){let dt={...yt};delete dt.trigger_event,delete dt.trigger,dt.display_trigger=!0;let Bt=Ct.findIndex(Pt=>Pt.id===dt.id);if(Bt===-1)et.saveCampaigns([dt,...Ct]);else{let Pt=Ct[Bt];if(!!(Pt.trigger_event??Pt.trigger)){let ge=[...Ct];ge[Bt]=dt,et.saveCampaigns(ge)}}return}}catch{}window.open(E.link,"_blank")};return W?(0,it.jsxs)("div",{style:J,onMouseDown:ht,children:[(0,it.jsx)("video",{ref:m,src:W,autoPlay:!0,loop:!0,playsInline:!0,muted:y,style:{width:"100%",height:d&&s?`calc(100% - ${M}px)`:"100%",objectFit:d?"contain":"cover",cursor:at&&!d||E.link?"pointer":"default"},onClick:()=>{if(C.current){C.current=!1;return}if(at){L();return}Y()},onEnded:()=>{I&&X("analyze",I.id)}}),(0,it.jsxs)("div",{style:{position:"absolute",top:8,right:8,display:"flex",gap:8,zIndex:2},children:[j&&(0,it.jsx)(Ho,{iconType:y?"mute":"unmute",config:k,imageOverride:y?E.muteImage:E.unmuteImage,onClick:()=>b(O=>!O)}),at&&(0,it.jsx)(Ho,{iconType:d?"minimize":"expand",config:lt,imageOverride:d?E.minimiseImage:E.maximiseImage,onClick:L}),V&&(0,it.jsx)(Ho,{iconType:"close",config:nt,imageOverride:E.crossButtonImage,onClick:()=>l(!0)})]}),d&&s&&(0,it.jsx)("button",{"data-control-button":"true",onClick:Y,style:{position:"absolute",left:12,right:12,bottom:12,height:a.height||42,width:a.ctaFullWidth?"auto":a.ctaWidth||"auto",maxWidth:"calc(100% - 24px)",margin:a.ctaFullWidth?"0":"0 auto",background:a.backgroundColor||"#F7921C",color:x.color||"#fff",border:`${a.borderWidth||0}px solid ${a.borderColor||"transparent"}`,borderRadius:10,fontSize:x.fontSize||14,fontFamily:mt(x.fontFamily),fontWeight:600,cursor:E.link?"pointer":"default"},children:E.button_text})]}):null};var Et=ae(require("react")),ni=require("lottie-react");rt();var Ie=require("react/jsx-runtime"),jt=(t,e=0)=>{let o=Number(t);return Number.isFinite(o)?o:e},qo=t=>(t||"").trim().toLowerCase(),$r="appstorysmediabucketdev.s3.ap-south-1.amazonaws.com",Wr=t=>{try{if(typeof window>"u")return[t];let e=new URL(t);if(e.hostname!==$r)return[t];let o=!!window.location.port,i=`/appstorys-media${e.pathname}${e.search}`;return o?[i,t]:[t]}catch{return[t]}},Or=t=>{if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return Array.isArray(e.layers)||Array.isArray(e.assets)||typeof e.v=="string"},Vo=class extends Et.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){this.props.onError()}render(){return this.state.hasError?null:this.props.children}},Nr=()=>{let[t,e]=(0,Et.useState)(null),[o,i]=(0,Et.useState)([]),[n,r]=(0,Et.useState)(!1),[l,d]=(0,Et.useState)(!1),c=(0,Et.useRef)(null),y=(0,Et.useRef)(null),b=xt("FLT"),h=A(x=>x.campaigns),f=A(x=>x.allCampaigns),v=A(x=>x.currentScreen),S=A(x=>x.isVisible),u=(0,Et.useRef)(null),m=b??(()=>{let x=[...h,...f].find(s=>{let p=s;if(p.campaign_type!=="FLT")return!1;let M=!!(p.trigger_event??p.trigger);return p.display_trigger===!1||M?!1:!qo(p.screen)||qo(p.screen)===qo(v)});if(x)try{return Ft(x)}catch{return x}})(),g=m?.id,C=A(x=>g?x.variantMappings[g]:void 0);if((0,Et.useEffect)(()=>{if(!m?.id||!S||to(m)&&!C)return;let s=`${m.id}:${C||""}`;u.current!==s&&(u.current=s,X("viewed",m.id))},[m?.id,C,S]),(0,Et.useEffect)(()=>{let x=m?.details?.lottie_data;if(e(null),i([]),r(!1),d(!1),!x)return;if(Or(x)){e(x),d(!0);return}if(typeof x!="string"){r(!0);return}let s=Wr(x);i(s),d(!0)},[m?.details?.lottie_data]),(0,Et.useEffect)(()=>{if(!m?.details?.lottie_data||!c.current)return;let x=ni.LottiePlayer;if(!x||typeof x.loadAnimation!="function"){r(!0),d(!1);return}let s=!1,p=null,M=()=>{p&&typeof p.destroy=="function"&&p.destroy(),p=null,y.current=null},T=(R,W)=>{if(s)return;if(W>=R.length){r(!0),d(!1),console.error("[Floater] lottie load failed",{lottieUrls:R});return}M();let H=x.loadAnimation({container:c.current,renderer:"svg",loop:!0,autoplay:!0,path:R[W]});p=H,y.current=H,H.addEventListener("DOMLoaded",()=>{s||d(!1)}),H.addEventListener("data_failed",()=>{s||T(R,W+1)})};if(t){M();let R=x.loadAnimation({container:c.current,renderer:"svg",loop:!0,autoplay:!0,animationData:t});p=R,y.current=R,R.addEventListener("DOMLoaded",()=>{s||d(!1)}),R.addEventListener("data_failed",()=>{s||(r(!0),d(!1))})}else o.length>0&&T(o,0);return()=>{s=!0,M()}},[m?.details?.lottie_data,t,o]),!m||!m.details||!S)return null;let{details:I}=m,z=I.styling||{},w=(typeof I.position=="string"?I.position:typeof m.position=="string"?m.position:"right").toLowerCase()==="left"?"left":"right",_={position:"fixed",left:w==="left"?jt(z.marginLeft,12):void 0,right:w==="left"?void 0:jt(z.marginRight,12),top:jt(z.marginTop,0)>0?jt(z.marginTop,0):void 0,bottom:jt(z.marginTop,0)>0?void 0:jt(z.marginBottom,80),zIndex:10040,display:"flex"},P={width:jt(I.width,60),height:jt(I.height,60),background:"transparent",overflow:"hidden",borderBottomLeftRadius:jt(z.bottomLeftRadius,0),borderBottomRightRadius:jt(z.bottomRightRadius,0),borderTopLeftRadius:jt(z.topLeftRadius,0),borderTopRightRadius:jt(z.topRightRadius,0),display:"flex",alignItems:"center",justifyContent:"center",cursor:I.link?"pointer":"default",boxShadow:"0 8px 18px rgba(0,0,0,0.2)"},$=async()=>{if(!I.link)return;await X("clicked",m.id);let x=String(I.link).trim();try{let s=A.getState(),p=s.allCampaigns||[],M=s.campaigns||[],T=p.find(R=>{if(!R)return!1;let W=String(R.id||"").trim(),H=R.details||{},U=String(H.campaign||H.id||"").trim();return!!(W&&W===x||U&&U===x||W&&x.includes(W)||U&&x.includes(U))});if(console.log("[Floater] clicked link=",x,"allCampaignsCount=",p.length,"visibleCount=",M.length),console.log("[Floater] all ids=",p.map(R=>R.id).slice(0,50)),console.log("[Floater] referenced found=",!!T,T&&(T.id||T.details?.campaign||T.details?.id)),T){let R={...T};delete R.trigger_event,delete R.trigger,R.display_trigger=!0;let W=M.findIndex(H=>H.id===R.id);if(W===-1)console.log("[Floater] revealing campaign (prepended)",R.id),s.saveCampaigns([R,...M]);else{let H=M[W];if(!!(H.trigger_event??H.trigger)){let j=[...M];j[W]=R,console.log("[Floater] replacing existing triggered campaign with revealed one",R.id),s.saveCampaigns(j)}else console.log("[Floater] campaign already visible and not trigger-driven",R.id)}return}}catch(s){console.warn("[Floater] error while resolving referenced campaign",s)}try{window.open(I.link,"_blank")}catch{}},q=!!(I.lottie_data&&!n),B=!!I.image,a=!!(I.lottie_data&&l&&!t&&!n);return!q&&!B&&!a?null:(0,Ie.jsx)("div",{style:_,children:(0,Ie.jsx)("div",{style:P,onClick:()=>{$()},children:q?(0,Ie.jsx)(Vo,{onError:()=>r(!0),children:(0,Ie.jsx)("div",{ref:c,style:{width:"100%",height:"100%",display:"block"}})},String(I.lottie_data)):a?(0,Ie.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.08)",color:"#333",fontSize:10,fontWeight:600},children:"..."}):(0,Ie.jsx)("img",{src:I.image,alt:"floater",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})})})},ii=Nr;rt();function ri(t){return(t||"").trim().toLowerCase()}function Uo(t,e){let o=ri(t.screen),i=ri(e);return!o||o===i}async function Yo(t){try{let e=A.getState(),o=await bt(),i=e.accountId;if(!o||!i)return;e.setCurrentScreen(t),e.setTrackedEvents([]);let n=e.baseUrl||"https://users.appstorys.co",r=await fetch(`${n}/v2/${i}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({user_id:Yt(),screenName:t})});if(!r.ok)return;let l=await r.json();if(typeof l.screen_capture_enabled<"u"&&e.setScreenCaptureEnabled(!!l.screen_capture_enabled),l.variants&&l.variants.length>0){let g={};l.variants.forEach(C=>{g[C.id]=C.v_id}),e.setVariantMappings(g)}l.personalization_data&&e.setPersonalizationData(l.personalization_data);let d=e.allCampaigns||[],c=l.eligibleCampaignList||[],y=d.filter(g=>c.includes(g.id)&&Uo(g,t)),b=y.map(g=>g.id),h=c.filter(g=>!b.includes(g)),f=[];if(h.length>0){let g=await fetch(`${n}/load-campaign-data`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(h)});g.ok&&(f=(await g.json()).filter(I=>Uo(I,t)))}let v=[...y,...f],S=d.filter(g=>{let C=!!(g.trigger_event??g.trigger);return Uo(g,t)&&g.display_trigger===!0&&!C}),u=[...v],m=new Set(u.map(g=>g.id));for(let g of S)m.has(g.id)||(u.push(g),m.add(g.id));e.saveCampaigns(u)}catch(e){console.error("Error when tracking screen:",t,e)}}bo();rt();ho();async function Qo(t){try{let e=await bt(),o=Yt(),i=A.getState();if(!e||!o){console.warn("AppStorys: Missing accessToken or userId. Ensure SDK is initialized before setting user properties.");return}let n={...t||{}},r=await Te();n={...n,...r};let l={user_id:o,attributes:n},d=i.baseUrl||"https://users.appstorys.co";await Co({url:`${d}/update-user-atr`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:l})}catch(e){console.error("AppStorys: Error in setUserProperties:",e)}}rt();function de(t){if(!t||t.trim()==="")return t;let e=A.getState().personalizationData;if(!e||Object.keys(e).length===0)return jr(t);let o=/\{\{([^|}\s]+)\s*\|\s*([^}]+)\}\}/g;return t.replace(o,(i,n,r)=>{let l=n.trim(),d=r.trim();return e[l]??d})}function jr(t){let e=/\{\{[^|}\s]+\s*\|\s*([^}]+)\}\}/g;return t.replace(e,(o,i)=>i.trim())}$e();rt();rt();var Go="appstorys_campaigns_cache",si="appstorys_campaigns_etag",Xo="appstorys_campaigns_version";async function Jo(t,e){try{let o=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),i=o?`/appstorys-campaigns/clients/${t}/campaigns.json`:`https://dev-cdn-campaign-appstorys.s3.ap-south-1.amazonaws.com/clients/${t}/campaigns.json`,n=await pt.getItem(Go),r=await pt.getItem(si),l=await pt.getItem(Xo),d={Accept:"application/json"};!o&&r&&(d["If-None-Match"]=r);let c=await fetch(i,{method:"GET",headers:d,...o?{cache:"no-store"}:{}});if(c.status===304)return{campaigns:n?JSON.parse(n):[],version:l?parseInt(l):1};let y=c.headers.get("ETag"),b=await c.json(),h=2,f=b,v=e;if(!v)try{let S=await bt(),u=Yt(),g=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...S?{Authorization:`Bearer ${S}`}:{}},body:JSON.stringify({user_id:u,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(g.ok){let C=await g.json();console.info("AppStorys: fetchAllCampaigns track-user-res returned",C);let I=C?.screenName||C?.screen||C?.currentScreen||C?.screen_name||C?.current_screen;I&&(v=I);try{let z=A.getState();typeof C.screen_capture_enabled<"u"&&z.setScreenCaptureEnabled(!!C.screen_capture_enabled)}catch{}}}catch(S){console.warn("Could not fetch screen name from track-user-res:",S)}if(b.length>0&&b[0].version!==void 0&&(h=b[0].version,f=b.slice(1)),!f||f.length===0)try{let S=await bt(),u=Yt(),g=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...S?{Authorization:`Bearer ${S}`}:{}},body:JSON.stringify({user_id:u,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(g.ok){let C=await g.json(),I=C?.user_id||C?.id||C?.userId||u;try{let z=A.getState();typeof C.screen_capture_enabled<"u"&&z.setScreenCaptureEnabled(!!C.screen_capture_enabled)}catch{}if(I){let E=await fetch(o?"/appstorys-users/load-campaign-data":"https://users.appstorys.com/load-campaign-data",{method:"POST",headers:{"Content-Type":"application/json",...S?{Authorization:`Bearer ${S}`}:{}},body:JSON.stringify({user_id:I})});if(E.ok){let w=await E.json();console.log(`Fetched ${w.length} missing campaigns from fallback`),console.log("Fallback campaigns:",JSON.stringify(w,null,2)),w&&w.length>0&&(f=w)}else console.error("Failed to fetch missing campaigns:",await E.text())}}}catch(S){console.error("Error fetching missing campaigns via fallback:",S)}if(v&&f&&f.length>0){let S=m=>(m||"").trim().toLowerCase(),u=S(v);f=f.filter(m=>!S(m.screen)||S(m.screen)===u)}return await pt.setItem(Go,JSON.stringify(f)),await pt.setItem(Xo,h.toString()),y&&await pt.setItem(si,y),{campaigns:f,version:h}}catch(o){console.error("Error fetching campaigns:",o);let i=await pt.getItem(Go),n=await pt.getItem(Xo);return{campaigns:i?JSON.parse(i):[],version:n?parseInt(n):1}}}rt();rt();rt();async function ko(t,e){try{let o=await bt(),i=A.getState();if(!o)return console.error("AppStorys: Access token not found for reconciliation"),!1;let n={anonymous_user_id:t,identified_user_id:e},r=i.baseUrl||"https://users.appstorys.co",l=await fetch(`${r}/reconcile-anonymous-user`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(n)});if(l.ok)return!0;{let d=await l.text();return console.error("AppStorys: Failed to reconcile anonymous user:",l.status,d),!1}}catch(o){return console.error("AppStorys: Error in reconcileAnonymousUser:",o),!1}}rt();var Ko=class{isInitialized=!1;setup(){this.isInitialized||typeof window>"u"||(document.addEventListener("mouseleave",this.handleMouseLeave),window.addEventListener("popstate",this.handlePopState),window.history.state!=="appstorys_navigation"&&window.history.pushState("appstorys_navigation",""),this.isInitialized=!0)}destroy(){!this.isInitialized||typeof window>"u"||(document.removeEventListener("mouseleave",this.handleMouseLeave),window.removeEventListener("popstate",this.handlePopState),this.isInitialized=!1)}handleMouseLeave=e=>{e.clientY<=0&&Oo()&&this.triggerCampaign()};handlePopState=()=>{Oo()&&(window.history.pushState("appstorys_navigation",""),this.triggerCampaign())};triggerCampaign(){let e=A.getState(),{trackedEvents:o}=e;o.includes(yo)||(console.log("AppStorys: Exit Intent triggered. Displaying campaign."),e.setTrackedEvents([...o,yo]))}},ai=new Ko;rt();var Zo=class{isInitialized=!1;setup(){this.isInitialized||typeof document>"u"||(document.addEventListener("visibilitychange",this.handleVisibilityChange),this.updateVisibility(document.visibilityState==="visible"),this.isInitialized=!0)}destroy(){!this.isInitialized||typeof document>"u"||(document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.isInitialized=!1)}handleVisibilityChange=()=>{this.updateVisibility(document.visibilityState==="visible")};updateVisibility(e){let o=A.getState();o.isVisible!==e&&(console.log(`AppStorys: SDK visibility changed to ${e?"visible":"hidden"}`),o.setVisibility(e))}},tn=new Zo;$e();var Ro="anonymous_user_id";async function li(){let t=Date.now(),e=navigator.userAgent.split(" ")[0].replace(/[^a-zA-Z0-9]/g,"_");return`${t}_${e}`}async function di(){try{let t=await pt.getItem(Ro);if(t)return t;let e=await li();return await pt.setItem(Ro,e),e}catch(t){return console.error("Error managing anonymous user ID:",t),await li()}}async function en(){try{await pt.removeItem(Ro)}catch(t){console.error("Error clearing anonymous user ID:",t)}}async function on(){try{return await pt.getItem(Ro)}catch(t){return console.error("Error getting stored anonymous user ID:",t),null}}function Hr(){if(document.getElementById("appstorys-widget-debug-styles"))return;let t=document.createElement("style");t.id="appstorys-widget-debug-styles",t.innerHTML=`
14
+ `,document.head.appendChild(t)}function pa(){ua();let t=document.createElement("button");return t.id="appstorys-screen-capture-btn",t.title="Capture screen",Object.assign(t.style,{position:"fixed",left:"16px",bottom:"16px",width:"100px",height:"56px",borderRadius:"28px",background:"#ff6a00",color:"#fff",border:"none",boxShadow:"0 6px 18px rgba(0,0,0,0.2)",zIndex:"2147483647",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",fontWeight:"600",fontFamily:"sans-serif",transition:"all 0.2s ease"}),t.innerText="Capture",t}function jr(){try{let t=P.getState(),o=!!window.__APPSTORYS_DEBUG_CAPTURE;if(console.info("AppStorys: mountScreenCaptureButton called, screenCaptureEnabled=",t.screenCaptureEnabled,"debugForce=",o),!t.screenCaptureEnabled&&!o||document.getElementById("appstorys-screen-capture-btn"))return null;let n=pa();return n.addEventListener("click",async()=>{n.disabled=!0;let i=n.innerText;n.innerHTML='<div class="appstorys-spinner"></div>';let l=P.getState().currentScreen||(typeof window<"u"?window.location.pathname:"");try{await eo.takeScreenshot(l)}catch(c){console.error("CaptureService error",c)}n.disabled=!1,n.innerText=i,n.animate([{transform:"scale(1.0)"},{transform:"scale(1.05)"},{transform:"scale(1.0)"}],{duration:300})}),document.body.appendChild(n),console.info("AppStorys: screen capture button mounted"),n}catch(t){return console.error("mountScreenCaptureButton error",t),null}}var Hr=Ge(()=>{"use strict";bt();Or();try{window.AppStorysMountCapture=function(){try{return jr()}catch(t){return console.error("AppStorysMountCapture failed",t),null}}}catch{}try{window.AppStorysDebugState=function(){try{let t=P.getState();return console.info("AppStorys store state:",t),t}catch(t){return console.error("AppStorysDebugState failed",t),null}}}catch{}try{window.AppStorysDebugToken=function(){try{let t=localStorage.getItem("access_token")||"",e=t.length,o=t?t.slice(0,20)+"..."+t.slice(-10):"(none)";if(console.info("Token length:",e,"masked:",o),t&&t.includes("."))try{let n=t.split(".");if(n.length===3){let i=JSON.parse(atob(n[1]));if(console.info("Token payload:",i),i.exp){let s=new Date(i.exp*1e3),l=new Date;console.info("Token expires:",s.toISOString(),"Expired:",l>s)}}}catch(n){console.warn("Could not decode JWT:",n)}return t?"Token present":"No token"}catch(t){return console.error("AppStorysDebugToken failed",t),null}}}catch{}});var fa={};ei(fa,{AppStorys:()=>ga,Banner:()=>yi,BottomSheet:()=>vr,Csat:()=>kr,Floater:()=>zi,Modal:()=>Dr,Pip:()=>Fi,SdkState:()=>fn,Story:()=>yr,Survey:()=>Lr,Tooltip:()=>Cr,Trackable:()=>_r,Widget:()=>Sr,getCampaignVariantId:()=>ts,getVariantId:()=>yn,hasVariants:()=>zo,personalizeText:()=>Pe,resolveCampaignVariant:()=>Ht,selectVariantByWeight:()=>ai});module.exports=Jr(fa);var fn=(i=>(i.uninitialized="uninitialized",i.initializing="initializing",i.initialized="initialized",i.error="error",i))(fn||{});var me=require("react"),ro=ge(require("lottie-react"));bt();var di=require("react");bt();bt();var ri="appstorys_variant_mappings",To={};function Kr(t){let e=0;for(let o=0;o<t.length;o++){let n=t.charCodeAt(o);e=(e<<5)-e+n,e|=0}return Math.abs(e)}function si(){if(typeof window>"u")return{};try{let t=localStorage.getItem(ri);if(t)return JSON.parse(t)}catch{}return{}}function Zr(t,e){if(!(!t||!e)){To[t]=e;try{let o=P.getState(),n=o.variantMappings||{};n[t]!==e&&o.setVariantMappings({...n,[t]:e})}catch{}if(typeof window<"u")try{let o=si();o[t]=e,localStorage.setItem(ri,JSON.stringify(o))}catch{}}}var yn=t=>{if(!t)return;if(To[t])return To[t];let e=P.getState().variantMappings?.[t];if(e)return To[t]=e,e;let o=si();if(o[t]){To[t]=o[t];try{P.getState().setVariantMappings({...P.getState().variantMappings||{},[t]:o[t]})}catch{}return o[t]}};function zo(t){if(!t)return!1;if(t.hasVariants===!0||t.variants&&typeof t.variants=="object"&&Object.keys(t.variants).length>0)return!0;if(t.details&&typeof t.details=="object"&&t.details.variants){let e=t.details.variants;if(typeof e=="object"&&Object.keys(e).length>0)return!0}return!1}function ai(t,e){let o=Object.keys(t);if(o.length===0)return;let n=o.filter(l=>t[l]&&t[l].isActive!==!1),i=n.length>0?n:o,s=i.reduce((l,c)=>l+(Number(t[c]?.weight)||0),0);if(s>0){let l=P.getState().userId||"default",c=`${e||"campaign"}_${l}`,S=Kr(c)%1e4/1e4*s;for(let p of i){let y=Number(t[p]?.weight)||0;if(S<y)return p;S-=y}}return i[0]}function Ht(t){if(!t||!zo(t))return t;let e=t,o=e.variants||e.details?.variants;if(!o||typeof o!="object"||Object.keys(o).length===0)return t;let n=yn(e.id||"");if((!n||!o[n])&&(n=ai(o,e.id),e.id&&n&&Zr(e.id,n)),!n||!o[n])return t;let i=o[n],l={...e.details&&typeof e.details=="object"?Object.fromEntries(Object.entries(e.details).filter(([c])=>c!=="variants")):{},...i};return{...t,details:l,_variantId:n}}function ts(t){if(t){if("_variantId"in t)return t._variantId;if(zo(t))return yn(t.id||"")}}var qo="__back_press_triggered__";function li(t){return(t||"").trim().toLowerCase()}function es(t,e){let o=li(t),n=li(e);return!o||o===n}function os(t,e,o){let n=Number(t),i=Number(o),s=!isNaN(n)&&!isNaN(i);switch(e){case"eq":return s?n===i:t===o;case"neq":return s?n!==i:t!==o;case"gt":return s?n>i:t>o;case"gte":return s?n>=i:t>=o;case"lt":return s?n<i:t<o;case"lte":return s?n<=i:t<=o;default:return!1}}function ns(t,e){let o=t.filter(n=>n.back_press==null);return o.length===0?!0:e.some(n=>o.every(i=>{let s=n[i.key];return s==null?!1:os(String(s),i.operator,i.value)}))}function is(t,e,o){let n=t,i=n.trigger_event??n.trigger,s=t.id;return!i}function hn(){let{campaigns:t,trackedEvents:e,trackedEventMetadata:o,currentScreen:n}=P.getState();return t.some(i=>{if(i.screen&&i.screen!==n)return!1;let s=i.trigger_event;if(!s||typeof s=="string")return!1;let{event:l,event_config:c}=s;if(!(c??[]).some(p=>p.back_press===!0)||e.includes(qo)||!e.includes(l))return!1;let d=(c??[]).filter(p=>p.back_press==null);if(d.length===0)return!0;let S=o[l]||[];return ns(d,S)})}function bn(t){return Array.isArray(t)?[...t].sort((o,n)=>{let i=typeof o?.order=="number"?o.order:0,s=typeof n?.order=="number"?n.order:0;return i-s}).map(o=>{if(!o||!Array.isArray(o.slides))return o;let n=[...o.slides].sort((i,s)=>{let l=typeof i?.order=="number"?i.order:0,c=typeof s?.order=="number"?s.order:0;return l-c});return{...o,slides:n}}):[]}function Mt(t,e){let o=P(d=>d.currentScreen),n=P(d=>d.campaigns),i=P(d=>d.allCampaigns),s=P(d=>d.trackedEvents),l=P(d=>d.trackedEventMetadata),c=P(d=>d.variantMappings);return(0,di.useMemo)(()=>{let d=u=>u.find(C=>{if(C.campaign_type!==t||e?.position&&C.position!==e.position||!is(C,s,l))return!1;if(e?.screenContains){let h=(e.screenContains||"").trim().toLowerCase();return(C.screen||"").trim().toLowerCase().includes(h)}return es(C.screen,o)}),p=(n&&n.length>0?d(n):void 0)??d(i||[]);if(!p)return;let y=Ht(p);return y&&y.details&&Array.isArray(y.details)&&(y.details=bn(y.details)),y},[n,i,s,l,c,t,e,o])}bt();Ho();io();bt();Vo();var ui="appstorys_offline_queue";async function pi(){let t=await kt.getItem(ui);return t?JSON.parse(t):[]}async function gi(t){await kt.setItem(ui,JSON.stringify(t))}function rs(t){return Math.min(3e4*Math.pow(2,t),12e4)}function ss(t){let o=t.retryCount||0,n=t.lastAttempt||0,i=rs(o);return o<3&&Date.now()-n>=i}async function as(){let t=P.getState();return!t.accountId||!t.appId?!1:await Ae(t.accountId,t.appId,t.userId)}async function fi(t,e){if(await as()){let n=await kt.getItem("access_token");n&&(t.headers={...t.headers,Authorization:`Bearer ${n}`}),t.authRetried=!0,t.lastAttempt=Date.now(),e(t)}}async function Yo(t,e){let o=(t.retryCount||0)+1;o<=3&&(t.retryCount=o,t.lastAttempt=Date.now(),e(t))}async function Uo(t){let e=await pi();e.push(t),await gi(e)}async function ls(){let t=await pi();if(t.length===0)return;let e=[];for(let o of t){if(!ss(o)){e.push(o);continue}try{let n=await fetch(o.url,{method:o.method,headers:o.headers,body:JSON.stringify(o.body)});if(n.ok)continue;n.status===401||n.status===403?o.authRetried||await fi(o,i=>e.push(i)):n.status>=500&&await Yo(o,i=>e.push(i))}catch{await Yo(o,i=>e.push(i))}}await gi(e)}async function Go(t){if(!navigator.onLine){await Uo(t);return}await ls();try{let e=await fetch(t.url,{method:t.method,headers:t.headers,body:JSON.stringify(t.body)});return e.ok||(e.status===401||e.status===403?await fi(t,Uo):e.status>=500&&await Yo(t,Uo)),e}catch{await Yo(t,Uo);return}}async function st(t,e,o){try{if(!t)return;let n=await At(),i=P.getState(),s=["viewed","clicked","csat captured","survey captured","shared"];if(!s.includes(t)){let S=i.trackedEvents;if(!S.includes(t))i.setTrackedEvents([...S,t]);else{let p=S.filter(y=>y!==t);p.push(t),i.setTrackedEvents(p)}if(o&&Object.keys(o).length>0){let p=i.trackedEventMetadata||{},y=p[t]||[];i.setTrackedEventMetadata({...p,[t]:[...y,o]})}}let l={...o||{}};if(!s.includes(t)){let S=await Qe();l={...l,...S}}if(e&&String(e).trim()!==""){let S=o?.variant_id||ii(e);S&&(l.variant_id=S)}let c={user_id:fe(),event:t,metadata:l};e&&(c.campaign_id=e);let d=i.trackingUrl||"https://tracking.appstorys.co";n&&await Go({url:`${d}/capture-event`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:c})}catch(n){console.error("Error in trackEvent",n)}}bt();function Nt(t){if(!t)return!1;let e=P.getState(),o=e.allCampaigns||[],n=e.campaigns||[],i=String(t).trim(),s=o.find(d=>{if(!d)return!1;let S=String(d.id||"").trim(),p=d.details||{},y=String(p.campaign||p.id||"").trim();return!!(S&&S===i||y&&y===i||S&&i.includes(S)||y&&i.includes(y))});if(!s)return!1;let l={...s};delete l.trigger_event,delete l.trigger,l.display_trigger=!0;let c=n.findIndex(d=>String(d.id||"")===String(l.id||""));if(c===-1)e.saveCampaigns([l,...n]);else{let d=n[c];if(!!(d.trigger_event??d.trigger)){let p=[...n];p[c]=l,e.saveCampaigns(p)}}return!0}var Xe=require("react/jsx-runtime"),ds=({config:t,onPress:e,style:o,ignoreSizeAndMargin:n=!1})=>{if(!t||!t.enabled)return null;let i=t.size,s=t.margin,l=t.color,c=t.image,d=t.selectedStyle,S=i!=null&&i>=0?i:18,p=n?40:S,y=s?.top!==void 0&&s?.top!==null&&s.top>=0?s.top:0,u=s?.bottom!==void 0&&s?.bottom!==null&&s.bottom>=0?s.bottom:0,C=s?.left!==void 0&&s?.left!==null&&s.left>=0?s.left:0,h=s?.right!==void 0&&s?.right!==null&&s.right>=0?s.right:0,g={marginTop:n?0:y,marginBottom:n?0:u,marginLeft:n?0:C,marginRight:n?0:h,width:p,height:p,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||"transparent",borderWidth:p*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:l?.stroke?"solid":"none",...o},b=()=>{let m=l?.cross||"#ffffff";return(0,Xe.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Xe.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:m,strokeWidth:"2.2",strokeLinecap:"round"}),(0,Xe.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:m,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,Xe.jsx)("button",{type:"button","data-control-button":"true",onMouseDown:m=>m.stopPropagation(),onClick:m=>{m.stopPropagation(),m.preventDefault(),e(m)},style:g,children:c&&c.trim()!==""?(0,Xe.jsx)("img",{src:c,style:{width:p,height:p,objectFit:"contain"},alt:"close"}):b()})},Ot=ds;var Je=require("react/jsx-runtime"),mi=ro.default?.default??ro.default??ro.Lottie??ro,yi=()=>{let t=Mt("BAN"),e=P(T=>T.isVisible),[o,n]=(0,me.useState)(!1),[i,s]=(0,me.useState)(null),[l,c]=(0,me.useState)(null),d=(0,me.useRef)(null),[S,p]=(0,me.useState)(0),y=(0,me.useRef)(null);if((0,me.useEffect)(()=>{t?.id&&y.current!==t.id&&(y.current=t.id,n(!1),st("viewed",t.id),t.details?.lottie_data&&fetch(t.details.lottie_data).then(T=>T.json()).then(T=>{s(T),T.w&&T.h&&c(T.h/T.w)}).catch(T=>console.error("Error loading Lottie:",T)))},[t?.id]),(0,me.useEffect)(()=>{let T=()=>{d.current&&p(d.current.offsetWidth)};return T(),window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[t,o]),!t||o||!e)return null;let{details:u}=t,C=u.styling||{},h=u.height||"auto";l&&S&&(h=S*l);let g=parseFloat(String(u.height)),b=parseFloat(String(u.originalWidth??u.styling?.originalWidth)),m=parseFloat(String(u.originalHeight??u.styling?.originalHeight)),E=Number.isFinite(g)&&g>0&&Number.isFinite(b)&&b>0&&Number.isFinite(m)&&m>0?g*(b/m):null,j=E!==null?`${E}px`:void 0,D=typeof h=="number"?`${h}px`:h||void 0,L=Number(C.marginRight),v=Number(C.marginBottom),w={position:"fixed",right:Number.isFinite(L)?`${L}px`:"0px",bottom:Number.isFinite(v)?`${v}px`:"0px",zIndex:9999,display:"block",cursor:u.link?"pointer":"default"},_={position:"relative",width:j||"100%",height:D||"auto",backgroundColor:"transparent",borderRadius:`${C.topRightRadius||0}px ${C.topLeftRadius||0}px ${C.bottomRightRadius||0}px ${C.bottomLeftRadius||0}px`,overflow:"hidden"},N={width:"100%",height:"100%",display:"block",objectFit:"contain"},U=T=>{T.stopPropagation(),n(!0),st("banner_closed",t.id)};return(0,Je.jsx)("div",{ref:d,style:w,onClick:()=>{if(u.link)if(st("clicked",t.id),u.link.startsWith("http"))window.open(u.link,"_blank");else{try{if(Nt(u.link))return}catch(T){console.warn("revealCampaignFromLink error",T)}console.log("Internal link:",u.link)}},children:(0,Je.jsxs)("div",{style:_,children:[i?(()=>{let T=mi.default||mi;return(0,Je.jsx)(T,{animationData:i,loop:!0,autoplay:e,style:N})})():u.image?(0,Je.jsx)("img",{src:u.image,alt:"Campaign Banner",style:N}):null,C.crossButton?.enabled&&(0,Je.jsx)(Ot,{config:C.crossButton,onPress:U,style:{top:C.crossButton?.margin?.top!==void 0?0:5,right:C.crossButton?.margin?.right!==void 0?0:5}})]})})};var Pt=require("react");bt();function Xo(t){let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")}function hi(t){try{let o=new URL(t).pathname.split("/").pop()||t;return o.split("?")[0].replace(/\.[^.]+$/,"")||`font_${o.length}`}catch{return(t.split("/").pop()??t).split("?")[0].replace(/\.[^.]+$/,"")||`font_${t.length}`}}function bi(t,e){if(typeof document>"u")return;let o=`appstorys-font-${t}`;if(document.getElementById(o))return;let n=document.createElement("style");n.id=o,n.type="text/css",n.textContent=`@font-face{font-family:"${t}";src:url("${e}");font-style:normal;font-weight:normal;font-display:swap;}`,document.head.appendChild(n)}var Qo=new Map;async function cs(t,e){try{bi(e.name,t);let o=globalThis.FontFace;if(typeof document<"u"&&o&&document.fonts?.add){let n=new o(e.name,`url(${t})`);await n.load(),document.fonts.add(n)}else typeof document<"u"&&document.fonts?.load&&await document.fonts.load(`1em "${e.name}"`);e.status="loaded",e.listeners.forEach(n=>n(e.name))}catch(o){console.warn(`[FontManager] Failed to load font from "${t}":`,o),e.status="failed",e.listeners.forEach(n=>n(void 0))}finally{e.listeners=[]}}var xn={async load(t){if(!t||!Xo(t))return;let e=Qo.get(t);if(e)return e.status==="loaded"?e.name:e.status==="failed"?void 0:new Promise(s=>e.listeners.push(s));let n={status:"pending",name:hi(t),listeners:[]};Qo.set(t,n);let i=new Promise(s=>n.listeners.push(s));return cs(t,n),i},ensure(t){if(!t||!Xo(t))return;let e=hi(t);return bi(e,t),xn.load(t),e},getSync(t){if(!t)return;let e=Qo.get(t);return e?.status==="loaded"?e.name:void 0},_clearCache(){Qo.clear()}};function lt(t,e){if(!t)return e;let o=String(t).trim();if(!o)return e;if(Xo(o)){let n=xn.ensure(o);return n?`"${n}", ${e||"sans-serif"}`:e}return o.includes(",")||o.includes('"')||o.includes("'")?o:`"${o}", ${e||"sans-serif"}`}function us(t){let e=new Set,o=new WeakSet,n=i=>{if(i!=null&&typeof i!="string"){if(Array.isArray(i)){for(let s of i)n(s);return}if(typeof i=="object"){if(o.has(i))return;o.add(i);for(let[s,l]of Object.entries(i))s==="fontFamily"&&typeof l=="string"&&Xo(l)&&e.add(l),n(l)}}};return n(t),Array.from(e)}async function xi(t){let e=new Set;for(let o of t)us(o).forEach(n=>e.add(n));await Promise.all(Array.from(e).map(o=>xn.load(o)))}var se=require("react/jsx-runtime"),Me=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:n,style:i,type:s})=>{if(!t||!n)return null;let{size:l=18,margin:c,color:d,image:S,selectedStyle:p}=t,y=o?40:l,u=o?0:c?.top??0,C=o?0:c?.bottom??0,h=o?0:c?.left??0,g=o?0:c?.right??0,b={marginTop:u,marginBottom:C,marginLeft:h,marginRight:g,width:y,height:y,backgroundColor:d?.fill||"transparent",borderColor:d?.stroke||"transparent",borderWidth:y*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,display:"flex",...o?{}:{marginTop:t.margin?.top??0,marginRight:t.margin?.right??0,marginBottom:t.margin?.bottom??0,marginLeft:t.margin?.left??0},...i},m=()=>{let E=d?.cross||"#ffffff";return s==="mute"?(0,se.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,se.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:E,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,se.jsx)("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:E,strokeWidth:"2.2",strokeLinecap:"round"}),(0,se.jsx)("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:E,strokeWidth:"2.2",strokeLinecap:"round"})]}):(0,se.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,se.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:E,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,se.jsx)("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:E,strokeWidth:"2.2",strokeLinecap:"round"}),(0,se.jsx)("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:E,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,se.jsx)("button",{type:"button","data-control-button":"true",onMouseDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),E.preventDefault(),e(E)},style:{...b,border:b.borderColor?`${b.borderWidth}px solid ${b.borderColor}`:"none",padding:0,cursor:"pointer",outline:"none"},children:S&&S.trim()!==""?(0,se.jsx)("img",{src:S,style:{width:y,height:y,objectFit:"contain"},alt:s}):m()})};var ee=require("react/jsx-runtime"),Si=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:n,style:i,type:s})=>{if(!t||!n)return null;let{size:l=18,margin:c,color:d,image:S,selectedStyle:p}=t,y=o?40:l,u={marginTop:o?0:c?.top??0,marginBottom:o?0:c?.bottom??0,marginLeft:o?0:c?.left??0,marginRight:o?0:c?.right??0,width:y,height:y,backgroundColor:d?.fill||"transparent",borderColor:d?.stroke||d?.cross||"#ffffff",borderWidth:d?.stroke?Math.max(1,y*.05):2,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:"solid",boxSizing:"border-box",...o?{}:{marginTop:t.margin?.top??0,marginRight:t.margin?.right??0,marginBottom:t.margin?.bottom??0,marginLeft:t.margin?.left??0},...i},C=()=>{let h=d?.cross||"#ffffff";return s==="maximise"?(0,ee.jsxs)("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%","aria-hidden":!0,children:[(0,ee.jsx)("polyline",{points:"15,5 19,5 19,9",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("line",{x1:"19",y1:"5",x2:"14",y2:"10",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"}),(0,ee.jsx)("polyline",{points:"9,19 5,19 5,15",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("line",{x1:"5",y1:"19",x2:"10",y2:"14",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"})]}):(0,ee.jsxs)("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%","aria-hidden":!0,children:[(0,ee.jsx)("polyline",{points:"14,6 14,10 18,10",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("line",{x1:"14",y1:"10",x2:"19",y2:"5",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"}),(0,ee.jsx)("polyline",{points:"6,14 10,14 10,18",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("line",{x1:"10",y1:"14",x2:"5",y2:"19",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,ee.jsx)("button",{type:"button","data-control-button":"true",onMouseDown:h=>h.stopPropagation(),onClick:h=>{h.stopPropagation(),h.preventDefault(),e(h)},style:u,children:S&&S.trim()!==""?(0,ee.jsx)("img",{src:S,style:{width:y,height:y,objectFit:"contain"},alt:s}):C()})};var so=require("react/jsx-runtime"),ps=({styling:t,mode:e,muted:o,expanded:n,onClose:i,onToggleMute:s,onToggleExpand:l,containerStyle:c})=>{if(!t)return null;let d=e==="LARGE",S={position:"absolute",pointerEvents:"auto",...d?{top:15,right:15}:{top:0,right:0}},p={position:"absolute",pointerEvents:"auto",...d?{top:15,right:60}:{top:0,left:0}},y={position:"absolute",pointerEvents:"auto",...d?{top:15,left:15}:{bottom:0,right:0}},u=o?t.soundToggle?.unmute:t.soundToggle?.mute,C=n?t.expandControls?.minimise:t.expandControls?.maximise;return(0,so.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:9999999,pointerEvents:"none",...c},children:[t.crossButton?.enabled&&(0,so.jsx)(Ot,{config:{enabled:t.crossButton?.enabled??!1,image:t.crossButton?.image??"",color:{cross:t.crossButton?.color?.cross??"#ffffff",fill:t.crossButton?.color?.fill??"",stroke:t.crossButton?.color?.stroke??""},margin:{top:t.crossButton?.margin?.top??0,bottom:t.crossButton?.margin?.bottom??0,left:t.crossButton?.margin?.left??0,right:t.crossButton?.margin?.right??0},size:t.crossButton?.size&&t.crossButton.size>10?t.crossButton.size:20},onPress:i,ignoreSizeAndMargin:d,style:S}),t.soundToggle?.enabled&&u&&(0,so.jsx)(Me,{config:u,onPress:s,ignoreSizeAndMargin:d,style:p,enabled:t.soundToggle?.enabled,type:o?"unmute":"mute"}),t.expandControls?.enabled&&C&&(0,so.jsx)(Si,{config:C,onPress:l,ignoreSizeAndMargin:d,style:y,enabled:t.expandControls?.enabled,type:n?"minimise":"maximise"})]})},Ci=ps;var ao=require("react/jsx-runtime"),Sn=t=>(t||"").trim().toLowerCase(),Jo=(t,e)=>{let o=Number(t);return Number.isFinite(o)?o:e},vi=20,wi=20,ki=20,Ri=(t,e,o)=>{let n=window.innerWidth,i=window.innerHeight,s=vi,l=Math.max(s,n-o.width-vi),c=o.topInset,d=Math.max(c,i-o.height-o.bottomInset);return{x:Math.min(Math.max(t,s),l),y:Math.min(Math.max(e,c),d)}},gs=t=>{if(t===!0||t===1)return!0;if(t===!1||t===0||t==null||t==="")return!1;let e=String(t).trim().toLowerCase();return e==="yes"||e==="true"||e==="1"},Fi=()=>{let t=Mt("PIP"),e=P(Z=>Z.campaigns),o=P(Z=>Z.allCampaigns),n=P(Z=>Z.currentScreen),i=P(Z=>Z.isVisible),[s,l]=(0,Pt.useState)(!1),[c,d]=(0,Pt.useState)(!1),[S,p]=(0,Pt.useState)(!0),[y,u]=(0,Pt.useState)(!1),[C,h]=(0,Pt.useState)(null),g=(0,Pt.useRef)({x:0,y:0}),b=(0,Pt.useRef)({width:150,height:300,topInset:wi,bottomInset:ki}),m=(0,Pt.useRef)(null),E=(0,Pt.useRef)({x:0,y:0}),j=(0,Pt.useRef)(!1),D=(0,Pt.useMemo)(()=>{if(t)return t;let Z=Sn(n),rt=ht=>ht.find(mt=>{let R=mt,I=R.campaign_type==="PIP",O=!Sn(R.screen)||Sn(R.screen)===Z,tt=!!(R.trigger_event??R.trigger),St=R.display_trigger!==!1&&!tt;return I&&O&&St}),dt=rt(e)??rt(o);return dt?Ht(dt):void 0},[t,e,o,n]),L=(0,Pt.useMemo)(()=>D,[D?.id,D?.details?.id]);if((0,Pt.useEffect)(()=>{if(!L)return;let Z=L.details||{},rt=Z?.styling?.soundToggle?.defaultSound||Z?.styling?.appearance?.defaultSound||"yes";p(String(rt).toLowerCase()!=="yes"),l(!1),d(!1),h(null),st("viewed",L.id)},[L]),(0,Pt.useEffect)(()=>{let Z=m.current;if(!Z)return;Z.muted=S;let rt=Z.play();rt&&typeof rt.catch=="function"&&rt.catch(()=>{S||(Z.muted=!0,p(!0))})},[S]),(0,Pt.useEffect)(()=>{if(!c)return;let Z=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=Z}},[c]),(0,Pt.useEffect)(()=>{if(!y)return;let Z=dt=>{let ht=dt.clientX-E.current.x,mt=dt.clientY-E.current.y;(Math.abs(ht)>4||Math.abs(mt)>4)&&(j.current=!0);let R=dt.clientX-g.current.x,I=dt.clientY-g.current.y;h(Ri(R,I,b.current))},rt=()=>{u(!1)};return window.addEventListener("pointermove",Z),window.addEventListener("pointerup",rt),window.addEventListener("pointercancel",rt),()=>{window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",rt),window.removeEventListener("pointercancel",rt)}},[y]),(0,Pt.useEffect)(()=>{let Z=()=>{h(rt=>rt&&Ri(rt.x,rt.y,b.current))};return window.addEventListener("resize",Z),window.addEventListener("orientationchange",Z),()=>{window.removeEventListener("resize",Z),window.removeEventListener("orientationchange",Z)}},[]),!L||!L.details||s||!i)return null;let v=L.details,w=v.styling||{},_=w.appearance||{},N=Jo(v.width??_.pipWidth,150),U=Jo(v.height??_.pipHeight,300),A=N,T=U,k=w.cta?.container||{},B=w.cta?.text||{},$=w.cta?.cornerRadius,V=w.cta?.margin||{},G=!!(v.button_text&&v.button_text.trim().length>0),r=Jo(w.pipBottomPadding,20),M=Jo(w.pipTopPadding,0);b.current={width:A,height:T,topInset:wi+M,bottomInset:ki+r};let a=c?v.large_video||v.small_video:v.small_video||v.large_video,f=(v.position||L.position||"right").toLowerCase(),x=!!w.isMovable,z=w.soundToggle?.enabled!==!1,Y=w.crossButton?.enabled!==!1,ot=w.expandablePip??v.expandablePip??v.expandable_pip,J=ot!=null&&ot!==""?gs(ot):w.expandControls?.enabled!==!1,H={...w,crossButton:{...w.crossButton,enabled:Y,image:v.crossButtonImage||w.crossButton?.image},soundToggle:{...w.soundToggle,enabled:z,mute:{...w.soundToggle?.mute,image:v.muteImage||w.soundToggle?.mute?.image},unmute:{...w.soundToggle?.unmute,image:v.unmuteImage||w.soundToggle?.unmute?.image}},expandControls:{...w.expandControls,enabled:J,maximise:{...w.expandControls?.maximise,image:v.maximiseImage||w.expandControls?.maximise?.image},minimise:{...w.expandControls?.minimise,image:v.minimiseImage||w.expandControls?.minimise?.image}}},K=()=>{d(Z=>{let rt=!Z;return rt&&L?.id&&(st("viewed",L.id),st("analyze",L.id)),rt})},it={position:"fixed",zIndex:10020,width:c?"auto":A,height:c?"auto":T,borderRadius:c?0:5,overflow:"hidden",background:"#000",boxShadow:"0 16px 40px rgba(0,0,0,0.35)",cursor:y?"grabbing":x&&!c?"grab":"default",transition:y?"none":"width 180ms ease, height 180ms ease, transform 180ms ease",touchAction:c||x?"none":"auto",WebkitUserSelect:"none",userSelect:"none",WebkitTapHighlightColor:"transparent"};C&&!c?(it.left=C.x,it.top=C.y):c?(it.left=0,it.top=0,it.right=0,it.bottom=0):(f==="left"?it.left=24:it.right=24,M>0?it.top=M:it.bottom=r+20);let xt=Z=>{if(!x||c||Z.pointerType==="mouse"&&Z.button!==0||Z.target.closest("[data-control-button='true']"))return;let dt=Z.currentTarget.getBoundingClientRect();g.current={x:Z.clientX-dt.left,y:Z.clientY-dt.top},E.current={x:Z.clientX,y:Z.clientY},j.current=!1,h({x:dt.left,y:dt.top}),u(!0)},ut=()=>{if(!v.link)return;st("clicked",L.id);let Z=String(v.link).trim();try{let rt=P.getState(),dt=rt.allCampaigns||[],ht=rt.campaigns||[],mt=dt.find(R=>R.id===Z);if(console.log("[Pip] clicked link=",Z,"allCount=",dt.length,"visibleCount=",ht.length,"referenced=",!!mt),mt){let R={...mt};delete R.trigger_event,delete R.trigger,R.display_trigger=!0;let I=ht.findIndex(O=>O.id===R.id);if(I===-1)rt.saveCampaigns([R,...ht]);else{let O=ht[I];if(!!(O.trigger_event??O.trigger)){let St=[...ht];St[I]=R,rt.saveCampaigns(St)}}return}}catch{}window.open(v.link,"_blank")};return a?(0,ao.jsxs)("div",{style:it,onPointerDown:xt,children:[(0,ao.jsx)("video",{ref:m,src:a,autoPlay:!0,loop:!0,playsInline:!0,muted:S,style:{width:"100%",height:"100%",objectFit:c?"contain":"cover",cursor:J&&!c||v.link?"pointer":"default"},onClick:()=>{if(j.current){j.current=!1;return}if(J){K();return}ut()},onEnded:()=>{D&&st("analyze",D.id)}}),(0,ao.jsx)(Ci,{styling:H,mode:c?"LARGE":"SMALL",muted:!S,expanded:c,onClose:()=>l(!0),onToggleMute:()=>p(Z=>!Z),onToggleExpand:K,containerStyle:c?{paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:"env(safe-area-inset-left, 0px)",paddingRight:"env(safe-area-inset-right, 0px)"}:void 0}),c&&G&&(0,ao.jsx)("button",{"data-control-button":"true",onClick:ut,style:{position:"absolute",left:V.left??12,right:V.right??12,bottom:`calc(${V.bottom??12}px + env(safe-area-inset-bottom, 0px))`,height:k.height||42,width:k.ctaFullWidth?"auto":k.ctaWidth||"auto",maxWidth:`calc(100% - ${(V.left??12)+(V.right??12)}px)`,margin:k.ctaFullWidth?"0":"0 auto",background:k.backgroundColor||"#F7921C",color:B.color||"#fff",border:`${k.borderWidth||0}px solid ${k.borderColor||"transparent"}`,borderTopLeftRadius:typeof $=="number"?$:$?.topLeft??10,borderTopRightRadius:typeof $=="number"?$:$?.topRight??10,borderBottomRightRadius:typeof $=="number"?$:$?.bottomRight??10,borderBottomLeftRadius:typeof $=="number"?$:$?.bottomLeft??10,fontSize:B.fontSize||14,fontFamily:lt(B.fontFamily),fontWeight:600,cursor:v.link?"pointer":"default"},children:v.button_text})]}):null};var Kt=ge(require("react")),Ti=require("lottie-react");bt();var Ke=require("react/jsx-runtime"),ae=(t,e=0)=>{let o=Number(t);return Number.isFinite(o)?o:e},Cn=t=>(t||"").trim().toLowerCase(),fs="appstorysmediabucketdev.s3.ap-south-1.amazonaws.com",ms=t=>{try{if(typeof window>"u")return[t];let e=new URL(t);if(e.hostname!==fs)return[t];let o=!!window.location.port,n=`/appstorys-media${e.pathname}${e.search}`;return o?[n,t]:[t]}catch{return[t]}},ys=t=>{if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return Array.isArray(e.layers)||Array.isArray(e.assets)||typeof e.v=="string"},vn=class extends Kt.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){this.props.onError()}render(){return this.state.hasError?null:this.props.children}},hs=()=>{let[t,e]=(0,Kt.useState)(null),[o,n]=(0,Kt.useState)([]),[i,s]=(0,Kt.useState)(!1),[l,c]=(0,Kt.useState)(!1),d=(0,Kt.useRef)(null),S=(0,Kt.useRef)(null),p=Mt("FLT"),y=P(k=>k.campaigns),u=P(k=>k.allCampaigns),C=P(k=>k.currentScreen),h=P(k=>k.isVisible),g=(0,Kt.useRef)(null),b=p??(()=>{let k=[...y,...u].find(B=>{let $=B;if($.campaign_type!=="FLT")return!1;let V=!!($.trigger_event??$.trigger);return $.display_trigger===!1||V?!1:!Cn($.screen)||Cn($.screen)===Cn(C)});if(k)try{return Ht(k)}catch{return k}})(),m=b?.id,E=P(k=>m?k.variantMappings[m]:void 0);if((0,Kt.useEffect)(()=>{if(!b?.id||!h||zo(b)&&!E)return;let B=`${b.id}:${E||""}`;g.current!==B&&(g.current=B,st("viewed",b.id))},[b?.id,E,h]),(0,Kt.useEffect)(()=>{let k=b?.details?.lottie_data;if(e(null),n([]),s(!1),c(!1),!k)return;if(ys(k)){e(k),c(!0);return}if(typeof k!="string"){s(!0);return}let B=ms(k);n(B),c(!0)},[b?.details?.lottie_data]),(0,Kt.useEffect)(()=>{if(!b?.details?.lottie_data||!d.current)return;let k=Ti.LottiePlayer;if(!k||typeof k.loadAnimation!="function"){s(!0),c(!1);return}let B=!1,$=null,V=()=>{$&&typeof $.destroy=="function"&&$.destroy(),$=null,S.current=null},G=(r,M)=>{if(B)return;if(M>=r.length){s(!0),c(!1),console.error("[Floater] lottie load failed",{lottieUrls:r});return}V();let a=k.loadAnimation({container:d.current,renderer:"svg",loop:!0,autoplay:!0,path:r[M]});$=a,S.current=a,a.addEventListener("DOMLoaded",()=>{B||c(!1)}),a.addEventListener("data_failed",()=>{B||G(r,M+1)})};if(t){V();let r=k.loadAnimation({container:d.current,renderer:"svg",loop:!0,autoplay:!0,animationData:t});$=r,S.current=r,r.addEventListener("DOMLoaded",()=>{B||c(!1)}),r.addEventListener("data_failed",()=>{B||(s(!0),c(!1))})}else o.length>0&&G(o,0);return()=>{B=!0,V()}},[b?.details?.lottie_data,t,o]),!b||!b.details||!h)return null;let{details:j}=b,D=j.styling||{},v=(typeof j.position=="string"?j.position:typeof b.position=="string"?b.position:"right").toLowerCase()==="left"?"left":"right",w={position:"fixed",left:v==="left"?ae(D.marginLeft,12):void 0,right:v==="left"?void 0:ae(D.marginRight,12),top:ae(D.marginTop,0)>0?ae(D.marginTop,0):void 0,bottom:ae(D.marginTop,0)>0?void 0:ae(D.marginBottom,80),zIndex:10040,display:"flex"},_={width:ae(j.width,60),height:ae(j.height,60),background:"transparent",overflow:"hidden",borderBottomLeftRadius:ae(D.bottomLeftRadius,0),borderBottomRightRadius:ae(D.bottomRightRadius,0),borderTopLeftRadius:ae(D.topLeftRadius,0),borderTopRightRadius:ae(D.topRightRadius,0),display:"flex",alignItems:"center",justifyContent:"center",cursor:j.link?"pointer":"default",boxShadow:"0 8px 18px rgba(0,0,0,0.2)"},N=async()=>{if(!j.link)return;await st("clicked",b.id);let k=String(j.link).trim();try{let B=P.getState(),$=B.allCampaigns||[],V=B.campaigns||[],G=$.find(r=>{if(!r)return!1;let M=String(r.id||"").trim(),a=r.details||{},f=String(a.campaign||a.id||"").trim();return!!(M&&M===k||f&&f===k||M&&k.includes(M)||f&&k.includes(f))});if(console.log("[Floater] clicked link=",k,"allCampaignsCount=",$.length,"visibleCount=",V.length),console.log("[Floater] all ids=",$.map(r=>r.id).slice(0,50)),console.log("[Floater] referenced found=",!!G,G&&(G.id||G.details?.campaign||G.details?.id)),G){let r={...G};delete r.trigger_event,delete r.trigger,r.display_trigger=!0;let M=V.findIndex(a=>a.id===r.id);if(M===-1)console.log("[Floater] revealing campaign (prepended)",r.id),B.saveCampaigns([r,...V]);else{let a=V[M];if(!!(a.trigger_event??a.trigger)){let x=[...V];x[M]=r,console.log("[Floater] replacing existing triggered campaign with revealed one",r.id),B.saveCampaigns(x)}else console.log("[Floater] campaign already visible and not trigger-driven",r.id)}return}}catch(B){console.warn("[Floater] error while resolving referenced campaign",B)}try{window.open(j.link,"_blank")}catch{}},U=!!(j.lottie_data&&!i),A=!!j.image,T=!!(j.lottie_data&&l&&!t&&!i);return!U&&!A&&!T?null:(0,Ke.jsx)("div",{style:w,children:(0,Ke.jsx)("div",{style:_,onClick:()=>{N()},children:U?(0,Ke.jsx)(vn,{onError:()=>s(!0),children:(0,Ke.jsx)("div",{ref:d,style:{width:"100%",height:"100%",display:"block"}})},String(j.lottie_data)):T?(0,Ke.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.08)",color:"#333",fontSize:10,fontWeight:600},children:"..."}):(0,Ke.jsx)("img",{src:j.image,alt:"floater",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})})})},zi=hs;bt();function Ii(t){return(t||"").trim().toLowerCase()}function wn(t,e){let o=Ii(t.screen),n=Ii(e);return!o||o===n}async function kn(t){try{let e=P.getState(),o=await At(),n=e.accountId;if(!o||!n)return;e.setCurrentScreen(t),e.setTrackedEvents([]);let i=e.baseUrl||"https://users.appstorys.co",s=await fetch(`${i}/v2/${n}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({user_id:fe(),screenName:t})});if(!s.ok)return;let l=await s.json();if(typeof l.screen_capture_enabled<"u"&&e.setScreenCaptureEnabled(!!l.screen_capture_enabled),l.variants&&l.variants.length>0){let m={};l.variants.forEach(E=>{m[E.id]=E.v_id}),e.setVariantMappings(m)}l.personalization_data&&e.setPersonalizationData(l.personalization_data);let c=e.allCampaigns||[],d=l.eligibleCampaignList||[],S=c.filter(m=>d.includes(m.id)&&wn(m,t)),p=S.map(m=>m.id),y=d.filter(m=>!p.includes(m)),u=[];if(y.length>0){let m=await fetch(`${i}/load-campaign-data`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(y)});m.ok&&(u=(await m.json()).filter(j=>wn(j,t)))}let C=[...S,...u],h=c.filter(m=>{let E=!!(m.trigger_event??m.trigger);return wn(m,t)&&m.display_trigger===!0&&!E}),g=[...C],b=new Set(g.map(m=>m.id));for(let m of h)b.has(m.id)||(g.push(m),b.add(m.id));e.saveCampaigns(g)}catch(e){console.error("Error when tracking screen:",t,e)}}Vo();bt();Ho();async function Rn(t){try{let e=await At(),o=fe(),n=P.getState();if(!e||!o){console.warn("AppStorys: Missing accessToken or userId. Ensure SDK is initialized before setting user properties.");return}let i={...t||{}},s=await Qe();i={...i,...s};let l={user_id:o,attributes:i},c=n.baseUrl||"https://users.appstorys.co";await Go({url:`${c}/update-user-atr`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:l})}catch(e){console.error("AppStorys: Error in setUserProperties:",e)}}bt();function Pe(t){if(!t||t.trim()==="")return t;let e=P.getState().personalizationData;if(!e||Object.keys(e).length===0)return bs(t);let o=/\{\{([^|}\s]+)\s*\|\s*([^}]+)\}\}/g;return t.replace(o,(n,i,s)=>{let l=i.trim(),c=s.trim();return e[l]??c})}function bs(t){let e=/\{\{[^|}\s]+\s*\|\s*([^}]+)\}\}/g;return t.replace(e,(o,n)=>n.trim())}io();bt();bt();var Fn="appstorys_campaigns_cache",Bi="appstorys_campaigns_etag",Tn="appstorys_campaigns_version";async function zn(t,e){try{let o=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),n=o?`/appstorys-campaigns/clients/${t}/campaigns.json`:`https://dev-cdn-campaign-appstorys.s3.ap-south-1.amazonaws.com/clients/${t}/campaigns.json`,i=await kt.getItem(Fn),s=await kt.getItem(Bi),l=await kt.getItem(Tn),c={Accept:"application/json"};!o&&s&&(c["If-None-Match"]=s);let d=await fetch(n,{method:"GET",headers:c,...o?{cache:"no-store"}:{}});if(d.status===304)return{campaigns:i?JSON.parse(i):[],version:l?parseInt(l):1};let S=d.headers.get("ETag"),p=await d.json(),y=2,u=p,C=e;if(!C)try{let h=await At(),g=fe(),m=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...h?{Authorization:`Bearer ${h}`}:{}},body:JSON.stringify({user_id:g,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(m.ok){let E=await m.json();console.info("AppStorys: fetchAllCampaigns track-user-res returned",E);let j=E?.screenName||E?.screen||E?.currentScreen||E?.screen_name||E?.current_screen;j&&(C=j);try{let D=P.getState();typeof E.screen_capture_enabled<"u"&&D.setScreenCaptureEnabled(!!E.screen_capture_enabled)}catch{}}}catch(h){console.warn("Could not fetch screen name from track-user-res:",h)}if(p.length>0&&p[0].version!==void 0&&(y=p[0].version,u=p.slice(1)),!u||u.length===0)try{let h=await At(),g=fe(),m=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...h?{Authorization:`Bearer ${h}`}:{}},body:JSON.stringify({user_id:g,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(m.ok){let E=await m.json(),j=E?.user_id||E?.id||E?.userId||g;try{let D=P.getState();typeof E.screen_capture_enabled<"u"&&D.setScreenCaptureEnabled(!!E.screen_capture_enabled)}catch{}if(j){let L=await fetch(o?"/appstorys-users/load-campaign-data":"https://users.appstorys.co/load-campaign-data",{method:"POST",headers:{"Content-Type":"application/json",...h?{Authorization:`Bearer ${h}`}:{}},body:JSON.stringify({user_id:j})});if(L.ok){let v=await L.json();console.log(`Fetched ${v.length} missing campaigns from fallback`),console.log("Fallback campaigns:",JSON.stringify(v,null,2)),v&&v.length>0&&(u=v)}else console.error("Failed to fetch missing campaigns:",await L.text())}}}catch(h){console.error("Error fetching missing campaigns via fallback:",h)}if(C&&u&&u.length>0){let h=b=>(b||"").trim().toLowerCase(),g=h(C);u=u.filter(b=>!h(b.screen)||h(b.screen)===g)}return await kt.setItem(Fn,JSON.stringify(u)),await kt.setItem(Tn,y.toString()),S&&await kt.setItem(Bi,S),{campaigns:u,version:y}}catch(o){console.error("Error fetching campaigns:",o);let n=await kt.getItem(Fn),i=await kt.getItem(Tn);return{campaigns:n?JSON.parse(n):[],version:i?parseInt(i):1}}}bt();bt();bt();async function Ko(t,e){try{let o=await At(),n=P.getState();if(!o)return console.error("AppStorys: Access token not found for reconciliation"),!1;let i={anonymous_user_id:t,identified_user_id:e},s=n.baseUrl||"https://users.appstorys.co",l=await fetch(`${s}/reconcile-anonymous-user`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(i)});if(l.ok)return!0;{let c=await l.text();return console.error("AppStorys: Failed to reconcile anonymous user:",l.status,c),!1}}catch(o){return console.error("AppStorys: Error in reconcileAnonymousUser:",o),!1}}bt();var In=class{isInitialized=!1;setup(){this.isInitialized||typeof window>"u"||(document.addEventListener("mouseleave",this.handleMouseLeave),window.addEventListener("popstate",this.handlePopState),window.history.state!=="appstorys_navigation"&&window.history.pushState("appstorys_navigation",""),this.isInitialized=!0)}destroy(){!this.isInitialized||typeof window>"u"||(document.removeEventListener("mouseleave",this.handleMouseLeave),window.removeEventListener("popstate",this.handlePopState),this.isInitialized=!1)}handleMouseLeave=e=>{e.clientY<=0&&hn()&&this.triggerCampaign()};handlePopState=()=>{hn()&&(window.history.pushState("appstorys_navigation",""),this.triggerCampaign())};triggerCampaign(){let e=P.getState(),{trackedEvents:o}=e;o.includes(qo)||(console.log("AppStorys: Exit Intent triggered. Displaying campaign."),e.setTrackedEvents([...o,qo]))}},Li=new In;bt();var Bn=class{isInitialized=!1;setup(){this.isInitialized||typeof document>"u"||(document.addEventListener("visibilitychange",this.handleVisibilityChange),this.updateVisibility(document.visibilityState==="visible"),this.isInitialized=!0)}destroy(){!this.isInitialized||typeof document>"u"||(document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.isInitialized=!1)}handleVisibilityChange=()=>{this.updateVisibility(document.visibilityState==="visible")};updateVisibility(e){let o=P.getState();o.isVisible!==e&&(console.log(`AppStorys: SDK visibility changed to ${e?"visible":"hidden"}`),o.setVisibility(e))}},Ln=new Bn;io();var Zo="anonymous_user_id";async function Ei(){let t=Date.now(),e=navigator.userAgent.split(" ")[0].replace(/[^a-zA-Z0-9]/g,"_");return`${t}_${e}`}async function Ai(){try{let t=await kt.getItem(Zo);if(t)return t;let e=await Ei();return await kt.setItem(Zo,e),e}catch(t){return console.error("Error managing anonymous user ID:",t),await Ei()}}async function En(){try{await kt.removeItem(Zo)}catch(t){console.error("Error clearing anonymous user ID:",t)}}async function An(){try{return await kt.getItem(Zo)}catch(t){return console.error("Error getting stored anonymous user ID:",t),null}}function xs(){if(document.getElementById("appstorys-widget-debug-styles"))return;let t=document.createElement("style");t.id="appstorys-widget-debug-styles",t.innerHTML=`
15
15
  .appstorys-widget-debug-pill {
16
16
  position: absolute;
17
17
  top: 8px;
@@ -30,7 +30,12 @@
30
30
  outline: 3px dashed rgba(255,122,24,0.85);
31
31
  outline-offset: 6px;
32
32
  }
33
- `,document.head.appendChild(t)}function ci(t){let e=document.createElement("div");return e.className="appstorys-widget-debug-pill",e.textContent=t,e}function qr(t){let e=t,o=getComputedStyle(e);(o.position==="static"||!o.position)&&(e.style.position="relative")}window.AppStorysShowWidgetElements=function(){try{Hr();let e=Array.from(document.querySelectorAll("[data-as-id], [data-widget], [data-widget-id]"));if(e.length||["#hero_section",".hero_section","#header_container",".header_container"].forEach(i=>{let n=document.querySelector(i);n&&e.push(n)}),!e.length){let o=ci("Widget");o.style.position="fixed",o.style.top="12px",o.style.left="12px",o.style.pointerEvents="auto",document.body.appendChild(o);return}e.forEach((o,i)=>{let n=o;qr(n),n.classList.add("appstorys-widget-debug-overlay");let r=n.querySelector(".appstorys-widget-debug-pill");r&&r.remove();let l=ci("Widget "+(i+1));n.appendChild(l)})}catch(e){console.error("AppStorysShowWidgetElements error",e)}};var je=require("react");rt();var eo=require("react"),Oe=ae(require("lottie-react")),nn=require("react/jsx-runtime"),ui=Oe.default?.default??Oe.default??Oe.Lottie??Oe,te=({src:t,alt:e,style:o,size:i})=>{let[n,r]=(0,eo.useState)(null),[l,d]=(0,eo.useState)(!1);(0,eo.useEffect)(()=>{t&&t.toLowerCase().endsWith(".json")?fetch(t).then(y=>{if(!y.ok)throw new Error("Failed to fetch Lottie");return y.json()}).then(y=>{r(y),d(!1)}).catch(y=>{console.error("AppStorys: Error loading Lottie thumbnail:",y),d(!0)}):(r(null),d(!1))},[t]);let c={width:i?`${i}px`:o?.width||"100%",height:i?`${i}px`:o?.height||"100%",objectFit:"cover",display:"block",...o};if(n&&!l){let y=ui.default||ui;return(0,nn.jsx)(y,{animationData:n,loop:!0,autoplay:!0,style:c})}return(0,nn.jsx)("img",{src:t,alt:e||"story thumbnail",style:c,onError:()=>d(!0)})};var Ne=require("react/jsx-runtime"),pi=({story:t,isViewed:e,onClick:o})=>{let i=t.styling||{},n=i.size||80,r=i.ringWidth||3,l=e?"#E5E7EB":t.ringColor||"#FF0000",d=t.nameColor||"#333333",c=i.cornerRadius,y=c?`${c.topLeft||0}px ${c.topRight||0}px ${c.bottomRight||0}px ${c.bottomLeft||0}px`:"50%",b=c?`${Math.max(0,(c.topLeft||0)-3)}px ${Math.max(0,(c.topRight||0)-3)}px ${Math.max(0,(c.bottomRight||0)-3)}px ${Math.max(0,(c.bottomLeft||0)-3)}px`:"50%";return(0,Ne.jsxs)("div",{onClick:o,style:{display:"flex",flexDirection:"column",alignItems:"center",cursor:"pointer",flexShrink:0},children:[(0,Ne.jsx)("div",{style:{width:`${n}px`,height:`${n}px`,borderRadius:y,border:`${r}px solid ${l}`,padding:"3px",boxSizing:"border-box",transition:"transform 0.1s ease",overflow:"hidden",backgroundColor:"#f5f5f5"},children:(0,Ne.jsx)(te,{src:t.thumbnail,alt:t.name,style:{borderRadius:b}})}),(0,Ne.jsx)("span",{style:{marginTop:"6px",fontSize:`${i.name?.size||12}px`,fontFamily:mt(i.name?.fontFamily)||"sans-serif",fontWeight:i.name?.font==="Bold"?"bold":"normal",color:d,maxWidth:`${n+10}px`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name})]})};var rn=require("react/jsx-runtime"),gi=({stories:t,viewedStories:e,onStoryClick:o})=>(0,rn.jsx)("div",{style:{display:"flex",gap:"18px",padding:"16px 20px",overflowX:"auto",WebkitOverflowScrolling:"touch",justifyContent:"flex-start"},children:t.sort((i,n)=>i.order-n.order).map((i,n)=>(0,rn.jsx)(pi,{story:i,isViewed:e.includes(i.id),onClick:()=>o(n)},i.id))});var st=ae(require("react"));rt();var G=t=>{if(t){if(typeof t=="string")return t;if(typeof t=="object"){if(typeof t.color=="string")return t.color;if(typeof t.color=="object"&&t.color){let e=G(t.color);if(e)return e}if(typeof t.solid=="string"&&t.solid)return t.solid;if(typeof t.value=="string"&&t.value)return t.value;if(typeof t.hex=="string"&&t.hex)return t.hex}}},gt=t=>{if(!t)return;if(typeof t=="string")return t;if(typeof t=="object"){if(typeof t.solid=="string"&&t.solid)return t.solid;if(typeof t.value=="string"&&t.value)return t.value;if(typeof t.color=="string"&&t.color)return t.color}let e=t.color||{};if(typeof e=="object"&&e&&e.type==="gradient"&&e.gradient){let{direction:o="right",from:i,to:n,stops:r=[]}=e.gradient,d={right:"to right",left:"to left",top:"to top",bottom:"to bottom"}[o]||o;if(r.length>0){let c=r.map(y=>{let b=y.offset,h="0%";if(b!=null){let f=String(b).trim();if(f.endsWith("%"))h=f;else{let v=Number(f);isNaN(v)||(h=v>1?`${v}%`:`${Math.round(v*100)}%`)}}return`${y.color} ${h}`}).join(", ");return`linear-gradient(${d}, ${c})`}return`linear-gradient(${d}, ${i}, ${n})`}return G(t)},To=t=>{if(!t||t.type==="none")return;let e=String(t.type).toLowerCase(),o=t.duration||.6;if(e==="fade")return`appstorys-fade-in ${o}s ease-out forwards`;if(e==="classic")return`appstorys-classic-in ${o}s cubic-bezier(0.34, 1.56, 0.64, 1) forwards`;if(e==="rotate")return`appstorys-rotate-in ${o}s ease-out forwards`;if(e==="bounce")return`appstorys-bounce-in ${o+.2}s cubic-bezier(0.68, -0.6, 0.32, 1.6) forwards`},K=(t,e="px")=>{if(t==null||t==="")return"";let o=String(t).trim();return/^[\d.-]+$/.test(o)?`${o}${e}`:o};var fi=ae(require("react"));var ee=require("react/jsx-runtime"),mi=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=fi.default.useState(()=>{try{return localStorage.getItem(`appstorys_poll_${t.id}`)}catch{return null}}),r=t.layout?.type==="horizontal",l={headerTextColor:"#000000",optionBgColor:"#1A1A1A",optionTextColor:"#FFFFFF",backgroundColor:"#FFFFFF",borderRadius:24,padding:20},d=t.styling||{},c={backgroundColor:d.backgroundColor||l.backgroundColor,borderRadius:K(d.borderRadius??l.borderRadius),overflow:"hidden",boxShadow:d.shadow||"0 12px 24px rgba(0,0,0,0.1)",boxSizing:"border-box",width:"100%",opacity:d.opacity??1,padding:K(d.padding??l.padding),display:"flex",flexDirection:"column",alignItems:"center",gap:"10px"},y={color:d.headerTextColor||l.headerTextColor,textAlign:"center",fontWeight:"800",fontSize:typeof d.fontSize=="string"?`min(${d.fontSize}, 16px)`:`${d.fontSize?Math.min(Number(d.fontSize),16):15}px`,lineHeight:"1.25",margin:"0",width:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},b={display:"flex",flexDirection:r?"row":"column",gap:i&&r?"0px":"4px",width:"100%",backgroundColor:"#1A1A1A",borderRadius:"12px",overflow:"hidden",padding:"0px"},h={backgroundColor:d.optionBgColor||"transparent",color:d.optionTextColor||l.optionTextColor,padding:r?"10px 8px":"10px 14px",fontSize:typeof d.fontSize=="string"?`min(${d.fontSize}, 14px)`:`${d.fontSize?Math.min(Number(d.fontSize),14):13}px`,fontWeight:"700",cursor:i?"default":"pointer",border:"none",width:"100%",textAlign:"center",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.6s cubic-bezier(0.4, 0, 0.2, 1)",flex:1,borderRight:r?"1px solid rgba(255,255,255,0.1)":"none",borderBottom:r?"none":"1px solid rgba(255,255,255,0.1)",position:"relative",overflow:"hidden"},f=Array.isArray(t.options)?t.options:[],v=g=>{let C=f.find(I=>I.id===g);if(!C)return 0;if(C.percentage!==void 0)return C.percentage;if(C.votes!==void 0){let I=f.reduce((z,E)=>z+(E.votes||0),0);if(I>0)return Math.round(C.votes/I*100)}return i?g===i?f.length===1?100:60:Math.round(40/(f.length-1)):0},S=(g,C)=>{let I=g.replace("#","");I.length===3&&(I=I.split("").map(_=>_+_).join(""));let z=parseInt(I.substring(0,2),16)||0,E=parseInt(I.substring(2,4),16)||0,w=parseInt(I.substring(4,6),16)||0;return`rgba(${z}, ${E}, ${w}, ${C})`},u=g=>{let C=g===i,I=C?d.activeResultBarColor:d.inactiveResultBarColor,z=I?.color||(C?"#F97316":"#404040"),E=I?.opacity!==void 0?I.opacity/100:1;return z.startsWith("#")&&(z.length===7||z.length===4)?S(z,E):z},m=g=>{if(!(o||i)){n(g);try{localStorage.setItem(`appstorys_poll_${t.id}`,g)}catch{}e?.({type:"poll",pollId:t.id,optionId:g,stickerId:t.id})}};return(0,ee.jsxs)("div",{style:c,children:[(0,ee.jsx)("h3",{style:y,children:t.question||"Ask A Question..."}),(0,ee.jsx)("div",{style:b,children:f.map((g,C)=>{let I=v(g.id),z=i!==null,E=g.id===i,w=z&&r?u(g.id):d.optionBgColor||"transparent";return(0,ee.jsxs)("button",{style:{...h,flex:z&&r?I:1,backgroundColor:w,borderRight:z||r&&C===f.length-1?"none":h.borderRight,borderBottom:z||!r&&C===f.length-1?"none":h.borderBottom},onClick:()=>m(g.id),disabled:z,onMouseOver:_=>{!o&&!z&&(_.currentTarget.style.backgroundColor="rgba(255,255,255,0.1)")},onMouseOut:_=>{!o&&!z&&(_.currentTarget.style.backgroundColor=d.optionBgColor||"transparent")},children:[z&&!r&&(0,ee.jsx)("div",{style:{position:"absolute",top:0,left:0,bottom:0,width:`${I}%`,backgroundColor:u(g.id),transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)",zIndex:1}}),(0,ee.jsxs)("div",{style:{display:"flex",flexDirection:r?"column":"row",justifyContent:r?"center":"space-between",alignItems:"center",width:"100%",zIndex:2,position:"relative"},children:[(0,ee.jsx)("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:g.text}),z&&(0,ee.jsxs)("span",{style:{fontWeight:"800",fontSize:r?"12px":"15px",marginTop:r?"4px":"0"},children:[I,"%"]})]})]},g.id)})})]})};var yi=require("react");var Se=require("react/jsx-runtime"),hi=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=(0,yi.useState)(()=>{try{return localStorage.getItem(`appstorys_quiz_${t.id}`)}catch{return null}}),r={backgroundColor:"#FFFFFF",borderRadius:20,padding:16,questionTextColor:"#FFFFFF",questionBgColor:"#000000",optionBgColor:"#FFFFFF",optionTextColor:"#2B2B2B",borderColor:"#E5E7EB",activeColor:"#10b981",incorrectColor:"#ef4444",labelBgColor:"#FFFFFF",labelTextColor:"#111111",labelBorderColor:"#111111"},l=t.styling||{},d=K(l.padding??r.padding),y=typeof l.fontSize=="string"?`min(${l.fontSize}, 16px)`:`${l.fontSize?Math.min(Number(l.fontSize),16):15}px`,b=typeof l.optionFontSize=="string",h=K(l.optionFontSize||13),f=K(l.optionBorderRadius||14),v=l.borderColor||r.borderColor,S=b?`max(min(calc(${h} * 1.8), 24px), 16px)`:`${Math.min(Math.max(Math.round(Number(l.optionFontSize||13)*1.8),16),24)}px`,u=b?`max(calc(${S} * 0.08), 1px)`:`${Math.max(Math.round(Number(S.replace("px",""))*.08),1)}px`,m=b?`max(calc(${S} * 0.46), 10px)`:`${Math.max(Math.round(Number(S.replace("px",""))*.46),10)}px`,g=b?`max(calc(${S} * 0.45), 8px)`:`${Math.max(Math.round(Number(S.replace("px",""))*.45),8)}px`,C=b?`calc(${d} * 0.6) calc(${d} * 0.7)`:"11px 14px",I=b?`max(calc(${d} * 0.45), 8px)`:"8px",z={backgroundColor:l.backgroundColor||r.backgroundColor,borderRadius:K(l.borderRadius??r.borderRadius),padding:d,paddingTop:0,paddingBottom:"12px",boxShadow:l.shadow||"0 10px 30px rgba(0,0,0,0.12)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",overflow:"hidden",opacity:l.opacity??1},E={color:l.questionTextColor||r.questionTextColor,backgroundColor:l.questionBgColor||r.questionBgColor,fontWeight:"900",fontSize:y,lineHeight:1.25,margin:`0 calc(-1 * ${d}) 12px calc(-1 * ${d})`,textAlign:"center",padding:`16px ${d}`,borderTopLeftRadius:K(l.borderRadius??r.borderRadius),borderTopRightRadius:K(l.borderRadius??r.borderRadius),letterSpacing:"-0.01em"},w={backgroundColor:l.optionBgColor||r.optionBgColor,color:l.optionTextColor||r.optionTextColor,padding:C,borderRadius:f,border:`1px solid ${v}`,display:"flex",alignItems:"center",gap:g,cursor:i?"default":"pointer",width:"100%",textAlign:"left",boxSizing:"border-box",transition:"all 0.2s ease",boxShadow:"0 1px 2px rgba(15,23,42,0.03)"},_={width:S,height:S,minWidth:S,borderRadius:"50%",backgroundColor:l.labelBgColor||r.labelBgColor,color:l.labelTextColor||r.labelTextColor,border:`${u} solid ${l.labelBorderColor||r.labelBorderColor}`,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"700",fontSize:m},P={backgroundColor:l.backgroundColor||r.backgroundColor,borderRadius:`0 0 ${K(l.borderRadius??r.borderRadius)} ${K(l.borderRadius??r.borderRadius)}`,display:"flex",flexDirection:"column",gap:I},$=a=>{if(!(o||i)){n(a);try{localStorage.setItem(`appstorys_quiz_${t.id}`,a)}catch{}e?.({type:"quiz",quizId:t.id,optionId:a,stickerId:t.id})}},q=["A","B","C","D","E","F"],B=Array.isArray(t.options)?t.options:[];return B.length===0&&!o&&console.warn("AppStorys: QuizSticker has no options!",t.id),(0,Se.jsxs)("div",{style:{...z,background:l.backgroundColor||r.backgroundColor},children:[t.question&&(0,Se.jsx)("h3",{style:E,children:t.question}),(0,Se.jsx)("div",{style:{...P,background:"transparent"},children:B.map((a,x)=>{let s=a.label||q[x]||"\u2022",p=a.id===i,M=a.isCorrect===!0,T={...w},R={..._};return i&&(M?(T.backgroundColor=l.activeColor||r.activeColor,T.borderColor=l.activeColor||r.activeColor,T.color="#FFFFFF"):p&&(T.backgroundColor=l.incorrectColor||r.incorrectColor,T.borderColor=l.incorrectColor||r.incorrectColor,T.color="#FFFFFF")),(0,Se.jsxs)("button",{style:T,onClick:()=>$(a.id),disabled:!!i,children:[(0,Se.jsx)("div",{style:_,className:"letter-circle",children:s}),(0,Se.jsx)("span",{style:{fontWeight:"600",fontSize:h},children:a.text})]},a.id)})})]})};var Fo=require("react");var Ht=require("react/jsx-runtime"),bi=({data:t})=>{let[e,o]=(0,Fo.useState)({days:"00",hours:"00",minutes:"00",seconds:"00"});(0,Fo.useEffect)(()=>{if(!t.targetDate)return;let $=()=>{let B=+new Date(t.targetDate)-+new Date;if(B>0){let a=Math.floor(B/864e5),x=Math.floor(B/(1e3*60*60)%24),s=Math.floor(B/1e3/60%60),p=Math.floor(B/1e3%60);o({days:a.toString().padStart(2,"0"),hours:x.toString().padStart(2,"0"),minutes:s.toString().padStart(2,"0"),seconds:p.toString().padStart(2,"0")})}else o({days:"00",hours:"00",minutes:"00",seconds:"00"})},q=setInterval($,1e3);return $(),()=>clearInterval(q)},[t.targetDate]);let i=t.styling||{},n=t.display||{showDays:!0,showHours:!0,showMinutes:!0,showSeconds:!0},r=i.digitSize||i.fontSize,l=typeof r=="string",d=l?r:`${!isNaN(Number(r))&&Number(r)>0?Number(r):18}px`,c=i.labelFontSize?K(i.labelFontSize):l?`calc(${d} * 0.45)`:`${Math.max(10,Math.round(Number(r||18)*.45))}px`,y=l?`calc(${d} * 1.65)`:`${Math.max(36,Math.round(Number(r||18)*1.65))}px`,b=l?`calc(${d} * 0.95)`:`${Math.max(26,Math.round(Number(r||18)*.95))}px`,h=l?`calc(${d} * 0.25)`:`${Math.max(6,Math.round(Number(r||18)*.25))}px`,f=l?`calc(${d} * 0.15)`:`${Math.max(6,Math.round(Number(r||18)*.15))}px`,v=l?`calc(${d} * 0.75)`:`${Math.max(14,Math.round(Number(r||18)*.75))}px`,S={backgroundColor:i.backgroundColor||"#FFFFFF",borderRadius:K(i.borderRadius!==void 0?i.borderRadius:16),padding:i.padding?K(i.padding):"16px 18px",boxShadow:i.shadow||"0 10px 30px rgba(0,0,0,0.08)",width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",gap:"10px",border:i.borderColor?`1px solid ${i.borderColor}`:"none",overflow:"hidden",opacity:i.opacity??1},u={color:i.titleColor||"#000000",fontWeight:"700",fontSize:K(i.fontSize||14),width:"100%",textAlign:"center",marginBottom:"4px"},m={display:"flex",gap:f,width:"100%",justifyContent:"center",alignItems:"center",flexWrap:"nowrap"},g={display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},C={display:"flex",gap:"2px"},I={backgroundColor:i.digitBackground||"#F1F3F5",borderRadius:h,minWidth:b,height:y,display:"flex",alignItems:"center",justifyContent:"center",fontSize:d,fontWeight:"bold",color:i.digitColor||"#1A202C",padding:"0 4px"},z={fontSize:l?c:`${Math.max(9,Number(String(c).replace("px","")))}px`,color:i.labelColor||"#A0AEC0",fontWeight:"600",textTransform:"lowercase"},E={fontSize:v,fontWeight:"700",color:i.labelColor||"#A0AEC0",display:"flex",alignItems:"center",lineHeight:1},w=($,q)=>(0,Ht.jsxs)("div",{style:g,children:[(0,Ht.jsx)("div",{style:C,children:$.split("").map((B,a)=>(0,Ht.jsx)("div",{style:I,children:B},a))}),(0,Ht.jsx)("span",{style:z,children:q})]}),_=[],P=0;return n.showDays!==!1&&(_.push(w(e.days,"days")),P++),n.showHours!==!1&&(P>0&&_.push((0,Ht.jsx)("div",{style:E,children:":"},"sep-h")),_.push(w(e.hours,"hours")),P++),n.showMinutes!==!1&&(P>0&&_.push((0,Ht.jsx)("div",{style:E,children:":"},"sep-m")),_.push(w(e.minutes,"minutes")),P++),n.showSeconds!==!1&&(P>0&&_.push((0,Ht.jsx)("div",{style:E,children:":"},"sep-s")),_.push(w(e.seconds,"seconds")),P++),(0,Ht.jsxs)("div",{style:S,children:[t.title&&(0,Ht.jsx)("div",{style:u,children:t.title}),(0,Ht.jsx)("div",{style:m,children:_})]})};var xi=require("react"),qt=require("react/jsx-runtime"),Si=({data:t,onInteraction:e})=>{let[o,i]=(0,xi.useState)(!1),n=b=>{b.stopPropagation(),t.code&&(navigator.clipboard.writeText(t.code).catch(()=>{}),i(!0),e?.({type:"promo_code",value:"copied",stickerId:t.id,code:t.code}),setTimeout(()=>i(!1),2e3))},r=t.styling||{},d={backgroundColor:r.backgroundColor||"#F4F4F6",padding:"8px 16px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",minHeight:"44px",boxSizing:"border-box",position:"relative",boxShadow:r.shadow||"0 4px 16px rgba(0,0,0,0.08)",cursor:"pointer",WebkitMaskImage:"radial-gradient(circle at 0px 50%, transparent 6px, black 6.5px), radial-gradient(circle at 100% 50%, transparent 6px, black 6.5px)",maskImage:"radial-gradient(circle at 0px 50%, transparent 6px, black 6.5px), radial-gradient(circle at 100% 50%, transparent 6px, black 6.5px)",WebkitMaskComposite:"destination-in",maskComposite:"intersect"};return(0,qt.jsxs)("div",{style:d,onClick:n,children:[(0,qt.jsx)("div",{style:{width:"26px",height:"26px",borderRadius:"6px",backgroundColor:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",fontWeight:"900",color:"#000000",border:"1.8px solid #000000",flexShrink:0},children:"%"}),(0,qt.jsx)("div",{style:{flex:1,minWidth:0,padding:"0 8px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,qt.jsx)("span",{style:{fontSize:"13px",fontWeight:"700",color:o?"#10B981":"#000000",fontFamily:'"SF Mono", "Roboto Mono", Menlo, Consolas, "Courier New", monospace',letterSpacing:"0.5px",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block",width:"100%",transition:"color 0.2s ease"},children:o?"Copied!":t.code||"OFFER20"})}),(0,qt.jsx)("div",{style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderLeft:"1.5px dashed rgba(0,0,0,0.2)",paddingLeft:"10px",marginLeft:"4px",height:"24px"},children:o?(0,qt.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#10B981",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,qt.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,qt.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[(0,qt.jsx)("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"}),(0,qt.jsx)("rect",{x:"4",y:"4",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"})]})})]})};var oo=require("react"),Be=require("react/jsx-runtime"),Ci=({data:t,onInteraction:e,isEditing:o=!1})=>{let i={emojis:["\u{1F60D}","\u{1F44D}"]},n=Array.isArray(t.emojis)?t.emojis:Array.isArray(i.emojis)?i.emojis:[],[r,l]=(0,oo.useState)(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)!==null}catch{return!1}}),[d,c]=(0,oo.useState)({});(0,oo.useEffect)(()=>{let u={},m=(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)}catch{return null}})();n.forEach(g=>{let C=Math.random()>.5?1999:2e3;m&&g===m&&(C+=1),u[g]=C}),c(u)},[t.emojis]);let y=(u,m)=>{if(!(o||r)){c(g=>({...g,[u]:(g[u]||0)+1})),l(!0);try{localStorage.setItem(`appstorys_reaction_${t.id}`,u)}catch{}e?.({type:"reaction",reactionId:t.id,optionId:`option${m+1}`,selected_option:`option${m+1}`,emoji:u,stickerId:t.id})}},b=u=>u>=1e3?(u/1e3).toFixed(0)+"k":String(u),h={display:"flex",gap:"12px",justifyContent:"center",alignItems:"center",width:"100%",padding:"12px",boxSizing:"border-box"},f={backgroundColor:"#FFFFFF",width:"60px",height:r?"90px":"60px",borderRadius:"100px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:r?"space-between":"center",padding:r?"10px 0":"0",boxShadow:"0 8px 30px rgba(0,0,0,0.12)",cursor:o||r?"default":"pointer",border:"none",outline:"none",position:"relative",zIndex:1,boxSizing:"border-box",flexShrink:0},v={fontSize:"35px",lineHeight:"1",userSelect:"none"},S={fontSize:"13px",fontWeight:"800",color:"#374151",animation:"appstorys-reaction-fade-in 0.3s ease forwards",lineHeight:"1",userSelect:"none",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'};return(0,Be.jsxs)("div",{style:h,children:[(0,Be.jsx)("style",{children:`
33
+ `,document.head.appendChild(t)}function Mi(t){let e=document.createElement("div");return e.className="appstorys-widget-debug-pill",e.textContent=t,e}function Ss(t){let e=t,o=getComputedStyle(e);(o.position==="static"||!o.position)&&(e.style.position="relative")}window.AppStorysShowWidgetElements=function(){try{xs();let e=Array.from(document.querySelectorAll("[data-as-id], [data-widget], [data-widget-id]"));if(e.length||["#hero_section",".hero_section","#header_container",".header_container"].forEach(n=>{let i=document.querySelector(n);i&&e.push(i)}),!e.length){let o=Mi("Widget");o.style.position="fixed",o.style.top="12px",o.style.left="12px",o.style.pointerEvents="auto",document.body.appendChild(o);return}e.forEach((o,n)=>{let i=o;Ss(i),i.classList.add("appstorys-widget-debug-overlay");let s=i.querySelector(".appstorys-widget-debug-pill");s&&s.remove();let l=Mi("Widget "+(n+1));i.appendChild(l)})}catch(e){console.error("AppStorysShowWidgetElements error",e)}};var $e=ge(require("react"));bt();var Io=require("react"),lo=ge(require("lottie-react")),Mn=require("react/jsx-runtime"),Pi=lo.default?.default??lo.default??lo.Lottie??lo,ke=({src:t,alt:e,style:o,size:n})=>{let[i,s]=(0,Io.useState)(null),[l,c]=(0,Io.useState)(!1);(0,Io.useEffect)(()=>{t&&t.toLowerCase().endsWith(".json")?fetch(t).then(y=>{if(!y.ok)throw new Error("Failed to fetch Lottie");return y.json()}).then(y=>{s(y),c(!1)}).catch(y=>{console.error("AppStorys: Error loading Lottie thumbnail:",y),c(!0)}):(s(null),c(!1))},[t]);let d={width:n?`${n}px`:o?.width||"100%",height:n?`${n}px`:o?.height||"100%",objectFit:"cover",display:"block",...o},S=o?.objectFit||"cover",p=S==="contain"?"xMidYMid meet":S==="fill"?"none":"xMidYMid slice";if(i&&!l){let y=Pi.default||Pi;return(0,Mn.jsx)(y,{animationData:i,loop:!0,autoplay:!0,style:d,rendererSettings:{preserveAspectRatio:p}})}return(0,Mn.jsx)("img",{src:t,alt:e||"story thumbnail",style:d,onError:()=>c(!0)})};var co=require("react/jsx-runtime"),Di=({story:t,isViewed:e,onClick:o})=>{let n=t.styling||{},i=n.size||80,s=n.ringWidth!==void 0?n.ringWidth:3,l=n.ringAndImageSpace!==void 0?n.ringAndImageSpace:3,c=e?"#E5E7EB":t.ringColor||"#FF0000",d=t.nameColor||"#333333",S=n.storyGroupText||t.name,p=n.cornerRadius,y=p?`${p.topLeft||0}px ${p.topRight||0}px ${p.bottomRight||0}px ${p.bottomLeft||0}px`:"50%",u=p?`${Math.max(0,(p.topLeft||0)-s)}px ${Math.max(0,(p.topRight||0)-s)}px ${Math.max(0,(p.bottomRight||0)-s)}px ${Math.max(0,(p.bottomLeft||0)-s)}px`:"50%",h=lt(n.name?.fontFamily||n.name?.font)||n.name?.fontFamily||(n.name?.font&&n.name.font!=="Bold"&&n.name.font!=="Normal"?n.name.font:void 0)||"sans-serif",g=n.name?.font==="Bold"||n.name?.font==="bold"||n.name?.font?.toLowerCase()?.includes("bold");return(0,co.jsxs)("div",{onClick:o,style:{display:"flex",flexDirection:"column",alignItems:"center",cursor:"pointer",flexShrink:0},children:[(0,co.jsx)("div",{style:{width:`${i}px`,height:`${i}px`,borderRadius:y,border:`${s}px solid ${c}`,padding:`${l}px`,boxSizing:"border-box",transition:"transform 0.1s ease",overflow:"hidden",backgroundColor:"#f5f5f5"},children:(0,co.jsx)(ke,{src:t.thumbnail,alt:S,style:{borderRadius:u}})}),(0,co.jsx)("span",{style:{marginTop:"6px",fontSize:`${n.name?.size||12}px`,fontFamily:h,fontWeight:g?"bold":"normal",color:d,maxWidth:`${i+20}px`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textAlign:"center"},children:S})]})};var Pn=require("react/jsx-runtime"),_i=({stories:t,viewedStories:e,onStoryClick:o})=>(0,Pn.jsx)("div",{style:{display:"flex",gap:"18px",padding:"16px 20px",overflowX:"auto",WebkitOverflowScrolling:"touch",justifyContent:"flex-start"},children:t.sort((n,i)=>n.order-i.order).map((n,i)=>(0,Pn.jsx)(Di,{story:n,isViewed:e.includes(n.id),onClick:()=>o(i)},n.id))});var yt=ge(require("react"));bt();bt();var Wi=()=>P.getState().trackingUrl||"https://tracking.appstorys.co";var Eo=require("react"),po=ge(require("lottie-react"));var et=t=>{if(t){if(typeof t=="string")return t;if(typeof t=="object"){if(typeof t.color=="string")return t.color;if(typeof t.color=="object"&&t.color){let e=et(t.color);if(e)return e}if(typeof t.solid=="string"&&t.solid)return t.solid;if(typeof t.value=="string"&&t.value)return t.value;if(typeof t.hex=="string"&&t.hex)return t.hex}}},Ct=t=>{if(!t)return;if(typeof t=="string")return t;if(typeof t=="object"){if(typeof t.solid=="string"&&t.solid)return t.solid;if(typeof t.value=="string"&&t.value)return t.value;if(typeof t.color=="string"&&t.color)return t.color}let e=t.color||{};if(typeof e=="object"&&e&&e.type==="gradient"&&e.gradient){let{direction:o="right",from:n,to:i,stops:s=[]}=e.gradient,c={right:"to right",left:"to left",top:"to top",bottom:"to bottom"}[o]||o;if(s.length>0){let d=s.map(S=>{let p=S.offset,y="0%";if(p!=null){let u=String(p).trim();if(u.endsWith("%"))y=u;else{let C=Number(u);isNaN(C)||(y=C>1?`${C}%`:`${Math.round(C*100)}%`)}}return`${S.color} ${y}`}).join(", ");return`linear-gradient(${c}, ${d})`}return`linear-gradient(${c}, ${n}, ${i})`}return et(t)},Bo=t=>{if(!t||t.type==="none")return;let e=String(t.type).toLowerCase(),o=t.duration||.6;if(e==="fade")return`appstorys-fade-in ${o}s ease-out forwards`;if(e==="classic")return`appstorys-classic-in ${o}s cubic-bezier(0.34, 1.56, 0.64, 1) forwards`;if(e==="rotate")return`appstorys-rotate-in ${o}s ease-out forwards`;if(e==="bounce")return`appstorys-bounce-in ${o+.2}s cubic-bezier(0.68, -0.6, 0.32, 1.6) forwards`},nt=(t,e="px")=>{if(t==null||t==="")return"";let o=String(t).trim();return/^[\d.-]+$/.test(o)?`${o}${e}`:o},uo=t=>{if(!t||typeof t!="string")return"center center";let e=t.trim().toLowerCase().replace(/_/g,"-");switch(e){case"top-left":case"left-top":return"top left";case"top-center":case"center-top":case"top":return"top center";case"top-right":case"right-top":return"top right";case"center-left":case"left-center":case"left":return"center left";case"center":case"center-center":return"center center";case"center-right":case"right-center":case"right":return"center right";case"bottom-left":case"left-bottom":return"bottom left";case"bottom-center":case"center-bottom":case"bottom":return"bottom center";case"bottom-right":case"right-bottom":return"bottom right";default:return e.replace("-"," ")}};var $i=ge(require("react"));var Re=require("react/jsx-runtime"),Ni=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=$i.default.useState(()=>{try{return localStorage.getItem(`appstorys_poll_${t.id}`)}catch{return null}}),s=t.layout?.type==="horizontal",l={headerTextColor:"#000000",optionBgColor:"#1A1A1A",optionTextColor:"#FFFFFF",backgroundColor:"#FFFFFF",borderRadius:20,padding:12},c=t.styling||{},d=lt(c.questionFontFamily||c.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),S=lt(c.optionFontFamily||c.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),p=c.optionBorderRadius??c.optionRadius,y=p!==void 0?nt(p):"9999px",u=c.optionBgColor||"#1A1A1A",C={backgroundColor:c.backgroundColor||l.backgroundColor,borderRadius:nt(c.borderRadius??l.borderRadius),overflow:"hidden",boxShadow:c.shadow||"0 12px 24px rgba(0,0,0,0.1)",boxSizing:"border-box",width:"100%",maxWidth:"280px",margin:"0 auto",opacity:c.opacity??1,padding:"14px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"10px"},h={color:c.headerTextColor||l.headerTextColor,textAlign:"center",fontWeight:"700",fontSize:nt(c.fontSize||14),lineHeight:"1.25",margin:"0",width:"100%",fontFamily:d},g={display:"flex",flexDirection:s?"row":"column",gap:s?n?"0px":"4px":nt(c.gap??8),width:"100%",backgroundColor:s?u:"transparent",borderRadius:s?nt(y):"0px",overflow:s?"hidden":"visible",padding:"0px"},b={backgroundColor:s?"transparent":u,color:c.optionTextColor||l.optionTextColor,padding:s?"8px 12px":"10px 16px",fontSize:nt(c.optionFontSize||14),fontWeight:"700",fontFamily:S,cursor:n?"default":"pointer",border:"none",borderRadius:s?"0px":nt(y),width:"100%",textAlign:"center",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)",flex:s?1:void 0,borderRight:s?"1px solid rgba(255,255,255,0.1)":"none",borderBottom:"none",position:"relative",overflow:"hidden"},m=Array.isArray(t.options)?t.options:[],E=v=>{let w=m.find(_=>_.id===v);if(!w)return 0;if(w.percentage!==void 0)return w.percentage;if(w.votes!==void 0){let _=m.reduce((N,U)=>N+(U.votes||0),0);if(_>0)return Math.round(w.votes/_*100)}return n?v===n?m.length===1?100:60:Math.round(40/(m.length-1)):0},j=(v,w)=>{let _=v.replace("#","");_.length===3&&(_=_.split("").map(T=>T+T).join(""));let N=parseInt(_.substring(0,2),16)||0,U=parseInt(_.substring(2,4),16)||0,A=parseInt(_.substring(4,6),16)||0;return`rgba(${N}, ${U}, ${A}, ${w})`},D=v=>{let w=v===n,_=w?c.activeResultBarColor:c.inactiveResultBarColor,N=_?.color||(w?"#F97316":"#404040"),U=_?.opacity!==void 0?_.opacity/100:1;return N.startsWith("#")&&(N.length===7||N.length===4)?j(N,U):N},L=v=>{if(!(o||n)){i(v);try{localStorage.setItem(`appstorys_poll_${t.id}`,v)}catch{}e?.({type:"poll",pollId:t.id,optionId:v,stickerId:t.id})}};return(0,Re.jsxs)("div",{style:C,children:[(0,Re.jsx)("h3",{style:h,children:t.question||"Ask A Question..."}),(0,Re.jsx)("div",{style:g,children:m.map((v,w)=>{let _=E(v.id),N=n!==null,U=v.id===n,A=N?s?D(v.id):u:s?"transparent":u;return(0,Re.jsxs)("button",{style:{...b,flex:N&&s?_:s?1:void 0,backgroundColor:A,borderRight:N||s&&w===m.length-1?"none":b.borderRight},onClick:()=>L(v.id),disabled:N,onMouseOver:T=>{!o&&!N&&!s&&(T.currentTarget.style.opacity="0.9")},onMouseOut:T=>{!o&&!N&&!s&&(T.currentTarget.style.opacity="1")},children:[N&&!s&&(0,Re.jsx)("div",{style:{position:"absolute",top:0,left:0,bottom:0,width:`${_}%`,backgroundColor:D(v.id),transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)",zIndex:1,borderRadius:"inherit"}}),(0,Re.jsxs)("div",{style:{display:"flex",flexDirection:s?"column":"row",justifyContent:s?"center":"space-between",alignItems:"center",width:"100%",zIndex:2,position:"relative"},children:[(0,Re.jsx)("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.text}),N&&(0,Re.jsxs)("span",{style:{fontWeight:"800",fontSize:s?"12px":"15px",marginTop:s?"4px":"0"},children:[_,"%"]})]})]},v.id)})})]})};var Oi=require("react");var jt=require("react/jsx-runtime"),ji=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=(0,Oi.useState)(()=>{try{return localStorage.getItem(`appstorys_quiz_${t.id}`)}catch{return null}}),s={backgroundColor:"#FFFFFF",borderRadius:28,padding:16,questionTextColor:"#FFFFFF",questionBgColor:"#000000",optionBgColor:"#F8FAFC",optionTextColor:"#1E293B",borderColor:"#000000",activeColor:"#10b981",incorrectColor:"#ef4444",labelBgColor:"#FFFFFF",labelTextColor:"#111111",labelBorderColor:"#111111"},l=t.styling||{},c=nt(l.padding??s.padding),d=nt(l.fontSize||16),S=nt(l.optionFontSize||15),p=l.optionBorderRadius!==void 0?nt(l.optionBorderRadius):"9999px",y=l.optionBorderColor||"#CBD5E1",u=lt(l.questionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),C=lt(l.optionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),h={backgroundColor:l.backgroundColor||s.backgroundColor,borderRadius:nt(l.borderRadius??s.borderRadius),padding:0,boxShadow:l.shadow||"0 12px 32px rgba(0,0,0,0.14)",boxSizing:"border-box",width:"100%",maxWidth:"270px",margin:"0 auto",display:"flex",flexDirection:"column",overflow:"hidden",opacity:l.opacity??1},g={color:l.questionTextColor||s.questionTextColor,backgroundColor:l.questionBgColor||s.questionBgColor,fontWeight:"700",fontSize:d,fontFamily:u,lineHeight:1.3,margin:0,textAlign:"center",padding:"14px 16px",minHeight:"48px",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",borderTopLeftRadius:nt(l.borderRadius??s.borderRadius),borderTopRightRadius:nt(l.borderRadius??s.borderRadius),letterSpacing:"-0.01em"},b={backgroundColor:l.optionBgColor||s.optionBgColor,color:l.optionTextColor||s.optionTextColor,fontFamily:C,padding:"8px 14px",borderRadius:p,border:`1px solid ${y}`,display:"flex",alignItems:"center",justifyContent:"flex-start",cursor:n?"default":"pointer",width:"100%",textAlign:"left",boxSizing:"border-box",transition:"all 0.2s ease",fontSize:S,fontWeight:"500"},m={backgroundColor:l.backgroundColor||s.backgroundColor,borderRadius:`0 0 ${nt(l.borderRadius??s.borderRadius)} ${nt(l.borderRadius??s.borderRadius)}`,display:"flex",flexDirection:"column",gap:"6px",padding:"10px 14px 12px 14px"},E=_=>{if(!(o||n)){i(_);try{localStorage.setItem(`appstorys_quiz_${t.id}`,_)}catch{}e?.({type:"quiz",quizId:t.id,optionId:_,stickerId:t.id})}},j=["A","B","C","D","E","F"],D=Array.isArray(t.options)?t.options:[];D.length===0&&!o&&console.warn("AppStorys: QuizSticker has no options!",t.id);let L=D.find(_=>_.id===n),v=L?L.isCorrect===!0:!1,w=!!n&&t.showExplanation!==!1&&!!t.explanation;return(0,jt.jsxs)("div",{style:{...h,background:l.backgroundColor||s.backgroundColor},children:[(0,jt.jsx)("style",{children:`
34
+ @keyframes appstorys-quiz-fade-in {
35
+ from { opacity: 0; transform: translateY(4px); }
36
+ to { opacity: 1; transform: translateY(0); }
37
+ }
38
+ `}),t.question&&(0,jt.jsx)("h3",{style:g,children:t.question}),(0,jt.jsxs)("div",{style:{...m,background:"transparent"},children:[D.map((_,N)=>{let U=_.label||j[N]||"\u2022",A=_.id===n,T=_.isCorrect===!0,k={...b};return n&&(T?(k.backgroundColor=l.activeColor||s.activeColor,k.borderColor=l.activeColor||s.activeColor,k.color="#FFFFFF"):A&&(k.backgroundColor=l.incorrectColor||s.incorrectColor,k.borderColor=l.incorrectColor||s.incorrectColor,k.color="#FFFFFF")),(0,jt.jsx)("button",{style:k,onClick:()=>E(_.id),disabled:!!n,children:(0,jt.jsx)("span",{style:{fontWeight:"600",fontSize:S},children:_.text})},_.id)}),w&&(0,jt.jsxs)("div",{style:{marginTop:"8px",padding:"12px 14px",backgroundColor:v?"#E6F4EA":"#FCE8E6",borderRadius:"12px",border:`1px solid ${v?"rgba(16, 185, 129, 0.3)":"rgba(239, 68, 68, 0.3)"}`,display:"flex",flexDirection:"column",gap:"4px",textAlign:"left",animation:"appstorys-quiz-fade-in 0.3s ease forwards"},children:[(0,jt.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[v?(0,jt.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",style:{flexShrink:0},children:[(0,jt.jsx)("circle",{cx:"10",cy:"10",r:"10",fill:"#10B981"}),(0,jt.jsx)("path",{d:"M6 10L9 13L14 7",stroke:"white",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})]}):(0,jt.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",style:{flexShrink:0},children:[(0,jt.jsx)("circle",{cx:"10",cy:"10",r:"10",fill:"#EF4444"}),(0,jt.jsx)("path",{d:"M7 7L13 13M13 7L7 13",stroke:"white",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})]}),(0,jt.jsx)("span",{style:{fontWeight:"700",fontSize:"14px",color:v?"#0ABA73":"#EF4444",fontFamily:C},children:v?"Correct":"Incorrect"})]}),(0,jt.jsx)("div",{style:{fontSize:"13px",color:"#374151",fontFamily:C,lineHeight:"1.4",paddingLeft:"26px",wordBreak:"break-word"},children:t.explanation})]})]})]})};var tn=require("react");var le=require("react/jsx-runtime"),qi=({data:t})=>{let[e,o]=(0,tn.useState)({days:"00",hours:"00",minutes:"00",seconds:"00"});(0,tn.useEffect)(()=>{if(!t.targetDate)return;let U=()=>{let T=+new Date(t.targetDate)-+new Date;if(T>0){let k=Math.floor(T/864e5),B=Math.floor(T/(1e3*60*60)%24),$=Math.floor(T/1e3/60%60),V=Math.floor(T/1e3%60);o({days:k.toString().padStart(2,"0"),hours:B.toString().padStart(2,"0"),minutes:$.toString().padStart(2,"0"),seconds:V.toString().padStart(2,"0")})}else o({days:"00",hours:"00",minutes:"00",seconds:"00"})},A=setInterval(U,1e3);return U(),()=>clearInterval(A)},[t.targetDate]);let n=t.styling||{},i=t.display||{showDays:!0,showHours:!0,showMinutes:!0,showSeconds:!0},s=lt(n.questionFontFamily||n.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),l=n.digitSize||n.fontSize,c=typeof l=="string",d=c?l:`${!isNaN(Number(l))&&Number(l)>0?Number(l):18}px`,S=n.labelFontSize?nt(n.labelFontSize):c?`calc(${d} * 0.45)`:`${Math.max(10,Math.round(Number(l||18)*.45))}px`,p=c?`calc(${d} * 1.65)`:`${Math.max(36,Math.round(Number(l||18)*1.65))}px`,y=c?`calc(${d} * 0.95)`:`${Math.max(26,Math.round(Number(l||18)*.95))}px`,u=c?`calc(${d} * 0.25)`:`${Math.max(6,Math.round(Number(l||18)*.25))}px`,C=c?`calc(${d} * 0.15)`:`${Math.max(6,Math.round(Number(l||18)*.15))}px`,h=c?`calc(${d} * 0.75)`:`${Math.max(14,Math.round(Number(l||18)*.75))}px`,g={backgroundColor:n.backgroundColor||"#FFFFFF",borderRadius:nt(n.borderRadius!==void 0?n.borderRadius:16),padding:n.padding?nt(n.padding):"16px 18px",boxShadow:n.shadow||"0 10px 30px rgba(0,0,0,0.08)",width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",gap:"10px",border:n.borderColor?`1px solid ${n.borderColor}`:"none",overflow:"hidden",opacity:n.opacity??1},b={color:n.titleColor||"#000000",fontWeight:"700",fontSize:nt(n.fontSize||14),fontFamily:s,width:"100%",textAlign:"center",marginBottom:"4px"},m={display:"flex",gap:C,width:"100%",justifyContent:"center",alignItems:"center",flexWrap:"nowrap"},E={display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},j={display:"flex",gap:"2px"},D={backgroundColor:n.digitBackground||"#F1F3F5",borderRadius:u,minWidth:y,height:p,display:"flex",alignItems:"center",justifyContent:"center",fontSize:d,fontWeight:"bold",color:n.digitColor||"#1A202C",padding:"0 4px"},L={fontSize:c?S:`${Math.max(9,Number(String(S).replace("px","")))}px`,color:n.labelColor||"#A0AEC0",fontWeight:"600",textTransform:"lowercase"},v={fontSize:h,fontWeight:"700",color:n.labelColor||"#A0AEC0",display:"flex",alignItems:"center",lineHeight:1},w=(U,A)=>(0,le.jsxs)("div",{style:E,children:[(0,le.jsx)("div",{style:j,children:U.split("").map((T,k)=>(0,le.jsx)("div",{style:D,children:T},k))}),(0,le.jsx)("span",{style:L,children:A})]}),_=[],N=0;return i.showDays!==!1&&(_.push(w(e.days,"days")),N++),i.showHours!==!1&&(N>0&&_.push((0,le.jsx)("div",{style:v,children:":"},"sep-h")),_.push(w(e.hours,"hours")),N++),i.showMinutes!==!1&&(N>0&&_.push((0,le.jsx)("div",{style:v,children:":"},"sep-m")),_.push(w(e.minutes,"minutes")),N++),i.showSeconds!==!1&&(N>0&&_.push((0,le.jsx)("div",{style:v,children:":"},"sep-s")),_.push(w(e.seconds,"seconds")),N++),(0,le.jsxs)("div",{style:g,children:[t.title&&(0,le.jsx)("div",{style:b,children:t.title}),(0,le.jsx)("div",{style:m,children:_})]})};var Hi=require("react");var de=require("react/jsx-runtime"),Vi=({data:t,onInteraction:e})=>{let[o,n]=(0,Hi.useState)(!1),i=y=>{y.stopPropagation(),t.code&&(navigator.clipboard.writeText(t.code).catch(()=>{}),n(!0),e?.({type:"promo_code",value:"copied",stickerId:t.id,code:t.code}),setTimeout(()=>n(!1),2e3))},s=t.styling||{},l=s.backgroundColor||"#F4F4F6",c=lt(s.fontFamily,'"SF Mono", "Roboto Mono", Menlo, Consolas, "Courier New", monospace'),d={backgroundColor:l,padding:"6px 14px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",minHeight:"36px",boxSizing:"border-box",position:"relative",boxShadow:s.shadow||"0 4px 16px rgba(0,0,0,0.08)",cursor:"pointer",WebkitMaskImage:"radial-gradient(circle at 0px 50%, transparent 6px, black 6.5px), radial-gradient(circle at 100% 50%, transparent 6px, black 6.5px)",maskImage:"radial-gradient(circle at 0px 50%, transparent 6px, black 6.5px), radial-gradient(circle at 100% 50%, transparent 6px, black 6.5px)",WebkitMaskComposite:"destination-in",maskComposite:"intersect"};return(0,de.jsxs)("div",{style:d,onClick:i,children:[(0,de.jsx)("div",{style:{width:"26px",height:"26px",borderRadius:"6px",backgroundColor:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",fontWeight:"900",color:"#000000",border:"1.8px solid #000000",flexShrink:0},children:"%"}),(0,de.jsx)("div",{style:{flex:1,minWidth:0,padding:"0 8px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,de.jsx)("span",{style:{fontSize:"13px",fontWeight:"700",color:o?"#10B981":"#000000",fontFamily:c,letterSpacing:"0.5px",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block",width:"100%",transition:"color 0.2s ease"},children:o?"Copied!":t.code||"OFFER20"})}),(0,de.jsx)("div",{style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderLeft:"1.5px dashed rgba(0,0,0,0.2)",paddingLeft:"10px",marginLeft:"4px",height:"24px"},children:o?(0,de.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#10B981",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,de.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,de.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[(0,de.jsx)("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"}),(0,de.jsx)("rect",{x:"4",y:"4",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"})]})})]})};var Lo=require("react");var Ze=require("react/jsx-runtime"),Ui=({data:t,onInteraction:e,isEditing:o=!1})=>{let n={emojis:["\u{1F60D}","\u{1F44D}"]},i=Array.isArray(t.emojis)?t.emojis:Array.isArray(n.emojis)?n.emojis:[],[s,l]=(0,Lo.useState)(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)!==null}catch{return!1}}),[c,d]=(0,Lo.useState)({});(0,Lo.useEffect)(()=>{let g={},b=(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)}catch{return null}})();i.forEach(m=>{let E=Math.random()>.5?1999:2e3;b&&m===b&&(E+=1),g[m]=E}),d(g)},[t.emojis]);let S=(g,b)=>{if(!(o||s)){d(m=>({...m,[g]:(m[g]||0)+1})),l(!0);try{localStorage.setItem(`appstorys_reaction_${t.id}`,g)}catch{}e?.({type:"reaction",reactionId:t.id,optionId:`option${b+1}`,selected_option:`option${b+1}`,emoji:g,stickerId:t.id})}},p=g=>g>=1e3?(g/1e3).toFixed(0)+"k":String(g),y={display:"flex",gap:"10px",justifyContent:"center",alignItems:"center",width:"100%",padding:"6px",boxSizing:"border-box"},u={backgroundColor:"#FFFFFF",width:"52px",height:s?"72px":"52px",borderRadius:"100px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:s?"space-between":"center",padding:s?"6px 0":"0",boxShadow:"0 8px 30px rgba(0,0,0,0.12)",cursor:o||s?"default":"pointer",border:"none",outline:"none",position:"relative",zIndex:1,boxSizing:"border-box",flexShrink:0},C={fontSize:"28px",lineHeight:"1",userSelect:"none"},h={fontSize:"13px",fontWeight:"800",color:"#374151",animation:"appstorys-reaction-fade-in 0.3s ease forwards",lineHeight:"1",userSelect:"none",fontFamily:lt(t.styling?.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif')};return(0,Ze.jsxs)("div",{style:y,children:[(0,Ze.jsx)("style",{children:`
34
39
  @keyframes appstorys-reaction-fade-in {
35
40
  from { opacity: 0; transform: translateY(4px); }
36
41
  to { opacity: 1; transform: translateY(0); }
@@ -44,7 +49,7 @@
44
49
  .appstorys-reaction-btn.voted {
45
50
  transform: scale(1) translateY(0) !important;
46
51
  }
47
- `}),n.map((u,m)=>{let g=d[u]||2e3;return(0,Be.jsxs)("button",{className:`appstorys-reaction-btn ${r?"voted":""} ${o?"editing":""}`,style:f,onClick:()=>y(u,m),children:[(0,Be.jsx)("span",{style:v,children:u}),r&&(0,Be.jsx)("span",{style:S,children:b(g)})]},m)})]})};var ce=require("react");var ue=require("react/jsx-runtime"),vi=({data:t,onInteraction:e,isEditing:o=!1})=>{let i=t.maxRating||5,n=t.currentRating??Math.floor(i/2),[r,l]=(0,ce.useState)(()=>{try{let x=localStorage.getItem(`appstorys_rating_${t.id}`);return x?Number(x):n}catch{return n}}),d=(0,ce.useRef)(null),[c,y]=(0,ce.useState)(!1),[b,h]=(0,ce.useState)(()=>{try{return localStorage.getItem(`appstorys_rating_${t.id}`)!==null}catch{return!1}}),[f,v]=(0,ce.useState)([]),S={backgroundColor:"#FFFFFF",borderRadius:20,padding:14,titleColor:"#000000",titleFontSize:15,sliderTrackColor:"#F3F4F6",sliderFillColor:"#F97316",emojiSize:32},u=t.styling||{},m={backgroundColor:u.backgroundColor||S.backgroundColor,borderRadius:K(u.borderRadius??S.borderRadius),padding:u.padding?K(u.padding):"12px 14px",boxShadow:u.shadow||"0 10px 24px rgba(0,0,0,0.08)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",cursor:"default",opacity:u.opacity??1},g={color:u.titleColor||S.titleColor,fontWeight:"700",fontSize:typeof u.titleFontSize=="string"?`min(${u.titleFontSize}, 16px)`:`${u.titleFontSize?Math.min(Number(u.titleFontSize),16):15}px`,margin:"0",textAlign:"center",lineHeight:"1.25",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:"100%"},C={width:"100%",height:"16px",backgroundColor:u.sliderTrackColor||S.sliderTrackColor,borderRadius:"100px",position:"relative",cursor:o||b?"default":"pointer",marginTop:"4px",marginBottom:"2px",userSelect:"none"},I=r/i*100,z={width:`${I}%`,height:"100%",background:u.sliderFillColor||"linear-gradient(90deg, #FF4582, #e11d48)",borderRadius:"100px",transition:c?"none":"width 0.1s ease"},E=u.emojiSize||S.emojiSize,w=typeof E=="string",_=K(E),P={position:"absolute",left:w?`calc(${I}% - calc(${_} / 2))`:`calc(${I}% - ${Number(E)/2}px)`,top:w?`calc(50% - calc(${_} / 2))`:`calc(50% - ${Number(E)/2}px)`,fontSize:_,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",cursor:b||o?"default":"grab",transition:c?"none":"left 0.1s ease",filter:"drop-shadow(0 4px 8px rgba(0,0,0,0.2))",animation:b?"thumbPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards":"none"},$=x=>{if(!d.current||o||b)return;let s=d.current.getBoundingClientRect(),p=x-s.left;p<0&&(p=0),p>s.width&&(p=s.width);let M=p/s.width,T=Math.round(M*i*10)/10;l(T)},q=x=>{o||b||(y(!0),$(x.clientX))},B=x=>{o||b||(y(!0),$(x.touches[0].clientX))},a=()=>{let x=Array.from({length:16}).map((s,p)=>({id:Date.now()+p,scale:.5+Math.random()*.8,angle:p*22.5+(Math.random()*15-7.5),delay:Math.random()*.1}));v(x),setTimeout(()=>{v([])},1200)};return(0,ce.useEffect)(()=>{let x=M=>{c&&$(M.clientX)},s=()=>{if(c){y(!1),h(!0);try{localStorage.setItem(`appstorys_rating_${t.id}`,String(r))}catch{}a(),e?.({type:"rating",ratingId:t.id,value:r,stickerId:t.id})}},p=M=>{c&&$(M.touches[0].clientX)};return c&&(window.addEventListener("mousemove",x),window.addEventListener("mouseup",s),window.addEventListener("touchmove",p),window.addEventListener("touchend",s)),()=>{window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",s),window.removeEventListener("touchmove",p),window.removeEventListener("touchend",s)}},[c,r]),(0,ue.jsxs)("div",{style:m,children:[(0,ue.jsx)("style",{children:`
52
+ `}),i.map((g,b)=>{let m=c[g]||2e3;return(0,Ze.jsxs)("button",{className:`appstorys-reaction-btn ${s?"voted":""} ${o?"editing":""}`,style:u,onClick:()=>S(g,b),children:[(0,Ze.jsx)("span",{style:C,children:g}),s&&(0,Ze.jsx)("span",{style:h,children:p(m)})]},b)})]})};var De=require("react");var _e=require("react/jsx-runtime"),Yi=({data:t,onInteraction:e,isEditing:o=!1})=>{let n=t.maxRating||5,i=t.currentRating??Math.floor(n/2),[s,l]=(0,De.useState)(()=>{try{let B=localStorage.getItem(`appstorys_rating_${t.id}`);return B?Number(B):i}catch{return i}}),c=(0,De.useRef)(null),[d,S]=(0,De.useState)(!1),[p,y]=(0,De.useState)(()=>{try{return localStorage.getItem(`appstorys_rating_${t.id}`)!==null}catch{return!1}}),[u,C]=(0,De.useState)([]),h={backgroundColor:"#FFFFFF",borderRadius:20,padding:14,titleColor:"#000000",titleFontSize:15,sliderTrackColor:"#F3F4F6",sliderFillColor:"#F97316",emojiSize:32},g=t.styling||{},b=lt(g.questionFontFamily||g.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),m={backgroundColor:g.backgroundColor||h.backgroundColor,borderRadius:nt(g.borderRadius??h.borderRadius),padding:g.padding?nt(g.padding):"8px 12px",boxShadow:g.shadow||"0 10px 24px rgba(0,0,0,0.08)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",cursor:"default",opacity:g.opacity??1},E={color:g.titleColor||h.titleColor,fontWeight:"700",fontSize:typeof g.titleFontSize=="string"?`min(${g.titleFontSize}, 16px)`:`${g.titleFontSize?Math.min(Number(g.titleFontSize),16):15}px`,margin:"0",textAlign:"center",lineHeight:"1.25",fontFamily:b,width:"100%"},j={width:"100%",height:"16px",backgroundColor:g.sliderTrackColor||h.sliderTrackColor,borderRadius:"100px",position:"relative",cursor:o||p?"default":"pointer",marginTop:"4px",marginBottom:"2px",userSelect:"none"},D=s/n*100,L={width:`${D}%`,height:"100%",background:g.sliderFillColor||"linear-gradient(90deg, #FF4582, #e11d48)",borderRadius:"100px",transition:d?"none":"width 0.1s ease"},v=g.emojiSize||h.emojiSize,w=typeof v=="string",_=nt(v),N={position:"absolute",left:w?`calc(${D}% - calc(${_} / 2))`:`calc(${D}% - ${Number(v)/2}px)`,top:w?`calc(50% - calc(${_} / 2))`:`calc(50% - ${Number(v)/2}px)`,fontSize:_,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",cursor:p||o?"default":"grab",transition:d?"none":"left 0.1s ease",filter:"drop-shadow(0 4px 8px rgba(0,0,0,0.2))",animation:p?"thumbPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards":"none"},U=B=>{if(!c.current||o||p)return;let $=c.current.getBoundingClientRect(),V=B-$.left;V<0&&(V=0),V>$.width&&(V=$.width);let G=V/$.width,r=Math.round(G*n*10)/10;l(r)},A=B=>{o||p||(S(!0),U(B.clientX))},T=B=>{o||p||(S(!0),U(B.touches[0].clientX))},k=()=>{let B=Array.from({length:16}).map(($,V)=>({id:Date.now()+V,scale:.5+Math.random()*.8,angle:V*22.5+(Math.random()*15-7.5),delay:Math.random()*.1}));C(B),setTimeout(()=>{C([])},1200)};return(0,De.useEffect)(()=>{let B=G=>{d&&U(G.clientX)},$=()=>{if(d){S(!1),y(!0);try{localStorage.setItem(`appstorys_rating_${t.id}`,String(s))}catch{}k(),e?.({type:"rating",ratingId:t.id,value:s,stickerId:t.id})}},V=G=>{d&&U(G.touches[0].clientX)};return d&&(window.addEventListener("mousemove",B),window.addEventListener("mouseup",$),window.addEventListener("touchmove",V),window.addEventListener("touchend",$)),()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",$),window.removeEventListener("touchmove",V),window.removeEventListener("touchend",$)}},[d,s]),(0,_e.jsxs)("div",{style:m,children:[(0,_e.jsx)("style",{children:`
48
53
  @keyframes emojiBurst {
49
54
  0% {
50
55
  transform: translate(0, 0) scale(0.3);
@@ -63,7 +68,7 @@
63
68
  50% { transform: scale(1.3); }
64
69
  100% { transform: scale(1); }
65
70
  }
66
- `}),(0,ue.jsx)("h3",{style:g,children:t.title||"Do you like my space?"}),(0,ue.jsxs)("div",{ref:d,style:C,onMouseDown:q,onTouchStart:B,children:[(0,ue.jsx)("div",{style:z}),(0,ue.jsxs)("div",{style:P,className:"interactive-emoji-thumb",children:[t.emoji||"\u{1F60D}",f.map(x=>{let s=60+Math.random()*80,p=x.angle*Math.PI/180,M=`${Math.cos(p)*s}px`,T=`${Math.sin(p)*s}px`;return(0,ue.jsx)("span",{style:{position:"absolute",left:"50%",top:"50%",width:"30px",height:"30px",marginLeft:"-15px",marginTop:"-15px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px",pointerEvents:"none",zIndex:100,animation:`emojiBurst 1s cubic-bezier(0.15, 0.85, 0.35, 1) ${x.delay}s forwards`,"--tx":M,"--ty":T,"--scale":x.scale},children:t.emoji||"\u{1F60D}"},x.id)})]})]})]})};var sn=require("react");var oe=require("react/jsx-runtime"),wi=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=(0,sn.useState)(()=>{try{return localStorage.getItem(`appstorys_question_${t.id}`)||""}catch{return""}}),[r,l]=(0,sn.useState)(()=>{try{return localStorage.getItem(`appstorys_question_${t.id}`)!==null}catch{return!1}}),d={backgroundColor:"#FFFFFF",borderRadius:16,padding:16,promptColor:"#111111",inputBgColor:"#FFFFFF",borderColor:"#EFEFEF",textColor:"#333333",placeholderColor:"#A0AEC0"},c=t.styling||{},y={backgroundColor:c.backgroundColor||d.backgroundColor,borderRadius:K(c.borderRadius??d.borderRadius),padding:c.padding?K(c.padding):"15px 16px",boxShadow:c.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"10px",border:`1px solid ${c.borderColor||"#F0F0F0"}`},b={color:c.promptColor||d.promptColor,fontWeight:"700",fontSize:typeof c.fontSize=="string"?`min(${c.fontSize}, 16px)`:`${c.fontSize?Math.min(Number(c.fontSize),16):15}px`,textAlign:"center",marginBottom:"2px",width:"100%"},h={width:"100%",position:"relative",display:"flex",alignItems:"center"},f={backgroundColor:c.inputBgColor||"#F1F3F5",border:"none",borderRadius:"30px",padding:"12px 42px 12px 16px",width:"100%",boxSizing:"border-box",color:c.inputTextColor||"#1A202C",fontSize:"13px",outline:"none",textAlign:"left",cursor:o?"default":"text",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},v={position:"absolute",right:"10px",background:c.submitBackground||"#FE6B35",color:"white",border:"none",borderRadius:"50%",width:"32px",height:"32px",display:i.length>0&&!r?"flex":"none",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"transform 0.2s"},S=m=>{o||r||n(m.target.value)},u=()=>{if(!(o||!i.trim()||r)){l(!0);try{localStorage.setItem(`appstorys_question_${t.id}`,i.trim())}catch{}e?.({type:"question",questionId:t.id,value:i.trim(),stickerId:t.id})}};return(0,oe.jsxs)("div",{style:y,children:[(0,oe.jsx)("div",{style:b,children:t.question||"Ask me anything"}),(0,oe.jsxs)("div",{style:h,children:[(0,oe.jsx)("input",{type:"text",value:i,placeholder:r?"Submitted!":t.placeholder||"Type your answer...",style:f,disabled:o||r,onChange:S,onKeyDown:m=>m.key==="Enter"&&u()}),(0,oe.jsx)("button",{style:v,onClick:u,children:(0,oe.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,oe.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,oe.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})};var ki=require("react");var ne=require("react/jsx-runtime"),Ri=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=(0,ki.useState)(()=>{try{return localStorage.getItem(`appstorys_image_quiz_${t.id}`)}catch{return null}}),r={backgroundColor:"#FFFFFF",borderRadius:20,padding:16,questionTextColor:"#111111",optionBgColor:"#F7FAFC",optionTextColor:"#2D3748",borderColor:"#E2E8F0",activeColor:"#10B981",incorrectColor:"#EF4444"},l=t.styling||{},d=K(l.padding??r.padding),c=K(l.borderRadius??r.borderRadius),y={backgroundColor:l.backgroundColor||r.backgroundColor,borderRadius:c,padding:d,paddingTop:t.question?0:d,boxShadow:l.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",gap:"12px",border:l.borderColor?`1px solid ${l.borderColor}`:"none",overflow:"hidden"},b={color:l.questionTextColor||"#FFFFFF",backgroundColor:l.questionBgColor||"#000000",fontWeight:"800",fontSize:typeof l.fontSize=="string"?`min(${l.fontSize}, 16px)`:`${l.fontSize?Math.min(Number(l.fontSize),16):15}px`,margin:`0 calc(-1 * ${d}) 8px calc(-1 * ${d})`,padding:`10px ${d}`,textAlign:"center",borderTopLeftRadius:c,borderTopRightRadius:c},h={display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",width:"100%"},f={backgroundColor:l.optionBgColor||r.optionBgColor,color:l.optionTextColor||r.optionTextColor,borderRadius:"16px",border:`2px solid ${l.borderColor||r.borderColor}`,cursor:i?"default":"pointer",display:"flex",flexDirection:"column",alignItems:"center",padding:"8px",boxSizing:"border-box",transition:"all 0.2s ease",overflow:"hidden"},v=m=>{if(!(o||i)){n(m);try{localStorage.setItem(`appstorys_image_quiz_${t.id}`,m)}catch{}e?.({type:"image",quizId:t.id,optionId:m,stickerId:t.id})}},S="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Crect width='100%25' height='100%25' fill='%23EDF2F7'/%3E%3Cpath d='M30 40 L40 30 L50 40 L60 30 L70 40 V60 H30 Z' fill='%23A0AEC0'/%3E%3Ccircle cx='40' cy='45' r='5' fill='%23FFFFFF'/%3E%3C/svg%3E",u=Array.isArray(t.options)?t.options:[];return(0,ne.jsxs)("div",{style:y,children:[t.question&&(0,ne.jsx)("h3",{style:b,children:t.question}),(0,ne.jsx)("div",{style:h,children:u.map(m=>{let g=m.id===i,C=m.isCorrect===!0,I={...f};return i&&(C?(I.borderColor=l.activeColor||r.activeColor,I.backgroundColor="rgba(16, 185, 129, 0.05)"):g&&(I.borderColor=l.incorrectColor||r.incorrectColor,I.backgroundColor="rgba(239, 68, 68, 0.05)")),(0,ne.jsxs)("button",{style:I,onClick:()=>v(m.id),disabled:!!i,onMouseOver:z=>{!o&&!i&&(z.currentTarget.style.transform="translateY(-2px)")},onMouseOut:z=>{!o&&!i&&(z.currentTarget.style.transform="translateY(0)")},children:[(0,ne.jsxs)("div",{style:{width:"100%",aspectRatio:"1",borderRadius:"12px",overflow:"hidden",backgroundColor:"#EDF2F7",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"8px",position:"relative"},children:[(0,ne.jsx)("img",{src:m.image||S,alt:m.text,style:{width:"100%",height:"100%",objectFit:"cover"}}),i&&(0,ne.jsx)("div",{style:{position:"absolute",top:"6px",right:"6px",width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:C?r.activeColor:g?r.incorrectColor:"#A0AEC0",color:"#FFFFFF",fontSize:"12px",fontWeight:"bold"},children:C?"\u2713":g?"\u2715":""})]}),(0,ne.jsx)("span",{style:{fontWeight:"600",fontSize:K(l.optionFontSize||13),color:i&&C?r.activeColor:r.optionTextColor,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:m.text})]},m.id)})})]})};var cn=require("react");var Ce=require("react");var N=require("react/jsx-runtime"),Li=({product:t,styling:e,onClose:o,onAddToCart:i})=>{let[n,r]=(0,Ce.useState)(""),[l,d]=(0,Ce.useState)(0),[c,y]=(0,Ce.useState)(1),[b,h]=(0,Ce.useState)(!1),[f,v]=(0,Ce.useState)(!1),S=t.attributes||{},u=S.colors||[],m=S.sizes||[],g=S.imageUrls||[t.image],C=S.description||"";(0,Ce.useEffect)(()=>{m.length>0&&r(m[0]),v(!0)},[m]);let I=()=>{let x={productId:t.productId||t.id,title:t.title,selectedSize:n,selectedColor:u[l]?.name,quantity:c,price:t.price};i(x);let s=t.redirectUrl||t.url;if(s){!s.startsWith("http")&&!s.startsWith("//")&&(s="https://"+s);try{window.open(s,"_blank","noopener,noreferrer")}catch(p){console.error("AppStorys: Redirect failed",p)}}h(!0)},z=()=>{v(!1),setTimeout(o,400)},E=e?.buttonBackground||"#000000",w=e?.buttonTextColor||"#ffffff",_=e?.titleColor||e?.textColor||"#1a1a2e",P=e?.priceColor||e?.textColor||"#1a1a2e",$=e?.mrpColor||"#8b8b98",q=e?.titleFontWeight||"600",B=e?.priceFontWeight||"700",a=e?.mrpFontWeight||"500";return b?(0,N.jsxs)("div",{className:"appstorys-shopable-success-overlay",style:Ti,children:[(0,N.jsx)("div",{className:"appstorys-shopable-backdrop",style:Fi,onClick:z}),(0,N.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...zi,height:"auto",minHeight:"310px",animation:"appstorys-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[(0,N.jsx)("div",{style:Ii,onClick:z}),(0,N.jsxs)("div",{style:{padding:"0 20px 24px",textAlign:"center"},children:[(0,N.jsxs)("div",{style:{backgroundColor:"#F3F4F6",borderRadius:"20px",padding:"22px",marginTop:"16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[(0,N.jsxs)("h3",{style:{margin:0,fontSize:"16px",fontWeight:"600",lineHeight:"1.4"},children:["Added to your bag",(0,N.jsx)("br",{}),"successfully"]}),(0,N.jsx)("svg",{width:"44",height:"26",viewBox:"0 0 44 26",fill:"none",children:(0,N.jsx)("path",{d:"M4 4C4 4 11 22 22 22C33 22 40 4 40 4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"})})]}),(0,N.jsxs)("div",{style:{marginTop:"24px",display:"flex",flexDirection:"column",gap:"8px"},children:[(0,N.jsx)("button",{onClick:z,style:{...dn,backgroundColor:"#000000",color:"#ffffff",padding:"17px",fontSize:"16px",fontWeight:"600"},children:(0,N.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[(0,N.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,N.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,N.jsx)("path",{d:"M3 6h18"}),(0,N.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),"Go to checkout"]})}),(0,N.jsx)("button",{onClick:z,style:{...dn,backgroundColor:"transparent",color:"#000000",border:"1px solid rgba(0,0,0,0.1)",padding:"15px",fontSize:"16px"},children:"Continue with stories"})]})]})]})]}):(0,N.jsxs)("div",{className:`appstorys-shopable-overlay ${f?"visible":""}`,style:Ti,children:[(0,N.jsx)("div",{className:"appstorys-shopable-backdrop",style:Fi,onClick:z}),(0,N.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...zi,transform:f?"translateY(0)":"translateY(100%)",opacity:f?1:0},children:[(0,N.jsxs)("div",{style:Vr,children:[(0,N.jsx)("div",{style:Ii,onClick:z}),(0,N.jsx)("button",{style:Ur,onClick:z,children:(0,N.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,N.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,N.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),(0,N.jsxs)("div",{style:Yr,children:[(0,N.jsx)("div",{style:Qr,children:g.map((x,s)=>(0,N.jsx)("div",{style:{minWidth:g.length>1?"85%":"100%",aspectRatio:"1.2 / 1",maxHeight:"240px",borderRadius:"16px",overflow:"hidden",backgroundColor:"#F9FAFB"},children:(0,N.jsx)("img",{src:x,alt:t.title,style:{width:"100%",height:"100%",objectFit:"contain"}})},s))}),(0,N.jsxs)("div",{style:{padding:"0 20px 20px"},children:[(0,N.jsx)("h2",{style:{margin:"16px 0 4px",fontSize:e?.titleFontSize?K(e.titleFontSize):"20px",fontWeight:q,color:_,lineHeight:"1.2"},children:t.title}),(0,N.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",marginBottom:"16px"},children:[(0,N.jsx)("span",{style:{fontSize:e?.priceFontSize?K(e.priceFontSize):"18px",fontWeight:B,color:P},children:t.price}),t.oldPrice&&(0,N.jsx)("span",{style:{fontSize:e?.mrpFontSize?K(e.mrpFontSize):"14px",color:$,textDecoration:"line-through",fontWeight:a},children:t.oldPrice})]}),u.length>0&&(0,N.jsxs)("div",{style:an,children:[(0,N.jsx)("div",{style:ln,children:"COLOR"}),(0,N.jsx)("div",{style:{display:"flex",gap:"14px",marginTop:"12px"},children:u.map((x,s)=>(0,N.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"5px"},children:[(0,N.jsx)("button",{onClick:()=>d(s),style:{width:"36px",height:"36px",borderRadius:"50%",border:"none",backgroundColor:x.hex||"#gray",position:"relative",cursor:"pointer",boxShadow:l===s?"0 0 0 2px #fff, 0 0 0 4px #000":"none",transition:"all 0.2s ease"}}),(0,N.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:l===s?"#000":"transparent",transition:"all 0.2s ease"}})]},x.id))})]}),m.length>0&&(0,N.jsxs)("div",{style:an,children:[(0,N.jsx)("div",{style:ln,children:"SIZE"}),(0,N.jsx)("div",{style:{display:"flex",gap:"10px",marginTop:"12px",flexWrap:"wrap"},children:m.map(x=>(0,N.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[(0,N.jsx)("button",{onClick:()=>r(x),style:{minWidth:"42px",height:"42px",borderRadius:"50%",backgroundColor:"transparent",border:`1px solid ${n===x?"#000":"rgba(0,0,0,0.1)"}`,color:n===x?"#000":"#8b8b98",fontSize:"13px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:x}),(0,N.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:n===x?"#000":"transparent",transition:"all 0.2s ease"}})]},x))})]}),C&&(0,N.jsxs)("div",{style:an,children:[(0,N.jsx)("div",{style:ln,children:"DESCRIPTION"}),(0,N.jsx)("p",{style:{margin:"8px 0 0",fontSize:"14px",lineHeight:"1.5",color:"#8b8b98",wordBreak:"break-word"},children:C})]})]})]}),(0,N.jsxs)("div",{style:Gr,children:[(0,N.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1px",minWidth:"75px"},children:[(0,N.jsx)("div",{style:{fontSize:"15px",fontWeight:B,color:P},children:t.price}),t.oldPrice&&(0,N.jsx)("div",{style:{fontSize:"11px",color:$,textDecoration:"line-through",fontWeight:a},children:t.oldPrice})]}),(0,N.jsxs)("div",{style:Xr,children:[(0,N.jsx)("button",{style:Bi,onClick:()=>y(x=>Math.max(1,x-1)),children:(0,N.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,N.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}),(0,N.jsx)("span",{style:{fontSize:"16px",fontWeight:"700",minWidth:"18px",textAlign:"center",color:"#000000",display:"inline-block"},children:c}),(0,N.jsx)("button",{style:Bi,onClick:()=>y(x=>x+1),children:(0,N.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,N.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,N.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),(()=>{let x=S.availability?.toLowerCase()||"",s=x==="out of stock"||x==="out-of-stock";return(0,N.jsxs)("button",{onClick:s?void 0:I,disabled:s,style:{...dn,backgroundColor:s?"#F3F4F6":E,color:s?"#9CA3AF":w,flex:"1",padding:"12px 8px",gap:"6px",cursor:s?"not-allowed":"pointer",opacity:s?.8:1},children:[!s&&(0,N.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,N.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,N.jsx)("path",{d:"M3 6h18"}),(0,N.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),(0,N.jsx)("span",{style:{fontSize:"12px",fontWeight:"700",whiteSpace:"nowrap"},children:s?"Out of Stock":"Add to cart"})]})})()]})]}),(0,N.jsx)("style",{children:`
71
+ `}),(0,_e.jsx)("h3",{style:E,children:t.title||"Do you like my space?"}),(0,_e.jsxs)("div",{ref:c,style:j,onMouseDown:A,onTouchStart:T,children:[(0,_e.jsx)("div",{style:L}),(0,_e.jsxs)("div",{style:N,className:"interactive-emoji-thumb",children:[t.emoji||"\u{1F60D}",u.map(B=>{let $=60+Math.random()*80,V=B.angle*Math.PI/180,G=`${Math.cos(V)*$}px`,r=`${Math.sin(V)*$}px`;return(0,_e.jsx)("span",{style:{position:"absolute",left:"50%",top:"50%",width:"30px",height:"30px",marginLeft:"-15px",marginTop:"-15px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px",pointerEvents:"none",zIndex:100,animation:`emojiBurst 1s cubic-bezier(0.15, 0.85, 0.35, 1) ${B.delay}s forwards`,"--tx":G,"--ty":r,"--scale":B.scale},children:t.emoji||"\u{1F60D}"},B.id)})]})]})]})};var Dn=require("react");var Fe=require("react/jsx-runtime"),Gi=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=(0,Dn.useState)(()=>{try{return localStorage.getItem(`appstorys_question_${t.id}`)||""}catch{return""}}),[s,l]=(0,Dn.useState)(()=>{try{return localStorage.getItem(`appstorys_question_${t.id}`)!==null}catch{return!1}}),c={backgroundColor:"#FFFFFF",borderRadius:16,padding:16,promptColor:"#111111",inputBgColor:"#FFFFFF",borderColor:"#EFEFEF",textColor:"#333333",placeholderColor:"#A0AEC0"},d=t.styling||{},S=lt(d.questionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),p=lt(d.optionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),y={backgroundColor:d.backgroundColor||c.backgroundColor,borderRadius:nt(d.borderRadius??c.borderRadius),padding:d.padding?nt(d.padding):"10px 12px",boxShadow:d.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",border:`1px solid ${d.borderColor||"#F0F0F0"}`},u={color:d.promptColor||c.promptColor,fontWeight:"700",fontSize:nt(d.fontSize||16),fontFamily:S,textAlign:"center",marginBottom:"2px",width:"100%"},C={width:"100%",position:"relative",display:"flex",alignItems:"center"},h=d.optionRadius??d.inputBorderRadius??d.optionBorderRadius??d.inputRadius,g=h!==void 0?typeof h=="number"&&h>=5?"9999px":nt(h):"9999px",b={backgroundColor:d.inputBgColor||"#F1F3F5",border:"none",borderRadius:g,padding:"8px 36px 8px 14px",width:"100%",boxSizing:"border-box",color:d.inputTextColor||"#1A202C",fontSize:"13px",fontFamily:p,outline:"none",textAlign:"left",cursor:o?"default":"text",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},m={position:"absolute",right:"4px",background:d.submitBackground||"#FE6B35",color:"white",border:"none",borderRadius:"50%",width:"24px",height:"24px",display:n.length>0&&!s?"flex":"none",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"transform 0.2s"},E=D=>{o||s||i(D.target.value)},j=()=>{if(!(o||!n.trim()||s)){l(!0);try{localStorage.setItem(`appstorys_question_${t.id}`,n.trim())}catch{}e?.({type:"question",questionId:t.id,value:n.trim(),stickerId:t.id})}};return(0,Fe.jsxs)("div",{style:y,children:[(0,Fe.jsx)("div",{style:u,children:t.question||"Ask me anything"}),(0,Fe.jsxs)("div",{style:C,children:[(0,Fe.jsx)("input",{type:"text",value:n,placeholder:s?"Submitted!":t.placeholder||"Type your answer...",style:b,disabled:o||s,onChange:E,onKeyDown:D=>D.key==="Enter"&&j()}),(0,Fe.jsx)("button",{style:m,onClick:j,children:(0,Fe.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Fe.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,Fe.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})};var Qi=require("react");var Te=require("react/jsx-runtime"),Xi=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=(0,Qi.useState)(()=>{try{return localStorage.getItem(`appstorys_image_quiz_${t.id}`)}catch{return null}}),s={backgroundColor:"#FFFFFF",borderRadius:16,padding:10,optionBgColor:"#F8FAFC",optionTextColor:"#0F172A",borderColor:"#E2E8F0",activeColor:"#10B981",incorrectColor:"#EF4444"},l=t.styling||{},c=nt(l.padding??s.padding),d=nt(l.borderRadius??s.borderRadius),S=lt(l.questionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),p=lt(l.optionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),y={backgroundColor:l.backgroundColor||s.backgroundColor,borderRadius:d,padding:c,boxShadow:l.shadow||"0 12px 32px rgba(0,0,0,0.12)",boxSizing:"border-box",width:"100%",maxWidth:"280px",margin:"0 auto",display:"flex",flexDirection:"column",opacity:l.opacity??1,border:l.borderColor?`1px solid ${l.borderColor}`:"none",overflow:"hidden"},u={color:l.questionTextColor||"#FFFFFF",backgroundColor:l.questionBgColor||"#000000",fontWeight:"800",fontSize:nt(l.fontSize||15),fontFamily:S,margin:`calc(-1 * ${c}) calc(-1 * ${c}) 8px calc(-1 * ${c})`,padding:`12px ${c} 10px ${c}`,textAlign:"center",borderTopLeftRadius:d,borderTopRightRadius:d},g={display:"grid",gridTemplateColumns:`repeat(${(v=>{if(typeof v=="number"&&!isNaN(v)&&v>0)return v;if(typeof v=="string"){let w=parseInt(v,10);if(!isNaN(w)&&w>0)return w}if(typeof v=="object"&&v!==null){let w=v.columns||v.cols||v.columnCount;if(typeof w=="number"&&!isNaN(w)&&w>0)return w;if(typeof w=="string"){let _=parseInt(w,10);if(!isNaN(_)&&_>0)return _}}return 2})(t.layout??l.layout??l.columns)}, 1fr)`,gap:"6px",width:"100%"},b=nt(l.optionRadius??l.optionBorderRadius??l.imageRadius??14),m={backgroundColor:l.optionBgColor||s.optionBgColor,color:l.optionTextColor||s.optionTextColor,fontFamily:p,borderRadius:b,border:`2px solid ${l.borderColor||s.borderColor}`,cursor:n?"default":"pointer",display:"flex",flexDirection:"column",alignItems:"center",padding:"6px",boxSizing:"border-box",transition:"all 0.2s ease",overflow:"hidden"},E=v=>{if(!(o||n)){i(v);try{localStorage.setItem(`appstorys_image_quiz_${t.id}`,v)}catch{}e?.({type:"image",quizId:t.id,optionId:v,stickerId:t.id})}},j="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Crect width='100%25' height='100%25' fill='%23EDF2F7'/%3E%3Cpath d='M30 40 L40 30 L50 40 L60 30 L70 40 V60 H30 Z' fill='%23A0AEC0'/%3E%3Ccircle cx='40' cy='45' r='5' fill='%23FFFFFF'/%3E%3C/svg%3E",D=["A","B","C","D","E","F"],L=Array.isArray(t.options)?t.options:[];return L.length===0&&!o&&console.warn("AppStorys: ImageQuizSticker has no options!",t.id),(0,Te.jsxs)("div",{style:{...y,background:l.backgroundColor||s.backgroundColor},children:[t.question&&(0,Te.jsx)("h3",{style:u,children:t.question}),(0,Te.jsx)("div",{style:g,children:L.map((v,w)=>{let _=v.id===n,N=v.isCorrect===!0,U=l.borderColor||s.borderColor,A=l.optionBgColor||s.optionBgColor;n&&(N?(U=l.activeColor||s.activeColor,A="rgba(16, 185, 129, 0.08)"):_&&(U=l.incorrectColor||s.incorrectColor,A="rgba(239, 68, 68, 0.08)"));let T=n?N?l.activeColor||s.activeColor:_?l.incorrectColor||s.incorrectColor:l.labelColor||l.optionTextColor||s.optionTextColor:l.labelColor||l.optionTextColor||s.optionTextColor;return(0,Te.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%",boxSizing:"border-box"},children:[(0,Te.jsxs)("button",{style:{width:"100%",aspectRatio:"1",borderRadius:b,border:`2px solid ${U}`,backgroundColor:A,overflow:"hidden",cursor:n?"default":"pointer",position:"relative",padding:0,margin:0,outline:"none",transition:"transform 0.2s ease, border-color 0.2s ease",boxSizing:"border-box"},onClick:()=>E(v.id),disabled:!!n,onMouseOver:k=>{!o&&!n&&(k.currentTarget.style.transform="scale(1.02)")},onMouseOut:k=>{!o&&!n&&(k.currentTarget.style.transform="scale(1)")},children:[(0,Te.jsx)("img",{src:v.image||j,alt:v.text,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),n&&(0,Te.jsx)("div",{style:{position:"absolute",top:"6px",right:"6px",width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:N?l.activeColor||s.activeColor:_?l.incorrectColor||s.incorrectColor:"#A0AEC0",color:"#FFFFFF",fontSize:"12px",fontWeight:"bold",boxShadow:"0 2px 6px rgba(0,0,0,0.2)"},children:N?"\u2713":_?"\u2715":""})]}),(0,Te.jsx)("span",{style:{marginTop:"6px",fontWeight:"600",fontSize:nt(l.optionFontSize||13),color:T,fontFamily:p,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.text})]},v.id)})})]})};var Nn=require("react");var Ne=require("react");var Q=require("react/jsx-runtime"),or=({product:t,styling:e,onClose:o,onAddToCart:n})=>{let[i,s]=(0,Ne.useState)(""),[l,c]=(0,Ne.useState)(0),[d,S]=(0,Ne.useState)(1),[p,y]=(0,Ne.useState)(!1),[u,C]=(0,Ne.useState)(!1),h=t.attributes||{},g=h.colors||[],b=h.sizes||[],m=h.imageUrls||[t.image],E=h.description||"";(0,Ne.useEffect)(()=>{b.length>0&&s(b[0]),C(!0)},[b]);let j=()=>{let k={productId:t.productId||t.id,title:t.title,selectedSize:i,selectedColor:g[l]?.name,quantity:d,price:t.price};n(k);let B=t.redirectUrl||t.url;if(B){!B.startsWith("http")&&!B.startsWith("//")&&(B="https://"+B);try{window.open(B,"_blank","noopener,noreferrer")}catch($){console.error("AppStorys: Redirect failed",$)}}y(!0)},D=()=>{C(!1),setTimeout(o,400)},L=e?.buttonBackground||"#000000",v=e?.buttonTextColor||"#ffffff",w=e?.titleColor||e?.textColor||"#1a1a2e",_=e?.priceColor||e?.textColor||"#1a1a2e",N=e?.mrpColor||"#8b8b98",U=e?.titleFontWeight||"600",A=e?.priceFontWeight||"700",T=e?.mrpFontWeight||"500";return p?(0,Q.jsxs)("div",{className:"appstorys-shopable-success-overlay",style:Ji,children:[(0,Q.jsx)("div",{className:"appstorys-shopable-backdrop",style:Ki,onClick:D}),(0,Q.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...Zi,height:"auto",minHeight:"310px",animation:"appstorys-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[(0,Q.jsx)("div",{style:tr,onClick:D}),(0,Q.jsxs)("div",{style:{padding:"0 20px 24px",textAlign:"center"},children:[(0,Q.jsxs)("div",{style:{backgroundColor:"#F3F4F6",borderRadius:"20px",padding:"22px",marginTop:"16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[(0,Q.jsxs)("h3",{style:{margin:0,fontSize:"16px",fontWeight:"600",lineHeight:"1.4"},children:["Added to your bag",(0,Q.jsx)("br",{}),"successfully"]}),(0,Q.jsx)("svg",{width:"44",height:"26",viewBox:"0 0 44 26",fill:"none",children:(0,Q.jsx)("path",{d:"M4 4C4 4 11 22 22 22C33 22 40 4 40 4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"})})]}),(0,Q.jsxs)("div",{style:{marginTop:"24px",display:"flex",flexDirection:"column",gap:"8px"},children:[(0,Q.jsx)("button",{onClick:D,style:{...$n,backgroundColor:"#000000",color:"#ffffff",padding:"17px",fontSize:"16px",fontWeight:"600"},children:(0,Q.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[(0,Q.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,Q.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,Q.jsx)("path",{d:"M3 6h18"}),(0,Q.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),"Go to checkout"]})}),(0,Q.jsx)("button",{onClick:D,style:{...$n,backgroundColor:"transparent",color:"#000000",border:"1px solid rgba(0,0,0,0.1)",padding:"15px",fontSize:"16px"},children:"Continue with stories"})]})]})]})]}):(0,Q.jsxs)("div",{className:`appstorys-shopable-overlay ${u?"visible":""}`,style:Ji,children:[(0,Q.jsx)("div",{className:"appstorys-shopable-backdrop",style:Ki,onClick:D}),(0,Q.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...Zi,transform:u?"translateY(0)":"translateY(100%)",opacity:u?1:0},children:[(0,Q.jsxs)("div",{style:Cs,children:[(0,Q.jsx)("div",{style:tr,onClick:D}),(0,Q.jsx)("button",{style:vs,onClick:D,children:(0,Q.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Q.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,Q.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),(0,Q.jsxs)("div",{style:ws,children:[(0,Q.jsx)("div",{style:ks,children:m.map((k,B)=>(0,Q.jsx)("div",{style:{minWidth:m.length>1?"85%":"100%",aspectRatio:"1.2 / 1",maxHeight:"240px",borderRadius:"16px",overflow:"hidden",backgroundColor:"#F9FAFB"},children:(0,Q.jsx)("img",{src:k,alt:t.title,style:{width:"100%",height:"100%",objectFit:"contain"}})},B))}),(0,Q.jsxs)("div",{style:{padding:"0 20px 20px"},children:[(0,Q.jsx)("h2",{style:{margin:"16px 0 4px",fontSize:e?.titleFontSize?nt(e.titleFontSize):"20px",fontWeight:U,color:w,lineHeight:"1.2"},children:t.title}),(0,Q.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",marginBottom:"16px"},children:[(0,Q.jsx)("span",{style:{fontSize:e?.priceFontSize?nt(e.priceFontSize):"18px",fontWeight:A,color:_},children:t.price}),t.oldPrice&&(0,Q.jsx)("span",{style:{fontSize:e?.mrpFontSize?nt(e.mrpFontSize):"14px",color:N,textDecoration:"line-through",fontWeight:T},children:t.oldPrice})]}),g.length>0&&(0,Q.jsxs)("div",{style:_n,children:[(0,Q.jsx)("div",{style:Wn,children:"COLOR"}),(0,Q.jsx)("div",{style:{display:"flex",gap:"14px",marginTop:"12px"},children:g.map((k,B)=>(0,Q.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"5px"},children:[(0,Q.jsx)("button",{onClick:()=>c(B),style:{width:"36px",height:"36px",borderRadius:"50%",border:"none",backgroundColor:k.hex||"#gray",position:"relative",cursor:"pointer",boxShadow:l===B?"0 0 0 2px #fff, 0 0 0 4px #000":"none",transition:"all 0.2s ease"}}),(0,Q.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:l===B?"#000":"transparent",transition:"all 0.2s ease"}})]},k.id))})]}),b.length>0&&(0,Q.jsxs)("div",{style:_n,children:[(0,Q.jsx)("div",{style:Wn,children:"SIZE"}),(0,Q.jsx)("div",{style:{display:"flex",gap:"10px",marginTop:"12px",flexWrap:"wrap"},children:b.map(k=>(0,Q.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[(0,Q.jsx)("button",{onClick:()=>s(k),style:{minWidth:"42px",height:"42px",borderRadius:"50%",backgroundColor:"transparent",border:`1px solid ${i===k?"#000":"rgba(0,0,0,0.1)"}`,color:i===k?"#000":"#8b8b98",fontSize:"13px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:k}),(0,Q.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:i===k?"#000":"transparent",transition:"all 0.2s ease"}})]},k))})]}),E&&(0,Q.jsxs)("div",{style:_n,children:[(0,Q.jsx)("div",{style:Wn,children:"DESCRIPTION"}),(0,Q.jsx)("p",{style:{margin:"8px 0 0",fontSize:"14px",lineHeight:"1.5",color:"#8b8b98",wordBreak:"break-word"},children:E})]})]})]}),(0,Q.jsxs)("div",{style:Rs,children:[(0,Q.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1px",minWidth:"75px"},children:[(0,Q.jsx)("div",{style:{fontSize:"15px",fontWeight:A,color:_},children:t.price}),t.oldPrice&&(0,Q.jsx)("div",{style:{fontSize:"11px",color:N,textDecoration:"line-through",fontWeight:T},children:t.oldPrice})]}),(0,Q.jsxs)("div",{style:Fs,children:[(0,Q.jsx)("button",{style:er,onClick:()=>S(k=>Math.max(1,k-1)),children:(0,Q.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,Q.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}),(0,Q.jsx)("span",{style:{fontSize:"16px",fontWeight:"700",minWidth:"18px",textAlign:"center",color:"#000000",display:"inline-block"},children:d}),(0,Q.jsx)("button",{style:er,onClick:()=>S(k=>k+1),children:(0,Q.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,Q.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,Q.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),(()=>{let k=h.availability?.toLowerCase()||"",B=k==="out of stock"||k==="out-of-stock";return(0,Q.jsxs)("button",{onClick:B?void 0:j,disabled:B,style:{...$n,backgroundColor:B?"#F3F4F6":L,color:B?"#9CA3AF":v,flex:"1",padding:"12px 8px",gap:"6px",cursor:B?"not-allowed":"pointer",opacity:B?.8:1},children:[!B&&(0,Q.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,Q.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,Q.jsx)("path",{d:"M3 6h18"}),(0,Q.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),(0,Q.jsx)("span",{style:{fontSize:"12px",fontWeight:"700",whiteSpace:"nowrap"},children:B?"Out of Stock":"Add to cart"})]})})()]})]}),(0,Q.jsx)("style",{children:`
67
72
  @keyframes appstorys-slide-up {
68
73
  from { transform: translateY(100%); }
69
74
  to { transform: translateY(0); }
@@ -76,10 +81,10 @@
76
81
  .appstorys-shopable-overlay.visible {
77
82
  visibility: visible;
78
83
  }
79
- `})]})},Ti={position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4,display:"flex",alignItems:"flex-end",justifyContent:"center",pointerEvents:"auto",fontFamily:"'Inter', system-ui, -apple-system, sans-serif",width:"100%",height:"100%",boxSizing:"border-box"},Fi={position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.45)",cursor:"pointer"},zi={position:"relative",width:"100%",maxWidth:"500px",backgroundColor:"#fff",borderTopLeftRadius:"28px",borderTopRightRadius:"28px",borderBottomLeftRadius:0,borderBottomRightRadius:0,maxHeight:"60vh",display:"flex",flexDirection:"column",margin:0,transition:"transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s ease",boxShadow:"0 -8px 24px rgba(0,0,0,0.15)",overflow:"hidden",boxSizing:"border-box"},Vr={height:"48px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0},Ii={width:"36px",height:"5px",backgroundColor:"rgba(0,0,0,0.1)",borderRadius:"3px",cursor:"pointer"},Ur={position:"absolute",right:"18px",top:"16px",border:"none",width:"28px",height:"28px",borderRadius:"50%",backgroundColor:"#F3F4F6",display:"flex",alignItems:"center",justifyContent:"center",color:"#666",cursor:"pointer"},Yr={flex:1,overflowY:"auto",WebkitOverflowScrolling:"touch"},Qr={padding:"0 16px 20px",display:"flex",gap:"8px",overflowX:"auto",scrollSnapType:"x mandatory"},an={marginTop:"20px"},ln={fontSize:"11px",fontWeight:"600",color:"rgba(0,0,0,0.5)",letterSpacing:"1.4px"},Gr={padding:"12px 16px calc(20px + env(safe-area-inset-bottom, 0px))",borderTop:"1px solid rgba(0,0,0,0.05)",display:"flex",alignItems:"center",gap:"8px",backgroundColor:"#fff",boxShadow:"0 -4px 12px rgba(0,0,0,0.06)",zIndex:10,boxSizing:"border-box"},Xr={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"100px",border:"1px solid rgba(0,0,0,0.1)"},Bi={border:"none",backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},dn={border:"none",borderRadius:"100px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"};var zt=require("react/jsx-runtime"),Mi=({data:t,onInteraction:e,isEditing:o})=>{let{products:i,styling:n}=t,[r,l]=(0,cn.useState)(!1),[d,c]=(0,cn.useState)(null),y=(u,m)=>{if(u.stopPropagation(),o)return;if(t.shopableType==="product"){c(m),l(!0),e&&e({type:"product_view",stickerId:t.id,productId:m.productId||m.id,value:m.title});return}let g=m.redirectUrl||m.url;if(g&&!g.startsWith("http")&&!g.startsWith("//")&&(g="https://"+g),e&&e({type:"buy",stickerId:t.id,productId:m.id,value:m.title,selected_option:g}),g)try{window.open(g,"_blank","noopener,noreferrer")}catch(C){console.error("AppStorys: Redirect failed",C),window.location.href=g}},b=u=>{e&&e({type:"add_to_cart",stickerId:t.id,productId:u.productId,value:u.title,selected_option:JSON.stringify({size:u.selectedSize,color:u.selectedColor,quantity:u.quantity})})},h={width:"100%",height:"100%",display:"flex",gap:"12px",overflowX:"auto",padding:"0 1px",scrollSnapType:"x mandatory",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",pointerEvents:"auto"},f={flex:"0 0 auto",width:"100%",backgroundColor:n?.cardBackground||"#ffffff",borderRadius:n?.cardBorderRadius!==void 0?K(n.cardBorderRadius):n?.cardRadiusPercent!==void 0?`${n.cardRadiusPercent}%`:"12px",overflow:"hidden",boxShadow:n?.shadow||"0 -2px 12px rgba(0,0,0,0.12)",display:"flex",flexDirection:"row",alignItems:"center",padding:"8px 12px",position:"relative",scrollSnapAlign:"center",transition:"transform 0.2s ease",cursor:"pointer",boxSizing:"border-box",pointerEvents:"auto",opacity:n?.opacity??1,marginBottom:0},v={width:"64px",height:"64px",borderRadius:n?.imageRadius!==void 0?K(n.imageRadius):"12px",overflow:"hidden",backgroundColor:"#f5f5f5",flexShrink:0},S={flex:1,display:"flex",flexDirection:"column",justifyContent:"center",padding:"0 12px",minWidth:0};return(0,zt.jsxs)(zt.Fragment,{children:[(0,zt.jsxs)("div",{style:h,className:"shopable-container",children:[(0,zt.jsx)("style",{children:`
84
+ `})]})},Ji={position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1e4,display:"flex",alignItems:"flex-end",justifyContent:"center",pointerEvents:"auto",fontFamily:"'Inter', system-ui, -apple-system, sans-serif",width:"100%",height:"100%",boxSizing:"border-box"},Ki={position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.45)",cursor:"pointer"},Zi={position:"relative",width:"100%",maxWidth:"500px",backgroundColor:"#fff",borderTopLeftRadius:"28px",borderTopRightRadius:"28px",borderBottomLeftRadius:0,borderBottomRightRadius:0,maxHeight:"60vh",display:"flex",flexDirection:"column",margin:0,transition:"transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s ease",boxShadow:"0 -8px 24px rgba(0,0,0,0.15)",overflow:"hidden",boxSizing:"border-box"},Cs={height:"48px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0},tr={width:"36px",height:"5px",backgroundColor:"rgba(0,0,0,0.1)",borderRadius:"3px",cursor:"pointer"},vs={position:"absolute",right:"18px",top:"16px",border:"none",width:"28px",height:"28px",borderRadius:"50%",backgroundColor:"#F3F4F6",display:"flex",alignItems:"center",justifyContent:"center",color:"#666",cursor:"pointer"},ws={flex:1,overflowY:"auto",WebkitOverflowScrolling:"touch"},ks={padding:"0 16px 20px",display:"flex",gap:"8px",overflowX:"auto",scrollSnapType:"x mandatory"},_n={marginTop:"20px"},Wn={fontSize:"11px",fontWeight:"600",color:"rgba(0,0,0,0.5)",letterSpacing:"1.4px"},Rs={padding:"12px 16px calc(20px + env(safe-area-inset-bottom, 0px))",borderTop:"1px solid rgba(0,0,0,0.05)",display:"flex",alignItems:"center",gap:"8px",backgroundColor:"#fff",boxShadow:"0 -4px 12px rgba(0,0,0,0.06)",zIndex:10,boxSizing:"border-box"},Fs={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"100px",border:"1px solid rgba(0,0,0,0.1)"},er={border:"none",backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},$n={border:"none",borderRadius:"100px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"};var Vt=require("react/jsx-runtime"),nr=({data:t,onInteraction:e,isEditing:o})=>{let{products:n,styling:i}=t,[s,l]=(0,Nn.useState)(!1),[c,d]=(0,Nn.useState)(null),S=(g,b)=>{if(g.stopPropagation(),o)return;if(t.shopableType==="product"){d(b),l(!0),e&&e({type:"product_view",stickerId:t.id,productId:b.productId||b.id,value:b.title});return}let m=b.redirectUrl||b.url;if(m&&!m.startsWith("http")&&!m.startsWith("//")&&(m="https://"+m),e&&e({type:"buy",stickerId:t.id,productId:b.id,value:b.title,selected_option:m}),m)try{window.open(m,"_blank","noopener,noreferrer")}catch(E){console.error("AppStorys: Redirect failed",E),window.location.href=m}},p=g=>{e&&e({type:"add_to_cart",stickerId:t.id,productId:g.productId,value:g.title,selected_option:JSON.stringify({size:g.selectedSize,color:g.selectedColor,quantity:g.quantity})})},y={width:"100%",height:"100%",display:"flex",gap:"12px",overflowX:"auto",padding:"0 1px",scrollSnapType:"x mandatory",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",pointerEvents:"auto"},u={flex:"0 0 auto",width:"100%",backgroundColor:i?.cardBackground||"#ffffff",borderRadius:i?.cardBorderRadius!==void 0?nt(i.cardBorderRadius):i?.cardRadiusPercent!==void 0?`${i.cardRadiusPercent}%`:"12px",overflow:"hidden",boxShadow:i?.shadow||"0 -2px 12px rgba(0,0,0,0.12)",display:"flex",flexDirection:"row",alignItems:"center",padding:"8px 12px",position:"relative",scrollSnapAlign:"center",transition:"transform 0.2s ease",cursor:"pointer",boxSizing:"border-box",pointerEvents:"auto",opacity:i?.opacity??1,marginBottom:0},C={width:"64px",height:"64px",borderRadius:i?.imageRadius!==void 0?nt(i.imageRadius):"12px",overflow:"hidden",backgroundColor:"#f5f5f5",flexShrink:0},h={flex:1,display:"flex",flexDirection:"column",justifyContent:"center",padding:"0 12px",minWidth:0};return(0,Vt.jsxs)(Vt.Fragment,{children:[(0,Vt.jsxs)("div",{style:y,className:"shopable-container",children:[(0,Vt.jsx)("style",{children:`
80
85
  .shopable-container::-webkit-scrollbar { display: none; }
81
86
  .shopable-card:active { transform: scale(0.98); }
82
- `}),i.map(u=>(0,zt.jsxs)("div",{style:f,className:"shopable-card",onClick:m=>y(m,u),children:[(0,zt.jsx)("div",{style:v,children:(0,zt.jsx)("img",{src:u.image,alt:u.title,style:{width:"100%",height:"100%",objectFit:"cover"}})}),(0,zt.jsxs)("div",{style:S,children:[(0,zt.jsx)("span",{style:{color:n?.titleColor||n?.textColor||"#1a1b2e",fontSize:n?.titleFontSize?K(n.titleFontSize):"15px",fontWeight:n?.titleFontWeight||"700",lineHeight:"1.2",display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"1px"},children:u.title}),(0,zt.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",flexWrap:"wrap"},children:[(0,zt.jsx)("span",{style:{color:n?.priceColor||n?.textColor||"#1a1b2e",fontSize:n?.priceFontSize?K(n.priceFontSize):"18px",fontWeight:n?.priceFontWeight||"800",display:"block"},children:u.price}),u.oldPrice&&(0,zt.jsx)("span",{style:{color:n?.mrpColor||"#8b8b98",fontSize:n?.mrpFontSize?K(n.mrpFontSize):"12px",fontWeight:n?.mrpFontWeight||"500",textDecoration:"line-through"},children:u.oldPrice})]})]}),(0,zt.jsx)("div",{style:{backgroundColor:n?.buttonBackground||"#000000",color:n?.buttonTextColor||"#ffffff",fontSize:n?.buttonFontSize?K(n.buttonFontSize):"14px",fontWeight:"700",padding:"10px 18px",borderRadius:n?.buttonBorderRadius!==void 0?K(n.buttonBorderRadius):"100px",textAlign:"center",flexShrink:0,whiteSpace:"nowrap"},children:"Buy Now"})]},u.id))]}),r&&d&&(0,zt.jsx)(Li,{product:d,styling:n,onClose:()=>l(!1),onAddToCart:b})]})};var ft=require("react/jsx-runtime"),Ai=({data:t,onInteraction:e,isEditing:o=!1})=>{let i={x:10,y:15,width:80,rotation:0},n=t.x??i.x,r=t.y??i.y,l=t.width??i.width,d=t.rotation??i.rotation,c={position:"absolute",top:`${r}%`,left:`${n}%`,width:`${l}%`,height:t.height?`${t.height}%`:"auto",transform:`rotate(${d}deg)`,zIndex:10,transformOrigin:"center center",boxSizing:"border-box",cursor:o?"move":"default",pointerEvents:"auto"},y={width:"100%",height:"100%",animation:t.styling?.animation,animationFillMode:"forwards"},b=()=>{switch(t.type){case"poll":return(0,ft.jsx)(mi,{data:t,onInteraction:e,isEditing:o});case"quiz":return(0,ft.jsx)(hi,{data:t,onInteraction:e,isEditing:o});case"rating":return(0,ft.jsx)(vi,{data:t,onInteraction:e,isEditing:o});case"question":case"input":return(0,ft.jsx)(wi,{data:t,onInteraction:e,isEditing:o});case"image_quiz":return(0,ft.jsx)(Ri,{data:t,onInteraction:e,isEditing:o});case"countdown":return(0,ft.jsx)(bi,{data:t,onInteraction:e,isEditing:o});case"promo_code":case"promo":return(0,ft.jsx)(Si,{data:t,onInteraction:e,isEditing:o});case"reaction":return(0,ft.jsx)(Ci,{data:t,onInteraction:e,isEditing:o});case"buy":case"shopable":return(0,ft.jsx)(Mi,{data:t,onInteraction:e,isEditing:o});case"shape":case"gif":case"svg":case"sticker":case"image":return(0,ft.jsx)("img",{src:t.url,alt:"static overlay",style:{width:"100%",height:"100%",objectFit:"fill"}});case"text":{let f=t.styling||{},v=f.verticalAlignment,S=f.textAlign;return(0,ft.jsx)("div",{style:{color:f.color||"#000000",fontSize:K(f.fontSize||14),fontFamily:mt(f.fontFamily)||"Arial",fontStyle:f.fontStyle||"normal",fontWeight:f.fontWeight||"normal",textDecoration:f.textDecoration||"none",lineHeight:f.lineHeight||"normal",letterSpacing:f.letterSpacing||"normal",opacity:f.opacity??1,wordBreak:"break-word",whiteSpace:"pre-wrap",width:"100%",height:"100%",display:"flex",alignItems:v==="center"?"center":v==="bottom"?"flex-end":"flex-start",justifyContent:S==="center"?"center":S==="right"?"flex-end":"flex-start",textAlign:S||"left"},children:t.text})}case"cta":{let f=t.styling||{};if(t.ctaType==="image")return(0,ft.jsx)("button",{onClick:w=>{w.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:{background:"none",border:"none",padding:0,width:"100%",height:"100%",cursor:"pointer",display:"block",outline:"none"},children:(0,ft.jsx)("img",{src:t.url,alt:t.text,style:{width:"100%",height:"100%",objectFit:"contain"}})});let S=f.borderRadius,u=(t.text||"").trim(),m=u.toLowerCase().includes("swipe")||String(t.ctaType).toLowerCase().includes("swipe")||String(t.type).toLowerCase().includes("swipe")||String(t.id).toLowerCase().includes("swipe"),g={width:"100%",height:f.pillH?`${f.pillH}cqh`:"100%",backgroundColor:f.transparent?"transparent":f.backgroundColor||"#3B82F6",color:f.textColor||"#FFFFFF",border:f.borderWidth?`${K(f.borderWidth)} solid ${f.borderColor||"#FFFFFF"}`:"none",borderRadius:S||"4px",fontSize:K(f.fontSize||14),fontFamily:mt(f.fontFamily)||"Arial",fontStyle:f.fontStyle||"normal",fontWeight:f.fontWeight||"normal",textDecoration:f.textDecoration||"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",outline:"none",padding:"0 12px",wordBreak:"break-word",flexShrink:0},C={position:"relative",width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-end",boxSizing:"border-box",animation:m&&f.arrowAnimation!==!1?"appstorys-swipe-bounce 2.2s ease-in-out infinite":"none",transformOrigin:"bottom center"},I={display:"flex",alignItems:"center",justifyContent:"center",flexGrow:1,width:"100%",color:f.arrowColor||f.textColor||"#FFFFFF",pointerEvents:"none",boxSizing:"border-box"},z=f.arrowSize?`${f.arrowSize}cqh`:"1.5cqh";return(0,ft.jsxs)("div",{style:C,children:[m&&(0,ft.jsxs)(ft.Fragment,{children:[(0,ft.jsx)("style",{children:`
87
+ `}),n.map(g=>(0,Vt.jsxs)("div",{style:u,className:"shopable-card",onClick:b=>S(b,g),children:[(0,Vt.jsx)("div",{style:C,children:(0,Vt.jsx)("img",{src:g.image,alt:g.title,style:{width:"100%",height:"100%",objectFit:"cover"}})}),(0,Vt.jsxs)("div",{style:h,children:[(0,Vt.jsx)("span",{style:{color:i?.titleColor||i?.textColor||"#1a1b2e",fontSize:i?.titleFontSize?nt(i.titleFontSize):"15px",fontWeight:i?.titleFontWeight||"700",lineHeight:"1.2",display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"1px"},children:g.title}),(0,Vt.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",flexWrap:"wrap"},children:[(0,Vt.jsx)("span",{style:{color:i?.priceColor||i?.textColor||"#1a1b2e",fontSize:i?.priceFontSize?nt(i.priceFontSize):"18px",fontWeight:i?.priceFontWeight||"800",display:"block"},children:g.price}),g.oldPrice&&(0,Vt.jsx)("span",{style:{color:i?.mrpColor||"#8b8b98",fontSize:i?.mrpFontSize?nt(i.mrpFontSize):"12px",fontWeight:i?.mrpFontWeight||"500",textDecoration:"line-through"},children:g.oldPrice})]})]}),(0,Vt.jsx)("div",{style:{backgroundColor:i?.buttonBackground||"#000000",color:i?.buttonTextColor||"#ffffff",fontSize:i?.buttonFontSize?nt(i.buttonFontSize):"14px",fontWeight:"700",padding:"10px 18px",borderRadius:i?.buttonBorderRadius!==void 0?nt(i.buttonBorderRadius):"100px",textAlign:"center",flexShrink:0,whiteSpace:"nowrap"},children:"Buy Now"})]},g.id))]}),s&&c&&(0,Vt.jsx)(or,{product:c,styling:i,onClose:()=>l(!1),onAddToCart:p})]})};var vt=require("react/jsx-runtime"),ir=po.default?.default??po.default??po.Lottie??po,Ts=({url:t,animationData:e,loop:o=!0,autoplay:n=!0,styling:i={}})=>{let[s,l]=(0,Eo.useState)(e||null),[c,d]=(0,Eo.useState)(!1);(0,Eo.useEffect)(()=>{if(e){l(e);return}t&&(d(!1),fetch(t).then(y=>{if(!y.ok)throw new Error(`Failed to fetch Lottie JSON (${y.status})`);return y.json()}).then(y=>{l(y),d(!1)}).catch(y=>{console.error("AppStorys: Error loading Lottie sticker from URL:",t,y),d(!0)}))},[t,e]);let S={width:"100%",height:"100%",display:"block",borderRadius:nt(i.borderRadius||"0px"),border:i.border||"none",boxShadow:i.boxShadow||"none",opacity:i.opacity??1,transform:i.transform||void 0,overflow:"hidden"};if(!s)return(0,vt.jsx)("div",{style:S});let p=ir.default||ir;return(0,vt.jsx)(p,{animationData:s,loop:o,autoplay:n,style:S,rendererSettings:{preserveAspectRatio:"xMidYMid meet"}})},rr=({data:t,onInteraction:e,isEditing:o=!1})=>{let n={x:10,y:15,width:80,rotation:0},i=t.x??n.x,s=t.y??n.y,l=t.width??n.width,c=t.rotation??n.rotation,d={position:"absolute",top:`${s}%`,left:`${i}%`,width:`${l}%`,height:t.height?`${t.height}%`:"auto",transform:`rotate(${c}deg)`,zIndex:10,transformOrigin:"center center",boxSizing:"border-box",cursor:o?"move":"default",pointerEvents:"auto"},S={width:"100%",height:"100%",animation:t.styling?.animation,animationFillMode:"forwards"},p=()=>{switch(t.type){case"poll":return(0,vt.jsx)(Ni,{data:t,onInteraction:e,isEditing:o});case"quiz":return(0,vt.jsx)(ji,{data:t,onInteraction:e,isEditing:o});case"rating":return(0,vt.jsx)(Yi,{data:t,onInteraction:e,isEditing:o});case"question":case"input":return(0,vt.jsx)(Gi,{data:t,onInteraction:e,isEditing:o});case"image_quiz":return(0,vt.jsx)(Xi,{data:t,onInteraction:e,isEditing:o});case"countdown":return(0,vt.jsx)(qi,{data:t,onInteraction:e,isEditing:o});case"promo_code":case"promo":return(0,vt.jsx)(Vi,{data:t,onInteraction:e,isEditing:o});case"reaction":return(0,vt.jsx)(Ui,{data:t,onInteraction:e,isEditing:o});case"lottie":return(0,vt.jsx)(Ts,{url:t.url,loop:t.loop,autoplay:t.autoplay,styling:t.styling});case"buy":case"shopable":return(0,vt.jsx)(nr,{data:t,onInteraction:e,isEditing:o});case"video":{let u=t.styling||{};return(0,vt.jsx)("video",{src:t.url,autoPlay:!0,loop:t.loop!==!1,muted:t.muted!==!1,playsInline:!0,style:{width:"100%",height:"100%",objectFit:u.objectFit||"cover",objectPosition:u.objectPosition||"center center",borderRadius:nt(u.borderRadius||"0px"),border:u.border||"none",boxShadow:u.boxShadow||"none",opacity:u.opacity??1,display:"block",overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"}})}case"shape":case"gif":case"svg":case"sticker":case"image":{let u=t.styling||{};return(0,vt.jsx)("img",{src:t.url,alt:"static overlay",style:{width:"100%",height:"100%",objectFit:u.objectFit||"cover",objectPosition:u.objectPosition||"center center",borderRadius:u.borderRadius||"0px",border:u.border||"none",boxShadow:u.boxShadow||"none",opacity:u.opacity??1,display:"block",overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"}})}case"text":{let u=t.styling||{},C=u.verticalAlignment,h=u.textAlign,g=u.lineHeight,b="1.25";if(g!=null&&g!==""){let m=Number(g);isNaN(m)?b=String(g):b=m<=5?String(m):"1.25"}return(0,vt.jsx)("div",{style:{color:u.color||"#000000",fontSize:nt(u.fontSize||14),fontFamily:lt(u.fontFamily)||"Arial",fontStyle:u.fontStyle||"normal",fontWeight:u.fontWeight||"normal",textDecoration:u.textDecoration||"none",lineHeight:b,letterSpacing:u.letterSpacing||"normal",opacity:u.opacity??1,wordBreak:"break-word",whiteSpace:"pre-wrap",width:"100%",height:"100%",display:"flex",alignItems:C==="middle"||C==="center"?"center":C==="bottom"?"flex-end":"flex-start",justifyContent:h==="center"?"center":h==="right"?"flex-end":"flex-start",textAlign:h||"left"},children:t.text})}case"cta":{let u=t.styling||{};if(t.ctaType==="image")return(0,vt.jsx)("button",{onClick:v=>{v.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:{background:"none",border:u.borderWidth&&u.borderWidth!=="0px"&&u.borderWidth!=="0cqh"?`${nt(u.borderWidth)} solid ${u.borderColor||"#FFFFFF"}`:"none",padding:0,width:"100%",height:"100%",cursor:"pointer",display:"block",outline:"none",borderRadius:u.borderRadius||"0px",overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"},children:(0,vt.jsx)("img",{src:t.url,alt:t.text,style:{width:"100%",height:"100%",objectFit:u.objectFit||"cover",objectPosition:u.objectPosition||"center center",display:"block",borderRadius:u.borderRadius||"0px"}})});let h=u.borderRadius,g=(t.text||"").trim(),b=g.toLowerCase().includes("swipe")||String(t.ctaType).toLowerCase().includes("swipe")||String(t.type).toLowerCase().includes("swipe")||String(t.id).toLowerCase().includes("swipe"),m={width:"100%",height:u.pillH?`${u.pillH}cqh`:"100%",backgroundColor:u.transparent?"transparent":u.backgroundColor||"#3B82F6",color:u.textColor||"#FFFFFF",border:u.borderWidth&&u.borderWidth!=="0px"&&u.borderWidth!=="0cqh"?`${nt(u.borderWidth)} solid ${u.borderColor||"#FFFFFF"}`:"none",borderRadius:h||"4px",fontSize:nt(u.fontSize||14),fontFamily:lt(u.fontFamily)||"Arial",fontStyle:u.fontStyle||"normal",fontWeight:u.fontWeight||"normal",textDecoration:u.textDecoration||"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",outline:"none",padding:"0 12px",wordBreak:"break-word",flexShrink:0},E={position:"relative",width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-end",boxSizing:"border-box",animation:b&&u.arrowAnimation!==!1?"appstorys-swipe-bounce 2.2s ease-in-out infinite":"none",transformOrigin:"bottom center"},j={display:"flex",alignItems:"center",justifyContent:"center",flexGrow:1,width:"100%",color:u.arrowColor||u.textColor||"#FFFFFF",pointerEvents:"none",boxSizing:"border-box"},D=u.arrowSize?`${u.arrowSize}cqh`:"1.5cqh";return(0,vt.jsxs)("div",{style:E,children:[b&&(0,vt.jsxs)(vt.Fragment,{children:[(0,vt.jsx)("style",{children:`
83
88
  @keyframes appstorys-swipe-bounce {
84
89
  0%, 100% {
85
90
  transform: translateY(0) scaleY(1) scaleX(1);
@@ -91,7 +96,7 @@
91
96
  transform: translateY(1px) scaleY(0.97) scaleX(1.02);
92
97
  }
93
98
  }
94
- `}),(0,ft.jsx)("div",{style:I,children:(0,ft.jsx)("svg",{style:{height:z,width:"auto"},viewBox:"0 0 28 18",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",children:(0,ft.jsx)("polyline",{points:"4 14 14 4 24 14"})})})]}),(0,ft.jsx)("button",{onClick:w=>{w.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:g,children:u||t.text})]})}default:return(0,ft.jsxs)("div",{style:{padding:"10px",background:"white",color:"black",borderRadius:"4px"},children:["Unsupported interactive element: ",t.type]})}};return(0,ft.jsx)("div",{style:c,className:`interactive-item-z${t.z??0}`,children:(0,ft.jsx)("div",{style:y,children:b()})})};var no=require("react/jsx-runtime"),zo=(t,e)=>{let o=t?.styling?.editorSource||t?.styling?.meta?.editorSource||t?.style?.editorSource||e?.editorSource||e?.meta?.editorSource||e?.styling?.editorSource||e?.styling?.meta?.editorSource;return o==="studio"||o==="editor"?"studio":"dashboard"},Le=(t,e)=>Array.isArray(t)?t.map((o,i)=>{let n=o?.id||o?.key||o?.value||`option_${i+1}`,r=o?.label||o?.optionLabel,l=typeof o=="string"?o:o?.text||o?.title||r||"";return{id:String(n),text:l,image:o?.image||o?.imageUrl||"",label:r,isCorrect:o?.isCorrect===!0||String(n)===String(e)}}):t&&typeof t=="object"?Object.entries(t).map(([o,i])=>{let n=typeof i=="string"?{text:i}:i||{};return{id:o,text:n.text||n.title||n.label||"",image:n.image||n.imageUrl||"",label:n.label,isCorrect:o===String(e)}}):[],Ei=t=>Array.isArray(t?.emojis)?t.emojis.map(e=>String(e)):Le(t?.options).map(e=>e.text).filter(Boolean),Di=t=>{let e=String(t||"").toLowerCase();return e==="quizz"?"quiz":e==="rate"?"rating":e==="input"||e==="ask_question"||e==="askquestion"?"question":e==="promo"||e==="promocode"?"promo_code":e},_i=(t,e,o)=>{let i=e?.couponCode||e?.code||e?.coupon_code||e?.promoCode||e?.promocode||e?.coupon||e?.value||t?.couponCode||t?.code||t?.coupon_code||o?.couponCode||o?.code||o?.data?.couponCode||o?.data?.code;return typeof i=="string"&&i.trim()!==""?i.trim():"OFFER20"},Pi=t=>{if(t.targetDate)return t.targetDate;if(!t.endDate)return new Date(Date.now()+864e5).toISOString();try{let e=`${t.endDate}${t.endTime?`T${t.endTime}`:""}`;return new Date(e).toISOString()}catch{return t.endDate||new Date(Date.now()+864e5).toISOString()}},un=({content:t={},onInteraction:e,isEditing:o=!1,elapsedTime:i=0})=>{let n=t?.canva||{height:1920,width:1080},r=n?.width||1080,l=n?.height||1920,d=.352,c=t?.elements||[],y=t?.image||[],b=t?.text||[],h=t?.ctas||[],f=t?.interactions||[],v=Array.isArray(t?.shopable)&&t.shopable.length>0?t.shopable:Array.isArray(t?.styling?.shopable)?t.styling.shopable:[],S=new Set(v.map(a=>a.id)),u=(t?.styling?.shopable||[]).concat(v.map(a=>a.styling).filter(Boolean)),g=zo(null,t)==="studio",C=(a,x=g)=>{if(a==null||a==="")return;if(x)return`${a}cqh`;let s=Number(a);return isNaN(s)?String(a):`${s/l*100}cqh`},I=(a,x=g)=>{if(a==null||a==="")return;let s=Number(a);return isNaN(s)?String(a):s<10?`clamp(11px, ${s*.85}cqh, 18px)`:`clamp(11px, ${s/1920*100*1.5}cqh, 18px)`};if(c.length===0&&y.length===0&&b.length===0&&f.length===0&&v.length===0&&h.length===0)return null;let z=c.filter(a=>!S.has(a.id)).map(a=>{let x=a.custom||{},s=x.data||{},p=x.style||a.styling||{},M=zo(a,t),T=M==="studio",R=a.position||a.postion||{},W=a.size||{},H=a.x!==void 0?a.x:R.x,U=a.y!==void 0?a.y:R.y,j=a.width!==void 0?a.width:W.width,V=a.height!==void 0?a.height:W.height,tt=H!==void 0&&!isNaN(Number(H))?T?Number(H):Number(H)/r*100:10,at=U!==void 0&&!isNaN(Number(U))?T?Number(U):Number(U)/l*100:15,nt=j!==void 0&&!isNaN(Number(j))?T?Number(j):Number(j)/r*100:80,lt=V!==void 0&&!isNaN(Number(V))?T?Number(V):Number(V)/l*100:void 0,k={id:a.id||Math.random().toString(),type:Di(x.interactiveType||a.widgetType||a.type||"unknown"),x:tt,y:at,width:nt,height:lt,url:a.url||s.url||a.link||s.link,rotation:p.rotation??a.rotation??0,z:a.z??a.position?.z??p.z??10,duration:s.duration||p.duration,styling:{backgroundColor:gt(p.background||p.containerBgColor||p.backgroundColor),borderRadius:p.borderRadius!==void 0?p.borderRadius>=100?"999px":C(p.borderRadius,T):p.radius!==void 0?p.radius>=100?"999px":C(p.radius,T):"0px",padding:C(p.containerPadding!==void 0?p.containerPadding:p.padding!==void 0?p.padding:0,T),shadow:p.shadow,fontSize:I(p.questionFontSize??p.questionFont?.fontSize??p.questionSize??p.fontSize,T),opacity:p.opacity??1,animation:To(p.animation)}};if(k.type==="poll"){let L=Le(s.options);return{...k,type:"poll",question:s.question||s.title||"Poll Question",options:L,layout:s.layout||{type:"vertical",columns:1},styling:{...k.styling,headerColor:gt(p.headerBgColor||p.background),headerTextColor:G(p.questionColor||p.questionTextColor||p.question?.color),optionBgColor:gt(p.optionBgColor||p.options?.background)||"#1A1A1A",optionTextColor:G(p.optionTextColor||p.options?.textColor)||"#ffffff",optionBorderRadius:p.optionBorderRadius!==void 0?C(p.optionBorderRadius,T):p.options?.radius!==void 0?C(p.options?.radius,T):"0px"}}}if(k.type==="quiz"){let L=p.colors||{},J=Le(s.options,s.isCorrect),ht=p.optionFontSize??p.optionFont?.fontSize??p.typography?.optionSize??p.options?.fontSize??16;return{...k,type:"quiz",question:s.question||s.title||"Quiz Question",options:J,showExplanation:s.showExplanation,url:s.url,styling:{...k.styling,backgroundColor:gt(p.background||p.containerBgColor||p.backgroundColor)||"transparent",questionTextColor:G(p.questionColor||L.questionColor||p.question?.color||p.colors?.questionText)||"#FFFFFF",questionBgColor:gt(p.questionBgColor||L.questionBackground||p.question?.background||p.colors?.questionBg)||"#000000",optionBgColor:gt(p.optionBgColor||L.optionBackground||p.options?.background||p.colors?.optionBg)||"#FFFFFF",optionTextColor:G(p.optionTextColor||L.optionTextColor||p.options?.textColor||p.colors?.optionText)||"#2B2B2B",borderColor:G(p.borderColor)||"transparent",activeColor:G(p.correctColor||L.correctColor||p.correctBorderColor)||"#10b981",incorrectColor:G(p.incorrectColor||L.incorrectColor)||"#ef4444",optionBorderRadius:p.optionRadius!==void 0?p.optionRadius>=100?"999px":C(p.optionRadius,T):p.optionBorderRadius!==void 0?p.optionBorderRadius>=100?"999px":C(p.optionBorderRadius,T):"100px",optionFontSize:I(ht,T)}}}if(k.type==="rating")return{...k,type:"rating",title:s.title||"Do you like my space?",emoji:s.emoji||"\u{1F60D}",currentRating:s.currentRating,maxRating:s.maxRating,styling:{...k.styling,sliderTrackColor:G(p.colors?.sliderTrack||p.sliderTrack),sliderFillColor:G(p.colors?.sliderFill||p.sliderFill),emojiSize:p.emojiSize?T?`${Math.min(Number(p.emojiSize),32)}px`:`${Math.min(p.emojiSize*.45,32)}px`:void 0,titleColor:G(p.colors?.titleColor||p.titleColor),titleFontSize:p.titleFontSize?T?`${Math.min(Number(p.titleFontSize),16)}px`:`${Math.min(p.titleFontSize*.4,16)}px`:void 0}};if(k.type==="question")return{...k,type:"question",question:s.question||s.title||"Ask me a question",placeholder:s.placeholder||"Type your answer...",styling:{...k.styling,promptColor:G(p.questionColor||p.textColor),inputBgColor:gt(p.inputBgColor),inputTextColor:G(p.inputTextColor),submitBackground:gt(p.submitBackground)}};if(k.type==="image_quiz"||k.type==="imageQuiz"||(x.interactiveType||"").toLowerCase()==="media_quiz"){let L=p.optionFontSize??p.optionFont?.fontSize??p.typography?.optionSize??p.options?.fontSize??13;return{...k,type:"image_quiz",question:s.question||s.title||"Image Quiz",options:Le(s.options||[]),styling:{...k.styling,questionTextColor:G(p.questionColor),activeColor:G(p.correctColor||p.correctBorderColor),incorrectColor:G(p.incorrectColor),imageRadius:p.imageRadius?C(p.imageRadius,T):void 0,optionFontSize:I(L,T)}}}if(k.type==="countdown")return{...k,type:"countdown",title:s.title||"Ends in...",targetDate:Pi(s),styling:{...k.styling,borderColor:G(p.borderColor),digitBackground:gt(p.digitBackground),digitColor:G(p.digitColor),digitSize:p.digitSize||p.fontSize?I(p.digitSize||p.fontSize,T):void 0,labelColor:G(p.labelColor),titleColor:G(p.titleColor)},display:s.display};if(k.type==="promo_code")return{...k,width:k.width?Math.max(k.width,65):75,type:"promo_code",code:_i(a,s,x),styling:{...k.styling,borderColor:G(p.borderColor)}};if(k.type==="reaction"||k.type==="emoji_reaction"){let L=Ei(s);return{...k,type:"reaction",emojis:L.length>0?L:["\u{1F60D}","\u{1F44D}"],source:M}}return k}),E=(t?.interactions||[]).filter(a=>!S.has(a.id)).map(a=>{let x=a.config||{},s=a.styling||a.style||{},p=zo(a,t),M=p==="studio",T=Di(a.interaction_type||a.type),R=s.position||a.position||{},W=s.size||a.size||{},H=R.x??a.x,U=R.y??a.y,j=W.width??a.width,V=W.height??a.height,tt=H!==void 0&&!isNaN(Number(H))?M?Number(H):Number(H)/r*100:10,at=U!==void 0&&!isNaN(Number(U))?M?Number(U):Number(U)/l*100:15,nt=j!==void 0&&!isNaN(Number(j))?M?Number(j):Number(j)/r*100:80,lt=V!==void 0&&!isNaN(Number(V))?M?Number(V):Number(V)/l*100:void 0,k={id:a.id||Math.random().toString(),type:T,x:tt,y:at,width:nt,height:lt,rotation:s.rotation??a.rotation??0,z:a.z??a.position?.z??s.z??10,source:p,duration:x.duration||s.duration,styling:{backgroundColor:gt(s.background||s.containerBgColor||s.backgroundColor),borderRadius:s.borderRadius!==void 0?s.borderRadius>=100?"999px":C(s.borderRadius,M):s.radius!==void 0?s.radius>=100?"999px":C(s.radius,M):"0px",padding:C(s.containerPadding!==void 0?s.containerPadding:s.padding!==void 0?s.padding:0,M),shadow:s.shadow,fontSize:I(s.questionFontSize??s.questionFont?.fontSize??s.questionSize??s.fontSize,M),opacity:s.opacity??1,animation:To(s.animation)}};if(k.type==="rating"||k.type==="rate"){let L=s.colors||{};return{...k,type:"rating",title:x.title||"Do you like my space?",emoji:x.emoji||"\u{1F60D}",currentRating:x.currentRating,maxRating:x.maxRating,styling:{...k.styling,sliderTrackColor:G(L.sliderTrack||s.colors?.sliderTrack||s.colors?.sliderTrack),sliderFillColor:G(L.sliderFill||s.colors?.sliderFill||s.colors?.sliderFill),emojiSize:s.emojiSize?M?`${Math.min(Number(s.emojiSize),32)}px`:`${Math.min(s.emojiSize*.45,32)}px`:void 0,titleColor:G(L.titleColor||s.colors?.titleColor||s.titleColor),titleFontSize:s.titleFontSize?M?`${Math.min(Number(s.titleFontSize),16)}px`:`${Math.min(s.titleFontSize*.4,16)}px`:void 0}}}if(k.type==="poll"){let L=Le(x.options);return{...k,type:"poll",question:x.question||x.title||"Poll Question",options:L,layout:x.layout||{type:"vertical",columns:1},styling:{...k.styling,headerColor:gt(s.headerBgColor||s.background),headerTextColor:G(s.questionColor||s.questionTextColor||s.question?.color),optionBgColor:gt(s.optionBgColor||s.options?.background)||"#1A1A1A",optionTextColor:G(s.optionTextColor||s.options?.textColor)||"#ffffff",optionBorderRadius:s.optionBorderRadius!==void 0?C(s.optionBorderRadius,M):s.options?.radius!==void 0?C(s.options?.radius,M):"0px"}}}if(k.type==="quiz"){let L=s.colors||{},J=Le(x.options,x.isCorrect),ht=s.optionFontSize??s.optionFont?.fontSize??s.typography?.optionSize??s.options?.fontSize??16;return{...k,type:"quiz",question:x.question||x.title||"Quiz Question",options:J,showExplanation:x.showExplanation,url:x.url,styling:{...k.styling,backgroundColor:gt(s.background||s.containerBgColor||s.backgroundColor)||"transparent",questionTextColor:G(s.questionColor||L.questionColor||s.question?.color||s.colors?.questionText)||"#FFFFFF",questionBgColor:gt(s.questionBgColor||L.questionBackground||s.question?.background||s.colors?.questionBg)||"#000000",optionBgColor:gt(s.optionBgColor||L.optionBackground||s.options?.background||s.colors?.optionBg)||"#FFFFFF",optionTextColor:G(s.optionTextColor||L.optionTextColor||s.options?.textColor||s.colors?.optionText)||"#2B2B2B",borderColor:G(s.borderColor)||"transparent",activeColor:G(s.correctColor||L.correctColor||s.correctBorderColor)||"#10b981",incorrectColor:G(s.incorrectColor||L.incorrectColor)||"#ef4444",optionBorderRadius:s.optionRadius!==void 0?s.optionRadius>=100?"999px":C(s.optionRadius,M):s.optionBorderRadius!==void 0?s.optionBorderRadius>=100?"999px":C(s.optionBorderRadius,M):"100px",optionFontSize:I(ht,M)}}}if(k.type==="question")return{...k,type:"question",question:x.question||x.title||"Ask me a question",placeholder:x.placeholder||"Type your answer...",styling:{...k.styling,promptColor:G(s.questionColor||s.promptColor||s.textColor),inputBgColor:gt(s.inputBackground||s.inputBgColor),inputTextColor:G(s.inputTextColor),submitBackground:gt(s.submitBackground)}};if(k.type==="image_quiz"||k.type==="imageQuiz"||T==="media_quiz"){let L=s.optionFontSize??s.optionFont?.fontSize??s.typography?.optionSize??s.options?.fontSize??13;return{...k,type:"image_quiz",question:x.question||x.title||"Image Quiz",options:Le(x.options||[]),styling:{...k.styling,questionTextColor:G(s.questionColor),activeColor:G(s.correctColor||s.correctBorderColor),incorrectColor:G(s.incorrectColor),imageRadius:s.imageRadius?C(s.imageRadius,M):void 0,optionFontSize:I(L,M)}}}if(k.type==="countdown")return{...k,type:"countdown",title:x.title||"Ends in...",targetDate:Pi(x),styling:{...k.styling,borderColor:G(s.borderColor),digitBackground:gt(s.digitBackground),digitColor:G(s.digitColor),digitSize:s.digitSize||s.fontSize?I(s.digitSize||s.fontSize,M):void 0,labelColor:G(s.labelColor),titleColor:G(s.titleColor),labelFontSize:s.labelFontSize?I(s.labelFontSize,M):void 0},display:x.display||a.display};if(k.type==="promo_code")return{...k,width:k.width?Math.max(k.width,65):75,type:"promo_code",code:_i(a,x,s),styling:{...k.styling,borderColor:G(s.borderColor)}};if(k.type==="reaction"||k.type==="emoji_reaction"){let L=Ei(x);return{...k,type:"reaction",emojis:L.length>0?L:["\u{1F60D}","\u{1F44D}"]}}return k}),w=v.map(a=>{let x=u.find(Y=>String(Y?.id)===String(a?.id))||u.find(Y=>Y?.id===void 0)||{},p=zo(a,t)==="studio",M={position:a?.position,size:a?.size,rotation:a?.rotation,z:a?.z,background:a?.background,cardBackground:a?.cardBackground,cardBorderRadius:a?.cardBorderRadius,cardRadiusPercent:a?.cardRadiusPercent,transparent:a?.transparent,textColor:a?.textColor,buttonBackground:a?.buttonBackground,buttonTextColor:a?.buttonTextColor,buttonFontSize:a?.buttonFontSize,buttonBorderRadius:a?.buttonBorderRadius,titleColor:a?.titleColor,titleFontSize:a?.titleFontSize,titleFontWeight:a?.titleFontWeight,priceColor:a?.priceColor,priceFontSize:a?.priceFontSize,priceFontWeight:a?.priceFontWeight,mrpColor:a?.mrpColor,mrpFontSize:a?.mrpFontSize,mrpFontWeight:a?.mrpFontWeight,imageRadius:a?.imageRadius,opacity:a?.opacity,animation:a?.animation},T={...x,...a?.styling||{},...Object.fromEntries(Object.entries(M).filter(([,Y])=>Y!==void 0))},R=T.position||{},W=T.size||{},H=T.cardBorderRadius!==void 0?Number(T.cardBorderRadius):void 0,U=T.cardRadiusPercent!==void 0?Number(T.cardRadiusPercent):void 0,j=W.height!==void 0?Number(W.height):void 0,V=H===void 0&&U!==void 0&&j!==void 0?Math.max(0,Math.min(100,U))/100*(j/2):void 0,tt=H??V,at=tt!==void 0&&!isNaN(tt)?tt*d:void 0,nt=R.x!==void 0?p?Number(R.x):Number(R.x)/r*100:0,lt=W.width!==void 0?p?Number(W.width):Number(W.width)/r*100:100,k=W.height!==void 0?p?Number(W.height):Number(W.height)/l*100:void 0,L=R.y!==void 0?p?Number(R.y):Number(R.y)/l*100:k?100-k-2.5:85;k&&L+k>96?L=Math.max(0,100-k):L>75&&k&&L+k>91&&(L=Math.max(0,100-k-1));let J=Array.isArray(a.product)&&a.product.length>0,ht=J?a.product:a.static||[];return{id:a.id||Math.random().toString(),type:"buy",shopableType:J?"product":"static",x:nt,y:L,width:lt,height:k,rotation:T.rotation??0,z:T.z??10,products:ht.map(Y=>{let O=Y.productData||Y||{},et=O.attributes||Y.attributes||{},ut=et.sales_price||O.price||et.price||Y.price,Ct=et.sales_price?O.price||et.price||Y.price:O.oldPrice||Y.oldPrice,yt=O.color||et.color||Y.color,dt=O.size||et.size||Y.size,Bt=et.colors||[];Bt.length===0&&yt&&(Bt=[{id:yt,hex:yt,name:yt}]);let Pt=et.sizes||[];Pt.length===0&&dt&&(Pt=typeof dt=="string"?dt.split(",").map(ge=>ge.trim()):[dt]);let Ee={description:O.description||et.description||Y.description,color:yt,size:dt,colors:Bt,sizes:Pt,imageUrls:et.imageUrls||[et.image_link||O.imageUrl||O.image||Y.imageUrl||Y.image||Y.url].filter(Boolean),availability:O.availability||et.availability||Y.availability,tags:O.tags||et.tags||Y.tags,...et};return{id:O.productId||O.id||Y.productId||Y.id||Math.random().toString(),image:et.image_link||O.imageUrl||O.image||Y.imageUrl||Y.image||Y.url,url:O.link||O.url||Y.link||Y.url||Y.redirectUrl,title:O.title||Y.title,price:ut,oldPrice:Ct,redirectUrl:Y.redirectUrl||O.link||Y.link||Y.url,svg:O.svg||Y.svg,productId:O.productId||Y.productId,collectionId:O.collectionId||Y.collectionId,feedId:O.feedId||Y.feedId,attributes:Ee}}),styling:{backgroundColor:gt(T.background),cardBackground:gt(T.cardBackground)||gt(T.background)||"#ffffff",cardBorderRadius:tt!==void 0&&!isNaN(tt)?p?`${tt}cqh`:`${at}px`:p?"1cqh":"10px",cardRadiusPercent:U,transparent:T.transparent===!0,textColor:G(T.textColor)||"#ffffff",buttonBackground:gt(T.buttonBackground)||"#000000",buttonTextColor:G(T.buttonTextColor)||"#ffffff",buttonFontSize:I(T.buttonFontSize||12,p),buttonBorderRadius:T.buttonBorderRadius!==void 0?p?`${T.buttonBorderRadius}cqh`:`${T.buttonBorderRadius}px`:p?"10cqh":"100px",titleColor:G(T.titleColor||T.textColor)||"#1a1a2e",titleFontSize:I(T.titleFontSize||14,p),titleFontWeight:T.titleFontWeight?String(T.titleFontWeight):"600",priceColor:G(T.priceColor||T.textColor)||"#1a1a2e",priceFontSize:I(T.priceFontSize||16,p),priceFontWeight:T.priceFontWeight?String(T.priceFontWeight):"700",mrpColor:G(T.mrpColor)||"#8b8b98",mrpFontSize:I(T.mrpFontSize||12,p),mrpFontWeight:T.mrpFontWeight?String(T.mrpFontWeight):"500",imageRadius:T.imageRadius!==void 0?p?`${T.imageRadius}cqh`:`${Number(T.imageRadius)*d}px`:p?"1cqh":"10px",animation:To(T.animation)}}}),_=y.map(a=>{let x=a.position||a.postion||{x:0,y:0};return{id:a.id||Math.random().toString(),type:"image",x:g?Number(x.x):x.x/r*100,y:g?Number(x.y):x.y/l*100,width:g?Number(a.width):a.width/r*100,height:a.height?g?Number(a.height):a.height/l*100:void 0,url:a.link||a.url,z:a.z??0}}),P=b.map(a=>{let s=(t?.styling?.text||[]).find(V=>V.id===a.id)||{},p=a.position||s.position||{x:0,y:0},M=a.font||s.font||{},T=a.size||s.size||{},R=a.alignment||s.alignment||{},W=a.color||s.color,H=M.fontDecoration||[],U=H.includes("underline")?"underline":H.includes("line-through")?"line-through":void 0,j=a.rotation!==void 0?a.rotation:s.rotation;return{id:a.id||Math.random().toString(),type:"text",x:g?Number(p.x):p.x/r*100,y:g?Number(p.y):p.y/l*100,width:T.width?g?Number(T.width):T.width/r*100:void 0,height:T.height?g?Number(T.height):T.height/l*100:void 0,rotation:j??0,text:a.text||a.value||s.text||s.value||"",z:a.z??s.z??1,styling:{color:G(W)||"#000000",fontSize:M.fontSize?I(M.fontSize,g):void 0,fontFamily:M.fontFamily,fontStyle:M.fontStyle||(H.includes("italic")?"italic":"normal"),fontWeight:M.fontWeight||(H.includes("bold")?"bold":"normal"),textDecoration:U,lineHeight:a.lineHeight!==void 0?a.lineHeight:s.lineHeight,letterSpacing:(a.letterSpacing!==void 0?a.letterSpacing:s.letterSpacing)!==void 0?`${a.letterSpacing!==void 0?a.letterSpacing:s.letterSpacing}px`:void 0,opacity:(a.opacity!==void 0?a.opacity:s.opacity)!==void 0?Number(a.opacity!==void 0?a.opacity:s.opacity)/100:void 0,textAlign:R.horizontalAlignment||"left",verticalAlignment:R.verticalAlignment||"top"}}}),$=h.map(a=>{let s=(t?.styling?.ctas||[]).find(U=>U.id===a.id)||{},p=a.position||s.position||{x:0,y:0},M=a.size||s.size||{},T=a.font||s.font||{},R=T.fontDecoration||[],W=R.includes("underline")?"underline":R.includes("line-through")?"line-through":void 0,H=a.rotation!==void 0?a.rotation:s.rotation;return{id:a.id||Math.random().toString(),type:"cta",x:g?Number(p.x):p.x/r*100,y:g?Number(p.y):p.y/l*100,width:M.width?g?Number(M.width):M.width/r*100:void 0,height:M.height?g?Number(M.height):M.height/l*100:void 0,rotation:H??0,text:a.text||s.text||"Learn More",redirectUrl:a.redirectUrl||s.redirectUrl||a.link||s.link,ctaType:a.type||s.type||"classic",url:a.url||s.url,z:a.z??s.z??10,source:g?"studio":"dashboard",styling:{backgroundColor:gt(a.background||s.background),textColor:G(a.textColor||s.textColor)||"#FFFFFF",borderColor:G(a.borderColor||s.borderColor)||"transparent",borderWidth:a.borderWidth!==void 0?a.borderWidth:s.borderWidth,borderRadius:C(a.borderRadius!==void 0?a.borderRadius:s.borderRadius,g),fontSize:T.fontSize?I(T.fontSize,g):void 0,fontFamily:T.fontFamily,fontStyle:T.fontStyle||(R.includes("italic")?"italic":"normal"),fontWeight:T.fontWeight||(R.includes("bold")?"bold":"normal"),textDecoration:W,pillH:s.pillH,arrowAnimation:s.arrowAnimation,arrowColor:G(s.arrowColor),arrowSize:s.arrowSize,transparent:s.transparent}}}),q=[...z,...E,...w,..._,...P,...$].filter(a=>{if(!a.duration)return!0;let{start:x,end:s}=a.duration;return i>=x&&i<=s}).sort((a,x)=>(a.z??0)-(x.z??0));return console.log("InteractiveOverlay Debug - content.ctas:",h,"displayCtas:",$,"displayItems:",q),(0,no.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,pointerEvents:"none",overflow:"hidden",containerType:"size"},children:[(0,no.jsx)("style",{children:`
99
+ `}),(0,vt.jsx)("div",{style:j,children:(0,vt.jsx)("svg",{style:{height:D,width:"auto"},viewBox:"0 0 28 18",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",children:(0,vt.jsx)("polyline",{points:"4 14 14 4 24 14"})})})]}),(0,vt.jsx)("button",{onClick:v=>{v.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:m,children:g||t.text})]})}default:return(0,vt.jsxs)("div",{style:{padding:"10px",background:"white",color:"black",borderRadius:"4px"},children:["Unsupported interactive element: ",t.type]})}};return(0,vt.jsx)("div",{style:d,className:`interactive-item-z${t.z??0}`,children:(0,vt.jsx)("div",{style:S,children:p()})})};var Ao=require("react/jsx-runtime"),en=(t,e)=>{let o=t?.styling?.editorSource||t?.styling?.meta?.editorSource||t?.style?.editorSource||e?.editorSource||e?.meta?.editorSource||e?.styling?.editorSource||e?.styling?.meta?.editorSource;return o==="studio"||o==="editor"?"studio":"dashboard"},sr=t=>{if(!t)return!1;let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")},go=(...t)=>{for(let e of t)if(e){if(typeof e=="object"){let o=e.fontFamily||e.font_family||e.font?.fontFamily||e.font?.font_family;if(typeof o=="string"&&o.trim()){let n=o.trim();if(sr(n)||n.length<50&&!/[?!.,;:\n]/.test(n))return n}}if(typeof e=="string"){let o=e.trim();if(!o)continue;if(sr(o)||o.length<35&&!/[?!.,;:\n]/.test(o)&&o.split(/\s+/).length<=3)return o}}},to=(t,e)=>Array.isArray(t)?t.map((o,n)=>{let i=o?.id||o?.key||o?.value||`option_${n+1}`,s=o?.label||o?.optionLabel,l=typeof o=="string"?o:o?.text||o?.title||s||"";return{id:String(i),text:l,image:o?.image||o?.imageUrl||"",label:s,isCorrect:o?.isCorrect===!0||String(i)===String(e)}}):t&&typeof t=="object"?Object.entries(t).map(([o,n])=>{let i=typeof n=="string"?{text:n}:n||{};return{id:o,text:i.text||i.title||i.label||"",image:i.image||i.imageUrl||"",label:i.label,isCorrect:o===String(e)}}):[],ar=t=>Array.isArray(t?.emojis)?t.emojis.map(e=>String(e)):to(t?.options).map(e=>e.text).filter(Boolean),lr=t=>{let e=String(t||"").toLowerCase();return e==="quizz"?"quiz":e==="rate"?"rating":e==="input"||e==="ask_question"||e==="askquestion"?"question":e==="promo"||e==="promocode"?"promo_code":e},dr=(t,e,o)=>{let n=e?.couponCode||e?.code||e?.coupon_code||e?.promoCode||e?.promocode||e?.coupon||e?.value||t?.couponCode||t?.code||t?.coupon_code||o?.couponCode||o?.code||o?.data?.couponCode||o?.data?.code;return typeof n=="string"&&n.trim()!==""?n.trim():"OFFER20"},cr=t=>{if(t.targetDate)return t.targetDate;if(!t.endDate)return new Date(Date.now()+864e5).toISOString();try{let e=`${t.endDate}${t.endTime?`T${t.endTime}`:""}`;return new Date(e).toISOString()}catch{return t.endDate||new Date(Date.now()+864e5).toISOString()}},On=({content:t={},onInteraction:e,isEditing:o=!1,elapsedTime:n=0})=>{let i=t?.canva||t?.styling?.canva||t?.meta?.canva||{height:1920,width:1080},s=Number(i?.width)||1080,l=Number(i?.height)||1920,c=.352,d=t?.elements||[],S=t?.image||[],p=t?.video||t?.styling?.video||[],y=Array.isArray(p)?p:typeof p=="object"&&p!==null?[p]:[],u=t?.lottie||t?.styling?.lottie||t?.styling?.lotties||t?.meta?.lottie||[],C=Array.isArray(u)?u:typeof u=="object"&&u!==null?[u]:[],h=t?.text||[],g=t?.ctas||[],b=t?.interactions||[],m=Array.isArray(t?.shopable)&&t.shopable.length>0?t.shopable:Array.isArray(t?.styling?.shopable)?t.styling.shopable:[],E=new Set(m.map(r=>r.id)),j=(t?.styling?.shopable||[]).concat(m.map(r=>r.styling).filter(Boolean)),L=en(null,t)==="studio",v=(r,M=L)=>{if(r==null||r==="")return;if(typeof r=="string"&&(r.endsWith("cqh")||r.endsWith("px")||r.endsWith("%")||r.endsWith("em")||r.endsWith("rem")))return r;let a=Number(r);return isNaN(a)?String(r):a>=1e3?"999px":M||a<=100?`${a}cqh`:`${a/l*100}cqh`},w=(r,M=L)=>{if(r==null||r==="")return;if(typeof r=="string"&&(r.endsWith("cqh")||r.endsWith("px")||r.endsWith("%")||r.endsWith("em")||r.endsWith("rem")))return r;let a=Number(r);if(isNaN(a))return String(r);let f;return a<10?f=a:f=a/l*100,f<1.4?`clamp(11px, ${(f*1.25).toFixed(3)}cqh, 22px)`:f<2.5?`clamp(14px, ${(f*1.15).toFixed(3)}cqh, 32px)`:`clamp(16px, ${(f*1.05).toFixed(3)}cqh, 48px)`};if(d.length===0&&S.length===0&&y.length===0&&C.length===0&&h.length===0&&b.length===0&&m.length===0&&g.length===0)return null;let _=d.filter(r=>!E.has(r.id)).map(r=>{let M=r.custom||{},a=M.data||{},f=M.style||r.styling||{},x=en(r,t),z=x==="studio",Y=r.position||r.postion||{},ot=r.size||{},J=r.x!==void 0?r.x:Y.x,H=r.y!==void 0?r.y:Y.y,K=r.width!==void 0?r.width:ot.width,it=r.height!==void 0?r.height:ot.height,xt=J!==void 0&&!isNaN(Number(J))?z?Number(J):Number(J)/s*100:10,ut=H!==void 0&&!isNaN(Number(H))?z?Number(H):Number(H)/l*100:15,Z=K!==void 0&&!isNaN(Number(K))?z?Number(K):Number(K)/s*100:80,rt=it!==void 0&&!isNaN(Number(it))?z?Number(it):Number(it)/l*100:void 0,dt=go(a.question,a.prompt,a.title,f.question,r.question,f.prompt,r.font,f.font,a.font,a.fontFamily,r.fontFamily,f.fontFamily),ht=go(a.options,f.options,r.options,a.font,f.font,r.font,a.fontFamily,r.fontFamily,f.fontFamily),mt=go(a.font,f.font,r.font,a.fontFamily,r.fontFamily,f.fontFamily),R={id:r.id||Math.random().toString(),type:lr(M.interactiveType||r.widgetType||r.type||"unknown"),x:xt,y:ut,width:Z,height:rt,url:r.url||a.url||r.link||a.link,rotation:f.rotation??r.rotation??0,z:r.z??r.position?.z??f.z??10,duration:a.duration||f.duration,styling:{backgroundColor:Ct(f.background||f.containerBgColor||f.backgroundColor),borderRadius:f.borderRadius!==void 0?f.borderRadius>=100?"999px":v(f.borderRadius,z):f.radius!==void 0?f.radius>=100?"999px":v(f.radius,z):"0px",padding:v(f.containerPadding!==void 0?f.containerPadding:f.padding!==void 0?f.padding:0,z),shadow:f.shadow,fontSize:w(f.questionFontSize??f.questionFont?.fontSize??f.questionSize??f.fontSize,z),opacity:f.opacity??1,animation:Bo(f.animation),fontFamily:mt,questionFontFamily:dt||mt,optionFontFamily:ht||mt}};if(R.type==="poll"){let I=to(a.options);return{...R,type:"poll",question:a.question||a.title||"Poll Question",options:I,layout:a.layout||{type:"vertical",columns:1},styling:{...R.styling,headerColor:Ct(f.headerBgColor||f.background),headerTextColor:et(f.questionColor||f.questionTextColor||f.question?.color),optionBgColor:Ct(f.optionBgColor||f.options?.background)||"#1A1A1A",optionTextColor:et(f.optionTextColor||f.options?.textColor)||"#ffffff",optionBorderRadius:f.optionBorderRadius!==void 0?v(f.optionBorderRadius,z):f.options?.radius!==void 0?v(f.options?.radius,z):"0px"}}}if(R.type==="quiz"){let I=f.colors||{},O=to(a.options,a.isCorrect),tt=f.optionFontSize??f.optionFont?.fontSize??f.typography?.optionSize??f.options?.fontSize??16;return{...R,type:"quiz",question:a.question||a.title||"Quiz Question",options:O,showExplanation:a.showExplanation??r.showExplanation??f.showExplanation??M.showExplanation??!0,explanation:a.explanation||r.explanation||f.explanation||M.explanation,url:a.url,styling:{...R.styling,backgroundColor:Ct(f.background||f.containerBgColor||f.backgroundColor)||"transparent",questionTextColor:et(f.questionColor||I.questionColor||f.question?.color||f.colors?.questionText)||"#FFFFFF",questionBgColor:Ct(f.questionBgColor||I.questionBackground||f.question?.background||f.colors?.questionBg)||"#000000",optionBgColor:Ct(f.optionBgColor||I.optionBackground||f.options?.background||f.colors?.optionBg)||"#FFFFFF",optionTextColor:et(f.optionTextColor||I.optionTextColor||f.options?.textColor||f.colors?.optionText)||"#2B2B2B",borderColor:et(f.borderColor)||"transparent",activeColor:et(f.correctColor||I.correctColor||f.correctBorderColor)||"#10b981",incorrectColor:et(f.incorrectColor||I.incorrectColor)||"#ef4444",optionBorderRadius:f.optionRadius!==void 0?f.optionRadius>=100?"999px":v(f.optionRadius,z):f.optionBorderRadius!==void 0?f.optionBorderRadius>=100?"999px":v(f.optionBorderRadius,z):"100px",optionFontSize:w(tt,z)}}}if(R.type==="rating")return{...R,type:"rating",title:a.title||"Do you like my space?",emoji:a.emoji||"\u{1F60D}",currentRating:a.currentRating,maxRating:a.maxRating,styling:{...R.styling,sliderTrackColor:et(f.colors?.sliderTrack||f.sliderTrack),sliderFillColor:et(f.colors?.sliderFill||f.sliderFill),emojiSize:f.emojiSize?z?`${Math.min(Number(f.emojiSize),32)}px`:`${Math.min(f.emojiSize*.45,32)}px`:void 0,titleColor:et(f.colors?.titleColor||f.titleColor),titleFontSize:f.titleFontSize?z?`${Math.min(Number(f.titleFontSize),16)}px`:`${Math.min(f.titleFontSize*.4,16)}px`:void 0}};if(R.type==="question"){let I=f.optionRadius??f.optionBorderRadius??f.inputRadius??f.inputBorderRadius,O=f.borderRadius??f.radius??f.containerBorderRadius;return{...R,type:"question",question:a.question||a.title||"Ask me a question",placeholder:a.placeholder||"Type your answer...",styling:{...R.styling,borderRadius:O!==void 0?O>=100?"999px":v(O,z):"16px",promptColor:et(f.questionColor||f.promptColor||f.textColor),inputBgColor:Ct(f.inputBackground||f.inputBgColor),inputTextColor:et(f.inputTextColor),submitBackground:Ct(f.submitBackground),optionRadius:I!==void 0?I>=5?"9999px":v(I,z):"9999px",inputBorderRadius:I!==void 0?I>=5?"9999px":v(I,z):"9999px"}}}if(R.type==="image_quiz"||R.type==="imageQuiz"||(M.interactiveType||"").toLowerCase()==="media_quiz"){let I=f.optionFontSize??f.optionFont?.fontSize??f.typography?.optionSize??f.options?.fontSize??13,O=f.borderRadius??f.radius??f.containerBorderRadius,tt=f.optionRadius??f.optionBorderRadius??f.imageRadius;return{...R,type:"image_quiz",question:a.question||a.title||"Image Quiz",options:to(a.options||[]),layout:a.layout??f.layout??r.layout,styling:{...R.styling,borderRadius:O!==void 0?O>=100?"999px":v(O,z):void 0,optionRadius:tt!==void 0?tt>=100?"999px":v(tt,z):void 0,questionBgColor:Ct(f.questionBgColor||f.questionBackground),questionTextColor:et(f.questionColor||f.questionTextColor),optionBgColor:Ct(f.optionBgColor||f.optionBackground),optionTextColor:et(f.optionTextColor||f.textColor),labelColor:et(f.labelColor),borderColor:et(f.borderColor),activeColor:et(f.correctBorderColor||f.correctColor||f.activeColor),incorrectColor:et(f.incorrectColor),imageRadius:tt!==void 0?v(tt,z):void 0,optionFontSize:w(I,z)}}}if(R.type==="countdown")return{...R,type:"countdown",title:a.title||"Ends in...",targetDate:cr(a),styling:{...R.styling,borderColor:et(f.borderColor),digitBackground:Ct(f.digitBackground),digitColor:et(f.digitColor),digitSize:f.digitSize||f.fontSize?w(f.digitSize||f.fontSize,z):void 0,labelColor:et(f.labelColor),titleColor:et(f.titleColor)},display:a.display};if(R.type==="promo_code")return{...R,width:R.width?Math.max(R.width,65):75,type:"promo_code",code:dr(r,a,M),styling:{...R.styling,borderColor:et(f.borderColor)}};if(R.type==="reaction"||R.type==="emoji_reaction"){let I=ar(a);return{...R,type:"reaction",emojis:I.length>0?I:["\u{1F60D}","\u{1F44D}"],source:x}}return R}),N=(t?.interactions||[]).filter(r=>!E.has(r.id)).map(r=>{let M=r.config||{},a=r.styling||r.style||{},f=en(r,t),x=f==="studio",z=lr(r.interaction_type||r.type),Y=a.position||r.position||{},ot=a.size||r.size||{},J=Y.x??r.x,H=Y.y??r.y,K=ot.width??r.width,it=ot.height??r.height,xt=J!==void 0&&!isNaN(Number(J))?x?Number(J):Number(J)/s*100:10,ut=H!==void 0&&!isNaN(Number(H))?x?Number(H):Number(H)/l*100:15,Z=K!==void 0&&!isNaN(Number(K))?x?Number(K):Number(K)/s*100:80,rt=it!==void 0&&!isNaN(Number(it))?x?Number(it):Number(it)/l*100:void 0,dt=go(a.question,r.question,a.prompt,M.question,M.prompt,M.title,a.font,r.font,M.font,a.fontFamily,M.fontFamily,r.fontFamily),ht=go(a.options,r.options,M.options,a.font,r.font,M.font,a.fontFamily,M.fontFamily,r.fontFamily),mt=go(a.font,r.font,M.font,a.fontFamily,M.fontFamily,r.fontFamily),R={id:r.id||Math.random().toString(),type:z,x:xt,y:ut,width:Z,height:rt,rotation:a.rotation??r.rotation??0,z:r.z??r.position?.z??a.z??10,source:f,duration:M.duration||a.duration,styling:{backgroundColor:Ct(a.background||a.containerBgColor||a.backgroundColor),borderRadius:a.borderRadius!==void 0?a.borderRadius>=100?"999px":v(a.borderRadius,x):a.radius!==void 0?a.radius>=100?"999px":v(a.radius,x):"0px",padding:v(a.containerPadding!==void 0?a.containerPadding:a.padding!==void 0?a.padding:0,x),shadow:a.shadow,fontSize:w(a.questionFontSize??a.questionFont?.fontSize??a.questionSize??a.fontSize,x),opacity:a.opacity??1,animation:Bo(a.animation),fontFamily:mt,questionFontFamily:dt||mt,optionFontFamily:ht||mt}};if(R.type==="rating"||R.type==="rate"){let I=a.colors||{};return{...R,type:"rating",title:M.title||"Do you like my space?",emoji:M.emoji||"\u{1F60D}",currentRating:M.currentRating,maxRating:M.maxRating,styling:{...R.styling,sliderTrackColor:et(I.sliderTrack||a.colors?.sliderTrack||a.colors?.sliderTrack),sliderFillColor:et(I.sliderFill||a.colors?.sliderFill||a.colors?.sliderFill),emojiSize:a.emojiSize?x?`${Math.min(Number(a.emojiSize),32)}px`:`${Math.min(a.emojiSize*.45,32)}px`:void 0,titleColor:et(I.titleColor||a.colors?.titleColor||a.titleColor),titleFontSize:a.titleFontSize?x?`${Math.min(Number(a.titleFontSize),16)}px`:`${Math.min(a.titleFontSize*.4,16)}px`:void 0}}}if(R.type==="poll"){let I=to(M.options);return{...R,type:"poll",question:M.question||M.title||"Poll Question",options:I,layout:M.layout||{type:"vertical",columns:1},styling:{...R.styling,headerColor:Ct(a.headerBgColor||a.background),headerTextColor:et(a.questionColor||a.questionTextColor||a.question?.color),optionBgColor:Ct(a.optionBgColor||a.options?.background)||"#1A1A1A",optionTextColor:et(a.optionTextColor||a.options?.textColor)||"#ffffff",optionBorderRadius:a.optionBorderRadius!==void 0?v(a.optionBorderRadius,x):a.options?.radius!==void 0?v(a.options?.radius,x):"0px"}}}if(R.type==="quiz"){let I=a.colors||{},O=to(M.options,M.isCorrect),tt=a.optionFontSize??a.optionFont?.fontSize??a.typography?.optionSize??a.options?.fontSize??16;return{...R,type:"quiz",question:M.question||M.title||"Quiz Question",options:O,showExplanation:M.showExplanation??r.showExplanation??a.showExplanation??!0,explanation:M.explanation||r.explanation||a.explanation,url:M.url,styling:{...R.styling,backgroundColor:Ct(a.background||a.containerBgColor||a.backgroundColor)||"transparent",questionTextColor:et(a.questionColor||I.questionColor||a.question?.color||a.colors?.questionText)||"#FFFFFF",questionBgColor:Ct(a.questionBgColor||I.questionBackground||a.question?.background||a.colors?.questionBg)||"#000000",optionBgColor:Ct(a.optionBgColor||I.optionBackground||a.options?.background||a.colors?.optionBg)||"#FFFFFF",optionTextColor:et(a.optionTextColor||I.optionTextColor||a.options?.textColor||a.colors?.optionText)||"#2B2B2B",borderColor:et(a.borderColor)||"transparent",activeColor:et(a.correctColor||I.correctColor||a.correctBorderColor)||"#10b981",incorrectColor:et(a.incorrectColor||I.incorrectColor)||"#ef4444",optionBorderRadius:a.optionRadius!==void 0?a.optionRadius>=100?"999px":v(a.optionRadius,x):a.optionBorderRadius!==void 0?a.optionBorderRadius>=100?"999px":v(a.optionBorderRadius,x):"100px",optionFontSize:w(tt,x)}}}if(R.type==="question"){let I=a.optionRadius??a.optionBorderRadius??a.inputRadius??a.inputBorderRadius,O=a.borderRadius??a.radius??a.containerBorderRadius;return{...R,type:"question",question:M.question||M.title||"Ask me a question",placeholder:M.placeholder||"Type your answer...",styling:{...R.styling,borderRadius:O!==void 0?O>=100?"999px":v(O,x):"16px",promptColor:et(a.questionColor||a.promptColor||a.textColor),inputBgColor:Ct(a.inputBackground||a.inputBgColor),inputTextColor:et(a.inputTextColor),submitBackground:Ct(a.submitBackground),optionRadius:I!==void 0?I>=5?"9999px":v(I,x):"9999px",inputBorderRadius:I!==void 0?I>=5?"9999px":v(I,x):"9999px"}}}if(R.type==="image_quiz"||R.type==="imageQuiz"||z==="media_quiz"){let I=a.optionFontSize??a.optionFont?.fontSize??a.typography?.optionSize??a.options?.fontSize??13,O=a.borderRadius??a.radius??a.containerBorderRadius,tt=a.optionRadius??a.optionBorderRadius??a.imageRadius;return{...R,type:"image_quiz",question:M.question||M.title||"Image Quiz",options:to(M.options||[]),layout:M.layout??a.layout??r.layout,styling:{...R.styling,borderRadius:O!==void 0?O>=100?"999px":v(O,x):void 0,optionRadius:tt!==void 0?tt>=100?"999px":v(tt,x):void 0,questionBgColor:Ct(a.questionBgColor||a.questionBackground),questionTextColor:et(a.questionColor||a.questionTextColor),optionBgColor:Ct(a.optionBgColor||a.optionBackground),optionTextColor:et(a.optionTextColor||a.textColor),labelColor:et(a.labelColor),borderColor:et(a.borderColor),activeColor:et(a.correctBorderColor||a.correctColor||a.activeColor),incorrectColor:et(a.incorrectColor),imageRadius:tt!==void 0?v(tt,x):void 0,optionFontSize:w(I,x)}}}if(R.type==="countdown")return{...R,type:"countdown",title:M.title||"Ends in...",targetDate:cr(M),styling:{...R.styling,borderColor:et(a.borderColor),digitBackground:Ct(a.digitBackground),digitColor:et(a.digitColor),digitSize:a.digitSize||a.fontSize?w(a.digitSize||a.fontSize,x):void 0,labelColor:et(a.labelColor),titleColor:et(a.titleColor),labelFontSize:a.labelFontSize?w(a.labelFontSize,x):void 0},display:M.display||r.display};if(R.type==="promo_code")return{...R,width:R.width?Math.max(R.width,65):75,type:"promo_code",code:dr(r,M,a),styling:{...R.styling,borderColor:et(a.borderColor)}};if(R.type==="reaction"||R.type==="emoji_reaction"){let I=ar(M);return{...R,type:"reaction",emojis:I.length>0?I:["\u{1F60D}","\u{1F44D}"]}}return R}),U=m.map(r=>{let M=j.find(I=>String(I?.id)===String(r?.id))||j.find(I=>I?.id===void 0)||{},f=en(r,t)==="studio",x={position:r?.position,size:r?.size,rotation:r?.rotation,z:r?.z,background:r?.background,cardBackground:r?.cardBackground,cardBorderRadius:r?.cardBorderRadius,cardRadiusPercent:r?.cardRadiusPercent,transparent:r?.transparent,textColor:r?.textColor,buttonBackground:r?.buttonBackground,buttonTextColor:r?.buttonTextColor,buttonFontSize:r?.buttonFontSize,buttonBorderRadius:r?.buttonBorderRadius,titleColor:r?.titleColor,titleFontSize:r?.titleFontSize,titleFontWeight:r?.titleFontWeight,priceColor:r?.priceColor,priceFontSize:r?.priceFontSize,priceFontWeight:r?.priceFontWeight,mrpColor:r?.mrpColor,mrpFontSize:r?.mrpFontSize,mrpFontWeight:r?.mrpFontWeight,imageRadius:r?.imageRadius,opacity:r?.opacity,animation:r?.animation},z={...M,...r?.styling||{},...Object.fromEntries(Object.entries(x).filter(([,I])=>I!==void 0))},Y=z.position||{},ot=z.size||{},J=z.cardBorderRadius!==void 0?Number(z.cardBorderRadius):void 0,H=z.cardRadiusPercent!==void 0?Number(z.cardRadiusPercent):void 0,K=ot.height!==void 0?Number(ot.height):void 0,it=J===void 0&&H!==void 0&&K!==void 0?Math.max(0,Math.min(100,H))/100*(K/2):void 0,xt=J??it,ut=xt!==void 0&&!isNaN(xt)?xt*c:void 0,Z=Y.x!==void 0?f?Number(Y.x):Number(Y.x)/s*100:0,rt=ot.width!==void 0?f?Number(ot.width):Number(ot.width)/s*100:100,dt=ot.height!==void 0?f?Number(ot.height):Number(ot.height)/l*100:void 0,ht=Y.y!==void 0?f?Number(Y.y):Number(Y.y)/l*100:dt?100-dt-2.5:85;dt&&ht+dt>96?ht=Math.max(0,100-dt):ht>75&&dt&&ht+dt>91&&(ht=Math.max(0,100-dt-1));let mt=Array.isArray(r.product)&&r.product.length>0,R=mt?r.product:r.static||[];return{id:r.id||Math.random().toString(),type:"buy",shopableType:mt?"product":"static",x:Z,y:ht,width:rt,height:dt,rotation:z.rotation??0,z:z.z??10,products:R.map(I=>{let O=I.productData||I||{},tt=O.attributes||I.attributes||{},St=tt.sales_price||O.price||tt.price||I.price,zt=tt.sales_price?O.price||tt.price||I.price:O.oldPrice||I.oldPrice,Tt=O.color||tt.color||I.color,Yt=O.size||tt.size||I.size,Lt=tt.colors||[];Lt.length===0&&Tt&&(Lt=[{id:Tt,hex:Tt,name:Tt}]);let Zt=tt.sizes||[];Zt.length===0&&Yt&&(Zt=typeof Yt=="string"?Yt.split(",").map(ce=>ce.trim()):[Yt]);let It={description:O.description||tt.description||I.description,color:Tt,size:Yt,colors:Lt,sizes:Zt,imageUrls:tt.imageUrls||[tt.image_link||O.imageUrl||O.image||I.imageUrl||I.image||I.url].filter(Boolean),availability:O.availability||tt.availability||I.availability,tags:O.tags||tt.tags||I.tags,...tt};return{id:O.productId||O.id||I.productId||I.id||Math.random().toString(),image:tt.image_link||O.imageUrl||O.image||I.imageUrl||I.image||I.url,url:O.link||O.url||I.link||I.url||I.redirectUrl,title:O.title||I.title,price:St,oldPrice:zt,redirectUrl:I.redirectUrl||O.link||I.link||I.url,svg:O.svg||I.svg,productId:O.productId||I.productId,collectionId:O.collectionId||I.collectionId,feedId:O.feedId||I.feedId,attributes:It}}),styling:{backgroundColor:Ct(z.background),cardBackground:Ct(z.cardBackground)||Ct(z.background)||"#ffffff",cardBorderRadius:xt!==void 0&&!isNaN(xt)?f?`${xt}cqh`:`${ut}px`:f?"1cqh":"10px",cardRadiusPercent:H,transparent:z.transparent===!0,textColor:et(z.textColor)||"#ffffff",buttonBackground:Ct(z.buttonBackground)||"#000000",buttonTextColor:et(z.buttonTextColor)||"#ffffff",buttonFontSize:w(z.buttonFontSize||12,f),buttonBorderRadius:z.buttonBorderRadius!==void 0?f?`${z.buttonBorderRadius}cqh`:`${z.buttonBorderRadius}px`:f?"10cqh":"100px",titleColor:et(z.titleColor||z.textColor)||"#1a1a2e",titleFontSize:w(z.titleFontSize||14,f),titleFontWeight:z.titleFontWeight?String(z.titleFontWeight):"600",priceColor:et(z.priceColor||z.textColor)||"#1a1a2e",priceFontSize:w(z.priceFontSize||16,f),priceFontWeight:z.priceFontWeight?String(z.priceFontWeight):"700",mrpColor:et(z.mrpColor)||"#8b8b98",mrpFontSize:w(z.mrpFontSize||12,f),mrpFontWeight:z.mrpFontWeight?String(z.mrpFontWeight):"500",imageRadius:z.imageRadius!==void 0?f?`${z.imageRadius}cqh`:`${Number(z.imageRadius)*c}px`:f?"1cqh":"10px",animation:Bo(z.animation)}}}),A=S.map(r=>{let a=(t?.styling?.image||t?.styling?.images||[]).find(z=>z.id===r.id)||{},f=r.position||a.position||r.postion||{x:0,y:0},x=r.borderRadius??r.styling?.borderRadius??a.borderRadius??a.styling?.borderRadius??r.imageRadius??r.radius;return{id:r.id||Math.random().toString(),type:"image",x:L?Number(f.x):f.x/s*100,y:L?Number(f.y):f.y/l*100,width:L?Number(r.width):r.width/s*100,height:r.height?L?Number(r.height):r.height/l*100:void 0,url:r.link||r.url,z:r.z??a.z??0,styling:{borderRadius:x!==void 0?v(x,L):void 0,objectFit:r.objectFit||a.objectFit||r.sizing||a.sizing||"fill",objectPosition:uo(r.objectPosition||a.objectPosition||r.positionStr),border:r.border||r.styling?.border||a.border,boxShadow:r.shadow||r.styling?.shadow||a.shadow,opacity:(r.opacity!==void 0?r.opacity:a.opacity)!==void 0?Number(r.opacity!==void 0?r.opacity:a.opacity)/100:void 0}}}),T=y.map(r=>{let a=(t?.styling?.video||t?.styling?.videos||[]).find(K=>K.id===r.id)||{},f=r.position||a.position||{x:r.x,y:r.y},x=f.x??r.x,z=f.y??r.y,Y=r.width??a.width,ot=r.height??a.height,J=r.cornerRadius??r.borderRadius??a.cornerRadius??a.borderRadius??r.radius,H=r.rotation!==void 0?r.rotation:a.rotation;return{id:r.id||Math.random().toString(),type:"video",x:x!==void 0&&!isNaN(Number(x))?L?Number(x):Number(x)/s*100:0,y:z!==void 0&&!isNaN(Number(z))?L?Number(z):Number(z)/l*100:0,width:Y!==void 0&&!isNaN(Number(Y))?L?Number(Y):Number(Y)/s*100:100,height:ot!==void 0&&!isNaN(Number(ot))?L?Number(ot):Number(ot)/l*100:void 0,url:r.link||r.url||r.src||a.link||a.url,rotation:H??0,z:r.z??a.z??2,loop:r.loop??a.loop??!0,muted:r.muted??a.muted??!1,styling:{borderRadius:J!==void 0?v(J,L):void 0,objectFit:r.objectFit||a.objectFit||r.sizing||a.sizing||"cover",objectPosition:uo(r.objectPosition||a.objectPosition),border:r.border||r.styling?.border||a.border,boxShadow:r.shadow||r.styling?.shadow||a.shadow,opacity:(r.opacity!==void 0?r.opacity:a.opacity)!==void 0?Number(r.opacity!==void 0?r.opacity:a.opacity)/100:void 0}}}),k=C.map(r=>{let a=(t?.styling?.lottie||t?.styling?.lotties||[]).find(ut=>ut.id===r.id)||{},f=r.position||a.position||{x:r.x,y:r.y},x=f.x??r.x,z=f.y??r.y,Y=r.width??a.width,ot=r.height??a.height,J=r.cornerRadius??r.borderRadius??a.cornerRadius??a.borderRadius??r.radius,H=r.rotation!==void 0?r.rotation:a.rotation,K=r.flip||a.flip||{},it="";K.horizontal&&K.vertical?it="scale(-1, -1)":K.horizontal?it="scaleX(-1)":K.vertical&&(it="scaleY(-1)");let xt=r.duration||a.duration;return{id:r.id||Math.random().toString(),type:"lottie",x:x!==void 0&&!isNaN(Number(x))?L?Number(x):Number(x)/s*100:0,y:z!==void 0&&!isNaN(Number(z))?L?Number(z):Number(z)/l*100:0,width:Y!==void 0&&!isNaN(Number(Y))?L?Number(Y):Number(Y)/s*100:100,height:ot!==void 0&&!isNaN(Number(ot))?L?Number(ot):Number(ot)/l*100:void 0,url:r.link||r.url||r.src||r.lottie_url||a.link||a.url,rotation:H??0,z:r.z??a.z??3,duration:xt?.start!==void 0?xt:void 0,loop:r.loop??a.loop??!0,autoplay:r.autoplay??a.autoplay??!0,styling:{borderRadius:J!==void 0?v(J,L):void 0,border:r.border||r.styling?.border||a.border,boxShadow:r.shadow||r.styling?.shadow||a.shadow,opacity:(r.opacity!==void 0?r.opacity:a.opacity)!==void 0?Number(r.opacity!==void 0?r.opacity:a.opacity)/100:void 0,transform:it||void 0,animation:Bo(r.animation||a.animation)}}}),B=h.map(r=>{let a=(t?.styling?.text||[]).find(xt=>xt.id===r.id)||{},f=r.position||a.position||{x:0,y:0},x=r.font||a.font||{},z=r.size||a.size||{},Y=r.alignment||a.alignment||{},ot=r.color||a.color,J=x.fontDecoration||[],H=J.includes("underline")?"underline":J.includes("line-through")?"line-through":void 0,K=r.rotation!==void 0?r.rotation:a.rotation,it=x.fontSize??r.fontSize??a.fontSize??a.font?.fontSize;return{id:r.id||Math.random().toString(),type:"text",x:L?Number(f.x):f.x/s*100,y:L?Number(f.y):f.y/l*100,width:z.width?L?Number(z.width):z.width/s*100:void 0,height:z.height?L?Number(z.height):z.height/l*100:void 0,rotation:K??0,text:r.text||r.value||a.text||a.value||"",z:r.z??a.z??1,styling:{color:et(ot)||"#000000",fontSize:it?w(it,L):void 0,fontFamily:x.fontFamily,fontStyle:x.fontStyle||(J.includes("italic")?"italic":"normal"),fontWeight:x.fontWeight||(J.includes("bold")?"bold":"normal"),textDecoration:H,lineHeight:r.lineHeight!==void 0?r.lineHeight:a.lineHeight,letterSpacing:(r.letterSpacing!==void 0?r.letterSpacing:a.letterSpacing)!==void 0?`${r.letterSpacing!==void 0?r.letterSpacing:a.letterSpacing}px`:void 0,opacity:(r.opacity!==void 0?r.opacity:a.opacity)!==void 0?Number(r.opacity!==void 0?r.opacity:a.opacity)/100:void 0,textAlign:Y.horizontalAlignment||"left",verticalAlignment:Y.verticalAlignment||"top"}}}),$=g.map(r=>{let a=(t?.styling?.ctas||t?.styling?.cta||[]).find(xt=>xt.id===r.id)||{},f=r.position||a.position||{x:0,y:0},x=r.size||a.size||{},z=r.font||a.font||{},Y=z.fontDecoration||[],ot=Y.includes("underline")?"underline":Y.includes("line-through")?"line-through":void 0,J=r.rotation!==void 0?r.rotation:a.rotation,H=z.fontSize??r.fontSize??a.fontSize??a.font?.fontSize,K=r.borderRadius??r.styling?.borderRadius??a.borderRadius??a.styling?.borderRadius,it=r.borderWidth??r.styling?.borderWidth??a.borderWidth??a.styling?.borderWidth;return{id:r.id||Math.random().toString(),type:"cta",x:L?Number(f.x):f.x/s*100,y:L?Number(f.y):f.y/l*100,width:x.width?L?Number(x.width):x.width/s*100:void 0,height:x.height?L?Number(x.height):x.height/l*100:void 0,rotation:J??0,text:r.text||a.text||"Learn More",redirectUrl:r.redirectUrl||a.redirectUrl||r.link||a.link,ctaType:r.type||a.type||"classic",url:r.url||a.url,z:r.z??a.z??10,source:L?"studio":"dashboard",styling:{backgroundColor:Ct(r.background||a.background),textColor:et(r.textColor||a.textColor)||"#FFFFFF",borderColor:et(r.borderColor||a.borderColor||r.styling?.borderColor||a.styling?.borderColor)||"#FFFFFF",borderWidth:it!==void 0&&Number(it)>0?v(it,L):void 0,borderRadius:K!==void 0?v(K,L):void 0,fontSize:H?w(H,L):void 0,fontFamily:z.fontFamily,fontStyle:z.fontStyle||(Y.includes("italic")?"italic":"normal"),fontWeight:z.fontWeight||(Y.includes("bold")?"bold":"normal"),textDecoration:ot,pillH:r.pillH??a.pillH,arrowAnimation:r.arrowAnimation??a.arrowAnimation,arrowColor:et(r.arrowColor||a.arrowColor),arrowSize:r.arrowSize??a.arrowSize,transparent:r.transparent??a.transparent}}}),V=[..._,...N,...U,...A,...T,...k,...B,...$].filter(r=>{if(!r.duration)return!0;let{start:M,end:a}=r.duration;return n>=M&&n<=a}).sort((r,M)=>(r.z??0)-(M.z??0));return console.log("InteractiveOverlay Debug - content.ctas:",g,"displayCtas:",$,"displayItems:",V),(0,Ao.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,pointerEvents:"none",overflow:"hidden",containerType:"size"},children:[(0,Ao.jsx)("style",{children:`
95
100
  @keyframes appstorys-fade-in {
96
101
  from { opacity: 0; transform: translateY(10px); }
97
102
  to { opacity: 1; transform: translateY(0); }
@@ -111,16 +116,16 @@
111
116
  70% { opacity: 1; transform: scale(0.95); }
112
117
  100% { opacity: 1; transform: scale(1); }
113
118
  }
114
- `}),q.map(a=>!a||typeof a!="object"||!(a.type||"").toLowerCase()?null:(0,no.jsx)(Ai,{data:a,onInteraction:e,isEditing:o},a.id))]})};var $i=require("react"),ve=require("react/jsx-runtime"),Jr=({isPaused:t,onPress:e,style:o,size:i=36})=>{let[n,r]=(0,$i.useState)(!1);return(0,ve.jsx)("button",{onClick:e,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{width:`${i}px`,height:`${i}px`,background:n?"rgba(255, 255, 255, 0.15)":"rgba(255, 255, 255, 0.08)",border:n?"1px solid white":"1px solid rgba(255, 255, 255, 0.1)",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"10px",cursor:"pointer",transition:"all 0.2s ease",padding:0,outline:"none",...o},children:t?(0,ve.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:(0,ve.jsx)("path",{d:"M5 3.867v16.266c0 .54.58.88 1.05.61l14.133-8.133c.46-.27.46-.94 0-1.21L6.05 3.257C5.58 2.987 5 3.327 5 3.867z"})}):(0,ve.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:[(0,ve.jsx)("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),(0,ve.jsx)("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})})},Wi=Jr;var Io=require("react/jsx-runtime"),Kr=t=>{switch(t){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},Zr=({cta:t,buttonText:e,onPress:o})=>!t||!e||e.trim()===""?null:(0,Io.jsx)("div",{style:{position:"absolute",bottom:t?.margin?.bottom,left:t?.margin?.left,right:t?.margin?.right,display:"flex",justifyContent:Kr(t?.container?.alignment),width:"100%",pointerEvents:"none",boxSizing:"border-box",zIndex:10},children:(0,Io.jsx)("button",{style:{backgroundColor:t?.container?.backgroundColor||"#F7921C",borderColor:t?.container?.borderColor||"transparent",borderWidth:t?.container?.borderWidth??0,borderStyle:t?.container?.borderWidth?"solid":"none",borderTopRightRadius:t?.cornerRadius?.topRight,borderTopLeftRadius:t?.cornerRadius?.topLeft,borderBottomRightRadius:t?.cornerRadius?.bottomRight,borderBottomLeftRadius:t?.cornerRadius?.bottomLeft,height:t?.container?.height||42,width:t?.container?.ctaFullWidth?"100%":t?.container?.ctaWidth||"auto",justifyContent:"center",alignItems:"center",display:"flex",cursor:"pointer",outline:"none",pointerEvents:"auto",padding:"0 12px",boxSizing:"border-box"},onClick:o,children:(0,Io.jsx)("span",{style:{color:t?.text?.color||"#ffffff",fontSize:t?.text?.fontSize||14,fontFamily:mt(t?.text?.fontFamily),fontWeight:t?.text?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:t?.text?.fontDecoration?.includes("italic")?"italic":"normal",textDecorationLine:t?.text?.fontDecoration?.includes("underline")?"underline":"none",textAlign:"center"},children:de(e)})})}),pn=Zr;var Vt=require("react/jsx-runtime"),Me=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:i,style:n,type:r})=>{if(!t||!i)return null;let{size:l=18,margin:d,color:c,image:y,selectedStyle:b}=t,h=o?40:l,f=o?0:d?.top??0,v=o?0:d?.bottom??0,S=o?0:d?.left??0,u=o?0:d?.right??0,m={marginTop:f,marginBottom:v,marginLeft:S,marginRight:u,width:h,height:h,backgroundColor:c?.fill||"transparent",borderColor:c?.stroke||"transparent",borderWidth:h*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,display:"flex",...o?{}:{marginTop:t.margin?.top??0,marginRight:t.margin?.right??0,marginBottom:t.margin?.bottom??0,marginLeft:t.margin?.left??0},...n},g=()=>{let C=c?.cross||"#ffffff";return r==="mute"?(0,Vt.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Vt.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:C,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,Vt.jsx)("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:C,strokeWidth:"2.2",strokeLinecap:"round"}),(0,Vt.jsx)("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:C,strokeWidth:"2.2",strokeLinecap:"round"})]}):(0,Vt.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Vt.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:C,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,Vt.jsx)("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:C,strokeWidth:"2.2",strokeLinecap:"round"}),(0,Vt.jsx)("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:C,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,Vt.jsx)("button",{onClick:e,style:{...m,border:m.borderColor?`${m.borderWidth}px solid ${m.borderColor}`:"none",padding:0,cursor:"pointer",outline:"none"},title:b||"",children:y&&y.trim()!==""?(0,Vt.jsx)("img",{src:y,style:{width:h,height:h,objectFit:"contain"},alt:r}):g()})};var ie=require("react/jsx-runtime"),ts=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,style:i})=>{if(!t||t.enabled===!1)return null;let{size:n=18,margin:r,color:l,image:d,selectedStyle:c}=t,y=o?40:n,b={marginTop:o?0:r?.top??0,marginBottom:o?0:r?.bottom??0,marginLeft:o?0:r?.left??0,marginRight:o?0:r?.right??0,width:y,height:y,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||"transparent",borderWidth:y*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:l?.stroke?"solid":"none",...i},h=()=>{let f=l?.cross||"#ffffff";return(0,ie.jsxs)("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"none",stroke:f,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,ie.jsx)("circle",{cx:"18",cy:"5",r:"3"}),(0,ie.jsx)("circle",{cx:"6",cy:"12",r:"3"}),(0,ie.jsx)("circle",{cx:"18",cy:"19",r:"3"}),(0,ie.jsx)("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),(0,ie.jsx)("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})};return(0,ie.jsx)("button",{onClick:e,style:b,title:c||"",children:d&&d.trim()!==""?(0,ie.jsx)("img",{src:d,style:{width:y,height:y,objectFit:"contain"},alt:"share"}):h()})},Oi=ts;var D=require("react/jsx-runtime"),io=.63;var pe=580,gn="cubic-bezier(0.65, 0, 0.35, 1)",fn="cubic-bezier(0.45, 0, 0.25, 1)";function es(t,e){let o=Math.round(e*1.08),i=o+Math.round(e*io)+20;switch(t){case"center":return{transform:"translateX(0px) scale(1)",opacity:1,zIndex:10,pointerEvents:"auto",boxShadow:"0 32px 64px -12px rgba(0,0,0,0.9)",filter:"brightness(1)"};case"left":return{transform:`translateX(-${o}px) scale(${io})`,opacity:1,filter:"brightness(0.55)",zIndex:5,pointerEvents:"auto",boxShadow:"0 8px 24px rgba(0,0,0,0.5)"};case"right":return{transform:`translateX(${o}px) scale(${io})`,opacity:1,filter:"brightness(0.55)",zIndex:5,pointerEvents:"auto",boxShadow:"0 8px 24px rgba(0,0,0,0.5)"};case"far-left":return{transform:`translateX(-${i}px) scale(${io})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};case"far-right":return{transform:`translateX(${i}px) scale(${io})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};default:return{opacity:0,zIndex:1,pointerEvents:"none",transform:"translateX(0px) scale(1)",filter:"brightness(1)"}}}var Ni=({src:t,isActive:e,isAnimating:o,isMuted:i,onLoadedData:n,activeVideoRef:r,objectFit:l="cover"})=>{let d=st.default.useRef(null);return st.default.useEffect(()=>{e&&!o?(r.current=d.current,d.current?.play().catch(()=>{}),d.current&&d.current.readyState>=2&&n?.()):(d.current?.pause(),r.current===d.current&&(r.current=null))},[e,o,t,r]),(0,D.jsx)("video",{ref:d,src:t,playsInline:!0,muted:i,onLoadedData:e&&!o?n:void 0,style:{width:"100%",height:"100%",objectFit:l}})},hn="appstorys_viewed_slide_ids",bn="appstorys_clicked_interaction_ids",os=t=>{try{let e=localStorage.getItem(hn);if(!e)return!1;let o=JSON.parse(e);return Array.isArray(o)&&o.includes(t)}catch{return!1}},ns=t=>{try{let e=localStorage.getItem(hn),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(hn,JSON.stringify(o)))}catch{}},mn=t=>{try{let e=localStorage.getItem(bn);if(!e)return!1;let o=JSON.parse(e);return Array.isArray(o)&&o.includes(t)}catch{return!1}},yn=t=>{try{let e=localStorage.getItem(bn),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(bn,JSON.stringify(o)))}catch{}},ji=({stories:t,activeStoryIndex:e,dataId:o,viewedStories:i,setViewedStories:n,onNextStory:r,onPrevStory:l,onClose:d})=>{let[c,y]=(0,st.useState)(0),[b,h]=(0,st.useState)(0),[f,v]=(0,st.useState)(!1),[S,u]=(0,st.useState)(!1),[m,g]=(0,st.useState)(!1),[C,I]=(0,st.useState)(!1),[z,E]=(0,st.useState)(null),[w,_]=(0,st.useState)({width:typeof window<"u"?window.innerWidth:1280,height:typeof window<"u"?window.innerHeight:800}),[P,$]=(0,st.useState)(typeof window<"u"?window.innerWidth>=1024:!1),[q,B]=(0,st.useState)(!1),[a,x]=(0,st.useState)(null),[s,p]=(0,st.useState)(null),[M,T]=(0,st.useState)(null),[R,W]=(0,st.useState)(!1),[H,U]=(0,st.useState)("none"),[j,V]=(0,st.useState)(null);(0,st.useEffect)(()=>{let F=()=>{_({width:window.innerWidth,height:window.innerHeight}),$(window.innerWidth>=1024)};return window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]);let tt=(0,st.useRef)(null),at=(0,st.useRef)(null),nt=(0,st.useRef)(0),lt=(0,st.useRef)(null),k=t[e],L=k?.slides[c],J=L?.styling,ht=J?.editorSource||J?.meta?.editorSource,Y=ht==="studio"||ht==="editor",O=Y?J?.background?.media?.mediaUrl:L?.image,et=Y?L?.content?.button_text:L?.button_text,ut=Y?L?.content?.link:L?.link,Ct=L?.video||(Y?L?.content?.video?.[0]?.link:void 0),yt=L?.content?.canva,dt=yt&&yt.width&&yt.height?yt.width/yt.height:9/16,Bt=P?160:80,Pt=Math.max(350,w.height-Bt),Ee=P?w.width*.75:w.width*.95,ge=Math.min(Pt,Ee/dt),De=Math.round(P?Math.max(450,Math.min(ge,850)):Math.min(Pt,850)),fe=Math.round(De*dt),Tn=async()=>{let F={title:k.name,text:`Check out this story: ${k.name}`,url:window.location.href};if(L?.id&&X("shared",o,{story_slide:L.id}),navigator.share)try{await navigator.share(F)}catch{}else if(navigator.clipboard)try{await navigator.clipboard.writeText(window.location.href),E("Story link copied to clipboard!"),setTimeout(()=>E(null),2500)}catch{}};if((0,st.useEffect)(()=>{y(0),h(0),u(!1),g(!1),B(!1),x(null),p(null),T(null)},[e]),(0,st.useEffect)(()=>{let F=Q=>{if(!(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA"))switch(Q.key){case"ArrowRight":Ke();break;case"ArrowLeft":_o();break;case" ":Q.preventDefault(),g(ct=>!ct);break;case"Escape":d();break;case"s":case"S":Q.preventDefault(),Tn();break}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[c,e,m,k,d]),(0,st.useEffect)(()=>{k&&L&&lt.current!==L.id&&(lt.current=L.id,os(L.id)||(ns(L.id),X("viewed",o,{story_slide:L.id})))},[c,k?.id,o,L?.id]),(0,st.useEffect)(()=>{if(k&&L){let F=k.styling?.slideShowTime||5,Q=!!Ct;if(tt.current&&clearInterval(tt.current),m){at.current&&at.current.pause();return}else at.current&&at.current.play().catch(()=>{});return Q&&!S||q?void 0:(tt.current=setInterval(()=>{h(ct=>ct>=100?(Ke(),100):ct+100/(F*10))},100),()=>{tt.current&&clearInterval(tt.current)})}},[e,c,m,S,q]),!L)return null;let Fn=(F,Q)=>{q||(T(F),x(c),p(Q),B(!0),setTimeout(()=>{y(Q),h(0),u(!1),B(!1),x(null),p(null),T(null)},pe+20))},Ke=()=>{if(!(q||R))if(c<k.slides.length-1)Fn("next",c+1);else{if(!i.includes(k.id)){let F=[...i,k.id];n(F),localStorage.setItem("app_storys_viewed_stories",JSON.stringify(F))}po("next")}},_o=()=>{q||R||(c>0?Fn("prev",c-1):po("prev"))},po=F=>{if(!(R||q)){if(F==="next"){if(e>=t.length-1){r();return}}else if(e<=0){l();return}W(!0),V(F),U("out"),setTimeout(()=>{F==="next"?r():l(),U("prepare-in"),setTimeout(()=>{U("in"),setTimeout(()=>{W(!1),U("none"),V(null)},320)},35)},280)}},zn=()=>H==="out"?{transform:`translateX(${j==="next"?-120:120}px) scale(0.92)`,opacity:0,filter:"blur(6px)",transition:"transform 280ms cubic-bezier(0.4, 0, 0.2, 1), opacity 280ms cubic-bezier(0.4, 0, 0.2, 1), filter 280ms cubic-bezier(0.4, 0, 0.2, 1)",willChange:"transform, opacity, filter"}:H==="prepare-in"?{transform:`translateX(${j==="next"?120:-120}px) scale(0.92)`,opacity:0,filter:"blur(6px)",transition:"none",willChange:"transform, opacity, filter"}:H==="in"?{transform:"translateX(0px) scale(1)",opacity:1,filter:"blur(0px)",transition:"transform 320ms cubic-bezier(0.16, 1, 0.3, 1), opacity 320ms cubic-bezier(0.16, 1, 0.3, 1), filter 320ms cubic-bezier(0.16, 1, 0.3, 1)",willChange:"transform, opacity, filter"}:{transition:"transform 320ms cubic-bezier(0.16, 1, 0.3, 1), opacity 320ms cubic-bezier(0.16, 1, 0.3, 1), filter 320ms cubic-bezier(0.16, 1, 0.3, 1)"},me=()=>{nt.current=Date.now(),g(!0)},ye=F=>{g(!1),Date.now()-nt.current<300&&(F==="next"?Ke():_o())},In=()=>u(!0),Bn=F=>{let Q=F?.styling,ct=Q?.editorSource||Q?.meta?.editorSource,wt=ct==="studio"||ct==="editor"?F.content?.link:F.link;if(wt){let Kt=`cta_slide_${F.id}`;mn(Kt)||(yn(Kt),X("clicked",o,{story_slide:F.id})),wt.startsWith("http")?window.open(wt,"_blank"):window.location.href=wt}},Ln=async(F,Q)=>{let{type:ct,questionId:Wt,pollId:wt,quizId:Kt,optionId:Ot,value:re,stickerId:se,redirectUrl:he}=F;if(ct==="cta"){if(he){let Nt=se||`cta_sticker_${Q.id}`;mn(Nt)||(yn(Nt),X("clicked",o,{story_slide:Q.id,cta_id:se})),he.startsWith("http")?window.open(he,"_blank"):window.location.href=he}return}g(!0);let Ut=ct?.split("_")[0]||"interaction";Ut==="quizz"&&(Ut="quiz"),ct?.startsWith("image_quiz")&&(Ut="quiz");let be=se||Wt||wt||Kt||Q.id;if(mn(be))return;yn(be);let xe=Ot||F.selected_option||F.emoji||"",_t=A.getState(),ke=_t.userId||"anonymous",go=_t.trackingUrl||"https://tracking.appstorys.co",Pe=await bt(),fo={interaction_type:Ut,interaction_id:be,story_slide:Q.id,selected_option:String(xe)};re!=null&&re!==""&&(fo.value=String(re)),fetch(`${go}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...Pe?{Authorization:`Bearer ${Pe}`}:{}},body:JSON.stringify({user_id:ke,campaign_id:o,event:"clicked",metadata:fo})}).catch(Nt=>console.error("AppStorys: Instant Tracking Failed",Nt))},Mn=F=>{F.stopPropagation(),v(!f)},An=k?.styling?.crossButton,En=k?.styling?.soundToggle,Ps=L?.styling?.cta,Dn=F=>q?M==="next"?F===a?"left":F===s?"center":F===(a??0)-1?"far-left":F===(a??0)-2?"hidden":F===(s??0)+1?"right":F===(s??0)+2?"far-right":"hidden":F===a?"right":F===s?"center":F===(a??0)+1?"far-right":F===(a??0)+2?"hidden":F===(s??0)-1?"left":F===(s??0)-2?"far-left":"hidden":F===c?"center":F===c-1?"left":F===c-2?"far-left":F===c+1?"right":F===c+2?"far-right":"hidden",fr=P?{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",background:"radial-gradient(circle at center, #0B1424 0%, #03070E 100%)",zIndex:1e5,display:"flex",flexDirection:"column",alignItems:"center",overflow:"hidden",color:"white"}:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.95)",zIndex:1e5,display:"flex",justifyContent:"center",alignItems:"center"},_n=P?{position:"absolute",width:`${fe}px`,height:`${De}px`,backgroundColor:"#000",borderRadius:"20px",overflow:"hidden",display:"flex",flexDirection:"column",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.8)",border:"1px solid rgba(255, 255, 255, 0.1)"}:{position:"relative",width:`${fe}px`,maxWidth:"100vw",height:`${De}px`,maxHeight:"92vh",aspectRatio:`${dt}`,backgroundColor:"#000",borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column"},$s={width:"240px",height:"420px",backgroundColor:"#000",borderRadius:"16px",overflow:"hidden",opacity:1,filter:"brightness(0.6)",display:"flex",flexDirection:"column",boxShadow:"0 10px 20px rgba(0,0,0,0.5)",border:"1px solid rgba(255, 255, 255, 0.05)",transform:"scale(0.9)",transition:"all 0.3s ease",cursor:"pointer"},mr=k.slides.reduce((F,Q,ct)=>(Dn(ct)!=="hidden"&&F.push(ct),F),[]),_e=new Set(mr);return _e.add(c),c>0&&_e.add(c-1),c>1&&_e.add(c-2),c<k.slides.length-1&&_e.add(c+1),c<k.slides.length-2&&_e.add(c+2),(0,D.jsxs)("div",{style:fr,onClick:()=>!P&&Ke(),children:[(0,D.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:0,overflow:"hidden",pointerEvents:"none",transition:"all 0.6s ease-in-out"},children:[Ct?(0,D.jsx)("video",{src:Ct,style:{width:"100%",height:"100%",objectFit:"cover",filter:"blur(120px) saturate(1.8) opacity(0.35)"},muted:!0}):(0,D.jsx)(te,{src:O||k.thumbnail,style:{width:"100%",height:"100%",filter:"blur(120px) saturate(1.8) opacity(0.35)"}}),(0,D.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(5, 5, 8, 0.4)"}})]},`${e}-${q?s:c}`),P&&(0,D.jsxs)("div",{style:{width:"100%",display:"flex",flexDirection:"column",paddingTop:"20px",zIndex:10,...zn()},children:[(0,D.jsx)("div",{style:{width:"100%",display:"flex",gap:"8px",padding:"0 20px",boxSizing:"border-box"},children:k.slides.map((F,Q)=>{let ct=q&&s!==null?s:c,Wt="0%";return Q<ct?Wt="100%":Q===ct&&(Wt=`${b}%`),(0,D.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.15)",borderRadius:"2px",overflow:"hidden"},children:(0,D.jsx)("div",{style:{width:Wt,height:"100%",backgroundColor:"white",transition:Q===ct?"width 0.1s linear":"none"}})},Q)})}),(0,D.jsxs)("div",{style:{width:"100%",margin:"0 auto",display:"grid",gridTemplateColumns:`minmax(0, 1fr) ${fe}px minmax(0, 1fr)`,gap:"12px",alignItems:"center",marginTop:"16px",padding:"0 20px",boxSizing:"border-box",zIndex:C?2e3:10},children:[(0,D.jsx)("div",{style:{paddingLeft:"0px"}}),(0,D.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,D.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,D.jsx)(te,{src:k.thumbnail,alt:k.name,style:{width:"44px",height:"44px",borderRadius:"50%",border:"2px solid white",margin:0}}),(0,D.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"16px",whiteSpace:"nowrap"},children:k.name})]}),(0,D.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,D.jsx)(Oi,{config:{enabled:k?.styling?.share?.enabled??!0,image:k?.styling?.share?.image??"",color:{cross:k?.styling?.share?.color?.cross??"#ffffff",fill:k?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:k?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:k?.styling?.share?.size??44},onPress:Tn,style:{position:"relative",borderRadius:"12px"}}),(0,D.jsx)(Me,{config:{size:44,color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:Mn,type:f?"mute":"unmute",enabled:!!En?.enabled&&!!Ct,style:{position:"relative",borderRadius:"12px"}}),(0,D.jsx)(Wi,{isPaused:m,onPress:()=>g(!m),size:44,style:{borderRadius:"12px"}})]})]}),(0,D.jsxs)("div",{style:{display:"flex",gap:"10px",flex:1,justifyContent:"flex-end",paddingRight:"0px"},children:[(0,D.jsxs)("div",{style:{position:"relative"},children:[(0,D.jsx)("button",{onClick:()=>{I(!C),g(!C)},style:{width:"44px",height:"44px",background:C?"rgba(255,255,255,0.15)":"rgba(255,255,255,0.08)",border:C?"1px solid white":"1px solid rgba(255,255,255,0.1)",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"12px",cursor:"pointer",transition:"all 0.2s",padding:0,outline:"none"},children:(0,D.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,D.jsx)("rect",{x:"3",y:"3",width:"7",height:"7"}),(0,D.jsx)("rect",{x:"14",y:"3",width:"7",height:"7"}),(0,D.jsx)("rect",{x:"14",y:"14",width:"7",height:"7"}),(0,D.jsx)("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),C&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("style",{children:`
119
+ `}),V.map(r=>!r||typeof r!="object"||!(r.type||"").toLowerCase()?null:(0,Ao.jsx)(rr,{data:r,onInteraction:e,isEditing:o},r.id))]})};var ur=require("react"),Oe=require("react/jsx-runtime"),zs=({isPaused:t,onPress:e,style:o,size:n=36})=>{let[i,s]=(0,ur.useState)(!1);return(0,Oe.jsx)("button",{onClick:e,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:`${n}px`,height:`${n}px`,background:i?"rgba(255, 255, 255, 0.15)":"rgba(255, 255, 255, 0.08)",border:i?"1px solid white":"1px solid rgba(255, 255, 255, 0.1)",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"10px",cursor:"pointer",transition:"all 0.2s ease",padding:0,outline:"none",...o},children:t?(0,Oe.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:(0,Oe.jsx)("path",{d:"M5 3.867v16.266c0 .54.58.88 1.05.61l14.133-8.133c.46-.27.46-.94 0-1.21L6.05 3.257C5.58 2.987 5 3.327 5 3.867z"})}):(0,Oe.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:[(0,Oe.jsx)("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),(0,Oe.jsx)("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})})},pr=zs;var on=require("react/jsx-runtime"),Is=t=>{switch(t){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},Bs=({cta:t,buttonText:e,onPress:o})=>!t||!e||e.trim()===""?null:(0,on.jsx)("div",{style:{position:"absolute",bottom:t?.margin?.bottom,left:t?.margin?.left,right:t?.margin?.right,display:"flex",justifyContent:Is(t?.container?.alignment),width:"100%",pointerEvents:"none",boxSizing:"border-box",zIndex:10},children:(0,on.jsx)("button",{style:{backgroundColor:t?.container?.backgroundColor||"#F7921C",borderColor:t?.container?.borderColor||"transparent",borderWidth:t?.container?.borderWidth??0,borderStyle:t?.container?.borderWidth?"solid":"none",borderTopRightRadius:t?.cornerRadius?.topRight,borderTopLeftRadius:t?.cornerRadius?.topLeft,borderBottomRightRadius:t?.cornerRadius?.bottomRight,borderBottomLeftRadius:t?.cornerRadius?.bottomLeft,height:t?.container?.height||42,width:t?.container?.ctaFullWidth?"100%":t?.container?.ctaWidth||"auto",justifyContent:"center",alignItems:"center",display:"flex",cursor:"pointer",outline:"none",pointerEvents:"auto",padding:"0 12px",boxSizing:"border-box"},onClick:o,children:(0,on.jsx)("span",{style:{color:t?.text?.color||"#ffffff",fontSize:t?.text?.fontSize||14,fontFamily:lt(t?.text?.fontFamily),fontWeight:t?.text?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:t?.text?.fontDecoration?.includes("italic")?"italic":"normal",textDecorationLine:t?.text?.fontDecoration?.includes("underline")?"underline":"none",textAlign:"center"},children:Pe(e)})})}),jn=Bs;var ze=require("react/jsx-runtime"),Ls=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,style:n})=>{if(!t||t.enabled===!1)return null;let{size:i=18,margin:s,color:l,image:c,selectedStyle:d}=t,S=o?40:i,p={marginTop:o?0:s?.top??0,marginBottom:o?0:s?.bottom??0,marginLeft:o?0:s?.left??0,marginRight:o?0:s?.right??0,width:S,height:S,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||"transparent",borderWidth:S*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"relative",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:l?.stroke?"solid":"none",...n},y=()=>{let u=l?.cross||"#ffffff";return(0,ze.jsxs)("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"none",stroke:u,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,ze.jsx)("circle",{cx:"18",cy:"5",r:"3"}),(0,ze.jsx)("circle",{cx:"6",cy:"12",r:"3"}),(0,ze.jsx)("circle",{cx:"18",cy:"19",r:"3"}),(0,ze.jsx)("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),(0,ze.jsx)("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})};return(0,ze.jsx)("button",{onClick:e,style:p,children:c&&c.trim()!==""?(0,ze.jsx)("img",{src:c,style:{width:S,height:S,objectFit:"contain"},alt:"share"}):y()})},qn=Ls;var W=require("react/jsx-runtime"),nn=t=>{if(t)return t.content?.canva||t.canva||t.styling?.canva||t.meta?.canva||t.content?.styling?.canva||t.content?.meta?.canva},Es=t=>{let e=nn(t),o=Number(e?.width),n=Number(e?.height);return o>0&&n>0?o/n:9/16},Mo=.63;var We=580,Hn="cubic-bezier(0.65, 0, 0.35, 1)",Vn="cubic-bezier(0.45, 0, 0.25, 1)";function As(t,e){let o=Math.round(e*1.08),n=o+Math.round(e*Mo)+20;switch(t){case"center":return{transform:"translateX(0px) scale(1)",opacity:1,zIndex:10,pointerEvents:"auto",boxShadow:"0 32px 64px -12px rgba(0,0,0,0.9)",filter:"brightness(1)"};case"left":return{transform:`translateX(-${o}px) scale(${Mo})`,opacity:1,filter:"brightness(0.55)",zIndex:5,pointerEvents:"auto",boxShadow:"0 8px 24px rgba(0,0,0,0.5)"};case"right":return{transform:`translateX(${o}px) scale(${Mo})`,opacity:1,filter:"brightness(0.55)",zIndex:5,pointerEvents:"auto",boxShadow:"0 8px 24px rgba(0,0,0,0.5)"};case"far-left":return{transform:`translateX(-${n}px) scale(${Mo})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};case"far-right":return{transform:`translateX(${n}px) scale(${Mo})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};default:return{opacity:0,zIndex:1,pointerEvents:"none",transform:"translateX(0px) scale(1)",filter:"brightness(1)"}}}var gr=({src:t,isActive:e,isAnimating:o,isMuted:n,onLoadedData:i,activeVideoRef:s,objectFit:l="cover",objectPosition:c="center center"})=>{let d=yt.default.useRef(null);return yt.default.useEffect(()=>{e&&!o?(s.current=d.current,d.current?.play().catch(()=>{}),d.current&&d.current.readyState>=1&&i?.()):(d.current?.pause(),s.current===d.current&&(s.current=null))},[e,o,t,s,i]),(0,W.jsx)("video",{ref:d,src:t,playsInline:!0,muted:n,onLoadedData:i,onCanPlay:i,onLoadedMetadata:i,style:{width:"100%",height:"100%",objectFit:l,objectPosition:c}})},fr="appstorys_viewed_slide_ids",Un="appstorys_clicked_interaction_ids";var Ms=t=>{try{let e=localStorage.getItem(fr),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(fr,JSON.stringify(o)))}catch{}},Ps=t=>{try{let e=localStorage.getItem(Un);if(!e)return!1;let o=JSON.parse(e);return Array.isArray(o)&&o.includes(t)}catch{return!1}},Ds=t=>{try{let e=localStorage.getItem(Un),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(Un,JSON.stringify(o)))}catch{}},mr=({stories:t,activeStoryIndex:e,dataId:o,viewedStories:n,setViewedStories:i,onNextStory:s,onPrevStory:l,onClose:c})=>{let d=t[e],S=F=>{if(!F?.id)return 0;try{let q=`appstorys_cta_redirect_${F.id}`,ft=sessionStorage.getItem(q);if(ft){let $t=JSON.parse(ft),Ft=Date.now()-($t.timestamp||0),Ee=F.slides?.length||1;if(sessionStorage.removeItem(q),Ft<=300*1e3&&typeof $t.slideIndex=="number"&&$t.slideIndex>=0&&$t.slideIndex<Ee)return $t.slideIndex}}catch{}return 0},[p,y]=(0,yt.useState)(()=>S(t[e])),[u,C]=(0,yt.useState)(0),[h,g]=(0,yt.useState)(t[e]?.styling?.soundToggle?.defaultSound==="no"),[b,m]=(0,yt.useState)(!1),[E,j]=(0,yt.useState)(!1),[D,L]=(0,yt.useState)(!1),[v,w]=(0,yt.useState)(null),[_,N]=(0,yt.useState)({width:typeof window<"u"?window.innerWidth:1280,height:typeof window<"u"?window.innerHeight:800}),[U,A]=(0,yt.useState)(typeof window<"u"?window.innerWidth>=1024:!1),[T,k]=(0,yt.useState)(!1),[B,$]=(0,yt.useState)(null),[V,G]=(0,yt.useState)(null),[r,M]=(0,yt.useState)(null),[a,f]=(0,yt.useState)(!1),[x,z]=(0,yt.useState)("none"),[Y,ot]=(0,yt.useState)(null),J=(0,yt.useRef)(null),H=(0,yt.useRef)(null),K=(0,yt.useRef)(0),it=(0,yt.useRef)(null),xt=(0,yt.useRef)(!1),ut=d?.slides[p],Z=ut?.styling,rt=Z?.editorSource||Z?.meta?.editorSource,dt=rt==="studio"||rt==="editor",ht=dt?Z?.background?.media?.mediaUrl:ut?.image,mt=dt?ut?.content?.button_text:ut?.button_text,R=dt?ut?.content?.link:ut?.link,I=F=>{if(!F)return;if(F.video&&typeof F.video=="string")return F.video;let q=F.styling?.background?.media||F.content?.styling?.background?.media||F.content?.background?.media;if(q&&(q.mediaType==="video"||q.type==="video"||q.isVideo))return q.mediaUrl||q.url||q.link},O=I(ut),tt=nn(ut),St=Es(ut),zt=U?160:80,Tt=Math.max(350,_.height-zt),Yt=U?_.width*.75:_.width*.95,Lt=Math.min(Tt,Yt/St),Zt=Math.round(U?Math.max(450,Math.min(Lt,850)):Math.min(Tt,850)),It=Math.round(Zt*St),ce=(F,q)=>{T||(C(0),M(F),$(p),G(q),k(!0),setTimeout(()=>{y(q),C(0),m(!1),k(!1),$(null),G(null),M(null)},We+20))},xe=F=>{if(!(a||T)){if(C(0),F==="next"){if(e>=t.length-1){s();return}}else if(e<=0){l();return}f(!0),ot(F),z("out"),setTimeout(()=>{F==="next"?s():l(),z("prepare-in"),setTimeout(()=>{z("in"),setTimeout(()=>{f(!1),z("none"),ot(null)},320)},35)},280)}},Ie=()=>{if(!(T||a))if(p<(d?.slides?.length||0)-1)ce("next",p+1);else{if(d&&!n.includes(d.id)){let F=[...n,d.id];i(F),localStorage.setItem("app_storys_viewed_stories",JSON.stringify(F))}xe("next")}},wo=()=>{T||a||(p>0?ce("prev",p-1):xe("prev"))},Oo=async()=>{if(!d)return;let F={title:d.name,text:`Check out this story: ${d.name}`,url:window.location.href};if(ut?.id&&st("shared",o,{story_slide:ut.id}),navigator.share)try{await navigator.share(F)}catch{}else if(navigator.clipboard)try{await navigator.clipboard.writeText(window.location.href),w("Story link copied to clipboard!"),setTimeout(()=>w(null),2500)}catch{}};if((0,yt.useEffect)(()=>{let F=()=>{N({width:window.innerWidth,height:window.innerHeight}),A(window.innerWidth>=1024)};return window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]),(0,yt.useEffect)(()=>{let F=document.body.style.overflow,q=document.body.style.touchAction;return document.body.style.overflow="hidden",document.body.style.touchAction="none",()=>{document.body.style.overflow=F,document.body.style.touchAction=q}},[]),(0,yt.useEffect)(()=>{let F=S(d);y(F),C(0),m(!1),j(!1),k(!1),f(!1),z("none"),ot(null),$(null),G(null),M(null),g(d?.styling?.soundToggle?.defaultSound==="no")},[e]),(0,yt.useEffect)(()=>{let F=()=>{document.hidden?(xt.current=E,j(!0),H.current&&H.current.pause()):xt.current||(j(!1),H.current&&H.current.play().catch(()=>{}))};return document.addEventListener("visibilitychange",F),()=>document.removeEventListener("visibilitychange",F)},[E]),(0,yt.useEffect)(()=>{let F=q=>{if(!(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA"))switch(q.key){case"ArrowRight":Ie();break;case"ArrowLeft":wo();break;case" ":q.preventDefault(),j(ft=>!ft);break;case"Escape":c();break;case"s":case"S":q.preventDefault(),Oo();break}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[p,e,E,d,c]),(0,yt.useEffect)(()=>{if(d&&ut){let F=ut.id?String(ut.id):`${d.id||o}_slide_${p}`,q=`${e}_${p}_${F}`;it.current!==q&&(it.current=q,Ms(F),st("viewed",o,{story_slide:F}))}},[e,p,d?.id,o,ut?.id]),(0,yt.useEffect)(()=>{if(d&&ut&&!!O&&!b){let q=setTimeout(()=>{m(!0)},2e3);return()=>clearTimeout(q)}},[e,p,O,b]),(0,yt.useEffect)(()=>{if(d&&ut){let F=d.styling?.slideShowTime||5,q=!!O;if(J.current&&clearInterval(J.current),E){H.current&&H.current.pause();return}else H.current&&H.current.play().catch(()=>{});return q&&!b||T||a?void 0:(J.current=setInterval(()=>{C(ft=>ft>=100?(Ie(),100):ft+100/(F*10))},100),()=>{J.current&&clearInterval(J.current)})}},[e,p,E,b,T,a,O]),!ut)return null;let ko=()=>x==="out"?{transform:`translateX(${Y==="next"?-120:120}px) scale(0.92)`,opacity:0,filter:"blur(6px)",transition:"transform 280ms cubic-bezier(0.4, 0, 0.2, 1), opacity 280ms cubic-bezier(0.4, 0, 0.2, 1), filter 280ms cubic-bezier(0.4, 0, 0.2, 1)",willChange:"transform, opacity, filter"}:x==="prepare-in"?{transform:`translateX(${Y==="next"?120:-120}px) scale(0.92)`,opacity:0,filter:"blur(6px)",transition:"none",willChange:"transform, opacity, filter"}:x==="in"?{transform:"translateX(0px) scale(1)",opacity:1,filter:"blur(0px)",transition:"transform 320ms cubic-bezier(0.16, 1, 0.3, 1), opacity 320ms cubic-bezier(0.16, 1, 0.3, 1), filter 320ms cubic-bezier(0.16, 1, 0.3, 1)",willChange:"transform, opacity, filter"}:{transition:"transform 320ms cubic-bezier(0.16, 1, 0.3, 1), opacity 320ms cubic-bezier(0.16, 1, 0.3, 1), filter 320ms cubic-bezier(0.16, 1, 0.3, 1)"},ie=()=>{K.current=Date.now(),j(!0)},Se=F=>{j(!1),Date.now()-K.current<300&&(F==="next"?Ie():wo())},Be=()=>m(!0),Le=()=>{if(d?.id)try{sessionStorage.setItem(`appstorys_cta_redirect_${d.id}`,JSON.stringify({slideIndex:p,timestamp:Date.now()}))}catch{}},X=F=>{let q=F?.styling,ft=q?.editorSource||q?.meta?.editorSource,Ft=ft==="studio"||ft==="editor"?F.content?.link:F.link;Ft&&(Le(),st("clicked",o,{story_slide:F.id}),Ft.startsWith("http")?window.open(Ft,"_blank"):window.location.href=Ft)},gt=async(F,q)=>{let{type:ft,questionId:$t,pollId:Ft,quizId:Ee,ratingId:ue,reactionId:no,productId:He,optionId:Ro,value:re,stickerId:Ve,redirectUrl:ve,code:Ue}=F;if(ft==="cta"){ve&&(Le(),st("clicked",o,{story_slide:q.id,cta_id:Ve}),ve.startsWith("http")?window.open(ve,"_blank"):window.location.href=ve);return}j(!0);let pe=ft||"interaction";pe==="quizz"&&(pe="quiz"),(pe==="image"||ft?.startsWith("image_quiz"))&&(pe="quiz"),ft?.startsWith("promo")&&(pe="promo_code");let Jt=Ve||$t||Ft||Ee||ue||no||He||q.id;if(Ps(Jt))return;Ds(Jt);let Ye=Ro||F.selected_option||F.emoji||re||Ue||"",Fo=P.getState().userId||"anonymous",gn=Wi(),we=await At(),ti={interaction_type:pe,interaction_id:Jt,story_slide:q.id,selected_option:String(Ye)};re!=null&&re!==""&&(ti.value=String(re)),fetch(`${gn}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...we?{Authorization:`Bearer ${we}`}:{}},body:JSON.stringify({user_id:Fo,campaign_id:o,event:"clicked",metadata:ti})}).catch(Vr=>console.error("AppStorys: Instant Tracking Failed",Vr))},Bt=F=>{F.stopPropagation(),g(!h)},te=d?.styling?.crossButton,pt=d?.styling?.soundToggle,Ce=ut?.styling?.cta,oo=F=>T?r==="next"?F===B?"left":F===V?"center":F===(B??0)-1?"far-left":F===(B??0)-2?"hidden":F===(V??0)+1?"right":F===(V??0)+2?"far-right":"hidden":F===B?"right":F===V?"center":F===(B??0)+1?"far-right":F===(B??0)+2?"hidden":F===(V??0)-1?"left":F===(V??0)-2?"far-left":"hidden":F===p?"center":F===p-1?"left":F===p-2?"far-left":F===p+1?"right":F===p+2?"far-right":"hidden",qe=U?{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",background:"radial-gradient(circle at center, #0B1424 0%, #03070E 100%)",zIndex:1e5,display:"flex",flexDirection:"column",alignItems:"center",overflow:"hidden",color:"white"}:{position:"fixed",top:0,left:0,width:"100vw",height:"100dvh",backgroundColor:"#000000",zIndex:1e5,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",touchAction:"none"},qt=U?{position:"absolute",width:`${It}px`,height:`${Zt}px`,backgroundColor:"#000",borderRadius:"20px",overflow:"hidden",display:"flex",flexDirection:"column",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.8)",border:"1px solid rgba(255, 255, 255, 0.1)"}:{position:"relative",width:`min(100vw, calc(100dvh * ${St}))`,height:`min(100dvh, calc(100vw / ${St}))`,aspectRatio:`${St}`,backgroundColor:"#000",borderRadius:"0px",overflow:"hidden",display:"flex",flexDirection:"column"},Gt={width:"240px",height:"420px",backgroundColor:"#000",borderRadius:"16px",overflow:"hidden",opacity:1,filter:"brightness(0.6)",display:"flex",flexDirection:"column",boxShadow:"0 10px 20px rgba(0,0,0,0.5)",border:"1px solid rgba(255, 255, 255, 0.05)",transform:"scale(0.9)",transition:"all 0.3s ease",cursor:"pointer"},Xt=d.slides.reduce((F,q,ft)=>(oo(ft)!=="hidden"&&F.push(ft),F),[]),Et=new Set(Xt);return Et.add(p),p>0&&Et.add(p-1),p>1&&Et.add(p-2),p<d.slides.length-1&&Et.add(p+1),p<d.slides.length-2&&Et.add(p+2),(0,W.jsxs)("div",{style:qe,onClick:()=>!U&&Ie(),children:[(0,W.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:0,overflow:"hidden",pointerEvents:"none",transition:"all 0.6s ease-in-out"},children:[O?(0,W.jsx)("video",{src:O,style:{width:"100%",height:"100%",objectFit:"cover",filter:"blur(120px) saturate(1.8) opacity(0.35)"},muted:!0}):ht||!dt&&d.thumbnail?(0,W.jsx)(ke,{src:ht||d.thumbnail,style:{width:"100%",height:"100%",filter:"blur(120px) saturate(1.8) opacity(0.35)"}}):null,(0,W.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(5, 5, 8, 0.4)"}})]},`${e}-${T?V:p}`),U&&(0,W.jsxs)("div",{style:{width:"100%",display:"flex",flexDirection:"column",paddingTop:"20px",zIndex:10,...ko()},children:[(0,W.jsx)("div",{style:{width:"100%",display:"flex",gap:"8px",padding:"0 20px",boxSizing:"border-box"},children:d.slides.map((F,q)=>{let ft=T&&V!==null?V:p,$t="0%";return q<ft?$t="100%":q===ft&&($t=`${u}%`),(0,W.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.15)",borderRadius:"2px",overflow:"hidden"},children:(0,W.jsx)("div",{style:{width:$t,height:"100%",backgroundColor:"white",transition:q===ft&&u>0&&!T?"width 0.1s linear":"none"}})},q)})}),(0,W.jsxs)("div",{style:{width:"100%",margin:"0 auto",display:"grid",gridTemplateColumns:`minmax(0, 1fr) ${It}px minmax(0, 1fr)`,gap:"12px",alignItems:"center",marginTop:"16px",padding:"0 20px",boxSizing:"border-box",zIndex:D?2e3:10},children:[(0,W.jsx)("div",{style:{paddingLeft:"0px"}}),(0,W.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,W.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,W.jsx)(ke,{src:d.thumbnail,alt:d.name,style:{width:"44px",height:"44px",borderRadius:"50%",border:"2px solid white",margin:0}}),(0,W.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"16px",whiteSpace:"nowrap"},children:d.name})]}),(0,W.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,W.jsx)(qn,{config:{enabled:d?.styling?.share?.enabled??!0,image:d?.styling?.share?.image??"",color:{cross:d?.styling?.share?.color?.cross??"#ffffff",fill:d?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:d?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:d?.styling?.share?.size??44},onPress:Oo,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"12px",width:"44px",height:"44px"}}),(0,W.jsx)(Me,{config:{size:(h?pt?.mute?.size:pt?.unmute?.size)||44,color:{cross:(h?pt?.mute?.color?.cross:pt?.unmute?.color?.cross)||"#ffffff",fill:(h?pt?.mute?.color?.fill:pt?.unmute?.color?.fill)||"rgba(255,255,255,0.08)",stroke:(h?pt?.mute?.color?.stroke:pt?.unmute?.color?.stroke)||"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:(h?pt?.mute?.image:pt?.unmute?.image)||""},onPress:Bt,type:h?"mute":"unmute",enabled:!!pt?.enabled&&!!O,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"12px",width:"44px",height:"44px"}}),(0,W.jsx)(pr,{isPaused:E,onPress:()=>j(!E),size:44,style:{borderRadius:"12px",margin:0}})]})]}),(0,W.jsxs)("div",{style:{display:"flex",gap:"10px",flex:1,justifyContent:"flex-end",paddingRight:"0px"},children:[(0,W.jsxs)("div",{style:{position:"relative"},children:[(0,W.jsx)("button",{onClick:()=>{L(!D),j(!D)},style:{width:"44px",height:"44px",background:D?"rgba(255,255,255,0.15)":"rgba(255,255,255,0.08)",border:D?"1px solid white":"1px solid rgba(255,255,255,0.1)",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"12px",cursor:"pointer",transition:"all 0.2s",padding:0,outline:"none"},children:(0,W.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,W.jsx)("rect",{x:"3",y:"3",width:"7",height:"7"}),(0,W.jsx)("rect",{x:"14",y:"3",width:"7",height:"7"}),(0,W.jsx)("rect",{x:"14",y:"14",width:"7",height:"7"}),(0,W.jsx)("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),D&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("style",{children:`
115
120
  @keyframes fadeUp {
116
121
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
117
122
  to { opacity: 1; transform: translateY(0) scale(1); }
118
123
  }
119
- `}),(0,D.jsxs)("div",{style:{position:"absolute",top:"46px",right:0,width:"260px",background:"rgba(25, 25, 25, 0.98)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"16px",padding:"18px",boxShadow:"0 20px 25px -5px rgba(0,0,0,0.4), 0 10px 10px -5px rgba(0,0,0,0.4)",zIndex:1001,animation:"fadeUp 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards"},children:[(0,D.jsx)("div",{style:{fontSize:"11px",fontWeight:"bold",color:"#9CA3AF",letterSpacing:"1px",textTransform:"uppercase",marginBottom:"16px",paddingBottom:"10px",borderBottom:"1px solid rgba(255,255,255,0.06)"},children:"Keyboard Shortcuts"}),(0,D.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[{key:"\u2192",label:"Next slide"},{key:"\u2190",label:"Previous slide"},{key:"space",label:"Play/Pause"},{key:"esc",label:"Close story"},{key:"S",label:"Share story link"}].map(({key:F,label:Q})=>(0,D.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"14px",justifyContent:"flex-start"},children:[(0,D.jsx)("span",{style:{minWidth:"54px",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.08)",padding:"5px 8px",borderRadius:"5px",fontSize:"12px",color:"white",border:"1px solid rgba(255,255,255,0.1)",boxSizing:"border-box"},children:F}),(0,D.jsx)("span",{style:{fontSize:"13px",color:"#E5E7EB",fontWeight:"500",textAlign:"left"},children:Q})]},F))})]})]})]}),(0,D.jsx)(At,{config:{enabled:An?.enabled??!0,image:"",color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:44},onPress:d,style:{position:"relative",borderRadius:"12px"}})]})]})]}),(0,D.jsx)("div",{style:{flex:1,width:"100%",display:"flex",flexDirection:"column",justifyContent:P?"flex-start":"center",alignItems:"center",paddingTop:P?"14px":"0px",...zn()},children:(0,D.jsxs)("div",{style:{display:P?"grid":"flex",gridTemplateColumns:P?`minmax(0, 1fr) ${fe}px minmax(0, 1fr)`:"none",alignItems:"center",justifyContent:"center",gap:"12px",width:"100%",maxWidth:"1400px",position:"relative"},onClick:F=>P&&F.stopPropagation(),children:[P&&(0,D.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(c>0||e>0)&&(0,D.jsx)("button",{onClick:_o,style:{background:"rgba(0,0,0,0.45)",border:"1px solid rgba(255,255,255,0.1)",color:"white",borderRadius:"50%",width:"44px",height:"44px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",backdropFilter:"blur(10px)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 8px 16px rgba(0,0,0,0.3)",outline:"none"},onMouseEnter:F=>{F.currentTarget.style.background="rgba(0,0,0,0.75)",F.currentTarget.style.transform="scale(1.1)",F.currentTarget.style.borderColor="rgba(255,255,255,0.25)"},onMouseLeave:F=>{F.currentTarget.style.background="rgba(0,0,0,0.45)",F.currentTarget.style.transform="scale(1)",F.currentTarget.style.borderColor="rgba(255,255,255,0.1)"},children:(0,D.jsx)("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,D.jsx)("polyline",{points:"15 18 9 12 15 6"})})})}),P?(0,D.jsx)("div",{style:{width:`${fe}px`,height:`${De}px`,position:"relative",zIndex:5,overflow:"visible"},children:Array.from(_e).sort((F,Q)=>F-Q).map(F=>{let Q=k.slides[F];if(!Q)return null;let ct=Dn(F),Wt=es(ct,fe),wt=Q?.styling,Kt=wt?.editorSource||wt?.meta?.editorSource,Ot=Kt==="studio"||Kt==="editor",re=wt?.background?.media?.mediaUrl||Q?.image,se=Q?.video||(Ot?Q?.content?.video?.[0]?.link:void 0),he=gt(wt?.background)||"#000000",Ut=Ot?Q?.content?.button_text:Q?.button_text,be=Ot?Q?.content?.link:Q?.link,xe=wt?.background?.media?.sizing,_t=xe==="fill"?"cover":xe==="fit"?"contain":xe==="stretch"?"fill":Ot?"contain":"cover",Pe=F===c&&!q||q&&F===s,fo={display:"flex",justifyContent:"center",alignItems:"center",background:Ot?he:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"16px"};return(0,D.jsxs)("div",{style:{..._n,position:"absolute",top:0,left:0,width:`${fe}px`,height:`${De}px`,...Wt,transition:ct==="hidden"||ct==="far-left"||ct==="far-right"?`opacity ${pe}ms ease, transform ${pe}ms ease`:F===a?`transform ${pe}ms ${gn}, opacity ${pe}ms ${gn}, filter ${pe}ms ${gn}`:`transform ${pe}ms ${fn}, opacity ${pe}ms ${fn}, filter ${pe}ms ${fn}`,transformOrigin:"center center",willChange:"transform, opacity, filter"},onClick:Nt=>Nt.stopPropagation(),children:[(0,D.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:me,onMouseUp:()=>ye("prev"),onTouchStart:me,onTouchEnd:()=>ye("prev")}),(0,D.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:me,onMouseUp:()=>ye("next"),onTouchStart:me,onTouchEnd:()=>ye("next")}),(0,D.jsxs)("div",{style:fo,children:[se?(0,D.jsx)(Ni,{src:se,isActive:Pe,isAnimating:q,isMuted:f,onLoadedData:In,activeVideoRef:at,objectFit:_t}):(re||!Ot&&k?.thumbnail)&&(0,D.jsx)(te,{src:re||k?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:_t}}),(0,D.jsx)(un,{content:{...Q.content,styling:{...Q.content?.styling,...Q?.styling},interactions:Q.interactions},elapsedTime:Pe?b/100*(k.styling?.slideShowTime||5):0,onInteraction:async Nt=>{Pe&&Ln(Nt,Q)}})]}),(Ut||be)&&(0,D.jsx)(pn,{cta:Q?.styling?.cta,buttonText:Ut||"Learn More",onPress:Nt=>{Nt&&Nt.stopPropagation&&Nt.stopPropagation(),Bn(Q)}})]},Q.id||F)})}):(0,D.jsx)("div",{style:{width:`${fe}px`,maxWidth:"100vw",height:`${De}px`,maxHeight:"92vh",aspectRatio:`${dt}`,overflow:"hidden",position:"relative",zIndex:5,display:"flex",flexDirection:"column"},children:k.slides.map((F,Q)=>{if(Math.abs(Q-c)>1)return(0,D.jsx)("div",{style:{display:"none"}},F.id||Q);let ct=F?.styling,Wt=ct?.editorSource||ct?.meta?.editorSource,wt=Wt==="studio"||Wt==="editor",Kt=ct?.background?.media?.mediaUrl||F?.image,Ot=F?.video||(wt?F?.content?.video?.[0]?.link:void 0),re=gt(ct?.background)||"#000000",se=wt?F?.content?.button_text:F?.button_text,he=wt?F?.content?.link:F?.link,Ut=ct?.background?.media?.sizing,be=Ut==="fill"?"cover":Ut==="fit"?"contain":Ut==="stretch"?"fill":wt?"contain":"cover",xe=Q===c;return xe?(0,D.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:(0,D.jsxs)("div",{style:{..._n},onClick:_t=>_t.stopPropagation(),children:[(0,D.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,display:"flex",gap:"4px",padding:"10px",zIndex:10},children:k.slides.map((_t,ke)=>{let go=ke<c?"100%":ke===c?`${b}%`:"0%";return(0,D.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.3)",borderRadius:"2px",overflow:"hidden"},children:(0,D.jsx)("div",{style:{width:go,height:"100%",backgroundColor:"white",transition:ke===c?"width 0.1s linear":"none"}})},ke)})}),(0,D.jsxs)("div",{style:{position:"absolute",top:"20px",left:"10px",right:"10px",display:"flex",alignItems:"center",justifyContent:"space-between",zIndex:10,padding:"5px"},children:[(0,D.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,D.jsx)(te,{src:k.thumbnail,alt:k.name,style:{width:"32px",height:"32px",borderRadius:"50%"}}),(0,D.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"14px",textShadow:"0 1px 3px rgba(0,0,0,0.8)"},children:k.name})]}),(0,D.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,D.jsx)(Me,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:Mn,type:f?"mute":"unmute",enabled:!!En?.enabled&&!!Ot,style:{position:"relative",borderRadius:"10px"}}),(0,D.jsx)(At,{config:{enabled:An?.enabled!==!1,image:"",color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:32},onPress:d,style:{position:"relative",borderRadius:"10px"}})]})]}),(0,D.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:me,onMouseUp:()=>ye("prev"),onTouchStart:me,onTouchEnd:()=>ye("prev")}),(0,D.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:me,onMouseUp:()=>ye("next"),onTouchStart:me,onTouchEnd:()=>ye("next")}),(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",background:wt?re:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"0px"},children:[Ot?(0,D.jsx)(Ni,{src:Ot,isActive:xe,isAnimating:q,isMuted:f,onLoadedData:In,activeVideoRef:at,objectFit:be}):(Kt||k?.thumbnail)&&(0,D.jsx)(te,{src:Kt||k?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:be}}),(0,D.jsx)(un,{content:{...F.content,styling:{...F.content?.styling,...F?.styling},interactions:F.interactions},elapsedTime:b/100*(k.styling?.slideShowTime||5),onInteraction:async _t=>{Ln(_t,F)}})]}),(se||he)&&(0,D.jsx)(pn,{cta:F?.styling?.cta,buttonText:se||"Learn More",onPress:_t=>{_t&&_t.stopPropagation&&_t.stopPropagation(),Bn(F)}})]})},F.id||Q):null})}),P&&(0,D.jsx)("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(0,D.jsx)("button",{onClick:Ke,style:{background:"rgba(0,0,0,0.45)",border:"1px solid rgba(255,255,255,0.1)",color:"white",borderRadius:"50%",width:"44px",height:"44px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",backdropFilter:"blur(10px)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 8px 16px rgba(0,0,0,0.3)",outline:"none"},onMouseEnter:F=>{F.currentTarget.style.background="rgba(0,0,0,0.75)",F.currentTarget.style.transform="scale(1.1)",F.currentTarget.style.borderColor="rgba(255,255,255,0.25)"},onMouseLeave:F=>{F.currentTarget.style.background="rgba(0,0,0,0.45)",F.currentTarget.style.transform="scale(1)",F.currentTarget.style.borderColor="rgba(255,255,255,0.1)"},children:(0,D.jsx)("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,D.jsx)("polyline",{points:"9 18 15 12 9 6"})})})})]})}),P&&e>0&&(0,D.jsxs)("div",{style:{position:"absolute",bottom:"36px",left:"24px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"6px",zIndex:20},children:[(0,D.jsx)("span",{style:{fontSize:"11px",fontWeight:"600",color:"rgba(255,255,255,0.65)",letterSpacing:"0.6px",textTransform:"uppercase",paddingLeft:"2px"},children:"Previous Stories"}),(0,D.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.08)",border:"1px solid rgba(255, 255, 255, 0.12)",padding:"8px 16px",borderRadius:"16px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(20px)",cursor:"pointer",boxShadow:"0 10px 24px rgba(0, 0, 0, 0.3)",transition:"all 0.25s cubic-bezier(0.4, 0, 0.2, 1)",maxWidth:"280px"},onClick:()=>po("prev"),onMouseEnter:F=>{F.currentTarget.style.transform="translateY(-2px) scale(1.03)",F.currentTarget.style.background="rgba(255, 255, 255, 0.12)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.25)"},onMouseLeave:F=>{F.currentTarget.style.transform="translateY(0px) scale(1)",F.currentTarget.style.background="rgba(255, 255, 255, 0.08)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.12)"},children:[(0,D.jsx)("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2190"}),(0,D.jsx)("div",{style:{width:"36px",height:"36px",borderRadius:"50%",border:"2px solid rgba(255,255,255,0.8)",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0,overflow:"hidden"},children:(0,D.jsx)(te,{src:t[e-1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),(0,D.jsx)("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e-1].name})]})]}),P&&e<t.length-1&&(0,D.jsxs)("div",{style:{position:"absolute",bottom:"36px",right:"24px",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"6px",zIndex:20},children:[(0,D.jsx)("span",{style:{fontSize:"11px",fontWeight:"600",color:"rgba(255,255,255,0.65)",letterSpacing:"0.6px",textTransform:"uppercase",paddingRight:"2px"},children:"Next Stories"}),(0,D.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.08)",border:"1px solid rgba(255, 255, 255, 0.12)",padding:"8px 16px",borderRadius:"16px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(20px)",cursor:"pointer",boxShadow:"0 10px 24px rgba(0, 0, 0, 0.3)",transition:"all 0.25s cubic-bezier(0.4, 0, 0.2, 1)",maxWidth:"280px"},onClick:()=>po("next"),onMouseEnter:F=>{F.currentTarget.style.transform="translateY(-2px) scale(1.03)",F.currentTarget.style.background="rgba(255, 255, 255, 0.12)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.25)"},onMouseLeave:F=>{F.currentTarget.style.transform="translateY(0px) scale(1)",F.currentTarget.style.background="rgba(255, 255, 255, 0.08)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.12)"},children:[(0,D.jsx)("div",{style:{width:"36px",height:"36px",borderRadius:"50%",border:"2px solid rgba(255,255,255,0.8)",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0,overflow:"hidden"},children:(0,D.jsx)(te,{src:t[e+1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),(0,D.jsx)("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e+1].name}),(0,D.jsx)("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2192"})]})]}),z&&(0,D.jsx)("div",{style:{position:"absolute",bottom:"40px",left:"50%",transform:"translateX(-50%)",background:"rgba(20, 20, 20, 0.96)",border:"1px solid rgba(255,255,255,0.08)",padding:"12px 24px",borderRadius:"12px",color:"white",fontSize:"13px",fontWeight:"500",boxShadow:"0 10px 20px rgba(0,0,0,0.5)",backdropFilter:"blur(10px)",zIndex:1e3},children:z})]})};var ro=require("react/jsx-runtime"),Hi=()=>{let t=xt("STR"),e=A(y=>y.isVisible),[o,i]=(0,je.useState)(null),[n,r]=(0,je.useState)([]);if((0,je.useEffect)(()=>{try{let y=localStorage.getItem("app_storys_viewed_stories");y&&r(JSON.parse(y))}catch(y){console.error("Failed to load viewed stories:",y)}},[]),(0,je.useEffect)(()=>{t&&t.details&&X("story_module_viewed",t.id)},[t]),!t||!t.details||t.details.length===0||!e)return null;let l=y=>{i(y)},d=()=>{o!==null&&(o<t.details.length-1?i(o+1):i(null))},c=()=>{o!==null&&o>0&&i(o-1)};return(0,ro.jsxs)("div",{className:"story-group-container",style:{width:"100vw",position:"relative",left:"50%",right:"50%",marginLeft:"-50vw",marginRight:"-50vw",boxSizing:"border-box"},children:[(0,ro.jsx)(gi,{stories:t.details,viewedStories:n,onStoryClick:l}),o!==null&&(0,ro.jsx)(ji,{stories:t.details,activeStoryIndex:o,dataId:t.id,viewedStories:n,setViewedStories:r,onNextStory:d,onPrevStory:c,onClose:()=>i(null)})]})};var $t=require("react"),Ui=require("react-dom");rt();var we=require("react");function so(t,e=.5){let o=(0,we.useRef)(t),i=(0,we.useRef)(!1),n=(0,we.useRef)(null),r=(0,we.useRef)(null);(0,we.useEffect)(()=>{o.current=t},[t]);let l=d=>{if(r.current&&(r.current.disconnect(),r.current=null),n.current=d,i.current=!1,!d)return;if(typeof IntersectionObserver>"u"){o.current();return}let c=null;r.current=new IntersectionObserver(y=>{y[0].isIntersecting&&!i.current?c||(c=setTimeout(()=>{i.current=!0,o.current(),r.current?.disconnect(),c=null},500)):c&&(clearTimeout(c),c=null)},{threshold:e}),r.current.observe(d)};return(0,we.useEffect)(()=>()=>{r.current?.disconnect()},[]),l}var qi=new Set;function is(){try{return globalThis?.process?.env?.NODE_ENV!=="production"}catch{return!0}}function Vi(t,e,o){if(!is()||o<=1)return;let i=`${e}::${t}`;qi.has(i)||(qi.add(i),console.warn(`AppStorys: Found ${o} elements matching target "${t}" (selector "${e}"). The first one in document order will be used. Target identifiers should be unique per screen.`))}function Bo(t){if(!t)return null;let e=[`[data-as-id="${t}"]`,`[data-id="${t}"]`,`[data-widget="${t}"]`];for(let i of e)try{let n=document.querySelectorAll(i);if(n.length>0)return Vi(t,i,n.length),n[0]}catch{}let o=document.getElementById(t);if(o)return o;try{let i=`.${CSS&&CSS.escape?CSS.escape(t):t}`,n=document.querySelectorAll(i);if(n.length>0)return Vi(t,i,n.length),n[0]}catch{}return null}var Gt=require("react/jsx-runtime"),Yi=({position:t})=>{let e=xt("WID",{position:t}),o=A(B=>B.campaigns),i=A(B=>B.allCampaigns),n=A(B=>B.currentScreen),r=B=>(B||"").trim().toLowerCase(),l=e??(()=>{let B=r(n),a=[...o||[],...i||[]].find(x=>{let s=x;if(s.campaign_type!=="WID"||t&&s.position!==t)return!1;let p=!!(s.trigger_event??s.trigger),M=s.display_trigger!==!1&&!p,T=!r(s.screen)||r(s.screen)===B;return M&&T});if(a)try{return Ft(a)}catch{return a}})(),[d,c]=(0,$t.useState)(0),y=(0,$t.useRef)(null),b=(0,$t.useRef)(null),h=l?.details||{},f=h.widget_images||[],v=h.styling||{},S=h.type||"full",u=S==="half",m=(0,$t.useRef)([]),g=(0,$t.useRef)(!1),C=(0,$t.useCallback)(()=>{g.current=!0;let B=f[d];B?.id&&z(B.id)},[f,d]),I=so(C),z=B=>{!l?.id||!B||g.current&&(m.current.includes(B)||(m.current.push(B),X("viewed",l.id,{widget_image:B})))};(0,$t.useEffect)(()=>{if(S==="full"&&f.length>1)return b.current=setInterval(()=>{c(B=>{let a=B+1;return a>=f.length?0:a})},5e3),()=>{b.current&&clearInterval(b.current)}},[S,f.length]);let E=(B,a)=>{if(l?.id&&X("clicked",l.id,{widget_image:B}),a){if(!a.startsWith("http")){try{if(kt(a))return}catch(x){console.warn("[Widget] revealCampaignFromLink error",x)}console.log("[Widget] Internal link:",a);return}window.open(a,"_blank")}},w=()=>{if(y.current&&u){let{scrollLeft:B,offsetWidth:a}=y.current,x=a/2+12,s=Math.round(B/x);c(s)}};(0,$t.useEffect)(()=>{if(!l?.id||S!=="full"||f.length===0)return;let B=f[d];B&&B.id&&z(B.id)},[d,l?.id,f,S]),(0,$t.useEffect)(()=>{if(!l?.id||!y.current||!u)return;let B=y.current,a=()=>{let{scrollLeft:x,offsetWidth:s}=B,p=s/2+12;f.forEach((M,T)=>{let R=T*p,W=R+p,H=x,U=x+s;Math.max(0,Math.min(W,U)-Math.max(R,H))/p>=.5&&z(M.id)})};return a(),B.addEventListener("scroll",a),()=>B.removeEventListener("scroll",a)},[l?.id,u,f]);let _={display:"flex",flexDirection:"row",flexWrap:u?"nowrap":"wrap",gap:"12px",width:"100%",height:u&&h.height?`${h.height}px`:"auto",marginTop:v.topMargin?`${v.topMargin}px`:"0px",marginBottom:v.bottomMargin?`${v.bottomMargin}px`:"0px",marginLeft:v.leftMargin?`${v.leftMargin}px`:"0px",marginRight:v.rightMargin?`${v.rightMargin}px`:"0px",boxSizing:"border-box",overflowX:u?"auto":"hidden",overflowY:"hidden",scrollSnapType:u?"x mandatory":void 0,msOverflowStyle:"none",scrollbarWidth:"none"},P=B=>({flex:u?"0 0 calc(50% - 6px)":"0 0 100%",height:u&&h.height?`${h.height}px`:"auto",cursor:"pointer",position:"relative",overflow:"hidden",borderRadius:v.borderRadius?`${v.borderRadius}px`:"0px",borderTopLeftRadius:v.topLeftRadius?`${v.topLeftRadius}px`:void 0,borderTopRightRadius:v.topRightRadius?`${v.topRightRadius}px`:void 0,borderBottomLeftRadius:v.bottomLeftRadius?`${v.bottomLeftRadius}px`:void 0,borderBottomRightRadius:v.bottomRightRadius?`${v.bottomRightRadius}px`:void 0,boxShadow:"0 4px 12px rgba(0,0,0,0.08)",scrollSnapAlign:"start"}),$=(0,Gt.jsxs)("div",{style:{width:"100%",position:"relative"},children:[(0,Gt.jsx)("style",{children:`
124
+ `}),(0,W.jsxs)("div",{style:{position:"absolute",top:"46px",right:0,width:"260px",background:"rgba(25, 25, 25, 0.98)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"16px",padding:"18px",boxShadow:"0 20px 25px -5px rgba(0,0,0,0.4), 0 10px 10px -5px rgba(0,0,0,0.4)",zIndex:1001,animation:"fadeUp 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards"},children:[(0,W.jsx)("div",{style:{fontSize:"11px",fontWeight:"bold",color:"#9CA3AF",letterSpacing:"1px",textTransform:"uppercase",marginBottom:"16px",paddingBottom:"10px",borderBottom:"1px solid rgba(255,255,255,0.06)"},children:"Keyboard Shortcuts"}),(0,W.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[{key:"\u2192",label:"Next slide"},{key:"\u2190",label:"Previous slide"},{key:"space",label:"Play/Pause"},{key:"esc",label:"Close story"},{key:"S",label:"Share story link"}].map(({key:F,label:q})=>(0,W.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"14px",justifyContent:"flex-start"},children:[(0,W.jsx)("span",{style:{minWidth:"54px",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.08)",padding:"5px 8px",borderRadius:"5px",fontSize:"12px",color:"white",border:"1px solid rgba(255,255,255,0.1)",boxSizing:"border-box"},children:F}),(0,W.jsx)("span",{style:{fontSize:"13px",color:"#E5E7EB",fontWeight:"500",textAlign:"left"},children:q})]},F))})]})]})]}),(0,W.jsx)(Ot,{config:{enabled:te?.enabled??!0,image:"",color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:44},onPress:c,style:{position:"relative",borderRadius:"12px"}})]})]})]}),(0,W.jsx)("div",{style:{flex:1,width:"100%",display:"flex",flexDirection:"column",justifyContent:U?"flex-start":"center",alignItems:"center",paddingTop:U?"14px":"0px",...ko()},children:(0,W.jsxs)("div",{style:{display:U?"grid":"flex",gridTemplateColumns:U?`minmax(0, 1fr) ${It}px minmax(0, 1fr)`:"none",alignItems:"center",justifyContent:"center",gap:"12px",width:"100%",maxWidth:"1400px",position:"relative"},onClick:F=>U&&F.stopPropagation(),children:[U&&(0,W.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(p>0||e>0)&&(0,W.jsx)("button",{onClick:wo,style:{background:"rgba(0,0,0,0.45)",border:"1px solid rgba(255,255,255,0.1)",color:"white",borderRadius:"50%",width:"44px",height:"44px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",backdropFilter:"blur(10px)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 8px 16px rgba(0,0,0,0.3)",outline:"none"},onMouseEnter:F=>{F.currentTarget.style.background="rgba(0,0,0,0.75)",F.currentTarget.style.transform="scale(1.1)",F.currentTarget.style.borderColor="rgba(255,255,255,0.25)"},onMouseLeave:F=>{F.currentTarget.style.background="rgba(0,0,0,0.45)",F.currentTarget.style.transform="scale(1)",F.currentTarget.style.borderColor="rgba(255,255,255,0.1)"},children:(0,W.jsx)("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,W.jsx)("polyline",{points:"15 18 9 12 15 6"})})})}),U?(0,W.jsx)("div",{style:{width:`${It}px`,height:`${Zt}px`,position:"relative",zIndex:5,overflow:"visible"},children:Array.from(Et).sort((F,q)=>F-q).map(F=>{let q=d.slides[F];if(!q)return null;let ft=oo(F),$t=As(ft,It),Ft=q?.styling,Ee=Ft?.editorSource||Ft?.meta?.editorSource,ue=Ee==="studio"||Ee==="editor",no=Ft?.background?.media?.mediaUrl||q?.image,He=I(q),Ro=Ct(Ft?.background)||"#000000",re=ue?q?.content?.button_text:q?.button_text,Ve=ue?q?.content?.link:q?.link,ve=Ft?.background?.media?.sizing||Ft?.background?.sizing||Ft?.media?.sizing||q?.sizing,Ue=ve==="fill"?"cover":ve==="fit"?"contain":ve==="stretch"?"fill":ue?"contain":"cover",pe=Ft?.background?.media?.position||Ft?.background?.position||Ft?.media?.position||q?.content?.background?.media?.position||q?.content?.media?.position||q?.position,Jt=uo(pe),Fo=F===p&&!T||T&&F===V,gn={display:"flex",justifyContent:"center",alignItems:"center",background:ue?Ro:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"16px"};return(0,W.jsxs)("div",{style:{...qt,position:"absolute",top:0,left:0,width:`${It}px`,height:`${Zt}px`,...$t,transition:ft==="hidden"||ft==="far-left"||ft==="far-right"?`opacity ${We}ms ease, transform ${We}ms ease`:F===B?`transform ${We}ms ${Hn}, opacity ${We}ms ${Hn}, filter ${We}ms ${Hn}`:`transform ${We}ms ${Vn}, opacity ${We}ms ${Vn}, filter ${We}ms ${Vn}`,transformOrigin:"center center",willChange:"transform, opacity, filter"},onClick:we=>we.stopPropagation(),children:[(0,W.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:ie,onMouseUp:()=>Se("prev"),onTouchStart:ie,onTouchEnd:()=>Se("prev")}),(0,W.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:ie,onMouseUp:()=>Se("next"),onTouchStart:ie,onTouchEnd:()=>Se("next")}),(0,W.jsxs)("div",{style:gn,children:[He?(0,W.jsx)(gr,{src:He,isActive:Fo,isAnimating:T,isMuted:h,onLoadedData:Be,activeVideoRef:H,objectFit:Ue,objectPosition:Jt}):no||!ue&&d?.thumbnail?(0,W.jsx)(ke,{src:no||d?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:Ue,objectPosition:Jt}}):null,(0,W.jsx)(On,{content:{...q.content,lottie:q.content?.lottie||q?.lottie||q.styling?.lottie,video:q.content?.video||q?.videoOverlay||q.styling?.video,image:q.content?.image||q?.imageOverlay||q.styling?.image,canva:nn(q),editorSource:q.content?.editorSource||q.editorSource||q.styling?.editorSource||q.meta?.editorSource,styling:{...q.content?.styling,...q?.styling},interactions:q.interactions},elapsedTime:Fo?u/100*(d.styling?.slideShowTime||5):0,onInteraction:async we=>{Fo&&gt(we,q)}})]}),(re||Ve)&&(0,W.jsx)(jn,{cta:q?.styling?.cta,buttonText:re||"Learn More",onPress:we=>{we&&we.stopPropagation&&we.stopPropagation(),X(q)}})]},q.id||F)})}):(0,W.jsx)("div",{style:{width:"100vw",height:"100dvh",maxWidth:"100vw",maxHeight:"100dvh",overflow:"hidden",position:"relative",zIndex:5,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",backgroundColor:"#000000"},children:d.slides.map((F,q)=>{if(Math.abs(q-p)>1)return(0,W.jsx)("div",{style:{display:"none"}},F.id||q);let ft=F?.styling,$t=ft?.editorSource||ft?.meta?.editorSource,Ft=$t==="studio"||$t==="editor",Ee=ft?.background?.media?.mediaUrl||F?.image,ue=F?.video||(Ft?F?.content?.video?.[0]?.link:void 0),no=Ct(ft?.background)||"#000000",He=Ft?F?.content?.button_text:F?.button_text,Ro=Ft?F?.content?.link:F?.link,re=ft?.background?.media?.sizing||ft?.background?.sizing||ft?.media?.sizing||F?.sizing,Ve=re==="fill"?"cover":re==="fit"?"contain":re==="stretch"?"fill":Ft?"contain":"cover",ve=ft?.background?.media?.position||ft?.background?.position||ft?.media?.position||F?.content?.background?.media?.position||F?.content?.media?.position||F?.position,Ue=uo(ve),pe=q===p;return pe?(0,W.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:(0,W.jsxs)("div",{style:{...qt},onClick:Jt=>Jt.stopPropagation(),children:[(0,W.jsx)("div",{style:{position:"absolute",top:"calc(10px + env(safe-area-inset-top, 0px))",left:"10px",right:"10px",display:"flex",gap:"4px",padding:"0 4px",zIndex:10},children:d.slides.map((Jt,Ye)=>{let pn=Ye<p?"100%":Ye===p?`${u}%`:"0%";return(0,W.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.3)",borderRadius:"2px",overflow:"hidden"},children:(0,W.jsx)("div",{style:{width:pn,height:"100%",backgroundColor:"white",transition:Ye===p&&u>0&&!T?"width 0.1s linear":"none"}})},Ye)})}),(0,W.jsxs)("div",{style:{position:"absolute",top:"calc(22px + env(safe-area-inset-top, 0px))",left:"10px",right:"10px",display:"flex",alignItems:"center",justifyContent:"space-between",zIndex:10,padding:"5px"},children:[(0,W.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,W.jsx)(ke,{src:d.thumbnail,alt:d.name,style:{width:"32px",height:"32px",borderRadius:"50%"}}),(0,W.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"14px",textShadow:"0 1px 3px rgba(0,0,0,0.8)"},children:d.name})]}),(0,W.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,W.jsx)(qn,{config:{enabled:d?.styling?.share?.enabled??!0,image:d?.styling?.share?.image??"",color:{cross:d?.styling?.share?.color?.cross??"#ffffff",fill:d?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:d?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:d?.styling?.share?.size??32},onPress:Oo,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"10px",width:"32px",height:"32px"}}),(0,W.jsx)(Me,{config:{size:(h?pt?.mute?.size:pt?.unmute?.size)||32,color:{cross:(h?pt?.mute?.color?.cross:pt?.unmute?.color?.cross)||"#ffffff",fill:(h?pt?.mute?.color?.fill:pt?.unmute?.color?.fill)||"rgba(255,255,255,0.08)",stroke:(h?pt?.mute?.color?.stroke:pt?.unmute?.color?.stroke)||"transparent"},margin:(h?pt?.mute?.margin:pt?.unmute?.margin)||{top:0,bottom:0,left:0,right:0},image:(h?pt?.mute?.image:pt?.unmute?.image)||""},onPress:Bt,type:h?"mute":"unmute",enabled:!!pt?.enabled&&!!ue,style:{position:"relative",borderRadius:"10px"}}),(0,W.jsx)(Ot,{config:{enabled:te?.enabled!==!1,image:"",color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:32},onPress:c,style:{position:"relative",borderRadius:"10px"}})]})]}),(0,W.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:ie,onMouseUp:()=>Se("prev"),onTouchStart:ie,onTouchEnd:()=>Se("prev")}),(0,W.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:ie,onMouseUp:()=>Se("next"),onTouchStart:ie,onTouchEnd:()=>Se("next")}),(0,W.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",background:Ft?no:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"0px"},children:[ue?(0,W.jsx)(gr,{src:ue,isActive:pe,isAnimating:T,isMuted:h,onLoadedData:Be,activeVideoRef:H,objectFit:Ve,objectPosition:Ue}):(Ee||!Ft&&d?.thumbnail)&&(0,W.jsx)(ke,{src:Ee||d?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:Ve,objectPosition:Ue}}),(0,W.jsx)(On,{content:{...F.content,canva:nn(F),editorSource:F.content?.editorSource||F.editorSource||F.styling?.editorSource||F.meta?.editorSource,styling:{...F.content?.styling,...F?.styling},interactions:F.interactions},elapsedTime:u/100*(d.styling?.slideShowTime||5),onInteraction:async Jt=>{gt(Jt,F)}})]}),(He||Ro)&&(0,W.jsx)(jn,{cta:F?.styling?.cta,buttonText:He||"Learn More",onPress:Jt=>{Jt&&Jt.stopPropagation&&Jt.stopPropagation(),X(F)}})]})},F.id||q):null})}),U&&(0,W.jsx)("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(0,W.jsx)("button",{onClick:Ie,style:{background:"rgba(0,0,0,0.45)",border:"1px solid rgba(255,255,255,0.1)",color:"white",borderRadius:"50%",width:"44px",height:"44px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",backdropFilter:"blur(10px)",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:"0 8px 16px rgba(0,0,0,0.3)",outline:"none"},onMouseEnter:F=>{F.currentTarget.style.background="rgba(0,0,0,0.75)",F.currentTarget.style.transform="scale(1.1)",F.currentTarget.style.borderColor="rgba(255,255,255,0.25)"},onMouseLeave:F=>{F.currentTarget.style.background="rgba(0,0,0,0.45)",F.currentTarget.style.transform="scale(1)",F.currentTarget.style.borderColor="rgba(255,255,255,0.1)"},children:(0,W.jsx)("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,W.jsx)("polyline",{points:"9 18 15 12 9 6"})})})})]})}),U&&e>0&&(0,W.jsxs)("div",{style:{position:"absolute",bottom:"36px",left:"24px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"6px",zIndex:20},children:[(0,W.jsx)("span",{style:{fontSize:"11px",fontWeight:"600",color:"rgba(255,255,255,0.65)",letterSpacing:"0.6px",textTransform:"uppercase",paddingLeft:"2px"},children:"Previous Stories"}),(0,W.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.08)",border:"1px solid rgba(255, 255, 255, 0.12)",padding:"8px 16px",borderRadius:"16px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(20px)",cursor:"pointer",boxShadow:"0 10px 24px rgba(0, 0, 0, 0.3)",transition:"all 0.25s cubic-bezier(0.4, 0, 0.2, 1)",maxWidth:"280px"},onClick:()=>xe("prev"),onMouseEnter:F=>{F.currentTarget.style.transform="translateY(-2px) scale(1.03)",F.currentTarget.style.background="rgba(255, 255, 255, 0.12)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.25)"},onMouseLeave:F=>{F.currentTarget.style.transform="translateY(0px) scale(1)",F.currentTarget.style.background="rgba(255, 255, 255, 0.08)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.12)"},children:[(0,W.jsx)("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2190"}),(0,W.jsx)("div",{style:{width:"36px",height:"36px",borderRadius:"50%",border:"2px solid rgba(255,255,255,0.8)",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0,overflow:"hidden"},children:(0,W.jsx)(ke,{src:t[e-1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),(0,W.jsx)("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e-1].name})]})]}),U&&e<t.length-1&&(0,W.jsxs)("div",{style:{position:"absolute",bottom:"36px",right:"24px",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"6px",zIndex:20},children:[(0,W.jsx)("span",{style:{fontSize:"11px",fontWeight:"600",color:"rgba(255,255,255,0.65)",letterSpacing:"0.6px",textTransform:"uppercase",paddingRight:"2px"},children:"Next Stories"}),(0,W.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.08)",border:"1px solid rgba(255, 255, 255, 0.12)",padding:"8px 16px",borderRadius:"16px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(20px)",cursor:"pointer",boxShadow:"0 10px 24px rgba(0, 0, 0, 0.3)",transition:"all 0.25s cubic-bezier(0.4, 0, 0.2, 1)",maxWidth:"280px"},onClick:()=>xe("next"),onMouseEnter:F=>{F.currentTarget.style.transform="translateY(-2px) scale(1.03)",F.currentTarget.style.background="rgba(255, 255, 255, 0.12)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.25)"},onMouseLeave:F=>{F.currentTarget.style.transform="translateY(0px) scale(1)",F.currentTarget.style.background="rgba(255, 255, 255, 0.08)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.12)"},children:[(0,W.jsx)("div",{style:{width:"36px",height:"36px",borderRadius:"50%",border:"2px solid rgba(255,255,255,0.8)",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0,overflow:"hidden"},children:(0,W.jsx)(ke,{src:t[e+1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),(0,W.jsx)("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e+1].name}),(0,W.jsx)("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2192"})]})]}),v&&(0,W.jsx)("div",{style:{position:"absolute",bottom:"40px",left:"50%",transform:"translateX(-50%)",background:"rgba(20, 20, 20, 0.96)",border:"1px solid rgba(255,255,255,0.08)",padding:"12px 24px",borderRadius:"12px",color:"white",fontSize:"13px",fontWeight:"500",boxShadow:"0 10px 20px rgba(0,0,0,0.5)",backdropFilter:"blur(10px)",zIndex:1e3},children:v})]})};var Po=require("react/jsx-runtime"),yr=()=>{let t=Mt("STR"),e=P(p=>p.isVisible),[o,n]=(0,$e.useState)(()=>{try{let p=sessionStorage.getItem("appstorys_active_story_index");if(p!==null){let y=parseInt(p,10);if(!isNaN(y)&&y>=0)return y}}catch{}return null}),[i,s]=(0,$e.useState)([]);(0,$e.useEffect)(()=>{try{o!==null?sessionStorage.setItem("appstorys_active_story_index",String(o)):sessionStorage.removeItem("appstorys_active_story_index")}catch{}},[o]),(0,$e.useEffect)(()=>{try{let p=localStorage.getItem("app_storys_viewed_stories");p&&s(JSON.parse(p))}catch(p){console.error("Failed to load viewed stories:",p)}},[]),(0,$e.useEffect)(()=>{t&&t.details&&st("story_module_viewed",t.id)},[t]);let l=$e.default.useMemo(()=>!t||!t.details?[]:bn(t.details),[t?.details]);if(!t||!l||l.length===0||!e)return null;let c=p=>{n(p)},d=()=>{o!==null&&(o<l.length-1?n(o+1):n(null))},S=()=>{o!==null&&o>0&&n(o-1)};return(0,Po.jsxs)("div",{className:"story-group-container",style:{width:"100vw",position:"relative",left:"50%",right:"50%",marginLeft:"-50vw",marginRight:"-50vw",boxSizing:"border-box"},children:[(0,Po.jsx)(_i,{stories:l,viewedStories:i,onStoryClick:c}),o!==null&&(0,Po.jsx)(mr,{stories:l,activeStoryIndex:o,dataId:t.id,viewedStories:i,setViewedStories:s,onNextStory:d,onPrevStory:S,onClose:()=>n(null)})]})};var ne=require("react"),xr=require("react-dom");bt();var je=require("react");function Do(t,e=.5){let o=(0,je.useRef)(t),n=(0,je.useRef)(!1),i=(0,je.useRef)(null),s=(0,je.useRef)(null);(0,je.useEffect)(()=>{o.current=t},[t]);let l=c=>{if(s.current&&(s.current.disconnect(),s.current=null),i.current=c,n.current=!1,!c)return;if(typeof IntersectionObserver>"u"){o.current();return}let d=null;s.current=new IntersectionObserver(S=>{S[0].isIntersecting&&!n.current?d||(d=setTimeout(()=>{n.current=!0,o.current(),s.current?.disconnect(),d=null},500)):d&&(clearTimeout(d),d=null)},{threshold:e}),s.current.observe(c)};return(0,je.useEffect)(()=>()=>{s.current?.disconnect()},[]),l}var hr=new Set;function _s(){try{return globalThis?.process?.env?.NODE_ENV!=="production"}catch{return!0}}function br(t,e,o){if(!_s()||o<=1)return;let n=`${e}::${t}`;hr.has(n)||(hr.add(n),console.warn(`AppStorys: Found ${o} elements matching target "${t}" (selector "${e}"). The first one in document order will be used. Target identifiers should be unique per screen.`))}function rn(t){if(!t)return null;let e=[`[data-as-id="${t}"]`,`[data-id="${t}"]`,`[data-widget="${t}"]`];for(let n of e)try{let i=document.querySelectorAll(n);if(i.length>0)return br(t,n,i.length),i[0]}catch{}let o=document.getElementById(t);if(o)return o;try{let n=`.${CSS&&CSS.escape?CSS.escape(t):t}`,i=document.querySelectorAll(n);if(i.length>0)return br(t,n,i.length),i[0]}catch{}return null}var ye=require("react/jsx-runtime"),Sr=({position:t})=>{let e=Mt("WID",{position:t}),o=P(A=>A.campaigns),n=P(A=>A.allCampaigns),i=P(A=>A.currentScreen),s=A=>(A||"").trim().toLowerCase(),l=e??(()=>{let A=s(i),T=[...o||[],...n||[]].find(k=>{let B=k;if(B.campaign_type!=="WID"||t&&B.position!==t)return!1;let $=!!(B.trigger_event??B.trigger),V=B.display_trigger!==!1&&!$,G=!s(B.screen)||s(B.screen)===A;return V&&G});if(T)try{return Ht(T)}catch{return T}})(),[c,d]=(0,ne.useState)(0),S=(0,ne.useRef)(null),p=(0,ne.useRef)(null),y=l?.details||{},u=y.widget_images||[],C=y.styling||{},h=y.type||"full",g=h==="half",b=(0,ne.useRef)([]),m=(0,ne.useRef)(!1),E=(0,ne.useCallback)(()=>{m.current=!0;let A=u[c];A?.id&&D(A.id)},[u,c]),j=Do(E),D=A=>{!l?.id||!A||m.current&&(b.current.includes(A)||(b.current.push(A),st("viewed",l.id,{widget_image:A})))};(0,ne.useEffect)(()=>{if(h==="full"&&u.length>1)return p.current=setInterval(()=>{d(A=>{let T=A+1;return T>=u.length?0:T})},5e3),()=>{p.current&&clearInterval(p.current)}},[h,u.length]);let L=(A,T)=>{let k=(T||"").trim();if(k){if(l?.id&&st("clicked",l.id,{widget_image:A}),!k.startsWith("http")){try{if(Nt(k))return}catch(B){console.warn("[Widget] revealCampaignFromLink error",B)}console.log("[Widget] Internal link:",k);return}window.open(k,"_blank")}},v=()=>{if(S.current&&g){let{scrollLeft:A,offsetWidth:T}=S.current,k=T/2+12,B=Math.round(A/k);d(B)}};(0,ne.useEffect)(()=>{if(!l?.id||h!=="full"||u.length===0)return;let A=u[c];A&&A.id&&D(A.id)},[c,l?.id,u,h]),(0,ne.useEffect)(()=>{if(!l?.id||!S.current||!g)return;let A=S.current,T=()=>{let{scrollLeft:k,offsetWidth:B}=A,$=B/2+12;u.forEach((V,G)=>{let r=G*$,M=r+$,a=k,f=k+B;Math.max(0,Math.min(M,f)-Math.max(r,a))/$>=.5&&D(V.id)})};return T(),A.addEventListener("scroll",T),()=>A.removeEventListener("scroll",T)},[l?.id,g,u]);let w={display:"flex",flexDirection:"row",flexWrap:g?"nowrap":"wrap",gap:"12px",width:"100%",height:g&&y.height?`${y.height}px`:"auto",marginTop:C.topMargin?`${C.topMargin}px`:"0px",marginBottom:C.bottomMargin?`${C.bottomMargin}px`:"0px",marginLeft:C.leftMargin?`${C.leftMargin}px`:"0px",marginRight:C.rightMargin?`${C.rightMargin}px`:"0px",boxSizing:"border-box",overflowX:g?"auto":"hidden",overflowY:"hidden",scrollSnapType:g?"x mandatory":void 0,msOverflowStyle:"none",scrollbarWidth:"none"},_=A=>({flex:g?"0 0 calc(50% - 6px)":"0 0 100%",height:g&&y.height?`${y.height}px`:"auto",cursor:"pointer",position:"relative",overflow:"hidden",borderRadius:C.borderRadius?`${C.borderRadius}px`:"0px",borderTopLeftRadius:C.topLeftRadius?`${C.topLeftRadius}px`:void 0,borderTopRightRadius:C.topRightRadius?`${C.topRightRadius}px`:void 0,borderBottomLeftRadius:C.bottomLeftRadius?`${C.bottomLeftRadius}px`:void 0,borderBottomRightRadius:C.bottomRightRadius?`${C.bottomRightRadius}px`:void 0,boxShadow:"0 4px 12px rgba(0,0,0,0.08)",scrollSnapAlign:"start"}),N=(0,ye.jsxs)("div",{style:{width:"100%",position:"relative"},children:[(0,ye.jsx)("style",{children:`
120
125
  .widget-scroll-container::-webkit-scrollbar {
121
126
  display: none;
122
127
  }
123
- `}),(0,Gt.jsx)("div",{ref:B=>{y.current=B,I(B)},className:"widget-scroll-container",style:_,onScroll:w,children:u?f.map((B,a)=>(0,Gt.jsx)("div",{style:P(a),children:(0,Gt.jsx)("img",{src:B.image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onClick:()=>E(B.id,B.link)})},B.id)):f.length>0&&(0,Gt.jsx)("div",{style:P(0),children:(0,Gt.jsx)("img",{src:f[d].image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onClick:()=>E(f[d].id,f[d].link)})},`slide-${d}`)}),S==="full"&&f.length>1&&(0,Gt.jsx)("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"8px",width:"100%"},children:f.map((B,a)=>(0,Gt.jsx)("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:a===d?"#333":"#ccc",transition:"background-color 0.2s ease"}},a))})]}),q=null;if(l?.position){let B=String(l.position||"").replace(/^widget_/,"");q=Bo(B),q?console.log("[Widget] Portal target found for campaign",l?.id):console.log("[Widget] No portal target found for position:",l?.position,"rendering inline for campaign:",l?.id)}return q?(0,Ui.createPortal)($,q):$};var vt=require("react");rt();var Lt=require("react/jsx-runtime"),xn=t=>(t||"").trim().toLowerCase(),rs=()=>{let t=xt("TTP"),e=A(L=>L.campaigns),o=A(L=>L.allCampaigns),i=A(L=>L.currentScreen),n=A(L=>L.isVisible),[r,l]=(0,vt.useState)(0),[d,c]=(0,vt.useState)(!1),[y,b]=(0,vt.useState)(null),[h,f]=(0,vt.useState)({width:0,height:0}),v=(0,vt.useRef)(null),S=(0,vt.useRef)(null),u=(0,vt.useRef)(null),m=(0,vt.useMemo)(()=>{if(t)return t;let L=xn(i),J=ht=>ht.find(Y=>{let O=Y,et=O.campaign_type==="TTP"||O.campaign_type==="TLTP",ut=!xn(O.screen)||xn(O.screen)===L,Ct=!!(O.trigger_event??O.trigger),yt=O.display_trigger!==!1&&!Ct;return et&&ut&&yt});return J(e)??J(o)},[t,e,o,i]),g=(0,vt.useMemo)(()=>m?.details?.tooltips&&Array.isArray(m.details.tooltips)?[...m.details.tooltips].sort((L,J)=>(L.order??0)-(J.order??0)):m?.details?.target||m?.details?.titleText?[{...m.details,_id:m.id}]:[],[m]),C=g[r];(0,vt.useEffect)(()=>{},[m]);let I=(0,vt.useRef)(new Set),z=(0,vt.useCallback)(()=>{if(!(!m||!C||d||!n))try{let L=C._id||C.id||void 0,J=String(m.id||"")+"::"+String(L||"");I.current.has(J)||(I.current.add(J),X("viewed",m.id,{tooltip_id:L}))}catch{}},[m,C,d,n]),E=so(z);if((0,vt.useEffect)(()=>{if(!C?.target||d)return;b(null);let L=(O=!1)=>{let et=C.target;if(!et)return null;let ut=Bo(et);return ut?(b(ut.getBoundingClientRect()),O&&ut.scrollIntoView({behavior:"smooth",block:"center"}),ut):null},J=O=>{u.current?.disconnect(),u.current=null,!(!O||typeof ResizeObserver>"u")&&(u.current=new ResizeObserver(()=>{b(O.getBoundingClientRect())}),u.current.observe(O))},ht=L(!0);J(ht),ht||(S.current=new MutationObserver(()=>{let O=L(!0);O&&(S.current?.disconnect(),J(O))}),S.current.observe(document.body,{childList:!0,subtree:!0}));let Y=()=>{let O=L(!1);O&&b(O.getBoundingClientRect())};return window.addEventListener("resize",Y),window.addEventListener("scroll",Y,{passive:!0,capture:!0}),()=>{S.current?.disconnect(),u.current?.disconnect(),window.removeEventListener("resize",Y),window.removeEventListener("scroll",Y,{capture:!0})}},[C,d,r]),(0,vt.useLayoutEffect)(()=>{if(v.current&&y){let{width:L,height:J}=v.current.getBoundingClientRect();f({width:L,height:J})}},[C,y]),!m||!C||d||!n||!y)return null;let w=C.styling||{},_=w.appearance||{},P=_.colors||{},$=w.cta||{},q=$.container||{},B=$.cornerRadius||{},a=$.text||{},x=!!(_.imageDimensions?.width&&_.imageDimensions?.height),s,p;if(x){let L=_.imageDimensions.width,J=_.imageDimensions.height,ht=typeof window<"u"?window.innerWidth*.9:L;s=Math.min(L,ht),p=s===L?J:Math.round(J*(s/L))}let M=C.arrowPosition;!M&&C.position&&(C.position==="left"?M="right":C.position==="right"?M="left":C.position==="top"?M="bottom":C.position==="bottom"&&(M="top")),M||(M="left");let R=(_.arrowStyle||{width:6,height:12}).width||6,W=y.top+window.scrollY,H=y.left+window.scrollX,U=0,j=0,V=8;M==="left"?(U=H+y.width+V,j=W+y.height/2-h.height/2):M==="right"?(U=H-h.width-V,j=W+y.height/2-h.height/2):M==="top"?(j=W+y.height+V,U=H+y.width/2-h.width/2):M==="bottom"&&(j=W-h.height-V,U=H+y.width/2-h.width/2);let tt=8,at=typeof document<"u"?document.documentElement.scrollHeight:window.innerHeight,nt=typeof document<"u"?document.documentElement.scrollWidth:window.innerWidth;h.height>0&&(j=Math.max(tt,Math.min(at-h.height-tt,j))),h.width>0&&(U=Math.max(tt,Math.min(nt-h.width-tt,U)));let lt=()=>{let L=C.link||C.url;try{let J=C._id||C.id||void 0;m?.id&&X("clicked",m.id,{tooltip_id:J})}catch{}r<g.length-1?(l(J=>J+1),L&&window.open(L,"_blank")):(c(!0),L&&window.open(L,"_blank"))},k=()=>{C.enableBackdrop&&(r<g.length-1?l(L=>L+1):c(!0))};return(0,Lt.jsxs)(Lt.Fragment,{children:[C.enableBackdrop&&(0,Lt.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:P.backdrop||"rgba(0, 0, 0, 0.7)",opacity:_.backdropOpacity?_.backdropOpacity/100:.7,zIndex:1e4},onClick:k}),(0,Lt.jsxs)("div",{ref:L=>{v.current=L,E(L)},style:{position:"absolute",top:j,left:U,zIndex:10001,backgroundColor:P.tooltip||"#FE6B35",padding:x?0:`${_.padding?.top??8}px ${_.padding?.right??8}px ${_.padding?.bottom??8}px ${_.padding?.left??8}px`,borderRadius:`${_.cornerRadius?.topLeft??12}px ${_.cornerRadius?.topRight??12}px ${_.cornerRadius?.bottomRight??12}px ${_.cornerRadius?.bottomLeft??12}px`,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",width:x?s:void 0,height:x?p:void 0,maxWidth:x?s:300,minWidth:x?void 0:200,transition:"top 0.2s ease, left 0.2s ease",cursor:C.ctaText?"default":"pointer"},onClick:L=>{L.target.tagName!=="BUTTON"&&(C.ctaText||lt())},children:[(0,Lt.jsx)("div",{style:{position:"absolute",width:0,height:0,borderStyle:"solid",...M==="left"&&{left:-V,top:Math.max(12,Math.min(h.height-R*2-12,W+y.height/2-j-R)),borderWidth:`${R}px ${V}px ${R}px 0`,borderColor:`transparent ${P.arrow||P.tooltip||"#FE6B35"} transparent transparent`},...M==="right"&&{right:-V,top:Math.max(12,Math.min(h.height-R*2-12,W+y.height/2-j-R)),borderWidth:`${R}px 0 ${R}px ${V}px`,borderColor:`transparent transparent transparent ${P.arrow||P.tooltip||"#FE6B35"}`},...M==="top"&&{top:-V,left:Math.max(12,Math.min(h.width-R*2-12,H+y.width/2-U-R)),borderWidth:`0 ${R}px ${V}px ${R}px`,borderColor:`transparent transparent ${P.arrow||P.tooltip||"#FE6B35"} transparent`},...M==="bottom"&&{bottom:-V,left:Math.max(12,Math.min(h.width-R*2-12,H+y.width/2-U-R)),borderWidth:`${V}px ${R}px 0 ${R}px`,borderColor:`${P.arrow||P.tooltip||"#FE6B35"} transparent transparent transparent`}}}),C.url&&(x?(0,Lt.jsx)("div",{style:{width:"100%",height:"100%",overflow:"hidden",borderRadius:`${_.cornerRadius?.topLeft??12}px ${_.cornerRadius?.topRight??12}px ${_.cornerRadius?.bottomRight??12}px ${_.cornerRadius?.bottomLeft??12}px`},children:(0,Lt.jsx)("img",{src:C.url,alt:"tooltip media",style:{width:"100%",height:"100%",display:"block",objectFit:"cover"}})}):(0,Lt.jsx)("img",{src:C.url,alt:"tooltip media",style:{width:"100%",borderRadius:6,marginBottom:8,display:"block",objectFit:"cover"}})),(C.titleText||C.subtitleText||C.ctaText)&&(0,Lt.jsxs)("div",{style:x?{padding:`${_.padding?.top??8}px ${_.padding?.right??8}px ${_.padding?.bottom??8}px ${_.padding?.left??8}px`}:void 0,children:[C.titleText&&(0,Lt.jsx)("div",{style:{color:w.title?.color||"#ffffff",fontFamily:mt(w.title?.fontFamily)||"Arial",fontSize:w.title?.fontSize||14,textAlign:w.title?.textAlign||"center",marginBottom:w.title?.margin?.bottom??4,marginTop:w.title?.margin?.top??0,marginLeft:w.title?.margin?.left??0,marginRight:w.title?.margin?.right??0,fontWeight:w.title?.fontDecoration?.includes("bold")?"bold":600,fontStyle:w.title?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:w.title?.fontDecoration?.includes("underline")?"underline":"none"},children:C.titleText}),C.subtitleText&&(0,Lt.jsx)("div",{style:{color:w.subTitle?.color||"#ffffff",fontFamily:mt(w.subTitle?.fontFamily)||"Arial",fontSize:w.subTitle?.fontSize||12,textAlign:w.subTitle?.textAlign||"center",marginBottom:w.subTitle?.margin?.bottom??8,marginTop:w.subTitle?.margin?.top??0,marginLeft:w.subTitle?.margin?.left??0,marginRight:w.subTitle?.margin?.right??0,fontWeight:w.subTitle?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:w.subTitle?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:w.subTitle?.fontDecoration?.includes("underline")?"underline":"none"},children:C.subtitleText}),C.ctaText&&(0,Lt.jsx)("div",{style:{display:"flex",justifyContent:q.alignment==="right"?"flex-end":q.alignment==="left"?"flex-start":"center",marginTop:8},children:(0,Lt.jsx)("button",{onClick:lt,style:{width:q.ctaFullWidth?"100%":q.ctaWidth||"auto",height:q.height||35,background:q.backgroundColor||"#F7921C",color:a.color||"#ffffff",border:`${q.borderWidth||0}px solid ${q.borderColor||"transparent"}`,borderRadius:`${B.topLeft??7}px ${B.topRight??7}px ${B.bottomRight??7}px ${B.bottomLeft??7}px`,fontSize:a.fontSize||14,fontFamily:mt(a.fontFamily)||"Arial",fontWeight:a.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:a.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:a.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:C.ctaText})})]})]})]})},Qi=rs;var He=require("react");rt();var It=require("react/jsx-runtime"),Gi=()=>{let t=xt("BTS"),e=A(u=>u.campaigns),o=A(u=>u.allCampaigns),i=A(u=>u.currentScreen),n=t??(()=>{let u=(i||"").trim().toLowerCase(),m=[...e||[],...o||[]].find(g=>{if(!g||g.campaign_type!=="BTS")return!1;let C=!!(g.trigger_event??g.trigger);if(!(g.display_trigger!==!1&&!C))return!1;let z=(g.screen||"").trim().toLowerCase();return!z||z===u});if(m)try{return Ft(m)}catch{return m}})(),r=A(u=>u.isVisible),[l,d]=(0,He.useState)(!1),c=(0,He.useRef)(null);(0,He.useEffect)(()=>{n?.id&&c.current!==n.id&&(c.current=n.id,d(!1),X("viewed",n.id))},[n?.id]);let y=u=>{try{let m=A.getState(),C=(m.trackedEvents||[]).filter(I=>I!==u);m.setTrackedEvents(C)}catch{}};if(!n||l||!r)return null;let{details:b}=n,f=[...b.elements||[]].sort((u,m)=>(u.order||0)-(m.order||0)),v=b.backdropOpacity??.5;v>1&&(v=v/100);let S=u=>{switch(u.type){case"image":{let m={width:"100%",display:"block",objectFit:"contain",backgroundColor:u.imageBackgroundColor||"transparent",paddingBottom:u.paddingBottom??0,paddingLeft:u.paddingLeft??0,paddingRight:u.paddingRight??0,paddingTop:u.paddingTop??0,cursor:u.imageLink?"pointer":"default"};return(0,It.jsx)("div",{style:{textAlign:u.alignment||"left",width:"100%"},children:u.url&&(0,It.jsx)("img",{src:u.url,alt:"",style:m,onClick:()=>{if(u.imageLink){n?.id&&X("clicked",n.id);try{let g=String(u.imageLink||"").trim();if(g&&!g.startsWith("http")&&kt(g))return}catch(g){console.warn("revealCampaignFromLink error",g)}try{window.open(u.imageLink,"_blank")}catch{}}}})},u.id)}case"cta":{let m=u.cta||{},g=m.container||{},C=m.cornerRadius||{},I=m.margin||{},z=m.text||{};return(0,It.jsx)("div",{style:{display:"flex",justifyContent:g.alignment==="center"?"center":g.alignment==="right"?"flex-end":"flex-start",width:"100%",marginTop:I.top??0,marginBottom:I.bottom??0,marginLeft:I.left??0,marginRight:I.right??0},children:(0,It.jsx)("button",{style:{width:g.ctaFullWidth?"100%":g.ctaWidth||"auto",height:g.height||45,backgroundColor:g.ctaBoxColor||g.backgroundColor||"#FE6B35",color:z.color||"#ffffff",border:`${g.borderWidth||0}px solid ${g.borderColor||"transparent"}`,borderRadius:`${C.topLeft??12}px ${C.topRight??12}px ${C.bottomRight??12}px ${C.bottomLeft??12}px`,fontSize:z.fontSize||14,fontFamily:mt(z.fontFamily)||"Arial",fontWeight:z.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:z.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:z.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px"},onClick:()=>{let E=u.ctaLink||u.url;if(E){n?.id&&X("clicked",n.id);try{let w=String(E||"").trim();if(w&&!w.startsWith("http")&&kt(w))return}catch(w){console.warn("revealCampaignFromLink error",w)}try{window.open(E,"_blank")}catch{}}},children:u.ctaText||"Button"})},u.id)}case"body":{let m=u.titleFontStyle||{},g=u.descriptionFontStyle||{};return(0,It.jsxs)("div",{style:{width:"100%",backgroundColor:u.bodyBackgroundColor||"transparent",marginTop:u.marginTop??0,marginBottom:u.marginBottom??20,marginLeft:u.marginLeft??4,marginRight:u.marginRight??4},children:[u.titleText&&(0,It.jsx)("div",{style:{color:m.colour||"#000000",fontSize:m.fontSize?`${m.fontSize}px`:u.titleFontSize?`${u.titleFontSize}px`:"16px",fontFamily:mt(m.fontFamily)||"inherit",textAlign:m.alignment||"left",lineHeight:u.titleLineHeight||1.2,fontWeight:m.decoration?.includes("bold")?"bold":"600",fontStyle:m.decoration?.includes("italic")?"italic":"normal",textDecoration:m.decoration?.includes("underline")?"underline":"none",marginBottom:u.spacingBetweenTitleDesc??4},children:u.titleText}),u.descriptionText&&(0,It.jsx)("div",{style:{color:g.colour||"#000000",fontSize:g.fontSize?`${g.fontSize}px`:u.descriptionFontSize?`${u.descriptionFontSize}px`:"14px",fontFamily:mt(g.fontFamily)||"inherit",textAlign:g.alignment||"left",lineHeight:u.descriptionLineHeight||1.5,fontWeight:g.decoration?.includes("bold")?"bold":"normal",fontStyle:g.decoration?.includes("italic")?"italic":"normal",textDecoration:g.decoration?.includes("underline")?"underline":"none"},children:u.descriptionText})]},u.id)}default:return null}};return(0,It.jsxs)(It.Fragment,{children:[(0,It.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:b.backdropColor||"rgba(0,0,0,0.5)",opacity:v,zIndex:999998,transition:"opacity 0.3s ease"},onClick:()=>{n?.id&&y(`viaAppStorys${n.id}`),d(!0)}}),(0,It.jsxs)("div",{style:{position:"fixed",bottom:0,left:"50%",transform:"translateX(-50%)",width:"100%",maxWidth:"500px",backgroundColor:b.backgroundColor||"#FFFFFF",borderTopLeftRadius:`${b.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${b.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:`${b.cornerRadius?.bottomLeft??0}px`,borderBottomRightRadius:`${b.cornerRadius?.bottomRight??0}px`,zIndex:999999,padding:"24px 16px",boxShadow:"0 -4px 16px rgba(0,0,0,0.15)",maxHeight:"85vh",overflowY:"auto",display:"flex",flexDirection:"column",alignItems:"center",transition:"transform 0.3s ease-out"},children:[(0,It.jsx)("div",{style:{width:"40px",height:"5px",backgroundColor:"#E0E0E0",borderRadius:"2.5px",marginBottom:"16px",cursor:"pointer"},onClick:()=>d(!0)}),b.crossButton?.enabled&&(0,It.jsx)(At,{config:b.crossButton,onPress:()=>{n?.id&&y(`viaAppStorys${n.id}`),d(!0)},style:{top:b.crossButton?.margin?.top??12,right:b.crossButton?.margin?.right??12}}),(0,It.jsx)("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:"12px"},children:f.map(S)})]})]})};var Dt=require("react");rt();var Ue=ae(require("lottie-react")),Z=require("react/jsx-runtime"),ss=Ue.default?.default??Ue.default??Ue.Lottie??Ue,Xi=5,Sn=3;function qe(t){if(t!=null)return`${t}px`}function ao(t){return{marginTop:qe(t?.top),marginRight:qe(t?.right),marginBottom:qe(t?.bottom),marginLeft:qe(t?.left)}}function vn(t){return mt(t)}function Ve(t){return t?{color:t.color,fontSize:t.fontSize,fontFamily:vn(t.fontFamily),textAlign:t.textAlign,fontWeight:t.fontDecoration?.includes("bold")?"bold":void 0,fontStyle:t.fontDecoration?.includes("italic")?"italic":void 0,textDecoration:t.fontDecoration?.includes("underline")?"underline":void 0}:{}}function Lo(t){return`${t?.topLeft??8}px ${t?.topRight??8}px ${t?.bottomRight??8}px ${t?.bottomLeft??8}px`}function as(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function ls(t){let e=t.styling?.rating?.ratingType;return e==="number"||e==="emoji"||e==="star"?e:"star"}function ds(t){let e=t.styling?.rating?.emoji,o=[];Array.isArray(e)?o=e:e&&typeof e=="object"?Array.isArray(e.values)?o=e.values:o=Object.values(e):typeof e=="string"&&e.trim()&&(o=e.split(","));let i=o.map(n=>{if(typeof n=="string")return n.trim();if(n&&typeof n=="object"){let r=n.emoji||n.value||n.text||n.icon||n.name||"";if(typeof r=="string")return r.trim()}return""}).filter(Boolean);return i.length>0?i:["\u{1F620}","\u{1F615}","\u{1F610}","\u{1F642}","\u{1F60D}"]}function cs(t){return Array.from({length:5},(e,o)=>o+1)}function Cn(t){if(typeof t=="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t=="string"&&t.trim().length>0){let e=Number(t);if(Number.isFinite(e)&&e>=0)return e}}function us(t){let e=t.styling?.rating||void 0,o=[e?.numberSpacing,e?.numberGap,e?.number_spacing,e?.number_gap,e?.spacingBetweenNumbers,e?.spaceBetweenNumbers,e?.numberOptionsSpacing];for(let n of o){let r=Cn(n);if(r!=null)return r}let i=e?.number;if(i&&typeof i=="object"){let n=i,r=[n.spacing,n.gap,n.optionsSpacing,n.numberSpacing,n.numberGap];for(let l of r){let d=Cn(l);if(d!=null)return d}}return 8}var ps=({fill:t,stroke:e})=>(0,Z.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":!0,children:(0,Z.jsx)("path",{d:"M12 2.25l2.91 5.89 6.5.95-4.7 4.58 1.11 6.46L12 17.03 6.18 20.13l1.11-6.46-4.7-4.58 6.5-.95L12 2.25z",fill:t,stroke:e,strokeWidth:"1.4",strokeLinejoin:"round"})}),gs=({details:t,appearance:e,rating:o,selectedOptions:i,comments:n,isHighRating:r,feedbackOptions:l,onRate:d,onToggleOption:c,onCommentChange:y,onInlineSubmit:b,canSubmit:h})=>{let f=t.styling||{},v=f.feedbackPage||{},S=f.rating||{},u=f.initialFeedback||{},m=v.submitButton?.cta,g=ls(t),C=g==="number"?cs(t):[],I=g==="emoji"?ds(t):[],z=g==="number"?us(t):8,E=r?S.star?.high:S.star?.low;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)("div",{style:ao(u.title?.margin),children:(0,Z.jsx)("div",{style:{...Ve(u.title?.textStyle),color:u.title?.textStyle?.color||"#101828",fontSize:u.title?.textStyle?.fontSize||20,lineHeight:1.3},children:t.title||"How was your experience?"})}),(0,Z.jsx)("div",{style:ao(u.subtitle?.margin),children:(0,Z.jsx)("div",{style:{...Ve(u.subtitle?.textStyle),color:u.subtitle?.textStyle?.color||"#4b5563",fontSize:u.subtitle?.textStyle?.fontSize||14,lineHeight:1.4},children:t.description_text||"Your feedback helps us improve your experience."})}),(0,Z.jsxs)("div",{style:{marginTop:8,display:"flex",justifyContent:"center",gap:g==="number"?z:8,flexWrap:"wrap"},children:[g==="star"&&Array.from({length:Xi},(w,_)=>{let P=_+1,$=P<=o,q=$?E?.stylingContainer:S.star?.unselected?.stylingContainer,B=$?E?.stylingStar:S.star?.unselected?.stylingStar;return(0,Z.jsx)("button",{onClick:()=>d(P),style:{border:`${q?.borderWidth??1}px solid ${q?.border||"#d1d5db"}`,background:q?.background||"#ffffff",borderRadius:10,width:44,height:44,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0},"aria-label":`Rate ${P} out of ${Xi}`,children:(0,Z.jsx)(ps,{fill:B?.background||($?"#f59e0b":"#e5e7eb"),stroke:B?.border||($?"#d97706":"#9ca3af")})},P)}),g==="number"&&C.map((w,_)=>{let P=w===o;return(0,Z.jsx)("button",{onClick:()=>d(w),style:{border:`1px solid ${P?"#1d4ed8":"#d1d5db"}`,background:P?"#dbeafe":"#ffffff",color:P?"#1d4ed8":"#111827",borderRadius:8,minWidth:36,height:36,padding:"0 10px",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontWeight:600},"aria-label":`Rate ${w}`,children:w},`${w}-${_}`)}),g==="emoji"&&I.map((w,_)=>{let P=_+1,$=P===o,q=S.emoji,a=($?q?.selected:q?.unselected)?.stylingContainer;return(0,Z.jsx)("button",{onClick:()=>d(P),style:{border:`${a?.borderWidth??1}px solid ${a?.border||($?"#1d4ed8":"#d1d5db")}`,background:a?.fill||a?.background||($?"#dbeafe":"#ffffff"),borderRadius:S.cornerRadius?Lo(S.cornerRadius):"999px",width:44,height:44,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:22},"aria-label":`Emoji rating ${_+1}`,children:w},`${w}-${_}`)})]}),o>0&&(0,Z.jsx)("div",{style:{marginTop:6,textAlign:"center",color:"#374151",fontSize:14},children:r?t.highStarText||S.highRatingSubtitle:t.lowStarText||S.lowRatingSubtitle}),o>0&&o<=Sn&&(0,Z.jsxs)(Z.Fragment,{children:[l.length>0&&(0,Z.jsx)("div",{style:{...ao(v.options?.margin),display:"flex",flexDirection:"column",alignItems:"stretch",gap:v.options?.optionsSpacing??8,width:"100%"},children:l.map(w=>{let P=i.includes(w)?v.options?.selectedOptions:v.options?.nonSelectedOptions;return(0,Z.jsx)("button",{onClick:()=>c(w),style:{border:`${P?.borderWidth??1}px solid ${P?.colors?.border||"#d1d5db"}`,background:P?.colors?.background||"#f9fafb",color:P?.colors?.text||"#111827",width:"100%",height:v.options?.optionsHeight||38,borderRadius:Lo(v.options?.cornerRadius),padding:"0 14px",cursor:"pointer",textAlign:"center",...Ve(P?.textStyle)},children:w},w)})}),(0,Z.jsx)("textarea",{value:n,onChange:w=>y(w.target.value),placeholder:v.additionalComments?.placeholder||"Tell us what we can improve",style:{width:"100%",boxSizing:"border-box",minHeight:56,height:56,maxHeight:64,marginTop:8,resize:"none",overflowY:"auto",border:`${v.additionalComments?.borderWidth??1}px solid ${v.additionalComments?.colors?.border||"#d1d5db"}`,background:v.additionalComments?.colors?.background||"#ffffff",color:v.additionalComments?.colors?.text||"#111827",borderRadius:8,padding:"12px",...Ve(v.additionalComments?.textStyle)}}),(0,Z.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:8,paddingTop:6,paddingBottom:6,background:e?.backgroundColor||"#2f6ef5",display:"flex",justifyContent:"center"},children:(0,Z.jsx)("button",{onClick:()=>b(),disabled:!h,style:{width:Math.max(140,Math.min(Cn(m?.container?.ctaWidth)??180,220)),maxWidth:"100%",minHeight:30,height:Math.max(30,Math.min(Number(m?.container?.height)||34,34)),border:`${m?.container?.borderWidth??1}px solid ${m?.container?.borderColor||"#ff7a00"}`,background:m?.container?.backgroundColor||"#ff2bc2",color:m?.text?.color||"#ffffff",borderRadius:Lo(m?.cornerRadius),fontFamily:vn(m?.text?.fontFamily),fontSize:Math.min(Number(m?.text?.fontSize)||14,14),fontWeight:m?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:h?"pointer":"not-allowed",opacity:h?1:.65,padding:"0 12px"},children:v.submitButton?.text||"Submit"})})]})]})},fs=({details:t,isHighRating:e,onDone:o})=>{let i=t.styling||{},n=i.thankyouPage||{},r=i.rating||{},l=as(n.doneButton?.cta?.container?.alignment),[d,c]=(0,Dt.useState)(null),y=t.thankyouImage?.endsWith(".json");return(0,Dt.useEffect)(()=>{y&&t.thankyouImage&&fetch(t.thankyouImage).then(b=>b.json()).then(b=>c(b)).catch(b=>console.error("Error loading Lottie:",b))},[t.thankyouImage,y]),(0,Z.jsxs)(Z.Fragment,{children:[t.thankyouImage&&(0,Z.jsx)("div",{style:{display:"flex",justifyContent:"center",marginTop:6},children:y?d?(0,Z.jsx)(ss,{animationData:d,loop:!0,style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):(0,Z.jsx)("div",{style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):(0,Z.jsx)("img",{src:t.thankyouImage,alt:"thank you",style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80,objectFit:"cover",borderRadius:8}})}),(0,Z.jsx)("div",{style:{...ao(n.title?.margin),textAlign:"center"},children:(0,Z.jsx)("div",{style:{...Ve(n.title?.textStyle),color:n.title?.textStyle?.color||"#111827",fontSize:n.title?.textStyle?.fontSize||20,fontWeight:n.title?.textStyle?.fontDecoration?.includes("bold")?"bold":600},children:t.thankyouText??(e?r.highRatingTitle:r.lowRatingTitle)??"Thank you for your feedback"})}),(0,Z.jsx)("div",{style:{...ao(n.subtitle?.margin),textAlign:"center"},children:(0,Z.jsx)("div",{style:{...Ve(n.subtitle?.textStyle),color:n.subtitle?.textStyle?.color||"#4b5563",fontSize:n.subtitle?.textStyle?.fontSize||14},children:t.thankyouDescription??(e?r.highRatingSubtitle:r.lowRatingSubtitle)??"We appreciate your time."})}),(0,Z.jsx)("div",{style:{marginTop:n.doneButton?.cta?.margin?.top??14,marginBottom:n.doneButton?.cta?.margin?.bottom??0,marginLeft:n.doneButton?.cta?.margin?.left??0,marginRight:n.doneButton?.cta?.margin?.right??0,display:"flex",justifyContent:l},children:(0,Z.jsx)("button",{onClick:o,style:{width:n.doneButton?.cta?.container?.ctaFullWidth?"100%":n.doneButton?.cta?.container?.ctaWidth||"auto",height:n.doneButton?.cta?.container?.height||45,border:`${n.doneButton?.cta?.container?.borderWidth??0}px solid ${n.doneButton?.cta?.container?.borderColor||"transparent"}`,background:n.doneButton?.cta?.container?.backgroundColor||"#111827",color:n.doneButton?.cta?.text?.color||"#ffffff",borderRadius:Lo(n.doneButton?.cta?.cornerRadius),fontFamily:vn(n.doneButton?.cta?.text?.fontFamily),fontSize:n.doneButton?.cta?.text?.fontSize||16,fontWeight:n.doneButton?.cta?.text?.fontDecoration?.includes("bold")?"bold":500,cursor:"pointer",padding:"0 16px"},children:n.doneButton?.text||(e?"Rate Now":"Done")})})]})},ms=()=>{let t=xt("CSAT"),e=A(s=>s.isVisible),o=A(s=>s.campaigns),i=A(s=>s.allCampaigns),n=A(s=>s.currentScreen),r=t??(()=>{let s=(n||"").trim().toLowerCase(),p=[...o||[],...i||[]].find(M=>{if(!M||M.campaign_type!=="CSAT")return!1;let T=!!(M.trigger_event??M.trigger);if(!(M.display_trigger!==!1&&!T))return!1;let W=(M.screen||"").trim().toLowerCase();return!W||W===s});if(p)try{return Ft(p)}catch{return p}})(),[l,d]=(0,Dt.useState)(!1),[c,y]=(0,Dt.useState)(!1),[b,h]=(0,Dt.useState)(0),[f,v]=(0,Dt.useState)([]),[S,u]=(0,Dt.useState)(""),[m,g]=(0,Dt.useState)(!1),C=(0,Dt.useRef)(null);(0,Dt.useEffect)(()=>{if(!r?.id||C.current===r.id)return;C.current=r.id,d(!1),y(!1),h(0),v([]),u(""),g(!1);let s=r.details?.styling?.appearance?.displayDelay??0,p=globalThis.setTimeout(()=>{y(!0),X("viewed",r.id)},Math.max(0,s)*1e3);return()=>globalThis.clearTimeout(p)},[r?.id]);let I=(0,Dt.useMemo)(()=>{let s=r?.details?.feedback_option||{};return Object.keys(s).sort((p,M)=>p.localeCompare(M)).map(p=>s[p]).filter(Boolean)},[r]);if(!r||!e||l||!c)return null;let z=r.details,E=z.styling||{},w=E.appearance||{},_=b>Sn,P=Number(z.width??80),$=Math.max(660,Math.min(1080,P*10)),q=s=>{v(p=>p.includes(s)?p.filter(M=>M!==s):[...p,s])},B=async s=>{let p=s?.rating??b;if(p<1)return;g(!0);let M=z.id||r.id,T=(s?.options??f)[0]||"",R=s?.comments??S??"";X("csat captured",M,{starCount:p,selectedOption:T,additionalComments:R})},a=s=>{if(h(s),s>Sn){v([]),u("");let p=z.id||r?.id;setTimeout(()=>{g(!0);try{X("csat captured",p,{starCount:s,selectedOption:"",additionalComments:""})}catch(M){console.warn("Error sending csat captured",M)}},1e3)}},x=()=>{if(_&&z.link){let s=r&&r.id||void 0;try{s&&X("clicked",s)}catch{}try{let p=String(z.link||"").trim();if(p&&!p.startsWith("http")&&kt(p)){d(!0);return}}catch(p){console.warn("revealCampaignFromLink error",p)}try{globalThis.open(z.link,"_blank")}catch{}}d(!0)};return(0,Z.jsx)("div",{style:{position:"fixed",right:`${w.margin?.right||20}px`,bottom:`${w.margin?.bottom||20}px`,zIndex:999999,pointerEvents:"none"},children:(0,Z.jsxs)("div",{style:{position:"relative",width:"min(450px, calc(100vw - 32px))",maxHeight:"85vh",overflow:"visible",backgroundColor:w.backgroundColor||"#2f6ef5",borderRadius:`${w.borderRadius??12}px`,boxSizing:"border-box",paddingTop:"8px",paddingRight:qe(w.padding?.right)||"12px",paddingBottom:"4px",paddingLeft:qe(w.padding?.left)||"12px",pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[(0,Z.jsx)("style",{children:`
128
+ `}),(0,ye.jsx)("div",{ref:A=>{S.current=A,j(A)},className:"widget-scroll-container",style:w,onScroll:v,children:g?u.map((A,T)=>(0,ye.jsx)("div",{style:_(T),children:(0,ye.jsx)("img",{src:A.image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block",cursor:(A.link||"").trim()?"pointer":"default"},onClick:()=>L(A.id,A.link)})},A.id)):u.length>0&&(0,ye.jsx)("div",{style:_(0),children:(0,ye.jsx)("img",{src:u[c].image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block",cursor:(u[c].link||"").trim()?"pointer":"default"},onClick:()=>L(u[c].id,u[c].link)})},`slide-${c}`)}),h==="full"&&u.length>1&&(0,ye.jsx)("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"8px",width:"100%"},children:u.map((A,T)=>(0,ye.jsx)("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:T===c?"#333":"#ccc",transition:"background-color 0.2s ease"}},T))})]}),U=null;if(l?.position){let A=String(l.position||"").replace(/^widget_/,"");U=rn(A),U?console.log("[Widget] Portal target found for campaign",l?.id):console.log("[Widget] No portal target found for position:",l?.position,"rendering inline for campaign:",l?.id)}return U?(0,xr.createPortal)(N,U):N};var Rt=require("react");bt();var _t=require("react/jsx-runtime"),Yn=t=>(t||"").trim().toLowerCase(),Ws=t=>{if(t==null)return"8px 8px 8px 8px";if(typeof t=="number")return`${t}px`;if(typeof t=="object"){let e=t.top??8,o=t.right??8,n=t.bottom??8,i=t.left??8;return`${e}px ${o}px ${n}px ${i}px`}return String(t)},$s=(t,e)=>{if(typeof t=="number")return`${t}px`;if(typeof e=="number")return`${e}px`;if(typeof t=="object"&&t!==null){let o=t.topLeft??12,n=t.topRight??12,i=t.bottomRight??12,s=t.bottomLeft??12;return`${o}px ${n}px ${i}px ${s}px`}return"12px"},Ns=()=>{let t=Mt("TTP"),e=P(X=>X.campaigns),o=P(X=>X.allCampaigns),n=P(X=>X.currentScreen),i=P(X=>X.isVisible),[s,l]=(0,Rt.useState)(0),[c,d]=(0,Rt.useState)(!1),[S,p]=(0,Rt.useState)(null),[y,u]=(0,Rt.useState)(null),[C,h]=(0,Rt.useState)({width:0,height:0}),[g,b]=(0,Rt.useState)(!1),m=(0,Rt.useRef)(null),E=(0,Rt.useRef)(null),j=(0,Rt.useRef)(null),D=(0,Rt.useCallback)(X=>{if(X)try{document.body.style.overflow="",document.documentElement.style.overflow="",X.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}catch{try{X.scrollIntoView()}catch{}}},[]),L=(0,Rt.useMemo)(()=>{if(t)return t;let X=Yn(n),gt=Bt=>Bt.find(te=>{let pt=te,Ce=pt.campaign_type==="TTP"||pt.campaign_type==="TLTP",oo=!Yn(pt.screen)||Yn(pt.screen)===X,qe=!!(pt.trigger_event??pt.trigger),qt=pt.display_trigger!==!1&&!qe;return Ce&&oo&&qt});return gt(e)??gt(o)},[t,e,o,n]);(0,Rt.useEffect)(()=>{b(!1)},[s,L?.id]);let v=(0,Rt.useMemo)(()=>L?.details?.tooltips&&Array.isArray(L.details.tooltips)?[...L.details.tooltips].sort((X,gt)=>(X.order??0)-(gt.order??0)):L?.details?.target||L?.details?.titleText?[{...L.details,_id:L.id}]:[],[L]),w=v[s];(0,Rt.useEffect)(()=>{},[L]);let _=(0,Rt.useRef)(new Set),N=(0,Rt.useCallback)(()=>{if(!(!L||!w||c||!i))try{let X=w._id||w.id||void 0,gt=String(L.id||"")+"::"+String(X||"");_.current.has(gt)||(_.current.add(gt),st("viewed",L.id,{tooltip_id:X}))}catch{}},[L,w,c,i]),U=Do(N);(0,Rt.useEffect)(()=>{if(!w||c)return;p(null),u(null);let X=null,gt=null,Bt=()=>{let Gt=typeof window<"u"?document.documentElement.clientWidth||window.innerWidth:1024,Xt=typeof window<"u"?document.documentElement.clientHeight||window.innerHeight:768;return new DOMRect(Gt/2-100,Xt/2-50,200,100)},te=Gt=>{if(!Gt||!(Gt instanceof HTMLElement))return!1;let Xt=Gt.getBoundingClientRect();if(Xt.width===0||Xt.height===0)return!1;try{let Et=window.getComputedStyle(Gt);if(Et.display==="none"||Et.visibility==="hidden"||Et.opacity==="0")return!1}catch{}return!0},pt=(Gt=!1)=>{let Xt=w.target||w.targetId||w.elementId;if(!Xt)return p(Bt()),u(null),null;let Et=rn(Xt);if(Et){if(u(Et),te(Et)){let F=Et.getBoundingClientRect();Gt?(D(Et),p(F),setTimeout(()=>{D(Et),p(Et.getBoundingClientRect())},50),setTimeout(()=>{p(Et.getBoundingClientRect())},150),setTimeout(()=>{p(Et.getBoundingClientRect())},350)):p(F)}else p(null);return Et}return u(null),p(null),null},Ce=()=>{b(!0)},oo=Gt=>{j.current?.disconnect(),j.current=null,!(!Gt||typeof ResizeObserver>"u")&&(j.current=new ResizeObserver(()=>{te(Gt)?p(Gt.getBoundingClientRect()):p(null)}),j.current.observe(Gt))},qe=(Gt=!1)=>{let Xt=pt(Gt);Xt&&Xt!==X&&(X&&X.removeEventListener("click",Ce),X=Xt,Xt.addEventListener("click",Ce),oo(Xt))};qe(!0),E.current=new MutationObserver(()=>{qe(!1)}),E.current.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let qt=()=>qe(!1);return window.addEventListener("resize",qt),window.addEventListener("scroll",qt,{passive:!0,capture:!0}),document.addEventListener("mouseenter",qt,!0),document.addEventListener("mouseover",qt,!0),document.addEventListener("mouseleave",qt,!0),document.addEventListener("click",qt,!0),()=>{gt&&clearTimeout(gt),X&&X.removeEventListener("click",Ce),E.current?.disconnect(),j.current?.disconnect(),window.removeEventListener("resize",qt),window.removeEventListener("scroll",qt,{capture:!0}),document.removeEventListener("mouseenter",qt,!0),document.removeEventListener("mouseover",qt,!0),document.removeEventListener("mouseleave",qt,!0),document.removeEventListener("click",qt,!0)}},[w,c,s,D]),(0,Rt.useEffect)(()=>{if(!w||c||!S)return;let X=w?.enableBackdrop??w?.enable_backdrop??L?.details?.enableBackdrop??L?.details?.enable_backdrop;if(!(X!==!1&&X!=="false"&&X!==0))return;let Bt=te=>{let pt=te.target;pt&&(m.current&&m.current.contains(pt)||y&&(y===pt||y.contains(pt))||(b(!0),s<v.length-1?l(Ce=>Ce+1):d(!0)))};return window.addEventListener("click",Bt,!0),()=>{window.removeEventListener("click",Bt,!0)}},[w,c,S,y,s,v.length,L]),(0,Rt.useEffect)(()=>{if(!y||!(y instanceof HTMLElement)||c)return;let X=y,gt=()=>{b(!0)};return X.addEventListener("click",gt),()=>{X.removeEventListener("click",gt)}},[y,s,c]),(0,Rt.useLayoutEffect)(()=>{if(m.current&&S){let{width:X,height:gt}=m.current.getBoundingClientRect();h({width:X,height:gt})}},[w,S]);let A=(0,Rt.useMemo)(()=>{let X=w?.styling?.appearance?.highlight?.radius;if(X!=null)return`${X}px`;if(y&&typeof window<"u")try{let gt=window.getComputedStyle(y);if(gt.borderRadius&&gt.borderRadius!=="0px")return gt.borderRadius}catch{}return"6px"},[w?.styling?.appearance?.highlight?.radius,y]);if(!L||!w||c||!i||!S)return null;let T=w.styling||{},k=T.appearance||{},B=k.colors||{},$=T.cta||{},V=$.container||{},G=$.cornerRadius||{},r=$.text||{},M=!!(k.imageDimensions?.width&&k.imageDimensions?.height),a,f;if(M){let X=k.imageDimensions.width,gt=k.imageDimensions.height,Bt=typeof window<"u"?window.innerWidth*.9:X;a=Math.min(X,Bt),f=a===X?gt:Math.round(gt*(a/X))}let x=w.arrowPosition;!x&&w.position&&(w.position==="left"?x="right":w.position==="right"?x="left":w.position==="top"?x="bottom":w.position==="bottom"&&(x="top")),x||(x="left");let Y=(k.arrowStyle||{width:6,height:12}).width||6,ot=S.top,J=S.left,H=8,K=8,it=typeof window<"u"?document.documentElement.clientWidth||window.innerWidth:1024,xt=typeof window<"u"?document.documentElement.clientHeight||window.innerHeight:768,ut=C.width||M&&a||250,Z=C.height||(M?f||150:100),rt=S.top,dt=xt-(S.top+S.height),ht=S.left,mt=it-(S.left+S.width),R=ut+H+K,I=Z+H+K;x?x==="left"&&mt<R?ht>=R?x="right":rt>=I||rt>=dt?x="bottom":x="top":x==="right"&&ht<R?mt>=R?x="left":rt>=I||rt>=dt?x="bottom":x="top":x==="top"&&dt<I?rt>=I?x="bottom":mt>=R||mt>=ht?x="left":x="right":x==="bottom"&&rt<I&&(dt>=I?x="top":mt>=R||mt>=ht?x="left":x="right"):mt>=R?x="left":ht>=R?x="right":rt>=I?x="bottom":x="top";let O=0,tt=0;x==="left"?(O=J+S.width+H,tt=ot+S.height/2-Z/2):x==="right"?(O=J-ut-H,tt=ot+S.height/2-Z/2):x==="top"?(tt=ot+S.height+H,O=J+S.width/2-ut/2):x==="bottom"&&(tt=ot-Z-H,O=J+S.width/2-ut/2);let St=Math.min(ut,Math.max(120,it-K*2)),zt=Math.min(Z,Math.max(80,xt-K*2)),Tt=K,Yt=Math.max(Tt,it-St-K),Lt=K,Zt=Math.max(Lt,xt-zt-K),It=Math.max(Tt,Math.min(Yt,O)),ce=Math.max(Lt,Math.min(Zt,tt)),xe=w?.enableBackdrop??w?.enable_backdrop??L?.details?.enableBackdrop??L?.details?.enable_backdrop,Ie=xe!==!1&&xe!=="false"&&xe!==0,wo=k.backdropOpacity!==void 0?k.backdropOpacity>1?k.backdropOpacity/100:k.backdropOpacity:.7,ko=((X,gt)=>{if(!X||X==="transparent")return"transparent";if(X.startsWith("rgba"))return X;if(X.startsWith("rgb"))return X.replace("rgb","rgba").replace(")",`, ${gt})`);if(X.startsWith("#")){let Bt=X.slice(1);if(Bt.length===3&&(Bt=Bt.split("").map(te=>te+te).join("")),Bt.length===6){let te=parseInt(Bt.slice(0,2),16),pt=parseInt(Bt.slice(2,4),16),Ce=parseInt(Bt.slice(4,6),16);return`rgba(${te}, ${pt}, ${Ce}, ${gt})`}}return X})(B.backdrop||"#000000",wo),ie=()=>{b(!0);let X=w.link;try{let gt=w._id||w.id||void 0;L?.id&&st("clicked",L.id,{tooltip_id:gt})}catch{}s<v.length-1?(l(gt=>gt+1),X&&window.open(X,"_blank")):(d(!0),X&&window.open(X,"_blank"))},Se=()=>{b(!0),Ie&&(s<v.length-1?l(X=>X+1):d(!0))},Be=w?.styling?.appearance?.highlight?.radius??w?.styling?.appearance?.radius,Le=0;if(typeof Be=="number"&&Be>0)Le=Be;else if(typeof Be=="string"&&Be!=="")Le=parseInt(Be,10)||0;else if(y&&typeof window<"u")try{let X=y,gt=window.getComputedStyle(X);if(gt.borderRadius&&gt.borderRadius!=="0px")Le=parseFloat(gt.borderRadius)||0;else if(X.firstElementChild){let Bt=window.getComputedStyle(X.firstElementChild);Bt.borderRadius&&Bt.borderRadius!=="0px"&&(Le=parseFloat(Bt.borderRadius)||0)}}catch{}return(0,_t.jsxs)("div",{style:{position:"relative",zIndex:99999},children:[Ie&&S&&(0,_t.jsxs)("svg",{style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",pointerEvents:"none",zIndex:1e4},children:[(0,_t.jsx)("defs",{children:(0,_t.jsxs)("mask",{id:"as-spotlight-mask",children:[(0,_t.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:"white"}),(0,_t.jsx)("rect",{x:S.left,y:S.top,width:S.width,height:S.height,rx:Le,ry:Le,fill:"black"})]})}),(0,_t.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:ko,mask:"url(#as-spotlight-mask)",style:{pointerEvents:"none",cursor:"default"}})]}),Ie&&!S&&(0,_t.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:ko,zIndex:1e4},onClick:Se}),(0,_t.jsxs)("div",{ref:X=>{m.current=X,U(X)},style:{position:"fixed",top:ce,left:It,zIndex:99999,backgroundColor:B.tooltip||"#FE6B35",padding:M?0:Ws(k.padding),borderRadius:$s(k.cornerRadius,k.radius),boxShadow:"0 4px 12px rgba(0,0,0,0.15)",width:M?a:k.width?Math.min(k.width,it-K*2):"auto",height:M?f:void 0,maxWidth:Math.max(160,it-K*2),minWidth:M?void 0:Math.min(200,it-K*2),boxSizing:"border-box",transition:"top 0.2s ease, left 0.2s ease",cursor:"default"},children:[(0,_t.jsx)("div",{style:{position:"absolute",width:0,height:0,borderStyle:"solid",...x==="left"&&{left:-H,top:Math.max(12,Math.min(C.height-Y*2-12,ot+S.height/2-ce-Y)),borderWidth:`${Y}px ${H}px ${Y}px 0`,borderColor:`transparent ${B.arrow||B.tooltip||"#FE6B35"} transparent transparent`},...x==="right"&&{right:-H,top:Math.max(12,Math.min(C.height-Y*2-12,ot+S.height/2-ce-Y)),borderWidth:`${Y}px 0 ${Y}px ${H}px`,borderColor:`transparent transparent transparent ${B.arrow||B.tooltip||"#FE6B35"}`},...x==="top"&&{top:-H,left:Math.max(12,Math.min(C.width-Y*2-12,J+S.width/2-It-Y)),borderWidth:`0 ${Y}px ${H}px ${Y}px`,borderColor:`transparent transparent ${B.arrow||B.tooltip||"#FE6B35"} transparent`},...x==="bottom"&&{bottom:-H,left:Math.max(12,Math.min(C.width-Y*2-12,J+S.width/2-It-Y)),borderWidth:`${H}px ${Y}px 0 ${Y}px`,borderColor:`${B.arrow||B.tooltip||"#FE6B35"} transparent transparent transparent`}}}),w.url&&(M?(0,_t.jsx)("div",{onClick:ie,style:{width:"100%",height:"100%",overflow:"hidden",borderRadius:`${k.cornerRadius?.topLeft??12}px ${k.cornerRadius?.topRight??12}px ${k.cornerRadius?.bottomRight??12}px ${k.cornerRadius?.bottomLeft??12}px`,cursor:"pointer"},children:(0,_t.jsx)("img",{src:w.url,alt:"tooltip media",style:{width:"100%",height:"100%",display:"block",objectFit:"cover",cursor:"pointer"}})}):(0,_t.jsx)("img",{src:w.url,alt:"tooltip media",onClick:ie,style:{width:"100%",borderRadius:6,marginBottom:8,display:"block",objectFit:"cover",cursor:"pointer"}})),(w.titleText||w.subtitleText||w.ctaText)&&(0,_t.jsxs)("div",{style:M?{padding:`${k.padding?.top??8}px ${k.padding?.right??8}px ${k.padding?.bottom??8}px ${k.padding?.left??8}px`}:void 0,children:[w.titleText&&(0,_t.jsx)("div",{style:{color:T.title?.color||"#ffffff",fontFamily:lt(T.title?.fontFamily)||"Arial",fontSize:T.title?.fontSize||14,textAlign:T.title?.textAlign||"center",marginBottom:T.title?.margin?.bottom??4,marginTop:T.title?.margin?.top??0,marginLeft:T.title?.margin?.left??0,marginRight:T.title?.margin?.right??0,fontWeight:T.title?.fontDecoration?.includes("bold")?"bold":600,fontStyle:T.title?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:T.title?.fontDecoration?.includes("underline")?"underline":"none"},children:w.titleText}),w.subtitleText&&(0,_t.jsx)("div",{style:{color:T.subTitle?.color||"#ffffff",fontFamily:lt(T.subTitle?.fontFamily)||"Arial",fontSize:T.subTitle?.fontSize||12,textAlign:T.subTitle?.textAlign||"center",marginBottom:T.subTitle?.margin?.bottom??8,marginTop:T.subTitle?.margin?.top??0,marginLeft:T.subTitle?.margin?.left??0,marginRight:T.subTitle?.margin?.right??0,fontWeight:T.subTitle?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:T.subTitle?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:T.subTitle?.fontDecoration?.includes("underline")?"underline":"none"},children:w.subtitleText}),w.ctaText&&(0,_t.jsx)("div",{style:{display:"flex",justifyContent:V.alignment==="right"?"flex-end":V.alignment==="left"?"flex-start":"center",marginTop:8},children:(0,_t.jsx)("button",{onClick:ie,style:{width:V.ctaFullWidth?"100%":V.ctaWidth||"auto",height:V.height||35,background:V.backgroundColor||"#F7921C",color:r.color||"#ffffff",border:`${V.borderWidth||0}px solid ${V.borderColor||"transparent"}`,borderRadius:`${G.topLeft??7}px ${G.topRight??7}px ${G.bottomRight??7}px ${G.bottomLeft??7}px`,fontSize:r.fontSize||14,fontFamily:lt(r.fontFamily)||"Arial",fontWeight:r.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:r.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:r.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:w.ctaText})})]})]})]})},Cr=Ns;var fo=require("react");bt();var Ut=require("react/jsx-runtime"),vr=()=>{let t=Mt("BTS"),e=P(g=>g.campaigns),o=P(g=>g.allCampaigns),n=P(g=>g.currentScreen),i=t??(()=>{let g=(n||"").trim().toLowerCase(),b=[...e||[],...o||[]].find(m=>{if(!m||m.campaign_type!=="BTS")return!1;let E=!!(m.trigger_event??m.trigger);if(!(m.display_trigger!==!1&&!E))return!1;let D=(m.screen||"").trim().toLowerCase();return!D||D===g});if(b)try{return Ht(b)}catch{return b}})(),s=P(g=>g.isVisible),[l,c]=(0,fo.useState)(!1),d=(0,fo.useRef)(null);(0,fo.useEffect)(()=>{i?.id&&d.current!==i.id&&(d.current=i.id,c(!1),st("viewed",i.id))},[i?.id]);let S=g=>{try{let b=P.getState(),E=(b.trackedEvents||[]).filter(j=>j!==g);b.setTrackedEvents(E)}catch{}};if(!i||l||!s)return null;let{details:p}=i,u=[...p.elements||[]].sort((g,b)=>(g.order||0)-(b.order||0)),C=p.backdropOpacity??.5;C>1&&(C=C/100);let h=g=>{switch(g.type){case"image":{let b={width:"100%",display:"block",objectFit:"contain",backgroundColor:g.imageBackgroundColor||"transparent",paddingBottom:g.paddingBottom??0,paddingLeft:g.paddingLeft??0,paddingRight:g.paddingRight??0,paddingTop:g.paddingTop??0,cursor:g.imageLink?"pointer":"default"};return(0,Ut.jsx)("div",{style:{textAlign:g.alignment||"left",width:"100%"},children:g.url&&(0,Ut.jsx)("img",{src:g.url,alt:"",style:b,onClick:()=>{if(g.imageLink){i?.id&&st("clicked",i.id);try{let m=String(g.imageLink||"").trim();if(m&&!m.startsWith("http")&&Nt(m))return}catch(m){console.warn("revealCampaignFromLink error",m)}try{window.open(g.imageLink,"_blank")}catch{}}}})},g.id)}case"cta":{let b=g.cta||{},m=b.container||{},E=b.cornerRadius||{},j=b.margin||{},D=b.text||{};return(0,Ut.jsx)("div",{style:{display:"flex",justifyContent:m.alignment==="center"?"center":m.alignment==="right"?"flex-end":"flex-start",width:"100%",marginTop:j.top??0,marginBottom:j.bottom??0,marginLeft:j.left??0,marginRight:j.right??0},children:(0,Ut.jsx)("button",{style:{width:m.ctaFullWidth?"100%":m.ctaWidth||"auto",height:m.height||45,backgroundColor:m.ctaBoxColor||m.backgroundColor||"#FE6B35",color:D.color||"#ffffff",border:`${m.borderWidth||0}px solid ${m.borderColor||"transparent"}`,borderRadius:`${E.topLeft??12}px ${E.topRight??12}px ${E.bottomRight??12}px ${E.bottomLeft??12}px`,fontSize:D.fontSize||14,fontFamily:lt(D.fontFamily)||"Arial",fontWeight:D.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:D.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:D.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px"},onClick:()=>{let L=g.ctaLink||g.url;if(L){i?.id&&st("clicked",i.id);try{let v=String(L||"").trim();if(v&&!v.startsWith("http")&&Nt(v))return}catch(v){console.warn("revealCampaignFromLink error",v)}try{window.open(L,"_blank")}catch{}}},children:g.ctaText||"Button"})},g.id)}case"body":{let b=g.titleFontStyle||{},m=g.descriptionFontStyle||{};return(0,Ut.jsxs)("div",{style:{width:"100%",backgroundColor:g.bodyBackgroundColor||"transparent",marginTop:g.marginTop??0,marginBottom:g.marginBottom??20,marginLeft:g.marginLeft??4,marginRight:g.marginRight??4},children:[g.titleText&&(0,Ut.jsx)("div",{style:{color:b.colour||"#000000",fontSize:b.fontSize?`${b.fontSize}px`:g.titleFontSize?`${g.titleFontSize}px`:"16px",fontFamily:lt(b.fontFamily)||"inherit",textAlign:b.alignment||"left",lineHeight:g.titleLineHeight||1.2,fontWeight:b.decoration?.includes("bold")?"bold":"600",fontStyle:b.decoration?.includes("italic")?"italic":"normal",textDecoration:b.decoration?.includes("underline")?"underline":"none",marginBottom:g.spacingBetweenTitleDesc??4},children:g.titleText}),g.descriptionText&&(0,Ut.jsx)("div",{style:{color:m.colour||"#000000",fontSize:m.fontSize?`${m.fontSize}px`:g.descriptionFontSize?`${g.descriptionFontSize}px`:"14px",fontFamily:lt(m.fontFamily)||"inherit",textAlign:m.alignment||"left",lineHeight:g.descriptionLineHeight||1.5,fontWeight:m.decoration?.includes("bold")?"bold":"normal",fontStyle:m.decoration?.includes("italic")?"italic":"normal",textDecoration:m.decoration?.includes("underline")?"underline":"none"},children:g.descriptionText})]},g.id)}default:return null}};return(0,Ut.jsxs)(Ut.Fragment,{children:[(0,Ut.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:p.backdropColor||"rgba(0,0,0,0.5)",opacity:C,zIndex:999998,transition:"opacity 0.3s ease"},onClick:()=>{i?.id&&S(`viaAppStorys${i.id}`),c(!0)}}),(0,Ut.jsxs)("div",{style:{position:"fixed",bottom:0,left:"50%",transform:"translateX(-50%)",width:"100%",maxWidth:"500px",backgroundColor:p.backgroundColor||"#FFFFFF",borderTopLeftRadius:`${p.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${p.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:`${p.cornerRadius?.bottomLeft??0}px`,borderBottomRightRadius:`${p.cornerRadius?.bottomRight??0}px`,zIndex:999999,padding:"24px 16px",boxShadow:"0 -4px 16px rgba(0,0,0,0.15)",maxHeight:"85vh",overflowY:"auto",display:"flex",flexDirection:"column",alignItems:"center",transition:"transform 0.3s ease-out"},children:[(0,Ut.jsx)("div",{style:{width:"40px",height:"5px",backgroundColor:"#E0E0E0",borderRadius:"2.5px",marginBottom:"16px",cursor:"pointer"},onClick:()=>c(!0)}),p.crossButton?.enabled&&(0,Ut.jsx)(Ot,{config:p.crossButton,onPress:()=>{i?.id&&S(`viaAppStorys${i.id}`),c(!0)},style:{top:p.crossButton?.margin?.top??12,right:p.crossButton?.margin?.right??12}}),(0,Ut.jsx)("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:"12px"},children:u.map(h)})]})]})};var Wt=require("react");bt();var ho=ge(require("lottie-react")),ct=require("react/jsx-runtime"),Os=ho.default?.default??ho.default??ho.Lottie??ho,wr=5,Gn=3;function sn(t){if(t!=null)return`${t}px`}function oe(t,e="0px"){return t==null?e:`${t}px`}function yo(t){return{marginTop:sn(t?.top),marginRight:sn(t?.right),marginBottom:sn(t?.bottom),marginLeft:sn(t?.left)}}function Jn(t){return lt(t)}function mo(t){if(!t)return{};let e={};t.color&&(e.color=t.color),t.fontSize&&(e.fontSize=t.fontSize);let o=Jn(t.fontFamily);return o&&(e.fontFamily=o),t.textAlign&&(e.textAlign=t.textAlign),t.fontDecoration?.includes("bold")&&(e.fontWeight="bold"),t.fontDecoration?.includes("italic")&&(e.fontStyle="italic"),t.fontDecoration?.includes("underline")&&(e.textDecoration="underline"),e}function an(t){return`${t?.topLeft??8}px ${t?.topRight??8}px ${t?.bottomRight??8}px ${t?.bottomLeft??8}px`}function Qn(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function js(t){let e=t.styling?.rating?.ratingType;return e==="number"||e==="emoji"||e==="star"?e:"star"}function qs(t){let e=t.styling?.rating?.emoji,o=[];Array.isArray(e)?o=e:e&&typeof e=="object"?Array.isArray(e.values)?o=e.values:o=Object.values(e):typeof e=="string"&&e.trim()&&(o=e.split(","));let n=o.map(i=>{if(typeof i=="string")return i.trim();if(i&&typeof i=="object"){let s=i.emoji||i.value||i.text||i.icon||i.name||"";if(typeof s=="string")return s.trim()}return""}).filter(Boolean);return n.length>0?n:["\u{1F620}","\u{1F615}","\u{1F610}","\u{1F642}","\u{1F60D}"]}function Hs(t){return Array.from({length:5},(e,o)=>o+1)}function Xn(t){if(typeof t=="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t=="string"&&t.trim().length>0){let e=Number(t);if(Number.isFinite(e)&&e>=0)return e}}function Vs(t){let e=t.styling?.rating||void 0,o=[e?.numberSpacing,e?.numberGap,e?.number_spacing,e?.number_gap,e?.spacingBetweenNumbers,e?.spaceBetweenNumbers,e?.numberOptionsSpacing,e?.spacing];for(let i of o){let s=Xn(i);if(s!=null)return s}let n=e?.number;if(n&&typeof n=="object"){let i=n,s=[i.spacing,i.gap,i.optionsSpacing,i.numberSpacing,i.numberGap];for(let l of s){let c=Xn(l);if(c!=null)return c}}return 8}var Us=({fill:t,stroke:e})=>(0,ct.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":!0,children:(0,ct.jsx)("path",{d:"M12 2.25l2.91 5.89 6.5.95-4.7 4.58 1.11 6.46L12 17.03 6.18 20.13l1.11-6.46-4.7-4.58 6.5-.95L12 2.25z",fill:t,stroke:e,strokeWidth:"1.4",strokeLinejoin:"round"})}),Ys=({details:t,appearance:e,rating:o,selectedOptions:n,comments:i,isHighRating:s,feedbackOptions:l,onRate:c,onToggleOption:d,onCommentChange:S,onInlineSubmit:p,canSubmit:y,isMobile:u})=>{let C=t.styling||{},h=C.feedbackPage||{},g=C.rating||{},b=C.initialFeedback||{},m=h.submitButton?.cta,E=js(t),j=E==="number"?Hs(t):[],D=E==="emoji"?qs(t):[],L=E==="number"?Vs(t):8,v=E==="number"?L:g.spacing??8,w=u?"clamp(32px, 11vw, 44px)":"44px",_=u?"clamp(16px, 4.5vw, 22px)":22,N=Qn(g.alignment),U=an(g.cornerRadius),A=s?g.star?.high:g.star?.low,T=typeof g.number=="object"&&g.number?g.number:void 0,k=s?T?.high:T?.low,B=m?.container?.ctaFullWidth?"100%":Math.max(140,Xn(m?.container?.ctaWidth)??180);return(0,ct.jsxs)(ct.Fragment,{children:[(0,ct.jsx)("div",{style:yo(b.title?.margin),children:(0,ct.jsx)("div",{style:{...mo(b.title?.textStyle),color:b.title?.textStyle?.color||"#101828",fontSize:b.title?.textStyle?.fontSize||20,lineHeight:1.3,wordBreak:"break-word",overflowWrap:"break-word",paddingRight:C.crossButton?.enabled?(C.crossButton.size??30)+(C.crossButton.margin?.right??4)+4:0},children:t.title||"How was your experience?"})}),(0,ct.jsx)("div",{style:yo(b.subtitle?.margin),children:(0,ct.jsx)("div",{style:{...mo(b.subtitle?.textStyle),color:b.subtitle?.textStyle?.color||"#4b5563",fontSize:b.subtitle?.textStyle?.fontSize||14,lineHeight:1.4,wordBreak:"break-word",overflowWrap:"break-word"},children:t.description_text||"Your feedback helps us improve your experience."})}),(0,ct.jsxs)("div",{style:{marginTop:8,display:"flex",justifyContent:N,gap:v,flexWrap:"wrap"},children:[E==="star"&&Array.from({length:wr},($,V)=>{let G=V+1,r=G<=o,M=r?A?.stylingContainer:g.star?.unselected?.stylingContainer,a=r?A?.stylingStar:g.star?.unselected?.stylingStar;return(0,ct.jsx)("button",{onClick:()=>c(G),style:{border:`${M?.borderWidth??1}px solid ${M?.border||"#d1d5db"}`,background:M?.background||"#ffffff",borderRadius:U,width:w,height:w,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,flexShrink:0},"aria-label":`Rate ${G} out of ${wr}`,children:(0,ct.jsx)(Us,{fill:a?.background||(r?"#f59e0b":"#e5e7eb"),stroke:a?.border||(r?"#d97706":"#9ca3af")})},G)}),E==="number"&&j.map(($,V)=>{let G=$===o,r=G?k?.stylingContainer:T?.unselected?.stylingContainer,M=G?T?.stylingNumber:T?.unselected?.stylingNumber;return(0,ct.jsx)("button",{onClick:()=>c($),style:{border:`${r?.borderWidth??1}px solid ${r?.border||(G?"#1d4ed8":"#d1d5db")}`,background:r?.fill||r?.background||(G?"#dbeafe":"#ffffff"),color:M?.text||(G?"#1d4ed8":"#111827"),fontSize:M?.textSize||void 0,borderRadius:U,minWidth:w,height:w,padding:"0 10px",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontWeight:600,flexShrink:0},"aria-label":`Rate ${$}`,children:$},`${$}-${V}`)}),E==="emoji"&&D.map(($,V)=>{let G=V+1,r=G===o,M=g.emoji,f=(r?M?.selected:M?.unselected)?.stylingContainer;return(0,ct.jsx)("button",{onClick:()=>c(G),style:{border:`${f?.borderWidth??1}px solid ${f?.border||(r?"#1d4ed8":"#d1d5db")}`,background:f?.fill||f?.background||(r?"#dbeafe":"#ffffff"),borderRadius:U,width:w,height:w,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:_,flexShrink:0},"aria-label":`Emoji rating ${V+1}`,children:$},`${$}-${V}`)})]}),o>0&&(0,ct.jsx)("div",{style:{marginTop:6,textAlign:"center",color:"#374151",fontSize:14},children:s?t.highStarText||g.highRatingSubtitle:t.lowStarText||g.lowRatingSubtitle}),o>0&&o<=Gn&&(0,ct.jsxs)(ct.Fragment,{children:[l.length>0&&(0,ct.jsx)("div",{style:{...yo(h.options?.margin),display:"flex",flexDirection:"column",alignItems:"stretch",gap:h.options?.optionsSpacing??8,width:"100%"},children:l.map($=>{let G=n.includes($)?h.options?.selectedOptions:h.options?.nonSelectedOptions;return(0,ct.jsx)("button",{onClick:()=>d($),style:{border:`${G?.borderWidth??1}px solid ${G?.colors?.border||"#d1d5db"}`,background:G?.colors?.background||"#f9fafb",color:G?.colors?.text||"#111827",width:"100%",height:h.options?.optionsHeight||38,borderRadius:an(h.options?.cornerRadius),padding:"0 14px",cursor:"pointer",textAlign:"center",...mo(G?.textStyle)},children:$},$)})}),h.additionalComments?.enabled!==!1&&(0,ct.jsx)("textarea",{value:i,onChange:$=>S($.target.value),placeholder:h.additionalComments?.placeholder||"Tell us what we can improve",style:{width:"100%",boxSizing:"border-box",minHeight:56,height:56,maxHeight:64,marginTop:8,resize:"none",overflowY:"auto",border:`${h.additionalComments?.borderWidth??1}px solid ${h.additionalComments?.colors?.border||"#d1d5db"}`,background:h.additionalComments?.colors?.background||"#ffffff",color:h.additionalComments?.colors?.text||"#111827",borderRadius:8,padding:"12px",...mo(h.additionalComments?.textStyle)}}),(0,ct.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:m?.margin?.top??8,marginBottom:m?.margin?.bottom??0,marginLeft:m?.margin?.left??0,marginRight:m?.margin?.right??0,paddingTop:6,paddingBottom:6,background:e?.backgroundColor||"#ffffff",display:"flex",justifyContent:Qn(m?.container?.alignment)},children:(0,ct.jsx)("button",{onClick:()=>p(),disabled:!y,style:{width:B,maxWidth:"100%",height:Number(m?.container?.height)||40,border:`${m?.container?.borderWidth??0}px solid ${m?.container?.borderColor||"transparent"}`,background:m?.container?.backgroundColor||"#6848b1",color:m?.text?.color||"#ffffff",borderRadius:an(m?.cornerRadius),fontFamily:Jn(m?.text?.fontFamily),fontSize:Number(m?.text?.fontSize)||14,fontWeight:m?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:y?"pointer":"not-allowed",opacity:y?1:.65,padding:"0 12px",boxSizing:"border-box"},children:h.submitButton?.text||"Submit"})})]})]})},Gs=({details:t,isHighRating:e,onDone:o})=>{let n=t.styling||{},i=n.thankyouPage||{},s=n.rating||{},l=Qn(i.doneButton?.cta?.container?.alignment),[c,d]=(0,Wt.useState)(null),S=t.thankyouImage?.endsWith(".json");return(0,Wt.useEffect)(()=>{S&&t.thankyouImage&&fetch(t.thankyouImage).then(p=>p.json()).then(p=>d(p)).catch(p=>console.error("Error loading Lottie:",p))},[t.thankyouImage,S]),(0,ct.jsxs)(ct.Fragment,{children:[t.thankyouImage&&(0,ct.jsx)("div",{style:{display:"flex",justifyContent:"center",...yo(i.imageStyle?.margin)},children:S?c?(0,ct.jsx)(Os,{animationData:c,loop:!0,style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):(0,ct.jsx)("div",{style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):(0,ct.jsx)("img",{src:t.thankyouImage,alt:"thank you",style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80,objectFit:"cover",borderRadius:8}})}),(0,ct.jsx)("div",{style:yo(i.title?.margin),children:(0,ct.jsx)("div",{style:{color:"#111827",fontSize:20,lineHeight:1.3,...mo(i.title?.textStyle),wordBreak:"break-word",overflowWrap:"break-word"},children:t.thankyouText||(e?s.highRatingTitle:s.lowRatingTitle)||"Thank you for your feedback"})}),(0,ct.jsx)("div",{style:yo(i.subtitle?.margin),children:(0,ct.jsx)("div",{style:{color:"#4b5563",fontSize:14,lineHeight:1.4,...mo(i.subtitle?.textStyle),wordBreak:"break-word",overflowWrap:"break-word"},children:t.thankyouDescription||(e?s.highRatingSubtitle:s.lowRatingSubtitle)||"We appreciate your time."})}),(0,ct.jsx)("div",{style:{marginTop:i.doneButton?.cta?.margin?.top??14,marginBottom:i.doneButton?.cta?.margin?.bottom??0,marginLeft:i.doneButton?.cta?.margin?.left??0,marginRight:i.doneButton?.cta?.margin?.right??0,display:"flex",justifyContent:l},children:(0,ct.jsx)("button",{onClick:o,style:{width:i.doneButton?.cta?.container?.ctaFullWidth?"100%":i.doneButton?.cta?.container?.ctaWidth||"auto",height:i.doneButton?.cta?.container?.height||45,border:`${i.doneButton?.cta?.container?.borderWidth??0}px solid ${i.doneButton?.cta?.container?.borderColor||"transparent"}`,background:i.doneButton?.cta?.container?.backgroundColor||"#111827",color:i.doneButton?.cta?.text?.color||"#ffffff",borderRadius:an(i.doneButton?.cta?.cornerRadius),fontFamily:Jn(i.doneButton?.cta?.text?.fontFamily),fontSize:i.doneButton?.cta?.text?.fontSize||16,fontWeight:i.doneButton?.cta?.text?.fontDecoration?.includes("bold")?"bold":"normal",cursor:"pointer",padding:"0 16px",boxSizing:"border-box"},children:e?t.highStarText||i.doneButton?.text||"Rate Now":t.lowStarText||i.doneButton?.text||"Done"})})]})},Qs=()=>{let t=Mt("CSAT"),e=P(x=>x.isVisible),o=P(x=>x.campaigns),n=P(x=>x.allCampaigns),i=P(x=>x.currentScreen),[s,l]=(0,Wt.useState)(typeof window<"u"?window.innerWidth:1024);(0,Wt.useEffect)(()=>{if(typeof window>"u")return;let x=()=>l(window.innerWidth);return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);let c=s<768,d=t??(()=>{let x=(i||"").trim().toLowerCase(),z=[...o||[],...n||[]].find(Y=>{if(!Y||Y.campaign_type!=="CSAT")return!1;let ot=!!(Y.trigger_event??Y.trigger);if(!(Y.display_trigger!==!1&&!ot))return!1;let H=(Y.screen||"").trim().toLowerCase();return!H||H===x});if(z)try{return Ht(z)}catch{return z}})(),[S,p]=(0,Wt.useState)(!1),[y,u]=(0,Wt.useState)(!1),[C,h]=(0,Wt.useState)(!1),[g,b]=(0,Wt.useState)(!1),[m,E]=(0,Wt.useState)(0),[j,D]=(0,Wt.useState)([]),[L,v]=(0,Wt.useState)(""),[w,_]=(0,Wt.useState)(!1),N=(0,Wt.useRef)(null);(0,Wt.useEffect)(()=>{if(!d?.id||N.current===d.id)return;N.current=d.id,p(!1),u(!1),h(!1),b(!1),E(0),D([]),v(""),_(!1);let x=d.details?.styling?.appearance?.displayDelay??0,z=globalThis.setTimeout(()=>{u(!0),st("viewed",d.id)},Math.max(0,x)*1e3);return()=>globalThis.clearTimeout(z)},[d?.id]),(0,Wt.useEffect)(()=>{if(y){let x=setTimeout(()=>h(!0),30);return()=>clearTimeout(x)}},[y]);let U=(0,Wt.useMemo)(()=>{let x=d?.details?.feedback_option||{};return Object.keys(x).sort((z,Y)=>z.localeCompare(Y)).map(z=>typeof x[z]=="string"?x[z].trim():x[z]).filter(Boolean)},[d]);if(!d||!e||S||!y)return null;let A=d.details,T=A.styling||{},k=T.appearance||{},B=m>Gn,$=x=>{D(z=>z.includes(x)?z.filter(Y=>Y!==x):[...z,x])},V=async x=>{let z=x?.rating??m;if(z<1)return;_(!0);let Y=d.id,ot=(x?.options??j)[0]||"",J=x?.comments??L??"";st("csat captured",Y,{starCount:z,selectedOption:ot,additionalComments:J})},G=x=>{if(E(x),x>Gn){D([]),v("");let z=d?.id;setTimeout(()=>{_(!0);try{st("csat captured",z,{starCount:x,selectedOption:"",additionalComments:""})}catch(Y){console.warn("Error sending csat captured",Y)}},1e3)}},r=async()=>{b(!0);try{let x=d?.id;await st("csat closed",x)}catch(x){console.warn("Error sending csat closed",x)}finally{setTimeout(()=>{p(!0)},300)}},M=()=>{if(B&&A.link){let x=d&&d.id||void 0;try{x&&st("clicked",x)}catch{}try{let z=String(A.link||"").trim();if(z&&!z.startsWith("http")&&Nt(z)){b(!0),setTimeout(()=>{p(!0)},300);return}}catch(z){console.warn("revealCampaignFromLink error",z)}try{globalThis.open(A.link,"_blank")}catch{}}b(!0),setTimeout(()=>{p(!0)},300)},a=c?{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"center",alignItems:"flex-end",paddingLeft:oe(k.margin?.left,"0px"),paddingRight:oe(k.margin?.right,"0px"),pointerEvents:"none"}:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"flex-end",alignItems:"flex-end",paddingTop:oe(k.margin?.top),paddingRight:oe(k.margin?.right,"20px"),paddingBottom:oe(k.margin?.bottom,"20px"),paddingLeft:oe(k.margin?.left,"20px"),pointerEvents:"none"},f=c?{position:"relative",width:"100%",maxWidth:"none",maxHeight:"85vh",overflow:"visible",backgroundColor:k.backgroundColor||"#ffffff",borderTopLeftRadius:`${k.borderRadius??16}px`,borderTopRightRadius:`${k.borderRadius??16}px`,borderBottomLeftRadius:0,borderBottomRightRadius:0,boxSizing:"border-box",paddingTop:oe(k.padding?.top,"12px"),paddingRight:oe(k.padding?.right,"16px"),paddingBottom:`max(${oe(k.padding?.bottom,"16px")}, env(safe-area-inset-bottom, 16px))`,paddingLeft:oe(k.padding?.left,"16px"),pointerEvents:"auto",boxShadow:"0 -8px 32px rgba(0, 0, 0, 0.20)",display:"flex",flexDirection:"column",transform:g||!C?"translateY(100%)":"translateY(0)",transition:"transform 0.3s cubic-bezier(0.25, 1, 0.5, 1)"}:{position:"relative",width:"min(450px, 92vw)",maxHeight:"85vh",overflow:"visible",backgroundColor:k.backgroundColor||"#ffffff",borderRadius:`${k.borderRadius??12}px`,boxSizing:"border-box",paddingTop:oe(k.padding?.top,"8px"),paddingRight:oe(k.padding?.right,"12px"),paddingBottom:oe(k.padding?.bottom,"8px"),paddingLeft:oe(k.padding?.left,"12px"),pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column",transform:g||!C?"translateY(100%)":"translateY(0)",transition:"transform 0.3s cubic-bezier(0.25, 1, 0.5, 1)"};return(0,ct.jsx)("div",{style:a,children:(0,ct.jsxs)("div",{style:f,children:[(0,ct.jsx)("style",{children:`
124
129
  .appstorys-csat-scroll {
125
130
  scrollbar-width: none; /* Firefox */
126
131
  -ms-overflow-style: none; /* IE/Edge */
@@ -130,21 +135,31 @@
130
135
  height: 0;
131
136
  display: none; /* Chrome/Safari */
132
137
  }
133
- `}),E.crossButton?.enabled&&(0,Z.jsx)(At,{config:E.crossButton,onPress:()=>d(!0),style:{top:E.crossButton?.margin?.top??10,right:E.crossButton?.margin?.right??10}}),(0,Z.jsx)("div",{className:"appstorys-csat-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:4},children:m?(0,Z.jsx)(fs,{details:z,isHighRating:_,onDone:x}):(0,Z.jsx)(gs,{details:z,rating:b,selectedOptions:f,comments:S,isHighRating:_,feedbackOptions:I,onRate:a,onToggleOption:q,onCommentChange:u,onInlineSubmit:B,canSubmit:b>=1,appearance:w})})]})})},Ji=ms;var Tt=require("react");rt();var Qe=ae(require("lottie-react")),ot=require("react/jsx-runtime"),ys=Qe.default?.default??Qe.default??Qe.Lottie??Qe;function Mo(t){if(t!=null)return`${t}px`}function wn(t){return mt(t)}function Ye(t){return t?{color:t.color,fontSize:t.fontSize,fontFamily:wn(t.fontFamily),textAlign:t.textAlign,fontWeight:t.fontDecoration?.includes("bold")?"bold":void 0,fontStyle:t.fontDecoration?.includes("italic")?"italic":void 0,textDecoration:t.fontDecoration?.includes("underline")?"underline":void 0}:{}}function Ao(t){return{marginTop:Mo(t?.top),marginRight:Mo(t?.right),marginBottom:Mo(t?.bottom),marginLeft:Mo(t?.left)}}function lo(t){return`${t?.topLeft??12}px ${t?.topRight??12}px ${t?.bottomRight??t?.topRight??12}px ${t?.bottomLeft??t?.topLeft??12}px`}function tr(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function co(t){return Math.max(0,Math.min(1,t))}function hs(t,e){let o=(t||"").trim().replace("#","");if(o.length===3){let i=Number.parseInt(o[0]+o[0],16),n=Number.parseInt(o[1]+o[1],16),r=Number.parseInt(o[2]+o[2],16);return`rgba(${i}, ${n}, ${r}, ${co(e)})`}if(o.length===6){let i=Number.parseInt(o.slice(0,2),16),n=Number.parseInt(o.slice(2,4),16),r=Number.parseInt(o.slice(4,6),16);return`rgba(${i}, ${n}, ${r}, ${co(e)})`}return`rgba(0, 0, 0, ${co(e)})`}function bs(t){if(t==null)return .4;let e=Number(t);return Number.isFinite(e)?e>1?co(e/100):co(e):.4}function Ki(t){return[...t.slides||[]].sort((o,i)=>(o.order??0)-(i.order??0))}function xs(t,e){let o=t.trim();if(!o)return{action:"none"};let i=o.toLowerCase().replace(/[\s_-]+/g,"");if(i==="thankyou"||i==="thankyoupage")return{action:"thankyou"};let n=/^question\s+(\d+)$/i.exec(o);if(n){let c=parseInt(n[1],10)-1;return c>=0&&c<e.length?{action:"jump",targetIndex:c}:{action:"none"}}let r=e.findIndex(d=>d.id===o);if(r!==-1)return{action:"jump",targetIndex:r};let l=Number(o);if(Number.isFinite(l)&&l>0){let d=e.findIndex(c=>c.order===l);if(d!==-1)return{action:"jump",targetIndex:d}}return{action:"none"}}function Ss(t){let e=t?.options||{},o=Object.keys(e),i=n=>{let r=/(\d+)/.exec(n);if(!r)return;let l=Number(r[1]);return Number.isFinite(l)?l:void 0};return o.sort((n,r)=>{let l=i(n),d=i(r);return l!=null&&d!=null?l-d:l!=null?-1:d!=null?1:n.localeCompare(r)}),o.map(n=>e[n]).filter(n=>typeof n=="string"&&n.trim().length>0)}function Cs(t,e){if(!t)return null;if(t==="alphabet"){let o="a".codePointAt(0)??97;return String.fromCodePoint(o+e%26)+"."}return t==="number"?String(e+1)+".":t==="roman"?(["i","ii","iii","iv","v","vi","vii","viii","ix","x","xi","xii","xiii","xiv","xv"][e]||String(e+1))+".":null}function vs(t){if(typeof t=="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t=="string"&&t.trim().length>0){let e=Number(t);if(Number.isFinite(e)&&e>=0)return e}}function Zi(t){return vs(t?.borderwidth)??1}var ws=({details:t,slide:e,appearance:o,selectedOptions:i,comment:n,onSelectOption:r,onCommentChange:l,onSubmit:d,canSubmit:c})=>{let y=t.styling||{},b=y.options||{},h=y.cta,f=(0,Tt.useMemo)(()=>Ss(e),[e]),v=b.optionsSpacing??8,S=b.bulletSpacing??10,u=b.optionsHeight??44,m=tr(h?.container?.alignment);return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)("div",{style:Ao(y.title?.textStyle?.margin),children:(0,ot.jsx)("div",{style:{...Ye(y.title?.textStyle),color:y.title?.textStyle?.color||"#111827",fontSize:y.title?.textStyle?.fontSize||20,lineHeight:1.3,fontWeight:y.title?.textStyle?.fontDecoration?.includes("bold")?"bold":700},children:e.title||e.question||t.name||"Survey"})}),(e.subtitle||y.subtitle?.textStyle)&&(0,ot.jsx)("div",{style:Ao(y.subtitle?.textStyle?.margin),children:(0,ot.jsx)("div",{style:{...Ye(y.subtitle?.textStyle),color:y.subtitle?.textStyle?.color||"#6b7280",fontSize:y.subtitle?.textStyle?.fontSize||14,lineHeight:1.35},children:e.subtitle||""})}),f.length>0&&(()=>{let g="__others__",C=e.additionalComment?.placeholder?.trim()||"Others",I=f.map(E=>({value:E,label:E}));e.additionalComment?.enabled&&I.push({value:g,label:C});let z=i.includes(g);return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:v},children:I.map(({value:E,label:w},_)=>{let P=i.includes(E),$=P?b.selectedOptions:b.nonSelectedOptions,q=Zi($?.textStyle),B=Cs(b.optionListStyle,_),a=b.optionListStyle,x=a==="bulleted",s=a==="number"||a==="alphabet"||a==="roman";return(0,ot.jsxs)("button",{onClick:()=>r(E),style:{width:"100%",boxSizing:"border-box",height:u,borderRadius:lo(b.cornerRadius),border:`${q}px solid ${$?.colors?.border||"#e5e7eb"}`,background:$?.colors?.background||"#ffffff",color:$?.colors?.text||"#111827",cursor:"pointer",display:"flex",alignItems:"center",gap:S,paddingLeft:14,paddingRight:14,textAlign:"left",...Ye($?.textStyle)},"aria-pressed":P,children:[x?(0,ot.jsx)("span",{"aria-hidden":!0,style:{width:18,height:18,borderRadius:"50%",border:`2px solid ${$?.colors?.text||"#111827"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:P&&(0,ot.jsx)("span",{style:{width:10,height:10,borderRadius:"50%",backgroundColor:$?.colors?.text||"#111827"}})}):s?(0,ot.jsx)("span",{"aria-hidden":!0,style:{fontSize:16,fontWeight:600,color:$?.colors?.text||"#111827",marginRight:2},children:B}):null,(0,ot.jsx)("span",{style:{flex:1,minWidth:0},children:w})]},`${E}-${_}`)})}),z&&(0,ot.jsx)("textarea",{value:n,onChange:E=>l(E.target.value),placeholder:e.additionalComment?.placeholder||"Type your response...",style:{marginTop:10,width:"100%",boxSizing:"border-box",minHeight:72,resize:"none",overflowY:"auto",border:`${Zi(b.additionalComments?.textStyle)}px solid ${b.additionalComments?.colors?.border||"#e5e7eb"}`,background:b.additionalComments?.colors?.background||"#ffffff",color:b.additionalComments?.colors?.text||"#111827",borderRadius:lo(b.cornerRadius),padding:"12px",...Ye(b.additionalComments?.textStyle)}})]})})(),(0,ot.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:12,paddingTop:10,paddingBottom:6,background:o?.backgroundColor||"#ffffff"},children:(0,ot.jsx)("div",{style:{marginTop:h?.margin?.top??0,marginBottom:h?.margin?.bottom??0,marginLeft:h?.margin?.left??0,marginRight:h?.margin?.right??0,display:"flex",justifyContent:m},children:(0,ot.jsx)("button",{onClick:d,disabled:!c,style:{width:h?.container?.ctaFullWidth?"100%":h?.container?.ctaWidth??"100%",height:h?.container?.height??44,border:`${h?.container?.borderWidth??0}px solid ${h?.container?.borderColor||"transparent"}`,background:h?.container?.backgroundColor||"#111827",color:h?.text?.color||"#ffffff",borderRadius:lo(h?.cornerRadius),fontFamily:wn(h?.text?.fontFamily),fontSize:h?.text?.fontSize||14,fontWeight:h?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:c?"pointer":"not-allowed",opacity:c?1:.6,padding:"0 16px"},children:e.submitButtonText||"Submit"})})})]})},ks=({details:t,onDone:e})=>{let i=(t.styling||{}).thankyouPage||{},n=i.cta,r=tr(n?.container?.alignment),l=t.thankYouImage?.endsWith(".json"),[d,c]=(0,Tt.useState)(null);return(0,Tt.useEffect)(()=>{l&&t.thankYouImage?fetch(t.thankYouImage).then(y=>y.json()).then(y=>c(y)).catch(y=>console.error("AppStorys Survey: Error loading Thank You Lottie:",y)):c(null)},[t.thankYouImage,l]),(0,ot.jsxs)(ot.Fragment,{children:[t.thankYouImage&&(0,ot.jsx)("div",{style:{display:"flex",justifyContent:"center",marginTop:8},children:l?d?(0,ot.jsx)(ys,{animationData:d,loop:!0,style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):(0,ot.jsx)("div",{style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):(0,ot.jsx)("img",{src:t.thankYouImage,alt:"thank you",style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80,objectFit:"cover",borderRadius:10}})}),(0,ot.jsx)("div",{style:{...Ao(i.title?.textStyle?.margin)},children:(0,ot.jsx)("div",{style:{...Ye(i.title?.textStyle),color:i.title?.textStyle?.color||"#111827",fontSize:i.title?.textStyle?.fontSize||20,lineHeight:1.3,fontWeight:i.title?.textStyle?.fontDecoration?.includes("bold")?"bold":700},children:t.thankYouTitle||"Thank you"})}),(0,ot.jsx)("div",{style:{...Ao(i.subtitle?.textStyle?.margin)},children:(0,ot.jsx)("div",{style:{...Ye(i.subtitle?.textStyle),color:i.subtitle?.textStyle?.color||"#6b7280",fontSize:i.subtitle?.textStyle?.fontSize||14,lineHeight:1.35},children:t.thankYouText||""})}),(t.thankYouButtonText||n)&&(0,ot.jsx)("div",{style:{marginTop:n?.margin?.top??14,marginBottom:n?.margin?.bottom??0,marginLeft:n?.margin?.left??0,marginRight:n?.margin?.right??0,display:"flex",justifyContent:r},children:(0,ot.jsx)("button",{onClick:e,style:{width:n?.container?.ctaFullWidth?"100%":n?.container?.ctaWidth??"auto",height:n?.container?.height??40,border:`${n?.container?.borderWidth??0}px solid ${n?.container?.borderColor||"transparent"}`,background:n?.container?.backgroundColor||"#111827",color:n?.text?.color||"#ffffff",borderRadius:lo(n?.cornerRadius),fontFamily:wn(n?.text?.fontFamily),fontSize:n?.text?.fontSize||14,fontWeight:n?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:"pointer",padding:"0 16px"},children:t.thankYouButtonText||"Done"})})]})},Rs=()=>{let t=xt("SUR"),e=A(R=>R.isVisible),o=A(R=>R.campaigns),i=A(R=>R.allCampaigns),n=A(R=>R.currentScreen),r=t??(()=>{let R=(n||"").trim().toLowerCase(),W=[...o||[],...i||[]].find(H=>{if(!H||H.campaign_type!=="SUR")return!1;let U=!!(H.trigger_event??H.trigger);if(!(H.display_trigger!==!1&&!U))return!1;let V=(H.screen||"").trim().toLowerCase();return!V||V===R});if(W)try{return Ft(W)}catch{return W}})(),[l,d]=(0,Tt.useState)(!1),[c,y]=(0,Tt.useState)(!1),[b,h]=(0,Tt.useState)(0),[f,v]=(0,Tt.useState)([]),[S,u]=(0,Tt.useState)(""),[m,g]=(0,Tt.useState)({}),[C,I]=(0,Tt.useState)(!1),z=(0,Tt.useRef)(null);(0,Tt.useEffect)(()=>{if(!r?.id||z.current===r.id)return;z.current=r.id,d(!1),y(!1),h(0),v([]),u(""),g({}),I(!1);let R=r.details?.styling?.appearance?.displayDelay??0,W=globalThis.setTimeout(()=>{y(!0);let H=r.details?.id,U=Ki(r.details),j=U.length>0?U[0].id:void 0;X("viewed",r.id,{survey_id:H,slide_id:j})},Math.max(0,R)*1e3);return()=>globalThis.clearTimeout(W)},[r?.id]);let E=(0,Tt.useMemo)(()=>r?Ki(r.details):[],[r]),w=E[b];if((0,Tt.useEffect)(()=>{if(!w)return;let R=m[w.id];v(R?.options??[]),u(R?.comment??"")},[w?.id]),!r||!e||l||!c)return null;let _=r.details,P=_.styling||{},$=P.appearance||{},q=$.backdropColor||"#000000",B=bs($.backdropOpacity),a=w?.multipleSelection!==!1&&w?.isMultiSelect!==!1&&P.options?.multipleSelection!==!1,x=R=>{v(a?W=>W.includes(R)?W.filter(H=>H!==R):[...W,R]:W=>W[0]===R?[]:[R])},s=async(R,W)=>{let H=E.map(nt=>({slide_id:nt.id,order:nt.order,title:nt.title,question:nt.question,selected_options:R[nt.id]?.options,comment:R[nt.id]?.comment})),U=r.id,j=[];for(let nt of E){let lt=R[nt.id]?.options||[];for(let k of lt){let L=Object.entries(nt.options||{}).find(([,J])=>String(J)===String(k));L&&j.push(L[0])}}let V=H.map(nt=>nt.comment).filter(Boolean).join(" || ")||"",tt=_.id||U;X("survey captured",tt,{survey_id:_.id,slide_id:W,selected_options:j,otherText:V}),P.content?.isThankyouPage!==!1?I(!0):d(!0)},p=async()=>{if(!w||f.length===0)return;let R={...m,[w.id]:{options:f,comment:S}};g(R);let W=[];if(w.options)for(let V of f){let tt=Object.entries(w.options).find(([,at])=>String(at)===String(V));tt&&W.push(tt[0])}try{let V=r.id,tt=_.id||V;X("survey captured",tt,{survey_id:_.id,slide_id:w.id,selected_options:W,otherText:S||""})}catch(V){console.warn("Error sending per-slide survey captured",V)}let H=f.includes("__others__"),U={action:"none"};for(let V of w.logic||[]){let tt=V.selectOption||[];if(tt.length===0)continue;let at=tt.some(k=>W.includes(k)),nt=tt.some(k=>f.includes(k)),lt=H&&tt.some(k=>k==="others"||k==="__others__");if(!(!at&&!nt&&!lt)&&V.redirectTo){let k=xs(V.redirectTo,E);if(k.action!=="none"){U=k;break}}}if(U.action==="thankyou"){await s(R,w.id);return}if(U.action==="jump"){h(U.targetIndex);return}if(b>=E.length-1){await s(R,w.id);return}h(V=>Math.min(V+1,E.length-1))},M=()=>{let R=_.thankYouButtonConfig;if(R?.enabled&&R.redirectUrl){try{let W=String(R.redirectUrl||"").trim();if(W&&!W.startsWith("http")&&kt(W)){d(!0);return}}catch(W){console.warn("revealCampaignFromLink error",W)}try{globalThis.open(R.redirectUrl,"_blank")}catch{}}d(!0)},T=async()=>{try{let R=r?.id,W=_?.id,H=w?.id;await X("SurveyDismissed",R,{survey_id:W,slide_id:H})}catch(R){console.warn("Error sending SurveyDismissed",R)}finally{d(!0)}};return w?(0,ot.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"flex-end",alignItems:"flex-end",padding:12,pointerEvents:"none"},children:[(0,ot.jsx)("div",{"aria-hidden":!0,style:{position:"absolute",inset:0,background:hs(q,B)}}),(0,ot.jsxs)("div",{style:{position:"relative",width:"min(420px, 92vw)",maxWidth:"92vw",minWidth:"320px",maxHeight:"80vh",overflow:"hidden",backgroundColor:$.backgroundColor||"#ffffff",borderRadius:lo($.cornerRadius),boxSizing:"border-box",paddingTop:14,paddingRight:16,paddingBottom:10,paddingLeft:16,pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[(0,ot.jsx)("style",{children:`
138
+ `}),T.crossButton?.enabled&&(0,ct.jsx)(Ot,{config:T.crossButton,onPress:()=>{r()},style:{top:T.crossButton?.margin?.top??10,right:T.crossButton?.margin?.right??10}}),(0,ct.jsx)("div",{className:"appstorys-csat-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:4},children:w?(0,ct.jsx)(Gs,{details:A,isHighRating:B,onDone:M}):(0,ct.jsx)(Ys,{details:A,rating:m,selectedOptions:j,comments:L,isHighRating:B,feedbackOptions:U,onRate:G,onToggleOption:$,onCommentChange:v,onInlineSubmit:V,canSubmit:m>=1,appearance:k,isMobile:c})})]})})},kr=Qs;var wt=require("react");bt();var xo=ge(require("lottie-react")),at=require("react/jsx-runtime"),Xs=xo.default?.default??xo.default??xo.Lottie??xo;function ln(t){if(t!=null)return`${t}px`}function dn(t){return lt(t)}function bo(t){if(!t)return{};let e={};t.color&&(e.color=t.color),t.fontSize&&(e.fontSize=t.fontSize);let o=dn(t.fontFamily);return o&&(e.fontFamily=o),t.textAlign&&(e.textAlign=t.textAlign),t.fontDecoration?.includes("bold")&&(e.fontWeight="bold"),t.fontDecoration?.includes("italic")&&(e.fontStyle="italic"),t.fontDecoration?.includes("underline")&&(e.textDecoration="underline"),e}function _o(t){return{marginTop:ln(t?.top),marginRight:ln(t?.right),marginBottom:ln(t?.bottom),marginLeft:ln(t?.left)}}function Wo(t,e=0){if(!t)return`${e}px`;let o=t.topLeft!==void 0&&t.topLeft!==null?t.topLeft:e,n=t.topRight!==void 0&&t.topRight!==null?t.topRight:e,i=t.bottomRight!==void 0&&t.bottomRight!==null?t.bottomRight:e,s=t.bottomLeft!==void 0&&t.bottomLeft!==null?t.bottomLeft:e;return`${o}px ${n}px ${i}px ${s}px`}function Br(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function $o(t){return Math.max(0,Math.min(1,t))}function Rr(t,e){let o=(t||"").trim().replace("#","");if(o.length===3){let n=Number.parseInt(o[0]+o[0],16),i=Number.parseInt(o[1]+o[1],16),s=Number.parseInt(o[2]+o[2],16);return`rgba(${n}, ${i}, ${s}, ${$o(e)})`}if(o.length===6){let n=Number.parseInt(o.slice(0,2),16),i=Number.parseInt(o.slice(2,4),16),s=Number.parseInt(o.slice(4,6),16);return`rgba(${n}, ${i}, ${s}, ${$o(e)})`}return`rgba(0, 0, 0, ${$o(e)})`}function Js(t){if(t==null)return .4;let e=Number(t);return Number.isFinite(e)?e>1?$o(e/100):$o(e):.4}function Fr(t){return[...t.slides||[]].sort((o,n)=>(o.order??0)-(n.order??0))}function Ks(t,e){let o=t.trim();if(!o)return{action:"none"};let n=o.toLowerCase().replace(/[\s_-]+/g,"");if(n==="thankyou"||n==="thankyoupage")return{action:"thankyou"};let i=/^question\s+(\d+)$/i.exec(o);if(i){let d=parseInt(i[1],10)-1;return d>=0&&d<e.length?{action:"jump",targetIndex:d}:{action:"none"}}let s=e.findIndex(c=>c.id===o);if(s!==-1)return{action:"jump",targetIndex:s};let l=Number(o);if(Number.isFinite(l)&&l>0){let c=e.findIndex(d=>d.order===l);if(c!==-1)return{action:"jump",targetIndex:c}}return{action:"none"}}function Zs(t){let e=t?.options||{},o=Object.keys(e),n=i=>{let s=/(\d+)/.exec(i);if(!s)return;let l=Number(s[1]);return Number.isFinite(l)?l:void 0};return o.sort((i,s)=>{let l=n(i),c=n(s);return l!=null&&c!=null?l-c:l!=null?-1:c!=null?1:i.localeCompare(s)}),o.map(i=>e[i]).filter(i=>typeof i=="string"&&i.trim().length>0)}function ta(t,e){if(!t)return null;if(t==="alphabet"){let o="a".codePointAt(0)??97;return String.fromCodePoint(o+e%26)+"."}return t==="number"?String(e+1)+".":t==="roman"?(["i","ii","iii","iv","v","vi","vii","viii","ix","x","xi","xii","xiii","xiv","xv"][e]||String(e+1))+".":null}function ea(t){if(typeof t=="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t=="string"&&t.trim().length>0){let e=Number(t);if(Number.isFinite(e)&&e>=0)return e}}function Tr(t){return ea(t?.borderwidth)??1}var zr=({details:t,slide:e,appearance:o,selectedOptions:n,comment:i,onSelectOption:s,onCommentChange:l,onSubmit:c,canSubmit:d})=>{let S=t.styling||{},p=S.options||{},y=S.cta,u=(0,wt.useMemo)(()=>Zs(e),[e]),C=p.optionsSpacing??6,h=p.bulletSpacing??12,g=p.optionsHeight??48,b=Br(y?.container?.alignment),m=S.title?.textStyle,E=S.subtitle?.textStyle;return(0,at.jsxs)(at.Fragment,{children:[(0,at.jsx)("div",{style:{width:"100%",..._o(m?.margin)},children:(0,at.jsx)("div",{style:{...bo(m),color:m?.color||"#111827",fontSize:m?.fontSize||22,lineHeight:1.3,textAlign:m?.textAlign||"left",fontWeight:m?.fontDecoration?.includes("bold")?"bold":m?.fontDecoration?"normal":600,fontStyle:m?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:m?.fontDecoration?.includes("underline")?"underline":"none"},children:e.title||e.question||t.name||"Survey"})}),(e.subtitle||E)&&(0,at.jsx)("div",{style:{width:"100%",..._o(E?.margin)},children:(0,at.jsx)("div",{style:{...bo(E),color:E?.color||"#6b7280",fontSize:E?.fontSize||16,lineHeight:1.35,textAlign:E?.textAlign||"left",fontWeight:E?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:E?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:E?.fontDecoration?.includes("underline")?"underline":"none"},children:e.subtitle||""})}),u.length>0&&(()=>{let j="__others__",D=e.additionalComment?.placeholder?.trim()||"Others",L=u.map(w=>({value:w,label:w}));e.additionalComment?.enabled&&L.push({value:j,label:D});let v=n.includes(j);return(0,at.jsxs)(at.Fragment,{children:[(0,at.jsx)("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:C},children:L.map(({value:w,label:_},N)=>{let U=n.includes(w),A=U?p.selectedOptions:p.nonSelectedOptions,T=Tr(A?.textStyle),k=ta(p.optionListStyle,N),B=p.optionListStyle,$=B==="bulleted",V=B==="number"||B==="alphabet"||B==="roman",G=A?.colors?.text||A?.textStyle?.color||(U?"#ffffff":"#111827"),r=A?.colors?.background||(U?"#1f35db":"#ffffff"),M=A?.colors?.border||(U?"#1f35db":"#e5e7eb");return(0,at.jsxs)("button",{onClick:()=>s(w),style:{width:"100%",boxSizing:"border-box",minHeight:g,height:"auto",borderRadius:Wo(p.cornerRadius,7),border:`${T}px solid ${M}`,background:r,color:G,cursor:"pointer",display:"flex",alignItems:"center",gap:h,paddingTop:8,paddingBottom:8,paddingLeft:14,paddingRight:14,textAlign:A?.textStyle?.textAlign||"left",...bo(A?.textStyle)},"aria-pressed":U,children:[$?(0,at.jsx)("span",{"aria-hidden":!0,style:{width:18,height:18,borderRadius:"50%",border:`2px solid ${U?p.selectedOptions?.colors?.border||M:p.nonSelectedOptions?.colors?.border||M}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:U&&(0,at.jsx)("span",{style:{width:10,height:10,borderRadius:"50%",backgroundColor:G}})}):V?(0,at.jsx)("span",{"aria-hidden":!0,style:{fontSize:A?.textStyle?.fontSize?A.textStyle.fontSize*.85:16,fontWeight:A?.textStyle?.fontDecoration?.includes("bold")?"bold":600,fontFamily:dn(A?.textStyle?.fontFamily),color:G,marginRight:2,flexShrink:0},children:k}):null,(0,at.jsx)("span",{style:{flex:1,minWidth:0,wordBreak:"break-word",lineHeight:1.35,color:G},children:_})]},`${w}-${N}`)})}),v&&(0,at.jsx)("textarea",{value:i,onChange:w=>l(w.target.value),placeholder:e.additionalComment?.placeholder||"Type your response...",style:{marginTop:10,width:"100%",boxSizing:"border-box",minHeight:72,resize:"none",overflowY:"auto",border:`${Tr(p.additionalComments?.textStyle)}px solid ${p.additionalComments?.colors?.border||"#e5e7eb"}`,background:p.additionalComments?.colors?.background||"#ffffff",color:p.additionalComments?.colors?.text||"#111827",borderRadius:Wo(p.cornerRadius,7),padding:"12px",...bo(p.additionalComments?.textStyle)}})]})})(),(0,at.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:y?.margin?.top??12,marginBottom:y?.margin?.bottom??0,marginLeft:y?.margin?.left??0,marginRight:y?.margin?.right??0,paddingTop:10,paddingBottom:4,background:o?.backgroundColor||"#ffffff",display:"flex",justifyContent:b,width:"100%",boxSizing:"border-box"},children:(0,at.jsx)("button",{onClick:c,disabled:!d,style:{width:y?.container?.ctaFullWidth?"100%":y?.container?.ctaWidth?`${y.container.ctaWidth}px`:"140px",maxWidth:"100%",height:y?.container?.height??50,border:`${y?.container?.borderWidth??0}px solid ${y?.container?.borderColor||"transparent"}`,background:y?.container?.backgroundColor||"#1f35db",color:y?.text?.color||"#ffffff",borderRadius:Wo(y?.cornerRadius,7),fontFamily:dn(y?.text?.fontFamily)||"Arial",fontSize:y?.text?.fontSize||18,fontWeight:y?.text?.fontDecoration?.includes("bold")?"bold":600,fontStyle:y?.text?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:y?.text?.fontDecoration?.includes("underline")?"underline":"none",cursor:d?"pointer":"not-allowed",opacity:d?1:.6,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 20px",boxSizing:"border-box"},children:e.submitButtonText||"Submit"})})]})},Ir=({details:t,onDone:e})=>{let o=t.styling||{},n=o.thankyouPage||{},i=n.cta||o.cta,s=Br(i?.container?.alignment),l=t.thankYouImage?.endsWith(".json"),[c,d]=(0,wt.useState)(null);(0,wt.useEffect)(()=>{l&&t.thankYouImage?fetch(t.thankYouImage).then(u=>u.json()).then(u=>d(u)).catch(u=>console.error("AppStorys Survey: Error loading Thank You Lottie:",u)):d(null)},[t.thankYouImage,l]);let S=t.thankYouTitle||t?.thank_you_title||"Thank you",p=t.thankYouText||t?.thank_you_text||"",y=t.thankYouButtonText||t?.thank_you_button_text||"Done";return(0,at.jsxs)(at.Fragment,{children:[t.thankYouImage&&(0,at.jsx)("div",{style:{display:"flex",justifyContent:"center",..._o(n.imageStyle?.margin)},children:l?c?(0,at.jsx)(Xs,{animationData:c,loop:!0,style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):(0,at.jsx)("div",{style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):(0,at.jsx)("img",{src:t.thankYouImage,alt:"thank you",style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80,objectFit:"cover",borderRadius:10}})}),(0,at.jsx)("div",{style:{width:"100%",..._o(n.title?.textStyle?.margin)},children:(0,at.jsx)("div",{style:{...bo(n.title?.textStyle),color:n.title?.textStyle?.color||"#111827",fontSize:n.title?.textStyle?.fontSize||20,lineHeight:1.3,textAlign:n.title?.textStyle?.textAlign||"center",fontWeight:n.title?.textStyle?.fontDecoration?.includes("bold")?"bold":n.title?.textStyle?.fontDecoration?.length?"normal":700},children:S})}),p&&(0,at.jsx)("div",{style:{width:"100%",..._o(n.subtitle?.textStyle?.margin)},children:(0,at.jsx)("div",{style:{...bo(n.subtitle?.textStyle),color:n.subtitle?.textStyle?.color||"#6b7280",fontSize:n.subtitle?.textStyle?.fontSize||14,lineHeight:1.35,textAlign:n.subtitle?.textStyle?.textAlign||"center",fontWeight:n.subtitle?.textStyle?.fontDecoration?.includes("bold")?"bold":"normal"},children:p})}),(y||i)&&(0,at.jsx)("div",{style:{marginTop:i?.margin?.top??14,marginBottom:i?.margin?.bottom??0,marginLeft:i?.margin?.left??0,marginRight:i?.margin?.right??0,display:"flex",justifyContent:s,width:"100%",boxSizing:"border-box"},children:(0,at.jsx)("button",{onClick:e,style:{width:i?.container?.ctaFullWidth?"100%":i?.container?.ctaWidth?`${i.container.ctaWidth}px`:"auto",maxWidth:"100%",height:i?.container?.height??44,border:`${i?.container?.borderWidth??0}px solid ${i?.container?.borderColor||"transparent"}`,background:i?.container?.backgroundColor||"#1f35db",color:i?.text?.color||"#ffffff",borderRadius:Wo(i?.cornerRadius,12),fontFamily:dn(i?.text?.fontFamily)||"Arial",fontSize:i?.text?.fontSize||14,fontWeight:i?.text?.fontDecoration?.includes("bold")?"bold":600,fontStyle:i?.text?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:i?.text?.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 20px",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:y})})]})},oa=()=>{let t=Mt("SUR"),e=P(R=>R.isVisible),o=P(R=>R.campaigns),n=P(R=>R.allCampaigns),i=P(R=>R.currentScreen),[s,l]=(0,wt.useState)(typeof window<"u"?window.innerWidth:1024),[c,d]=(0,wt.useState)(0),[S,p]=(0,wt.useState)(!1),[y,u]=(0,wt.useState)(!1),[C,h]=(0,wt.useState)(!1),g=(0,wt.useRef)(0),b=(0,wt.useRef)(0),m=(0,wt.useRef)(null),E=(0,wt.useRef)(0),j=(0,wt.useRef)(!1);(0,wt.useEffect)(()=>{if(typeof window>"u")return;let R=()=>l(window.innerWidth);return window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[]);let D=s<768,L=t??(()=>{let R=(i||"").trim().toLowerCase(),I=[...o||[],...n||[]].find(O=>{if(!O||O.campaign_type!=="SUR")return!1;let tt=!!(O.trigger_event??O.trigger);if(!(O.display_trigger!==!1&&!tt))return!1;let zt=(O.screen||"").trim().toLowerCase();return!zt||zt===R});if(I)try{return Ht(I)}catch{return I}})(),[v,w]=(0,wt.useState)(!1),[_,N]=(0,wt.useState)(!1),[U,A]=(0,wt.useState)(0),[T,k]=(0,wt.useState)([]),[B,$]=(0,wt.useState)(""),[V,G]=(0,wt.useState)({}),[r,M]=(0,wt.useState)(!1),a=(0,wt.useRef)(null);(0,wt.useEffect)(()=>{if(!L?.id||a.current===L.id)return;a.current=L.id,w(!1),N(!1),A(0),k([]),$(""),G({}),M(!1),h(!1),u(!1),d(0);let R=L.details?.styling?.appearance?.displayDelay??0,I=globalThis.setTimeout(()=>{N(!0);let O=L.details?.id,tt=Fr(L.details),St=tt.length>0?tt[0].id:void 0;st("viewed",L.id,{survey_id:O,slide_id:St})},Math.max(0,R)*1e3);return()=>globalThis.clearTimeout(I)},[L?.id]),(0,wt.useEffect)(()=>{if(_){let R=setTimeout(()=>h(!0),30);return()=>clearTimeout(R)}},[_]);let f=(0,wt.useMemo)(()=>L?Fr(L.details):[],[L]),x=f[U];(0,wt.useEffect)(()=>{if(typeof window>"u"||!L||!e||v||!_)return;let R=window.scrollY||window.pageYOffset||0,I=document.body.style.position,O=document.body.style.top,tt=document.body.style.left,St=document.body.style.right,zt=document.body.style.width,Tt=document.body.style.overflow,Yt=document.documentElement.style.overflow;return document.body.style.position="fixed",document.body.style.top=`-${R}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%",document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",()=>{document.body.style.position=I,document.body.style.top=O,document.body.style.left=tt,document.body.style.right=St,document.body.style.width=zt,document.body.style.overflow=Tt,document.documentElement.style.overflow=Yt,window.scrollTo(0,R)}},[L,e,v,_]);let z=(R,I)=>{g.current=R,b.current=0,j.current=I,m.current?E.current=m.current.scrollTop:E.current=0,p(!0)},Y=R=>{if(!g.current)return;let I=R-g.current,O=m.current?m.current.scrollTop:0,tt=E.current<=0&&O<=0;(j.current||tt)&&I>0?(b.current=I,d(I)):(b.current=0,d(0))},ot=()=>{p(!1),j.current=!1,b.current>80?(u(!0),setTimeout(()=>{mt()},250)):(d(0),b.current=0),g.current=0};if((0,wt.useEffect)(()=>{if(!S)return;let R=St=>{Y(St.clientY)},I=()=>{ot()},O=St=>{St.cancelable&&St.preventDefault(),St.touches&&St.touches[0]&&Y(St.touches[0].clientY)},tt=()=>{ot()};return window.addEventListener("pointermove",R),window.addEventListener("pointerup",I),window.addEventListener("touchmove",O,{passive:!1}),window.addEventListener("touchend",tt),()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",I),window.removeEventListener("touchmove",O),window.removeEventListener("touchend",tt)}},[S]),!L||!e||v||!_)return null;let J=L.details,H=J.styling||{},K=H.appearance||{},it=K.backdropColor||"#000000",xt=Js(K.backdropOpacity),ut=x?.multipleSelection!==!1&&x?.isMultiSelect!==!1&&H.options?.multipleSelection!==!1,Z=R=>{k(ut?I=>I.includes(R)?I.filter(O=>O!==R):[...I,R]:I=>I[0]===R?[]:[R])},rt=async(R,I)=>{let O=f.map(Lt=>({slide_id:Lt.id,order:Lt.order,title:Lt.title,question:Lt.question,selected_options:R[Lt.id]?.options,comment:R[Lt.id]?.comment})),tt=L.id,St=[];for(let Lt of f){let Zt=R[Lt.id]?.options||[];for(let It of Zt){let ce=Object.entries(Lt.options||{}).find(([,xe])=>String(xe)===String(It));ce&&St.push(ce[0])}}let zt=O.map(Lt=>Lt.comment).filter(Boolean).join(" || ")||"",Tt=J.id||tt;st("survey captured",Tt,{survey_id:J.id,slide_id:I,selected_options:St,otherText:zt}),H.content?.isThankyouPage!==!1?M(!0):w(!0)},dt=async()=>{if(!x||T.length===0)return;let R={...V,[x.id]:{options:T,comment:B}};G(R);let I=[];if(x.options)for(let zt of T){let Tt=Object.entries(x.options).find(([,Yt])=>String(Yt)===String(zt));Tt&&I.push(Tt[0])}try{let zt=L.id,Tt=J.id||zt;st("survey captured",Tt,{survey_id:J.id,slide_id:x.id,selected_options:I,otherText:B||""})}catch(zt){console.warn("Error sending per-slide survey captured",zt)}let O=T.includes("__others__"),tt={action:"none"};for(let zt of x.logic||[]){let Tt=zt.selectOption||[];if(Tt.length===0)continue;let Yt=Tt.some(It=>I.includes(It)),Lt=Tt.some(It=>T.includes(It)),Zt=O&&Tt.some(It=>It==="others"||It==="__others__");if(!(!Yt&&!Lt&&!Zt)&&zt.redirectTo){let It=Ks(zt.redirectTo,f);if(It.action!=="none"){tt=It;break}}}if(tt.action==="thankyou"){await rt(R,x.id);return}if(tt.action==="jump"){A(tt.targetIndex);return}if(U>=f.length-1){await rt(R,x.id);return}A(zt=>Math.min(zt+1,f.length-1))},ht=()=>{let R=J.thankYouButtonConfig;if(R?.enabled&&R.redirectUrl){try{let I=String(R.redirectUrl||"").trim();if(I&&!I.startsWith("http")&&Nt(I)){w(!0);return}}catch(I){console.warn("revealCampaignFromLink error",I)}try{globalThis.open(R.redirectUrl,"_blank")}catch{}}w(!0)},mt=async()=>{try{let R=L?.id,I=J?.id,O=x?.id;await st("SurveyDismissed",R,{survey_id:I,slide_id:O})}catch(R){console.warn("Error sending SurveyDismissed",R)}finally{w(!0)}};return x?D?(0,at.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"center",alignItems:"flex-end",padding:0,boxSizing:"border-box",pointerEvents:"auto",touchAction:"none",overscrollBehavior:"none"},children:[(0,at.jsx)("div",{"aria-hidden":!0,onClick:()=>{u(!0),setTimeout(()=>mt(),250)},onTouchMove:R=>{R.cancelable&&R.preventDefault()},style:{position:"absolute",inset:0,background:Rr(it,y?0:xt),transition:S?"none":"background 0.25s ease-out",zIndex:1,touchAction:"none"}}),(0,at.jsxs)("div",{onPointerDown:R=>{let I=R.target;I&&I.closest("button, input, textarea, a")||z(R.clientY,!1)},onTouchStart:R=>{let I=R.target;I&&I.closest("button, input, textarea, a")||R.touches&&R.touches[0]&&z(R.touches[0].clientY,!1)},style:{position:"relative",zIndex:2,width:"100%",maxWidth:"520px",maxHeight:"85vh",backgroundColor:K.backgroundColor||"#ffffff",borderTopLeftRadius:`${K.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${K.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:0,borderBottomRightRadius:0,boxSizing:"border-box",paddingTop:10,paddingRight:16,paddingBottom:"max(14px, env(safe-area-inset-bottom, 14px))",paddingLeft:16,boxShadow:"0 -8px 32px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column",overflow:"hidden",touchAction:"none",overscrollBehavior:"contain",transform:y?"translateY(100%)":C?`translateY(${c}px)`:"translateY(100%)",transition:S?"none":"transform 0.28s cubic-bezier(0.25, 1, 0.5, 1)"},children:[(0,at.jsx)("style",{children:`
134
139
  .appstorys-survey-scroll {
135
- scrollbar-width: none; /* Firefox */
136
- -ms-overflow-style: none; /* IE/Edge */
140
+ scrollbar-width: none;
141
+ -ms-overflow-style: none;
137
142
  }
138
143
  .appstorys-survey-scroll::-webkit-scrollbar {
139
144
  width: 0;
140
145
  height: 0;
141
- display: none; /* Chrome/Safari */
146
+ display: none;
142
147
  }
143
- `}),P.crossButton?.enabled&&(0,ot.jsx)(At,{config:P.crossButton,onPress:T,style:{top:P.crossButton?.margin?.top??10,right:P.crossButton?.margin?.right??10}}),(0,ot.jsx)("div",{className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingRight:2},children:C?(0,ot.jsx)(ks,{details:_,onDone:M}):(0,ot.jsx)(ws,{details:_,slide:w,appearance:$,selectedOptions:f,comment:S,onSelectOption:x,onCommentChange:u,onSubmit:p,canSubmit:f.length>0})})]})]}):null},er=Rs;var Je=require("react");rt();var Xt=require("react");var Ge=ae(require("lottie-react")),St=require("react/jsx-runtime"),Ts=Ge.default?.default??Ge.default??Ge.Lottie??Ge,or=t=>{if(!t)return;let e=t.trim().toLowerCase();if(e==="middle")return"center";if(e==="left"||e==="right"||e==="center"||e==="justify")return e},Fs=(t,e,o)=>{if(!t)return;if(e){let r=o?._variantId||o?.details?.id;X("clicked",e,r?{variant_id:r}:void 0)}let i=(t.url||"").trim(),n=(t.value||"").trim();if(n&&!n.startsWith("http"))try{if(kt(n))return}catch{}if(i){try{window.open(i,"_blank")}catch{}return}if(n)try{window.open(n,"_blank")}catch{}},nr=({campaign:t,onDismiss:e})=>{let[o,i]=(0,Xt.useState)(typeof window<"u"?window.innerWidth:1024),[n,r]=(0,Xt.useState)(null),[l,d]=(0,Xt.useState)(!0),c=(0,Xt.useRef)(null);(0,Xt.useEffect)(()=>{if(typeof window>"u")return;let j=()=>i(window.innerWidth);window.addEventListener("resize",j);let V=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",j),document.body.style.overflow=V}},[]);let{details:y}=t,b=y?.modals?.[0],h=b?.content||{},f=b?.styling||{},v=h?.chooseMediaType||b?.chooseMediaType,S=v?.type,u=v?.url;if((0,Xt.useEffect)(()=>{S==="lottie"&&u?(r(null),fetch(u).then(j=>j.json()).then(j=>r(j)).catch(j=>console.error("Error fetching Lottie in ModalWithCta:",j))):r(null)},[S,u]),(0,Xt.useEffect)(()=>{c.current&&(c.current.muted=l)},[l]),(0,Xt.useEffect)(()=>{let j=c.current;if(!j||S!=="video")return;j.muted=!1;let V=j.play();V!==void 0&&V.then(()=>{d(!1)}).catch(()=>{j.muted=!0,d(!0),j.play().catch(()=>{})})},[u,S]),!b)return null;let m=f.appearance||{},g=f.crossButton,C=m.backdrop?.color||"rgba(0, 0, 0, 0.4)",I=m.backdrop?.opacity!==void 0&&m.backdrop?.opacity!==null?m.backdrop.opacity>1?m.backdrop.opacity/100:m.backdrop.opacity:0,z=m.enableBackdrop!==!1,E=m.dimension?.width!==void 0&&m.dimension?.width!==null&&m.dimension.width>0?m.dimension.width:300,w=o>=768,_=w?E*1.4:E,P=Math.min(_,o*.9),$=m.cornerRadius||{},q=m.backgroundColor||"#FFFFFF",B=h.titleText||"",a=h.subtitleText||"",x=h.primaryCtaText||"",s=h.secondaryCtaText||"",p=h.primaryCtaRedirection,M=h.secondaryCtaRedirection,T=f.title||{},R=f.subTitle||{},W=f.primaryCta||{},H=f.secondaryCta||{},U=(j,V,tt,at=!1)=>{if(!j||j.trim()==="")return null;let nt=V?.container||{},lt=V?.cornerRadius||{},k=V?.margin||{},L=V?.text||{},J=Bt=>Bt==="left"?"flex-start":Bt==="right"?"flex-end":"center",ht=nt.ctaWidth,Y=w&&ht?ht*1.4:ht,O=nt.height||40,et=w?O*1.2:O,ut=lt.topLeft!==void 0&&lt.topLeft>=0?lt.topLeft:8,Ct=lt.topRight!==void 0&&lt.topRight>=0?lt.topRight:8,yt=lt.bottomRight!==void 0&&lt.bottomRight>=0?lt.bottomRight:8,dt=lt.bottomLeft!==void 0&&lt.bottomLeft>=0?lt.bottomLeft:8;return(0,St.jsx)("div",{style:{display:"flex",justifyContent:J(nt.alignment),width:at?"auto":"100%",flex:at?1:void 0,marginTop:k.top!==void 0&&k.top>=0?k.top:0,marginBottom:k.bottom!==void 0&&k.bottom>=0?k.bottom:0,marginLeft:k.left!==void 0&&k.left>=0?k.left:0,marginRight:k.right!==void 0&&k.right>=0?k.right:0,boxSizing:"border-box"},children:(0,St.jsx)("button",{style:{width:at||nt.ctaFullWidth?"100%":Y?`${Y}px`:"auto",height:et,backgroundColor:nt.backgroundColor||"#FE6B35",color:L.color||"#FFFFFF",border:`${nt.borderWidth||0}px solid ${nt.borderColor||"transparent"}`,borderRadius:`${ut}px ${Ct}px ${yt}px ${dt}px`,fontSize:L.fontSize||14,fontFamily:mt(L.fontFamily)||"Arial",fontWeight:L.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:L.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:L.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px",outline:"none",boxSizing:"border-box"},onClick:()=>Fs(tt,t?.id,t),children:de(j)})})};return(0,St.jsxs)(St.Fragment,{children:[(0,St.jsx)("style",{children:`
148
+ `}),(0,at.jsx)("div",{onPointerDown:R=>{R.stopPropagation(),z(R.clientY,!0)},onTouchStart:R=>{R.stopPropagation(),R.touches&&R.touches[0]&&z(R.touches[0].clientY,!0)},style:{width:"40px",height:"4px",backgroundColor:"#D1D5DB",borderRadius:"2px",margin:"0 auto 8px auto",flexShrink:0,cursor:"grab",touchAction:"none",userSelect:"none"}}),H.crossButton?.enabled&&(0,at.jsx)(Ot,{config:H.crossButton,onPress:()=>{u(!0),setTimeout(()=>mt(),250)},style:{top:H.crossButton?.margin?.top!==void 0&&H.crossButton.margin.top>=0?H.crossButton.margin.top:10,right:H.crossButton?.margin?.right!==void 0&&H.crossButton.margin.right>=0?H.crossButton.margin.right:10,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0}}),(0,at.jsx)("div",{ref:m,className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",overscrollBehavior:"contain",touchAction:"pan-y",paddingRight:2,WebkitOverflowScrolling:"touch"},children:r?(0,at.jsx)(Ir,{details:J,onDone:ht}):(0,at.jsx)(zr,{details:J,slide:x,appearance:K,selectedOptions:T,comment:B,onSelectOption:Z,onCommentChange:$,onSubmit:dt,canSubmit:T.length>0})})]})]}):(0,at.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"flex-end",alignItems:"flex-end",padding:16,boxSizing:"border-box",pointerEvents:"none"},children:[(0,at.jsx)("div",{"aria-hidden":!0,onClick:mt,style:{position:"absolute",inset:0,background:Rr(it,xt),pointerEvents:xt>0?"auto":"none",zIndex:1}}),(0,at.jsxs)("div",{style:{position:"relative",zIndex:2,width:"min(420px, 92vw)",maxWidth:"92vw",minWidth:"320px",maxHeight:"80vh",overflow:"hidden",backgroundColor:K.backgroundColor||"#ffffff",borderRadius:Wo(K.cornerRadius,12),boxSizing:"border-box",paddingTop:14,paddingRight:16,paddingBottom:10,paddingLeft:16,pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[(0,at.jsx)("style",{children:`
149
+ .appstorys-survey-scroll {
150
+ scrollbar-width: none;
151
+ -ms-overflow-style: none;
152
+ }
153
+ .appstorys-survey-scroll::-webkit-scrollbar {
154
+ width: 0;
155
+ height: 0;
156
+ display: none;
157
+ }
158
+ `}),H.crossButton?.enabled&&(0,at.jsx)(Ot,{config:H.crossButton,onPress:mt,style:{top:H.crossButton?.margin?.top!==void 0&&H.crossButton.margin.top>=0?H.crossButton.margin.top:10,right:H.crossButton?.margin?.right!==void 0&&H.crossButton.margin.right>=0?H.crossButton.margin.right:10,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0}}),(0,at.jsx)("div",{className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingRight:2},children:r?(0,at.jsx)(Ir,{details:J,onDone:ht}):(0,at.jsx)(zr,{details:J,slide:x,appearance:K,selectedOptions:T,comment:B,onSelectOption:Z,onCommentChange:$,onSubmit:dt,canSubmit:T.length>0})})]})]}):null},Lr=oa;var vo=require("react");bt();var he=require("react");var So=ge(require("lottie-react")),Dt=require("react/jsx-runtime"),na=So.default?.default??So.default??So.Lottie??So,Er=t=>{if(!t)return;let e=t.trim().toLowerCase();if(e==="middle")return"center";if(e==="left"||e==="right"||e==="center"||e==="justify")return e},ia=t=>{if(!t)return null;if(typeof t=="string"){let e=t.trim();return e.length>0?e:null}if(typeof t=="object"){let e=typeof t.url=="string"?t.url.trim():"";if(e)return e;let o=typeof t.value=="string"?t.value.trim():"";if(o)return o;let n=typeof t.pageName=="string"?t.pageName.trim():"";if(n)return n;let i=typeof t.key=="string"?t.key.trim():"";if(i)return i}return null},ra=(t,e,o)=>{let n=ia(t);if(n){if(e){let i=o?._variantId||o?.details?.id;st("clicked",e,i?{variant_id:i}:void 0)}if(!n.startsWith("http"))try{if(Nt(n))return}catch{}try{window.open(n,"_blank")}catch{}}},Ar=({campaign:t,onDismiss:e})=>{let[o,n]=(0,he.useState)(typeof window<"u"?window.innerWidth:1024),[i,s]=(0,he.useState)(null),[l,c]=(0,he.useState)(!0),d=(0,he.useRef)(null);(0,he.useEffect)(()=>{if(typeof window>"u")return;let x=()=>n(window.innerWidth);window.addEventListener("resize",x);let z=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",x),document.body.style.overflow=z}},[]);let{details:S}=t,p=S?.modals?.[0],y=p?.content||{},u=p?.styling||{},C=y?.chooseMediaType||p?.chooseMediaType,h=C?.type,g=C?.url;if((0,he.useEffect)(()=>{h==="lottie"&&g?(s(null),fetch(g).then(x=>x.json()).then(x=>s(x)).catch(x=>console.error("Error fetching Lottie in ModalWithCta:",x))):s(null)},[h,g]),(0,he.useEffect)(()=>{d.current&&(d.current.muted=l)},[l]),(0,he.useEffect)(()=>{let x=d.current;if(!x||h!=="video")return;x.muted=!1;let z=x.play();z!==void 0&&z.then(()=>{c(!1)}).catch(()=>{x.muted=!0,c(!0),x.play().catch(()=>{})})},[g,h]),!p)return null;let b=u.appearance||{},m=u.crossButton,E=b.backdrop?.color||"rgba(0, 0, 0, 0.4)",j=b.backdrop?.opacity!==void 0&&b.backdrop?.opacity!==null?b.backdrop.opacity>1?b.backdrop.opacity/100:b.backdrop.opacity:0,D=b.enableBackdrop!==!1,L=b.dimension?.width!==void 0&&b.dimension?.width!==null&&b.dimension.width>0?b.dimension.width:300,v=o>=768,w=v?L*1.4:L,_=Math.min(w,o*.9),N=b.cornerRadius||{},U=b.backgroundColor||"#FFFFFF",A=y.titleText||"",T=y.subtitleText||"",k=y.primaryCtaText||"",B=y.secondaryCtaText||"",$=y.primaryCtaRedirection,V=y.secondaryCtaRedirection,G=u.title||{},r=u.subTitle||{},M=u.primaryCta||{},a=u.secondaryCta||{},f=(x,z,Y,ot=!1)=>{if(!x||x.trim()==="")return null;let J=z?.container||{},H=z?.cornerRadius||{},K=z?.margin||{},it=z?.text||{},xt=O=>O==="left"?"flex-start":O==="right"?"flex-end":"center",ut=J.ctaWidth,Z=v&&ut?ut*1.4:ut,rt=J.height||40,dt=v?rt*1.2:rt,ht=H.topLeft!==void 0&&H.topLeft>=0?H.topLeft:8,mt=H.topRight!==void 0&&H.topRight>=0?H.topRight:8,R=H.bottomRight!==void 0&&H.bottomRight>=0?H.bottomRight:8,I=H.bottomLeft!==void 0&&H.bottomLeft>=0?H.bottomLeft:8;return(0,Dt.jsx)("div",{style:{display:"flex",justifyContent:xt(J.alignment),width:ot?"auto":"100%",flex:ot?1:void 0,marginTop:K.top!==void 0&&K.top>=0?K.top:0,marginBottom:K.bottom!==void 0&&K.bottom>=0?K.bottom:0,marginLeft:K.left!==void 0&&K.left>=0?K.left:0,marginRight:K.right!==void 0&&K.right>=0?K.right:0,boxSizing:"border-box"},children:(0,Dt.jsx)("button",{style:{width:ot||J.ctaFullWidth?"100%":Z?`${Z}px`:"auto",height:dt,backgroundColor:J.backgroundColor||"#FE6B35",color:it.color||"#FFFFFF",border:`${J.borderWidth||0}px solid ${J.borderColor||"transparent"}`,borderRadius:`${ht}px ${mt}px ${R}px ${I}px`,fontSize:it.fontSize||14,fontFamily:lt(it.fontFamily)||"Arial",fontWeight:it.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:it.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:it.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px",outline:"none",boxSizing:"border-box"},onClick:()=>ra(Y,t?.id,t),children:Pe(x)})})};return(0,Dt.jsxs)(Dt.Fragment,{children:[(0,Dt.jsx)("style",{children:`
144
159
  .appstorys-modal-scroll::-webkit-scrollbar { display: none; }
145
160
  .appstorys-modal-scroll { scrollbar-width: none; }
146
- `}),(0,St.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:z?C:"transparent",opacity:z?I:1,zIndex:999998,transition:"opacity 0.3s ease"}}),(0,St.jsxs)("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:P,maxWidth:"95vw",zIndex:999999,overflow:"visible"},children:[(g?.enabled??!0)&&(0,St.jsx)(At,{config:g||{enabled:!0},onPress:j=>{j&&typeof j.stopPropagation=="function"&&j.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:g?.margin?.top!==void 0&&g.margin?.top>=0?g.margin.top:8,right:g?.margin?.right!==void 0&&g.margin?.right>=0?g.margin.right:8}}),(0,St.jsxs)("div",{style:{width:"100%",backgroundColor:q,borderTopLeftRadius:$.topLeft!==void 0&&$.topLeft>=0?$.topLeft:0,borderTopRightRadius:$.topRight!==void 0&&$.topRight>=0?$.topRight:0,borderBottomLeftRadius:$.bottomLeft!==void 0&&$.bottomLeft>=0?$.bottomLeft:0,borderBottomRightRadius:$.bottomRight!==void 0&&$.bottomRight>=0?$.bottomRight:0,overflow:"hidden",boxShadow:"0 8px 32px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",maxHeight:"90vh"},children:[(0,St.jsxs)("div",{className:"appstorys-modal-scroll",style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",alignItems:"center",minHeight:0},children:[u&&(S==="image"||!S)&&(0,St.jsx)("img",{src:u,alt:"",style:{width:"100%",display:"block"}}),u&&S==="video"&&(0,St.jsxs)("div",{style:{position:"relative",width:"100%"},children:[(0,St.jsx)("video",{ref:c,src:u,autoPlay:!0,loop:!0,muted:l,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),(0,St.jsx)(Me,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(0,0,0,0.45)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:j=>{j.stopPropagation(),d(V=>!V)},type:l?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),u&&S==="lottie"&&n&&(()=>{let j=n.w,V=n.h,tt=j&&V&&j>0?V/j:void 0,at=P,nt=tt?Math.round(at*tt):void 0;return(0,St.jsx)(Ts,{animationData:n,loop:!0,autoplay:!0,style:{width:at,height:nt,display:"block"}})})(),B.trim()!==""&&(0,St.jsx)("div",{style:{width:"100%",padding:"12px 16px 0 16px",color:T.color||"#000000",fontSize:T.fontSize||26,fontFamily:mt(T.fontFamily)||"Helvetica",fontWeight:T.fontDecoration?.includes("bold")?"bold":"600",fontStyle:T.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:T.fontDecoration?.includes("underline")?"underline":"none",textAlign:or(T.textAlign)||"center",boxSizing:"border-box"},children:de(B)}),a.trim()!==""&&(0,St.jsx)("div",{style:{width:"100%",padding:"4px 16px 0 16px",color:R.color||"#000000",fontSize:R.fontSize||20,fontFamily:mt(R.fontFamily)||"Helvetica",fontWeight:R.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:R.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:R.fontDecoration?.includes("underline")?"underline":"none",textAlign:or(R.textAlign)||"center",boxSizing:"border-box"},children:de(a)})]}),(x.trim()!==""||s.trim()!=="")&&(0,St.jsxs)("div",{style:{flexShrink:0,width:"100%",padding:"0 12px 12px 12px",boxSizing:"border-box",display:"flex",flexDirection:x.trim()!==""&&s.trim()!==""?"row":"column",gap:"8px",justifyContent:"center"},children:[U(x,W,p,x.trim()!==""&&s.trim()!==""),U(s,H,M,x.trim()!==""&&s.trim()!=="")]})]})]})]})};var Jt=require("react");var Xe=ae(require("lottie-react")),Mt=require("react/jsx-runtime"),zs=Xe.default?.default??Xe.default??Xe.Lottie??Xe,Is=(t,e,o)=>{if(!t)return;if(e){let r=o?._variantId||o?.details?.id;X("clicked",e,r?{variant_id:r}:void 0)}let i=(t.url||"").trim(),n=(t.value||"").trim();if(n&&!n.startsWith("http"))try{if(kt(n))return}catch{}if(i){try{window.open(i,"_blank")}catch{}return}if(n)try{window.open(n,"_blank")}catch{}},ir=({campaign:t,onDismiss:e})=>{let[o,i]=(0,Jt.useState)(typeof window<"u"?window.innerWidth:1024),[n,r]=(0,Jt.useState)(null),[l,d]=(0,Jt.useState)(!0),c=(0,Jt.useRef)(null);(0,Jt.useEffect)(()=>{if(typeof window>"u")return;let B=()=>i(window.innerWidth);window.addEventListener("resize",B);let a=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",B),document.body.style.overflow=a}},[]);let{details:y}=t,b=y?.modals?.[0],h=b?.chooseMediaType,f=b?.styling||{},v=b?.redirection,S=h?.type,u=h?.url;if((0,Jt.useEffect)(()=>{S==="lottie"&&u?(r(null),fetch(u).then(B=>B.json()).then(B=>r(B)).catch(B=>console.error("Error fetching Lottie in MediaOnlyModal:",B))):r(null)},[S,u]),(0,Jt.useEffect)(()=>{c.current&&(c.current.muted=l)},[l]),(0,Jt.useEffect)(()=>{let B=c.current;if(!B||S!=="video")return;B.muted=!1;let a=B.play();a!==void 0&&a.then(()=>{d(!1)}).catch(()=>{B.muted=!0,d(!0),B.play().catch(()=>{})})},[u,S]),!b||!h||!u)return null;let m=f.appearance||{},g=f.crossButton,C=m.backdrop?.color||"rgba(0, 0, 0, 0.4)",I=m.backdrop?.opacity!==void 0&&m.backdrop?.opacity!==null?m.backdrop.opacity>1?m.backdrop.opacity/100:m.backdrop.opacity:0,z=m.enableBackdrop!==!1,E=m.dimension?.width!==void 0&&m.dimension?.width!==null&&m.dimension.width>0?m.dimension.width:300,_=o>=768?E*1.4:E,P=Math.min(_,o*.9),$=m.cornerRadius||{},q=m.backgroundColor||(S==="lottie"?"transparent":"#FFFFFF");return(0,Mt.jsxs)(Mt.Fragment,{children:[(0,Mt.jsx)("style",{children:`
161
+ `}),(0,Dt.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:D?E:"transparent",opacity:D?j:1,zIndex:999998,transition:"opacity 0.3s ease"}}),(0,Dt.jsxs)("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:_,maxWidth:"95vw",zIndex:999999,overflow:"visible"},children:[(m?.enabled??!0)&&(0,Dt.jsx)(Ot,{config:m||{enabled:!0},onPress:x=>{x&&typeof x.stopPropagation=="function"&&x.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:m?.margin?.top!==void 0&&m.margin?.top>=0?m.margin.top:8,right:m?.margin?.right!==void 0&&m.margin?.right>=0?m.margin.right:8}}),(0,Dt.jsxs)("div",{style:{width:"100%",backgroundColor:U,borderTopLeftRadius:N.topLeft!==void 0&&N.topLeft>=0?N.topLeft:0,borderTopRightRadius:N.topRight!==void 0&&N.topRight>=0?N.topRight:0,borderBottomLeftRadius:N.bottomLeft!==void 0&&N.bottomLeft>=0?N.bottomLeft:0,borderBottomRightRadius:N.bottomRight!==void 0&&N.bottomRight>=0?N.bottomRight:0,overflow:"hidden",boxShadow:"0 8px 32px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",maxHeight:"90vh"},children:[(0,Dt.jsxs)("div",{className:"appstorys-modal-scroll",style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",alignItems:"center",minHeight:0},children:[g&&(h==="image"||!h)&&(0,Dt.jsx)("img",{src:g,alt:"",style:{width:"100%",display:"block"}}),g&&h==="video"&&(0,Dt.jsxs)("div",{style:{position:"relative",width:"100%"},children:[(0,Dt.jsx)("video",{ref:d,src:g,autoPlay:!0,loop:!0,muted:l,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),(0,Dt.jsx)(Me,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(0,0,0,0.45)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:x=>{x.stopPropagation(),c(z=>!z)},type:l?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),g&&h==="lottie"&&i&&(()=>{let x=i.w,z=i.h,Y=x&&z&&x>0?z/x:void 0,ot=_,J=Y?Math.round(ot*Y):void 0;return(0,Dt.jsx)(na,{animationData:i,loop:!0,autoplay:!0,style:{width:ot,height:J,display:"block"}})})(),A.trim()!==""&&(0,Dt.jsx)("div",{style:{width:"100%",padding:"12px 16px 0 16px",color:G.color||"#000000",fontSize:G.fontSize||26,fontFamily:lt(G.fontFamily)||"Helvetica",fontWeight:G.fontDecoration?.includes("bold")?"bold":"600",fontStyle:G.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:G.fontDecoration?.includes("underline")?"underline":"none",textAlign:Er(G.textAlign)||"center",boxSizing:"border-box"},children:Pe(A)}),T.trim()!==""&&(0,Dt.jsx)("div",{style:{width:"100%",padding:"4px 16px 0 16px",color:r.color||"#000000",fontSize:r.fontSize||20,fontFamily:lt(r.fontFamily)||"Helvetica",fontWeight:r.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:r.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:r.fontDecoration?.includes("underline")?"underline":"none",textAlign:Er(r.textAlign)||"center",boxSizing:"border-box"},children:Pe(T)})]}),(k.trim()!==""||B.trim()!=="")&&(0,Dt.jsxs)("div",{style:{flexShrink:0,width:"100%",padding:"0 12px 12px 12px",boxSizing:"border-box",display:"flex",flexDirection:k.trim()!==""&&B.trim()!==""?"row":"column",gap:"8px",justifyContent:"center"},children:[f(k,M,$,k.trim()!==""&&B.trim()!==""),f(B,a,V,k.trim()!==""&&B.trim()!=="")]})]})]})]})};var be=require("react");var Co=ge(require("lottie-react")),Qt=require("react/jsx-runtime"),sa=Co.default?.default??Co.default??Co.Lottie??Co,Mr=t=>{if(!t)return null;if(typeof t=="string"){let e=t.trim();return e.length>0?e:null}if(typeof t=="object"){let e=typeof t.url=="string"?t.url.trim():"";if(e)return e;let o=typeof t.value=="string"?t.value.trim():"";if(o)return o;let n=typeof t.pageName=="string"?t.pageName.trim():"";if(n)return n;let i=typeof t.key=="string"?t.key.trim():"";if(i)return i}return null},aa=(t,e,o)=>{let n=Mr(t);if(n){if(e){let i=o?._variantId||o?.details?.id;st("clicked",e,i?{variant_id:i}:void 0)}if(!n.startsWith("http"))try{if(Nt(n))return}catch{}try{window.open(n,"_blank")}catch{}}},Pr=({campaign:t,onDismiss:e})=>{let[o,n]=(0,be.useState)(typeof window<"u"?window.innerWidth:1024),[i,s]=(0,be.useState)(null),[l,c]=(0,be.useState)(!0),d=(0,be.useRef)(null);(0,be.useEffect)(()=>{if(typeof window>"u")return;let A=()=>n(window.innerWidth);window.addEventListener("resize",A);let T=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",A),document.body.style.overflow=T}},[]);let{details:S}=t,p=S?.modals?.[0],y=p?.chooseMediaType,u=p?.styling||{},C=p?.redirection,h=y?.type,g=y?.url;if((0,be.useEffect)(()=>{h==="lottie"&&g?(s(null),fetch(g).then(A=>A.json()).then(A=>s(A)).catch(A=>console.error("Error fetching Lottie in MediaOnlyModal:",A))):s(null)},[h,g]),(0,be.useEffect)(()=>{d.current&&(d.current.muted=l)},[l]),(0,be.useEffect)(()=>{let A=d.current;if(!A||h!=="video")return;A.muted=!1;let T=A.play();T!==void 0&&T.then(()=>{c(!1)}).catch(()=>{A.muted=!0,c(!0),A.play().catch(()=>{})})},[g,h]),!p||!y||!g)return null;let b=u.appearance||{},m=u.crossButton,E=b.backdrop?.color||"rgba(0, 0, 0, 0.4)",j=b.backdrop?.opacity!==void 0&&b.backdrop?.opacity!==null?b.backdrop.opacity>1?b.backdrop.opacity/100:b.backdrop.opacity:0,D=b.enableBackdrop!==!1,L=b.dimension?.width!==void 0&&b.dimension?.width!==null&&b.dimension.width>0?b.dimension.width:300,w=o>=768?L*1.4:L,_=Math.min(w,o*.9),N=b.cornerRadius||{},U=b.backgroundColor||(h==="lottie"?"transparent":"#FFFFFF");return(0,Qt.jsxs)(Qt.Fragment,{children:[(0,Qt.jsx)("style",{children:`
147
162
  .appstorys-media-modal-scroll::-webkit-scrollbar { display: none; }
148
163
  .appstorys-media-modal-scroll { scrollbar-width: none; }
149
- `}),(0,Mt.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:z?C:"transparent",opacity:z?I:1,zIndex:999998,transition:"opacity 0.3s ease"}}),(0,Mt.jsxs)("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:P,maxWidth:"95vw",zIndex:999999,overflow:"visible"},children:[(g?.enabled??!0)&&(0,Mt.jsx)(At,{config:g||{enabled:!0},onPress:B=>{B&&typeof B.stopPropagation=="function"&&B.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:g?.margin?.top!==void 0&&g.margin?.top>=0?g.margin.top:8,right:g?.margin?.right!==void 0&&g.margin?.right>=0?g.margin.right:8}}),(0,Mt.jsx)("div",{className:"appstorys-media-modal-scroll",style:{width:"100%",backgroundColor:q,borderTopLeftRadius:$.topLeft!==void 0&&$.topLeft>=0?$.topLeft:0,borderTopRightRadius:$.topRight!==void 0&&$.topRight>=0?$.topRight:0,borderBottomLeftRadius:$.bottomLeft!==void 0&&$.bottomLeft>=0?$.bottomLeft:0,borderBottomRightRadius:$.bottomRight!==void 0&&$.bottomRight>=0?$.bottomRight:0,overflow:"hidden",boxShadow:q==="transparent"?"none":"0 8px 32px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",alignItems:"center",maxHeight:"90vh",overflowY:"auto"},children:(0,Mt.jsxs)("div",{onClick:()=>Is(v,t?.id,t),style:{width:"100%",cursor:v?"pointer":"default",minHeight:0},children:[u&&(S==="image"||!S)&&(0,Mt.jsx)("img",{src:u,alt:"",style:{width:"100%",display:"block"}}),u&&S==="video"&&(0,Mt.jsxs)("div",{style:{position:"relative",width:"100%"},children:[(0,Mt.jsx)("video",{ref:c,src:u,autoPlay:!0,loop:!0,muted:l,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),(0,Mt.jsx)(Me,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(0,0,0,0.45)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:B=>{B.stopPropagation(),d(a=>!a)},type:l?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),u&&S==="lottie"&&n&&(()=>{let B=n.w,a=n.h,x=B&&a&&B>0?a/B:void 0,s=P,p=x?Math.round(s*x):void 0;return(0,Mt.jsx)(zs,{animationData:n,loop:!0,autoplay:!0,style:{width:s,height:p,display:"block"}})})()]})})]})]})};var kn=require("react/jsx-runtime"),rr=()=>{let t=xt("MOD"),e=A(v=>v.campaigns),o=A(v=>v.allCampaigns),i=A(v=>v.currentScreen),n=t??(()=>{let v=(i||"").trim().toLowerCase(),S=[...e||[],...o||[]].find(u=>{if(!u||u.campaign_type!=="MOD")return!1;let m=!!(u.trigger_event??u.trigger);if(!(u.display_trigger!==!1&&!m))return!1;let C=(u.screen||"").trim().toLowerCase();return!C||C===v});if(S)try{return Ft(S)}catch{return S}})(),r=A(v=>v.isVisible),[l,d]=(0,Je.useState)(!1),c=(0,Je.useRef)(null);(0,Je.useEffect)(()=>{if(n?.id&&c.current!==n.id){c.current=n.id,d(!1);let v=n._variantId||n.details?.id,S=v?{variant_id:v}:void 0;X("viewed",n.id,S)}},[n?.id]);let y=v=>{try{let S=A.getState(),m=(S.trackedEvents||[]).filter(g=>g!==v);S.setTrackedEvents(m)}catch{}};if(!n||l||!r)return null;let b=()=>{n?.id&&y(`viaAppStorys${n.id}`),d(!0)},h=n.details?.modal_type||n.details?.modals?.[0]?.modal_type||"";return h==="full-page-modal"||h==="media-only-modal"?(0,kn.jsx)(ir,{campaign:n,onDismiss:b}):(0,kn.jsx)(nr,{campaign:n,onDismiss:b})};var ar=require("react/jsx-runtime"),sr=({id:t,children:e})=>(0,ar.jsx)("div",{"data-as-id":t,style:{display:"contents"},children:e});var Rn=class{state="uninitialized";navigateToScreen;async initialize(e){let{appId:o,accountId:i,userId:n}=e;if(this.navigateToScreen=e.navigateToScreen,this.state!=="initializing"){if(this.state==="initialized"){let r=A.getState();if(r.isAnonymousUser&&n&&n.trim()!==""){console.log("AppStorys: Reconciling anonymous user with identified user..."),await this.reconcileUser(r.userId,n,o,i);return}if(r.appId===o&&r.accountId===i&&r.userId===n)return}this.state="initializing";try{let r,l;if(!n||n.trim()==="")r=await di(),l=!0;else{let h=await on();h&&h!==n&&console.log("AppStorys: Found previous anonymous user, will reconcile after verification."),r=n,l=!1}if(!await le(i,o,r)){this.state="error";return}if(!l){let h=await on();h&&h!==r&&(await ko(h,r),await en())}try{let h=await bt(),f=e.baseUrl||"https://users.appstorys.co";fetch(`${f}/v2/${i}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...h?{Authorization:`Bearer ${h}`}:{}},body:JSON.stringify({user_id:r,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})}).then(async v=>{if(v.ok)try{let S=await v.json(),u=A.getState();if(typeof S.screen_capture_enabled<"u"){let m=!!S.screen_capture_enabled;console.info("AppStorys: track-user-res returned screen_capture_enabled=",m),u.setScreenCaptureEnabled(m)}}catch{}}).catch(v=>console.warn("track-user-res (init) failed",v))}catch(h){console.warn("track-user-res (init) setup failed",h)}let{campaigns:c,version:y}=await Jo(i);try{ei(c)}catch(h){console.warn("Failed to preload campaign fonts",h)}let b=A.getState();b.setAppId(o),b.setAccountId(i),b.setUserId(r),b.setIsAnonymousUser(l),b.setBaseUrl(e.baseUrl),b.setTrackingUrl(e.trackingUrl),b.saveAllCampaigns(c),b.setCampaignVersion(y);try{A.getState().screenCaptureEnabled&&(await Promise.resolve().then(()=>(gr(),pr))).mountScreenCaptureButton()}catch(h){console.warn("Failed to mount screen capture button",h)}ai.setup(),tn.setup(),this.state="initialized"}catch(r){this.state="error",console.error("AppStorys initialization failed:",r)}}}async reconcileUser(e,o,i,n){try{if(!await le(n,i,o)){console.error("AppStorys: Failed to verify identified user account during reconciliation.");return}if(!await ko(e,o)){console.error("AppStorys: Failed to reconcile anonymous and identified users.");return}await en();let d=A.getState();d.setUserId(o),d.setIsAnonymousUser(!1)}catch(r){console.error("AppStorys: Error during user reconciliation:",r)}}async trackScreen(e){return await this.ensureInitialized(),Yo(e)}async trackEvent(e,o,i){return await this.ensureInitialized(),X(e,o,i)}async setUserProperties(e){return await this.ensureInitialized(),Qo(e)}handleLink(e){if(e){if(typeof e=="string"){try{if(!e.startsWith("http")&&kt(e))return}catch(o){console.warn("revealCampaignFromLink error",o)}e.startsWith("http")?window.open(e,"_blank"):this.navigateToScreen?.(e)}else if(typeof e=="object"&&e.value){try{if(kt(e.value))return}catch{}this.navigateToScreen?.(e.value)}}}get visibility(){return A.getState().isVisible}set visibility(e){tn.updateVisibility(e)}async ensureInitialized(){if(this.state==="initialized")return;let e=Date.now();for(;this.state!=="initialized";){if(this.state==="error")throw new Error("AppStorys SDK error");if(Date.now()-e>1e4)throw new Error("AppStorys SDK initialization timeout");await new Promise(o=>setTimeout(o,100))}}personalizeText(e){return de(e)}},Ds=new Rn;0&&(module.exports={AppStorys,Banner,BottomSheet,Csat,Floater,Modal,Pip,SdkState,Story,Survey,Tooltip,Trackable,Widget,getCampaignVariantId,getVariantId,hasVariants,personalizeText,resolveCampaignVariant,selectVariantByWeight});
164
+ `}),(0,Qt.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:D?E:"transparent",opacity:D?j:1,zIndex:999998,transition:"opacity 0.3s ease"}}),(0,Qt.jsxs)("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:_,maxWidth:"95vw",zIndex:999999,overflow:"visible"},children:[(m?.enabled??!0)&&(0,Qt.jsx)(Ot,{config:m||{enabled:!0},onPress:A=>{A&&typeof A.stopPropagation=="function"&&A.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:m?.margin?.top!==void 0&&m.margin?.top>=0?m.margin.top:8,right:m?.margin?.right!==void 0&&m.margin?.right>=0?m.margin.right:8}}),(0,Qt.jsx)("div",{className:"appstorys-media-modal-scroll",style:{width:"100%",backgroundColor:U,borderTopLeftRadius:N.topLeft!==void 0&&N.topLeft>=0?N.topLeft:0,borderTopRightRadius:N.topRight!==void 0&&N.topRight>=0?N.topRight:0,borderBottomLeftRadius:N.bottomLeft!==void 0&&N.bottomLeft>=0?N.bottomLeft:0,borderBottomRightRadius:N.bottomRight!==void 0&&N.bottomRight>=0?N.bottomRight:0,overflow:"hidden",boxShadow:U==="transparent"?"none":"0 8px 32px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",alignItems:"center",maxHeight:"90vh",overflowY:"auto"},children:(()=>{let A=!!Mr(C);return(0,Qt.jsxs)("div",{onClick:A?()=>aa(C,t?.id,t):void 0,style:{width:"100%",cursor:A?"pointer":"default",minHeight:0},children:[g&&(h==="image"||!h)&&(0,Qt.jsx)("img",{src:g,alt:"",style:{width:"100%",display:"block"}}),g&&h==="video"&&(0,Qt.jsxs)("div",{style:{position:"relative",width:"100%"},children:[(0,Qt.jsx)("video",{ref:d,src:g,autoPlay:!0,loop:!0,muted:l,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),(0,Qt.jsx)(Me,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(0,0,0,0.45)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:T=>{T.stopPropagation(),c(k=>!k)},type:l?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),g&&h==="lottie"&&i&&(()=>{let T=i.w,k=i.h,B=T&&k&&T>0?k/T:void 0,$=_,V=B?Math.round($*B):void 0;return(0,Qt.jsx)(sa,{animationData:i,loop:!0,autoplay:!0,style:{width:$,height:V,display:"block"}})})()]})})()})]})]})};var Kn=require("react/jsx-runtime"),Dr=()=>{let t=Mt("MOD"),e=P(C=>C.campaigns),o=P(C=>C.allCampaigns),n=P(C=>C.currentScreen),i=t??(()=>{let C=(n||"").trim().toLowerCase(),h=[...e||[],...o||[]].find(g=>{if(!g||g.campaign_type!=="MOD")return!1;let b=!!(g.trigger_event??g.trigger);if(!(g.display_trigger!==!1&&!b))return!1;let E=(g.screen||"").trim().toLowerCase();return!E||E===C});if(h)try{return Ht(h)}catch{return h}})(),s=P(C=>C.isVisible),[l,c]=(0,vo.useState)(!1),d=(0,vo.useRef)(null);(0,vo.useEffect)(()=>{if(i?.id&&d.current!==i.id){d.current=i.id,c(!1);let C=i._variantId||i.details?.id,h=C?{variant_id:C}:void 0;st("viewed",i.id,h)}},[i?.id]);let S=C=>{try{let h=P.getState(),b=(h.trackedEvents||[]).filter(m=>m!==C);h.setTrackedEvents(b)}catch{}};if(!i||l||!s)return null;let p=()=>{i?.id&&S(`viaAppStorys${i.id}`),c(!0)},y=i.details?.modal_type||i.details?.modals?.[0]?.modal_type||"";return y==="full-page-modal"||y==="media-only-modal"?(0,Kn.jsx)(Pr,{campaign:i,onDismiss:p}):(0,Kn.jsx)(Ar,{campaign:i,onDismiss:p})};var Wr=require("react/jsx-runtime"),_r=({id:t,children:e})=>(0,Wr.jsx)("div",{"data-as-id":t,style:{display:"contents"},children:e});var Zn=class{state="uninitialized";navigateToScreen;async initialize(e){let{appId:o,accountId:n,userId:i}=e;if(this.navigateToScreen=e.navigateToScreen,this.state!=="initializing"){if(this.state==="initialized"){let s=P.getState();if(s.isAnonymousUser&&i&&i.trim()!==""){console.log("AppStorys: Reconciling anonymous user with identified user..."),await this.reconcileUser(s.userId,i,o,n);return}if(s.appId===o&&s.accountId===n&&s.userId===i)return}this.state="initializing";try{let s,l;if(!i||i.trim()==="")s=await Ai(),l=!0;else{let y=await An();y&&y!==i&&console.log("AppStorys: Found previous anonymous user, will reconcile after verification."),s=i,l=!1}if(!await Ae(n,o,s)){this.state="error";return}if(!l){let y=await An();y&&y!==s&&(await Ko(y,s),await En())}try{let y=await At(),u=e.baseUrl||"https://users.appstorys.co";fetch(`${u}/v2/${n}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...y?{Authorization:`Bearer ${y}`}:{}},body:JSON.stringify({user_id:s,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})}).then(async C=>{if(C.ok)try{let h=await C.json(),g=P.getState();if(typeof h.screen_capture_enabled<"u"){let b=!!h.screen_capture_enabled;console.info("AppStorys: track-user-res returned screen_capture_enabled=",b),g.setScreenCaptureEnabled(b)}}catch{}}).catch(C=>console.warn("track-user-res (init) failed",C))}catch(y){console.warn("track-user-res (init) setup failed",y)}let{campaigns:d,version:S}=await zn(n);try{xi(d)}catch(y){console.warn("Failed to preload campaign fonts",y)}let p=P.getState();p.setAppId(o),p.setAccountId(n),p.setUserId(s),p.setIsAnonymousUser(l),p.setBaseUrl(e.baseUrl),p.setTrackingUrl(e.trackingUrl),p.saveAllCampaigns(d),p.setCampaignVersion(S);try{P.getState().screenCaptureEnabled&&(await Promise.resolve().then(()=>(Hr(),qr))).mountScreenCaptureButton()}catch(y){console.warn("Failed to mount screen capture button",y)}Li.setup(),Ln.setup(),this.state="initialized"}catch(s){this.state="error",console.error("AppStorys initialization failed:",s)}}}async reconcileUser(e,o,n,i){try{if(!await Ae(i,n,o)){console.error("AppStorys: Failed to verify identified user account during reconciliation.");return}if(!await Ko(e,o)){console.error("AppStorys: Failed to reconcile anonymous and identified users.");return}await En();let c=P.getState();c.setUserId(o),c.setIsAnonymousUser(!1)}catch(s){console.error("AppStorys: Error during user reconciliation:",s)}}async trackScreen(e){return await this.ensureInitialized(),kn(e)}async trackEvent(e,o,n){return await this.ensureInitialized(),st(e,o,n)}async setUserProperties(e){return await this.ensureInitialized(),Rn(e)}handleLink(e){if(e){if(typeof e=="string"){try{if(!e.startsWith("http")&&Nt(e))return}catch(o){console.warn("revealCampaignFromLink error",o)}e.startsWith("http")?window.open(e,"_blank"):this.navigateToScreen?.(e)}else if(typeof e=="object"&&e.value){try{if(Nt(e.value))return}catch{}this.navigateToScreen?.(e.value)}}}get visibility(){return P.getState().isVisible}set visibility(e){Ln.updateVisibility(e)}async ensureInitialized(){if(this.state==="initialized")return;let e=Date.now();for(;this.state!=="initialized";){if(this.state==="error")throw new Error("AppStorys SDK error");if(Date.now()-e>1e4)throw new Error("AppStorys SDK initialization timeout");await new Promise(o=>setTimeout(o,100))}}personalizeText(e){return Pe(e)}},ga=new Zn;0&&(module.exports={AppStorys,Banner,BottomSheet,Csat,Floater,Modal,Pip,SdkState,Story,Survey,Tooltip,Trackable,Widget,getCampaignVariantId,getVariantId,hasVariants,personalizeText,resolveCampaignVariant,selectVariantByWeight});
150
165
  //# sourceMappingURL=index.js.map