"use strict";(self.webpackChunk_genially_view_client=self.webpackChunk_genially_view_client||[]).push([[1616],{91616:(e,t,a)=>{a.r(t),a.d(t,{geniallyRandomImageViewScript:()=>u});var i=a(54072),n=a(48237),o=a(68283),s=a(10285),c=a(66264),l=a(84054),r=function(e,t,a,i){return new(a||(a=Promise))((function(n,o){function s(e){try{l(i.next(e))}catch(t){o(t)}}function c(e){try{l(i.throw(e))}catch(t){o(t)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(s,c)}l((i=i.apply(e,t||[])).next())}))};function d(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}const u=(e,t)=>{const a=e.item,{config:u}=e,g=u.imageItemRef,m=[],p=e=>{if(!e||e.data.type!==n.L.PlayAudio||!e.data.source)return;const{source:a}=e.data;return t.preloadAudio(a),Object.assign(Object.assign({},e.data),{source:a})},f=p(u.onStepAudio),y=p(u.onClickAudio);(f||y)&&(e.slide.audioRequirement=l.w.ShowMute);const h=u.images.filter((e=>!!e.image.source)).map((e=>Object.assign(Object.assign({},e),{id:(0,i.Ak)()})));h.forEach((e=>{e.imageAction&&e.imageAction.preload()}));const b=e=>{g&&(g.alternativeText=e.image.altText,g.source=e.image.source,g.imageId=e.id)};h.forEach((e=>{t.preloadImage(e.image.source)})),u.showCoverImage?(u.coverImage.source&&t.preloadImage(u.coverImage.source),g&&(g.alternativeText=u.coverImage.altText)):h.length>0&&b(h[0]);let v=0;const A=e=>{const a=(e=>{let t;do{t=d(0,h.length-1)}while(t===v&&!e&&h.length>1);return v=t,t})(e);b(h[a]),f&&t.playAudio(Object.assign(Object.assign({},f),{refId:(0,i.Ak)()}))},I=[];let j=Symbol("animationInstance");const O=e=>200+10*(6-e),w=(()=>{let e=0;for(let t=0;t<6;t+=1)e+=O(t);return e})(),M=e=>r(void 0,void 0,void 0,(function*(){const n=h.length<=2;A(n);for(let i=0;i<5&&(yield new Promise((e=>t.setTimeout(e,O(i)))),a.parentSlide.isCurrent&&j===e);i+=1)A(!1);u.exclusiveResults?(()=>{0===I.length&&I.push(...h);const e=d(0,I.length-1),a=I.splice(e,1).pop();b(a),f&&t.playAudio(Object.assign(Object.assign({},f),{refId:(0,i.Ak)()}))})():A(!1)}));h.length>1&&(a.markAsInteractive=!0,a.on(c.q.Click,(()=>r(void 0,void 0,void 0,(function*(){let e;m.forEach((e=>{t.playAudio(Object.assign(Object.assign({},e),{playMode:s.F.Stop}))})),m.length=0,a.playAnimation({type:o.x.Wobble,parameters:{delayMs:0,durationMs:w}}),y&&(e=t.playAudio(Object.assign(Object.assign({},y),{playMode:s.F.PlayRestart}))),j=Symbol("animationInstance"),yield M(j);const i=h.find((e=>e.id===(null===g||void 0===g?void 0:g.imageId)));if(i&&i.imageAction)if(i.imageAction.data.type===n.L.PlayAudio){const a=i.imageAction.data;if(a.source){y&&e&&t.playAudio(Object.assign(Object.assign({},y),{refId:e.refId,playMode:s.F.PlayStop}));const i={source:a.source,playMode:s.F.PlayStop},n=t.playAudio(i);m.push(Object.assign(Object.assign({},i),{refId:n.refId,completed:!1}))}}else i.imageAction.run()})))))}}}]);
//# sourceMappingURL=https://s3-static-genially.genially.com/view/static/js/1616.2263a444.chunk.js.map