Liferay.Loader.define("data-engine-js-components-web@1.0.107/js/utils/ReactComponentAdapter.es",["module","exports","require","frontend-js-metal-web$metal-incremental-dom","frontend-js-metal-web$metal-jsx","frontend-js-metal-web$metal-state","liferay!frontend-js-react-web$react","liferay!frontend-js-react-web$react-dom","./Observer.es"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.getConnectedReactComponentAdapter=getConnectedReactComponentAdapter,t.default=void 0;var n=_interopRequireDefault(r("frontend-js-metal-web$metal-incremental-dom")),o=_interopRequireDefault(r("frontend-js-metal-web$metal-jsx")),a=r("frontend-js-metal-web$metal-state"),c=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")),i=_interopRequireDefault(r("liferay!frontend-js-react-web$react-dom")),s=_interopRequireDefault(r("./Observer.es"));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 _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,o=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}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=["children","events","ref","visible"],u=["displayErrors"];function getConnectedReactComponentAdapter(t){class ReactComponentAdapter extends o.default{constructor(t,r){const n={};Object.keys(t).concat(u).forEach((r=>{e.includes(r)||(n[r]=a.Config.any().value(t[r]))})),super(t,r);o.default.DATA_MANAGER.getManagerData(this).props_.configState(_objectSpread(_objectSpread({},o.default.DATA),n))}created(){this.observer=new s.default,this.reactComponentRef=c.default.createRef()}disposed(){this.instance_&&(i.default.unmountComponentAtNode(this.instance_),this.instance_=null)}willReceiveProps(t){if(delete t.events,delete t.children,t&&Object.keys(t).length){const r={};Object.keys(t).forEach((n=>{e.includes(n)||(r[n]=t[n].newVal)})),this.observer.dispatch(r)}}shouldUpdate(){return!1}syncVisible(e){this.observer.dispatch({visible:e})}render(){const e=this.props,{events:r,ref:n,store:o}=e,a=_objectWithoutProperties(e,["events","ref","store"]);IncrementalDOM.elementOpen("div",n,[],"class","react-component-adapter");const s=IncrementalDOM.currentElement();IncrementalDOM.skip(),IncrementalDOM.elementClose("div"),i.default.render(c.default.createElement(ObserverSubscribe,{observer:this.observer},c.default.createElement(t,_extends({},a,r,o,{instance:this,ref:this.reactComponentRef}))),s),this.instance_=s}}return ReactComponentAdapter.RENDERER=n.default,ReactComponentAdapter}const ObserverSubscribe=({children:e,observer:t})=>{const[r,n]=(0,c.useState)({});return(0,c.useEffect)((()=>{const change=e=>n(_objectSpread(_objectSpread({},r),e));return t.subscribe(change),()=>{t.unsubscribe(change)}}),[r,n,t]),c.default.cloneElement(e,_objectSpread(_objectSpread({},e.props),r))};var l=getConnectedReactComponentAdapter;t.default=l}}));
//# sourceMappingURL=ReactComponentAdapter.es.js.map