1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9335],{59335:(e,t,r)=>{r.d(t,{o7:()=>P,qu:()=>w,gY:()=>T,HM:()=>v,U5:()=>b,AB:()=>F,d7:()=>A});var a=r(79040),o=r(14448),i=r(59372);let s={categories:[],categoriesLoading:!0,fetchCategories:async()=>{},refreshCategories:()=>{},products:[],productsLoading:!0,productsTotalCount:0,productsFetchFailed:!1,hasMoreProducts:!0,fetchProducts:async()=>{},loadMoreProducts:async()=>{},refreshProducts:async()=>{},addProduct:async()=>null,updateProduct:async()=>{},deleteProduct:async()=>{},cart:[],addToCart:()=>{},removeFromCart:()=>{},updateQuantity:()=>{},clearCart:()=>{},cartTotal:0,isCartOpen:!1,setIsCartOpen:()=>{},wishlist:[],toggleWishlist:()=>{},fetchWishlist:async()=>{},searchQuery:"",setSearchQuery:()=>{},clearSearchQuery:()=>{},notifications:[],addNotification:()=>{},intendedView:null,setIntendedView:()=>{},isDarkMode:!1,toggleDarkMode:()=>{},discount:0,appliedPromoCode:null,applyDiscount:async()=>!1,clearAppliedPromoCode:()=>{}};var c=r(17952),u=r(81292),l=r(41217);function d(e){return!!e&&Array.isArray(e.data)&&e.data.length>0&&"number"==typeof e.timestamp&&Date.now()-e.timestamp<u.xR.CATEGORIES}function n(){let e=(0,c.bi)(u.d5.CATEGORIES,null);if(d(e))return e;try{let e=localStorage.getItem(u.d5.CATEGORIES);if(!e)return null;let t=JSON.parse(e);return d(t)?t:null}catch{return null}}var p=r(71052);let h=(0,i.createContext)(void 0),g=(0,i.createContext)(void 0),f=(0,i.createContext)(void 0),C=(0,i.createContext)(void 0),m=(0,i.createContext)(void 0),y=(0,i.createContext)(void 0),P=({children:e})=>{let t=(0,o.usePathname)(),r=(0,i.useRef)(!1),s=(0,i.useRef)(0),{notifications:d,addNotification:P}=function(){let[e,t]=(0,i.useState)([]);return{notifications:e,addNotification:(0,i.useCallback)((e,r="success")=>{t(a=>{if(a.some(t=>t.message===e))return a;let o=Math.random().toString(36).substring(7);setTimeout(()=>{t(e=>e.filter(e=>e.id!==o))},3e3);let i=[...a,{id:o,message:e,type:r}];return i.length>u.Iq?i.slice(-u.Iq):i})},[])}}(),S=function(){let e=n(),[t,r]=(0,i.useState)(()=>e?.data||[]),[a,o]=(0,i.useState)(()=>!e),s=(0,i.useCallback)(async()=>{let e=n();if(e){r(e.data),o(!1);return}o(!0);try{let e=await l.apiClient.getCategories();if(e.success&&e.data){let t=e.data;r(t);let a={data:t,timestamp:Date.now()};(0,c.FX)(u.d5.CATEGORIES,a);try{localStorage.setItem(u.d5.CATEGORIES,JSON.stringify(a))}catch{}}else throw Error(e.error||"Failed to fetch categories")}catch(e){r([])}finally{o(!1)}},[]),d=(0,i.useCallback)(()=>{(0,c.Pw)(u.d5.CATEGORIES);try{localStorage.removeItem(u.d5.CATEGORIES)}catch{}s()},[s]);return{categories:t,categoriesLoading:a,fetchCategories:s,refreshCategories:d}}(),w=function(e){let t,r=(0,i.useRef)(void 0);void 0===r.current&&(r.current=function(){try{let e=sessionStorage.getItem("blogtriggers_products_cache");if(!e)return null;let t=JSON.parse(e);if(t.timestamp&&Date.now()-t.timestamp<u.xR.PRODUCTS&&Array.isArray(t.data)&&t.data.length>0)return{data:t.data,timestamp:t.timestamp,totalCount:t.totalCount,hasMore:t.hasMore}}catch{}return null}());let a=r.current,[o,s]=(0,i.useState)(()=>a?.data||[]),[c,d]=(0,i.useState)(a?.totalCount||a?.data.length||0),[n,p]=(0,i.useState)(!1),[h,g]=(0,i.useState)(a?.hasMore??!0),[f,C]=(0,i.useState)(!1),[m,y]=(0,i.useState)(!a),P=(0,i.useRef)(a?.data.length||0),S=(0,i.useRef)(a?.timestamp||0),w=(0,i.useRef)(new Map),v=(t=(0,i.useCallback)(async(t,r)=>{try{let a=await l.apiClient.createAdminProduct(t);if(!a.success)throw Error(a.error);return e(`Product "${t.title}" created successfully`),await r(),a.data?.id||null}catch(t){return e("Failed to create product","error"),null}},[e]),{addProduct:t,updateProduct:(0,i.useCallback)(async(t,r,a,o)=>{let i=[...a];o(e=>e.map(e=>e.id===t?{...e,...r}:e));try{let a=await l.apiClient.updateAdminProduct(t,r);if(!a.success)throw Error(a.error);e("Product updated successfully")}catch(t){throw o(i),e("Failed to update product","error"),t}},[e]),deleteProduct:(0,i.useCallback)(async(t,r,a)=>{let o=[...r];a(e=>e.filter(e=>e.id!==t));try{let r=await l.apiClient.deleteAdminProduct(t);if(!r.success)throw Error(r.error);e("Product deleted","info")}catch(t){a(o),e("Failed to delete product","error")}},[e])}),T=(0,i.useRef)(a?.data.length||0),A=(0,i.useCallback)(async(t=!1)=>{let r=Date.now();if(!t&&T.current>0&&r-S.current<u.xR.PRODUCTS)return void y(!1);let a="fetchProducts";if(w.current.has(a))return w.current.get(a);y(!0),P.current=0;let o=(async()=>{try{let e=await l.apiClient.getProducts({page:1,limit:u.hv});if(!e.success)throw Error(e.error);d(e.pagination?.total||0),S.current=r;let t=(e.data||[]).map(u.iL).filter(u.KA);s(t),T.current=t.length,P.current=t.length,g(e.pagination?.hasMore||!1);try{sessionStorage.setItem("blogtriggers_products_cache",JSON.stringify({data:t,timestamp:Date.now(),totalCount:e.pagination?.total||t.length,hasMore:e.pagination?.hasMore||!1}))}catch{}}catch(t){e("Failed to load products. Please refresh.","error"),p(!0)}finally{y(!1),w.current.delete(a)}})();return w.current.set(a,o),o},[e]),F=(0,i.useCallback)(async()=>
1{if(!h||m||f)return;let t="loadMoreProducts";if(w.current.has(t))return w.current.get(t);C(!0);let r=(async()=>{try{let e=Math.floor(P.current/u.hv)+2,t=await l.apiClient.getProducts({page:e,limit:u.hv});if(!t.success)throw Error(t.error);let r=(t.data||[]).map(u.iL).filter(u.KA);r.length>0&&(s(e=>[...e,...r]),P.current+=r.length),t.pagination?.total&&d(t.pagination.total),g(t.pagination?.hasMore||!1)}catch(t){e("Failed to load more products.","error")}finally{C(!1),w.current.delete(t)}})();return w.current.set(t,r),r},[h,m,f,e]),b=(0,i.useCallback)(async()=>{p(!1),S.current=0;try{sessionStorage.removeItem("blogtriggers_products_cache")}catch{}await A(!0)},[A]),M=(0,i.useCallback)(async e=>v.addProduct(e,b),[v,b]),R=(0,i.useCallback)(async(e,t)=>v.updateProduct(e,t,o,s),[v,o]),E=(0,i.useCallback)(async e=>v.deleteProduct(e,o,s),[v,o]);return{products:o,productsLoading:m,productsTotalCount:c,productsFetchFailed:n,hasMoreProducts:h,fetchProducts:A,loadMoreProducts:F,refreshProducts:b,addProduct:M,updateProduct:R,deleteProduct:E}}(P),v=function(e,t){let r=(0,i.useCallback)(e=>{let t=new Set;return e.reduce((e,r)=>{let a=String(r.id);return!a||t.has(a)||(t.add(a),e.push({...r,quantity:1})),e},[])},[]),[a,o]=(0,i.useState)(()=>{{let e=(0,c.bi)(u.d5.CART,null);if(e&&e.version===u.d5.CART_VERSION&&Array.isArray(e.items)&&Date.now()-e.timestamp<u.xR.CART){let t=new Set;return e.items.reduce((e,r)=>{let a=String(r.id);return!a||t.has(a)||(t.add(a),e.push({...r,quantity:1})),e},[])}}return[]}),[s,l]=(0,i.useState)(!1),d=(0,i.useRef)(a);(0,i.useEffect)(()=>{d.current=a},[a]),(0,i.useEffect)(()=>{(0,c.FX)(u.d5.CART,{version:u.d5.CART_VERSION,items:a,timestamp:Date.now()})||a.length},[a]),(0,i.useEffect)(()=>{if(0===t.length)return;let e=d.current;if(0===e.length)return;let a=!1,i=r(e).map(e=>{let r=t.find(t=>t.id===e.id);return r&&(r.price!==e.price||r.isFree!==e.isFree||r.category!==e.category||1!==e.quantity)?(a=!0,{...e,price:r.price,isFree:r.isFree,category:r.category,quantity:1}):e});i.length!==e.length&&(a=!0),a&&o(i)},[t,r]);let n=(0,i.useCallback)((t,r)=>{if(d.current.some(e=>e.id===t.id)){e(`${t.title} is already in your cart`,"info"),l(!0);return}o(a=>a.length>=u.dF?(e(`Cart limit reached (max ${u.dF} items)`,"error"),a):a.find(e=>e.id===t.id)?a:[...a,{id:t.id,title:t.title,price:t.price,isFree:t.isFree,category:t.category,image:t.image,slug:t.slug,quantity:1,selectedColor:r}]),e(`Added ${t.title} to cart`),l(!0)},[e]),p=(0,i.useCallback)((e,t)=>{o(r=>r.filter(r=>r.id!==e||r.selectedColor!==t))},[]),h=(0,i.useCallback)((t,r,a)=>{o(e=>e.map(e=>e.id===t&&e.selectedColor===a?{...e,quantity:1}:e)),r>0&&e("Digital products can only be added once per order","info")},[e]),g=(0,i.useCallback)(()=>{o([]),(0,c.Pw)(u.d5.CART)},[]),f=Number(a.reduce((e,t)=>e+t.price*t.quantity,0).toFixed(2));return{cart:a,addToCart:n,removeFromCart:p,updateQuantity:h,clearCart:g,cartTotal:f,isCartOpen:s,setIsCartOpen:l}}(P,w.products),T=function(e){let[t,r]=(0,i.useState)([]),a=(0,i.useRef)(new Set),o=(0,i.useCallback)(async e=>{if(e&&"string"==typeof e&&""!==e.trim())try{let e=await l.apiClient.getWishlist();if(!e.success)return;if(e.data){let t=e.data.map(e=>String(e));r(e=>{let r=[...new Set([...t,...e])],a=e.filter(e=>!t.includes(e));return a.length>0&&a.forEach(e=>{l.apiClient.addToWishlist(e).catch(()=>{})}),r})}}catch(e){}},[]),s=(0,i.useCallback)(async(o,i)=>{if(!o||"string"!=typeof o||""===o.trim()||a.current.has(o))return;a.current.add(o);let s=t.includes(o);if(s?(r(e=>e.filter(e=>e!==o)),e("Removed from wishlist","info")):(r(e=>[...e,o]),e("Saved to wishlist")),i&&"string"==typeof i&&i.trim())try{s?await l.apiClient.removeFromWishlist(o):await l.apiClient.addToWishlist(o)}catch(t){s?r(e=>[...e,o]):r(e=>e.filter(e=>e!==o)),e("Failed to sync wishlist","error")}finally{a.current.delete(o)}else a.current.delete(o)},[t,e]);return{wishlist:t,toggleWishlist:s,fetchWishlist:o}}(P),A=function(e,t){let[r,a]=(0,i.useState)(0),[o,s]=(0,i.useState)(null),[c,u]=(0,i.useState)(new Set),[d,n]=(0,i.useState)([]);return{discount:r,appliedPromoCode:o,applyDiscount:(0,i.useCallback)(async r=>{if(!r||"string"!=typeof r||0===r.trim().length)return e("Please enter a promo code","error"),!1;let o=r.trim().toUpperCase();if(c.has(o))return e("This promo code has already been applied in this session","error"),!1;let i=t.filter(e=>e.price>0).reduce((e,t)=>
1e+t.price*t.quantity,0);if(0===t.length||0===i)return e("Promo codes can only be applied to paid items","error"),!1;let h=d.find(e=>e.code.toUpperCase()===o&&e.isActive);if(h)return h.expiresAt&&new Date(h.expiresAt)<new Date?(e("This promo code has expired","error"),!1):h.maxUsage&&h.usageCount>=h.maxUsage?(e("This promo code has reached its usage limit","error"),!1):(a(h.discount),s(o),u(e=>new Set([...e,o])),e(`Code applied! ${Math.round(100*h.discount)}% Off`),!0);try{let t=await l.apiClient.validatePromoCode(o),r=(0,p.qY)(t.data);if(!t.success||!r.isValid)return e(t.error||"Invalid or inactive promo code","error"),!1;let i=(0,p.Me)(r.discount);return a(i),s(o),u(e=>new Set([...e,o])),n(e=>e.some(e=>e.id===r.id)?e:[...e,{id:(0,p.wK)(r.id),code:o,discount:i,description:(0,p.wK)(r.description),isActive:!0,expiresAt:(0,p.wK)(r.expiresAt||r.expires_at)||void 0,usageCount:(0,p.Me)(r.usageCount||r.usage_count),maxUsage:r.maxUsage||r.max_usage?(0,p.Me)(r.maxUsage||r.max_usage):void 0}]),e(`Code applied! ${Math.round(100*i)}% Off`),!0}catch(t){return e("Failed to validate promo code. Please try again.","error"),!1}},[t,d,c,e]),clearAppliedPromoCode:(0,i.useCallback)(()=>{a(0),s(null)},[])}}(P,v.cart),F=v.clearCart,b=A.clearAppliedPromoCode,[M,R]=(0,i.useState)(""),[E,O]=(0,i.useState)(null),k=(0,i.useCallback)(()=>{},[]),[x,_]=(0,i.useState)(0),I="/"===t||"/checkout"===t||t.startsWith("/user"),D=S.fetchCategories,U=w.fetchProducts;(0,i.useEffect)(()=>{I&&(!r.current||0!==x)&&(r.current=!0,Promise.allSettled([D(),U()]).then(e=>{!e.every(e=>"fulfilled"===e.status)&&s.current<2&&(s.current++,setTimeout(()=>_(e=>e+1),2e3))}))},[D,U,t,x,I]);let W=(0,i.useCallback)(()=>{F(),b()},[F,b]),L=(0,i.useCallback)(()=>R(""),[]),N=(0,i.useMemo)(()=>({categories:S.categories,categoriesLoading:S.categoriesLoading,fetchCategories:S.fetchCategories,refreshCategories:S.refreshCategories,products:w.products,productsLoading:w.productsLoading,productsTotalCount:w.productsTotalCount,productsFetchFailed:w.productsFetchFailed,hasMoreProducts:w.hasMoreProducts,fetchProducts:w.fetchProducts,loadMoreProducts:w.loadMoreProducts,refreshProducts:w.refreshProducts,addProduct:w.addProduct,updateProduct:w.updateProduct,deleteProduct:w.deleteProduct,cart:v.cart,addToCart:v.addToCart,removeFromCart:v.removeFromCart,updateQuantity:v.updateQuantity,clearCart:W,cartTotal:v.cartTotal,isCartOpen:v.isCartOpen,setIsCartOpen:v.setIsCartOpen,wishlist:T.wishlist,toggleWishlist:T.toggleWishlist,fetchWishlist:T.fetchWishlist,searchQuery:M,setSearchQuery:R,clearSearchQuery:L,notifications:d,addNotification:P,intendedView:E,setIntendedView:O,isDarkMode:!0,toggleDarkMode:k,discount:A.discount,appliedPromoCode:A.appliedPromoCode,applyDiscount:A.applyDiscount,clearAppliedPromoCode:A.clearAppliedPromoCode}),[P,v.addToCart,v.cart,v.cartTotal,v.isCartOpen,v.removeFromCart,v.setIsCartOpen,v.updateQuantity,S.categories,S.categoriesLoading,S.fetchCategories,S.refreshCategories,W,L,E,!0,d,w.addProduct,w.deleteProduct,w.fetchProducts,w.hasMoreProducts,w.loadMoreProducts,w.products,w.productsFetchFailed,w.productsLoading,w.productsTotalCount,w.refreshProducts,w.updateProduct,A.appliedPromoCode,A.applyDiscount,A.clearAppliedPromoCode,A.discount,M,k,T.fetchWishlist,T.toggleWishlist,T.wishlist]),q=(0,i.useMemo)(()=>({categories:S.categories,categoriesLoading:S.categoriesLoading,fetchCategories:S.fetchCategories,refreshCategories:S.refreshCategories,products:w.products,productsLoading:w.productsLoading,productsTotalCount:w.productsTotalCount,productsFetchFailed:w.productsFetchFailed,hasMoreProducts:w.hasMoreProducts,fetchProducts:w.fetchProducts,loadMoreProducts:w.loadMoreProducts,refreshProducts:w.refreshProducts,addProduct:w.addProduct,updateProduct:w.updateProduct,deleteProduct:w.deleteProduct}),[S.categories,S.categoriesLoading,S.fetchCategories,S.refreshCategories,w.addProduct,w.deleteProduct,w.fetchProducts,w.hasMoreProducts,w.loadMoreProducts,w.products,w.productsFetchFailed,w.productsLoading,w.productsTotalCount,w.refreshProducts,w.updateProduct]),Q=(0,i.useMemo)(()=>({cart:v.cart,addToCart:v.addToCart,removeFromCart:v.removeFromCart,updateQuantity:v.updateQuantity,clearCart:W,cartTotal:v.cartTotal,isCartOpen:v.isCartOpen,setIsCartOpen:v.setIsCartOpen}),[v.addToCart,v.cart,v.cartTotal,v.isCartOpen,v.removeFromCart,v.setIsCartOpen,v.updateQuantity,W]),G=(0,i.useMemo)(()=>({wishlist:T.wishlist,toggleWishlist:T.toggleWishlist,fetchWishlist:T.fetchWishlist}),[T.fetchWishlist,T.toggleWishlist,T.wishlist]),j=(0,i.useMemo)(()=>({searchQuery:M,setSearchQuery:R,clearSearchQuery:L}),[L,M]),$=(0,i.useMemo)(()=>({notifications:d,addNotification:P}),[P,d]);return(0,a.jsx)(g.Provider,{value:q,children:(0,a.jsx)(f.Provider,{value:Q,children:(0,a.jsx)(C.Provider,{value:G,children:(0,a.jsx)(m.Provider,{value:j,children:(0,a.jsx)(y.Provider,{value:$,children:(0,a.jsx)(h.Provider,{value:N,children:e})})})})})})};function S(e,t,r){let a=(0,i.useContext)(e);if(a)return a;throw Error(`${r} must be used within ShopProvider`)}let w=()=>S(h,s,"useShop"),v=()=>S(g,s,"useShopCatalog"),T=()=>S(f,s,"useShopCart"),A=()=>S(C,s,"useShopWishlist"),F=()=>S(m,s,"useShopSearch"),b=()=>S(y,s,"useShopNotifications")},71052:(e,t,r)=>{function a(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function o(e){return a(e)?e:{}}function i(e){return Array.isArray(e)?e.filter(a):[]}function s(e,t=""){return"string"==typeof e?e:null==e?t:String(e)}function c(e,t=0){let r=Number(e);return Number.isFinite(r)?r:t}function u(e){return!0===e||"true"===e||1===e||"1"===e}r.d(t,{Dr:()=>u,Me:()=>c,jd:()=>i,qY:()=>o,wK:()=>s})},81292:(e,t,r)=>{r.d(t,{Iq:()=>l,KA:()=>a,d5:()=>i,dF:()=>u,hv:()=>c,iL:()=>o,xR:()=>s});let a=e=>!!(e&&("string"==typeof e.id||"number"==typeof e.id)&&"string"==typeof e.title&&e.title.length>0&&"number"==typeof e.price)&&(e.slug&&"string"==typeof e.slug&&0!==e.slug.length||(e.slug=e.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")),!0),o=e=>({id:e.id??"",title:e.title??"",slug:e.slug??"",price:e.price??0,category:e.category??"",image:e.image??"",images:e.images||[],description:e.description??"",rating:e.rating||4.5,colors:e.colors||[],frameworks:e.frameworks||[],features:e.features||[],previewUrl:e.previewUrl,version:e.version,author:e.author,lastUpdate:e.lastUpdate,fileSize:e.fileSize,isFree:e.isFree,livePreviewUrl:e.livePreviewUrl,documentationUrl:e.documentationUrl,zipFileUrl:e.zipFileUrl,downloadCount:e.downloadCount||0,reviewCount:e.reviewCount||0}),i={CART:"blogtriggers_cart",CART_VERSION:"1",CATEGORIES:"blogtriggers_categories_v2",PRODUCTS_CACHE:"blogtriggers_products_cache"},s={CATEGORIES:36e5,PRODUCTS:3e5,CART:6048e5},c=50,u=99,l=5}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.