@appstorys/react-web 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Di=Object.create;var je=Object.defineProperty;var _i=Object.getOwnPropertyDescriptor;var $i=Object.getOwnPropertyNames;var Wi=Object.getPrototypeOf,Mi=Object.prototype.hasOwnProperty;var ee=(t,e)=>()=>(t&&(e=t(t=0)),e);var ln=(t,e)=>{for(var o in e)je(t,o,{get:e[o],enumerable:!0})},dn=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $i(e))!Mi.call(t,n)&&n!==o&&je(t,n,{get:()=>e[n],enumerable:!(i=_i(e,n))||i.enumerable});return t};var Ne=(t,e,o)=>(o=t!=null?Di(Wi(t)):{},dn(e||!t||!t.__esModule?je(o,"default",{value:t,enumerable:!0}):o,t)),Oi=t=>dn(je({},"__esModule",{value:!0}),t);var nt,ge=ee(()=>{"use strict";nt=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 Bt(){return ho.getState().userId}async function lt(){return nt.getItem("access_token")}function pn(t){if(!t)return;let e=String(t||"").trim();if(e)return ho.getState().variantMappings?.[e]}var cn,ho,F,et=ee(()=>{"use strict";cn=require("zustand");ge();ho=(0,cn.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})}));F=ho});async function oe(){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 Ue=ee(()=>{"use strict"});async function Ht(t,e,o){try{let i={account_id:t,app_id:e,user_id:o};if(await nt.getItem(fn))console.log("Device info already sent previously - skipping");else{let c=await oe();i.attributes={...c},console.log("First time verification - including device info in attributes")}let s=F.getState().baseUrl||"https://users.appstorys.co",a=await fetch(`${s}/${t}/validate-account`,{method:"POST",body:JSON.stringify(i),headers:{Accept:"application/json","Content-Type":"application/json"}});if(console.log("Verify account body",i),console.log("Verifying account",a.status,a.statusText),a.ok){let c=await a.json();console.log("Account verified",c);let{access_token:u,refresh_token:x}=c;if(u&&x)return await nt.setItem("access_token",u),await nt.setItem("refresh_token",x),i.attributes&&(await nt.setItem(fn,"true"),console.log("Device info sent flag set")),!0}return!1}catch(i){return console.error("Error when verifying AppStorys account",i),!1}}var fn,He=ee(()=>{"use strict";ge();Ue();et();fn="device_info_sent"});async function so(t,e){if(!e||e.length===0){console.info("AppStorys: identifyWidgetPositions called with empty positionList; skipping");return}let o=await lt();if(!o){console.error("AppStorys: identifyWidgetPositions - access token not found");return}try{let i="https://backend.appstorys.co/api/v2/appinfo/identify-positions/";console.info("AppStorys: identifyWidgetPositions payload",{screen_name:t,position_list:e});let n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,Accept:"application/json"},body:JSON.stringify({screen_name:t,position_list:e})});n.ok?console.info("AppStorys: identifyWidgetPositions OK"):console.error("AppStorys: identifyWidgetPositions failed",n.status,await n.text())}catch(i){console.error("AppStorys: identifyWidgetPositions error",i)}}var wi=ee(()=>{"use strict";et()});function ao(t){return t&&(t.startsWith("widget_")?t:`widget_${t}`)}function Ri(){try{let t=F.getState().allCampaigns||[],e=[];return t.forEach(o=>{o&&o.position&&typeof o.position=="string"&&e.push(String(o.position));try{if(o&&o.campaign_type==="WID"&&o.details){let i=o.details;typeof i=="object"&&(i.id&&typeof i.id=="string"&&e.push(String(i.id)),i.variants&&typeof i.variants=="object"&&Object.values(i.variants).forEach(n=>{n&&n.id&&typeof n.id=="string"&&e.push(String(n.id))}))}}catch{}}),e.filter(o=>!!o).map(o=>ao(String(o))).filter(o=>!!o)}catch{return[]}}function _r(t){try{let e=Ri();if(!e||e.length===0)return[];let o=[];return e.forEach(i=>{let n=i.replace(/^widget_/,""),r=[`[data-as-id="${n}"]`,`#${n}`,`.${n}`,`[data-widget="${n}"]`],s=null;for(let a of r)if(s=document.querySelector(a),s)break;if(s){let a=s.getBoundingClientRect(),c={x:Math.round(a.left),y:Math.round(a.top),width:Math.round(a.width),height:Math.round(a.height),screenWidth:window.innerWidth,screenHeight:window.innerHeight};de.addLayoutInfo(t,n,c),o.push(n)}}),console.info("AppStorys: mapServerPositionsToDOM mapped",o.length,"server positions to DOM elements",o),o}catch(e){return console.warn("AppStorys: mapServerPositionsToDOM error",e),[]}}function $r(t){return De[t]||(De[t]=[]),De[t]}function ki(t,e,o,i){let n=new FormData,r=t.replace(/[^a-z0-9]/gi,"_"),s=`screenshot_${e}_${r}_${Date.now()}.png`,a=new File([i],s,{type:"image/png"});n.append("screenName",t),n.append("user_id",e),n.append("children",o),n.append("screenshot",a);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:",a.name,`(${a.size} bytes)`),console.groupEnd()}catch(c){console.warn("AppStorys: Could not run FormData diagnostics",c)}return n}var De,de,Ti=ee(()=>{"use strict";et();He();wi();et();De={};de=class{static setup(e,o){let i=F.getState();i.setScreenCaptureEnabled(o),i.setCurrentScreen(e)}static addLayoutInfo(e,o,i){let n=$r(e),r=n.findIndex(c=>c.id===o),s={...i,screenWidth:i.screenWidth||window.innerWidth,screenHeight:i.screenHeight||window.innerHeight},a={id:o,frame:s};r>=0?n[r]=a:n.push(a)}static collectElements(e){this.clearLayoutData(e);let o=document.querySelectorAll("[data-as-id]"),i=window.innerWidth,n=window.innerHeight,r=[];o.forEach(s=>{let a=s.getAttribute("data-as-id");if(a){r.push(a);let c=s.getBoundingClientRect();this.addLayoutInfo(e,a,{x:Math.round(c.left),y:Math.round(c.top),width:Math.round(c.width),height:Math.round(c.height),screenWidth:i,screenHeight:n})}}),console.info(`AppStorys: Identified ${o.length} elements:`,r)}static clearLayoutData(e){De[e]=[]}static getLayoutData(e){return De[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),F.getState().setCurrentScreen(e),this.collectElements(e);try{let g=_r(e);g&&g.length>0&&console.info("AppStorys: mapServerPositionsToDOM added",g.length,"elements")}catch{}await new Promise(g=>setTimeout(g,100));let n=window,r=null;if(typeof n.html2canvas!="function")try{await new Promise((g,v)=>{let f=document.createElement("script");f.src="https://html2canvas.hertzen.com/dist/html2canvas.min.js",f.onload=()=>g(),f.onerror=()=>v(new Error("Failed to load html2canvas")),document.head.appendChild(f)})}catch(g){console.warn("AppStorys: html2canvas load error",g)}if(typeof n.html2canvas=="function")try{let g=await n.html2canvas(document.documentElement,{useCORS:!0,allowTaint:!0,logging:!1,scale:window.devicePixelRatio||1});r=await new Promise(v=>g.toBlob(f=>v(f),"image/png"))}catch(g){console.warn("AppStorys: html2canvas capture failed (falling back to getDisplayMedia)",g),r=null}if(!r&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)try{let g=await navigator.mediaDevices.getDisplayMedia({video:!0}),v=document.createElement("video");v.srcObject=g,await v.play();let f=document.createElement("canvas");f.width=v.videoWidth||window.innerWidth,f.height=v.videoHeight||window.innerHeight;let b=f.getContext("2d");b&&b.drawImage(v,0,0,f.width,f.height),r=await new Promise(h=>f.toBlob(y=>h(y),"image/png")),v.pause(),g.getTracks().forEach(h=>h.stop())}catch(g){console.warn("AppStorys: getDisplayMedia capture failed",g)}if(!r)return console.warn("AppStorys: Capture failed \u2014 no blob generated"),!1;let s=await lt(),a=Bt();if(!a)return console.warn("AppStorys: No userId"),!1;if(!s){let g=F.getState();g.accountId&&g.appId&&g.userId&&await Ht(g.accountId,g.appId,g.userId)&&(s=await lt())}if(!s)return console.warn("AppStorys: No token available"),!1;let c="https://backend.appstorys.co/api/v1/appinfo/identify-elements/",u=JSON.stringify(this.getLayoutData(e)||[]),x=ki(e,a,u,r);console.info("AppStorys: Sending identify-elements with payload size:",u.length);let m=await fetch(c,{method:"POST",headers:{Authorization:`Bearer ${s}`,Accept:"application/json"},body:x});if(m.status===401){console.warn("AppStorys: 401 response \u2014 retrying once");let g=F.getState();if(g.accountId&&g.appId&&g.userId&&await Ht(g.accountId,g.appId,g.userId)){let f=await lt();f&&(m=await fetch(c,{method:"POST",headers:{Authorization:`Bearer ${f}`,Accept:"application/json"},body:ki(e,a,u,r)}))}}if(!m.ok){let g=await m.text();return console.error("AppStorys: identify-elements failed",m.status,g),!1}console.info("AppStorys: identify-elements success \u2713");try{let g=o,v=[];!g||g.length===0?v=(this.getLayoutData(e)||[]).map(y=>ao(y.id)).filter(y=>!!y):v=g.map(h=>ao(h)).filter(h=>!!h);let f=Ri(),b=Array.from(new Set([...v,...f]));console.info("AppStorys: identifyWidgetPositions will send",b.length,"positions (collected + server)",b),await so(e,b)}catch(g){console.warn("AppStorys: identifyWidgetPositions failed",g)}return!0}catch(i){return console.error("AppStorys: takeScreenshot error",i),!1}}};(function(){try{let e=window;e.AppStorysForceIdentifyPositions=async o=>{let i=F.getState(),n=o||i.currentScreen;if(!n){console.warn("AppStorys: AppStorysForceIdentifyPositions - no screen name available");return}let s=(de.getLayoutData(n)||[]).map(a=>ao(a.id)).filter(a=>!!a);console.info("AppStorys: AppStorysForceIdentifyPositions sending",s.length,"positions for",n,s);try{await so(n,s),console.info("AppStorys: AppStorysForceIdentifyPositions completed")}catch(a){console.error("AppStorys: AppStorysForceIdentifyPositions error",a)}}}catch{}})()});var Ii={};ln(Ii,{mountScreenCaptureButton:()=>Fi});function Wr(){if(document.getElementById("appstorys-capture-styles"))return;let t=document.createElement("style");t.id="appstorys-capture-styles",t.innerHTML=`
|
|
1
|
+
"use strict";var _i=Object.create;var Oe=Object.defineProperty;var $i=Object.getOwnPropertyDescriptor;var Wi=Object.getOwnPropertyNames;var Mi=Object.getPrototypeOf,Oi=Object.prototype.hasOwnProperty;var oe=(t,e)=>()=>(t&&(e=t(t=0)),e);var cn=(t,e)=>{for(var o in e)Oe(t,o,{get:e[o],enumerable:!0})},pn=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Wi(e))!Oi.call(t,n)&&n!==o&&Oe(t,n,{get:()=>e[n],enumerable:!(i=$i(e,n))||i.enumerable});return t};var je=(t,e,o)=>(o=t!=null?_i(Mi(t)):{},pn(e||!t||!t.__esModule?Oe(o,"default",{value:t,enumerable:!0}):o,t)),ji=t=>pn(Oe({},"__esModule",{value:!0}),t);var ot,fe=oe(()=>{"use strict";ot=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 Pt(){return yo.getState().userId}async function lt(){return ot.getItem("access_token")}function gn(t){if(!t)return;let e=String(t||"").trim();if(e)return yo.getState().variantMappings?.[e]}var un,yo,F,et=oe(()=>{"use strict";un=require("zustand");fe();yo=(0,un.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})}));F=yo});async function ne(){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 qe=oe(()=>{"use strict"});async function Vt(t,e,o){try{let i={account_id:t,app_id:e,user_id:o};if(await ot.getItem(yn))console.log("Device info already sent previously - skipping");else{let c=await ne();i.attributes={...c},console.log("First time verification - including device info in attributes")}let s=F.getState().baseUrl||"https://users.appstorys.co",a=await fetch(`${s}/${t}/validate-account`,{method:"POST",body:JSON.stringify(i),headers:{Accept:"application/json","Content-Type":"application/json"}});if(console.log("Verify account body",i),console.log("Verifying account",a.status,a.statusText),a.ok){let c=await a.json();console.log("Account verified",c);let{access_token:u,refresh_token:x}=c;if(u&&x)return await ot.setItem("access_token",u),await ot.setItem("refresh_token",x),i.attributes&&(await ot.setItem(yn,"true"),console.log("Device info sent flag set")),!0}return!1}catch(i){return console.error("Error when verifying AppStorys account",i),!1}}var yn,Ue=oe(()=>{"use strict";fe();qe();et();yn="device_info_sent"});async function ro(t,e){if(!e||e.length===0){console.info("AppStorys: identifyWidgetPositions called with empty positionList; skipping");return}let o=await lt();if(!o){console.error("AppStorys: identifyWidgetPositions - access token not found");return}try{let i="https://backend.appstorys.co/api/v2/appinfo/identify-positions/";console.info("AppStorys: identifyWidgetPositions payload",{screen_name:t,position_list:e});let n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,Accept:"application/json"},body:JSON.stringify({screen_name:t,position_list:e})});n.ok?console.info("AppStorys: identifyWidgetPositions OK"):console.error("AppStorys: identifyWidgetPositions failed",n.status,await n.text())}catch(i){console.error("AppStorys: identifyWidgetPositions error",i)}}var ki=oe(()=>{"use strict";et()});function so(t){return t&&(t.startsWith("widget_")?t:`widget_${t}`)}function Ti(){try{let t=F.getState().allCampaigns||[],e=[];return t.forEach(o=>{o&&o.position&&typeof o.position=="string"&&e.push(String(o.position));try{if(o&&o.campaign_type==="WID"&&o.details){let i=o.details;typeof i=="object"&&(i.id&&typeof i.id=="string"&&e.push(String(i.id)),i.variants&&typeof i.variants=="object"&&Object.values(i.variants).forEach(n=>{n&&n.id&&typeof n.id=="string"&&e.push(String(n.id))}))}}catch{}}),e.filter(o=>!!o).map(o=>so(String(o))).filter(o=>!!o)}catch{return[]}}function $r(t){try{let e=Ti();if(!e||e.length===0)return[];let o=[];return e.forEach(i=>{let n=i.replace(/^widget_/,""),r=[`[data-as-id="${n}"]`,`#${n}`,`.${n}`,`[data-widget="${n}"]`],s=null;for(let a of r)if(s=document.querySelector(a),s)break;if(s){let a=s.getBoundingClientRect(),c={x:Math.round(a.left),y:Math.round(a.top),width:Math.round(a.width),height:Math.round(a.height),screenWidth:window.innerWidth,screenHeight:window.innerHeight};ce.addLayoutInfo(t,n,c),o.push(n)}}),console.info("AppStorys: mapServerPositionsToDOM mapped",o.length,"server positions to DOM elements",o),o}catch(e){return console.warn("AppStorys: mapServerPositionsToDOM error",e),[]}}function Wr(t){return Le[t]||(Le[t]=[]),Le[t]}function Ri(t,e,o,i){let n=new FormData,r=t.replace(/[^a-z0-9]/gi,"_"),s=`screenshot_${e}_${r}_${Date.now()}.png`,a=new File([i],s,{type:"image/png"});n.append("screenName",t),n.append("user_id",e),n.append("children",o),n.append("screenshot",a);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:",a.name,`(${a.size} bytes)`),console.groupEnd()}catch(c){console.warn("AppStorys: Could not run FormData diagnostics",c)}return n}var Le,ce,Fi=oe(()=>{"use strict";et();Ue();ki();et();Le={};ce=class{static setup(e,o){let i=F.getState();i.setScreenCaptureEnabled(o),i.setCurrentScreen(e)}static addLayoutInfo(e,o,i){let n=Wr(e),r=n.findIndex(c=>c.id===o),s={...i,screenWidth:i.screenWidth||window.innerWidth,screenHeight:i.screenHeight||window.innerHeight},a={id:o,frame:s};r>=0?n[r]=a:n.push(a)}static collectElements(e){this.clearLayoutData(e);let o=document.querySelectorAll("[data-as-id]"),i=window.innerWidth,n=window.innerHeight,r=[];o.forEach(s=>{let a=s.getAttribute("data-as-id");if(a){r.push(a);let c=s.getBoundingClientRect();this.addLayoutInfo(e,a,{x:Math.round(c.left),y:Math.round(c.top),width:Math.round(c.width),height:Math.round(c.height),screenWidth:i,screenHeight:n})}}),console.info(`AppStorys: Identified ${o.length} elements:`,r)}static clearLayoutData(e){Le[e]=[]}static getLayoutData(e){return Le[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),F.getState().setCurrentScreen(e),this.collectElements(e);try{let g=$r(e);g&&g.length>0&&console.info("AppStorys: mapServerPositionsToDOM added",g.length,"elements")}catch{}await new Promise(g=>setTimeout(g,100));let n=window,r=null;if(typeof n.html2canvas!="function")try{await new Promise((g,v)=>{let f=document.createElement("script");f.src="https://html2canvas.hertzen.com/dist/html2canvas.min.js",f.onload=()=>g(),f.onerror=()=>v(new Error("Failed to load html2canvas")),document.head.appendChild(f)})}catch(g){console.warn("AppStorys: html2canvas load error",g)}if(typeof n.html2canvas=="function")try{let g=await n.html2canvas(document.documentElement,{useCORS:!0,allowTaint:!0,logging:!1,scale:window.devicePixelRatio||1});r=await new Promise(v=>g.toBlob(f=>v(f),"image/png"))}catch(g){console.warn("AppStorys: html2canvas capture failed (falling back to getDisplayMedia)",g),r=null}if(!r&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)try{let g=await navigator.mediaDevices.getDisplayMedia({video:!0}),v=document.createElement("video");v.srcObject=g,await v.play();let f=document.createElement("canvas");f.width=v.videoWidth||window.innerWidth,f.height=v.videoHeight||window.innerHeight;let b=f.getContext("2d");b&&b.drawImage(v,0,0,f.width,f.height),r=await new Promise(h=>f.toBlob(y=>h(y),"image/png")),v.pause(),g.getTracks().forEach(h=>h.stop())}catch(g){console.warn("AppStorys: getDisplayMedia capture failed",g)}if(!r)return console.warn("AppStorys: Capture failed \u2014 no blob generated"),!1;let s=await lt(),a=Pt();if(!a)return console.warn("AppStorys: No userId"),!1;if(!s){let g=F.getState();g.accountId&&g.appId&&g.userId&&await Vt(g.accountId,g.appId,g.userId)&&(s=await lt())}if(!s)return console.warn("AppStorys: No token available"),!1;let c="https://backend.appstorys.co/api/v1/appinfo/identify-elements/",u=JSON.stringify(this.getLayoutData(e)||[]),x=Ri(e,a,u,r);console.info("AppStorys: Sending identify-elements with payload size:",u.length);let m=await fetch(c,{method:"POST",headers:{Authorization:`Bearer ${s}`,Accept:"application/json"},body:x});if(m.status===401){console.warn("AppStorys: 401 response \u2014 retrying once");let g=F.getState();if(g.accountId&&g.appId&&g.userId&&await Vt(g.accountId,g.appId,g.userId)){let f=await lt();f&&(m=await fetch(c,{method:"POST",headers:{Authorization:`Bearer ${f}`,Accept:"application/json"},body:Ri(e,a,u,r)}))}}if(!m.ok){let g=await m.text();return console.error("AppStorys: identify-elements failed",m.status,g),!1}console.info("AppStorys: identify-elements success \u2713");try{let g=o,v=[];!g||g.length===0?v=(this.getLayoutData(e)||[]).map(y=>so(y.id)).filter(y=>!!y):v=g.map(h=>so(h)).filter(h=>!!h);let f=Ti(),b=Array.from(new Set([...v,...f]));console.info("AppStorys: identifyWidgetPositions will send",b.length,"positions (collected + server)",b),await ro(e,b)}catch(g){console.warn("AppStorys: identifyWidgetPositions failed",g)}return!0}catch(i){return console.error("AppStorys: takeScreenshot error",i),!1}}};(function(){try{let e=window;e.AppStorysForceIdentifyPositions=async o=>{let i=F.getState(),n=o||i.currentScreen;if(!n){console.warn("AppStorys: AppStorysForceIdentifyPositions - no screen name available");return}let s=(ce.getLayoutData(n)||[]).map(a=>so(a.id)).filter(a=>!!a);console.info("AppStorys: AppStorysForceIdentifyPositions sending",s.length,"positions for",n,s);try{await ro(n,s),console.info("AppStorys: AppStorysForceIdentifyPositions completed")}catch(a){console.error("AppStorys: AppStorysForceIdentifyPositions error",a)}}}catch{}})()});var zi={};cn(zi,{mountScreenCaptureButton:()=>Ii});function Mr(){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 Mr(){Wr();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 Fi(){try{let t=F.getState(),o=!!window.__APPSTORYS_DEBUG_CAPTURE;if(console.info("AppStorys: mountScreenCaptureButton called, screenCaptureEnabled=",t.screenCaptureEnabled,"debugForce=",o),!t.screenCaptureEnabled&&!o||document.getElementById("appstorys-screen-capture-btn"))return null;let i=Mr();return i.addEventListener("click",async()=>{i.disabled=!0;let n=i.innerText;i.innerHTML='<div class="appstorys-spinner"></div>';let s=F.getState().currentScreen||(typeof window<"u"?window.location.pathname:"");try{await de.takeScreenshot(s)}catch(a){console.error("CaptureService error",a)}i.disabled=!1,i.innerText=n,i.animate([{transform:"scale(1.0)"},{transform:"scale(1.05)"},{transform:"scale(1.0)"}],{duration:300})}),document.body.appendChild(i),console.info("AppStorys: screen capture button mounted"),i}catch(t){return console.error("mountScreenCaptureButton error",t),null}}var zi=ee(()=>{"use strict";et();Ti();try{window.AppStorysMountCapture=function(){try{return Fi()}catch(t){return console.error("AppStorysMountCapture failed",t),null}}}catch{}try{window.AppStorysDebugState=function(){try{let t=F.getState();return console.info("AppStorys store state:",t),t}catch(t){return console.error("AppStorysDebugState failed",t),null}}}catch{}try{window.AppStorysDebugToken=function(){try{let t=localStorage.getItem("access_token")||"",e=t.length,o=t?t.slice(0,20)+"..."+t.slice(-10):"(none)";if(console.info("Token length:",e,"masked:",o),t&&t.includes("."))try{let i=t.split(".");if(i.length===3){let n=JSON.parse(atob(i[1]));if(console.info("Token payload:",n),n.exp){let r=new Date(n.exp*1e3),s=new Date;console.info("Token expires:",r.toISOString(),"Expired:",s>r)}}}catch(i){console.warn("Could not decode JWT:",i)}return t?"Token present":"No token"}catch(t){return console.error("AppStorysDebugToken failed",t),null}}}catch{}});var jr={};ln(jr,{AppStorys:()=>Or,Banner:()=>Sn,BottomSheet:()=>yi,Csat:()=>bi,Floater:()=>Tn,Pip:()=>kn,SdkState:()=>yo,Story:()=>ui,Survey:()=>vi,Tooltip:()=>mi,Widget:()=>fi,personalizeText:()=>Fe});module.exports=Oi(jr);var yo=(n=>(n.uninitialized="uninitialized",n.initializing="initializing",n.initialized="initialized",n.error="error",n))(yo||{});var $t=require("react"),me=Ne(require("lottie-react"));et();var gn=require("react");et();et();var ji=t=>F.getState().variantMappings[t];function bo(t){return!!(t.details&&typeof t.details=="object"&&"variants"in t.details)}function St(t){if(!bo(t))return t;let e=ji(t.id||"");if(!e)return t;let o=t.details?.variants;if(!o||typeof o!="object")return t;let i=o[e];if(!i)return t;let n=typeof t.details=="object"?Object.fromEntries(Object.entries(t.details).filter(([s])=>s!=="variants")):{};return{...t,details:{...n,...i},_variantId:e}}var qe="__back_press_triggered__";function un(t){return(t||"").trim().toLowerCase()}function Ni(t,e){let o=un(t),i=un(e);return!o||o===i}function qi(t,e,o){let i=Number(t),n=Number(o),r=!isNaN(i)&&!isNaN(n);switch(e){case"eq":return r?i===n:t===o;case"neq":return r?i!==n:t!==o;case"gt":return r?i>n:t>o;case"gte":return r?i>=n:t>=o;case"lt":return r?i<n:t<o;case"lte":return r?i<=n:t<=o;default:return!1}}function Ui(t,e){let o=t.filter(i=>i.back_press==null);return o.length===0?!0:e.some(i=>o.every(n=>{let r=i[n.key];return r==null?!1:qi(String(r),n.operator,n.value)}))}function Hi(t,e,o){let i=t,n=i.trigger_event??i.trigger,r=t.id;return!n}function xo(){let{campaigns:t,trackedEvents:e,trackedEventMetadata:o,currentScreen:i}=F.getState();return t.some(n=>{if(n.screen&&n.screen!==i)return!1;let r=n.trigger_event;if(!r||typeof r=="string")return!1;let{event:s,event_config:a}=r;if(!(a??[]).some(x=>x.back_press===!0)||e.includes(qe)||!e.includes(s))return!1;let c=(a??[]).filter(x=>x.back_press==null);if(c.length===0)return!0;let u=o[s]||[];return Ui(c,u)})}function pt(t,e){let o=F(c=>c.currentScreen),i=F(c=>c.campaigns),n=F(c=>c.allCampaigns),r=F(c=>c.trackedEvents),s=F(c=>c.trackedEventMetadata),a=F(c=>c.variantMappings);return(0,gn.useMemo)(()=>{let c=m=>m.find(g=>Ni(g.screen,o)&&g.campaign_type===t&&(e?.position?g.position===e.position:!0)&&Hi(g,r,s)),x=(i&&i.length>0?c(i):void 0)??c(n||[]);if(x)return St(x)},[i,n,r,s,a,t,e,o])}et();Ue();ge();et();He();var mn="appstorys_offline_queue";async function yn(){let t=await nt.getItem(mn);return t?JSON.parse(t):[]}async function hn(t){await nt.setItem(mn,JSON.stringify(t))}function Vi(t){return Math.min(3e4*Math.pow(2,t),12e4)}function Yi(t){let o=t.retryCount||0,i=t.lastAttempt||0,n=Vi(o);return o<3&&Date.now()-i>=n}async function Qi(){let t=F.getState();return!t.accountId||!t.appId?!1:await Ht(t.accountId,t.appId,t.userId)}async function bn(t,e){if(await Qi()){let i=await nt.getItem("access_token");i&&(t.headers={...t.headers,Authorization:`Bearer ${i}`}),t.authRetried=!0,t.lastAttempt=Date.now(),e(t)}}async function Ye(t,e){let o=(t.retryCount||0)+1;o<=3&&(t.retryCount=o,t.lastAttempt=Date.now(),e(t))}async function Ve(t){let e=await yn();e.push(t),await hn(e)}async function Gi(){let t=await yn();if(t.length===0)return;let e=[];for(let o of t){if(!Yi(o)){e.push(o);continue}try{let i=await fetch(o.url,{method:o.method,headers:o.headers,body:JSON.stringify(o.body)});if(i.ok)continue;i.status===401||i.status===403?o.authRetried||await bn(o,n=>e.push(n)):i.status>=500&&await Ye(o,n=>e.push(n))}catch{await Ye(o,n=>e.push(n))}}await hn(e)}async function Qe(t){if(!navigator.onLine){await Ve(t);return}await Gi();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 bn(t,Ve):e.status>=500&&await Ye(t,Ve)),e}catch{await Ye(t,Ve);return}}async function H(t,e,o){try{if(!t)return;let i=await lt(),n=F.getState(),r=["viewed","clicked","csat captured","survey captured","shared"];if(!r.includes(t)){let u=n.trackedEvents;if(!u.includes(t))n.setTrackedEvents([...u,t]);else{let x=u.filter(m=>m!==t);x.push(t),n.setTrackedEvents(x)}if(o&&Object.keys(o).length>0){let x=n.trackedEventMetadata||{},m=x[t]||[];n.setTrackedEventMetadata({...x,[t]:[...m,o]})}}let s={...o||{}};if(!r.includes(t)){let u=await oe();s={...s,...u}}if(e&&String(e).trim()!==""){let u=pn(e);u&&(s.variant_id=u)}let a={user_id:Bt(),event:t,metadata:s};e&&(a.campaign_id=e);let c=n.trackingUrl||"https://tracking.appstorys.co";i&&await Qe({url:`${c}/capture-event`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:a})}catch(i){console.error("Error in trackEvent",i)}}et();function Ct(t){if(!t)return!1;let e=F.getState(),o=e.allCampaigns||[],i=e.campaigns||[],n=String(t).trim(),r=o.find(c=>{if(!c)return!1;let u=String(c.id||"").trim(),x=c.details||{},m=String(x.campaign||x.id||"").trim();return!!(u&&u===n||m&&m===n||u&&n.includes(u)||m&&n.includes(m))});if(!r)return!1;let s={...r};delete s.trigger_event,delete s.trigger,s.display_trigger=!0;let a=i.findIndex(c=>String(c.id||"")===String(s.id||""));if(a===-1)e.saveCampaigns([s,...i]);else{let c=i[a];if(!!(c.trigger_event??c.trigger)){let x=[...i];x[a]=s,e.saveCampaigns(x)}}return!0}var fe=require("react/jsx-runtime"),xn=me.default?.default??me.default??me.Lottie??me,Sn=()=>{let t=pt("BAN"),e=F(w=>w.isVisible),[o,i]=(0,$t.useState)(!1),[n,r]=(0,$t.useState)(null),[s,a]=(0,$t.useState)(null),c=(0,$t.useRef)(null),[u,x]=(0,$t.useState)(0);if((0,$t.useEffect)(()=>{t&&(i(!1),H("viewed",t.id),t.details.lottie_data&&fetch(t.details.lottie_data).then(w=>w.json()).then(w=>{r(w),w.w&&w.h&&a(w.h/w.w)}).catch(w=>console.error("Error loading Lottie:",w)))},[t]),(0,$t.useEffect)(()=>{let w=()=>{c.current&&x(c.current.offsetWidth)};return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[t,o]),!t||o||!e)return null;let{details:m}=t,g=m.styling||{},v=m.height||"auto";s&&u&&(v=u*s);let f={position:"fixed",left:g.marginLeft?`${g.marginLeft}px`:"10px",right:g.marginRight?`${g.marginRight}px`:"10px",bottom:g.marginBottom?`${g.marginBottom}px`:"10px",backgroundColor:"transparent",borderRadius:`${g.topRightRadius||0}px ${g.topLeftRadius||0}px ${g.bottomRightRadius||0}px ${g.bottomLeftRadius||0}px`,overflow:"hidden",zIndex:9999,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:m.link?"pointer":"default"},b={width:"100%",height:typeof v=="number"?`${v}px`:v,display:"block",objectFit:"cover"},h=w=>{w.stopPropagation(),i(!0),H("banner_closed",t.id)};return(0,fe.jsxs)("div",{ref:c,style:f,onClick:()=>{if(m.link)if(H("clicked",t.id),m.link.startsWith("http"))window.open(m.link,"_blank");else{try{if(Ct(m.link))return}catch(w){console.warn("revealCampaignFromLink error",w)}console.log("Internal link:",m.link)}},children:[n?(()=>{let w=xn.default||xn;return(0,fe.jsx)(w,{animationData:n,loop:!0,autoplay:e,style:b})})():m.image?(0,fe.jsx)("img",{src:m.image,alt:"Campaign Banner",style:b}):null,g.crossButton?.enabled&&(0,fe.jsx)("button",{onClick:h,style:{position:"absolute",top:"5px",right:"5px",background:"rgba(0,0,0,0.3)",color:"white",border:"none",borderRadius:"50%",width:"24px",height:"24px",lineHeight:"22px",textAlign:"center",cursor:"pointer",padding:"0",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10},children:"\u2715"})]})};var yt=require("react");et();function Je(t){let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")}function Cn(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 vn(t,e){if(typeof document>"u")return;let o=`appstorys-font-${t}`;if(document.getElementById(o))return;let i=document.createElement("style");i.id=o,i.type="text/css",i.textContent=`@font-face{font-family:"${t}";src:url("${e}");font-style:normal;font-weight:normal;font-display:swap;}`,document.head.appendChild(i)}var Ge=new Map;async function Ji(t,e){try{vn(e.name,t);let o=globalThis.FontFace;if(typeof document<"u"&&o&&document.fonts?.add){let i=new o(e.name,`url(${t})`);await i.load(),document.fonts.add(i)}else typeof document<"u"&&document.fonts?.load&&await document.fonts.load(`1em "${e.name}"`);e.status="loaded",e.listeners.forEach(i=>i(e.name))}catch(o){console.warn(`[FontManager] Failed to load font from "${t}":`,o),e.status="failed",e.listeners.forEach(i=>i(void 0))}finally{e.listeners=[]}}var So={async load(t){if(!t||!Je(t))return;let e=Ge.get(t);if(e)return e.status==="loaded"?e.name:e.status==="failed"?void 0:new Promise(r=>e.listeners.push(r));let i={status:"pending",name:Cn(t),listeners:[]};Ge.set(t,i);let n=new Promise(r=>i.listeners.push(r));return Ji(t,i),n},ensure(t){if(!t||!Je(t))return;let e=Cn(t);return vn(e,t),So.load(t),e},getSync(t){if(!t)return;let e=Ge.get(t);return e?.status==="loaded"?e.name:void 0},_clearCache(){Ge.clear()}};function dt(t){if(t)return Je(t)?So.ensure(t):t}function Xi(t){let e=new Set,o=new WeakSet,i=n=>{if(n!=null&&typeof n!="string"){if(Array.isArray(n)){for(let r of n)i(r);return}if(typeof n=="object"){if(o.has(n))return;o.add(n);for(let[r,s]of Object.entries(n))r==="fontFamily"&&typeof s=="string"&&Je(s)&&e.add(s),i(s)}}};return i(t),Array.from(e)}async function wn(t){let e=new Set;for(let o of t)Xi(o).forEach(i=>e.add(i));await Promise.all(Array.from(e).map(o=>So.load(o)))}var Z=require("react/jsx-runtime"),Co=t=>(t||"").trim().toLowerCase(),Wt=(t,e)=>{let o=Number(t);return Number.isFinite(o)?o:e};function Ki({iconType:t,color:e}){let o=e||"#FFFFFF";return t==="close"?(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:o,strokeWidth:"2.2",strokeLinecap:"round"}),(0,Z.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:o,strokeWidth:"2.2",strokeLinecap:"round"})]}):t==="expand"?(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("polyline",{points:"8,3 3,3 3,8",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"3",y1:"3",x2:"9",y2:"9",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,Z.jsx)("polyline",{points:"16,21 21,21 21,16",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"15",y1:"15",x2:"21",y2:"21",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):t==="minimize"?(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("polyline",{points:"9,9 3,9 3,3",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"3",y1:"9",x2:"9",y2:"3",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,Z.jsx)("polyline",{points:"15,15 21,15 21,21",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"15",y1:"21",x2:"21",y2:"15",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):t==="mute"?(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:o,strokeWidth:"2",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,Z.jsx)("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:o,strokeWidth:"2",strokeLinejoin:"round"}),(0,Z.jsx)("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,Z.jsx)("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]})}function vo({iconType:t,config:e,imageOverride:o,onClick:i}){let n=Wt(e?.size,18),r=Math.max(24,n+10),s=e?.margin||{},a=o||e?.image,c=e?.color?.cross||"#FFFFFF",u=e?.color?.fill||"rgba(0,0,0,0.55)",x=e?.color?.stroke||"rgba(255,255,255,0.35)";return(0,Z.jsx)("button",{"data-control-button":"true",type:"button",onPointerDown:m=>{m.preventDefault(),m.stopPropagation()},onPointerUp:m=>{m.preventDefault(),m.stopPropagation()},onMouseDown:m=>{m.preventDefault(),m.stopPropagation()},onTouchStart:m=>{m.preventDefault(),m.stopPropagation()},onClick:m=>{m.preventDefault(),m.stopPropagation(),i()},title:e?.selectedStyle||t,style:{width:r,height:r,borderRadius:999,pointerEvents:"auto",zIndex:10030,position:"relative",border:`1px solid ${x}`,background:u,color:c,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,marginTop:Wt(s.top,0),marginRight:Wt(s.right,0),marginBottom:Wt(s.bottom,0),marginLeft:Wt(s.left,0)},children:a?(0,Z.jsx)("img",{src:a,alt:t,style:{width:n,height:n,objectFit:"contain"}}):(0,Z.jsx)(Ki,{iconType:t,color:c})})}var kn=()=>{let t=pt("PIP"),e=F(q=>q.campaigns),o=F(q=>q.allCampaigns),i=F(q=>q.currentScreen),n=F(q=>q.isVisible),[r,s]=(0,yt.useState)(!1),[a,c]=(0,yt.useState)(!1),[u,x]=(0,yt.useState)(!0),[m,g]=(0,yt.useState)(!1),[v,f]=(0,yt.useState)(null),b=(0,yt.useRef)({x:0,y:0}),h=(0,yt.useRef)(null),y=(0,yt.useMemo)(()=>{if(t)return t;let q=Co(i),Q=ot=>ot.find(ct=>{let at=ct,Pt=at.campaign_type==="PIP",Ut=!Co(at.screen)||Co(at.screen)===q,ve=!!(at.trigger_event??at.trigger),te=at.display_trigger!==!1&&!ve;return Pt&&Ut&&te}),J=Q(e)??Q(o);return J?St(J):void 0},[t,e,o,i]),w=(0,yt.useMemo)(()=>y,[y?.id,y?.details?.id]);if((0,yt.useEffect)(()=>{if(!w)return;let q=w.details||{},Q=q?.styling?.soundToggle?.defaultSound||q?.styling?.appearance?.defaultSound||"yes";x(String(Q).toLowerCase()!=="yes"),s(!1),c(!1),f(null),H("viewed",w.id)},[w]),(0,yt.useEffect)(()=>{h.current&&(h.current.muted=u)},[u]),(0,yt.useEffect)(()=>{if(!m)return;let q=J=>{let ot=J.clientX-b.current.x,ct=J.clientY-b.current.y;f({x:Math.max(0,ot),y:Math.max(0,ct)})},Q=()=>{g(!1)};return window.addEventListener("mousemove",q),window.addEventListener("mouseup",Q),()=>{window.removeEventListener("mousemove",q),window.removeEventListener("mouseup",Q)}},[m]),!w||!w.details||r||!n)return null;let I=w.details,B=I.styling||{},R=B.appearance||{},d=Wt(I.width??R.pipWidth,150),T=Wt(I.height??R.pipHeight,300),l=Math.max(d,T),p=Math.min(d,T),O=B.cta?.container||{},A=B.cta?.text||{},_=!!(I.button_text&&I.button_text.trim().length>0),C=Wt(B.cta?.container?.height,42),S=_?C+24:0,W=Wt(B.pipBottomPadding,20),P=Wt(B.pipTopPadding,0),M=a?I.large_video||I.small_video:I.small_video||I.large_video,$=(I.position||w.position||"right").toLowerCase(),k=!!B.isMovable,L=B.soundToggle?.enabled!==!1,j=B.crossButton?.enabled!==!1,X=B.expandControls?.enabled!==!1&&String(B.expandablePip||"yes").toLowerCase()==="yes",mt=B.crossButton,N=a?B.expandControls?.minimise:B.expandControls?.maximise,tt=u?B.soundToggle?.mute:B.soundToggle?.unmute,K={position:"fixed",zIndex:10020,width:a?"100vw":l,height:a?"100vh":p,borderRadius:0,overflow:"hidden",background:"#000",boxShadow:"0 16px 40px rgba(0,0,0,0.35)",cursor:m?"grabbing":k&&!a?"grab":"default",transition:m?"none":"width 180ms ease, height 180ms ease, transform 180ms ease"};v&&!a?(K.left=v.x,K.top=v.y):a?(K.left=0,K.top=0,K.right=0,K.bottom=0):($==="left"?K.left=24:K.right=24,P>0?K.top=P:K.bottom=W+20);let Y=q=>{if(!k||a||q.target.closest("[data-control-button='true']"))return;let J=q.currentTarget.getBoundingClientRect();b.current={x:q.clientX-J.left,y:q.clientY-J.top},f({x:J.left,y:J.top}),g(!0)},st=()=>{if(!I.link)return;H("clicked",w.id);let q=String(I.link).trim();try{let Q=F.getState(),J=Q.allCampaigns||[],ot=Q.campaigns||[],ct=J.find(at=>at.id===q);if(console.log("[Pip] clicked link=",q,"allCount=",J.length,"visibleCount=",ot.length,"referenced=",!!ct),ct){let at={...ct};delete at.trigger_event,delete at.trigger,at.display_trigger=!0;let Pt=ot.findIndex(Ut=>Ut.id===at.id);if(Pt===-1)Q.saveCampaigns([at,...ot]);else{let Ut=ot[Pt];if(!!(Ut.trigger_event??Ut.trigger)){let te=[...ot];te[Pt]=at,Q.saveCampaigns(te)}}return}}catch{}window.open(I.link,"_blank")};return M?(0,Z.jsxs)("div",{style:K,onMouseDown:Y,children:[(0,Z.jsx)("video",{ref:h,src:M,autoPlay:!0,loop:!0,playsInline:!0,muted:u,style:{width:"100%",height:a&&_?`calc(100% - ${S}px)`:"100%",objectFit:a?"contain":"cover"},onClick:st,onEnded:()=>{y&&H("analyze",y.id)}}),(0,Z.jsxs)("div",{style:{position:"absolute",top:8,right:8,display:"flex",gap:8,zIndex:2},children:[L&&(0,Z.jsx)(vo,{iconType:u?"mute":"unmute",config:tt,imageOverride:u?I.muteImage:I.unmuteImage,onClick:()=>x(q=>!q)}),X&&(0,Z.jsx)(vo,{iconType:a?"minimize":"expand",config:N,imageOverride:a?I.minimiseImage:I.maximiseImage,onClick:()=>{console.log("[Pip] expand button clicked - isExpanded before:",a),c(q=>{let Q=!q;return Q&&w?.id&&(H("viewed",w.id),H("analyze",w.id)),Q})}}),j&&(0,Z.jsx)(vo,{iconType:"close",config:mt,imageOverride:I.crossButtonImage,onClick:()=>s(!0)})]}),a&&_&&(0,Z.jsx)("button",{"data-control-button":"true",onClick:st,style:{position:"absolute",left:12,right:12,bottom:12,height:O.height||42,width:O.ctaFullWidth?"auto":O.ctaWidth||"auto",margin:O.ctaFullWidth?"0":"0 auto",background:O.backgroundColor||"#F7921C",color:A.color||"#fff",border:`${O.borderWidth||0}px solid ${O.borderColor||"transparent"}`,borderRadius:10,fontSize:A.fontSize||14,fontFamily:dt(A.fontFamily),fontWeight:600,cursor:I.link?"pointer":"default"},children:I.button_text})]}):null};var xt=Ne(require("react")),Rn=require("lottie-react");et();var ne=require("react/jsx-runtime"),kt=(t,e=0)=>{let o=Number(t);return Number.isFinite(o)?o:e},wo=t=>(t||"").trim().toLowerCase(),Zi="appstorysmediabucketdev.s3.ap-south-1.amazonaws.com",tr=t=>{try{if(typeof window>"u")return[t];let e=new URL(t);if(e.hostname!==Zi)return[t];let o=!!window.location.port,i=`/appstorys-media${e.pathname}${e.search}`;return o?[i,t]:[t]}catch{return[t]}},er=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"},ko=class extends xt.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}},or=()=>{let[t,e]=(0,xt.useState)(null),[o,i]=(0,xt.useState)([]),[n,r]=(0,xt.useState)(!1),[s,a]=(0,xt.useState)(!1),c=(0,xt.useRef)(null),u=(0,xt.useRef)(null),x=pt("FLT"),m=F(C=>C.campaigns),g=F(C=>C.allCampaigns),v=F(C=>C.currentScreen),f=F(C=>C.isVisible),b=(0,xt.useRef)(null),h=x??(()=>{let C=[...m,...g].find(S=>{let W=S;if(W.campaign_type!=="FLT")return!1;let P=!!(W.trigger_event??W.trigger);return W.display_trigger===!1||P?!1:!wo(W.screen)||wo(W.screen)===wo(v)});if(C)try{return St(C)}catch{return C}})(),y=h?.id,w=F(C=>y?C.variantMappings[y]:void 0);if((0,xt.useEffect)(()=>{if(!h?.id||!f||bo(h)&&!w)return;let S=`${h.id}:${w||""}`;b.current!==S&&(b.current=S,H("viewed",h.id))},[h?.id,w,f]),(0,xt.useEffect)(()=>{let C=h?.details?.lottie_data;if(e(null),i([]),r(!1),a(!1),!C)return;if(er(C)){e(C),a(!0);return}if(typeof C!="string"){r(!0);return}let S=tr(C);i(S),a(!0)},[h?.details?.lottie_data]),(0,xt.useEffect)(()=>{if(!h?.details?.lottie_data||!c.current)return;let C=Rn.LottiePlayer;if(!C||typeof C.loadAnimation!="function"){r(!0),a(!1);return}let S=!1,W=null,P=()=>{W&&typeof W.destroy=="function"&&W.destroy(),W=null,u.current=null},M=($,k)=>{if(S)return;if(k>=$.length){r(!0),a(!1),console.error("[Floater] lottie load failed",{lottieUrls:$});return}P();let L=C.loadAnimation({container:c.current,renderer:"svg",loop:!0,autoplay:!0,path:$[k]});W=L,u.current=L,L.addEventListener("DOMLoaded",()=>{S||a(!1)}),L.addEventListener("data_failed",()=>{S||M($,k+1)})};if(t){P();let $=C.loadAnimation({container:c.current,renderer:"svg",loop:!0,autoplay:!0,animationData:t});W=$,u.current=$,$.addEventListener("DOMLoaded",()=>{S||a(!1)}),$.addEventListener("data_failed",()=>{S||(r(!0),a(!1))})}else o.length>0&&M(o,0);return()=>{S=!0,P()}},[h?.details?.lottie_data,t,o]),!h||!h.details||!f)return null;let{details:I}=h,B=I.styling||{},d=(typeof I.position=="string"?I.position:typeof h.position=="string"?h.position:"right").toLowerCase()==="left"?"left":"right",T={position:"fixed",left:d==="left"?kt(B.marginLeft,12):void 0,right:d==="left"?void 0:kt(B.marginRight,12),top:kt(B.marginTop,0)>0?kt(B.marginTop,0):void 0,bottom:kt(B.marginTop,0)>0?void 0:kt(B.marginBottom,80),zIndex:10040,display:"flex"},l={width:kt(I.width,60),height:kt(I.height,60),background:"transparent",overflow:"hidden",borderBottomLeftRadius:kt(B.bottomLeftRadius,0),borderBottomRightRadius:kt(B.bottomRightRadius,0),borderTopLeftRadius:kt(B.topLeftRadius,0),borderTopRightRadius:kt(B.topRightRadius,0),display:"flex",alignItems:"center",justifyContent:"center",cursor:I.link?"pointer":"default",boxShadow:"0 8px 18px rgba(0,0,0,0.2)"},p=async()=>{if(!I.link)return;await H("clicked",h.id);let C=String(I.link).trim();try{let S=F.getState(),W=S.allCampaigns||[],P=S.campaigns||[],M=W.find($=>{if(!$)return!1;let k=String($.id||"").trim(),L=$.details||{},j=String(L.campaign||L.id||"").trim();return!!(k&&k===C||j&&j===C||k&&C.includes(k)||j&&C.includes(j))});if(console.log("[Floater] clicked link=",C,"allCampaignsCount=",W.length,"visibleCount=",P.length),console.log("[Floater] all ids=",W.map($=>$.id).slice(0,50)),console.log("[Floater] referenced found=",!!M,M&&(M.id||M.details?.campaign||M.details?.id)),M){let $={...M};delete $.trigger_event,delete $.trigger,$.display_trigger=!0;let k=P.findIndex(L=>L.id===$.id);if(k===-1)console.log("[Floater] revealing campaign (prepended)",$.id),S.saveCampaigns([$,...P]);else{let L=P[k];if(!!(L.trigger_event??L.trigger)){let X=[...P];X[k]=$,console.log("[Floater] replacing existing triggered campaign with revealed one",$.id),S.saveCampaigns(X)}else console.log("[Floater] campaign already visible and not trigger-driven",$.id)}return}}catch(S){console.warn("[Floater] error while resolving referenced campaign",S)}try{window.open(I.link,"_blank")}catch{}},O=!!(I.lottie_data&&!n),A=!!I.image,_=!!(I.lottie_data&&s&&!t&&!n);return!O&&!A&&!_?null:(0,ne.jsx)("div",{style:T,children:(0,ne.jsx)("div",{style:l,onClick:()=>{p()},children:O?(0,ne.jsx)(ko,{onError:()=>r(!0),children:(0,ne.jsx)("div",{ref:c,style:{width:"100%",height:"100%",display:"block"}})},String(I.lottie_data)):_?(0,ne.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,ne.jsx)("img",{src:I.image,alt:"floater",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})})})},Tn=or;et();function Fn(t){return(t||"").trim().toLowerCase()}function Ro(t,e){let o=Fn(t.screen),i=Fn(e);return!o||o===i}async function To(t){try{let e=F.getState(),o=await lt(),i=e.accountId;if(!o||!i)return;e.setCurrentScreen(t),e.setTrackedEvents([]);let n=e.baseUrl||"https://users.appstorys.co",r=await fetch(`${n}/v2/${i}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({user_id:Bt(),screenName:t})});if(!r.ok)return;let s=await r.json();if(typeof s.screen_capture_enabled<"u"&&e.setScreenCaptureEnabled(!!s.screen_capture_enabled),s.variants&&s.variants.length>0){let y={};s.variants.forEach(w=>{y[w.id]=w.v_id}),e.setVariantMappings(y)}s.personalization_data&&e.setPersonalizationData(s.personalization_data);let a=e.allCampaigns||[],c=s.eligibleCampaignList||[],u=a.filter(y=>c.includes(y.id)&&Ro(y,t)),x=u.map(y=>y.id),m=c.filter(y=>!x.includes(y)),g=[];if(m.length>0){let y=await fetch(`${n}/load-campaign-data`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(m)});y.ok&&(g=(await y.json()).filter(I=>Ro(I,t)))}let v=[...u,...g],f=a.filter(y=>{let w=!!(y.trigger_event??y.trigger);return Ro(y,t)&&y.display_trigger===!0&&!w}),b=[...v],h=new Set(b.map(y=>y.id));for(let y of f)h.has(y.id)||(b.push(y),h.add(y.id));e.saveCampaigns(b)}catch(e){console.error("Error when tracking screen:",t,e)}}He();et();Ue();async function Fo(t){try{let e=await lt(),o=Bt(),i=F.getState();if(!e||!o){console.warn("AppStorys: Missing accessToken or userId. Ensure SDK is initialized before setting user properties.");return}let n={...t||{}},r=await oe();n={...n,...r};let s={user_id:o,attributes:n},a=i.baseUrl||"https://users.appstorys.co";await Qe({url:`${a}/update-user-atr`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:s})}catch(e){console.error("AppStorys: Error in setUserProperties:",e)}}et();function Fe(t){if(!t||t.trim()==="")return t;let e=F.getState().personalizationData;if(!e||Object.keys(e).length===0)return nr(t);let o=/\{\{([^|}\s]+)\s*\|\s*([^}]+)\}\}/g;return t.replace(o,(i,n,r)=>{let s=n.trim(),a=r.trim();return e[s]??a})}function nr(t){let e=/\{\{[^|}\s]+\s*\|\s*([^}]+)\}\}/g;return t.replace(e,(o,i)=>i.trim())}ge();et();et();var Io="appstorys_campaigns_cache",In="appstorys_campaigns_etag",zo="appstorys_campaigns_version";async function Bo(t,e){try{let o=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),i=o?`/appstorys-campaigns/clients/${t}/campaigns.json`:`https://dev-cdn-campaign-appstorys.s3.ap-south-1.amazonaws.com/clients/${t}/campaigns.json`,n=await nt.getItem(Io),r=await nt.getItem(In),s=await nt.getItem(zo),a={Accept:"application/json"};!o&&r&&(a["If-None-Match"]=r);let c=await fetch(i,{method:"GET",headers:a,...o?{cache:"no-store"}:{}});if(c.status===304)return{campaigns:n?JSON.parse(n):[],version:s?parseInt(s):1};let u=c.headers.get("ETag"),x=await c.json(),m=2,g=x,v=e;if(!v)try{let f=await lt(),b=Bt(),y=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...f?{Authorization:`Bearer ${f}`}:{}},body:JSON.stringify({user_id:b,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(y.ok){let w=await y.json();console.info("AppStorys: fetchAllCampaigns track-user-res returned",w);let I=w?.screenName||w?.screen||w?.currentScreen||w?.screen_name||w?.current_screen;I&&(v=I);try{let B=F.getState();typeof w.screen_capture_enabled<"u"&&B.setScreenCaptureEnabled(!!w.screen_capture_enabled)}catch{}}}catch(f){console.warn("Could not fetch screen name from track-user-res:",f)}if(x.length>0&&x[0].version!==void 0&&(m=x[0].version,g=x.slice(1)),!g||g.length===0)try{let f=await lt(),b=Bt(),y=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...f?{Authorization:`Bearer ${f}`}:{}},body:JSON.stringify({user_id:b,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(y.ok){let w=await y.json(),I=w?.user_id||w?.id||w?.userId||b;try{let B=F.getState();typeof w.screen_capture_enabled<"u"&&B.setScreenCaptureEnabled(!!w.screen_capture_enabled)}catch{}if(I){let R=await fetch(o?"/appstorys-users/load-campaign-data":"https://users.appstorys.com/load-campaign-data",{method:"POST",headers:{"Content-Type":"application/json",...f?{Authorization:`Bearer ${f}`}:{}},body:JSON.stringify({user_id:I})});if(R.ok){let d=await R.json();console.log(`Fetched ${d.length} missing campaigns from fallback`),console.log("Fallback campaigns:",JSON.stringify(d,null,2)),d&&d.length>0&&(g=d)}else console.error("Failed to fetch missing campaigns:",await R.text())}}}catch(f){console.error("Error fetching missing campaigns via fallback:",f)}if(v&&g&&g.length>0){let f=h=>(h||"").trim().toLowerCase(),b=f(v);g=g.filter(h=>!f(h.screen)||f(h.screen)===b)}return await nt.setItem(Io,JSON.stringify(g)),await nt.setItem(zo,m.toString()),u&&await nt.setItem(In,u),{campaigns:g,version:m}}catch(o){console.error("Error fetching campaigns:",o);let i=await nt.getItem(Io),n=await nt.getItem(zo);return{campaigns:i?JSON.parse(i):[],version:n?parseInt(n):1}}}et();et();et();async function Xe(t,e){try{let o=await lt(),i=F.getState();if(!o)return console.error("AppStorys: Access token not found for reconciliation"),!1;let n={anonymous_user_id:t,identified_user_id:e},r=i.baseUrl||"https://users.appstorys.co",s=await fetch(`${r}/reconcile-anonymous-user`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(n)});if(s.ok)return!0;{let a=await s.text();return console.error("AppStorys: Failed to reconcile anonymous user:",s.status,a),!1}}catch(o){return console.error("AppStorys: Error in reconcileAnonymousUser:",o),!1}}et();var Ao=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&&xo()&&this.triggerCampaign()};handlePopState=()=>{xo()&&(window.history.pushState("appstorys_navigation",""),this.triggerCampaign())};triggerCampaign(){let e=F.getState(),{trackedEvents:o}=e;o.includes(qe)||(console.log("AppStorys: Exit Intent triggered. Displaying campaign."),e.setTrackedEvents([...o,qe]))}},zn=new Ao;et();var Eo=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=F.getState();o.isVisible!==e&&(console.log(`AppStorys: SDK visibility changed to ${e?"visible":"hidden"}`),o.setVisibility(e))}},Po=new Eo;ge();var Ke="anonymous_user_id";async function Bn(){let t=Date.now(),e=navigator.userAgent.split(" ")[0].replace(/[^a-zA-Z0-9]/g,"_");return`${t}_${e}`}async function An(){try{let t=await nt.getItem(Ke);if(t)return t;let e=await Bn();return await nt.setItem(Ke,e),e}catch(t){return console.error("Error managing anonymous user ID:",t),await Bn()}}async function Lo(){try{await nt.removeItem(Ke)}catch(t){console.error("Error clearing anonymous user ID:",t)}}async function Do(){try{return await nt.getItem(Ke)}catch(t){return console.error("Error getting stored anonymous user ID:",t),null}}function ir(){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 Or(){Mr();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 Ii(){try{let t=F.getState(),o=!!window.__APPSTORYS_DEBUG_CAPTURE;if(console.info("AppStorys: mountScreenCaptureButton called, screenCaptureEnabled=",t.screenCaptureEnabled,"debugForce=",o),!t.screenCaptureEnabled&&!o||document.getElementById("appstorys-screen-capture-btn"))return null;let i=Or();return i.addEventListener("click",async()=>{i.disabled=!0;let n=i.innerText;i.innerHTML='<div class="appstorys-spinner"></div>';let s=F.getState().currentScreen||(typeof window<"u"?window.location.pathname:"");try{await ce.takeScreenshot(s)}catch(a){console.error("CaptureService error",a)}i.disabled=!1,i.innerText=n,i.animate([{transform:"scale(1.0)"},{transform:"scale(1.05)"},{transform:"scale(1.0)"}],{duration:300})}),document.body.appendChild(i),console.info("AppStorys: screen capture button mounted"),i}catch(t){return console.error("mountScreenCaptureButton error",t),null}}var Bi=oe(()=>{"use strict";et();Fi();try{window.AppStorysMountCapture=function(){try{return Ii()}catch(t){return console.error("AppStorysMountCapture failed",t),null}}}catch{}try{window.AppStorysDebugState=function(){try{let t=F.getState();return console.info("AppStorys store state:",t),t}catch(t){return console.error("AppStorysDebugState failed",t),null}}}catch{}try{window.AppStorysDebugToken=function(){try{let t=localStorage.getItem("access_token")||"",e=t.length,o=t?t.slice(0,20)+"..."+t.slice(-10):"(none)";if(console.info("Token length:",e,"masked:",o),t&&t.includes("."))try{let i=t.split(".");if(i.length===3){let n=JSON.parse(atob(i[1]));if(console.info("Token payload:",n),n.exp){let r=new Date(n.exp*1e3),s=new Date;console.info("Token expires:",r.toISOString(),"Expired:",s>r)}}}catch(i){console.warn("Could not decode JWT:",i)}return t?"Token present":"No token"}catch(t){return console.error("AppStorysDebugToken failed",t),null}}}catch{}});var Nr={};cn(Nr,{AppStorys:()=>jr,Banner:()=>vn,BottomSheet:()=>hi,Csat:()=>xi,Floater:()=>In,Pip:()=>Tn,SdkState:()=>mo,Story:()=>gi,Survey:()=>wi,Tooltip:()=>yi,Widget:()=>mi,personalizeText:()=>Te});module.exports=ji(Nr);var mo=(n=>(n.uninitialized="uninitialized",n.initializing="initializing",n.initialized="initialized",n.error="error",n))(mo||{});var Mt=require("react"),ye=je(require("lottie-react"));et();var mn=require("react");et();et();var Ni=t=>F.getState().variantMappings[t];function ho(t){return!!(t.details&&typeof t.details=="object"&&"variants"in t.details)}function Ct(t){if(!ho(t))return t;let e=Ni(t.id||"");if(!e)return t;let o=t.details?.variants;if(!o||typeof o!="object")return t;let i=o[e];if(!i)return t;let n=typeof t.details=="object"?Object.fromEntries(Object.entries(t.details).filter(([s])=>s!=="variants")):{};return{...t,details:{...n,...i},_variantId:e}}var Ne="__back_press_triggered__";function fn(t){return(t||"").trim().toLowerCase()}function qi(t,e){let o=fn(t),i=fn(e);return!o||o===i}function Ui(t,e,o){let i=Number(t),n=Number(o),r=!isNaN(i)&&!isNaN(n);switch(e){case"eq":return r?i===n:t===o;case"neq":return r?i!==n:t!==o;case"gt":return r?i>n:t>o;case"gte":return r?i>=n:t>=o;case"lt":return r?i<n:t<o;case"lte":return r?i<=n:t<=o;default:return!1}}function Hi(t,e){let o=t.filter(i=>i.back_press==null);return o.length===0?!0:e.some(i=>o.every(n=>{let r=i[n.key];return r==null?!1:Ui(String(r),n.operator,n.value)}))}function Vi(t,e,o){let i=t,n=i.trigger_event??i.trigger,r=t.id;return!n}function bo(){let{campaigns:t,trackedEvents:e,trackedEventMetadata:o,currentScreen:i}=F.getState();return t.some(n=>{if(n.screen&&n.screen!==i)return!1;let r=n.trigger_event;if(!r||typeof r=="string")return!1;let{event:s,event_config:a}=r;if(!(a??[]).some(x=>x.back_press===!0)||e.includes(Ne)||!e.includes(s))return!1;let c=(a??[]).filter(x=>x.back_press==null);if(c.length===0)return!0;let u=o[s]||[];return Hi(c,u)})}function ct(t,e){let o=F(c=>c.currentScreen),i=F(c=>c.campaigns),n=F(c=>c.allCampaigns),r=F(c=>c.trackedEvents),s=F(c=>c.trackedEventMetadata),a=F(c=>c.variantMappings);return(0,mn.useMemo)(()=>{let c=m=>m.find(g=>qi(g.screen,o)&&g.campaign_type===t&&(e?.position?g.position===e.position:!0)&&Vi(g,r,s)),x=(i&&i.length>0?c(i):void 0)??c(n||[]);if(x)return Ct(x)},[i,n,r,s,a,t,e,o])}et();qe();fe();et();Ue();var hn="appstorys_offline_queue";async function bn(){let t=await ot.getItem(hn);return t?JSON.parse(t):[]}async function xn(t){await ot.setItem(hn,JSON.stringify(t))}function Yi(t){return Math.min(3e4*Math.pow(2,t),12e4)}function Qi(t){let o=t.retryCount||0,i=t.lastAttempt||0,n=Yi(o);return o<3&&Date.now()-i>=n}async function Gi(){let t=F.getState();return!t.accountId||!t.appId?!1:await Vt(t.accountId,t.appId,t.userId)}async function Sn(t,e){if(await Gi()){let i=await ot.getItem("access_token");i&&(t.headers={...t.headers,Authorization:`Bearer ${i}`}),t.authRetried=!0,t.lastAttempt=Date.now(),e(t)}}async function Ve(t,e){let o=(t.retryCount||0)+1;o<=3&&(t.retryCount=o,t.lastAttempt=Date.now(),e(t))}async function He(t){let e=await bn();e.push(t),await xn(e)}async function Ji(){let t=await bn();if(t.length===0)return;let e=[];for(let o of t){if(!Qi(o)){e.push(o);continue}try{let i=await fetch(o.url,{method:o.method,headers:o.headers,body:JSON.stringify(o.body)});if(i.ok)continue;i.status===401||i.status===403?o.authRetried||await Sn(o,n=>e.push(n)):i.status>=500&&await Ve(o,n=>e.push(n))}catch{await Ve(o,n=>e.push(n))}}await xn(e)}async function Ye(t){if(!navigator.onLine){await He(t);return}await Ji();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 Sn(t,He):e.status>=500&&await Ve(t,He)),e}catch{await Ve(t,He);return}}async function H(t,e,o){try{if(!t)return;let i=await lt(),n=F.getState(),r=["viewed","clicked","csat captured","survey captured","shared"];if(!r.includes(t)){let u=n.trackedEvents;if(!u.includes(t))n.setTrackedEvents([...u,t]);else{let x=u.filter(m=>m!==t);x.push(t),n.setTrackedEvents(x)}if(o&&Object.keys(o).length>0){let x=n.trackedEventMetadata||{},m=x[t]||[];n.setTrackedEventMetadata({...x,[t]:[...m,o]})}}let s={...o||{}};if(!r.includes(t)){let u=await ne();s={...s,...u}}if(e&&String(e).trim()!==""){let u=gn(e);u&&(s.variant_id=u)}let a={user_id:Pt(),event:t,metadata:s};e&&(a.campaign_id=e);let c=n.trackingUrl||"https://tracking.appstorys.co";i&&await Ye({url:`${c}/capture-event`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:a})}catch(i){console.error("Error in trackEvent",i)}}et();function vt(t){if(!t)return!1;let e=F.getState(),o=e.allCampaigns||[],i=e.campaigns||[],n=String(t).trim(),r=o.find(c=>{if(!c)return!1;let u=String(c.id||"").trim(),x=c.details||{},m=String(x.campaign||x.id||"").trim();return!!(u&&u===n||m&&m===n||u&&n.includes(u)||m&&n.includes(m))});if(!r)return!1;let s={...r};delete s.trigger_event,delete s.trigger,s.display_trigger=!0;let a=i.findIndex(c=>String(c.id||"")===String(s.id||""));if(a===-1)e.saveCampaigns([s,...i]);else{let c=i[a];if(!!(c.trigger_event??c.trigger)){let x=[...i];x[a]=s,e.saveCampaigns(x)}}return!0}var me=require("react/jsx-runtime"),Cn=ye.default?.default??ye.default??ye.Lottie??ye,vn=()=>{let t=ct("BAN"),e=F(w=>w.isVisible),[o,i]=(0,Mt.useState)(!1),[n,r]=(0,Mt.useState)(null),[s,a]=(0,Mt.useState)(null),c=(0,Mt.useRef)(null),[u,x]=(0,Mt.useState)(0);if((0,Mt.useEffect)(()=>{t&&(i(!1),H("viewed",t.id),t.details.lottie_data&&fetch(t.details.lottie_data).then(w=>w.json()).then(w=>{r(w),w.w&&w.h&&a(w.h/w.w)}).catch(w=>console.error("Error loading Lottie:",w)))},[t]),(0,Mt.useEffect)(()=>{let w=()=>{c.current&&x(c.current.offsetWidth)};return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[t,o]),!t||o||!e)return null;let{details:m}=t,g=m.styling||{},v=m.height||"auto";s&&u&&(v=u*s);let f={position:"fixed",left:g.marginLeft?`${g.marginLeft}px`:"10px",right:g.marginRight?`${g.marginRight}px`:"10px",bottom:g.marginBottom?`${g.marginBottom}px`:"10px",backgroundColor:"transparent",borderRadius:`${g.topRightRadius||0}px ${g.topLeftRadius||0}px ${g.bottomRightRadius||0}px ${g.bottomLeftRadius||0}px`,overflow:"hidden",zIndex:9999,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:m.link?"pointer":"default"},b={width:"100%",height:typeof v=="number"?`${v}px`:v,display:"block",objectFit:"cover"},h=w=>{w.stopPropagation(),i(!0),H("banner_closed",t.id)};return(0,me.jsxs)("div",{ref:c,style:f,onClick:()=>{if(m.link)if(H("clicked",t.id),m.link.startsWith("http"))window.open(m.link,"_blank");else{try{if(vt(m.link))return}catch(w){console.warn("revealCampaignFromLink error",w)}console.log("Internal link:",m.link)}},children:[n?(()=>{let w=Cn.default||Cn;return(0,me.jsx)(w,{animationData:n,loop:!0,autoplay:e,style:b})})():m.image?(0,me.jsx)("img",{src:m.image,alt:"Campaign Banner",style:b}):null,g.crossButton?.enabled&&(0,me.jsx)("button",{onClick:h,style:{position:"absolute",top:"5px",right:"5px",background:"rgba(0,0,0,0.3)",color:"white",border:"none",borderRadius:"50%",width:"24px",height:"24px",lineHeight:"22px",textAlign:"center",cursor:"pointer",padding:"0",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10},children:"\u2715"})]})};var mt=require("react");et();function Ge(t){let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")}function wn(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 kn(t,e){if(typeof document>"u")return;let o=`appstorys-font-${t}`;if(document.getElementById(o))return;let i=document.createElement("style");i.id=o,i.type="text/css",i.textContent=`@font-face{font-family:"${t}";src:url("${e}");font-style:normal;font-weight:normal;font-display:swap;}`,document.head.appendChild(i)}var Qe=new Map;async function Xi(t,e){try{kn(e.name,t);let o=globalThis.FontFace;if(typeof document<"u"&&o&&document.fonts?.add){let i=new o(e.name,`url(${t})`);await i.load(),document.fonts.add(i)}else typeof document<"u"&&document.fonts?.load&&await document.fonts.load(`1em "${e.name}"`);e.status="loaded",e.listeners.forEach(i=>i(e.name))}catch(o){console.warn(`[FontManager] Failed to load font from "${t}":`,o),e.status="failed",e.listeners.forEach(i=>i(void 0))}finally{e.listeners=[]}}var xo={async load(t){if(!t||!Ge(t))return;let e=Qe.get(t);if(e)return e.status==="loaded"?e.name:e.status==="failed"?void 0:new Promise(r=>e.listeners.push(r));let i={status:"pending",name:wn(t),listeners:[]};Qe.set(t,i);let n=new Promise(r=>i.listeners.push(r));return Xi(t,i),n},ensure(t){if(!t||!Ge(t))return;let e=wn(t);return kn(e,t),xo.load(t),e},getSync(t){if(!t)return;let e=Qe.get(t);return e?.status==="loaded"?e.name:void 0},_clearCache(){Qe.clear()}};function dt(t){if(t)return Ge(t)?xo.ensure(t):t}function Ki(t){let e=new Set,o=new WeakSet,i=n=>{if(n!=null&&typeof n!="string"){if(Array.isArray(n)){for(let r of n)i(r);return}if(typeof n=="object"){if(o.has(n))return;o.add(n);for(let[r,s]of Object.entries(n))r==="fontFamily"&&typeof s=="string"&&Ge(s)&&e.add(s),i(s)}}};return i(t),Array.from(e)}async function Rn(t){let e=new Set;for(let o of t)Ki(o).forEach(i=>e.add(i));await Promise.all(Array.from(e).map(o=>xo.load(o)))}var Z=require("react/jsx-runtime"),So=t=>(t||"").trim().toLowerCase(),Ot=(t,e)=>{let o=Number(t);return Number.isFinite(o)?o:e};function Zi({iconType:t,color:e}){let o=e||"#FFFFFF";return t==="close"?(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:o,strokeWidth:"2.2",strokeLinecap:"round"}),(0,Z.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:o,strokeWidth:"2.2",strokeLinecap:"round"})]}):t==="expand"?(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("polyline",{points:"8,3 3,3 3,8",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"3",y1:"3",x2:"9",y2:"9",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,Z.jsx)("polyline",{points:"16,21 21,21 21,16",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"15",y1:"15",x2:"21",y2:"21",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):t==="minimize"?(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("polyline",{points:"9,9 3,9 3,3",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"3",y1:"9",x2:"9",y2:"3",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,Z.jsx)("polyline",{points:"15,15 21,15 21,21",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"15",y1:"21",x2:"21",y2:"15",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):t==="mute"?(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:o,strokeWidth:"2",strokeLinejoin:"round"}),(0,Z.jsx)("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,Z.jsx)("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):(0,Z.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Z.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:o,strokeWidth:"2",strokeLinejoin:"round"}),(0,Z.jsx)("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round"}),(0,Z.jsx)("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]})}function Co({iconType:t,config:e,imageOverride:o,onClick:i}){let n=Ot(e?.size,18),r=Math.max(24,n+10),s=e?.margin||{},a=o||e?.image,c=e?.color?.cross||"#FFFFFF",u=e?.color?.fill||"rgba(0,0,0,0.55)",x=e?.color?.stroke||"rgba(255,255,255,0.35)";return(0,Z.jsx)("button",{"data-control-button":"true",type:"button",onPointerDown:m=>{m.preventDefault(),m.stopPropagation()},onPointerUp:m=>{m.preventDefault(),m.stopPropagation()},onMouseDown:m=>{m.preventDefault(),m.stopPropagation()},onTouchStart:m=>{m.preventDefault(),m.stopPropagation()},onClick:m=>{m.preventDefault(),m.stopPropagation(),i()},title:e?.selectedStyle||t,style:{width:r,height:r,borderRadius:999,pointerEvents:"auto",zIndex:10030,position:"relative",border:`1px solid ${x}`,background:u,color:c,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,marginTop:Ot(s.top,0),marginRight:Ot(s.right,0),marginBottom:Ot(s.bottom,0),marginLeft:Ot(s.left,0)},children:a?(0,Z.jsx)("img",{src:a,alt:t,style:{width:n,height:n,objectFit:"contain"}}):(0,Z.jsx)(Zi,{iconType:t,color:c})})}var Tn=()=>{let t=ct("PIP"),e=F(U=>U.campaigns),o=F(U=>U.allCampaigns),i=F(U=>U.currentScreen),n=F(U=>U.isVisible),[r,s]=(0,mt.useState)(!1),[a,c]=(0,mt.useState)(!1),[u,x]=(0,mt.useState)(!0),[m,g]=(0,mt.useState)(!1),[v,f]=(0,mt.useState)(null),b=(0,mt.useRef)({x:0,y:0}),h=(0,mt.useRef)(null),y=(0,mt.useMemo)(()=>{if(t)return t;let U=So(i),G=at=>at.find(St=>{let rt=St,Bt=rt.campaign_type==="PIP",ht=!So(rt.screen)||So(rt.screen)===U,At=!!(rt.trigger_event??rt.trigger),ee=rt.display_trigger!==!1&&!At;return Bt&&ht&&ee}),Q=G(e)??G(o);return Q?Ct(Q):void 0},[t,e,o,i]),w=(0,mt.useMemo)(()=>y,[y?.id,y?.details?.id]);if((0,mt.useEffect)(()=>{if(!w)return;let U=w.details||{},G=U?.styling?.soundToggle?.defaultSound||U?.styling?.appearance?.defaultSound||"yes";x(String(G).toLowerCase()!=="yes"),s(!1),c(!1),f(null),H("viewed",w.id)},[w]),(0,mt.useEffect)(()=>{h.current&&(h.current.muted=u)},[u]),(0,mt.useEffect)(()=>{if(!m)return;let U=Q=>{let at=Q.clientX-b.current.x,St=Q.clientY-b.current.y;f({x:Math.max(0,at),y:Math.max(0,St)})},G=()=>{g(!1)};return window.addEventListener("mousemove",U),window.addEventListener("mouseup",G),()=>{window.removeEventListener("mousemove",U),window.removeEventListener("mouseup",G)}},[m]),!w||!w.details||r||!n)return null;let I=w.details,B=I.styling||{},R=B.appearance||{},d=Ot(I.width??R.pipWidth,150),T=Ot(I.height??R.pipHeight,300),l=Math.max(d,T),p=Math.min(d,T),O=B.cta?.container||{},A=B.cta?.text||{},_=!!(I.button_text&&I.button_text.trim().length>0),C=Ot(B.cta?.container?.height,42),S=_?C+24:0,W=Ot(B.pipBottomPadding,20),P=Ot(B.pipTopPadding,0),M=a?I.large_video||I.small_video:I.small_video||I.large_video,$=(I.position||w.position||"right").toLowerCase(),k=!!B.isMovable,L=B.soundToggle?.enabled!==!1,j=B.crossButton?.enabled!==!1,X=B.expandControls?.enabled!==!1&&String(B.expandablePip||"yes").toLowerCase()==="yes",ft=B.crossButton,N=a?B.expandControls?.minimise:B.expandControls?.maximise,tt=u?B.soundToggle?.mute:B.soundToggle?.unmute,K={position:"fixed",zIndex:10020,width:a?"100vw":l,height:a?"100vh":p,borderRadius:0,overflow:"hidden",background:"#000",boxShadow:"0 16px 40px rgba(0,0,0,0.35)",cursor:m?"grabbing":k&&!a?"grab":"default",transition:m?"none":"width 180ms ease, height 180ms ease, transform 180ms ease"};v&&!a?(K.left=v.x,K.top=v.y):a?(K.left=0,K.top=0,K.right=0,K.bottom=0):($==="left"?K.left=24:K.right=24,P>0?K.top=P:K.bottom=W+20);let Y=U=>{if(!k||a||U.target.closest("[data-control-button='true']"))return;let Q=U.currentTarget.getBoundingClientRect();b.current={x:U.clientX-Q.left,y:U.clientY-Q.top},f({x:Q.left,y:Q.top}),g(!0)},nt=()=>{if(!I.link)return;H("clicked",w.id);let U=String(I.link).trim();try{let G=F.getState(),Q=G.allCampaigns||[],at=G.campaigns||[],St=Q.find(rt=>rt.id===U);if(console.log("[Pip] clicked link=",U,"allCount=",Q.length,"visibleCount=",at.length,"referenced=",!!St),St){let rt={...St};delete rt.trigger_event,delete rt.trigger,rt.display_trigger=!0;let Bt=at.findIndex(ht=>ht.id===rt.id);if(Bt===-1)G.saveCampaigns([rt,...at]);else{let ht=at[Bt];if(!!(ht.trigger_event??ht.trigger)){let ee=[...at];ee[Bt]=rt,G.saveCampaigns(ee)}}return}}catch{}window.open(I.link,"_blank")};return M?(0,Z.jsxs)("div",{style:K,onMouseDown:Y,children:[(0,Z.jsx)("video",{ref:h,src:M,autoPlay:!0,loop:!0,playsInline:!0,muted:u,style:{width:"100%",height:a&&_?`calc(100% - ${S}px)`:"100%",objectFit:a?"contain":"cover"},onClick:nt,onEnded:()=>{y&&H("analyze",y.id)}}),(0,Z.jsxs)("div",{style:{position:"absolute",top:8,right:8,display:"flex",gap:8,zIndex:2},children:[L&&(0,Z.jsx)(Co,{iconType:u?"mute":"unmute",config:tt,imageOverride:u?I.muteImage:I.unmuteImage,onClick:()=>x(U=>!U)}),X&&(0,Z.jsx)(Co,{iconType:a?"minimize":"expand",config:N,imageOverride:a?I.minimiseImage:I.maximiseImage,onClick:()=>{console.log("[Pip] expand button clicked - isExpanded before:",a),c(U=>{let G=!U;return G&&w?.id&&(H("viewed",w.id),H("analyze",w.id)),G})}}),j&&(0,Z.jsx)(Co,{iconType:"close",config:ft,imageOverride:I.crossButtonImage,onClick:()=>s(!0)})]}),a&&_&&(0,Z.jsx)("button",{"data-control-button":"true",onClick:nt,style:{position:"absolute",left:12,right:12,bottom:12,height:O.height||42,width:O.ctaFullWidth?"auto":O.ctaWidth||"auto",margin:O.ctaFullWidth?"0":"0 auto",background:O.backgroundColor||"#F7921C",color:A.color||"#fff",border:`${O.borderWidth||0}px solid ${O.borderColor||"transparent"}`,borderRadius:10,fontSize:A.fontSize||14,fontFamily:dt(A.fontFamily),fontWeight:600,cursor:I.link?"pointer":"default"},children:I.button_text})]}):null};var xt=je(require("react")),Fn=require("lottie-react");et();var ie=require("react/jsx-runtime"),Rt=(t,e=0)=>{let o=Number(t);return Number.isFinite(o)?o:e},vo=t=>(t||"").trim().toLowerCase(),tr="appstorysmediabucketdev.s3.ap-south-1.amazonaws.com",er=t=>{try{if(typeof window>"u")return[t];let e=new URL(t);if(e.hostname!==tr)return[t];let o=!!window.location.port,i=`/appstorys-media${e.pathname}${e.search}`;return o?[i,t]:[t]}catch{return[t]}},or=t=>{if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return Array.isArray(e.layers)||Array.isArray(e.assets)||typeof e.v=="string"},wo=class extends xt.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){this.props.onError()}render(){return this.state.hasError?null:this.props.children}},nr=()=>{let[t,e]=(0,xt.useState)(null),[o,i]=(0,xt.useState)([]),[n,r]=(0,xt.useState)(!1),[s,a]=(0,xt.useState)(!1),c=(0,xt.useRef)(null),u=(0,xt.useRef)(null),x=ct("FLT"),m=F(C=>C.campaigns),g=F(C=>C.allCampaigns),v=F(C=>C.currentScreen),f=F(C=>C.isVisible),b=(0,xt.useRef)(null),h=x??(()=>{let C=[...m,...g].find(S=>{let W=S;if(W.campaign_type!=="FLT")return!1;let P=!!(W.trigger_event??W.trigger);return W.display_trigger===!1||P?!1:!vo(W.screen)||vo(W.screen)===vo(v)});if(C)try{return Ct(C)}catch{return C}})(),y=h?.id,w=F(C=>y?C.variantMappings[y]:void 0);if((0,xt.useEffect)(()=>{if(!h?.id||!f||ho(h)&&!w)return;let S=`${h.id}:${w||""}`;b.current!==S&&(b.current=S,H("viewed",h.id))},[h?.id,w,f]),(0,xt.useEffect)(()=>{let C=h?.details?.lottie_data;if(e(null),i([]),r(!1),a(!1),!C)return;if(or(C)){e(C),a(!0);return}if(typeof C!="string"){r(!0);return}let S=er(C);i(S),a(!0)},[h?.details?.lottie_data]),(0,xt.useEffect)(()=>{if(!h?.details?.lottie_data||!c.current)return;let C=Fn.LottiePlayer;if(!C||typeof C.loadAnimation!="function"){r(!0),a(!1);return}let S=!1,W=null,P=()=>{W&&typeof W.destroy=="function"&&W.destroy(),W=null,u.current=null},M=($,k)=>{if(S)return;if(k>=$.length){r(!0),a(!1),console.error("[Floater] lottie load failed",{lottieUrls:$});return}P();let L=C.loadAnimation({container:c.current,renderer:"svg",loop:!0,autoplay:!0,path:$[k]});W=L,u.current=L,L.addEventListener("DOMLoaded",()=>{S||a(!1)}),L.addEventListener("data_failed",()=>{S||M($,k+1)})};if(t){P();let $=C.loadAnimation({container:c.current,renderer:"svg",loop:!0,autoplay:!0,animationData:t});W=$,u.current=$,$.addEventListener("DOMLoaded",()=>{S||a(!1)}),$.addEventListener("data_failed",()=>{S||(r(!0),a(!1))})}else o.length>0&&M(o,0);return()=>{S=!0,P()}},[h?.details?.lottie_data,t,o]),!h||!h.details||!f)return null;let{details:I}=h,B=I.styling||{},d=(typeof I.position=="string"?I.position:typeof h.position=="string"?h.position:"right").toLowerCase()==="left"?"left":"right",T={position:"fixed",left:d==="left"?Rt(B.marginLeft,12):void 0,right:d==="left"?void 0:Rt(B.marginRight,12),top:Rt(B.marginTop,0)>0?Rt(B.marginTop,0):void 0,bottom:Rt(B.marginTop,0)>0?void 0:Rt(B.marginBottom,80),zIndex:10040,display:"flex"},l={width:Rt(I.width,60),height:Rt(I.height,60),background:"transparent",overflow:"hidden",borderBottomLeftRadius:Rt(B.bottomLeftRadius,0),borderBottomRightRadius:Rt(B.bottomRightRadius,0),borderTopLeftRadius:Rt(B.topLeftRadius,0),borderTopRightRadius:Rt(B.topRightRadius,0),display:"flex",alignItems:"center",justifyContent:"center",cursor:I.link?"pointer":"default",boxShadow:"0 8px 18px rgba(0,0,0,0.2)"},p=async()=>{if(!I.link)return;await H("clicked",h.id);let C=String(I.link).trim();try{let S=F.getState(),W=S.allCampaigns||[],P=S.campaigns||[],M=W.find($=>{if(!$)return!1;let k=String($.id||"").trim(),L=$.details||{},j=String(L.campaign||L.id||"").trim();return!!(k&&k===C||j&&j===C||k&&C.includes(k)||j&&C.includes(j))});if(console.log("[Floater] clicked link=",C,"allCampaignsCount=",W.length,"visibleCount=",P.length),console.log("[Floater] all ids=",W.map($=>$.id).slice(0,50)),console.log("[Floater] referenced found=",!!M,M&&(M.id||M.details?.campaign||M.details?.id)),M){let $={...M};delete $.trigger_event,delete $.trigger,$.display_trigger=!0;let k=P.findIndex(L=>L.id===$.id);if(k===-1)console.log("[Floater] revealing campaign (prepended)",$.id),S.saveCampaigns([$,...P]);else{let L=P[k];if(!!(L.trigger_event??L.trigger)){let X=[...P];X[k]=$,console.log("[Floater] replacing existing triggered campaign with revealed one",$.id),S.saveCampaigns(X)}else console.log("[Floater] campaign already visible and not trigger-driven",$.id)}return}}catch(S){console.warn("[Floater] error while resolving referenced campaign",S)}try{window.open(I.link,"_blank")}catch{}},O=!!(I.lottie_data&&!n),A=!!I.image,_=!!(I.lottie_data&&s&&!t&&!n);return!O&&!A&&!_?null:(0,ie.jsx)("div",{style:T,children:(0,ie.jsx)("div",{style:l,onClick:()=>{p()},children:O?(0,ie.jsx)(wo,{onError:()=>r(!0),children:(0,ie.jsx)("div",{ref:c,style:{width:"100%",height:"100%",display:"block"}})},String(I.lottie_data)):_?(0,ie.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.08)",color:"#333",fontSize:10,fontWeight:600},children:"..."}):(0,ie.jsx)("img",{src:I.image,alt:"floater",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})})})},In=nr;et();function zn(t){return(t||"").trim().toLowerCase()}function ko(t,e){let o=zn(t.screen),i=zn(e);return!o||o===i}async function Ro(t){try{let e=F.getState(),o=await lt(),i=e.accountId;if(!o||!i)return;e.setCurrentScreen(t),e.setTrackedEvents([]);let n=e.baseUrl||"https://users.appstorys.co",r=await fetch(`${n}/v2/${i}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({user_id:Pt(),screenName:t})});if(!r.ok)return;let s=await r.json();if(typeof s.screen_capture_enabled<"u"&&e.setScreenCaptureEnabled(!!s.screen_capture_enabled),s.variants&&s.variants.length>0){let y={};s.variants.forEach(w=>{y[w.id]=w.v_id}),e.setVariantMappings(y)}s.personalization_data&&e.setPersonalizationData(s.personalization_data);let a=e.allCampaigns||[],c=s.eligibleCampaignList||[],u=a.filter(y=>c.includes(y.id)&&ko(y,t)),x=u.map(y=>y.id),m=c.filter(y=>!x.includes(y)),g=[];if(m.length>0){let y=await fetch(`${n}/load-campaign-data`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(m)});y.ok&&(g=(await y.json()).filter(I=>ko(I,t)))}let v=[...u,...g],f=a.filter(y=>{let w=!!(y.trigger_event??y.trigger);return ko(y,t)&&y.display_trigger===!0&&!w}),b=[...v],h=new Set(b.map(y=>y.id));for(let y of f)h.has(y.id)||(b.push(y),h.add(y.id));e.saveCampaigns(b)}catch(e){console.error("Error when tracking screen:",t,e)}}Ue();et();qe();async function To(t){try{let e=await lt(),o=Pt(),i=F.getState();if(!e||!o){console.warn("AppStorys: Missing accessToken or userId. Ensure SDK is initialized before setting user properties.");return}let n={...t||{}},r=await ne();n={...n,...r};let s={user_id:o,attributes:n},a=i.baseUrl||"https://users.appstorys.co";await Ye({url:`${a}/update-user-atr`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:s})}catch(e){console.error("AppStorys: Error in setUserProperties:",e)}}et();function Te(t){if(!t||t.trim()==="")return t;let e=F.getState().personalizationData;if(!e||Object.keys(e).length===0)return ir(t);let o=/\{\{([^|}\s]+)\s*\|\s*([^}]+)\}\}/g;return t.replace(o,(i,n,r)=>{let s=n.trim(),a=r.trim();return e[s]??a})}function ir(t){let e=/\{\{[^|}\s]+\s*\|\s*([^}]+)\}\}/g;return t.replace(e,(o,i)=>i.trim())}fe();et();et();var Fo="appstorys_campaigns_cache",Bn="appstorys_campaigns_etag",Io="appstorys_campaigns_version";async function zo(t,e){try{let o=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),i=o?`/appstorys-campaigns/clients/${t}/campaigns.json`:`https://dev-cdn-campaign-appstorys.s3.ap-south-1.amazonaws.com/clients/${t}/campaigns.json`,n=await ot.getItem(Fo),r=await ot.getItem(Bn),s=await ot.getItem(Io),a={Accept:"application/json"};!o&&r&&(a["If-None-Match"]=r);let c=await fetch(i,{method:"GET",headers:a,...o?{cache:"no-store"}:{}});if(c.status===304)return{campaigns:n?JSON.parse(n):[],version:s?parseInt(s):1};let u=c.headers.get("ETag"),x=await c.json(),m=2,g=x,v=e;if(!v)try{let f=await lt(),b=Pt(),y=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...f?{Authorization:`Bearer ${f}`}:{}},body:JSON.stringify({user_id:b,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(y.ok){let w=await y.json();console.info("AppStorys: fetchAllCampaigns track-user-res returned",w);let I=w?.screenName||w?.screen||w?.currentScreen||w?.screen_name||w?.current_screen;I&&(v=I);try{let B=F.getState();typeof w.screen_capture_enabled<"u"&&B.setScreenCaptureEnabled(!!w.screen_capture_enabled)}catch{}}}catch(f){console.warn("Could not fetch screen name from track-user-res:",f)}if(x.length>0&&x[0].version!==void 0&&(m=x[0].version,g=x.slice(1)),!g||g.length===0)try{let f=await lt(),b=Pt(),y=await fetch(`${o?"/appstorys-users":"https://users.appstorys.co"}/v2/${t}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...f?{Authorization:`Bearer ${f}`}:{}},body:JSON.stringify({user_id:b,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})});if(y.ok){let w=await y.json(),I=w?.user_id||w?.id||w?.userId||b;try{let B=F.getState();typeof w.screen_capture_enabled<"u"&&B.setScreenCaptureEnabled(!!w.screen_capture_enabled)}catch{}if(I){let R=await fetch(o?"/appstorys-users/load-campaign-data":"https://users.appstorys.com/load-campaign-data",{method:"POST",headers:{"Content-Type":"application/json",...f?{Authorization:`Bearer ${f}`}:{}},body:JSON.stringify({user_id:I})});if(R.ok){let d=await R.json();console.log(`Fetched ${d.length} missing campaigns from fallback`),console.log("Fallback campaigns:",JSON.stringify(d,null,2)),d&&d.length>0&&(g=d)}else console.error("Failed to fetch missing campaigns:",await R.text())}}}catch(f){console.error("Error fetching missing campaigns via fallback:",f)}if(v&&g&&g.length>0){let f=h=>(h||"").trim().toLowerCase(),b=f(v);g=g.filter(h=>!f(h.screen)||f(h.screen)===b)}return await ot.setItem(Fo,JSON.stringify(g)),await ot.setItem(Io,m.toString()),u&&await ot.setItem(Bn,u),{campaigns:g,version:m}}catch(o){console.error("Error fetching campaigns:",o);let i=await ot.getItem(Fo),n=await ot.getItem(Io);return{campaigns:i?JSON.parse(i):[],version:n?parseInt(n):1}}}et();et();et();async function Je(t,e){try{let o=await lt(),i=F.getState();if(!o)return console.error("AppStorys: Access token not found for reconciliation"),!1;let n={anonymous_user_id:t,identified_user_id:e},r=i.baseUrl||"https://users.appstorys.co",s=await fetch(`${r}/reconcile-anonymous-user`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(n)});if(s.ok)return!0;{let a=await s.text();return console.error("AppStorys: Failed to reconcile anonymous user:",s.status,a),!1}}catch(o){return console.error("AppStorys: Error in reconcileAnonymousUser:",o),!1}}et();var Bo=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&&bo()&&this.triggerCampaign()};handlePopState=()=>{bo()&&(window.history.pushState("appstorys_navigation",""),this.triggerCampaign())};triggerCampaign(){let e=F.getState(),{trackedEvents:o}=e;o.includes(Ne)||(console.log("AppStorys: Exit Intent triggered. Displaying campaign."),e.setTrackedEvents([...o,Ne]))}},An=new Bo;et();var Ao=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=F.getState();o.isVisible!==e&&(console.log(`AppStorys: SDK visibility changed to ${e?"visible":"hidden"}`),o.setVisibility(e))}},Eo=new Ao;fe();var Xe="anonymous_user_id";async function En(){let t=Date.now(),e=navigator.userAgent.split(" ")[0].replace(/[^a-zA-Z0-9]/g,"_");return`${t}_${e}`}async function Pn(){try{let t=await ot.getItem(Xe);if(t)return t;let e=await En();return await ot.setItem(Xe,e),e}catch(t){return console.error("Error managing anonymous user ID:",t),await En()}}async function Po(){try{await ot.removeItem(Xe)}catch(t){console.error("Error clearing anonymous user ID:",t)}}async function Lo(){try{return await ot.getItem(Xe)}catch(t){return console.error("Error getting stored anonymous user ID:",t),null}}function rr(){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,10 +30,10 @@
|
|
|
30
30
|
outline: 3px dashed rgba(255,122,24,0.85);
|
|
31
31
|
outline-offset: 6px;
|
|
32
32
|
}
|
|
33
|
-
`,document.head.appendChild(t)}function En(t){let e=document.createElement("div");return e.className="appstorys-widget-debug-pill",e.textContent=t,e}function rr(t){let e=t,o=getComputedStyle(e);(o.position==="static"||!o.position)&&(e.style.position="relative")}window.AppStorysShowWidgetElements=function(){try{ir();let e=Array.from(document.querySelectorAll("[data-as-id], [data-widget], [data-widget-id]"));if(e.length||["#hero_section",".hero_section","#header_container",".header_container"].forEach(i=>{let n=document.querySelector(i);n&&e.push(n)}),!e.length){let o=En("Widget");o.style.position="fixed",o.style.top="12px",o.style.left="12px",o.style.pointerEvents="auto",document.body.appendChild(o);return}e.forEach((o,i)=>{let n=o;rr(n),n.classList.add("appstorys-widget-debug-overlay");let r=n.querySelector(".appstorys-widget-debug-pill");r&&r.remove();let s=En("Widget "+(i+1));n.appendChild(s)})}catch(e){console.error("AppStorysShowWidgetElements error",e)}};var xe=require("react");et();var Ie=require("react"),ye=Ne(require("lottie-react")),_o=require("react/jsx-runtime"),Pn=ye.default?.default??ye.default??ye.Lottie??ye,Mt=({src:t,alt:e,style:o,size:i})=>{let[n,r]=(0,Ie.useState)(null),[s,a]=(0,Ie.useState)(!1);(0,Ie.useEffect)(()=>{t&&t.toLowerCase().endsWith(".json")?fetch(t).then(u=>{if(!u.ok)throw new Error("Failed to fetch Lottie");return u.json()}).then(u=>{r(u),a(!1)}).catch(u=>{console.error("AppStorys: Error loading Lottie thumbnail:",u),a(!0)}):(r(null),a(!1))},[t]);let c={width:i?`${i}px`:o?.width||"100%",height:i?`${i}px`:o?.height||"100%",objectFit:"cover",display:"block",...o};if(n&&!s){let u=Pn.default||Pn;return(0,_o.jsx)(u,{animationData:n,loop:!0,autoplay:!0,style:c})}return(0,_o.jsx)("img",{src:t,alt:e||"story thumbnail",style:c,onError:()=>a(!0)})};var he=require("react/jsx-runtime"),Ln=({story:t,isViewed:e,onClick:o})=>{let i=t.styling||{},n=i.size||80,r=i.ringWidth||3,s=e?"#E5E7EB":t.ringColor||"#FF0000",a=t.nameColor||"#333333",c=i.cornerRadius,u=c?`${c.topLeft||0}px ${c.topRight||0}px ${c.bottomRight||0}px ${c.bottomLeft||0}px`:"50%",x=c?`${Math.max(0,(c.topLeft||0)-3)}px ${Math.max(0,(c.topRight||0)-3)}px ${Math.max(0,(c.bottomRight||0)-3)}px ${Math.max(0,(c.bottomLeft||0)-3)}px`:"50%";return(0,he.jsxs)("div",{onClick:o,style:{display:"flex",flexDirection:"column",alignItems:"center",cursor:"pointer",flexShrink:0},children:[(0,he.jsx)("div",{style:{width:`${n}px`,height:`${n}px`,borderRadius:u,border:`${r}px solid ${s}`,padding:"3px",boxSizing:"border-box",transition:"transform 0.1s ease",overflow:"hidden",backgroundColor:"#f5f5f5"},children:(0,he.jsx)(Mt,{src:t.thumbnail,alt:t.name,style:{borderRadius:x}})}),(0,he.jsx)("span",{style:{marginTop:"6px",fontSize:`${i.name?.size||12}px`,fontFamily:dt(i.name?.fontFamily)||"sans-serif",fontWeight:i.name?.font==="Bold"?"bold":"normal",color:a,maxWidth:`${n+10}px`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name})]})};var $o=require("react/jsx-runtime"),Dn=({stories:t,viewedStories:e,onStoryClick:o})=>(0,$o.jsx)("div",{style:{display:"flex",gap:"18px",padding:"16px 20px",overflowX:"auto",WebkitOverflowScrolling:"touch",justifyContent:"flex-start"},children:t.sort((i,n)=>i.order-n.order).map((i,n)=>(0,$o.jsx)(Ln,{story:i,isViewed:e.includes(i.id),onClick:()=>o(n)},i.id))});var it=Ne(require("react"));et();var ie=require("react/jsx-runtime"),_n=({data:t,onInteraction:e,isEditing:o=!1})=>{let i=t.layout?.type==="horizontal",n={headerTextColor:"#000000",optionBgColor:"#1A1A1A",optionTextColor:"#FFFFFF",backgroundColor:"#FFFFFF",borderRadius:24,padding:20},r=t.styling||{},s={backgroundColor:r.backgroundColor||n.backgroundColor,borderRadius:`${r.borderRadius??n.borderRadius}px`,overflow:"hidden",boxShadow:r.shadow||"0 12px 24px rgba(0,0,0,0.1)",boxSizing:"border-box",width:"100%",opacity:r.opacity??1,padding:`${r.padding??n.padding}px`,display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},a={color:r.headerTextColor||n.headerTextColor,textAlign:"center",fontWeight:"800",fontSize:`${r.fontSize?r.fontSize+4:20}px`,lineHeight:"1.2",margin:"0",width:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},c={display:"flex",flexDirection:i?"row":"column",gap:"4px",width:"100%",backgroundColor:"#1A1A1A",borderRadius:"12px",overflow:"hidden",padding:"2px"},u={backgroundColor:r.optionBgColor||"transparent",color:r.optionTextColor||n.optionTextColor,padding:i?"14px 10px":"16px 20px",fontSize:`${r.fontSize?r.fontSize+1:16}px`,fontWeight:"700",cursor:"pointer",border:"none",width:"100%",textAlign:"center",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.2s",flex:1,borderRight:i?"1px solid rgba(255,255,255,0.1)":"none",borderBottom:i?"none":"1px solid rgba(255,255,255,0.1)"},x=g=>{o||e?.({type:"poll",pollId:t.id,optionId:g,stickerId:t.id})},m=Array.isArray(t.options)?t.options:[];return(0,ie.jsxs)("div",{style:s,children:[(0,ie.jsx)("h3",{style:a,children:t.question||"Ask A Question..."}),(0,ie.jsx)("div",{style:c,children:m.map((g,v)=>(0,ie.jsxs)("button",{style:{...u,borderRight:i&&v===m.length-1?"none":u.borderRight,borderBottom:!i&&v===m.length-1?"none":u.borderBottom},onClick:()=>x(g.id),onMouseOver:f=>{o||(f.currentTarget.style.backgroundColor="rgba(255,255,255,0.1)")},onMouseOut:f=>{o||(f.currentTarget.style.backgroundColor=r.optionBgColor||"transparent")},children:[g.text,g.percentage!==void 0&&(0,ie.jsxs)("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"8px"},children:[g.percentage,"%"]})]},g.id))})]})};var $n=require("react"),Jt=require("react/jsx-runtime"),Wn=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=(0,$n.useState)(null),r={backgroundColor:"#FFFFFF",borderRadius:20,padding:16,questionTextColor:"#FFFFFF",questionBgColor:"#000000",optionBgColor:"#FFFFFF",optionTextColor:"#2B2B2B",borderColor:"#E5E7EB",activeColor:"#10b981",incorrectColor:"#ef4444",labelBgColor:"#FFFFFF",labelTextColor:"#111111",labelBorderColor:"#111111"},s=t.styling||{},a=s.padding??r.padding,c=s.fontSize?s.fontSize+6:22,u=s.optionFontSize||17,x=s.optionBorderRadius||14,m=s.borderColor||r.borderColor,g=Math.min(Math.max(Math.round(u*2.1),18),32),v={backgroundColor:s.backgroundColor||r.backgroundColor,borderRadius:`${s.borderRadius??r.borderRadius}px`,padding:`${a}px`,paddingTop:0,boxShadow:s.shadow||"0 10px 30px rgba(0,0,0,0.12)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",overflow:"hidden",opacity:s.opacity??1},f={color:s.questionTextColor||r.questionTextColor,backgroundColor:s.questionBgColor||r.questionBgColor,fontWeight:"900",fontSize:`${c}px`,lineHeight:1.25,margin:`0 -${a}px 16px -${a}px`,textAlign:"center",padding:`24px ${a}px`,borderTopLeftRadius:`${s.borderRadius??r.borderRadius}px`,borderTopRightRadius:`${s.borderRadius??r.borderRadius}px`,letterSpacing:"-0.01em"},b={backgroundColor:s.optionBgColor||r.optionBgColor,color:s.optionTextColor||r.optionTextColor,padding:`${s.optionPadding||Math.max(a*.7,10)}px ${Math.max(a*.8,12)}px`,borderRadius:`${x}px`,border:`1px solid ${m}`,display:"flex",alignItems:"center",gap:`${Math.max(Math.round(g*.45),8)}px`,cursor:i?"default":"pointer",width:"100%",textAlign:"left",boxSizing:"border-box",transition:"all 0.2s ease",boxShadow:"0 1px 2px rgba(15,23,42,0.03)"},h={width:`${g}px`,height:`${g}px`,minWidth:`${g}px`,borderRadius:"50%",backgroundColor:s.labelBgColor||r.labelBgColor,color:s.labelTextColor||r.labelTextColor,border:`${Math.max(Math.round(g*.08),1)}px solid ${s.labelBorderColor||r.labelBorderColor}`,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"700",fontSize:`${Math.max(Math.round(g*.46),10)}px`},y={backgroundColor:s.backgroundColor||r.backgroundColor,borderRadius:`0 0 ${s.borderRadius??r.borderRadius}px ${s.borderRadius??r.borderRadius}px`,display:"flex",flexDirection:"column",gap:`${Math.max(a*.55,8)}px`},w=R=>{o||i||(n(R),e?.({type:"quiz",quizId:t.id,optionId:R,stickerId:t.id}))},I=["A","B","C","D","E","F"],B=Array.isArray(t.options)?t.options:[];return B.length===0&&!o&&console.warn("AppStorys: QuizSticker has no options!",t.id),(0,Jt.jsxs)("div",{style:{...v,background:s.backgroundColor||r.backgroundColor},children:[t.question&&(0,Jt.jsx)("h3",{style:f,children:t.question}),(0,Jt.jsx)("div",{style:{...y,background:"transparent"},children:B.map((R,d)=>{let T=R.label||I[d]||"\u2022",l=R.id===i,p=R.isCorrect===!0,O={...b},A={...h};return i&&(p?(O.backgroundColor=s.activeColor||r.activeColor,O.borderColor=s.activeColor||r.activeColor,O.color="#FFFFFF"):l&&(O.backgroundColor=s.incorrectColor||r.incorrectColor,O.borderColor=s.incorrectColor||r.incorrectColor,O.color="#FFFFFF")),(0,Jt.jsxs)("button",{style:O,onClick:()=>w(R.id),disabled:!!i,children:[(0,Jt.jsx)("div",{style:h,className:"letter-circle",children:T}),(0,Jt.jsx)("span",{style:{fontWeight:"600",fontSize:`${u}px`},children:R.text})]},R.id)})})]})};var Ze=require("react"),Rt=require("react/jsx-runtime"),Mn=({data:t})=>{let[e,o]=(0,Ze.useState)({days:"00",hours:"00",minutes:"00",seconds:"00"});(0,Ze.useEffect)(()=>{if(!t.targetDate)return;let T=()=>{let p=+new Date(t.targetDate)-+new Date;if(p>0){let O=Math.floor(p/864e5),A=Math.floor(p/(1e3*60*60)%24),_=Math.floor(p/1e3/60%60),C=Math.floor(p/1e3%60);o({days:O.toString().padStart(2,"0"),hours:A.toString().padStart(2,"0"),minutes:_.toString().padStart(2,"0"),seconds:C.toString().padStart(2,"0")})}else o({days:"00",hours:"00",minutes:"00",seconds:"00"})},l=setInterval(T,1e3);return T(),()=>clearInterval(l)},[t.targetDate]);let i=t.styling||{},n=t.display||{showDays:!0,showHours:!0,showMinutes:!0,showSeconds:!0},r=Number(i.digitSize||18),s=!isNaN(r)&&r>0?r:18,a=typeof i.labelFontSize<"u"?Number(i.labelFontSize):Math.max(10,Math.round(s*.55)),c=Math.max(30,Math.round(s*1.8)),u=Math.max(24,Math.round(s*1.3)),x=Math.max(6,Math.round(s*.35)),m=Math.max(6,Math.round(s*.25)),g={backgroundColor:i.backgroundColor||"#FFFFFF",borderRadius:`${i.borderRadius!==void 0?i.borderRadius:16}px`,padding:`${i.padding!==void 0?i.padding:16}px`,boxShadow:i.shadow||"0 10px 30px rgba(0,0,0,0.08)",width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",border:i.borderColor?`1px solid ${i.borderColor}`:"none",overflow:"hidden",opacity:i.opacity??1},v={color:i.titleColor||"#000000",fontWeight:"700",fontSize:`${i.fontSize?i.fontSize:14}px`,width:"100%",textAlign:"center",marginBottom:"4px"},f={display:"flex",gap:`${m}px`,width:"100%",justifyContent:"center",alignItems:"center",flexWrap:"nowrap"},b={display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},h={display:"flex",gap:"2px"},y={backgroundColor:i.digitBackground||"#F1F3F5",borderRadius:`${x}px`,minWidth:`${u}px`,height:`${c}px`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${s}px`,fontWeight:"bold",color:i.digitColor||"#1A202C",padding:"0 4px"},w={fontSize:`${Math.max(9,a)}px`,color:i.labelColor||"#A0AEC0",fontWeight:"600",textTransform:"lowercase"},I={fontSize:`${Math.max(14,Math.round(s*.9))}px`,fontWeight:"700",color:i.labelColor||"#A0AEC0",display:"flex",alignItems:"center",lineHeight:1},B=(T,l)=>(0,Rt.jsxs)("div",{style:b,children:[(0,Rt.jsx)("div",{style:h,children:T.split("").map((p,O)=>(0,Rt.jsx)("div",{style:y,children:p},O))}),(0,Rt.jsx)("span",{style:w,children:l})]}),R=[],d=0;return n.showDays!==!1&&(R.push(B(e.days,"days")),d++),n.showHours!==!1&&(d>0&&R.push((0,Rt.jsx)("div",{style:I,children:":"},"sep-h")),R.push(B(e.hours,"hours")),d++),n.showMinutes!==!1&&(d>0&&R.push((0,Rt.jsx)("div",{style:I,children:":"},"sep-m")),R.push(B(e.minutes,"min")),d++),n.showSeconds!==!1&&(d>0&&R.push((0,Rt.jsx)("div",{style:I,children:":"},"sep-s")),R.push(B(e.seconds,"sec")),d++),(0,Rt.jsxs)("div",{style:g,children:[t.title&&(0,Rt.jsx)("div",{style:v,children:t.title}),(0,Rt.jsx)("div",{style:f,children:R})]})};var On=require("react"),Tt=require("react/jsx-runtime"),jn=({data:t,onInteraction:e})=>{let[o,i]=(0,On.useState)(!1),n=()=>{t.code&&(navigator.clipboard.writeText(t.code).catch(()=>{}),i(!0),e?.({type:"promo_code",value:"copied",stickerId:t.id,code:t.code}),setTimeout(()=>i(!1),2e3))},r=t.styling||{},s={backgroundColor:r.backgroundColor||"#FFFFFF",padding:"12px 18px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",height:"60px",boxSizing:"border-box",position:"relative",filter:"drop-shadow(0 8px 16px rgba(0,0,0,0.1))",cursor:"pointer",clipPath:"polygon(0% 0%, 0% 40%, 4% 50%, 0% 60%, 0% 100%, 100% 100%, 100% 60%, 96% 50%, 100% 40%, 100% 0%)",backgroundImage:`
|
|
33
|
+
`,document.head.appendChild(t)}function Ln(t){let e=document.createElement("div");return e.className="appstorys-widget-debug-pill",e.textContent=t,e}function sr(t){let e=t,o=getComputedStyle(e);(o.position==="static"||!o.position)&&(e.style.position="relative")}window.AppStorysShowWidgetElements=function(){try{rr();let e=Array.from(document.querySelectorAll("[data-as-id], [data-widget], [data-widget-id]"));if(e.length||["#hero_section",".hero_section","#header_container",".header_container"].forEach(i=>{let n=document.querySelector(i);n&&e.push(n)}),!e.length){let o=Ln("Widget");o.style.position="fixed",o.style.top="12px",o.style.left="12px",o.style.pointerEvents="auto",document.body.appendChild(o);return}e.forEach((o,i)=>{let n=o;sr(n),n.classList.add("appstorys-widget-debug-overlay");let r=n.querySelector(".appstorys-widget-debug-pill");r&&r.remove();let s=Ln("Widget "+(i+1));n.appendChild(s)})}catch(e){console.error("AppStorysShowWidgetElements error",e)}};var xe=require("react");et();var Fe=require("react"),he=je(require("lottie-react")),Do=require("react/jsx-runtime"),Dn=he.default?.default??he.default??he.Lottie??he,jt=({src:t,alt:e,style:o,size:i})=>{let[n,r]=(0,Fe.useState)(null),[s,a]=(0,Fe.useState)(!1);(0,Fe.useEffect)(()=>{t&&t.toLowerCase().endsWith(".json")?fetch(t).then(u=>{if(!u.ok)throw new Error("Failed to fetch Lottie");return u.json()}).then(u=>{r(u),a(!1)}).catch(u=>{console.error("AppStorys: Error loading Lottie thumbnail:",u),a(!0)}):(r(null),a(!1))},[t]);let c={width:i?`${i}px`:o?.width||"100%",height:i?`${i}px`:o?.height||"100%",objectFit:"cover",display:"block",...o};if(n&&!s){let u=Dn.default||Dn;return(0,Do.jsx)(u,{animationData:n,loop:!0,autoplay:!0,style:c})}return(0,Do.jsx)("img",{src:t,alt:e||"story thumbnail",style:c,onError:()=>a(!0)})};var be=require("react/jsx-runtime"),_n=({story:t,isViewed:e,onClick:o})=>{let i=t.styling||{},n=i.size||80,r=i.ringWidth||3,s=e?"#E5E7EB":t.ringColor||"#FF0000",a=t.nameColor||"#333333",c=i.cornerRadius,u=c?`${c.topLeft||0}px ${c.topRight||0}px ${c.bottomRight||0}px ${c.bottomLeft||0}px`:"50%",x=c?`${Math.max(0,(c.topLeft||0)-3)}px ${Math.max(0,(c.topRight||0)-3)}px ${Math.max(0,(c.bottomRight||0)-3)}px ${Math.max(0,(c.bottomLeft||0)-3)}px`:"50%";return(0,be.jsxs)("div",{onClick:o,style:{display:"flex",flexDirection:"column",alignItems:"center",cursor:"pointer",flexShrink:0},children:[(0,be.jsx)("div",{style:{width:`${n}px`,height:`${n}px`,borderRadius:u,border:`${r}px solid ${s}`,padding:"3px",boxSizing:"border-box",transition:"transform 0.1s ease",overflow:"hidden",backgroundColor:"#f5f5f5"},children:(0,be.jsx)(jt,{src:t.thumbnail,alt:t.name,style:{borderRadius:x}})}),(0,be.jsx)("span",{style:{marginTop:"6px",fontSize:`${i.name?.size||12}px`,fontFamily:dt(i.name?.fontFamily)||"sans-serif",fontWeight:i.name?.font==="Bold"?"bold":"normal",color:a,maxWidth:`${n+10}px`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name})]})};var _o=require("react/jsx-runtime"),$n=({stories:t,viewedStories:e,onStoryClick:o})=>(0,_o.jsx)("div",{style:{display:"flex",gap:"18px",padding:"16px 20px",overflowX:"auto",WebkitOverflowScrolling:"touch",justifyContent:"flex-start"},children:t.sort((i,n)=>i.order-n.order).map((i,n)=>(0,_o.jsx)(_n,{story:i,isViewed:e.includes(i.id),onClick:()=>o(n)},i.id))});var it=je(require("react"));et();var re=require("react/jsx-runtime"),Wn=({data:t,onInteraction:e,isEditing:o=!1})=>{let i=t.layout?.type==="horizontal",n={headerTextColor:"#000000",optionBgColor:"#1A1A1A",optionTextColor:"#FFFFFF",backgroundColor:"#FFFFFF",borderRadius:24,padding:20},r=t.styling||{},s={backgroundColor:r.backgroundColor||n.backgroundColor,borderRadius:`${r.borderRadius??n.borderRadius}px`,overflow:"hidden",boxShadow:r.shadow||"0 12px 24px rgba(0,0,0,0.1)",boxSizing:"border-box",width:"100%",opacity:r.opacity??1,padding:`${r.padding??n.padding}px`,display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},a={color:r.headerTextColor||n.headerTextColor,textAlign:"center",fontWeight:"800",fontSize:`${r.fontSize?r.fontSize+4:20}px`,lineHeight:"1.2",margin:"0",width:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},c={display:"flex",flexDirection:i?"row":"column",gap:"4px",width:"100%",backgroundColor:"#1A1A1A",borderRadius:"12px",overflow:"hidden",padding:"2px"},u={backgroundColor:r.optionBgColor||"transparent",color:r.optionTextColor||n.optionTextColor,padding:i?"14px 10px":"16px 20px",fontSize:`${r.fontSize?r.fontSize+1:16}px`,fontWeight:"700",cursor:"pointer",border:"none",width:"100%",textAlign:"center",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.2s",flex:1,borderRight:i?"1px solid rgba(255,255,255,0.1)":"none",borderBottom:i?"none":"1px solid rgba(255,255,255,0.1)"},x=g=>{o||e?.({type:"poll",pollId:t.id,optionId:g,stickerId:t.id})},m=Array.isArray(t.options)?t.options:[];return(0,re.jsxs)("div",{style:s,children:[(0,re.jsx)("h3",{style:a,children:t.question||"Ask A Question..."}),(0,re.jsx)("div",{style:c,children:m.map((g,v)=>(0,re.jsxs)("button",{style:{...u,borderRight:i&&v===m.length-1?"none":u.borderRight,borderBottom:!i&&v===m.length-1?"none":u.borderBottom},onClick:()=>x(g.id),onMouseOver:f=>{o||(f.currentTarget.style.backgroundColor="rgba(255,255,255,0.1)")},onMouseOut:f=>{o||(f.currentTarget.style.backgroundColor=r.optionBgColor||"transparent")},children:[g.text,g.percentage!==void 0&&(0,re.jsxs)("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"8px"},children:[g.percentage,"%"]})]},g.id))})]})};var Mn=require("react"),Xt=require("react/jsx-runtime"),On=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=(0,Mn.useState)(null),r={backgroundColor:"#FFFFFF",borderRadius:20,padding:16,questionTextColor:"#FFFFFF",questionBgColor:"#000000",optionBgColor:"#FFFFFF",optionTextColor:"#2B2B2B",borderColor:"#E5E7EB",activeColor:"#10b981",incorrectColor:"#ef4444",labelBgColor:"#FFFFFF",labelTextColor:"#111111",labelBorderColor:"#111111"},s=t.styling||{},a=s.padding??r.padding,c=s.fontSize?s.fontSize+6:22,u=s.optionFontSize||17,x=s.optionBorderRadius||14,m=s.borderColor||r.borderColor,g=Math.min(Math.max(Math.round(u*2.1),18),32),v={backgroundColor:s.backgroundColor||r.backgroundColor,borderRadius:`${s.borderRadius??r.borderRadius}px`,padding:`${a}px`,paddingTop:0,boxShadow:s.shadow||"0 10px 30px rgba(0,0,0,0.12)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",overflow:"hidden",opacity:s.opacity??1},f={color:s.questionTextColor||r.questionTextColor,backgroundColor:s.questionBgColor||r.questionBgColor,fontWeight:"900",fontSize:`${c}px`,lineHeight:1.25,margin:`0 -${a}px 16px -${a}px`,textAlign:"center",padding:`24px ${a}px`,borderTopLeftRadius:`${s.borderRadius??r.borderRadius}px`,borderTopRightRadius:`${s.borderRadius??r.borderRadius}px`,letterSpacing:"-0.01em"},b={backgroundColor:s.optionBgColor||r.optionBgColor,color:s.optionTextColor||r.optionTextColor,padding:`${s.optionPadding||Math.max(a*.7,10)}px ${Math.max(a*.8,12)}px`,borderRadius:`${x}px`,border:`1px solid ${m}`,display:"flex",alignItems:"center",gap:`${Math.max(Math.round(g*.45),8)}px`,cursor:i?"default":"pointer",width:"100%",textAlign:"left",boxSizing:"border-box",transition:"all 0.2s ease",boxShadow:"0 1px 2px rgba(15,23,42,0.03)"},h={width:`${g}px`,height:`${g}px`,minWidth:`${g}px`,borderRadius:"50%",backgroundColor:s.labelBgColor||r.labelBgColor,color:s.labelTextColor||r.labelTextColor,border:`${Math.max(Math.round(g*.08),1)}px solid ${s.labelBorderColor||r.labelBorderColor}`,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"700",fontSize:`${Math.max(Math.round(g*.46),10)}px`},y={backgroundColor:s.backgroundColor||r.backgroundColor,borderRadius:`0 0 ${s.borderRadius??r.borderRadius}px ${s.borderRadius??r.borderRadius}px`,display:"flex",flexDirection:"column",gap:`${Math.max(a*.55,8)}px`},w=R=>{o||i||(n(R),e?.({type:"quiz",quizId:t.id,optionId:R,stickerId:t.id}))},I=["A","B","C","D","E","F"],B=Array.isArray(t.options)?t.options:[];return B.length===0&&!o&&console.warn("AppStorys: QuizSticker has no options!",t.id),(0,Xt.jsxs)("div",{style:{...v,background:s.backgroundColor||r.backgroundColor},children:[t.question&&(0,Xt.jsx)("h3",{style:f,children:t.question}),(0,Xt.jsx)("div",{style:{...y,background:"transparent"},children:B.map((R,d)=>{let T=R.label||I[d]||"\u2022",l=R.id===i,p=R.isCorrect===!0,O={...b},A={...h};return i&&(p?(O.backgroundColor=s.activeColor||r.activeColor,O.borderColor=s.activeColor||r.activeColor,O.color="#FFFFFF"):l&&(O.backgroundColor=s.incorrectColor||r.incorrectColor,O.borderColor=s.incorrectColor||r.incorrectColor,O.color="#FFFFFF")),(0,Xt.jsxs)("button",{style:O,onClick:()=>w(R.id),disabled:!!i,children:[(0,Xt.jsx)("div",{style:h,className:"letter-circle",children:T}),(0,Xt.jsx)("span",{style:{fontWeight:"600",fontSize:`${u}px`},children:R.text})]},R.id)})})]})};var Ke=require("react"),Tt=require("react/jsx-runtime"),jn=({data:t})=>{let[e,o]=(0,Ke.useState)({days:"00",hours:"00",minutes:"00",seconds:"00"});(0,Ke.useEffect)(()=>{if(!t.targetDate)return;let T=()=>{let p=+new Date(t.targetDate)-+new Date;if(p>0){let O=Math.floor(p/864e5),A=Math.floor(p/(1e3*60*60)%24),_=Math.floor(p/1e3/60%60),C=Math.floor(p/1e3%60);o({days:O.toString().padStart(2,"0"),hours:A.toString().padStart(2,"0"),minutes:_.toString().padStart(2,"0"),seconds:C.toString().padStart(2,"0")})}else o({days:"00",hours:"00",minutes:"00",seconds:"00"})},l=setInterval(T,1e3);return T(),()=>clearInterval(l)},[t.targetDate]);let i=t.styling||{},n=t.display||{showDays:!0,showHours:!0,showMinutes:!0,showSeconds:!0},r=Number(i.digitSize||18),s=!isNaN(r)&&r>0?r:18,a=typeof i.labelFontSize<"u"?Number(i.labelFontSize):Math.max(10,Math.round(s*.55)),c=Math.max(30,Math.round(s*1.8)),u=Math.max(24,Math.round(s*1.3)),x=Math.max(6,Math.round(s*.35)),m=Math.max(6,Math.round(s*.25)),g={backgroundColor:i.backgroundColor||"#FFFFFF",borderRadius:`${i.borderRadius!==void 0?i.borderRadius:16}px`,padding:`${i.padding!==void 0?i.padding:16}px`,boxShadow:i.shadow||"0 10px 30px rgba(0,0,0,0.08)",width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",border:i.borderColor?`1px solid ${i.borderColor}`:"none",overflow:"hidden",opacity:i.opacity??1},v={color:i.titleColor||"#000000",fontWeight:"700",fontSize:`${i.fontSize?i.fontSize:14}px`,width:"100%",textAlign:"center",marginBottom:"4px"},f={display:"flex",gap:`${m}px`,width:"100%",justifyContent:"center",alignItems:"center",flexWrap:"nowrap"},b={display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},h={display:"flex",gap:"2px"},y={backgroundColor:i.digitBackground||"#F1F3F5",borderRadius:`${x}px`,minWidth:`${u}px`,height:`${c}px`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${s}px`,fontWeight:"bold",color:i.digitColor||"#1A202C",padding:"0 4px"},w={fontSize:`${Math.max(9,a)}px`,color:i.labelColor||"#A0AEC0",fontWeight:"600",textTransform:"lowercase"},I={fontSize:`${Math.max(14,Math.round(s*.9))}px`,fontWeight:"700",color:i.labelColor||"#A0AEC0",display:"flex",alignItems:"center",lineHeight:1},B=(T,l)=>(0,Tt.jsxs)("div",{style:b,children:[(0,Tt.jsx)("div",{style:h,children:T.split("").map((p,O)=>(0,Tt.jsx)("div",{style:y,children:p},O))}),(0,Tt.jsx)("span",{style:w,children:l})]}),R=[],d=0;return n.showDays!==!1&&(R.push(B(e.days,"days")),d++),n.showHours!==!1&&(d>0&&R.push((0,Tt.jsx)("div",{style:I,children:":"},"sep-h")),R.push(B(e.hours,"hours")),d++),n.showMinutes!==!1&&(d>0&&R.push((0,Tt.jsx)("div",{style:I,children:":"},"sep-m")),R.push(B(e.minutes,"min")),d++),n.showSeconds!==!1&&(d>0&&R.push((0,Tt.jsx)("div",{style:I,children:":"},"sep-s")),R.push(B(e.seconds,"sec")),d++),(0,Tt.jsxs)("div",{style:g,children:[t.title&&(0,Tt.jsx)("div",{style:v,children:t.title}),(0,Tt.jsx)("div",{style:f,children:R})]})};var Nn=require("react"),Ft=require("react/jsx-runtime"),qn=({data:t,onInteraction:e})=>{let[o,i]=(0,Nn.useState)(!1),n=()=>{t.code&&(navigator.clipboard.writeText(t.code).catch(()=>{}),i(!0),e?.({type:"promo_code",value:"copied",stickerId:t.id,code:t.code}),setTimeout(()=>i(!1),2e3))},r=t.styling||{},s={backgroundColor:r.backgroundColor||"#FFFFFF",padding:"12px 18px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",height:"60px",boxSizing:"border-box",position:"relative",filter:"drop-shadow(0 8px 16px rgba(0,0,0,0.1))",cursor:"pointer",clipPath:"polygon(0% 0%, 0% 40%, 4% 50%, 0% 60%, 0% 100%, 100% 100%, 100% 60%, 96% 50%, 100% 40%, 100% 0%)",backgroundImage:`
|
|
34
34
|
radial-gradient(circle at 0px 30px, transparent 8px, white 8.5px),
|
|
35
35
|
radial-gradient(circle at 100% 30px, transparent 8px, white 8.5px)
|
|
36
|
-
`,backgroundPosition:"0 0, 100% 0",backgroundSize:"100% 100%",backgroundRepeat:"no-repeat"},a={width:"36px",height:"36px",borderRadius:"8px",backgroundColor:"#F1F3F5",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"18px",fontWeight:"800",color:"#2D3748",border:"1px solid #E2E8F0"},c={fontSize:`${r.fontSize||18}px`,fontWeight:"800",color:"#1A202C",letterSpacing:"1px",flex:1,textAlign:"center"};return(0,Tt.jsxs)("div",{style:s,onClick:n,children:[(0,Tt.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[(0,Tt.jsx)("div",{style:a,children:"%"}),(0,Tt.jsx)("span",{style:c,children:t.code||"OFFER20"})]}),(0,Tt.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[o&&(0,Tt.jsx)("span",{style:{fontSize:"11px",color:"#10B981",fontWeight:"700"},children:"Copied!"}),(0,Tt.jsx)("div",{style:{padding:"8px",display:"flex",alignItems:"center"},children:(0,Tt.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#4A5568",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Tt.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,Tt.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]})};var Wo=require("react/jsx-runtime"),Nn=({data:t,onInteraction:e,isEditing:o=!1})=>{let i={emojis:["\u{1F60D}","\u{1F44D}"]},n=Array.isArray(t.emojis)?t.emojis:Array.isArray(i.emojis)?i.emojis:[],r=c=>{o||e?.({type:"reaction",reactionId:t.id,emoji:c,stickerId:t.id})},s={display:"flex",gap:"20px",justifyContent:"center",alignItems:"center",width:"100%",padding:"12px"},a={backgroundColor:"#FFFFFF",width:"64px",height:"64px",borderRadius:"100px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 8px 30px rgba(0,0,0,0.12)",fontSize:"32px",cursor:o?"default":"pointer",transition:"all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)",border:"none",outline:"none",padding:0,position:"relative",zIndex:1};return(0,Wo.jsx)("div",{style:s,children:n.map((c,u)=>(0,Wo.jsx)("button",{style:a,onClick:()=>r(c),onMouseOver:x=>{o||(x.currentTarget.style.transform="scale(1.15) translateY(-4px)")},onMouseOut:x=>{o||(x.currentTarget.style.transform="scale(1) translateY(0)")},children:c},u))})};var se=require("react"),re=require("react/jsx-runtime"),qn=({data:t,onInteraction:e,isEditing:o=!1})=>{let i=t.maxRating||5,n=t.currentRating??Math.floor(i/2),[r,s]=(0,se.useState)(n),a=(0,se.useRef)(null),[c,u]=(0,se.useState)(!1),x={backgroundColor:"#FFFFFF",borderRadius:36,padding:24,titleColor:"#000000",titleFontSize:24,sliderTrackColor:"#F3F4F6",sliderFillColor:"#F97316",emojiSize:42},m=t.styling||{},g={backgroundColor:m.backgroundColor||x.backgroundColor,borderRadius:`${m.borderRadius??x.borderRadius}px`,padding:`${m.padding??x.padding}px`,boxShadow:m.shadow||"0 12px 30px rgba(0,0,0,0.08)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",cursor:"default",opacity:m.opacity??1},v={color:m.titleColor||x.titleColor,fontWeight:"900",fontSize:`${m.titleFontSize||x.titleFontSize}px`,margin:"0",textAlign:"center",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:"100%"},f={width:"100%",height:"18px",backgroundColor:m.sliderTrackColor||x.sliderTrackColor,borderRadius:"100px",position:"relative",cursor:o?"default":"pointer",marginTop:"24px",marginBottom:"8px",userSelect:"none"},b=r/i*100,h={width:`${b}%`,height:"100%",background:m.sliderFillColor||"linear-gradient(90deg, #FF4582, #e11d48)",borderRadius:"100px",transition:c?"none":"width 0.1s ease"},y=m.emojiSize||x.emojiSize,w={position:"absolute",left:`calc(${b}% - ${y/2}px)`,top:`-${y/4}px`,fontSize:`${y}px`,userSelect:"none",cursor:"grab",transition:c?"none":"left 0.1s ease",filter:"drop-shadow(0 4px 8px rgba(0,0,0,0.2))"},I=d=>{if(!a.current||o)return;let T=a.current.getBoundingClientRect(),l=d-T.left;l<0&&(l=0),l>T.width&&(l=T.width);let p=l/T.width,O=Math.round(p*i*10)/10;s(O)},B=d=>{o||(u(!0),I(d.clientX))},R=d=>{o||(u(!0),I(d.touches[0].clientX))};return(0,se.useEffect)(()=>{let d=p=>{c&&I(p.clientX)},T=()=>{c&&(u(!1),e?.({type:"rating",ratingId:t.id,value:r,stickerId:t.id}))},l=p=>{c&&I(p.touches[0].clientX)};return c&&(window.addEventListener("mousemove",d),window.addEventListener("mouseup",T),window.addEventListener("touchmove",l),window.addEventListener("touchend",T)),()=>{window.removeEventListener("mousemove",d),window.removeEventListener("mouseup",T),window.removeEventListener("touchmove",l),window.removeEventListener("touchend",T)}},[c,r]),(0,re.jsxs)("div",{style:g,children:[(0,re.jsx)("h3",{style:v,children:t.title||"Do you like my space?"}),(0,re.jsxs)("div",{ref:a,style:f,onMouseDown:B,onTouchStart:R,children:[(0,re.jsx)("div",{style:h}),(0,re.jsx)("div",{style:w,className:"interactive-emoji-thumb",children:t.emoji||"\u{1F60D}"})]})]})};var Un=require("react"),Ot=require("react/jsx-runtime"),Hn=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=(0,Un.useState)(""),r={backgroundColor:"#FFFFFF",borderRadius:16,padding:16,promptColor:"#111111",inputBgColor:"#FFFFFF",borderColor:"#EFEFEF",textColor:"#333333",placeholderColor:"#A0AEC0"},s=t.styling||{},a={backgroundColor:s.backgroundColor||r.backgroundColor,borderRadius:`${s.borderRadius??r.borderRadius}px`,padding:`${s.padding??r.padding}px`,boxShadow:s.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",border:`1px solid ${s.borderColor||"#F0F0F0"}`},c={color:s.promptColor||r.promptColor,fontWeight:"700",fontSize:`${s.fontSize?s.fontSize+2:16}px`,textAlign:"center",marginBottom:"2px",width:"100%"},u={width:"100%",position:"relative",display:"flex",alignItems:"center"},x={backgroundColor:s.inputBgColor||"#F1F3F5",border:"none",borderRadius:"30px",padding:"14px 45px 14px 20px",width:"100%",boxSizing:"border-box",color:s.inputTextColor||"#1A202C",fontSize:`${s.fontSize||14}px`,outline:"none",textAlign:"left",cursor:o?"default":"text",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},m={position:"absolute",right:"10px",background:s.submitBackground||"#FE6B35",color:"white",border:"none",borderRadius:"50%",width:"32px",height:"32px",display:i.length>0?"flex":"none",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"transform 0.2s"},g=f=>{o||n(f.target.value)},v=()=>{o||!i.trim()||(e?.({type:"question",questionId:t.id,value:i.trim(),stickerId:t.id}),n(""))};return(0,Ot.jsxs)("div",{style:a,children:[(0,Ot.jsx)("div",{style:c,children:t.question||"Ask me anything"}),(0,Ot.jsxs)("div",{style:u,children:[(0,Ot.jsx)("input",{type:"text",value:i,placeholder:t.placeholder||"Type your answer...",style:x,disabled:o,onChange:g,onKeyDown:f=>f.key==="Enter"&&v()}),(0,Ot.jsx)("button",{style:m,onClick:v,children:(0,Ot.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Ot.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,Ot.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})};var Vn=require("react"),jt=require("react/jsx-runtime"),Yn=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=(0,Vn.useState)(null),r={backgroundColor:"#FFFFFF",borderRadius:20,padding:16,questionTextColor:"#111111",optionBgColor:"#F7FAFC",optionTextColor:"#2D3748",borderColor:"#E2E8F0",activeColor:"#10B981",incorrectColor:"#EF4444"},s=t.styling||{},a={backgroundColor:s.backgroundColor||r.backgroundColor,borderRadius:`${s.borderRadius??r.borderRadius}px`,padding:`${s.padding??r.padding}px`,boxShadow:s.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",gap:"12px",border:s.borderColor?`1px solid ${s.borderColor}`:"none"},c={color:s.questionTextColor||r.questionTextColor,fontWeight:"800",fontSize:`${s.fontSize?s.fontSize+2:16}px`,margin:"0 0 4px 0",textAlign:"left"},u={display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"12px",width:"100%"},x={backgroundColor:s.optionBgColor||r.optionBgColor,color:s.optionTextColor||r.optionTextColor,borderRadius:"16px",border:`2px solid ${s.borderColor||r.borderColor}`,cursor:i?"default":"pointer",display:"flex",flexDirection:"column",alignItems:"center",padding:"8px",boxSizing:"border-box",transition:"all 0.2s ease",overflow:"hidden"},m=f=>{o||i||(n(f),e?.({type:"image",quizId:t.id,optionId:f,stickerId:t.id}))},g="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",v=Array.isArray(t.options)?t.options:[];return(0,jt.jsxs)("div",{style:a,children:[t.question&&(0,jt.jsx)("h3",{style:c,children:t.question}),(0,jt.jsx)("div",{style:u,children:v.map(f=>{let b=f.id===i,h=f.isCorrect===!0,y={...x};return i&&(h?(y.borderColor=s.activeColor||r.activeColor,y.backgroundColor="rgba(16, 185, 129, 0.05)"):b&&(y.borderColor=s.incorrectColor||r.incorrectColor,y.backgroundColor="rgba(239, 68, 68, 0.05)")),(0,jt.jsxs)("button",{style:y,onClick:()=>m(f.id),disabled:!!i,onMouseOver:w=>{!o&&!i&&(w.currentTarget.style.transform="translateY(-2px)")},onMouseOut:w=>{!o&&!i&&(w.currentTarget.style.transform="translateY(0)")},children:[(0,jt.jsxs)("div",{style:{width:"100%",aspectRatio:"1",borderRadius:"12px",overflow:"hidden",backgroundColor:"#EDF2F7",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"8px",position:"relative"},children:[(0,jt.jsx)("img",{src:f.image||g,alt:f.text,style:{width:"100%",height:"100%",objectFit:"cover"}}),i&&(0,jt.jsx)("div",{style:{position:"absolute",top:"6px",right:"6px",width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:h?r.activeColor:b?r.incorrectColor:"#A0AEC0",color:"#FFFFFF",fontSize:"12px",fontWeight:"bold"},children:h?"\u2713":b?"\u2715":""})]}),(0,jt.jsx)("span",{style:{fontWeight:"600",fontSize:`${s.optionFontSize||13}px`,color:i&&h?r.activeColor:r.optionTextColor,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:f.text})]},f.id)})})]})};var No=require("react");var Xt=require("react"),D=require("react/jsx-runtime"),Zn=({product:t,styling:e,onClose:o,onAddToCart:i})=>{let[n,r]=(0,Xt.useState)(""),[s,a]=(0,Xt.useState)(0),[c,u]=(0,Xt.useState)(1),[x,m]=(0,Xt.useState)(!1),[g,v]=(0,Xt.useState)(!1),f=t.attributes||{},b=f.colors||[],h=f.sizes||[],y=f.imageUrls||[t.image],w=f.description||"";(0,Xt.useEffect)(()=>{h.length>0&&r(h[0]),v(!0)},[h]);let I=()=>{let C={productId:t.productId||t.id,title:t.title,selectedSize:n,selectedColor:b[s]?.name,quantity:c,price:t.price};i(C);let S=t.redirectUrl||t.url;if(S){!S.startsWith("http")&&!S.startsWith("//")&&(S="https://"+S);try{window.open(S,"_blank","noopener,noreferrer")}catch(W){console.error("AppStorys: Redirect failed",W)}}m(!0)},B=()=>{v(!1),setTimeout(o,400)},R=e?.buttonBackground||"#000000",d=e?.buttonTextColor||"#ffffff",T=e?.titleColor||e?.textColor||"#1a1a2e",l=e?.priceColor||e?.textColor||"#1a1a2e",p=e?.mrpColor||"#8b8b98",O=e?.titleFontWeight||"600",A=e?.priceFontWeight||"700",_=e?.mrpFontWeight||"500";return x?(0,D.jsxs)("div",{className:"appstorys-shopable-success-overlay",style:Qn,children:[(0,D.jsx)("div",{className:"appstorys-shopable-backdrop",style:Gn,onClick:B}),(0,D.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...Jn,height:"auto",minHeight:"310px",animation:"appstorys-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[(0,D.jsx)("div",{style:Xn,onClick:B}),(0,D.jsxs)("div",{style:{padding:"0 20px 24px",textAlign:"center"},children:[(0,D.jsxs)("div",{style:{backgroundColor:"#F3F4F6",borderRadius:"20px",padding:"22px",marginTop:"16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[(0,D.jsxs)("h3",{style:{margin:0,fontSize:"16px",fontWeight:"600",lineHeight:"1.4"},children:["Added to your bag",(0,D.jsx)("br",{}),"successfully"]}),(0,D.jsx)("svg",{width:"44",height:"26",viewBox:"0 0 44 26",fill:"none",children:(0,D.jsx)("path",{d:"M4 4C4 4 11 22 22 22C33 22 40 4 40 4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"})})]}),(0,D.jsxs)("div",{style:{marginTop:"24px",display:"flex",flexDirection:"column",gap:"8px"},children:[(0,D.jsx)("button",{onClick:B,style:{...jo,backgroundColor:"#000000",color:"#ffffff",padding:"17px",fontSize:"16px",fontWeight:"600"},children:(0,D.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[(0,D.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,D.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,D.jsx)("path",{d:"M3 6h18"}),(0,D.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),"Go to checkout"]})}),(0,D.jsx)("button",{onClick:B,style:{...jo,backgroundColor:"transparent",color:"#000000",border:"1px solid rgba(0,0,0,0.1)",padding:"15px",fontSize:"16px"},children:"Continue with stories"})]})]})]})]}):(0,D.jsxs)("div",{className:`appstorys-shopable-overlay ${g?"visible":""}`,style:Qn,children:[(0,D.jsx)("div",{className:"appstorys-shopable-backdrop",style:Gn,onClick:B}),(0,D.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...Jn,transform:g?"translateY(0)":"translateY(100%)",opacity:g?1:0},children:[(0,D.jsxs)("div",{style:sr,children:[(0,D.jsx)("div",{style:Xn,onClick:B}),(0,D.jsx)("button",{style:ar,onClick:B,children:(0,D.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,D.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,D.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),(0,D.jsxs)("div",{style:lr,children:[(0,D.jsx)("div",{style:dr,children:y.map((C,S)=>(0,D.jsx)("div",{style:{minWidth:y.length>1?"85%":"100%",aspectRatio:"1.2 / 1",maxHeight:"240px",borderRadius:"16px",overflow:"hidden",backgroundColor:"#F9FAFB"},children:(0,D.jsx)("img",{src:C,alt:t.title,style:{width:"100%",height:"100%",objectFit:"contain"}})},S))}),(0,D.jsxs)("div",{style:{padding:"0 20px 20px"},children:[(0,D.jsx)("h2",{style:{margin:"16px 0 4px",fontSize:e?.titleFontSize?`${e.titleFontSize}px`:"20px",fontWeight:O,color:T,lineHeight:"1.2"},children:t.title}),(0,D.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",marginBottom:"16px"},children:[(0,D.jsx)("span",{style:{fontSize:e?.priceFontSize?`${e.priceFontSize}px`:"18px",fontWeight:A,color:l},children:t.price}),t.oldPrice&&(0,D.jsx)("span",{style:{fontSize:e?.mrpFontSize?`${e.mrpFontSize}px`:"14px",color:p,textDecoration:"line-through",fontWeight:_},children:t.oldPrice})]}),b.length>0&&(0,D.jsxs)("div",{style:Mo,children:[(0,D.jsx)("div",{style:Oo,children:"COLOR"}),(0,D.jsx)("div",{style:{display:"flex",gap:"14px",marginTop:"12px"},children:b.map((C,S)=>(0,D.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"5px"},children:[(0,D.jsx)("button",{onClick:()=>a(S),style:{width:"36px",height:"36px",borderRadius:"50%",border:"none",backgroundColor:C.hex||"#gray",position:"relative",cursor:"pointer",boxShadow:s===S?"0 0 0 2px #fff, 0 0 0 4px #000":"none",transition:"all 0.2s ease"}}),(0,D.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:s===S?"#000":"transparent",transition:"all 0.2s ease"}})]},C.id))})]}),h.length>0&&(0,D.jsxs)("div",{style:Mo,children:[(0,D.jsx)("div",{style:Oo,children:"SIZE"}),(0,D.jsx)("div",{style:{display:"flex",gap:"10px",marginTop:"12px",flexWrap:"wrap"},children:h.map(C=>(0,D.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[(0,D.jsx)("button",{onClick:()=>r(C),style:{minWidth:"42px",height:"42px",borderRadius:"50%",backgroundColor:"transparent",border:`1px solid ${n===C?"#000":"rgba(0,0,0,0.1)"}`,color:n===C?"#000":"#8b8b98",fontSize:"13px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:C}),(0,D.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:n===C?"#000":"transparent",transition:"all 0.2s ease"}})]},C))})]}),w&&(0,D.jsxs)("div",{style:Mo,children:[(0,D.jsx)("div",{style:Oo,children:"DESCRIPTION"}),(0,D.jsx)("p",{style:{margin:"8px 0 0",fontSize:"14px",lineHeight:"1.5",color:"#8b8b98",wordBreak:"break-word"},children:w})]})]})]}),(0,D.jsxs)("div",{style:cr,children:[(0,D.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1px",minWidth:"75px"},children:[(0,D.jsx)("div",{style:{fontSize:"15px",fontWeight:A,color:l},children:t.price}),t.oldPrice&&(0,D.jsx)("div",{style:{fontSize:"11px",color:p,textDecoration:"line-through",fontWeight:_},children:t.oldPrice})]}),(0,D.jsxs)("div",{style:pr,children:[(0,D.jsx)("button",{style:Kn,onClick:()=>u(C=>Math.max(1,C-1)),children:(0,D.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,D.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}),(0,D.jsx)("span",{style:{fontSize:"16px",fontWeight:"700",minWidth:"18px",textAlign:"center",color:"#000000",display:"inline-block"},children:c}),(0,D.jsx)("button",{style:Kn,onClick:()=>u(C=>C+1),children:(0,D.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,D.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,D.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),(()=>{let C=f.availability?.toLowerCase()||"",S=C==="out of stock"||C==="out-of-stock";return(0,D.jsxs)("button",{onClick:S?void 0:I,disabled:S,style:{...jo,backgroundColor:S?"#F3F4F6":R,color:S?"#9CA3AF":d,flex:"1",padding:"12px 8px",gap:"6px",cursor:S?"not-allowed":"pointer",opacity:S?.8:1},children:[!S&&(0,D.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,D.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,D.jsx)("path",{d:"M3 6h18"}),(0,D.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),(0,D.jsx)("span",{style:{fontSize:"12px",fontWeight:"700",whiteSpace:"nowrap"},children:S?"Out of Stock":"Add to cart"})]})})()]})]}),(0,D.jsx)("style",{children:`
|
|
36
|
+
`,backgroundPosition:"0 0, 100% 0",backgroundSize:"100% 100%",backgroundRepeat:"no-repeat"},a={width:"36px",height:"36px",borderRadius:"8px",backgroundColor:"#F1F3F5",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"18px",fontWeight:"800",color:"#2D3748",border:"1px solid #E2E8F0"},c={fontSize:`${r.fontSize||18}px`,fontWeight:"800",color:"#1A202C",letterSpacing:"1px",flex:1,textAlign:"center"};return(0,Ft.jsxs)("div",{style:s,onClick:n,children:[(0,Ft.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[(0,Ft.jsx)("div",{style:a,children:"%"}),(0,Ft.jsx)("span",{style:c,children:t.code||"OFFER20"})]}),(0,Ft.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[o&&(0,Ft.jsx)("span",{style:{fontSize:"11px",color:"#10B981",fontWeight:"700"},children:"Copied!"}),(0,Ft.jsx)("div",{style:{padding:"8px",display:"flex",alignItems:"center"},children:(0,Ft.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#4A5568",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Ft.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,Ft.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]})};var $o=require("react/jsx-runtime"),Un=({data:t,onInteraction:e,isEditing:o=!1})=>{let i={emojis:["\u{1F60D}","\u{1F44D}"]},n=Array.isArray(t.emojis)?t.emojis:Array.isArray(i.emojis)?i.emojis:[],r=c=>{o||e?.({type:"reaction",reactionId:t.id,emoji:c,stickerId:t.id})},s={display:"flex",gap:"20px",justifyContent:"center",alignItems:"center",width:"100%",padding:"12px"},a={backgroundColor:"#FFFFFF",width:"64px",height:"64px",borderRadius:"100px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 8px 30px rgba(0,0,0,0.12)",fontSize:"32px",cursor:o?"default":"pointer",transition:"all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)",border:"none",outline:"none",padding:0,position:"relative",zIndex:1};return(0,$o.jsx)("div",{style:s,children:n.map((c,u)=>(0,$o.jsx)("button",{style:a,onClick:()=>r(c),onMouseOver:x=>{o||(x.currentTarget.style.transform="scale(1.15) translateY(-4px)")},onMouseOut:x=>{o||(x.currentTarget.style.transform="scale(1) translateY(0)")},children:c},u))})};var ae=require("react"),se=require("react/jsx-runtime"),Hn=({data:t,onInteraction:e,isEditing:o=!1})=>{let i=t.maxRating||5,n=t.currentRating??Math.floor(i/2),[r,s]=(0,ae.useState)(n),a=(0,ae.useRef)(null),[c,u]=(0,ae.useState)(!1),x={backgroundColor:"#FFFFFF",borderRadius:36,padding:24,titleColor:"#000000",titleFontSize:24,sliderTrackColor:"#F3F4F6",sliderFillColor:"#F97316",emojiSize:42},m=t.styling||{},g={backgroundColor:m.backgroundColor||x.backgroundColor,borderRadius:`${m.borderRadius??x.borderRadius}px`,padding:`${m.padding??x.padding}px`,boxShadow:m.shadow||"0 12px 30px rgba(0,0,0,0.08)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",cursor:"default",opacity:m.opacity??1},v={color:m.titleColor||x.titleColor,fontWeight:"900",fontSize:`${m.titleFontSize||x.titleFontSize}px`,margin:"0",textAlign:"center",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:"100%"},f={width:"100%",height:"18px",backgroundColor:m.sliderTrackColor||x.sliderTrackColor,borderRadius:"100px",position:"relative",cursor:o?"default":"pointer",marginTop:"24px",marginBottom:"8px",userSelect:"none"},b=r/i*100,h={width:`${b}%`,height:"100%",background:m.sliderFillColor||"linear-gradient(90deg, #FF4582, #e11d48)",borderRadius:"100px",transition:c?"none":"width 0.1s ease"},y=m.emojiSize||x.emojiSize,w={position:"absolute",left:`calc(${b}% - ${y/2}px)`,top:`-${y/4}px`,fontSize:`${y}px`,userSelect:"none",cursor:"grab",transition:c?"none":"left 0.1s ease",filter:"drop-shadow(0 4px 8px rgba(0,0,0,0.2))"},I=d=>{if(!a.current||o)return;let T=a.current.getBoundingClientRect(),l=d-T.left;l<0&&(l=0),l>T.width&&(l=T.width);let p=l/T.width,O=Math.round(p*i*10)/10;s(O)},B=d=>{o||(u(!0),I(d.clientX))},R=d=>{o||(u(!0),I(d.touches[0].clientX))};return(0,ae.useEffect)(()=>{let d=p=>{c&&I(p.clientX)},T=()=>{c&&(u(!1),e?.({type:"rating",ratingId:t.id,value:r,stickerId:t.id}))},l=p=>{c&&I(p.touches[0].clientX)};return c&&(window.addEventListener("mousemove",d),window.addEventListener("mouseup",T),window.addEventListener("touchmove",l),window.addEventListener("touchend",T)),()=>{window.removeEventListener("mousemove",d),window.removeEventListener("mouseup",T),window.removeEventListener("touchmove",l),window.removeEventListener("touchend",T)}},[c,r]),(0,se.jsxs)("div",{style:g,children:[(0,se.jsx)("h3",{style:v,children:t.title||"Do you like my space?"}),(0,se.jsxs)("div",{ref:a,style:f,onMouseDown:B,onTouchStart:R,children:[(0,se.jsx)("div",{style:h}),(0,se.jsx)("div",{style:w,className:"interactive-emoji-thumb",children:t.emoji||"\u{1F60D}"})]})]})};var Vn=require("react"),Nt=require("react/jsx-runtime"),Yn=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=(0,Vn.useState)(""),r={backgroundColor:"#FFFFFF",borderRadius:16,padding:16,promptColor:"#111111",inputBgColor:"#FFFFFF",borderColor:"#EFEFEF",textColor:"#333333",placeholderColor:"#A0AEC0"},s=t.styling||{},a={backgroundColor:s.backgroundColor||r.backgroundColor,borderRadius:`${s.borderRadius??r.borderRadius}px`,padding:`${s.padding??r.padding}px`,boxShadow:s.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",border:`1px solid ${s.borderColor||"#F0F0F0"}`},c={color:s.promptColor||r.promptColor,fontWeight:"700",fontSize:`${s.fontSize?s.fontSize+2:16}px`,textAlign:"center",marginBottom:"2px",width:"100%"},u={width:"100%",position:"relative",display:"flex",alignItems:"center"},x={backgroundColor:s.inputBgColor||"#F1F3F5",border:"none",borderRadius:"30px",padding:"14px 45px 14px 20px",width:"100%",boxSizing:"border-box",color:s.inputTextColor||"#1A202C",fontSize:`${s.fontSize||14}px`,outline:"none",textAlign:"left",cursor:o?"default":"text",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.05)"},m={position:"absolute",right:"10px",background:s.submitBackground||"#FE6B35",color:"white",border:"none",borderRadius:"50%",width:"32px",height:"32px",display:i.length>0?"flex":"none",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"transform 0.2s"},g=f=>{o||n(f.target.value)},v=()=>{o||!i.trim()||(e?.({type:"question",questionId:t.id,value:i.trim(),stickerId:t.id}),n(""))};return(0,Nt.jsxs)("div",{style:a,children:[(0,Nt.jsx)("div",{style:c,children:t.question||"Ask me anything"}),(0,Nt.jsxs)("div",{style:u,children:[(0,Nt.jsx)("input",{type:"text",value:i,placeholder:t.placeholder||"Type your answer...",style:x,disabled:o,onChange:g,onKeyDown:f=>f.key==="Enter"&&v()}),(0,Nt.jsx)("button",{style:m,onClick:v,children:(0,Nt.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Nt.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,Nt.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})};var Qn=require("react"),qt=require("react/jsx-runtime"),Gn=({data:t,onInteraction:e,isEditing:o=!1})=>{let[i,n]=(0,Qn.useState)(null),r={backgroundColor:"#FFFFFF",borderRadius:20,padding:16,questionTextColor:"#111111",optionBgColor:"#F7FAFC",optionTextColor:"#2D3748",borderColor:"#E2E8F0",activeColor:"#10B981",incorrectColor:"#EF4444"},s=t.styling||{},a={backgroundColor:s.backgroundColor||r.backgroundColor,borderRadius:`${s.borderRadius??r.borderRadius}px`,padding:`${s.padding??r.padding}px`,boxShadow:s.shadow||"0 8px 24px rgba(0,0,0,0.06)",boxSizing:"border-box",width:"100%",display:"flex",flexDirection:"column",gap:"12px",border:s.borderColor?`1px solid ${s.borderColor}`:"none"},c={color:s.questionTextColor||r.questionTextColor,fontWeight:"800",fontSize:`${s.fontSize?s.fontSize+2:16}px`,margin:"0 0 4px 0",textAlign:"left"},u={display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"12px",width:"100%"},x={backgroundColor:s.optionBgColor||r.optionBgColor,color:s.optionTextColor||r.optionTextColor,borderRadius:"16px",border:`2px solid ${s.borderColor||r.borderColor}`,cursor:i?"default":"pointer",display:"flex",flexDirection:"column",alignItems:"center",padding:"8px",boxSizing:"border-box",transition:"all 0.2s ease",overflow:"hidden"},m=f=>{o||i||(n(f),e?.({type:"image",quizId:t.id,optionId:f,stickerId:t.id}))},g="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",v=Array.isArray(t.options)?t.options:[];return(0,qt.jsxs)("div",{style:a,children:[t.question&&(0,qt.jsx)("h3",{style:c,children:t.question}),(0,qt.jsx)("div",{style:u,children:v.map(f=>{let b=f.id===i,h=f.isCorrect===!0,y={...x};return i&&(h?(y.borderColor=s.activeColor||r.activeColor,y.backgroundColor="rgba(16, 185, 129, 0.05)"):b&&(y.borderColor=s.incorrectColor||r.incorrectColor,y.backgroundColor="rgba(239, 68, 68, 0.05)")),(0,qt.jsxs)("button",{style:y,onClick:()=>m(f.id),disabled:!!i,onMouseOver:w=>{!o&&!i&&(w.currentTarget.style.transform="translateY(-2px)")},onMouseOut:w=>{!o&&!i&&(w.currentTarget.style.transform="translateY(0)")},children:[(0,qt.jsxs)("div",{style:{width:"100%",aspectRatio:"1",borderRadius:"12px",overflow:"hidden",backgroundColor:"#EDF2F7",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"8px",position:"relative"},children:[(0,qt.jsx)("img",{src:f.image||g,alt:f.text,style:{width:"100%",height:"100%",objectFit:"cover"}}),i&&(0,qt.jsx)("div",{style:{position:"absolute",top:"6px",right:"6px",width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:h?r.activeColor:b?r.incorrectColor:"#A0AEC0",color:"#FFFFFF",fontSize:"12px",fontWeight:"bold"},children:h?"\u2713":b?"\u2715":""})]}),(0,qt.jsx)("span",{style:{fontWeight:"600",fontSize:`${s.optionFontSize||13}px`,color:i&&h?r.activeColor:r.optionTextColor,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:f.text})]},f.id)})})]})};var jo=require("react");var Kt=require("react"),D=require("react/jsx-runtime"),ei=({product:t,styling:e,onClose:o,onAddToCart:i})=>{let[n,r]=(0,Kt.useState)(""),[s,a]=(0,Kt.useState)(0),[c,u]=(0,Kt.useState)(1),[x,m]=(0,Kt.useState)(!1),[g,v]=(0,Kt.useState)(!1),f=t.attributes||{},b=f.colors||[],h=f.sizes||[],y=f.imageUrls||[t.image],w=f.description||"";(0,Kt.useEffect)(()=>{h.length>0&&r(h[0]),v(!0)},[h]);let I=()=>{let C={productId:t.productId||t.id,title:t.title,selectedSize:n,selectedColor:b[s]?.name,quantity:c,price:t.price};i(C);let S=t.redirectUrl||t.url;if(S){!S.startsWith("http")&&!S.startsWith("//")&&(S="https://"+S);try{window.open(S,"_blank","noopener,noreferrer")}catch(W){console.error("AppStorys: Redirect failed",W)}}m(!0)},B=()=>{v(!1),setTimeout(o,400)},R=e?.buttonBackground||"#000000",d=e?.buttonTextColor||"#ffffff",T=e?.titleColor||e?.textColor||"#1a1a2e",l=e?.priceColor||e?.textColor||"#1a1a2e",p=e?.mrpColor||"#8b8b98",O=e?.titleFontWeight||"600",A=e?.priceFontWeight||"700",_=e?.mrpFontWeight||"500";return x?(0,D.jsxs)("div",{className:"appstorys-shopable-success-overlay",style:Jn,children:[(0,D.jsx)("div",{className:"appstorys-shopable-backdrop",style:Xn,onClick:B}),(0,D.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...Kn,height:"auto",minHeight:"310px",animation:"appstorys-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[(0,D.jsx)("div",{style:Zn,onClick:B}),(0,D.jsxs)("div",{style:{padding:"0 20px 24px",textAlign:"center"},children:[(0,D.jsxs)("div",{style:{backgroundColor:"#F3F4F6",borderRadius:"20px",padding:"22px",marginTop:"16px",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[(0,D.jsxs)("h3",{style:{margin:0,fontSize:"16px",fontWeight:"600",lineHeight:"1.4"},children:["Added to your bag",(0,D.jsx)("br",{}),"successfully"]}),(0,D.jsx)("svg",{width:"44",height:"26",viewBox:"0 0 44 26",fill:"none",children:(0,D.jsx)("path",{d:"M4 4C4 4 11 22 22 22C33 22 40 4 40 4",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round"})})]}),(0,D.jsxs)("div",{style:{marginTop:"24px",display:"flex",flexDirection:"column",gap:"8px"},children:[(0,D.jsx)("button",{onClick:B,style:{...Oo,backgroundColor:"#000000",color:"#ffffff",padding:"17px",fontSize:"16px",fontWeight:"600"},children:(0,D.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[(0,D.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,D.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,D.jsx)("path",{d:"M3 6h18"}),(0,D.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),"Go to checkout"]})}),(0,D.jsx)("button",{onClick:B,style:{...Oo,backgroundColor:"transparent",color:"#000000",border:"1px solid rgba(0,0,0,0.1)",padding:"15px",fontSize:"16px"},children:"Continue with stories"})]})]})]})]}):(0,D.jsxs)("div",{className:`appstorys-shopable-overlay ${g?"visible":""}`,style:Jn,children:[(0,D.jsx)("div",{className:"appstorys-shopable-backdrop",style:Xn,onClick:B}),(0,D.jsxs)("div",{className:"appstorys-shopable-sheet",style:{...Kn,transform:g?"translateY(0)":"translateY(100%)",opacity:g?1:0},children:[(0,D.jsxs)("div",{style:ar,children:[(0,D.jsx)("div",{style:Zn,onClick:B}),(0,D.jsx)("button",{style:lr,onClick:B,children:(0,D.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,D.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,D.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),(0,D.jsxs)("div",{style:dr,children:[(0,D.jsx)("div",{style:cr,children:y.map((C,S)=>(0,D.jsx)("div",{style:{minWidth:y.length>1?"85%":"100%",aspectRatio:"1.2 / 1",maxHeight:"240px",borderRadius:"16px",overflow:"hidden",backgroundColor:"#F9FAFB"},children:(0,D.jsx)("img",{src:C,alt:t.title,style:{width:"100%",height:"100%",objectFit:"contain"}})},S))}),(0,D.jsxs)("div",{style:{padding:"0 20px 20px"},children:[(0,D.jsx)("h2",{style:{margin:"16px 0 4px",fontSize:e?.titleFontSize?`${e.titleFontSize}px`:"20px",fontWeight:O,color:T,lineHeight:"1.2"},children:t.title}),(0,D.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",marginBottom:"16px"},children:[(0,D.jsx)("span",{style:{fontSize:e?.priceFontSize?`${e.priceFontSize}px`:"18px",fontWeight:A,color:l},children:t.price}),t.oldPrice&&(0,D.jsx)("span",{style:{fontSize:e?.mrpFontSize?`${e.mrpFontSize}px`:"14px",color:p,textDecoration:"line-through",fontWeight:_},children:t.oldPrice})]}),b.length>0&&(0,D.jsxs)("div",{style:Wo,children:[(0,D.jsx)("div",{style:Mo,children:"COLOR"}),(0,D.jsx)("div",{style:{display:"flex",gap:"14px",marginTop:"12px"},children:b.map((C,S)=>(0,D.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"5px"},children:[(0,D.jsx)("button",{onClick:()=>a(S),style:{width:"36px",height:"36px",borderRadius:"50%",border:"none",backgroundColor:C.hex||"#gray",position:"relative",cursor:"pointer",boxShadow:s===S?"0 0 0 2px #fff, 0 0 0 4px #000":"none",transition:"all 0.2s ease"}}),(0,D.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:s===S?"#000":"transparent",transition:"all 0.2s ease"}})]},C.id))})]}),h.length>0&&(0,D.jsxs)("div",{style:Wo,children:[(0,D.jsx)("div",{style:Mo,children:"SIZE"}),(0,D.jsx)("div",{style:{display:"flex",gap:"10px",marginTop:"12px",flexWrap:"wrap"},children:h.map(C=>(0,D.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},children:[(0,D.jsx)("button",{onClick:()=>r(C),style:{minWidth:"42px",height:"42px",borderRadius:"50%",backgroundColor:"transparent",border:`1px solid ${n===C?"#000":"rgba(0,0,0,0.1)"}`,color:n===C?"#000":"#8b8b98",fontSize:"13px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:C}),(0,D.jsx)("div",{style:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:n===C?"#000":"transparent",transition:"all 0.2s ease"}})]},C))})]}),w&&(0,D.jsxs)("div",{style:Wo,children:[(0,D.jsx)("div",{style:Mo,children:"DESCRIPTION"}),(0,D.jsx)("p",{style:{margin:"8px 0 0",fontSize:"14px",lineHeight:"1.5",color:"#8b8b98",wordBreak:"break-word"},children:w})]})]})]}),(0,D.jsxs)("div",{style:pr,children:[(0,D.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"1px",minWidth:"75px"},children:[(0,D.jsx)("div",{style:{fontSize:"15px",fontWeight:A,color:l},children:t.price}),t.oldPrice&&(0,D.jsx)("div",{style:{fontSize:"11px",color:p,textDecoration:"line-through",fontWeight:_},children:t.oldPrice})]}),(0,D.jsxs)("div",{style:ur,children:[(0,D.jsx)("button",{style:ti,onClick:()=>u(C=>Math.max(1,C-1)),children:(0,D.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,D.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}),(0,D.jsx)("span",{style:{fontSize:"16px",fontWeight:"700",minWidth:"18px",textAlign:"center",color:"#000000",display:"inline-block"},children:c}),(0,D.jsx)("button",{style:ti,onClick:()=>u(C=>C+1),children:(0,D.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,D.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,D.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),(()=>{let C=f.availability?.toLowerCase()||"",S=C==="out of stock"||C==="out-of-stock";return(0,D.jsxs)("button",{onClick:S?void 0:I,disabled:S,style:{...Oo,backgroundColor:S?"#F3F4F6":R,color:S?"#9CA3AF":d,flex:"1",padding:"12px 8px",gap:"6px",cursor:S?"not-allowed":"pointer",opacity:S?.8:1},children:[!S&&(0,D.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,D.jsx)("path",{d:"M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z"}),(0,D.jsx)("path",{d:"M3 6h18"}),(0,D.jsx)("path",{d:"M16 10a4 4 0 0 1-8 0"})]}),(0,D.jsx)("span",{style:{fontSize:"12px",fontWeight:"700",whiteSpace:"nowrap"},children:S?"Out of Stock":"Add to cart"})]})})()]})]}),(0,D.jsx)("style",{children:`
|
|
37
37
|
@keyframes appstorys-slide-up {
|
|
38
38
|
from { transform: translateY(100%); }
|
|
39
39
|
to { transform: translateY(0); }
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
.appstorys-shopable-overlay.visible {
|
|
47
47
|
visibility: visible;
|
|
48
48
|
}
|
|
49
|
-
`})]})},
|
|
49
|
+
`})]})},Jn={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"},Xn={position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.45)",cursor:"pointer"},Kn={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"},ar={height:"48px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0},Zn={width:"36px",height:"5px",backgroundColor:"rgba(0,0,0,0.1)",borderRadius:"3px",cursor:"pointer"},lr={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"},dr={flex:1,overflowY:"auto",WebkitOverflowScrolling:"touch"},cr={padding:"0 16px 20px",display:"flex",gap:"8px",overflowX:"auto",scrollSnapType:"x mandatory"},Wo={marginTop:"20px"},Mo={fontSize:"11px",fontWeight:"600",color:"rgba(0,0,0,0.5)",letterSpacing:"1.4px"},pr={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"},ur={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"100px",border:"1px solid rgba(0,0,0,0.1)"},ti={border:"none",backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},Oo={border:"none",borderRadius:"100px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"};var ut=require("react/jsx-runtime"),oi=({data:t,onInteraction:e,isEditing:o})=>{let{products:i,styling:n}=t,[r,s]=(0,jo.useState)(!1),[a,c]=(0,jo.useState)(null),u=(b,h)=>{if(b.stopPropagation(),o)return;if(t.shopableType==="product"){c(h),s(!0),e&&e({type:"product_view",stickerId:t.id,productId:h.productId||h.id,value:h.title});return}let y=h.redirectUrl||h.url;if(y&&!y.startsWith("http")&&!y.startsWith("//")&&(y="https://"+y),e&&e({type:"buy",stickerId:t.id,productId:h.id,value:h.title,selected_option:y}),y)try{window.open(y,"_blank","noopener,noreferrer")}catch(w){console.error("AppStorys: Redirect failed",w),window.location.href=y}},x=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"},g={flex:"0 0 auto",width:"100%",backgroundColor:n?.cardBackground||"#ffffff",borderRadius:n?.cardBorderRadius!==void 0?`${n.cardBorderRadius}px`:n?.cardRadiusPercent!==void 0?`${n.cardRadiusPercent}%`:"12px",overflow:"hidden",boxShadow:n?.shadow||"0 -2px 12px rgba(0,0,0,0.12)",display:"flex",flexDirection:"row",alignItems:"center",padding:"8px 12px",position:"relative",scrollSnapAlign:"center",transition:"transform 0.2s ease",cursor:"pointer",boxSizing:"border-box",pointerEvents:"auto",opacity:n?.opacity??1,marginBottom:0},v={width:"64px",height:"64px",borderRadius:n?.imageRadius!==void 0?`${n.imageRadius}px`:"12px",overflow:"hidden",backgroundColor:"#f5f5f5",flexShrink:0},f={flex:1,display:"flex",flexDirection:"column",justifyContent:"center",padding:"0 12px",minWidth:0};return(0,ut.jsxs)(ut.Fragment,{children:[(0,ut.jsxs)("div",{style:m,className:"shopable-container",children:[(0,ut.jsx)("style",{children:`
|
|
50
50
|
.shopable-container::-webkit-scrollbar { display: none; }
|
|
51
51
|
.shopable-card:active { transform: scale(0.98); }
|
|
52
|
-
`}),i.map(b=>(0,gt.jsxs)("div",{style:g,className:"shopable-card",onClick:h=>u(h,b),children:[(0,gt.jsx)("div",{style:v,children:(0,gt.jsx)("img",{src:b.image,alt:b.title,style:{width:"100%",height:"100%",objectFit:"cover"}})}),(0,gt.jsxs)("div",{style:f,children:[(0,gt.jsx)("span",{style:{color:n?.titleColor||n?.textColor||"#1a1b2e",fontSize:n?.titleFontSize?`${n.titleFontSize}px`:"15px",fontWeight:n?.titleFontWeight||"700",lineHeight:"1.2",display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"1px"},children:b.title}),(0,gt.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",flexWrap:"wrap"},children:[(0,gt.jsx)("span",{style:{color:n?.priceColor||n?.textColor||"#1a1b2e",fontSize:n?.priceFontSize?`${n.priceFontSize}px`:"18px",fontWeight:n?.priceFontWeight||"800",display:"block"},children:b.price}),b.oldPrice&&(0,gt.jsx)("span",{style:{color:n?.mrpColor||"#8b8b98",fontSize:n?.mrpFontSize?`${n.mrpFontSize}px`:"12px",fontWeight:n?.mrpFontWeight||"500",textDecoration:"line-through"},children:b.oldPrice})]})]}),(0,gt.jsx)("div",{style:{backgroundColor:n?.buttonBackground||"#000000",color:n?.buttonTextColor||"#ffffff",fontSize:n?.buttonFontSize?`${n.buttonFontSize}px`:"14px",fontWeight:"700",padding:"10px 18px",borderRadius:n?.buttonBorderRadius!==void 0?`${n.buttonBorderRadius}px`:"100px",textAlign:"center",flexShrink:0,whiteSpace:"nowrap"},children:"Buy Now"})]},b.id))]}),r&&a&&(0,gt.jsx)(Zn,{product:a,styling:n,onClose:()=>s(!1),onAddToCart:x})]})};var ht=require("react/jsx-runtime"),ei=({data:t,onInteraction:e,isEditing:o=!1})=>{let i={x:10,y:15,width:80,rotation:0},n=t.x??i.x,r=t.y??i.y,s=t.width??i.width,a=t.rotation??i.rotation,c={position:"absolute",top:`${r}%`,left:`${n}%`,width:`${s}%`,height:t.height?`${t.height}%`:"auto",transform:`rotate(${a}deg)`,zIndex:10,transformOrigin:"center center",boxSizing:"border-box",cursor:o?"move":"default",pointerEvents:"auto"},u={width:"100%",height:"100%",animation:t.styling?.animation,animationFillMode:"forwards"},x=()=>{switch(t.type){case"poll":return(0,ht.jsx)(_n,{data:t,onInteraction:e,isEditing:o});case"quiz":return(0,ht.jsx)(Wn,{data:t,onInteraction:e,isEditing:o});case"rating":return(0,ht.jsx)(qn,{data:t,onInteraction:e,isEditing:o});case"question":case"input":return(0,ht.jsx)(Hn,{data:t,onInteraction:e,isEditing:o});case"image_quiz":return(0,ht.jsx)(Yn,{data:t,onInteraction:e,isEditing:o});case"countdown":return(0,ht.jsx)(Mn,{data:t,onInteraction:e,isEditing:o});case"promo_code":case"promo":return(0,ht.jsx)(jn,{data:t,onInteraction:e,isEditing:o});case"reaction":return(0,ht.jsx)(Nn,{data:t,onInteraction:e,isEditing:o});case"buy":case"shopable":return(0,ht.jsx)(ti,{data:t,onInteraction:e,isEditing:o});case"image":return(0,ht.jsx)("img",{src:t.url,alt:"static overlay",style:{width:"100%",height:"100%",objectFit:"fill"}});case"text":{let g=t.styling||{};return(0,ht.jsx)("span",{style:{color:g.color||"#000000",fontSize:`${g.fontSize||14}px`,fontFamily:dt(g.fontFamily)||"Arial",fontStyle:g.fontStyle||"normal",fontWeight:g.fontWeight||"normal",wordBreak:"break-word",display:"inline-block"},children:t.text})}default:return(0,ht.jsxs)("div",{style:{padding:"10px",background:"white",color:"black",borderRadius:"4px"},children:["Unsupported interactive element: ",t.type]})}};return(0,ht.jsx)("div",{style:c,className:`interactive-item-z${t.z??0}`,children:(0,ht.jsx)("div",{style:u,children:x()})})};var Vt=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}let e=t.color||{};if(e.type==="gradient"&&e.gradient){let{direction:o="right",from:i,to:n,stops:r=[]}=e.gradient,a={right:"to right",left:"to left",top:"to top",bottom:"to bottom"}[o]||o;if(r.length>0){let c=r.map(u=>`${u.color} ${Math.round((u.offset||0)*100)}%`).join(", ");return`linear-gradient(${a}, ${c})`}return`linear-gradient(${a}, ${i}, ${n})`}return e.solid||e.value||void 0},to=t=>{if(!t||t.type==="none")return;let e=String(t.type).toLowerCase(),o=t.duration||.6;if(e==="fade")return`appstorys-fade-in ${o}s ease-out forwards`;if(e==="classic")return`appstorys-classic-in ${o}s cubic-bezier(0.34, 1.56, 0.64, 1) forwards`;if(e==="rotate")return`appstorys-rotate-in ${o}s ease-out forwards`;if(e==="bounce")return`appstorys-bounce-in ${o+.2}s cubic-bezier(0.68, -0.6, 0.32, 1.6) forwards`};var ze=require("react/jsx-runtime"),oi=(t,e)=>{let o=t?.styling?.editorSource||t?.styling?.meta?.editorSource||t?.style?.editorSource||e?.editorSource||e?.meta?.editorSource;return o==="studio"||o==="editor"?"studio":"dashboard"},ae=(t,e)=>Array.isArray(t)?t.map((o,i)=>{let n=o?.id||o?.key||o?.value||`option_${i+1}`,r=o?.label||o?.optionLabel,s=typeof o=="string"?o:o?.text||o?.title||r||"";return{id:String(n),text:s,image:o?.image||o?.imageUrl||"",label:r,isCorrect:o?.isCorrect===!0||String(n)===String(e)}}):t&&typeof t=="object"?Object.entries(t).map(([o,i])=>{let n=typeof i=="string"?{text:i}:i||{};return{id:o,text:n.text||n.title||n.label||"",image:n.image||n.imageUrl||"",label:n.label,isCorrect:o===String(e)}}):[],ni=t=>Array.isArray(t?.emojis)?t.emojis.map(e=>String(e)):ae(t?.options).map(e=>e.text).filter(Boolean),ii=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},ri=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()}},qo=({content:t={},onInteraction:e,isEditing:o=!1,elapsedTime:i=0})=>{let n=t?.canva||{height:1920,width:1080},r=n?.width||1080,s=n?.height||1920,a=.352,c=t?.elements||[],u=t?.image||[],x=t?.text||[],m=t?.interactions||[],g=Array.isArray(t?.shopable)&&t.shopable.length>0?t.shopable:Array.isArray(t?.styling?.shopable)?t.styling.shopable:[],v=new Set(g.map(d=>d.id)),f=(t?.styling?.shopable||[]).concat(g.map(d=>d.styling).filter(Boolean));if(c.length===0&&u.length===0&&x.length===0&&m.length===0&&g.length===0)return null;let b=c.filter(d=>!v.has(d.id)).map(d=>{let T=d.custom||{},l=T.data||{},p=T.style||d.styling||{},O=oi(d,t),A=d.position||d.postion||{},_=d.size||{},C=d.x!==void 0?d.x:A.x,S=d.y!==void 0?d.y:A.y,W=d.width!==void 0?d.width:_.width,P=C!==void 0&&!isNaN(Number(C))?Number(C)/r*100:10,M=S!==void 0&&!isNaN(Number(S))?Number(S)/s*100:15,$=W!==void 0&&!isNaN(Number(W))?Number(W)/r*100:80,k={id:d.id||Math.random().toString(),type:ii(T.interactiveType||d.widgetType||d.type||"unknown"),x:P,y:M,width:$,rotation:p.rotation??d.rotation??0,z:d.z??d.position?.z??p.z??10,duration:l.duration||p.duration,styling:{backgroundColor:Vt(p.background||p.containerBgColor||p.backgroundColor),borderRadius:p.borderRadius!==void 0?p.borderRadius>=100?999:p.borderRadius*a:p.radius!==void 0?p.radius>=100?999:p.radius*a:0,padding:(p.containerPadding!==void 0?p.containerPadding:p.padding!==void 0?p.padding:0)*a,shadow:p.shadow,fontSize:p.questionFontSize?p.questionFontSize*a:void 0,opacity:p.opacity??1,animation:to(p.animation)}};if(k.type==="poll"){let L=ae(l.options);return{...k,type:"poll",question:l.question||l.title||"Poll Question",options:L,layout:l.layout||{type:"vertical",columns:1},styling:{...k.styling,headerColor:p.headerBgColor||p.background,headerTextColor:p.questionColor||p.questionTextColor||p.question?.color,optionBgColor:p.optionBgColor||p.options?.background||"#1A1A1A",optionTextColor:p.optionTextColor||p.options?.textColor||"#ffffff",optionBorderRadius:p.optionBorderRadius!==void 0?p.optionBorderRadius*a:p.options?.radius!==void 0?p.options?.radius*a:0}}}if(k.type==="quiz"){let L=p.colors||{},j=ae(l.options,l.isCorrect);return{...k,type:"quiz",question:l.question||l.title||"Quiz Question",options:j,showExplanation:l.showExplanation,url:l.url,styling:{...k.styling,backgroundColor:p.background||p.containerBgColor||p.backgroundColor||"transparent",questionTextColor:p.questionColor||L.questionColor||p.question?.color||p.colors?.questionText||"#FF0000",questionBgColor:p.questionBgColor||L.questionBackground||p.question?.background||p.colors?.questionBg||"#3BFF00",optionBgColor:p.optionBgColor||L.optionBackground||p.options?.background||p.colors?.optionBg||"#C100FF",optionTextColor:p.optionTextColor||L.optionTextColor||p.options?.textColor||p.colors?.optionText||"#ffffff",borderColor:p.borderColor||"transparent",activeColor:p.correctColor||L.correctColor||p.correctBorderColor||"#00D9FF",incorrectColor:p.incorrectColor||L.incorrectColor||"#ef4444",optionBorderRadius:p.optionRadius!==void 0?p.optionRadius>=100?999:p.optionRadius*a:p.optionBorderRadius!==void 0?p.optionBorderRadius>=100?999:p.optionBorderRadius*a:100,optionFontSize:(p.optionFontSize?p.optionFontSize:p.typography?.optionSize?p.typography?.optionSize:p.options?.fontSize?p.options?.fontSize:16)*a*1.25}}}if(k.type==="rating")return{...k,type:"rating",title:l.title||"Do you like my space?",emoji:l.emoji||"\u{1F60D}",currentRating:l.currentRating,maxRating:l.maxRating,styling:{...k.styling,sliderTrackColor:p.colors?.sliderTrack||p.sliderTrack,sliderFillColor:p.colors?.sliderFill||p.sliderFill,emojiSize:p.emojiSize?p.emojiSize*.45:void 0,titleColor:p.colors?.titleColor||p.titleColor,titleFontSize:p.titleFontSize?p.titleFontSize*.4:void 0}};if(k.type==="question")return{...k,type:"question",question:l.question||l.title||"Ask me a question",placeholder:l.placeholder||"Type your answer...",styling:{...k.styling,promptColor:p.questionColor||p.textColor,inputBgColor:p.inputBgColor,inputTextColor:p.inputTextColor,submitBackground:p.submitBackground}};if(k.type==="image_quiz"||k.type==="imageQuiz"||(T.interactiveType||"").toLowerCase()==="media_quiz")return{...k,type:"image_quiz",question:l.question||l.title||"Image Quiz",options:ae(l.options||[]),styling:{...k.styling,questionTextColor:p.questionColor,activeColor:p.correctColor||p.correctBorderColor,incorrectColor:p.incorrectColor,imageRadius:p.imageRadius?p.imageRadius*a:void 0}};if(k.type==="countdown")return{...k,type:"countdown",title:l.title||"Ends in...",targetDate:ri(l),styling:{...k.styling,borderColor:p.borderColor,digitBackground:p.digitBackground,digitColor:p.digitColor,digitSize:p.digitSize?p.digitSize*a:void 0,labelColor:p.labelColor,titleColor:p.titleColor},display:l.display};if(k.type==="promo_code")return{...k,type:"promo_code",code:l.code||"CODE20",styling:{...k.styling,borderColor:p.borderColor}};if(k.type==="reaction"||k.type==="emoji_reaction"){let L=ni(l);return{...k,type:"reaction",emojis:L.length>0?L:["\u{1F60D}","\u{1F44D}"],source:O}}return k}),h=(t?.interactions||[]).filter(d=>!v.has(d.id)).map(d=>{let T=d.config||{},l=d.styling||d.style||{},p=oi(d,t),O=ii(d.interaction_type||d.type),A=l.position||d.position||{},_=l.size||d.size||{},C=A.x??d.x,S=A.y??d.y,W=_.width??d.width,P=_.height??d.height,M=C!==void 0&&!isNaN(Number(C))?Number(C)/r*100:10,$=S!==void 0&&!isNaN(Number(S))?Number(S)/s*100:15,k=W!==void 0&&!isNaN(Number(W))?Number(W)/r*100:80,L=P!==void 0&&!isNaN(Number(P))?Number(P)/s*100:void 0,j={id:d.id||Math.random().toString(),type:O,x:M,y:$,width:k,height:L,rotation:l.rotation??d.rotation??0,z:d.z??d.position?.z??l.z??10,source:p,duration:T.duration||l.duration,styling:{backgroundColor:Vt(l.background||l.containerBgColor||l.backgroundColor),borderRadius:l.borderRadius!==void 0?l.borderRadius>=100?999:l.borderRadius*a:l.radius!==void 0?l.radius>=100?999:l.radius*a:0,padding:(l.containerPadding!==void 0?l.containerPadding:l.padding!==void 0?l.padding:0)*a,shadow:l.shadow,fontSize:l.questionSize?l.questionSize*a:l.questionFontSize?l.questionFontSize*a:void 0,opacity:l.opacity??1,animation:to(l.animation)}};if(j.type==="rating"||j.type==="rate"){let X=l.colors||{};return{...j,type:"rating",title:T.title||"Do you like my space?",emoji:T.emoji||"\u{1F60D}",currentRating:T.currentRating,maxRating:T.maxRating,styling:{...j.styling,sliderTrackColor:X.sliderTrack||l.colors?.sliderTrack||l.colors?.sliderTrack,sliderFillColor:X.sliderFill||l.colors?.sliderFill||l.sliderFill,emojiSize:l.emojiSize?l.emojiSize*.45:void 0,titleColor:X.titleColor||l.colors?.titleColor||l.titleColor,titleFontSize:l.titleFontSize?l.titleFontSize*.4:void 0}}}if(j.type==="poll"){let X=ae(T.options);return{...j,type:"poll",question:T.question||T.title||"Poll Question",options:X,layout:T.layout||{type:"vertical",columns:1},styling:{...j.styling,headerColor:l.headerBgColor||l.background,headerTextColor:l.questionColor||l.questionTextColor||l.question?.color,optionBgColor:l.optionBgColor||l.options?.background||"#1A1A1A",optionTextColor:l.optionTextColor||l.options?.textColor||"#ffffff",optionBorderRadius:l.optionBorderRadius!==void 0?l.optionBorderRadius*a:l.options?.radius!==void 0?l.options?.radius*a:0}}}if(j.type==="quiz"){let X=l.colors||{},mt=ae(T.options,T.isCorrect);return{...j,type:"quiz",question:T.question||T.title||"Quiz Question",options:mt,showExplanation:T.showExplanation,url:T.url,styling:{...j.styling,backgroundColor:l.background||l.containerBgColor||l.backgroundColor||"transparent",questionTextColor:l.questionColor||X.questionColor||l.question?.color||l.colors?.questionText||"#FF0000",questionBgColor:l.questionBgColor||X.questionBackground||l.question?.background||l.colors?.questionBg||"#3BFF00",optionBgColor:l.optionBgColor||X.optionBackground||l.options?.background||l.colors?.optionBg||"#C100FF",optionTextColor:l.optionTextColor||X.optionTextColor||l.options?.textColor||l.colors?.optionText||"#ffffff",borderColor:l.borderColor||"transparent",activeColor:l.correctColor||X.correctColor||l.correctBorderColor||"#00D9FF",incorrectColor:l.incorrectColor||X.incorrectColor||"#ef4444",optionBorderRadius:l.optionRadius!==void 0?l.optionRadius>=100?999:l.optionRadius*a:l.optionBorderRadius!==void 0?l.optionBorderRadius>=100?999:l.optionBorderRadius*a:100,optionFontSize:(l.optionFontSize?l.optionFontSize:l.typography?.optionSize?l.typography?.optionSize:l.options?.fontSize?l.options?.fontSize:16)*a*1.25}}}if(j.type==="question")return{...j,type:"question",question:T.question||T.title||"Ask me a question",placeholder:T.placeholder||"Type your answer...",styling:{...j.styling,promptColor:l.questionColor||l.promptColor||l.textColor,inputBgColor:l.inputBackground||l.inputBgColor,inputTextColor:l.inputTextColor,submitBackground:l.submitBackground}};if(j.type==="image_quiz"||j.type==="imageQuiz"||O==="media_quiz")return{...j,type:"image_quiz",question:T.question||T.title||"Image Quiz",options:ae(T.options||[]),styling:{...j.styling,questionTextColor:l.questionColor,activeColor:l.correctColor||l.correctBorderColor,incorrectColor:l.incorrectColor,imageRadius:l.imageRadius?l.imageRadius*a:void 0}};if(j.type==="countdown")return{...j,type:"countdown",title:T.title||"Ends in...",targetDate:ri(T),styling:{...j.styling,borderColor:l.borderColor,digitBackground:l.digitBackground,digitColor:l.digitColor,digitSize:l.digitSize||l.fontSize?Number(l.digitSize||l.fontSize):void 0,labelColor:l.labelColor,titleColor:l.titleColor,labelFontSize:l.labelFontSize?Number(l.labelFontSize):void 0},display:T.display||d.display};if(j.type==="promo_code")return{...j,type:"promo_code",code:T.code||"CODE20",styling:{...j.styling,borderColor:l.borderColor}};if(j.type==="reaction"||j.type==="emoji_reaction"){let X=ni(T);return{...j,type:"reaction",emojis:X.length>0?X:["\u{1F60D}","\u{1F44D}"]}}return j}),y=g.map(d=>{let T=f.find(N=>String(N?.id)===String(d?.id))||f.find(N=>N?.id===void 0)||{},l={position:d?.position,size:d?.size,rotation:d?.rotation,z:d?.z,background:d?.background,cardBackground:d?.cardBackground,cardBorderRadius:d?.cardBorderRadius,cardRadiusPercent:d?.cardRadiusPercent,transparent:d?.transparent,textColor:d?.textColor,buttonBackground:d?.buttonBackground,buttonTextColor:d?.buttonTextColor,buttonFontSize:d?.buttonFontSize,buttonBorderRadius:d?.buttonBorderRadius,titleColor:d?.titleColor,titleFontSize:d?.titleFontSize,titleFontWeight:d?.titleFontWeight,priceColor:d?.priceColor,priceFontSize:d?.priceFontSize,priceFontWeight:d?.priceFontWeight,mrpColor:d?.mrpColor,mrpFontSize:d?.mrpFontSize,mrpFontWeight:d?.mrpFontWeight,imageRadius:d?.imageRadius,opacity:d?.opacity,animation:d?.animation},p={...T,...d?.styling||{},...Object.fromEntries(Object.entries(l).filter(([,N])=>N!==void 0))},O=p.position||{},A=p.size||{},_=p.cardBorderRadius!==void 0?Number(p.cardBorderRadius):void 0,C=p.cardRadiusPercent!==void 0?Number(p.cardRadiusPercent):void 0,S=A.height!==void 0?Number(A.height):void 0,W=_===void 0&&C!==void 0&&S!==void 0?Math.max(0,Math.min(100,C))/100*(S/2):void 0,P=_??W,M=P!==void 0&&!isNaN(P)?P*a:void 0,$=O.x!==void 0?Number(O.x)/r*100:0,k=A.width!==void 0?Number(A.width)/r*100:100,L=A.height!==void 0?Number(A.height)/s*100:void 0,j=O.y!==void 0?Number(O.y)/s*100:L?100-L-2.5:85;L&&j+L>96?j=Math.max(0,100-L):j>75&&L&&j+L>91&&(j=Math.max(0,100-L-1));let X=Array.isArray(d.product)&&d.product.length>0,mt=X?d.product:d.static||[];return{id:d.id||Math.random().toString(),type:"buy",shopableType:X?"product":"static",x:$,y:j,width:k,height:L,rotation:p.rotation??0,z:p.z??10,products:mt.map(N=>{let tt=N.productData||N||{},K=tt.attributes||N.attributes||{},Y=K.sales_price||tt.price||K.price||N.price,st=K.sales_price?tt.price||K.price||N.price:tt.oldPrice||N.oldPrice,q=tt.color||K.color||N.color,Q=tt.size||K.size||N.size,J=K.colors||[];J.length===0&&q&&(J=[{id:q,hex:q,name:q}]);let ot=K.sizes||[];ot.length===0&&Q&&(ot=typeof Q=="string"?Q.split(",").map(at=>at.trim()):[Q]);let ct={description:tt.description||K.description||N.description,color:q,size:Q,colors:J,sizes:ot,imageUrls:K.imageUrls||[K.image_link||tt.imageUrl||tt.image||N.imageUrl||N.image||N.url].filter(Boolean),availability:tt.availability||K.availability||N.availability,tags:tt.tags||K.tags||N.tags,...K};return{id:tt.productId||tt.id||N.productId||N.id||Math.random().toString(),image:K.image_link||tt.imageUrl||tt.image||N.imageUrl||N.image||N.url,url:tt.link||tt.url||N.link||N.url||N.redirectUrl,title:tt.title||N.title,price:Y,oldPrice:st,redirectUrl:N.redirectUrl||tt.link||N.link||N.url,svg:tt.svg||N.svg,productId:tt.productId||N.productId,collectionId:tt.collectionId||N.collectionId,feedId:tt.feedId||N.feedId,attributes:ct}}),styling:{backgroundColor:Vt(p.background),cardBackground:Vt(p.cardBackground)||Vt(p.background)||"#ffffff",cardBorderRadius:M!==void 0?M:10,cardRadiusPercent:C,transparent:p.transparent===!0,textColor:p.textColor||"#ffffff",buttonBackground:p.buttonBackground||"#000000",buttonTextColor:p.buttonTextColor||"#ffffff",buttonFontSize:p.buttonFontSize||12,buttonBorderRadius:p.buttonBorderRadius!==void 0?p.buttonBorderRadius:100,titleColor:p.titleColor||p.textColor||"#1a1a2e",titleFontSize:p.titleFontSize||14,titleFontWeight:p.titleFontWeight?String(p.titleFontWeight):"600",priceColor:p.priceColor||p.textColor||"#1a1a2e",priceFontSize:p.priceFontSize||16,priceFontWeight:p.priceFontWeight?String(p.priceFontWeight):"700",mrpColor:p.mrpColor||"#8b8b98",mrpFontSize:p.mrpFontSize||12,mrpFontWeight:p.mrpFontWeight?String(p.mrpFontWeight):"500",imageRadius:p.imageRadius!==void 0?Number(p.imageRadius)*a:10,animation:to(p.animation)}}}),w=u.map(d=>{let T=d.position||d.postion||{x:0,y:0};return{id:d.id||Math.random().toString(),type:"image",x:T.x/r*100,y:T.y/s*100,width:d.width/r*100,height:d.height?d.height/s*100:void 0,url:d.link||d.url,z:d.z??0}}),I=x.map(d=>{let T=d.position||{x:0,y:0},l=d.font||{};return{id:d.id||Math.random().toString(),type:"text",x:T.x/r*100,y:T.y/s*100,width:d.size?.width?d.size.width/r*100:void 0,text:d.value,z:d.z??1,styling:{color:d.color||"#000000",fontSize:l.fontSize?l.fontSize*a:void 0,fontFamily:dt(l.fontFamily),fontStyle:l.fontStyle,fontWeight:l.fontWeight}}}),B=[...b,...h,...y,...w,...I].filter(d=>{if(!d.duration)return!0;let{start:T,end:l}=d.duration;return i>=T&&i<=l}).sort((d,T)=>(d.z??0)-(T.z??0));return(0,ze.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,pointerEvents:"none",overflow:"hidden"},children:[(0,ze.jsx)("style",{children:`
|
|
52
|
+
`}),i.map(b=>(0,ut.jsxs)("div",{style:g,className:"shopable-card",onClick:h=>u(h,b),children:[(0,ut.jsx)("div",{style:v,children:(0,ut.jsx)("img",{src:b.image,alt:b.title,style:{width:"100%",height:"100%",objectFit:"cover"}})}),(0,ut.jsxs)("div",{style:f,children:[(0,ut.jsx)("span",{style:{color:n?.titleColor||n?.textColor||"#1a1b2e",fontSize:n?.titleFontSize?`${n.titleFontSize}px`:"15px",fontWeight:n?.titleFontWeight||"700",lineHeight:"1.2",display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"1px"},children:b.title}),(0,ut.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",flexWrap:"wrap"},children:[(0,ut.jsx)("span",{style:{color:n?.priceColor||n?.textColor||"#1a1b2e",fontSize:n?.priceFontSize?`${n.priceFontSize}px`:"18px",fontWeight:n?.priceFontWeight||"800",display:"block"},children:b.price}),b.oldPrice&&(0,ut.jsx)("span",{style:{color:n?.mrpColor||"#8b8b98",fontSize:n?.mrpFontSize?`${n.mrpFontSize}px`:"12px",fontWeight:n?.mrpFontWeight||"500",textDecoration:"line-through"},children:b.oldPrice})]})]}),(0,ut.jsx)("div",{style:{backgroundColor:n?.buttonBackground||"#000000",color:n?.buttonTextColor||"#ffffff",fontSize:n?.buttonFontSize?`${n.buttonFontSize}px`:"14px",fontWeight:"700",padding:"10px 18px",borderRadius:n?.buttonBorderRadius!==void 0?`${n.buttonBorderRadius}px`:"100px",textAlign:"center",flexShrink:0,whiteSpace:"nowrap"},children:"Buy Now"})]},b.id))]}),r&&a&&(0,ut.jsx)(ei,{product:a,styling:n,onClose:()=>s(!1),onAddToCart:x})]})};var yt=require("react/jsx-runtime"),ni=({data:t,onInteraction:e,isEditing:o=!1})=>{let i={x:10,y:15,width:80,rotation:0},n=t.x??i.x,r=t.y??i.y,s=t.width??i.width,a=t.rotation??i.rotation,c={position:"absolute",top:`${r}%`,left:`${n}%`,width:`${s}%`,height:t.height?`${t.height}%`:"auto",transform:`rotate(${a}deg)`,zIndex:10,transformOrigin:"center center",boxSizing:"border-box",cursor:o?"move":"default",pointerEvents:"auto"},u={width:"100%",height:"100%",animation:t.styling?.animation,animationFillMode:"forwards"},x=()=>{switch(t.type){case"poll":return(0,yt.jsx)(Wn,{data:t,onInteraction:e,isEditing:o});case"quiz":return(0,yt.jsx)(On,{data:t,onInteraction:e,isEditing:o});case"rating":return(0,yt.jsx)(Hn,{data:t,onInteraction:e,isEditing:o});case"question":case"input":return(0,yt.jsx)(Yn,{data:t,onInteraction:e,isEditing:o});case"image_quiz":return(0,yt.jsx)(Gn,{data:t,onInteraction:e,isEditing:o});case"countdown":return(0,yt.jsx)(jn,{data:t,onInteraction:e,isEditing:o});case"promo_code":case"promo":return(0,yt.jsx)(qn,{data:t,onInteraction:e,isEditing:o});case"reaction":return(0,yt.jsx)(Un,{data:t,onInteraction:e,isEditing:o});case"buy":case"shopable":return(0,yt.jsx)(oi,{data:t,onInteraction:e,isEditing:o});case"image":return(0,yt.jsx)("img",{src:t.url,alt:"static overlay",style:{width:"100%",height:"100%",objectFit:"fill"}});case"text":{let g=t.styling||{};return(0,yt.jsx)("span",{style:{color:g.color||"#000000",fontSize:`${g.fontSize||14}px`,fontFamily:dt(g.fontFamily)||"Arial",fontStyle:g.fontStyle||"normal",fontWeight:g.fontWeight||"normal",wordBreak:"break-word",display:"inline-block"},children:t.text})}default:return(0,yt.jsxs)("div",{style:{padding:"10px",background:"white",color:"black",borderRadius:"4px"},children:["Unsupported interactive element: ",t.type]})}};return(0,yt.jsx)("div",{style:c,className:`interactive-item-z${t.z??0}`,children:(0,yt.jsx)("div",{style:u,children:x()})})};var Yt=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}let e=t.color||{};if(e.type==="gradient"&&e.gradient){let{direction:o="right",from:i,to:n,stops:r=[]}=e.gradient,a={right:"to right",left:"to left",top:"to top",bottom:"to bottom"}[o]||o;if(r.length>0){let c=r.map(u=>`${u.color} ${Math.round((u.offset||0)*100)}%`).join(", ");return`linear-gradient(${a}, ${c})`}return`linear-gradient(${a}, ${i}, ${n})`}return e.solid||e.value||void 0},Ze=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`};var Ie=require("react/jsx-runtime"),ii=(t,e)=>{let o=t?.styling?.editorSource||t?.styling?.meta?.editorSource||t?.style?.editorSource||e?.editorSource||e?.meta?.editorSource;return o==="studio"||o==="editor"?"studio":"dashboard"},le=(t,e)=>Array.isArray(t)?t.map((o,i)=>{let n=o?.id||o?.key||o?.value||`option_${i+1}`,r=o?.label||o?.optionLabel,s=typeof o=="string"?o:o?.text||o?.title||r||"";return{id:String(n),text:s,image:o?.image||o?.imageUrl||"",label:r,isCorrect:o?.isCorrect===!0||String(n)===String(e)}}):t&&typeof t=="object"?Object.entries(t).map(([o,i])=>{let n=typeof i=="string"?{text:i}:i||{};return{id:o,text:n.text||n.title||n.label||"",image:n.image||n.imageUrl||"",label:n.label,isCorrect:o===String(e)}}):[],ri=t=>Array.isArray(t?.emojis)?t.emojis.map(e=>String(e)):le(t?.options).map(e=>e.text).filter(Boolean),si=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},ai=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()}},No=({content:t={},onInteraction:e,isEditing:o=!1,elapsedTime:i=0})=>{let n=t?.canva||{height:1920,width:1080},r=n?.width||1080,s=n?.height||1920,a=.352,c=t?.elements||[],u=t?.image||[],x=t?.text||[],m=t?.interactions||[],g=Array.isArray(t?.shopable)&&t.shopable.length>0?t.shopable:Array.isArray(t?.styling?.shopable)?t.styling.shopable:[],v=new Set(g.map(d=>d.id)),f=(t?.styling?.shopable||[]).concat(g.map(d=>d.styling).filter(Boolean));if(c.length===0&&u.length===0&&x.length===0&&m.length===0&&g.length===0)return null;let b=c.filter(d=>!v.has(d.id)).map(d=>{let T=d.custom||{},l=T.data||{},p=T.style||d.styling||{},O=ii(d,t),A=d.position||d.postion||{},_=d.size||{},C=d.x!==void 0?d.x:A.x,S=d.y!==void 0?d.y:A.y,W=d.width!==void 0?d.width:_.width,P=C!==void 0&&!isNaN(Number(C))?Number(C)/r*100:10,M=S!==void 0&&!isNaN(Number(S))?Number(S)/s*100:15,$=W!==void 0&&!isNaN(Number(W))?Number(W)/r*100:80,k={id:d.id||Math.random().toString(),type:si(T.interactiveType||d.widgetType||d.type||"unknown"),x:P,y:M,width:$,rotation:p.rotation??d.rotation??0,z:d.z??d.position?.z??p.z??10,duration:l.duration||p.duration,styling:{backgroundColor:Yt(p.background||p.containerBgColor||p.backgroundColor),borderRadius:p.borderRadius!==void 0?p.borderRadius>=100?999:p.borderRadius*a:p.radius!==void 0?p.radius>=100?999:p.radius*a:0,padding:(p.containerPadding!==void 0?p.containerPadding:p.padding!==void 0?p.padding:0)*a,shadow:p.shadow,fontSize:p.questionFontSize?p.questionFontSize*a:void 0,opacity:p.opacity??1,animation:Ze(p.animation)}};if(k.type==="poll"){let L=le(l.options);return{...k,type:"poll",question:l.question||l.title||"Poll Question",options:L,layout:l.layout||{type:"vertical",columns:1},styling:{...k.styling,headerColor:p.headerBgColor||p.background,headerTextColor:p.questionColor||p.questionTextColor||p.question?.color,optionBgColor:p.optionBgColor||p.options?.background||"#1A1A1A",optionTextColor:p.optionTextColor||p.options?.textColor||"#ffffff",optionBorderRadius:p.optionBorderRadius!==void 0?p.optionBorderRadius*a:p.options?.radius!==void 0?p.options?.radius*a:0}}}if(k.type==="quiz"){let L=p.colors||{},j=le(l.options,l.isCorrect);return{...k,type:"quiz",question:l.question||l.title||"Quiz Question",options:j,showExplanation:l.showExplanation,url:l.url,styling:{...k.styling,backgroundColor:p.background||p.containerBgColor||p.backgroundColor||"transparent",questionTextColor:p.questionColor||L.questionColor||p.question?.color||p.colors?.questionText||"#FF0000",questionBgColor:p.questionBgColor||L.questionBackground||p.question?.background||p.colors?.questionBg||"#3BFF00",optionBgColor:p.optionBgColor||L.optionBackground||p.options?.background||p.colors?.optionBg||"#C100FF",optionTextColor:p.optionTextColor||L.optionTextColor||p.options?.textColor||p.colors?.optionText||"#ffffff",borderColor:p.borderColor||"transparent",activeColor:p.correctColor||L.correctColor||p.correctBorderColor||"#00D9FF",incorrectColor:p.incorrectColor||L.incorrectColor||"#ef4444",optionBorderRadius:p.optionRadius!==void 0?p.optionRadius>=100?999:p.optionRadius*a:p.optionBorderRadius!==void 0?p.optionBorderRadius>=100?999:p.optionBorderRadius*a:100,optionFontSize:(p.optionFontSize?p.optionFontSize:p.typography?.optionSize?p.typography?.optionSize:p.options?.fontSize?p.options?.fontSize:16)*a*1.25}}}if(k.type==="rating")return{...k,type:"rating",title:l.title||"Do you like my space?",emoji:l.emoji||"\u{1F60D}",currentRating:l.currentRating,maxRating:l.maxRating,styling:{...k.styling,sliderTrackColor:p.colors?.sliderTrack||p.sliderTrack,sliderFillColor:p.colors?.sliderFill||p.sliderFill,emojiSize:p.emojiSize?p.emojiSize*.45:void 0,titleColor:p.colors?.titleColor||p.titleColor,titleFontSize:p.titleFontSize?p.titleFontSize*.4:void 0}};if(k.type==="question")return{...k,type:"question",question:l.question||l.title||"Ask me a question",placeholder:l.placeholder||"Type your answer...",styling:{...k.styling,promptColor:p.questionColor||p.textColor,inputBgColor:p.inputBgColor,inputTextColor:p.inputTextColor,submitBackground:p.submitBackground}};if(k.type==="image_quiz"||k.type==="imageQuiz"||(T.interactiveType||"").toLowerCase()==="media_quiz")return{...k,type:"image_quiz",question:l.question||l.title||"Image Quiz",options:le(l.options||[]),styling:{...k.styling,questionTextColor:p.questionColor,activeColor:p.correctColor||p.correctBorderColor,incorrectColor:p.incorrectColor,imageRadius:p.imageRadius?p.imageRadius*a:void 0}};if(k.type==="countdown")return{...k,type:"countdown",title:l.title||"Ends in...",targetDate:ai(l),styling:{...k.styling,borderColor:p.borderColor,digitBackground:p.digitBackground,digitColor:p.digitColor,digitSize:p.digitSize?p.digitSize*a:void 0,labelColor:p.labelColor,titleColor:p.titleColor},display:l.display};if(k.type==="promo_code")return{...k,type:"promo_code",code:l.code||"CODE20",styling:{...k.styling,borderColor:p.borderColor}};if(k.type==="reaction"||k.type==="emoji_reaction"){let L=ri(l);return{...k,type:"reaction",emojis:L.length>0?L:["\u{1F60D}","\u{1F44D}"],source:O}}return k}),h=(t?.interactions||[]).filter(d=>!v.has(d.id)).map(d=>{let T=d.config||{},l=d.styling||d.style||{},p=ii(d,t),O=si(d.interaction_type||d.type),A=l.position||d.position||{},_=l.size||d.size||{},C=A.x??d.x,S=A.y??d.y,W=_.width??d.width,P=_.height??d.height,M=C!==void 0&&!isNaN(Number(C))?Number(C)/r*100:10,$=S!==void 0&&!isNaN(Number(S))?Number(S)/s*100:15,k=W!==void 0&&!isNaN(Number(W))?Number(W)/r*100:80,L=P!==void 0&&!isNaN(Number(P))?Number(P)/s*100:void 0,j={id:d.id||Math.random().toString(),type:O,x:M,y:$,width:k,height:L,rotation:l.rotation??d.rotation??0,z:d.z??d.position?.z??l.z??10,source:p,duration:T.duration||l.duration,styling:{backgroundColor:Yt(l.background||l.containerBgColor||l.backgroundColor),borderRadius:l.borderRadius!==void 0?l.borderRadius>=100?999:l.borderRadius*a:l.radius!==void 0?l.radius>=100?999:l.radius*a:0,padding:(l.containerPadding!==void 0?l.containerPadding:l.padding!==void 0?l.padding:0)*a,shadow:l.shadow,fontSize:l.questionSize?l.questionSize*a:l.questionFontSize?l.questionFontSize*a:void 0,opacity:l.opacity??1,animation:Ze(l.animation)}};if(j.type==="rating"||j.type==="rate"){let X=l.colors||{};return{...j,type:"rating",title:T.title||"Do you like my space?",emoji:T.emoji||"\u{1F60D}",currentRating:T.currentRating,maxRating:T.maxRating,styling:{...j.styling,sliderTrackColor:X.sliderTrack||l.colors?.sliderTrack||l.colors?.sliderTrack,sliderFillColor:X.sliderFill||l.colors?.sliderFill||l.sliderFill,emojiSize:l.emojiSize?l.emojiSize*.45:void 0,titleColor:X.titleColor||l.colors?.titleColor||l.titleColor,titleFontSize:l.titleFontSize?l.titleFontSize*.4:void 0}}}if(j.type==="poll"){let X=le(T.options);return{...j,type:"poll",question:T.question||T.title||"Poll Question",options:X,layout:T.layout||{type:"vertical",columns:1},styling:{...j.styling,headerColor:l.headerBgColor||l.background,headerTextColor:l.questionColor||l.questionTextColor||l.question?.color,optionBgColor:l.optionBgColor||l.options?.background||"#1A1A1A",optionTextColor:l.optionTextColor||l.options?.textColor||"#ffffff",optionBorderRadius:l.optionBorderRadius!==void 0?l.optionBorderRadius*a:l.options?.radius!==void 0?l.options?.radius*a:0}}}if(j.type==="quiz"){let X=l.colors||{},ft=le(T.options,T.isCorrect);return{...j,type:"quiz",question:T.question||T.title||"Quiz Question",options:ft,showExplanation:T.showExplanation,url:T.url,styling:{...j.styling,backgroundColor:l.background||l.containerBgColor||l.backgroundColor||"transparent",questionTextColor:l.questionColor||X.questionColor||l.question?.color||l.colors?.questionText||"#FF0000",questionBgColor:l.questionBgColor||X.questionBackground||l.question?.background||l.colors?.questionBg||"#3BFF00",optionBgColor:l.optionBgColor||X.optionBackground||l.options?.background||l.colors?.optionBg||"#C100FF",optionTextColor:l.optionTextColor||X.optionTextColor||l.options?.textColor||l.colors?.optionText||"#ffffff",borderColor:l.borderColor||"transparent",activeColor:l.correctColor||X.correctColor||l.correctBorderColor||"#00D9FF",incorrectColor:l.incorrectColor||X.incorrectColor||"#ef4444",optionBorderRadius:l.optionRadius!==void 0?l.optionRadius>=100?999:l.optionRadius*a:l.optionBorderRadius!==void 0?l.optionBorderRadius>=100?999:l.optionBorderRadius*a:100,optionFontSize:(l.optionFontSize?l.optionFontSize:l.typography?.optionSize?l.typography?.optionSize:l.options?.fontSize?l.options?.fontSize:16)*a*1.25}}}if(j.type==="question")return{...j,type:"question",question:T.question||T.title||"Ask me a question",placeholder:T.placeholder||"Type your answer...",styling:{...j.styling,promptColor:l.questionColor||l.promptColor||l.textColor,inputBgColor:l.inputBackground||l.inputBgColor,inputTextColor:l.inputTextColor,submitBackground:l.submitBackground}};if(j.type==="image_quiz"||j.type==="imageQuiz"||O==="media_quiz")return{...j,type:"image_quiz",question:T.question||T.title||"Image Quiz",options:le(T.options||[]),styling:{...j.styling,questionTextColor:l.questionColor,activeColor:l.correctColor||l.correctBorderColor,incorrectColor:l.incorrectColor,imageRadius:l.imageRadius?l.imageRadius*a:void 0}};if(j.type==="countdown")return{...j,type:"countdown",title:T.title||"Ends in...",targetDate:ai(T),styling:{...j.styling,borderColor:l.borderColor,digitBackground:l.digitBackground,digitColor:l.digitColor,digitSize:l.digitSize||l.fontSize?Number(l.digitSize||l.fontSize):void 0,labelColor:l.labelColor,titleColor:l.titleColor,labelFontSize:l.labelFontSize?Number(l.labelFontSize):void 0},display:T.display||d.display};if(j.type==="promo_code")return{...j,type:"promo_code",code:T.code||"CODE20",styling:{...j.styling,borderColor:l.borderColor}};if(j.type==="reaction"||j.type==="emoji_reaction"){let X=ri(T);return{...j,type:"reaction",emojis:X.length>0?X:["\u{1F60D}","\u{1F44D}"]}}return j}),y=g.map(d=>{let T=f.find(N=>String(N?.id)===String(d?.id))||f.find(N=>N?.id===void 0)||{},l={position:d?.position,size:d?.size,rotation:d?.rotation,z:d?.z,background:d?.background,cardBackground:d?.cardBackground,cardBorderRadius:d?.cardBorderRadius,cardRadiusPercent:d?.cardRadiusPercent,transparent:d?.transparent,textColor:d?.textColor,buttonBackground:d?.buttonBackground,buttonTextColor:d?.buttonTextColor,buttonFontSize:d?.buttonFontSize,buttonBorderRadius:d?.buttonBorderRadius,titleColor:d?.titleColor,titleFontSize:d?.titleFontSize,titleFontWeight:d?.titleFontWeight,priceColor:d?.priceColor,priceFontSize:d?.priceFontSize,priceFontWeight:d?.priceFontWeight,mrpColor:d?.mrpColor,mrpFontSize:d?.mrpFontSize,mrpFontWeight:d?.mrpFontWeight,imageRadius:d?.imageRadius,opacity:d?.opacity,animation:d?.animation},p={...T,...d?.styling||{},...Object.fromEntries(Object.entries(l).filter(([,N])=>N!==void 0))},O=p.position||{},A=p.size||{},_=p.cardBorderRadius!==void 0?Number(p.cardBorderRadius):void 0,C=p.cardRadiusPercent!==void 0?Number(p.cardRadiusPercent):void 0,S=A.height!==void 0?Number(A.height):void 0,W=_===void 0&&C!==void 0&&S!==void 0?Math.max(0,Math.min(100,C))/100*(S/2):void 0,P=_??W,M=P!==void 0&&!isNaN(P)?P*a:void 0,$=O.x!==void 0?Number(O.x)/r*100:0,k=A.width!==void 0?Number(A.width)/r*100:100,L=A.height!==void 0?Number(A.height)/s*100:void 0,j=O.y!==void 0?Number(O.y)/s*100:L?100-L-2.5:85;L&&j+L>96?j=Math.max(0,100-L):j>75&&L&&j+L>91&&(j=Math.max(0,100-L-1));let X=Array.isArray(d.product)&&d.product.length>0,ft=X?d.product:d.static||[];return{id:d.id||Math.random().toString(),type:"buy",shopableType:X?"product":"static",x:$,y:j,width:k,height:L,rotation:p.rotation??0,z:p.z??10,products:ft.map(N=>{let tt=N.productData||N||{},K=tt.attributes||N.attributes||{},Y=K.sales_price||tt.price||K.price||N.price,nt=K.sales_price?tt.price||K.price||N.price:tt.oldPrice||N.oldPrice,U=tt.color||K.color||N.color,G=tt.size||K.size||N.size,Q=K.colors||[];Q.length===0&&U&&(Q=[{id:U,hex:U,name:U}]);let at=K.sizes||[];at.length===0&&G&&(at=typeof G=="string"?G.split(",").map(rt=>rt.trim()):[G]);let St={description:tt.description||K.description||N.description,color:U,size:G,colors:Q,sizes:at,imageUrls:K.imageUrls||[K.image_link||tt.imageUrl||tt.image||N.imageUrl||N.image||N.url].filter(Boolean),availability:tt.availability||K.availability||N.availability,tags:tt.tags||K.tags||N.tags,...K};return{id:tt.productId||tt.id||N.productId||N.id||Math.random().toString(),image:K.image_link||tt.imageUrl||tt.image||N.imageUrl||N.image||N.url,url:tt.link||tt.url||N.link||N.url||N.redirectUrl,title:tt.title||N.title,price:Y,oldPrice:nt,redirectUrl:N.redirectUrl||tt.link||N.link||N.url,svg:tt.svg||N.svg,productId:tt.productId||N.productId,collectionId:tt.collectionId||N.collectionId,feedId:tt.feedId||N.feedId,attributes:St}}),styling:{backgroundColor:Yt(p.background),cardBackground:Yt(p.cardBackground)||Yt(p.background)||"#ffffff",cardBorderRadius:M!==void 0?M:10,cardRadiusPercent:C,transparent:p.transparent===!0,textColor:p.textColor||"#ffffff",buttonBackground:p.buttonBackground||"#000000",buttonTextColor:p.buttonTextColor||"#ffffff",buttonFontSize:p.buttonFontSize||12,buttonBorderRadius:p.buttonBorderRadius!==void 0?p.buttonBorderRadius:100,titleColor:p.titleColor||p.textColor||"#1a1a2e",titleFontSize:p.titleFontSize||14,titleFontWeight:p.titleFontWeight?String(p.titleFontWeight):"600",priceColor:p.priceColor||p.textColor||"#1a1a2e",priceFontSize:p.priceFontSize||16,priceFontWeight:p.priceFontWeight?String(p.priceFontWeight):"700",mrpColor:p.mrpColor||"#8b8b98",mrpFontSize:p.mrpFontSize||12,mrpFontWeight:p.mrpFontWeight?String(p.mrpFontWeight):"500",imageRadius:p.imageRadius!==void 0?Number(p.imageRadius)*a:10,animation:Ze(p.animation)}}}),w=u.map(d=>{let T=d.position||d.postion||{x:0,y:0};return{id:d.id||Math.random().toString(),type:"image",x:T.x/r*100,y:T.y/s*100,width:d.width/r*100,height:d.height?d.height/s*100:void 0,url:d.link||d.url,z:d.z??0}}),I=x.map(d=>{let T=d.position||{x:0,y:0},l=d.font||{};return{id:d.id||Math.random().toString(),type:"text",x:T.x/r*100,y:T.y/s*100,width:d.size?.width?d.size.width/r*100:void 0,text:d.value,z:d.z??1,styling:{color:d.color||"#000000",fontSize:l.fontSize?l.fontSize*a:void 0,fontFamily:dt(l.fontFamily),fontStyle:l.fontStyle,fontWeight:l.fontWeight}}}),B=[...b,...h,...y,...w,...I].filter(d=>{if(!d.duration)return!0;let{start:T,end:l}=d.duration;return i>=T&&i<=l}).sort((d,T)=>(d.z??0)-(T.z??0));return(0,Ie.jsxs)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,pointerEvents:"none",overflow:"hidden"},children:[(0,Ie.jsx)("style",{children:`
|
|
53
53
|
@keyframes appstorys-fade-in {
|
|
54
54
|
from { opacity: 0; transform: translateY(10px); }
|
|
55
55
|
to { opacity: 1; transform: translateY(0); }
|
|
@@ -69,16 +69,16 @@
|
|
|
69
69
|
70% { opacity: 1; transform: scale(0.95); }
|
|
70
70
|
100% { opacity: 1; transform: scale(1); }
|
|
71
71
|
}
|
|
72
|
-
`}),B.map(d=>!d||typeof d!="object"||!(d.type||"").toLowerCase()?null:(0,ze.jsx)(ei,{data:d,onInteraction:e,isEditing:o},d.id))]})};var si=require("react"),Kt=require("react/jsx-runtime"),ur=({isPaused:t,onPress:e,style:o,size:i=36})=>{let[n,r]=(0,si.useState)(!1);return(0,Kt.jsx)("button",{onClick:e,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{width:`${i}px`,height:`${i}px`,background:n?"rgba(255, 255, 255, 0.15)":"rgba(255, 255, 255, 0.08)",border:n?"1px solid white":"1px solid rgba(255, 255, 255, 0.1)",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"10px",cursor:"pointer",transition:"all 0.2s ease",padding:0,outline:"none",...o},children:t?(0,Kt.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:(0,Kt.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,Kt.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:[(0,Kt.jsx)("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),(0,Kt.jsx)("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})})},ai=ur;var eo=require("react/jsx-runtime"),gr=t=>{switch(t){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},fr=({cta:t,buttonText:e,onPress:o})=>!t||!e||e.trim()===""?null:(0,eo.jsx)("div",{style:{position:"absolute",bottom:t?.margin?.bottom,left:t?.margin?.left,right:t?.margin?.right,display:"flex",justifyContent:gr(t?.container?.alignment),width:"100%",pointerEvents:"none",boxSizing:"border-box",zIndex:10},children:(0,eo.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,eo.jsx)("span",{style:{color:t?.text?.color||"#ffffff",fontSize:t?.text?.fontSize||14,fontFamily:dt(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:Fe(e)})})}),Uo=fr;var le=require("react/jsx-runtime"),mr=({config:t,onPress:e,style:o,ignoreSizeAndMargin:i=!1})=>{if(!t||!t.enabled)return null;let{size:n=18,margin:r,color:s,image:a,selectedStyle:c}=t,u=i?40:n,x={marginTop:i?0:r?.top??0,marginBottom:i?0:r?.bottom??0,marginLeft:i?0:r?.left??0,marginRight:i?0:r?.right??0,width:u,height:u,backgroundColor:s?.fill||"transparent",borderColor:s?.stroke||"transparent",borderWidth:u*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:s?.stroke?"solid":"none",...o},m=()=>{let g=s?.cross||"#ffffff";return(0,le.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,le.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"}),(0,le.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,le.jsx)("button",{onClick:e,style:x,title:c||"",children:a&&a.trim()!==""?(0,le.jsx)("img",{src:a,style:{width:u,height:u,objectFit:"contain"},alt:"close"}):m()})},Yt=mr;var Ft=require("react/jsx-runtime"),Ho=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:i,style:n,type:r})=>{if(!t||!i)return null;let{size:s=18,margin:a,color:c,image:u,selectedStyle:x}=t,m=o?40:s,g=o?0:a?.top??0,v=o?0:a?.bottom??0,f=o?0:a?.left??0,b=o?0:a?.right??0,h={marginTop:g,marginBottom:v,marginLeft:f,marginRight:b,width:m,height:m,backgroundColor:c?.fill||"transparent",borderColor:c?.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},...n},y=()=>{let w=c?.cross||"#ffffff";return r==="mute"?(0,Ft.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Ft.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,Ft.jsx)("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"}),(0,Ft.jsx)("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"})]}):(0,Ft.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,Ft.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,Ft.jsx)("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"}),(0,Ft.jsx)("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,Ft.jsx)("button",{onClick:e,style:{...h,border:h.borderColor?`${h.borderWidth}px solid ${h.borderColor}`:"none",padding:0,cursor:"pointer",outline:"none"},title:x||"",children:u&&u.trim()!==""?(0,Ft.jsx)("img",{src:u,style:{width:m,height:m,objectFit:"contain"},alt:r}):y()})};var Nt=require("react/jsx-runtime"),yr=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,style:i})=>{if(!t||t.enabled===!1)return null;let{size:n=18,margin:r,color:s,image:a,selectedStyle:c}=t,u=o?40:n,x={marginTop:o?0:r?.top??0,marginBottom:o?0:r?.bottom??0,marginLeft:o?0:r?.left??0,marginRight:o?0:r?.right??0,width:u,height:u,backgroundColor:s?.fill||"transparent",borderColor:s?.stroke||"transparent",borderWidth:u*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:s?.stroke?"solid":"none",...i},m=()=>{let g=s?.cross||"#ffffff";return(0,Nt.jsxs)("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"none",stroke:g,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,Nt.jsx)("circle",{cx:"18",cy:"5",r:"3"}),(0,Nt.jsx)("circle",{cx:"6",cy:"12",r:"3"}),(0,Nt.jsx)("circle",{cx:"18",cy:"19",r:"3"}),(0,Nt.jsx)("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),(0,Nt.jsx)("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})};return(0,Nt.jsx)("button",{onClick:e,style:x,title:c||"",children:a&&a.trim()!==""?(0,Nt.jsx)("img",{src:a,style:{width:u,height:u,objectFit:"contain"},alt:"share"}):m()})},li=yr;var z=require("react/jsx-runtime"),be=400,Vo=700,Be=.63,Go=420,di=Go+be*Be+27,Qt=580,Yo="cubic-bezier(0.65, 0, 0.35, 1)",Qo="cubic-bezier(0.45, 0, 0.25, 1)";function hr(t){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(-${Go}px) scale(${Be})`,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(${Go}px) scale(${Be})`,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(-${di}px) scale(${Be})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};case"far-right":return{transform:`translateX(${di}px) scale(${Be})`,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 ci=({src:t,isActive:e,isAnimating:o,isMuted:i,onLoadedData:n,activeVideoRef:r})=>{let s=it.default.useRef(null);return it.default.useEffect(()=>{e&&!o?(r.current=s.current,s.current?.play().catch(()=>{})):(s.current?.pause(),r.current===s.current&&(r.current=null))},[e,o,t,r]),(0,z.jsx)("video",{ref:s,src:t,playsInline:!0,muted:i,onLoadedData:e&&!o?n:void 0,style:{width:"100%",height:"100%",objectFit:"cover"}})},pi=({stories:t,activeStoryIndex:e,dataId:o,viewedStories:i,setViewedStories:n,onNextStory:r,onPrevStory:s,onClose:a})=>{let[c,u]=(0,it.useState)(0),[x,m]=(0,it.useState)(0),[g,v]=(0,it.useState)(!1),[f,b]=(0,it.useState)(!1),[h,y]=(0,it.useState)(!1),[w,I]=(0,it.useState)(!1),[B,R]=(0,it.useState)(null),[d,T]=(0,it.useState)(typeof window<"u"?window.innerWidth>=1024:!1),[l,p]=(0,it.useState)(!1),[O,A]=(0,it.useState)(null),[_,C]=(0,it.useState)(null),[S,W]=(0,it.useState)(null);(0,it.useEffect)(()=>{let E=()=>{T(window.innerWidth>=1024)};return window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[]);let P=(0,it.useRef)(null),M=(0,it.useRef)(null),$=(0,it.useRef)(0),k=t[e],L=k?.slides[c],j=L?.styling,X=j?.editorSource||j?.meta?.editorSource,mt=X==="studio"||X==="editor",N=mt?j?.background?.media?.mediaUrl:L?.image,tt=mt?L?.content?.button_text:L?.button_text,K=mt?L?.content?.link:L?.link,Y=L?.video||(mt?L?.content?.video?.[0]?.link:void 0),st=async()=>{let E={title:k.name,text:`Check out this story: ${k.name}`,url:window.location.href};if(L?.id&&H("shared",o,{story_slide:L.id}),navigator.share)try{await navigator.share(E)}catch{}else if(navigator.clipboard)try{await navigator.clipboard.writeText(window.location.href),R("Story link copied to clipboard!"),setTimeout(()=>R(null),2500)}catch{}};if((0,it.useEffect)(()=>{u(0),m(0),b(!1),y(!1),p(!1),A(null),C(null),W(null)},[e]),(0,it.useEffect)(()=>{let E=U=>{if(!(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA"))switch(U.key){case"ArrowRight":Q();break;case"ArrowLeft":J();break;case" ":U.preventDefault(),y(rt=>!rt);break;case"Escape":a();break;case"s":case"S":U.preventDefault(),st();break}};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[c,e,h,k,a]),(0,it.useEffect)(()=>{k&&L&&H("viewed",o,{story_slide:L.id})},[c,k?.id,o]),(0,it.useEffect)(()=>{if(k&&L){let E=k.styling?.slideShowTime||5,U=!!Y;if(P.current&&clearInterval(P.current),h){M.current&&M.current.pause();return}else M.current&&M.current.play().catch(()=>{});return U&&!f||l?void 0:(P.current=setInterval(()=>{m(rt=>rt>=100?(Q(),100):rt+100/(E*10))},100),()=>{P.current&&clearInterval(P.current)})}},[e,c,h,f,l]),!L)return null;let q=(E,U)=>{l||(W(E),A(c),C(U),p(!0),setTimeout(()=>{u(U),m(0),b(!1),p(!1),A(null),C(null),W(null)},Qt+20))},Q=()=>{if(!l)if(c<k.slides.length-1)q("next",c+1);else{if(!i.includes(k.id)){let E=[...i,k.id];n(E),localStorage.setItem("app_storys_viewed_stories",JSON.stringify(E))}r()}},J=()=>{l||(c>0?q("prev",c-1):s())},ot=()=>{$.current=Date.now(),y(!0)},ct=E=>{y(!1),Date.now()-$.current<300&&(E==="next"?Q():J())},at=()=>b(!0),Pt=E=>{let U=E?.styling,rt=U?.editorSource||U?.meta?.editorSource,bt=rt==="studio"||rt==="editor"?E.content?.link:E.link;bt&&(H("clicked",o,{story_slide:E.id}),bt.startsWith("http")?window.open(bt,"_blank"):window.location.href=bt)},Ut=E=>{E.stopPropagation(),v(!g)},ve=k?.styling?.crossButton,te=k?.styling?.soundToggle,Nr=L?.styling?.cta,nn=E=>l?S==="next"?E===O?"left":E===_?"center":E===(O??0)-1?"far-left":E===(O??0)-2?"hidden":E===(_??0)+1?"right":E===(_??0)+2?"far-right":"hidden":E===O?"right":E===_?"center":E===(O??0)+1?"far-right":E===(O??0)+2?"hidden":E===(_??0)-1?"left":E===(_??0)-2?"far-left":"hidden":E===c?"center":E===c-1?"left":E===c-2?"far-left":E===c+1?"right":E===c+2?"far-right":"hidden",Bi=d?{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",background:"radial-gradient(circle at center, #0B1424 0%, #03070E 100%)",zIndex:1e5,display:"flex",flexDirection:"column",alignItems:"center",overflow:"hidden",color:"white"}:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.95)",zIndex:1e5,display:"flex",justifyContent:"center",alignItems:"center"},rn=d?{position:"absolute",width:`${be}px`,height:`${Vo}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:"100%",maxWidth:"450px",height:"100%",maxHeight:"850px",backgroundColor:"#000",borderRadius:"0px",overflow:"hidden",display:"flex",flexDirection:"column"},qr={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"},Ai=k.slides.reduce((E,U,rt)=>(nn(rt)!=="hidden"&&E.push(rt),E),[]),ce=new Set(Ai);return ce.add(c),c>0&&ce.add(c-1),c>1&&ce.add(c-2),c<k.slides.length-1&&ce.add(c+1),c<k.slides.length-2&&ce.add(c+2),(0,z.jsxs)("div",{style:Bi,onClick:()=>!d&&Q(),children:[(0,z.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:[Y?(0,z.jsx)("video",{src:Y,style:{width:"100%",height:"100%",objectFit:"cover",filter:"blur(120px) saturate(1.8) opacity(0.35)"},muted:!0}):(0,z.jsx)(Mt,{src:N||k.thumbnail,style:{width:"100%",height:"100%",filter:"blur(120px) saturate(1.8) opacity(0.35)"}}),(0,z.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(5, 5, 8, 0.4)"}})]},`${e}-${l?_:c}`),d&&(0,z.jsxs)("div",{style:{width:"100%",display:"flex",flexDirection:"column",paddingTop:"20px",zIndex:10},children:[(0,z.jsx)("div",{style:{width:"100%",display:"flex",gap:"8px",padding:"0 20px",boxSizing:"border-box"},children:k.slides.map((E,U)=>{let rt=l&&_!==null?_:c,Lt="0%";return U<rt?Lt="100%":U===rt&&(Lt=`${x}%`),(0,z.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.15)",borderRadius:"2px",overflow:"hidden"},children:(0,z.jsx)("div",{style:{width:Lt,height:"100%",backgroundColor:"white",transition:U===rt?"width 0.1s linear":"none"}})},U)})}),(0,z.jsxs)("div",{style:{width:"100%",maxWidth:"1400px",margin:"0 auto",display:"grid",gridTemplateColumns:`minmax(0, 1fr) ${be}px minmax(0, 1fr)`,gap:"12px",alignItems:"center",marginTop:"16px",padding:"0 20px",boxSizing:"border-box",zIndex:w?2e3:10},children:[(0,z.jsx)("div",{style:{paddingLeft:"0px"}}),(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,z.jsx)(Mt,{src:k.thumbnail,alt:k.name,style:{width:"44px",height:"44px",borderRadius:"50%",border:"2px solid white",margin:0}}),(0,z.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"16px",whiteSpace:"nowrap"},children:k.name})]}),(0,z.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,z.jsx)(li,{config:{enabled:k?.styling?.share?.enabled??!0,image:k?.styling?.share?.image??"",color:{cross:k?.styling?.share?.color?.cross??"#ffffff",fill:k?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:k?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:k?.styling?.share?.size??44},onPress:st,style:{position:"relative",borderRadius:"12px"}}),(0,z.jsx)(Ho,{config:{size:44,color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:Ut,type:g?"mute":"unmute",enabled:!!te?.enabled&&!!Y,style:{position:"relative",borderRadius:"12px"}}),(0,z.jsx)(ai,{isPaused:h,onPress:()=>y(!h),size:44,style:{borderRadius:"12px"}})]})]}),(0,z.jsxs)("div",{style:{display:"flex",gap:"10px",flex:1,justifyContent:"flex-end",paddingRight:"0px"},children:[(0,z.jsxs)("div",{style:{position:"relative"},children:[(0,z.jsx)("button",{onClick:()=>{I(!w),y(!w)},style:{width:"44px",height:"44px",background:w?"rgba(255,255,255,0.15)":"rgba(255,255,255,0.08)",border:w?"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,z.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,z.jsx)("rect",{x:"3",y:"3",width:"7",height:"7"}),(0,z.jsx)("rect",{x:"14",y:"3",width:"7",height:"7"}),(0,z.jsx)("rect",{x:"14",y:"14",width:"7",height:"7"}),(0,z.jsx)("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),w&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("style",{children:`
|
|
72
|
+
`}),B.map(d=>!d||typeof d!="object"||!(d.type||"").toLowerCase()?null:(0,Ie.jsx)(ni,{data:d,onInteraction:e,isEditing:o},d.id))]})};var li=require("react"),Zt=require("react/jsx-runtime"),gr=({isPaused:t,onPress:e,style:o,size:i=36})=>{let[n,r]=(0,li.useState)(!1);return(0,Zt.jsx)("button",{onClick:e,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{width:`${i}px`,height:`${i}px`,background:n?"rgba(255, 255, 255, 0.15)":"rgba(255, 255, 255, 0.08)",border:n?"1px solid white":"1px solid rgba(255, 255, 255, 0.1)",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"10px",cursor:"pointer",transition:"all 0.2s ease",padding:0,outline:"none",...o},children:t?(0,Zt.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:(0,Zt.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,Zt.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"white",children:[(0,Zt.jsx)("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),(0,Zt.jsx)("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})})},di=gr;var to=require("react/jsx-runtime"),fr=t=>{switch(t){case"left":return"flex-start";case"right":return"flex-end";default:return"center"}},mr=({cta:t,buttonText:e,onPress:o})=>!t||!e||e.trim()===""?null:(0,to.jsx)("div",{style:{position:"absolute",bottom:t?.margin?.bottom,left:t?.margin?.left,right:t?.margin?.right,display:"flex",justifyContent:fr(t?.container?.alignment),width:"100%",pointerEvents:"none",boxSizing:"border-box",zIndex:10},children:(0,to.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,to.jsx)("span",{style:{color:t?.text?.color||"#ffffff",fontSize:t?.text?.fontSize||14,fontFamily:dt(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:Te(e)})})}),qo=mr;var de=require("react/jsx-runtime"),yr=({config:t,onPress:e,style:o,ignoreSizeAndMargin:i=!1})=>{if(!t||!t.enabled)return null;let{size:n=18,margin:r,color:s,image:a,selectedStyle:c}=t,u=i?40:n,x={marginTop:i?0:r?.top??0,marginBottom:i?0:r?.bottom??0,marginLeft:i?0:r?.left??0,marginRight:i?0:r?.right??0,width:u,height:u,backgroundColor:s?.fill||"transparent",borderColor:s?.stroke||"transparent",borderWidth:u*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:s?.stroke?"solid":"none",...o},m=()=>{let g=s?.cross||"#ffffff";return(0,de.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,de.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"}),(0,de.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18",stroke:g,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,de.jsx)("button",{onClick:e,style:x,title:c||"",children:a&&a.trim()!==""?(0,de.jsx)("img",{src:a,style:{width:u,height:u,objectFit:"contain"},alt:"close"}):m()})},Qt=yr;var It=require("react/jsx-runtime"),Uo=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,enabled:i,style:n,type:r})=>{if(!t||!i)return null;let{size:s=18,margin:a,color:c,image:u,selectedStyle:x}=t,m=o?40:s,g=o?0:a?.top??0,v=o?0:a?.bottom??0,f=o?0:a?.left??0,b=o?0:a?.right??0,h={marginTop:g,marginBottom:v,marginLeft:f,marginRight:b,width:m,height:m,backgroundColor:c?.fill||"transparent",borderColor:c?.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},...n},y=()=>{let w=c?.cross||"#ffffff";return r==="mute"?(0,It.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,It.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,It.jsx)("line",{x1:"16",y1:"8",x2:"21",y2:"16",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"}),(0,It.jsx)("line",{x1:"21",y1:"8",x2:"16",y2:"16",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"})]}):(0,It.jsxs)("svg",{viewBox:"0 0 24 24",width:"70%",height:"70%","aria-hidden":!0,children:[(0,It.jsx)("polygon",{points:"4,10 8,10 13,6 13,18 8,14 4,14",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinejoin:"round"}),(0,It.jsx)("path",{d:"M16 10 Q18 12 16 14",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"}),(0,It.jsx)("path",{d:"M18 8 Q22 12 18 16",fill:"none",stroke:w,strokeWidth:"2.2",strokeLinecap:"round"})]})};return(0,It.jsx)("button",{onClick:e,style:{...h,border:h.borderColor?`${h.borderWidth}px solid ${h.borderColor}`:"none",padding:0,cursor:"pointer",outline:"none"},title:x||"",children:u&&u.trim()!==""?(0,It.jsx)("img",{src:u,style:{width:m,height:m,objectFit:"contain"},alt:r}):y()})};var Ut=require("react/jsx-runtime"),hr=({config:t,onPress:e,ignoreSizeAndMargin:o=!1,style:i})=>{if(!t||t.enabled===!1)return null;let{size:n=18,margin:r,color:s,image:a,selectedStyle:c}=t,u=o?40:n,x={marginTop:o?0:r?.top??0,marginBottom:o?0:r?.bottom??0,marginLeft:o?0:r?.left??0,marginRight:o?0:r?.right??0,width:u,height:u,backgroundColor:s?.fill||"transparent",borderColor:s?.stroke||"transparent",borderWidth:u*.05,borderRadius:"50%",justifyContent:"center",alignItems:"center",zIndex:1e6,position:"absolute",display:"flex",padding:0,cursor:"pointer",outline:"none",borderStyle:s?.stroke?"solid":"none",...i},m=()=>{let g=s?.cross||"#ffffff";return(0,Ut.jsxs)("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"none",stroke:g,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,Ut.jsx)("circle",{cx:"18",cy:"5",r:"3"}),(0,Ut.jsx)("circle",{cx:"6",cy:"12",r:"3"}),(0,Ut.jsx)("circle",{cx:"18",cy:"19",r:"3"}),(0,Ut.jsx)("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),(0,Ut.jsx)("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})};return(0,Ut.jsx)("button",{onClick:e,style:x,title:c||"",children:a&&a.trim()!==""?(0,Ut.jsx)("img",{src:a,style:{width:u,height:u,objectFit:"contain"},alt:"share"}):m()})},ci=hr;var z=require("react/jsx-runtime"),ze=.63,Ho=420,Gt=580,Vo="cubic-bezier(0.65, 0, 0.35, 1)",Yo="cubic-bezier(0.45, 0, 0.25, 1)";function br(t,e){let o=Ho+e*ze+27;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(-${Ho}px) scale(${ze})`,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(${Ho}px) scale(${ze})`,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(-${o}px) scale(${ze})`,opacity:1,filter:"brightness(0.3)",zIndex:2,pointerEvents:"none"};case"far-right":return{transform:`translateX(${o}px) scale(${ze})`,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 pi=({src:t,isActive:e,isAnimating:o,isMuted:i,onLoadedData:n,activeVideoRef:r})=>{let s=it.default.useRef(null);return it.default.useEffect(()=>{e&&!o?(r.current=s.current,s.current?.play().catch(()=>{}),s.current&&s.current.readyState>=2&&n?.()):(s.current?.pause(),r.current===s.current&&(r.current=null))},[e,o,t,r]),(0,z.jsx)("video",{ref:s,src:t,playsInline:!0,muted:i,onLoadedData:e&&!o?n:void 0,style:{width:"100%",height:"100%",objectFit:"cover"}})},ui=({stories:t,activeStoryIndex:e,dataId:o,viewedStories:i,setViewedStories:n,onNextStory:r,onPrevStory:s,onClose:a})=>{let[c,u]=(0,it.useState)(0),[x,m]=(0,it.useState)(0),[g,v]=(0,it.useState)(!1),[f,b]=(0,it.useState)(!1),[h,y]=(0,it.useState)(!1),[w,I]=(0,it.useState)(!1),[B,R]=(0,it.useState)(null),[d,T]=(0,it.useState)(typeof window<"u"?window.innerWidth>=1024:!1),[l,p]=(0,it.useState)(!1),[O,A]=(0,it.useState)(null),[_,C]=(0,it.useState)(null),[S,W]=(0,it.useState)(null);(0,it.useEffect)(()=>{let E=()=>{T(window.innerWidth>=1024)};return window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[]);let P=(0,it.useRef)(null),M=(0,it.useRef)(null),$=(0,it.useRef)(0),k=t[e],L=k?.slides[c],j=L?.styling,X=j?.editorSource||j?.meta?.editorSource,ft=X==="studio"||X==="editor",N=ft?j?.background?.media?.mediaUrl:L?.image,tt=ft?L?.content?.button_text:L?.button_text,K=ft?L?.content?.link:L?.link,Y=L?.video||(ft?L?.content?.video?.[0]?.link:void 0),nt=L?.content?.canva,U=nt&&nt.width&&nt.height?nt.width/nt.height:400/700,G=700,Q=Math.round(G*U),at=async()=>{let E={title:k.name,text:`Check out this story: ${k.name}`,url:window.location.href};if(L?.id&&H("shared",o,{story_slide:L.id}),navigator.share)try{await navigator.share(E)}catch{}else if(navigator.clipboard)try{await navigator.clipboard.writeText(window.location.href),R("Story link copied to clipboard!"),setTimeout(()=>R(null),2500)}catch{}};if((0,it.useEffect)(()=>{u(0),m(0),b(!1),y(!1),p(!1),A(null),C(null),W(null)},[e]),(0,it.useEffect)(()=>{let E=q=>{if(!(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA"))switch(q.key){case"ArrowRight":rt();break;case"ArrowLeft":Bt();break;case" ":q.preventDefault(),y(st=>!st);break;case"Escape":a();break;case"s":case"S":q.preventDefault(),at();break}};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[c,e,h,k,a]),(0,it.useEffect)(()=>{k&&L&&H("viewed",o,{story_slide:L.id})},[c,k?.id,o]),(0,it.useEffect)(()=>{if(k&&L){let E=k.styling?.slideShowTime||5,q=!!Y;if(P.current&&clearInterval(P.current),h){M.current&&M.current.pause();return}else M.current&&M.current.play().catch(()=>{});return q&&!f||l?void 0:(P.current=setInterval(()=>{m(st=>st>=100?(rt(),100):st+100/(E*10))},100),()=>{P.current&&clearInterval(P.current)})}},[e,c,h,f,l]),!L)return null;let St=(E,q)=>{l||(W(E),A(c),C(q),p(!0),setTimeout(()=>{u(q),m(0),b(!1),p(!1),A(null),C(null),W(null)},Gt+20))},rt=()=>{if(!l)if(c<k.slides.length-1)St("next",c+1);else{if(!i.includes(k.id)){let E=[...i,k.id];n(E),localStorage.setItem("app_storys_viewed_stories",JSON.stringify(E))}r()}},Bt=()=>{l||(c>0?St("prev",c-1):s())},ht=()=>{$.current=Date.now(),y(!0)},At=E=>{y(!1),Date.now()-$.current<300&&(E==="next"?rt():Bt())},ee=()=>b(!0),en=E=>{let q=E?.styling,st=q?.editorSource||q?.meta?.editorSource,bt=st==="studio"||st==="editor"?E.content?.link:E.link;bt&&(H("clicked",o,{story_slide:E.id}),bt.startsWith("http")?window.open(bt,"_blank"):window.location.href=bt)},on=E=>{E.stopPropagation(),v(!g)},nn=k?.styling?.crossButton,rn=k?.styling?.soundToggle,qr=L?.styling?.cta,sn=E=>l?S==="next"?E===O?"left":E===_?"center":E===(O??0)-1?"far-left":E===(O??0)-2?"hidden":E===(_??0)+1?"right":E===(_??0)+2?"far-right":"hidden":E===O?"right":E===_?"center":E===(O??0)+1?"far-right":E===(O??0)+2?"hidden":E===(_??0)-1?"left":E===(_??0)-2?"far-left":"hidden":E===c?"center":E===c-1?"left":E===c-2?"far-left":E===c+1?"right":E===c+2?"far-right":"hidden",Ai=d?{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",background:"radial-gradient(circle at center, #0B1424 0%, #03070E 100%)",zIndex:1e5,display:"flex",flexDirection:"column",alignItems:"center",overflow:"hidden",color:"white"}:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.95)",zIndex:1e5,display:"flex",justifyContent:"center",alignItems:"center"},an=d?{position:"absolute",width:`${Q}px`,height:`${G}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:"100%",maxWidth:"450px",height:"100%",maxHeight:"850px",backgroundColor:"#000",borderRadius:"0px",overflow:"hidden",display:"flex",flexDirection:"column"},Ur={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"},Ei=k.slides.reduce((E,q,st)=>(sn(st)!=="hidden"&&E.push(st),E),[]),pe=new Set(Ei);return pe.add(c),c>0&&pe.add(c-1),c>1&&pe.add(c-2),c<k.slides.length-1&&pe.add(c+1),c<k.slides.length-2&&pe.add(c+2),(0,z.jsxs)("div",{style:Ai,onClick:()=>!d&&rt(),children:[(0,z.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:[Y?(0,z.jsx)("video",{src:Y,style:{width:"100%",height:"100%",objectFit:"cover",filter:"blur(120px) saturate(1.8) opacity(0.35)"},muted:!0}):(0,z.jsx)(jt,{src:N||k.thumbnail,style:{width:"100%",height:"100%",filter:"blur(120px) saturate(1.8) opacity(0.35)"}}),(0,z.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(5, 5, 8, 0.4)"}})]},`${e}-${l?_:c}`),d&&(0,z.jsxs)("div",{style:{width:"100%",display:"flex",flexDirection:"column",paddingTop:"20px",zIndex:10},children:[(0,z.jsx)("div",{style:{width:"100%",display:"flex",gap:"8px",padding:"0 20px",boxSizing:"border-box"},children:k.slides.map((E,q)=>{let st=l&&_!==null?_:c,_t="0%";return q<st?_t="100%":q===st&&(_t=`${x}%`),(0,z.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.15)",borderRadius:"2px",overflow:"hidden"},children:(0,z.jsx)("div",{style:{width:_t,height:"100%",backgroundColor:"white",transition:q===st?"width 0.1s linear":"none"}})},q)})}),(0,z.jsxs)("div",{style:{width:"100%",maxWidth:"1400px",margin:"0 auto",display:"grid",gridTemplateColumns:`minmax(0, 1fr) ${Q}px minmax(0, 1fr)`,gap:"12px",alignItems:"center",marginTop:"16px",padding:"0 20px",boxSizing:"border-box",zIndex:w?2e3:10},children:[(0,z.jsx)("div",{style:{paddingLeft:"0px"}}),(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,z.jsx)(jt,{src:k.thumbnail,alt:k.name,style:{width:"44px",height:"44px",borderRadius:"50%",border:"2px solid white",margin:0}}),(0,z.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"16px",whiteSpace:"nowrap"},children:k.name})]}),(0,z.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,z.jsx)(ci,{config:{enabled:k?.styling?.share?.enabled??!0,image:k?.styling?.share?.image??"",color:{cross:k?.styling?.share?.color?.cross??"#ffffff",fill:k?.styling?.share?.color?.fill??"rgba(255,255,255,0.08)",stroke:k?.styling?.share?.color?.stroke??"transparent"},margin:{top:0,bottom:0,left:0,right:0},size:k?.styling?.share?.size??44},onPress:at,style:{position:"relative",borderRadius:"12px"}}),(0,z.jsx)(Uo,{config:{size:44,color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:on,type:g?"mute":"unmute",enabled:!!rn?.enabled&&!!Y,style:{position:"relative",borderRadius:"12px"}}),(0,z.jsx)(di,{isPaused:h,onPress:()=>y(!h),size:44,style:{borderRadius:"12px"}})]})]}),(0,z.jsxs)("div",{style:{display:"flex",gap:"10px",flex:1,justifyContent:"flex-end",paddingRight:"0px"},children:[(0,z.jsxs)("div",{style:{position:"relative"},children:[(0,z.jsx)("button",{onClick:()=>{I(!w),y(!w)},style:{width:"44px",height:"44px",background:w?"rgba(255,255,255,0.15)":"rgba(255,255,255,0.08)",border:w?"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,z.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,z.jsx)("rect",{x:"3",y:"3",width:"7",height:"7"}),(0,z.jsx)("rect",{x:"14",y:"3",width:"7",height:"7"}),(0,z.jsx)("rect",{x:"14",y:"14",width:"7",height:"7"}),(0,z.jsx)("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),w&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("style",{children:`
|
|
73
73
|
@keyframes fadeUp {
|
|
74
74
|
from { opacity: 0; transform: translateY(10px) scale(0.95); }
|
|
75
75
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
76
76
|
}
|
|
77
|
-
`}),(0,z.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,z.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,z.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:E,label:U})=>(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,z.jsx)("span",{style:{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)"},children:E}),(0,z.jsx)("span",{style:{fontSize:"13px",color:"#E5E7EB",fontWeight:"500"},children:U})]},E))})]})]})]}),(0,z.jsx)(Yt,{config:{enabled:ve?.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:a,style:{position:"relative",borderRadius:"12px"}})]})]})]}),(0,z.jsx)("div",{style:{flex:1,width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"20px"},children:(0,z.jsxs)("div",{style:{display:d?"grid":"flex",gridTemplateColumns:d?`minmax(0, 1fr) ${be}px minmax(0, 1fr)`:"none",alignItems:"center",justifyContent:"center",gap:"12px",width:"100%",maxWidth:"1400px",position:"relative"},onClick:E=>d&&E.stopPropagation(),children:[d&&(0,z.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(c>0||e>0)&&(0,z.jsx)("button",{onClick:J,style:{background:"rgba(0,0,0,0.5)",border:"none",color:"white",borderRadius:"50%",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"18px",backdropFilter:"blur(5px)",transition:"background 0.2s"},onMouseEnter:E=>E.currentTarget.style.background="rgba(0,0,0,0.7)",onMouseLeave:E=>E.currentTarget.style.background="rgba(0,0,0,0.5)",children:"\u2039"})}),d?(0,z.jsx)("div",{style:{width:`${be}px`,height:`${Vo}px`,position:"relative",zIndex:5,overflow:"visible"},children:Array.from(ce).sort((E,U)=>E-U).map(E=>{let U=k.slides[E];if(!U)return null;let rt=nn(E),Lt=hr(rt),bt=U?.styling,we=bt?.editorSource||bt?.meta?.editorSource,Dt=we==="studio"||we==="editor",_e=bt?.background?.media?.mediaUrl||U?.image,ke=U?.video||(Dt?U?.content?.video?.[0]?.link:void 0),lo=Vt(bt?.background)||"#000000",Re=Dt?U?.content?.button_text:U?.button_text,zt=Dt?U?.content?.link:U?.link,Te=E===c&&!l||l&&E===_,co={display:"flex",justifyContent:"center",alignItems:"center",background:Dt?lo:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"16px"};return(0,z.jsxs)("div",{style:{...rn,position:"absolute",top:0,left:0,width:`${be}px`,height:`${Vo}px`,...Lt,transition:rt==="hidden"||rt==="far-left"||rt==="far-right"?`opacity ${Qt}ms ease, transform ${Qt}ms ease`:E===O?`transform ${Qt}ms ${Yo}, opacity ${Qt}ms ${Yo}, filter ${Qt}ms ${Yo}`:`transform ${Qt}ms ${Qo}, opacity ${Qt}ms ${Qo}, filter ${Qt}ms ${Qo}`,transformOrigin:"center center",willChange:"transform, opacity, filter"},onClick:_t=>_t.stopPropagation(),children:[(0,z.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:ot,onMouseUp:()=>ct("prev"),onTouchStart:ot,onTouchEnd:()=>ct("prev")}),(0,z.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:ot,onMouseUp:()=>ct("next"),onTouchStart:ot,onTouchEnd:()=>ct("next")}),(0,z.jsxs)("div",{style:co,children:[ke?(0,z.jsx)(ci,{src:ke,isActive:Te,isAnimating:l,isMuted:g,onLoadedData:at,activeVideoRef:M}):(_e||!Dt&&k?.thumbnail)&&(0,z.jsx)(Mt,{src:_e||k?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:Dt?"contain":"cover"}}),(0,z.jsx)(qo,{content:{...U.content,styling:{...U.content?.styling,...U?.styling},interactions:U.interactions},elapsedTime:Te?x/100*(k.styling?.slideShowTime||5):0,onInteraction:async _t=>{if(!Te)return;y(!0);let{type:We,questionId:po,pollId:pe,quizId:uo,optionId:go,value:Me,stickerId:fo}=_t,ue=We?.split("_")[0]||"interaction";ue==="quizz"&&(ue="quiz"),We?.startsWith("image_quiz")&&(ue="quiz");let Oe=fo||po||pe||uo||U.id,mo=go||_t.selected_option||"",sn=F.getState(),Ei=sn.userId||"anonymous",Pi=sn.trackingUrl||"https://tracking.appstorys.co",an=await lt();fetch(`${Pi}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...an?{Authorization:`Bearer ${an}`}:{}},body:JSON.stringify({user_id:Ei,campaign_id:o,event:"interaction",metadata:{interaction_type:ue,interaction_id:Oe,slide_id:U.id,selected_option:String(mo),value:String(Me||"")}})}).catch(Li=>console.error("AppStorys: Instant Tracking Failed",Li))}})]}),(Re||zt)&&(0,z.jsx)(Uo,{cta:U?.styling?.cta,buttonText:Re||"Learn More",onPress:_t=>{_t&&_t.stopPropagation&&_t.stopPropagation(),Pt(U)}})]},U.id||E)})}):(0,z.jsx)("div",{style:{width:"100%",maxWidth:"450px",height:"100%",maxHeight:"850px",overflow:"hidden",position:"relative",zIndex:5,display:"flex",flexDirection:"column"},children:k.slides.map((E,U)=>{if(Math.abs(U-c)>1)return(0,z.jsx)("div",{style:{display:"none"}},E.id||U);let rt=E?.styling,Lt=rt?.editorSource||rt?.meta?.editorSource,bt=Lt==="studio"||Lt==="editor",we=rt?.background?.media?.mediaUrl||E?.image,Dt=E?.video||(bt?E?.content?.video?.[0]?.link:void 0),_e=Vt(rt?.background)||"#000000",ke=bt?E?.content?.button_text:E?.button_text,lo=bt?E?.content?.link:E?.link,Re=U===c;return Re?(0,z.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:(0,z.jsxs)("div",{style:{...rn},onClick:zt=>zt.stopPropagation(),children:[(0,z.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,display:"flex",gap:"4px",padding:"10px",zIndex:10},children:k.slides.map((zt,Gt)=>{let $e=Gt<c?"100%":Gt===c?`${x}%`:"0%";return(0,z.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.3)",borderRadius:"2px",overflow:"hidden"},children:(0,z.jsx)("div",{style:{width:$e,height:"100%",backgroundColor:"white",transition:Gt===c?"width 0.1s linear":"none"}})},Gt)})}),(0,z.jsxs)("div",{style:{position:"absolute",top:"20px",left:"10px",right:"10px",display:"flex",alignItems:"center",justifyContent:"space-between",zIndex:10,padding:"5px"},children:[(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,z.jsx)(Mt,{src:k.thumbnail,alt:k.name,style:{width:"32px",height:"32px",borderRadius:"50%"}}),(0,z.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"14px",textShadow:"0 1px 3px rgba(0,0,0,0.8)"},children:k.name})]}),(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,z.jsx)(Ho,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:Ut,type:g?"mute":"unmute",enabled:!!te?.enabled&&!!Dt,style:{position:"relative",borderRadius:"10px"}}),(0,z.jsx)(Yt,{config:{enabled:ve?.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:a,style:{position:"relative",borderRadius:"10px"}})]})]}),(0,z.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:ot,onMouseUp:()=>ct("prev"),onTouchStart:ot,onTouchEnd:()=>ct("prev")}),(0,z.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:ot,onMouseUp:()=>ct("next"),onTouchStart:ot,onTouchEnd:()=>ct("next")}),(0,z.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",background:bt?_e:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"0px"},children:[Dt?(0,z.jsx)(ci,{src:Dt,isActive:Re,isAnimating:l,isMuted:g,onLoadedData:at,activeVideoRef:M}):(we||k?.thumbnail)&&(0,z.jsx)(Mt,{src:we||k?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:bt?"contain":"cover"}}),(0,z.jsx)(qo,{content:{...E.content,styling:{...E.content?.styling,...E?.styling},interactions:E.interactions},elapsedTime:x/100*(k.styling?.slideShowTime||5),onInteraction:async zt=>{y(!0);let{type:Gt,questionId:$e,pollId:Te,quizId:co,optionId:_t,value:We,stickerId:po}=zt,pe=Gt?.split("_")[0]||"interaction";pe==="quizz"&&(pe="quiz"),Gt?.startsWith("image_quiz")&&(pe="quiz");let uo=po||$e||Te||co||E.id,go=_t||zt.selected_option||"",Me=F.getState(),fo=Me.userId||"anonymous",ue=Me.trackingUrl||"https://tracking.appstorys.co",Oe=await lt();fetch(`${ue}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...Oe?{Authorization:`Bearer ${Oe}`}:{}},body:JSON.stringify({user_id:fo,campaign_id:o,event:"interaction",metadata:{interaction_type:pe,interaction_id:uo,slide_id:E.id,selected_option:String(go),value:String(We||"")}})}).catch(mo=>console.error("AppStorys: Instant Tracking Failed",mo))}})]}),(ke||lo)&&(0,z.jsx)(Uo,{cta:E?.styling?.cta,buttonText:ke||"Learn More",onPress:zt=>{zt&&zt.stopPropagation&&zt.stopPropagation(),Pt(E)}})]})},E.id||U):null})}),d&&(0,z.jsx)("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(0,z.jsx)("button",{onClick:Q,style:{background:"rgba(0,0,0,0.5)",border:"none",color:"white",borderRadius:"50%",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"18px",backdropFilter:"blur(5px)",transition:"background 0.2s"},onMouseEnter:E=>E.currentTarget.style.background="rgba(0,0,0,0.7)",onMouseLeave:E=>E.currentTarget.style.background="rgba(0,0,0,0.5)",children:"\u203A"})}),d&&e>0&&(0,z.jsxs)("div",{style:{position:"absolute",bottom:"40px",left:"40px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"5px",zIndex:20},children:[(0,z.jsx)("span",{style:{fontSize:"11px",fontWeight:"bold",color:"rgba(255,255,255,0.75)",letterSpacing:"0.4px",paddingLeft:"2px"},children:"Previous Stories"}),(0,z.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.06)",padding:"8px 14px",borderRadius:"14px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(16px)",cursor:"pointer",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.25)",transition:"all 0.2s",maxWidth:"280px"},onClick:s,children:[(0,z.jsx)("span",{style:{color:"white",fontSize:"15px"},children:"\u2190"}),(0,z.jsx)("div",{style:{width:"40px",height:"40px",borderRadius:"50%",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0},children:(0,z.jsx)(Mt,{src:t[e-1].thumbnail,style:{width:"36px",height:"36px",borderRadius:"50%"}})}),(0,z.jsx)("span",{style:{fontSize:"14px",color:"white",fontWeight:"500",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e-1].name})]})]}),d&&e<t.length-1&&(0,z.jsxs)("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"5px",zIndex:20},children:[(0,z.jsx)("span",{style:{fontSize:"11px",fontWeight:"bold",color:"rgba(255,255,255,0.75)",letterSpacing:"0.4px",paddingLeft:"2px"},children:"Next Stories"}),(0,z.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.06)",padding:"8px 14px",borderRadius:"14px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(16px)",cursor:"pointer",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.25)",transition:"all 0.2s",maxWidth:"280px"},onClick:r,children:[(0,z.jsx)("div",{style:{width:"40px",height:"40px",borderRadius:"50%",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0},children:(0,z.jsx)(Mt,{src:t[e+1].thumbnail,style:{width:"36px",height:"36px",borderRadius:"50%"}})}),(0,z.jsx)("span",{style:{fontSize:"14px",color:"white",fontWeight:"500",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e+1].name}),(0,z.jsx)("span",{style:{color:"white",fontSize:"15px"},children:"\u2192"})]})]}),B&&(0,z.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:B})]})})]})};var Ae=require("react/jsx-runtime"),ui=()=>{let t=pt("STR"),e=F(u=>u.isVisible),[o,i]=(0,xe.useState)(null),[n,r]=(0,xe.useState)([]);if((0,xe.useEffect)(()=>{try{let u=localStorage.getItem("app_storys_viewed_stories");u&&r(JSON.parse(u))}catch(u){console.error("Failed to load viewed stories:",u)}},[]),(0,xe.useEffect)(()=>{t&&t.details&&H("story_module_viewed",t.id)},[t]),!t||!t.details||t.details.length===0||!e)return null;let s=u=>{i(u);let x=t.details[u];H("story_opened",t.id,{story_id:x.id,story_name:x.name})},a=()=>{o!==null&&(o<t.details.length-1?i(o+1):i(null))},c=()=>{o!==null&&o>0&&i(o-1)};return(0,Ae.jsxs)("div",{className:"story-group-container",style:{width:"100vw",position:"relative",left:"50%",right:"50%",marginLeft:"-50vw",marginRight:"-50vw",boxSizing:"border-box"},children:[(0,Ae.jsx)(Dn,{stories:t.details,viewedStories:n,onStoryClick:s}),o!==null&&(0,Ae.jsx)(pi,{stories:t.details,activeStoryIndex:o,dataId:t.id,viewedStories:n,setViewedStories:r,onNextStory:a,onPrevStory:c,onClose:()=>i(null)})]})};var wt=require("react"),gi=require("react-dom");et();var Zt=require("react");function Ee(t,e=.5){let o=(0,Zt.useRef)(t),i=(0,Zt.useRef)(!1),n=(0,Zt.useRef)(null),r=(0,Zt.useRef)(null);(0,Zt.useEffect)(()=>{o.current=t},[t]);let s=a=>{if(r.current&&(r.current.disconnect(),r.current=null),n.current=a,i.current=!1,!a)return;if(typeof IntersectionObserver>"u"){o.current();return}let c=null;r.current=new IntersectionObserver(u=>{u[0].isIntersecting&&!i.current?c||(c=setTimeout(()=>{i.current=!0,o.current(),r.current?.disconnect(),c=null},500)):c&&(clearTimeout(c),c=null)},{threshold:e}),r.current.observe(a)};return(0,Zt.useEffect)(()=>()=>{r.current?.disconnect()},[]),s}var At=require("react/jsx-runtime"),fi=({position:t})=>{let e=pt("WID",{position:t}),o=F(A=>A.campaigns),i=F(A=>A.allCampaigns),n=F(A=>A.currentScreen),r=A=>(A||"").trim().toLowerCase(),s=e??(()=>{let A=r(n),_=[...o||[],...i||[]].find(C=>{let S=C;if(S.campaign_type!=="WID"||t&&S.position!==t)return!1;let W=!!(S.trigger_event??S.trigger),P=S.display_trigger!==!1&&!W,M=!r(S.screen)||r(S.screen)===A;return P&&M});if(_)try{return St(_)}catch{return _}})(),[a,c]=(0,wt.useState)(0),u=(0,wt.useRef)(null),x=(0,wt.useRef)(null),m=s?.details||{},g=m.widget_images||[],v=m.styling||{},f=m.type||"full",b=f==="half",h=(0,wt.useRef)([]),y=(0,wt.useRef)(!1),w=(0,wt.useCallback)(()=>{y.current=!0;let A=g[a];A?.id&&B(A.id)},[g,a]),I=Ee(w),B=A=>{!s?.id||!A||y.current&&(h.current.includes(A)||(h.current.push(A),H("viewed",s.id,{widget_image:A})))};(0,wt.useEffect)(()=>{if(f==="full"&&g.length>1)return x.current=setInterval(()=>{c(A=>{let _=A+1;return _>=g.length?0:_})},5e3),()=>{x.current&&clearInterval(x.current)}},[f,g.length]);let R=(A,_)=>{if(s?.id&&H("clicked",s.id,{widget_image:A}),_){if(!_.startsWith("http")){try{if(Ct(_))return}catch(C){console.warn("[Widget] revealCampaignFromLink error",C)}console.log("[Widget] Internal link:",_);return}window.open(_,"_blank")}},d=()=>{if(u.current&&b){let{scrollLeft:A,offsetWidth:_}=u.current,C=_/2+12,S=Math.round(A/C);c(S)}};(0,wt.useEffect)(()=>{if(!s?.id||f!=="full"||g.length===0)return;let A=g[a];A&&A.id&&B(A.id)},[a,s?.id,g,f]),(0,wt.useEffect)(()=>{if(!s?.id||!u.current||!b)return;let A=u.current,_=()=>{let{scrollLeft:C,offsetWidth:S}=A,W=S/2+12;g.forEach((P,M)=>{let $=M*W,k=$+W,L=C,j=C+S;Math.max(0,Math.min(k,j)-Math.max($,L))/W>=.5&&B(P.id)})};return _(),A.addEventListener("scroll",_),()=>A.removeEventListener("scroll",_)},[s?.id,b,g]);let T={display:"flex",flexDirection:"row",flexWrap:b?"nowrap":"wrap",gap:"12px",width:"100%",height:b&&m.height?`${m.height}px`:"auto",marginTop:v.topMargin?`${v.topMargin}px`:"0px",marginBottom:v.bottomMargin?`${v.bottomMargin}px`:"0px",marginLeft:v.leftMargin?`${v.leftMargin}px`:"0px",marginRight:v.rightMargin?`${v.rightMargin}px`:"0px",boxSizing:"border-box",overflowX:b?"auto":"hidden",overflowY:"hidden",scrollSnapType:b?"x mandatory":void 0,msOverflowStyle:"none",scrollbarWidth:"none"},l=A=>({flex:b?"0 0 calc(50% - 6px)":"0 0 100%",height:b&&m.height?`${m.height}px`:"auto",cursor:"pointer",position:"relative",overflow:"hidden",borderRadius:v.borderRadius?`${v.borderRadius}px`:"0px",borderTopLeftRadius:v.topLeftRadius?`${v.topLeftRadius}px`:void 0,borderTopRightRadius:v.topRightRadius?`${v.topRightRadius}px`:void 0,borderBottomLeftRadius:v.bottomLeftRadius?`${v.bottomLeftRadius}px`:void 0,borderBottomRightRadius:v.bottomRightRadius?`${v.bottomRightRadius}px`:void 0,boxShadow:"0 4px 12px rgba(0,0,0,0.08)",scrollSnapAlign:"start"}),p=(0,At.jsxs)("div",{style:{width:"100%",position:"relative"},children:[(0,At.jsx)("style",{children:`
|
|
77
|
+
`}),(0,z.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,z.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,z.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:E,label:q})=>(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,z.jsx)("span",{style:{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)"},children:E}),(0,z.jsx)("span",{style:{fontSize:"13px",color:"#E5E7EB",fontWeight:"500"},children:q})]},E))})]})]})]}),(0,z.jsx)(Qt,{config:{enabled:nn?.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:a,style:{position:"relative",borderRadius:"12px"}})]})]})]}),(0,z.jsx)("div",{style:{flex:1,width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"20px"},children:(0,z.jsxs)("div",{style:{display:d?"grid":"flex",gridTemplateColumns:d?`minmax(0, 1fr) ${Q}px minmax(0, 1fr)`:"none",alignItems:"center",justifyContent:"center",gap:"12px",width:"100%",maxWidth:"1400px",position:"relative"},onClick:E=>d&&E.stopPropagation(),children:[d&&(0,z.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(c>0||e>0)&&(0,z.jsx)("button",{onClick:Bt,style:{background:"rgba(0,0,0,0.5)",border:"none",color:"white",borderRadius:"50%",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"18px",backdropFilter:"blur(5px)",transition:"background 0.2s"},onMouseEnter:E=>E.currentTarget.style.background="rgba(0,0,0,0.7)",onMouseLeave:E=>E.currentTarget.style.background="rgba(0,0,0,0.5)",children:"\u2039"})}),d?(0,z.jsx)("div",{style:{width:`${Q}px`,height:`${G}px`,position:"relative",zIndex:5,overflow:"visible"},children:Array.from(pe).sort((E,q)=>E-q).map(E=>{let q=k.slides[E];if(!q)return null;let st=sn(E),_t=br(st,Q),bt=q?.styling,ve=bt?.editorSource||bt?.meta?.editorSource,$t=ve==="studio"||ve==="editor",De=bt?.background?.media?.mediaUrl||q?.image,we=q?.video||($t?q?.content?.video?.[0]?.link:void 0),ao=Yt(bt?.background)||"#000000",ke=$t?q?.content?.button_text:q?.button_text,Et=$t?q?.content?.link:q?.link,Re=E===c&&!l||l&&E===_,lo={display:"flex",justifyContent:"center",alignItems:"center",background:$t?ao:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"16px"};return(0,z.jsxs)("div",{style:{...an,position:"absolute",top:0,left:0,width:`${Q}px`,height:`${G}px`,..._t,transition:st==="hidden"||st==="far-left"||st==="far-right"?`opacity ${Gt}ms ease, transform ${Gt}ms ease`:E===O?`transform ${Gt}ms ${Vo}, opacity ${Gt}ms ${Vo}, filter ${Gt}ms ${Vo}`:`transform ${Gt}ms ${Yo}, opacity ${Gt}ms ${Yo}, filter ${Gt}ms ${Yo}`,transformOrigin:"center center",willChange:"transform, opacity, filter"},onClick:Wt=>Wt.stopPropagation(),children:[(0,z.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:ht,onMouseUp:()=>At("prev"),onTouchStart:ht,onTouchEnd:()=>At("prev")}),(0,z.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:ht,onMouseUp:()=>At("next"),onTouchStart:ht,onTouchEnd:()=>At("next")}),(0,z.jsxs)("div",{style:lo,children:[we?(0,z.jsx)(pi,{src:we,isActive:Re,isAnimating:l,isMuted:g,onLoadedData:ee,activeVideoRef:M}):(De||!$t&&k?.thumbnail)&&(0,z.jsx)(jt,{src:De||k?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:$t?"contain":"cover"}}),(0,z.jsx)(No,{content:{...q.content,styling:{...q.content?.styling,...q?.styling},interactions:q.interactions},elapsedTime:Re?x/100*(k.styling?.slideShowTime||5):0,onInteraction:async Wt=>{if(!Re)return;y(!0);let{type:$e,questionId:co,pollId:ue,quizId:po,optionId:uo,value:We,stickerId:go}=Wt,ge=$e?.split("_")[0]||"interaction";ge==="quizz"&&(ge="quiz"),$e?.startsWith("image_quiz")&&(ge="quiz");let Me=go||co||ue||po||q.id,fo=uo||Wt.selected_option||"",ln=F.getState(),Pi=ln.userId||"anonymous",Li=ln.trackingUrl||"https://tracking.appstorys.co",dn=await lt();fetch(`${Li}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...dn?{Authorization:`Bearer ${dn}`}:{}},body:JSON.stringify({user_id:Pi,campaign_id:o,event:"interaction",metadata:{interaction_type:ge,interaction_id:Me,slide_id:q.id,selected_option:String(fo),value:String(We||"")}})}).catch(Di=>console.error("AppStorys: Instant Tracking Failed",Di))}})]}),(ke||Et)&&(0,z.jsx)(qo,{cta:q?.styling?.cta,buttonText:ke||"Learn More",onPress:Wt=>{Wt&&Wt.stopPropagation&&Wt.stopPropagation(),en(q)}})]},q.id||E)})}):(0,z.jsx)("div",{style:{width:"100%",maxWidth:"450px",height:"100%",maxHeight:"850px",overflow:"hidden",position:"relative",zIndex:5,display:"flex",flexDirection:"column"},children:k.slides.map((E,q)=>{if(Math.abs(q-c)>1)return(0,z.jsx)("div",{style:{display:"none"}},E.id||q);let st=E?.styling,_t=st?.editorSource||st?.meta?.editorSource,bt=_t==="studio"||_t==="editor",ve=st?.background?.media?.mediaUrl||E?.image,$t=E?.video||(bt?E?.content?.video?.[0]?.link:void 0),De=Yt(st?.background)||"#000000",we=bt?E?.content?.button_text:E?.button_text,ao=bt?E?.content?.link:E?.link,ke=q===c;return ke?(0,z.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:(0,z.jsxs)("div",{style:{...an},onClick:Et=>Et.stopPropagation(),children:[(0,z.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,display:"flex",gap:"4px",padding:"10px",zIndex:10},children:k.slides.map((Et,Jt)=>{let _e=Jt<c?"100%":Jt===c?`${x}%`:"0%";return(0,z.jsx)("div",{style:{flex:1,height:"3px",backgroundColor:"rgba(255,255,255,0.3)",borderRadius:"2px",overflow:"hidden"},children:(0,z.jsx)("div",{style:{width:_e,height:"100%",backgroundColor:"white",transition:Jt===c?"width 0.1s linear":"none"}})},Jt)})}),(0,z.jsxs)("div",{style:{position:"absolute",top:"20px",left:"10px",right:"10px",display:"flex",alignItems:"center",justifyContent:"space-between",zIndex:10,padding:"5px"},children:[(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,z.jsx)(jt,{src:k.thumbnail,alt:k.name,style:{width:"32px",height:"32px",borderRadius:"50%"}}),(0,z.jsx)("span",{style:{color:"white",fontWeight:"bold",fontSize:"14px",textShadow:"0 1px 3px rgba(0,0,0,0.8)"},children:k.name})]}),(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,z.jsx)(Uo,{config:{size:32,color:{cross:"#ffffff",fill:"rgba(255,255,255,0.08)",stroke:"transparent"},margin:{top:0,bottom:0,left:0,right:0},image:""},onPress:on,type:g?"mute":"unmute",enabled:!!rn?.enabled&&!!$t,style:{position:"relative",borderRadius:"10px"}}),(0,z.jsx)(Qt,{config:{enabled:nn?.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:a,style:{position:"relative",borderRadius:"10px"}})]})]}),(0,z.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:"30%",zIndex:5,cursor:"pointer"},onMouseDown:ht,onMouseUp:()=>At("prev"),onTouchStart:ht,onTouchEnd:()=>At("prev")}),(0,z.jsx)("div",{style:{position:"absolute",top:0,bottom:0,right:0,width:"70%",zIndex:4,cursor:"pointer"},onMouseDown:ht,onMouseUp:()=>At("next"),onTouchStart:ht,onTouchEnd:()=>At("next")}),(0,z.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",background:bt?De:"#000",position:"relative",width:"100%",height:"100%",overflow:"hidden",borderRadius:"0px"},children:[$t?(0,z.jsx)(pi,{src:$t,isActive:ke,isAnimating:l,isMuted:g,onLoadedData:ee,activeVideoRef:M}):(ve||k?.thumbnail)&&(0,z.jsx)(jt,{src:ve||k?.thumbnail,alt:"Story content",style:{width:"100%",height:"100%",objectFit:bt?"contain":"cover"}}),(0,z.jsx)(No,{content:{...E.content,styling:{...E.content?.styling,...E?.styling},interactions:E.interactions},elapsedTime:x/100*(k.styling?.slideShowTime||5),onInteraction:async Et=>{y(!0);let{type:Jt,questionId:_e,pollId:Re,quizId:lo,optionId:Wt,value:$e,stickerId:co}=Et,ue=Jt?.split("_")[0]||"interaction";ue==="quizz"&&(ue="quiz"),Jt?.startsWith("image_quiz")&&(ue="quiz");let po=co||_e||Re||lo||E.id,uo=Wt||Et.selected_option||"",We=F.getState(),go=We.userId||"anonymous",ge=We.trackingUrl||"https://tracking.appstorys.co",Me=await lt();fetch(`${ge}/capture-event`,{method:"POST",headers:{"Content-Type":"application/json",...Me?{Authorization:`Bearer ${Me}`}:{}},body:JSON.stringify({user_id:go,campaign_id:o,event:"interaction",metadata:{interaction_type:ue,interaction_id:po,slide_id:E.id,selected_option:String(uo),value:String($e||"")}})}).catch(fo=>console.error("AppStorys: Instant Tracking Failed",fo))}})]}),(we||ao)&&(0,z.jsx)(qo,{cta:E?.styling?.cta,buttonText:we||"Learn More",onPress:Et=>{Et&&Et.stopPropagation&&Et.stopPropagation(),en(E)}})]})},E.id||q):null})}),d&&(0,z.jsx)("div",{style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"12px",width:"100%",boxSizing:"border-box"},children:(0,z.jsx)("button",{onClick:rt,style:{background:"rgba(0,0,0,0.5)",border:"none",color:"white",borderRadius:"50%",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"18px",backdropFilter:"blur(5px)",transition:"background 0.2s"},onMouseEnter:E=>E.currentTarget.style.background="rgba(0,0,0,0.7)",onMouseLeave:E=>E.currentTarget.style.background="rgba(0,0,0,0.5)",children:"\u203A"})}),d&&e>0&&(0,z.jsxs)("div",{style:{position:"absolute",bottom:"40px",left:"40px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"5px",zIndex:20},children:[(0,z.jsx)("span",{style:{fontSize:"11px",fontWeight:"bold",color:"rgba(255,255,255,0.75)",letterSpacing:"0.4px",paddingLeft:"2px"},children:"Previous Stories"}),(0,z.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.06)",padding:"8px 14px",borderRadius:"14px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(16px)",cursor:"pointer",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.25)",transition:"all 0.2s",maxWidth:"280px"},onClick:s,children:[(0,z.jsx)("span",{style:{color:"white",fontSize:"15px"},children:"\u2190"}),(0,z.jsx)("div",{style:{width:"40px",height:"40px",borderRadius:"50%",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0},children:(0,z.jsx)(jt,{src:t[e-1].thumbnail,style:{width:"36px",height:"36px",borderRadius:"50%"}})}),(0,z.jsx)("span",{style:{fontSize:"14px",color:"white",fontWeight:"500",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e-1].name})]})]}),d&&e<t.length-1&&(0,z.jsxs)("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"5px",zIndex:20},children:[(0,z.jsx)("span",{style:{fontSize:"11px",fontWeight:"bold",color:"rgba(255,255,255,0.75)",letterSpacing:"0.4px",paddingLeft:"2px"},children:"Next Stories"}),(0,z.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.06)",padding:"8px 14px",borderRadius:"14px",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(16px)",cursor:"pointer",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.25)",transition:"all 0.2s",maxWidth:"280px"},onClick:r,children:[(0,z.jsx)("div",{style:{width:"40px",height:"40px",borderRadius:"50%",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",background:"white",flexShrink:0},children:(0,z.jsx)(jt,{src:t[e+1].thumbnail,style:{width:"36px",height:"36px",borderRadius:"50%"}})}),(0,z.jsx)("span",{style:{fontSize:"14px",color:"white",fontWeight:"500",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:t[e+1].name}),(0,z.jsx)("span",{style:{color:"white",fontSize:"15px"},children:"\u2192"})]})]}),B&&(0,z.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:B})]})})]})};var Be=require("react/jsx-runtime"),gi=()=>{let t=ct("STR"),e=F(u=>u.isVisible),[o,i]=(0,xe.useState)(null),[n,r]=(0,xe.useState)([]);if((0,xe.useEffect)(()=>{try{let u=localStorage.getItem("app_storys_viewed_stories");u&&r(JSON.parse(u))}catch(u){console.error("Failed to load viewed stories:",u)}},[]),(0,xe.useEffect)(()=>{t&&t.details&&H("story_module_viewed",t.id)},[t]),!t||!t.details||t.details.length===0||!e)return null;let s=u=>{i(u);let x=t.details[u];H("story_opened",t.id,{story_id:x.id,story_name:x.name})},a=()=>{o!==null&&(o<t.details.length-1?i(o+1):i(null))},c=()=>{o!==null&&o>0&&i(o-1)};return(0,Be.jsxs)("div",{className:"story-group-container",style:{width:"100vw",position:"relative",left:"50%",right:"50%",marginLeft:"-50vw",marginRight:"-50vw",boxSizing:"border-box"},children:[(0,Be.jsx)($n,{stories:t.details,viewedStories:n,onStoryClick:s}),o!==null&&(0,Be.jsx)(ui,{stories:t.details,activeStoryIndex:o,dataId:t.id,viewedStories:n,setViewedStories:r,onNextStory:a,onPrevStory:c,onClose:()=>i(null)})]})};var kt=require("react"),fi=require("react-dom");et();var te=require("react");function Ae(t,e=.5){let o=(0,te.useRef)(t),i=(0,te.useRef)(!1),n=(0,te.useRef)(null),r=(0,te.useRef)(null);(0,te.useEffect)(()=>{o.current=t},[t]);let s=a=>{if(r.current&&(r.current.disconnect(),r.current=null),n.current=a,i.current=!1,!a)return;if(typeof IntersectionObserver>"u"){o.current();return}let c=null;r.current=new IntersectionObserver(u=>{u[0].isIntersecting&&!i.current?c||(c=setTimeout(()=>{i.current=!0,o.current(),r.current?.disconnect(),c=null},500)):c&&(clearTimeout(c),c=null)},{threshold:e}),r.current.observe(a)};return(0,te.useEffect)(()=>()=>{r.current?.disconnect()},[]),s}var Lt=require("react/jsx-runtime"),mi=({position:t})=>{let e=ct("WID",{position:t}),o=F(A=>A.campaigns),i=F(A=>A.allCampaigns),n=F(A=>A.currentScreen),r=A=>(A||"").trim().toLowerCase(),s=e??(()=>{let A=r(n),_=[...o||[],...i||[]].find(C=>{let S=C;if(S.campaign_type!=="WID"||t&&S.position!==t)return!1;let W=!!(S.trigger_event??S.trigger),P=S.display_trigger!==!1&&!W,M=!r(S.screen)||r(S.screen)===A;return P&&M});if(_)try{return Ct(_)}catch{return _}})(),[a,c]=(0,kt.useState)(0),u=(0,kt.useRef)(null),x=(0,kt.useRef)(null),m=s?.details||{},g=m.widget_images||[],v=m.styling||{},f=m.type||"full",b=f==="half",h=(0,kt.useRef)([]),y=(0,kt.useRef)(!1),w=(0,kt.useCallback)(()=>{y.current=!0;let A=g[a];A?.id&&B(A.id)},[g,a]),I=Ae(w),B=A=>{!s?.id||!A||y.current&&(h.current.includes(A)||(h.current.push(A),H("viewed",s.id,{widget_image:A})))};(0,kt.useEffect)(()=>{if(f==="full"&&g.length>1)return x.current=setInterval(()=>{c(A=>{let _=A+1;return _>=g.length?0:_})},5e3),()=>{x.current&&clearInterval(x.current)}},[f,g.length]);let R=(A,_)=>{if(s?.id&&H("clicked",s.id,{widget_image:A}),_){if(!_.startsWith("http")){try{if(vt(_))return}catch(C){console.warn("[Widget] revealCampaignFromLink error",C)}console.log("[Widget] Internal link:",_);return}window.open(_,"_blank")}},d=()=>{if(u.current&&b){let{scrollLeft:A,offsetWidth:_}=u.current,C=_/2+12,S=Math.round(A/C);c(S)}};(0,kt.useEffect)(()=>{if(!s?.id||f!=="full"||g.length===0)return;let A=g[a];A&&A.id&&B(A.id)},[a,s?.id,g,f]),(0,kt.useEffect)(()=>{if(!s?.id||!u.current||!b)return;let A=u.current,_=()=>{let{scrollLeft:C,offsetWidth:S}=A,W=S/2+12;g.forEach((P,M)=>{let $=M*W,k=$+W,L=C,j=C+S;Math.max(0,Math.min(k,j)-Math.max($,L))/W>=.5&&B(P.id)})};return _(),A.addEventListener("scroll",_),()=>A.removeEventListener("scroll",_)},[s?.id,b,g]);let T={display:"flex",flexDirection:"row",flexWrap:b?"nowrap":"wrap",gap:"12px",width:"100%",height:b&&m.height?`${m.height}px`:"auto",marginTop:v.topMargin?`${v.topMargin}px`:"0px",marginBottom:v.bottomMargin?`${v.bottomMargin}px`:"0px",marginLeft:v.leftMargin?`${v.leftMargin}px`:"0px",marginRight:v.rightMargin?`${v.rightMargin}px`:"0px",boxSizing:"border-box",overflowX:b?"auto":"hidden",overflowY:"hidden",scrollSnapType:b?"x mandatory":void 0,msOverflowStyle:"none",scrollbarWidth:"none"},l=A=>({flex:b?"0 0 calc(50% - 6px)":"0 0 100%",height:b&&m.height?`${m.height}px`:"auto",cursor:"pointer",position:"relative",overflow:"hidden",borderRadius:v.borderRadius?`${v.borderRadius}px`:"0px",borderTopLeftRadius:v.topLeftRadius?`${v.topLeftRadius}px`:void 0,borderTopRightRadius:v.topRightRadius?`${v.topRightRadius}px`:void 0,borderBottomLeftRadius:v.bottomLeftRadius?`${v.bottomLeftRadius}px`:void 0,borderBottomRightRadius:v.bottomRightRadius?`${v.bottomRightRadius}px`:void 0,boxShadow:"0 4px 12px rgba(0,0,0,0.08)",scrollSnapAlign:"start"}),p=(0,Lt.jsxs)("div",{style:{width:"100%",position:"relative"},children:[(0,Lt.jsx)("style",{children:`
|
|
78
78
|
.widget-scroll-container::-webkit-scrollbar {
|
|
79
79
|
display: none;
|
|
80
80
|
}
|
|
81
|
-
`}),(0,At.jsx)("div",{ref:A=>{u.current=A,I(A)},className:"widget-scroll-container",style:T,onScroll:d,children:b?g.map((A,_)=>(0,At.jsx)("div",{style:l(_),children:(0,At.jsx)("img",{src:A.image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onClick:()=>R(A.id,A.link)})},A.id)):g.length>0&&(0,At.jsx)("div",{style:l(0),children:(0,At.jsx)("img",{src:g[a].image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onClick:()=>R(g[a].id,g[a].link)})},`slide-${a}`)}),f==="full"&&g.length>1&&(0,At.jsx)("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"8px",width:"100%"},children:g.map((A,_)=>(0,At.jsx)("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:_===a?"#333":"#ccc",transition:"background-color 0.2s ease"}},_))})]}),O=null;if(s?.position){let A=String(s.position||"").replace(/^widget_/,""),_=[`[data-as-id="${A}"]`,`#${A}`,`.${A}`,`[data-widget="${A}"]`];for(let C of _)try{let S=document.querySelector(C);if(S){O=S,console.log("[Widget] Portal target found:",C,"for campaign",s?.id);break}}catch{}O||console.log("[Widget] No portal target found for position:",s?.position,"rendering inline for campaign:",s?.id)}return O?(0,gi.createPortal)(p,O):p};var ut=require("react");et();var It=require("react/jsx-runtime"),Jo=t=>(t||"").trim().toLowerCase(),br=()=>{let t=pt("TTP"),e=F(Y=>Y.campaigns),o=F(Y=>Y.allCampaigns),i=F(Y=>Y.currentScreen),n=F(Y=>Y.isVisible),[r,s]=(0,ut.useState)(0),[a,c]=(0,ut.useState)(!1),[u,x]=(0,ut.useState)(null),[m,g]=(0,ut.useState)({width:0,height:0}),v=(0,ut.useRef)(null),f=(0,ut.useRef)(null),b=(0,ut.useMemo)(()=>{if(t)return t;let Y=Jo(i),st=q=>q.find(Q=>{let J=Q,ot=J.campaign_type==="TTP"||J.campaign_type==="TLTP",ct=!Jo(J.screen)||Jo(J.screen)===Y,at=!!(J.trigger_event??J.trigger),Pt=J.display_trigger!==!1&&!at;return ot&&ct&&Pt});return st(e)??st(o)},[t,e,o,i]),h=(0,ut.useMemo)(()=>b?.details?.tooltips&&Array.isArray(b.details.tooltips)?[...b.details.tooltips].sort((Y,st)=>(Y.order??0)-(st.order??0)):b?.details?.target||b?.details?.titleText?[{...b.details,_id:b.id}]:[],[b]),y=h[r];(0,ut.useEffect)(()=>{},[b]);let w=(0,ut.useRef)(new Set),I=(0,ut.useCallback)(()=>{if(!(!b||!y||a||!n))try{let Y=y._id||y.id||void 0,st=String(b.id||"")+"::"+String(Y||"");w.current.has(st)||(w.current.add(st),H("viewed",b.id,{tooltip_id:Y}))}catch{}},[b,y,a,n]),B=Ee(I);if((0,ut.useEffect)(()=>{if(!y?.target||a)return;x(null);let Y=(Q=!1)=>{let J=y.target;if(!J)return null;let ot=document.getElementById(J)||document.querySelector(`[data-id="${J}"]`)||document.querySelector(`.${J}`);return ot?(x(ot.getBoundingClientRect()),Q&&ot.scrollIntoView({behavior:"smooth",block:"center"}),ot):null};Y(!0)||(f.current=new MutationObserver(()=>{Y(!0)&&f.current?.disconnect()}),f.current.observe(document.body,{childList:!0,subtree:!0}));let q=()=>{let Q=Y(!1);Q&&x(Q.getBoundingClientRect())};return window.addEventListener("resize",q),window.addEventListener("scroll",q,{passive:!0}),()=>{f.current?.disconnect(),window.removeEventListener("resize",q),window.removeEventListener("scroll",q)}},[y,a,r]),(0,ut.useLayoutEffect)(()=>{if(v.current&&u){let{width:Y,height:st}=v.current.getBoundingClientRect();g({width:Y,height:st})}},[y,u]),!b||!y||a||!n||!u)return null;let R=y.styling||{},d=R.appearance||{},T=d.colors||{},l=R.cta||{},p=l.container||{},O=l.cornerRadius||{},A=l.text||{},_=y.arrowPosition||"left",S=(d.arrowStyle||{width:6,height:12}).width||6,W=u.top+window.scrollY,P=u.left+window.scrollX,M=0,$=0,k=8;_==="left"?(M=P+u.width+k,$=W+u.height/2-m.height/2):_==="right"?(M=P-m.width-k,$=W+u.height/2-m.height/2):_==="top"?($=W+u.height+k,M=P+u.width/2-m.width/2):_==="bottom"&&($=W-m.height-k,M=P+u.width/2-m.width/2);let L=8,j=window.scrollY,X=window.scrollY+window.innerHeight,mt=window.scrollX,N=window.scrollX+window.innerWidth;m.height>0&&($=Math.max(j+L,Math.min(X-m.height-L,$))),m.width>0&&(M=Math.max(mt+L,Math.min(N-m.width-L,M)));let tt=()=>{let Y=y.clickAction||"nextStep",st=y.link||y.url;try{let q=y._id||y.id||void 0;b?.id&&H("clicked",b.id,{tooltip_id:q})}catch{}if(Y==="close"){c(!0),st&&window.open(st,"_blank");return}r<h.length-1?s(q=>q+1):(c(!0),st&&window.open(st,"_blank"))},K=()=>{y.enableBackdrop&&c(!0)};return(0,It.jsxs)(It.Fragment,{children:[y.enableBackdrop&&(0,It.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:T.backdrop||"rgba(0, 0, 0, 0.7)",opacity:d.backdropOpacity?d.backdropOpacity/100:.7,zIndex:1e4},onClick:K}),(0,It.jsxs)("div",{ref:Y=>{v.current=Y,B(Y)},style:{position:"absolute",top:$,left:M,zIndex:10001,backgroundColor:T.tooltip||"#FE6B35",padding:`${d.padding?.top??8}px ${d.padding?.right??8}px ${d.padding?.bottom??8}px ${d.padding?.left??8}px`,borderRadius:`${d.cornerRadius?.topLeft??12}px ${d.cornerRadius?.topRight??12}px ${d.cornerRadius?.bottomRight??12}px ${d.cornerRadius?.bottomLeft??12}px`,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",maxWidth:300,minWidth:200,transition:"top 0.2s ease, left 0.2s ease"},children:[(0,It.jsx)("div",{style:{position:"absolute",width:0,height:0,borderStyle:"solid",..._==="left"&&{left:-k,top:Math.max(12,Math.min(m.height-S*2-12,W+u.height/2-$-S)),borderWidth:`${S}px ${k}px ${S}px 0`,borderColor:`transparent ${T.tooltip||"#FE6B35"} transparent transparent`},..._==="right"&&{right:-k,top:Math.max(12,Math.min(m.height-S*2-12,W+u.height/2-$-S)),borderWidth:`${S}px 0 ${S}px ${k}px`,borderColor:`transparent transparent transparent ${T.tooltip||"#FE6B35"}`},..._==="top"&&{top:-k,left:Math.max(12,Math.min(m.width-S*2-12,P+u.width/2-M-S)),borderWidth:`0 ${S}px ${k}px ${S}px`,borderColor:`transparent transparent ${T.tooltip||"#FE6B35"} transparent`},..._==="bottom"&&{bottom:-k,left:Math.max(12,Math.min(m.width-S*2-12,P+u.width/2-M-S)),borderWidth:`${k}px ${S}px 0 ${S}px`,borderColor:`${T.tooltip||"#FE6B35"} transparent transparent transparent`}}}),y.titleText&&(0,It.jsx)("div",{style:{color:R.title?.color||"#ffffff",fontFamily:dt(R.title?.fontFamily)||"Arial",fontSize:R.title?.fontSize||14,textAlign:R.title?.textAlign||"center",marginBottom:R.title?.margin?.bottom??4,marginTop:R.title?.margin?.top??0,marginLeft:R.title?.margin?.left??0,marginRight:R.title?.margin?.right??0,fontWeight:R.title?.fontDecoration?.includes("bold")?"bold":600,fontStyle:R.title?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:R.title?.fontDecoration?.includes("underline")?"underline":"none"},children:y.titleText}),y.subtitleText&&(0,It.jsx)("div",{style:{color:R.subTitle?.color||"#ffffff",fontFamily:dt(R.subTitle?.fontFamily)||"Arial",fontSize:R.subTitle?.fontSize||12,textAlign:R.subTitle?.textAlign||"center",marginBottom:R.subTitle?.margin?.bottom??8,marginTop:R.subTitle?.margin?.top??0,marginLeft:R.subTitle?.margin?.left??0,marginRight:R.subTitle?.margin?.right??0,fontWeight:R.subTitle?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:R.subTitle?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:R.subTitle?.fontDecoration?.includes("underline")?"underline":"none"},children:y.subtitleText}),y.ctaText&&(0,It.jsx)("div",{style:{display:"flex",justifyContent:p.alignment==="right"?"flex-end":p.alignment==="left"?"flex-start":"center",marginTop:8},children:(0,It.jsx)("button",{onClick:tt,style:{width:p.ctaFullWidth?"100%":p.ctaWidth||"auto",height:p.height||35,background:p.backgroundColor||"#F7921C",color:A.color||"#ffffff",border:`${p.borderWidth||0}px solid ${p.borderColor||"transparent"}`,borderRadius:`${O.topLeft??7}px ${O.topRight??7}px ${O.bottomRight??7}px ${O.bottomLeft??7}px`,fontSize:A.fontSize||14,fontFamily:dt(A.fontFamily)||"Arial",fontWeight:A.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:A.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:A.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:y.ctaText})})]})]})},mi=br;var oo=require("react");et();var ft=require("react/jsx-runtime"),yi=()=>{let t=pt("BTS"),e=F(f=>f.campaigns),o=F(f=>f.allCampaigns),i=F(f=>f.currentScreen),n=t??(()=>{let f=(i||"").trim().toLowerCase(),b=[...e||[],...o||[]].find(h=>{if(!h||h.campaign_type!=="BTS")return!1;let y=!!(h.trigger_event??h.trigger);if(!(h.display_trigger!==!1&&!y))return!1;let I=(h.screen||"").trim().toLowerCase();return!I||I===f});if(b)try{return St(b)}catch{return b}})(),r=F(f=>f.isVisible),[s,a]=(0,oo.useState)(!1);(0,oo.useEffect)(()=>{n&&(a(!1),H("viewed",n.id))},[n]);let c=f=>{try{let b=F.getState(),y=(b.trackedEvents||[]).filter(w=>w!==f);b.setTrackedEvents(y)}catch{}};if(!n||s||!r)return null;let{details:u}=n,m=[...u.elements||[]].sort((f,b)=>(f.order||0)-(b.order||0)),g=u.backdropOpacity??.5;g>1&&(g=g/100);let v=f=>{switch(f.type){case"image":{let b={width:"100%",display:"block",objectFit:"contain",backgroundColor:f.imageBackgroundColor||"transparent",paddingBottom:f.paddingBottom??0,paddingLeft:f.paddingLeft??0,paddingRight:f.paddingRight??0,paddingTop:f.paddingTop??0,cursor:f.imageLink?"pointer":"default"};return(0,ft.jsx)("div",{style:{textAlign:f.alignment||"left",width:"100%"},children:f.url&&(0,ft.jsx)("img",{src:f.url,alt:"",style:b,onClick:()=>{if(f.imageLink){n?.id&&H("clicked",n.id);try{let h=String(f.imageLink||"").trim();if(h&&!h.startsWith("http")&&Ct(h))return}catch(h){console.warn("revealCampaignFromLink error",h)}try{window.open(f.imageLink,"_blank")}catch{}}}})},f.id)}case"cta":{let b=f.cta||{},h=b.container||{},y=b.cornerRadius||{},w=b.margin||{},I=b.text||{};return(0,ft.jsx)("div",{style:{display:"flex",justifyContent:h.alignment==="center"?"center":h.alignment==="right"?"flex-end":"flex-start",width:"100%",marginTop:w.top??0,marginBottom:w.bottom??0,marginLeft:w.left??0,marginRight:w.right??0},children:(0,ft.jsx)("button",{style:{width:h.ctaFullWidth?"100%":h.ctaWidth||"auto",height:h.height||45,backgroundColor:h.ctaBoxColor||h.backgroundColor||"#FE6B35",color:I.color||"#ffffff",border:`${h.borderWidth||0}px solid ${h.borderColor||"transparent"}`,borderRadius:`${y.topLeft??12}px ${y.topRight??12}px ${y.bottomRight??12}px ${y.bottomLeft??12}px`,fontSize:I.fontSize||14,fontFamily:dt(I.fontFamily)||"Arial",fontWeight:I.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:I.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:I.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px"},onClick:()=>{let B=f.ctaLink||f.url;if(B){n?.id&&H("clicked",n.id);try{let R=String(B||"").trim();if(R&&!R.startsWith("http")&&Ct(R))return}catch(R){console.warn("revealCampaignFromLink error",R)}try{window.open(B,"_blank")}catch{}}},children:f.ctaText||"Button"})},f.id)}case"body":{let b=f.titleFontStyle||{},h=f.descriptionFontStyle||{};return(0,ft.jsxs)("div",{style:{width:"100%",backgroundColor:f.bodyBackgroundColor||"transparent",marginTop:f.marginTop??0,marginBottom:f.marginBottom??20,marginLeft:f.marginLeft??4,marginRight:f.marginRight??4},children:[f.titleText&&(0,ft.jsx)("div",{style:{color:b.colour||"#000000",fontSize:b.fontSize?`${b.fontSize}px`:f.titleFontSize?`${f.titleFontSize}px`:"16px",fontFamily:dt(b.fontFamily)||"inherit",textAlign:b.alignment||"left",lineHeight:f.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:f.spacingBetweenTitleDesc??4},children:f.titleText}),f.descriptionText&&(0,ft.jsx)("div",{style:{color:h.colour||"#000000",fontSize:h.fontSize?`${h.fontSize}px`:f.descriptionFontSize?`${f.descriptionFontSize}px`:"14px",fontFamily:dt(h.fontFamily)||"inherit",textAlign:h.alignment||"left",lineHeight:f.descriptionLineHeight||1.5,fontWeight:h.decoration?.includes("bold")?"bold":"normal",fontStyle:h.decoration?.includes("italic")?"italic":"normal",textDecoration:h.decoration?.includes("underline")?"underline":"none"},children:f.descriptionText})]},f.id)}default:return null}};return(0,ft.jsxs)(ft.Fragment,{children:[(0,ft.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:u.backdropColor||"rgba(0,0,0,0.5)",opacity:g,zIndex:999998,transition:"opacity 0.3s ease"},onClick:()=>{n?.id&&c(`viaAppStorys${n.id}`),a(!0)}}),(0,ft.jsxs)("div",{style:{position:"fixed",bottom:0,left:"50%",transform:"translateX(-50%)",width:"100%",maxWidth:"500px",backgroundColor:u.backgroundColor||"#FFFFFF",borderTopLeftRadius:`${u.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${u.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:`${u.cornerRadius?.bottomLeft??0}px`,borderBottomRightRadius:`${u.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,ft.jsx)("div",{style:{width:"40px",height:"5px",backgroundColor:"#E0E0E0",borderRadius:"2.5px",marginBottom:"16px",cursor:"pointer"},onClick:()=>a(!0)}),u.crossButton?.enabled&&(0,ft.jsx)(Yt,{config:u.crossButton,onPress:()=>{n?.id&&c(`viaAppStorys${n.id}`),a(!0)},style:{top:u.crossButton?.margin?.top??12,right:u.crossButton?.margin?.right??12}}),(0,ft.jsx)("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:"12px"},children:m.map(v)})]})]})};var Et=require("react");et();var V=require("react/jsx-runtime"),hi=5,Xo=3;function qt(t){if(t!=null)return`${t}px`}function Pe(t){return{marginTop:qt(t?.top),marginRight:qt(t?.right),marginBottom:qt(t?.bottom),marginLeft:qt(t?.left)}}function tn(t){return dt(t)}function Se(t){return t?{color:t.color,fontSize:t.fontSize,fontFamily:tn(t.fontFamily),textAlign:t.textAlign,fontWeight:t.fontDecoration?.includes("bold")?"bold":void 0,fontStyle:t.fontDecoration?.includes("italic")?"italic":void 0,textDecoration:t.fontDecoration?.includes("underline")?"underline":void 0}:{}}function Ko(t){return`${t?.topLeft??8}px ${t?.topRight??8}px ${t?.bottomRight??8}px ${t?.bottomLeft??8}px`}function xr(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function Sr(t){let e=t.styling?.rating?.ratingType;return e==="number"||e==="emoji"||e==="star"?e:"star"}function Cr(t){let e=t.styling?.rating?.emoji;if(Array.isArray(e))return e.filter(o=>typeof o=="string"&&o.trim().length>0);if(e&&typeof e=="object"){let o=Object.values(e).filter(i=>typeof i=="string"&&i.trim().length>0);if(o.length>0)return o}if(typeof e=="string"&&e.trim()){if(e.includes(",")){let o=e.split(",").map(i=>i.trim()).filter(Boolean);if(o.length>0)return o}return[e]}return["\u{1F620}","\u{1F615}","\u{1F610}","\u{1F642}","\u{1F60D}"]}function vr(t){return Array.from({length:5},(e,o)=>o+1)}function Zo(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 wr(t){let e=t.styling?.rating||void 0,o=[e?.numberSpacing,e?.numberGap,e?.number_spacing,e?.number_gap,e?.spacingBetweenNumbers,e?.spaceBetweenNumbers,e?.numberOptionsSpacing];for(let n of o){let r=Zo(n);if(r!=null)return r}let i=e?.number;if(i&&typeof i=="object"){let n=i,r=[n.spacing,n.gap,n.optionsSpacing,n.numberSpacing,n.numberGap];for(let s of r){let a=Zo(s);if(a!=null)return a}}return 8}var kr=({fill:t,stroke:e})=>(0,V.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":!0,children:(0,V.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"})}),Rr=({details:t,appearance:e,rating:o,selectedOptions:i,comments:n,isHighRating:r,feedbackOptions:s,onRate:a,onToggleOption:c,onCommentChange:u,onInlineSubmit:x,canSubmit:m})=>{let g=t.styling||{},v=g.feedbackPage||{},f=g.rating||{},b=g.initialFeedback||{},h=v.submitButton?.cta,y=Sr(t),w=y==="number"?vr(t):[],I=y==="emoji"?Cr(t):[],B=y==="number"?wr(t):8,R=r?f.star?.high:f.star?.low;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)("div",{style:Pe(b.title?.margin),children:(0,V.jsx)("div",{style:{...Se(b.title?.textStyle),color:b.title?.textStyle?.color||"#101828",fontSize:b.title?.textStyle?.fontSize||20,lineHeight:1.3},children:t.title||"How was your experience?"})}),(0,V.jsx)("div",{style:Pe(b.subtitle?.margin),children:(0,V.jsx)("div",{style:{...Se(b.subtitle?.textStyle),color:b.subtitle?.textStyle?.color||"#4b5563",fontSize:b.subtitle?.textStyle?.fontSize||14,lineHeight:1.4},children:t.description_text||"Your feedback helps us improve your experience."})}),(0,V.jsxs)("div",{style:{marginTop:8,display:"flex",justifyContent:"center",gap:y==="number"?B:8,flexWrap:"wrap"},children:[y==="star"&&Array.from({length:hi},(d,T)=>{let l=T+1,p=l<=o,O=p?R?.stylingContainer:f.star?.unselected?.stylingContainer,A=p?R?.stylingStar:f.star?.unselected?.stylingStar;return(0,V.jsx)("button",{onClick:()=>a(l),style:{border:`${O?.borderWidth??1}px solid ${O?.border||"#d1d5db"}`,background:O?.background||"#ffffff",borderRadius:10,width:44,height:44,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0},"aria-label":`Rate ${l} out of ${hi}`,children:(0,V.jsx)(kr,{fill:A?.background||(p?"#f59e0b":"#e5e7eb"),stroke:A?.border||(p?"#d97706":"#9ca3af")})},l)}),y==="number"&&w.map((d,T)=>{let l=d===o;return(0,V.jsx)("button",{onClick:()=>a(d),style:{border:`1px solid ${l?"#1d4ed8":"#d1d5db"}`,background:l?"#dbeafe":"#ffffff",color:l?"#1d4ed8":"#111827",borderRadius:8,minWidth:36,height:36,padding:"0 10px",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontWeight:600},"aria-label":`Rate ${d}`,children:d},`${d}-${T}`)}),y==="emoji"&&I.map((d,T)=>{let l=T+1,p=l===o;return(0,V.jsx)("button",{onClick:()=>a(l),style:{border:`1px solid ${p?"#1d4ed8":"#d1d5db"}`,background:p?"#dbeafe":"#ffffff",borderRadius:"999px",width:44,height:44,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:22},"aria-label":`Emoji rating ${T+1}`,children:d},`${d}-${T}`)})]}),o>0&&(0,V.jsx)("div",{style:{marginTop:6,textAlign:"center",color:"#374151",fontSize:14},children:r?t.highStarText||f.highRatingSubtitle:t.lowStarText||f.lowRatingSubtitle}),o>0&&o<=Xo&&(0,V.jsxs)(V.Fragment,{children:[s.length>0&&(0,V.jsx)("div",{style:{...Pe(v.options?.margin),display:"flex",flexDirection:"column",alignItems:"stretch",gap:v.options?.optionsSpacing??8,width:"100%"},children:s.map(d=>{let l=i.includes(d)?v.options?.selectedOptions:v.options?.nonSelectedOptions;return(0,V.jsx)("button",{onClick:()=>c(d),style:{border:`${l?.borderWidth??1}px solid ${l?.colors?.border||"#d1d5db"}`,background:l?.colors?.background||"#f9fafb",color:l?.colors?.text||"#111827",width:"100%",height:v.options?.optionsHeight||38,borderRadius:Ko(v.options?.cornerRadius),padding:"0 14px",cursor:"pointer",textAlign:"center",...Se(l?.textStyle)},children:d},d)})}),(0,V.jsx)("textarea",{value:n,onChange:d=>u(d.target.value),placeholder:v.additionalComments?.placeholder||"Tell us what we can improve",style:{width:"100%",boxSizing:"border-box",minHeight:56,height:56,maxHeight:64,marginTop:8,resize:"none",overflowY:"auto",border:`${v.additionalComments?.borderWidth??1}px solid ${v.additionalComments?.colors?.border||"#d1d5db"}`,background:v.additionalComments?.colors?.background||"#ffffff",color:v.additionalComments?.colors?.text||"#111827",borderRadius:8,padding:"12px",...Se(v.additionalComments?.textStyle)}}),(0,V.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:8,paddingTop:6,paddingBottom:6,background:e?.backgroundColor||"#2f6ef5",display:"flex",justifyContent:"center"},children:(0,V.jsx)("button",{onClick:()=>x(),disabled:!m,style:{width:Math.max(140,Math.min(Zo(h?.container?.ctaWidth)??180,220)),maxWidth:"100%",minHeight:30,height:Math.max(30,Math.min(Number(h?.container?.height)||34,34)),border:`${h?.container?.borderWidth??1}px solid ${h?.container?.borderColor||"#ff7a00"}`,background:h?.container?.backgroundColor||"#ff2bc2",color:h?.text?.color||"#ffffff",borderRadius:Ko(h?.cornerRadius),fontFamily:tn(h?.text?.fontFamily),fontSize:Math.min(Number(h?.text?.fontSize)||14,14),fontWeight:h?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:m?"pointer":"not-allowed",opacity:m?1:.65,padding:"0 12px"},children:v.submitButton?.text||"Submit"})})]})]})},Tr=({details:t,isHighRating:e,onDone:o})=>{let i=t.styling||{},n=i.thankyouPage||{},r=i.rating||{},s=xr(n.doneButton?.cta?.container?.alignment);return(0,V.jsxs)(V.Fragment,{children:[t.thankyouImage&&(0,V.jsx)("div",{style:{display:"flex",justifyContent:"center",marginTop:6},children:(0,V.jsx)("img",{src:t.thankyouImage,alt:"thank you",style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80,objectFit:"cover",borderRadius:8}})}),(0,V.jsx)("div",{style:{...Pe(n.title?.margin),textAlign:"center"},children:(0,V.jsx)("div",{style:{...Se(n.title?.textStyle),color:n.title?.textStyle?.color||"#111827",fontSize:n.title?.textStyle?.fontSize||20,fontWeight:n.title?.textStyle?.fontDecoration?.includes("bold")?"bold":600},children:t.thankyouText||(e?r.highRatingTitle:r.lowRatingTitle)||"Thank you for your feedback"})}),(0,V.jsx)("div",{style:{...Pe(n.subtitle?.margin),textAlign:"center"},children:(0,V.jsx)("div",{style:{...Se(n.subtitle?.textStyle),color:n.subtitle?.textStyle?.color||"#4b5563",fontSize:n.subtitle?.textStyle?.fontSize||14},children:t.thankyouDescription||(e?r.highRatingSubtitle:r.lowRatingSubtitle)||"We appreciate your time."})}),(0,V.jsx)("div",{style:{marginTop:n.doneButton?.cta?.margin?.top??14,marginBottom:n.doneButton?.cta?.margin?.bottom??0,marginLeft:n.doneButton?.cta?.margin?.left??0,marginRight:n.doneButton?.cta?.margin?.right??0,display:"flex",justifyContent:s},children:(0,V.jsx)("button",{onClick:o,style:{width:n.doneButton?.cta?.container?.ctaFullWidth?"100%":n.doneButton?.cta?.container?.ctaWidth||"auto",height:n.doneButton?.cta?.container?.height||45,border:`${n.doneButton?.cta?.container?.borderWidth??0}px solid ${n.doneButton?.cta?.container?.borderColor||"transparent"}`,background:n.doneButton?.cta?.container?.backgroundColor||"#111827",color:n.doneButton?.cta?.text?.color||"#ffffff",borderRadius:Ko(n.doneButton?.cta?.cornerRadius),fontFamily:tn(n.doneButton?.cta?.text?.fontFamily),fontSize:n.doneButton?.cta?.text?.fontSize||16,fontWeight:n.doneButton?.cta?.text?.fontDecoration?.includes("bold")?"bold":500,cursor:"pointer",padding:"0 16px"},children:n.doneButton?.text||(e?"Rate Now":"Done")})})]})},Fr=()=>{let t=pt("CSAT"),e=F(C=>C.isVisible),o=F(C=>C.campaigns),i=F(C=>C.allCampaigns),n=F(C=>C.currentScreen),r=t??(()=>{let C=(n||"").trim().toLowerCase(),S=[...o||[],...i||[]].find(W=>{if(!W||W.campaign_type!=="CSAT")return!1;let P=!!(W.trigger_event??W.trigger);if(!(W.display_trigger!==!1&&!P))return!1;let $=(W.screen||"").trim().toLowerCase();return!$||$===C});if(S)try{return St(S)}catch{return S}})(),[s,a]=(0,Et.useState)(!1),[c,u]=(0,Et.useState)(!1),[x,m]=(0,Et.useState)(0),[g,v]=(0,Et.useState)([]),[f,b]=(0,Et.useState)(""),[h,y]=(0,Et.useState)(!1);(0,Et.useEffect)(()=>{if(!r)return;a(!1),u(!1),m(0),v([]),b(""),y(!1);let C=r.details?.styling?.appearance?.displayDelay??0,S=globalThis.setTimeout(()=>{u(!0),H("viewed",r.id)},Math.max(0,C)*1e3);return()=>globalThis.clearTimeout(S)},[r]);let w=(0,Et.useMemo)(()=>{let C=r?.details?.feedback_option||{};return Object.keys(C).sort((S,W)=>S.localeCompare(W)).map(S=>C[S]).filter(Boolean)},[r]);if(!r||!e||s||!c)return null;let I=r.details,B=I.styling||{},R=B.appearance||{},d=x>Xo,T=Number(I.width??80),l=Math.max(660,Math.min(1080,T*10)),p=C=>{v(S=>S.includes(C)?S.filter(W=>W!==C):[...S,C])},O=async C=>{let S=C?.rating??x;if(S<1)return;y(!0);let W=I.id||r.id,P=(C?.options??g)[0]||"",M=C?.comments??f??"";H("csat captured",W,{starCount:S,selectedOption:P,additionalComments:M})},A=C=>{if(m(C),C>Xo){v([]),b("");let S=I.id||r?.id;setTimeout(()=>{y(!0);try{H("csat captured",S,{starCount:C,selectedOption:"",additionalComments:""})}catch(W){console.warn("Error sending csat captured",W)}},1e3)}},_=()=>{if(d&&I.link){let C=r&&r.id||void 0;try{C&&H("clicked",C)}catch{}try{let S=String(I.link||"").trim();if(S&&!S.startsWith("http")&&Ct(S)){a(!0);return}}catch(S){console.warn("revealCampaignFromLink error",S)}try{globalThis.open(I.link,"_blank")}catch{}}a(!0)};return(0,V.jsx)("div",{style:{position:"fixed",left:0,right:0,bottom:0,zIndex:999999,display:"flex",justifyContent:"center",alignItems:"flex-end",paddingLeft:"10px",paddingRight:"10px",paddingBottom:"10px",pointerEvents:"none"},children:(0,V.jsxs)("div",{style:{position:"relative",width:`min(${l}px, 96vw)`,maxWidth:"96vw",minWidth:"320px",minHeight:"220px",maxHeight:"55vh",overflow:"hidden",backgroundColor:R.backgroundColor||"#2f6ef5",borderRadius:`${R.borderRadius??12}px`,boxSizing:"border-box",paddingTop:"8px",paddingRight:qt(R.padding?.right)||"12px",paddingBottom:"4px",paddingLeft:qt(R.padding?.left)||"12px",marginTop:qt(R.margin?.top),marginRight:qt(R.margin?.right),marginBottom:qt(R.margin?.bottom),marginLeft:qt(R.margin?.left),pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[(0,V.jsx)("style",{children:`
|
|
81
|
+
`}),(0,Lt.jsx)("div",{ref:A=>{u.current=A,I(A)},className:"widget-scroll-container",style:T,onScroll:d,children:b?g.map((A,_)=>(0,Lt.jsx)("div",{style:l(_),children:(0,Lt.jsx)("img",{src:A.image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onClick:()=>R(A.id,A.link)})},A.id)):g.length>0&&(0,Lt.jsx)("div",{style:l(0),children:(0,Lt.jsx)("img",{src:g[a].image,alt:"widget",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onClick:()=>R(g[a].id,g[a].link)})},`slide-${a}`)}),f==="full"&&g.length>1&&(0,Lt.jsx)("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"8px",width:"100%"},children:g.map((A,_)=>(0,Lt.jsx)("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:_===a?"#333":"#ccc",transition:"background-color 0.2s ease"}},_))})]}),O=null;if(s?.position){let A=String(s.position||"").replace(/^widget_/,""),_=[`[data-as-id="${A}"]`,`#${A}`,`.${A}`,`[data-widget="${A}"]`];for(let C of _)try{let S=document.querySelector(C);if(S){O=S,console.log("[Widget] Portal target found:",C,"for campaign",s?.id);break}}catch{}O||console.log("[Widget] No portal target found for position:",s?.position,"rendering inline for campaign:",s?.id)}return O?(0,fi.createPortal)(p,O):p};var pt=require("react");et();var zt=require("react/jsx-runtime"),Qo=t=>(t||"").trim().toLowerCase(),xr=()=>{let t=ct("TTP"),e=F(Y=>Y.campaigns),o=F(Y=>Y.allCampaigns),i=F(Y=>Y.currentScreen),n=F(Y=>Y.isVisible),[r,s]=(0,pt.useState)(0),[a,c]=(0,pt.useState)(!1),[u,x]=(0,pt.useState)(null),[m,g]=(0,pt.useState)({width:0,height:0}),v=(0,pt.useRef)(null),f=(0,pt.useRef)(null),b=(0,pt.useMemo)(()=>{if(t)return t;let Y=Qo(i),nt=U=>U.find(G=>{let Q=G,at=Q.campaign_type==="TTP"||Q.campaign_type==="TLTP",St=!Qo(Q.screen)||Qo(Q.screen)===Y,rt=!!(Q.trigger_event??Q.trigger),Bt=Q.display_trigger!==!1&&!rt;return at&&St&&Bt});return nt(e)??nt(o)},[t,e,o,i]),h=(0,pt.useMemo)(()=>b?.details?.tooltips&&Array.isArray(b.details.tooltips)?[...b.details.tooltips].sort((Y,nt)=>(Y.order??0)-(nt.order??0)):b?.details?.target||b?.details?.titleText?[{...b.details,_id:b.id}]:[],[b]),y=h[r];(0,pt.useEffect)(()=>{},[b]);let w=(0,pt.useRef)(new Set),I=(0,pt.useCallback)(()=>{if(!(!b||!y||a||!n))try{let Y=y._id||y.id||void 0,nt=String(b.id||"")+"::"+String(Y||"");w.current.has(nt)||(w.current.add(nt),H("viewed",b.id,{tooltip_id:Y}))}catch{}},[b,y,a,n]),B=Ae(I);if((0,pt.useEffect)(()=>{if(!y?.target||a)return;x(null);let Y=(G=!1)=>{let Q=y.target;if(!Q)return null;let at=document.getElementById(Q)||document.querySelector(`[data-id="${Q}"]`)||document.querySelector(`.${Q}`);return at?(x(at.getBoundingClientRect()),G&&at.scrollIntoView({behavior:"smooth",block:"center"}),at):null};Y(!0)||(f.current=new MutationObserver(()=>{Y(!0)&&f.current?.disconnect()}),f.current.observe(document.body,{childList:!0,subtree:!0}));let U=()=>{let G=Y(!1);G&&x(G.getBoundingClientRect())};return window.addEventListener("resize",U),window.addEventListener("scroll",U,{passive:!0}),()=>{f.current?.disconnect(),window.removeEventListener("resize",U),window.removeEventListener("scroll",U)}},[y,a,r]),(0,pt.useLayoutEffect)(()=>{if(v.current&&u){let{width:Y,height:nt}=v.current.getBoundingClientRect();g({width:Y,height:nt})}},[y,u]),!b||!y||a||!n||!u)return null;let R=y.styling||{},d=R.appearance||{},T=d.colors||{},l=R.cta||{},p=l.container||{},O=l.cornerRadius||{},A=l.text||{},_=y.arrowPosition||"left",S=(d.arrowStyle||{width:6,height:12}).width||6,W=u.top+window.scrollY,P=u.left+window.scrollX,M=0,$=0,k=8;_==="left"?(M=P+u.width+k,$=W+u.height/2-m.height/2):_==="right"?(M=P-m.width-k,$=W+u.height/2-m.height/2):_==="top"?($=W+u.height+k,M=P+u.width/2-m.width/2):_==="bottom"&&($=W-m.height-k,M=P+u.width/2-m.width/2);let L=8,j=window.scrollY,X=window.scrollY+window.innerHeight,ft=window.scrollX,N=window.scrollX+window.innerWidth;m.height>0&&($=Math.max(j+L,Math.min(X-m.height-L,$))),m.width>0&&(M=Math.max(ft+L,Math.min(N-m.width-L,M)));let tt=()=>{let Y=y.clickAction||"nextStep",nt=y.link||y.url;try{let U=y._id||y.id||void 0;b?.id&&H("clicked",b.id,{tooltip_id:U})}catch{}if(Y==="close"){c(!0),nt&&window.open(nt,"_blank");return}r<h.length-1?s(U=>U+1):(c(!0),nt&&window.open(nt,"_blank"))},K=()=>{y.enableBackdrop&&c(!0)};return(0,zt.jsxs)(zt.Fragment,{children:[y.enableBackdrop&&(0,zt.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:T.backdrop||"rgba(0, 0, 0, 0.7)",opacity:d.backdropOpacity?d.backdropOpacity/100:.7,zIndex:1e4},onClick:K}),(0,zt.jsxs)("div",{ref:Y=>{v.current=Y,B(Y)},style:{position:"absolute",top:$,left:M,zIndex:10001,backgroundColor:T.tooltip||"#FE6B35",padding:`${d.padding?.top??8}px ${d.padding?.right??8}px ${d.padding?.bottom??8}px ${d.padding?.left??8}px`,borderRadius:`${d.cornerRadius?.topLeft??12}px ${d.cornerRadius?.topRight??12}px ${d.cornerRadius?.bottomRight??12}px ${d.cornerRadius?.bottomLeft??12}px`,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",maxWidth:300,minWidth:200,transition:"top 0.2s ease, left 0.2s ease"},children:[(0,zt.jsx)("div",{style:{position:"absolute",width:0,height:0,borderStyle:"solid",..._==="left"&&{left:-k,top:Math.max(12,Math.min(m.height-S*2-12,W+u.height/2-$-S)),borderWidth:`${S}px ${k}px ${S}px 0`,borderColor:`transparent ${T.tooltip||"#FE6B35"} transparent transparent`},..._==="right"&&{right:-k,top:Math.max(12,Math.min(m.height-S*2-12,W+u.height/2-$-S)),borderWidth:`${S}px 0 ${S}px ${k}px`,borderColor:`transparent transparent transparent ${T.tooltip||"#FE6B35"}`},..._==="top"&&{top:-k,left:Math.max(12,Math.min(m.width-S*2-12,P+u.width/2-M-S)),borderWidth:`0 ${S}px ${k}px ${S}px`,borderColor:`transparent transparent ${T.tooltip||"#FE6B35"} transparent`},..._==="bottom"&&{bottom:-k,left:Math.max(12,Math.min(m.width-S*2-12,P+u.width/2-M-S)),borderWidth:`${k}px ${S}px 0 ${S}px`,borderColor:`${T.tooltip||"#FE6B35"} transparent transparent transparent`}}}),y.titleText&&(0,zt.jsx)("div",{style:{color:R.title?.color||"#ffffff",fontFamily:dt(R.title?.fontFamily)||"Arial",fontSize:R.title?.fontSize||14,textAlign:R.title?.textAlign||"center",marginBottom:R.title?.margin?.bottom??4,marginTop:R.title?.margin?.top??0,marginLeft:R.title?.margin?.left??0,marginRight:R.title?.margin?.right??0,fontWeight:R.title?.fontDecoration?.includes("bold")?"bold":600,fontStyle:R.title?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:R.title?.fontDecoration?.includes("underline")?"underline":"none"},children:y.titleText}),y.subtitleText&&(0,zt.jsx)("div",{style:{color:R.subTitle?.color||"#ffffff",fontFamily:dt(R.subTitle?.fontFamily)||"Arial",fontSize:R.subTitle?.fontSize||12,textAlign:R.subTitle?.textAlign||"center",marginBottom:R.subTitle?.margin?.bottom??8,marginTop:R.subTitle?.margin?.top??0,marginLeft:R.subTitle?.margin?.left??0,marginRight:R.subTitle?.margin?.right??0,fontWeight:R.subTitle?.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:R.subTitle?.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:R.subTitle?.fontDecoration?.includes("underline")?"underline":"none"},children:y.subtitleText}),y.ctaText&&(0,zt.jsx)("div",{style:{display:"flex",justifyContent:p.alignment==="right"?"flex-end":p.alignment==="left"?"flex-start":"center",marginTop:8},children:(0,zt.jsx)("button",{onClick:tt,style:{width:p.ctaFullWidth?"100%":p.ctaWidth||"auto",height:p.height||35,background:p.backgroundColor||"#F7921C",color:A.color||"#ffffff",border:`${p.borderWidth||0}px solid ${p.borderColor||"transparent"}`,borderRadius:`${O.topLeft??7}px ${O.topRight??7}px ${O.bottomRight??7}px ${O.bottomLeft??7}px`,fontSize:A.fontSize||14,fontFamily:dt(A.fontFamily)||"Arial",fontWeight:A.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:A.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:A.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:y.ctaText})})]})]})},yi=xr;var eo=require("react");et();var gt=require("react/jsx-runtime"),hi=()=>{let t=ct("BTS"),e=F(f=>f.campaigns),o=F(f=>f.allCampaigns),i=F(f=>f.currentScreen),n=t??(()=>{let f=(i||"").trim().toLowerCase(),b=[...e||[],...o||[]].find(h=>{if(!h||h.campaign_type!=="BTS")return!1;let y=!!(h.trigger_event??h.trigger);if(!(h.display_trigger!==!1&&!y))return!1;let I=(h.screen||"").trim().toLowerCase();return!I||I===f});if(b)try{return Ct(b)}catch{return b}})(),r=F(f=>f.isVisible),[s,a]=(0,eo.useState)(!1);(0,eo.useEffect)(()=>{n&&(a(!1),H("viewed",n.id))},[n]);let c=f=>{try{let b=F.getState(),y=(b.trackedEvents||[]).filter(w=>w!==f);b.setTrackedEvents(y)}catch{}};if(!n||s||!r)return null;let{details:u}=n,m=[...u.elements||[]].sort((f,b)=>(f.order||0)-(b.order||0)),g=u.backdropOpacity??.5;g>1&&(g=g/100);let v=f=>{switch(f.type){case"image":{let b={width:"100%",display:"block",objectFit:"contain",backgroundColor:f.imageBackgroundColor||"transparent",paddingBottom:f.paddingBottom??0,paddingLeft:f.paddingLeft??0,paddingRight:f.paddingRight??0,paddingTop:f.paddingTop??0,cursor:f.imageLink?"pointer":"default"};return(0,gt.jsx)("div",{style:{textAlign:f.alignment||"left",width:"100%"},children:f.url&&(0,gt.jsx)("img",{src:f.url,alt:"",style:b,onClick:()=>{if(f.imageLink){n?.id&&H("clicked",n.id);try{let h=String(f.imageLink||"").trim();if(h&&!h.startsWith("http")&&vt(h))return}catch(h){console.warn("revealCampaignFromLink error",h)}try{window.open(f.imageLink,"_blank")}catch{}}}})},f.id)}case"cta":{let b=f.cta||{},h=b.container||{},y=b.cornerRadius||{},w=b.margin||{},I=b.text||{};return(0,gt.jsx)("div",{style:{display:"flex",justifyContent:h.alignment==="center"?"center":h.alignment==="right"?"flex-end":"flex-start",width:"100%",marginTop:w.top??0,marginBottom:w.bottom??0,marginLeft:w.left??0,marginRight:w.right??0},children:(0,gt.jsx)("button",{style:{width:h.ctaFullWidth?"100%":h.ctaWidth||"auto",height:h.height||45,backgroundColor:h.ctaBoxColor||h.backgroundColor||"#FE6B35",color:I.color||"#ffffff",border:`${h.borderWidth||0}px solid ${h.borderColor||"transparent"}`,borderRadius:`${y.topLeft??12}px ${y.topRight??12}px ${y.bottomRight??12}px ${y.bottomLeft??12}px`,fontSize:I.fontSize||14,fontFamily:dt(I.fontFamily)||"Arial",fontWeight:I.fontDecoration?.includes("bold")?"bold":"normal",fontStyle:I.fontDecoration?.includes("italic")?"italic":"normal",textDecoration:I.fontDecoration?.includes("underline")?"underline":"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 16px"},onClick:()=>{let B=f.ctaLink||f.url;if(B){n?.id&&H("clicked",n.id);try{let R=String(B||"").trim();if(R&&!R.startsWith("http")&&vt(R))return}catch(R){console.warn("revealCampaignFromLink error",R)}try{window.open(B,"_blank")}catch{}}},children:f.ctaText||"Button"})},f.id)}case"body":{let b=f.titleFontStyle||{},h=f.descriptionFontStyle||{};return(0,gt.jsxs)("div",{style:{width:"100%",backgroundColor:f.bodyBackgroundColor||"transparent",marginTop:f.marginTop??0,marginBottom:f.marginBottom??20,marginLeft:f.marginLeft??4,marginRight:f.marginRight??4},children:[f.titleText&&(0,gt.jsx)("div",{style:{color:b.colour||"#000000",fontSize:b.fontSize?`${b.fontSize}px`:f.titleFontSize?`${f.titleFontSize}px`:"16px",fontFamily:dt(b.fontFamily)||"inherit",textAlign:b.alignment||"left",lineHeight:f.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:f.spacingBetweenTitleDesc??4},children:f.titleText}),f.descriptionText&&(0,gt.jsx)("div",{style:{color:h.colour||"#000000",fontSize:h.fontSize?`${h.fontSize}px`:f.descriptionFontSize?`${f.descriptionFontSize}px`:"14px",fontFamily:dt(h.fontFamily)||"inherit",textAlign:h.alignment||"left",lineHeight:f.descriptionLineHeight||1.5,fontWeight:h.decoration?.includes("bold")?"bold":"normal",fontStyle:h.decoration?.includes("italic")?"italic":"normal",textDecoration:h.decoration?.includes("underline")?"underline":"none"},children:f.descriptionText})]},f.id)}default:return null}};return(0,gt.jsxs)(gt.Fragment,{children:[(0,gt.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:u.backdropColor||"rgba(0,0,0,0.5)",opacity:g,zIndex:999998,transition:"opacity 0.3s ease"},onClick:()=>{n?.id&&c(`viaAppStorys${n.id}`),a(!0)}}),(0,gt.jsxs)("div",{style:{position:"fixed",bottom:0,left:"50%",transform:"translateX(-50%)",width:"100%",maxWidth:"500px",backgroundColor:u.backgroundColor||"#FFFFFF",borderTopLeftRadius:`${u.cornerRadius?.topLeft??16}px`,borderTopRightRadius:`${u.cornerRadius?.topRight??16}px`,borderBottomLeftRadius:`${u.cornerRadius?.bottomLeft??0}px`,borderBottomRightRadius:`${u.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,gt.jsx)("div",{style:{width:"40px",height:"5px",backgroundColor:"#E0E0E0",borderRadius:"2.5px",marginBottom:"16px",cursor:"pointer"},onClick:()=>a(!0)}),u.crossButton?.enabled&&(0,gt.jsx)(Qt,{config:u.crossButton,onPress:()=>{n?.id&&c(`viaAppStorys${n.id}`),a(!0)},style:{top:u.crossButton?.margin?.top??12,right:u.crossButton?.margin?.right??12}}),(0,gt.jsx)("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:"12px"},children:m.map(v)})]})]})};var Dt=require("react");et();var V=require("react/jsx-runtime"),bi=5,Go=3;function Ht(t){if(t!=null)return`${t}px`}function Ee(t){return{marginTop:Ht(t?.top),marginRight:Ht(t?.right),marginBottom:Ht(t?.bottom),marginLeft:Ht(t?.left)}}function Ko(t){return dt(t)}function Se(t){return t?{color:t.color,fontSize:t.fontSize,fontFamily:Ko(t.fontFamily),textAlign:t.textAlign,fontWeight:t.fontDecoration?.includes("bold")?"bold":void 0,fontStyle:t.fontDecoration?.includes("italic")?"italic":void 0,textDecoration:t.fontDecoration?.includes("underline")?"underline":void 0}:{}}function Jo(t){return`${t?.topLeft??8}px ${t?.topRight??8}px ${t?.bottomRight??8}px ${t?.bottomLeft??8}px`}function Sr(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function Cr(t){let e=t.styling?.rating?.ratingType;return e==="number"||e==="emoji"||e==="star"?e:"star"}function vr(t){let e=t.styling?.rating?.emoji;if(Array.isArray(e))return e.filter(o=>typeof o=="string"&&o.trim().length>0);if(e&&typeof e=="object"){let o=Object.values(e).filter(i=>typeof i=="string"&&i.trim().length>0);if(o.length>0)return o}if(typeof e=="string"&&e.trim()){if(e.includes(",")){let o=e.split(",").map(i=>i.trim()).filter(Boolean);if(o.length>0)return o}return[e]}return["\u{1F620}","\u{1F615}","\u{1F610}","\u{1F642}","\u{1F60D}"]}function wr(t){return Array.from({length:5},(e,o)=>o+1)}function Xo(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 kr(t){let e=t.styling?.rating||void 0,o=[e?.numberSpacing,e?.numberGap,e?.number_spacing,e?.number_gap,e?.spacingBetweenNumbers,e?.spaceBetweenNumbers,e?.numberOptionsSpacing];for(let n of o){let r=Xo(n);if(r!=null)return r}let i=e?.number;if(i&&typeof i=="object"){let n=i,r=[n.spacing,n.gap,n.optionsSpacing,n.numberSpacing,n.numberGap];for(let s of r){let a=Xo(s);if(a!=null)return a}}return 8}var Rr=({fill:t,stroke:e})=>(0,V.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":!0,children:(0,V.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"})}),Tr=({details:t,appearance:e,rating:o,selectedOptions:i,comments:n,isHighRating:r,feedbackOptions:s,onRate:a,onToggleOption:c,onCommentChange:u,onInlineSubmit:x,canSubmit:m})=>{let g=t.styling||{},v=g.feedbackPage||{},f=g.rating||{},b=g.initialFeedback||{},h=v.submitButton?.cta,y=Cr(t),w=y==="number"?wr(t):[],I=y==="emoji"?vr(t):[],B=y==="number"?kr(t):8,R=r?f.star?.high:f.star?.low;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)("div",{style:Ee(b.title?.margin),children:(0,V.jsx)("div",{style:{...Se(b.title?.textStyle),color:b.title?.textStyle?.color||"#101828",fontSize:b.title?.textStyle?.fontSize||20,lineHeight:1.3},children:t.title||"How was your experience?"})}),(0,V.jsx)("div",{style:Ee(b.subtitle?.margin),children:(0,V.jsx)("div",{style:{...Se(b.subtitle?.textStyle),color:b.subtitle?.textStyle?.color||"#4b5563",fontSize:b.subtitle?.textStyle?.fontSize||14,lineHeight:1.4},children:t.description_text||"Your feedback helps us improve your experience."})}),(0,V.jsxs)("div",{style:{marginTop:8,display:"flex",justifyContent:"center",gap:y==="number"?B:8,flexWrap:"wrap"},children:[y==="star"&&Array.from({length:bi},(d,T)=>{let l=T+1,p=l<=o,O=p?R?.stylingContainer:f.star?.unselected?.stylingContainer,A=p?R?.stylingStar:f.star?.unselected?.stylingStar;return(0,V.jsx)("button",{onClick:()=>a(l),style:{border:`${O?.borderWidth??1}px solid ${O?.border||"#d1d5db"}`,background:O?.background||"#ffffff",borderRadius:10,width:44,height:44,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0},"aria-label":`Rate ${l} out of ${bi}`,children:(0,V.jsx)(Rr,{fill:A?.background||(p?"#f59e0b":"#e5e7eb"),stroke:A?.border||(p?"#d97706":"#9ca3af")})},l)}),y==="number"&&w.map((d,T)=>{let l=d===o;return(0,V.jsx)("button",{onClick:()=>a(d),style:{border:`1px solid ${l?"#1d4ed8":"#d1d5db"}`,background:l?"#dbeafe":"#ffffff",color:l?"#1d4ed8":"#111827",borderRadius:8,minWidth:36,height:36,padding:"0 10px",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontWeight:600},"aria-label":`Rate ${d}`,children:d},`${d}-${T}`)}),y==="emoji"&&I.map((d,T)=>{let l=T+1,p=l===o;return(0,V.jsx)("button",{onClick:()=>a(l),style:{border:`1px solid ${p?"#1d4ed8":"#d1d5db"}`,background:p?"#dbeafe":"#ffffff",borderRadius:"999px",width:44,height:44,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:22},"aria-label":`Emoji rating ${T+1}`,children:d},`${d}-${T}`)})]}),o>0&&(0,V.jsx)("div",{style:{marginTop:6,textAlign:"center",color:"#374151",fontSize:14},children:r?t.highStarText||f.highRatingSubtitle:t.lowStarText||f.lowRatingSubtitle}),o>0&&o<=Go&&(0,V.jsxs)(V.Fragment,{children:[s.length>0&&(0,V.jsx)("div",{style:{...Ee(v.options?.margin),display:"flex",flexDirection:"column",alignItems:"stretch",gap:v.options?.optionsSpacing??8,width:"100%"},children:s.map(d=>{let l=i.includes(d)?v.options?.selectedOptions:v.options?.nonSelectedOptions;return(0,V.jsx)("button",{onClick:()=>c(d),style:{border:`${l?.borderWidth??1}px solid ${l?.colors?.border||"#d1d5db"}`,background:l?.colors?.background||"#f9fafb",color:l?.colors?.text||"#111827",width:"100%",height:v.options?.optionsHeight||38,borderRadius:Jo(v.options?.cornerRadius),padding:"0 14px",cursor:"pointer",textAlign:"center",...Se(l?.textStyle)},children:d},d)})}),(0,V.jsx)("textarea",{value:n,onChange:d=>u(d.target.value),placeholder:v.additionalComments?.placeholder||"Tell us what we can improve",style:{width:"100%",boxSizing:"border-box",minHeight:56,height:56,maxHeight:64,marginTop:8,resize:"none",overflowY:"auto",border:`${v.additionalComments?.borderWidth??1}px solid ${v.additionalComments?.colors?.border||"#d1d5db"}`,background:v.additionalComments?.colors?.background||"#ffffff",color:v.additionalComments?.colors?.text||"#111827",borderRadius:8,padding:"12px",...Se(v.additionalComments?.textStyle)}}),(0,V.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:8,paddingTop:6,paddingBottom:6,background:e?.backgroundColor||"#2f6ef5",display:"flex",justifyContent:"center"},children:(0,V.jsx)("button",{onClick:()=>x(),disabled:!m,style:{width:Math.max(140,Math.min(Xo(h?.container?.ctaWidth)??180,220)),maxWidth:"100%",minHeight:30,height:Math.max(30,Math.min(Number(h?.container?.height)||34,34)),border:`${h?.container?.borderWidth??1}px solid ${h?.container?.borderColor||"#ff7a00"}`,background:h?.container?.backgroundColor||"#ff2bc2",color:h?.text?.color||"#ffffff",borderRadius:Jo(h?.cornerRadius),fontFamily:Ko(h?.text?.fontFamily),fontSize:Math.min(Number(h?.text?.fontSize)||14,14),fontWeight:h?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:m?"pointer":"not-allowed",opacity:m?1:.65,padding:"0 12px"},children:v.submitButton?.text||"Submit"})})]})]})},Fr=({details:t,isHighRating:e,onDone:o})=>{let i=t.styling||{},n=i.thankyouPage||{},r=i.rating||{},s=Sr(n.doneButton?.cta?.container?.alignment);return(0,V.jsxs)(V.Fragment,{children:[t.thankyouImage&&(0,V.jsx)("div",{style:{display:"flex",justifyContent:"center",marginTop:6},children:(0,V.jsx)("img",{src:t.thankyouImage,alt:"thank you",style:{width:n.imageStyle?.width||80,height:n.imageStyle?.height||80,objectFit:"cover",borderRadius:8}})}),(0,V.jsx)("div",{style:{...Ee(n.title?.margin),textAlign:"center"},children:(0,V.jsx)("div",{style:{...Se(n.title?.textStyle),color:n.title?.textStyle?.color||"#111827",fontSize:n.title?.textStyle?.fontSize||20,fontWeight:n.title?.textStyle?.fontDecoration?.includes("bold")?"bold":600},children:t.thankyouText||(e?r.highRatingTitle:r.lowRatingTitle)||"Thank you for your feedback"})}),(0,V.jsx)("div",{style:{...Ee(n.subtitle?.margin),textAlign:"center"},children:(0,V.jsx)("div",{style:{...Se(n.subtitle?.textStyle),color:n.subtitle?.textStyle?.color||"#4b5563",fontSize:n.subtitle?.textStyle?.fontSize||14},children:t.thankyouDescription||(e?r.highRatingSubtitle:r.lowRatingSubtitle)||"We appreciate your time."})}),(0,V.jsx)("div",{style:{marginTop:n.doneButton?.cta?.margin?.top??14,marginBottom:n.doneButton?.cta?.margin?.bottom??0,marginLeft:n.doneButton?.cta?.margin?.left??0,marginRight:n.doneButton?.cta?.margin?.right??0,display:"flex",justifyContent:s},children:(0,V.jsx)("button",{onClick:o,style:{width:n.doneButton?.cta?.container?.ctaFullWidth?"100%":n.doneButton?.cta?.container?.ctaWidth||"auto",height:n.doneButton?.cta?.container?.height||45,border:`${n.doneButton?.cta?.container?.borderWidth??0}px solid ${n.doneButton?.cta?.container?.borderColor||"transparent"}`,background:n.doneButton?.cta?.container?.backgroundColor||"#111827",color:n.doneButton?.cta?.text?.color||"#ffffff",borderRadius:Jo(n.doneButton?.cta?.cornerRadius),fontFamily:Ko(n.doneButton?.cta?.text?.fontFamily),fontSize:n.doneButton?.cta?.text?.fontSize||16,fontWeight:n.doneButton?.cta?.text?.fontDecoration?.includes("bold")?"bold":500,cursor:"pointer",padding:"0 16px"},children:n.doneButton?.text||(e?"Rate Now":"Done")})})]})},Ir=()=>{let t=ct("CSAT"),e=F(C=>C.isVisible),o=F(C=>C.campaigns),i=F(C=>C.allCampaigns),n=F(C=>C.currentScreen),r=t??(()=>{let C=(n||"").trim().toLowerCase(),S=[...o||[],...i||[]].find(W=>{if(!W||W.campaign_type!=="CSAT")return!1;let P=!!(W.trigger_event??W.trigger);if(!(W.display_trigger!==!1&&!P))return!1;let $=(W.screen||"").trim().toLowerCase();return!$||$===C});if(S)try{return Ct(S)}catch{return S}})(),[s,a]=(0,Dt.useState)(!1),[c,u]=(0,Dt.useState)(!1),[x,m]=(0,Dt.useState)(0),[g,v]=(0,Dt.useState)([]),[f,b]=(0,Dt.useState)(""),[h,y]=(0,Dt.useState)(!1);(0,Dt.useEffect)(()=>{if(!r)return;a(!1),u(!1),m(0),v([]),b(""),y(!1);let C=r.details?.styling?.appearance?.displayDelay??0,S=globalThis.setTimeout(()=>{u(!0),H("viewed",r.id)},Math.max(0,C)*1e3);return()=>globalThis.clearTimeout(S)},[r]);let w=(0,Dt.useMemo)(()=>{let C=r?.details?.feedback_option||{};return Object.keys(C).sort((S,W)=>S.localeCompare(W)).map(S=>C[S]).filter(Boolean)},[r]);if(!r||!e||s||!c)return null;let I=r.details,B=I.styling||{},R=B.appearance||{},d=x>Go,T=Number(I.width??80),l=Math.max(660,Math.min(1080,T*10)),p=C=>{v(S=>S.includes(C)?S.filter(W=>W!==C):[...S,C])},O=async C=>{let S=C?.rating??x;if(S<1)return;y(!0);let W=I.id||r.id,P=(C?.options??g)[0]||"",M=C?.comments??f??"";H("csat captured",W,{starCount:S,selectedOption:P,additionalComments:M})},A=C=>{if(m(C),C>Go){v([]),b("");let S=I.id||r?.id;setTimeout(()=>{y(!0);try{H("csat captured",S,{starCount:C,selectedOption:"",additionalComments:""})}catch(W){console.warn("Error sending csat captured",W)}},1e3)}},_=()=>{if(d&&I.link){let C=r&&r.id||void 0;try{C&&H("clicked",C)}catch{}try{let S=String(I.link||"").trim();if(S&&!S.startsWith("http")&&vt(S)){a(!0);return}}catch(S){console.warn("revealCampaignFromLink error",S)}try{globalThis.open(I.link,"_blank")}catch{}}a(!0)};return(0,V.jsx)("div",{style:{position:"fixed",left:0,right:0,bottom:0,zIndex:999999,display:"flex",justifyContent:"center",alignItems:"flex-end",paddingLeft:"10px",paddingRight:"10px",paddingBottom:"10px",pointerEvents:"none"},children:(0,V.jsxs)("div",{style:{position:"relative",width:`min(${l}px, 96vw)`,maxWidth:"96vw",minWidth:"320px",minHeight:"220px",maxHeight:"55vh",overflow:"hidden",backgroundColor:R.backgroundColor||"#2f6ef5",borderRadius:`${R.borderRadius??12}px`,boxSizing:"border-box",paddingTop:"8px",paddingRight:Ht(R.padding?.right)||"12px",paddingBottom:"4px",paddingLeft:Ht(R.padding?.left)||"12px",marginTop:Ht(R.margin?.top),marginRight:Ht(R.margin?.right),marginBottom:Ht(R.margin?.bottom),marginLeft:Ht(R.margin?.left),pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[(0,V.jsx)("style",{children:`
|
|
82
82
|
.appstorys-csat-scroll {
|
|
83
83
|
scrollbar-width: none; /* Firefox */
|
|
84
84
|
-ms-overflow-style: none; /* IE/Edge */
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
height: 0;
|
|
89
89
|
display: none; /* Chrome/Safari */
|
|
90
90
|
}
|
|
91
|
-
`}),B.crossButton?.enabled&&(0,V.jsx)(Yt,{config:B.crossButton,onPress:()=>a(!0),style:{top:B.crossButton?.margin?.top??10,right:B.crossButton?.margin?.right??10}}),(0,V.jsx)("div",{className:"appstorys-csat-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:4},children:h?(0,V.jsx)(Tr,{details:I,isHighRating:d,onDone:_}):(0,V.jsx)(Rr,{details:I,rating:x,selectedOptions:g,comments:f,isHighRating:d,feedbackOptions:w,onRate:A,onToggleOption:p,onCommentChange:b,onInlineSubmit:O,canSubmit:x>=1,appearance:R})})]})})},bi=Fr;var vt=require("react");et();var G=require("react/jsx-runtime");function no(t){if(t!=null)return`${t}px`}function en(t){return dt(t)}function Ce(t){return t?{color:t.color,fontSize:t.fontSize,fontFamily:en(t.fontFamily),textAlign:t.textAlign,fontWeight:t.fontDecoration?.includes("bold")?"bold":void 0,fontStyle:t.fontDecoration?.includes("italic")?"italic":void 0,textDecoration:t.fontDecoration?.includes("underline")?"underline":void 0}:{}}function io(t){return{marginTop:no(t?.top),marginRight:no(t?.right),marginBottom:no(t?.bottom),marginLeft:no(t?.left)}}function ro(t){return`${t?.topLeft??12}px ${t?.topRight??12}px ${t?.bottomRight??t?.topRight??12}px ${t?.bottomLeft??t?.topLeft??12}px`}function Ci(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function Le(t){return Math.max(0,Math.min(1,t))}function Ir(t,e){let o=(t||"").trim().replace("#","");if(o.length===3){let i=Number.parseInt(o[0]+o[0],16),n=Number.parseInt(o[1]+o[1],16),r=Number.parseInt(o[2]+o[2],16);return`rgba(${i}, ${n}, ${r}, ${Le(e)})`}if(o.length===6){let i=Number.parseInt(o.slice(0,2),16),n=Number.parseInt(o.slice(2,4),16),r=Number.parseInt(o.slice(4,6),16);return`rgba(${i}, ${n}, ${r}, ${Le(e)})`}return`rgba(0, 0, 0, ${Le(e)})`}function zr(t){if(t==null)return .4;let e=Number(t);return Number.isFinite(e)?e>1?Le(e/100):Le(e):.4}function xi(t){return[...t.slides||[]].sort((o,i)=>(o.order??0)-(i.order??0))}function Br(t){let e=t?.options||{},o=Object.keys(e),i=n=>{let r=/(\d+)/.exec(n);if(!r)return;let s=Number(r[1]);return Number.isFinite(s)?s:void 0};return o.sort((n,r)=>{let s=i(n),a=i(r);return s!=null&&a!=null?s-a:s!=null?-1:a!=null?1:n.localeCompare(r)}),o.map(n=>e[n]).filter(n=>typeof n=="string"&&n.trim().length>0)}function Ar(t,e){if(!t)return null;if(t==="alphabet"){let o="A".codePointAt(0)??65;return String.fromCodePoint(o+e%26)}return t==="number"?String(e+1):null}function Er(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 Si(t){return Er(t?.borderwidth)??1}var Pr=({details:t,slide:e,appearance:o,selectedOption:i,comment:n,onSelectOption:r,onCommentChange:s,onSubmit:a,canSubmit:c})=>{let u=t.styling||{},x=u.options||{},m=u.cta,g=(0,vt.useMemo)(()=>Br(e),[e]),v=x.optionsSpacing??8,f=x.bulletSpacing??10,b=x.optionsHeight??44,h=Ci(m?.container?.alignment);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)("div",{style:io(u.title?.textStyle?.margin),children:(0,G.jsx)("div",{style:{...Ce(u.title?.textStyle),color:u.title?.textStyle?.color||"#111827",fontSize:u.title?.textStyle?.fontSize||20,lineHeight:1.3,fontWeight:u.title?.textStyle?.fontDecoration?.includes("bold")?"bold":700},children:e.title||e.question||t.name||"Survey"})}),(e.subtitle||u.subtitle?.textStyle)&&(0,G.jsx)("div",{style:io(u.subtitle?.textStyle?.margin),children:(0,G.jsx)("div",{style:{...Ce(u.subtitle?.textStyle),color:u.subtitle?.textStyle?.color||"#6b7280",fontSize:u.subtitle?.textStyle?.fontSize||14,lineHeight:1.35},children:e.subtitle||""})}),g.length>0&&(0,G.jsx)("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:v},children:g.map((y,w)=>{let I=i===y,B=I?x.selectedOptions:x.nonSelectedOptions,R=Si(B?.textStyle),d=Ar(x.optionListStyle,w);return(0,G.jsxs)("button",{onClick:()=>r(y),style:{width:"100%",boxSizing:"border-box",height:b,borderRadius:ro(x.cornerRadius),border:`${R}px solid ${B?.colors?.border||"#e5e7eb"}`,background:B?.colors?.background||"#ffffff",color:B?.colors?.text||"#111827",cursor:"pointer",display:"flex",alignItems:"center",gap:f,paddingLeft:14,paddingRight:14,textAlign:"left",...Ce(B?.textStyle)},"aria-pressed":I,children:[(0,G.jsx)("span",{"aria-hidden":!0,style:{width:16,height:16,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",border:`1.5px solid ${B?.colors?.border||"#111827"}`,background:"#ffffff",flex:"0 0 auto",fontSize:11,fontWeight:700,color:B?.colors?.text||"#111827"},children:I?"\u2713":d||""}),(0,G.jsx)("span",{style:{flex:1,minWidth:0},children:y})]},`${y}-${w}`)})}),e.additionalComment?.enabled&&(0,G.jsx)("textarea",{value:n,onChange:y=>s(y.target.value),placeholder:e.additionalComment?.placeholder||"",style:{marginTop:10,width:"100%",boxSizing:"border-box",minHeight:72,resize:"none",overflowY:"auto",border:`${Si(x.additionalComments?.textStyle)}px solid ${x.additionalComments?.colors?.border||"#e5e7eb"}`,background:x.additionalComments?.colors?.background||"#ffffff",color:x.additionalComments?.colors?.text||"#111827",borderRadius:10,padding:"12px",...Ce(x.additionalComments?.textStyle)}}),(0,G.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:12,paddingTop:10,paddingBottom:6,background:o?.backgroundColor||"#ffffff"},children:(0,G.jsx)("div",{style:{marginTop:m?.margin?.top??0,marginBottom:m?.margin?.bottom??0,marginLeft:m?.margin?.left??0,marginRight:m?.margin?.right??0,display:"flex",justifyContent:h},children:(0,G.jsx)("button",{onClick:a,disabled:!c,style:{width:m?.container?.ctaFullWidth?"100%":m?.container?.ctaWidth??"100%",height:m?.container?.height??44,border:`${m?.container?.borderWidth??0}px solid ${m?.container?.borderColor||"transparent"}`,background:m?.container?.backgroundColor||"#111827",color:m?.text?.color||"#ffffff",borderRadius:ro(m?.cornerRadius),fontFamily:en(m?.text?.fontFamily),fontSize:m?.text?.fontSize||14,fontWeight:m?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:c?"pointer":"not-allowed",opacity:c?1:.6,padding:"0 16px"},children:e.submitButtonText||"Submit"})})})]})},Lr=({details:t,onDone:e})=>{let i=(t.styling||{}).thankyouPage||{},n=i.cta,r=Ci(n?.container?.alignment);return(0,G.jsxs)(G.Fragment,{children:[t.thankYouImage&&(0,G.jsx)("div",{style:{display:"flex",justifyContent:"center",marginTop:8},children:(0,G.jsx)("img",{src:t.thankYouImage,alt:"thank you",style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80,objectFit:"cover",borderRadius:10}})}),(0,G.jsx)("div",{style:{...io(i.title?.textStyle?.margin)},children:(0,G.jsx)("div",{style:{...Ce(i.title?.textStyle),color:i.title?.textStyle?.color||"#111827",fontSize:i.title?.textStyle?.fontSize||20,lineHeight:1.3,fontWeight:i.title?.textStyle?.fontDecoration?.includes("bold")?"bold":700},children:t.thankYouTitle||"Thank you"})}),(0,G.jsx)("div",{style:{...io(i.subtitle?.textStyle?.margin)},children:(0,G.jsx)("div",{style:{...Ce(i.subtitle?.textStyle),color:i.subtitle?.textStyle?.color||"#6b7280",fontSize:i.subtitle?.textStyle?.fontSize||14,lineHeight:1.35},children:t.thankYouText||""})}),(t.thankYouButtonText||n)&&(0,G.jsx)("div",{style:{marginTop:n?.margin?.top??14,marginBottom:n?.margin?.bottom??0,marginLeft:n?.margin?.left??0,marginRight:n?.margin?.right??0,display:"flex",justifyContent:r},children:(0,G.jsx)("button",{onClick:e,style:{width:n?.container?.ctaFullWidth?"100%":n?.container?.ctaWidth??"auto",height:n?.container?.height??40,border:`${n?.container?.borderWidth??0}px solid ${n?.container?.borderColor||"transparent"}`,background:n?.container?.backgroundColor||"#111827",color:n?.text?.color||"#ffffff",borderRadius:ro(n?.cornerRadius),fontFamily:en(n?.text?.fontFamily),fontSize:n?.text?.fontSize||14,fontWeight:n?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:"pointer",padding:"0 16px"},children:t.thankYouButtonText||"Done"})})]})},Dr=()=>{let t=pt("SUR"),e=F(P=>P.isVisible),o=F(P=>P.campaigns),i=F(P=>P.allCampaigns),n=F(P=>P.currentScreen),r=t??(()=>{let P=(n||"").trim().toLowerCase(),M=[...o||[],...i||[]].find($=>{if(!$||$.campaign_type!=="SUR")return!1;let k=!!($.trigger_event??$.trigger);if(!($.display_trigger!==!1&&!k))return!1;let j=($.screen||"").trim().toLowerCase();return!j||j===P});if(M)try{return St(M)}catch{return M}})(),[s,a]=(0,vt.useState)(!1),[c,u]=(0,vt.useState)(!1),[x,m]=(0,vt.useState)(0),[g,v]=(0,vt.useState)(null),[f,b]=(0,vt.useState)(""),[h,y]=(0,vt.useState)({}),[w,I]=(0,vt.useState)(!1);(0,vt.useEffect)(()=>{if(!r)return;a(!1),u(!1),m(0),v(null),b(""),y({}),I(!1);let P=r.details?.styling?.appearance?.displayDelay??0,M=globalThis.setTimeout(()=>{u(!0);let $=r.details?.id,k=xi(r.details),L=k.length>0?k[0].id:void 0;H("viewed",r.id,{survey_id:$,slide_id:L})},Math.max(0,P)*1e3);return()=>globalThis.clearTimeout(M)},[r]);let B=(0,vt.useMemo)(()=>r?xi(r.details):[],[r]),R=B[x];if((0,vt.useEffect)(()=>{if(!R)return;let P=h[R.id];v(P?.option??null),b(P?.comment??"")},[R?.id]),!r||!e||s||!c)return null;let d=r.details,T=d.styling||{},l=T.appearance||{},p=l.backdropColor||"#000000",O=zr(l.backdropOpacity),A=P=>{v(M=>M===P?null:P)},_=async(P,M)=>{let $=B.map(N=>({slide_id:N.id,order:N.order,title:N.title,question:N.question,selected_options:P[N.id]?.option,comment:P[N.id]?.comment})),k=r.id,L=[];for(let N of B){let tt=P[N.id]?.option;if(!tt)continue;let K=Object.entries(N.options||{}).find(([,Y])=>String(Y)===String(tt));K&&L.push(K[0])}let j=$.map(N=>N.comment).filter(Boolean).join(" || ")||"",X=d.id||k;H("survey captured",X,{survey_id:d.id,slide_id:M,selected_options:L,otherText:j}),T.content?.isThankyouPage!==!1?I(!0):a(!0)},C=async()=>{if(!R||!g)return;let P={...h,[R.id]:{option:g,comment:f}};y(P);try{let L=r.id,j=null;if(g&&R&&R.options){let mt=Object.entries(R.options).find(([,N])=>String(N)===String(g));mt&&(j=mt[0])}let X=d.id||L;H("survey captured",X,{survey_id:d.id,slide_id:R.id,selected_options:j?[j]:[],otherText:f||""})}catch(L){console.warn("Error sending per-slide survey captured",L)}if((R.logic||[]).find(L=>(L.selectOption||[]).includes(g))?.redirectTo==="thank-you"){await _(P,R.id);return}if(x>=B.length-1){await _(P,R.id);return}m(L=>Math.min(L+1,B.length-1))},S=()=>{let P=d.thankYouButtonConfig;if(P?.enabled&&P.redirectUrl){try{let M=String(P.redirectUrl||"").trim();if(M&&!M.startsWith("http")&&Ct(M)){a(!0);return}}catch(M){console.warn("revealCampaignFromLink error",M)}try{globalThis.open(P.redirectUrl,"_blank")}catch{}}a(!0)},W=async()=>{try{let P=r?.id,M=d?.id,$=R?.id;await H("SurveyDismissed",P,{survey_id:M,slide_id:$})}catch(P){console.warn("Error sending SurveyDismissed",P)}finally{a(!0)}};return R?(0,G.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"flex-end",alignItems:"flex-end",padding:12,pointerEvents:"none"},children:[(0,G.jsx)("div",{"aria-hidden":!0,style:{position:"absolute",inset:0,background:Ir(p,O)}}),(0,G.jsxs)("div",{style:{position:"relative",width:"min(420px, 92vw)",maxWidth:"92vw",minWidth:"320px",maxHeight:"80vh",overflow:"hidden",backgroundColor:l.backgroundColor||"#ffffff",borderRadius:ro(l.cornerRadius),boxSizing:"border-box",paddingTop:14,paddingRight:16,paddingBottom:10,paddingLeft:16,pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[(0,G.jsx)("style",{children:`
|
|
91
|
+
`}),B.crossButton?.enabled&&(0,V.jsx)(Qt,{config:B.crossButton,onPress:()=>a(!0),style:{top:B.crossButton?.margin?.top??10,right:B.crossButton?.margin?.right??10}}),(0,V.jsx)("div",{className:"appstorys-csat-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:4},children:h?(0,V.jsx)(Fr,{details:I,isHighRating:d,onDone:_}):(0,V.jsx)(Tr,{details:I,rating:x,selectedOptions:g,comments:f,isHighRating:d,feedbackOptions:w,onRate:A,onToggleOption:p,onCommentChange:b,onInlineSubmit:O,canSubmit:x>=1,appearance:R})})]})})},xi=Ir;var wt=require("react");et();var J=require("react/jsx-runtime");function oo(t){if(t!=null)return`${t}px`}function Zo(t){return dt(t)}function Ce(t){return t?{color:t.color,fontSize:t.fontSize,fontFamily:Zo(t.fontFamily),textAlign:t.textAlign,fontWeight:t.fontDecoration?.includes("bold")?"bold":void 0,fontStyle:t.fontDecoration?.includes("italic")?"italic":void 0,textDecoration:t.fontDecoration?.includes("underline")?"underline":void 0}:{}}function no(t){return{marginTop:oo(t?.top),marginRight:oo(t?.right),marginBottom:oo(t?.bottom),marginLeft:oo(t?.left)}}function io(t){return`${t?.topLeft??12}px ${t?.topRight??12}px ${t?.bottomRight??t?.topRight??12}px ${t?.bottomLeft??t?.topLeft??12}px`}function vi(t){return t==="right"?"flex-end":t==="left"?"flex-start":"center"}function Pe(t){return Math.max(0,Math.min(1,t))}function zr(t,e){let o=(t||"").trim().replace("#","");if(o.length===3){let i=Number.parseInt(o[0]+o[0],16),n=Number.parseInt(o[1]+o[1],16),r=Number.parseInt(o[2]+o[2],16);return`rgba(${i}, ${n}, ${r}, ${Pe(e)})`}if(o.length===6){let i=Number.parseInt(o.slice(0,2),16),n=Number.parseInt(o.slice(2,4),16),r=Number.parseInt(o.slice(4,6),16);return`rgba(${i}, ${n}, ${r}, ${Pe(e)})`}return`rgba(0, 0, 0, ${Pe(e)})`}function Br(t){if(t==null)return .4;let e=Number(t);return Number.isFinite(e)?e>1?Pe(e/100):Pe(e):.4}function Si(t){return[...t.slides||[]].sort((o,i)=>(o.order??0)-(i.order??0))}function Ar(t){let e=t?.options||{},o=Object.keys(e),i=n=>{let r=/(\d+)/.exec(n);if(!r)return;let s=Number(r[1]);return Number.isFinite(s)?s:void 0};return o.sort((n,r)=>{let s=i(n),a=i(r);return s!=null&&a!=null?s-a:s!=null?-1:a!=null?1:n.localeCompare(r)}),o.map(n=>e[n]).filter(n=>typeof n=="string"&&n.trim().length>0)}function Er(t,e){if(!t)return null;if(t==="alphabet"){let o="A".codePointAt(0)??65;return String.fromCodePoint(o+e%26)}return t==="number"?String(e+1):null}function Pr(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 Ci(t){return Pr(t?.borderwidth)??1}var Lr=({details:t,slide:e,appearance:o,selectedOption:i,comment:n,onSelectOption:r,onCommentChange:s,onSubmit:a,canSubmit:c})=>{let u=t.styling||{},x=u.options||{},m=u.cta,g=(0,wt.useMemo)(()=>Ar(e),[e]),v=x.optionsSpacing??8,f=x.bulletSpacing??10,b=x.optionsHeight??44,h=vi(m?.container?.alignment);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("div",{style:no(u.title?.textStyle?.margin),children:(0,J.jsx)("div",{style:{...Ce(u.title?.textStyle),color:u.title?.textStyle?.color||"#111827",fontSize:u.title?.textStyle?.fontSize||20,lineHeight:1.3,fontWeight:u.title?.textStyle?.fontDecoration?.includes("bold")?"bold":700},children:e.title||e.question||t.name||"Survey"})}),(e.subtitle||u.subtitle?.textStyle)&&(0,J.jsx)("div",{style:no(u.subtitle?.textStyle?.margin),children:(0,J.jsx)("div",{style:{...Ce(u.subtitle?.textStyle),color:u.subtitle?.textStyle?.color||"#6b7280",fontSize:u.subtitle?.textStyle?.fontSize||14,lineHeight:1.35},children:e.subtitle||""})}),g.length>0&&(0,J.jsx)("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:v},children:g.map((y,w)=>{let I=i===y,B=I?x.selectedOptions:x.nonSelectedOptions,R=Ci(B?.textStyle),d=Er(x.optionListStyle,w);return(0,J.jsxs)("button",{onClick:()=>r(y),style:{width:"100%",boxSizing:"border-box",height:b,borderRadius:io(x.cornerRadius),border:`${R}px solid ${B?.colors?.border||"#e5e7eb"}`,background:B?.colors?.background||"#ffffff",color:B?.colors?.text||"#111827",cursor:"pointer",display:"flex",alignItems:"center",gap:f,paddingLeft:14,paddingRight:14,textAlign:"left",...Ce(B?.textStyle)},"aria-pressed":I,children:[(0,J.jsx)("span",{"aria-hidden":!0,style:{width:16,height:16,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",border:`1.5px solid ${B?.colors?.border||"#111827"}`,background:"#ffffff",flex:"0 0 auto",fontSize:11,fontWeight:700,color:B?.colors?.text||"#111827"},children:I?"\u2713":d||""}),(0,J.jsx)("span",{style:{flex:1,minWidth:0},children:y})]},`${y}-${w}`)})}),e.additionalComment?.enabled&&(0,J.jsx)("textarea",{value:n,onChange:y=>s(y.target.value),placeholder:e.additionalComment?.placeholder||"",style:{marginTop:10,width:"100%",boxSizing:"border-box",minHeight:72,resize:"none",overflowY:"auto",border:`${Ci(x.additionalComments?.textStyle)}px solid ${x.additionalComments?.colors?.border||"#e5e7eb"}`,background:x.additionalComments?.colors?.background||"#ffffff",color:x.additionalComments?.colors?.text||"#111827",borderRadius:10,padding:"12px",...Ce(x.additionalComments?.textStyle)}}),(0,J.jsx)("div",{style:{position:"sticky",bottom:0,marginTop:12,paddingTop:10,paddingBottom:6,background:o?.backgroundColor||"#ffffff"},children:(0,J.jsx)("div",{style:{marginTop:m?.margin?.top??0,marginBottom:m?.margin?.bottom??0,marginLeft:m?.margin?.left??0,marginRight:m?.margin?.right??0,display:"flex",justifyContent:h},children:(0,J.jsx)("button",{onClick:a,disabled:!c,style:{width:m?.container?.ctaFullWidth?"100%":m?.container?.ctaWidth??"100%",height:m?.container?.height??44,border:`${m?.container?.borderWidth??0}px solid ${m?.container?.borderColor||"transparent"}`,background:m?.container?.backgroundColor||"#111827",color:m?.text?.color||"#ffffff",borderRadius:io(m?.cornerRadius),fontFamily:Zo(m?.text?.fontFamily),fontSize:m?.text?.fontSize||14,fontWeight:m?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:c?"pointer":"not-allowed",opacity:c?1:.6,padding:"0 16px"},children:e.submitButtonText||"Submit"})})})]})},Dr=({details:t,onDone:e})=>{let i=(t.styling||{}).thankyouPage||{},n=i.cta,r=vi(n?.container?.alignment);return(0,J.jsxs)(J.Fragment,{children:[t.thankYouImage&&(0,J.jsx)("div",{style:{display:"flex",justifyContent:"center",marginTop:8},children:(0,J.jsx)("img",{src:t.thankYouImage,alt:"thank you",style:{width:i.imageStyle?.width||80,height:i.imageStyle?.height||80,objectFit:"cover",borderRadius:10}})}),(0,J.jsx)("div",{style:{...no(i.title?.textStyle?.margin)},children:(0,J.jsx)("div",{style:{...Ce(i.title?.textStyle),color:i.title?.textStyle?.color||"#111827",fontSize:i.title?.textStyle?.fontSize||20,lineHeight:1.3,fontWeight:i.title?.textStyle?.fontDecoration?.includes("bold")?"bold":700},children:t.thankYouTitle||"Thank you"})}),(0,J.jsx)("div",{style:{...no(i.subtitle?.textStyle?.margin)},children:(0,J.jsx)("div",{style:{...Ce(i.subtitle?.textStyle),color:i.subtitle?.textStyle?.color||"#6b7280",fontSize:i.subtitle?.textStyle?.fontSize||14,lineHeight:1.35},children:t.thankYouText||""})}),(t.thankYouButtonText||n)&&(0,J.jsx)("div",{style:{marginTop:n?.margin?.top??14,marginBottom:n?.margin?.bottom??0,marginLeft:n?.margin?.left??0,marginRight:n?.margin?.right??0,display:"flex",justifyContent:r},children:(0,J.jsx)("button",{onClick:e,style:{width:n?.container?.ctaFullWidth?"100%":n?.container?.ctaWidth??"auto",height:n?.container?.height??40,border:`${n?.container?.borderWidth??0}px solid ${n?.container?.borderColor||"transparent"}`,background:n?.container?.backgroundColor||"#111827",color:n?.text?.color||"#ffffff",borderRadius:io(n?.cornerRadius),fontFamily:Zo(n?.text?.fontFamily),fontSize:n?.text?.fontSize||14,fontWeight:n?.text?.fontDecoration?.includes("bold")?"bold":600,cursor:"pointer",padding:"0 16px"},children:t.thankYouButtonText||"Done"})})]})},_r=()=>{let t=ct("SUR"),e=F(P=>P.isVisible),o=F(P=>P.campaigns),i=F(P=>P.allCampaigns),n=F(P=>P.currentScreen),r=t??(()=>{let P=(n||"").trim().toLowerCase(),M=[...o||[],...i||[]].find($=>{if(!$||$.campaign_type!=="SUR")return!1;let k=!!($.trigger_event??$.trigger);if(!($.display_trigger!==!1&&!k))return!1;let j=($.screen||"").trim().toLowerCase();return!j||j===P});if(M)try{return Ct(M)}catch{return M}})(),[s,a]=(0,wt.useState)(!1),[c,u]=(0,wt.useState)(!1),[x,m]=(0,wt.useState)(0),[g,v]=(0,wt.useState)(null),[f,b]=(0,wt.useState)(""),[h,y]=(0,wt.useState)({}),[w,I]=(0,wt.useState)(!1);(0,wt.useEffect)(()=>{if(!r)return;a(!1),u(!1),m(0),v(null),b(""),y({}),I(!1);let P=r.details?.styling?.appearance?.displayDelay??0,M=globalThis.setTimeout(()=>{u(!0);let $=r.details?.id,k=Si(r.details),L=k.length>0?k[0].id:void 0;H("viewed",r.id,{survey_id:$,slide_id:L})},Math.max(0,P)*1e3);return()=>globalThis.clearTimeout(M)},[r]);let B=(0,wt.useMemo)(()=>r?Si(r.details):[],[r]),R=B[x];if((0,wt.useEffect)(()=>{if(!R)return;let P=h[R.id];v(P?.option??null),b(P?.comment??"")},[R?.id]),!r||!e||s||!c)return null;let d=r.details,T=d.styling||{},l=T.appearance||{},p=l.backdropColor||"#000000",O=Br(l.backdropOpacity),A=P=>{v(M=>M===P?null:P)},_=async(P,M)=>{let $=B.map(N=>({slide_id:N.id,order:N.order,title:N.title,question:N.question,selected_options:P[N.id]?.option,comment:P[N.id]?.comment})),k=r.id,L=[];for(let N of B){let tt=P[N.id]?.option;if(!tt)continue;let K=Object.entries(N.options||{}).find(([,Y])=>String(Y)===String(tt));K&&L.push(K[0])}let j=$.map(N=>N.comment).filter(Boolean).join(" || ")||"",X=d.id||k;H("survey captured",X,{survey_id:d.id,slide_id:M,selected_options:L,otherText:j}),T.content?.isThankyouPage!==!1?I(!0):a(!0)},C=async()=>{if(!R||!g)return;let P={...h,[R.id]:{option:g,comment:f}};y(P);try{let L=r.id,j=null;if(g&&R&&R.options){let ft=Object.entries(R.options).find(([,N])=>String(N)===String(g));ft&&(j=ft[0])}let X=d.id||L;H("survey captured",X,{survey_id:d.id,slide_id:R.id,selected_options:j?[j]:[],otherText:f||""})}catch(L){console.warn("Error sending per-slide survey captured",L)}if((R.logic||[]).find(L=>(L.selectOption||[]).includes(g))?.redirectTo==="thank-you"){await _(P,R.id);return}if(x>=B.length-1){await _(P,R.id);return}m(L=>Math.min(L+1,B.length-1))},S=()=>{let P=d.thankYouButtonConfig;if(P?.enabled&&P.redirectUrl){try{let M=String(P.redirectUrl||"").trim();if(M&&!M.startsWith("http")&&vt(M)){a(!0);return}}catch(M){console.warn("revealCampaignFromLink error",M)}try{globalThis.open(P.redirectUrl,"_blank")}catch{}}a(!0)},W=async()=>{try{let P=r?.id,M=d?.id,$=R?.id;await H("SurveyDismissed",P,{survey_id:M,slide_id:$})}catch(P){console.warn("Error sending SurveyDismissed",P)}finally{a(!0)}};return R?(0,J.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:999999,display:"flex",justifyContent:"flex-end",alignItems:"flex-end",padding:12,pointerEvents:"none"},children:[(0,J.jsx)("div",{"aria-hidden":!0,style:{position:"absolute",inset:0,background:zr(p,O)}}),(0,J.jsxs)("div",{style:{position:"relative",width:"min(420px, 92vw)",maxWidth:"92vw",minWidth:"320px",maxHeight:"80vh",overflow:"hidden",backgroundColor:l.backgroundColor||"#ffffff",borderRadius:io(l.cornerRadius),boxSizing:"border-box",paddingTop:14,paddingRight:16,paddingBottom:10,paddingLeft:16,pointerEvents:"auto",boxShadow:"0 14px 36px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"},children:[(0,J.jsx)("style",{children:`
|
|
92
92
|
.appstorys-survey-scroll {
|
|
93
93
|
scrollbar-width: none; /* Firefox */
|
|
94
94
|
-ms-overflow-style: none; /* IE/Edge */
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
height: 0;
|
|
99
99
|
display: none; /* Chrome/Safari */
|
|
100
100
|
}
|
|
101
|
-
`}),T.crossButton?.enabled&&(0,
|
|
101
|
+
`}),T.crossButton?.enabled&&(0,J.jsx)(Qt,{config:T.crossButton,onPress:W,style:{top:T.crossButton?.margin?.top??10,right:T.crossButton?.margin?.right??10}}),(0,J.jsx)("div",{className:"appstorys-survey-scroll",style:{flex:1,minHeight:0,overflowY:"auto",paddingRight:2},children:w?(0,J.jsx)(Dr,{details:d,onDone:S}):(0,J.jsx)(Lr,{details:d,slide:R,appearance:l,selectedOption:g,comment:f,onSelectOption:A,onCommentChange:b,onSubmit:C,canSubmit:g!=null})})]})]}):null},wi=_r;var tn=class{state="uninitialized";navigateToScreen;async initialize(e){let{appId:o,accountId:i,userId:n}=e;if(this.navigateToScreen=e.navigateToScreen,this.state!=="initializing"){if(this.state==="initialized"){let r=F.getState();if(r.isAnonymousUser&&n&&n.trim()!==""){console.log("AppStorys: Reconciling anonymous user with identified user..."),await this.reconcileUser(r.userId,n,o,i);return}if(r.appId===o&&r.accountId===i&&r.userId===n)return}this.state="initializing";try{let r,s;if(!n||n.trim()==="")r=await Pn(),s=!0;else{let m=await Lo();m&&m!==n&&console.log("AppStorys: Found previous anonymous user, will reconcile after verification."),r=n,s=!1}if(!await Vt(i,o,r)){this.state="error";return}if(!s){let m=await Lo();m&&m!==r&&(await Je(m,r),await Po())}try{let m=await lt(),g=e.baseUrl||"https://users.appstorys.co";fetch(`${g}/v2/${i}/track-user-res`,{method:"POST",headers:{"Content-Type":"application/json",...m?{Authorization:`Bearer ${m}`}:{}},body:JSON.stringify({user_id:r,screenName:typeof window<"u"&&window.location&&window.location.pathname?window.location.pathname:"",silentUpdate:!0})}).then(async v=>{if(v.ok)try{let f=await v.json(),b=F.getState();if(typeof f.screen_capture_enabled<"u"){let h=!!f.screen_capture_enabled;console.info("AppStorys: track-user-res returned screen_capture_enabled=",h),b.setScreenCaptureEnabled(h)}}catch{}}).catch(v=>console.warn("track-user-res (init) failed",v))}catch(m){console.warn("track-user-res (init) setup failed",m)}let{campaigns:c,version:u}=await zo(i);try{Rn(c)}catch(m){console.warn("Failed to preload campaign fonts",m)}let x=F.getState();x.setAppId(o),x.setAccountId(i),x.setUserId(r),x.setIsAnonymousUser(s),x.setBaseUrl(e.baseUrl),x.setTrackingUrl(e.trackingUrl),x.saveAllCampaigns(c),x.setCampaignVersion(u);try{F.getState().screenCaptureEnabled&&(await Promise.resolve().then(()=>(Bi(),zi))).mountScreenCaptureButton()}catch(m){console.warn("Failed to mount screen capture button",m)}An.setup(),Eo.setup(),this.state="initialized"}catch(r){this.state="error",console.error("AppStorys initialization failed:",r)}}}async reconcileUser(e,o,i,n){try{if(!await Vt(n,i,o)){console.error("AppStorys: Failed to verify identified user account during reconciliation.");return}if(!await Je(e,o)){console.error("AppStorys: Failed to reconcile anonymous and identified users.");return}await Po();let a=F.getState();a.setUserId(o),a.setIsAnonymousUser(!1)}catch(r){console.error("AppStorys: Error during user reconciliation:",r)}}async trackScreen(e){return await this.ensureInitialized(),Ro(e)}async trackEvent(e,o,i){return await this.ensureInitialized(),H(e,o,i)}async setUserProperties(e){return await this.ensureInitialized(),To(e)}handleLink(e){if(e){if(typeof e=="string"){try{if(!e.startsWith("http")&&vt(e))return}catch(o){console.warn("revealCampaignFromLink error",o)}e.startsWith("http")?window.open(e,"_blank"):this.navigateToScreen?.(e)}else if(typeof e=="object"&&e.value){try{if(vt(e.value))return}catch{}this.navigateToScreen?.(e.value)}}}get visibility(){return F.getState().isVisible}set visibility(e){Eo.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 Te(e)}},jr=new tn;0&&(module.exports={AppStorys,Banner,BottomSheet,Csat,Floater,Pip,SdkState,Story,Survey,Tooltip,Widget,personalizeText});
|
|
102
102
|
//# sourceMappingURL=index.js.map
|