import { jsxs, jsx } from 'react/jsx-runtime';
import { c as cx } from './index-De1g9FRV.js';
import * as React from 'react';
import { forwardRef } from 'react';
import { S as SvgCheck } from './check-Cf67OWrZ.js';
import { C as Card } from './Card-DSFuXUGk.js';
import { T as Text } from './Text-J5YtSSXY.js';
import { I as Icon } from './Icon-BMMbp40n.js';
import { B as Button } from './Button-Bnt8XUI7.js';
import { u as useLayoutPropsUtil } from './useLayoutPropsUtil-CB_zHDbW.js';

import './EditCard.css';const container = "_container_1u530_23";
const header = "_header_1u530_30";
const heading = "_heading_1u530_38";
const content = "_content_1u530_42";
const footer = "_footer_1u530_49";
const indicator = "_indicator_1u530_55";
const styles = {
	"edit-card": "_edit-card_1u530_1",
	"edit-card-in-progress": "_edit-card-in-progress_1u530_8",
	"edit-card-complete": "_edit-card-complete_1u530_13",
	"edit-card-error": "_edit-card-error_1u530_18",
	container: container,
	header: header,
	heading: heading,
	content: content,
	footer: footer,
	indicator: indicator,
	"indicator-in-progress": "_indicator-in-progress_1u530_78",
	"indicator-complete": "_indicator-complete_1u530_84",
	"indicator-error": "_indicator-error_1u530_91"
};

const SvgPriorityHigh = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("circle", { cx: 12, cy: 19, r: 2 }), /* @__PURE__ */ React.createElement("path", { d: "M12 3c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2s2-.9 2-2V5c0-1.1-.9-2-2-2z" }));

const EditCard = forwardRef(
  (props, ref) => {
    const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
    const {
      children,
      className,
      style,
      headerText,
      state,
      editButtonText = "Edit",
      saveButtonText = "Save",
      disableEdit = false,
      disableSave = false,
      onStateChange,
      ...rest
    } = componentProps;
    const kebabState = state?.replaceAll(" ", "-");
    const editCardClassNames = cx(
      styles["edit-card"],
      styles[`edit-card-${kebabState}`],
      className
    );
    return /* @__PURE__ */ jsxs(
      Card,
      {
        padding: "large",
        className: editCardClassNames,
        "data-anv": "edit-card",
        style,
        ref,
        ...rest,
        children: [
          /* @__PURE__ */ jsxs(
            "div",
            {
              className: cx(styles.indicator, styles[`indicator-${kebabState}`]),
              children: [
                state === "complete" && /* @__PURE__ */ jsx(Icon, { svg: SvgCheck }),
                state === "error" && /* @__PURE__ */ jsx(Icon, { svg: SvgPriorityHigh })
              ]
            }
          ),
          /* @__PURE__ */ jsxs("div", { className: styles.container, children: [
            /* @__PURE__ */ jsxs("div", { className: styles.header, children: [
              /* @__PURE__ */ jsx(Text, { className: styles.heading, variant: "headline", el: "h3", children: typeof headerText === "string" ? headerText : headerText[state] }),
              state !== "in progress" && /* @__PURE__ */ jsx(
                Button,
                {
                  disabled: disableEdit,
                  onClick: () => onStateChange?.("edit"),
                  children: editButtonText
                }
              )
            ] }),
            children && /* @__PURE__ */ jsx("div", { className: styles.content, style: layoutStyles, children }),
            state === "in progress" && /* @__PURE__ */ jsxs("div", { className: styles.footer, children: [
              /* @__PURE__ */ jsx(Button, { onClick: () => onStateChange?.("cancel"), children: "Cancel" }),
              /* @__PURE__ */ jsx(
                Button,
                {
                  appearance: "primary",
                  onClick: () => onStateChange?.("save"),
                  disabled: disableSave,
                  children: saveButtonText
                }
              )
            ] })
          ] })
        ]
      }
    );
  }
);
EditCard.displayName = "EditCard";

export { EditCard as E };
//# sourceMappingURL=EditCard-D7-Ye7R0.js.map
