/**
 * Minified by jsDelivr using Terser v5.48.0.
 * Original file: /npm/mjml-column@5.4.0/lib/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault").default;Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_callSuper2=_interopRequireDefault(require("@babel/runtime/helpers/callSuper")),_inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_mjmlCore=require("mjml-core"),_widthParser=_interopRequireDefault(require("mjml-core/lib/helpers/widthParser"));let MjColumn=exports.default=function(t){function e(){return(0,_classCallCheck2.default)(this,e),(0,_callSuper2.default)(this,e,arguments)}return(0,_inherits2.default)(e,t),(0,_createClass2.default)(e,[{key:"getChildContext",value:function(){const{containerWidth:t}=this.context,{nonRawSiblings:e}=this.props,{borders:r,paddings:i}=this.getBoxWidths(),n=i+r+(this.getShorthandBorderValue("left","inner-border")+this.getShorthandBorderValue("right","inner-border"));let o=this.getAttribute("width")||parseFloat(t)/e+"px";const{unit:a,parsedWidth:s}=(0,_widthParser.default)(o,{parseFloatToInt:!1});return o="%"===a?parseFloat(t)*s/100-n+"px":s-n+"px",{...this.context,containerWidth:o}}},{key:"getStyles",value:function(){const t=this.hasBorderRadius(),e=this.hasInnerBorderRadius(),r={"background-color":this.getAttribute("background-color"),border:this.getAttribute("border"),"border-bottom":this.getAttribute("border-bottom"),"border-left":this.getAttribute("border-left"),"border-radius":this.getAttribute("border-radius"),"border-right":this.getAttribute("border-right"),"border-top":this.getAttribute("border-top"),"vertical-align":this.getAttribute("vertical-align"),...t&&{"border-collapse":"separate"}},i=this.getMobileGutterStyles(),n=this.getOutlookGutterStyles();return{div:{"font-size":"0px","text-align":"left",direction:this.getAttribute("direction"),display:"inline-block","vertical-align":this.getAttribute("vertical-align"),width:this.getMobileWidth(),...i},table:{...this.hasGutter()?{"background-color":this.getAttribute("inner-background-color"),border:this.getAttribute("inner-border"),"border-bottom":this.getAttribute("inner-border-bottom"),"border-left":this.getAttribute("inner-border-left"),"border-radius":this.getAttribute("inner-border-radius"),"border-right":this.getAttribute("inner-border-right"),"border-top":this.getAttribute("inner-border-top")}:r,...e&&{"border-collapse":"separate"}},tdOutlook:{"vertical-align":this.getAttribute("vertical-align"),width:this.getWidthAsPixel(),...n},gutter:{...r,padding:this.getAttribute("padding"),"padding-top":this.getAttribute("padding-top"),"padding-right":this.getAttribute("padding-right"),"padding-bottom":this.getAttribute("padding-bottom"),"padding-left":this.getAttribute("padding-left")}}}},{key:"getMobileWidth",value:function(){const{containerWidth:t,isInGroup:r}=this.context,{nonRawSiblings:i}=this.props,n=this.getAttribute("width");if("mobileWidth"!==this.getAttribute("mobileWidth"))return"100%";if(r&&this.hasColumnGutter()){const{parsedWidth:r,unit:i}=this.getDesktopWidth();return"%"===i?`${r}%`:`${e.normalizeUnitValue(r/parseInt(t,10)*100)}%`}if(void 0===n)return`${parseInt(100/i,10)}%`;const{unit:o,parsedWidth:a}=(0,_widthParser.default)(n,{parseFloatToInt:!1});return"%"===o?n:`${e.normalizeUnitValue(a/parseInt(t,10)*100)}%`}},{key:"getWidthAsPixel",value:function(){const{containerWidth:t}=this.context,{unit:r,parsedWidth:i}=(0,_widthParser.default)(this.getParsedWidth(!0),{parseFloatToInt:!1});return"%"===r?`${e.normalizePxValue(parseFloat(t)*i/100)}px`:`${e.normalizePxValue(i)}px`}},{key:"getParsedWidth",value:function(t){const{nonRawSiblings:e}=this.props,r=this.getAttribute("width")||100/e+"%",{unit:i,parsedWidth:n}=(0,_widthParser.default)(r,{parseFloatToInt:!1});return t?`${n}${i}`:{unit:i,parsedWidth:n}}},{key:"getColumnClass",value:function(){const{addMediaQuery:t}=this.context,{isInGroup:r}=this.context;let i="";const{parsedWidth:n,unit:o}=this.hasColumnGutter()?this.getDesktopWidth():this.getParsedWidth(),a="px"===o?e.normalizePxValue(n):n,s=a.toString().replace(".","-");if("%"===o)i=`mj-column-per-${s}`;else i=`mj-column-px-${s}`;return this.hasColumnGutter()?(t(i,{parsedWidth:a,unit:o}),r||t(this.getDesktopGutterClassName(),{padding:this.getDesktopPadding()})):t(i,{parsedWidth:a,unit:o}),i}},{key:"getDesktopGutterClassName",value:function(){const t=this.getDesktopUnit(),r=this.getNormalizedGutterValue(t),i="%"===t?"per":t,n="rtl"===this.context.direction?"-rtl":"",o="px"===t?e.normalizePxValue(r):r,a=e.normalizeUnitValue(o).toString().replace(".","-");return`mj-column-gutter-${this.props.sibling}-${this.props.index+1}-${i}-${a}${n}`}},{key:"getDesktopUnit",value:function(){return this.getParsedWidth().unit}},{key:"getDesktopWidth",value:function(){const{sibling:t,index:r}=this.props,{parsedWidth:i,unit:n}=this.getParsedWidth();if(!this.hasColumnGutter())return{parsedWidth:"px"===n?e.normalizePxValue(i):i,unit:n};const o=this.getNormalizedGutterValue(n)*(t-1)/t,a=Math.max(0,e.normalizeUnitValue(i-o));if("px"===n){const e=Math.floor(a),i=a-e;return{parsedWidth:e+(r<Math.max(0,Math.min(t,Math.round(t*i)))?1:0),unit:n}}return{parsedWidth:a,unit:n}}},{key:"getNormalizedGutterValue",value:function(t){const{gutter:e}=this.context;if(!e)return 0;const{containerWidth:r}=this.context,{unit:i,parsedWidth:n}=(0,_widthParser.default)(e,{parseFloatToInt:!1});return i===t?n:"%"===t&&"px"===i?n/parseFloat(r)*100:"px"===t&&"%"===i?parseFloat(r)*n/100:n}},{key:"hasColumnGutter",value:function(){const{gutter:t}=this.context;return null!=t&&""!==t}},{key:"getDesktopPaddingValues",value:function(t){const{first:r,last:i,sibling:n}=this.props,{direction:o}=this.context,a=this.getNormalizedGutterValue(t),s="px"===t?e.normalizePxValue(a):a,u="px"===t,l=u?Math.ceil(s/2):s/2,d=u?Math.floor(s/2):s/2;return 1===n?{top:0,right:0,bottom:0,left:0}:"rtl"===o?{top:0,right:r?0:d,bottom:0,left:i?0:l}:{top:0,right:i?0:l,bottom:0,left:r?0:d}}},{key:"getMobilePaddingValues",value:function(){const{first:t,last:e}=this.props,r=this.getNormalizedGutterValue("%")/2;return{top:t?0:r,right:0,bottom:e?0:r,left:0}}},{key:"getDesktopPadding",value:function(){const t=this.getDesktopUnit(),{top:r,right:i,bottom:n,left:o}=this.getDesktopPaddingValues(t);return e.formatPadding(r,i,n,o,t)}},{key:"getMobilePadding",value:function(){const{top:t,right:r,bottom:i,left:n}=this.getMobilePaddingValues();return e.formatPadding(t,r,i,n,"%")}},{key:"getMobileGutterStyles",value:function(){if(!this.hasColumnGutter())return{};const{isInGroup:t}=this.context;return t?{padding:this.getDesktopPadding()}:{padding:this.getMobilePadding()}}},{key:"getOutlookGutterStyles",value:function(){if(!this.hasColumnGutter())return{};const{top:t,right:r,bottom:i,left:n}=this.getDesktopPaddingValues("px");return{padding:e.formatPadding(t,r,i,n,"px")}}},{key:"hasBorderRadius",value:function(){const t=this.getAttribute("border-radius");return""!==t&&void 0!==t}},{key:"hasInnerBorderRadius",value:function(){const t=this.getAttribute("inner-border-radius");return""!==t&&void 0!==t}},{key:"hasGutter",value:function(){return["padding","padding-bottom","padding-left","padding-right","padding-top"].some(t=>null!=this.getAttribute(t))}},{key:"renderGutter",value:function(){const t=this.hasBorderRadius();return`\n      <table\n        ${this.htmlAttributes({border:"0",cellpadding:"0",cellspacing:"0",role:"presentation",width:"100%",...t&&{style:{"border-collapse":"separate"}}})}\n      >\n        <tbody>\n          <tr>\n            <td ${this.htmlAttributes({style:"gutter"})}>\n              ${this.renderColumn()}\n            </td>\n          </tr>\n        </tbody>\n      </table>\n    `}},{key:"renderColumn",value:function(){const{children:t}=this.props;return`\n      <table\n        ${this.htmlAttributes({border:"0",cellpadding:"0",cellspacing:"0",role:"presentation",style:"table",width:"100%"})}\n      >\n        <tbody>\n          ${this.renderChildren(t,{renderer:t=>t.constructor.isRawElement()?t.render():`\n              <tr>\n                <td\n                  ${t.htmlAttributes({align:t.getAttribute("align"),class:t.getAttribute("css-class"),style:{background:t.getAttribute("container-background-color"),"font-size":"0px",padding:t.getAttribute("padding"),"padding-top":t.getAttribute("padding-top"),"padding-right":t.getAttribute("padding-right"),"padding-bottom":t.getAttribute("padding-bottom"),"padding-left":t.getAttribute("padding-left"),"word-break":"break-word"}})}\n                >\n                  ${t.render()}\n                </td>\n              </tr>\n            `})}\n        </tbody>\n      </table>\n    `}},{key:"render",value:function(){let t=this.getColumnClass();return this.hasColumnGutter()&&(t+=` ${this.getDesktopGutterClassName()}`),t+=" mj-outlook-group-fix",this.getAttribute("css-class")&&(t+=` ${this.getAttribute("css-class")}`),`\n      <div\n        ${this.htmlAttributes({class:t,style:"div"})}\n      >\n        ${this.hasGutter()?this.renderGutter():this.renderColumn()}\n      </div>\n    `}}],[{key:"normalizeUnitValue",value:function(t){return Number(parseFloat(t).toFixed(6))}},{key:"normalizePxValue",value:function(t){return Math.round(parseFloat(t))}},{key:"formatPadding",value:function(t,r,i,n,o){return"px"===o?`${e.normalizePxValue(t)}px ${e.normalizePxValue(r)}px ${e.normalizePxValue(i)}px ${e.normalizePxValue(n)}px`:`${e.normalizeUnitValue(t)}${o} ${e.normalizeUnitValue(r)}${o} ${e.normalizeUnitValue(i)}${o} ${e.normalizeUnitValue(n)}${o}`}}])}(_mjmlCore.BodyComponent);(0,_defineProperty2.default)(MjColumn,"componentName","mj-column"),(0,_defineProperty2.default)(MjColumn,"allowedAttributes",{"background-color":"color",border:"string","border-bottom":"string","border-left":"string","border-radius":"string","border-right":"string","border-top":"string",direction:"enum(ltr,rtl)","inner-background-color":"color","padding-bottom":"unit(px,%)","padding-left":"unit(px,%)","padding-right":"unit(px,%)","padding-top":"unit(px,%)","inner-border":"string","inner-border-bottom":"string","inner-border-left":"string","inner-border-radius":"string","inner-border-right":"string","inner-border-top":"string",padding:"unit(px,%){1,4}","vertical-align":"enum(top,bottom,middle)",width:"unit(px,%)"}),(0,_defineProperty2.default)(MjColumn,"defaultAttributes",{direction:"ltr","vertical-align":"top"}),module.exports=exports.default;
//# sourceMappingURL=/sm/b84963383a4b7e0411c7f16b338b228f3fadb291c0efc9d29dac8078d8bf6d1d.map