import { g } from './SvgIcon-DRvxO0-V.mjs';
import { b as useI18n, g as useRouter, a as useNuxtApp, h as useRoute, f as useLocalePath, i as useAsyncData, _ as __nuxt_component_0$2 } from './server.mjs';
import { q } from './BaseTextInput-Bfb2_8Ur.mjs';
import { 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 j = { __name: "return", __ssrInlineRender: true, setup(h2) {
  const { t: j2 } = useI18n(), D2 = useRouter(), A = useNuxtApp().$axios, U = useRoute(), B = useLocalePath(), { data: N, status: R$1, refresh: q$1 } = useAsyncData("order-details", () => A(`orders/${U.params.slug}`).then((e2) => e2.data.data).catch((e2) => e2.response.data)), O = ref([]);
  watch(() => N.value, (e2) => {
    var r2;
    (null == (r2 = null == e2 ? undefined : e2.products) ? undefined : r2.length) && (O.value = e2.products.map((e3) => e3.product_order_id));
  }, { immediate: true, deep: true });
  const C = ref(R.object().shape({ reason: R.string().required(j2("ERRORS.reason")) })), P = ref({ reason: null }), V = ref(false), X = async (e2) => {
    const r2 = new FormData();
    r2.append("reason", e2.reason), O.value.map((e3, t2) => {
      r2.append(`order_product_ids[${t2}]`, e3);
    }), V.value = true;
    try {
      const e3 = await A.post(`orders/${U.params.slug}/return_order`, r2);
      pe.success(e3.data.message), D2.push(B(`/order/tracking-order/${U.params.slug}`));
    } catch (t2) {
      pe.error(t2.response.data.message);
    } finally {
      V.value = false;
    }
  };
  return (r2, t2, a2, o2) => {
    var s2, i2, n2, p2, h3;
    const L2 = g, z2 = __nuxt_component_0$2, j3 = resolveComponent("VeeForm"), D3 = 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(R$1) && (null == (s2 = unref(N)) ? undefined : s2.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(N).order_no)}</div><div>${ssrInterpolate(r2.$t("TITLES.date"))} : ${ssrInterpolate(unref(N).created_at)}</div></div>`), (null == (i2 = unref(N)) ? undefined : i2.products) && (null == (p2 = null == (n2 = unref(N)) ? undefined : n2.products) ? undefined : p2.length) ? (t2('<div class="space-y-8"><!--[-->'), ssrRenderList(null == (h3 = unref(N)) ? undefined : h3.products, (e2) => {
      t2(`<div class="${ssrRenderClass([{ "border-primary bg-[#FAFAFA]": unref(O).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(O)) ? ssrLooseContain(unref(O), e2.product_order_id) : unref(O)) ? " checked" : ""}><span style="${ssrRenderStyle(unref(O).includes(e2.product_order_id) ? { display: "none" } : null)}" class="block size-[30px] border rounded-full border-primary cursor-pointer"></span>`), t2(ssrRenderComponent(L2, { style: unref(O).includes(e2.product_order_id) ? null : { display: "none" }, onClick: (r3) => {
        return t3 = e2.product_order_id, void (O.value.includes(t3) ? O.value = O.value.filter((e3) => e3 !== t3) : O.value.push(t3));
        var t3;
      }, name: "checked", class: "cursor-pointer" }, null, a2)), t2('<div class="flex-1 flex items-center gap-5">'), t2(ssrRenderComponent(z2, { to: unref(B)(`/product/${e2.product_id}?color=${e2.color_id}&size=${e2.size_id}`), class: "block flex-shrink-0 relative z-0" }, { default: withCtx((r3, t3, a3, o3) => {
        var s3, i3, l2, d2;
        if (!t3) return [(null == e2 ? undefined : e2.images) && (null == (l2 = null == e2 ? undefined : e2.images) ? undefined : l2.length) ? (openBlock(), createBlock("img", { key: 0, src: null == (d2 = null == e2 ? undefined : e2.images[0]) ? undefined : d2.media, alt: e2.title, class: "size-[128px] object-cover" }, null, 8, ["src", "alt"])) : createCommentVNode("", true)];
        (null == e2 ? undefined : e2.images) && (null == (s3 = null == e2 ? undefined : e2.images) ? undefined : s3.length) ? t3(`<img${ssrRenderAttr("src", null == (i3 = null == e2 ? undefined : e2.images[0]) ? undefined : i3.media)}${ssrRenderAttr("alt", e2.title)} class="size-[128px] object-cover"${o3}>`) : t3("<!---->");
      }), _: 2 }, a2)), t2('<div class="space-y-6">'), t2(ssrRenderComponent(z2, { to: unref(B)(`/product/${e2.product_id}?color=${e2.color_id}&size=${e2.size_id}`) }, { default: withCtx((r3, t3, a3, o3) => {
        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"${o3}>${ssrInterpolate(e2.title)}</h3>`);
      }), _: 2 }, a2)), t2(`<div class="flex text-[#797979] text-lg items-center gap-2"> 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(r2.$t("TITLES.egp"))}</p><p>${ssrInterpolate(e2.offer_price)} ${ssrInterpolate(r2.$t("TITLES.egp"))}</p></div>`) : t2(`<p>${ssrInterpolate(e2.price)} ${ssrInterpolate(r2.$t("TITLES.egp"))}</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(j3, { "validation-schema": unref(C), onSubmit: X, initialValues: unref(P) }, { default: withCtx((e2, t3, a3, o3) => {
      if (!t3) return [createVNode("div", { class: "mb-8" }, [createVNode(D3, { name: "reason", label: r2.$t("LABELS.reason"), placeholder: r2.$t("INPUTS.reason"), type: "textarea", value: unref(P).reason, "onUpdate:value": (e3) => unref(P).reason = e3 }, null, 8, ["label", "placeholder", "value", "onUpdate:value"])]), createVNode("div", null, [createVNode("button", { disabled: unref(V), loading: unref(V), 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(D3, { name: "reason", label: r2.$t("LABELS.reason"), placeholder: r2.$t("INPUTS.reason"), type: "textarea", value: unref(P).reason, "onUpdate:value": (e3) => unref(P).reason = e3 }, null, a3, o3)), t3(`</div><div${o3}><button${ssrIncludeBooleanAttr(unref(V)) ? " disabled" : ""}${ssrRenderAttr("loading", unref(V))} type="submit" class="base-btn capitalize w-full mb-2"${o3}>${ssrInterpolate(r2.$t("BUTTONS.confirm"))}</button></div>`);
    }), _: 1 }, a2)), t2("</div></div>")) : t2("<!---->"), t2("</div></div>");
  };
} }, D = j.setup;
j.setup = (e2, r2) => {
  const t2 = useSSRContext();
  return (t2.modules || (t2.modules = /* @__PURE__ */ new Set())).add("pages/order/tracking-order/[slug]/return.vue"), D ? D(e2, r2) : undefined;
};

export { j as default };
//# sourceMappingURL=return-BY29QgWd.mjs.map
