diff --git a/assets/index-eAIAgAOC.js b/assets/index-keS9LZg2.js similarity index 98% rename from assets/index-eAIAgAOC.js rename to assets/index-keS9LZg2.js index 4d63b76..9725476 100644 --- a/assets/index-eAIAgAOC.js +++ b/assets/index-keS9LZg2.js @@ -72,4 +72,4 @@ Error generating stack: `+i.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Cr=E;function Jm(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Zm=typeof Object.is=="function"?Object.is:Jm,qm=Cr.useSyncExternalStore,bm=Cr.useRef,ev=Cr.useEffect,tv=Cr.useMemo,nv=Cr.useDebugValue;qf.useSyncExternalStoreWithSelector=function(e,t,n,r,l){var i=bm(null);if(i.current===null){var o={hasValue:!1,value:null};i.current=o}else o=i.current;i=tv(function(){function s(v){if(!a){if(a=!0,d=v,v=r(v),l!==void 0&&o.hasValue){var y=o.value;if(l(y,v))return p=y}return p=v}if(y=p,Zm(d,v))return y;var g=r(v);return l!==void 0&&l(y,g)?y:(d=v,p=g)}var a=!1,d,p,m=n===void 0?null:n;return[function(){return s(t())},m===null?void 0:function(){return s(m())}]},[t,n,r,l]);var u=qm(e,i[0],i[1]);return ev(function(){o.hasValue=!0,o.value=u},[u]),nv(u),u};Zf.exports=qf;var rv=Zf.exports;function lv(e){e()}var bf=lv,iv=e=>bf=e,ov=()=>bf,we="default"in $i?Yo:$i,da=Symbol.for("react-redux-context"),pa=typeof globalThis<"u"?globalThis:{};function uv(){if(!we.createContext)return{};const e=pa[da]??(pa[da]=new Map);let t=e.get(we.createContext);return t||(t=we.createContext(null),e.set(we.createContext,t)),t}var Et=uv(),sv=()=>{throw new Error("uSES not initialized!")};function Wu(e=Et){return function(){return we.useContext(e)}}var ed=Wu(),td=sv,av=e=>{td=e},cv=(e,t)=>e===t;function fv(e=Et){const t=e===Et?ed:Wu(e);return function(r,l={}){const{equalityFn:i=cv,devModeChecks:o={}}=typeof l=="function"?{equalityFn:l}:l,{store:u,subscription:s,getServerState:a,stabilityCheck:d,identityFunctionCheck:p}=t();we.useRef(!0);const m=we.useCallback({[r.name](y){return r(y)}}[r.name],[r,d,o.stabilityCheck]),v=td(s.addNestedSub,u.getState,a||u.getState,m,i);return we.useDebugValue(v),v}}var jl=fv();function dv(){const e=ov();let t=null,n=null;return{clear(){t=null,n=null},notify(){e(()=>{let r=t;for(;r;)r.callback(),r=r.next})},get(){let r=[],l=t;for(;l;)r.push(l),l=l.next;return r},subscribe(r){let l=!0,i=n={callback:r,next:null,prev:n};return i.prev?i.prev.next=i:t=i,function(){!l||t===null||(l=!1,i.next?i.next.prev=i.prev:n=i.prev,i.prev?i.prev.next=i.next:t=i.next)}}}}var ha={notify(){},get:()=>[]};function pv(e,t){let n,r=ha,l=0,i=!1;function o(g){d();const S=r.subscribe(g);let f=!1;return()=>{f||(f=!0,S(),p())}}function u(){r.notify()}function s(){y.onStateChange&&y.onStateChange()}function a(){return i}function d(){l++,n||(n=t?t.addNestedSub(s):e.subscribe(s),r=dv())}function p(){l--,n&&l===0&&(n(),n=void 0,r.clear(),r=ha)}function m(){i||(i=!0,d())}function v(){i&&(i=!1,p())}const y={addNestedSub:o,notifyNestedSubs:u,handleChangeWrapper:s,isSubscribed:a,trySubscribe:m,tryUnsubscribe:v,getListeners:()=>r};return y}var hv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",mv=hv?we.useLayoutEffect:we.useEffect;function vv({store:e,context:t,children:n,serverState:r,stabilityCheck:l="once",identityFunctionCheck:i="once"}){const o=we.useMemo(()=>{const a=pv(e);return{store:e,subscription:a,getServerState:r?()=>r:void 0,stabilityCheck:l,identityFunctionCheck:i}},[e,r,l,i]),u=we.useMemo(()=>e.getState(),[e]);mv(()=>{const{subscription:a}=o;return a.onStateChange=a.notifyNestedSubs,a.trySubscribe(),u!==e.getState()&&a.notifyNestedSubs(),()=>{a.tryUnsubscribe(),a.onStateChange=void 0}},[o,u]);const s=t||Et;return we.createElement(s.Provider,{value:o},n)}var yv=vv;function nd(e=Et){const t=e===Et?ed:Wu(e);return function(){const{store:r}=t();return r}}var gv=nd();function wv(e=Et){const t=e===Et?gv:nd(e);return function(){return t().dispatch}}var ti=wv();av(rv.useSyncExternalStoreWithSelector);iv($f.unstable_batchedUpdates);const Vu=()=>{const[e,t]=E.useState(0),n=sessionStorage.getItem("cartItems"),r=jl(l=>l.cart.length);return E.useEffect(()=>{if(r===0){const l=JSON.parse(n||"[]");t(l.length)}else t(r)},[r]),C.jsxs("nav",{className:"m-10 flex flex-col md:flex-row justify-between md:items-center h-{50px} px-5 bg-gray-500 text-white",children:[C.jsx("h3",{className:"font-bold",children:"goods"}),C.jsxs("span",{className:"flex flex-col md:flex-row justify-between items-center",children:[C.jsx(Fo,{className:"mr-8 my-2 text-3xl",to:"/",children:"Все товары"}),C.jsxs(Fo,{className:"flex mr-2 my-2 text-3xl",to:"/favorite",children:["Корзина ",C.jsx("p",{className:"mr-5 text-base font-bold",children:e})]})]})]})},Sv=()=>{const[e,t]=E.useState([]);return E.useEffect(()=>{Ym().then(n=>{t(n)})},[]),C.jsxs(C.Fragment,{children:[C.jsx(Vu,{}),C.jsx("h2",{className:"ml-20 text-3xl underline",children:"Все товары"}),C.jsx("div",{className:"m-8 flex flex-wrap justify-center ",children:e.map(n=>C.jsxs(Fo,{className:"m-10 w-282 flex flex-col items-center box-border rounded-10 overflow-hidden bg-gray-100 cursor-pointer shadow-md hover:shadow-2xl",to:`/product/${n.id}`,children:[n.colors.length>0&&C.jsx("div",{className:"",children:C.jsx("img",{className:"w-80 bg-contain ",src:n.colors[0].images[0],alt:n.colors[0].name})}),C.jsx("h2",{className:"my-5 mr-5 xl:text-3xl lg:text-2xl sm:text-xl font-bold text-orange-900",children:n.name})]},n.id))})]})};function ee(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var xv=typeof Symbol=="function"&&Symbol.observable||"@@observable",ma=xv,Di=()=>Math.random().toString(36).substring(7).split("").join("."),kv={INIT:`@@redux/INIT${Di()}`,REPLACE:`@@redux/REPLACE${Di()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Di()}`},Ll=kv;function Hu(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function rd(e,t,n){if(typeof e!="function")throw new Error(ee(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ee(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ee(1));return n(rd)(e,t)}let r=e,l=t,i=new Map,o=i,u=0,s=!1;function a(){o===i&&(o=new Map,i.forEach((S,f)=>{o.set(f,S)}))}function d(){if(s)throw new Error(ee(3));return l}function p(S){if(typeof S!="function")throw new Error(ee(4));if(s)throw new Error(ee(5));let f=!0;a();const c=u++;return o.set(c,S),function(){if(f){if(s)throw new Error(ee(6));f=!1,a(),o.delete(c),i=null}}}function m(S){if(!Hu(S))throw new Error(ee(7));if(typeof S.type>"u")throw new Error(ee(8));if(typeof S.type!="string")throw new Error(ee(17));if(s)throw new Error(ee(9));try{s=!0,l=r(l,S)}finally{s=!1}return(i=o).forEach(c=>{c()}),S}function v(S){if(typeof S!="function")throw new Error(ee(10));r=S,m({type:Ll.REPLACE})}function y(){const S=p;return{subscribe(f){if(typeof f!="object"||f===null)throw new Error(ee(11));function c(){const w=f;w.next&&w.next(d())}return c(),{unsubscribe:S(c)}},[ma](){return this}}}return m({type:Ll.INIT}),{dispatch:m,subscribe:p,getState:d,replaceReducer:v,[ma]:y}}function Ev(e){Object.keys(e).forEach(t=>{const n=e[t];if(typeof n(void 0,{type:Ll.INIT})>"u")throw new Error(ee(12));if(typeof n(void 0,{type:Ll.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ee(13))})}function Cv(e){const t=Object.keys(e),n={};for(let i=0;i"u")throw u&&u.type,new Error(ee(14));a[p]=y,s=s||y!==v}return s=s||r.length!==Object.keys(o).length,s?a:o}}function Il(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function _v(...e){return t=>(n,r)=>{const l=t(n,r);let i=()=>{throw new Error(ee(15))};const o={getState:l.getState,dispatch:(s,...a)=>i(s,...a)},u=e.map(s=>s(o));return i=Il(...u)(l.dispatch),{...l,dispatch:i}}}function Pv(e){return Hu(e)&&"type"in e&&typeof e.type=="string"}var ld=Symbol.for("immer-nothing"),va=Symbol.for("immer-draftable"),ke=Symbol.for("immer-state");function Fe(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Sn=Object.getPrototypeOf;function Ct(e){return!!e&&!!e[ke]}function nt(e){var t;return e?id(e)||Array.isArray(e)||!!e[va]||!!((t=e.constructor)!=null&&t[va])||ri(e)||li(e):!1}var Nv=Object.prototype.constructor.toString();function id(e){if(!e||typeof e!="object")return!1;const t=Sn(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Nv}function hr(e,t){ni(e)===0?Object.entries(e).forEach(([n,r])=>{t(n,r,e)}):e.forEach((n,r)=>t(r,n,e))}function ni(e){const t=e[ke];return t?t.type_:Array.isArray(e)?1:ri(e)?2:li(e)?3:0}function Uo(e,t){return ni(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function od(e,t,n){const r=ni(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function zv(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function ri(e){return e instanceof Map}function li(e){return e instanceof Set}function Lt(e){return e.copy_||e.base_}function $o(e,t){if(ri(e))return new Map(e);if(li(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&id(e))return Sn(e)?{...e}:Object.assign(Object.create(null),e);const n=Object.getOwnPropertyDescriptors(e);delete n[ke];let r=Reflect.ownKeys(n);for(let l=0;l1&&(e.set=e.add=e.clear=e.delete=Rv),Object.freeze(e),t&&hr(e,(n,r)=>Qu(r,!0))),e}function Rv(){Fe(2)}function ii(e){return Object.isFrozen(e)}var Tv={};function Ht(e){const t=Tv[e];return t||Fe(0,e),t}var mr;function ud(){return mr}function Ov(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ya(e,t){t&&(Ht("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ao(e){Bo(e),e.drafts_.forEach(jv),e.drafts_=null}function Bo(e){e===mr&&(mr=e.parent_)}function ga(e){return mr=Ov(mr,e)}function jv(e){const t=e[ke];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function wa(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[ke].modified_&&(Ao(t),Fe(4)),nt(e)&&(e=Ml(t,e),t.parent_||Dl(t,e)),t.patches_&&Ht("Patches").generateReplacementPatches_(n[ke].base_,e,t.patches_,t.inversePatches_)):e=Ml(t,n,[]),Ao(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ld?e:void 0}function Ml(e,t,n){if(ii(t))return t;const r=t[ke];if(!r)return hr(t,(l,i)=>Sa(e,r,t,l,i,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return Dl(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const l=r.copy_;let i=l,o=!1;r.type_===3&&(i=new Set(l),l.clear(),o=!0),hr(i,(u,s)=>Sa(e,r,l,u,s,n,o)),Dl(e,l,!1),n&&e.patches_&&Ht("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Sa(e,t,n,r,l,i,o){if(Ct(l)){const u=i&&t&&t.type_!==3&&!Uo(t.assigned_,r)?i.concat(r):void 0,s=Ml(e,l,u);if(od(n,r,s),Ct(s))e.canAutoFreeze_=!1;else return}else o&&n.add(l);if(nt(l)&&!ii(l)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ml(e,l),(!t||!t.scope_.parent_)&&Dl(e,l)}}function Dl(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Qu(t,n)}function Lv(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:ud(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let l=r,i=Ku;n&&(l=[r],i=vr);const{revoke:o,proxy:u}=Proxy.revocable(l,i);return r.draft_=u,r.revoke_=o,u}var Ku={get(e,t){if(t===ke)return e;const n=Lt(e);if(!Uo(n,t))return Iv(e,n,t);const r=n[t];return e.finalized_||!nt(r)?r:r===Fi(e.base_,t)?(Ui(e),e.copy_[t]=Vo(r,e)):r},has(e,t){return t in Lt(e)},ownKeys(e){return Reflect.ownKeys(Lt(e))},set(e,t,n){const r=sd(Lt(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const l=Fi(Lt(e),t),i=l==null?void 0:l[ke];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(zv(n,l)&&(n!==void 0||Uo(e.base_,t)))return!0;Ui(e),Wo(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Fi(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Ui(e),Wo(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Lt(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){Fe(11)},getPrototypeOf(e){return Sn(e.base_)},setPrototypeOf(){Fe(12)}},vr={};hr(Ku,(e,t)=>{vr[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});vr.deleteProperty=function(e,t){return vr.set.call(this,e,t,void 0)};vr.set=function(e,t,n){return Ku.set.call(this,e[0],t,n,e[0])};function Fi(e,t){const n=e[ke];return(n?Lt(n):e)[t]}function Iv(e,t,n){var l;const r=sd(t,n);return r?"value"in r?r.value:(l=r.get)==null?void 0:l.call(e.draft_):void 0}function sd(e,t){if(!(t in e))return;let n=Sn(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Sn(n)}}function Wo(e){e.modified_||(e.modified_=!0,e.parent_&&Wo(e.parent_))}function Ui(e){e.copy_||(e.copy_=$o(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Mv=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const o=this;return function(s=i,...a){return o.produce(s,d=>n.call(this,d,...a))}}typeof n!="function"&&Fe(6),r!==void 0&&typeof r!="function"&&Fe(7);let l;if(nt(t)){const i=ga(this),o=Vo(t,void 0);let u=!0;try{l=n(o),u=!1}finally{u?Ao(i):Bo(i)}return ya(i,r),wa(l,i)}else if(!t||typeof t!="object"){if(l=n(t),l===void 0&&(l=t),l===ld&&(l=void 0),this.autoFreeze_&&Qu(l,!0),r){const i=[],o=[];Ht("Patches").generateReplacementPatches_(t,l,i,o),r(i,o)}return l}else Fe(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(o,...u)=>this.produceWithPatches(o,s=>t(s,...u));let r,l;return[this.produce(t,n,(o,u)=>{r=o,l=u}),r,l]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){nt(e)||Fe(8),Ct(e)&&(e=ad(e));const t=ga(this),n=Vo(e,void 0);return n[ke].isManual_=!0,Bo(t),n}finishDraft(e,t){const n=e&&e[ke];(!n||!n.isManual_)&&Fe(9);const{scope_:r}=n;return ya(r,t),wa(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const l=t[n];if(l.path.length===0&&l.op==="replace"){e=l.value;break}}n>-1&&(t=t.slice(n+1));const r=Ht("Patches").applyPatches_;return Ct(e)?r(e,t):this.produce(e,l=>r(l,t))}};function Vo(e,t){const n=ri(e)?Ht("MapSet").proxyMap_(e,t):li(e)?Ht("MapSet").proxySet_(e,t):Lv(e,t);return(t?t.scope_:ud()).drafts_.push(n),n}function ad(e){return Ct(e)||Fe(10,e),cd(e)}function cd(e){if(!nt(e)||ii(e))return e;const t=e[ke];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=$o(e,t.scope_.immer_.useStrictShallowCopy_)}else n=$o(e,!0);return hr(n,(r,l)=>{od(n,r,cd(l))}),t&&(t.finalized_=!1),n}var Ee=new Mv,fd=Ee.produce;Ee.produceWithPatches.bind(Ee);Ee.setAutoFreeze.bind(Ee);Ee.setUseStrictShallowCopy.bind(Ee);Ee.applyPatches.bind(Ee);Ee.createDraft.bind(Ee);Ee.finishDraft.bind(Ee);function Dv(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function Fv(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var xa=e=>Array.isArray(e)?e:[e];function Uv(e){const t=Array.isArray(e[0])?e[0]:e;return Fv(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function $v(e,t){const n=[],{length:r}=e;for(let l=0;l{n=Hr(),o.resetResultsCount()},o.resultsCount=()=>i,o.resetResultsCount=()=>{i=0},o}function Vv(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e;return(...l)=>{let i=0,o=0,u,s={},a=l.pop();typeof a=="object"&&(s=a,a=l.pop()),Dv(a,`createSelector expects an output function after the inputs, but received: [${typeof a}]`);const d={...n,...s},{memoize:p,memoizeOptions:m=[],argsMemoize:v=dd,argsMemoizeOptions:y=[],devModeChecks:g={}}=d,S=xa(m),f=xa(y),c=Uv(l),h=p(function(){return i++,a.apply(null,arguments)},...S),w=v(function(){o++;const N=$v(c,arguments);return u=h.apply(null,N),u},...f);return Object.assign(w,{resultFunc:a,memoizedResultFunc:h,dependencies:c,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>u,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:p,argsMemoize:v})}}function pd(e){return({dispatch:n,getState:r})=>l=>i=>typeof i=="function"?i(n,r,e):l(i)}var Hv=pd(),Qv=pd,Kv=(...e)=>{const t=Vv(...e);return(...n)=>{const r=t(...n),l=(i,...o)=>r(Ct(i)?ad(i):i,...o);return Object.assign(l,r),l}};Kv(dd);var Xv=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Il:Il.apply(null,arguments)};function yr(e,t){function n(...r){if(t){let l=t(...r);if(!l)throw new Error(Ae(0));return{type:e,payload:l.payload,..."meta"in l&&{meta:l.meta},..."error"in l&&{error:l.error}}}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>Pv(r)&&r.type===e,n}var hd=class An extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,An.prototype)}static get[Symbol.species](){return An}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new An(...t[0].concat(this)):new An(...t.concat(this))}};function Ea(e){return nt(e)?fd(e,()=>{}):e}function Ca(e,t,n){if(e.has(t)){let l=e.get(t);return n.update&&(l=n.update(l,t,e),e.set(t,l)),l}if(!n.insert)throw new Error(Ae(10));const r=n.insert(t,e);return e.set(t,r),r}function Yv(e){return typeof e=="boolean"}var Gv=()=>function(t){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:l=!0,actionCreatorCheck:i=!0}=t??{};let o=new hd;return n&&(Yv(n)?o.push(Hv):o.push(Qv(n.extraArgument))),o},Jv="RTK_autoBatch",md=e=>t=>{setTimeout(t,e)},Zv=typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:md(10),qv=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let l=!0,i=!1,o=!1;const u=new Set,s=e.type==="tick"?queueMicrotask:e.type==="raf"?Zv:e.type==="callback"?e.queueNotification:md(e.timeout),a=()=>{o=!1,i&&(i=!1,u.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const p=()=>l&&d(),m=r.subscribe(p);return u.add(d),()=>{m(),u.delete(d)}},dispatch(d){var p;try{return l=!((p=d==null?void 0:d.meta)!=null&&p[Jv]),i=!l,i&&(o||(o=!0,s(a))),r.dispatch(d)}finally{l=!0}}})},bv=e=>function(n){const{autoBatch:r=!0}=n??{};let l=new hd(e);return r&&l.push(qv(typeof r=="object"?r:void 0)),l},ey=!0;function ty(e){const t=Gv(),{reducer:n=void 0,middleware:r,devTools:l=!0,preloadedState:i=void 0,enhancers:o=void 0}=e||{};let u;if(typeof n=="function")u=n;else if(Hu(n))u=Cv(n);else throw new Error(Ae(1));let s;typeof r=="function"?s=r(t):s=t();let a=Il;l&&(a=Xv({trace:!ey,...typeof l=="object"&&l}));const d=_v(...s),p=bv(d);let m=typeof o=="function"?o(p):p();const v=a(...m);return rd(u,i,v)}function vd(e){const t={},n=[];let r;const l={addCase(i,o){const u=typeof i=="string"?i:i.type;if(!u)throw new Error(Ae(28));if(u in t)throw new Error(Ae(29));return t[u]=o,l},addMatcher(i,o){return n.push({matcher:i,reducer:o}),l},addDefaultCase(i){return r=i,l}};return e(l),[t,n,r]}function ny(e){return typeof e=="function"}function ry(e,t){let[n,r,l]=vd(t),i;if(ny(e))i=()=>Ea(e());else{const u=Ea(e);i=()=>u}function o(u=i(),s){let a=[n[s.type],...r.filter(({matcher:d})=>d(s)).map(({reducer:d})=>d)];return a.filter(d=>!!d).length===0&&(a=[l]),a.reduce((d,p)=>{if(p)if(Ct(d)){const v=p(d,s);return v===void 0?d:v}else{if(nt(d))return fd(d,m=>p(m,s));{const m=p(d,s);if(m===void 0){if(d===null)return d;throw new Error(Ae(9))}return m}}return d},u)}return o.getInitialState=i,o}var ly=Symbol.for("rtk-slice-createasyncthunk");function iy(e,t){return`${e}/${t}`}function oy({creators:e}={}){var n;const t=(n=e==null?void 0:e.asyncThunk)==null?void 0:n[ly];return function(l){const{name:i,reducerPath:o=i}=l;if(!i)throw new Error(Ae(11));typeof process<"u";const u=(typeof l.reducers=="function"?l.reducers(sy()):l.reducers)||{},s=Object.keys(u),a={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},d={addCase(S,f){const c=typeof S=="string"?S:S.type;if(!c)throw new Error(Ae(12));if(c in a.sliceCaseReducersByType)throw new Error(Ae(13));return a.sliceCaseReducersByType[c]=f,d},addMatcher(S,f){return a.sliceMatchers.push({matcher:S,reducer:f}),d},exposeAction(S,f){return a.actionCreators[S]=f,d},exposeCaseReducer(S,f){return a.sliceCaseReducersByName[S]=f,d}};s.forEach(S=>{const f=u[S],c={reducerName:S,type:iy(i,S),createNotation:typeof l.reducers=="function"};cy(f)?dy(c,f,d,t):ay(c,f,d)});function p(){const[S={},f=[],c=void 0]=typeof l.extraReducers=="function"?vd(l.extraReducers):[l.extraReducers],h={...S,...a.sliceCaseReducersByType};return ry(l.initialState,w=>{for(let k in h)w.addCase(k,h[k]);for(let k of a.sliceMatchers)w.addMatcher(k.matcher,k.reducer);for(let k of f)w.addMatcher(k.matcher,k.reducer);c&&w.addDefaultCase(c)})}const m=S=>S,v=new WeakMap;let y;const g={name:i,reducerPath:o,reducer(S,f){return y||(y=p()),y(S,f)},actions:a.actionCreators,caseReducers:a.sliceCaseReducersByName,getInitialState(){return y||(y=p()),y.getInitialState()},getSelectors(S=m){const f=Ca(v,this,{insert:()=>new WeakMap});return Ca(f,S,{insert:()=>{const c={};for(const[h,w]of Object.entries(l.selectors??{}))c[h]=uy(this,w,S,this!==g);return c}})},selectSlice(S){let f=S[this.reducerPath];return typeof f>"u"&&this!==g&&(f=this.getInitialState()),f},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(S,{reducerPath:f,...c}={}){const h=f??this.reducerPath;return S.inject({reducerPath:h,reducer:this.reducer},c),{...this,reducerPath:h}}};return g}}function uy(e,t,n,r){function l(i,...o){let u=n.call(e,i);return typeof u>"u"&&r&&(u=e.getInitialState()),t(u,...o)}return l.unwrapped=t,l}var Xu=oy();function sy(){function e(t,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...n}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function ay({type:e,reducerName:t,createNotation:n},r,l){let i,o;if("reducer"in r){if(n&&!fy(r))throw new Error(Ae(17));i=r.reducer,o=r.prepare}else i=r;l.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,o?yr(e,o):yr(e))}function cy(e){return e._reducerDefinitionType==="asyncThunk"}function fy(e){return e._reducerDefinitionType==="reducerWithPrepare"}function dy({type:e,reducerName:t},n,r,l){if(!l)throw new Error(Ae(18));const{payloadCreator:i,fulfilled:o,pending:u,rejected:s,settled:a,options:d}=n,p=l(e,i,d);r.exposeAction(t,p),o&&r.addCase(p.fulfilled,o),u&&r.addCase(p.pending,u),s&&r.addCase(p.rejected,s),a&&r.addMatcher(p.settled,a),r.exposeCaseReducer(t,{fulfilled:o||Qr,pending:u||Qr,rejected:s||Qr,settled:a||Qr})}function Qr(){}var Yu="listenerMiddleware";yr(`${Yu}/add`);yr(`${Yu}/removeAll`);yr(`${Yu}/remove`);function Ae(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}const py={items:[],length:0},yd=Xu({name:"cart",initialState:py,reducers:{addToCart:(e,t)=>{e.items.push(t.payload),e.length=e.items.length},removeFromCart:(e,t)=>{const n=t.payload;n>=0&&n{const e=ti(),[t,n]=E.useState([]);E.useEffect(()=>{const i=JSON.parse(sessionStorage.getItem("cartItems")||"[]");console.log(i),n(i)},[]);const r=i=>{sessionStorage.setItem("cartItems",JSON.stringify(i))},l=i=>{e(my(i)),n(o=>{const u=o.filter((s,a)=>a!==i);return r(u),u})};return C.jsxs(C.Fragment,{children:[C.jsx(Vu,{}),C.jsx("h2",{className:"ml-20 text-3xl underline",children:"Ваша корзина"}),C.jsxs("div",{className:"m-8 flex flex-wrap justify-center",children:[t.length===0&&C.jsx("h2",{className:"mt-3 xl:text-3xl lg:text-2xl sm:text-sm font-bold text-amber-950",children:"товаров в корзине нет"}),t.map((i,o)=>C.jsxs("div",{className:"m-10 w-282 flex flex-col items-center box-border rounded-10 overflow-hidden bg-gray-100 shadow-md rounded",children:[C.jsx("div",{className:"min-h-max",children:C.jsx("img",{className:"w-80 bg-contain cursor-pointer hover:shadow-2xl",src:i.photo,alt:i.nameProduct,title:"фото товара"})}),C.jsx("h2",{className:"mt-3 xl:text-3xl lg:text-2xl sm:text-sm font-bold text-amber-950",children:i.nameProduct}),C.jsxs("p",{className:"mt-2 xl:text-xl lg:text-base sm:text-sm",children:["цвет: ",i.colorName]}),C.jsxs("p",{className:"mt-2 xl:text-xl lg:text-base sm:text-sm",children:["размер: ",i.sizeName," "]}),C.jsxs("p",{className:"mt-2 xl:text-xl lg:text-base sm:text-sm",children:["цена: ",i.price," "]}),C.jsx("button",{className:"mb-2 bg-slate-400 rounded-full",onClick:()=>l(o),children:C.jsx("p",{className:"py-2 px-3 font-bold xl:text-base lg:text-base sm:text-sm text-black",children:"Удалить из корзины"})})]},o))]})]})},gy={isOpen:!1,images:[],currentImageIndex:0},gd=Xu({name:"popup",initialState:gy,reducers:{openPopup:(e,t)=>{e.isOpen=!0,e.images=t.payload,e.currentImageIndex=0},closePopup:e=>{e.isOpen=!1,e.images=[],e.currentImageIndex=0},nextImage:e=>{e.currentImageIndex=(e.currentImageIndex+1)%e.images.length},prevImage:e=>{e.currentImageIndex=(e.currentImageIndex-1+e.images.length)%e.images.length}}}),{openPopup:wy,closePopup:Sy,nextImage:xy,prevImage:ky}=gd.actions,Ey=gd.reducer,Cy={selectedSizes:{}},wd=Xu({name:"sizeSelect",initialState:Cy,reducers:{isSelect:(e,t)=>{const{cardId:n,sizeName:r}=t.payload;e.selectedSizes={...e.selectedSizes,[n]:r}},notSelect:(e,t)=>{const n=t.payload;e.selectedSizes={...e.selectedSizes,[n]:null}}}}),{isSelect:_y,notSelect:Py}=wd.actions,Ny=wd.reducer,zy=({sizes:e,colorId:t})=>{const n=ti(),[r,l]=E.useState([]),[i,o]=E.useState(null);E.useEffect(()=>{(async()=>{const a=e.map(async p=>(await Xm(p)).label),d=await Promise.all(a);l(d)})()},[e]);const u=s=>{i===s?(o(null),n(Py(t.toString()))):(o(s),n(_y({cardId:t.toString(),sizeName:s})))};return C.jsx("div",{className:"flex",children:r.map((s,a)=>C.jsx("p",{className:`m-3 p-0 cursor-pointer font-bold ${i===s?"underline":""}`,onClick:()=>u(s),children:s},a))})},Ry=()=>{const e=ti(),{isOpen:t,images:n,currentImageIndex:r}=jl(u=>u.popup),l=()=>{e(Sy())},i=()=>{e(xy())},o=()=>{e(ky())};return!t||!n.length?null:C.jsx("div",{className:`fixed top-0 left-0 w-full h-full flex items-center justify-center bg-black bg-opacity-50 transition-all duration-500 ${t?"visible opacity-100":"invisible opacity-0"}`,children:C.jsxs("div",{className:"w-430 mx-auto bg-white shadow-md rounded-10 flex flex-col items-center",children:[C.jsx("button",{type:"button",className:"w-32 h-8 bg-slate-400 border-none font-bold text-24 text-black",onClick:l,children:"Закрыть ×"}),C.jsx("img",{className:"w-80 bg-contain",src:n[r],alt:`Image ${r+1}`}),C.jsxs("div",{className:"flex justify-between w-full items-start p-3",children:[C.jsx("button",{className:"w-32 h-8 bg-slate-400 font-bold text-24 text-black",onClick:o,children:"< Предыдущая"}),C.jsx("button",{className:"w-32 h-8 bg-slate-400 font-bold text-24 text-black",onClick:i,children:"Следующая >"})]})]})})},Ty=()=>{const e=ti(),{id:t}=km(),[n,r]=E.useState([]),[l,i]=E.useState(""),[o,u]=E.useState([]),{items:s}=jl(v=>v.cart);E.useEffect(()=>{sessionStorage.setItem("cartItems",JSON.stringify(s))},[s]);const{selectedSizes:a}=jl(v=>v.sizeSelect),d=async()=>{if(t!==void 0){const v=await Gm(parseInt(t.toString()));i(v.name),r(v.colors);const g=await Promise.all(v.colors.map(async S=>S.sizes));u(g)}};E.useEffect(()=>{d()},[]);const p=v=>{const g=v.currentTarget.getAttribute("data-images");g&&e(wy(JSON.parse(g)))},m=(v,y,g,S,f)=>{e(hy({colorName:y,sizeName:f,photo:g,price:S,nameProduct:v}))};return C.jsxs(C.Fragment,{children:[C.jsx(Vu,{}),C.jsx("h2",{className:"ml-20 text-3xl underline",children:l}),C.jsx("div",{className:"m-8 flex flex-wrap justify-center",children:n.map((v,y)=>C.jsxs("div",{className:"m-10 w-282 flex flex-col items-center box-border rounded-10 overflow-hidden bg-gray-100 shadow-md rounded",children:[C.jsx("div",{className:"",children:C.jsx("img",{className:"w-80 bg-contain cursor-pointer hover:shadow-2xl",src:v.images[0],alt:v.name,title:"посмотреть","data-images":JSON.stringify(v.images),onClick:p,onTouchStart:p})}),C.jsxs("h2",{className:"mt-3 xl:text-3xl lg:text-2xl sm:text-sm font-bold text-amber-950",children:["цвет: ",v.name]}),C.jsxs("p",{className:"mt-2 xl:text-xl lg:text-base sm:text-sm",children:["цена: ",v.price," "]}),C.jsx("p",{className:"my-2",children:"выберете размер:"}),v.sizes.length>0?C.jsxs("div",{className:"flex flex-col items-center",children:[C.jsx(zy,{sizes:o[y],colorId:v.id}),C.jsx("button",{className:`mb-2 ${a[v.id]?"bg-slate-400":"bg-gray-300"} rounded-full`,disabled:!a[v.id],onClick:()=>{const g=a[v.id];g!==null&&m(l,v.name,v.images[0],v.price,g)},children:C.jsx("p",{className:"py-2 px-3 font-bold xl:text-base lg:text-base sm:text-sm text-black",children:"Добавить в корзину"})})]}):C.jsx("p",{className:"my-2 font-bold xl:text-base lg:text-base sm:text-sm",children:"нет в наличии"})]},v.id))}),C.jsx(Ry,{})]})},Oy=()=>C.jsxs("main",{className:"bg-slate-200 min-h-screen",children:[C.jsx("h2",{className:"pt-10 mx-10 text-3xl sm:text-5xl font-bold",children:"E-commerce"}),C.jsxs(Dm,{children:[C.jsx(ll,{path:"/e-commmerce-spa",element:C.jsx(Sv,{})}),C.jsx(ll,{path:"/product/:id",element:C.jsx(Ty,{})}),C.jsx(ll,{path:"/favorite",element:C.jsx(yy,{})})]})]}),jy=ty({reducer:{popup:Ey,cart:vy,sizeSelect:Ny}});Ai.createRoot(document.getElementById("root")).render(C.jsx(Yo.StrictMode,{children:C.jsx(yv,{store:jy,children:C.jsx(Wm,{children:C.jsx(Oy,{})})})})); + */var Cr=E;function Jm(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Zm=typeof Object.is=="function"?Object.is:Jm,qm=Cr.useSyncExternalStore,bm=Cr.useRef,ev=Cr.useEffect,tv=Cr.useMemo,nv=Cr.useDebugValue;qf.useSyncExternalStoreWithSelector=function(e,t,n,r,l){var i=bm(null);if(i.current===null){var o={hasValue:!1,value:null};i.current=o}else o=i.current;i=tv(function(){function s(v){if(!a){if(a=!0,d=v,v=r(v),l!==void 0&&o.hasValue){var y=o.value;if(l(y,v))return p=y}return p=v}if(y=p,Zm(d,v))return y;var g=r(v);return l!==void 0&&l(y,g)?y:(d=v,p=g)}var a=!1,d,p,m=n===void 0?null:n;return[function(){return s(t())},m===null?void 0:function(){return s(m())}]},[t,n,r,l]);var u=qm(e,i[0],i[1]);return ev(function(){o.hasValue=!0,o.value=u},[u]),nv(u),u};Zf.exports=qf;var rv=Zf.exports;function lv(e){e()}var bf=lv,iv=e=>bf=e,ov=()=>bf,we="default"in $i?Yo:$i,da=Symbol.for("react-redux-context"),pa=typeof globalThis<"u"?globalThis:{};function uv(){if(!we.createContext)return{};const e=pa[da]??(pa[da]=new Map);let t=e.get(we.createContext);return t||(t=we.createContext(null),e.set(we.createContext,t)),t}var Et=uv(),sv=()=>{throw new Error("uSES not initialized!")};function Wu(e=Et){return function(){return we.useContext(e)}}var ed=Wu(),td=sv,av=e=>{td=e},cv=(e,t)=>e===t;function fv(e=Et){const t=e===Et?ed:Wu(e);return function(r,l={}){const{equalityFn:i=cv,devModeChecks:o={}}=typeof l=="function"?{equalityFn:l}:l,{store:u,subscription:s,getServerState:a,stabilityCheck:d,identityFunctionCheck:p}=t();we.useRef(!0);const m=we.useCallback({[r.name](y){return r(y)}}[r.name],[r,d,o.stabilityCheck]),v=td(s.addNestedSub,u.getState,a||u.getState,m,i);return we.useDebugValue(v),v}}var jl=fv();function dv(){const e=ov();let t=null,n=null;return{clear(){t=null,n=null},notify(){e(()=>{let r=t;for(;r;)r.callback(),r=r.next})},get(){let r=[],l=t;for(;l;)r.push(l),l=l.next;return r},subscribe(r){let l=!0,i=n={callback:r,next:null,prev:n};return i.prev?i.prev.next=i:t=i,function(){!l||t===null||(l=!1,i.next?i.next.prev=i.prev:n=i.prev,i.prev?i.prev.next=i.next:t=i.next)}}}}var ha={notify(){},get:()=>[]};function pv(e,t){let n,r=ha,l=0,i=!1;function o(g){d();const S=r.subscribe(g);let f=!1;return()=>{f||(f=!0,S(),p())}}function u(){r.notify()}function s(){y.onStateChange&&y.onStateChange()}function a(){return i}function d(){l++,n||(n=t?t.addNestedSub(s):e.subscribe(s),r=dv())}function p(){l--,n&&l===0&&(n(),n=void 0,r.clear(),r=ha)}function m(){i||(i=!0,d())}function v(){i&&(i=!1,p())}const y={addNestedSub:o,notifyNestedSubs:u,handleChangeWrapper:s,isSubscribed:a,trySubscribe:m,tryUnsubscribe:v,getListeners:()=>r};return y}var hv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",mv=hv?we.useLayoutEffect:we.useEffect;function vv({store:e,context:t,children:n,serverState:r,stabilityCheck:l="once",identityFunctionCheck:i="once"}){const o=we.useMemo(()=>{const a=pv(e);return{store:e,subscription:a,getServerState:r?()=>r:void 0,stabilityCheck:l,identityFunctionCheck:i}},[e,r,l,i]),u=we.useMemo(()=>e.getState(),[e]);mv(()=>{const{subscription:a}=o;return a.onStateChange=a.notifyNestedSubs,a.trySubscribe(),u!==e.getState()&&a.notifyNestedSubs(),()=>{a.tryUnsubscribe(),a.onStateChange=void 0}},[o,u]);const s=t||Et;return we.createElement(s.Provider,{value:o},n)}var yv=vv;function nd(e=Et){const t=e===Et?ed:Wu(e);return function(){const{store:r}=t();return r}}var gv=nd();function wv(e=Et){const t=e===Et?gv:nd(e);return function(){return t().dispatch}}var ti=wv();av(rv.useSyncExternalStoreWithSelector);iv($f.unstable_batchedUpdates);const Vu=()=>{const[e,t]=E.useState(0),n=sessionStorage.getItem("cartItems"),r=jl(l=>l.cart.length);return E.useEffect(()=>{if(r===0){const l=JSON.parse(n||"[]");t(l.length)}else t(r)},[r]),C.jsxs("nav",{className:"m-10 flex flex-col md:flex-row justify-between md:items-center h-{50px} px-5 bg-gray-500 text-white",children:[C.jsx("h3",{className:"font-bold",children:"goods"}),C.jsxs("span",{className:"flex flex-col md:flex-row justify-between items-center",children:[C.jsx(Fo,{className:"mr-8 my-2 text-3xl",to:"/",children:"Все товары"}),C.jsxs(Fo,{className:"flex mr-2 my-2 text-3xl",to:"/favorite",children:["Корзина ",C.jsx("p",{className:"mr-5 text-base font-bold",children:e})]})]})]})},Sv=()=>{const[e,t]=E.useState([]);return E.useEffect(()=>{Ym().then(n=>{t(n)})},[]),C.jsxs(C.Fragment,{children:[C.jsx(Vu,{}),C.jsx("h2",{className:"ml-20 text-3xl underline",children:"Все товары"}),C.jsx("div",{className:"m-8 flex flex-wrap justify-center ",children:e.map(n=>C.jsxs(Fo,{className:"m-10 w-282 flex flex-col items-center box-border rounded-10 overflow-hidden bg-gray-100 cursor-pointer shadow-md hover:shadow-2xl",to:`/product/${n.id}`,children:[n.colors.length>0&&C.jsx("div",{className:"",children:C.jsx("img",{className:"w-80 bg-contain ",src:n.colors[0].images[0],alt:n.colors[0].name})}),C.jsx("h2",{className:"my-5 mr-5 xl:text-3xl lg:text-2xl sm:text-xl font-bold text-orange-900",children:n.name})]},n.id))})]})};function ee(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var xv=typeof Symbol=="function"&&Symbol.observable||"@@observable",ma=xv,Di=()=>Math.random().toString(36).substring(7).split("").join("."),kv={INIT:`@@redux/INIT${Di()}`,REPLACE:`@@redux/REPLACE${Di()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Di()}`},Ll=kv;function Hu(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function rd(e,t,n){if(typeof e!="function")throw new Error(ee(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ee(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ee(1));return n(rd)(e,t)}let r=e,l=t,i=new Map,o=i,u=0,s=!1;function a(){o===i&&(o=new Map,i.forEach((S,f)=>{o.set(f,S)}))}function d(){if(s)throw new Error(ee(3));return l}function p(S){if(typeof S!="function")throw new Error(ee(4));if(s)throw new Error(ee(5));let f=!0;a();const c=u++;return o.set(c,S),function(){if(f){if(s)throw new Error(ee(6));f=!1,a(),o.delete(c),i=null}}}function m(S){if(!Hu(S))throw new Error(ee(7));if(typeof S.type>"u")throw new Error(ee(8));if(typeof S.type!="string")throw new Error(ee(17));if(s)throw new Error(ee(9));try{s=!0,l=r(l,S)}finally{s=!1}return(i=o).forEach(c=>{c()}),S}function v(S){if(typeof S!="function")throw new Error(ee(10));r=S,m({type:Ll.REPLACE})}function y(){const S=p;return{subscribe(f){if(typeof f!="object"||f===null)throw new Error(ee(11));function c(){const w=f;w.next&&w.next(d())}return c(),{unsubscribe:S(c)}},[ma](){return this}}}return m({type:Ll.INIT}),{dispatch:m,subscribe:p,getState:d,replaceReducer:v,[ma]:y}}function Ev(e){Object.keys(e).forEach(t=>{const n=e[t];if(typeof n(void 0,{type:Ll.INIT})>"u")throw new Error(ee(12));if(typeof n(void 0,{type:Ll.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ee(13))})}function Cv(e){const t=Object.keys(e),n={};for(let i=0;i"u")throw u&&u.type,new Error(ee(14));a[p]=y,s=s||y!==v}return s=s||r.length!==Object.keys(o).length,s?a:o}}function Il(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function _v(...e){return t=>(n,r)=>{const l=t(n,r);let i=()=>{throw new Error(ee(15))};const o={getState:l.getState,dispatch:(s,...a)=>i(s,...a)},u=e.map(s=>s(o));return i=Il(...u)(l.dispatch),{...l,dispatch:i}}}function Pv(e){return Hu(e)&&"type"in e&&typeof e.type=="string"}var ld=Symbol.for("immer-nothing"),va=Symbol.for("immer-draftable"),ke=Symbol.for("immer-state");function Fe(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Sn=Object.getPrototypeOf;function Ct(e){return!!e&&!!e[ke]}function nt(e){var t;return e?id(e)||Array.isArray(e)||!!e[va]||!!((t=e.constructor)!=null&&t[va])||ri(e)||li(e):!1}var Nv=Object.prototype.constructor.toString();function id(e){if(!e||typeof e!="object")return!1;const t=Sn(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Nv}function hr(e,t){ni(e)===0?Object.entries(e).forEach(([n,r])=>{t(n,r,e)}):e.forEach((n,r)=>t(r,n,e))}function ni(e){const t=e[ke];return t?t.type_:Array.isArray(e)?1:ri(e)?2:li(e)?3:0}function Uo(e,t){return ni(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function od(e,t,n){const r=ni(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function zv(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function ri(e){return e instanceof Map}function li(e){return e instanceof Set}function Lt(e){return e.copy_||e.base_}function $o(e,t){if(ri(e))return new Map(e);if(li(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&id(e))return Sn(e)?{...e}:Object.assign(Object.create(null),e);const n=Object.getOwnPropertyDescriptors(e);delete n[ke];let r=Reflect.ownKeys(n);for(let l=0;l1&&(e.set=e.add=e.clear=e.delete=Rv),Object.freeze(e),t&&hr(e,(n,r)=>Qu(r,!0))),e}function Rv(){Fe(2)}function ii(e){return Object.isFrozen(e)}var Tv={};function Ht(e){const t=Tv[e];return t||Fe(0,e),t}var mr;function ud(){return mr}function Ov(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ya(e,t){t&&(Ht("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ao(e){Bo(e),e.drafts_.forEach(jv),e.drafts_=null}function Bo(e){e===mr&&(mr=e.parent_)}function ga(e){return mr=Ov(mr,e)}function jv(e){const t=e[ke];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function wa(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[ke].modified_&&(Ao(t),Fe(4)),nt(e)&&(e=Ml(t,e),t.parent_||Dl(t,e)),t.patches_&&Ht("Patches").generateReplacementPatches_(n[ke].base_,e,t.patches_,t.inversePatches_)):e=Ml(t,n,[]),Ao(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ld?e:void 0}function Ml(e,t,n){if(ii(t))return t;const r=t[ke];if(!r)return hr(t,(l,i)=>Sa(e,r,t,l,i,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return Dl(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const l=r.copy_;let i=l,o=!1;r.type_===3&&(i=new Set(l),l.clear(),o=!0),hr(i,(u,s)=>Sa(e,r,l,u,s,n,o)),Dl(e,l,!1),n&&e.patches_&&Ht("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Sa(e,t,n,r,l,i,o){if(Ct(l)){const u=i&&t&&t.type_!==3&&!Uo(t.assigned_,r)?i.concat(r):void 0,s=Ml(e,l,u);if(od(n,r,s),Ct(s))e.canAutoFreeze_=!1;else return}else o&&n.add(l);if(nt(l)&&!ii(l)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ml(e,l),(!t||!t.scope_.parent_)&&Dl(e,l)}}function Dl(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Qu(t,n)}function Lv(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:ud(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let l=r,i=Ku;n&&(l=[r],i=vr);const{revoke:o,proxy:u}=Proxy.revocable(l,i);return r.draft_=u,r.revoke_=o,u}var Ku={get(e,t){if(t===ke)return e;const n=Lt(e);if(!Uo(n,t))return Iv(e,n,t);const r=n[t];return e.finalized_||!nt(r)?r:r===Fi(e.base_,t)?(Ui(e),e.copy_[t]=Vo(r,e)):r},has(e,t){return t in Lt(e)},ownKeys(e){return Reflect.ownKeys(Lt(e))},set(e,t,n){const r=sd(Lt(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const l=Fi(Lt(e),t),i=l==null?void 0:l[ke];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(zv(n,l)&&(n!==void 0||Uo(e.base_,t)))return!0;Ui(e),Wo(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Fi(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Ui(e),Wo(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Lt(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){Fe(11)},getPrototypeOf(e){return Sn(e.base_)},setPrototypeOf(){Fe(12)}},vr={};hr(Ku,(e,t)=>{vr[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});vr.deleteProperty=function(e,t){return vr.set.call(this,e,t,void 0)};vr.set=function(e,t,n){return Ku.set.call(this,e[0],t,n,e[0])};function Fi(e,t){const n=e[ke];return(n?Lt(n):e)[t]}function Iv(e,t,n){var l;const r=sd(t,n);return r?"value"in r?r.value:(l=r.get)==null?void 0:l.call(e.draft_):void 0}function sd(e,t){if(!(t in e))return;let n=Sn(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Sn(n)}}function Wo(e){e.modified_||(e.modified_=!0,e.parent_&&Wo(e.parent_))}function Ui(e){e.copy_||(e.copy_=$o(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Mv=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const o=this;return function(s=i,...a){return o.produce(s,d=>n.call(this,d,...a))}}typeof n!="function"&&Fe(6),r!==void 0&&typeof r!="function"&&Fe(7);let l;if(nt(t)){const i=ga(this),o=Vo(t,void 0);let u=!0;try{l=n(o),u=!1}finally{u?Ao(i):Bo(i)}return ya(i,r),wa(l,i)}else if(!t||typeof t!="object"){if(l=n(t),l===void 0&&(l=t),l===ld&&(l=void 0),this.autoFreeze_&&Qu(l,!0),r){const i=[],o=[];Ht("Patches").generateReplacementPatches_(t,l,i,o),r(i,o)}return l}else Fe(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(o,...u)=>this.produceWithPatches(o,s=>t(s,...u));let r,l;return[this.produce(t,n,(o,u)=>{r=o,l=u}),r,l]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){nt(e)||Fe(8),Ct(e)&&(e=ad(e));const t=ga(this),n=Vo(e,void 0);return n[ke].isManual_=!0,Bo(t),n}finishDraft(e,t){const n=e&&e[ke];(!n||!n.isManual_)&&Fe(9);const{scope_:r}=n;return ya(r,t),wa(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const l=t[n];if(l.path.length===0&&l.op==="replace"){e=l.value;break}}n>-1&&(t=t.slice(n+1));const r=Ht("Patches").applyPatches_;return Ct(e)?r(e,t):this.produce(e,l=>r(l,t))}};function Vo(e,t){const n=ri(e)?Ht("MapSet").proxyMap_(e,t):li(e)?Ht("MapSet").proxySet_(e,t):Lv(e,t);return(t?t.scope_:ud()).drafts_.push(n),n}function ad(e){return Ct(e)||Fe(10,e),cd(e)}function cd(e){if(!nt(e)||ii(e))return e;const t=e[ke];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=$o(e,t.scope_.immer_.useStrictShallowCopy_)}else n=$o(e,!0);return hr(n,(r,l)=>{od(n,r,cd(l))}),t&&(t.finalized_=!1),n}var Ee=new Mv,fd=Ee.produce;Ee.produceWithPatches.bind(Ee);Ee.setAutoFreeze.bind(Ee);Ee.setUseStrictShallowCopy.bind(Ee);Ee.applyPatches.bind(Ee);Ee.createDraft.bind(Ee);Ee.finishDraft.bind(Ee);function Dv(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function Fv(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var xa=e=>Array.isArray(e)?e:[e];function Uv(e){const t=Array.isArray(e[0])?e[0]:e;return Fv(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function $v(e,t){const n=[],{length:r}=e;for(let l=0;l{n=Hr(),o.resetResultsCount()},o.resultsCount=()=>i,o.resetResultsCount=()=>{i=0},o}function Vv(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e;return(...l)=>{let i=0,o=0,u,s={},a=l.pop();typeof a=="object"&&(s=a,a=l.pop()),Dv(a,`createSelector expects an output function after the inputs, but received: [${typeof a}]`);const d={...n,...s},{memoize:p,memoizeOptions:m=[],argsMemoize:v=dd,argsMemoizeOptions:y=[],devModeChecks:g={}}=d,S=xa(m),f=xa(y),c=Uv(l),h=p(function(){return i++,a.apply(null,arguments)},...S),w=v(function(){o++;const N=$v(c,arguments);return u=h.apply(null,N),u},...f);return Object.assign(w,{resultFunc:a,memoizedResultFunc:h,dependencies:c,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>u,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:p,argsMemoize:v})}}function pd(e){return({dispatch:n,getState:r})=>l=>i=>typeof i=="function"?i(n,r,e):l(i)}var Hv=pd(),Qv=pd,Kv=(...e)=>{const t=Vv(...e);return(...n)=>{const r=t(...n),l=(i,...o)=>r(Ct(i)?ad(i):i,...o);return Object.assign(l,r),l}};Kv(dd);var Xv=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Il:Il.apply(null,arguments)};function yr(e,t){function n(...r){if(t){let l=t(...r);if(!l)throw new Error(Ae(0));return{type:e,payload:l.payload,..."meta"in l&&{meta:l.meta},..."error"in l&&{error:l.error}}}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>Pv(r)&&r.type===e,n}var hd=class An extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,An.prototype)}static get[Symbol.species](){return An}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new An(...t[0].concat(this)):new An(...t.concat(this))}};function Ea(e){return nt(e)?fd(e,()=>{}):e}function Ca(e,t,n){if(e.has(t)){let l=e.get(t);return n.update&&(l=n.update(l,t,e),e.set(t,l)),l}if(!n.insert)throw new Error(Ae(10));const r=n.insert(t,e);return e.set(t,r),r}function Yv(e){return typeof e=="boolean"}var Gv=()=>function(t){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:l=!0,actionCreatorCheck:i=!0}=t??{};let o=new hd;return n&&(Yv(n)?o.push(Hv):o.push(Qv(n.extraArgument))),o},Jv="RTK_autoBatch",md=e=>t=>{setTimeout(t,e)},Zv=typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:md(10),qv=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let l=!0,i=!1,o=!1;const u=new Set,s=e.type==="tick"?queueMicrotask:e.type==="raf"?Zv:e.type==="callback"?e.queueNotification:md(e.timeout),a=()=>{o=!1,i&&(i=!1,u.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const p=()=>l&&d(),m=r.subscribe(p);return u.add(d),()=>{m(),u.delete(d)}},dispatch(d){var p;try{return l=!((p=d==null?void 0:d.meta)!=null&&p[Jv]),i=!l,i&&(o||(o=!0,s(a))),r.dispatch(d)}finally{l=!0}}})},bv=e=>function(n){const{autoBatch:r=!0}=n??{};let l=new hd(e);return r&&l.push(qv(typeof r=="object"?r:void 0)),l},ey=!0;function ty(e){const t=Gv(),{reducer:n=void 0,middleware:r,devTools:l=!0,preloadedState:i=void 0,enhancers:o=void 0}=e||{};let u;if(typeof n=="function")u=n;else if(Hu(n))u=Cv(n);else throw new Error(Ae(1));let s;typeof r=="function"?s=r(t):s=t();let a=Il;l&&(a=Xv({trace:!ey,...typeof l=="object"&&l}));const d=_v(...s),p=bv(d);let m=typeof o=="function"?o(p):p();const v=a(...m);return rd(u,i,v)}function vd(e){const t={},n=[];let r;const l={addCase(i,o){const u=typeof i=="string"?i:i.type;if(!u)throw new Error(Ae(28));if(u in t)throw new Error(Ae(29));return t[u]=o,l},addMatcher(i,o){return n.push({matcher:i,reducer:o}),l},addDefaultCase(i){return r=i,l}};return e(l),[t,n,r]}function ny(e){return typeof e=="function"}function ry(e,t){let[n,r,l]=vd(t),i;if(ny(e))i=()=>Ea(e());else{const u=Ea(e);i=()=>u}function o(u=i(),s){let a=[n[s.type],...r.filter(({matcher:d})=>d(s)).map(({reducer:d})=>d)];return a.filter(d=>!!d).length===0&&(a=[l]),a.reduce((d,p)=>{if(p)if(Ct(d)){const v=p(d,s);return v===void 0?d:v}else{if(nt(d))return fd(d,m=>p(m,s));{const m=p(d,s);if(m===void 0){if(d===null)return d;throw new Error(Ae(9))}return m}}return d},u)}return o.getInitialState=i,o}var ly=Symbol.for("rtk-slice-createasyncthunk");function iy(e,t){return`${e}/${t}`}function oy({creators:e}={}){var n;const t=(n=e==null?void 0:e.asyncThunk)==null?void 0:n[ly];return function(l){const{name:i,reducerPath:o=i}=l;if(!i)throw new Error(Ae(11));typeof process<"u";const u=(typeof l.reducers=="function"?l.reducers(sy()):l.reducers)||{},s=Object.keys(u),a={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},d={addCase(S,f){const c=typeof S=="string"?S:S.type;if(!c)throw new Error(Ae(12));if(c in a.sliceCaseReducersByType)throw new Error(Ae(13));return a.sliceCaseReducersByType[c]=f,d},addMatcher(S,f){return a.sliceMatchers.push({matcher:S,reducer:f}),d},exposeAction(S,f){return a.actionCreators[S]=f,d},exposeCaseReducer(S,f){return a.sliceCaseReducersByName[S]=f,d}};s.forEach(S=>{const f=u[S],c={reducerName:S,type:iy(i,S),createNotation:typeof l.reducers=="function"};cy(f)?dy(c,f,d,t):ay(c,f,d)});function p(){const[S={},f=[],c=void 0]=typeof l.extraReducers=="function"?vd(l.extraReducers):[l.extraReducers],h={...S,...a.sliceCaseReducersByType};return ry(l.initialState,w=>{for(let k in h)w.addCase(k,h[k]);for(let k of a.sliceMatchers)w.addMatcher(k.matcher,k.reducer);for(let k of f)w.addMatcher(k.matcher,k.reducer);c&&w.addDefaultCase(c)})}const m=S=>S,v=new WeakMap;let y;const g={name:i,reducerPath:o,reducer(S,f){return y||(y=p()),y(S,f)},actions:a.actionCreators,caseReducers:a.sliceCaseReducersByName,getInitialState(){return y||(y=p()),y.getInitialState()},getSelectors(S=m){const f=Ca(v,this,{insert:()=>new WeakMap});return Ca(f,S,{insert:()=>{const c={};for(const[h,w]of Object.entries(l.selectors??{}))c[h]=uy(this,w,S,this!==g);return c}})},selectSlice(S){let f=S[this.reducerPath];return typeof f>"u"&&this!==g&&(f=this.getInitialState()),f},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(S,{reducerPath:f,...c}={}){const h=f??this.reducerPath;return S.inject({reducerPath:h,reducer:this.reducer},c),{...this,reducerPath:h}}};return g}}function uy(e,t,n,r){function l(i,...o){let u=n.call(e,i);return typeof u>"u"&&r&&(u=e.getInitialState()),t(u,...o)}return l.unwrapped=t,l}var Xu=oy();function sy(){function e(t,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...n}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function ay({type:e,reducerName:t,createNotation:n},r,l){let i,o;if("reducer"in r){if(n&&!fy(r))throw new Error(Ae(17));i=r.reducer,o=r.prepare}else i=r;l.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,o?yr(e,o):yr(e))}function cy(e){return e._reducerDefinitionType==="asyncThunk"}function fy(e){return e._reducerDefinitionType==="reducerWithPrepare"}function dy({type:e,reducerName:t},n,r,l){if(!l)throw new Error(Ae(18));const{payloadCreator:i,fulfilled:o,pending:u,rejected:s,settled:a,options:d}=n,p=l(e,i,d);r.exposeAction(t,p),o&&r.addCase(p.fulfilled,o),u&&r.addCase(p.pending,u),s&&r.addCase(p.rejected,s),a&&r.addMatcher(p.settled,a),r.exposeCaseReducer(t,{fulfilled:o||Qr,pending:u||Qr,rejected:s||Qr,settled:a||Qr})}function Qr(){}var Yu="listenerMiddleware";yr(`${Yu}/add`);yr(`${Yu}/removeAll`);yr(`${Yu}/remove`);function Ae(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}const py={items:[],length:0},yd=Xu({name:"cart",initialState:py,reducers:{addToCart:(e,t)=>{e.items.push(t.payload),e.length=e.items.length},removeFromCart:(e,t)=>{const n=t.payload;n>=0&&n{const e=ti(),[t,n]=E.useState([]);E.useEffect(()=>{const i=JSON.parse(sessionStorage.getItem("cartItems")||"[]");console.log(i),n(i)},[]);const r=i=>{sessionStorage.setItem("cartItems",JSON.stringify(i))},l=i=>{e(my(i)),n(o=>{const u=o.filter((s,a)=>a!==i);return r(u),u})};return C.jsxs(C.Fragment,{children:[C.jsx(Vu,{}),C.jsx("h2",{className:"ml-20 text-3xl underline",children:"Ваша корзина"}),C.jsxs("div",{className:"m-8 flex flex-wrap justify-center",children:[t.length===0&&C.jsx("h2",{className:"mt-3 xl:text-3xl lg:text-2xl sm:text-sm font-bold text-amber-950",children:"товаров в корзине нет"}),t.map((i,o)=>C.jsxs("div",{className:"m-10 w-282 flex flex-col items-center box-border rounded-10 overflow-hidden bg-gray-100 shadow-md rounded",children:[C.jsx("div",{className:"min-h-max",children:C.jsx("img",{className:"w-80 bg-contain cursor-pointer hover:shadow-2xl",src:i.photo,alt:i.nameProduct,title:"фото товара"})}),C.jsx("h2",{className:"mt-3 xl:text-3xl lg:text-2xl sm:text-sm font-bold text-amber-950",children:i.nameProduct}),C.jsxs("p",{className:"mt-2 xl:text-xl lg:text-base sm:text-sm",children:["цвет: ",i.colorName]}),C.jsxs("p",{className:"mt-2 xl:text-xl lg:text-base sm:text-sm",children:["размер: ",i.sizeName," "]}),C.jsxs("p",{className:"mt-2 xl:text-xl lg:text-base sm:text-sm",children:["цена: ",i.price," "]}),C.jsx("button",{className:"mb-2 bg-slate-400 rounded-full",onClick:()=>l(o),children:C.jsx("p",{className:"py-2 px-3 font-bold xl:text-base lg:text-base sm:text-sm text-black",children:"Удалить из корзины"})})]},o))]})]})},gy={isOpen:!1,images:[],currentImageIndex:0},gd=Xu({name:"popup",initialState:gy,reducers:{openPopup:(e,t)=>{e.isOpen=!0,e.images=t.payload,e.currentImageIndex=0},closePopup:e=>{e.isOpen=!1,e.images=[],e.currentImageIndex=0},nextImage:e=>{e.currentImageIndex=(e.currentImageIndex+1)%e.images.length},prevImage:e=>{e.currentImageIndex=(e.currentImageIndex-1+e.images.length)%e.images.length}}}),{openPopup:wy,closePopup:Sy,nextImage:xy,prevImage:ky}=gd.actions,Ey=gd.reducer,Cy={selectedSizes:{}},wd=Xu({name:"sizeSelect",initialState:Cy,reducers:{isSelect:(e,t)=>{const{cardId:n,sizeName:r}=t.payload;e.selectedSizes={...e.selectedSizes,[n]:r}},notSelect:(e,t)=>{const n=t.payload;e.selectedSizes={...e.selectedSizes,[n]:null}}}}),{isSelect:_y,notSelect:Py}=wd.actions,Ny=wd.reducer,zy=({sizes:e,colorId:t})=>{const n=ti(),[r,l]=E.useState([]),[i,o]=E.useState(null);E.useEffect(()=>{(async()=>{const a=e.map(async p=>(await Xm(p)).label),d=await Promise.all(a);l(d)})()},[e]);const u=s=>{i===s?(o(null),n(Py(t.toString()))):(o(s),n(_y({cardId:t.toString(),sizeName:s})))};return C.jsx("div",{className:"flex",children:r.map((s,a)=>C.jsx("p",{className:`m-3 p-0 cursor-pointer font-bold ${i===s?"underline":""}`,onClick:()=>u(s),children:s},a))})},Ry=()=>{const e=ti(),{isOpen:t,images:n,currentImageIndex:r}=jl(u=>u.popup),l=()=>{e(Sy())},i=()=>{e(xy())},o=()=>{e(ky())};return!t||!n.length?null:C.jsx("div",{className:`fixed top-0 left-0 w-full h-full flex items-center justify-center bg-black bg-opacity-50 transition-all duration-500 ${t?"visible opacity-100":"invisible opacity-0"}`,children:C.jsxs("div",{className:"w-430 mx-auto bg-white shadow-md rounded-10 flex flex-col items-center",children:[C.jsx("button",{type:"button",className:"w-32 h-8 bg-slate-400 border-none font-bold text-24 text-black",onClick:l,children:"Закрыть ×"}),C.jsx("img",{className:"w-80 bg-contain",src:n[r],alt:`Image ${r+1}`}),C.jsxs("div",{className:"flex justify-between w-full items-start p-3",children:[C.jsx("button",{className:"w-32 h-8 bg-slate-400 font-bold text-24 text-black",onClick:o,children:"< Предыдущая"}),C.jsx("button",{className:"w-32 h-8 bg-slate-400 font-bold text-24 text-black",onClick:i,children:"Следующая >"})]})]})})},Ty=()=>{const e=ti(),{id:t}=km(),[n,r]=E.useState([]),[l,i]=E.useState(""),[o,u]=E.useState([]),{items:s}=jl(v=>v.cart);E.useEffect(()=>{sessionStorage.setItem("cartItems",JSON.stringify(s))},[s]);const{selectedSizes:a}=jl(v=>v.sizeSelect),d=async()=>{if(t!==void 0){const v=await Gm(parseInt(t.toString()));i(v.name),r(v.colors);const g=await Promise.all(v.colors.map(async S=>S.sizes));u(g)}};E.useEffect(()=>{d()},[d]);const p=v=>{const g=v.currentTarget.getAttribute("data-images");g&&e(wy(JSON.parse(g)))},m=(v,y,g,S,f)=>{e(hy({colorName:y,sizeName:f,photo:g,price:S,nameProduct:v}))};return C.jsxs(C.Fragment,{children:[C.jsx(Vu,{}),C.jsx("h2",{className:"ml-20 text-3xl underline",children:l}),C.jsx("div",{className:"m-8 flex flex-wrap justify-center",children:n.map((v,y)=>C.jsxs("div",{className:"m-10 w-282 flex flex-col items-center box-border rounded-10 overflow-hidden bg-gray-100 shadow-md rounded",children:[C.jsx("div",{className:"",children:C.jsx("img",{className:"w-80 bg-contain cursor-pointer hover:shadow-2xl",src:v.images[0],alt:v.name,title:"посмотреть","data-images":JSON.stringify(v.images),onClick:p,onTouchStart:p})}),C.jsxs("h2",{className:"mt-3 xl:text-3xl lg:text-2xl sm:text-sm font-bold text-amber-950",children:["цвет: ",v.name]}),C.jsxs("p",{className:"mt-2 xl:text-xl lg:text-base sm:text-sm",children:["цена: ",v.price," "]}),C.jsx("p",{className:"my-2",children:"выберете размер:"}),v.sizes.length>0?C.jsxs("div",{className:"flex flex-col items-center",children:[C.jsx(zy,{sizes:o[y],colorId:v.id}),C.jsx("button",{className:`mb-2 ${a[v.id]?"bg-slate-400":"bg-gray-300"} rounded-full`,disabled:!a[v.id],onClick:()=>{const g=a[v.id];g!==null&&m(l,v.name,v.images[0],v.price,g)},children:C.jsx("p",{className:"py-2 px-3 font-bold xl:text-base lg:text-base sm:text-sm text-black",children:"Добавить в корзину"})})]}):C.jsx("p",{className:"my-2 font-bold xl:text-base lg:text-base sm:text-sm",children:"нет в наличии"})]},v.id))}),C.jsx(Ry,{})]})},Oy=()=>C.jsxs("main",{className:"bg-slate-200 min-h-screen",children:[C.jsx("h2",{className:"pt-10 mx-10 text-3xl sm:text-5xl font-bold",children:"E-commerce"}),C.jsxs(Dm,{children:[C.jsx(ll,{path:"/",element:C.jsx(Sv,{})}),C.jsx(ll,{path:"/product/:id",element:C.jsx(Ty,{})}),C.jsx(ll,{path:"/favorite",element:C.jsx(yy,{})})]})]}),jy=ty({reducer:{popup:Ey,cart:vy,sizeSelect:Ny}});Ai.createRoot(document.getElementById("root")).render(C.jsx(Yo.StrictMode,{children:C.jsx(yv,{store:jy,children:C.jsx(Wm,{children:C.jsx(Oy,{})})})})); diff --git a/index.html b/index.html index 469a95b..f14b72d 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ E-commerce - +