import { _ as __nuxt_component_0$1 } from './nuxt-link-Cq8xZgFP.mjs';
import { defineComponent, computed, ref, withAsyncContext, mergeProps, withCtx, unref, createTextVNode, toDisplayString, createVNode, isRef, createBlock, createCommentVNode, openBlock, watch, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrRenderComponent, ssrInterpolate, ssrRenderList, ssrRenderAttr, ssrIncludeBooleanAttr, ssrLooseContain, ssrLooseEqual, ssrRenderClass } from 'vue/server-renderer';
import { _ as _export_sfc, j as useRoute, b as useRouter, u as useI18n, a as useHead } from './server.mjs';
import draggable from 'vuedraggable';
import { aJ as isLockedColumn, aK as isBacklogColumn, aL as isDoneColumn } from '../nitro/nitro.mjs';
import { u as useFetch } from './fetch-B5NxMLIO.mjs';
import { u as useNotification } from './useNotification-BqDqaGnC.mjs';
import { u as usePipeline } from './usePipeline-ZPHbtOs6.mjs';
import { onBeforeRouteLeave } from 'vue-router';
import '../routes/renderer.mjs';
import 'vue-bundle-renderer/runtime';
import 'unhead/server';
import 'devalue';
import 'unhead/utils';
import 'node:http';
import 'node:https';
import 'node:crypto';
import 'stream';
import 'events';
import 'http';
import 'crypto';
import 'buffer';
import 'zlib';
import 'https';
import 'net';
import 'tls';
import 'url';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import '@prisma/client';
import '@prisma/adapter-better-sqlite3';
import 'fs';
import 'path';
import 'fs/promises';
import 'child_process';
import 'node:child_process';
import 'node:url';
import '@vue/shared';

