const isDevelopment = process.env.NODE_ENV === "development";
const isTest = process.env.NODE_ENV === "test";
const enableTestingAttributes = isDevelopment || isTest;
function createStateAttr(state) {
  return state;
}
function createPriorityAttr(priority) {
  return priority;
}
function createTestingProps(config) {
  const props = {};
  if (config.testId) {
    props["data-testid"] = enableTestingAttributes ? config.testId : void 0;
  }
  if (config.cyId) {
    props["data-cy"] = enableTestingAttributes ? config.cyId : void 0;
  }
  if (config.state) {
    props["data-state"] = config.state;
  }
  if (config.priority) {
    props["data-priority"] = config.priority;
  }
  if (config.taskId) {
    props["data-task-id"] = config.taskId;
  }
  if (config.userId) {
    props["data-user-id"] = config.userId;
  }
  return Object.fromEntries(
    Object.entries(props).filter((entry) => entry[1] !== void 0)
  );
}
function createAriaLabel(template, values) {
  return template.replace(/\{(\w+)\}/g, (match, key) => {
    return String(values[key] ?? match);
  });
}
const keyboardHelpers = {
  /**
   * Handle Enter and Space key activation
   */
  createActivationHandler: (onActivate) => {
    return (e) => {
      if (e.key === "Enter" || e.key === " ") {
        e.preventDefault();
        onActivate();
      }
    };
  },
  /**
   * Handle Escape key for closing
   */
  createEscapeHandler: (onClose) => {
    return (e) => {
      if (e.key === "Escape") {
        e.preventDefault();
        onClose();
      }
    };
  },
  /**
   * Handle arrow navigation in lists
   */
  createArrowNavigationHandler: (currentIndex, maxIndex, onIndexChange) => {
    return (e) => {
      switch (e.key) {
        case "ArrowDown":
          e.preventDefault();
          onIndexChange(currentIndex < maxIndex ? currentIndex + 1 : 0);
          break;
        case "ArrowUp":
          e.preventDefault();
          onIndexChange(currentIndex > 0 ? currentIndex - 1 : maxIndex);
          break;
      }
    };
  }
};
export {
  createAriaLabel,
  createPriorityAttr,
  createStateAttr,
  createTestingProps,
  keyboardHelpers
};
