import { Action as DUAction, KeyboardManager, StringUtils } from '@sankhyalabs/core';
import { Host, forceUpdate, h } from '@stencil/core';
import { SnkFormConfigManager } from '../../../snk-form-config/SnkFormConfigManager';
import { buildFormMetadata } from "@sankhyalabs/ezui/dist/collection/utils/form";
import { PresentationMode } from '../../../../lib';
import { TaskbarElement } from '../../../snk-taskbar/elements/taskbar-elements';
import { VIEW_MODE } from '../../../../lib/utils/constants';
import { SnkGuidesViewer } from '../snk-guides-viewer';
import { SnkMessageBuilder } from '../../../../lib/message/SnkMessageBuilder';
import { GuideBuilder } from '../GuideBuilder';
import { buildFieldSearch, SHORTCUT_SEARCH_FIELD } from '@sankhyalabs/ezui/dist/collection/utils';
export class SnkDetailView {
  constructor() {
    this._disabledButtons = undefined;
    this._currentView = undefined;
    this.attachmentRegisterKey = undefined;
    this._fieldToGetFocus = undefined;
    this._hasToCreateFieldSearch = true;
    this.formConfigManager = undefined;
    this.dataUnitName = undefined;
    this.resourceID = undefined;
    this.guideItemPath = undefined;
    this.entityName = undefined;
    this.label = undefined;
    this.dataUnit = undefined;
    this.selectedForm = undefined;
    this.dataState = undefined;
    this.messagesBuilder = undefined;
    this.branchGuide = undefined;
    this.canEdit = true;
    this.taskbarCustomContainerId = undefined;
    this.customEditors = undefined;
    this.customRenders = undefined;
    this.presentationMode = PresentationMode.SECONDARY;
  }
  observeDataUnit(newDataUnit, oldDataUnit) {
    newDataUnit === null || newDataUnit === void 0 ? void 0 : newDataUnit.subscribe(this.dataUnitActionHandler.bind(this));
    oldDataUnit === null || oldDataUnit === void 0 ? void 0 : oldDataUnit.unsubscribe(this.dataUnitActionHandler);
  }
  observerDataState(newValue, oldValue) {
    const openInsertion = !(oldValue === null || oldValue === void 0 ? void 0 : oldValue.insertionMode) && (newValue === null || newValue === void 0 ? void 0 : newValue.insertionMode);
    const closeInsertion = (oldValue === null || oldValue === void 0 ? void 0 : oldValue.insertionMode) && !(newValue === null || newValue === void 0 ? void 0 : newValue.insertionMode);
    if (openInsertion || closeInsertion) {
      this.loadMetadata();
    }
    if (this._formMetadata == undefined) {
      return;
    }
    const newRecord = newValue === null || newValue === void 0 ? void 0 : newValue.selectedRecord;
    const oldRecord = oldValue === null || oldValue === void 0 ? void 0 : oldValue.selectedRecord;
    if ((newRecord === null || newRecord === void 0 ? void 0 : newRecord.__record__id__) !== (oldRecord === null || oldRecord === void 0 ? void 0 : oldRecord.__record__id__)) {
      this.snkDetailGuidesChange.emit(new GuideBuilder(this.branchGuide, this._formMetadata, this.dataUnit, this.messagesBuilder));
    }
    if (openInsertion) {
      setTimeout(() => {
        //FIXME: A necessidade de usar esse timeout é por causa da renderização
        //do guide navigator... se esse evento subir antes do guidenavigator ter
        //um item com esse id, ele fica sem seleção. Acredito que poderíamos
        //ajustar o componente para manter o item selecionado e então remover
        //esse timeout.
        this.changeViewMode(VIEW_MODE.FORM);
      }, 0);
    }
    if (closeInsertion) {
      this.changeViewMode(VIEW_MODE.GRID);
    }
    const disabledButtons = [];
    if (!this.dataState.hasPrevious) {
      disabledButtons.push(TaskbarElement.PREVIOUS);
    }
    if (!this.dataState.hasNext) {
      disabledButtons.push(TaskbarElement.NEXT);
    }
    if (this.dataState.insertionMode) {
      disabledButtons.push(TaskbarElement.INSERT);
    }
    this._disabledButtons = disabledButtons;
  }
  /**
  * Muda o modo de visualização do componente entre VIEW_MODE.GRID e VIEW_MODE.FORM
  * @param mode - Novo modo que o componente deve ser apresentado.
  */
  async changeViewMode(mode) {
    this.emitSwitchEvent(mode);
  }
  /**
   * Abre o configurador de grid.
   */
  async configGrid() {
    if (this._snkGrid) {
      this._snkGrid.showConfig();
    }
  }
  async showUp() {
    if (this._snkFormView) {
      this._snkFormView.showUp();
    }
    if (this._snkGrid) {
      this._snkGrid.scrollIntoView({ behavior: "smooth", block: "start" });
    }
  }
  /**
   * Registra um editor customizado para campos da grade e formulário.
   */
  async addCustomEditor(fieldName, customEditor) {
    var _a;
    const detailContext = this.normalizeBranchGuideId((_a = this.branchGuide) === null || _a === void 0 ? void 0 : _a.id);
    this._snkGrid.addCustomEditor(fieldName, customEditor, detailContext);
    this._snkFormView.addCustomEditor(fieldName, customEditor, detailContext);
  }
  async observerPropsCustomEditor(newValue) {
    for (const fieldName in newValue) {
      await this.addCustomEditor(fieldName, newValue[fieldName]);
    }
  }
  /**
   * Registra um render customizado para colunas da grid.
   */
  async addGridCustomRender(fieldName, customRender) {
    var _a;
    const detailContext = this.normalizeBranchGuideId((_a = this.branchGuide) === null || _a === void 0 ? void 0 : _a.id);
    await this._snkGrid.addGridCustomRender(fieldName, customRender, detailContext);
  }
  onContentCardChanged(evt) {
    SnkGuidesViewer.updateContentCard(evt.detail.formName, evt.detail.cardConfig, evt.detail.propertyChanged, this.formConfigManager).then(() => forceUpdate(this));
    evt.stopPropagation();
  }
  async observeCustomRenders(newValue) {
    for (const field in newValue) {
      const customRender = newValue[field];
      await this.addGridCustomRender(field, customRender);
    }
  }
  updateLabel() {
    const guideItemPathSize = this.guideItemPath ? this.guideItemPath.length : 0;
    if (guideItemPathSize > 0) {
      const labels = guideItemPathSize > 0 ? this.guideItemPath.map(item => item.label) : undefined;
      this.label = labels.pop();
      this._levelPath = labels.length > 0 ? labels.join(" / ") : undefined;
    }
    else {
      this.label = "";
      this._levelPath = undefined;
    }
  }
  getFormGuideId(formName) {
    var _a;
    if (!formName) {
      const currentRecord = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.selectedRecord;
      if (currentRecord == undefined) {
        return;
      }
      const forms = Array.from(this._formMetadata.getAllSheets().keys());
      if (!forms || forms.length == 0) {
        return;
      }
      formName = forms[0];
    }
    return `${this.stripFormPattern(this.branchGuide.id)}__FORM:${formName}`;
  }
  stripFormPattern(guideId) {
    return guideId.replace(SnkDetailView.REGEX_FORM_ID, "");
  }
  loadMetadata() {
    if (!this.dataUnit) {
      return;
    }
    if (!this.formConfigManager.isLoaded) {
      return;
    }
    const formConfig = this.formConfigManager.getConfig(this.dataUnit);
    //this._cardsState = formConfig?.cardsState;
    this._formMetadata = buildFormMetadata(formConfig == undefined || formConfig.fields.length === 0 ? undefined : formConfig, this.dataUnit, true);
  }
  dataUnitReadyHandler(evt) {
    this.dataUnit = evt.detail;
    this.loadMetadata();
  }
  updateViewStack(viewStack) {
    var _a, _b;
    this._viewStack = viewStack;
    this._currentView = this.selectedForm ? 1 : 0;
    (_b = (_a = this._viewStack) === null || _a === void 0 ? void 0 : _a.show) === null || _b === void 0 ? void 0 : _b.call(_a, this._currentView);
  }
  getFormFields() {
    if (this.selectedForm && this._formMetadata) {
      return this._formMetadata.getSheet(this.selectedForm).fields;
    }
    return [];
  }
  emitSwitchEvent(mode) {
    const guideId = mode === VIEW_MODE.GRID ? this.stripFormPattern(this.branchGuide.id) : this.getFormGuideId();
    if (guideId) {
      this.snkSwitchGuide.emit(guideId);
    }
  }
  handleAttachBack() {
    this._viewStack.show(VIEW_MODE.GRID);
  }
  executeActionHandler(evt) {
    if (evt.detail === TaskbarElement.GRID_MODE) {
      this.emitSwitchEvent(VIEW_MODE.GRID);
      evt.stopPropagation();
    }
    if (evt.detail === TaskbarElement.FORM_MODE || evt.detail === TaskbarElement.UPDATE) {
      this.emitSwitchEvent(VIEW_MODE.FORM);
      evt.stopPropagation();
    }
    if (evt.detail === TaskbarElement.ATTACH) {
      this._viewStack.show(VIEW_MODE.ATTACHMENT);
      evt.stopPropagation();
    }
  }
  async getAttachmentRegisterKey() {
    if (!this._snkDataUnit)
      return;
    const recordCriteria = await this._snkDataUnit.getSelectedRecordsIDsInfo();
    const joinedPrimaryKeys = recordCriteria.map(({ value }) => value).join('_');
    return joinedPrimaryKeys;
  }
  async handleDataStateChange({ detail: dataState }) {
    this.dataState = dataState;
    if (dataState.selectedRecord !== undefined && this._snkDataUnit) {
      this.attachmentRegisterKey = await this.getAttachmentRegisterKey();
    }
  }
  componentWillLoad() {
    this._configName = `dynaform.${this.entityName}`;
    this.formConfigManager = new SnkFormConfigManager(this._configName, this.resourceID, () => this.loadMetadata(), this.dataUnit);
    this.formConfigManager.loadConfig();
    if (this.messagesBuilder == undefined) {
      this.messagesBuilder = new SnkMessageBuilder(this.entityName);
    }
  }
  async componentDidLoad() {
    await this.observerPropsCustomEditor(this.customEditors);
    await this.observeCustomRenders(this.customRenders);
    this.initKeyboardManager();
  }
  disconnectedCallback() {
    var _a;
    (_a = this._keyboardManager) === null || _a === void 0 ? void 0 : _a.unbindAllShortcutKeys();
  }
  async dataUnitActionHandler(action) {
    if (action.type === DUAction.FIELD_INVALIDATED) {
      this.addErrorBadgeToBranchGuide();
    }
  }
  addErrorBadgeToBranchGuide() {
    this.branchGuide = Object.assign(Object.assign({}, this.branchGuide), { badge: 'error' });
    this.snkDetailGuidesChange.emit(new GuideBuilder(this.branchGuide, this._formMetadata, this.dataUnit, this.messagesBuilder));
  }
  normalizeBranchGuideId(id) {
    return id === null || id === void 0 ? void 0 : id.replace(/child\[(.*?)\]/g, '$1').replace(/::/g, '>');
  }
  getSettingsListForm() {
    const hardList = [{
        value: StringUtils.generateUUID(),
        label: this.messagesBuilder.getMessage("snkCrud.findColumn", undefined),
        disableCloseOnSelect: true,
        eagerInitialize: true,
        itemBuilder: (_, item) => this.getFieldsSearch(item)
      }];
    return hardList;
  }
  getFieldsSearch(item) {
    if (this._fieldSearch == undefined || this._hasToCreateFieldSearch) {
      this._hasToCreateFieldSearch = false;
      this._fieldSearch = buildFieldSearch(item, ({ argument }) => this.fieldsOptionLoader(argument), (option) => this.onSelectField(option));
    }
    return this._fieldSearch;
  }
  fieldsOptionLoader(argument) {
    const searchTerm = argument === null || argument === void 0 ? void 0 : argument.toLowerCase();
    const allFields = this.getFormFields().map(field => { var _a; return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(field.name); });
    const filteredFields = allFields.filter(field => {
      var _a, _b;
      return ((_a = field.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchTerm)) ||
        ((_b = field.label) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchTerm));
    });
    const options = filteredFields.map(field => ({ value: field.name, label: field.label }));
    return Promise.resolve(options);
  }
  onSelectField(option) {
    if (option == undefined) {
      return;
    }
    this._fieldToGetFocus = option.value;
  }
  clearFieldToFocusHandler() {
    this._fieldToGetFocus = undefined;
  }
  async initKeyboardManager() {
    this._keyboardManager = new KeyboardManager({ propagate: false, element: this._element });
    this._keyboardManager.bind(SHORTCUT_SEARCH_FIELD, async () => {
      await this._snkFormView.showSearchField();
    }, { description: this.messagesBuilder.getMessage("snkSimpleCrud.findFields"), element: this._element });
  }
  render() {
    this.updateLabel();
    //const cardConfig: IFormCardConfig = this._cardsState?.get(this.selectedForm);
    return (h(Host, null, h("snk-data-unit", { ref: (el) => this._snkDataUnit = el, dataUnitName: `${this.dataUnitName}`, onDataUnitReady: evt => this.dataUnitReadyHandler(evt), entityName: this.entityName, onDataStateChange: this.handleDataStateChange.bind(this), ignoreSaveMessage: this._currentView === VIEW_MODE.GRID, messagesBuilder: this.messagesBuilder, configName: this._configName }, h("ez-view-stack", { ref: (ref) => this.updateViewStack(ref) }, h("stack-item", null, h("div", { class: "ez-box ez-box--shadow grid-container" }, h("div", { class: "ez-title--primary ez-size-width--full ez-padding--large detail-header" }, h("div", { class: "ez-flex ez-text ez-text--bold ez-flex--justify-start ez-flex--align-items-center" }, this._levelPath ? h("span", { class: "level-path" }, this._levelPath + " /") : undefined, this.label)), h("snk-grid", { class: "ez-size-width--full", ref: (ref) => this._snkGrid = ref, configName: this._configName, messagesBuilder: this.messagesBuilder, onGridDoubleClick: () => this.emitSwitchEvent(VIEW_MODE.FORM), onActionClick: (evt) => this.executeActionHandler(evt), presentationMode: this.presentationMode, canEdit: this.canEdit, isDetail: true, taskbarCustomContainerId: this.taskbarCustomContainerId, gridHeaderCustomSlotId: "DETAIL_GRID_HEADER_CUSTOM_ELEMENTS", topTaskbarCustomSlotId: "DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS", outlineMode: false }))), h("stack-item", null, h("snk-form-view", { ref: (ref) => this._snkFormView = ref, canExpand: false, canFix: false, name: this.selectedForm, formMetadata: this._formMetadata, dataUnit: this.dataUnit, fields: this.getFormFields(), fieldToFocus: this._fieldToGetFocus, label: this.label, levelPath: this._levelPath, onFormItemsReady: ({ detail: formItems }) => this.formItemsReady.emit(formItems), onSnkRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this), fieldSearch: this._fieldSearch }, h("snk-taskbar", { key: "guideViewerTaskbar", class: "form-taskbar", "data-element-id": "guideViewer", configName: this._configName, messagesBuilder: this.messagesBuilder, disabledButtons: this._disabledButtons, buttons: "INSERT,PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,ACTIONS_BUTTON,DIVIDER,GRID_MODE,CONFIGURATOR", primaryButton: "INSERT", presentationMode: this.presentationMode, onActionClick: evt => this.executeActionHandler(evt), dataUnit: this.dataUnit, resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: "DETAIL_TASKBAR_CUSTOM_ELEMENTS", actionsSettingsList: this.getSettingsListForm() }, h("slot", { name: "DETAIL_TASKBAR_CUSTOM_ELEMENTS" })))), h("stack-item", null, h("snk-attach", { registerKey: this.attachmentRegisterKey, messagesBuilder: this.messagesBuilder, entityName: this.entityName, onBack: this.handleAttachBack.bind(this) }))))));
  }
  static get is() { return "snk-detail-view"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() {
    return {
      "$": ["snk-detail-view.css"]
    };
  }
  static get styleUrls() {
    return {
      "$": ["snk-detail-view.css"]
    };
  }
  static get properties() {
    return {
      "formConfigManager": {
        "type": "unknown",
        "mutable": true,
        "complexType": {
          "original": "SnkFormConfigManager",
          "resolved": "SnkFormConfigManager",
          "references": {
            "SnkFormConfigManager": {
              "location": "import",
              "path": "../../../snk-form-config/SnkFormConfigManager"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Gerenciador de configura\u00E7\u00E3o do formul\u00E1rio."
        }
      },
      "dataUnitName": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Determina todo o caminho desde o pai at\u00E9 chegar neste n\u00EDvel"
        },
        "attribute": "data-unit-name",
        "reflect": false
      },
      "resourceID": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Identificador de recursos como configura\u00E7\u00F5es e acesso."
        },
        "attribute": "resource-i-d",
        "reflect": false
      },
      "guideItemPath": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "Array<IGuideItem>",
          "resolved": "IGuideItem[]",
          "references": {
            "Array": {
              "location": "global"
            },
            "IGuideItem": {
              "location": "import",
              "path": "@sankhyalabs/ezui/dist/types/components/ez-guide-navigator/interfaces"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Caminho do identificador da guia vinculada."
        }
      },
      "entityName": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Nome da entidade detail."
        },
        "attribute": "entity-name",
        "reflect": false
      },
      "label": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Descri\u00E7\u00E3o amig\u00E1vel do cadastro detalhe."
        },
        "attribute": "label",
        "reflect": false
      },
      "dataUnit": {
        "type": "unknown",
        "mutable": true,
        "complexType": {
          "original": "DataUnit",
          "resolved": "DataUnit",
          "references": {
            "DataUnit": {
              "location": "import",
              "path": "@sankhyalabs/core"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Inst\u00E2ncia do DataUnit detail."
        }
      },
      "selectedForm": {
        "type": "string",
        "mutable": true,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Representa o formul\u00E1rio selecionado."
        },
        "attribute": "selected-form",
        "reflect": false
      },
      "dataState": {
        "type": "unknown",
        "mutable": true,
        "complexType": {
          "original": "DataState",
          "resolved": "DataState",
          "references": {
            "DataState": {
              "location": "import",
              "path": "../../../snk-data-unit/snk-data-unit"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Representa o estado do dataUnit detail."
        }
      },
      "messagesBuilder": {
        "type": "unknown",
        "mutable": true,
        "complexType": {
          "original": "SnkMessageBuilder",
          "resolved": "SnkMessageBuilder",
          "references": {
            "SnkMessageBuilder": {
              "location": "import",
              "path": "../../../../lib/message/SnkMessageBuilder"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        }
      },
      "branchGuide": {
        "type": "unknown",
        "mutable": true,
        "complexType": {
          "original": "IGuideItem",
          "resolved": "IGuideItem",
          "references": {
            "IGuideItem": {
              "location": "import",
              "path": "@sankhyalabs/ezui/dist/types/components/ez-guide-navigator/interfaces"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        }
      },
      "canEdit": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define se a edi\u00E7\u00E3o est\u00E1 habilitada na grid."
        },
        "attribute": "can-edit",
        "reflect": false,
        "defaultValue": "true"
      },
      "taskbarCustomContainerId": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define o identificador do container de elementos customizados da Taskbar."
        },
        "attribute": "taskbar-custom-container-id",
        "reflect": false
      },
      "customEditors": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "PropsCustomEditor",
          "resolved": "PropsCustomEditor",
          "references": {
            "PropsCustomEditor": {
              "location": "import",
              "path": "../../interfaces/PropsCustomEditor"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Registra um editor customizado para campos da grade e formul\u00E1rio."
        }
      },
      "customRenders": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "PropsCustomRender",
          "resolved": "PropsCustomRender",
          "references": {
            "PropsCustomRender": {
              "location": "import",
              "path": "../../interfaces/PropsCustomRender"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Render customizados da grade."
        }
      },
      "presentationMode": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "PresentationMode",
          "resolved": "PresentationMode.PRIMARY | PresentationMode.SECONDARY | PresentationMode.SINGLE_TASKBAR",
          "references": {
            "PresentationMode": {
              "location": "import",
              "path": "../../../../lib"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Altera o modo de apresenta\u00E7\u00E3o dos bot\u00F5es do snk-taskbar."
        },
        "attribute": "presentation-mode",
        "reflect": false,
        "defaultValue": "PresentationMode.SECONDARY"
      }
    };
  }
  static get states() {
    return {
      "_disabledButtons": {},
      "_currentView": {},
      "attachmentRegisterKey": {},
      "_fieldToGetFocus": {},
      "_hasToCreateFieldSearch": {}
    };
  }
  static get events() {
    return [{
        "method": "snkDetailGuidesChange",
        "name": "snkDetailGuidesChange",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": "Emitido quando h\u00E1 necessidade de atualizar a estrutura de guias."
        },
        "complexType": {
          "original": "GuideBuilder",
          "resolved": "GuideBuilder",
          "references": {
            "GuideBuilder": {
              "location": "import",
              "path": "../GuideBuilder"
            }
          }
        }
      }, {
        "method": "snkSwitchGuide",
        "name": "snkSwitchGuide",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": "Emitido quando h\u00E1 necessidade de comutar entre grid e form."
        },
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        }
      }, {
        "method": "formItemsReady",
        "name": "formItemsReady",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": "Respons\u00E1vel por notificar quando ocorrer a renderiza\u00E7\u00E3o de itens do formul\u00E1rio."
        },
        "complexType": {
          "original": "Array<HTMLElement>",
          "resolved": "HTMLElement[]",
          "references": {
            "Array": {
              "location": "global"
            },
            "HTMLElement": {
              "location": "global"
            }
          }
        }
      }];
  }
  static get methods() {
    return {
      "changeViewMode": {
        "complexType": {
          "signature": "(mode: VIEW_MODE) => Promise<void>",
          "parameters": [{
              "tags": [{
                  "name": "param",
                  "text": "mode - Novo modo que o componente deve ser apresentado."
                }],
              "text": "- Novo modo que o componente deve ser apresentado."
            }],
          "references": {
            "Promise": {
              "location": "global"
            },
            "VIEW_MODE": {
              "location": "import",
              "path": "../../../../lib/utils/constants"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Muda o modo de visualiza\u00E7\u00E3o do componente entre VIEW_MODE.GRID e VIEW_MODE.FORM",
          "tags": [{
              "name": "param",
              "text": "mode - Novo modo que o componente deve ser apresentado."
            }]
        }
      },
      "configGrid": {
        "complexType": {
          "signature": "() => Promise<void>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Abre o configurador de grid.",
          "tags": []
        }
      },
      "showUp": {
        "complexType": {
          "signature": "() => Promise<void>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "",
          "tags": []
        }
      },
      "addCustomEditor": {
        "complexType": {
          "signature": "(fieldName: string, customEditor: ICustomEditor) => Promise<void>",
          "parameters": [{
              "tags": [],
              "text": ""
            }, {
              "tags": [],
              "text": ""
            }],
          "references": {
            "Promise": {
              "location": "global"
            },
            "ICustomEditor": {
              "location": "import",
              "path": "@sankhyalabs/ezui/dist/types/utils"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
          "tags": []
        }
      },
      "addGridCustomRender": {
        "complexType": {
          "signature": "(fieldName: string, customRender: ICustomRender) => Promise<void>",
          "parameters": [{
              "tags": [],
              "text": ""
            }, {
              "tags": [],
              "text": ""
            }],
          "references": {
            "Promise": {
              "location": "global"
            },
            "ICustomRender": {
              "location": "import",
              "path": "@sankhyalabs/ezui/dist/types/utils"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Registra um render customizado para colunas da grid.",
          "tags": []
        }
      }
    };
  }
  static get elementRef() { return "_element"; }
  static get watchers() {
    return [{
        "propName": "dataUnit",
        "methodName": "observeDataUnit"
      }, {
        "propName": "dataState",
        "methodName": "observerDataState"
      }, {
        "propName": "customEditors",
        "methodName": "observerPropsCustomEditor"
      }, {
        "propName": "customRenders",
        "methodName": "observeCustomRenders"
      }];
  }
  static get listeners() {
    return [{
        "name": "snkContentCardChanged",
        "method": "onContentCardChanged",
        "target": undefined,
        "capture": false,
        "passive": false
      }];
  }
}
SnkDetailView.REGEX_FORM_ID = /__FORM:[^:]+/g;
