import { g } from './SvgIcon-YE_5uJaI.mjs';
import { d as gs, h as $a, u as Qt, i as Ma, g as ws, c as tf, e as _n, a as Ts, _ as Ds } from './server.mjs';
import { q } from './BaseTextInput-sD2PisNb.mjs';
import { computed, ref, watch, resolveComponent, mergeProps, unref, withCtx, openBlock, createBlock, createCommentVNode, createVNode, toDisplayString, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrInterpolate, ssrRenderList, ssrRenderClass, ssrRenderAttr, ssrIncludeBooleanAttr, ssrLooseContain, ssrRenderStyle, ssrRenderComponent } from 'vue/server-renderer';
import * as R from 'yup';
import { p as pe } from './index-Dj5w-pp2.mjs';
import '../_/nitro.mjs';
import 'node:http';
import 'node:https';
import 'node:fs';
import 'node:url';
import 'node:path';
import 'unhead';
import '@unhead/shared';
import 'vue-router';
import 'vue-rate';
import 'date-fns';
import '@hennge/vue3-pagination';
import 'axios';
import 'vue-social-sharing';

const U = { __name: "return", __ssrInlineRender: true, setup(k2) {
  const { t: U2 } = gs(), B2 = $a(), N = Qt().$axios, R$1 = Ma(), q$1 = ws(), O = tf(), P = computed(() => _n("yumaii_country_id").value), { data: V, status: C, refresh: J } = Ts("order-details", () => N(`orders/${R$1.params.slug}`).then((e2) => e2.data.data).catch((e2) => e2.response.data)), X = ref([]);
  watch(() => V.value, (e2) => {
    var r2;
    (null == (r2 = null == e2 ? undefined : e2.products) ? undefined : r2.length) && (X.value = e2.products.map((e3) => e3.product_order_id));
  }, { immediate: true, deep: true });
  const G = ref(R.object().shape({ reason: R.string().required(U2("ERRORS.reason")) })), H = ref({ reason: null }), K = ref(false), M = async (e2) => {
    const r2 = new FormData();
    r2.append("reason", e2.reason), X.value.map((e3, t2) => {
      r2.append(`order_product_ids[${t2}]`, e3);
    }), K.value = true;
    try {
      const e3 = await N.post(`orders/${R$1.params.slug}/return_order`, r2);
      pe.success(e3.data.message), B2.push(q$1(`/order/tracking-order/${R$1.params.slug}`));
    } catch (t2) {
      pe.error(t2.response.data.message);
    } finally {
      K.value = false;
    }
  };
  return (r2, t2, i2, o2) => {
    var a2, l2, s2, d2, c2;
    const p2 = g, m2 = Ds, k3 = resolveComponent("VeeForm"), A2 = q;
    t2(`<div${ssrRenderAttrs(mergeProps({ class: "container" }, o2))}><div data-aos="fade-right" class="my-10 max-w-[992px] mx-auto"><h2 class="font-bold text-xl sm:text-2xl mb-6 pb-6 border-b border-[#D1D1D6]">${ssrInterpolate(r2.$t("TITLES.return_order"))}</h2>`), "success" === unref(C) && (null == (a2 = unref(V)) ? undefined : a2.products) ? (t2(`<div class="p-4 lg:p-8 bg-[#F9F9F9]"><h3 class="font-bold text-xl sm:text-2xl mb-6 pb-6 border-b border-[#D1D1D6]">${ssrInterpolate(r2.$t("TITLES.order_details"))}</h3><div class="flex justify-between mb-8 font-medium text-lg items-center gap-4 flex-wrap"><div>${ssrInterpolate(r2.$t("TITLES.order"))} : ${ssrInterpolate(unref(V).order_no)}</div></div>`), (null == (l2 = unref(V)) ? undefined : l2.products) && (null == (d2 = null == (s2 = unref(V)) ? undefined : s2.products) ? undefined : d2.length) ? (t2('<div class="space-y-8"><!--[-->'), ssrRenderList(null == (c2 = unref(V)) ? undefined : c2.products, (e2) => {
      var o3, a3, l3, s3, d3, n2, u2, c3, v2;
      t2(`<div class="${ssrRenderClass([{ "border-primary bg-[#FAFAFA]": unref(X).includes(e2.product_order_id) }, "flex lg:items-center border bg-white border-[#E1E1E1] p-5 flex-wrap flex-col lg:flex-row gap-5"])}"><input type="checkbox"${ssrRenderAttr("name", `checked_${e2.product_order_id}`)}${ssrRenderAttr("id", `id_${e2.product_order_id}`)}${ssrRenderAttr("value", e2.product_order_id)} class="hidden"${ssrIncludeBooleanAttr(Array.isArray(unref(X)) ? ssrLooseContain(unref(X), e2.product_order_id) : unref(X)) ? " checked" : ""}><span style="${ssrRenderStyle(unref(X).includes(e2.product_order_id) ? { display: "none" } : null)}" class="block size-[30px] border rounded-full border-primary cursor-pointer"></span>`), t2(ssrRenderComponent(p2, { style: unref(X).includes(e2.product_order_id) ? null : { display: "none" }, onClick: (r3) => {
        return t3 = e2.product_order_id, void (X.value.includes(t3) ? X.value = X.value.filter((e3) => e3 !== t3) : X.value.push(t3));
        var t3;
      }, name: "checked", class: "cursor-pointer" }, null, i2)), t2('<div class="flex-1 flex items-center gap-5">'), t2(ssrRenderComponent(m2, { to: unref(q$1)(`/product/${e2.product_id}?color=${e2.color_id}&size=${e2.size_id}`), class: "block flex-shrink-0 relative z-0" }, { default: withCtx((r3, t3, i3, o4) => {
        var a4, l4, s4, d4;
        if (!t3) return [(null == e2 ? undefined : e2.images) && (null == (s4 = null == e2 ? undefined : e2.images) ? undefined : s4.length) ? (openBlock(), createBlock("img", { key: 0, src: null == (d4 = null == e2 ? undefined : e2.images[0]) ? undefined : d4.media, alt: e2.title, class: "size-[128px] object-cover" }, null, 8, ["src", "alt"])) : createCommentVNode("", true)];
        (null == e2 ? undefined : e2.images) && (null == (a4 = null == e2 ? undefined : e2.images) ? undefined : a4.length) ? t3(`<img${ssrRenderAttr("src", null == (l4 = null == e2 ? undefined : e2.images[0]) ? undefined : l4.media)}${ssrRenderAttr("alt", e2.title)} class="size-[128px] object-cover"${o4}>`) : t3("<!---->");
      }), _: 2 }, i2)), t2('<div class="space-y-6">'), t2(ssrRenderComponent(m2, { to: unref(q$1)(`/product/${e2.product_id}?color=${e2.color_id}&size=${e2.size_id}`) }, { default: withCtx((r3, t3, i3, o4) => {
        if (!t3) return [createVNode("h3", { class: "text-primary font-medium line-clamp-1" }, toDisplayString(e2.title), 1)];
        t3(`<h3 class="text-primary font-medium line-clamp-1"${o4}>${ssrInterpolate(e2.title)}</h3>`);
      }), _: 2 }, i2)), t2(`<div class="flex text-[#797979] text-lg items-center gap-2">${ssrInterpolate(r2.$t("TITLES.color"))} : <span>${ssrInterpolate(e2.color)} x${ssrInterpolate(e2.quantity)}</span></div><div class="font-bold text-xl text-primary">`), e2.has_offer ? t2(`<div class="flex items-center gap-2"><p class="line-through text-desc">${ssrInterpolate(e2.price)} ${ssrInterpolate((null == (d3 = null == (s3 = unref(O).countries) ? undefined : s3.find((e3) => e3.id == unref(P))) ? undefined : d3.currency) || (null == (n2 = unref(O).countries[0]) ? undefined : n2.currency))}</p><p>${ssrInterpolate(e2.offer_price)} ${ssrInterpolate((null == (c3 = null == (u2 = unref(O).countries) ? undefined : u2.find((e3) => e3.id == unref(P))) ? undefined : c3.currency) || (null == (v2 = unref(O).countries[0]) ? undefined : v2.currency))}</p></div>`) : t2(`<p>${ssrInterpolate(e2.price)} ${ssrInterpolate((null == (a3 = null == (o3 = unref(O).countries) ? undefined : o3.find((e3) => e3.id == unref(P))) ? undefined : a3.currency) || (null == (l3 = unref(O).countries[0]) ? undefined : l3.currency))}</p>`), t2(`</div></div></div><div class="flex-shrink-0 lg:ms-auto"><div class="px-8 py-2 bg-[#F5F5F5] text-center text-2xl font-medium"> X ${ssrInterpolate(e2.quantity)}</div></div></div>`);
    }), t2("<!--]--></div>")) : t2("<!---->"), t2('<div class="my-8">'), t2(ssrRenderComponent(k3, { "validation-schema": unref(G), onSubmit: M, initialValues: unref(H) }, { default: withCtx((e2, t3, i3, o3) => {
      if (!t3) return [createVNode("div", { class: "mb-8" }, [createVNode(A2, { name: "reason", label: r2.$t("LABELS.reason"), placeholder: r2.$t("INPUTS.reason"), type: "textarea", value: unref(H).reason, "onUpdate:value": (e3) => unref(H).reason = e3 }, null, 8, ["label", "placeholder", "value", "onUpdate:value"])]), createVNode("div", null, [createVNode("button", { disabled: unref(K), loading: unref(K), type: "submit", class: "base-btn capitalize w-full mb-2" }, toDisplayString(r2.$t("BUTTONS.confirm")), 9, ["disabled", "loading"])])];
      t3(`<div class="mb-8"${o3}>`), t3(ssrRenderComponent(A2, { name: "reason", label: r2.$t("LABELS.reason"), placeholder: r2.$t("INPUTS.reason"), type: "textarea", value: unref(H).reason, "onUpdate:value": (e3) => unref(H).reason = e3 }, null, i3, o3)), t3(`</div><div${o3}><button${ssrIncludeBooleanAttr(unref(K)) ? " disabled" : ""}${ssrRenderAttr("loading", unref(K))} type="submit" class="base-btn capitalize w-full mb-2"${o3}>${ssrInterpolate(r2.$t("BUTTONS.confirm"))}</button></div>`);
    }), _: 1 }, i2)), t2("</div></div>")) : t2("<!---->"), t2("</div></div>");
  };
} }, B = U.setup;
U.setup = (e2, r2) => {
  const t2 = useSSRContext();
  return (t2.modules || (t2.modules = /* @__PURE__ */ new Set())).add("pages/order/tracking-order/[slug]/return.vue"), B ? B(e2, r2) : undefined;
};

export { U as default };
//# sourceMappingURL=return-B8KgmZ3a.mjs.map
