(()=>{var t={942:(t,e)=>{var o;!function(){"use strict";var s={}.hasOwnProperty;function n(){for(var t="",e=0;e<arguments.length;e++){var o=arguments[e];o&&(t=r(t,i(o)))}return t}function i(t){if("string"==typeof t||"number"==typeof t)return t;if("object"!=typeof t)return"";if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes("[native code]"))return t.toString();var e="";for(var o in t)s.call(t,o)&&t[o]&&(e=r(e,o));return e}function r(t,e){return e?t?t+" "+e:t+e:t}t.exports?(n.default=n,t.exports=n):void 0===(o=function(){return n}.apply(e,[]))||(t.exports=o)}()}},e={};function o(s){var n=e[s];if(void 0!==n)return n.exports;var i=e[s]={exports:{}};return t[s](i,i.exports,o),i.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var s in e)o.o(e,s)&&!o.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";const t=window.wp.blocks,e=window.wp.i18n,s=window.lodash;var n=o(942),i=o.n(n);const r=window.wp.blockEditor,l=window.wp.element,a=window.wp.components,c=window.wp.keycodes,u=window.wp.compose,d=window.wp.primitives,h=window.ReactJSXRuntime,g=(0,h.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,h.jsx)(d.Path,{d:"M20.5 16h-.7V8c0-1.1-.9-2-2-2H6.2c-1.1 0-2 .9-2 2v8h-.7c-.8 0-1.5.7-1.5 1.5h20c0-.8-.7-1.5-1.5-1.5zM5.7 8c0-.3.2-.5.5-.5h11.6c.3 0 .5.2.5.5v7.6H5.7V8z"})}),p=(0,h.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,h.jsx)(d.Path,{d:"M17 4H7c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H7c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h10c.3 0 .5.2.5.5v12zm-7.5-.5h4V16h-4v1.5z"})}),m=(0,h.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,h.jsx)(d.Path,{d:"M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z"})});function v(){return[{value:"small",label:(0,e.__)("Small","layout-grid")},{value:"medium",label:(0,e.__)("Medium","layout-grid")},{value:"large",label:(0,e.__)("Large","layout-grid")},{value:"huge",label:(0,e.__)("Huge","layout-grid")}]}const f=()=>[{label:(0,e.__)("1 cols","layout-grid"),value:1},{label:(0,e.__)("2 cols","layout-grid"),value:2},{label:(0,e.__)("3 cols","layout-grid"),value:3},{label:(0,e.__)("4 cols","layout-grid"),value:4}],w="Desktop",b="Tablet",_="Mobile",y=()=>[{value:w,label:(0,e.__)("Desktop","layout-grid"),icon:g},{value:b,label:(0,e.__)("Tablet","layout-grid"),icon:p},{value:_,label:(0,e.__)("Mobile","layout-grid"),icon:m}],k=[w,b,_];function x(t,e){return`column${t+1}${e}Span`}function j(t,e){return`column${t+1}${e}Offset`}const C=t=>t===b?8:t===_?4:12;function S(t,e,o){return t===b?3===e&&2===o?C(t):e>1?C(t)/2:C(t):t===_?C(t):C(t)/e}const z=(t,e)=>`column${t+1}-grid__span-${e}`,M=(t,e)=>`column${t+1}-grid__start-${e}`,B=(t,e)=>`column${t+1}-grid__row-${e}`,A=(t,e,o)=>`column${t+1}-${o.toLowerCase()}-grid__span-${e}`,D=(t,e,o)=>`column${t+1}-${o.toLowerCase()}-grid__start-${e}`,P=(t,e,o)=>`column${t+1}-${o.toLowerCase()}-grid__row-${e}`;function O(t,e){return Math.floor(t/e)}function V(t,e){return t%e}function N(t,e,o,s,n=!0){return{name:t,column:e,value:o,device:s,enabled:n}}function T(t,e,o){const s=[],n=C(t),i=function(t,e,o){const s=[];let n=0;for(let i=0;i<t;i++){const r=x(i,e),l=j(i,e),a=o[r]||S(e,t,i),c=o[l]||0;s.push({position:n+c,span:a}),n+=c,n+=a}return s}(e,t,o);for(let e=0;e<i.length;e++){const{span:o,position:r}=i[e],l=O(r,n),a=V(r,n);s.push(N("span",e,o,t)),s.push(N("offset",e,a+1,t,a>0)),s.push(N("row",e,l+1,t))}return s}function G(t,e){const o={};return t.filter((t=>t.enabled&&e[t.name])).map((t=>o[e[t.name](t.column,t.value,t.device)]=!0)),o}function R(t){return t?t.replace(/column\d-\w*-grid__\w*-\d*/g,"").replace(/column\d-grid__\w*-\d*/g,"").replace(/\s{2,}/,"").replace(/wp-block-jetpack-layout-gutter__\w*/,"").replace(/is-vertically-aligned-\w*/,"").replace(/is-style-[A-Za-z-_]*/,"").replace(/are-vertically-aligned-\w*/):t}function L({gutterSize:t,addGutterEnds:e}){return{"wp-block-jetpack-layout-gutter__nowrap":!e,"wp-block-jetpack-layout-gutter__none":"none"===t,"wp-block-jetpack-layout-gutter__small":"small"===t,"wp-block-jetpack-layout-gutter__medium":"medium"===t,"wp-block-jetpack-layout-gutter__huge":"huge"===t}}const I=t=>(0,h.jsx)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48",...t,children:(0,h.jsx)(a.Path,{d:"M7 12v24h34V12H7zm32 22H9V14h30v20z"})}),E=t=>(0,h.jsx)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48",...t,children:(0,h.jsx)(a.Path,{d:"M7,12v24h34V12H7z M23,34H9V14h14V34z M39,34H25V14h14V34z"})}),$=t=>(0,h.jsx)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48",...t,children:(0,h.jsx)(a.Path,{d:"M7 12v24h34V12H7zm23 2h9v20h-9V14zm-2 20h-8V14h8v20zM9 14h9v20H9V14z"})}),H=t=>(0,h.jsx)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48",...t,children:(0,h.jsx)(a.Path,{d:"M7 12v24h34V12H7zm8 22H9V14h6v20zm8 0h-6V14h6v20zm8 0h-6V14h6v20zm8 0h-6V14h6v20z"})}),U=({columns:t,...e})=>4===t?(0,h.jsx)(H,{...e}):3===t?(0,h.jsx)($,{...e}):2===t?(0,h.jsx)(E,{...e}):(0,h.jsx)(I,{...e}),X=({direction:t,height:e,xPos:o,top:s,isSelected:n})=>{const r=i()("wpcom-overlay-resize__handle","components-resizable-box__container",{"is-selected":n}),l={height:e+"px",width:o+"px",top:s+"px"},a={left:o+"px"},c=i()("components-resizable-box__handle","components-resizable-box__side-handle",{"components-resizable-box__handle-left":"left"===t,"components-resizable-box__handle-right":"right"===t});return(0,h.jsx)("div",{className:r,style:l,children:(0,h.jsx)("span",{children:(0,h.jsx)("div",{className:c,style:a})})})};class F extends l.Component{constructor(t){super(t),this.containerRef=(0,l.createRef)(),this.state={resizingColumn:-1,xPos:0,height:0}}getNearestColumn(t,e){const{totalColumns:o,layoutGrid:s}=this.props,n=s.getStart(this.state.resizingColumn),i=s.getSpan(this.state.resizingColumn),r=Math.min(o,Math.max(0,function(t,e,o,s){const{width:n,x:i}=t.getBoundingClientRect(),r=n/s,l=e-i,a=Math.floor(l/r),c=l%r;return"left"===o?c<=r/2?a:a+1:c<r/2?a:a+1}(this.containerRef.current,this.getMouseX(e),t,o)));if("left"===t){if(r===n)return null;const e=Math.abs(r-n),o={start:r,span:r>n?i-e:i+e,direction:t};return o.start>=n+i?null:(o.span=Math.max(1,o.span),o)}return{span:Math.max(1,r-n),direction:t}}getMouseX(t){const{clientX:e,targetTouches:o}=t;return e||o&&o[0].clientX}getAdjustedOffset(t,e=0){const{width:o}=this.state,s=e>0?e:o;return t-this.containerRef.current.getBoundingClientRect().left-s/2}getAdjustedTop(t){return t-this.containerRef.current.getBoundingClientRect().top}getRestrictedOffset(t){const{direction:e,max:o,width:s}=this.state;return"left"===e?Math.min(o-s,t):Math.max(o+s,t)}getChildPosition(t){let e=0;for(;null!==t.previousSibling;)t=t.previousSibling,e++;return e}onMouseDown=t=>{const{target:e}=t;if((0===t.button||t.touches)&&(e.dataset.resizeRight||e.dataset.resizeLeft)){this.block=e.closest(".wp-block"),this.targetDocument=e.ownerDocument;const{height:o,right:s,left:n,top:i}=this.block.getBoundingClientRect(),{width:r}=e.getBoundingClientRect(),l=this.getChildPosition(this.block),a=e.dataset.resizeLeft;this.setState({resizingColumn:l,xPos:this.getAdjustedOffset(this.getMouseX(t),r),height:o,width:r,top:this.getAdjustedTop(i),direction:a?"left":"right",max:a?this.getAdjustedOffset(s,r):this.getAdjustedOffset(n,r)}),0===t.button?(this.targetDocument.addEventListener("mousemove",this.onMouseMove),this.targetDocument.addEventListener("mouseup",this.onMouseUp),t.preventDefault()):(this.targetDocument.addEventListener("touchmove",this.onMouseMove),this.targetDocument.addEventListener("touchend",this.onMouseUp)),t.stopPropagation()}};onMouseMove=t=>{t.stopPropagation(),void 0===t.touches&&t.preventDefault();const{height:e}=this.block.getBoundingClientRect();this.setState({xPos:this.getRestrictedOffset(this.getAdjustedOffset(this.getMouseX(t))),height:e});const o=this.getNearestColumn(this.state.direction,t);o&&this.props.onResize(this.state.resizingColumn,o)};onMouseUp=t=>{this.setState({resizingColumn:-1}),this.targetDocument.removeEventListener("mousemove",this.onMouseMove),this.targetDocument.removeEventListener("mouseup",this.onMouseUp),this.targetDocument.removeEventListener("touchmove",this.onMouseMove),this.targetDocument.removeEventListener("touchend",this.onMouseUp)};render(){const{className:t,children:e,isSelected:o}=this.props,{resizingColumn:s,xPos:n,height:r}=this.state,l=i()(t,-1!==s?"wp-block-jetpack-layout-grid__resizing":null);return(0,h.jsxs)("div",{className:l,onMouseDown:this.onMouseDown,onTouchStart:this.onMouseDown,ref:this.containerRef,children:[-1!==s&&(0,h.jsx)(X,{direction:this.state.direction,height:r,xPos:n,top:this.state.top,isSelected:o}),e]})}}const q=F,J=class{constructor(t,e,o){this.attributes=t,this.device=e,this.columnCount=o}getGridValues(){const t={};for(let e=0;e<this.columnCount;e++){const o=S(this.device,this.columnCount,e);t[x(e,this.device)]=this.getSpan(e)||o,t[j(e,this.device)]=this.getOffset(e)}return t}applyAdjustments(t){let e=this.getGridValues();for(let o=0;o<t.length;o++)e={...e,...t[o]};return e}getSpanAdjustment(t,e){return{[x(t,this.device)]:e}}getAdjustOffset(t,e){return{[j(t,this.device)]:e}}getShrinkOffset(t,e){const o=this.getOffset(t),s=e>=o?o:e;return{adjustment:this.getAdjustOffset(t,o-s),offsetUsed:s}}hasOverlaps(t){for(let e=0;e<t.length;e++){const o=t[e];for(let s=e+1;s<t.length;s++){const e=t[s];if(o.start>e.start&&o.start<e.end)return!0;if(o.end>e.start&&o.end<e.end)return!0}}return!1}validateGrid(t){const e=[],o=C(this.device);let s=0,n=0;for(let i=0;i<this.columnCount;i++){const r=t[x(i,this.device)],l=t[j(i,this.device)];if(n+=l,n>=o&&(n-=o),n+=r,n>o)return!1;e.push({start:s+l,end:s+l+r}),s+=r+l}return!(s>(i=this.device,r=this.columnCount,i===b&&r>2?2*C(i):i===_?C(i)*r:C(i))||this.hasOverlaps(e));var i,r}getEndAdjustments(t,e){const o=[];if(e<0)return[this.getAdjustOffset(t,this.getOffset(t)+Math.abs(e))];if(e>0)for(let s=t;s<this.columnCount&&e>0;s++){const t=this.getShrinkOffset(s,Math.abs(e));o.push(t.adjustment),e-=t.offsetUsed}return o}getStartMovedLeft(t,e){const o=[];for(let s=t;s>=0&&e>0;s--){const t=this.getShrinkOffset(s,e);o.push(t.adjustment),e-=t.offsetUsed}return o}getStartAdjustments(t,e){const o=this.getOffset(t),s=this.getOffsetFromStart(t,e),n=s-o;return n<0?this.getStartMovedLeft(t,Math.abs(n)):[this.getAdjustOffset(t,s)]}getSpan(t){return this.attributes[x(t,this.device)]}getOffset(t){return this.attributes[j(t,this.device)]}getStart(t){let e=0;for(let o=0;o<t;o++)e+=this.getSpan(o)+this.getOffset(o);const o=Math.max(1,Math.floor(e/C(this.device)));return(e+this.getOffset(t))%(o*C(this.device))}getOffsetFromStart(t,e){if(0===t)return e;const o=e-this.getStart(t);return this.getOffset(t)+o}convertOffsetToStart(t,e){return this.getStart(t)+(e-this.getOffset(t))}getAdjustedGrid(t,e){const{start:o=this.getStart(t),span:s=this.getSpan(t)}=e;let n=[];o!==this.getStart(t)&&s!==this.getSpan(t)?(n=n.concat(this.getStartAdjustments(t,o)),n=n.concat(this.getSpanAdjustment(t,s))):s!==this.getSpan(t)?(n=n.concat(this.getSpanAdjustment(t,s)),n=n.concat(this.getEndAdjustments(t+1,s-this.getSpan(t)))):o!==this.getStart(t)&&(n=n.concat(this.getStartAdjustments(t,o)),n=n.concat(this.getEndAdjustments(t+1,o-this.getStart(t))));const i=this.applyAdjustments(n);return n.length>0&&this.validateGrid(i)?i:null}},K=window.wp.data,W=function(t){const{viewPort:e,updateViewport:o}=t,{__experimentalSetPreviewDeviceType:s}=(0,K.useDispatch)("core/edit-post")||(0,K.useDispatch)("core/edit-site"),n=(0,K.useSelect)((t=>(t("core/edit-site")||t("core/edit-post")).__experimentalGetPreviewDeviceType()),[]),[i,c]=(0,u.useResizeObserver)(),d=(0,u.useViewportMatch)("medium","<"),g=(0,u.useViewportMatch)("small","<");return(0,l.useEffect)((()=>{const t=function(t,e){return t?"Mobile":e?"Tablet":"Desktop"}(g,d);t!==e&&o(t)}),[c]),(0,h.jsxs)(h.Fragment,{children:[i,!g&&(0,h.jsx)(r.BlockControls,{children:(0,h.jsx)(a.Dropdown,{renderToggle:({isOpen:t,onToggle:e})=>(0,h.jsx)(a.ToolbarGroup,{children:(0,h.jsx)(a.Button,{"aria-expanded":t,onClick:e,icon:y().find((t=>t.value===n)).icon})}),renderContent:()=>(0,h.jsx)(a.MenuGroup,{children:(0,h.jsx)(a.MenuItemsChoice,{value:n,onSelect:t=>s(t),choices:y()})})})})]})};function Z(){return!!document.querySelector("#edit-site-editor")}const Q=["jetpack/layout-grid-column"];class Y extends l.Component{constructor(t){super(t),this.overlayRef=(0,l.createRef)(),this.state={inspectorDeviceType:"Desktop",viewPort:"Desktop"}}onChangeLayout=t=>{const e={};for(let o=0;o<t;o++)for(let s=0;s<k.length;s++){const n=S(k[s],t,o);e[x(o,k[s])]=n,e[j(o,k[s])]=0}this.props.updateColumns(this.props.columns,t,e)};onResize=(t,e)=>{const{attributes:o,columns:s}=this.props,n=new J(o,this.getPreviewMode(),s).getAdjustedGrid(t,e);n&&this.adjustGrid(n)};onChangeSpan=(t,e,o)=>{const{attributes:s,columns:n}=this.props,i=new J(s,e,n).getAdjustedGrid(t,{span:parseInt(o,10)});i&&this.adjustGrid(i)};onChangeOffset=(t,e,o)=>{const{attributes:s,columns:n}=this.props,i=new J(s,e,n),r=i.getAdjustedGrid(t,{start:i.convertOffsetToStart(t,parseInt(o,10))});r&&this.adjustGrid(r)};adjustGrid(t){const{setAttributes:e,attributes:o}=this.props;e({...t,className:R(o.className)})}renderDeviceSettings(t,o,s){const n=new J(s,o,this.props.columns),i=[];for(let s=0;s<t;s++){const r=n.getSpan(s)||S(o,t,s),l=n.getOffset(s)||0;i.push((0,h.jsxs)("div",{className:"jetpack-layout-grid-settings",children:[(0,h.jsxs)("strong",{children:[(0,e.__)("Column","layout-grid")," ",s+1]}),(0,h.jsxs)("div",{className:"jetpack-layout-grid-settings__group",children:[(0,h.jsx)(a.TextControl,{type:"number",label:(0,e.__)("Offset","layout-grid"),value:l||0,min:0,max:C(o)-1,onChange:t=>this.onChangeOffset(s,o,t)}),(0,h.jsx)(a.TextControl,{type:"number",label:(0,e.__)("Span","layout-grid"),value:r,min:1,max:C(o),onChange:t=>this.onChangeSpan(s,o,t)})]})]},s))}return i}canResizeBreakpoint(t){if(this.overlayRef&&this.overlayRef.current){const{width:e}=this.overlayRef.current.getBoundingClientRect();return e/C(t)>50}return!1}updateInspectorDevice(t){this.setState({inspectorDeviceType:t}),"Mobile"!==this.state.viewPort&&this.props.setPreviewDeviceType(t)}getPreviewMode(){return this.props.isBlockOrPatternPreview?"Desktop":"Desktop"===this.state.viewPort||"Mobile"===this.props.previewDeviceType?this.props.previewDeviceType:this.state.viewPort}getInspectorMode(){return"Desktop"===this.state.viewPort?this.props.previewDeviceType:this.state.inspectorDeviceType}render(){const{className:t,attributes:o={},isSelected:n,columns:l,setAttributes:u,updateAlignment:d,columnAttributes:g}=this.props,{viewPort:p}=this.state,m=this.getPreviewMode(),w=this.getInspectorMode(),b=function(t,e,o={},s=[]){const n=T(t,e,o),i={span:z,offset:M,row:B},r={};for(let t=0;t<e;t++)s[t].verticalAlignment&&s[t].verticalAlignment!==o.verticalAlignment&&(r[(l=t,a=s[t].verticalAlignment,`column${l+1}-grid__valign-${a}`)]=!0);var l,a;return{...G(n,i),...r}}(m,l,o,g),{gutterSize:_,addGutterEnds:k,verticalAlignment:x}=o,j=new J(o,m,l),S=i()(R(t).replace("layout-grid","layout-grid-editor"),"wp-block-jetpack-editor",b,{"wp-block-jetpack-layout-tablet":"Tablet"===m,"wp-block-jetpack-layout-desktop":"Desktop"===m,"wp-block-jetpack-layout-mobile":"Mobile"===m,"wp-block-jetpack-layout-resizable":this.canResizeBreakpoint(m),[`are-vertically-aligned-${x}`]:x},L(o));if(0===l)return(0,h.jsx)(a.Placeholder,{icon:"layout",label:(0,e.__)("Choose Layout","layout-grid"),instructions:(0,e.__)("Select a layout to start with:","layout-grid"),className:S,children:(0,h.jsx)("ul",{className:"block-editor-inner-blocks__template-picker-options",children:f().map((t=>(0,h.jsx)("li",{children:(0,h.jsx)(a.IconButton,{isSecondary:!0,icon:(0,h.jsx)(U,{columns:t.value}),onClick:()=>this.onChangeLayout(t.value),className:"block-editor-inner-blocks__template-picker-option",label:t.label})},t.value)))})});const A=(0,h.jsx)(a.ToggleControl,{label:(0,e.__)("Add end gutters","layout-grid"),help:k?(0,e.__)("Toggle off to remove the spacing left and right of the grid.","layout-grid"):(0,e.__)("Toggle on to add space left and right of the layout grid. ","layout-grid"),checked:k,onChange:t=>u({addGutterEnds:t})});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(W,{currentViewport:p,updateViewport:t=>this.setState({viewPort:t,inspectorDeviceType:t})}),(0,h.jsxs)(q,{className:S,onResize:this.onResize,totalColumns:C(m),layoutGrid:j,isSelected:n,children:[(0,h.jsx)("div",{className:"wpcom-overlay-grid",ref:this.overlayRef,children:(0,h.jsx)("div",{className:"wpcom-overlay-grid__inner",children:(0,s.times)(C(m)).map((t=>(0,h.jsx)("div",{className:"wpcom-overlay-grid__column"},t)))})}),(0,h.jsx)(r.InnerBlocks,{template:null,templateLock:"all",allowedBlocks:Q}),(0,h.jsxs)(r.InspectorControls,{children:[(0,h.jsxs)(a.PanelBody,{title:(0,e.__)("Layout","layout-grid"),children:[(0,h.jsx)("div",{className:"jetpack-layout-grid-columns block-editor-block-styles",children:f().map((t=>(0,h.jsxs)("div",{className:i()("block-editor-block-styles__item",{"is-active":l===t.value}),onClick:()=>this.onChangeLayout(t.value),onKeyDown:e=>{c.ENTER!==e.keyCode&&c.SPACE!==e.keyCode||(e.preventDefault(),this.onChangeLayout(t.value))},role:"button",tabIndex:"0","aria-label":t.label,children:[(0,h.jsx)("div",{className:"block-editor-block-styles__item-preview",children:(0,h.jsx)(U,{columns:t.value})}),(0,h.jsx)("div",{className:"editor-block-styles__item-label block-editor-block-styles__item-label",children:t.label})]},t.value)))}),(0,h.jsx)("p",{className:"jetpack-layout-grid-help",children:(0,e.__)("Changing the number of columns will reset your layout and could remove content.","layout-grid")})]}),(0,h.jsxs)(a.PanelBody,{title:(0,e.__)("Responsive Breakpoints","layout-grid"),children:[(0,h.jsx)("p",{className:"jetpack-layout-grid-help",children:(0,e.__)("Previewing your post will show your browser's breakpoint, not the currently selected one.","layout-grid")}),(0,h.jsx)(a.ButtonGroup,{children:y().map((t=>(0,h.jsx)(a.Button,{isPrimary:t.value===w,onClick:()=>this.updateInspectorDevice(t.value),children:t.label},t.value)))}),this.renderDeviceSettings(l,w,o)]}),(0,h.jsxs)(a.PanelBody,{title:(0,e.__)("Gutter","layout-grid"),children:[(0,h.jsx)("p",{children:(0,e.__)("Gutter size","layout-grid")}),(0,h.jsx)(a.SelectControl,{value:_,onChange:t=>u({gutterSize:t,addGutterEnds:"none"!==t&&k}),options:[{value:"none",label:(0,e.__)("No gutter","layout-grid")}].concat(v())}),"none"===_?(0,h.jsx)(a.Disabled,{children:A}):A]})]})]}),(0,h.jsx)(r.BlockControls,{children:(0,h.jsx)(r.BlockVerticalAlignmentToolbar,{onChange:d,value:x})})]})}}const tt=(0,u.compose)([(0,K.withDispatch)(((t,e,o)=>({updateAlignment(s){const{clientId:n,setAttributes:i}=e,{updateBlockAttributes:r}=t("core/block-editor"),{getBlockOrder:l}=o.select("core/block-editor");i({verticalAlignment:s}),l(n).forEach((t=>{r(t,{verticalAlignment:s})}))}}))),(0,K.withDispatch)(((e,o,s)=>({updateColumns(n,i,r){const{clientId:l}=o,{replaceBlock:a}=e("core/block-editor"),{getBlocks:c}=s.select("core/block-editor"),u=function(e,o,s){if(s>o)return[...e,...Array.from({length:s-o},(()=>(0,t.createBlock)("jetpack/layout-grid-column")))];let n=[...e],i=0;return n.reverse(),n=n.filter((t=>!(i<o-s&&0===t.innerBlocks.length&&(i++,1)))),n.slice(Math.max(0,o-s-i)).reverse()}(c(l),n,i);a(l,(0,t.createBlock)(o.name,{...o.attributes,...r,className:R(o.attributes.className)},u))}}))),(0,K.withDispatch)((t=>({setPreviewDeviceType(e){if(Z())return t("core/edit-site")?.__experimentalSetPreviewDeviceType(e);t("core/edit-post")?.__experimentalSetPreviewDeviceType(e)}}))),(0,K.withSelect)(((t,{clientId:e})=>{const{getBlockCount:o}=t("core/block-editor");return{columns:o(e)}})),(0,K.withSelect)(((t,{clientId:e})=>{const{getBlockOrder:o,getBlocksByClientId:s}=t("core/block-editor");return{columnAttributes:o(e).map((t=>s(t)[0].attributes))}})),(0,K.withSelect)((t=>Z()?{previewDeviceType:t("core/edit-site")?.__experimentalGetPreviewDeviceType()}:{previewDeviceType:t("core/edit-post")?.__experimentalGetPreviewDeviceType()}))])((function(t){return(0,h.jsx)(a.Disabled.Consumer,{children:e=>(0,h.jsx)(Y,{...t,isBlockOrPatternPreview:e})})}));class et extends l.Component{constructor(t){super(t),this.state={direction:null}}onLeftIn=()=>{this.setState({direction:"left"}),document.addEventListener("mouseup",this.onLeftOut)};onLeftOut=()=>{this.setState({direction:null}),document.removeEventListener("mouseup",this.onLeftOut)};onRightIn=()=>{this.setState({direction:"right"}),document.addEventListener("mouseup",this.onRightOut)};onRightOut=()=>{this.setState({direction:null}),document.removeEventListener("mouseup",this.onRightOut)};render(){const{className:t,hasChildBlocks:o,backgroundColor:s,setBackgroundColor:n,attributes:l,setAttributes:c,updateAlignment:u}=this.props,{padding:d,verticalAlignment:g}=l,{direction:p}=this.state,m=i()(t,s.class,{["wp-block-jetpack-layout-grid__padding-"+d]:!0,"has-background":s.color,"components-resizable-box__container":!0,[s.class]:s.class,"wp-blocks-jetpack-layout-grid__showleft":"right"===p,"wp-blocks-jetpack-layout-grid__showright":"left"===p,[`is-vertically-aligned-${g}`]:g}),f={backgroundColor:s.color};return(0,h.jsxs)("div",{className:m,style:f,children:[(0,h.jsxs)("span",{className:"wp-blocks-jetpack-layout-grid__resize-handles",children:[(0,h.jsx)("div",{className:"components-resizable-box__handle components-resizable-box__side-handle components-resizable-box__handle-right",onMouseDown:this.onRightIn,"data-resize-right":!0}),(0,h.jsx)("div",{className:"components-resizable-box__handle components-resizable-box__side-handle components-resizable-box__handle-left",onMouseDown:this.onLeftIn,"data-resize-left":!0})]}),(0,h.jsx)(r.InnerBlocks,{templateLock:!1,renderAppender:o?void 0:()=>(0,h.jsx)(r.InnerBlocks.ButtonBlockAppender,{})}),(0,h.jsxs)(r.InspectorControls,{children:[(0,h.jsx)(r.PanelColorSettings,{title:(0,e.__)("Column Color","layout-grid"),initialOpen:!0,colorSettings:[{value:s.color,onChange:n,label:(0,e.__)("Background","layout-grid")}]}),(0,h.jsxs)(a.PanelBody,{title:(0,e.__)("Column Padding","layout-grid"),children:[(0,h.jsx)("p",{children:(0,e.__)("Choose padding for this column:","layout-grid")}),(0,h.jsx)(a.SelectControl,{value:d,onChange:t=>c({padding:t}),options:[{value:"none",label:(0,e.__)("No padding","layout-grid")}].concat(v())})]})]}),(0,h.jsx)(r.BlockControls,{children:(0,h.jsx)(r.BlockVerticalAlignmentToolbar,{onChange:u,value:g})})]})}}const ot=(0,u.compose)((0,r.withColors)("backgroundColor"),(0,K.withSelect)(((t,e)=>{const{clientId:o}=e,{getBlockOrder:s}=t("core/block-editor");return{hasChildBlocks:s(o).length>0}})),(0,K.withDispatch)(((t,e,o)=>({updateAlignment(s){const{clientId:n,setAttributes:i}=e,{updateBlockAttributes:r}=t("core/block-editor"),{getBlockRootClientId:l}=o.select("core/block-editor");i({verticalAlignment:s}),r(l(n),{verticalAlignment:null})}}))))(et),st=[{attributes:{backgroundColor:{type:"string"},customBackgroundColor:{type:"string"},padding:{type:"string",default:"none"},verticalAlignment:{type:"string"}},save:({attributes:t={}})=>{const{className:e,backgroundColor:o,customBackgroundColor:s,padding:n,verticalAlignment:l}=t,a=(0,r.getColorClassName)("background-color",o),c=i()(e,{["wp-block-jetpack-layout-grid__padding-"+n]:!0,"has-background":o,[a]:a,[`is-vertically-aligned-${l}`]:l}),u={backgroundColor:a?void 0:s};return(0,h.jsx)("div",{className:c,style:u,children:(0,h.jsx)(r.InnerBlocks.Content,{})})}}];(0,t.registerBlockType)("jetpack/layout-grid",{title:(0,e.__)("Layout Grid","layout-grid"),description:(0,e.__)("Align blocks to a global grid, with support for responsive breakpoints.","layout-grid"),icon:t=>{const e={...t};return t.size&&(e.width=t.size,e.height=t.size),(0,h.jsx)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...e,children:(0,h.jsx)(a.Path,{d:"M19 6H6c-1.1 0-2 .9-2 2v9c0 1.1.9 2 2 2h13c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-7.5 11.5H6c-.3 0-.5-.2-.5-.5V8c0-.3.2-.5.5-.5h5.5v10zm4 0H13v-10h2.5v10zm4-.5c0 .3-.2.5-.5.5h-2v-10h2c.3 0 .5.2.5.5v9z"})})},category:"design",supports:{align:["full"],html:!1},example:{attributes:{columns:2},innerBlocks:[{name:"jetpack/layout-grid-column",innerBlocks:[{name:"core/paragraph",attributes:{customFontSize:32,content:(0,e.__)("<strong>Snow Patrol</strong>","layout-grid"),align:"center"}}]},{name:"jetpack/layout-grid-column",innerBlocks:[{name:"core/image",attributes:{url:"https://s.w.org/images/core/5.3/Windbuchencom.jpg"}}]}]},attributes:{gutterSize:{type:"string",default:"large"},addGutterEnds:{type:"boolean",default:!0},verticalAlignment:{type:"string"},...function(t,e){const o={};for(let s=0;s<t;s++)e.map((t=>{o[x(s,t)]={type:"number"},o[j(s,t)]={type:"number",default:0}}));return o}(4,k)},edit:tt,save:({attributes:t,innerBlocks:e})=>{const{className:o}=t,s=function(t,e={}){let o={};const s={span:A,offset:D,row:P};for(let n=0;n<k.length;n++)o={...o,...G(T(k[n],t,e),s)};return e.addGutterEnds||(o["wp-block-jetpack-layout-gutter__nowrap"]=!0),e.verticalAlignment&&"top"!==e.verticalAlignment&&(o[`are-vertically-aligned-${e.verticalAlignment}`]=!0),o}(e.length,t),n=i()(R(o),s,L(t));return(0,h.jsx)("div",{className:n,children:(0,h.jsx)(r.InnerBlocks.Content,{})})}}),(0,t.registerBlockType)("jetpack/layout-grid-column",{description:(0,e.__)("A column used inside a Layout Grid block.","layout-grid"),title:(0,e.__)("Column","layout-grid"),icon:t=>(0,h.jsx)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...t,children:(0,h.jsx)(a.Path,{d:"M19 6H6c-1.1 0-2 .9-2 2v9c0 1.1.9 2 2 2h13c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zM5.5 17V8c0-.3.2-.5.5-.5h5.5v10H6c-.3 0-.5-.2-.5-.5zm14 0c0 .3-.2.5-.5.5h-2v-10h2c.3 0 .5.2.5.5v9z"})}),category:"design",parent:["jetpack/layout-grid"],supports:{inserter:!1,reusable:!1,html:!1},attributes:{backgroundColor:{type:"string"},customBackgroundColor:{type:"string"},padding:{type:"string",default:"none"},verticalAlignment:{type:"string"}},edit:ot,save:({attributes:t={}})=>{const{className:e,backgroundColor:o,customBackgroundColor:s,padding:n,verticalAlignment:l}=t,a=(0,r.getColorClassName)("background-color",o),c=i()(e,{["wp-block-jetpack-layout-grid__padding-"+n]:!0,"has-background":o||s,[a]:a,[`is-vertically-aligned-${l}`]:l}),u={backgroundColor:a?void 0:s};return(0,h.jsx)("div",{className:c,style:u,children:(0,h.jsx)(r.InnerBlocks.Content,{})})},deprecated:st})})()})();