"use strict";var core=require("@gem-sdk/core"),system=require("@gem-sdk/system");const getResponsiveSetting=e=>{let t=e.desktop,r=e.tablet?e.tablet:t,d=e.mobile?e.mobile:r;return{desktop:t,tablet:r,mobile:d}},defaultWidth={desktop:"1200px",tablet:"100%",mobile:"100%"},getStyleByDevice=(e,t)=>t?.[e]==="100%"?{contentWidth:"100%",wrapperWidth:"100%",wrapperPadding:"var(--g-ct-p)"}:t?.[e]==="default"?{contentWidth:`var(--g-ct-w, ${defaultWidth[e]})`,wrapperWidth:`calc(var(--g-ct-w, ${defaultWidth[e]}) + 2 * var(--g-ct-p, 15px))`,wrapperPadding:"var(--g-ct-p, 15px)"}:t?.[e]!==void 0?{contentWidth:t?.[e],wrapperWidth:`calc(${t?.[e]} + 2 * var(--g-ct-p, 15px))`,wrapperPadding:"var(--g-ct-p, 15px)"}:{contentWidth:void 0,wrapperWidth:`calc(var(--g-ct-w, ${defaultWidth[e]}) + 2 * var(--g-ct-p, 15px))`,wrapperPadding:"var(--g-ct-p, 15px)"},createStyleObject=e=>{let t=getStyleByDevice("desktop",e),r=getStyleByDevice("tablet",e),d=getStyleByDevice("mobile",e);return{content:{desktop:t.contentWidth,tablet:r.contentWidth,mobile:d.contentWidth},wrapper:{desktop:t.wrapperWidth,tablet:r.wrapperWidth,mobile:d.wrapperWidth},padding:{desktop:t.wrapperPadding,tablet:r.wrapperPadding,mobile:d.wrapperPadding}}},getData=(e,t)=>{let{builderProps:r}=e,d=system.createStateOrContext({background:t,uid:r?.uid});return{stateData:core.dataStringify(d).replaceAll("'","&#039;")}};function reduceRadiusForState(e,t){if(!e||!t)return{};let r=("string"==typeof e?e.split(" "):[]).map(e=>parseInt(e,10)||0),d=Object.fromEntries(["btrr","bblr","bbrr","btlr"].map((e,d)=>[e,Math.max(0,(parseInt(t[e]??"0",10)||0)-(r[d]||0))+"px"]));return{...d,radiusType:t.radiusType}}function reduceBorderRadiusForDevice(e,t){if(!e||!t)return{};let r={};return["normal","hover","active"].forEach(d=>{let i=e?.[d],o=t?.[d];i&&o&&(r[d]=reduceRadiusForState(i.width,o))}),r}function getInnerRadiusExcludeBorder(e,t){return{desktop:reduceBorderRadiusForDevice(e?.desktop,t?.desktop),tablet:reduceBorderRadiusForDevice(e?.tablet??e?.desktop,t?.tablet??t?.desktop),mobile:reduceBorderRadiusForDevice(e?.mobile??e?.tablet??e?.desktop,t?.mobile??t?.tablet??t?.desktop)}}const checkHasBackgroundVideo=e=>core.DEVICES.some(t=>{let r=core.getValueByDevice(e,t);return!!r&&(r?.videoType==="html5"&&r?.videoHtml5||r?.videoType==="youtube"&&r?.video)}),isRenderHtmlVideo=e=>{let t=getResponsiveSetting(e||{}),r=t.desktop?.videoType,d=t.tablet?.videoType,i=t.mobile?.videoType;return"html5"==r||"html5"==d||"html5"==i},isRenderYoutubeVideo=e=>{let t=getResponsiveSetting(e||{}),r=t.desktop?.videoType,d=t.tablet?.videoType,i=t.mobile?.videoType;return"youtube"==r||"youtube"==d||"youtube"==i};exports.checkHasBackgroundVideo=checkHasBackgroundVideo,exports.createStyleObject=createStyleObject,exports.getData=getData,exports.getInnerRadiusExcludeBorder=getInnerRadiusExcludeBorder,exports.isRenderHtmlVideo=isRenderHtmlVideo,exports.isRenderYoutubeVideo=isRenderYoutubeVideo;
