@appstorys/react-web 1.1.2 → 1.1.3
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.d.mts +62 -25
- package/dist/index.d.ts +62 -25
- package/dist/index.js +17 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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=`
|
|
1
|
+
"use strict";var ls=Object.create;var Zo=Object.defineProperty;var ds=Object.getOwnPropertyDescriptor;var cs=Object.getOwnPropertyNames;var us=Object.getPrototypeOf,ps=Object.prototype.hasOwnProperty;var Ye=(t,e)=>()=>(t&&(e=t(t=0)),e);var fi=(t,e)=>{for(var o in e)Zo(t,o,{get:e[o],enumerable:!0})},mi=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of cs(e))!ps.call(t,i)&&i!==o&&Zo(t,i,{get:()=>e[i],enumerable:!(n=ds(e,i))||n.enumerable});return t};var me=(t,e,o)=>(o=t!=null?ls(us(t)):{},mi(e||!t||!t.__esModule?Zo(o,"default",{value:t,enumerable:!0}):o,t)),gs=t=>mi(Zo({},"__esModule",{value:!0}),t);var Bt,mo=Ye(()=>{"use strict";Bt=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 tn(t){if(!t)return{priority:9999,hasExplicitPriority:!1};let e=t.priority??t.details?.priority;if(e!=null&&e!==""){let i=Number(e);if(!isNaN(i)&&i>0)return{priority:i,hasExplicitPriority:!0}}let o=(t.campaign_type||"").toUpperCase();return{priority:Fn[o]??999,hasExplicitPriority:!1}}function hi(t,e){if(!t&&!e)return 0;if(!t)return 1;if(!e)return-1;let o=tn(t),n=tn(e);return o.hasExplicitPriority&&n.hasExplicitPriority||o.priority!==n.priority?o.priority-n.priority:o.hasExplicitPriority&&!n.hasExplicitPriority?-1:!o.hasExplicitPriority&&n.hasExplicitPriority?1:0}function Et(t){return Array.isArray(t)?[...t].sort(hi):[]}function Pt(t,e,o=yi){if(!t&&!e)return o;let n=1;return t?n=tn(t).priority:e&&(n=Fn[e.toUpperCase()]??1),o+n*100}var Fn,yi,te=Ye(()=>{"use strict";Fn={BAN:1,FLT:2,PIP:3,CSAT:4,WID:5,SCRT:6,BTS:7,SUR:8,TTP:9,TLTP:9,MOD:10},yi=1e4});function ve(){return In.getState().userId}async function Mt(){return Bt.getItem("access_token")}function xi(t){if(!t)return;let e=String(t||"").trim();if(e)return In.getState().variantMappings?.[e]}var bi,In,W,kt=Ye(()=>{"use strict";bi=require("zustand");mo();te();In=(0,bi.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:Et(e)}),saveAllCampaigns:e=>t({allCampaigns:Et(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})}));W=In});async function io(){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 on=Ye(()=>{"use strict"});async function De(t,e,o){try{let n={account_id:t,app_id:e,user_id:o};if(await Bt.getItem(Ri))console.log("Device info already sent previously - skipping");else{let l=await io();n.attributes={...l},console.log("First time verification - including device info in attributes")}let d=W.getState().baseUrl||"https://users.appstorys.co",c=await fetch(`${d}/${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 l=await c.json();console.log("Account verified",l);let{access_token:y,refresh_token:u}=l;if(y&&u)return await Bt.setItem("access_token",y),await Bt.setItem("refresh_token",u),n.attributes&&(await Bt.setItem(Ri,"true"),console.log("Device info sent flag set")),!0}return!1}catch(n){return console.error("Error when verifying AppStorys account",n),!1}}var Ri,nn=Ye(()=>{"use strict";mo();on();kt();Ri="device_info_sent"});async function vn(t,e){if(!e||e.length===0){console.info("AppStorys: identifyWidgetPositions called with empty positionList; skipping");return}let o=await Mt();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 ts=Ye(()=>{"use strict";kt()});function os(t){return t&&t.trim()}function Ta(t){return Xo[t]||(Xo[t]=[]),Xo[t]}function es(t,e,o,n){let i=new FormData,s=t.replace(/[^a-z0-9]/gi,"_"),d=`screenshot_${e}_${s}_${Date.now()}.png`,c=new File([n],d,{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(l){console.warn("AppStorys: Could not run FormData diagnostics",l)}return i}var Xo,Po,ns=Ye(()=>{"use strict";kt();nn();ts();kt();Xo={};Po=class{static setup(e,o){let n=W.getState();n.setScreenCaptureEnabled(o),n.setCurrentScreen(e)}static addLayoutInfo(e,o,n){let i=Ta(e),s=i.findIndex(l=>l.id===o),d={...n,screenWidth:n.screenWidth||window.innerWidth,screenHeight:n.screenHeight||window.innerHeight},c={id:o,frame:d};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(d=>{let c=d.getAttribute("data-as-id");if(c){s.push(c);let l=d.getBoundingClientRect();this.addLayoutInfo(e,c,{x:Math.round(l.left),y:Math.round(l.top),width:Math.round(l.width),height:Math.round(l.height),screenWidth:n,screenHeight:i})}}),console.info(`AppStorys: Identified ${o.length} elements:`,s)}static clearLayoutData(e){Xo[e]=[]}static getLayoutData(e){return Xo[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),W.getState().setCurrentScreen(e),this.collectElements(e),await new Promise(f=>setTimeout(f,100));let i=window,s=null;if(typeof i.html2canvas!="function")try{await new Promise((f,P)=>{let g=document.createElement("script");g.src="https://html2canvas.hertzen.com/dist/html2canvas.min.js",g.onload=()=>f(),g.onerror=()=>P(new Error("Failed to load html2canvas")),document.head.appendChild(g)})}catch(f){console.warn("AppStorys: html2canvas load error",f)}if(typeof i.html2canvas=="function")try{let f=await i.html2canvas(document.documentElement,{useCORS:!0,allowTaint:!0,logging:!1,scale:window.devicePixelRatio||1});s=await new Promise(P=>f.toBlob(g=>P(g),"image/png"))}catch(f){console.warn("AppStorys: html2canvas capture failed (falling back to getDisplayMedia)",f),s=null}if(!s&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)try{let f=await navigator.mediaDevices.getDisplayMedia({video:!0}),P=document.createElement("video");P.srcObject=f,await P.play();let g=document.createElement("canvas");g.width=P.videoWidth||window.innerWidth,g.height=P.videoHeight||window.innerHeight;let b=g.getContext("2d");b&&b.drawImage(P,0,0,g.width,g.height),s=await new Promise(R=>g.toBlob(C=>R(C),"image/png")),P.pause(),f.getTracks().forEach(R=>R.stop())}catch(f){console.warn("AppStorys: getDisplayMedia capture failed",f)}if(!s)return console.warn("AppStorys: Capture failed \u2014 no blob generated"),!1;let d=await Mt(),c=ve();if(!c)return console.warn("AppStorys: No userId"),!1;if(!d){let f=W.getState();f.accountId&&f.appId&&f.userId&&await De(f.accountId,f.appId,f.userId)&&(d=await Mt())}if(!d)return console.warn("AppStorys: No token available"),!1;let l="https://backend.appstorys.co/api/v1/appinfo/identify-elements/",y=JSON.stringify(this.getLayoutData(e)||[]),u=es(e,c,y,s);console.info("AppStorys: Sending identify-elements with payload size:",y.length);let m=await fetch(l,{method:"POST",headers:{Authorization:`Bearer ${d}`,Accept:"application/json"},body:u});if(m.status===401){console.warn("AppStorys: 401 response \u2014 retrying once");let f=W.getState();if(f.accountId&&f.appId&&f.userId&&await De(f.accountId,f.appId,f.userId)){let g=await Mt();g&&(m=await fetch(l,{method:"POST",headers:{Authorization:`Bearer ${g}`,Accept:"application/json"},body:es(e,c,y,s)}))}}if(!m.ok){let f=await m.text();return console.error("AppStorys: identify-elements failed",m.status,f),!1}console.info("AppStorys: identify-elements success \u2713");try{let f=o?[...o]:[];document.querySelectorAll("[data-widget]").forEach(b=>{let R=b.getAttribute("data-widget");R&&f.push(R)});let g=Array.from(new Set(f)).map(b=>os(b)).filter(b=>!!b);console.info("AppStorys: identifyWidgetPositions will send",g.length,"positions",g),g.length>0&&await vn(e,g)}catch(f){console.warn("AppStorys: identifyWidgetPositions failed",f)}return!0}catch(n){return console.error("AppStorys: takeScreenshot error",n),!1}}};(function(){try{let e=window;e.AppStorysForceIdentifyPositions=async o=>{let n=W.getState(),i=o||n.currentScreen;if(!i){console.warn("AppStorys: AppStorysForceIdentifyPositions - no screen name available");return}let d=(Po.getLayoutData(i)||[]).map(c=>os(c.id)).filter(c=>!!c);console.info("AppStorys: AppStorysForceIdentifyPositions sending",d.length,"positions for",i,d);try{await vn(i,d),console.info("AppStorys: AppStorysForceIdentifyPositions completed")}catch(c){console.error("AppStorys: AppStorysForceIdentifyPositions error",c)}}}catch{}})()});var rs={};fi(rs,{mountScreenCaptureButton:()=>is});function Fa(){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 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=`
|
|
14
|
+
`,document.head.appendChild(t)}function Ia(){Fa();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 is(){try{let t=W.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=Ia();return n.addEventListener("click",async()=>{n.disabled=!0;let i=n.innerText;n.innerHTML='<div class="appstorys-spinner"></div>';let d=W.getState().currentScreen||(typeof window<"u"?window.location.pathname:"");try{await Po.takeScreenshot(d)}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 ss=Ye(()=>{"use strict";kt();ns();try{window.AppStorysMountCapture=function(){try{return is()}catch(t){return console.error("AppStorysMountCapture failed",t),null}}}catch{}try{window.AppStorysDebugState=function(){try{let t=W.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),d=new Date;console.info("Token expires:",s.toISOString(),"Expired:",d>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 Ba={};fi(Ba,{AppStorys:()=>za,BASE_OVERLAY_Z_INDEX:()=>yi,Banner:()=>Ai,BottomSheet:()=>Wr,Csat:()=>$r,DEFAULT_OVERLAY_PRIORITIES:()=>Fn,Floater:()=>qi,Modal:()=>Xr,Pip:()=>Oi,SdkState:()=>Tn,Story:()=>Ar,Survey:()=>Vr,Tooltip:()=>_r,Trackable:()=>Kr,Widget:()=>Yo,Widgets:()=>Yo,compareCampaignPriority:()=>hi,getCampaignVariantId:()=>ys,getCampaignZIndex:()=>Pt,getVariantId:()=>zn,hasVariants:()=>$o,parseCampaignPriority:()=>tn,personalizeText:()=>Ne,resolveCampaignVariant:()=>ae,selectVariantByWeight:()=>vi,sortCampaignsByPriority:()=>Et});module.exports=gs(Ba);var Tn=(i=>(i.uninitialized="uninitialized",i.initializing="initializing",i.initialized="initialized",i.error="error",i))(Tn||{});var we=require("react"),yo=me(require("lottie-react"));kt();var ki=require("react");kt();kt();var Si="appstorys_variant_mappings",Do={};function fs(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 Ci(){if(typeof window>"u")return{};try{let t=localStorage.getItem(Si);if(t)return JSON.parse(t)}catch{}return{}}function ms(t,e){if(!(!t||!e)){Do[t]=e;try{let o=W.getState(),n=o.variantMappings||{};n[t]!==e&&o.setVariantMappings({...n,[t]:e})}catch{}if(typeof window<"u")try{let o=Ci();o[t]=e,localStorage.setItem(Si,JSON.stringify(o))}catch{}}}var zn=t=>{if(!t)return;if(Do[t])return Do[t];let e=W.getState().variantMappings?.[t];if(e)return Do[t]=e,e;let o=Ci();if(o[t]){Do[t]=o[t];try{W.getState().setVariantMappings({...W.getState().variantMappings||{},[t]:o[t]})}catch{}return o[t]}};function $o(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 vi(t,e){let o=Object.keys(t);if(o.length===0)return;let n=o.filter(d=>t[d]&&t[d].isActive!==!1),i=n.length>0?n:o,s=i.reduce((d,c)=>d+(Number(t[c]?.weight)||0),0);if(s>0){let d=W.getState().userId||"default",c=`${e||"campaign"}_${d}`,y=fs(c)%1e4/1e4*s;for(let u of i){let m=Number(t[u]?.weight)||0;if(y<m)return u;y-=m}}return i[0]}function ae(t){if(!t||!$o(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=zn(e.id||"");if((!n||!o[n])&&(n=vi(o,e.id),e.id&&n&&ms(e.id,n)),!n||!o[n])return t;let i=o[n],d={...e.details&&typeof e.details=="object"?Object.fromEntries(Object.entries(e.details).filter(([c])=>c!=="variants")):{},...i};return{...t,details:d,_variantId:n}}function ys(t){if(t){if("_variantId"in t)return t._variantId;if($o(t))return zn(t.id||"")}}te();kt();function Vt(t,e){return t?t.isTesting===!0||Array.isArray(t.testUsers)&&t.testUsers.length>0?!e||typeof e!="string"||e.trim()===""?!1:(Array.isArray(t.testUsers)?t.testUsers:[]).includes(e):!0:!1}function Rt(t){return!t||(typeof t=="object"&&(t=t.url||t.value||t.key||t.link||""),typeof t!="string")?!1:t.trim().toUpperCase()==="APPSTORYS-CLOSE"}function Gt(t){if(!t||Rt(t))return!1;let e=W.getState(),o=e.allCampaigns||[],n=e.campaigns||[],i=String(t).trim(),s=o.find(l=>{if(!l)return!1;let y=String(l.id||"").trim(),u=l.details||{},m=String(u.campaign||u.id||"").trim();return!!(y&&y===i||m&&m===i||y&&i.includes(y)||m&&i.includes(m))});if(!s)return!1;let d={...s};delete d.trigger_event,delete d.trigger,d.display_trigger=!0;let c=n.findIndex(l=>String(l.id||"")===String(d.id||""));if(c===-1)e.saveCampaigns([d,...n]);else{let l=n[c];if(!!(l.trigger_event??l.trigger)){let u=[...n];u[c]=d,e.saveCampaigns(u)}}return!0}var en="__back_press_triggered__";function wi(t){return(t||"").trim().toLowerCase()}function hs(t,e){let o=wi(t),n=wi(e);return!o||o===n}function bs(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 xs(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:bs(String(s),i.operator,i.value)}))}function Ss(t,e,o){let n=t,i=n.trigger_event??n.trigger,s=t.id;return!i}function Bn(){let{campaigns:t,trackedEvents:e,trackedEventMetadata:o,currentScreen:n}=W.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:d,event_config:c}=s;if(!(c??[]).some(u=>u.back_press===!0)||e.includes(en)||!e.includes(d))return!1;let l=(c??[]).filter(u=>u.back_press==null);if(l.length===0)return!0;let y=o[d]||[];return xs(l,y)})}function An(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 d=typeof i?.order=="number"?i.order:0,c=typeof s?.order=="number"?s.order:0;return d-c});return{...o,slides:n}}):[]}function _t(t,e){let o=W(y=>y.currentScreen),n=W(y=>y.campaigns),i=W(y=>y.allCampaigns),s=W(y=>y.userId),d=W(y=>y.trackedEvents),c=W(y=>y.trackedEventMetadata),l=W(y=>y.variantMappings);return(0,ki.useMemo)(()=>{let y=P=>{let g=P.filter(R=>{if(!Vt(R,s))return!1;let C=R.campaign_type;if(!(t==="TTP"||t==="TLTP"?C==="TTP"||C==="TLTP":C===t)||e?.position&&R.position!==e.position||!Ss(R,d,c))return!1;if(e?.screenContains){let T=(e.screenContains||"").trim().toLowerCase();return(R.screen||"").trim().toLowerCase().includes(T)}return hs(R.screen,o)});return g.length===0?void 0:Et(g)[0]},m=(n&&n.length>0?y(n):void 0)??y(i||[]);if(!m)return;let f=ae(m);return f&&f.details&&Array.isArray(f.details)&&(f.details=An(f.details)),f},[n,i,s,d,c,l,t,e,o])}kt();on();mo();kt();nn();var Ti="appstorys_offline_queue";async function Fi(){let t=await Bt.getItem(Ti);return t?JSON.parse(t):[]}async function Ii(t){await Bt.setItem(Ti,JSON.stringify(t))}function Cs(t){return Math.min(3e4*Math.pow(2,t),12e4)}function vs(t){let o=t.retryCount||0,n=t.lastAttempt||0,i=Cs(o);return o<3&&Date.now()-n>=i}async function ws(){let t=W.getState();return!t.accountId||!t.appId?!1:await De(t.accountId,t.appId,t.userId)}async function zi(t,e){if(await ws()){let n=await Bt.getItem("access_token");n&&(t.headers={...t.headers,Authorization:`Bearer ${n}`}),t.authRetried=!0,t.lastAttempt=Date.now(),e(t)}}async function sn(t,e){let o=(t.retryCount||0)+1;o<=3&&(t.retryCount=o,t.lastAttempt=Date.now(),e(t))}async function rn(t){let e=await Fi();e.push(t),await Ii(e)}async function ks(){let t=await Fi();if(t.length===0)return;let e=[];for(let o of t){if(!vs(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 zi(o,i=>e.push(i)):n.status>=500&&await sn(o,i=>e.push(i))}catch{await sn(o,i=>e.push(i))}}await Ii(e)}async function an(t){if(!navigator.onLine){await rn(t);return}await ks();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 zi(t,rn):e.status>=500&&await sn(t,rn)),e}catch{await sn(t,rn);return}}async function at(t,e,o){try{if(!t)return;let n=await Mt(),i=W.getState(),s=["viewed","clicked","csat captured","survey captured","shared"];if(!s.includes(t)){let y=i.trackedEvents;if(!y.includes(t))i.setTrackedEvents([...y,t]);else{let u=y.filter(m=>m!==t);u.push(t),i.setTrackedEvents(u)}if(o&&Object.keys(o).length>0){let u=i.trackedEventMetadata||{},m=u[t]||[];i.setTrackedEventMetadata({...u,[t]:[...m,o]})}}let d={...o||{}};if(!s.includes(t)){let y=await io();d={...d,...y}}if(e&&String(e).trim()!==""){let y=o?.variant_id||xi(e);y&&(d.variant_id=y)}let c={user_id:ve(),event:t,metadata:d};e&&(c.campaign_id=e);let l=i.trackingUrl||"https://tracking.appstorys.co";n&&await an({url:`${l}/capture-event`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:c})}catch(n){console.error("Error in trackEvent",n)}}var ro=require("react/jsx-runtime"),Rs=({config:t,onPress:e,style:o,ignoreSizeAndMargin:n=!1})=>{if(!t||!t.enabled)return null;let i=t.size,s=t.margin,d=t.color,c=t.image,l=t.selectedStyle,y=i!=null&&i>=0?i:18,u=n?40:y,m=s?.top!==void 0&&s?.top!==null&&s.top>=0?s.top:0,f=s?.bottom!==void 0&&s?.bottom!==null&&s.bottom>=0?s.bottom:0,P=s?.left!==void 0&&s?.left!==null&&s.left>=0?s.left:0,g=s?.right!==void 0&&s?.right!==null&&s.right>=0?s.right:0,b={marginTop:n?0:m,marginBottom:n?0:f,marginLeft:n?0:P,marginRight:n?0:g,width:u,height:u,backgroundColor:d?.fill||"transparent",borderColor:d?.stroke||"transparent",borderWidth:u*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:d?.stroke?"solid":"none",...o},R=()=>{let C=d?.cross||"#ffffff";return(0,ro.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,ro.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:C,strokeWidth:"2.2",strokeLinecap:"round"}),(0,ro.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:C,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,ro.jsx)("button",{type:"button","data-control-button":"true",onMouseDown:C=>C.stopPropagation(),onClick:C=>{C.stopPropagation(),C.preventDefault(),e(C)},style:b,children:c&&c.trim()!==""?(0,ro.jsx)("img",{src:c,style:{width:u,height:u,objectFit:"contain"},alt:"close"}):R()})},Qt=Rs;te();var so=require("react/jsx-runtime"),Bi=yo.default?.default??yo.default??yo.Lottie??yo,Ai=()=>{let t=_t("BAN"),e=W(z=>z.isVisible),[o,n]=(0,we.useState)(!1),[i,s]=(0,we.useState)(null),[d,c]=(0,we.useState)(null),l=(0,we.useRef)(null),[y,u]=(0,we.useState)(0),m=(0,we.useRef)(null);if((0,we.useEffect)(()=>{t?.id&&m.current!==t.id&&(m.current=t.id,n(!1),at("viewed",t.id),t.details?.lottie_data&&fetch(t.details.lottie_data).then(z=>z.json()).then(z=>{s(z),z.w&&z.h&&c(z.h/z.w)}).catch(z=>console.error("Error loading Lottie:",z)))},[t?.id]),(0,we.useEffect)(()=>{let z=()=>{l.current&&u(l.current.offsetWidth)};return z(),window.addEventListener("resize",z),()=>window.removeEventListener("resize",z)},[t,o]),!t||o||!e)return null;let{details:f}=t,P=f.styling||{},g=f.height||"auto";d&&y&&(g=y*d);let b=parseFloat(String(f.height)),R=parseFloat(String(f.originalWidth??f.styling?.originalWidth)),C=parseFloat(String(f.originalHeight??f.styling?.originalHeight)),h=Number.isFinite(b)&&b>0&&Number.isFinite(R)&&R>0&&Number.isFinite(C)&&C>0?b*(R/C):null,T=h!==null?`${h}px`:void 0,E=typeof g=="number"?`${g}px`:g||void 0,K=Number(P.marginRight),I=Number(P.marginBottom),S={position:"fixed",right:Number.isFinite(K)?`${K}px`:"0px",bottom:Number.isFinite(I)?`${I}px`:"0px",zIndex:Pt(t,"BAN"),display:"block",cursor:f.link?"pointer":"default"},M={position:"relative",width:T||"100%",height:E||"auto",backgroundColor:"transparent",borderRadius:`${P.topRightRadius||0}px ${P.topLeftRadius||0}px ${P.bottomRightRadius||0}px ${P.bottomLeftRadius||0}px`,overflow:"hidden"},x={width:"100%",height:"100%",display:"block",objectFit:"contain"},N=z=>{z.stopPropagation(),n(!0),at("banner_closed",t.id)};return(0,so.jsx)("div",{ref:l,style:S,onClick:()=>{if(f.link){if(at("clicked",t.id),Rt(f.link)){n(!0),at("banner_closed",t.id);return}if(f.link.startsWith("http"))window.open(f.link,"_blank");else{try{if(Gt(f.link))return}catch(z){console.warn("revealCampaignFromLink error",z)}console.log("Internal link:",f.link)}}},children:(0,so.jsxs)("div",{style:M,children:[i?(()=>{let z=Bi.default||Bi;return(0,so.jsx)(z,{animationData:i,loop:!0,autoplay:e,style:x})})():f.image?(0,so.jsx)("img",{src:f.image,alt:"Campaign Banner",style:x}):null,P.crossButton?.enabled&&(0,so.jsx)(Qt,{config:P.crossButton,onPress:N,style:{top:P.crossButton?.margin?.top!==void 0?0:5,right:P.crossButton?.margin?.right!==void 0?0:5}})]})})};var Wt=require("react");kt();function dn(t){let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")}function Li(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 Ei(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 ln=new Map;async function Ts(t,e){try{Ei(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 Ln={async load(t){if(!t||!dn(t))return;let e=ln.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:Li(t),listeners:[]};ln.set(t,n);let i=new Promise(s=>n.listeners.push(s));return Ts(t,n),i},ensure(t){if(!t||!dn(t))return;let e=Li(t);return Ei(e,t),Ln.load(t),e},getSync(t){if(!t)return;let e=ln.get(t);return e?.status==="loaded"?e.name:void 0},_clearCache(){ln.clear()}};function gt(t,e){if(!t)return e;let o=String(t).trim();if(!o)return e;if(dn(o)){let n=Ln.ensure(o);return n?`"${n}", ${e||"sans-serif"}`:e}return o.includes(",")||o.includes('"')||o.includes("'")?o:`"${o}", ${e||"sans-serif"}`}function Fs(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,d]of Object.entries(i))s==="fontFamily"&&typeof d=="string"&&dn(d)&&e.add(d),n(d)}}};return n(t),Array.from(e)}async function Pi(t){let e=new Set;for(let o of t)Fs(o).forEach(n=>e.add(n));await Promise.all(Array.from(e).map(o=>Ln.load(o)))}var be=require("react/jsx-runtime"),$e=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:n,style:i,type:s})=>{if(!t||!n)return null;let{size:d=18,margin:c,color:l,image:y,selectedStyle:u}=t,m=o?40:d,f=o?0:c?.top??0,P=o?0:c?.bottom??0,g=o?0:c?.left??0,b=o?0:c?.right??0,R={marginTop:f,marginBottom:P,marginLeft:g,marginRight:b,width:m,height:m,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||"transparent",borderWidth:m*.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},C=()=>{let h=l?.cross||"#ffffff";return s==="mute"?(0,be.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,be.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,be.jsx)("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"}),(0,be.jsx)("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"})]}):(0,be.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,be.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,be.jsx)("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"}),(0,be.jsx)("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:h,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,be.jsx)("button",{type:"button","data-control-button":"true",onMouseDown:h=>h.stopPropagation(),onClick:h=>{h.stopPropagation(),h.preventDefault(),e(h)},style:{...R,border:R.borderColor?`${R.borderWidth}px solid ${R.borderColor}`:"none",padding:0,cursor:"pointer",outline:"none"},children:y&&y.trim()!==""?(0,be.jsx)("img",{src:y,style:{width:m,height:m,objectFit:"contain"},alt:s}):C()})};var ce=require("react/jsx-runtime"),Mi=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:n,style:i,type:s})=>{if(!t||!n)return null;let{size:d=18,margin:c,color:l,image:y,selectedStyle:u}=t,m=o?40:d,f={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:m,height:m,backgroundColor:l?.fill||"transparent",borderColor:l?.stroke||l?.cross||"#ffffff",borderWidth:l?.stroke?Math.max(1,m*.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},P=()=>{let g=l?.cross||"#ffffff";return s==="maximise"?(0,ce.jsxs)("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%","aria-hidden":!0,children:[(0,ce.jsx)("polyline",{points:"15,5 19,5 19,9",fill:"none",stroke:g,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ce.jsx)("line",{x1:"19",y1:"5",x2:"14",y2:"10",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"}),(0,ce.jsx)("polyline",{points:"9,19 5,19 5,15",fill:"none",stroke:g,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ce.jsx)("line",{x1:"5",y1:"19",x2:"10",y2:"14",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"})]}):(0,ce.jsxs)("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%","aria-hidden":!0,children:[(0,ce.jsx)("polyline",{points:"14,6 14,10 18,10",fill:"none",stroke:g,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ce.jsx)("line",{x1:"14",y1:"10",x2:"19",y2:"5",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"}),(0,ce.jsx)("polyline",{points:"6,14 10,14 10,18",fill:"none",stroke:g,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ce.jsx)("line",{x1:"10",y1:"14",x2:"5",y2:"19",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,ce.jsx)("button",{type:"button","data-control-button":"true",onMouseDown:g=>g.stopPropagation(),onClick:g=>{g.stopPropagation(),g.preventDefault(),e(g)},style:f,children:y&&y.trim()!==""?(0,ce.jsx)("img",{src:y,style:{width:m,height:m,objectFit:"contain"},alt:s}):P()})};var ho=require("react/jsx-runtime"),Is=({styling:t,mode:e,muted:o,expanded:n,onClose:i,onToggleMute:s,onToggleExpand:d,containerStyle:c})=>{if(!t)return null;let l=e==="LARGE",y={position:"absolute",pointerEvents:"auto",...l?{top:15,right:15}:{top:0,right:0}},u={position:"absolute",pointerEvents:"auto",...l?{top:15,right:60}:{top:0,left:0}},m={position:"absolute",pointerEvents:"auto",...l?{top:15,left:15}:{bottom:0,right:0}},f=o?t.soundToggle?.unmute:t.soundToggle?.mute,P=n?t.expandControls?.minimise:t.expandControls?.maximise;return(0,ho.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,ho.jsx)(Qt,{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:l,style:y}),t.soundToggle?.enabled&&f&&(0,ho.jsx)($e,{config:f,onPress:s,ignoreSizeAndMargin:l,style:u,enabled:t.soundToggle?.enabled,type:o?"unmute":"mute"}),t.expandControls?.enabled&&P&&(0,ho.jsx)(Mi,{config:P,onPress:d,ignoreSizeAndMargin:l,style:m,enabled:t.expandControls?.enabled,type:n?"minimise":"maximise"})]})},_i=Is;te();var bo=require("react/jsx-runtime"),En=t=>(t||"").trim().toLowerCase(),cn=(t,e)=>{let o=Number(t);return Number.isFinite(o)?o:e},Wi=20,Di=20,$i=20,Ni=(t,e,o)=>{let n=window.innerWidth,i=window.innerHeight,s=Wi,d=Math.max(s,n-o.width-Wi),c=o.topInset,l=Math.max(c,i-o.height-o.bottomInset);return{x:Math.min(Math.max(t,s),d),y:Math.min(Math.max(e,c),l)}},zs=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"},Oi=()=>{let t=_t("PIP"),e=W(J=>J.campaigns),o=W(J=>J.allCampaigns),n=W(J=>J.currentScreen),i=W(J=>J.userId),s=W(J=>J.isVisible),[d,c]=(0,Wt.useState)(!1),[l,y]=(0,Wt.useState)(!1),[u,m]=(0,Wt.useState)(!0),[f,P]=(0,Wt.useState)(!1),[g,b]=(0,Wt.useState)(null),R=(0,Wt.useRef)({x:0,y:0}),C=(0,Wt.useRef)({width:150,height:300,topInset:Di,bottomInset:$i}),h=(0,Wt.useRef)(null),T=(0,Wt.useRef)({x:0,y:0}),E=(0,Wt.useRef)(!1),K=(0,Wt.useMemo)(()=>{if(t)return t;let J=En(n),xt=($=>$.filter(_=>{let D=_,L=D.campaign_type==="PIP",G=!En(D.screen)||En(D.screen)===J,nt=!!(D.trigger_event??D.trigger),yt=D.display_trigger!==!1&&!nt;return L&&G&&yt&&Vt(D,i)}))(e&&e.length>0?e:o||[]);if(xt.length===0)return;let ht=Et(xt)[0];return ht?ae(ht):void 0},[t,e,o,i,n]),I=(0,Wt.useMemo)(()=>K,[K?.id,K?.details?.id]);if((0,Wt.useEffect)(()=>{if(!I)return;let J=I.details||{},ct=J?.styling?.soundToggle?.defaultSound||J?.styling?.appearance?.defaultSound||"yes";m(String(ct).toLowerCase()!=="yes"),c(!1),y(!1),b(null),at("viewed",I.id)},[I]),(0,Wt.useEffect)(()=>{let J=h.current;if(!J)return;J.muted=u;let ct=J.play();ct&&typeof ct.catch=="function"&&ct.catch(()=>{u||(J.muted=!0,m(!0))})},[u]),(0,Wt.useEffect)(()=>{if(!l)return;let J=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=J}},[l]),(0,Wt.useEffect)(()=>{if(!f)return;let J=xt=>{let pt=xt.clientX-T.current.x,ht=xt.clientY-T.current.y;(Math.abs(pt)>4||Math.abs(ht)>4)&&(E.current=!0);let $=xt.clientX-R.current.x,_=xt.clientY-R.current.y;b(Ni($,_,C.current))},ct=()=>{P(!1)};return window.addEventListener("pointermove",J),window.addEventListener("pointerup",ct),window.addEventListener("pointercancel",ct),()=>{window.removeEventListener("pointermove",J),window.removeEventListener("pointerup",ct),window.removeEventListener("pointercancel",ct)}},[f]),(0,Wt.useEffect)(()=>{let J=()=>{b(ct=>ct&&Ni(ct.x,ct.y,C.current))};return window.addEventListener("resize",J),window.addEventListener("orientationchange",J),()=>{window.removeEventListener("resize",J),window.removeEventListener("orientationchange",J)}},[]),!I||!I.details||d||!s)return null;let S=I.details,M=S.styling||{},x=M.appearance||{},N=cn(S.width??x.pipWidth,150),H=cn(S.height??x.pipHeight,300),z=N,O=H,B=M.cta?.container||{},Z=M.cta?.text||{},v=M.cta?.cornerRadius,A=M.cta?.margin||{},V=!!(S.button_text&&S.button_text.trim().length>0),rt=cn(M.pipBottomPadding,20),lt=cn(M.pipTopPadding,0);C.current={width:z,height:O,topInset:Di+lt,bottomInset:$i+rt};let a=l?S.large_video||S.small_video:S.small_video||S.large_video,F=(S.position||I.position||"right").toLowerCase(),r=!!M.isMovable,p=M.soundToggle?.enabled!==!1,j=M.crossButton?.enabled!==!1,k=M.expandablePip??S.expandablePip??S.expandable_pip,Q=k!=null&&k!==""?zs(k):M.expandControls?.enabled!==!1,Y={...M,crossButton:{...M.crossButton,enabled:j,image:S.crossButtonImage||M.crossButton?.image},soundToggle:{...M.soundToggle,enabled:p,mute:{...M.soundToggle?.mute,image:S.muteImage||M.soundToggle?.mute?.image},unmute:{...M.soundToggle?.unmute,image:S.unmuteImage||M.soundToggle?.unmute?.image}},expandControls:{...M.expandControls,enabled:Q,maximise:{...M.expandControls?.maximise,image:S.maximiseImage||M.expandControls?.maximise?.image},minimise:{...M.expandControls?.minimise,image:S.minimiseImage||M.expandControls?.minimise?.image}}},st=()=>{y(J=>{let ct=!J;return ct&&I?.id&&(at("viewed",I.id),at("analyze",I.id)),ct})},dt={position:"fixed",zIndex:l?1e5:Pt(I,"PIP"),width:l?"auto":z,height:l?"auto":O,borderRadius:l?0:5,overflow:"hidden",background:"#000",boxShadow:"0 16px 40px rgba(0,0,0,0.35)",cursor:f?"grabbing":r&&!l?"grab":"default",transition:f?"none":"width 180ms ease, height 180ms ease, transform 180ms ease",touchAction:l||r?"none":"auto",WebkitUserSelect:"none",userSelect:"none",WebkitTapHighlightColor:"transparent"};g&&!l?(dt.left=g.x,dt.top=g.y):l?(dt.left=0,dt.top=0,dt.right=0,dt.bottom=0):(F==="left"?dt.left=24:dt.right=24,lt>0?dt.top=lt:dt.bottom=rt+20);let tt=J=>{if(!r||l||J.pointerType==="mouse"&&J.button!==0||J.target.closest("[data-control-button='true']"))return;let xt=J.currentTarget.getBoundingClientRect();R.current={x:J.clientX-xt.left,y:J.clientY-xt.top},T.current={x:J.clientX,y:J.clientY},E.current=!1,b({x:xt.left,y:xt.top}),P(!0)},ft=()=>{if(!S.link)return;at("clicked",I.id);let J=String(S.link).trim();if(Rt(J)){c(!0),at("pip_closed",I.id);return}try{let ct=W.getState(),xt=ct.allCampaigns||[],pt=ct.campaigns||[],ht=xt.find($=>$.id===J);if(console.log("[Pip] clicked link=",J,"allCount=",xt.length,"visibleCount=",pt.length,"referenced=",!!ht),ht){let $={...ht};delete $.trigger_event,delete $.trigger,$.display_trigger=!0;let _=pt.findIndex(D=>D.id===$.id);if(_===-1)ct.saveCampaigns([$,...pt]);else{let D=pt[_];if(!!(D.trigger_event??D.trigger)){let G=[...pt];G[_]=$,ct.saveCampaigns(G)}}return}}catch{}window.open(S.link,"_blank")};return a?(0,bo.jsxs)("div",{style:dt,onPointerDown:tt,children:[(0,bo.jsx)("video",{ref:h,src:a,autoPlay:!0,loop:!0,playsInline:!0,muted:u,style:{width:"100%",height:"100%",objectFit:l?"contain":"cover",cursor:Q&&!l||S.link?"pointer":"default"},onClick:()=>{if(E.current){E.current=!1;return}if(Q){st();return}ft()},onEnded:()=>{K&&at("analyze",K.id)}}),(0,bo.jsx)(_i,{styling:Y,mode:l?"LARGE":"SMALL",muted:!u,expanded:l,onClose:()=>c(!0),onToggleMute:()=>m(J=>!J),onToggleExpand:st,containerStyle:l?{paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:"env(safe-area-inset-left, 0px)",paddingRight:"env(safe-area-inset-right, 0px)"}:void 0}),l&&V&&(0,bo.jsx)("button",{"data-control-button":"true",onClick:ft,style:{position:"absolute",left:A.left??12,right:A.right??12,bottom:`calc(${A.bottom??12}px + env(safe-area-inset-bottom, 0px))`,height:B.height||42,width:B.ctaFullWidth?"auto":B.ctaWidth||"auto",maxWidth:`calc(100% - ${(A.left??12)+(A.right??12)}px)`,margin:B.ctaFullWidth?"0":"0 auto",background:B.backgroundColor||"#F7921C",color:Z.color||"#fff",border:`${B.borderWidth||0}px solid ${B.borderColor||"transparent"}`,borderTopLeftRadius:typeof v=="number"?v:v?.topLeft??10,borderTopRightRadius:typeof v=="number"?v:v?.topRight??10,borderBottomRightRadius:typeof v=="number"?v:v?.bottomRight??10,borderBottomLeftRadius:typeof v=="number"?v:v?.bottomLeft??10,fontSize:Z.fontSize||14,fontFamily:gt(Z.fontFamily),fontWeight:600,cursor:S.link?"pointer":"default"},children:S.button_text})]}):null};var ee=me(require("react")),ji=require("lottie-react");kt();te();var ao=require("react/jsx-runtime"),xe=(t,e=0)=>{let o=Number(t);return Number.isFinite(o)?o:e},Pn=t=>(t||"").trim().toLowerCase(),Bs="appstorysmediabucketdev.s3.ap-south-1.amazonaws.com",As=t=>{try{if(typeof window>"u")return[t];let e=new URL(t);if(e.hostname!==Bs)return[t];let o=!!window.location.port,n=`/appstorys-media${e.pathname}${e.search}`;return o?[n,t]:[t]}catch{return[t]}},Ls=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"},Mn=class extends ee.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}},Es=()=>{let[t,e]=(0,ee.useState)(null),[o,n]=(0,ee.useState)([]),[i,s]=(0,ee.useState)(!1),[d,c]=(0,ee.useState)(!1),[l,y]=(0,ee.useState)(!1),u=(0,ee.useRef)(null),m=(0,ee.useRef)(null),f=_t("FLT"),P=W(v=>v.campaigns),g=W(v=>v.allCampaigns),b=W(v=>v.currentScreen),R=W(v=>v.userId),C=W(v=>v.isVisible),h=(0,ee.useRef)(null),T=f??(()=>{let v=[...P,...g].filter(rt=>{let lt=rt;if(lt.campaign_type!=="FLT"||!Vt(lt,R))return!1;let a=!!(lt.trigger_event??lt.trigger);return lt.display_trigger===!1||a?!1:!Pn(lt.screen)||Pn(lt.screen)===Pn(b)});if(v.length===0)return;let V=Et(v)[0];if(V)try{return ae(V)}catch{return V}})(),E=T?.id,K=W(v=>E?v.variantMappings[E]:void 0);if((0,ee.useEffect)(()=>{if(!T?.id||!C||$o(T)&&!K)return;let A=`${T.id}:${K||""}`;h.current!==A&&(h.current=A,at("viewed",T.id))},[T?.id,K,C]),(0,ee.useEffect)(()=>{let v=T?.details?.lottie_data;if(e(null),n([]),s(!1),c(!1),!v)return;if(Ls(v)){e(v),c(!0);return}if(typeof v!="string"){s(!0);return}let A=As(v);n(A),c(!0)},[T?.details?.lottie_data]),(0,ee.useEffect)(()=>{if(!T?.details?.lottie_data||!u.current)return;let v=ji.LottiePlayer;if(!v||typeof v.loadAnimation!="function"){s(!0),c(!1);return}let A=!1,V=null,rt=()=>{V&&typeof V.destroy=="function"&&V.destroy(),V=null,m.current=null},lt=(a,F)=>{if(A)return;if(F>=a.length){s(!0),c(!1),console.error("[Floater] lottie load failed",{lottieUrls:a});return}rt();let r=v.loadAnimation({container:u.current,renderer:"svg",loop:!0,autoplay:!0,path:a[F]});V=r,m.current=r,r.addEventListener("DOMLoaded",()=>{A||c(!1)}),r.addEventListener("data_failed",()=>{A||lt(a,F+1)})};if(t){rt();let a=v.loadAnimation({container:u.current,renderer:"svg",loop:!0,autoplay:!0,animationData:t});V=a,m.current=a,a.addEventListener("DOMLoaded",()=>{A||c(!1)}),a.addEventListener("data_failed",()=>{A||(s(!0),c(!1))})}else o.length>0&<(o,0);return()=>{A=!0,rt()}},[T?.details?.lottie_data,t,o]),!T||!T.details||!C)return null;let{details:I}=T,S=I.styling||{},x=(typeof I.position=="string"?I.position:typeof T.position=="string"?T.position:"right").toLowerCase()==="left"?"left":"right",N={position:"fixed",left:x==="left"?xe(S.marginLeft,12):void 0,right:x==="left"?void 0:xe(S.marginRight,12),top:xe(S.marginTop,0)>0?xe(S.marginTop,0):void 0,bottom:xe(S.marginTop,0)>0?void 0:xe(S.marginBottom,80),zIndex:Pt(T,"FLT"),display:"flex"},H={width:xe(I.width,60),height:xe(I.height,60),background:"transparent",overflow:"hidden",borderBottomLeftRadius:xe(S.bottomLeftRadius,0),borderBottomRightRadius:xe(S.bottomRightRadius,0),borderTopLeftRadius:xe(S.topLeftRadius,0),borderTopRightRadius:xe(S.topRightRadius,0),display:"flex",alignItems:"center",justifyContent:"center",cursor:I.link?"pointer":"default",boxShadow:"0 8px 18px rgba(0,0,0,0.2)"},z=async()=>{if(!I.link)return;await at("clicked",T.id);let v=String(I.link).trim();if(Rt(v)){y(!0),at("floater_closed",T.id);return}try{let A=W.getState(),V=A.allCampaigns||[],rt=A.campaigns||[],lt=V.find(a=>{if(!a)return!1;let F=String(a.id||"").trim(),r=a.details||{},p=String(r.campaign||r.id||"").trim();return!!(F&&F===v||p&&p===v||F&&v.includes(F)||p&&v.includes(p))});if(console.log("[Floater] clicked link=",v,"allCampaignsCount=",V.length,"visibleCount=",rt.length),console.log("[Floater] all ids=",V.map(a=>a.id).slice(0,50)),console.log("[Floater] referenced found=",!!lt,lt&&(lt.id||lt.details?.campaign||lt.details?.id)),lt){let a={...lt};delete a.trigger_event,delete a.trigger,a.display_trigger=!0;let F=rt.findIndex(r=>r.id===a.id);if(F===-1)console.log("[Floater] revealing campaign (prepended)",a.id),A.saveCampaigns([a,...rt]);else{let r=rt[F];if(!!(r.trigger_event??r.trigger)){let j=[...rt];j[F]=a,console.log("[Floater] replacing existing triggered campaign with revealed one",a.id),A.saveCampaigns(j)}else console.log("[Floater] campaign already visible and not trigger-driven",a.id)}return}}catch(A){console.warn("[Floater] error while resolving referenced campaign",A)}try{window.open(I.link,"_blank")}catch{}},O=!!(I.lottie_data&&!i),B=!!I.image,Z=!!(I.lottie_data&&d&&!t&&!i);return l||!O&&!B&&!Z?null:(0,ao.jsx)("div",{style:N,children:(0,ao.jsx)("div",{style:H,onClick:()=>{z()},children:O?(0,ao.jsx)(Mn,{onError:()=>s(!0),children:(0,ao.jsx)("div",{ref:u,style:{width:"100%",height:"100%",display:"block"}})},String(I.lottie_data)):Z?(0,ao.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,ao.jsx)("img",{src:I.image,alt:"floater",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})})})},qi=Es;kt();te();function Ui(t){return(t||"").trim().toLowerCase()}function _n(t,e){let o=Ui(t.screen),n=Ui(e);return!o||o===n}async function Wn(t){try{let e=W.getState(),o=await Mt(),n=e.accountId,i=ve();if(!o||!n)return;e.setCurrentScreen(t),e.setTrackedEvents([]);let s=e.baseUrl||"https://users.appstorys.co",d=await fetch(`${s}/v2/${n}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({user_id:i,screenName:t})});if(!d.ok)return;let c=await d.json();if(typeof c.screen_capture_enabled<"u"&&e.setScreenCaptureEnabled(!!c.screen_capture_enabled),c.variants&&c.variants.length>0){let T={};c.variants.forEach(E=>{T[E.id]=E.v_id}),e.setVariantMappings(T)}c.personalization_data&&e.setPersonalizationData(c.personalization_data);let l=(e.allCampaigns||[]).filter(T=>Vt(T,i)),y=c.eligibleCampaignList||[],u=l.filter(T=>y.includes(T.id)&&_n(T,t)),m=u.map(T=>T.id),f=y.filter(T=>!m.includes(T)),P=[];if(f.length>0){let T=await fetch(`${s}/load-campaign-data`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(f)});T.ok&&(P=(await T.json()).filter(K=>_n(K,t)&&Vt(K,i)))}let g=[...u,...P],b=l.filter(T=>{let E=!!(T.trigger_event??T.trigger);return _n(T,t)&&T.display_trigger===!0&&!E}),R=[...g],C=new Set(R.map(T=>T.id));for(let T of b)C.has(T.id)||(R.push(T),C.add(T.id));let h=Et(R);e.saveCampaigns(h)}catch(e){console.error("Error when tracking screen:",t,e)}}nn();kt();on();async function Dn(t){try{let e=await Mt(),o=ve(),n=W.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 io();i={...i,...s};let d={user_id:o,attributes:i},c=n.baseUrl||"https://users.appstorys.co";await an({url:`${c}/update-user-atr`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:d})}catch(e){console.error("AppStorys: Error in setUserProperties:",e)}}kt();function Ne(t){if(!t||t.trim()==="")return t;let e=W.getState().personalizationData;if(!e||Object.keys(e).length===0)return Ps(t);let o=/\{\{([^|}\s]+)\s*\|\s*([^}]+)\}\}/g;return t.replace(o,(n,i,s)=>{let d=i.trim(),c=s.trim();return e[d]??c})}function Ps(t){let e=/\{\{[^|}\s]+\s*\|\s*([^}]+)\}\}/g;return t.replace(e,(o,n)=>n.trim())}mo();kt();kt();te();var $n="appstorys_campaigns_cache",Hi="appstorys_campaigns_etag",Nn="appstorys_campaigns_version";async function On(t,e){try{let o=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),n=`https://dev-cdn-campaign-appstorys.s3.ap-south-1.amazonaws.com/clients/${t}/campaigns.json`,i=await Bt.getItem($n),s=await Bt.getItem(Hi),d=await Bt.getItem(Nn),c={Accept:"application/json"};!o&&s&&(c["If-None-Match"]=s);let l=await fetch(n,{method:"GET",headers:c,...o?{cache:"no-store"}:{}});if(l.status===304)return{campaigns:i?Et(JSON.parse(i)):[],version:d?parseInt(d):1};let y=l.headers.get("ETag"),u=await l.json(),m=2,f=u,P=e;if(!P)try{let g=await Mt(),b=ve(),R=W.getState().baseUrl||"https://users.appstorys.co",C=await fetch(`${R}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...g?{Authorization:`Bearer ${g}`}:{}},body:JSON.stringify({user_id:b,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(C.ok){let h=await C.json();console.info("AppStorys: fetchAllCampaigns track-user-res returned",h);let T=h?.screenName||h?.screen||h?.currentScreen||h?.screen_name||h?.current_screen;T&&(P=T);try{let E=W.getState();typeof h.screen_capture_enabled<"u"&&E.setScreenCaptureEnabled(!!h.screen_capture_enabled)}catch{}}}catch(g){console.warn("Could not fetch screen name from track-user-res:",g)}if(u.length>0&&u[0].version!==void 0&&(m=u[0].version,f=u.slice(1)),!f||f.length===0)try{let g=await Mt(),b=ve(),R=W.getState().baseUrl||"https://users.appstorys.co",C=await fetch(`${R}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...g?{Authorization:`Bearer ${g}`}:{}},body:JSON.stringify({user_id:b,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(C.ok){let h=await C.json(),T=h?.user_id||h?.id||h?.userId||b;try{let E=W.getState();typeof h.screen_capture_enabled<"u"&&E.setScreenCaptureEnabled(!!h.screen_capture_enabled)}catch{}if(T){let E=`${R}/load-campaign-data`,K=await fetch(E,{method:"POST",headers:{"Content-Type":"application/json",...g?{Authorization:`Bearer ${g}`}:{}},body:JSON.stringify({user_id:T})});if(K.ok){let I=await K.json();console.log(`Fetched ${I.length} missing campaigns from fallback`),console.log("Fallback campaigns:",JSON.stringify(I,null,2)),I&&I.length>0&&(f=I)}else console.error("Failed to fetch missing campaigns:",await K.text())}}}catch(g){console.error("Error fetching missing campaigns via fallback:",g)}if(e&&f&&f.length>0){let g=R=>(R||"").trim().toLowerCase(),b=g(e);f=f.filter(R=>!g(R.screen)||g(R.screen)===b)}return f=Et(f),await Bt.setItem($n,JSON.stringify(f)),await Bt.setItem(Nn,m.toString()),y&&await Bt.setItem(Hi,y),{campaigns:f,version:m}}catch(o){console.error("Error fetching campaigns:",o);let n=await Bt.getItem($n),i=await Bt.getItem(Nn);return{campaigns:n?JSON.parse(n):[],version:i?parseInt(i):1}}}kt();kt();kt();async function un(t,e){try{let o=await Mt(),n=W.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",d=await fetch(`${s}/reconcile-anonymous-user`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(i)});if(d.ok)return!0;{let c=await d.text();return console.error("AppStorys: Failed to reconcile anonymous user:",d.status,c),!1}}catch(o){return console.error("AppStorys: Error in reconcileAnonymousUser:",o),!1}}kt();var jn=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&&Bn()&&this.triggerCampaign()};handlePopState=()=>{Bn()&&(window.history.pushState("appstorys_navigation",""),this.triggerCampaign())};triggerCampaign(){let e=W.getState(),{trackedEvents:o}=e;o.includes(en)||(console.log("AppStorys: Exit Intent triggered. Displaying campaign."),e.setTrackedEvents([...o,en]))}},Vi=new jn;kt();var qn=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=W.getState();o.isVisible!==e&&(console.log(`AppStorys: SDK visibility changed to ${e?"visible":"hidden"}`),o.setVisibility(e))}},Un=new qn;mo();var pn="anonymous_user_id";async function Yi(){let t=Date.now(),e=navigator.userAgent.split(" ")[0].replace(/[^a-zA-Z0-9]/g,"_");return`${t}_${e}`}async function Gi(){try{let t=await Bt.getItem(pn);if(t)return t;let e=await Yi();return await Bt.setItem(pn,e),e}catch(t){return console.error("Error managing anonymous user ID:",t),await Yi()}}async function Hn(){try{await Bt.removeItem(pn)}catch(t){console.error("Error clearing anonymous user ID:",t)}}async function Vn(){try{return await Bt.getItem(pn)}catch(t){return console.error("Error getting stored anonymous user ID:",t),null}}function Ms(){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,12 +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 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:`
|
|
33
|
+
`,document.head.appendChild(t)}function Qi(t){let e=document.createElement("div");return e.className="appstorys-widget-debug-pill",e.textContent=t,e}function _s(t){let e=t,o=getComputedStyle(e);(o.position==="static"||!o.position)&&(e.style.position="relative")}window.AppStorysShowWidgetElements=function(){try{Ms();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=Qi("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;_s(i),i.classList.add("appstorys-widget-debug-overlay");let s=i.querySelector(".appstorys-widget-debug-pill");s&&s.remove();let d=Qi("Widget "+(n+1));i.appendChild(d)})}catch(e){console.error("AppStorysShowWidgetElements error",e)}};var Ue=me(require("react"));kt();var No=require("react"),xo=me(require("lottie-react")),Yn=require("react/jsx-runtime"),Ji=xo.default?.default??xo.default??xo.Lottie??xo,Ae=({src:t,alt:e,style:o,size:n})=>{let[i,s]=(0,No.useState)(null),[d,c]=(0,No.useState)(!1);(0,No.useEffect)(()=>{t&&t.toLowerCase().endsWith(".json")?fetch(t).then(m=>{if(!m.ok)throw new Error("Failed to fetch Lottie");return m.json()}).then(m=>{s(m),c(!1)}).catch(m=>{console.error("AppStorys: Error loading Lottie thumbnail:",m),c(!0)}):(s(null),c(!1))},[t]);let l={width:n?`${n}px`:o?.width||"100%",height:n?`${n}px`:o?.height||"100%",objectFit:"contain",display:"block",...o},y=o?.objectFit||"contain",u=y==="contain"?"xMidYMid meet":y==="fill"?"none":"xMidYMid slice";if(i&&!d){let m=Ji.default||Ji;return(0,Yn.jsx)(m,{animationData:i,loop:!0,autoplay:!0,style:l,rendererSettings:{preserveAspectRatio:u}})}return(0,Yn.jsx)("img",{src:t,alt:e||"story thumbnail",style:l,onError:()=>c(!0)})};var So=require("react/jsx-runtime"),Xi=({story:t,isViewed:e,onClick:o})=>{let n=t.styling||{},i=n.size||80,s=n.ringWidth!==void 0?n.ringWidth:3,d=n.ringAndImageSpace!==void 0?n.ringAndImageSpace:3,c=e?"#E5E7EB":t.ringColor||"#FF0000",l=t.nameColor||"#333333",y=n.storyGroupText||t.name,u=n.cornerRadius,m=u?`${u.topLeft||0}px ${u.topRight||0}px ${u.bottomRight||0}px ${u.bottomLeft||0}px`:"50%",f=u?`${Math.max(0,(u.topLeft||0)-s)}px ${Math.max(0,(u.topRight||0)-s)}px ${Math.max(0,(u.bottomRight||0)-s)}px ${Math.max(0,(u.bottomLeft||0)-s)}px`:"50%",g=gt(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",b=n.name?.font==="Bold"||n.name?.font==="bold"||n.name?.font?.toLowerCase()?.includes("bold");return(0,So.jsxs)("div",{onClick:o,style:{display:"flex",flexDirection:"column",alignItems:"center",cursor:"pointer",flexShrink:0},children:[(0,So.jsx)("div",{style:{width:`${i}px`,height:`${i}px`,borderRadius:m,border:`${s}px solid ${c}`,padding:`${d}px`,boxSizing:"border-box",transition:"transform 0.1s ease",overflow:"hidden",backgroundColor:"#f5f5f5"},children:(0,So.jsx)(Ae,{src:t.thumbnail,alt:y,style:{borderRadius:f}})}),(0,So.jsx)("span",{style:{marginTop:"6px",fontSize:`${n.name?.size||12}px`,fontFamily:g,fontWeight:b?"bold":"normal",color:l,maxWidth:`${i+20}px`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textAlign:"center"},children:y})]})};var Gn=require("react/jsx-runtime"),Ki=({stories:t,viewedStories:e,onStoryClick:o})=>(0,Gn.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,Gn.jsx)(Xi,{story:n,isViewed:e.includes(n.id),onClick:()=>o(i)},n.id))});var bt=me(require("react"));kt();kt();var Zi=()=>W.getState().trackingUrl||"https://tracking.appstorys.co";var Qe=me(require("react")),vo=me(require("lottie-react"));var gn=(t,e)=>{if(!t||e===void 0||e===null||e==="")return t;let o=Number(e);if(isNaN(o))return t;let n=o>1?Math.min(Math.max(o/100,0),1):Math.min(Math.max(o,0),1),i=t.trim();if(i.startsWith("#")){let d=i.slice(1);if(d.length===3&&(d=d.split("").map(c=>c+c).join("")),d.length===6||d.length===8){let c=parseInt(d.slice(0,2),16),l=parseInt(d.slice(2,4),16),y=parseInt(d.slice(4,6),16);if(!isNaN(c)&&!isNaN(l)&&!isNaN(y))return`rgba(${c}, ${l}, ${y}, ${n})`}}let s=i.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);return s?`rgba(${s[1]}, ${s[2]}, ${s[3]}, ${n})`:t},ot=t=>{if(t){if(typeof t=="string")return t;if(typeof t=="object"){let e,o=t.opacity;if(typeof t.color=="string")e=t.color;else if(typeof t.color=="object"&&t.color){let n=ot(t.color);n&&(e=n),o===void 0&&t.color.opacity!==void 0&&(o=t.color.opacity)}else typeof t.solid=="string"&&t.solid?e=t.solid:typeof t.value=="string"&&t.value?e=t.value:typeof t.hex=="string"&&t.hex&&(e=t.hex);if(e)return gn(e,o)}}},wt=t=>{if(!t)return;if(typeof t=="string")return t;if(typeof t=="object"){let o=t.opacity;if(typeof t.solid=="string"&&t.solid)return gn(t.solid,o);if(typeof t.value=="string"&&t.value)return gn(t.value,o);if(typeof t.color=="string"&&t.color)return gn(t.color,o)}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 u=s.map(m=>{let f=m.offset,P="0%";if(f!=null){let b=String(f).trim();if(b.endsWith("%"))P=b;else{let R=Number(b);isNaN(R)||(P=R>1?`${R}%`:`${Math.round(R*100)}%`)}}return`${ot(m.color)||m.color} ${P}`}).join(", ");return`linear-gradient(${c}, ${u})`}let l=ot(n)||n,y=ot(i)||i;return`linear-gradient(${c}, ${l}, ${y})`}return ot(t)},Oo=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`},it=(t,e="px")=>{if(t==null||t==="")return"";let o=String(t).trim();return/^[\d.-]+$/.test(o)?`${o}${e}`:o},Co=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 tr=me(require("react"));var Le=require("react/jsx-runtime"),er=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=tr.default.useState(()=>{try{return localStorage.getItem(`appstorys_poll_${t.id}`)}catch{return null}}),s=t.layout?.type==="horizontal",d={headerTextColor:"#000000",optionBgColor:"#1A1A1A",optionTextColor:"#FFFFFF",backgroundColor:"#FFFFFF",borderRadius:20,padding:12},c=t.styling||{},l=gt(c.questionFontFamily||c.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),y=gt(c.optionFontFamily||c.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),u=c.optionBorderRadius??c.optionRadius,m=u!==void 0?it(u):"9999px",f=c.optionBgColor||"#1A1A1A",P={backgroundColor:c.backgroundColor||d.backgroundColor,borderRadius:it(c.borderRadius??d.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"},g={color:c.headerTextColor||d.headerTextColor,textAlign:"center",fontWeight:"700",fontSize:it(c.fontSize||14),lineHeight:"1.25",margin:"0",width:"100%",fontFamily:l},b={display:"flex",flexDirection:s?"row":"column",gap:s?n?"0px":"4px":it(c.gap??8),width:"100%",backgroundColor:s?f:"transparent",borderRadius:s?it(m):"0px",overflow:s?"hidden":"visible",padding:"0px"},C=c.optionTextAlign||c.optionFont?.textAlign||c.options?.font?.textAlign||c.options?.textAlign||"center",h=x=>{switch(x){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},T={backgroundColor:s?"transparent":f,color:c.optionTextColor||d.optionTextColor,padding:s?"8px 12px":"10px 16px",fontSize:it(c.optionFontSize||14),fontWeight:"700",fontFamily:y,cursor:n?"default":"pointer",border:"none",borderRadius:s?"0px":it(m),width:"100%",textAlign:C||"center",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:h(C),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"},E=Array.isArray(t.options)?t.options:[],K=x=>{let N=E.find(H=>H.id===x);if(!N)return 0;if(N.percentage!==void 0)return N.percentage;if(N.votes!==void 0){let H=E.reduce((z,O)=>z+(O.votes||0),0);if(H>0)return Math.round(N.votes/H*100)}return n?x===n?E.length===1?100:60:Math.round(40/(E.length-1)):0},I=(x,N)=>{let H=x.replace("#","");H.length===3&&(H=H.split("").map(Z=>Z+Z).join(""));let z=parseInt(H.substring(0,2),16)||0,O=parseInt(H.substring(2,4),16)||0,B=parseInt(H.substring(4,6),16)||0;return`rgba(${z}, ${O}, ${B}, ${N})`},S=x=>{let N=x===n,H=N?c.activeResultBarColor:c.inactiveResultBarColor,z=H?.color||(N?"#F97316":"#404040"),O=H?.opacity!==void 0?H.opacity/100:1;return z.startsWith("#")&&(z.length===7||z.length===4)?I(z,O):z},M=x=>{if(!(o||n)){i(x);try{localStorage.setItem(`appstorys_poll_${t.id}`,x)}catch{}e?.({type:"poll",pollId:t.id,optionId:x,stickerId:t.id})}};return(0,Le.jsxs)("div",{style:P,children:[(0,Le.jsx)("h3",{style:g,children:t.question||"Ask A Question..."}),(0,Le.jsx)("div",{style:b,children:E.map((x,N)=>{let H=K(x.id),z=n!==null,O=x.id===n,B=z?s?S(x.id):f:s?"transparent":f;return(0,Le.jsxs)("button",{style:{...T,flex:z&&s?H:s?1:void 0,backgroundColor:B,borderRight:z||s&&N===E.length-1?"none":T.borderRight},onClick:()=>M(x.id),disabled:z,onMouseOver:Z=>{!o&&!z&&!s&&(Z.currentTarget.style.opacity="0.9")},onMouseOut:Z=>{!o&&!z&&!s&&(Z.currentTarget.style.opacity="1")},children:[z&&!s&&(0,Le.jsx)("div",{style:{position:"absolute",top:0,left:0,bottom:0,width:`${H}%`,backgroundColor:S(x.id),transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)",zIndex:1,borderRadius:"inherit"}}),(0,Le.jsxs)("div",{style:{display:"flex",flexDirection:s?"column":"row",justifyContent:s?"center":z?"space-between":h(C),alignItems:"center",width:"100%",zIndex:2,position:"relative"},children:[(0,Le.jsx)("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:C||"center",flex:s||!z?1:void 0},children:x.text}),z&&(0,Le.jsxs)("span",{style:{fontWeight:"800",fontSize:s?"12px":"15px",marginTop:s?"4px":"0"},children:[H,"%"]})]})]},x.id)})})]})};var or=require("react");var Jt=require("react/jsx-runtime"),nr=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=(0,or.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"},d=t.styling||{},c=it(d.padding??s.padding),l=it(d.fontSize||16),y=it(d.optionFontSize||15),u=d.optionBorderRadius!==void 0?it(d.optionBorderRadius):"9999px",m=d.optionBorderColor||"#CBD5E1",f=gt(d.questionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),P=gt(d.optionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),g={backgroundColor:d.backgroundColor||s.backgroundColor,borderRadius:it(d.borderRadius??s.borderRadius),padding:0,boxShadow:d.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:d.opacity??1},b={color:d.questionTextColor||s.questionTextColor,backgroundColor:d.questionBgColor||s.questionBgColor,fontWeight:"700",fontSize:l,fontFamily:f,lineHeight:1.3,margin:0,textAlign:"center",padding:"14px 16px",minHeight:"48px",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",borderTopLeftRadius:it(d.borderRadius??s.borderRadius),borderTopRightRadius:it(d.borderRadius??s.borderRadius),letterSpacing:"-0.01em"},C=d.optionTextAlign||d.optionFont?.textAlign||d.options?.font?.textAlign||d.options?.textAlign||"center",h=H=>{switch(H){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},T={backgroundColor:d.optionBgColor||s.optionBgColor,color:d.optionTextColor||s.optionTextColor,fontFamily:P,padding:"8px 14px",borderRadius:u,border:`1px solid ${m}`,display:"flex",alignItems:"center",justifyContent:h(C),cursor:n?"default":"pointer",width:"100%",textAlign:C||"center",boxSizing:"border-box",transition:"all 0.2s ease",fontSize:y,fontWeight:"500"},E={backgroundColor:d.backgroundColor||s.backgroundColor,borderRadius:`0 0 ${it(d.borderRadius??s.borderRadius)} ${it(d.borderRadius??s.borderRadius)}`,display:"flex",flexDirection:"column",gap:"6px",padding:"10px 14px 12px 14px"},K=H=>{if(!(o||n)){i(H);try{localStorage.setItem(`appstorys_quiz_${t.id}`,H)}catch{}e?.({type:"quiz",quizId:t.id,optionId:H,stickerId:t.id})}},I=["A","B","C","D","E","F"],S=Array.isArray(t.options)?t.options:[];S.length===0&&!o&&console.warn("AppStorys: QuizSticker has no options!",t.id);let M=S.find(H=>H.id===n),x=M?M.isCorrect===!0:!1,N=!!n&&t.showExplanation!==!1&&!!t.explanation;return(0,Jt.jsxs)("div",{style:{...g,background:d.backgroundColor||s.backgroundColor},children:[(0,Jt.jsx)("style",{children:`
|
|
34
34
|
@keyframes appstorys-quiz-fade-in {
|
|
35
35
|
from { opacity: 0; transform: translateY(4px); }
|
|
36
36
|
to { opacity: 1; transform: translateY(0); }
|
|
37
37
|
}
|
|
38
|
-
`}),t.question&&(0,
|
|
38
|
+
`}),t.question&&(0,Jt.jsx)("h3",{style:b,children:t.question}),(0,Jt.jsxs)("div",{style:{...E,background:"transparent"},children:[S.map((H,z)=>{let O=H.label||I[z]||"\u2022",B=H.id===n,Z=H.isCorrect===!0,v={...T};return n&&(Z?(v.backgroundColor=d.activeColor||s.activeColor,v.borderColor=d.activeColor||s.activeColor,v.color="#FFFFFF"):B&&(v.backgroundColor=d.incorrectColor||s.incorrectColor,v.borderColor=d.incorrectColor||s.incorrectColor,v.color="#FFFFFF")),(0,Jt.jsx)("button",{style:v,onClick:()=>K(H.id),disabled:!!n,children:(0,Jt.jsx)("span",{style:{fontWeight:"600",fontSize:y,width:"100%",textAlign:C||"center"},children:H.text})},H.id)}),N&&(0,Jt.jsxs)("div",{style:{marginTop:"8px",padding:"12px 14px",backgroundColor:x?"#E6F4EA":"#FCE8E6",borderRadius:"12px",border:`1px solid ${x?"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:[x?(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:x?"#0ABA73":"#EF4444",fontFamily:P},children:x?"Correct":"Incorrect"})]}),(0,Jt.jsx)("div",{style:{fontSize:"13px",color:"#374151",fontFamily:P,lineHeight:"1.4",paddingLeft:"26px",wordBreak:"break-word"},children:t.explanation})]})]})]})};var fn=require("react");var Se=require("react/jsx-runtime"),ir=({data:t})=>{let[e,o]=(0,fn.useState)({days:"00",hours:"00",minutes:"00",seconds:"00"});(0,fn.useEffect)(()=>{if(!t.targetDate)return;let N=()=>{let z=+new Date(t.targetDate)-+new Date;if(z>0){let O=Math.floor(z/864e5),B=Math.floor(z/(1e3*60*60)%24),Z=Math.floor(z/1e3/60%60),v=Math.floor(z/1e3%60);o({days:O.toString().padStart(2,"0"),hours:B.toString().padStart(2,"0"),minutes:Z.toString().padStart(2,"0"),seconds:v.toString().padStart(2,"0")})}else o({days:"00",hours:"00",minutes:"00",seconds:"00"})},H=setInterval(N,1e3);return N(),()=>clearInterval(H)},[t.targetDate]);let n=t.styling||{},i=t.display||{showDays:!0,showHours:!0,showMinutes:!0,showSeconds:!0},s=gt(n.questionFontFamily||n.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),d=n.digitSize||n.fontSize,c=typeof d=="string",l=c?d:`${!isNaN(Number(d))&&Number(d)>0?Number(d):18}px`,y=n.labelFontSize?it(n.labelFontSize):c?`calc(${l} * 0.45)`:`${Math.max(10,Math.round(Number(d||18)*.45))}px`,u=c?`calc(${l} * 1.65)`:`${Math.max(36,Math.round(Number(d||18)*1.65))}px`,m=c?`calc(${l} * 0.95)`:`${Math.max(26,Math.round(Number(d||18)*.95))}px`,f=c?`calc(${l} * 0.25)`:`${Math.max(6,Math.round(Number(d||18)*.25))}px`,P=c?`calc(${l} * 0.15)`:`${Math.max(6,Math.round(Number(d||18)*.15))}px`,g=c?`calc(${l} * 0.75)`:`${Math.max(14,Math.round(Number(d||18)*.75))}px`,b={backgroundColor:n.backgroundColor||"#FFFFFF",borderRadius:it(n.borderRadius!==void 0?n.borderRadius:16),padding:n.padding?it(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},R={color:n.titleColor||"#000000",fontWeight:"700",fontSize:it(n.fontSize||14),fontFamily:s,width:"100%",textAlign:"center",marginBottom:"4px"},C={display:"flex",gap:P,width:"100%",justifyContent:"center",alignItems:"center",flexWrap:"nowrap"},h={display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},T={display:"flex",gap:"2px"},E={backgroundColor:n.digitBackground||"#F1F3F5",borderRadius:f,minWidth:m,height:u,display:"flex",alignItems:"center",justifyContent:"center",fontSize:l,fontWeight:"bold",color:n.digitColor||"#1A202C",padding:"0 4px"},K={fontSize:c?y:`${Math.max(9,Number(String(y).replace("px","")))}px`,color:n.labelColor||"#A0AEC0",fontWeight:"600",textTransform:"lowercase"},I={fontSize:g,fontWeight:"700",color:n.labelColor||"#A0AEC0",display:"flex",alignItems:"center",lineHeight:1},S=(N,H)=>(0,Se.jsxs)("div",{style:h,children:[(0,Se.jsx)("div",{style:T,children:N.split("").map((z,O)=>(0,Se.jsx)("div",{style:E,children:z},O))}),(0,Se.jsx)("span",{style:K,children:H})]}),M=[],x=0;return i.showDays!==!1&&(M.push(S(e.days,"days")),x++),i.showHours!==!1&&(x>0&&M.push((0,Se.jsx)("div",{style:I,children:":"},"sep-h")),M.push(S(e.hours,"hours")),x++),i.showMinutes!==!1&&(x>0&&M.push((0,Se.jsx)("div",{style:I,children:":"},"sep-m")),M.push(S(e.minutes,"minutes")),x++),i.showSeconds!==!1&&(x>0&&M.push((0,Se.jsx)("div",{style:I,children:":"},"sep-s")),M.push(S(e.seconds,"seconds")),x++),(0,Se.jsxs)("div",{style:b,children:[t.title&&(0,Se.jsx)("div",{style:R,children:t.title}),(0,Se.jsx)("div",{style:C,children:M})]})};var rr=require("react");var Ce=require("react/jsx-runtime"),sr=({data:t,onInteraction:e})=>{let[o,n]=(0,rr.useState)(!1),i=m=>{m.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||{},d=s.backgroundColor||"#F4F4F6",c=gt(s.fontFamily,'"SF Mono", "Roboto Mono", Menlo, Consolas, "Courier New", monospace'),l={backgroundColor:d,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,Ce.jsxs)("div",{style:l,onClick:i,children:[(0,Ce.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,Ce.jsx)("div",{style:{flex:1,minWidth:0,padding:"0 8px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,Ce.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,Ce.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,Ce.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#10B981",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,Ce.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,Ce.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[(0,Ce.jsx)("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"}),(0,Ce.jsx)("rect",{x:"4",y:"4",width:"12",height:"12",rx:"2.5",stroke:"#000000",strokeWidth:"2",fill:"none"})]})})]})};var jo=require("react");var lo=require("react/jsx-runtime"),ar=({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,d]=(0,jo.useState)(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)!==null}catch{return!1}}),[c,l]=(0,jo.useState)({});(0,jo.useEffect)(()=>{let b={},R=(()=>{try{return localStorage.getItem(`appstorys_reaction_${t.id}`)}catch{return null}})();i.forEach(C=>{let h=Math.random()>.5?1999:2e3;R&&C===R&&(h+=1),b[C]=h}),l(b)},[t.emojis]);let y=(b,R)=>{if(!(o||s)){l(C=>({...C,[b]:(C[b]||0)+1})),d(!0);try{localStorage.setItem(`appstorys_reaction_${t.id}`,b)}catch{}e?.({type:"reaction",reactionId:t.id,optionId:`option${R+1}`,selected_option:`option${R+1}`,emoji:b,stickerId:t.id})}},u=b=>b>=1e3?(b/1e3).toFixed(0)+"k":String(b),m={display:"flex",gap:"10px",justifyContent:"center",alignItems:"center",width:"100%",padding:"6px",boxSizing:"border-box"},f={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},P={fontSize:"28px",lineHeight:"1",userSelect:"none"},g={fontSize:"13px",fontWeight:"800",color:"#374151",animation:"appstorys-reaction-fade-in 0.3s ease forwards",lineHeight:"1",userSelect:"none",fontFamily:gt(t.styling?.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif')};return(0,lo.jsxs)("div",{style:m,children:[(0,lo.jsx)("style",{children:`
|
|
39
39
|
@keyframes appstorys-reaction-fade-in {
|
|
40
40
|
from { opacity: 0; transform: translateY(4px); }
|
|
41
41
|
to { opacity: 1; transform: translateY(0); }
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
.appstorys-reaction-btn.voted {
|
|
50
50
|
transform: scale(1) translateY(0) !important;
|
|
51
51
|
}
|
|
52
|
-
`}),i.map((
|
|
52
|
+
`}),i.map((b,R)=>{let C=c[b]||2e3;return(0,lo.jsxs)("button",{className:`appstorys-reaction-btn ${s?"voted":""} ${o?"editing":""}`,style:f,onClick:()=>y(b,R),children:[(0,lo.jsx)("span",{style:P,children:b}),s&&(0,lo.jsx)("span",{style:g,children:u(C)})]},R)})]})};var Oe=require("react");var je=require("react/jsx-runtime"),lr=({data:t,onInteraction:e,isEditing:o=!1})=>{let n=t.maxRating||5,i=t.currentRating??Math.floor(n/2),[s,d]=(0,Oe.useState)(()=>{try{let B=localStorage.getItem(`appstorys_rating_${t.id}`);return B?Number(B):i}catch{return i}}),c=(0,Oe.useRef)(null),[l,y]=(0,Oe.useState)(!1),[u,m]=(0,Oe.useState)(()=>{try{return localStorage.getItem(`appstorys_rating_${t.id}`)!==null}catch{return!1}}),[f,P]=(0,Oe.useState)([]),g={backgroundColor:"#FFFFFF",borderRadius:20,padding:14,titleColor:"#000000",titleFontSize:15,sliderTrackColor:"#F3F4F6",sliderFillColor:"#F97316",emojiSize:32},b=t.styling||{},R=gt(b.questionFontFamily||b.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),C={backgroundColor:b.backgroundColor||g.backgroundColor,borderRadius:it(b.borderRadius??g.borderRadius),padding:b.padding?it(b.padding):"8px 12px",boxShadow:b.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:b.opacity??1},h={color:b.titleColor||g.titleColor,fontWeight:"700",fontSize:typeof b.titleFontSize=="string"?`min(${b.titleFontSize}, 16px)`:`${b.titleFontSize?Math.min(Number(b.titleFontSize),16):15}px`,margin:"0",textAlign:"center",lineHeight:"1.25",fontFamily:R,width:"100%"},T={width:"100%",height:"16px",backgroundColor:b.sliderTrackColor||g.sliderTrackColor,borderRadius:"100px",position:"relative",cursor:o||u?"default":"pointer",marginTop:"4px",marginBottom:"2px",userSelect:"none"},E=s/n*100,K={width:`${E}%`,height:"100%",background:b.sliderFillColor||"linear-gradient(90deg, #FF4582, #e11d48)",borderRadius:"100px",transition:l?"none":"width 0.1s ease"},I=b.emojiSize||g.emojiSize,S=typeof I=="string",M=it(I),x={position:"absolute",left:S?`calc(${E}% - calc(${M} / 2))`:`calc(${E}% - ${Number(I)/2}px)`,top:S?`calc(50% - calc(${M} / 2))`:`calc(50% - ${Number(I)/2}px)`,fontSize:M,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",cursor:u||o?"default":"grab",transition:l?"none":"left 0.1s ease",filter:"drop-shadow(0 4px 8px rgba(0,0,0,0.2))",animation:u?"thumbPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards":"none"},N=B=>{if(!c.current||o||u)return;let Z=c.current.getBoundingClientRect(),v=B-Z.left;v<0&&(v=0),v>Z.width&&(v=Z.width);let A=v/Z.width,V=Math.round(A*n*10)/10;d(V)},H=B=>{o||u||(y(!0),N(B.clientX))},z=B=>{o||u||(y(!0),N(B.touches[0].clientX))},O=()=>{let B=Array.from({length:16}).map((Z,v)=>({id:Date.now()+v,scale:.5+Math.random()*.8,angle:v*22.5+(Math.random()*15-7.5),delay:Math.random()*.1}));P(B),setTimeout(()=>{P([])},1200)};return(0,Oe.useEffect)(()=>{let B=A=>{l&&N(A.clientX)},Z=()=>{if(l){y(!1),m(!0);try{localStorage.setItem(`appstorys_rating_${t.id}`,String(s))}catch{}O(),e?.({type:"rating",ratingId:t.id,value:s,stickerId:t.id})}},v=A=>{l&&N(A.touches[0].clientX)};return l&&(window.addEventListener("mousemove",B),window.addEventListener("mouseup",Z),window.addEventListener("touchmove",v),window.addEventListener("touchend",Z)),()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",Z),window.removeEventListener("touchmove",v),window.removeEventListener("touchend",Z)}},[l,s]),(0,je.jsxs)("div",{style:C,children:[(0,je.jsx)("style",{children:`
|
|
53
53
|
@keyframes emojiBurst {
|
|
54
54
|
0% {
|
|
55
55
|
transform: translate(0, 0) scale(0.3);
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
50% { transform: scale(1.3); }
|
|
69
69
|
100% { transform: scale(1); }
|
|
70
70
|
}
|
|
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:`
|
|
71
|
+
`}),(0,je.jsx)("h3",{style:h,children:t.title||"Do you like my space?"}),(0,je.jsxs)("div",{ref:c,style:T,onMouseDown:H,onTouchStart:z,children:[(0,je.jsx)("div",{style:K}),(0,je.jsxs)("div",{style:x,className:"interactive-emoji-thumb",children:[t.emoji||"\u{1F60D}",f.map(B=>{let Z=60+Math.random()*80,v=B.angle*Math.PI/180,A=`${Math.cos(v)*Z}px`,V=`${Math.sin(v)*Z}px`;return(0,je.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":A,"--ty":V,"--scale":B.scale},children:t.emoji||"\u{1F60D}"},B.id)})]})]})]})};var Qn=require("react");var Ee=require("react/jsx-runtime"),dr=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=(0,Qn.useState)(()=>{try{return localStorage.getItem(`appstorys_question_${t.id}`)||""}catch{return""}}),[s,d]=(0,Qn.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"},l=t.styling||{},y=gt(l.questionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),u=gt(l.optionFontFamily||l.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),m={backgroundColor:l.backgroundColor||c.backgroundColor,borderRadius:it(l.borderRadius??c.borderRadius),padding:l.padding?it(l.padding):"10px 12px",boxShadow:l.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 ${l.borderColor||"#F0F0F0"}`},f={color:l.promptColor||c.promptColor,fontWeight:"700",fontSize:it(l.fontSize||16),fontFamily:y,textAlign:"center",marginBottom:"2px",width:"100%"},P={width:"100%",position:"relative",display:"flex",alignItems:"center"},g=l.optionRadius??l.inputBorderRadius??l.optionBorderRadius??l.inputRadius,b=g!==void 0?typeof g=="number"&&g>=5?"9999px":it(g):"9999px",R={backgroundColor:l.inputBgColor||"#F1F3F5",border:"none",borderRadius:b,padding:"8px 36px 8px 14px",width:"100%",boxSizing:"border-box",color:l.inputTextColor||"#1A202C",fontSize:"13px",fontFamily:u,outline:"none",textAlign:"left",cursor:o?"default":"text",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},C={position:"absolute",right:"4px",background:l.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"},h=E=>{o||s||i(E.target.value)},T=()=>{if(!(o||!n.trim()||s)){d(!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,Ee.jsxs)("div",{style:m,children:[(0,Ee.jsx)("div",{style:f,children:t.question||"Ask me anything"}),(0,Ee.jsxs)("div",{style:P,children:[(0,Ee.jsx)("input",{type:"text",value:n,placeholder:s?"Submitted!":t.placeholder||"Type your answer...",style:R,disabled:o||s,onChange:h,onKeyDown:E=>E.key==="Enter"&&T()}),(0,Ee.jsx)("button",{style:C,onClick:T,children:(0,Ee.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Ee.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,Ee.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})};var cr=require("react");var Pe=require("react/jsx-runtime"),ur=({data:t,onInteraction:e,isEditing:o=!1})=>{let[n,i]=(0,cr.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"},d=t.styling||{},c=it(d.padding??s.padding),l=it(d.borderRadius??s.borderRadius),y=gt(d.questionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),u=gt(d.optionFontFamily||d.fontFamily,'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'),m={backgroundColor:d.backgroundColor||s.backgroundColor,borderRadius:l,padding:c,boxShadow:d.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:d.opacity??1,border:d.borderColor?`1px solid ${d.borderColor}`:"none",overflow:"hidden"},f={color:d.questionTextColor||"#FFFFFF",backgroundColor:d.questionBgColor||"#000000",fontWeight:"800",fontSize:it(d.fontSize||15),fontFamily:y,margin:`calc(-1 * ${c}) calc(-1 * ${c}) 8px calc(-1 * ${c})`,padding:`12px ${c} 10px ${c}`,textAlign:"center",borderTopLeftRadius:l,borderTopRightRadius:l},b={display:"grid",gridTemplateColumns:`repeat(${(I=>{if(typeof I=="number"&&!isNaN(I)&&I>0)return I;if(typeof I=="string"){let S=parseInt(I,10);if(!isNaN(S)&&S>0)return S}if(typeof I=="object"&&I!==null){let S=I.columns||I.cols||I.columnCount;if(typeof S=="number"&&!isNaN(S)&&S>0)return S;if(typeof S=="string"){let M=parseInt(S,10);if(!isNaN(M)&&M>0)return M}}return 2})(t.layout??d.layout??d.columns)}, 1fr)`,gap:"6px",width:"100%"},R=it(d.optionRadius??d.optionBorderRadius??d.imageRadius??14),C={backgroundColor:d.optionBgColor||s.optionBgColor,color:d.optionTextColor||s.optionTextColor,fontFamily:u,borderRadius:R,border:`2px solid ${d.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"},h=I=>{if(!(o||n)){i(I);try{localStorage.setItem(`appstorys_image_quiz_${t.id}`,I)}catch{}e?.({type:"image",quizId:t.id,optionId:I,stickerId:t.id})}},T="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",E=["A","B","C","D","E","F"],K=Array.isArray(t.options)?t.options:[];return K.length===0&&!o&&console.warn("AppStorys: ImageQuizSticker has no options!",t.id),(0,Pe.jsxs)("div",{style:{...m,background:d.backgroundColor||s.backgroundColor},children:[t.question&&(0,Pe.jsx)("h3",{style:f,children:t.question}),(0,Pe.jsx)("div",{style:b,children:K.map((I,S)=>{let M=I.id===n,x=I.isCorrect===!0,N=d.borderColor||s.borderColor,H=d.optionBgColor||s.optionBgColor;n&&(x?(N=d.activeColor||s.activeColor,H="rgba(16, 185, 129, 0.08)"):M&&(N=d.incorrectColor||s.incorrectColor,H="rgba(239, 68, 68, 0.08)"));let z=n?x?d.activeColor||s.activeColor:M?d.incorrectColor||s.incorrectColor:d.labelColor||d.optionTextColor||s.optionTextColor:d.labelColor||d.optionTextColor||s.optionTextColor;return(0,Pe.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%",boxSizing:"border-box"},children:[(0,Pe.jsxs)("button",{style:{width:"100%",aspectRatio:"1",borderRadius:R,border:`2px solid ${N}`,backgroundColor:H,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:()=>h(I.id),disabled:!!n,onMouseOver:O=>{!o&&!n&&(O.currentTarget.style.transform="scale(1.02)")},onMouseOut:O=>{!o&&!n&&(O.currentTarget.style.transform="scale(1)")},children:[(0,Pe.jsx)("img",{src:I.image||T,alt:I.text,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),n&&(0,Pe.jsx)("div",{style:{position:"absolute",top:"6px",right:"6px",width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:x?d.activeColor||s.activeColor:M?d.incorrectColor||s.incorrectColor:"#A0AEC0",color:"#FFFFFF",fontSize:"12px",fontWeight:"bold",boxShadow:"0 2px 6px rgba(0,0,0,0.2)"},children:x?"\u2713":M?"\u2715":""})]}),(0,Pe.jsx)("span",{style:{marginTop:"6px",fontWeight:"600",fontSize:it(d.optionFontSize||13),color:z,fontFamily:u,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:I.text})]},I.id)})})]})};var Zn=require("react");var Ge=require("react");var et=require("react/jsx-runtime"),hr=({product:t,styling:e,onClose:o,onAddToCart:n})=>{let[i,s]=(0,Ge.useState)(""),[d,c]=(0,Ge.useState)(0),[l,y]=(0,Ge.useState)(1),[u,m]=(0,Ge.useState)(!1),[f,P]=(0,Ge.useState)(!1),g=t.attributes||{},b=g.colors||[],R=g.sizes||[],C=g.imageUrls||[t.image],h=g.description||"";(0,Ge.useEffect)(()=>{R.length>0&&s(R[0]),P(!0)},[R]);let T=()=>{let O={productId:t.productId||t.id,title:t.title,selectedSize:i,selectedColor:b[d]?.name,quantity:l,price:t.price};n(O);let B=t.redirectUrl||t.url;if(B){if(Rt(B)){E();return}!B.startsWith("http")&&!B.startsWith("//")&&(B="https://"+B);try{window.open(B,"_blank","noopener,noreferrer")}catch(Z){console.error("AppStorys: Redirect failed",Z)}}m(!0)},E=()=>{P(!1),setTimeout(o,400)},K=e?.buttonBackground||"#000000",I=e?.buttonTextColor||"#ffffff",S=e?.titleColor||e?.textColor||"#1a1a2e",M=e?.priceColor||e?.textColor||"#1a1a2e",x=e?.mrpColor||"#8b8b98",N=e?.titleFontWeight||"600",H=e?.priceFontWeight||"700",z=e?.mrpFontWeight||"500";return u?(0,et.jsxs)("div",{className:"appstorys-shopable-success-overlay",style:pr,children:[(0,et.jsx)("div",{className:"appstorys-shopable-backdrop",style:gr,onClick:E}),(0,et.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...fr,height:"auto",minHeight:"310px",animation:"appstorys-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[(0,et.jsx)("div",{style:mr,onClick:E}),(0,et.jsxs)("div",{style:{padding:"0 20px 24px",textAlign:"center"},children:[(0,et.jsxs)("div",{style:{backgroundColor:"#F3F4F6",borderRadius:"20px",padding:"22px",marginTop:"16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[(0,et.jsxs)("h3",{style:{margin:0,fontSize:"16px",fontWeight:"600",lineHeight:"1.4"},children:["Added to your bag",(0,et.jsx)("br",{}),"successfully"]}),(0,et.jsx)("svg",{width:"44",height:"26",viewBox:"0 0 44 26",fill:"none",children:(0,et.jsx)("path",{d:"M4 4C4 4 11 22 22 22C33 22 40 4 40 4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"})})]}),(0,et.jsxs)("div",{style:{marginTop:"24px",display:"flex",flexDirection:"column",gap:"8px"},children:[(0,et.jsx)("button",{onClick:E,style:{...Kn,backgroundColor:"#000000",color:"#ffffff",padding:"17px",fontSize:"16px",fontWeight:"600"},children:(0,et.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[(0,et.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,et.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,et.jsx)("path",{d:"M3 6h18"}),(0,et.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),"Go to checkout"]})}),(0,et.jsx)("button",{onClick:E,style:{...Kn,backgroundColor:"transparent",color:"#000000",border:"1px solid rgba(0,0,0,0.1)",padding:"15px",fontSize:"16px"},children:"Continue with stories"})]})]})]})]}):(0,et.jsxs)("div",{className:`appstorys-shopable-overlay ${f?"visible":""}`,style:pr,children:[(0,et.jsx)("div",{className:"appstorys-shopable-backdrop",style:gr,onClick:E}),(0,et.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...fr,transform:f?"translateY(0)":"translateY(100%)",opacity:f?1:0},children:[(0,et.jsxs)("div",{style:Ws,children:[(0,et.jsx)("div",{style:mr,onClick:E}),(0,et.jsx)("button",{style:Ds,onClick:E,children:(0,et.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,et.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,et.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),(0,et.jsxs)("div",{style:$s,children:[(0,et.jsx)("div",{style:Ns,children:C.map((O,B)=>(0,et.jsx)("div",{style:{minWidth:C.length>1?"85%":"100%",aspectRatio:"1.2 / 1",maxHeight:"240px",borderRadius:"16px",overflow:"hidden",backgroundColor:"#F9FAFB"},children:(0,et.jsx)("img",{src:O,alt:t.title,style:{width:"100%",height:"100%",objectFit:"contain"}})},B))}),(0,et.jsxs)("div",{style:{padding:"0 20px 20px"},children:[(0,et.jsx)("h2",{style:{margin:"16px 0 4px",fontSize:e?.titleFontSize?it(e.titleFontSize):"20px",fontWeight:N,color:S,lineHeight:"1.2"},children:t.title}),(0,et.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",marginBottom:"16px"},children:[(0,et.jsx)("span",{style:{fontSize:e?.priceFontSize?it(e.priceFontSize):"18px",fontWeight:H,color:M},children:t.price}),t.oldPrice&&(0,et.jsx)("span",{style:{fontSize:e?.mrpFontSize?it(e.mrpFontSize):"14px",color:x,textDecoration:"line-through",fontWeight:z},children:t.oldPrice})]}),b.length>0&&(0,et.jsxs)("div",{style:Jn,children:[(0,et.jsx)("div",{style:Xn,children:"COLOR"}),(0,et.jsx)("div",{style:{display:"flex",gap:"14px",marginTop:"12px"},children:b.map((O,B)=>(0,et.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"5px"},children:[(0,et.jsx)("button",{onClick:()=>c(B),style:{width:"36px",height:"36px",borderRadius:"50%",border:"none",backgroundColor:O.hex||"#gray",position:"relative",cursor:"pointer",boxShadow:d===B?"0 0 0 2px #fff, 0 0 0 4px #000":"none",transition:"all 0.2s ease"}}),(0,et.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:d===B?"#000":"transparent",transition:"all 0.2s ease"}})]},O.id))})]}),R.length>0&&(0,et.jsxs)("div",{style:Jn,children:[(0,et.jsx)("div",{style:Xn,children:"SIZE"}),(0,et.jsx)("div",{style:{display:"flex",gap:"10px",marginTop:"12px",flexWrap:"wrap"},children:R.map(O=>(0,et.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[(0,et.jsx)("button",{onClick:()=>s(O),style:{minWidth:"42px",height:"42px",borderRadius:"50%",backgroundColor:"transparent",border:`1px solid ${i===O?"#000":"rgba(0,0,0,0.1)"}`,color:i===O?"#000":"#8b8b98",fontSize:"13px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:O}),(0,et.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:i===O?"#000":"transparent",transition:"all 0.2s ease"}})]},O))})]}),h&&(0,et.jsxs)("div",{style:Jn,children:[(0,et.jsx)("div",{style:Xn,children:"DESCRIPTION"}),(0,et.jsx)("p",{style:{margin:"8px 0 0",fontSize:"14px",lineHeight:"1.5",color:"#8b8b98",wordBreak:"break-word"},children:h})]})]})]}),(0,et.jsxs)("div",{style:Os,children:[(0,et.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1px",minWidth:"75px"},children:[(0,et.jsx)("div",{style:{fontSize:"15px",fontWeight:H,color:M},children:t.price}),t.oldPrice&&(0,et.jsx)("div",{style:{fontSize:"11px",color:x,textDecoration:"line-through",fontWeight:z},children:t.oldPrice})]}),(0,et.jsxs)("div",{style:js,children:[(0,et.jsx)("button",{style:yr,onClick:()=>y(O=>Math.max(1,O-1)),children:(0,et.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,et.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}),(0,et.jsx)("span",{style:{fontSize:"16px",fontWeight:"700",minWidth:"18px",textAlign:"center",color:"#000000",display:"inline-block"},children:l}),(0,et.jsx)("button",{style:yr,onClick:()=>y(O=>O+1),children:(0,et.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,et.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,et.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),(()=>{let O=g.availability?.toLowerCase()||"",B=O==="out of stock"||O==="out-of-stock";return(0,et.jsxs)("button",{onClick:B?void 0:T,disabled:B,style:{...Kn,backgroundColor:B?"#F3F4F6":K,color:B?"#9CA3AF":I,flex:"1",padding:"12px 8px",gap:"6px",cursor:B?"not-allowed":"pointer",opacity:B?.8:1},children:[!B&&(0,et.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,et.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,et.jsx)("path",{d:"M3 6h18"}),(0,et.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),(0,et.jsx)("span",{style:{fontSize:"12px",fontWeight:"700",whiteSpace:"nowrap"},children:B?"Out of Stock":"Add to cart"})]})})()]})]}),(0,et.jsx)("style",{children:`
|
|
72
72
|
@keyframes appstorys-slide-up {
|
|
73
73
|
from { transform: translateY(100%); }
|
|
74
74
|
to { transform: translateY(0); }
|
|
@@ -81,10 +81,10 @@
|
|
|
81
81
|
.appstorys-shopable-overlay.visible {
|
|
82
82
|
visibility: visible;
|
|
83
83
|
}
|
|
84
|
-
`})]})},
|
|
84
|
+
`})]})},pr={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"},gr={position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.45)",cursor:"pointer"},fr={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"},Ws={height:"48px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0},mr={width:"36px",height:"5px",backgroundColor:"rgba(0,0,0,0.1)",borderRadius:"3px",cursor:"pointer"},Ds={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"},$s={flex:1,overflowY:"auto",WebkitOverflowScrolling:"touch"},Ns={padding:"0 16px 20px",display:"flex",gap:"8px",overflowX:"auto",scrollSnapType:"x mandatory"},Jn={marginTop:"20px"},Xn={fontSize:"11px",fontWeight:"600",color:"rgba(0,0,0,0.5)",letterSpacing:"1.4px"},Os={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"},js={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"100px",border:"1px solid rgba(0,0,0,0.1)"},yr={border:"none",backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},Kn={border:"none",borderRadius:"100px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"};var Kt=require("react/jsx-runtime"),br=({data:t,onInteraction:e,isEditing:o})=>{let{products:n,styling:i}=t,[s,d]=(0,Zn.useState)(!1),[c,l]=(0,Zn.useState)(null),y=(b,R)=>{if(b.stopPropagation(),o)return;if(t.shopableType==="product"){l(R),d(!0),e&&e({type:"product_view",stickerId:t.id,productId:R.productId||R.id,value:R.title});return}let C=R.redirectUrl||R.url;if(!(C&&Rt(C))&&(C&&!C.startsWith("http")&&!C.startsWith("//")&&(C="https://"+C),e&&e({type:"buy",stickerId:t.id,productId:R.id,value:R.title,selected_option:C}),C))try{window.open(C,"_blank","noopener,noreferrer")}catch(h){console.error("AppStorys: Redirect failed",h),window.location.href=C}},u=b=>{e&&e({type:"add_to_cart",stickerId:t.id,productId:b.productId,value:b.title,selected_option:JSON.stringify({size:b.selectedSize,color:b.selectedColor,quantity:b.quantity})})},m={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:i?.cardBackground||"#ffffff",borderRadius:i?.cardBorderRadius!==void 0?it(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},P={width:"64px",height:"64px",borderRadius:i?.imageRadius!==void 0?it(i.imageRadius):"12px",overflow:"hidden",backgroundColor:"#f5f5f5",flexShrink:0},g={flex:1,display:"flex",flexDirection:"column",justifyContent:"center",padding:"0 12px",minWidth:0};return(0,Kt.jsxs)(Kt.Fragment,{children:[(0,Kt.jsxs)("div",{style:m,className:"shopable-container",children:[(0,Kt.jsx)("style",{children:`
|
|
85
85
|
.shopable-container::-webkit-scrollbar { display: none; }
|
|
86
86
|
.shopable-card:active { transform: scale(0.98); }
|
|
87
|
-
`}),n.map(
|
|
87
|
+
`}),n.map(b=>(0,Kt.jsxs)("div",{style:f,className:"shopable-card",onClick:R=>y(R,b),children:[(0,Kt.jsx)("div",{style:P,children:(0,Kt.jsx)("img",{src:b.image,alt:b.title,style:{width:"100%",height:"100%",objectFit:"cover"}})}),(0,Kt.jsxs)("div",{style:g,children:[(0,Kt.jsx)("span",{style:{color:i?.titleColor||i?.textColor||"#1a1b2e",fontSize:i?.titleFontSize?it(i.titleFontSize):"15px",fontWeight:i?.titleFontWeight||"700",lineHeight:"1.2",display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"1px"},children:b.title}),(0,Kt.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",flexWrap:"wrap"},children:[(0,Kt.jsx)("span",{style:{color:i?.priceColor||i?.textColor||"#1a1b2e",fontSize:i?.priceFontSize?it(i.priceFontSize):"18px",fontWeight:i?.priceFontWeight||"800",display:"block"},children:b.price}),b.oldPrice&&(0,Kt.jsx)("span",{style:{color:i?.mrpColor||"#8b8b98",fontSize:i?.mrpFontSize?it(i.mrpFontSize):"12px",fontWeight:i?.mrpFontWeight||"500",textDecoration:"line-through"},children:b.oldPrice})]})]}),(0,Kt.jsx)("div",{style:{backgroundColor:i?.buttonBackground||"#000000",color:i?.buttonTextColor||"#ffffff",fontSize:i?.buttonFontSize?it(i.buttonFontSize):"14px",fontWeight:"700",padding:"10px 18px",borderRadius:i?.buttonBorderRadius!==void 0?it(i.buttonBorderRadius):"100px",textAlign:"center",flexShrink:0,whiteSpace:"nowrap"},children:"Buy Now"})]},b.id))]}),s&&c&&(0,Kt.jsx)(hr,{product:c,styling:i,onClose:()=>d(!1),onAddToCart:u})]})};var Tt=require("react/jsx-runtime"),xr=vo.default?.default??vo.default??vo.Lottie??vo,qs=({url:t,animationData:e,loop:o=!0,autoplay:n=!0,styling:i={}})=>{let[s,d]=(0,Qe.useState)(e||null),[c,l]=(0,Qe.useState)(!1);(0,Qe.useEffect)(()=>{if(e){d(e);return}t&&(l(!1),fetch(t).then(m=>{if(!m.ok)throw new Error(`Failed to fetch Lottie JSON (${m.status})`);return m.json()}).then(m=>{d(m),l(!1)}).catch(m=>{console.error("AppStorys: Error loading Lottie sticker from URL:",t,m),l(!0)}))},[t,e]);let y={width:"100%",height:"100%",display:"block",borderRadius:it(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,Tt.jsx)("div",{style:y});let u=xr.default||xr;return(0,Tt.jsx)(u,{animationData:s,loop:o,autoplay:n,style:y,rendererSettings:{preserveAspectRatio:"xMidYMid meet"}})},Us=({url:t,loop:e=!0,muted:o=!1,isActive:n=!0,isMuted:i=!1,styling:s={}})=>{let d=Qe.default.useRef(null);return Qe.default.useEffect(()=>{let l=d.current;l&&(n?l.play().catch(()=>{}):l.pause())},[n,t]),(0,Tt.jsx)("video",{ref:d,src:t,autoPlay:n,loop:e,muted:!n||i||o,playsInline:!0,style:{width:"100%",height:"100%",objectFit:s.objectFit||"contain",objectPosition:s.objectPosition||"center center",borderRadius:it(s.borderRadius||"0px"),border:s.border||"none",boxShadow:s.boxShadow||"none",opacity:s.opacity??1,display:"block",overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"}})},Sr=({data:t,onInteraction:e,isEditing:o=!1,isActive:n=!0,isMuted:i=!1})=>{let s={x:10,y:15,width:80,rotation:0},d=t.x??s.x,c=t.y??s.y,l=t.width??s.width,y=t.rotation??s.rotation,u={position:"absolute",top:`${c}%`,left:`${d}%`,width:`${l}%`,height:t.height?`${t.height}%`:"auto",transform:`rotate(${y}deg)`,zIndex:10,transformOrigin:"center center",boxSizing:"border-box",cursor:o?"move":"default",pointerEvents:"auto",opacity:t.styling?.opacity!==void 0?t.styling.opacity:1},m={width:"100%",height:"100%",animation:t.styling?.animation,animationFillMode:"forwards"},f=()=>{switch(t.type){case"poll":return(0,Tt.jsx)(er,{data:t,onInteraction:e,isEditing:o});case"quiz":return(0,Tt.jsx)(nr,{data:t,onInteraction:e,isEditing:o});case"rating":return(0,Tt.jsx)(lr,{data:t,onInteraction:e,isEditing:o});case"question":case"input":return(0,Tt.jsx)(dr,{data:t,onInteraction:e,isEditing:o});case"image_quiz":return(0,Tt.jsx)(ur,{data:t,onInteraction:e,isEditing:o});case"countdown":return(0,Tt.jsx)(ir,{data:t,onInteraction:e,isEditing:o});case"promo_code":case"promo":return(0,Tt.jsx)(sr,{data:t,onInteraction:e,isEditing:o});case"reaction":return(0,Tt.jsx)(ar,{data:t,onInteraction:e,isEditing:o});case"lottie":return(0,Tt.jsx)(qs,{url:t.url,loop:t.loop,autoplay:t.autoplay,styling:t.styling});case"buy":case"shopable":return(0,Tt.jsx)(br,{data:t,onInteraction:e,isEditing:o});case"video":{let g=t.isActive!==void 0?t.isActive:n,b=t.isMuted!==void 0?t.isMuted:i;return(0,Tt.jsx)(Us,{url:t.url,loop:t.loop!==!1,muted:t.muted===!0,isActive:g,isMuted:b,styling:t.styling})}case"shape":case"gif":case"svg":case"sticker":case"image":{let g=t.styling||{};return(0,Tt.jsx)("img",{src:t.url,alt:"static overlay",style:{width:"100%",height:"100%",objectFit:g.objectFit||"contain",objectPosition:g.objectPosition||"center center",borderRadius:g.borderRadius||"0px",border:g.border||"none",boxShadow:g.boxShadow||"none",opacity:g.opacity??1,display:"block",overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"}})}case"text":{let g=t.styling||{},b=g.verticalAlignment,R=g.textAlign,C=g.lineHeight,h="1.25";if(C!=null&&C!==""){let T=Number(C);isNaN(T)?h=String(C):h=T<=5?String(T):"1.25"}return(0,Tt.jsx)("div",{style:{color:g.color||"#000000",fontSize:it(g.fontSize||14),fontFamily:gt(g.fontFamily)||"Arial",fontStyle:g.fontStyle||"normal",fontWeight:g.fontWeight||"normal",textDecoration:g.textDecoration||"none",lineHeight:h,letterSpacing:g.letterSpacing||"normal",opacity:g.opacity??1,wordBreak:"break-word",whiteSpace:"pre-wrap",width:"100%",height:"100%",display:"flex",alignItems:b==="middle"||b==="center"?"center":b==="bottom"?"flex-end":"flex-start",justifyContent:R==="center"?"center":R==="right"?"flex-end":"flex-start",textAlign:R||"left"},children:t.text})}case"cta":{let g=t.styling||{};if(t.ctaType==="image"||!!(t.url&&!t.text)){let x=g.borderRadius||"0px";return(0,Tt.jsx)("button",{onClick:N=>{N.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:{background:"none",border:g.borderWidth&&g.borderWidth!=="0px"&&g.borderWidth!=="0cqh"?`${it(g.borderWidth)} solid ${g.borderColor||"#FFFFFF"}`:"none",padding:0,width:"100%",height:"100%",cursor:"pointer",display:"block",outline:"none",borderRadius:x,overflow:"hidden",WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)"},children:(0,Tt.jsx)("img",{src:t.url,alt:t.text||"cta",style:{width:"100%",height:"100%",objectFit:g.objectFit||"contain",objectPosition:g.objectPosition||"center center",display:"block",borderRadius:x}})})}let R=g.borderRadius,C=(t.text||"").trim(),h=C.toLowerCase().includes("swipe")||String(t.ctaType).toLowerCase().includes("swipe")||String(t.type).toLowerCase().includes("swipe")||String(t.id).toLowerCase().includes("swipe"),T={width:"100%",height:g.pillH?`${g.pillH}cqh`:"100%",backgroundColor:g.transparent?"transparent":g.backgroundColor||"#3B82F6",color:g.textColor||"#FFFFFF",border:g.borderWidth&&g.borderWidth!=="0px"&&g.borderWidth!=="0cqh"?`${it(g.borderWidth)} solid ${g.borderColor||"#FFFFFF"}`:"none",borderRadius:R||"4px",fontSize:it(g.fontSize||14),fontFamily:gt(g.fontFamily)||"Arial",fontStyle:g.fontStyle||"normal",fontWeight:g.fontWeight||"normal",textDecoration:g.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:h&&g.arrowAnimation!==!1?"appstorys-swipe-bounce 2.2s ease-in-out infinite":"none",transformOrigin:"bottom center"},K={display:"flex",alignItems:"center",justifyContent:"center",flexGrow:1,width:"100%",color:g.arrowColor||g.textColor||"#FFFFFF",pointerEvents:"none",boxSizing:"border-box"},I=g.arrowSize,S=I?typeof I=="string"?I:it(I,"cqh"):"clamp(12px, 1.5cqh, 24px)";return(0,Tt.jsxs)("div",{style:E,children:[h&&(0,Tt.jsxs)(Tt.Fragment,{children:[(0,Tt.jsx)("style",{children:`
|
|
88
88
|
@keyframes appstorys-swipe-bounce {
|
|
89
89
|
0%, 100% {
|
|
90
90
|
transform: translateY(0) scaleY(1) scaleX(1);
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
transform: translateY(1px) scaleY(0.97) scaleX(1.02);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
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:`
|
|
99
|
+
`}),(0,Tt.jsx)("div",{style:K,children:(0,Tt.jsx)("svg",{style:{height:S,width:"auto"},viewBox:"0 0 28 18",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",children:(0,Tt.jsx)("polyline",{points:"4 14 14 4 24 14"})})})]}),(0,Tt.jsx)("button",{onClick:x=>{x.stopPropagation(),e&&e({type:"cta",stickerId:t.id,redirectUrl:t.redirectUrl})},style:T,children:C||t.text})]})}default:return(0,Tt.jsxs)("div",{style:{padding:"10px",background:"white",color:"black",borderRadius:"4px"},children:["Unsupported interactive element: ",t.type]})}};return(0,Tt.jsx)("div",{style:u,className:`interactive-item-z${t.z??0}`,children:(0,Tt.jsx)("div",{style:m,children:f()})})};var qo=require("react/jsx-runtime"),mn=(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"},Cr=t=>{if(!t)return!1;let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")},wo=(...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(Cr(n)||n.length<50&&!/[?!.,;:\n]/.test(n))return n}}if(typeof e=="string"){let o=e.trim();if(!o)continue;if(Cr(o)||o.length<35&&!/[?!.,;:\n]/.test(o)&&o.split(/\s+/).length<=3)return o}}},co=(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,d=typeof o=="string"?o:o?.text||o?.title||s||"",c=o?.isCorrect===!0||String(o?.isCorrect)==="true"||o?.is_correct===!0||String(o?.is_correct)==="true",l=e!=null&&(String(i)===String(e)||String(n+1)===String(e)||o?.key&&String(o.key)===String(e)||o?.value&&String(o.value)===String(e));return{id:String(i),text:d,image:o?.image||o?.imageUrl||o?.image_url||o?.url||"",label:s,isCorrect:c||l}}):t&&typeof t=="object"?Object.entries(t).map(([o,n])=>{let i=typeof n=="string"?{text:n}:n||{},s=i?.isCorrect===!0||String(i?.isCorrect)==="true"||i?.is_correct===!0||String(i?.is_correct)==="true",d=e!=null&&(o===String(e)||i?.id===String(e)||i?.key===String(e));return{id:o,text:i.text||i.title||i.label||"",image:i.image||i.imageUrl||i.image_url||i.url||"",label:i.label,isCorrect:s||d}}):[],vr=t=>Array.isArray(t?.emojis)?t.emojis.map(e=>String(e)):co(t?.options).map(e=>e.text).filter(Boolean),wr=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},kr=(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"},Rr=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()}},ti=({content:t={},onInteraction:e,isEditing:o=!1,elapsedTime:n=0,isActive:i=!0,isMuted:s=!1})=>{let d=t?.canva||t?.styling?.canva||t?.meta?.canva||{height:1920,width:1080},c=Number(d?.width)||1080,l=Number(d?.height)||1920,y=.352,u=t?.elements||[],m=t?.image||[],f=t?.video||t?.styling?.video||[],P=Array.isArray(f)?f:typeof f=="object"&&f!==null?[f]:[],g=t?.lottie||t?.styling?.lottie||t?.styling?.lotties||t?.meta?.lottie||[],b=Array.isArray(g)?g:typeof g=="object"&&g!==null?[g]:[],R=t?.text||[],C=t?.ctas||[],h=t?.interactions||[],T=Array.isArray(t?.shopable)&&t.shopable.length>0?t.shopable:Array.isArray(t?.styling?.shopable)?t.styling.shopable:[],E=new Set(T.map(a=>a.id)),K=(t?.styling?.shopable||[]).concat(T.map(a=>a.styling).filter(Boolean)),S=mn(null,t)==="studio",M=(a,F=S)=>{if(a==null||a==="")return;if(typeof a=="string"&&(a.endsWith("cqh")||a.endsWith("px")||a.endsWith("%")||a.endsWith("em")||a.endsWith("rem")))return a;let r=Number(a);return isNaN(r)?String(a):r>=1e3?"999px":F||r<=100?`${r}cqh`:`${r/l*100}cqh`},x=(a,F,r=S)=>{if(a==null||a==="")return;if(typeof a=="string"&&(a.endsWith("cqh")||a.endsWith("px")||a.endsWith("%")||a.endsWith("em")||a.endsWith("rem")))return a;let p=Number(a);if(isNaN(p))return String(a);if(p>=1e3)return"999px";let j=r||p<=100?p:p/l*100;return j>=100?"999px":F&&F>0?`${j*F/100}cqh`:`${j}cqh`},N=(a,F=S)=>{if(a==null||a==="")return;if(typeof a=="string"&&(a.endsWith("cqh")||a.endsWith("px")||a.endsWith("%")||a.endsWith("em")||a.endsWith("rem")))return a;let r=Number(a);if(isNaN(r))return String(a);let p;return r<10?p=r:p=r/l*100,p<1.4?`clamp(11px, ${(p*1.25).toFixed(3)}cqh, 22px)`:p<2.5?`clamp(14px, ${(p*1.15).toFixed(3)}cqh, 32px)`:`clamp(16px, ${(p*1.05).toFixed(3)}cqh, 48px)`};if(u.length===0&&m.length===0&&P.length===0&&b.length===0&&R.length===0&&h.length===0&&T.length===0&&C.length===0)return null;let H=u.filter(a=>!E.has(a.id)).map(a=>{let F=a.custom||{},r=F.data||{},p=F.style||a.styling||{},j=mn(a,t),k=j==="studio",Q=a.position||a.postion||{},Y=a.size||{},st=a.x!==void 0?a.x:Q.x,dt=a.y!==void 0?a.y:Q.y,tt=a.width!==void 0?a.width:Y.width,ft=a.height!==void 0?a.height:Y.height,J=st!==void 0&&!isNaN(Number(st))?k?Number(st):Number(st)/c*100:10,ct=dt!==void 0&&!isNaN(Number(dt))?k?Number(dt):Number(dt)/l*100:15,xt=tt!==void 0&&!isNaN(Number(tt))?k?Number(tt):Number(tt)/c*100:80,pt=ft!==void 0&&!isNaN(Number(ft))?k?Number(ft):Number(ft)/l*100:void 0,ht=wo(r.question,r.prompt,r.title,p.question,a.question,p.prompt,a.font,p.font,r.font,r.fontFamily,a.fontFamily,p.fontFamily),$=wo(r.options,p.options,a.options,r.font,p.font,a.font,r.fontFamily,a.fontFamily,p.fontFamily),_=wo(r.font,p.font,a.font,r.fontFamily,a.fontFamily,p.fontFamily),D={id:a.id||Math.random().toString(),type:wr(F.interactiveType||a.widgetType||a.type||"unknown"),x:J,y:ct,width:xt,height:pt,url:a.url||r.url||a.link||r.link,rotation:p.rotation??a.rotation??0,z:a.z??a.position?.z??p.z??10,duration:r.duration||p.duration,styling:{backgroundColor:wt(p.background||p.containerBgColor||p.backgroundColor),borderRadius:p.borderRadius!==void 0?p.borderRadius>=100?"999px":M(p.borderRadius,k):p.radius!==void 0?p.radius>=100?"999px":M(p.radius,k):"0px",padding:M(p.containerPadding!==void 0?p.containerPadding:p.padding!==void 0?p.padding:0,k),shadow:p.shadow,fontSize:N(p.questionFontSize??p.questionFont?.fontSize??p.questionSize??p.fontSize,k),opacity:p.opacity??1,animation:Oo(p.animation),fontFamily:_,questionFontFamily:ht||_,optionFontFamily:$||_}};if(D.type==="poll"){let L=co(r.options),G=p.options?.font?.textAlign||p.optionFont?.textAlign||p.optionTextAlign||p.options?.textAlign||p.textAlign;return{...D,type:"poll",question:r.question||r.title||"Poll Question",options:L,layout:r.layout||{type:"vertical",columns:1},styling:{...D.styling,headerColor:wt(p.headerBgColor||p.background),headerTextColor:ot(p.questionColor||p.questionTextColor||p.question?.color),optionBgColor:wt(p.optionBgColor||p.options?.background)||"#1A1A1A",optionTextColor:ot(p.optionTextColor||p.options?.textColor)||"#ffffff",optionBorderRadius:p.optionBorderRadius!==void 0?x(p.optionBorderRadius,pt,k):p.options?.radius!==void 0?x(p.options?.radius,pt,k):"0px",optionTextAlign:G}}}if(D.type==="quiz"){let L=p.colors||{},G=r.correctAnswerId??r.correctOption??r.correct_answer_id??r.correct_option??r.correctAnswer??r.correctOptionId??r.isCorrect??a.correctAnswerId??a.correctOption,nt=co(r.options,G),yt=p.optionFontSize??p.optionFont?.fontSize??p.typography?.optionSize??p.options?.fontSize??16,qt=p.optionFont?.textAlign||p.optionTextAlign||p.options?.font?.textAlign||p.options?.textAlign||p.textAlign;return{...D,type:"quiz",question:r.question||r.title||"Quiz Question",options:nt,showExplanation:r.showExplanation??a.showExplanation??p.showExplanation??F.showExplanation??!0,explanation:r.explanation||a.explanation||p.explanation||F.explanation,url:r.url,styling:{...D.styling,backgroundColor:wt(p.background||p.containerBgColor||p.backgroundColor)||"transparent",questionTextColor:ot(p.questionColor||L.questionColor||p.question?.color||p.colors?.questionText)||"#FFFFFF",questionBgColor:wt(p.questionBgColor||L.questionBackground||p.question?.background||p.colors?.questionBg)||"#000000",optionBgColor:wt(p.optionBgColor||L.optionBackground||p.options?.background||p.colors?.optionBg)||"#FFFFFF",optionTextColor:ot(p.optionTextColor||L.optionTextColor||p.options?.textColor||p.colors?.optionText)||"#2B2B2B",borderColor:ot(p.borderColor)||"transparent",activeColor:ot(p.correctColor||L.correctColor||p.correctBorderColor)||"#10b981",incorrectColor:ot(p.incorrectColor||L.incorrectColor)||"#ef4444",optionBorderRadius:p.optionRadius!==void 0?p.optionRadius>=100?"999px":x(p.optionRadius,pt,k):p.optionBorderRadius!==void 0?p.optionBorderRadius>=100?"999px":x(p.optionBorderRadius,pt,k):"100px",optionFontSize:N(yt,k),optionTextAlign:qt}}}if(D.type==="rating")return{...D,type:"rating",title:r.title||"Do you like my space?",emoji:r.emoji||"\u{1F60D}",currentRating:r.currentRating,maxRating:r.maxRating,styling:{...D.styling,sliderTrackColor:ot(p.colors?.sliderTrack||p.sliderTrack),sliderFillColor:ot(p.colors?.sliderFill||p.sliderFill),emojiSize:p.emojiSize?k?`${Math.min(Number(p.emojiSize),32)}px`:`${Math.min(p.emojiSize*.45,32)}px`:void 0,titleColor:ot(p.colors?.titleColor||p.titleColor),titleFontSize:p.titleFontSize?k?`${Math.min(Number(p.titleFontSize),16)}px`:`${Math.min(p.titleFontSize*.4,16)}px`:void 0}};if(D.type==="question"){let L=p.optionRadius??p.optionBorderRadius??p.inputRadius??p.inputBorderRadius,G=p.borderRadius??p.radius??p.containerBorderRadius;return{...D,type:"question",question:r.question||r.title||"Ask me a question",placeholder:r.placeholder||"Type your answer...",styling:{...D.styling,borderRadius:G!==void 0?G>=100?"999px":M(G,k):"16px",promptColor:ot(p.questionColor||p.promptColor||p.textColor),inputBgColor:wt(p.inputBackground||p.inputBgColor),inputTextColor:ot(p.inputTextColor),submitBackground:wt(p.submitBackground),optionRadius:L!==void 0?L>=5?"9999px":x(L,pt,k):"9999px",inputBorderRadius:L!==void 0?L>=5?"9999px":x(L,pt,k):"9999px"}}}if(D.type==="image_quiz"||D.type==="imageQuiz"||D.type==="media_quiz"||(F.interactiveType||"").toLowerCase()==="media_quiz"){let L=r.correctAnswerId??r.correctOption??r.correct_answer_id??r.correct_option??r.correctAnswer??r.correctOptionId??r.isCorrect??a.correctAnswerId??a.correctOption,G=p.optionFontSize??p.optionFont?.fontSize??p.typography?.optionSize??p.options?.fontSize??13,nt=p.borderRadius??p.radius??p.containerBorderRadius,yt=p.optionRadius??p.optionBorderRadius??p.imageRadius;return{...D,type:"image_quiz",question:r.question||r.title||"Image Quiz",options:co(r.options||[],L),layout:r.layout??p.layout??a.layout,styling:{...D.styling,borderRadius:nt!==void 0?nt>=100?"999px":M(nt,k):void 0,optionRadius:yt!==void 0?yt>=100?"999px":x(yt,pt,k):void 0,questionBgColor:wt(p.questionBgColor||p.questionBackground),questionTextColor:ot(p.questionColor||p.questionTextColor),optionBgColor:wt(p.optionBgColor||p.optionBackground),optionTextColor:ot(p.optionTextColor||p.textColor),labelColor:ot(p.labelColor),borderColor:ot(p.borderColor),activeColor:ot(p.correctBorderColor||p.correctColor||p.activeColor),incorrectColor:ot(p.incorrectColor),imageRadius:yt!==void 0?x(yt,pt,k):void 0,optionFontSize:N(G,k)}}}if(D.type==="countdown")return{...D,type:"countdown",title:r.title||"Ends in...",targetDate:Rr(r),styling:{...D.styling,borderColor:ot(p.borderColor),digitBackground:wt(p.digitBackground),digitColor:ot(p.digitColor),digitSize:p.digitSize||p.fontSize?N(p.digitSize||p.fontSize,k):void 0,labelColor:ot(p.labelColor),titleColor:ot(p.titleColor)},display:r.display};if(D.type==="promo_code")return{...D,width:D.width?Math.max(D.width,65):75,type:"promo_code",code:kr(a,r,F),styling:{...D.styling,borderColor:ot(p.borderColor)}};if(D.type==="reaction"||D.type==="emoji_reaction"){let L=vr(r);return{...D,type:"reaction",emojis:L.length>0?L:["\u{1F60D}","\u{1F44D}"],source:j}}return D}),z=(t?.interactions||[]).filter(a=>!E.has(a.id)).map(a=>{let F=a.config||{},r=a.styling||a.style||{},p=mn(a,t),j=p==="studio",k=wr(a.interaction_type||a.type),Q=r.position||a.position||{},Y=r.size||a.size||{},st=Q.x??a.x,dt=Q.y??a.y,tt=Y.width??a.width,ft=Y.height??a.height,J=st!==void 0&&!isNaN(Number(st))?j?Number(st):Number(st)/c*100:10,ct=dt!==void 0&&!isNaN(Number(dt))?j?Number(dt):Number(dt)/l*100:15,xt=tt!==void 0&&!isNaN(Number(tt))?j?Number(tt):Number(tt)/c*100:80,pt=ft!==void 0&&!isNaN(Number(ft))?j?Number(ft):Number(ft)/l*100:void 0,ht=wo(r.question,a.question,r.prompt,F.question,F.prompt,F.title,r.font,a.font,F.font,r.fontFamily,F.fontFamily,a.fontFamily),$=wo(r.options,a.options,F.options,r.font,a.font,F.font,r.fontFamily,F.fontFamily,a.fontFamily),_=wo(r.font,a.font,F.font,r.fontFamily,F.fontFamily,a.fontFamily),D={id:a.id||Math.random().toString(),type:k,x:J,y:ct,width:xt,height:pt,rotation:r.rotation??a.rotation??0,z:a.z??a.position?.z??r.z??10,source:p,duration:F.duration||r.duration,styling:{backgroundColor:wt(r.background||r.containerBgColor||r.backgroundColor),borderRadius:r.borderRadius!==void 0?r.borderRadius>=100?"999px":M(r.borderRadius,j):r.radius!==void 0?r.radius>=100?"999px":M(r.radius,j):"0px",padding:M(r.containerPadding!==void 0?r.containerPadding:r.padding!==void 0?r.padding:0,j),shadow:r.shadow,fontSize:N(r.questionFontSize??r.questionFont?.fontSize??r.questionSize??r.fontSize,j),opacity:r.opacity??1,animation:Oo(r.animation),fontFamily:_,questionFontFamily:ht||_,optionFontFamily:$||_}};if(D.type==="rating"||D.type==="rate"){let L=r.colors||{};return{...D,type:"rating",title:F.title||"Do you like my space?",emoji:F.emoji||"\u{1F60D}",currentRating:F.currentRating,maxRating:F.maxRating,styling:{...D.styling,sliderTrackColor:ot(L.sliderTrack||r.colors?.sliderTrack||r.colors?.sliderTrack),sliderFillColor:ot(L.sliderFill||r.colors?.sliderFill||r.colors?.sliderFill),emojiSize:r.emojiSize?j?`${Math.min(Number(r.emojiSize),32)}px`:`${Math.min(r.emojiSize*.45,32)}px`:void 0,titleColor:ot(L.titleColor||r.colors?.titleColor||r.titleColor),titleFontSize:r.titleFontSize?j?`${Math.min(Number(r.titleFontSize),16)}px`:`${Math.min(r.titleFontSize*.4,16)}px`:void 0}}}if(D.type==="poll"){let L=co(F.options),G=r.options?.font?.textAlign||r.optionFont?.textAlign||r.optionTextAlign||r.options?.textAlign||r.textAlign;return{...D,type:"poll",question:F.question||F.title||"Poll Question",options:L,layout:F.layout||{type:"vertical",columns:1},styling:{...D.styling,headerColor:wt(r.headerBgColor||r.background),headerTextColor:ot(r.questionColor||r.questionTextColor||r.question?.color),optionBgColor:wt(r.optionBgColor||r.options?.background)||"#1A1A1A",optionTextColor:ot(r.optionTextColor||r.options?.textColor)||"#ffffff",optionBorderRadius:r.optionBorderRadius!==void 0?x(r.optionBorderRadius,pt,j):r.options?.radius!==void 0?x(r.options?.radius,pt,j):"0px",optionTextAlign:G}}}if(D.type==="quiz"){let L=r.colors||{},G=F.correctAnswerId??F.correctOption??F.correct_answer_id??F.correct_option??F.correctAnswer??F.correctOptionId??F.isCorrect??a.correctAnswerId??a.correctOption,nt=co(F.options,G),yt=r.optionFontSize??r.optionFont?.fontSize??r.typography?.optionSize??r.options?.fontSize??16,qt=r.optionFont?.textAlign||r.optionTextAlign||r.options?.font?.textAlign||r.options?.textAlign||r.textAlign;return{...D,type:"quiz",question:F.question||F.title||"Quiz Question",options:nt,showExplanation:F.showExplanation??a.showExplanation??r.showExplanation??!0,explanation:F.explanation||a.explanation||r.explanation,url:F.url,styling:{...D.styling,backgroundColor:wt(r.background||r.containerBgColor||r.backgroundColor)||"transparent",questionTextColor:ot(r.questionColor||L.questionColor||r.question?.color||r.colors?.questionText)||"#FFFFFF",questionBgColor:wt(r.questionBgColor||L.questionBackground||r.question?.background||r.colors?.questionBg)||"#000000",optionBgColor:wt(r.optionBgColor||L.optionBackground||r.options?.background||r.colors?.optionBg)||"#FFFFFF",optionTextColor:ot(r.optionTextColor||L.optionTextColor||r.options?.textColor||r.colors?.optionText)||"#2B2B2B",borderColor:ot(r.borderColor)||"transparent",activeColor:ot(r.correctColor||L.correctColor||r.correctBorderColor)||"#10b981",incorrectColor:ot(r.incorrectColor||L.incorrectColor)||"#ef4444",optionBorderRadius:r.optionRadius!==void 0?r.optionRadius>=100?"999px":x(r.optionRadius,pt,j):r.optionBorderRadius!==void 0?r.optionBorderRadius>=100?"999px":x(r.optionBorderRadius,pt,j):"100px",optionFontSize:N(yt,j),optionTextAlign:qt}}}if(D.type==="question"){let L=r.optionRadius??r.optionBorderRadius??r.inputRadius??r.inputBorderRadius,G=r.borderRadius??r.radius??r.containerBorderRadius;return{...D,type:"question",question:F.question||F.title||"Ask me a question",placeholder:F.placeholder||"Type your answer...",styling:{...D.styling,borderRadius:G!==void 0?G>=100?"999px":M(G,j):"16px",promptColor:ot(r.questionColor||r.promptColor||r.textColor),inputBgColor:wt(r.inputBackground||r.inputBgColor),inputTextColor:ot(r.inputTextColor),submitBackground:wt(r.submitBackground),optionRadius:L!==void 0?L>=5?"9999px":x(L,pt,j):"9999px",inputBorderRadius:L!==void 0?L>=5?"9999px":x(L,pt,j):"9999px"}}}if(D.type==="image_quiz"||D.type==="imageQuiz"||k==="media_quiz"||D.type==="media_quiz"){let L=F.correctAnswerId??F.correctOption??F.correct_answer_id??F.correct_option??F.correctAnswer??F.correctOptionId??F.isCorrect??a.correctAnswerId??a.correctOption,G=r.optionFontSize??r.optionFont?.fontSize??r.typography?.optionSize??r.options?.fontSize??13,nt=r.borderRadius??r.radius??r.containerBorderRadius,yt=r.optionRadius??r.optionBorderRadius??r.imageRadius;return{...D,type:"image_quiz",question:F.question||F.title||"Image Quiz",options:co(F.options||[],L),layout:F.layout??r.layout??a.layout,styling:{...D.styling,borderRadius:nt!==void 0?nt>=100?"999px":M(nt,j):void 0,optionRadius:yt!==void 0?yt>=100?"999px":x(yt,pt,j):void 0,questionBgColor:wt(r.questionBgColor||r.questionBackground),questionTextColor:ot(r.questionColor||r.questionTextColor),optionBgColor:wt(r.optionBgColor||r.optionBackground),optionTextColor:ot(r.optionTextColor||r.textColor),labelColor:ot(r.labelColor),borderColor:ot(r.borderColor),activeColor:ot(r.correctBorderColor||r.correctColor||r.activeColor),incorrectColor:ot(r.incorrectColor),imageRadius:yt!==void 0?x(yt,pt,j):void 0,optionFontSize:N(G,j)}}}if(D.type==="countdown")return{...D,type:"countdown",title:F.title||"Ends in...",targetDate:Rr(F),styling:{...D.styling,borderColor:ot(r.borderColor),digitBackground:wt(r.digitBackground),digitColor:ot(r.digitColor),digitSize:r.digitSize||r.fontSize?N(r.digitSize||r.fontSize,j):void 0,labelColor:ot(r.labelColor),titleColor:ot(r.titleColor),labelFontSize:r.labelFontSize?N(r.labelFontSize,j):void 0},display:F.display||a.display};if(D.type==="promo_code")return{...D,width:D.width?Math.max(D.width,65):75,type:"promo_code",code:kr(a,F,r),styling:{...D.styling,borderColor:ot(r.borderColor)}};if(D.type==="reaction"||D.type==="emoji_reaction"){let L=vr(F);return{...D,type:"reaction",emojis:L.length>0?L:["\u{1F60D}","\u{1F44D}"]}}return D}),O=T.map(a=>{let F=K.find(L=>String(L?.id)===String(a?.id))||K.find(L=>L?.id===void 0)||{},p=mn(a,t)==="studio",j={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},k={...F,...a?.styling||{},...Object.fromEntries(Object.entries(j).filter(([,L])=>L!==void 0))},Q=k.position||{},Y=k.size||{},st=k.cardBorderRadius!==void 0?Number(k.cardBorderRadius):void 0,dt=k.cardRadiusPercent!==void 0?Number(k.cardRadiusPercent):void 0,tt=Y.height!==void 0?Number(Y.height):void 0,ft=st===void 0&&dt!==void 0&&tt!==void 0?Math.max(0,Math.min(100,dt))/100*(tt/2):void 0,J=st??ft,ct=J!==void 0&&!isNaN(J)?J*y:void 0,xt=Q.x!==void 0?p?Number(Q.x):Number(Q.x)/c*100:0,pt=Y.width!==void 0?p?Number(Y.width):Number(Y.width)/c*100:100,ht=Y.height!==void 0?p?Number(Y.height):Number(Y.height)/l*100:void 0,$=Q.y!==void 0?p?Number(Q.y):Number(Q.y)/l*100:ht?100-ht-2.5:85;ht&&$+ht>96?$=Math.max(0,100-ht):$>75&&ht&&$+ht>91&&($=Math.max(0,100-ht-1));let _=Array.isArray(a.product)&&a.product.length>0,D=_?a.product:a.static||[];return{id:a.id||Math.random().toString(),type:"buy",shopableType:_?"product":"static",x:xt,y:$,width:pt,height:ht,rotation:k.rotation??0,z:k.z??10,products:D.map(L=>{let G=L.productData||L||{},nt=G.attributes||L.attributes||{},yt=nt.sales_price||G.price||nt.price||L.price,qt=nt.sales_price?G.price||nt.price||L.price:G.oldPrice||L.oldPrice,At=G.color||nt.color||L.color,Ut=G.size||nt.size||L.size,$t=nt.colors||[];$t.length===0&&At&&($t=[{id:At,hex:At,name:At}]);let le=nt.sizes||[];le.length===0&&Ut&&(le=typeof Ut=="string"?Ut.split(",").map(Te=>Te.trim()):[Ut]);let ye={description:G.description||nt.description||L.description,color:At,size:Ut,colors:$t,sizes:le,imageUrls:nt.imageUrls||[nt.image_link||G.imageUrl||G.image||L.imageUrl||L.image||L.url].filter(Boolean),availability:G.availability||nt.availability||L.availability,tags:G.tags||nt.tags||L.tags,...nt};return{id:G.productId||G.id||L.productId||L.id||Math.random().toString(),image:nt.image_link||G.imageUrl||G.image||L.imageUrl||L.image||L.url,url:G.link||G.url||L.link||L.url||L.redirectUrl,title:G.title||L.title,price:yt,oldPrice:qt,redirectUrl:L.redirectUrl||G.link||L.link||L.url,svg:G.svg||L.svg,productId:G.productId||L.productId,collectionId:G.collectionId||L.collectionId,feedId:G.feedId||L.feedId,attributes:ye}}),styling:{backgroundColor:wt(k.background),cardBackground:wt(k.cardBackground)||wt(k.background)||"#ffffff",cardBorderRadius:J!==void 0&&!isNaN(J)?p?`${J}cqh`:`${ct}px`:p?"1cqh":"10px",cardRadiusPercent:dt,transparent:k.transparent===!0,textColor:ot(k.textColor)||"#ffffff",buttonBackground:wt(k.buttonBackground)||"#000000",buttonTextColor:ot(k.buttonTextColor)||"#ffffff",buttonFontSize:N(k.buttonFontSize||12,p),buttonBorderRadius:k.buttonBorderRadius!==void 0?p?`${k.buttonBorderRadius}cqh`:`${k.buttonBorderRadius}px`:p?"10cqh":"100px",titleColor:ot(k.titleColor||k.textColor)||"#1a1a2e",titleFontSize:N(k.titleFontSize||14,p),titleFontWeight:k.titleFontWeight?String(k.titleFontWeight):"600",priceColor:ot(k.priceColor||k.textColor)||"#1a1a2e",priceFontSize:N(k.priceFontSize||16,p),priceFontWeight:k.priceFontWeight?String(k.priceFontWeight):"700",mrpColor:ot(k.mrpColor)||"#8b8b98",mrpFontSize:N(k.mrpFontSize||12,p),mrpFontWeight:k.mrpFontWeight?String(k.mrpFontWeight):"500",imageRadius:k.imageRadius!==void 0?p?`${k.imageRadius}cqh`:`${Number(k.imageRadius)*y}px`:p?"1cqh":"10px",animation:Oo(k.animation)}}}),B=m.map(a=>{let r=(t?.styling?.image||t?.styling?.images||[]).find(k=>k.id===a.id)||{},p=a.position||r.position||a.postion||{x:0,y:0},j=a.borderRadius??a.styling?.borderRadius??r.borderRadius??r.styling?.borderRadius??a.imageRadius??a.radius;return{id:a.id||Math.random().toString(),type:"image",x:S?Number(p.x):p.x/c*100,y:S?Number(p.y):p.y/l*100,width:S?Number(a.width):a.width/c*100,height:a.height?S?Number(a.height):a.height/l*100:void 0,url:a.link||a.url,z:a.z??r.z??0,styling:{borderRadius:j!==void 0?M(j,S):void 0,objectFit:(()=>{let k=a.objectFit||r.objectFit||a.sizing||r.sizing;return k==="fill"||k==="cover"?"cover":k==="fit"||k==="contain"?"contain":k==="stretch"?"fill":"contain"})(),objectPosition:Co(a.objectPosition||r.objectPosition||a.positionStr),border:a.border||a.styling?.border||r.border,boxShadow:a.shadow||a.styling?.shadow||r.shadow,opacity:(a.opacity!==void 0?a.opacity:r.opacity)!==void 0?Number(a.opacity!==void 0?a.opacity:r.opacity)/100:void 0}}}),Z=P.map(a=>{let r=(t?.styling?.video||t?.styling?.videos||[]).find(tt=>tt.id===a.id)||{},p=a.position||r.position||{x:a.x,y:a.y},j=p.x??a.x,k=p.y??a.y,Q=a.width??r.width,Y=a.height??r.height,st=a.cornerRadius??a.borderRadius??r.cornerRadius??r.borderRadius??a.radius,dt=a.rotation!==void 0?a.rotation:r.rotation;return{id:a.id||Math.random().toString(),type:"video",x:j!==void 0&&!isNaN(Number(j))?S?Number(j):Number(j)/c*100:0,y:k!==void 0&&!isNaN(Number(k))?S?Number(k):Number(k)/l*100:0,width:Q!==void 0&&!isNaN(Number(Q))?S?Number(Q):Number(Q)/c*100:100,height:Y!==void 0&&!isNaN(Number(Y))?S?Number(Y):Number(Y)/l*100:void 0,url:a.link||a.url||a.src||r.link||r.url,rotation:dt??0,z:a.z??r.z??2,loop:a.loop??r.loop??!0,muted:a.muted??r.muted??!1,isActive:i,isMuted:s,styling:{borderRadius:st!==void 0?M(st,S):void 0,objectFit:(()=>{let tt=a.objectFit||r.objectFit||a.sizing||r.sizing;return tt==="fill"||tt==="cover"?"cover":tt==="fit"||tt==="contain"?"contain":tt==="stretch"?"fill":"contain"})(),objectPosition:Co(a.objectPosition||r.objectPosition),border:a.border||a.styling?.border||r.border,boxShadow:a.shadow||a.styling?.shadow||r.shadow,opacity:(a.opacity!==void 0?a.opacity:r.opacity)!==void 0?Number(a.opacity!==void 0?a.opacity:r.opacity)/100:void 0}}}),v=b.map(a=>{let r=(t?.styling?.lottie||t?.styling?.lotties||[]).find(ct=>ct.id===a.id)||{},p=a.position||r.position||{x:a.x,y:a.y},j=p.x??a.x,k=p.y??a.y,Q=a.width??r.width,Y=a.height??r.height,st=a.cornerRadius??a.borderRadius??r.cornerRadius??r.borderRadius??a.radius,dt=a.rotation!==void 0?a.rotation:r.rotation,tt=a.flip||r.flip||{},ft="";tt.horizontal&&tt.vertical?ft="scale(-1, -1)":tt.horizontal?ft="scaleX(-1)":tt.vertical&&(ft="scaleY(-1)");let J=a.duration||r.duration;return{id:a.id||Math.random().toString(),type:"lottie",x:j!==void 0&&!isNaN(Number(j))?S?Number(j):Number(j)/c*100:0,y:k!==void 0&&!isNaN(Number(k))?S?Number(k):Number(k)/l*100:0,width:Q!==void 0&&!isNaN(Number(Q))?S?Number(Q):Number(Q)/c*100:100,height:Y!==void 0&&!isNaN(Number(Y))?S?Number(Y):Number(Y)/l*100:void 0,url:a.link||a.url||a.src||a.lottie_url||r.link||r.url,rotation:dt??0,z:a.z??r.z??3,duration:J?.start!==void 0?J:void 0,loop:a.loop??r.loop??!0,autoplay:a.autoplay??r.autoplay??!0,styling:{borderRadius:st!==void 0?M(st,S):void 0,border:a.border||a.styling?.border||r.border,boxShadow:a.shadow||a.styling?.shadow||r.shadow,opacity:(a.opacity!==void 0?a.opacity:r.opacity)!==void 0?Number(a.opacity!==void 0?a.opacity:r.opacity)/100:void 0,transform:ft||void 0,animation:Oo(a.animation||r.animation)}}}),A=R.map(a=>{let r=(t?.styling?.text||[]).find(J=>J.id===a.id)||{},p=a.position||r.position||{x:0,y:0},j=a.font||r.font||{},k=a.size||r.size||{},Q=a.alignment||r.alignment||{},Y=a.color||r.color,st=j.fontDecoration||[],dt=st.includes("underline")?"underline":st.includes("line-through")?"line-through":void 0,tt=a.rotation!==void 0?a.rotation:r.rotation,ft=j.fontSize??a.fontSize??r.fontSize??r.font?.fontSize;return{id:a.id||Math.random().toString(),type:"text",x:S?Number(p.x):p.x/c*100,y:S?Number(p.y):p.y/l*100,width:k.width?S?Number(k.width):k.width/c*100:void 0,height:k.height?S?Number(k.height):k.height/l*100:void 0,rotation:tt??0,text:a.text||a.value||r.text||r.value||"",z:a.z??r.z??1,styling:{color:ot(Y)||"#000000",fontSize:ft?N(ft,S):void 0,fontFamily:j.fontFamily,fontStyle:j.fontStyle||(st.includes("italic")?"italic":"normal"),fontWeight:j.fontWeight||(st.includes("bold")?"bold":"normal"),textDecoration:dt,lineHeight:a.lineHeight!==void 0?a.lineHeight:r.lineHeight,letterSpacing:(a.letterSpacing!==void 0?a.letterSpacing:r.letterSpacing)!==void 0?`${a.letterSpacing!==void 0?a.letterSpacing:r.letterSpacing}px`:void 0,opacity:(a.opacity!==void 0?a.opacity:r.opacity)!==void 0?Number(a.opacity!==void 0?a.opacity:r.opacity)/100:void 0,textAlign:Q.horizontalAlignment||"left",verticalAlignment:Q.verticalAlignment||"top"}}}),V=C.map(a=>{let r=(t?.styling?.ctas||t?.styling?.cta||[]).find(_=>_.id===a.id)||{},p=a.position||r.position||{x:0,y:0},j=a.size||r.size||{},k=a.font||r.font||{},Q=k.fontDecoration||[],Y=Q.includes("underline")?"underline":Q.includes("line-through")?"line-through":void 0,st=a.rotation!==void 0?a.rotation:r.rotation,dt=k.fontSize??a.fontSize??r.fontSize??r.font?.fontSize,tt=a.borderRadius??a.cornerRadius??a.imageRadius??a.radius??a.styling?.borderRadius??a.styling?.cornerRadius??a.styling?.imageRadius??r.borderRadius??r.cornerRadius??r.imageRadius??r.styling?.borderRadius??r.styling?.cornerRadius,J=(_=>{if(!(_==null||_==="")){if(typeof _=="number"||typeof _=="string"&&/^[\d.-]+$/.test(_.trim()))return M(_,S);if(typeof _=="string")return _;if(typeof _=="object"){let D=M(_.topLeft??_.top_left??0,S)||"0px",L=M(_.topRight??_.top_right??0,S)||"0px",G=M(_.bottomRight??_.bottom_right??0,S)||"0px",nt=M(_.bottomLeft??_.bottom_left??0,S)||"0px";return`${D} ${L} ${G} ${nt}`}}})(tt),ct=_=>{if(_==null||_==="")return;if(typeof _=="string"&&(_.endsWith("cqh")||_.endsWith("px")||_.endsWith("%")||_.endsWith("em")||_.endsWith("rem")||_.includes("clamp")))return _;let D=Number(_);if(isNaN(D))return String(_);let L=D<1?D*2.5:D;return`clamp(12px, ${Math.max(L,1.2).toFixed(2)}cqh, 28px)`},xt=a.borderWidth??a.styling?.borderWidth??r.borderWidth??r.styling?.borderWidth,pt=a.opacity!==void 0?a.opacity:a.styling?.opacity!==void 0?a.styling?.opacity:r.opacity,ht=pt!==void 0?Number(pt)>1?Number(pt)/100:Number(pt):void 0,$=a.ctaType||a.type||r.ctaType||r.type||((a.url||a.image||a.imageUrl)&&!a.text?"image":"classic");return{id:a.id||Math.random().toString(),type:"cta",x:S?Number(p.x):p.x/c*100,y:S?Number(p.y):p.y/l*100,width:j.width?S?Number(j.width):j.width/c*100:void 0,height:j.height?S?Number(j.height):j.height/l*100:void 0,rotation:st??0,text:a.text||r.text||"",redirectUrl:a.redirectUrl||r.redirectUrl||a.link||r.link,ctaType:$,url:a.url||a.image||a.imageUrl||r.url||r.image||r.imageUrl,z:a.z??r.z??10,source:S?"studio":"dashboard",styling:{backgroundColor:wt(a.background||r.background||a.color),textColor:ot(a.textColor||r.textColor)||"#FFFFFF",borderColor:ot(a.borderColor||r.borderColor||a.styling?.borderColor||r.styling?.borderColor)||"#FFFFFF",borderWidth:xt!==void 0&&Number(xt)>0?M(xt,S):void 0,borderRadius:J,fontSize:dt?N(dt,S):void 0,fontFamily:k.fontFamily,fontStyle:k.fontStyle||(Q.includes("italic")?"italic":"normal"),fontWeight:k.fontWeight||(Q.includes("bold")?"bold":"normal"),textDecoration:Y,pillH:a.pillH??r.pillH,arrowAnimation:a.arrowAnimation??r.arrowAnimation,arrowColor:ot(a.arrowColor||r.arrowColor),arrowSize:ct(a.arrowSize??r.arrowSize),transparent:a.transparent??r.transparent,opacity:ht}}}),rt=[...H,...z,...O,...B,...Z,...v,...A,...V].filter(a=>{if(!a.duration)return!0;let{start:F,end:r}=a.duration;return n>=F&&n<=r}).sort((a,F)=>(a.z??0)-(F.z??0));return console.log("InteractiveOverlay Debug - content.ctas:",C,"displayCtas:",V,"displayItems:",rt),(0,qo.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,pointerEvents:"none",overflow:"hidden",containerType:"size"},children:[(0,qo.jsx)("style",{children:`
|
|
100
100
|
@keyframes appstorys-fade-in {
|
|
101
101
|
from { opacity: 0; transform: translateY(10px); }
|
|
102
102
|
to { opacity: 1; transform: translateY(0); }
|
|
@@ -116,16 +116,16 @@
|
|
|
116
116
|
70% { opacity: 1; transform: scale(0.95); }
|
|
117
117
|
100% { opacity: 1; transform: scale(1); }
|
|
118
118
|
}
|
|
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:`
|
|
119
|
+
`}),rt.map(a=>!a||typeof a!="object"||!(a.type||"").toLowerCase()?null:(0,qo.jsx)(Sr,{data:a,onInteraction:e,isEditing:o,isActive:i,isMuted:s},a.id))]})};var Tr=require("react"),Je=require("react/jsx-runtime"),Hs=({isPaused:t,onPress:e,style:o,size:n=36})=>{let[i,s]=(0,Tr.useState)(!1);return(0,Je.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,Je.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:(0,Je.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,Je.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:[(0,Je.jsx)("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),(0,Je.jsx)("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})})},Fr=Hs;var yn=require("react/jsx-runtime"),Vs=t=>{switch(t){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},Ys=({cta:t,buttonText:e,onPress:o})=>{if(!t||!e||e.trim()==="")return null;let n=t?.opacity,i=n!==void 0?Number(n)>1?Number(n)/100:Number(n):void 0;return(0,yn.jsx)("div",{style:{position:"absolute",bottom:t?.margin?.bottom,left:t?.margin?.left,right:t?.margin?.right,display:"flex",justifyContent:Vs(t?.container?.alignment),width:"100%",pointerEvents:"none",boxSizing:"border-box",zIndex:10,opacity:i},children:(0,yn.jsx)("button",{style:{backgroundColor:wt(t?.container?.backgroundColor)||"#F7921C",borderColor:ot(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,yn.jsx)("span",{style:{color:ot(t?.text?.color)||"#ffffff",fontSize:t?.text?.fontSize||14,fontFamily:gt(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:Ne(e)})})})},ei=Ys;var Me=require("react/jsx-runtime"),Gs=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,style:n})=>{if(!t||t.enabled===!1)return null;let{size:i=18,margin:s,color:d,image:c,selectedStyle:l}=t,y=o?40:i,u={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:y,height:y,backgroundColor:d?.fill||"transparent",borderColor:d?.stroke||"transparent",borderWidth:y*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"relative",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:d?.stroke?"solid":"none",...n},m=()=>{let f=d?.cross||"#ffffff";return(0,Me.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,Me.jsx)("circle",{cx:"18",cy:"5",r:"3"}),(0,Me.jsx)("circle",{cx:"6",cy:"12",r:"3"}),(0,Me.jsx)("circle",{cx:"18",cy:"19",r:"3"}),(0,Me.jsx)("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),(0,Me.jsx)("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})};return(0,Me.jsx)("button",{onClick:e,style:u,children:c&&c.trim()!==""?(0,Me.jsx)("img",{src:c,style:{width:y,height:y,objectFit:"contain"},alt:"share"}):m()})},oi=Gs;var q=require("react/jsx-runtime"),hn=t=>{if(t)return t.content?.canva||t.canva||t.styling?.canva||t.meta?.canva||t.content?.styling?.canva||t.content?.meta?.canva},Qs=t=>{let e=hn(t),o=Number(e?.width),n=Number(e?.height);return o>0&&n>0?o/n:9/16},Uo=.63;var qe=580,ni="cubic-bezier(0.65, 0, 0.35, 1)",ii="cubic-bezier(0.45, 0, 0.25, 1)";function Js(t,e){let o=Math.round(e*1.08),n=o+Math.round(e*Uo)+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(${Uo})`,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(${Uo})`,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(${Uo})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};case"far-right":return{transform:`translateX(${n}px) scale(${Uo})`,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 Ir=({src:t,isActive:e,isAnimating:o,isMuted:n,onLoadedData:i,activeVideoRef:s,objectFit:d="contain",objectPosition:c="center center"})=>{let l=bt.default.useRef(null);return bt.default.useEffect(()=>{e&&!o?(s.current=l.current,l.current?.play().catch(()=>{}),l.current&&l.current.readyState>=1&&i?.()):(l.current?.pause(),s.current===l.current&&(s.current=null))},[e,o,t,s,i]),(0,q.jsx)("video",{ref:l,src:t,playsInline:!0,muted:n,onLoadedData:i,onCanPlay:i,onLoadedMetadata:i,style:{width:"100%",height:"100%",objectFit:d,objectPosition:c}})},zr="appstorys_viewed_slide_ids",ri="appstorys_clicked_interaction_ids";var Xs=t=>{try{let e=localStorage.getItem(zr),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(zr,JSON.stringify(o)))}catch{}},Ks=t=>{try{let e=localStorage.getItem(ri);if(!e)return!1;let o=JSON.parse(e);return Array.isArray(o)&&o.includes(t)}catch{return!1}},Zs=t=>{try{let e=localStorage.getItem(ri),o=e?JSON.parse(e):[];Array.isArray(o)&&!o.includes(t)&&(o.push(t),localStorage.setItem(ri,JSON.stringify(o)))}catch{}},Br=({stories:t,activeStoryIndex:e,dataId:o,viewedStories:n,setViewedStories:i,onNextStory:s,onPrevStory:d,onClose:c})=>{let l=t[e],y=w=>{if(!w?.id)return 0;try{let U=`appstorys_cta_redirect_${w.id}`,St=sessionStorage.getItem(U);if(St){let Yt=JSON.parse(St),Lt=Date.now()-(Yt.timestamp||0),We=w.slides?.length||1;if(sessionStorage.removeItem(U),Lt<=300*1e3&&typeof Yt.slideIndex=="number"&&Yt.slideIndex>=0&&Yt.slideIndex<We)return Yt.slideIndex}}catch{}return 0},[u,m]=(0,bt.useState)(()=>y(t[e])),[f,P]=(0,bt.useState)(0),[g,b]=(0,bt.useState)(t[e]?.styling?.soundToggle?.defaultSound==="no"),[R,C]=(0,bt.useState)(!1),[h,T]=(0,bt.useState)(!1),[E,K]=(0,bt.useState)(!1),[I,S]=(0,bt.useState)(null),[M,x]=(0,bt.useState)({width:typeof window<"u"?window.innerWidth:1280,height:typeof window<"u"?window.innerHeight:800}),[N,H]=(0,bt.useState)(typeof window<"u"?window.innerWidth>=1024:!1),[z,O]=(0,bt.useState)(!1),[B,Z]=(0,bt.useState)(null),[v,A]=(0,bt.useState)(null),[V,rt]=(0,bt.useState)(null),[lt,a]=(0,bt.useState)(!1),[F,r]=(0,bt.useState)("none"),[p,j]=(0,bt.useState)(null),k=(0,bt.useRef)(null),Q=(0,bt.useRef)(null),Y=(0,bt.useRef)(0),st=(0,bt.useRef)(null),dt=(0,bt.useRef)(!1),tt=l?.slides[u],ft=tt?.styling,J=ft?.editorSource||ft?.meta?.editorSource,ct=J==="studio"||J==="editor",xt=ct?ft?.background?.media?.mediaUrl:tt?.image,pt=ct?tt?.content?.button_text:tt?.button_text,ht=ct?tt?.content?.link:tt?.link,$=w=>{if(!w)return;if(w.video&&typeof w.video=="string")return w.video;let U=w.styling?.background?.media||w.content?.styling?.background?.media||w.content?.background?.media;if(U&&(U.mediaType==="video"||U.type==="video"||U.isVideo))return U.mediaUrl||U.url||U.link},_=$(tt),D=hn(tt),L=Qs(tt),G=N?160:80,nt=Math.max(350,M.height-G),yt=N?M.width*.75:M.width*.95,qt=Math.min(nt,yt/L),At=Math.round(N?Math.max(450,Math.min(qt,850)):Math.min(nt,850)),Ut=Math.round(At*L),$t=(w,U)=>{z||(P(0),rt(w),Z(u),A(U),O(!0),setTimeout(()=>{m(U),P(0),C(!1),O(!1),Z(null),A(null),rt(null)},qe+20))},le=w=>{if(!(lt||z)){if(P(0),w==="next"){if(e>=t.length-1){s();return}}else if(e<=0){d();return}a(!0),j(w),r("out"),setTimeout(()=>{w==="next"?s():d(),r("prepare-in"),setTimeout(()=>{r("in"),setTimeout(()=>{a(!1),r("none"),j(null)},320)},35)},280)}},ye=()=>{if(!(z||lt))if(u<(l?.slides?.length||0)-1)$t("next",u+1);else{if(l&&!n.includes(l.id)){let w=[...n,l.id];i(w),localStorage.setItem("app_storys_viewed_stories",JSON.stringify(w))}le("next")}},Te=()=>{z||lt||(u>0?$t("prev",u-1):le("prev"))},He=async()=>{if(!l)return;let w={title:l.name,text:`Check out this story: ${l.name}`,url:window.location.href};if(tt?.id&&at("shared",o,{story_slide:tt.id}),navigator.share)try{await navigator.share(w)}catch{}else if(navigator.clipboard)try{await navigator.clipboard.writeText(window.location.href),S("Story link copied to clipboard!"),setTimeout(()=>S(null),2500)}catch{}};(0,bt.useEffect)(()=>{let w=()=>{x({width:window.innerWidth,height:window.innerHeight}),H(window.innerWidth>=1024)};return window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[]),(0,bt.useEffect)(()=>{let w=document.body.style.overflow,U=document.body.style.touchAction;return document.body.style.overflow="hidden",document.body.style.touchAction="none",()=>{document.body.style.overflow=w,document.body.style.touchAction=U}},[]);let uo=(0,bt.useRef)(e),po=(0,bt.useRef)(ye),Ko=(0,bt.useRef)(Te),wn=(0,bt.useRef)(He),Mo=(0,bt.useRef)(c);if((0,bt.useEffect)(()=>{po.current=ye,Ko.current=Te,wn.current=He,Mo.current=c}),(0,bt.useEffect)(()=>{let w=e<uo.current;uo.current=e;let U=w&&l?.slides?.length?l.slides.length-1:y(l);m(U),P(0),C(!1),T(!1),O(!1),a(!1),r("none"),j(null),Z(null),A(null),rt(null),b(l?.styling?.soundToggle?.defaultSound==="no")},[e]),(0,bt.useEffect)(()=>{let w=()=>{document.hidden?(dt.current=h,T(!0),Q.current&&Q.current.pause()):dt.current||(T(!1),Q.current&&Q.current.play().catch(()=>{}))};return document.addEventListener("visibilitychange",w),()=>document.removeEventListener("visibilitychange",w)},[h]),(0,bt.useEffect)(()=>{let w=U=>{if(!(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA"))switch(U.key){case"ArrowRight":po.current();break;case"ArrowLeft":Ko.current();break;case" ":U.preventDefault(),T(St=>!St);break;case"Escape":Mo.current();break;case"s":case"S":U.preventDefault(),wn.current();break}};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[]),(0,bt.useEffect)(()=>{if(l&&tt){let w=tt.id?String(tt.id):`${l.id||o}_slide_${u}`,U=`${e}_${u}_${w}`;st.current!==U&&(st.current=U,Xs(w),at("viewed",o,{story_slide:w}))}},[e,u,l?.id,o,tt?.id]),(0,bt.useEffect)(()=>{if(l&&tt&&!!_&&!R){let U=setTimeout(()=>{C(!0)},2e3);return()=>clearTimeout(U)}},[e,u,_,R]),(0,bt.useEffect)(()=>{if(l&&tt){let w=l.styling?.slideShowTime||5,U=!!_;if(k.current&&clearInterval(k.current),h){Q.current&&Q.current.pause();return}else Q.current&&Q.current.play().catch(()=>{});return U&&!R||z||lt?void 0:(k.current=setInterval(()=>{P(St=>St>=100?(ye(),100):St+100/(w*10))},100),()=>{k.current&&clearInterval(k.current)})}},[e,u,h,R,z,lt,_]),!tt)return null;let _o=()=>F==="out"?{transform:`translateX(${p==="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"}:F==="prepare-in"?{transform:`translateX(${p==="next"?120:-120}px) scale(0.92)`,opacity:0,filter:"blur(6px)",transition:"none",willChange:"transform, opacity, filter"}:F==="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)"},Fe=()=>{Y.current=Date.now(),T(!0)},re=w=>{T(!1),Date.now()-Y.current<300&&(w==="next"?ye():Te())},_e=()=>C(!0),Ke=()=>{if(l?.id)try{sessionStorage.setItem(`appstorys_cta_redirect_${l.id}`,JSON.stringify({slideIndex:u,timestamp:Date.now()}))}catch{}},X=w=>{let U=w?.styling,St=U?.editorSource||U?.meta?.editorSource,Lt=St==="studio"||St==="editor"?w.content?.link:w.link;if(Lt){if(Ke(),at("clicked",o,{story_slide:w.id}),Rt(Lt)){c();return}Lt.startsWith("http")?window.open(Lt,"_blank"):window.location.href=Lt}},Ct=async(w,U)=>{let{type:St,questionId:Yt,pollId:Lt,quizId:We,ratingId:ze,reactionId:go,productId:to,optionId:Wo,value:de,stickerId:eo,redirectUrl:fe,code:oo}=w;if(St==="cta"){if(fe){if(Ke(),at("clicked",o,{story_slide:U.id,cta_id:eo}),Rt(fe)){c();return}fe.startsWith("http")?window.open(fe,"_blank"):window.location.href=fe}return}T(!0);let he=St||"interaction";he==="quizz"&&(he="quiz"),(he==="image"||St?.startsWith("image_quiz"))&&(he="quiz"),St?.startsWith("promo")&&(he="promo_code");let se=eo||Yt||Lt||We||ze||go||to||U.id;if(Ks(se))return;Zs(se);let no=Wo||w.selected_option||w.emoji||de||oo||"",fo=W.getState().userId||"anonymous",Rn=Zi(),Be=await Mt(),gi={interaction_type:he,interaction_id:se,story_slide:U.id,selected_option:String(no)};de!=null&&de!==""&&(gi.value=String(de)),fetch(`${Rn}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...Be?{Authorization:`Bearer ${Be}`}:{}},body:JSON.stringify({user_id:fo,campaign_id:o,event:"clicked",metadata:gi})}).catch(as=>console.error("AppStorys: Instant Tracking Failed",as))},zt=w=>{w.stopPropagation(),b(!g)},pe=l?.styling?.crossButton,vt=l?.styling?.soundToggle,Ie=tt?.styling?.cta,ge=w=>z?V==="next"?w===B?"left":w===v?"center":w===(B??0)-1?"far-left":w===(B??0)-2?"hidden":w===(v??0)+1?"right":w===(v??0)+2?"far-right":"hidden":w===B?"right":w===v?"center":w===(B??0)+1?"far-right":w===(B??0)+2?"hidden":w===(v??0)-1?"left":w===(v??0)-2?"far-left":"hidden":w===u?"center":w===u-1?"left":w===u-2?"far-left":w===u+1?"right":w===u+2?"far-right":"hidden",Ve=N?{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"},Xt=N?{position:"absolute",width:`${Ut}px`,height:`${At}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 * ${L}))`,height:`min(100dvh, calc(100vw / ${L}))`,aspectRatio:`${L}`,backgroundColor:"#000",borderRadius:"0px",overflow:"hidden",display:"flex",flexDirection:"column"},Ze={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"},Ht=l.slides.reduce((w,U,St)=>(ge(St)!=="hidden"&&w.push(St),w),[]),Nt=new Set(Ht);return Nt.add(u),u>0&&Nt.add(u-1),u>1&&Nt.add(u-2),u<l.slides.length-1&&Nt.add(u+1),u<l.slides.length-2&&Nt.add(u+2),(0,q.jsxs)("div",{style:Ve,onClick:()=>!N&&ye(),children:[(0,q.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:[_?(0,q.jsx)("video",{src:_,style:{width:"100%",height:"100%",objectFit:"cover",filter:"blur(120px) saturate(1.8) opacity(0.35)"},muted:!0}):xt||!ct&&l.thumbnail?(0,q.jsx)(Ae,{src:xt||l.thumbnail,style:{width:"100%",height:"100%",filter:"blur(120px) saturate(1.8) opacity(0.35)"}}):null,(0,q.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(5, 5, 8, 0.4)"}})]},`${e}-${z?v:u}`),N&&(0,q.jsxs)("div",{style:{width:"100%",display:"flex",flexDirection:"column",paddingTop:"20px",zIndex:10,..._o()},children:[(0,q.jsx)("div",{style:{width:"100%",display:"flex",gap:"8px",padding:"0 20px",boxSizing:"border-box"},children:l.slides.map((w,U)=>{let St=z&&v!==null?v:u,Yt="0%";return U<St?Yt="100%":U===St&&(Yt=`${f}%`),(0,q.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.15)",borderRadius:"2px",overflow:"hidden"},children:(0,q.jsx)("div",{style:{width:Yt,height:"100%",backgroundColor:"white",transition:U===St&&f>0&&!z?"width 0.1s linear":"none"}})},U)})}),(0,q.jsxs)("div",{style:{width:"100%",margin:"0 auto",display:"grid",gridTemplateColumns:`minmax(0, 1fr) ${Ut}px minmax(0, 1fr)`,gap:"12px",alignItems:"center",marginTop:"16px",padding:"0 20px",boxSizing:"border-box",zIndex:E?2e3:10},children:[(0,q.jsx)("div",{style:{paddingLeft:"0px"}}),(0,q.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,q.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,q.jsx)(Ae,{src:l.thumbnail,alt:l.name,style:{width:"44px",height:"44px",borderRadius:"50%",border:"2px solid white",margin:0}}),(0,q.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"16px",whiteSpace:"nowrap"},children:l.name})]}),(0,q.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,q.jsx)(oi,{config:{enabled:l?.styling?.share?.enabled??!0,image:l?.styling?.share?.image??"",color:{cross:l?.styling?.share?.color?.cross??"#ffffff",fill:l?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:l?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:l?.styling?.share?.size??44},onPress:He,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"12px",width:"44px",height:"44px"}}),(0,q.jsx)($e,{config:{size:(g?vt?.mute?.size:vt?.unmute?.size)||44,color:{cross:(g?vt?.mute?.color?.cross:vt?.unmute?.color?.cross)||"#ffffff",fill:(g?vt?.mute?.color?.fill:vt?.unmute?.color?.fill)||"rgba(255,255,255,0.08)",stroke:(g?vt?.mute?.color?.stroke:vt?.unmute?.color?.stroke)||"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:(g?vt?.mute?.image:vt?.unmute?.image)||""},onPress:zt,type:g?"mute":"unmute",enabled:!!vt?.enabled&&!!_,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"12px",width:"44px",height:"44px"}}),(0,q.jsx)(Fr,{isPaused:h,onPress:()=>T(!h),size:44,style:{borderRadius:"12px",margin:0}})]})]}),(0,q.jsxs)("div",{style:{display:"flex",gap:"10px",flex:1,justifyContent:"flex-end",paddingRight:"0px"},children:[(0,q.jsxs)("div",{style:{position:"relative"},children:[(0,q.jsx)("button",{onClick:()=>{K(!E),T(!E)},style:{width:"44px",height:"44px",background:E?"rgba(255,255,255,0.15)":"rgba(255,255,255,0.08)",border:E?"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,q.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,q.jsx)("rect",{x:"3",y:"3",width:"7",height:"7"}),(0,q.jsx)("rect",{x:"14",y:"3",width:"7",height:"7"}),(0,q.jsx)("rect",{x:"14",y:"14",width:"7",height:"7"}),(0,q.jsx)("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),E&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)("style",{children:`
|
|
120
120
|
@keyframes fadeUp {
|
|
121
121
|
from { opacity: 0; transform: translateY(10px) scale(0.95); }
|
|
122
122
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
123
123
|
}
|
|
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&>(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:`
|
|
124
|
+
`}),(0,q.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,q.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,q.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:w,label:U})=>(0,q.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"14px",justifyContent:"flex-start"},children:[(0,q.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:w}),(0,q.jsx)("span",{style:{fontSize:"13px",color:"#E5E7EB",fontWeight:"500",textAlign:"left"},children:U})]},w))})]})]})]}),(0,q.jsx)(Qt,{config:{enabled:pe?.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,q.jsx)("div",{style:{flex:1,width:"100%",display:"flex",flexDirection:"column",justifyContent:N?"flex-start":"center",alignItems:"center",paddingTop:N?"14px":"0px",..._o()},children:(0,q.jsxs)("div",{style:{display:N?"grid":"flex",gridTemplateColumns:N?`minmax(0, 1fr) ${Ut}px minmax(0, 1fr)`:"none",alignItems:"center",justifyContent:"center",gap:"12px",width:"100%",maxWidth:"1400px",position:"relative"},onClick:w=>N&&w.stopPropagation(),children:[N&&(0,q.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(u>0||e>0)&&(0,q.jsx)("button",{onClick:Te,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:w=>{w.currentTarget.style.background="rgba(0,0,0,0.75)",w.currentTarget.style.transform="scale(1.1)",w.currentTarget.style.borderColor="rgba(255,255,255,0.25)"},onMouseLeave:w=>{w.currentTarget.style.background="rgba(0,0,0,0.45)",w.currentTarget.style.transform="scale(1)",w.currentTarget.style.borderColor="rgba(255,255,255,0.1)"},children:(0,q.jsx)("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,q.jsx)("polyline",{points:"15 18 9 12 15 6"})})})}),N?(0,q.jsx)("div",{style:{width:`${Ut}px`,height:`${At}px`,position:"relative",zIndex:5,overflow:"visible"},children:Array.from(Nt).sort((w,U)=>w-U).map(w=>{let U=l.slides[w];if(!U)return null;let St=ge(w),Yt=Js(St,Ut),Lt=U?.styling,We=Lt?.editorSource||Lt?.meta?.editorSource,ze=We==="studio"||We==="editor",go=Lt?.background?.media?.mediaUrl||U?.image,to=$(U),Wo=wt(Lt?.background)||"#000000",de=ze?U?.content?.button_text:U?.button_text,eo=ze?U?.content?.link:U?.link,fe=Lt?.background?.media?.sizing||Lt?.background?.sizing||Lt?.media?.sizing||U?.sizing,oo=fe==="fill"||fe==="cover"?"cover":fe==="fit"||fe==="contain"?"contain":fe==="stretch"?"fill":"contain",he=Lt?.background?.media?.position||Lt?.background?.position||Lt?.media?.position||U?.content?.background?.media?.position||U?.content?.media?.position||U?.position,se=Co(he),fo=w===u&&!z||z&&w===v,Rn={display:"flex",justifyContent:"center",alignItems:"center",background:ze?Wo:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"16px"};return(0,q.jsxs)("div",{style:{...Xt,position:"absolute",top:0,left:0,width:`${Ut}px`,height:`${At}px`,...Yt,transition:St==="hidden"||St==="far-left"||St==="far-right"?`opacity ${qe}ms ease, transform ${qe}ms ease`:w===B?`transform ${qe}ms ${ni}, opacity ${qe}ms ${ni}, filter ${qe}ms ${ni}`:`transform ${qe}ms ${ii}, opacity ${qe}ms ${ii}, filter ${qe}ms ${ii}`,transformOrigin:"center center",willChange:"transform, opacity, filter"},onClick:Be=>Be.stopPropagation(),children:[(0,q.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:Fe,onMouseUp:()=>re("prev"),onTouchStart:Fe,onTouchEnd:()=>re("prev")}),(0,q.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:Fe,onMouseUp:()=>re("next"),onTouchStart:Fe,onTouchEnd:()=>re("next")}),(0,q.jsxs)("div",{style:Rn,children:[to?(0,q.jsx)(Ir,{src:to,isActive:fo,isAnimating:z,isMuted:g,onLoadedData:_e,activeVideoRef:Q,objectFit:oo,objectPosition:se}):go||!ze&&l?.thumbnail?(0,q.jsx)(Ae,{src:go||l?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:oo,objectPosition:se}}):null,(0,q.jsx)(ti,{content:{...U.content,lottie:U.content?.lottie||U?.lottie||U.styling?.lottie,video:U.content?.video||U?.videoOverlay||U.styling?.video,image:U.content?.image||U?.imageOverlay||U.styling?.image,canva:hn(U),editorSource:U.content?.editorSource||U.editorSource||U.styling?.editorSource||U.meta?.editorSource,styling:{...U.content?.styling,...U?.styling},interactions:U.interactions},elapsedTime:fo?f/100*(l.styling?.slideShowTime||5):0,onInteraction:async Be=>{fo&&Ct(Be,U)},isActive:fo,isMuted:g})]}),(de||eo)&&(0,q.jsx)(ei,{cta:U?.styling?.cta,buttonText:de||"Learn More",onPress:Be=>{Be&&Be.stopPropagation&&Be.stopPropagation(),X(U)}})]},U.id||w)})}):(0,q.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:l.slides.map((w,U)=>{if(Math.abs(U-u)>1)return(0,q.jsx)("div",{style:{display:"none"}},w.id||U);let St=w?.styling,Yt=St?.editorSource||St?.meta?.editorSource,Lt=Yt==="studio"||Yt==="editor",We=St?.background?.media?.mediaUrl||w?.image,ze=w?.video||(Lt?w?.content?.video?.[0]?.link:void 0),go=wt(St?.background)||"#000000",to=Lt?w?.content?.button_text:w?.button_text,Wo=Lt?w?.content?.link:w?.link,de=St?.background?.media?.sizing||St?.background?.sizing||St?.media?.sizing||w?.sizing,eo=de==="fill"||de==="cover"?"cover":de==="fit"||de==="contain"?"contain":de==="stretch"?"fill":"contain",fe=St?.background?.media?.position||St?.background?.position||St?.media?.position||w?.content?.background?.media?.position||w?.content?.media?.position||w?.position,oo=Co(fe),he=U===u;return he?(0,q.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:(0,q.jsxs)("div",{style:{...Xt},onClick:se=>se.stopPropagation(),children:[(0,q.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:l.slides.map((se,no)=>{let kn=no<u?"100%":no===u?`${f}%`:"0%";return(0,q.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.3)",borderRadius:"2px",overflow:"hidden"},children:(0,q.jsx)("div",{style:{width:kn,height:"100%",backgroundColor:"white",transition:no===u&&f>0&&!z?"width 0.1s linear":"none"}})},no)})}),(0,q.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,q.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,q.jsx)(Ae,{src:l.thumbnail,alt:l.name,style:{width:"32px",height:"32px",borderRadius:"50%"}}),(0,q.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"14px",textShadow:"0 1px 3px rgba(0,0,0,0.8)"},children:l.name})]}),(0,q.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,q.jsx)(oi,{config:{enabled:l?.styling?.share?.enabled??!0,image:l?.styling?.share?.image??"",color:{cross:l?.styling?.share?.color?.cross??"#ffffff",fill:l?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:l?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:l?.styling?.share?.size??32},onPress:He,ignoreSizeAndMargin:!0,style:{position:"relative",margin:0,borderRadius:"10px",width:"32px",height:"32px"}}),(0,q.jsx)($e,{config:{size:(g?vt?.mute?.size:vt?.unmute?.size)||32,color:{cross:(g?vt?.mute?.color?.cross:vt?.unmute?.color?.cross)||"#ffffff",fill:(g?vt?.mute?.color?.fill:vt?.unmute?.color?.fill)||"rgba(255,255,255,0.08)",stroke:(g?vt?.mute?.color?.stroke:vt?.unmute?.color?.stroke)||"transparent"},margin:(g?vt?.mute?.margin:vt?.unmute?.margin)||{top:0,bottom:0,left:0,right:0},image:(g?vt?.mute?.image:vt?.unmute?.image)||""},onPress:zt,type:g?"mute":"unmute",enabled:!!vt?.enabled&&!!ze,style:{position:"relative",borderRadius:"10px"}}),(0,q.jsx)(Qt,{config:{enabled:pe?.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,q.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:Fe,onMouseUp:()=>re("prev"),onTouchStart:Fe,onTouchEnd:()=>re("prev")}),(0,q.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:Fe,onMouseUp:()=>re("next"),onTouchStart:Fe,onTouchEnd:()=>re("next")}),(0,q.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",background:Lt?go:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"0px"},children:[ze?(0,q.jsx)(Ir,{src:ze,isActive:he,isAnimating:z,isMuted:g,onLoadedData:_e,activeVideoRef:Q,objectFit:eo,objectPosition:oo}):(We||!Lt&&l?.thumbnail)&&(0,q.jsx)(Ae,{src:We||l?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:eo,objectPosition:oo}}),(0,q.jsx)(ti,{content:{...w.content,canva:hn(w),editorSource:w.content?.editorSource||w.editorSource||w.styling?.editorSource||w.meta?.editorSource,styling:{...w.content?.styling,...w?.styling},interactions:w.interactions},elapsedTime:f/100*(l.styling?.slideShowTime||5),onInteraction:async se=>{Ct(se,w)},isActive:he,isMuted:g})]}),(to||Wo)&&(0,q.jsx)(ei,{cta:w?.styling?.cta,buttonText:to||"Learn More",onPress:se=>{se&&se.stopPropagation&&se.stopPropagation(),X(w)}})]})},w.id||U):null})}),N&&(0,q.jsx)("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(0,q.jsx)("button",{onClick:ye,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:w=>{w.currentTarget.style.background="rgba(0,0,0,0.75)",w.currentTarget.style.transform="scale(1.1)",w.currentTarget.style.borderColor="rgba(255,255,255,0.25)"},onMouseLeave:w=>{w.currentTarget.style.background="rgba(0,0,0,0.45)",w.currentTarget.style.transform="scale(1)",w.currentTarget.style.borderColor="rgba(255,255,255,0.1)"},children:(0,q.jsx)("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,q.jsx)("polyline",{points:"9 18 15 12 9 6"})})})})]})}),N&&e>0&&(0,q.jsxs)("div",{style:{position:"absolute",bottom:"36px",left:"24px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"6px",zIndex:20},children:[(0,q.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,q.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:()=>le("prev"),onMouseEnter:w=>{w.currentTarget.style.transform="translateY(-2px) scale(1.03)",w.currentTarget.style.background="rgba(255, 255, 255, 0.12)",w.currentTarget.style.borderColor="rgba(255, 255, 255, 0.25)"},onMouseLeave:w=>{w.currentTarget.style.transform="translateY(0px) scale(1)",w.currentTarget.style.background="rgba(255, 255, 255, 0.08)",w.currentTarget.style.borderColor="rgba(255, 255, 255, 0.12)"},children:[(0,q.jsx)("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2190"}),(0,q.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,q.jsx)(Ae,{src:t[e-1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),(0,q.jsx)("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e-1].name})]})]}),N&&e<t.length-1&&(0,q.jsxs)("div",{style:{position:"absolute",bottom:"36px",right:"24px",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"6px",zIndex:20},children:[(0,q.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,q.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:()=>le("next"),onMouseEnter:w=>{w.currentTarget.style.transform="translateY(-2px) scale(1.03)",w.currentTarget.style.background="rgba(255, 255, 255, 0.12)",w.currentTarget.style.borderColor="rgba(255, 255, 255, 0.25)"},onMouseLeave:w=>{w.currentTarget.style.transform="translateY(0px) scale(1)",w.currentTarget.style.background="rgba(255, 255, 255, 0.08)",w.currentTarget.style.borderColor="rgba(255, 255, 255, 0.12)"},children:[(0,q.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,q.jsx)(Ae,{src:t[e+1].thumbnail,style:{width:"100%",height:"100%",borderRadius:"50%"}})}),(0,q.jsx)("span",{style:{fontSize:"13px",color:"white",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e+1].name}),(0,q.jsx)("span",{style:{color:"white",fontSize:"14px",display:"flex"},children:"\u2192"})]})]}),I&&(0,q.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:I})]})};var Ho=require("react/jsx-runtime"),Ar=()=>{let t=_t("STR"),e=W(u=>u.isVisible),[o,n]=(0,Ue.useState)(()=>{try{let u=sessionStorage.getItem("appstorys_active_story_index");if(u!==null){let m=parseInt(u,10);if(!isNaN(m)&&m>=0)return m}}catch{}return null}),[i,s]=(0,Ue.useState)([]);(0,Ue.useEffect)(()=>{try{o!==null?sessionStorage.setItem("appstorys_active_story_index",String(o)):sessionStorage.removeItem("appstorys_active_story_index")}catch{}},[o]),(0,Ue.useEffect)(()=>{try{let u=localStorage.getItem("app_storys_viewed_stories");u&&s(JSON.parse(u))}catch(u){console.error("Failed to load viewed stories:",u)}},[]),(0,Ue.useEffect)(()=>{t&&t.details&&at("story_module_viewed",t.id)},[t]);let d=Ue.default.useMemo(()=>!t||!t.details?[]:An(t.details),[t?.details]);if(!t||!d||d.length===0||!e)return null;let c=u=>{n(u)},l=()=>{o!==null&&(o<d.length-1?n(o+1):n(null))},y=()=>{o!==null&&o>0&&n(o-1)};return(0,Ho.jsxs)("div",{className:"story-group-container",style:{width:"100vw",position:"relative",left:"50%",right:"50%",marginLeft:"-50vw",marginRight:"-50vw",boxSizing:"border-box"},children:[(0,Ho.jsx)(Ki,{stories:d,viewedStories:i,onStoryClick:c}),o!==null&&(0,Ho.jsx)(Br,{stories:d,activeStoryIndex:o,dataId:t.id,viewedStories:i,setViewedStories:s,onNextStory:l,onPrevStory:y,onClose:()=>n(null)})]})};var ne=require("react"),ko=me(require("lottie-react"));var Xe=require("react");function Vo(t,e=.5){let o=(0,Xe.useRef)(t),n=(0,Xe.useRef)(!1),i=(0,Xe.useRef)(null),s=(0,Xe.useRef)(null);(0,Xe.useEffect)(()=>{o.current=t},[t]);let d=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 l=null;s.current=new IntersectionObserver(y=>{y[0].isIntersecting&&!n.current?l||(l=setTimeout(()=>{n.current=!0,o.current(),s.current?.disconnect(),l=null},500)):l&&(clearTimeout(l),l=null)},{threshold:e}),s.current.observe(c)};return(0,Xe.useEffect)(()=>()=>{s.current?.disconnect()},[]),d}var oe=require("react/jsx-runtime"),Lr=ko.default?.default??ko.default??ko.Lottie??ko,ta=({item:t,onClick:e})=>{let[o,n]=(0,ne.useState)(null);(0,ne.useEffect)(()=>{t.lottie_data&&(typeof t.lottie_data=="object"?n(t.lottie_data):typeof t.lottie_data=="string"&&fetch(t.lottie_data).then(d=>d.json()).then(d=>n(d)).catch(d=>console.error("[Widget] Failed to load Lottie JSON:",d)))},[t.lottie_data]);let i=!!(t.link||"").trim(),s=Lr.default||Lr;return t.lottie_data&&o?(0,oe.jsx)("div",{onClick:e,style:{width:"100%",height:"100%",cursor:i?"pointer":"default"},children:(0,oe.jsx)(s,{animationData:o,loop:!0,autoplay:!0,style:{width:"100%",height:"100%",objectFit:"contain"}})}):!t.image&&!t.lottie_data?(0,oe.jsx)("div",{onClick:e,style:{width:"100%",height:"100%",backgroundColor:"#f3f4f6",display:"flex",alignItems:"center",justifyContent:"center",color:"#9ca3af",fontSize:"14px",fontWeight:500},children:"No Image Provided"}):(0,oe.jsx)("img",{src:t.image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block",cursor:i?"pointer":"default"},onClick:e})},Yo=({position:t,leftPadding:e=0,rightPadding:o=0})=>{let n=_t("WID",{position:t});(0,ne.useEffect)(()=>{t&&console.info(`[AppStorys Widget] Position "${t}":`,n?`Matched campaign "${n.id}"`:"No matching campaign found in store",n)},[t,n]);let[i,s]=(0,ne.useState)(0),d=(0,ne.useRef)(null),c=(0,ne.useRef)(null),l=n?.details||{},y=l.widget_images||[],u=l.styling||{},m=l.type||"full",f=m==="half",P=(0,ne.useRef)([]),g=(0,ne.useRef)(!1),b=(0,ne.useCallback)(()=>{g.current=!0;let v=y[i];v?.id&&C(v.id)},[y,i]),R=Vo(b),C=v=>{!n?.id||!v||g.current&&(P.current.includes(v)||(P.current.push(v),at("viewed",n.id,{widget_image:v})))};(0,ne.useEffect)(()=>{if(m==="full"&&y.length>1)return c.current=setInterval(()=>{if(!d.current)return;let v=d.current.clientWidth;v<=0||s(A=>{let V=(A+1)%y.length;return d.current?.scrollTo({left:V*v,behavior:"smooth"}),V})},5e3),()=>{c.current&&clearInterval(c.current)}},[m,y.length]);let h=(v,A)=>{let V=(A||"").trim();if(V&&(n?.id&&at("clicked",n.id,{widget_image:v}),!Rt(V))){if(!V.startsWith("http")){try{if(Gt(V))return}catch(rt){console.warn("[Widget] revealCampaignFromLink error",rt)}console.log("[Widget] Internal link:",V);return}window.open(V,"_blank")}},T=()=>{if(!d.current)return;let{scrollLeft:v,clientWidth:A}=d.current;if(!(A<=0))if(f){let V=A/2+12,rt=Math.round(v/V);rt!==i&&rt>=0&&rt<y.length&&s(rt)}else{let V=Math.round(v/A);V!==i&&V>=0&&V<y.length&&s(V)}},E=v=>{if(s(v),d.current){let A=d.current.clientWidth;d.current.scrollTo({left:v*A,behavior:"smooth"})}};(0,ne.useEffect)(()=>{if(!n?.id||m!=="full"||y.length===0)return;let v=y[i];v&&v.id&&C(v.id)},[i,n?.id,y,m]),(0,ne.useEffect)(()=>{if(!n?.id||!d.current||!f)return;let v=d.current,A=()=>{let{scrollLeft:V,offsetWidth:rt}=v,lt=rt/2+12;y.forEach((a,F)=>{let r=F*lt,p=r+lt,j=V,k=V+rt;Math.max(0,Math.min(p,k)-Math.max(r,j))/lt>=.5&&C(a.id)})};return A(),v.addEventListener("scroll",A),()=>v.removeEventListener("scroll",A)},[n?.id,f,y]);let K=!!(l.width&&l.height&&Number(l.width)>0&&Number(l.height)>0),I=K?`${l.width} / ${l.height}`:void 0,S=Number(u.borderRadius)||0,M=typeof u.topLeftRadius<"u"?Number(u.topLeftRadius):S,x=typeof u.topRightRadius<"u"?Number(u.topRightRadius):S,N=typeof u.bottomLeftRadius<"u"?Number(u.bottomLeftRadius):S,H=typeof u.bottomRightRadius<"u"?Number(u.bottomRightRadius):S,z={display:"flex",flexDirection:"row",flexWrap:"nowrap",gap:f?"12px":"0px",width:"100%",height:"auto",marginTop:u.topMargin?`${u.topMargin}px`:"0px",marginBottom:u.bottomMargin?`${u.bottomMargin}px`:"0px",marginLeft:u.leftMargin?`${u.leftMargin}px`:"0px",marginRight:u.rightMargin?`${u.rightMargin}px`:"0px",paddingLeft:e?`${e}px`:"0px",paddingRight:o?`${o}px`:"0px",boxSizing:"border-box",overflowX:"auto",overflowY:"hidden",scrollSnapType:"x mandatory",scrollBehavior:"smooth",msOverflowStyle:"none",scrollbarWidth:"none"},O=v=>({flex:f?"0 0 calc(50% - 6px)":"0 0 100%",width:f?"calc(50% - 6px)":"100%",minWidth:f?"calc(50% - 6px)":"100%",maxWidth:f?"calc(50% - 6px)":"100%",boxSizing:"border-box",aspectRatio:I,height:!K&&l.height?`${l.height}px`:"auto",cursor:"pointer",position:"relative",overflow:"hidden",borderTopLeftRadius:`${M}px`,borderTopRightRadius:`${x}px`,borderBottomLeftRadius:`${N}px`,borderBottomRightRadius:`${H}px`,WebkitMaskImage:"-webkit-radial-gradient(white, black)",transform:"translateZ(0)",boxShadow:"0 4px 12px rgba(0,0,0,0.08)",scrollSnapAlign:"start"}),B=!!(n&&y&&y.length>0);return!B&&!t?null:(0,oe.jsxs)("div",{"data-widget":t,style:{width:"100%",position:"relative"},children:[(0,oe.jsx)("style",{children:`
|
|
125
125
|
.widget-scroll-container::-webkit-scrollbar {
|
|
126
126
|
display: none;
|
|
127
127
|
}
|
|
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&>.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&>.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:`
|
|
128
|
+
`}),B&&(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsx)("div",{ref:v=>{d.current=v,R(v)},className:"widget-scroll-container",style:z,onScroll:T,children:y.map((v,A)=>(0,oe.jsx)("div",{style:O(A),children:(0,oe.jsx)(ta,{item:v,onClick:()=>h(v.id,v.link)})},v.id||A))}),m==="full"&&y.length>1&&(0,oe.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"6px",marginTop:"8px",width:"100%"},children:y.map((v,A)=>(0,oe.jsx)("div",{onClick:()=>E(A),style:{width:A===i?"14px":"6px",height:"6px",borderRadius:"50px",backgroundColor:A===i?"#101010":"#d1d5db",transition:"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",cursor:"pointer"}},A))})]})]})};var Ft=require("react");kt();var Er=new Set;function ea(){try{return globalThis?.process?.env?.NODE_ENV!=="production"}catch{return!0}}function Pr(t,e,o){if(!ea()||o<=1)return;let n=`${e}::${t}`;Er.has(n)||(Er.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 Mr(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 Pr(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 Pr(t,n,i.length),i[0]}catch{}return null}te();var Ot=require("react/jsx-runtime"),si=t=>(t||"").trim().toLowerCase(),oa=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)},na=(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"},ia=()=>{let t=_t("TTP"),e=W(X=>X.campaigns),o=W(X=>X.allCampaigns),n=W(X=>X.currentScreen),i=W(X=>X.userId),s=W(X=>X.isVisible),[d,c]=(0,Ft.useState)(0),[l,y]=(0,Ft.useState)(!1),[u,m]=(0,Ft.useState)(null),[f,P]=(0,Ft.useState)(null),[g,b]=(0,Ft.useState)({width:0,height:0}),[R,C]=(0,Ft.useState)(!1),h=(0,Ft.useRef)(null),T=(0,Ft.useRef)(null),E=(0,Ft.useRef)(null),K=(0,Ft.useRef)(!1),I=(0,Ft.useCallback)(X=>{if(X)try{X.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}catch{try{X.scrollIntoView()}catch{}}},[]),S=(0,Ft.useMemo)(()=>{if(t)return t;let X=si(n),zt=(vt=>vt.filter(Ie=>{let ge=Ie,Ve=ge.campaign_type==="TTP"||ge.campaign_type==="TLTP",Xt=!si(ge.screen)||si(ge.screen)===X,Ze=!!(ge.trigger_event??ge.trigger),Ht=ge.display_trigger!==!1&&!Ze;return Ve&&Xt&&Ht&&Vt(ge,i)}))(e&&e.length>0?e:o||[]);return zt.length===0?void 0:Et(zt)[0]},[t,e,o,i,n]);(0,Ft.useEffect)(()=>{c(0),y(!1),C(!1)},[S?.id]);let M=(0,Ft.useMemo)(()=>S?.details?.tooltips&&Array.isArray(S.details.tooltips)?[...S.details.tooltips].sort((X,Ct)=>(X.order??0)-(Ct.order??0)):S?.details?.target||S?.details?.titleText?[{...S.details,_id:S.id}]:[],[S]),x=M[d];(0,Ft.useEffect)(()=>{},[S]);let N=(0,Ft.useRef)(new Set),H=(0,Ft.useCallback)(()=>{if(!(!S||!x||l||!s))try{let X=x._id||x.id||void 0,Ct=String(S.id||"")+"::"+String(X||"");N.current.has(Ct)||(N.current.add(Ct),at("viewed",S.id,{tooltip_id:X}))}catch{}},[S,x,l,s]),z=Vo(H);(0,Ft.useEffect)(()=>{if(!x||l)return;m(null),P(null);let X=null,Ct=null,zt=()=>{let Ht=typeof window<"u"?document.documentElement.clientWidth||window.innerWidth:1024,Nt=typeof window<"u"?document.documentElement.clientHeight||window.innerHeight:768;return new DOMRect(Ht/2-100,Nt/2-50,200,100)},pe=Ht=>{if(!Ht||!(Ht instanceof HTMLElement))return!1;let Nt=Ht.getBoundingClientRect();if(Nt.width===0||Nt.height===0)return!1;try{let w=window.getComputedStyle(Ht);if(w.display==="none"||w.visibility==="hidden"||w.opacity==="0")return!1}catch{}return!0},vt=(Ht=!1)=>{let Nt=x.target||x.targetId||x.elementId;if(!Nt)return m(zt()),P(null),null;let w=Mr(Nt);if(w){if(P(w),pe(w)){let U=w.getBoundingClientRect();Ht?(I(w),m(U),setTimeout(()=>{I(w),m(w.getBoundingClientRect())},50),setTimeout(()=>{m(w.getBoundingClientRect())},150),setTimeout(()=>{m(w.getBoundingClientRect())},350)):m(zt())}else m(zt());return w}return P(null),m(zt()),null},Ie=()=>{C(!0)},ge=Ht=>{E.current?.disconnect(),E.current=null,!(!Ht||typeof ResizeObserver>"u")&&(E.current=new ResizeObserver(()=>{pe(Ht)?m(Ht.getBoundingClientRect()):m(null)}),E.current.observe(Ht))},Ve=(Ht=!1)=>{let Nt=vt(Ht);Nt&&Nt!==X&&(X&&X.removeEventListener("click",Ie),X=Nt,Nt.addEventListener("click",Ie),ge(Nt))};Ve(!0),T.current=new MutationObserver(()=>{Ve(!1)}),T.current.observe(document.body,{childList:!0,subtree:!0,attributes:!0});let Xt=()=>Ve(!1),Ze=()=>{typeof document<"u"&&document.visibilityState==="hidden"||Ve(!0)};return window.addEventListener("resize",Xt),window.addEventListener("scroll",Xt,{passive:!0,capture:!0}),window.addEventListener("focus",Ze),document.addEventListener("visibilitychange",Ze),document.addEventListener("mouseenter",Xt,!0),document.addEventListener("mouseover",Xt,!0),document.addEventListener("mouseleave",Xt,!0),document.addEventListener("click",Xt,!0),()=>{Ct&&clearTimeout(Ct),X&&X.removeEventListener("click",Ie),T.current?.disconnect(),E.current?.disconnect(),window.removeEventListener("resize",Xt),window.removeEventListener("scroll",Xt,{capture:!0}),window.removeEventListener("focus",Ze),document.removeEventListener("visibilitychange",Ze),document.removeEventListener("mouseenter",Xt,!0),document.removeEventListener("mouseover",Xt,!0),document.removeEventListener("mouseleave",Xt,!0),document.removeEventListener("click",Xt,!0)}},[x,l,d,I]),(0,Ft.useEffect)(()=>{if(!x||l||!u)return;let X=x?.enableBackdrop??x?.enable_backdrop??S?.details?.enableBackdrop??S?.details?.enable_backdrop;if(!(X!==!1&&X!=="false"&&X!==0))return;let zt=pe=>{let vt=pe.target;vt&&(h.current&&h.current.contains(vt)||f&&(f===vt||f.contains(vt))||(C(!0),d<M.length-1?c(Ie=>Ie+1):y(!0)))};return window.addEventListener("click",zt,!0),()=>{window.removeEventListener("click",zt,!0)}},[x,l,u,f,d,M.length,S]);let O=(0,Ft.useRef)(null),B=(0,Ft.useRef)(null);(0,Ft.useEffect)(()=>{if(!S||!x||l||!s||!u){O.current!==null&&(document.body.style.overflow=O.current,O.current=null),B.current!==null&&(document.documentElement.style.overflow=B.current,B.current=null);return}return O.current===null&&(O.current=document.body.style.overflow!=="hidden"?document.body.style.overflow:""),B.current===null&&(B.current=document.documentElement.style.overflow!=="hidden"?document.documentElement.style.overflow:""),document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",()=>{O.current!==null&&(document.body.style.overflow=O.current,O.current=null),B.current!==null&&(document.documentElement.style.overflow=B.current,B.current=null)}},[S,x,l,s,!!u]),(0,Ft.useEffect)(()=>{if(!f||!(f instanceof HTMLElement)||l)return;let X=f,Ct=()=>{C(!0)};return X.addEventListener("click",Ct),()=>{X.removeEventListener("click",Ct)}},[f,d,l]),(0,Ft.useLayoutEffect)(()=>{if(h.current&&u){let{width:X,height:Ct}=h.current.getBoundingClientRect();b({width:X,height:Ct})}},[x,u]);let Z=(0,Ft.useMemo)(()=>{let X=x?.styling?.appearance?.highlight?.radius;if(X!=null)return`${X}px`;if(f&&typeof window<"u")try{let Ct=window.getComputedStyle(f);if(Ct.borderRadius&&Ct.borderRadius!=="0px")return Ct.borderRadius}catch{}return"6px"},[x?.styling?.appearance?.highlight?.radius,f]);if(!S||!x||l||!s||!u)return null;let v=x.styling||{},A=v.appearance||{},V=A.colors||{},rt=v.cta||{},lt=rt.container||{},a=rt.cornerRadius||{},F=rt.text||{},r=!!(A.imageDimensions?.width&&A.imageDimensions?.height),p,j;if(r){let X=A.imageDimensions.width,Ct=A.imageDimensions.height,zt=typeof window<"u"?window.innerWidth*.9:X;p=Math.min(X,zt),j=p===X?Ct:Math.round(Ct*(p/X))}let k=x.arrowPosition;!k&&x.position&&(x.position==="left"?k="right":x.position==="right"?k="left":x.position==="top"?k="bottom":x.position==="bottom"&&(k="top")),k||(k="left");let Y=(A.arrowStyle||{width:6,height:12}).width||6,st=u.top,dt=u.left,tt=8,ft=8,J=typeof window<"u"?document.documentElement.clientWidth||window.innerWidth:1024,ct=typeof window<"u"?document.documentElement.clientHeight||window.innerHeight:768,xt=g.width||r&&p||250,pt=g.height||(r?j||150:100),ht=u.top,$=ct-(u.top+u.height),_=u.left,D=J-(u.left+u.width),L=xt+tt+ft,G=pt+tt+ft;k?k==="left"&&D<L?_>=L?k="right":ht>=G||ht>=$?k="bottom":k="top":k==="right"&&_<L?D>=L?k="left":ht>=G||ht>=$?k="bottom":k="top":k==="top"&&$<G?ht>=G?k="bottom":D>=L||D>=_?k="left":k="right":k==="bottom"&&ht<G&&($>=G?k="top":D>=L||D>=_?k="left":k="right"):D>=L?k="left":_>=L?k="right":ht>=G?k="bottom":k="top";let nt=0,yt=0;k==="left"?(nt=dt+u.width+tt,yt=st+u.height/2-pt/2):k==="right"?(nt=dt-xt-tt,yt=st+u.height/2-pt/2):k==="top"?(yt=st+u.height+tt,nt=dt+u.width/2-xt/2):k==="bottom"&&(yt=st-pt-tt,nt=dt+u.width/2-xt/2);let qt=Math.min(xt,Math.max(120,J-ft*2)),At=Math.min(pt,Math.max(80,ct-ft*2)),Ut=ft,$t=Math.max(Ut,J-qt-ft),le=ft,ye=Math.max(le,ct-At-ft),Te=Math.max(Ut,Math.min($t,nt)),He=Math.max(le,Math.min(ye,yt)),uo=x?.enableBackdrop??x?.enable_backdrop??S?.details?.enableBackdrop??S?.details?.enable_backdrop,po=uo!==!1&&uo!=="false"&&uo!==0,Ko=A.backdropOpacity!==void 0?A.backdropOpacity>1?A.backdropOpacity/100:A.backdropOpacity:.7,Mo=((X,Ct)=>{if(!X||X==="transparent")return"transparent";if(X.startsWith("rgba"))return X;if(X.startsWith("rgb"))return X.replace("rgb","rgba").replace(")",`, ${Ct})`);if(X.startsWith("#")){let zt=X.slice(1);if(zt.length===3&&(zt=zt.split("").map(pe=>pe+pe).join("")),zt.length===6){let pe=parseInt(zt.slice(0,2),16),vt=parseInt(zt.slice(2,4),16),Ie=parseInt(zt.slice(4,6),16);return`rgba(${pe}, ${vt}, ${Ie}, ${Ct})`}}return X})(V.backdrop||"#000000",Ko),_o=()=>{if(K.current)return;K.current=!0,setTimeout(()=>{K.current=!1},400),C(!0);let X=x.link;try{let Ct=x._id||x.id||void 0;S?.id&&at("clicked",S.id,{tooltip_id:Ct})}catch{}if(X&&Rt(X)){y(!0);return}d<M.length-1?(c(Ct=>Ct+1),X&&window.open(X,"_blank")):(y(!0),X&&window.open(X,"_blank"))},Fe=()=>{C(!0),po&&(d<M.length-1?c(X=>X+1):y(!0))},re=x?.styling?.appearance?.highlight?.radius??x?.styling?.appearance?.radius,_e=0;if(typeof re=="number"&&re>0)_e=re;else if(typeof re=="string"&&re!=="")_e=parseInt(re,10)||0;else if(f&&typeof window<"u")try{let X=f,Ct=window.getComputedStyle(X);if(Ct.borderRadius&&Ct.borderRadius!=="0px")_e=parseFloat(Ct.borderRadius)||0;else if(X.firstElementChild){let zt=window.getComputedStyle(X.firstElementChild);zt.borderRadius&&zt.borderRadius!=="0px"&&(_e=parseFloat(zt.borderRadius)||0)}}catch{}let Ke=Pt(S,"TTP");return(0,Ot.jsxs)("div",{style:{position:"relative",zIndex:Ke},children:[po&&u&&(0,Ot.jsxs)("svg",{style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",pointerEvents:"none",zIndex:Ke-1},children:[(0,Ot.jsx)("defs",{children:(0,Ot.jsxs)("mask",{id:"as-spotlight-mask",children:[(0,Ot.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:"white"}),(0,Ot.jsx)("rect",{x:u.left,y:u.top,width:u.width,height:u.height,rx:_e,ry:_e,fill:"black"})]})}),(0,Ot.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:Mo,mask:"url(#as-spotlight-mask)",style:{pointerEvents:"none",cursor:"default"}})]}),po&&!u&&(0,Ot.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:Mo,zIndex:Ke-1},onClick:Fe}),(0,Ot.jsxs)("div",{ref:X=>{h.current=X,z(X)},onClick:X=>{X.stopPropagation(),X.target.tagName!=="BUTTON"&&_o()},style:{position:"fixed",top:He,left:Te,zIndex:Ke,backgroundColor:V.tooltip||"#FE6B35",padding:r?0:oa(A.padding),borderRadius:na(A.cornerRadius,A.radius),boxShadow:"0 4px 12px rgba(0,0,0,0.15)",width:r?p:A.width?Math.min(A.width,J-ft*2):"auto",height:r?j:void 0,maxWidth:Math.max(160,J-ft*2),minWidth:r?void 0:Math.min(200,J-ft*2),boxSizing:"border-box",transition:"top 0.2s ease, left 0.2s ease",cursor:"pointer"},children:[(0,Ot.jsx)("div",{style:{position:"absolute",width:0,height:0,borderStyle:"solid",...k==="left"&&{left:-tt,top:Math.max(12,Math.min(g.height-Y*2-12,st+u.height/2-He-Y)),borderWidth:`${Y}px ${tt}px ${Y}px 0`,borderColor:`transparent ${V.arrow||V.tooltip||"#FE6B35"} transparent transparent`},...k==="right"&&{right:-tt,top:Math.max(12,Math.min(g.height-Y*2-12,st+u.height/2-He-Y)),borderWidth:`${Y}px 0 ${Y}px ${tt}px`,borderColor:`transparent transparent transparent ${V.arrow||V.tooltip||"#FE6B35"}`},...k==="top"&&{top:-tt,left:Math.max(12,Math.min(g.width-Y*2-12,dt+u.width/2-Te-Y)),borderWidth:`0 ${Y}px ${tt}px ${Y}px`,borderColor:`transparent transparent ${V.arrow||V.tooltip||"#FE6B35"} transparent`},...k==="bottom"&&{bottom:-tt,left:Math.max(12,Math.min(g.width-Y*2-12,dt+u.width/2-Te-Y)),borderWidth:`${tt}px ${Y}px 0 ${Y}px`,borderColor:`${V.arrow||V.tooltip||"#FE6B35"} transparent transparent transparent`}}}),x.url&&(r?(0,Ot.jsx)("div",{style:{width:"100%",height:"100%",overflow:"hidden",borderRadius:`${A.cornerRadius?.topLeft??12}px ${A.cornerRadius?.topRight??12}px ${A.cornerRadius?.bottomRight??12}px ${A.cornerRadius?.bottomLeft??12}px`,cursor:"pointer"},children:(0,Ot.jsx)("img",{src:x.url,alt:"tooltip media",style:{width:"100%",height:"100%",display:"block",objectFit:"cover",cursor:"pointer"}})}):(0,Ot.jsx)("img",{src:x.url,alt:"tooltip media",style:{width:"100%",borderRadius:6,marginBottom:8,display:"block",objectFit:"cover",cursor:"pointer"}})),(x.titleText||x.subtitleText||x.ctaText)&&(0,Ot.jsxs)("div",{style:r?{padding:`${A.padding?.top??8}px ${A.padding?.right??8}px ${A.padding?.bottom??8}px ${A.padding?.left??8}px`}:void 0,children:[x.titleText&&(0,Ot.jsx)("div",{style:{color:v.title?.color||"#ffffff",fontFamily:gt(v.title?.fontFamily)||"Arial",fontSize:v.title?.fontSize||14,textAlign:v.title?.textAlign||"center",marginBottom:v.title?.margin?.bottom??4,marginTop:v.title?.margin?.top??0,marginLeft:v.title?.margin?.left??0,marginRight:v.title?.margin?.right??0,fontWeight:v.title?.fontDecoration?.includes("bold")?"bold":600,fontStyle:v.title?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:v.title?.fontDecoration?.includes("underline")?"underline":"none"},children:x.titleText}),x.subtitleText&&(0,Ot.jsx)("div",{style:{color:v.subTitle?.color||"#ffffff",fontFamily:gt(v.subTitle?.fontFamily)||"Arial",fontSize:v.subTitle?.fontSize||12,textAlign:v.subTitle?.textAlign||"center",marginBottom:v.subTitle?.margin?.bottom??8,marginTop:v.subTitle?.margin?.top??0,marginLeft:v.subTitle?.margin?.left??0,marginRight:v.subTitle?.margin?.right??0,fontWeight:v.subTitle?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:v.subTitle?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:v.subTitle?.fontDecoration?.includes("underline")?"underline":"none"},children:x.subtitleText}),x.ctaText&&(0,Ot.jsx)("div",{style:{display:"flex",justifyContent:lt.alignment==="right"?"flex-end":lt.alignment==="left"?"flex-start":"center",marginTop:8},children:(0,Ot.jsx)("button",{onClick:X=>{X.stopPropagation(),_o()},style:{width:lt.ctaFullWidth?"100%":lt.ctaWidth||"auto",height:lt.height||35,background:lt.backgroundColor||"#F7921C",color:F.color||"#ffffff",border:`${lt.borderWidth||0}px solid ${lt.borderColor||"transparent"}`,borderRadius:`${a.topLeft??7}px ${a.topRight??7}px ${a.bottomRight??7}px ${a.bottomLeft??7}px`,fontSize:F.fontSize||14,fontFamily:gt(F.fontFamily)||"Arial",fontWeight:F.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:F.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:F.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:x.ctaText})})]})]})]})},_r=ia;var Ro=require("react");kt();te();var Zt=require("react/jsx-runtime"),Wr=()=>{let t=_t("BTS"),e=W(h=>h.campaigns),o=W(h=>h.allCampaigns),n=W(h=>h.currentScreen),i=W(h=>h.userId),s=t??(()=>{let h=(n||"").trim().toLowerCase(),T=[...e||[],...o||[]].filter(I=>{if(!I||I.campaign_type!=="BTS"||!Vt(I,i))return!1;let S=!!(I.trigger_event??I.trigger);if(!(I.display_trigger!==!1&&!S))return!1;let x=(I.screen||"").trim().toLowerCase();return!x||x===h});if(T.length===0)return;let K=Et(T)[0];if(K)try{return ae(K)}catch{return K}})(),d=W(h=>h.isVisible),[c,l]=(0,Ro.useState)(!1),y=(0,Ro.useRef)(null);(0,Ro.useEffect)(()=>{s?.id&&y.current!==s.id&&(y.current=s.id,l(!1),at("viewed",s.id))},[s?.id]);let u=h=>{try{let T=W.getState(),K=(T.trackedEvents||[]).filter(I=>I!==h);T.setTrackedEvents(K)}catch{}},m=()=>{if(l(!0),s?.id){at("bottomsheet_closed",s.id);let h=[...e||[],...o||[]].find(E=>E?.id===s.id),T=h?.trigger_event??h?.trigger;T&&u(T)}};if(!s||c||!d)return null;let{details:f}=s,g=[...f.elements||[]].sort((h,T)=>(h.order||0)-(T.order||0)),b=f.backdropOpacity??.5;b>1&&(b=b/100);let R=h=>{switch(h.type){case"image":{let T={width:"100%",display:"block",objectFit:"contain",backgroundColor:h.imageBackgroundColor||"transparent",paddingBottom:h.paddingBottom??0,paddingLeft:h.paddingLeft??0,paddingRight:h.paddingRight??0,paddingTop:h.paddingTop??0,cursor:h.imageLink?"pointer":"default"};return(0,Zt.jsx)("div",{style:{textAlign:h.alignment||"left",width:"100%"},children:h.url&&(0,Zt.jsx)("img",{src:h.url,alt:"",style:T,onClick:()=>{if(h.imageLink){if(s?.id&&at("clicked",s.id),Rt(h.imageLink)){m();return}try{let E=String(h.imageLink||"").trim();if(E&&!E.startsWith("http")&&Gt(E))return}catch(E){console.warn("revealCampaignFromLink error",E)}try{window.open(h.imageLink,"_blank")}catch{}}}})},h.id)}case"cta":{let T=h.cta||{},E=T.container||{},K=T.cornerRadius||{},I=T.margin||{},S=T.text||{};return(0,Zt.jsx)("div",{style:{display:"flex",justifyContent:E.alignment==="center"?"center":E.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,Zt.jsx)("button",{style:{width:E.ctaFullWidth?"100%":E.ctaWidth||"auto",height:E.height||45,backgroundColor:E.ctaBoxColor||E.backgroundColor||"#FE6B35",color:S.color||"#ffffff",border:`${E.borderWidth||0}px solid ${E.borderColor||"transparent"}`,borderRadius:`${K.topLeft??12}px ${K.topRight??12}px ${K.bottomRight??12}px ${K.bottomLeft??12}px`,fontSize:S.fontSize||14,fontFamily:gt(S.fontFamily)||"Arial",fontWeight:S.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:S.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:S.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px"},onClick:()=>{let M=h.ctaLink||h.url;if(M){if(s?.id&&at("clicked",s.id),Rt(M)){m();return}try{let x=String(M||"").trim();if(x&&!x.startsWith("http")&&Gt(x))return}catch(x){console.warn("revealCampaignFromLink error",x)}try{window.open(M,"_blank")}catch{}}},children:h.ctaText||"Button"})},h.id)}case"body":{let T=h.titleFontStyle||{},E=h.descriptionFontStyle||{};return(0,Zt.jsxs)("div",{style:{width:"100%",backgroundColor:h.bodyBackgroundColor||"transparent",marginTop:h.marginTop??0,marginBottom:h.marginBottom??20,marginLeft:h.marginLeft??4,marginRight:h.marginRight??4},children:[h.titleText&&(0,Zt.jsx)("div",{style:{color:T.colour||"#000000",fontSize:T.fontSize?`${T.fontSize}px`:h.titleFontSize?`${h.titleFontSize}px`:"16px",fontFamily:gt(T.fontFamily)||"inherit",textAlign:T.alignment||"left",lineHeight:h.titleLineHeight||1.2,fontWeight:T.decoration?.includes("bold")?"bold":"600",fontStyle:T.decoration?.includes("italic")?"italic":"normal",textDecoration:T.decoration?.includes("underline")?"underline":"none",marginBottom:h.spacingBetweenTitleDesc??4},children:h.titleText}),h.descriptionText&&(0,Zt.jsx)("div",{style:{color:E.colour||"#000000",fontSize:E.fontSize?`${E.fontSize}px`:h.descriptionFontSize?`${h.descriptionFontSize}px`:"14px",fontFamily:gt(E.fontFamily)||"inherit",textAlign:E.alignment||"left",lineHeight:h.descriptionLineHeight||1.5,fontWeight:E.decoration?.includes("bold")?"bold":"normal",fontStyle:E.decoration?.includes("italic")?"italic":"normal",textDecoration:E.decoration?.includes("underline")?"underline":"none"},children:h.descriptionText})]},h.id)}default:return null}},C=Pt(s,"BTS");return(0,Zt.jsxs)(Zt.Fragment,{children:[(0,Zt.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:f.backdropColor||"rgba(0,0,0,0.5)",opacity:b,zIndex:C-1,transition:"opacity 0.3s ease"},onClick:()=>{s?.id&&u(`viaAppStorys${s.id}`),l(!0)}}),(0,Zt.jsxs)("div",{style:{position:"fixed",bottom:0,left:"50%",transform:"translateX(-50%)",width:"100%",maxWidth:"500px",backgroundColor:f.backgroundColor||"#FFFFFF",borderTopLeftRadius:`${f.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${f.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:`${f.cornerRadius?.bottomLeft??0}px`,borderBottomRightRadius:`${f.cornerRadius?.bottomRight??0}px`,zIndex:C,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,Zt.jsx)("div",{style:{width:"40px",height:"5px",backgroundColor:"#E0E0E0",borderRadius:"2.5px",marginBottom:"16px",cursor:"pointer"},onClick:()=>l(!0)}),f.crossButton?.enabled&&(0,Zt.jsx)(Qt,{config:f.crossButton,onPress:()=>{s?.id&&u(`viaAppStorys${s.id}`),l(!0)},style:{top:f.crossButton?.margin?.top??12,right:f.crossButton?.margin?.right??12}}),(0,Zt.jsx)("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:"12px"},children:g.map(R)})]})]})};var jt=require("react");kt();te();var Io=me(require("lottie-react")),mt=require("react/jsx-runtime"),ra=Io.default?.default??Io.default??Io.Lottie??Io,Dr=5,ai=3;function bn(t){if(t!=null)return`${t}px`}function ue(t,e="0px"){return t==null?e:`${t}px`}function Fo(t){return{marginTop:bn(t?.top),marginRight:bn(t?.right),marginBottom:bn(t?.bottom),marginLeft:bn(t?.left)}}function ci(t){return gt(t)}function To(t){if(!t)return{};let e={};t.color&&(e.color=t.color),t.fontSize&&(e.fontSize=t.fontSize);let o=ci(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 xn(t){return`${t?.topLeft??8}px ${t?.topRight??8}px ${t?.bottomRight??8}px ${t?.bottomLeft??8}px`}function li(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function sa(t){let e=t.styling?.rating?.ratingType;return e==="number"||e==="emoji"||e==="star"?e:"star"}function aa(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 la(t){return Array.from({length:5},(e,o)=>o+1)}function di(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 da(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=di(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 d of s){let c=di(d);if(c!=null)return c}}return 8}var ca=({fill:t,stroke:e})=>(0,mt.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":!0,children:(0,mt.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"})}),ua=({details:t,appearance:e,rating:o,selectedOptions:n,comments:i,isHighRating:s,feedbackOptions:d,onRate:c,onToggleOption:l,onCommentChange:y,onInlineSubmit:u,canSubmit:m,isMobile:f})=>{let P=t.styling||{},g=P.feedbackPage||{},b=P.rating||{},R=P.initialFeedback||{},C=g.submitButton?.cta,h=sa(t),T=h==="number"?la(t):[],E=h==="emoji"?aa(t):[],K=h==="number"?da(t):8,I=h==="number"?K:b.spacing??8,S=f?"clamp(32px, 11vw, 44px)":"44px",M=f?"clamp(16px, 4.5vw, 22px)":22,x=li(b.alignment),N=xn(b.cornerRadius),H=s?b.star?.high:b.star?.low,z=typeof b.number=="object"&&b.number?b.number:void 0,O=s?z?.high:z?.low,B=C?.container?.ctaFullWidth?"100%":Math.max(140,di(C?.container?.ctaWidth)??180);return(0,mt.jsxs)(mt.Fragment,{children:[(0,mt.jsx)("div",{style:Fo(R.title?.margin),children:(0,mt.jsx)("div",{style:{...To(R.title?.textStyle),color:R.title?.textStyle?.color||"#101828",fontSize:R.title?.textStyle?.fontSize||20,lineHeight:1.3,wordBreak:"break-word",overflowWrap:"break-word",paddingRight:P.crossButton?.enabled?(P.crossButton.size??30)+(P.crossButton.margin?.right??4)+4:0},children:t.title||"How was your experience?"})}),(0,mt.jsx)("div",{style:Fo(R.subtitle?.margin),children:(0,mt.jsx)("div",{style:{...To(R.subtitle?.textStyle),color:R.subtitle?.textStyle?.color||"#4b5563",fontSize:R.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,mt.jsxs)("div",{style:{marginTop:8,display:"flex",justifyContent:x,gap:I,flexWrap:"wrap"},children:[h==="star"&&Array.from({length:Dr},(Z,v)=>{let A=v+1,V=A<=o,rt=V?H?.stylingContainer:b.star?.unselected?.stylingContainer,lt=V?H?.stylingStar:b.star?.unselected?.stylingStar;return(0,mt.jsx)("button",{onClick:()=>c(A),style:{border:`${rt?.borderWidth??1}px solid ${rt?.border||"#d1d5db"}`,background:rt?.background||"#ffffff",borderRadius:N,width:S,height:S,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,flexShrink:0},"aria-label":`Rate ${A} out of ${Dr}`,children:(0,mt.jsx)(ca,{fill:lt?.background||(V?"#f59e0b":"#e5e7eb"),stroke:lt?.border||(V?"#d97706":"#9ca3af")})},A)}),h==="number"&&T.map((Z,v)=>{let A=Z===o,V=A?O?.stylingContainer:z?.unselected?.stylingContainer,rt=A?z?.stylingNumber:z?.unselected?.stylingNumber;return(0,mt.jsx)("button",{onClick:()=>c(Z),style:{border:`${V?.borderWidth??1}px solid ${V?.border||(A?"#1d4ed8":"#d1d5db")}`,background:V?.fill||V?.background||(A?"#dbeafe":"#ffffff"),color:rt?.text||(A?"#1d4ed8":"#111827"),fontSize:rt?.textSize||void 0,borderRadius:N,minWidth:S,height:S,padding:"0 10px",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontWeight:600,flexShrink:0},"aria-label":`Rate ${Z}`,children:Z},`${Z}-${v}`)}),h==="emoji"&&E.map((Z,v)=>{let A=v+1,V=A===o,rt=b.emoji,a=(V?rt?.selected:rt?.unselected)?.stylingContainer;return(0,mt.jsx)("button",{onClick:()=>c(A),style:{border:`${a?.borderWidth??1}px solid ${a?.border||(V?"#1d4ed8":"#d1d5db")}`,background:a?.fill||a?.background||(V?"#dbeafe":"#ffffff"),borderRadius:N,width:S,height:S,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:M,flexShrink:0},"aria-label":`Emoji rating ${v+1}`,children:Z},`${Z}-${v}`)})]}),o>0&&(0,mt.jsx)("div",{style:{marginTop:6,textAlign:"center",color:"#374151",fontSize:14},children:s?t.highStarText||b.highRatingSubtitle:t.lowStarText||b.lowRatingSubtitle}),o>0&&o<=ai&&(0,mt.jsxs)(mt.Fragment,{children:[d.length>0&&(0,mt.jsx)("div",{style:{...Fo(g.options?.margin),display:"flex",flexDirection:"column",alignItems:"stretch",gap:g.options?.optionsSpacing??8,width:"100%"},children:d.map(Z=>{let A=n.includes(Z)?g.options?.selectedOptions:g.options?.nonSelectedOptions;return(0,mt.jsx)("button",{onClick:()=>l(Z),style:{border:`${A?.borderWidth??1}px solid ${A?.colors?.border||"#d1d5db"}`,background:A?.colors?.background||"#f9fafb",color:A?.colors?.text||"#111827",width:"100%",height:g.options?.optionsHeight||38,borderRadius:xn(g.options?.cornerRadius),padding:"0 14px",cursor:"pointer",textAlign:"center",...To(A?.textStyle)},children:Z},Z)})}),g.additionalComments?.enabled!==!1&&(0,mt.jsx)("textarea",{value:i,onChange:Z=>y(Z.target.value),placeholder:g.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:`${g.additionalComments?.borderWidth??1}px solid ${g.additionalComments?.colors?.border||"#d1d5db"}`,background:g.additionalComments?.colors?.background||"#ffffff",color:g.additionalComments?.colors?.text||"#111827",borderRadius:8,padding:"12px",...To(g.additionalComments?.textStyle)}}),(0,mt.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:C?.margin?.top??8,marginBottom:C?.margin?.bottom??0,marginLeft:C?.margin?.left??0,marginRight:C?.margin?.right??0,paddingTop:6,paddingBottom:6,background:e?.backgroundColor||"#ffffff",display:"flex",justifyContent:li(C?.container?.alignment)},children:(0,mt.jsx)("button",{onClick:()=>u(),disabled:!m,style:{width:B,maxWidth:"100%",height:Number(C?.container?.height)||40,border:`${C?.container?.borderWidth??0}px solid ${C?.container?.borderColor||"transparent"}`,background:C?.container?.backgroundColor||"#6848b1",color:C?.text?.color||"#ffffff",borderRadius:xn(C?.cornerRadius),fontFamily:ci(C?.text?.fontFamily),fontSize:Number(C?.text?.fontSize)||14,fontWeight:C?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:m?"pointer":"not-allowed",opacity:m?1:.65,padding:"0 12px",boxSizing:"border-box"},children:g.submitButton?.text||"Submit"})})]})]})},pa=({details:t,isHighRating:e,onDone:o})=>{let n=t.styling||{},i=n.thankyouPage||{},s=n.rating||{},d=li(i.doneButton?.cta?.container?.alignment),[c,l]=(0,jt.useState)(null),y=t.thankyouImage?.endsWith(".json");return(0,jt.useEffect)(()=>{y&&t.thankyouImage&&fetch(t.thankyouImage).then(u=>u.json()).then(u=>l(u)).catch(u=>console.error("Error loading Lottie:",u))},[t.thankyouImage,y]),(0,mt.jsxs)(mt.Fragment,{children:[t.thankyouImage&&(0,mt.jsx)("div",{style:{display:"flex",justifyContent:"center",...Fo(i.imageStyle?.margin)},children:y?c?(0,mt.jsx)(ra,{animationData:c,loop:!0,style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):(0,mt.jsx)("div",{style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80}}):(0,mt.jsx)("img",{src:t.thankyouImage,alt:"thank you",style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80,objectFit:"cover",borderRadius:8}})}),(0,mt.jsx)("div",{style:Fo(i.title?.margin),children:(0,mt.jsx)("div",{style:{color:"#111827",fontSize:20,lineHeight:1.3,...To(i.title?.textStyle),wordBreak:"break-word",overflowWrap:"break-word"},children:t.thankyouText||(e?s.highRatingTitle:s.lowRatingTitle)||"Thank you for your feedback"})}),(0,mt.jsx)("div",{style:Fo(i.subtitle?.margin),children:(0,mt.jsx)("div",{style:{color:"#4b5563",fontSize:14,lineHeight:1.4,...To(i.subtitle?.textStyle),wordBreak:"break-word",overflowWrap:"break-word"},children:t.thankyouDescription||(e?s.highRatingSubtitle:s.lowRatingSubtitle)||"We appreciate your time."})}),(0,mt.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:d},children:(0,mt.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:xn(i.doneButton?.cta?.cornerRadius),fontFamily:ci(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"})})]})},ga=()=>{let t=_t("CSAT"),e=W(r=>r.isVisible),o=W(r=>r.campaigns),n=W(r=>r.allCampaigns),i=W(r=>r.currentScreen),s=W(r=>r.userId),[d,c]=(0,jt.useState)(typeof window<"u"?window.innerWidth:1024);(0,jt.useEffect)(()=>{if(typeof window>"u")return;let r=()=>c(window.innerWidth);return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]);let l=d<768,y=t??(()=>{let r=(i||"").trim().toLowerCase(),p=[...o||[],...n||[]].filter(Q=>{if(!Q||Q.campaign_type!=="CSAT"||!Vt(Q,s))return!1;let Y=!!(Q.trigger_event??Q.trigger);if(!(Q.display_trigger!==!1&&!Y))return!1;let dt=(Q.screen||"").trim().toLowerCase();return!dt||dt===r});if(p.length===0)return;let k=Et(p)[0];if(k)try{return ae(k)}catch{return k}})(),[u,m]=(0,jt.useState)(!1),[f,P]=(0,jt.useState)(!1),[g,b]=(0,jt.useState)(!1),[R,C]=(0,jt.useState)(!1),[h,T]=(0,jt.useState)(0),[E,K]=(0,jt.useState)([]),[I,S]=(0,jt.useState)(""),[M,x]=(0,jt.useState)(!1),N=(0,jt.useRef)(null);(0,jt.useEffect)(()=>{if(!y?.id||N.current===y.id)return;N.current=y.id,m(!1),P(!1),b(!1),C(!1),T(0),K([]),S(""),x(!1);let r=y.details?.styling?.appearance?.displayDelay??0,p=globalThis.setTimeout(()=>{P(!0),at("viewed",y.id)},Math.max(0,r)*1e3);return()=>globalThis.clearTimeout(p)},[y?.id]),(0,jt.useEffect)(()=>{if(f){let r=setTimeout(()=>b(!0),30);return()=>clearTimeout(r)}},[f]);let H=(0,jt.useMemo)(()=>{let r=y?.details?.feedback_option||{};return Object.keys(r).sort((p,j)=>p.localeCompare(j)).map(p=>typeof r[p]=="string"?r[p].trim():r[p]).filter(Boolean)},[y]);if(!y||!e||u||!f)return null;let z=y.details,O=z.styling||{},B=O.appearance||{},Z=h>ai,v=r=>{K(p=>p.includes(r)?p.filter(j=>j!==r):[...p,r])},A=async r=>{let p=r?.rating??h;if(p<1)return;x(!0);let j=y.id,k=(r?.options??E)[0]||"",Q=r?.comments??I??"";at("csat captured",j,{starCount:p,selectedOption:k,additionalComments:Q})},V=r=>{if(T(r),r>ai){K([]),S("");let p=y?.id;setTimeout(()=>{x(!0);try{at("csat captured",p,{starCount:r,selectedOption:"",additionalComments:""})}catch(j){console.warn("Error sending csat captured",j)}},1e3)}},rt=async()=>{C(!0);try{let r=y?.id;await at("csat closed",r)}catch(r){console.warn("Error sending csat closed",r)}finally{setTimeout(()=>{m(!0)},300)}},lt=()=>{if(Z&&z.link){let r=y&&y.id||void 0;try{r&&at("clicked",r)}catch{}try{let p=String(z.link||"").trim();if(Rt(p)){C(!0),setTimeout(()=>{m(!0)},300);return}if(p&&!p.startsWith("http")&&Gt(p)){C(!0),setTimeout(()=>{m(!0)},300);return}}catch(p){console.warn("revealCampaignFromLink error",p)}try{globalThis.open(z.link,"_blank")}catch{}}C(!0),setTimeout(()=>{m(!0)},300)},a=l?{position:"fixed",inset:0,zIndex:Pt(y,"CSAT"),display:"flex",justifyContent:"center",alignItems:"flex-end",paddingLeft:ue(B.margin?.left,"0px"),paddingRight:ue(B.margin?.right,"0px"),pointerEvents:"none"}:{position:"fixed",inset:0,zIndex:Pt(y,"CSAT"),display:"flex",justifyContent:"flex-end",alignItems:"flex-end",paddingTop:ue(B.margin?.top),paddingRight:ue(B.margin?.right,"20px"),paddingBottom:ue(B.margin?.bottom,"20px"),paddingLeft:ue(B.margin?.left,"20px"),pointerEvents:"none"},F=l?{position:"relative",width:"100%",maxWidth:"none",maxHeight:"85vh",overflow:"visible",backgroundColor:B.backgroundColor||"#ffffff",borderTopLeftRadius:`${B.borderRadius??16}px`,borderTopRightRadius:`${B.borderRadius??16}px`,borderBottomLeftRadius:0,borderBottomRightRadius:0,boxSizing:"border-box",paddingTop:ue(B.padding?.top,"12px"),paddingRight:ue(B.padding?.right,"16px"),paddingBottom:`max(${ue(B.padding?.bottom,"16px")}, env(safe-area-inset-bottom, 16px))`,paddingLeft:ue(B.padding?.left,"16px"),pointerEvents:"auto",boxShadow:"0 -8px 32px rgba(0, 0, 0, 0.20)",display:"flex",flexDirection:"column",transform:R||!g?"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:B.backgroundColor||"#ffffff",borderRadius:`${B.borderRadius??12}px`,boxSizing:"border-box",paddingTop:ue(B.padding?.top,"8px"),paddingRight:ue(B.padding?.right,"12px"),paddingBottom:ue(B.padding?.bottom,"8px"),paddingLeft:ue(B.padding?.left,"12px"),pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column",transform:R||!g?"translateY(100%)":"translateY(0)",transition:"transform 0.3s cubic-bezier(0.25, 1, 0.5, 1)"};return(0,mt.jsx)("div",{style:a,children:(0,mt.jsxs)("div",{style:F,children:[(0,mt.jsx)("style",{children:`
|
|
129
129
|
.appstorys-csat-scroll {
|
|
130
130
|
scrollbar-width: none; /* Firefox */
|
|
131
131
|
-ms-overflow-style: none; /* IE/Edge */
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
height: 0;
|
|
136
136
|
display: none; /* Chrome/Safari */
|
|
137
137
|
}
|
|
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:`
|
|
138
|
+
`}),O.crossButton?.enabled&&(0,mt.jsx)(Qt,{config:O.crossButton,onPress:()=>{rt()},style:{top:O.crossButton?.margin?.top??10,right:O.crossButton?.margin?.right??10}}),(0,mt.jsx)("div",{className:"appstorys-csat-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:4},children:M?(0,mt.jsx)(pa,{details:z,isHighRating:Z,onDone:lt}):(0,mt.jsx)(ua,{details:z,rating:h,selectedOptions:E,comments:I,isHighRating:Z,feedbackOptions:H,onRate:V,onToggleOption:v,onCommentChange:S,onInlineSubmit:A,canSubmit:h>=1,appearance:B,isMobile:l})})]})})},$r=ga;var It=require("react");kt();te();var Bo=me(require("lottie-react")),ut=require("react/jsx-runtime"),fa=Bo.default?.default??Bo.default??Bo.Lottie??Bo;function Sn(t){if(t!=null)return`${t}px`}function Cn(t){return gt(t)}function zo(t){if(!t)return{};let e={};t.color&&(e.color=t.color),t.fontSize&&(e.fontSize=t.fontSize);let o=Cn(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 Go(t){return{marginTop:Sn(t?.top),marginRight:Sn(t?.right),marginBottom:Sn(t?.bottom),marginLeft:Sn(t?.left)}}function Qo(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 Hr(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function Jo(t){return Math.max(0,Math.min(1,t))}function Nr(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}, ${Jo(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}, ${Jo(e)})`}return`rgba(0, 0, 0, ${Jo(e)})`}function ma(t){if(t==null)return .4;let e=Number(t);return Number.isFinite(e)?e>1?Jo(e/100):Jo(e):.4}function Or(t){return[...t.slides||[]].sort((o,n)=>(o.order??0)-(n.order??0))}function ya(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 l=parseInt(i[1],10)-1;return l>=0&&l<e.length?{action:"jump",targetIndex:l}:{action:"none"}}let s=e.findIndex(c=>c.id===o);if(s!==-1)return{action:"jump",targetIndex:s};let d=Number(o);if(Number.isFinite(d)&&d>0){let c=e.findIndex(l=>l.order===d);if(c!==-1)return{action:"jump",targetIndex:c}}return{action:"none"}}function ha(t){let e=t?.options||{},o=Object.keys(e),n=i=>{let s=/(\d+)/.exec(i);if(!s)return;let d=Number(s[1]);return Number.isFinite(d)?d:void 0};return o.sort((i,s)=>{let d=n(i),c=n(s);return d!=null&&c!=null?d-c:d!=null?-1:c!=null?1:i.localeCompare(s)}),o.map(i=>e[i]).filter(i=>typeof i=="string"&&i.trim().length>0)}function ba(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 xa(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 jr(t){return xa(t?.borderwidth)??1}var qr=({details:t,slide:e,appearance:o,selectedOptions:n,comment:i,onSelectOption:s,onCommentChange:d,onSubmit:c,canSubmit:l})=>{let y=t.styling||{},u=y.options||{},m=y.cta,f=(0,It.useMemo)(()=>ha(e),[e]),P=u.optionsSpacing??6,g=u.bulletSpacing??12,b=u.optionsHeight??48,R=Hr(m?.container?.alignment),C=y.title?.textStyle,h=y.subtitle?.textStyle;return(0,ut.jsxs)(ut.Fragment,{children:[(0,ut.jsx)("div",{style:{width:"100%",...Go(C?.margin)},children:(0,ut.jsx)("div",{style:{...zo(C),color:C?.color||"#111827",fontSize:C?.fontSize||22,lineHeight:1.3,textAlign:C?.textAlign||"left",fontWeight:C?.fontDecoration?.includes("bold")?"bold":C?.fontDecoration?"normal":600,fontStyle:C?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:C?.fontDecoration?.includes("underline")?"underline":"none"},children:e.title||e.question||t.name||"Survey"})}),(e.subtitle||h)&&(0,ut.jsx)("div",{style:{width:"100%",...Go(h?.margin)},children:(0,ut.jsx)("div",{style:{...zo(h),color:h?.color||"#6b7280",fontSize:h?.fontSize||16,lineHeight:1.35,textAlign:h?.textAlign||"left",fontWeight:h?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:h?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:h?.fontDecoration?.includes("underline")?"underline":"none"},children:e.subtitle||""})}),f.length>0&&(()=>{let T="__others__",E=e.additionalComment?.placeholder?.trim()||"Others",K=f.map(S=>({value:S,label:S}));e.additionalComment?.enabled&&K.push({value:T,label:E});let I=n.includes(T);return(0,ut.jsxs)(ut.Fragment,{children:[(0,ut.jsx)("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:P},children:K.map(({value:S,label:M},x)=>{let N=n.includes(S),H=N?u.selectedOptions:u.nonSelectedOptions,z=jr(H?.textStyle),O=ba(u.optionListStyle,x),B=u.optionListStyle,Z=B==="bulleted",v=B==="number"||B==="alphabet"||B==="roman",A=H?.colors?.text||H?.textStyle?.color||(N?"#ffffff":"#111827"),V=H?.colors?.background||(N?"#1f35db":"#ffffff"),rt=H?.colors?.border||(N?"#1f35db":"#e5e7eb");return(0,ut.jsxs)("button",{onClick:()=>s(S),style:{width:"100%",boxSizing:"border-box",minHeight:b,height:"auto",borderRadius:Qo(u.cornerRadius,7),border:`${z}px solid ${rt}`,background:V,color:A,cursor:"pointer",display:"flex",alignItems:"center",gap:g,paddingTop:8,paddingBottom:8,paddingLeft:14,paddingRight:14,textAlign:H?.textStyle?.textAlign||"left",...zo(H?.textStyle)},"aria-pressed":N,children:[Z?(0,ut.jsx)("span",{"aria-hidden":!0,style:{width:18,height:18,borderRadius:"50%",border:`2px solid ${N?u.selectedOptions?.colors?.border||rt:u.nonSelectedOptions?.colors?.border||rt}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:N&&(0,ut.jsx)("span",{style:{width:10,height:10,borderRadius:"50%",backgroundColor:A}})}):v?(0,ut.jsx)("span",{"aria-hidden":!0,style:{fontSize:H?.textStyle?.fontSize?H.textStyle.fontSize*.85:16,fontWeight:H?.textStyle?.fontDecoration?.includes("bold")?"bold":600,fontFamily:Cn(H?.textStyle?.fontFamily),color:A,marginRight:2,flexShrink:0},children:O}):null,(0,ut.jsx)("span",{style:{flex:1,minWidth:0,wordBreak:"break-word",lineHeight:1.35,color:A},children:M})]},`${S}-${x}`)})}),I&&(0,ut.jsx)("textarea",{value:i,onChange:S=>d(S.target.value),placeholder:e.additionalComment?.placeholder||"Type your response...",style:{marginTop:10,width:"100%",boxSizing:"border-box",minHeight:72,resize:"none",overflowY:"auto",border:`${jr(u.additionalComments?.textStyle)}px solid ${u.additionalComments?.colors?.border||"#e5e7eb"}`,background:u.additionalComments?.colors?.background||"#ffffff",color:u.additionalComments?.colors?.text||"#111827",borderRadius:Qo(u.cornerRadius,7),padding:"12px",...zo(u.additionalComments?.textStyle)}})]})})(),(0,ut.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:m?.margin?.top??12,marginBottom:m?.margin?.bottom??0,marginLeft:m?.margin?.left??0,marginRight:m?.margin?.right??0,paddingTop:10,paddingBottom:4,background:o?.backgroundColor||"#ffffff",display:"flex",justifyContent:R,width:"100%",boxSizing:"border-box"},children:(0,ut.jsx)("button",{onClick:c,disabled:!l,style:{width:m?.container?.ctaFullWidth?"100%":m?.container?.ctaWidth?`${m.container.ctaWidth}px`:"140px",maxWidth:"100%",height:m?.container?.height??50,border:`${m?.container?.borderWidth??0}px solid ${m?.container?.borderColor||"transparent"}`,background:m?.container?.backgroundColor||"#1f35db",color:m?.text?.color||"#ffffff",borderRadius:Qo(m?.cornerRadius,7),fontFamily:Cn(m?.text?.fontFamily)||"Arial",fontSize:m?.text?.fontSize||18,fontWeight:m?.text?.fontDecoration?.includes("bold")?"bold":600,fontStyle:m?.text?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:m?.text?.fontDecoration?.includes("underline")?"underline":"none",cursor:l?"pointer":"not-allowed",opacity:l?1:.6,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 20px",boxSizing:"border-box"},children:e.submitButtonText||"Submit"})})]})},Ur=({details:t,onDone:e})=>{let o=t.styling||{},n=o.thankyouPage||{},i=n.cta||o.cta,s=Hr(i?.container?.alignment),d=t.thankYouImage?.endsWith(".json"),[c,l]=(0,It.useState)(null);(0,It.useEffect)(()=>{d&&t.thankYouImage?fetch(t.thankYouImage).then(f=>f.json()).then(f=>l(f)).catch(f=>console.error("AppStorys Survey: Error loading Thank You Lottie:",f)):l(null)},[t.thankYouImage,d]);let y=t.thankYouTitle||t?.thank_you_title||"Thank you",u=t.thankYouText||t?.thank_you_text||"",m=t.thankYouButtonText||t?.thank_you_button_text||"Done";return(0,ut.jsxs)(ut.Fragment,{children:[t.thankYouImage&&(0,ut.jsx)("div",{style:{display:"flex",justifyContent:"center",...Go(n.imageStyle?.margin)},children:d?c?(0,ut.jsx)(fa,{animationData:c,loop:!0,style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):(0,ut.jsx)("div",{style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80}}):(0,ut.jsx)("img",{src:t.thankYouImage,alt:"thank you",style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80,objectFit:"cover",borderRadius:10}})}),(0,ut.jsx)("div",{style:{width:"100%",...Go(n.title?.textStyle?.margin)},children:(0,ut.jsx)("div",{style:{...zo(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:y})}),u&&(0,ut.jsx)("div",{style:{width:"100%",...Go(n.subtitle?.textStyle?.margin)},children:(0,ut.jsx)("div",{style:{...zo(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:u})}),(m||i)&&(0,ut.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,ut.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:Qo(i?.cornerRadius,12),fontFamily:Cn(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:m})})]})},Sa=()=>{let t=_t("SUR"),e=W($=>$.isVisible),o=W($=>$.campaigns),n=W($=>$.allCampaigns),i=W($=>$.currentScreen),s=W($=>$.userId),[d,c]=(0,It.useState)(typeof window<"u"?window.innerWidth:1024),[l,y]=(0,It.useState)(0),[u,m]=(0,It.useState)(!1),[f,P]=(0,It.useState)(!1),[g,b]=(0,It.useState)(!1),R=(0,It.useRef)(0),C=(0,It.useRef)(0),h=(0,It.useRef)(null),T=(0,It.useRef)(0),E=(0,It.useRef)(!1);(0,It.useEffect)(()=>{if(typeof window>"u")return;let $=()=>c(window.innerWidth);return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)},[]);let K=d<768,I=t??(()=>{let $=(i||"").trim().toLowerCase(),_=[...o||[],...n||[]].filter(G=>{if(!G||G.campaign_type!=="SUR"||!Vt(G,s))return!1;let nt=!!(G.trigger_event??G.trigger);if(!(G.display_trigger!==!1&&!nt))return!1;let qt=(G.screen||"").trim().toLowerCase();return!qt||qt===$});if(_.length===0)return;let L=Et(_)[0];if(L)try{return ae(L)}catch{return L}})(),[S,M]=(0,It.useState)(!1),[x,N]=(0,It.useState)(!1),[H,z]=(0,It.useState)(0),[O,B]=(0,It.useState)([]),[Z,v]=(0,It.useState)(""),[A,V]=(0,It.useState)({}),[rt,lt]=(0,It.useState)(!1),a=(0,It.useRef)(null);(0,It.useEffect)(()=>{if(!I?.id||a.current===I.id)return;a.current=I.id,M(!1),N(!1),z(0),B([]),v(""),V({}),lt(!1),b(!1),P(!1),y(0);let $=I.details?.styling?.appearance?.displayDelay??0,_=globalThis.setTimeout(()=>{N(!0);let D=I.details?.id,L=Or(I.details),G=L.length>0?L[0].id:void 0;at("viewed",I.id,{survey_id:D,slide_id:G})},Math.max(0,$)*1e3);return()=>globalThis.clearTimeout(_)},[I?.id]),(0,It.useEffect)(()=>{if(x){let $=setTimeout(()=>b(!0),30);return()=>clearTimeout($)}},[x]);let F=(0,It.useMemo)(()=>I?Or(I.details):[],[I]),r=F[H];(0,It.useEffect)(()=>{if(typeof window>"u"||!I||!e||S||!x)return;let $=window.scrollY||window.pageYOffset||0,_=document.body.style.position,D=document.body.style.top,L=document.body.style.left,G=document.body.style.right,nt=document.body.style.width,yt=document.body.style.overflow,qt=document.documentElement.style.overflow;return document.body.style.position="fixed",document.body.style.top=`-${$}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=_,document.body.style.top=D,document.body.style.left=L,document.body.style.right=G,document.body.style.width=nt,document.body.style.overflow=yt,document.documentElement.style.overflow=qt,window.scrollTo(0,$)}},[I,e,S,x]);let p=($,_)=>{R.current=$,C.current=0,E.current=_,h.current?T.current=h.current.scrollTop:T.current=0,m(!0)},j=$=>{if(!R.current)return;let _=$-R.current,D=h.current?h.current.scrollTop:0,L=T.current<=0&&D<=0;(E.current||L)&&_>0?(C.current=_,y(_)):(C.current=0,y(0))},k=()=>{m(!1),E.current=!1,C.current>80?(P(!0),setTimeout(()=>{ht()},250)):(y(0),C.current=0),R.current=0};if((0,It.useEffect)(()=>{if(!u)return;let $=G=>{j(G.clientY)},_=()=>{k()},D=G=>{G.cancelable&&G.preventDefault(),G.touches&&G.touches[0]&&j(G.touches[0].clientY)},L=()=>{k()};return window.addEventListener("pointermove",$),window.addEventListener("pointerup",_),window.addEventListener("touchmove",D,{passive:!1}),window.addEventListener("touchend",L),()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",_),window.removeEventListener("touchmove",D),window.removeEventListener("touchend",L)}},[u]),!I||!e||S||!x)return null;let Q=I.details,Y=Q.styling||{},st=Y.appearance||{},dt=st.backdropColor||"#000000",tt=ma(st.backdropOpacity),ft=r?.multipleSelection!==!1&&r?.isMultiSelect!==!1&&Y.options?.multipleSelection!==!1,J=$=>{B(ft?_=>_.includes($)?_.filter(D=>D!==$):[..._,$]:_=>_[0]===$?[]:[$])},ct=async($,_)=>{let D=F.map(At=>({slide_id:At.id,order:At.order,title:At.title,question:At.question,selected_options:$[At.id]?.options,comment:$[At.id]?.comment})),L=I.id,G=[];for(let At of F){let Ut=$[At.id]?.options||[];for(let $t of Ut){let le=Object.entries(At.options||{}).find(([,ye])=>String(ye)===String($t));le&&G.push(le[0])}}let nt=D.map(At=>At.comment).filter(Boolean).join(" || ")||"",yt=Q.id||L;at("survey captured",yt,{survey_id:Q.id,slide_id:_,selected_options:G,otherText:nt}),Y.content?.isThankyouPage!==!1?lt(!0):M(!0)},xt=async()=>{if(!r||O.length===0)return;let $={...A,[r.id]:{options:O,comment:Z}};V($);let _=[];if(r.options)for(let nt of O){let yt=Object.entries(r.options).find(([,qt])=>String(qt)===String(nt));yt&&_.push(yt[0])}try{let nt=I.id,yt=Q.id||nt;at("survey captured",yt,{survey_id:Q.id,slide_id:r.id,selected_options:_,otherText:Z||""})}catch(nt){console.warn("Error sending per-slide survey captured",nt)}let D=O.includes("__others__"),L={action:"none"};for(let nt of r.logic||[]){let yt=nt.selectOption||[];if(yt.length===0)continue;let qt=yt.some($t=>_.includes($t)),At=yt.some($t=>O.includes($t)),Ut=D&&yt.some($t=>$t==="others"||$t==="__others__");if(!(!qt&&!At&&!Ut)&&nt.redirectTo){let $t=ya(nt.redirectTo,F);if($t.action!=="none"){L=$t;break}}}if(L.action==="thankyou"){await ct($,r.id);return}if(L.action==="jump"){z(L.targetIndex);return}if(H>=F.length-1){await ct($,r.id);return}z(nt=>Math.min(nt+1,F.length-1))},pt=()=>{let $=Q.thankYouButtonConfig;if($?.enabled&&$.redirectUrl){try{let _=String($.redirectUrl||"").trim();if(Rt(_)){M(!0);return}if(_&&!_.startsWith("http")&&Gt(_)){M(!0);return}}catch(_){console.warn("revealCampaignFromLink error",_)}try{globalThis.open($.redirectUrl,"_blank")}catch{}}M(!0)},ht=async()=>{try{let $=I?.id,_=Q?.id,D=r?.id;await at("SurveyDismissed",$,{survey_id:_,slide_id:D})}catch($){console.warn("Error sending SurveyDismissed",$)}finally{M(!0)}};return r?K?(0,ut.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:Pt(I,"SUR"),display:"flex",justifyContent:"center",alignItems:"flex-end",padding:0,boxSizing:"border-box",pointerEvents:"auto",touchAction:"none",overscrollBehavior:"none"},children:[(0,ut.jsx)("div",{"aria-hidden":!0,onClick:()=>{P(!0),setTimeout(()=>ht(),250)},onTouchMove:$=>{$.cancelable&&$.preventDefault()},style:{position:"absolute",inset:0,background:Nr(dt,f?0:tt),transition:u?"none":"background 0.25s ease-out",zIndex:1,touchAction:"none"}}),(0,ut.jsxs)("div",{onPointerDown:$=>{let _=$.target;_&&_.closest("button, input, textarea, a")||p($.clientY,!1)},onTouchStart:$=>{let _=$.target;_&&_.closest("button, input, textarea, a")||$.touches&&$.touches[0]&&p($.touches[0].clientY,!1)},style:{position:"relative",zIndex:2,width:"100%",maxWidth:"520px",maxHeight:"85vh",backgroundColor:st.backgroundColor||"#ffffff",borderTopLeftRadius:`${st.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${st.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:f?"translateY(100%)":g?`translateY(${l}px)`:"translateY(100%)",transition:u?"none":"transform 0.28s cubic-bezier(0.25, 1, 0.5, 1)"},children:[(0,ut.jsx)("style",{children:`
|
|
139
139
|
.appstorys-survey-scroll {
|
|
140
140
|
scrollbar-width: none;
|
|
141
141
|
-ms-overflow-style: none;
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
height: 0;
|
|
146
146
|
display: none;
|
|
147
147
|
}
|
|
148
|
-
`}),(0,
|
|
148
|
+
`}),(0,ut.jsx)("div",{onPointerDown:$=>{$.stopPropagation(),p($.clientY,!0)},onTouchStart:$=>{$.stopPropagation(),$.touches&&$.touches[0]&&p($.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"}}),Y.crossButton?.enabled&&(0,ut.jsx)(Qt,{config:Y.crossButton,onPress:()=>{P(!0),setTimeout(()=>ht(),250)},style:{top:Y.crossButton?.margin?.top!==void 0&&Y.crossButton.margin.top>=0?Y.crossButton.margin.top:10,right:Y.crossButton?.margin?.right!==void 0&&Y.crossButton.margin.right>=0?Y.crossButton.margin.right:10,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0}}),(0,ut.jsx)("div",{ref:h,className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",overscrollBehavior:"contain",touchAction:"pan-y",paddingRight:2,WebkitOverflowScrolling:"touch"},children:rt?(0,ut.jsx)(Ur,{details:Q,onDone:pt}):(0,ut.jsx)(qr,{details:Q,slide:r,appearance:st,selectedOptions:O,comment:Z,onSelectOption:J,onCommentChange:v,onSubmit:xt,canSubmit:O.length>0})})]})]}):(0,ut.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:Pt(I,"SUR"),display:"flex",justifyContent:"flex-end",alignItems:"flex-end",padding:16,boxSizing:"border-box",pointerEvents:"none"},children:[(0,ut.jsx)("div",{"aria-hidden":!0,onClick:ht,style:{position:"absolute",inset:0,background:Nr(dt,tt),pointerEvents:tt>0?"auto":"none",zIndex:1}}),(0,ut.jsxs)("div",{style:{position:"relative",zIndex:2,width:"min(420px, 92vw)",maxWidth:"92vw",minWidth:"320px",maxHeight:"80vh",overflow:"hidden",backgroundColor:st.backgroundColor||"#ffffff",borderRadius:Qo(st.cornerRadius,12),pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[(0,ut.jsx)("style",{children:`
|
|
149
149
|
.appstorys-survey-scroll {
|
|
150
150
|
scrollbar-width: none;
|
|
151
151
|
-ms-overflow-style: none;
|
|
@@ -155,11 +155,11 @@
|
|
|
155
155
|
height: 0;
|
|
156
156
|
display: none;
|
|
157
157
|
}
|
|
158
|
-
`}),
|
|
158
|
+
`}),Y.crossButton?.enabled&&(0,ut.jsx)(Qt,{config:Y.crossButton,onPress:ht,style:{top:Y.crossButton?.margin?.top!==void 0&&Y.crossButton.margin.top>=0?Y.crossButton.margin.top:10,right:Y.crossButton?.margin?.right!==void 0&&Y.crossButton.margin.right>=0?Y.crossButton.margin.right:10,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0}}),(0,ut.jsx)("div",{className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingRight:2},children:rt?(0,ut.jsx)(Ur,{details:Q,onDone:pt}):(0,ut.jsx)(qr,{details:Q,slide:r,appearance:st,selectedOptions:O,comment:Z,onSelectOption:J,onCommentChange:v,onSubmit:xt,canSubmit:O.length>0})})]})]}):null},Vr=Sa;var Eo=require("react");kt();var ke=require("react");te();var Ao=me(require("lottie-react")),Dt=require("react/jsx-runtime"),Ca=Ao.default?.default??Ao.default??Ao.Lottie??Ao,Yr=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},va=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},wa=(t,e,o,n)=>{let i=va(t);if(i){if(e){let s=o?._variantId||o?.details?.id;at("clicked",e,s?{variant_id:s}:void 0)}if(Rt(i)){n?.();return}if(!i.startsWith("http"))try{if(Gt(i))return}catch{}try{window.open(i,"_blank")}catch{}}},Gr=({campaign:t,onDismiss:e})=>{let[o,n]=(0,ke.useState)(typeof window<"u"?window.innerWidth:1024),[i,s]=(0,ke.useState)(null),[d,c]=(0,ke.useState)(!0),l=(0,ke.useRef)(null);(0,ke.useEffect)(()=>{if(typeof window>"u")return;let F=()=>n(window.innerWidth);window.addEventListener("resize",F);let r=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",F),document.body.style.overflow=r}},[]);let{details:y}=t,u=y?.modals?.[0],m=u?.content||{},f=u?.styling||{},P=m?.chooseMediaType||u?.chooseMediaType,g=P?.type,b=P?.url;if((0,ke.useEffect)(()=>{g==="lottie"&&b?(s(null),fetch(b).then(F=>F.json()).then(F=>s(F)).catch(F=>console.error("Error fetching Lottie in ModalWithCta:",F))):s(null)},[g,b]),(0,ke.useEffect)(()=>{l.current&&(l.current.muted=d)},[d]),(0,ke.useEffect)(()=>{let F=l.current;if(!F||g!=="video")return;F.muted=!1;let r=F.play();r!==void 0&&r.then(()=>{c(!1)}).catch(()=>{F.muted=!0,c(!0),F.play().catch(()=>{})})},[b,g]),!u)return null;let R=f.appearance||{},C=f.crossButton,h=R.backdrop?.color||"rgba(0, 0, 0, 0.4)",T=R.backdrop?.opacity!==void 0&&R.backdrop?.opacity!==null?R.backdrop.opacity>1?R.backdrop.opacity/100:R.backdrop.opacity:0,E=R.enableBackdrop!==!1,K=R.dimension?.width!==void 0&&R.dimension?.width!==null&&R.dimension.width>0?R.dimension.width:300,I=o>=768,S=I?K*1.4:K,M=Math.min(S,o*.9),x=R.cornerRadius||{},N=R.backgroundColor||"#FFFFFF",H=m.titleText||"",z=m.subtitleText||"",O=m.primaryCtaText||"",B=m.secondaryCtaText||"",Z=m.primaryCtaRedirection,v=m.secondaryCtaRedirection,A=f.title||{},V=f.subTitle||{},rt=f.primaryCta||{},lt=f.secondaryCta||{},a=(F,r,p,j=!1)=>{if(!F||F.trim()==="")return null;let k=r?.container||{},Q=r?.cornerRadius||{},Y=r?.margin||{},st=r?.text||{},dt=_=>_==="left"?"flex-start":_==="right"?"flex-end":"center",tt=k.ctaWidth,ft=I&&tt?tt*1.4:tt,J=k.height||40,ct=I?J*1.2:J,xt=Q.topLeft!==void 0&&Q.topLeft>=0?Q.topLeft:8,pt=Q.topRight!==void 0&&Q.topRight>=0?Q.topRight:8,ht=Q.bottomRight!==void 0&&Q.bottomRight>=0?Q.bottomRight:8,$=Q.bottomLeft!==void 0&&Q.bottomLeft>=0?Q.bottomLeft:8;return(0,Dt.jsx)("div",{style:{display:"flex",justifyContent:dt(k.alignment),width:j?"auto":"100%",flex:j?1:void 0,marginTop:Y.top!==void 0&&Y.top>=0?Y.top:0,marginBottom:Y.bottom!==void 0&&Y.bottom>=0?Y.bottom:0,marginLeft:Y.left!==void 0&&Y.left>=0?Y.left:0,marginRight:Y.right!==void 0&&Y.right>=0?Y.right:0,boxSizing:"border-box"},children:(0,Dt.jsx)("button",{style:{width:j||k.ctaFullWidth?"100%":ft?`${ft}px`:"auto",height:ct,backgroundColor:k.backgroundColor||"#FE6B35",color:st.color||"#FFFFFF",border:`${k.borderWidth||0}px solid ${k.borderColor||"transparent"}`,borderRadius:`${xt}px ${pt}px ${ht}px ${$}px`,fontSize:st.fontSize||14,fontFamily:gt(st.fontFamily)||"Arial",fontWeight:st.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:st.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:st.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px",outline:"none",boxSizing:"border-box"},onClick:()=>wa(p,t?.id,t,e),children:Ne(F)})})};return(0,Dt.jsxs)(Dt.Fragment,{children:[(0,Dt.jsx)("style",{children:`
|
|
159
159
|
.appstorys-modal-scroll::-webkit-scrollbar { display: none; }
|
|
160
160
|
.appstorys-modal-scroll { scrollbar-width: none; }
|
|
161
|
-
`}),(0,Dt.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:
|
|
161
|
+
`}),(0,Dt.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:E?h:"transparent",opacity:E?T:1,zIndex:Pt(t,"MOD")-1,transition:"opacity 0.3s ease"}}),(0,Dt.jsxs)("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:M,maxWidth:"95vw",zIndex:Pt(t,"MOD"),overflow:"visible"},children:[(C?.enabled??!0)&&(0,Dt.jsx)(Qt,{config:C||{enabled:!0},onPress:F=>{F&&typeof F.stopPropagation=="function"&&F.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:C?.margin?.top!==void 0&&C.margin?.top>=0?C.margin.top:8,right:C?.margin?.right!==void 0&&C.margin?.right>=0?C.margin.right:8}}),(0,Dt.jsxs)("div",{style:{width:"100%",backgroundColor:N,borderTopLeftRadius:x.topLeft!==void 0&&x.topLeft>=0?x.topLeft:0,borderTopRightRadius:x.topRight!==void 0&&x.topRight>=0?x.topRight:0,borderBottomLeftRadius:x.bottomLeft!==void 0&&x.bottomLeft>=0?x.bottomLeft:0,borderBottomRightRadius:x.bottomRight!==void 0&&x.bottomRight>=0?x.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:[b&&(g==="image"||!g)&&(0,Dt.jsx)("img",{src:b,alt:"",style:{width:"100%",display:"block"}}),b&&g==="video"&&(0,Dt.jsxs)("div",{style:{position:"relative",width:"100%"},children:[(0,Dt.jsx)("video",{ref:l,src:b,autoPlay:!0,loop:!0,muted:d,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),(0,Dt.jsx)($e,{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:F=>{F.stopPropagation(),c(r=>!r)},type:d?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),b&&g==="lottie"&&i&&(()=>{let F=i.w,r=i.h,p=F&&r&&F>0?r/F:void 0,j=M,k=p?Math.round(j*p):void 0;return(0,Dt.jsx)(Ca,{animationData:i,loop:!0,autoplay:!0,style:{width:j,height:k,display:"block"}})})(),H.trim()!==""&&(0,Dt.jsx)("div",{style:{width:"100%",padding:"12px 16px 0 16px",color:A.color||"#000000",fontSize:A.fontSize||26,fontFamily:gt(A.fontFamily)||"Helvetica",fontWeight:A.fontDecoration?.includes("bold")?"bold":"600",fontStyle:A.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:A.fontDecoration?.includes("underline")?"underline":"none",textAlign:Yr(A.textAlign)||"center",boxSizing:"border-box"},children:Ne(H)}),z.trim()!==""&&(0,Dt.jsx)("div",{style:{width:"100%",padding:"4px 16px 0 16px",color:V.color||"#000000",fontSize:V.fontSize||20,fontFamily:gt(V.fontFamily)||"Helvetica",fontWeight:V.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:V.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:V.fontDecoration?.includes("underline")?"underline":"none",textAlign:Yr(V.textAlign)||"center",boxSizing:"border-box"},children:Ne(z)})]}),(O.trim()!==""||B.trim()!=="")&&(0,Dt.jsxs)("div",{style:{flexShrink:0,width:"100%",padding:"0 12px 12px 12px",boxSizing:"border-box",display:"flex",flexDirection:O.trim()!==""&&B.trim()!==""?"row":"column",gap:"8px",justifyContent:"center"},children:[a(O,rt,Z,O.trim()!==""&&B.trim()!==""),a(B,lt,v,O.trim()!==""&&B.trim()!=="")]})]})]})]})};var Re=require("react");te();var Lo=me(require("lottie-react")),ie=require("react/jsx-runtime"),ka=Lo.default?.default??Lo.default??Lo.Lottie??Lo,Qr=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,n)=>{let i=Qr(t);if(i){if(e){let s=o?._variantId||o?.details?.id;at("clicked",e,s?{variant_id:s}:void 0)}if(Rt(i)){n?.();return}if(!i.startsWith("http"))try{if(Gt(i))return}catch{}try{window.open(i,"_blank")}catch{}}},Jr=({campaign:t,onDismiss:e})=>{let[o,n]=(0,Re.useState)(typeof window<"u"?window.innerWidth:1024),[i,s]=(0,Re.useState)(null),[d,c]=(0,Re.useState)(!0),l=(0,Re.useRef)(null);(0,Re.useEffect)(()=>{if(typeof window>"u")return;let z=()=>n(window.innerWidth);window.addEventListener("resize",z);let O=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("resize",z),document.body.style.overflow=O}},[]);let{details:y}=t,u=y?.modals?.[0],m=u?.chooseMediaType,f=u?.styling||{},P=u?.redirection,g=m?.type,b=m?.url;if((0,Re.useEffect)(()=>{g==="lottie"&&b?(s(null),fetch(b).then(z=>z.json()).then(z=>s(z)).catch(z=>console.error("Error fetching Lottie in MediaOnlyModal:",z))):s(null)},[g,b]),(0,Re.useEffect)(()=>{l.current&&(l.current.muted=d)},[d]),(0,Re.useEffect)(()=>{let z=l.current;if(!z||g!=="video")return;z.muted=!1;let O=z.play();O!==void 0&&O.then(()=>{c(!1)}).catch(()=>{z.muted=!0,c(!0),z.play().catch(()=>{})})},[b,g]),!u||!m||!b)return null;let R=f.appearance||{},C=f.crossButton,h=R.backdrop?.color||"rgba(0, 0, 0, 0.4)",T=R.backdrop?.opacity!==void 0&&R.backdrop?.opacity!==null?R.backdrop.opacity>1?R.backdrop.opacity/100:R.backdrop.opacity:0,E=R.enableBackdrop!==!1,K=R.dimension?.width!==void 0&&R.dimension?.width!==null&&R.dimension.width>0?R.dimension.width:300,S=o>=768?K*1.4:K,M=Math.min(S,o*.9),x=R.cornerRadius||{},N=R.backgroundColor||(g==="lottie"?"transparent":"#FFFFFF"),H=Pt(t,"MOD");return(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)("style",{children:`
|
|
162
162
|
.appstorys-media-modal-scroll::-webkit-scrollbar { display: none; }
|
|
163
163
|
.appstorys-media-modal-scroll { scrollbar-width: none; }
|
|
164
|
-
`}),(0,
|
|
164
|
+
`}),(0,ie.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:E?h:"transparent",opacity:E?T:1,zIndex:H-1,transition:"opacity 0.3s ease"}}),(0,ie.jsxs)("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:M,maxWidth:"95vw",zIndex:H,overflow:"visible"},children:[(C?.enabled??!0)&&(0,ie.jsx)(Qt,{config:C||{enabled:!0},onPress:z=>{z&&typeof z.stopPropagation=="function"&&z.stopPropagation(),e()},style:{position:"absolute",zIndex:1e7,top:C?.margin?.top!==void 0&&C.margin?.top>=0?C.margin.top:8,right:C?.margin?.right!==void 0&&C.margin?.right>=0?C.margin.right:8}}),(0,ie.jsx)("div",{className:"appstorys-media-modal-scroll",style:{width:"100%",backgroundColor:N,borderTopLeftRadius:x.topLeft!==void 0&&x.topLeft>=0?x.topLeft:0,borderTopRightRadius:x.topRight!==void 0&&x.topRight>=0?x.topRight:0,borderBottomLeftRadius:x.bottomLeft!==void 0&&x.bottomLeft>=0?x.bottomLeft:0,borderBottomRightRadius:x.bottomRight!==void 0&&x.bottomRight>=0?x.bottomRight:0,overflow:"hidden",boxShadow:N==="transparent"?"none":"0 8px 32px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",alignItems:"center",maxHeight:"90vh",overflowY:"auto"},children:(()=>{let z=!!Qr(P);return(0,ie.jsxs)("div",{onClick:z?()=>Ra(P,t?.id,t,e):void 0,style:{width:"100%",cursor:z?"pointer":"default",minHeight:0},children:[b&&(g==="image"||!g)&&(0,ie.jsx)("img",{src:b,alt:"",style:{width:"100%",display:"block"}}),b&&g==="video"&&(0,ie.jsxs)("div",{style:{position:"relative",width:"100%"},children:[(0,ie.jsx)("video",{ref:l,src:b,autoPlay:!0,loop:!0,muted:d,playsInline:!0,controls:!1,style:{width:"100%",display:"block"}}),(0,ie.jsx)($e,{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:O=>{O.stopPropagation(),c(B=>!B)},type:d?"mute":"unmute",enabled:!0,style:{position:"absolute",zIndex:1e7,bottom:12,left:12,borderRadius:"50%"}})]}),b&&g==="lottie"&&i&&(()=>{let O=i.w,B=i.h,Z=O&&B&&O>0?B/O:void 0,v=M,A=Z?Math.round(v*Z):void 0;return(0,ie.jsx)(ka,{animationData:i,loop:!0,autoplay:!0,style:{width:v,height:A,display:"block"}})})()]})})()})]})]})};te();var ui=require("react/jsx-runtime"),Xr=()=>{let t=_t("MOD"),e=W(g=>g.campaigns),o=W(g=>g.allCampaigns),n=W(g=>g.currentScreen),i=W(g=>g.userId),s=t??(()=>{let g=(n||"").trim().toLowerCase(),b=[...e||[],...o||[]].filter(h=>{if(!h||h.campaign_type!=="MOD"||!Vt(h,i))return!1;let T=!!(h.trigger_event??h.trigger);if(!(h.display_trigger!==!1&&!T))return!1;let K=(h.screen||"").trim().toLowerCase();return!K||K===g});if(b.length===0)return;let C=Et(b)[0];if(C)try{return ae(C)}catch{return C}})(),d=W(g=>g.isVisible),[c,l]=(0,Eo.useState)(!1),y=(0,Eo.useRef)(null);(0,Eo.useEffect)(()=>{if(s?.id&&y.current!==s.id){y.current=s.id,l(!1);let g=s._variantId||s.details?.id,b=g?{variant_id:g}:void 0;at("viewed",s.id,b)}},[s?.id]);let u=g=>{try{let b=W.getState(),C=(b.trackedEvents||[]).filter(h=>h!==g);b.setTrackedEvents(C)}catch{}};if(!s||c||!d)return null;let m=()=>{s?.id&&u(`viaAppStorys${s.id}`),l(!0)},f=s.details?.modal_type||s.details?.modals?.[0]?.modal_type||"";return f==="full-page-modal"||f==="media-only-modal"?(0,ui.jsx)(Jr,{campaign:s,onDismiss:m}):(0,ui.jsx)(Gr,{campaign:s,onDismiss:m})};var Zr=require("react/jsx-runtime"),Kr=({id:t,children:e})=>(0,Zr.jsx)("div",{"data-as-id":t,style:{display:"contents"},children:e});te();var pi=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=W.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,d;if(!i||i.trim()==="")s=await Gi(),d=!0;else{let m=await Vn();m&&m!==i&&console.log("AppStorys: Found previous anonymous user, will reconcile after verification."),s=i,d=!1}if(!await De(n,o,s)){this.state="error";return}if(!d){let m=await Vn();m&&m!==s&&(await un(m,s),await Hn())}try{let m=await Mt(),f=e.baseUrl||"https://users.appstorys.co";fetch(`${f}/v2/${n}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...m?{Authorization:`Bearer ${m}`}:{}},body:JSON.stringify({user_id:s,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})}).then(async P=>{if(P.ok)try{let g=await P.json(),b=W.getState();if(typeof g.screen_capture_enabled<"u"){let R=!!g.screen_capture_enabled;console.info("AppStorys: track-user-res returned screen_capture_enabled=",R),b.setScreenCaptureEnabled(R)}}catch{}}).catch(P=>console.warn("track-user-res (init) failed",P))}catch(m){console.warn("track-user-res (init) setup failed",m)}let{campaigns:l,version:y}=await On(n);try{Pi(l)}catch(m){console.warn("Failed to preload campaign fonts",m)}let u=W.getState();u.setAppId(o),u.setAccountId(n),u.setUserId(s),u.setIsAnonymousUser(d),u.setBaseUrl(e.baseUrl),u.setTrackingUrl(e.trackingUrl),u.saveAllCampaigns(l),u.setCampaignVersion(y);try{W.getState().screenCaptureEnabled&&(await Promise.resolve().then(()=>(ss(),rs))).mountScreenCaptureButton()}catch(m){console.warn("Failed to mount screen capture button",m)}Vi.setup(),Un.setup(),this.state="initialized"}catch(s){this.state="error",console.error("AppStorys initialization failed:",s)}}}async reconcileUser(e,o,n,i){try{if(!await De(i,n,o)){console.error("AppStorys: Failed to verify identified user account during reconciliation.");return}if(!await un(e,o)){console.error("AppStorys: Failed to reconcile anonymous and identified users.");return}await Hn();let c=W.getState();c.setUserId(o),c.setIsAnonymousUser(!1)}catch(s){console.error("AppStorys: Error during user reconciliation:",s)}}async trackScreen(e){return await this.ensureInitialized(),Wn(e)}async trackEvent(e,o,n){return await this.ensureInitialized(),at(e,o,n)}async setUserProperties(e){return await this.ensureInitialized(),Dn(e)}handleLink(e){if(e&&!Rt(e)){if(typeof e=="string"){try{if(!e.startsWith("http")&&Gt(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){if(Rt(e.value))return;try{if(Gt(e.value))return}catch{}this.navigateToScreen?.(e.value)}}}get visibility(){return W.getState().isVisible}set visibility(e){Un.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 Ne(e)}Widget=Yo;Widgets=Yo},za=new pi;0&&(module.exports={AppStorys,BASE_OVERLAY_Z_INDEX,Banner,BottomSheet,Csat,DEFAULT_OVERLAY_PRIORITIES,Floater,Modal,Pip,SdkState,Story,Survey,Tooltip,Trackable,Widget,Widgets,compareCampaignPriority,getCampaignVariantId,getCampaignZIndex,getVariantId,hasVariants,parseCampaignPriority,personalizeText,resolveCampaignVariant,selectVariantByWeight,sortCampaignsByPriority});
|
|
165
165
|
//# sourceMappingURL=index.js.map
|