import { defineComponent, computed, ref, reactive, createVNode, resolveDynamicComponent, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrInterpolate, ssrRenderList, ssrRenderClass, ssrRenderVNode, ssrRenderAttr, ssrIncludeBooleanAttr, ssrRenderComponent } from 'vue/server-renderer';
import { useRoute, useRouter } from 'vue-router';
import { _ as _export_sfc } from './_plugin-vue_export-helper-1tPrXgE0.mjs';
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
__name: "TreeNode",
__ssrInlineRender: true,
props: {
node: {},
selectedIds: {},
expandedIds: {}
},
emits: ["toggle", "toggle-expand"],
setup(__props) {
return (_ctx, _push, _parent, _attrs) => {
var _a;
const _component_TreeNode = _sfc_main$1;
_push(`
`);
if (__props.expandedIds.has(__props.node.id) && ((_a = __props.node.children) == null ? void 0 : _a.length)) {
_push(`
`);
ssrRenderList(__props.node.children, (child) => {
_push(`
`);
_push(ssrRenderComponent(_component_TreeNode, {
node: child,
"selected-ids": __props.selectedIds,
"expanded-ids": __props.expandedIds,
onToggle: (id) => _ctx.$emit("toggle", id),
onToggleExpand: (id) => _ctx.$emit("toggle-expand", id)
}, null, _parent));
_push(`
`);
});
_push(`
`);
} else {
_push(``);
}
_push(`
`);
};
}
});
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/TreeNode.vue");
return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
};
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "edit",
__ssrInlineRender: true,
setup(__props) {
const VEHICLE_CLASSES = [
{ key: "car", label: "Szem\xE9lyaut\xF3" },
{ key: "motorcycle", label: "Motorker\xE9kp\xE1r" },
{ key: "truck", label: "Teheraut\xF3" },
{ key: "hgv", label: "Neh\xE9zg\xE9pj\xE1rm\u0171 (HGV)" },
{ key: "light_commercial", label: "Kishaszonj\xE1rm\u0171" },
{ key: "personal", label: "Szem\xE9lyes" },
{ key: "boat", label: "Cs\xF3nak/V\xEDzi" },
{ key: "other", label: "Egy\xE9b" }
];
const route = useRoute();
useRouter();
computed(() => Number(route.params.id));
const loading = ref(true);
const error = ref(false);
const provider = ref(null);
const saveLoading = ref(false);
const toast = ref(null);
const activeTab = ref("basic");
const tabs = [
{ key: "basic", label: "Alapadatok & Kapcsolat", icon: "svg" },
{ key: "matrix", label: "Szolg\xE1ltat\xE1sok & J\xE1rm\u0171vek", icon: "svg" },
{ key: "location", label: "Helysz\xEDn & Lok\xE1ci\xF3", icon: "svg" }
];
const categoryTree = ref([]);
const treeLoading = ref(false);
const expandedNodes = ref(/* @__PURE__ */ new Set());
const brandInput = ref("");
const propulsionInput = ref("");
const form = reactive({
name: "",
address: "",
city: "",
address_zip: "",
address_street_name: "",
address_street_type: "",
address_house_number: "",
plus_code: "",
contact_phone: "",
contact_email: "",
website: "",
category: "",
category_ids: [],
supported_vehicle_classes: [],
specializations: {
brands: [],
propulsion: []
}
});
const hasChanges = computed(() => {
if (!provider.value) return false;
const p = provider.value;
return form.name !== (p.name || "") || form.city !== (p.city || "") || form.address_zip !== (p.address_zip || "") || form.address_street_name !== (p.address_street_name || "") || form.address_house_number !== (p.address_house_number || "") || form.plus_code !== (p.plus_code || "") || form.contact_phone !== (p.contact_phone || "") || form.contact_email !== (p.contact_email || "") || form.website !== (p.website || "") || form.category !== (p.category || "") || JSON.stringify(form.category_ids.sort()) !== JSON.stringify((p.category_ids || []).sort()) || JSON.stringify(form.supported_vehicle_classes.sort()) !== JSON.stringify((p.supported_vehicle_classes || []).sort()) || JSON.stringify(form.specializations) !== JSON.stringify(p.specializations || { brands: [], propulsion: [] });
});
function findCategoryById(id, nodes) {
var _a;
for (const node of nodes) {
if (node.id === id) return node;
if ((_a = node.children) == null ? void 0 : _a.length) {
const found = findCategoryById(id, node.children);
if (found) return found;
}
}
return null;
}
function getCategoryName(id) {
const node = findCategoryById(id, categoryTree.value);
if (!node) return `#${id}`;
return node.name_hu || node.name_en || node.key;
}
function toggleCategory(id) {
const idx = form.category_ids.indexOf(id);
if (idx >= 0) {
form.category_ids.splice(idx, 1);
} else {
form.category_ids.push(id);
}
}
function toggleTreeNode(id) {
const newSet = new Set(expandedNodes.value);
if (newSet.has(id)) {
newSet.delete(id);
} else {
newSet.add(id);
}
expandedNodes.value = newSet;
}
function isCategorySelected(id) {
return form.category_ids.includes(id);
}
return (_ctx, _push, _parent, _attrs) => {
const _component_TreeNode = _sfc_main$1;
_push(` Vissza a szolg\xE1ltat\xF3hoz Szolg\xE1ltat\xF3 szerkeszt\xE9se Szolg\xE1ltat\xF3 #${ssrInterpolate(_ctx.$route.params.id)}
`);
if (loading.value) {
_push(`
Szolg\xE1ltat\xF3 bet\xF6lt\xE9se... `);
} else if (error.value) {
_push(`
Hiba t\xF6rt\xE9nt a szolg\xE1ltat\xF3 bet\xF6lt\xE9se k\xF6zben.
\xDAjrapr\xF3b\xE1lkoz\xE1s `);
} else if (!provider.value) {
_push(`
A szolg\xE1ltat\xF3 nem tal\xE1lhat\xF3.
`);
} else {
_push(`
`);
ssrRenderList(tabs, (tab) => {
_push(``);
ssrRenderVNode(_push, createVNode(resolveDynamicComponent(tab.icon), { class: "w-4 h-4" }, null), _parent);
_push(` ${ssrInterpolate(tab.label)} `);
});
_push(`
`);
if (activeTab.value === "basic") {
_push(`
`);
} else {
_push(``);
}
if (activeTab.value === "matrix") {
_push(`
3D K\xE9pess\xE9g M\xE1trix \xC1ll\xEDtsd be, hogy a szolg\xE1ltat\xF3 milyen j\xE1rm\u0171oszt\xE1lyokhoz, szolg\xE1ltat\xE1si kateg\xF3ri\xE1khoz \xE9s specializ\xE1ci\xF3khoz tartozik.
B Szolg\xE1ltat\xE1si Kateg\xF3ri\xE1k (Expertise Tags) V\xE1laszd ki a szolg\xE1ltat\xF3hoz tartoz\xF3 kateg\xF3ri\xE1kat a hierarchikus f\xE1b\xF3l.
`);
if (treeLoading.value) {
_push(`
Kateg\xF3ri\xE1k bet\xF6lt\xE9se... `);
} else {
_push(`
`);
ssrRenderList(categoryTree.value, (node) => {
var _a;
_push(`
`);
if (expandedNodes.value.has(node.id) && ((_a = node.children) == null ? void 0 : _a.length)) {
_push(`
`);
ssrRenderList(node.children, (child) => {
_push(`
`);
_push(ssrRenderComponent(_component_TreeNode, {
node: child,
"selected-ids": form.category_ids,
"expanded-ids": expandedNodes.value,
onToggle: toggleCategory,
onToggleExpand: toggleTreeNode
}, null, _parent));
_push(`
`);
});
_push(`
`);
} else {
_push(``);
}
_push(`
`);
});
_push(`
`);
}
if (form.category_ids.length > 0) {
_push(`
`);
ssrRenderList(form.category_ids, (id) => {
_push(`
${ssrInterpolate(getCategoryName(id))} `);
});
_push(`
`);
} else {
_push(``);
}
_push(`
C Specializ\xE1ci\xF3k Adj meg speci\xE1lis m\xE1rk\xE1kat, hajt\xE1sl\xE1nc t\xEDpusokat vagy egy\xE9b c\xEDmk\xE9ket.
M\xE1rk\xE1k (Brands) `);
ssrRenderList(form.specializations.brands, (brand, idx) => {
_push(`
${ssrInterpolate(brand)} `);
});
_push(`
Hozz\xE1ad
Hajt\xE1sl\xE1nc (Propulsion) `);
ssrRenderList(form.specializations.propulsion, (prop, idx) => {
_push(`
${ssrInterpolate(prop)} `);
});
_push(`
Hozz\xE1ad
`);
} else {
_push(``);
}
if (activeTab.value === "location") {
_push(`
`);
} else {
_push(``);
}
_push(`
`);
if (hasChanges.value) {
_push(`\u25CF M\xF3dos\xEDt\xE1sok el nem mentve `);
} else {
_push(`Nincs v\xE1ltoz\xE1s `);
}
_push(`
M\xE9gse `);
if (saveLoading.value) {
_push(` `);
} else {
_push(` `);
}
_push(` Ment\xE9s `);
}
if (toast.value) {
_push(`
${ssrInterpolate(toast.value.message)}
`);
} else {
_push(``);
}
_push(`
`);
};
}
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/providers/[id]/edit.vue");
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const edit = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-03c94385"]]);
export { edit as default };
//# sourceMappingURL=edit-Db3uK3sd.mjs.map