import { h } from '@stencil/core';
import { StringUtils } from '@sankhyalabs/core';
export class ContinuousInsertUtils {
  constructor(snkApplication, resourceID, configName) {
    this.snkApplication = snkApplication;
    this.keyConfigEnableContinuousInsert = `${resourceID}enableContinuousInsert${configName ? configName : ''}`;
  }
  handleSaveConfig(enableContinuousInsert) {
    return this.snkApplication.saveConfig(this.keyConfigEnableContinuousInsert, enableContinuousInsert);
  }
  getConfig() {
    return this.snkApplication.getConfig(this.keyConfigEnableContinuousInsert).then(value => {
      if (value) {
        return value == "true" ? true : false;
      }
      return false;
    }).catch(() => {
      return false;
    });
  }
  getMessage(key, params) {
    var _a, _b;
    return (_b = (_a = this.snkApplication) === null || _a === void 0 ? void 0 : _a.messagesBuilder) === null || _b === void 0 ? void 0 : _b.getMessage(key, params);
  }
  actionContinuousInsert(enableContinuousInsert, handleEnableContinuousInsert) {
    return {
      value: StringUtils.generateUUID(),
      label: enableContinuousInsert ? this.getMessage('continuousInsertUtils.actions.disable') : this.getMessage('continuousInsertUtils.actions.enable'),
      enabled: true,
      itemBuilder: () => {
        return (h("div", { class: "ez-dropdown__item-wrapper", onClick: handleEnableContinuousInsert }, h("span", { class: "ez-dropdown__item-label" }, enableContinuousInsert ? this.getMessage('continuousInsertUtils.actions.disable') : this.getMessage('continuousInsertUtils.actions.enable'))));
      },
    };
  }
}
