"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import {
  Dialog,
  DialogContent,
  DialogHeader,
  DialogTitle
} from "@open-mercato/ui/primitives/dialog";
import { Button } from "@open-mercato/ui/primitives/button";
import { Input } from "@open-mercato/ui/primitives/input";
import { Textarea } from "@open-mercato/ui/primitives/textarea";
import { Label } from "@open-mercato/ui/primitives/label";
import { Switch } from "@open-mercato/ui/primitives/switch";
import { TagsInput } from "@open-mercato/ui/backend/inputs/TagsInput";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { DefinitionTriggersEditor } from "../DefinitionTriggersEditor.js";
function MobileMetadataSheet({
  open,
  onOpenChange,
  definitionId,
  metadata,
  metadataHandlers
}) {
  const t = useT();
  const {
    workflowId,
    workflowName,
    description,
    version,
    enabled,
    category,
    tags,
    icon,
    effectiveFrom,
    effectiveTo,
    triggers
  } = metadata;
  const {
    setWorkflowId,
    setWorkflowName,
    setDescription,
    setVersion,
    setEnabled,
    setCategory,
    setTags,
    setIcon,
    setEffectiveFrom,
    setEffectiveTo,
    setTriggers
  } = metadataHandlers;
  return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[85svh] overflow-y-auto", children: [
    /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: t("workflows.mobile.metadata", "Metadata") }) }),
    /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
      /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ jsxs(Label, { htmlFor: "m-workflowId", className: "text-xs", children: [
          t("workflows.form.workflowId"),
          " *"
        ] }),
        /* @__PURE__ */ jsx(
          Input,
          {
            id: "m-workflowId",
            value: workflowId,
            onChange: (e) => setWorkflowId(e.target.value),
            placeholder: t("workflows.form.placeholders.workflowId"),
            disabled: !!definitionId,
            className: "h-11 text-sm"
          }
        )
      ] }),
      /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ jsxs(Label, { htmlFor: "m-workflowName", className: "text-xs", children: [
          t("workflows.form.workflowName"),
          " *"
        ] }),
        /* @__PURE__ */ jsx(
          Input,
          {
            id: "m-workflowName",
            value: workflowName,
            onChange: (e) => setWorkflowName(e.target.value),
            placeholder: t("workflows.form.placeholders.workflowName"),
            className: "h-11 text-sm"
          }
        )
      ] }),
      /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ jsx(Label, { htmlFor: "m-description", className: "text-xs", children: t("workflows.form.description") }),
        /* @__PURE__ */ jsx(
          Textarea,
          {
            id: "m-description",
            value: description,
            onChange: (e) => setDescription(e.target.value),
            placeholder: t("workflows.form.placeholders.description"),
            rows: 2,
            className: "min-h-[60px] text-sm"
          }
        )
      ] }),
      /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ jsx(Label, { htmlFor: "m-category", className: "text-xs", children: t("workflows.form.category") }),
        /* @__PURE__ */ jsx(
          Input,
          {
            id: "m-category",
            value: category,
            onChange: (e) => setCategory(e.target.value),
            placeholder: t("workflows.form.placeholders.category"),
            className: "h-11 text-sm"
          }
        )
      ] }),
      /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-3", children: [
        /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
          /* @__PURE__ */ jsxs(Label, { htmlFor: "m-version", className: "text-xs", children: [
            t("workflows.form.version"),
            " *"
          ] }),
          /* @__PURE__ */ jsx(
            Input,
            {
              id: "m-version",
              type: "number",
              value: version,
              onChange: (e) => setVersion(parseInt(e.target.value) || 1),
              min: 1,
              disabled: !!definitionId,
              className: "h-11 text-sm"
            }
          )
        ] }),
        /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
          /* @__PURE__ */ jsx(Label, { className: "text-xs", children: t("workflows.form.enabled") }),
          /* @__PURE__ */ jsxs("div", { className: "flex h-11 items-center gap-2", children: [
            /* @__PURE__ */ jsx(
              Switch,
              {
                id: "m-enabled",
                checked: enabled,
                onCheckedChange: setEnabled
              }
            ),
            /* @__PURE__ */ jsx(Label, { htmlFor: "m-enabled", className: "cursor-pointer text-xs font-normal", children: enabled ? t("common.on") : t("common.off") })
          ] })
        ] })
      ] }),
      /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ jsx(Label, { className: "text-xs", children: t("workflows.form.tags") }),
        /* @__PURE__ */ jsx(
          TagsInput,
          {
            value: tags,
            onChange: setTags,
            placeholder: t("workflows.form.placeholders.tags")
          }
        )
      ] }),
      /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
        /* @__PURE__ */ jsx(Label, { htmlFor: "m-icon", className: "text-xs", children: t("workflows.form.icon") }),
        /* @__PURE__ */ jsx(
          Input,
          {
            id: "m-icon",
            value: icon,
            onChange: (e) => setIcon(e.target.value),
            placeholder: t("workflows.form.placeholders.icon"),
            className: "h-11 text-sm"
          }
        )
      ] }),
      /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-3", children: [
        /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
          /* @__PURE__ */ jsx(Label, { htmlFor: "m-effectiveFrom", className: "text-xs", children: t("workflows.form.effectiveFrom") }),
          /* @__PURE__ */ jsx(
            Input,
            {
              id: "m-effectiveFrom",
              type: "date",
              value: effectiveFrom,
              onChange: (e) => setEffectiveFrom(e.target.value),
              className: "h-11 text-sm"
            }
          )
        ] }),
        /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
          /* @__PURE__ */ jsx(Label, { htmlFor: "m-effectiveTo", className: "text-xs", children: t("workflows.form.effectiveTo") }),
          /* @__PURE__ */ jsx(
            Input,
            {
              id: "m-effectiveTo",
              type: "date",
              value: effectiveTo,
              onChange: (e) => setEffectiveTo(e.target.value),
              className: "h-11 text-sm"
            }
          )
        ] })
      ] }),
      /* @__PURE__ */ jsx(
        DefinitionTriggersEditor,
        {
          value: triggers,
          onChange: setTriggers
        }
      ),
      /* @__PURE__ */ jsx(
        Button,
        {
          className: "w-full h-11",
          onClick: () => onOpenChange(false),
          children: t("common.done")
        }
      )
    ] })
  ] }) });
}
export {
  MobileMetadataSheet
};
//# sourceMappingURL=MobileMetadataSheet.js.map
