Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/page_editor/app/components/DragPreview",["module","exports","require","@frontend-taglib-clay$clayui/icon","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react","liferay!frontend-js-react-web$react-dnd","../config/constants/itemActivationOrigins","../config/constants/layoutDataItemTypes","../contexts/StoreContext","../selectors/selectLanguageId","../utils/getWidget"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var t;const n=(0,i.useRef)(),d=(0,s.useSelector)((e=>e.fragmentEntryLinks)),g=(0,s.useSelector)((e=>e.fragments)),y=(0,s.useSelector)(u.default),m=(0,s.useSelector)((e=>e.layoutData)),p=(0,s.useSelector)((e=>e.widgets)),{currentOffset:v,isDragging:_,item:w}=(0,o.useDragLayer)((e=>({currentOffset:e.getClientOffset(),isDragging:e.isDragging(),item:e.getItem()})));if(!_||!(null==w?void 0:w.id))return null;const b=m.items[null==w?void 0:w.id];let O;(null==w?void 0:w.icon)?O=w.icon:b&&(O=function(e,t,n,r){var a;const i=n.flatMap((e=>e.fragmentEntries));if(e.type===c.LAYOUT_DATA_ITEM_TYPES.fragment){var o;const n=t[e.config.fragmentEntryLinkId];if(n.portletId){return(0,f.default)(r,n.portletId).instanceable?"square-hole-multi":"square-hole"}return null===(o=i.find((e=>e.fragmentEntryKey===n.fragmentEntryKey)))||void 0===o?void 0:o.icon}return null===(a=i.find((t=>t.type===e.type)))||void 0===a?void 0:a.icon}(b,d,g,p));return i.default.createElement("div",{className:"cadmin"},i.default.createElement("div",{className:"page-editor__drag-preview"},i.default.createElement("div",{className:(0,a.default)("page-editor__drag-preview__content",{"page-editor__drag-preview__content__treeview":(null==w?void 0:w.origin)===l.ITEM_ACTIVATION_ORIGINS.sidebar}),dir:Liferay.Language.direction[null===(t=themeDisplay)||void 0===t?void 0:t.getLanguageId()],ref:n,style:e(v,n,"rtl"===Liferay.Language.direction[y])},O&&i.default.createElement("div",{className:"align-items-center d-flex h-100"},i.default.createElement(r.default,{className:"mt-0",symbol:O})),i.default.createElement("span",{className:(0,a.default)("text-truncate",{"ml-3":O})},(null==w?void 0:w.name)?w.name:Liferay.Language.get("element")))))};var r=g(n("@frontend-taglib-clay$clayui/icon")),a=g(n("liferay!frontend-js-react-web$classnames")),i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=d();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var i=r?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}n.default=e,t&&t.set(e,n);return n}(n("liferay!frontend-js-react-web$react")),o=n("liferay!frontend-js-react-web$react-dnd"),l=n("../config/constants/itemActivationOrigins"),c=n("../config/constants/layoutDataItemTypes"),s=n("../contexts/StoreContext"),u=g(n("../selectors/selectLanguageId")),f=g(n("../utils/getWidget"));function d(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return d=function(){return e},e}function g(e){return e&&e.__esModule?e:{default:e}}const e=(e,t,n)=>{if(!e||!t.current)return{display:"none"};const r=t.current.getBoundingClientRect(),a=n?e.x+.5*r.width-window.innerWidth:e.x-.5*r.width,i=e.y-.5*r.height,o="translate(".concat(a,"px, ").concat(i,"px)");return{WebkitTransform:o,transform:o}}}}));
//# sourceMappingURL=DragPreview.js.map