Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/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({children:t,itemElement:r,style:i}){const f=(0,l.useGlobalContext)(),p=(0,c.useSelector)(s.default),d=(0,c.useSelector)((e=>e.layoutData)),[y,g]=(0,a.useState)({isInset:!1,style:{}}),w=(0,a.useMemo)((()=>f.document.getElementById("wrapper")),[f]);return(0,a.useEffect)((()=>{if(r){const t=f.document.getElementById("page-editor");let n=0,o=0,a=0,l=0,c=0,s=w.scrollTop;const i=()=>{var t,r;const i=(null===(t=Liferay.Language.direction)||void 0===t?void 0:t[null===(r=themeDisplay)||void 0===r?void 0:r.getLanguageId()])||"ltr",f=n-l+b,p=o-c+b,u=Math.floor(a-e-s)<=0,d=u?a+b:a-e;g({isInset:u,style:"rtl"===i?{right:p,top:d}:{left:f,top:d}})},p=()=>{s=w.scrollTop,i()},u=e=>{const t=e.getBoundingClientRect(),r=f.window.getComputedStyle(e);c=parseInt(r.marginRight,10)||0,l=parseInt(r.marginLeft,10)||0,n=t.left-w.offsetLeft+w.scrollLeft,o=w.getBoundingClientRect().width-(t.right-w.offsetLeft+w.scrollLeft),a=t.top-w.offsetTop+w.scrollTop},d=f.window.ResizeObserver?new f.window.ResizeObserver((e=>{e.forEach((e=>{e.target!==r&&e.target!==w&&e.target!==t||u(r)})),i()})):null;let y=null;return d?(d.observe(r),t&&d.observe(t)):y=setInterval((()=>{u(r),i()}),500),w.addEventListener("scroll",p),u(r),i(),()=>{w.removeEventListener("scroll",p),d?d.disconnect():clearInterval(y)}}}),[f,r,p,d,w]),a.default.createElement(n.ReactPortal,{container:w,wrapper:!1},a.default.createElement("div",{className:(0,o.default)("cadmin","page-editor__topper__bar","tbar",{"page-editor__topper__bar--inset":y.isInset}),style:u(u({},i),y.style)},t))};var n=r("@liferay/frontend-js-react-web"),o=f(r("liferay!frontend-js-react-web$classnames")),a=(f(r("liferay!frontend-js-react-web$prop-types")),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=i();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"),c=r("../../contexts/StoreContext"),s=f(r("../../selectors/selectLanguageId"));function i(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return i=function(){return e},e}function f(e){return e&&e.__esModule?e:{default:e}}function p(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 u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function d(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,b=2}}));
//# sourceMappingURL=TopperLabel.js.map