Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.170/page_editor/app/components/topper/TopperLabel",["module","exports","require","@liferay/frontend-js-react-web","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../contexts/GlobalContext","../../contexts/StoreContext","../../selectors/selectLanguageId"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.TopperLabel=function TopperLabel({children:t,itemElement:r,style:f}){const u=(0,l.useGlobalContext)(),p=(0,i.useSelector)(c.default),d=(0,i.useSelector)((e=>e.layoutData)),[y,b]=(0,a.useState)({isInset:!1,style:{}}),g=(0,a.useMemo)((()=>u.document.getElementById("wrapper")),[u]);return(0,a.useEffect)((()=>{if(r){const t=u.document.getElementById("page-editor");let n=0,o=0,a=0,l=0,i=0,c=g.scrollTop;const updatePosition=()=>{var t,r;const f=(null===(t=Liferay.Language.direction)||void 0===t?void 0:t[null===(r=themeDisplay)||void 0===r?void 0:r.getLanguageId()])||"ltr",u=n-l+s,p=o-i+s,d=Math.floor(a-e-c)<=0,y=d?a+s:a-e;b({isInset:d,style:"rtl"===f?{right:p,top:y}:{left:u,top:y}})},handleScroll=()=>{c=g.scrollTop,updatePosition()},updateItemElementSize=e=>{const t=e.getBoundingClientRect(),r=u.window.getComputedStyle(e);i=parseInt(r.marginRight,10)||0,l=parseInt(r.marginLeft,10)||0,n=t.left-g.offsetLeft+g.scrollLeft,o=g.getBoundingClientRect().width-(t.right-g.offsetLeft+g.scrollLeft),a=t.top-g.offsetTop+g.scrollTop},f=u.window.ResizeObserver?new u.window.ResizeObserver((e=>{e.forEach((e=>{e.target!==r&&e.target!==g&&e.target!==t||updateItemElementSize(r)})),updatePosition()})):null;let p=null;return f?(f.observe(r),t&&f.observe(t)):p=setInterval((()=>{updateItemElementSize(r),updatePosition()}),500),g.addEventListener("scroll",handleScroll),updateItemElementSize(r),updatePosition(),()=>{g.removeEventListener("scroll",handleScroll),f?f.disconnect():clearInterval(p)}}}),[u,r,p,d,g]),a.default.createElement(n.ReactPortal,{container:g,wrapper:!1},a.default.createElement("div",{className:(0,o.default)("cadmin","page-editor__topper__bar","tbar",{"page-editor__topper__bar--inset":y.isInset}),style:_objectSpread(_objectSpread({},f),y.style)},t))};var n=r("@liferay/frontend-js-react-web"),o=_interopRequireDefault(r("liferay!frontend-js-react-web$classnames")),a=(_interopRequireDefault(r("liferay!frontend-js-react-web$prop-types")),function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=n?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react"))),l=r("../../contexts/GlobalContext"),i=r("../../contexts/StoreContext"),c=_interopRequireDefault(r("../../selectors/selectLanguageId"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const e=24,s=2}}));
//# sourceMappingURL=TopperLabel.js.map