"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7529],{7529:(e,t,r)=>{function s(e){if(!e)return"/";let t=e.trim();if(t.startsWith("mailto:")||t.startsWith("tel:")||t.startsWith("#")||t.startsWith("javascript:"))return t;try{if(t.startsWith("http://")||t.startsWith("https://")){let e=new URL(t);t=e.pathname+e.search+e.hash}}catch{}let r=t.startsWith("/")?t:`/${t}`;return r.startsWith("/knottele")&&(r=r.replace(/^\/knottele(?:\/|$)/,"/")),!r||r.includes("?")||r.includes("#")||/\.[a-zA-Z0-9]+$/.test(r)||r.endsWith("/")||(r=`${r}/`),r||"/"}function a(e,t){if(!e||!t)return!1;let r=e=>{let t=e.startsWith("/knottele")?e.replace(/^\/knottele(?:\/|$)/,"/"):e,r=(t=t.split("?")[0].split("#")[0].trim()).replace(/\/+$/,"");return""===r?"/":r};return r(e)===r(t)}function o(e){let t=e.startsWith("/")?e:`/${e}`;return t.startsWith("/knottele")&&(t=t.replace(/^\/knottele(?:\/|$)/,"/")),t||"/"}r.d(t,{$E:()=>B,$L:()=>b,A8:()=>D,GE:()=>v,Gr:()=>f,HF:()=>_,Io:()=>$,Ko:()=>E,LZ:()=>S,Me:()=>m,Mn:()=>g,Ps:()=>P,Qk:()=>U,R0:()=>Z,RS:()=>y,SI:()=>C,Sh:()=>N,Z2:()=>W,Z7:()=>A,ZG:()=>R,_t:()=>M,bc:()=>I,bq:()=>F,c:()=>j,dy:()=>o,fy:()=>T,gZ:()=>a,hw:()=>L,ii:()=>z,j$:()=>J,j0:()=>h,jE:()=>p,l6:()=>O,mw:()=>q,nT:()=>s,oY:()=>k,qs:()=>V,wE:()=>x,wU:()=>w}),r(1463);let n=new Map,c=new Map;function i(e,t,r=6e4){let s=n.get(e);if(s&&Date.now()-s.timestamp(null!=t&&n.set(e,{data:t,timestamp:Date.now()}),t)).finally(()=>{c.delete(e)});return c.set(e,a),a}let u=()=>("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)&&"3000"===window.location.port?"http://127.0.0.1:8000/api":"/api",l=new Set(["bunny-keychain.jpg","sunflower-stem.jpg","rose-bouquet.jpg","teddy-bear.jpg","daisy-phone-cover.jpg","granny-square-bag.jpg","strawberry-coin-purse.jpg","tulip-mug-cozy.jpg","sprout-bookmark.jpg","floral-scrunchies.jpg","crochet-vest.jpg","potted-tulips.jpg"]);function m(e,t="/images/products/bunny-keychain.jpg"){if(!e)return t;let r=e.trim();if(r.split("?")[0].toLowerCase().endsWith(".json"))return t;r=r.replace(/^https?:\/\/(127\.0\.0\.1|localhost):8000/,"");let s=r.split("/").pop()?.split("?")[0]||"";if(l.has(s))return`/images/products/${s}`;try{if(r.startsWith("http://")||r.startsWith("https://")){let e=new URL(r);if(e.hostname!==window.location.hostname&&"187.127.158.24"!==e.hostname&&"localhost"!==e.hostname&&"127.0.0.1"!==e.hostname)return r;r=e.pathname+e.search}}catch{}return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("data:")||r.startsWith("/")?r:`/${r}`}function d(e){let t=e.main_image||(e.images&&e.images.length>0?"string"==typeof e.images[0]?e.images[0]:e.images[0].url:"/images/logo/Logo_1.png"),r=m(t),s=(e.images&&e.images.length>0?e.images.map(e=>"string"==typeof e?e:e.url):[t]).map(e=>m(e)),a="string"==typeof e.category?e.category:e.category?.name||"Handmade",o=e.category_slug||("object"==typeof e.category?e.category?.slug:null)||"all",n=e.variants&&e.variants.length>0?Array.from(new Set(e.variants.map(e=>e.size||(e.price?`Size (₹${e.price})`:"Standard")).filter(Boolean))):["Standard Size"];return{id:String(e.id),slug:e.slug,name:e.name,category:a,categorySlug:o,price:Number(e.price)||0,comparePrice:e.compare_price?Number(e.compare_price):void 0,images:s.length>0?s:[r],description:e.description||e.short_description||"",shortDescription:e.short_description||"",materials:["100% Pure Natural Cotton","Hypoallergenic Fiberfill","Artisan Hand-stitched"],dimensions:"Standard Artisan Craft Size",craftTime:"2-4 hours of meticulous handcrafting",colors:[{name:"Artisan Natural",hex:"#FFFDF9"},{name:"Blush Rose",hex:"#F8C8C8"},{name:"Sage Garden",hex:"#D8E2DC"},{name:"Dusty Terracotta",hex:"#E8B4B8"}],sizes:n.length>0?n:["Standard Size"],isCustomizable:!0,isFeatured:!!e.is_featured,isBestSeller:!!e.is_bestseller,isNew:!!e.is_new,rating:e.rating?Number(e.rating):4.9,reviewCount:e.review_count?Number(e.review_count):16,stock:e.stock_quantity??25,tags:[o,"handmade","crochet","boutique","gift"],reviews:e.reviews_data&&e.reviews_data.length>0?e.reviews_data.map(e=>({id:String(e.id),userName:e.user_name||"Boutique Customer",rating:Number(e.rating||5),date:e.created_at||"Recently",comment:e.review||"Exquisite craftsmanship, wonderful quality!",verified:!0})):[{id:"rev-default",userName:"Verified Patron",rating:5,date:"Recent",comment:"Exquisite craftsmanship, the stitches are neat and the yarn is delightfully soft!",verified:!0}]}}async function p(){return i("categories_list",async()=>{try{let e=`${u()}/customer/categories`,t=await fetch(e,{headers:{Accept:"application/json"}}),r=await t.json();if("success"===r.status&&Array.isArray(r.data))return r.data;return[]}catch(e){return console.warn("Fetch categories network issue:",e),[]}},3e5)}async function h(e){let t=new URLSearchParams;e?.category_id&&t.set("category_id",String(e.category_id)),e?.search&&t.set("search",e.search),e?.min_price!==void 0&&t.set("min_price",String(e.min_price)),e?.max_price!==void 0&&t.set("max_price",String(e.max_price)),e?.is_featured!==void 0&&t.set("is_featured",String(e.is_featured)),e?.is_bestseller!==void 0&&t.set("is_bestseller",String(e.is_bestseller)),e?.is_new!==void 0&&t.set("is_new",String(e.is_new)),e?.sort_by&&t.set("sort_by",e.sort_by),e?.per_page&&t.set("per_page",String(e.per_page)),e?.in_stock&&t.set("in_stock","true");let r=t.toString();return i(`products_${r||"default"}`,async()=>{try{let e=`${u()}/customer/products${r?`?${r}`:""}`,t=await fetch(e,{headers:{Accept:"application/json"}}),s=await t.json();if(s.success&&s.data&&Array.isArray(s.data.products))return{products:s.data.products.map(d),rawApiProducts:s.data.products,meta:s.data.meta,filters:s.data.filters};return{products:[]}}catch(e){return console.warn("Fetch products error:",e),{products:[]}}},6e4)}async function g(e){return i(`product_slug_${e}`,async()=>{try{let t=`${u()}/customer/products/${encodeURIComponent(e)}`,r=await fetch(t,{headers:{Accept:"application/json"}}),s=await r.json();if(s.success&&s.data)return d(s.data);return null}catch(t){return console.warn(`Fetch product by slug (${e}) error:`,t),null}},3e5)}async function f(e){return i(`product_related_${e}`,async()=>{try{let t=`${u()}/customer/products/${e}/related`,r=await fetch(t,{headers:{Accept:"application/json"}}),s=await r.json();if(s.success&&Array.isArray(s.data))return s.data.map(d);return[]}catch(e){return console.warn("Fetch related products error:",e),[]}},3e5)}async function y(e){try{let t=await fetch(`${u()}/customer/contact`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({name:e.name,email:e.email,phone:e.phone?e.phone.replace(/\D/g,"").slice(-10):void 0,subject:e.subject||void 0,message:e.message})}),r=await t.json();if(t.ok&&("success"===r.status||!0===r.success))return{success:!0,message:r.message||"Message sent successfully."};return{success:!1,message:r.message||"Failed to submit message."}}catch(e){return console.warn("Contact API network issue:",e),{success:!1,message:"Network error. Please try again."}}}async function w(e){try{let t=e;if(!t){let e=localStorage.getItem("knotelle_customer_user");if(e)try{let r=JSON.parse(e);r.email&&(t=r.email)}catch{}t||(t=localStorage.getItem("knotelle_guest_email")||void 0)}let r=localStorage.getItem("knotelle_customer_token"),s=t?`${u()}/customer/orders?email=${encodeURIComponent(t)}`:`${u()}/customer/orders`,a={Accept:"application/json"};r&&(a.Authorization=`Bearer ${r}`);let o=await fetch(s,{headers:a,cache:"no-store"}),n=await o.json();if(n.success&&Array.isArray(n.data))return n.data;return[]}catch(e){return console.warn("Failed to fetch customer orders:",e),[]}}async function _(e,t){try{let r=t;if(!r){let e=localStorage.getItem("knotelle_customer_user");if(e)try{let t=JSON.parse(e);t.email&&(r=t.email)}catch{}r||(r=localStorage.getItem("knotelle_guest_email")||void 0)}let s=localStorage.getItem("knotelle_customer_token"),a=r?`?email=${encodeURIComponent(r)}`:"",o=`${u()}/customer/orders/${encodeURIComponent(e)}${a}`,n={Accept:"application/json"};s&&(n.Authorization=`Bearer ${s}`);let c=await fetch(o,{headers:n,cache:"no-store"}),i=await c.json();if(i.success&&i.data)return i.data;return null}catch(e){return console.warn("Failed to fetch order detail by id:",e),null}}async function j(e){try{let t=localStorage.getItem("knotelle_customer_token"),r={Accept:"application/json"};t&&(r.Authorization=`Bearer ${t}`);let s=await fetch(`${u()}/customer/custom-orders`,{method:"POST",headers:r,body:e}),a=await s.json();if(s.ok&&a.success)return{success:!0,message:a.message||"Custom order submitted successfully!",data:a.data,reference_id:a.reference_id||a.data?.reference_id};return{success:!1,message:a.message||"Failed to submit custom order."}}catch(e){return console.warn("Submit custom order error:",e),{success:!1,message:"Network error. Please try submitting again."}}}async function S(e){try{let t=e;if(!t){let e=localStorage.getItem("knotelle_customer_user");if(e)try{let r=JSON.parse(e);r.email&&(t=r.email)}catch{}t||(t=localStorage.getItem("knotelle_guest_email")||void 0)}let r=localStorage.getItem("knotelle_customer_token"),s=t?`${u()}/customer/custom-orders?email=${encodeURIComponent(t)}`:`${u()}/customer/custom-orders`,a={Accept:"application/json"};r&&(a.Authorization=`Bearer ${r}`);let o=await fetch(s,{headers:a,cache:"no-store"}),n=await o.json();if(n.success&&Array.isArray(n.data))return n.data;return[]}catch(e){return console.warn("Failed to fetch customer custom orders:",e),[]}}async function $(e){try{let t=null==e||isNaN(e)?"":`&subtotal=${encodeURIComponent(e)}`,r=`${u()}/customer/offers/active?_t=${Date.now()}${t}`,s=await fetch(r,{headers:{Accept:"application/json"},cache:"no-store"}),a=await s.json();if(a.success&&Array.isArray(a.data))return a.data;return[]}catch(e){return console.warn("Failed to fetch active offers:",e),[]}}async function k(e,t){try{let r=await fetch(`${u()}/customer/offers/validate`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({code:e.trim().toUpperCase(),subtotal:t})}),s=await r.json();if(r.ok&&s.success&&s.data)return{success:!0,discount_amount:s.data.discount_amount,offer:s.data.offer,message:s.message};return{success:!1,message:s.message||"Invalid or expired coupon code."}}catch(e){return console.warn("Validate offer error:",e),{success:!1,message:"Connection error validating offer code."}}}async function A(e){try{let t=localStorage.getItem("knotelle_customer_token"),r={"Content-Type":"application/json",Accept:"application/json"};t&&(r.Authorization=`Bearer ${t}`);let s=await fetch(`${u()}/customer/orders`,{method:"POST",headers:r,body:JSON.stringify(e)}),a=await s.json();if(s.ok&&a.success)return{success:!0,orderId:a.data?.order_id,orderNumber:a.data?.order_number,message:a.message};return{success:!1,message:a.message||"Order placement failed."}}catch(e){return console.warn("Order submit error:",e),{success:!1,message:"Connection error"}}}async function b(e,t="INR",r){try{let s=Math.max(100,Math.round(e)),a=await fetch(`${u()}/customer/payment/razorpay/order`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({amount:s,currency:t,receipt:r})});404===a.status&&(a=await fetch(`${u()}/create-order`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({amount:s,currency:t,receipt:r})}));let o=await a.text(),n={};try{n=JSON.parse(o)}catch{return{success:!1,message:`Server error (${a.status})`}}return n}catch(e){return console.error("Create Razorpay Order error:",e),{success:!1,message:"Network error creating Razorpay order."}}}async function v(e){try{let t=await fetch(`${u()}/customer/payment/razorpay/verify`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});404===t.status&&(t=await fetch(`${u()}/verify-payment`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}));let r=await t.text(),s={};try{s=JSON.parse(r)}catch{return{success:!1,message:`Server error (${t.status})`}}return s}catch(e){return console.error("Verify Razorpay Payment error:",e),{success:!1,message:"Network error verifying Razorpay payment."}}}async function C(e){try{let t=await fetch(`${u()}/customer/register`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({...e,password_confirmation:e.password_confirmation||e.password})}),r=await t.text(),s={};try{s=JSON.parse(r)}catch{return{success:!1,message:504===t.status?"Server timeout. Please try again.":`Server error (${t.status}). Please try again.`}}if(t.ok&&s.success)return{success:!0,token:s.token,user:s.user,email:s.email,requires_otp:!!s.requires_otp,message:s.message||"Registration successful!"};return{success:!1,message:s.message||(s.errors?Object.values(s.errors).flat().join(", "):"Registration failed.")}}catch(e){return console.warn("Register customer error:",e),{success:!1,message:"Connection error. Please try again."}}}async function O(e){try{let t=await fetch(`${u()}/customer/verify-otp`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await t.text(),s={};try{s=JSON.parse(r)}catch{return{success:!1,message:504===t.status?"Server timeout. Please try again.":`Server error (${t.status}). Please try again.`}}if(t.ok&&s.success)return{success:!0,token:s.token,user:s.user,message:s.message||"Email verified successfully!"};return{success:!1,message:s.message||(s.errors?Object.values(s.errors).flat().join(", "):"Verification failed.")}}catch(e){return console.warn("Verify OTP error:",e),{success:!1,message:"Connection error. Please try again."}}}async function P(e){try{let t=await fetch(`${u()}/customer/resend-otp`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await t.json();if(t.ok&&r.success)return{success:!0,message:r.message||"Verification code sent!"};return{success:!1,message:r.message||"Failed to resend verification code.",cooldown_remaining:r.cooldown_remaining}}catch(e){return console.warn("Resend OTP error:",e),{success:!1,message:"Connection error. Please try again."}}}function T(e){if(!e)return"/account/";let t=e.trim();return!t.startsWith("/")||t.startsWith("//")||t.startsWith("/\\")||t.includes(":\\")||t.includes("://")||t.toLowerCase().includes("javascript:")?"/account/":t}async function N(e){try{let t=await fetch(`${u()}/customer/login`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await t.text(),s={};try{s=JSON.parse(r)}catch{return{success:!1,message:504===t.status?"Server timeout. Please try again.":`Server error (${t.status}). Please try again.`}}if(t.ok&&s.success)return{success:!0,token:s.token,user:s.user,message:s.message||"Login successful!"};return{success:!1,message:s.message||"Invalid email or password."}}catch(e){return console.warn("Login customer error:",e),{success:!1,message:"Connection error. Please try again."}}}async function I(){try{let e=localStorage.getItem("knotelle_customer_token");return e&&await fetch(`${u()}/customer/logout`,{method:"POST",headers:{Accept:"application/json",Authorization:`Bearer ${e}`}}),{success:!0}}catch(e){return console.warn("Logout API error:",e),{success:!0}}}async function z(){try{let e=localStorage.getItem("knotelle_customer_token");if(!e)return{success:!1,message:"No token"};let t=await fetch(`${u()}/customer/profile?_t=${Date.now()}`,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`},cache:"no-store"}),r=await t.json();if(t.ok&&r.success&&r.user)return{success:!0,user:r.user};return{success:!1,message:r.message||"Unauthenticated."}}catch(e){return console.warn("Fetch customer profile error:",e),{success:!1,message:"Connection error."}}}async function F(e){try{let t=await fetch(`${u()}/customer/forgot-password`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({email:e})}),r=await t.json();return{success:t.ok&&r.success,message:r.message||"If that email is registered, instructions have been sent."}}catch(e){return console.warn("Forgot password error:",e),{success:!1,message:"Connection error. Please try again."}}}async function R(e){try{let t=await fetch(`${u()}/customer/reset-password`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await t.json();return{success:t.ok&&r.success,message:r.message||"Password update failed."}}catch(e){return console.warn("Reset password error:",e),{success:!1,message:"Connection error. Please try again."}}}async function J(e){try{let t=localStorage.getItem("knotelle_customer_token"),r=await fetch(`${u()}/customer/update-profile`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(e)}),s=await r.json();if(r.ok&&s.success)return{success:!0,user:s.user,message:s.message||"Profile updated successfully!"};return{success:!1,message:s.message||(s.errors?Object.values(s.errors).flat().join(", "):"Failed to update profile.")}}catch(e){return console.warn("Update customer profile error:",e),{success:!1,message:"Connection error. Please try again."}}}async function W(){return i("homepage_media",async()=>{try{let e=`${u()}/customer/media`,t=await fetch(e,{headers:{Accept:"application/json"}});if(!t.ok)return console.warn(`Fetch homepage media returned HTTP ${t.status}`),null;let r=t.headers.get("content-type")||"";if(!r.includes("application/json"))return console.warn("Fetch homepage media received non-JSON content type:",r),null;let s=await t.json();if(s.success&&s.data)return s.data;return null}catch(e){return console.warn("Fetch homepage media error:",e),null}},18e4)}async function B(){try{let e=`${u()}/customer/about?_t=${Date.now()}`,t=await fetch(e,{headers:{Accept:"application/json"},cache:"no-store"}),r=await t.json();if(r.success&&r.data)return r.data;return null}catch(e){return console.warn("Fetch about page data error:",e),null}}async function U(e){try{await fetch(`${u()}/customer/media/video/${e}/view`,{method:"POST",headers:{Accept:"application/json"}})}catch(e){}}async function E(){try{let e=localStorage.getItem("knotelle_customer_token");if(!e)return null;let t=await fetch(`${u()}/customer/wishlist`,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`},cache:"no-store"}),r=await t.json();if(r.success)return{products:r.data||[],product_ids:r.product_ids||[]};return null}catch(e){return console.warn("Fetch wishlist error:",e),null}}async function x(e){try{let t=localStorage.getItem("knotelle_customer_token");if(!t)return null;let r=await fetch(`${u()}/customer/wishlist/${e}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${t}`}}),s=await r.json();if(s.success)return{in_wishlist:s.in_wishlist,count:s.count};return null}catch(e){return console.warn("Toggle wishlist error:",e),null}}async function D(e){try{let t=localStorage.getItem("knotelle_customer_token");if(!t)return null;let r=await fetch(`${u()}/customer/wishlist/${e}`,{method:"DELETE",headers:{Accept:"application/json",Authorization:`Bearer ${t}`}}),s=await r.json();if(s.success)return{count:s.count};return null}catch(e){return console.warn("Remove wishlist error:",e),null}}async function L(){try{let e=localStorage.getItem("knotelle_customer_token");if(!e)return null;let t=await fetch(`${u()}/customer/addresses?_t=${Date.now()}`,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`},cache:"no-store"}),r=await t.json();if(r.success&&Array.isArray(r.addresses))return r.addresses;return[]}catch(e){return console.warn("Fetch addresses error:",e),null}}async function q(e){try{let t=localStorage.getItem("knotelle_customer_token");if(!t)return{success:!1,message:"Unauthenticated"};let r=await fetch(`${u()}/customer/addresses`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(e)}),s=await r.json();if(r.ok&&s.success)return{success:!0,address:s.address,message:s.message};return{success:!1,message:s.message||"Failed to save address."}}catch(e){return console.warn("Save address error:",e),{success:!1,message:"Connection error. Please try again."}}}async function M(e){try{let t=localStorage.getItem("knotelle_customer_token");if(!t)return{success:!1,message:"Unauthenticated"};let r=await fetch(`${u()}/customer/addresses/${encodeURIComponent(e)}`,{method:"DELETE",headers:{Accept:"application/json",Authorization:`Bearer ${t}`}}),s=await r.json();return{success:r.ok&&s.success,message:s.message}}catch(e){return console.warn("Delete address error:",e),{success:!1,message:"Connection error."}}}async function V(e){try{let t=localStorage.getItem("knotelle_customer_token");if(!t)return{success:!1,message:"Unauthenticated"};let r=await fetch(`${u()}/customer/addresses/${encodeURIComponent(e)}/default`,{method:"POST",headers:{Accept:"application/json",Authorization:`Bearer ${t}`}}),s=await r.json();return{success:r.ok&&s.success,message:s.message}}catch(e){return console.warn("Set default address error:",e),{success:!1,message:"Connection error."}}}async function Z(){return i("store_settings",async()=>{try{let e=await fetch(`${u()}/customer/settings`,{headers:{Accept:"application/json"}}),t=await e.json();return t?.data||{}}catch(e){return console.warn("fetchStoreSettings error:",e),{}}},6e5)}}}]);