text: /**
   * @license
   * Copyright Akveo. All Rights Reserved.
   * Licensed under the MIT License. See License.txt in the project root for license information.
   */
  import React from 'react';
  import { View, StyleSheet, } from 'react-native';
  import { ModalResolver, } from './modalResolver.component';
  import { ModalService, } from './modal.service';
  export class ModalPanel extends React.Component {
      constructor() {
          super(...arguments);
          this.state = {
              components: new Map(),
          };
          this.hide = (identifier) => {
              const components = this.state.components;
              components.delete(identifier);
              this.setState({ components });
              return '';
          };
          this.generateUniqueComponentKey = () => {
              return Math.random().toString(36).substring(2);
          };
          this.areThereAnyComponents = () => {
              return this.state.components && this.state.components.size !== 0;
          };
          this.renderModal = (config, index) => {
              return (<ModalResolver {...config.element.props} visible={true} key={index} allowBackdrop={config.allowBackdrop} onBackdropPress={config.onBackdropPress}>
          {config.element}
        </ModalResolver>);
          };
          this.renderModals = () => {
              return Array.from(this.state.components.values()).map(this.renderModal);
          };
      }
      componentDidMount() {
          ModalService.mount(this);
      }
      componentWillUnmount() {
          ModalService.unmount();
      }
      show(element, config) {
          const key = this.generateUniqueComponentKey();
          const components = this.state.components
              .set(key, Object.assign(Object.assign({}, config), { element }));
          this.setState({ components });
          return key;
      }
      update(identifier, children) {
          const panelChild = this.state.components.get(identifier);
          const childElement = panelChild.element;
          panelChild.element = React.cloneElement(childElement, {
              children: children,
          });
          const components = this.state.components;
          components.delete(identifier);
          components.set(identifier, panelChild);
          this.setState({ components });
      }
      render() {
          return (<View style={styles.container}>
          {this.props.children}
          {this.areThereAnyComponents() && this.renderModals()}
        </View>);
      }
  }
  const styles = StyleSheet.create({
      container: {
          flex: 1,
      },
  });
  //# sourceMappingURL=modalPanel.component.js.map