const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  __name: "PipelineColumn",
  __ssrInlineRender: true,
  props: {
    column: {},
    pipelineName: { default: "" },
    editable: { type: Boolean, default: true },
    isDragging: { type: Boolean, default: false },
    showPrompt: { type: Boolean, default: true },
    showRemove: { type: Boolean, default: true },
    locked: { type: Boolean, default: false }
  },
  emits: ["nameChange", "nameBlur", "remove"],
  setup(__props) {
    const props = __props;
    const promptLink = computed(() => {
      const base = `/column/${props.column.slug}/prompt`;
      const params = new URLSearchParams();
      if (props.pipelineName) params.set("pipeline", props.pipelineName);
      params.set("name", props.column.name);
      return `${base}?${params.toString()}`;
    });
    const localName = ref(props.column.name);
    watch(
      () => props.column.name,
      (newName) => {
        localName.value = newName;
      }
    );
    return (_ctx, _push, _parent, _attrs) => {
      const _component_NuxtLink = __nuxt_component_0$1;
      _push(`<div${ssrRenderAttrs(mergeProps({
        class: ["pipeline-column", { dragging: __props.isDragging, locked: __props.locked }]
      }, _attrs))} data-v-b7d3d1e3><div class="${ssrRenderClass([{ disabled: __props.locked }, "column-drag-handle"])}" data-v-b7d3d1e3>`);
      if (__props.locked) {
        _push(`<span class="icon-lock" data-v-b7d3d1e3></span>`);
      } else {
        _push(`<span class="handle-icon" data-v-b7d3d1e3></span>`);
      }
      _push(`</div><div class="column-info" data-v-b7d3d1e3>`);
      if (__props.editable) {
        _push(`<input${ssrRenderAttr("value", unref(localName))} class="column-name-input" data-v-b7d3d1e3>`);
      } else {
        _push(`<span class="column-name" data-v-b7d3d1e3>${ssrInterpolate(__props.column.name)}</span>`);
      }
      _push(`<span class="column-slug" data-v-b7d3d1e3>${ssrInterpolate(__props.column.slug)}</span></div><div class="column-actions" data-v-b7d3d1e3>`);
      if (__props.showPrompt) {
        _push(ssrRenderComponent(_component_NuxtLink, {
          to: unref(promptLink),
          class: "btn-icon",
          title: _ctx.$t("column.viewPrompt")
        }, {
          default: withCtx((_, _push2, _parent2, _scopeId) => {
            if (_push2) {
              _push2(`<span class="icon-eye" data-v-b7d3d1e3${_scopeId}></span>`);
            } else {
              return [
                createVNode("span", { class: "icon-eye" })
              ];
            }
          }),
          _: 1
        }, _parent));
      } else {
        _push(`<!---->`);
      }
      if (__props.showRemove && !__props.locked) {
        _push(`<button class="btn-icon btn-danger"${ssrRenderAttr("title", _ctx.$t("form.delete"))} data-v-b7d3d1e3><span class="icon-remove" data-v-b7d3d1e3></span></button>`);
      } else {
        _push(`<!---->`);
      }
      _push(`</div></div>`);
    };
  }
});
const _sfc_setup$3 = _sfc_main$3.setup;
_sfc_main$3.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/pipeline/PipelineColumn.vue");
  return _sfc_setup$3 ? _sfc_setup$3(props, ctx) : void 0;
};
const __nuxt_component_0 = /* @__PURE__ */ Object.assign(_export_sfc(_sfc_main$3, [["__scopeId", "data-v-b7d3d1e3"]]), { __name: "PipelineColumn" });
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  __name: "PipelineSegments",
  __ssrInlineRender: true,
  props: {
    definition: {},
    action: {},
    finish: {},
    pipelineName: { default: "" },
    editable: { type: Boolean, default: true }
  },
  emits: ["update:definition", "update:action", "update:finish", "change", "remove"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const definition = computed({
      get: () => props.definition,
      set: (value) => emit("update:definition", value)
    });
    const action = computed({
      get: () => props.action,
      set: (value) => emit("update:action", value)
    });
    const finish = computed({
      get: () => props.finish,
      set: (value) => emit("update:finish", value)
    });
    const dragOverSegment = ref(null);
    const dragInvalidSegment = ref(null);
    const validateDrop = (targetSegment, el) => {
      const columnSegment = el.getAttribute("data-segment");
      if (!columnSegment || columnSegment === targetSegment) {
        dragOverSegment.value = targetSegment;
        dragInvalidSegment.value = null;
        return true;
      }
      dragInvalidSegment.value = targetSegment;
      return false;
    };
    const onDragStart = () => {
      dragOverSegment.value = null;
      dragInvalidSegment.value = null;
    };
    const onDragEnd = () => {
      dragOverSegment.value = null;
      dragInvalidSegment.value = null;
    };
    const checkMove = (evt) => {
      const draggedSlug = evt.draggedContext.element.slug;
      const targetList = evt.relatedContext.list;
      const futureIndex = evt.draggedContext.futureIndex;
      if (isLockedColumn(draggedSlug)) {
        return false;
      }
      const firstCol = targetList[0];
      if (firstCol && isBacklogColumn(firstCol.slug)) {
        if (futureIndex === 0) {
          return false;
        }
      }
      const lastCol = targetList[targetList.length - 1];
      if (lastCol && isDoneColumn(lastCol.slug)) {
        if (futureIndex >= targetList.length) {
          return false;
        }
      }
      return true;
    };
    const onColumnNameChange = (column, name) => {
      column.name = name;
      emit("change");
    };
    const enforceBacklogFirst = () => {
      const backlogIndex = definition.value.findIndex((c) => isBacklogColumn(c.slug));
      if (backlogIndex > 0) {
        const backlog = definition.value.splice(backlogIndex, 1)[0];
        if (backlog) {
          definition.value.unshift(backlog);
        }
      }
    };
    const enforceDoneLast = () => {
      const doneIndex = finish.value.findIndex((c) => isDoneColumn(c.slug));
      if (doneIndex !== -1 && doneIndex !== finish.value.length - 1) {
        const done = finish.value.splice(doneIndex, 1)[0];
        if (done) {
          finish.value.push(done);
        }
      }
    };
    const onDefinitionChange = () => {
      enforceBacklogFirst();
      emit("change");
    };
    const onActionChange = () => emit("change");
    const onFinishChange = () => {
      enforceDoneLast();
      emit("change");
    };
    return (_ctx, _push, _parent, _attrs) => {
      const _component_PipelineColumn = __nuxt_component_0;
      _push(`<div${ssrRenderAttrs(mergeProps({ class: "pipeline-segments" }, _attrs))} data-v-b9eff701><div class="segment segment-definition" data-v-b9eff701><div class="segment-header" data-v-b9eff701><h3 data-v-b9eff701>DEFINITION</h3><span class="segment-count" data-v-b9eff701>${ssrInterpolate(unref(definition).length)}</span></div><p class="segment-description" data-v-b9eff701>${ssrInterpolate(_ctx.$t("pipeline.definitionDesc"))}</p>`);
      _push(ssrRenderComponent(unref(draggable), {
        modelValue: unref(definition),
        "onUpdate:modelValue": ($event) => isRef(definition) ? definition.value = $event : null,
        group: {
          name: "columns",
          pull: true,
          put: (_to, _from, el) => validateDrop("definition", el)
        },
        move: checkMove,
        "item-key": "slug",
        class: ["segment-columns", {
          "drag-over": unref(dragOverSegment) === "definition",
          "drag-invalid": unref(dragInvalidSegment) === "definition"
        }],
        "ghost-class": "ghost",
        "drag-class": "dragging",
        onStart: onDragStart,
        onEnd: onDragEnd,
        onChange: onDefinitionChange
      }, {
        item: withCtx(({ element }, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(_component_PipelineColumn, {
              column: element,
              "pipeline-name": __props.pipelineName,
              editable: __props.editable,
              locked: unref(isLockedColumn)(element.slug),
              onNameChange: (name) => onColumnNameChange(element, name),
              onRemove: ($event) => _ctx.$emit("remove", "definition", element)
            }, null, _parent2, _scopeId));
          } else {
            return [
              createVNode(_component_PipelineColumn, {
                column: element,
                "pipeline-name": __props.pipelineName,
                editable: __props.editable,
                locked: unref(isLockedColumn)(element.slug),
                onNameChange: (name) => onColumnNameChange(element, name),
                onRemove: ($event) => _ctx.$emit("remove", "definition", element)
              }, null, 8, ["column", "pipeline-name", "editable", "locked", "onNameChange", "onRemove"])
            ];
          }
        }),
        _: 1
      }, _parent));
      if (!unref(definition).length) {
        _push(`<div class="segment-empty" data-v-b9eff701>${ssrInterpolate(_ctx.$t("pipeline.dropHere"))}</div>`);
      } else {
        _push(`<!---->`);
      }
      _push(`</div><div class="segment segment-action" data-v-b9eff701><div class="segment-header" data-v-b9eff701><h3 data-v-b9eff701>ACTION</h3><span class="segment-count" data-v-b9eff701>${ssrInterpolate(unref(action).length)}</span></div><p class="segment-description" data-v-b9eff701>${ssrInterpolate(_ctx.$t("pipeline.actionDesc"))}</p>`);
      _push(ssrRenderComponent(unref(draggable), {
        modelValue: unref(action),
        "onUpdate:modelValue": ($event) => isRef(action) ? action.value = $event : null,
        group: {
          name: "columns",
          pull: true,
          put: (_to, _from, el) => validateDrop("action", el)
        },
        move: checkMove,
        "item-key": "slug",
        class: ["segment-columns", {
          "drag-over": unref(dragOverSegment) === "action",
          "drag-invalid": unref(dragInvalidSegment) === "action"
        }],
        "ghost-class": "ghost",
        "drag-class": "dragging",
        onStart: onDragStart,
        onEnd: onDragEnd,
        onChange: onActionChange
      }, {
        item: withCtx(({ element }, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(_component_PipelineColumn, {
              column: element,
              "pipeline-name": __props.pipelineName,
              editable: __props.editable,
              locked: unref(isLockedColumn)(element.slug),
              onNameChange: (name) => onColumnNameChange(element, name),
              onRemove: ($event) => _ctx.$emit("remove", "action", element)
            }, null, _parent2, _scopeId));
          } else {
            return [
              createVNode(_component_PipelineColumn, {
                column: element,
                "pipeline-name": __props.pipelineName,
                editable: __props.editable,
                locked: unref(isLockedColumn)(element.slug),
                onNameChange: (name) => onColumnNameChange(element, name),
                onRemove: ($event) => _ctx.$emit("remove", "action", element)
              }, null, 8, ["column", "pipeline-name", "editable", "locked", "onNameChange", "onRemove"])
            ];
          }
        }),
        _: 1
      }, _parent));
      if (!unref(action).length) {
        _push(`<div class="segment-empty" data-v-b9eff701>${ssrInterpolate(_ctx.$t("pipeline.dropHere"))}</div>`);
      } else {
        _push(`<!---->`);
      }
      _push(`</div><div class="segment segment-finish" data-v-b9eff701><div class="segment-header" data-v-b9eff701><h3 data-v-b9eff701>FINISH</h3><span class="segment-count" data-v-b9eff701>${ssrInterpolate(unref(finish).length)}</span></div><p class="segment-description" data-v-b9eff701>${ssrInterpolate(_ctx.$t("pipeline.finishDesc"))}</p>`);
      _push(ssrRenderComponent(unref(draggable), {
        modelValue: unref(finish),
        "onUpdate:modelValue": ($event) => isRef(finish) ? finish.value = $event : null,
        group: {
          name: "columns",
          pull: true,
          put: (_to, _from, el) => validateDrop("finish", el)
        },
        move: checkMove,
        "item-key": "slug",
        class: ["segment-columns", {
          "drag-over": unref(dragOverSegment) === "finish",
          "drag-invalid": unref(dragInvalidSegment) === "finish"
        }],
        "ghost-class": "ghost",
        "drag-class": "dragging",
        onStart: onDragStart,
        onEnd: onDragEnd,
        onChange: onFinishChange
      }, {
        item: withCtx(({ element }, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(_component_PipelineColumn, {
              column: element,
              "pipeline-name": __props.pipelineName,
              editable: __props.editable,
              locked: unref(isLockedColumn)(element.slug),
              onNameChange: (name) => onColumnNameChange(element, name),
              onRemove: ($event) => _ctx.$emit("remove", "finish", element)
            }, null, _parent2, _scopeId));
          } else {
            return [
              createVNode(_component_PipelineColumn, {
                column: element,
                "pipeline-name": __props.pipelineName,
                editable: __props.editable,
                locked: unref(isLockedColumn)(element.slug),
                onNameChange: (name) => onColumnNameChange(element, name),
                onRemove: ($event) => _ctx.$emit("remove", "finish", element)
              }, null, 8, ["column", "pipeline-name", "editable", "locked", "onNameChange", "onRemove"])
            ];
          }
        }),
        _: 1
      }, _parent));
      if (!unref(finish).length) {
        _push(`<div class="segment-empty" data-v-b9eff701>${ssrInterpolate(_ctx.$t("pipeline.dropHere"))}</div>`);
      } else {
        _push(`<!---->`);
      }
      _push(`</div></div>`);
    };
  }
});
const _sfc_setup$2 = _sfc_main$2.setup;
_sfc_main$2.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/pipeline/PipelineSegments.vue");
  return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
};
const __nuxt_component_1 = /* @__PURE__ */ Object.assign(_export_sfc(_sfc_main$2, [["__scopeId", "data-v-b9eff701"]]), { __name: "PipelineSegments" });
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  __name: "CatalogPanel",
  __ssrInlineRender: true,
  props: {
    pipelineSlugs: {},
    pipelineName: { default: "" }
  },
  emits: ["addColumn"],
  async setup(__props) {
    let __temp, __restore;
    const props = __props;
    const buildPromptLink = (column) => {
      const base = `/column/${column.slug}/prompt`;
      const params = new URLSearchParams();
      if (props.pipelineName) params.set("pipeline", props.pipelineName);
      params.set("name", column.name);
      return `${base}?${params.toString()}`;
    };
    const { data: catalog, pending: loading } = ([__temp, __restore] = withAsyncContext(() => useFetch("/api/catalog", "$TVyW1O5EUN")), __temp = await __temp, __restore(), __temp);
    const definitionColumns = computed(() => {
      return catalog.value?.segments.definition.columns.map((col) => ({
        ...col,
        segment: "definition"
      })) || [];
    });
    const actionColumns = computed(() => {
      return catalog.value?.segments.action.columns.map((col) => ({
        ...col,
        segment: "action"
      })) || [];
    });
    const finishColumns = computed(() => {
      return catalog.value?.segments.finish.columns.map((col) => ({
        ...col,
        segment: "finish"
      })) || [];
    });
    const isInPipeline = (slug) => {
      const baseSlug = slug.replace(/^\d+_/, "");
      return props.pipelineSlugs.some((s) => s.replace(/^\d+_/, "") === baseSlug);
    };
    const cloneColumn = (segment) => (original) => ({
      name: original.name,
      slug: original.slug,
      segment
    });
    return (_ctx, _push, _parent, _attrs) => {
      const _component_NuxtLink = __nuxt_component_0$1;
      _push(`<div${ssrRenderAttrs(mergeProps({ class: "catalog-panel card" }, _attrs))} data-v-d6078e40><div class="catalog-header" data-v-d6078e40><h2 data-v-d6078e40>${ssrInterpolate(_ctx.$t("pipeline.catalog"))}</h2><button class="btn btn-secondary btn-sm" data-v-d6078e40> + ${ssrInterpolate(_ctx.$t("pipeline.addColumn"))}</button></div><p class="catalog-description" data-v-d6078e40>${ssrInterpolate(_ctx.$t("pipeline.catalogDesc"))}</p>`);
      if (unref(loading)) {
        _push(`<div class="loading" data-v-d6078e40>${ssrInterpolate(_ctx.$t("app.loading"))}</div>`);
      } else {
        _push(`<div class="catalog-segments" data-v-d6078e40><div class="catalog-segment" data-v-d6078e40><h3 class="segment-label segment-definition" data-v-d6078e40>DEFINITION</h3>`);
        _push(ssrRenderComponent(unref(draggable), {
          modelValue: unref(definitionColumns),
          "onUpdate:modelValue": ($event) => isRef(definitionColumns) ? definitionColumns.value = $event : null,
          group: { name: "columns", pull: "clone", put: false },
          "item-key": "slug",
          class: "catalog-columns",
          clone: cloneColumn("definition")
        }, {
          item: withCtx(({ element }, _push2, _parent2, _scopeId) => {
            if (_push2) {
              _push2(`<div class="catalog-column" data-segment="definition" data-v-d6078e40${_scopeId}><span class="column-name" data-v-d6078e40${_scopeId}>${ssrInterpolate(element.name)}</span>`);
              _push2(ssrRenderComponent(_component_NuxtLink, {
                to: buildPromptLink(element),
                class: "column-link",
                title: _ctx.$t("column.viewPrompt")
              }, {
                default: withCtx((_, _push3, _parent3, _scopeId2) => {
                  if (_push3) {
                    _push3(`<span class="icon-eye" data-v-d6078e40${_scopeId2}></span>`);
                  } else {
                    return [
                      createVNode("span", { class: "icon-eye" })
                    ];
                  }
                }),
                _: 2
              }, _parent2, _scopeId));
              if (isInPipeline(element.slug)) {
                _push2(`<span class="in-pipeline-badge" data-v-d6078e40${_scopeId}>${ssrInterpolate(_ctx.$t("pipeline.columnAdded"))}</span>`);
              } else {
                _push2(`<!---->`);
              }
              _push2(`</div>`);
            } else {
              return [
                createVNode("div", {
                  class: "catalog-column",
                  "data-segment": "definition"
                }, [
                  createVNode("span", { class: "column-name" }, toDisplayString(element.name), 1),
                  createVNode(_component_NuxtLink, {
                    to: buildPromptLink(element),
                    class: "column-link",
                    title: _ctx.$t("column.viewPrompt")
                  }, {
                    default: withCtx(() => [
                      createVNode("span", { class: "icon-eye" })
                    ]),
                    _: 1
                  }, 8, ["to", "title"]),
                  isInPipeline(element.slug) ? (openBlock(), createBlock("span", {
                    key: 0,
                    class: "in-pipeline-badge"
                  }, toDisplayString(_ctx.$t("pipeline.columnAdded")), 1)) : createCommentVNode("", true)
                ])
              ];
            }
          }),
          _: 1
        }, _parent));
        _push(`</div><div class="catalog-segment" data-v-d6078e40><h3 class="segment-label segment-action" data-v-d6078e40>ACTION</h3>`);
        _push(ssrRenderComponent(unref(draggable), {
          modelValue: unref(actionColumns),
          "onUpdate:modelValue": ($event) => isRef(actionColumns) ? actionColumns.value = $event : null,
          group: { name: "columns", pull: "clone", put: false },
          "item-key": "slug",
          class: "catalog-columns",
          clone: cloneColumn("action")
        }, {
          item: withCtx(({ element }, _push2, _parent2, _scopeId) => {
            if (_push2) {
              _push2(`<div class="catalog-column" data-segment="action" data-v-d6078e40${_scopeId}><span class="column-name" data-v-d6078e40${_scopeId}>${ssrInterpolate(element.name)}</span>`);
              _push2(ssrRenderComponent(_component_NuxtLink, {
                to: buildPromptLink(element),
                class: "column-link",
                title: _ctx.$t("column.viewPrompt")
              }, {
                default: withCtx((_, _push3, _parent3, _scopeId2) => {
                  if (_push3) {
                    _push3(`<span class="icon-eye" data-v-d6078e40${_scopeId2}></span>`);
                  } else {
                    return [
                      createVNode("span", { class: "icon-eye" })
                    ];
                  }
                }),
                _: 2
              }, _parent2, _scopeId));
              if (isInPipeline(element.slug)) {
                _push2(`<span class="in-pipeline-badge" data-v-d6078e40${_scopeId}>${ssrInterpolate(_ctx.$t("pipeline.columnAdded"))}</span>`);
              } else {
                _push2(`<!---->`);
              }
              _push2(`</div>`);
            } else {
              return [
                createVNode("div", {
                  class: "catalog-column",
                  "data-segment": "action"
                }, [
                  createVNode("span", { class: "column-name" }, toDisplayString(element.name), 1),
                  createVNode(_component_NuxtLink, {
                    to: buildPromptLink(element),
                    class: "column-link",
                    title: _ctx.$t("column.viewPrompt")
                  }, {
                    default: withCtx(() => [
                      createVNode("span", { class: "icon-eye" })
                    ]),
                    _: 1
                  }, 8, ["to", "title"]),
                  isInPipeline(element.slug) ? (openBlock(), createBlock("span", {
                    key: 0,
                    class: "in-pipeline-badge"
                  }, toDisplayString(_ctx.$t("pipeline.columnAdded")), 1)) : createCommentVNode("", true)
                ])
              ];
            }
          }),
          _: 1
        }, _parent));
        _push(`</div><div class="catalog-segment" data-v-d6078e40><h3 class="segment-label segment-finish" data-v-d6078e40>FINISH</h3>`);
        _push(ssrRenderComponent(unref(draggable), {
          modelValue: unref(finishColumns),
          "onUpdate:modelValue": ($event) => isRef(finishColumns) ? finishColumns.value = $event : null,
          group: { name: "columns", pull: "clone", put: false },
          "item-key": "slug",
          class: "catalog-columns",
          clone: cloneColumn("finish")
        }, {
          item: withCtx(({ element }, _push2, _parent2, _scopeId) => {
            if (_push2) {
              _push2(`<div class="catalog-column" data-segment="finish" data-v-d6078e40${_scopeId}><span class="column-name" data-v-d6078e40${_scopeId}>${ssrInterpolate(element.name)}</span>`);
              _push2(ssrRenderComponent(_component_NuxtLink, {
                to: buildPromptLink(element),
                class: "column-link",
                title: _ctx.$t("column.viewPrompt")
              }, {
                default: withCtx((_, _push3, _parent3, _scopeId2) => {
                  if (_push3) {
                    _push3(`<span class="icon-eye" data-v-d6078e40${_scopeId2}></span>`);
                  } else {
                    return [
                      createVNode("span", { class: "icon-eye" })
                    ];
                  }
                }),
                _: 2
              }, _parent2, _scopeId));
              if (isInPipeline(element.slug)) {
                _push2(`<span class="in-pipeline-badge" data-v-d6078e40${_scopeId}>${ssrInterpolate(_ctx.$t("pipeline.columnAdded"))}</span>`);
              } else {
                _push2(`<!---->`);
              }
              _push2(`</div>`);
            } else {
              return [
                createVNode("div", {
                  class: "catalog-column",
                  "data-segment": "finish"
                }, [
                  createVNode("span", { class: "column-name" }, toDisplayString(element.name), 1),
                  createVNode(_component_NuxtLink, {
                    to: buildPromptLink(element),
                    class: "column-link",
                    title: _ctx.$t("column.viewPrompt")
                  }, {
                    default: withCtx(() => [
                      createVNode("span", { class: "icon-eye" })
                    ]),
                    _: 1
                  }, 8, ["to", "title"]),
                  isInPipeline(element.slug) ? (openBlock(), createBlock("span", {
                    key: 0,
                    class: "in-pipeline-badge"
                  }, toDisplayString(_ctx.$t("pipeline.columnAdded")), 1)) : createCommentVNode("", true)
                ])
              ];
            }
          }),
          _: 1
        }, _parent));
        _push(`</div></div>`);
      }
      _push(`</div>`);
    };
  }
});
const _sfc_setup$1 = _sfc_main$1.setup;
_sfc_main$1.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/pipeline/CatalogPanel.vue");
  return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
};
const __nuxt_component_2 = /* @__PURE__ */ Object.assign(_export_sfc(_sfc_main$1, [["__scopeId", "data-v-d6078e40"]]), { __name: "PipelineCatalogPanel" });
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "[name]",
  __ssrInlineRender: true,
  async setup(__props) {
    let __temp, __restore;
    const route = useRoute();
    useRouter();
    useNotification();
    const {
      pipelineConfig,
      isDirty,
      loading,
      saving,
      markDirty,
      isValid,
      removeColumn
    } = usePipeline();
    const pipelineName = computed(() => decodeURIComponent(route.params["name"]));
    const selectedPipeline = ref("");
    const showAddColumnModal = ref(false);
    const allColumnSlugs = computed(() => {
      if (!pipelineConfig.value) return [];
      return [
        ...pipelineConfig.value.definition.map((c) => c.slug),
        ...pipelineConfig.value.action.map((c) => c.slug),
        ...pipelineConfig.value.finish.map((c) => c.slug)
      ];
    });
    const { data: pipelines, refresh: refreshPipelines } = ([__temp, __restore] = withAsyncContext(() => useFetch("/api/pipelines", "$OFwCMlST2k")), __temp = await __temp, __restore(), __temp);
    onBeforeRouteLeave((_to, _from, next) => {
      if (isDirty.value) {
        const answer = (void 0).confirm("You have unsaved changes. Are you sure you want to leave?");
        if (!answer) {
          next(false);
          return;
        }
      }
      next();
    });
    const handleRemoveColumn = (segment, column) => {
      if (!confirm(`Are you sure you want to remove "${column.name}"?`)) return;
      removeColumn(segment, column);
    };
    const { t: $t } = useI18n();
    useHead({
      title: computed(() => `${pipelineName.value} - Pipeline - AutoCode`)
    });
    return (_ctx, _push, _parent, _attrs) => {
      const _component_NuxtLink = __nuxt_component_0$1;
      const _component_PipelineSegments = __nuxt_component_1;
      const _component_PipelineCatalogPanel = __nuxt_component_2;
      _push(`<div${ssrRenderAttrs(mergeProps({ class: "pipeline-page" }, _attrs))} data-v-455b1ab3><header class="page-header card" data-v-455b1ab3><div class="header-left" data-v-455b1ab3>`);
      _push(ssrRenderComponent(_component_NuxtLink, {
        to: "/kanban",
        class: "back-link"
      }, {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(`← ${ssrInterpolate(unref($t)("nav.back"))}`);
          } else {
            return [
              createTextVNode("← " + toDisplayString(unref($t)("nav.back")), 1)
            ];
          }
        }),
        _: 1
      }, _parent));
      _push(`<span class="header-separator" data-v-455b1ab3>/</span><select class="pipeline-select" data-v-455b1ab3><!--[-->`);
      ssrRenderList(unref(pipelines), (pipeline) => {
        _push(`<option${ssrRenderAttr("value", pipeline.name)} data-v-455b1ab3${ssrIncludeBooleanAttr(Array.isArray(unref(selectedPipeline)) ? ssrLooseContain(unref(selectedPipeline), pipeline.name) : ssrLooseEqual(unref(selectedPipeline), pipeline.name)) ? " selected" : ""}>${ssrInterpolate(pipeline.name)}</option>`);
      });
      _push(`<!--]--></select>`);
      if (unref(pipelineConfig)?.active) {
        _push(`<span class="badge badge-active" data-v-455b1ab3>ACTIVE</span>`);
      } else {
        _push(`<!---->`);
      }
      if (unref(pipelineConfig)?.version) {
        _push(`<span class="badge badge-version" data-v-455b1ab3>v${ssrInterpolate(unref(pipelineConfig).version)}</span>`);
      } else {
        _push(`<!---->`);
      }
      _push(`</div><div class="header-right" data-v-455b1ab3>`);
      if (unref(pipelineConfig) && !unref(pipelineConfig).active) {
        _push(`<button class="btn btn-secondary btn-sm"${ssrIncludeBooleanAttr(unref(isDirty) || !unref(isValid)) ? " disabled" : ""} data-v-455b1ab3>${ssrInterpolate(unref($t)("pipeline.activateSync"))}</button>`);
      } else {
        _push(`<!---->`);
      }
      if (unref(pipelineConfig) && !unref(pipelineConfig).active) {
        _push(`<button class="btn btn-danger btn-sm" data-v-455b1ab3>${ssrInterpolate(unref($t)("form.delete"))}</button>`);
      } else {
        _push(`<!---->`);
      }
      _push(ssrRenderComponent(_component_NuxtLink, {
        to: "/settings/pipeline/new",
        class: "btn btn-ghost"
      }, {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(`<span class="btn-icon" data-v-455b1ab3${_scopeId}>+</span><span class="btn-text" data-v-455b1ab3${_scopeId}>${ssrInterpolate(unref($t)("pipeline.new"))}</span>`);
          } else {
            return [
              createVNode("span", { class: "btn-icon" }, "+"),
              createVNode("span", { class: "btn-text" }, toDisplayString(unref($t)("pipeline.new")), 1)
            ];
          }
        }),
        _: 1
      }, _parent));
      _push(`<button class="btn btn-primary"${ssrIncludeBooleanAttr(!unref(isDirty) || unref(saving) || !unref(isValid)) ? " disabled" : ""} data-v-455b1ab3>${ssrInterpolate(unref(saving) ? unref($t)("form.saving") : unref($t)("pipeline.save"))}</button></div></header>`);
      if (unref(loading)) {
        _push(`<div class="loading card" data-v-455b1ab3>${ssrInterpolate(unref($t)("app.loading"))}</div>`);
      } else if (unref(pipelineConfig)) {
        _push(`<div class="pipeline-editor" data-v-455b1ab3>`);
        if (unref(isDirty)) {
          _push(`<div class="warning-banner" data-v-455b1ab3><span data-v-455b1ab3>${ssrInterpolate(unref($t)("form.unsavedChanges"))}</span><button class="btn btn-sm btn-secondary" data-v-455b1ab3>${ssrInterpolate(unref($t)("form.dismiss"))}</button></div>`);
        } else {
          _push(`<!---->`);
        }
        if (!unref(isValid) && unref(pipelineConfig)) {
          _push(`<div class="error-banner" data-v-455b1ab3>${ssrInterpolate(unref($t)("pipeline.minColumnError"))}</div>`);
        } else {
          _push(`<!---->`);
        }
        _push(ssrRenderComponent(_component_PipelineSegments, {
          definition: unref(pipelineConfig).definition,
          "onUpdate:definition": ($event) => unref(pipelineConfig).definition = $event,
          action: unref(pipelineConfig).action,
          "onUpdate:action": ($event) => unref(pipelineConfig).action = $event,
          finish: unref(pipelineConfig).finish,
          "onUpdate:finish": ($event) => unref(pipelineConfig).finish = $event,
          "pipeline-name": unref(pipelineName),
          onChange: unref(markDirty),
          onRemove: handleRemoveColumn
        }, null, _parent));
        _push(ssrRenderComponent(_component_PipelineCatalogPanel, {
          "pipeline-slugs": unref(allColumnSlugs),
          "pipeline-name": unref(pipelineName),
          onAddColumn: ($event) => showAddColumnModal.value = true
        }, null, _parent));
        _push(`</div>`);
      } else {
        _push(`<div class="empty-state card" data-v-455b1ab3><p data-v-455b1ab3>${ssrInterpolate(unref($t)("pipeline.notFound"))}</p>`);
        _push(ssrRenderComponent(_component_NuxtLink, {
          to: "/settings/pipeline",
          class: "btn btn-primary"
        }, {
          default: withCtx((_, _push2, _parent2, _scopeId) => {
            if (_push2) {
              _push2(`${ssrInterpolate(unref($t)("nav.back"))}`);
            } else {
              return [
                createTextVNode(toDisplayString(unref($t)("nav.back")), 1)
              ];
            }
          }),
          _: 1
        }, _parent));
        _push(`</div>`);
      }
      _push(`</div>`);
    };
  }
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/settings/pipeline/[name].vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const _name_ = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-455b1ab3"]]);

export { _name_ as default };
//# sourceMappingURL=_name_-UJA12Rs2.mjs.map
