'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),NextImage=require("../../image/components/NextImage.js"),useLiteHtml5Embed=require("../hooks/useLiteHtml5Embed.js"),system=require("@gem-sdk/system"),classes=require("../common/classes.js"),styles=require("../common/styles.js"),attrs=require("../common/attrs.js");const HTML5Embed=e=>{let s=core.useEditorMode(),t="edit"!==s,{thumbnail:a,muted:l,autoplay:r,loop:i,controls:m,src:o,style:u,title:c,className:n,lazy:d,poster:x}=e,{playVideoAndTurnOffThumbnail:j,videoRef:y,showThumbnail:g}=useLiteHtml5Embed.useLiteHtml5Embed(r,l,o),b=!t&&r&&l&&!!a,p=!d&&e.isVideoComponent&&t,C=!a||!g,h=o||void 0,R=system.createAttr({...attrs.getHtml5Attr({title:c,autoplay:r,preloadThumbnail:b,offLazyLoad:p,src:o,thumbnail:a})}),L=system.createClass({...classes.getWrapThumbnailClasses(C)}),N=system.createStyle({...styles.getPreloadImageStyle()}),q=system.createClass({...classes.getButtonThumbnailClasses()}),v=system.createClass({...classes.getImageThumbnailClasses()}),I=system.createClass({...classes.getVideoYoutubeClasses(n,p)}),E=()=>b?jsxRuntime.jsx(NextImage.default,{src:a,alt:c,priority:!0,style:N}):"",H=()=>jsxRuntime.jsxs("div",{role:"presentation",style:u,className:L,onClick:j,children:[jsxRuntime.jsx(NextImage.default,{id:"video-thumbnail",src:a??"",alt:x?.altText,title:x?.imageTitle,priority:x?.preload&&t,className:v,isDisableAspectStyle:!0,enableLazyLoadImage:!0}),jsxRuntime.jsx("button",{type:"button",className:q,"aria-label":"Play",children:jsxRuntime.jsx("svg",{className:"gp-w-5 gp-text-white",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{fill:"currentColor",d:"M5 5.274c0-1.707 1.826-2.792 3.325-1.977l12.362 6.726c1.566.853 1.566 3.101 0 3.953L8.325 20.702C6.826 21.518 5 20.432 5 18.726V5.274Z"})})})]});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[E(),jsxRuntime.jsx("video",{ref:y,...R,style:u,className:I,controls:m,loop:i,muted:l,autoPlay:r,playsInline:!0,src:h}),!C&&H()]})};exports.default=HTML5Embed;
