Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.130/page_editor/plugins/browser/components/page-structure/components/item-configuration-panels/CommonStyles",["module","exports","require","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../../../../app/config/constants/commonStylesRoles","../../../../../../app/config/constants/layoutDataItemTypes","../../../../../../app/config/index","../../../../../../app/contexts/StoreContext","../../../../../../app/utils/updateItemStyle","./FieldSet"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.CommonStyles=function({className:e,commonStylesValues:t,role:n=l.COMMON_STYLES_ROLES.styles,item:u}){const f=(0,i.useDispatch)(),d=(0,i.useSelector)((e=>e.selectedViewportSize)),S=(0,i.useSelector)((e=>e.permissions));let O=function({item:e,permissions:t,role:n,styles:a}){let s=a.filter((e=>n===l.COMMON_STYLES_ROLES.general?e.configurationRole===l.COMMON_STYLES_ROLES.general:e.configurationRole!==l.COMMON_STYLES_ROLES.general));e.type===r.LAYOUT_DATA_ITEM_TYPES.collection&&(s=s.filter((e=>e.styles.find((e=>"display"===e.name)))).map((e=>y(y({},e),{},{styles:e.styles.filter((e=>"display"===e.name))}))));e.type===r.LAYOUT_DATA_ITEM_TYPES.container||e.type===r.LAYOUT_DATA_ITEM_TYPES.row||t.UPDATE?t.UPDATE||t.UPDATE_LAYOUT_LIMITED||n!==l.COMMON_STYLES_ROLES.styles||(s=s.map((e=>y(y({},e),{},{styles:e.styles.filter((e=>g(e)))})))):s=s.map((e=>y(y({},e),{},{styles:e.styles.filter((e=>!function(e){return e.name.toLowerCase().endsWith("height")||e.name.toLowerCase().endsWith("width")}(e)))})));return s}({item:u,permissions:S,role:n,styles:o.config.commonStyles});const b=(e,t)=>{(0,c.default)({dispatch:f,itemId:u.itemId,selectedViewportSize:d,styleName:e,styleValue:t})},_=O.filter((e=>m(e))).map((e=>y(y({},e),{},{styles:e.styles.map((e=>y(y({},e),{},{disabled:(0,p.fieldIsDisabled)(u,e)})))})));_.length&&(O=O.filter((e=>!m(e))));return s.default.createElement(s.default.Fragment,null,s.default.createElement("div",{className:(0,a.default)("page-editor__common-styles",e)},_.length?s.default.createElement(p.FieldSet,{fields:[{displaySize:"",label:"",name:"",responsive:!0,type:"spacing",typeOptions:{spacingFieldSets:_}}],item:u,label:Liferay.Language.get("spacing"),languageId:o.config.defaultLanguageId,onValueSelect:b,values:t}):null,O.map(((e,n)=>s.default.createElement(p.FieldSet,{fields:e.styles,item:u,key:n,label:e.label,languageId:o.config.defaultLanguageId,onValueSelect:b,values:t})))))};var a=u(n("liferay!frontend-js-react-web$classnames")),s=(u(n("liferay!frontend-js-react-web$prop-types")),u(n("liferay!frontend-js-react-web$react"))),l=n("../../../../../../app/config/constants/commonStylesRoles"),r=n("../../../../../../app/config/constants/layoutDataItemTypes"),o=n("../../../../../../app/config/index"),i=n("../../../../../../app/contexts/StoreContext"),c=u(n("../../../../../../app/utils/updateItemStyle")),p=n("./FieldSet");function u(e){return e&&e.__esModule?e:{default:e}}function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach((function(t){d(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e){return e.styles.every((e=>g(e)))}function g(e){return e.name.startsWith("margin")||e.name.startsWith("padding")}}}));
//# sourceMappingURL=CommonStyles.js.map