import { defineComponent, computed, ref, reactive, createVNode, resolveDynamicComponent, watch, mergeProps, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrInterpolate, ssrRenderList, ssrRenderClass, ssrRenderVNode, ssrRenderAttr, ssrIncludeBooleanAttr, ssrRenderComponent, ssrLooseContain } from 'vue/server-renderer'; import { _ as _export_sfc } from './_plugin-vue_export-helper-1tPrXgE0.mjs'; import { useRoute, useRouter } from 'vue-router'; const _sfc_main$3 = /* @__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$3; _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$3 = _sfc_main$3.setup; _sfc_main$3.setup = (props, ctx) => { const ssrContext = useSSRContext(); (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/TreeNode.vue"); return _sfc_setup$3 ? _sfc_setup$3(props, ctx) : void 0; }; const _sfc_main$2 = /* @__PURE__ */ defineComponent({ __name: "SmartLocationInput", __ssrInlineRender: true, props: { modelValue: { default: null }, label: { default: "" }, placeholder: { default: "Kezdj el g\xE9pelni (ir\xE1ny\xEDt\xF3sz\xE1m vagy v\xE1ros)..." }, minChars: { default: 2 }, countryCode: { default: "HU" }, debounceMs: { default: 300 } }, emits: ["update:modelValue", "select"], setup(__props, { emit: __emit }) { const props = __props; ref(null); const query = ref(""); const selectedItem = ref(props.modelValue); const items = ref([]); const searching = ref(false); const showDropdown = ref(false); const highlightedIndex = ref(0); const displayText = computed(() => { if (selectedItem.value) { return `${selectedItem.value.zip_code} ${selectedItem.value.city}`; } return query.value; }); const filteredItems = computed(() => { if (!query.value || query.value.length < props.minChars) return []; const q = query.value.toLowerCase(); return items.value.filter( (item) => item.zip_code.toLowerCase().includes(q) || item.city.toLowerCase().includes(q) ); }); watch( () => props.modelValue, (val) => { selectedItem.value = val; } ); return (_ctx, _push, _parent, _attrs) => { _push(``); if (__props.label) { _push(``); } else { _push(``); } _push(`
`); if (searching.value) { _push(``); } else { _push(``); } if (selectedItem.value && !searching.value) { _push(``); } else { _push(``); } _push(`
`); if (showDropdown.value && filteredItems.value.length > 0) { _push(`
`); ssrRenderList(filteredItems.value, (item, index) => { _push(``); }); _push(`
`); } else { _push(``); } if (showDropdown.value && query.value.length >= __props.minChars && filteredItems.value.length === 0 && !searching.value) { _push(`
Nincs tal\xE1lat
`); } else { _push(``); } _push(``); }; } }); 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/SmartLocationInput.vue"); return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0; }; const __nuxt_component_0 = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-b43e13ca"]]); const _sfc_main$1 = /* @__PURE__ */ defineComponent({ __name: "SharedAddressForm", __ssrInlineRender: true, props: { modelValue: { default: () => ({ zip: null, city: null, street_name: null, street_type: null, house_number: null, stairwell: null, floor: null, door: null, parcel_id: null, full_address_text: null, latitude: null, longitude: null }) } }, emits: ["update:modelValue"], setup(__props, { emit: __emit }) { const props = __props; const emit = __emit; const selectedLocation = computed(() => { var _a, _b; if (((_a = props.modelValue) == null ? void 0 : _a.zip) && ((_b = props.modelValue) == null ? void 0 : _b.city)) { return { id: 0, // We don't have the DB id here, but SmartLocationInput handles this zip_code: props.modelValue.zip, city: props.modelValue.city, country_code: "HU" }; } return null; }); function onLocationSelected(location) { const updated = { ...props.modelValue }; if (location) { updated.zip = location.zip_code; updated.city = location.city; } else { updated.zip = null; updated.city = null; } emit("update:modelValue", updated); } return (_ctx, _push, _parent, _attrs) => { const _component_SmartLocationInput = __nuxt_component_0; _push(`

C\xEDm adatok

`); _push(ssrRenderComponent(_component_SmartLocationInput, { "model-value": selectedLocation.value, "onUpdate:modelValue": onLocationSelected, label: "Ir\xE1ny\xEDt\xF3sz\xE1m / V\xE1ros", placeholder: "Kezdj el g\xE9pelni (pl. 1011 vagy Budapest)..." }, null, _parent)); _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/SharedAddressForm.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" }, { key: "hours", label: "Nyitvatart\xE1s", 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: [] }, opening_hours: {}, is_always_open: false, // Nested address object matching AddressIn schema (used by SharedAddressForm) address: { zip: "", city: "", street_name: "", street_type: "", house_number: "", stairwell: "", floor: "", door: "", parcel_id: "", full_address_text: "", latitude: null, longitude: null } }); const hasChanges = computed(() => { var _a; if (!provider.value) return false; const p = provider.value; if (form.name !== (p.name || "")) return true; if (form.address !== (p.address || "")) return true; if (form.plus_code !== (p.plus_code || "")) return true; if (form.address.zip !== (p.address_zip || "")) return true; if (form.address.city !== (p.city || "")) return true; if (form.address.street_name !== (p.address_street_name || "")) return true; if (form.address.street_type !== (p.address_street_type || "")) return true; if (form.address.house_number !== (p.address_house_number || "")) return true; if (form.contact_phone !== (p.contact_phone || "")) return true; if (form.contact_email !== (p.contact_email || "")) return true; if (form.website !== (p.website || "")) return true; if (form.category !== (p.category || "")) return true; const sortedFormCategories = [...form.category_ids].sort(); const sortedOrigCategories = [...p.category_ids || []].sort(); if (JSON.stringify(sortedFormCategories) !== JSON.stringify(sortedOrigCategories)) return true; const sortedFormClasses = [...form.supported_vehicle_classes].sort(); const sortedOrigClasses = [...p.supported_vehicle_classes || []].sort(); if (JSON.stringify(sortedFormClasses) !== JSON.stringify(sortedOrigClasses)) return true; const normalizeSpec = (spec) => ({ brands: Array.isArray(spec == null ? void 0 : spec.brands) ? [...spec.brands].sort() : [], propulsion: Array.isArray(spec == null ? void 0 : spec.propulsion) ? [...spec.propulsion].sort() : [] }); if (JSON.stringify(normalizeSpec(form.specializations)) !== JSON.stringify(normalizeSpec(p.specializations))) return true; const DAYS2 = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]; const normalizeHours = (hours) => { const result = {}; const daysSource = (hours == null ? void 0 : hours.days) || hours; for (const day of DAYS2) { const slot = daysSource == null ? void 0 : daysSource[day]; if (slot && typeof slot === "object" && slot.open && slot.close) { result[day] = { open: slot.open, close: slot.close }; } else { result[day] = null; } } return result; }; if (JSON.stringify(normalizeHours(form.opening_hours)) !== JSON.stringify(normalizeHours(p.opening_hours))) return true; if (form.is_always_open !== (((_a = p.opening_hours) == null ? void 0 : _a.always_open) === true)) return true; return false; }); 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); } const DAYS = [ { key: "monday", label: "H\xE9tf\u0151" }, { key: "tuesday", label: "Kedd" }, { key: "wednesday", label: "Szerda" }, { key: "thursday", label: "Cs\xFCt\xF6rt\xF6k" }, { key: "friday", label: "P\xE9ntek" }, { key: "saturday", label: "Szombat" }, { key: "sunday", label: "Vas\xE1rnap" } ]; return (_ctx, _push, _parent, _attrs) => { const _component_TreeNode = _sfc_main$3; const _component_SharedAddressForm = _sfc_main$1; _push(`

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.

`); } else if (!provider.value) { _push(`

A szolg\xE1ltat\xF3 nem tal\xE1lhat\xF3.

`); } else { _push(`
`); if (activeTab.value === "basic") { _push(`

Alapadatok

${ssrInterpolate(provider.value.source)}

El\xE9rhet\u0151s\xE9g

`); } 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.

A J\xE1rm\u0171oszt\xE1lyok (Vehicle Classes)

Mely j\xE1rm\u0171t\xEDpusokat szervizeli a szolg\xE1ltat\xF3?

`); ssrRenderList(VEHICLE_CLASSES, (vc) => { _push(``); }); _push(`

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.

`); ssrRenderList(form.specializations.brands, (brand, idx) => { _push(`${ssrInterpolate(brand)} `); }); _push(`
Hozz\xE1ad
`); ssrRenderList(form.specializations.propulsion, (prop, idx) => { _push(`${ssrInterpolate(prop)} `); }); _push(`
Hozz\xE1ad
`); } else { _push(``); } if (activeTab.value === "location") { _push(`
`); _push(ssrRenderComponent(_component_SharedAddressForm, { modelValue: form.address, "onUpdate:modelValue": ($event) => form.address = $event }, null, _parent)); _push(`

Tov\xE1bbi helysz\xEDn adatok

`); } else { _push(``); } if (activeTab.value === "hours") { _push(`

Nyitvatart\xE1s

\xC1ll\xEDtsd be a szolg\xE1ltat\xF3 nyitvatart\xE1si idej\xE9t napokra bontva.

`); ssrRenderList(DAYS, (day) => { var _a, _b; _push(`
`); if (form.opening_hours[day.key]) { _push(`
\u2013
`); } else { _push(`Z\xE1rva`); } _push(`
`); }); _push(`
`); } else { _push(``); } _push(`
`); if (hasChanges.value) { _push(`\u25CF M\xF3dos\xEDt\xE1sok el nem mentve`); } else { _push(`Nincs v\xE1ltoz\xE1s`); } _push(`
`); 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-ab22d560"]]); export { edit as default }; //# sourceMappingURL=edit-ZNmjSMhu.mjs.map