@letscooee/web-sdk 12.1.0 → 12.1.1

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.
@@ -1,4 +1,4 @@
1
- import{A as ki,B as Di,C as Ai,a as di,b as pi,d as it,e as dt,g as se,h as ui,i as he,j as fi,k as gi,l as hi,m as vi,n as qe,o as yi,p as xi,q as _i,r as wi,u as Ti,x as Ei,y as Mt,z as Pi}from"./chunk-JVCMQGUJ.js";import{c as K,d as ci,g as mi,i as Ci,j as bi,k as pt,l as Vi,m as Ii,n as Si,q as Mi}from"./chunk-O6T74BO2.js";import{a as mt}from"./chunk-QG5GD32H.js";import{a as Ze}from"./chunk-SBONG2TS.js";import{$ as H,$a as ae,A as zt,Aa as J,B as Ut,Ba as Y,Ca as St,Da as S,E as Ie,F as qt,Ga as He,Ha as je,Ia as $e,K as le,L as xe,La as fe,Ma as et,N as Zt,O as I,P as Qt,Pa as ii,Q as Wt,Qa as pe,Ra as ni,S as It,Sa as ze,Wa as tt,X as B,Xa as Fe,Ya as _e,Za as Ue,_ as Gt,aa as Jt,ab as oi,b as Lt,bb as ri,cb as ge,da as Yt,db as we,e as Nt,eb as ai,fa as Kt,ga as Xe,gb as si,ha as j,ia as $,ja as Xt,k as Bt,ka as oe,la as re,ma as z,na as k,oa as A,p as Ht,pa as Se,qa as X,ra as ce,s as jt,sa as ee,sb as ct,ta as ei,ua as ti,v as be,x as O,xb as li,y as L,z as $t,za as de}from"./chunk-I62LO6BZ.js";import{a as Ce,b as Ot,e as ji,f as $i}from"./chunk-V7UGKYBN.js";var Li=ji((ut,Oi)=>{"use strict";(function(o,e){typeof ut=="object"&&typeof Oi<"u"?e(ut):typeof define=="function"&&define.amd?define(["exports"],e):e((o=typeof globalThis<"u"?globalThis:o||self).Sqrl={})})(ut,function(o){"use strict";function e(s){var l,d,m=new Error(s);return l=m,d=e.prototype,Object.setPrototypeOf?Object.setPrototypeOf(l,d):l.__proto__=d,m}function t(s,l,d){var m=l.slice(0,d).split(/\n/),n=m.length,i=m[n-1].length+1;throw e(s+=" at line "+n+" col "+i+`:
1
+ import{A as ki,B as Di,C as Ai,a as di,b as pi,d as it,e as dt,g as se,h as ui,i as he,j as fi,k as gi,l as hi,m as vi,n as qe,o as yi,p as xi,q as _i,r as wi,u as Ti,x as Ei,y as Mt,z as Pi}from"./chunk-ND7UMDP2.js";import{c as K,d as ci,g as mi,i as Ci,j as bi,k as pt,l as Vi,m as Ii,n as Si,q as Mi}from"./chunk-OYCLWHYU.js";import{a as mt}from"./chunk-QG5GD32H.js";import{a as Ze}from"./chunk-SBONG2TS.js";import{$ as H,$a as ae,A as zt,Aa as J,B as Ut,Ba as Y,Ca as St,Da as S,E as Ie,F as qt,Ga as He,Ha as je,Ia as $e,K as le,L as xe,La as fe,Ma as et,N as Zt,O as I,P as Qt,Pa as ii,Q as Wt,Qa as pe,Ra as ni,S as It,Sa as ze,Wa as tt,X as B,Xa as Fe,Ya as _e,Za as Ue,_ as Gt,aa as Jt,ab as oi,b as Lt,bb as ri,cb as ge,da as Yt,db as we,e as Nt,eb as ai,fa as Kt,ga as Xe,gb as si,ha as j,ia as $,ja as Xt,k as Bt,ka as oe,la as re,ma as z,na as k,oa as A,p as Ht,pa as Se,qa as X,ra as ce,s as jt,sa as ee,sb as ct,ta as ei,ua as ti,v as be,x as O,xb as li,y as L,z as $t,za as de}from"./chunk-I62LO6BZ.js";import{a as Ce,b as Ot,e as ji,f as $i}from"./chunk-V7UGKYBN.js";var Li=ji((ut,Oi)=>{"use strict";(function(o,e){typeof ut=="object"&&typeof Oi<"u"?e(ut):typeof define=="function"&&define.amd?define(["exports"],e):e((o=typeof globalThis<"u"?globalThis:o||self).Sqrl={})})(ut,function(o){"use strict";function e(s){var l,d,m=new Error(s);return l=m,d=e.prototype,Object.setPrototypeOf?Object.setPrototypeOf(l,d):l.__proto__=d,m}function t(s,l,d){var m=l.slice(0,d).split(/\n/),n=m.length,i=m[n-1].length+1;throw e(s+=" at line "+n+" col "+i+`:
2
2
 
3
3
  `+l.split(/\n/)[n-1]+`
4
4
  `+Array(i).join(" ")+"^")}e.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var r=new Function("return this")().Promise,a=!1;try{a=new Function("return (async function(){}).constructor")()}catch(s){if(!(s instanceof SyntaxError))throw s}function c(s,l){return Object.prototype.hasOwnProperty.call(s,l)}function u(s,l,d){for(var m in l)c(l,m)&&(l[m]==null||typeof l[m]!="object"||m!=="storage"&&m!=="prefixes"||d?s[m]=l[m]:s[m]=u({},l[m]));return s}var g=/^async +/,_=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,D=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,Q=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,Te=/[.*+\-?^${}()|[\]\\]/g;function Ee(s){return Te.test(s)?s.replace(Te,"\\$&"):s}function nt(s,l){l.rmWhitespace&&(s=s.replace(/[\r\n]+/g,`
@@ -13,7 +13,7 @@ import{A as ki,B as Di,C as Ai,a as di,b as pi,d as it,e as dt,g as se,h as ui,i
13
13
  `],encapsulation:3})};var yt=class o extends he{item;data=be(bi);dialogRef=be(Ci);ItemDetailLayout=xi;constructor(){super(),this.triggerContext=this.data.triggerContext,this.item=this.data.item}close(){this.dialogRef.close()}engagementTriggerReceived(e){}update(){}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=B({type:o,selectors:[["cooee-item-quick-view"]],features:[ae(se()),H],decls:1,vars:2,consts:[[3,"closeClick","item","layout"]],template:function(t,r){t&1&&(k(0,"cooee-item-detail",0),Y("closeClick",function(){return r.close()}),A()),t&2&&z("item",r.item)("layout",r.ItemDetailLayout.TWO_PANE)},dependencies:[Ti],styles:[`:host{display:flex;align-items:center;justify-content:center;height:100%}@media (min-width: 768px){cooee-item-detail{max-width:900px;max-height:80vh;border-radius:var(--lc-card-radius)}}
14
14
  `],encapsulation:3})};var Ct=class o{dialog=be(pt);dialogRef;constructor(){}showItemQuickView(e,t){this.dialogRef=this.dialog.open(yt,{width:"100vw",height:"100dvh",backdropClass:["letscooee-backdrop"],data:{item:t,triggerContext:e}})}static \u0275fac=function(t){return new(t||o)};static \u0275prov=jt({token:o,factory:o.\u0275fac,providedIn:"root"})};var ln=(o,e)=>({enter:o,exit:e});function cn(o,e){if(o&1&&(k(0,"div",7),pe(1),A(),k(2,"div",8),pe(3),A()),o&2){let t=S(2);I(),ze(" ",t.getCurrency(t.selectedVariant().price.cmp)," "),I(2),ze(" ",t.getDiscountPercentage(t.selectedVariant().price),"% off ")}}function dn(o,e){if(o&1&&(k(0,"div",6),pe(1),A()),o&2){let t=S(2);I(),ze(" ",t.stickyATCConfig.leftText," ")}}function pn(o,e){if(o&1&&(k(0,"div",1)(1,"div",5),pe(2),A(),j(3,cn,4,2),j(4,dn,2,1,"div",6),A()),o&2){let t=S();I(2),ze(" ",t.getCurrency(t.selectedVariant().price.d)," "),I(),$(t.selectedVariant().price.cmp?3:-1),I(),$(t.stickyATCConfig.leftText?4:-1)}}function mn(o,e){if(o&1&&(k(0,"div",9),pe(1),A()),o&2){let t=e.$implicit,r=e.$index;S(2);let a=_e(5);z("ngClass",ri(2,ln,r===a.currentIndex,r===a.previousIndex)),I(),ze(" ",t," ")}}function un(o,e){if(o&1&&(k(0,"div",4),oe(1,mn,2,5,"div",9,Xt),A()),o&2){S();let t=_e(5);I(),re(t.features)}}var bt=class o extends he{currentItem;stickyATCConfig;selectedVariant=Ie(void 0);featureSlider=Ie({features:[],currentIndex:0});constructor(){super()}onVariantChange(e){this.currentItem&&(this.currentItem.setSelectedVariantByID(e.detail.variantID),this.selectedVariant.set(this.currentItem.selectedOrFirstVariant.value))}engagementTriggerReceived(e){this.stickyATCConfig=e.stickyATCConfig??{},this.currentItem=e.items[0],this.selectedVariant.set(this.currentItem.vars[0]),this.stickyATCConfig.leftText=this.replaceVariables(this.stickyATCConfig.leftText),this.stickyATCConfig.rightText=this.replaceVariables(this.stickyATCConfig.rightText),this.startFeatureRotation()}update(){}getCurrency(e){return qe(e)}getDiscountPercentage(e){return((e.cmp-e.d)/e.cmp*100).toFixed(0)}addToCart(){this.engagementService.executeCTA(it.ADD_TO_CART,{item:this.currentItem})}startFeatureRotation(){if(!this.stickyATCConfig.rightText)return;let e=this.stickyATCConfig.rightText.split(`
15
15
  `),t=e.length===1?null:setInterval(()=>{this.featureSlider.update(r=>Ot(Ce({},r),{previousIndex:r.currentIndex,currentIndex:(r.currentIndex+1)%r.features.length}))},3e3);this.featureSlider.set({intervalRef:t,currentIndex:0,features:e})}replaceVariables(e){return e?Qe(e,this.currentItem.getTemplateVariables(),this.triggerContext):""}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=B({type:o,selectors:[["cooee-sticky-atc"]],hostBindings:function(t,r){t&1&&Y("letscooee:variant-change",function(c){return r.onVariantChange(c)},Zt)},features:[ae(se()),H],decls:7,vars:3,consts:[[1,"lc-wrapper"],[1,"lc-prices"],[1,"lc-button-wrapper"],["type","button",1,"lc-button","lc-button-atc",3,"click"],[1,"lc-features"],[1,"lc-sale-price"],[1,"lc-additional-text"],[1,"lc-compare-price"],[1,"lc-discount-label"],[1,"lc-feature",3,"ngClass"]],template:function(t,r){if(t&1){let a=de();k(0,"div",0),j(1,pn,5,3,"div",1),k(2,"div",2)(3,"button",3),Y("click",function(){return O(a),L(r.addToCart())}),pe(4,"Add To Cart"),A(),tt(5),j(6,un,3,0,"div",4),A()()}if(t&2){I(),$(r.selectedVariant()&&r.stickyATCConfig.showProductInfo?1:-1),I(4);let a=Fe(r.featureSlider());I(),$(a.features.length?6:-1)}},dependencies:[ct],styles:[`:host{display:flex;justify-content:center;padding:10px;background-color:#fff;width:100%;box-shadow:4px 0 10px #0006;line-height:normal}.lc-wrapper{display:flex;justify-content:space-between;align-items:center;gap:8px;max-width:1100px;width:100%}.lc-prices{flex:1 1 100%;display:flex;flex-wrap:wrap;align-items:center;gap:6px}@media (min-width: 768px){.lc-prices{gap:8px}}.lc-sale-price{font-size:24px;font-weight:600}.lc-compare-price{font-size:18px;font-weight:600;color:red;text-decoration:line-through}.lc-discount-label{font-size:12px;font-weight:500;color:green}.lc-button-wrapper{flex:1 1 100%;display:flex;flex-direction:column;gap:4px;align-items:center}.lc-button{background-color:#000;color:#fff;opacity:1;pointer-events:auto;border-radius:4px;min-width:150px;width:100%;padding:8px}.lc-additional-text,.lc-feature{font-size:12px;color:#666}.lc-features{position:relative;overflow:hidden;height:16px;text-align:center;width:100%}.lc-features .lc-feature{position:absolute;width:100%;opacity:0;transform:translateY(100%);transition:transform .5s ease,opacity .5s ease}.lc-features .lc-feature.enter{opacity:1;transform:translateY(0);z-index:2}.lc-features .lc-feature.exit{opacity:0;transform:translateY(-100%);z-index:1}
16
- `],encapsulation:3})};var gn=["videoEl"];async function Bi(){return(await import("./video-detail-dialog.component-NN64J5BQ.js")).VideoDetailDialogComponent}var Me=class o extends he{videoElements;videos;videoConfig;dialogRef=null;dialog=be(pt);isMobile=wi();pausedVideos=[];videoLoadingStates=new Map;intersectionObserver;visibleVideos=new Set;constructor(){super(),Bi()}ngAfterViewInit(){this.checkAndOpenVideoFromUrl()}ngOnDestroy(){super.ngOnDestroy(),this.intersectionObserver?.disconnect()}engagementTriggerReceived(e){this.videoConfig=e.content?.videoConfig,this.videos=this.videoConfig.videos}onMuteToggled(e,t){e||this.videoElements.forEach(r=>{r.nativeElement!==t&&(r.nativeElement.muted=!0,r.nativeElement.pause())})}sendTriggerClicked(e,t){this.sendEvent("CE Trigger Clicked",{},e,t)}async onVideoTap(e,t,r,a){e?.stopPropagation(),e?.preventDefault();let c=t.items?.[0];if(this.sendTriggerClicked(t,c),this.videoConfig.footerContent==="NONE"){a&&(a.muted=!1,a.play(),this.onMuteToggled(!1,a));return}await this.openDialog(t,r)}sendEvent(e,t,r,a){let c=new mi(e,t,this.engagementTrigger);c.setVideos(r),a&&(c.items=[a.toEmbed()]),window.CooeeSDK.sendEvent(c)}onDialogClosed(){this.resumePlaylistVideos()}isVideoLoading(e){return this.videoLoadingStates.get(e)??!0}onVideoLoadStart(e){this.videoLoadingStates.set(e,!0)}onVideoCanPlay(e){this.videoLoadingStates.set(e,!1)}playVideo(e){e.play().catch(t=>{K.error("Failed to play video:",t)})}setupIntersectionObserver(e=.5,t="50px"){this.intersectionObserver=new IntersectionObserver(r=>{r.forEach(a=>{let c=a.target,u=c.dataset.videoId;u&&(a.isIntersecting?(this.visibleVideos.add(u),this.handleVideoVisibilityChange(c,!0)):(this.visibleVideos.delete(u),this.handleVideoVisibilityChange(c,!1)))})},{threshold:e,rootMargin:t}),setTimeout(()=>{this.videoElements.forEach(r=>{this.intersectionObserver?.observe(r.nativeElement)})},100)}handleVideoVisibilityChange(e,t){t?this.onVideoBecameVisible(e):e.pause()}onVideoBecameVisible(e){this.playVideo(e)}pauseAllPlaylistVideos(){this.pausedVideos=[],this.videoElements.forEach(e=>{let t=e.nativeElement;t.paused||(this.pausedVideos.push(t),t.pause())})}resumePlaylistVideos(){this.pausedVideos.forEach(e=>{e.play().catch(()=>{})}),this.pausedVideos=[]}async checkAndOpenVideoFromUrl(){let e=Mi();if(!e||!this.videos)return;let t=Si();if(t.utm_campaign?.toLowerCase()!=="shoppable_video"||t.utm_source?.toLowerCase()!==Ii)return;let r=this.videos.findIndex(a=>a.shortID===+e);if(r!==-1){let a=this.videos[r];await gi.set("muted",!0),await this.openDialog(a,r)}}async openDialog(e,t){await pi();let r={videos:this.videos,currentIndex:t,triggerContext:this.triggerContext};this.dialogRef&&this.dialogRef.close(),this.pauseAllPlaylistVideos();let a=await Bi();this.dialogRef=this.dialog.open(a,{width:"100vw",height:"100vh",data:r,providers:ui(this.triggerContext,{video:e,index:t}),disableClose:!0});let c={videoID:e.id,videoIndex:t};this.sendEvent("CE Video Dialog Opened",{current:c},e),this.dialogRef.closed.subscribe(u=>{if(this.dialogRef=null,!u)return;let g=u.lastVideoDuration*1e3,_={videoID:u.lastVideo.id,videoIndex:u.lastVideoIndex,playedTillMS:g,playedTillPercent:g/u.lastVideo.durationMS};this.sendEvent("CE Video Dialog Closed",{current:_},u.lastVideo),this.onDialogClosed()})}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=B({type:o,selectors:[["cooee-abstract-video"]],viewQuery:function(t,r){if(t&1&&He(gn,5),t&2){let a;je(a=$e())&&(r.videoElements=a)}},features:[H],decls:0,vars:0,template:function(t,r){},encapsulation:2})};var hn=(o,e)=>e.id,vn=(o,e)=>e.url;function yn(o,e){if(o&1&&(Se(0,"div",1),ge(1,"safeHtml")),o&2){let t=S();z("innerHTML",we(1,1,t.videoConfig.heading),le)}}function Cn(o,e){o&1&&(k(0,"div",6),Se(1,"div",14),A())}function bn(o,e){if(o&1&&Se(0,"source",8),o&2){let t=e.$implicit;z("type",Ue(t.mimeType))("src",t.url,xe)}}function xn(o,e){if(o&1){let t=de();k(0,"cooee-mute-toggle",15),Y("toggled",function(a){O(t),S();let c=fe(6),u=S();return L(u.onMuteToggled(a,c))}),A()}if(o&2){S();let t=fe(6);z("muted",t.muted)("videoEl",t)}}function _n(o,e){if(o&1){let t=de();k(0,"cooee-item-card",16),Y("buttonClick",function(){O(t);let a=S(),c=a.$implicit,u=a.$index,g=fe(6),_=S();return L(_.addToCartClicked(null,c,u,g))})("click",function(a){O(t);let c=S(),u=c.$implicit,g=c.$index,_=fe(6),D=S();return L(D.onVideoTap(a,u,g,_))}),A()}if(o&2){S();let t=_e(0);z("item",t)}}function wn(o,e){if(o&1){let t=de();k(0,"cooee-video-card",17),Y("linkClicked",function(){O(t);let a=S().$implicit,c=S();return L(c.sendTriggerClicked(a))}),A()}if(o&2){S();let t=_e(1);z("card",t)}}function Vn(o,e){if(o&1){let t=de();tt(0)(1),k(2,"div",4)(3,"div",5),Y("click",function(a){let c=O(t),u=c.$implicit,g=c.$index,_=fe(6),D=S();return L(D.onVideoTap(a,u,g,_))})("keydown.enter",function(a){let c=O(t),u=c.$implicit,g=c.$index,_=fe(6),D=S();return L(D.onVideoTap(a,u,g,_))})("keydown.space",function(a){let c=O(t),u=c.$implicit,g=c.$index,_=fe(6),D=S();return L(D.onVideoTap(a,u,g,_))}),j(4,Cn,2,0,"div",6),k(5,"video",7,0),Y("mouseenter",function(){O(t);let a=fe(6);S();let c=_e(1);return L(c&&a.play())})("mouseleave",function(){O(t);let a=fe(6);S();let c=_e(1);return L(c&&a.pause())})("loadstart",function(){let a=O(t).$implicit,c=S();return L(c.onVideoLoadStart(a.id))})("canplay",function(){let a=O(t).$implicit,c=S();return L(c.onVideoCanPlay(a.id))}),oe(7,bn,1,3,"source",8,vn),A(),k(9,"div",9),j(10,xn,1,2,"cooee-mute-toggle",10),A()(),k(11,"div",11),j(12,_n,1,1,"cooee-item-card",12)(13,wn,1,1,"cooee-video-card",13),A()()}if(o&2){let t=e.$implicit,r=S(),a=_e(0),c=Fe(t.items[0]);I();let u=Fe(t.card),g=c&&r.videoConfig.footerContent==r.VideoConfigFooterContent.FIRST_ITEM,_=u&&r.videoConfig.footerContent==r.VideoConfigFooterContent.CARD;I(2),et("background-image",t.thumbnail?"url("+t.thumbnail+")":null),I(),$(r.isVideoLoading(t.id)?4:-1),I(),z("muted",!0),Xe("preload",a?"metadata":"none")("autoplay",null)("data-video-id",t.id),I(2),re(t.sources),I(3),$(r.videoConfig.showMuteButton?10:-1),I(2),$(g?12:_?13:-1)}}var xt=class o extends Me{VideoConfigFooterContent=Mt;VideoConfigAutoPlay=Ei;swiperOptions=null;constructor(){super(),this.hasSwiper=!0}ngAfterViewInit(){super.ngAfterViewInit();let e=this.videoConfig.playlistConfig?.videoSwiper,t=e?(this.isMobile?e.gapSm:e.gap)+"px":window.cooeePlaylistGap??24,r=e?this.isMobile?e.maxInRowSm:e.maxInRow:"auto";this.swiperOptions={direction:"horizontal",effect:"slide",loop:e?.loop,freeMode:!0,spaceBetween:t,slidesPerView:r,mousewheel:{enabled:!0,forceToAxis:!0},autoplay:e?.autoplay?.enabled?{delay:e?.autoplay?.delay,disableOnInteraction:!1}:!1},this.setupIntersectionObserver(),this.playFirstVideo()}ngOnDestroy(){super.ngOnDestroy()}addToCartClicked(e,t,r,a){let c=t.items?.[0],u=di.get().website?.canChangeVariantInCart;if(t.items?.length>1||c?.hasVariants()&&!u){this.onVideoTap(e,t,r,a);return}this.engagementService.executeCTA(it.ADD_TO_CART,{item:c,video:t})}goToPDP(e,t){e?.stopPropagation(),e?.preventDefault();let r=t.items?.[0];this.engagementService.executeCTA(it.GO_TO_PRODUCT,{item:r,video:t})}update(){}onVideoBecameVisible(e){this.shouldAutoPlay()&&(this.dialogRef?this.pausedVideos.push(e):this.playVideo(e))}shouldAutoPlay(){return this.videoConfig.autoPlay==="ON"||this.videoConfig.autoPlay==="ON_HOVER"&&this.isMobile}playFirstVideo(){}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=B({type:o,selectors:[["cooee-video-playlist"]],features:[ae(se()),H],decls:7,vars:6,consts:[["videoEl",""],[1,"heading-text",3,"innerHTML"],[3,"options","navigationConfig","paginationConfig"],["ngProjectAs","swiper-slides",5,["swiper-slides"]],[1,"swiper-slide","video-card"],["role","button","tabindex","0","aria-label","Play video","aria-haspopup","dialog",1,"video-wrapper",3,"click","keydown.enter","keydown.space"],[1,"video-loading-overlay"],["width","100%","playsinline","","loop","",3,"mouseenter","mouseleave","loadstart","canplay","muted"],[3,"src","type"],[1,"video-controls"],[3,"muted","videoEl"],["role","region","aria-label","Video details",1,"video-footer"],["role","button","tabindex","0","aria-label","Product detail",3,"item"],[3,"card"],[1,"loading-spinner"],[3,"toggled","muted","videoEl"],["role","button","tabindex","0","aria-label","Product detail",3,"buttonClick","click","item"],[3,"linkClicked","card"]],template:function(t,r){if(t&1&&(tt(0)(1),j(2,yn,2,3,"div",1),k(3,"cooee-swiper",2),ei(4,3),oe(5,Vn,14,11,"div",4,hn),ti(),A()),t&2){Fe(!r.videoConfig.autoPlay||r.videoConfig.autoPlay===r.VideoConfigAutoPlay.ON),I(),Fe(r.videoConfig.autoPlay===r.VideoConfigAutoPlay.ON_HOVER),I(),$(r.videoConfig.heading?2:-1);let a=r.videoConfig.playlistConfig==null?null:r.videoConfig.playlistConfig.videoSwiper;I(),z("options",r.swiperOptions)("navigationConfig",a==null?null:a.navigation)("paginationConfig",a==null?null:a.pagination),I(2),re(r.videos)}},dependencies:[Di,ki,Pi,Ai,Ze],styles:[`:host{display:block}cooee-swiper.swiper{margin:8px;padding-top:25px;padding-bottom:25px}.video-wrapper{position:relative;cursor:pointer;outline:none;border-radius:var(--lc-media-radius, 8px);background-size:cover;background-position:center;background-repeat:no-repeat}.video-wrapper video{width:100%;height:var(--lc-video-card-height);object-fit:cover;border-radius:var(--lc-media-radius, 8px);position:relative}.video-card.swiper-slide{width:var(--lc-video-card-width);transition:transform .3s ease}.video-card.swiper-slide:hover{transform:scale(1.05)}@media (max-width: 768px),(prefers-reduced-motion: reduce){.video-card.swiper-slide{transition:none}.video-card.swiper-slide:hover{transform:none}}.video-controls{position:absolute;bottom:8px;z-index:10;right:8px;display:flex;gap:8px}cooee-item-card{cursor:pointer;padding-left:0!important;padding-right:0!important}cooee-item-card .item-image{width:50px;height:50px;display:none}cooee-item-card .item-info{font-size:14px;line-height:normal}cooee-item-card .item-info .item-name{-webkit-line-clamp:1;overflow:hidden}.video-loading-overlay{border-radius:var(--lc-media-radius, 8px)}
16
+ `],encapsulation:3})};var gn=["videoEl"];async function Bi(){return(await import("./video-detail-dialog.component-WR37GPM5.js")).VideoDetailDialogComponent}var Me=class o extends he{videoElements;videos;videoConfig;dialogRef=null;dialog=be(pt);isMobile=wi();pausedVideos=[];videoLoadingStates=new Map;intersectionObserver;visibleVideos=new Set;constructor(){super(),Bi()}ngAfterViewInit(){this.checkAndOpenVideoFromUrl()}ngOnDestroy(){super.ngOnDestroy(),this.intersectionObserver?.disconnect()}engagementTriggerReceived(e){this.videoConfig=e.content?.videoConfig,this.videos=this.videoConfig.videos}onMuteToggled(e,t){e||this.videoElements.forEach(r=>{r.nativeElement!==t&&(r.nativeElement.muted=!0,r.nativeElement.pause())})}sendTriggerClicked(e,t){this.sendEvent("CE Trigger Clicked",{},e,t)}async onVideoTap(e,t,r,a){e?.stopPropagation(),e?.preventDefault();let c=t.items?.[0];if(this.sendTriggerClicked(t,c),this.videoConfig.footerContent==="NONE"){a&&(a.muted=!1,a.play(),this.onMuteToggled(!1,a));return}await this.openDialog(t,r)}sendEvent(e,t,r,a){let c=new mi(e,t,this.engagementTrigger);c.setVideos(r),a&&(c.items=[a.toEmbed()]),window.CooeeSDK.sendEvent(c)}onDialogClosed(){this.resumePlaylistVideos()}isVideoLoading(e){return this.videoLoadingStates.get(e)??!0}onVideoLoadStart(e){this.videoLoadingStates.set(e,!0)}onVideoCanPlay(e){this.videoLoadingStates.set(e,!1)}playVideo(e){e.play().catch(t=>{K.error("Failed to play video:",t)})}setupIntersectionObserver(e=.5,t="50px"){this.intersectionObserver=new IntersectionObserver(r=>{r.forEach(a=>{let c=a.target,u=c.dataset.videoId;u&&(a.isIntersecting?(this.visibleVideos.add(u),this.handleVideoVisibilityChange(c,!0)):(this.visibleVideos.delete(u),this.handleVideoVisibilityChange(c,!1)))})},{threshold:e,rootMargin:t}),setTimeout(()=>{this.videoElements.forEach(r=>{this.intersectionObserver?.observe(r.nativeElement)})},100)}handleVideoVisibilityChange(e,t){t?this.onVideoBecameVisible(e):e.pause()}onVideoBecameVisible(e){this.playVideo(e)}pauseAllPlaylistVideos(){this.pausedVideos=[],this.videoElements.forEach(e=>{let t=e.nativeElement;t.paused||(this.pausedVideos.push(t),t.pause())})}resumePlaylistVideos(){this.pausedVideos.forEach(e=>{e.play().catch(()=>{})}),this.pausedVideos=[]}async checkAndOpenVideoFromUrl(){let e=Mi();if(!e||!this.videos)return;let t=Si();if(t.utm_campaign?.toLowerCase()!=="shoppable_video"||t.utm_source?.toLowerCase()!==Ii)return;let r=this.videos.findIndex(a=>a.shortID===+e);if(r!==-1){let a=this.videos[r];await gi.set("muted",!0),await this.openDialog(a,r)}}async openDialog(e,t){await pi();let r={videos:this.videos,currentIndex:t,triggerContext:this.triggerContext};this.dialogRef&&this.dialogRef.close(),this.pauseAllPlaylistVideos();let a=await Bi();this.dialogRef=this.dialog.open(a,{width:"100vw",height:"100vh",data:r,providers:ui(this.triggerContext,{video:e,index:t}),disableClose:!0});let c={videoID:e.id,videoIndex:t};this.sendEvent("CE Video Dialog Opened",{current:c},e),this.dialogRef.closed.subscribe(u=>{if(this.dialogRef=null,!u)return;let g=u.lastVideoDuration*1e3,_={videoID:u.lastVideo.id,videoIndex:u.lastVideoIndex,playedTillMS:g,playedTillPercent:g/u.lastVideo.durationMS};this.sendEvent("CE Video Dialog Closed",{current:_},u.lastVideo),this.onDialogClosed()})}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=B({type:o,selectors:[["cooee-abstract-video"]],viewQuery:function(t,r){if(t&1&&He(gn,5),t&2){let a;je(a=$e())&&(r.videoElements=a)}},features:[H],decls:0,vars:0,template:function(t,r){},encapsulation:2})};var hn=(o,e)=>e.id,vn=(o,e)=>e.url;function yn(o,e){if(o&1&&(Se(0,"div",1),ge(1,"safeHtml")),o&2){let t=S();z("innerHTML",we(1,1,t.videoConfig.heading),le)}}function Cn(o,e){o&1&&(k(0,"div",6),Se(1,"div",14),A())}function bn(o,e){if(o&1&&Se(0,"source",8),o&2){let t=e.$implicit;z("type",Ue(t.mimeType))("src",t.url,xe)}}function xn(o,e){if(o&1){let t=de();k(0,"cooee-mute-toggle",15),Y("toggled",function(a){O(t),S();let c=fe(6),u=S();return L(u.onMuteToggled(a,c))}),A()}if(o&2){S();let t=fe(6);z("muted",t.muted)("videoEl",t)}}function _n(o,e){if(o&1){let t=de();k(0,"cooee-item-card",16),Y("buttonClick",function(){O(t);let a=S(),c=a.$implicit,u=a.$index,g=fe(6),_=S();return L(_.addToCartClicked(null,c,u,g))})("click",function(a){O(t);let c=S(),u=c.$implicit,g=c.$index,_=fe(6),D=S();return L(D.onVideoTap(a,u,g,_))}),A()}if(o&2){S();let t=_e(0);z("item",t)}}function wn(o,e){if(o&1){let t=de();k(0,"cooee-video-card",17),Y("linkClicked",function(){O(t);let a=S().$implicit,c=S();return L(c.sendTriggerClicked(a))}),A()}if(o&2){S();let t=_e(1);z("card",t)}}function Vn(o,e){if(o&1){let t=de();tt(0)(1),k(2,"div",4)(3,"div",5),Y("click",function(a){let c=O(t),u=c.$implicit,g=c.$index,_=fe(6),D=S();return L(D.onVideoTap(a,u,g,_))})("keydown.enter",function(a){let c=O(t),u=c.$implicit,g=c.$index,_=fe(6),D=S();return L(D.onVideoTap(a,u,g,_))})("keydown.space",function(a){let c=O(t),u=c.$implicit,g=c.$index,_=fe(6),D=S();return L(D.onVideoTap(a,u,g,_))}),j(4,Cn,2,0,"div",6),k(5,"video",7,0),Y("mouseenter",function(){O(t);let a=fe(6);S();let c=_e(1);return L(c&&a.play())})("mouseleave",function(){O(t);let a=fe(6);S();let c=_e(1);return L(c&&a.pause())})("loadstart",function(){let a=O(t).$implicit,c=S();return L(c.onVideoLoadStart(a.id))})("canplay",function(){let a=O(t).$implicit,c=S();return L(c.onVideoCanPlay(a.id))}),oe(7,bn,1,3,"source",8,vn),A(),k(9,"div",9),j(10,xn,1,2,"cooee-mute-toggle",10),A()(),k(11,"div",11),j(12,_n,1,1,"cooee-item-card",12)(13,wn,1,1,"cooee-video-card",13),A()()}if(o&2){let t=e.$implicit,r=S(),a=_e(0),c=Fe(t.items[0]);I();let u=Fe(t.card),g=c&&r.videoConfig.footerContent==r.VideoConfigFooterContent.FIRST_ITEM,_=u&&r.videoConfig.footerContent==r.VideoConfigFooterContent.CARD;I(2),et("background-image",t.thumbnail?"url("+t.thumbnail+")":null),I(),$(r.isVideoLoading(t.id)?4:-1),I(),z("muted",!0),Xe("preload",a?"metadata":"none")("autoplay",null)("data-video-id",t.id),I(2),re(t.sources),I(3),$(r.videoConfig.showMuteButton?10:-1),I(2),$(g?12:_?13:-1)}}var xt=class o extends Me{VideoConfigFooterContent=Mt;VideoConfigAutoPlay=Ei;swiperOptions=null;constructor(){super(),this.hasSwiper=!0}ngAfterViewInit(){super.ngAfterViewInit();let e=this.videoConfig.playlistConfig?.videoSwiper,t=e?(this.isMobile?e.gapSm:e.gap)+"px":window.cooeePlaylistGap??24,r=e?this.isMobile?e.maxInRowSm:e.maxInRow:"auto";this.swiperOptions={direction:"horizontal",effect:"slide",loop:e?.loop,freeMode:!0,spaceBetween:t,slidesPerView:r,mousewheel:{enabled:!0,forceToAxis:!0},autoplay:e?.autoplay?.enabled?{delay:e?.autoplay?.delay,disableOnInteraction:!1}:!1},this.setupIntersectionObserver(),this.playFirstVideo()}ngOnDestroy(){super.ngOnDestroy()}addToCartClicked(e,t,r,a){let c=t.items?.[0],u=di.get().website?.canChangeVariantInCart;if(t.items?.length>1||c?.hasVariants()&&!u){this.onVideoTap(e,t,r,a);return}this.engagementService.executeCTA(it.ADD_TO_CART,{item:c,video:t})}goToPDP(e,t){e?.stopPropagation(),e?.preventDefault();let r=t.items?.[0];this.engagementService.executeCTA(it.GO_TO_PRODUCT,{item:r,video:t})}update(){}onVideoBecameVisible(e){this.shouldAutoPlay()&&(this.dialogRef?this.pausedVideos.push(e):this.playVideo(e))}shouldAutoPlay(){return this.videoConfig.autoPlay==="ON"||this.videoConfig.autoPlay==="ON_HOVER"&&this.isMobile}playFirstVideo(){}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=B({type:o,selectors:[["cooee-video-playlist"]],features:[ae(se()),H],decls:7,vars:6,consts:[["videoEl",""],[1,"heading-text",3,"innerHTML"],[3,"options","navigationConfig","paginationConfig"],["ngProjectAs","swiper-slides",5,["swiper-slides"]],[1,"swiper-slide","video-card"],["role","button","tabindex","0","aria-label","Play video","aria-haspopup","dialog",1,"video-wrapper",3,"click","keydown.enter","keydown.space"],[1,"video-loading-overlay"],["width","100%","playsinline","","loop","",3,"mouseenter","mouseleave","loadstart","canplay","muted"],[3,"src","type"],[1,"video-controls"],[3,"muted","videoEl"],["role","region","aria-label","Video details",1,"video-footer"],["role","button","tabindex","0","aria-label","Product detail",3,"item"],[3,"card"],[1,"loading-spinner"],[3,"toggled","muted","videoEl"],["role","button","tabindex","0","aria-label","Product detail",3,"buttonClick","click","item"],[3,"linkClicked","card"]],template:function(t,r){if(t&1&&(tt(0)(1),j(2,yn,2,3,"div",1),k(3,"cooee-swiper",2),ei(4,3),oe(5,Vn,14,11,"div",4,hn),ti(),A()),t&2){Fe(!r.videoConfig.autoPlay||r.videoConfig.autoPlay===r.VideoConfigAutoPlay.ON),I(),Fe(r.videoConfig.autoPlay===r.VideoConfigAutoPlay.ON_HOVER),I(),$(r.videoConfig.heading?2:-1);let a=r.videoConfig.playlistConfig==null?null:r.videoConfig.playlistConfig.videoSwiper;I(),z("options",r.swiperOptions)("navigationConfig",a==null?null:a.navigation)("paginationConfig",a==null?null:a.pagination),I(2),re(r.videos)}},dependencies:[Di,ki,Pi,Ai,Ze],styles:[`:host{display:block}cooee-swiper.swiper{margin:8px;padding-top:25px;padding-bottom:25px}.video-wrapper{position:relative;cursor:pointer;outline:none;border-radius:var(--lc-media-radius, 8px);background-size:cover;background-position:center;background-repeat:no-repeat}.video-wrapper video{width:100%;height:var(--lc-video-card-height);object-fit:cover;border-radius:var(--lc-media-radius, 8px);position:relative}.video-card.swiper-slide{width:var(--lc-video-card-width);transition:transform .3s ease}.video-card.swiper-slide:hover{transform:scale(1.05)}@media (max-width: 768px),(prefers-reduced-motion: reduce){.video-card.swiper-slide{transition:none}.video-card.swiper-slide:hover{transform:none}}.video-controls{position:absolute;bottom:8px;z-index:10;right:8px;display:flex;gap:8px}cooee-item-card{cursor:pointer;padding-left:0!important;padding-right:0!important}cooee-item-card .item-image{width:50px;height:50px;display:none}cooee-item-card .item-info{font-size:14px;line-height:normal}cooee-item-card .item-info .item-name{-webkit-line-clamp:1;overflow:hidden}.video-loading-overlay{border-radius:var(--lc-media-radius, 8px)}
17
17
  `],encapsulation:3})};var Tn=["videoElement"],En=o=>({"cursor-grab":o}),In=(o,e)=>e.url;function Sn(o,e){if(o&1&&Se(0,"source",8),o&2){let t=e.$implicit;z("type",Ue(t.mimeType))("src",t.url,xe)}}var _t=class o extends Me{videoElement;video;isDragging=!1;hidden=!1;cdkDrag=be(mt,{self:!0});untilDestroyed=_i();constructor(){super()}get popupClasses(){return this.hidden?["hidden"]:["visible"]}onClick(e){e.stopPropagation(),e.preventDefault(),this.onVideoClick()}ngOnInit(){super.ngOnInit();let e=this.elementRef.nativeElement.closest(".letscooee-engagement");e&&(e.style.zIndex="10000"),this.cdkDrag.moved.pipe(this.untilDestroyed).subscribe(()=>this.isDragging=!0)}ngAfterViewInit(){super.ngAfterViewInit(),setTimeout(()=>{this.autoPlay()},100)}onVideoClick(){if(this.isDragging){this.isDragging=!1;return}this.hidden=!0,this.onVideoTap(null,this.video,0)}close(){this.hidden=!0;let e=(new Date().getTime()-this.triggerContext.startTime.getTime())/1e3;this.sendEvent("CE Trigger Closed",{duration:e})}engagementTriggerReceived(e){super.engagementTriggerReceived(e),this.video=this.videos[0]}update(){}onDialogClosed(){this.hidden=!1}autoPlay(){let e=this.videoElement.nativeElement;this.hidden||this.playVideo(e)}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=B({type:o,selectors:[["cooee-video-popup"]],viewQuery:function(t,r){if(t&1&&He(Tn,5),t&2){let a;je(a=$e())&&(r.videoElement=a.first)}},hostAttrs:["role","button","tabindex","0","aria-label","Open video popup "],hostVars:3,hostBindings:function(t,r){t&1&&Y("keydown.enter",function(c){return r.onClick(c)})("keydown.space",function(c){return r.onClick(c)})("click",function(c){return r.onClick(c)}),t&2&&(J("cdkDragBoundary","body"),ii(r.popupClasses))},features:[ae(se()),Jt([{directive:mt,inputs:["cdkDragBoundary","cdkDragBoundary"]}]),H],decls:11,vars:4,consts:[["videoElement",""],[1,"popup-inner",3,"ngClass"],["type","button","aria-label","Close video popup",1,"close-button",3,"click"],["name","close","aria-hidden","true"],[1,"play-button"],["name","unmute","aria-hidden","true"],[1,"text"],["loop","","preload","metadata","playsinline","",3,"muted"],[3,"src","type"]],template:function(t,r){if(t&1){let a=de();k(0,"div",1)(1,"button",2),Y("click",function(u){return O(a),u.stopPropagation(),L(r.close())}),Se(2,"cooee-icon",3),A(),k(3,"div",4),Se(4,"cooee-icon",5),k(5,"div",6),pe(6,"Tap to unmute"),A()(),k(7,"video",7,0),oe(9,Sn,1,3,"source",8,In),A()()}t&2&&(z("ngClass",oi(2,En,r.isDragging)),I(7),z("muted",!0),I(2),re(r.video.sources))},dependencies:[ct,Vi],styles:[`:host{position:fixed;display:block;right:24px;bottom:24px;min-height:150px;max-width:150px;box-shadow:0 25px 50px -12px #00000040}:host(.hidden){display:none}.popup-inner{display:flex;justify-content:center;align-items:center;position:relative}video{width:100%;border-radius:8px;background-color:#fff}.close-button{position:absolute;top:-14px;right:-14px;background-color:#00000080;border-radius:9999px;width:32px;height:32px;border:none;z-index:10;display:flex;justify-content:center;align-items:center}.play-button{display:flex;justify-content:center;align-items:center;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%) scale(1);transition:all .1s ease-in-out;z-index:999;flex-wrap:wrap;width:100%;max-width:130px;border-radius:5px;padding:5px 10px;background-color:#97979761;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.play-button cooee-icon{width:14px;height:14px}.play-button .text{font-size:11px;line-height:1;color:#fff;font-weight:400;margin-left:5px;text-align:center}
18
18
  `],encapsulation:3})};var Mn=(o,e)=>e.id,Pn=(o,e)=>e.url;function kn(o,e){if(o&1&&(ee(0,"div",1),ge(1,"safeHtml")),o&2){let t=S();J("innerHTML",we(1,1,t.videoConfig.heading),le)}}function Dn(o,e){o&1&&(X(0,"div",9),ee(1,"div",12),ce())}function An(o,e){if(o&1&&ee(0,"source",11),o&2){let t=e.$implicit;J("type",Ue(t.mimeType))("src",t.url,xe)}}function Fn(o,e){if(o&1){let t=de();X(0,"div",4),St("click",function(a){let c=O(t),u=c.$implicit,g=c.$index,_=S();return L(_.onVideoTap(a,u,g))})("keydown.enter",function(a){let c=O(t),u=c.$implicit,g=c.$index,_=S();return L(_.onVideoTap(a,u,g))})("keydown.space",function(a){let c=O(t),u=c.$implicit,g=c.$index,_=S();return L(_.onVideoTap(a,u,g))}),$t(),X(1,"svg",5),ee(2,"circle",6)(3,"circle",7),ce(),zt(),X(4,"div",8),j(5,Dn,2,0,"div",9),X(6,"video",10,0),St("loadstart",function(){let a=O(t).$implicit,c=S();return L(c.onVideoLoadStart(a.id))})("canplay",function(){let a=O(t).$implicit,c=S();return L(c.onVideoCanPlay(a.id))}),oe(8,An,1,3,"source",11,Pn),ce()()()}if(o&2){let t=e.$implicit,r=e.$index,a=S();Xe("aria-label","Open video story "+(r+1)),I(5),$(a.isVideoLoading(t.id)?5:-1),I(),J("poster",t.thumbnail,xe)("muted",!0),Xe("data-video-id",t.id),I(2),re(a.getOptimalSources(t.sources))}}var wt=class o extends Me{constructor(){super()}ngAfterViewInit(){super.ngAfterViewInit(),this.setupIntersectionObserver()}ngOnDestroy(){super.ngOnDestroy()}update(){}getOptimalSources(e){return[...e].reverse().sort((r,a)=>r.mimeType.includes("mp4")&&a.mimeType.includes("m3u8")?-1:r.mimeType.includes("m3u8")&&a.mimeType.includes("mp4")?1:0)}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=B({type:o,selectors:[["cooee-video-stories"]],features:[ae(se()),H],decls:4,vars:1,consts:[["videoEl",""],[1,"heading-text",3,"innerHTML"],[1,"video-stories"],["role","button","tabindex","0",1,"video-story"],["role","button","tabindex","0",1,"video-story",3,"click","keydown.enter","keydown.space"],["viewBox","0 0 100 100"],["cx","50","cy","50","r","48","fill","none","stroke-width","4"],["cx","50","cy","50","r","48","fill","none","stroke-width","4","stroke-linecap","round","stroke-dasharray","301.6","stroke-dashoffset","301.6",1,"video-story-circle"],[1,"video-wrapper"],[1,"video-loading-overlay"],["loop","","playsinline","","preload","metadata",3,"loadstart","canplay","poster","muted"],[3,"src","type"],[1,"loading-spinner"]],template:function(t,r){t&1&&(j(0,kn,2,3,"div",1),X(1,"div",2),oe(2,Fn,10,5,"div",3,Mn),ce()),t&2&&($(r.videoConfig.heading?0:-1),I(2),re(r.videos))},dependencies:[Ze],styles:[`:host{display:block}.video-stories{display:flex;overflow:auto;margin:.75rem;gap:.75rem;justify-content:center;align-items:center;scrollbar-width:none}.video-stories::-webkit-scrollbar{display:none}@media (max-width: 768px){.video-stories{justify-content:start!important}}.video-story{position:relative;width:5rem;height:5rem;cursor:pointer;flex-shrink:0}.video-story svg{position:absolute;top:0;left:0;width:100%;height:100%}.video-story svg circle:first-child{stroke:#d1d5db}.video-story svg circle:last-child{stroke:#3b82f6}.video-story .video-wrapper{position:relative;width:100%;height:100%;border-radius:9999px;overflow:hidden}.video-story .video-wrapper video{width:100%;height:100%;object-fit:cover;border-radius:9999px;position:relative;z-index:1}.video-story .video-wrapper .video-loading-overlay{border-radius:9999px}
19
19
  `],encapsulation:3})};ci("CooeeWidgetSDK");(async()=>{let o=await li(Ri),e=(t,r)=>{let a=Fi(t,{injector:o.injector});customElements.define(r,a)};e(bt,"cooee-sticky-atc"),e(vt,"cooee-savings-bar"),e(ht,"cooee-progressbar"),e(xt,"cooee-video-playlist"),e(_t,"cooee-video-popup"),e(wt,"cooee-video-stories"),e(fi,"cooee-product-options-picker"),sessionStorage.cooeeDebug&&import("./debugger.component-BLNLSLZS.js").then(t=>{e(t.DebuggerComponent,"cooee-debugger")}),window.cooeeShowQuickItem=(t,r)=>{o.injector.get(Ct).showItemQuickView(t,r)}})();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@letscooee/web-sdk",
3
3
  "description": "Engage uniquely and boost conversions with AI-powered customer journeys driven by real-time intent",
4
- "version": "12.1.0",
4
+ "version": "12.1.1",
5
5
  "scripts": {
6
6
  "lint": "ng lint",
7
7
  "integrity": "./scripts/validate-integrity.sh",