1import{c as Ue,r as p,R as He,j as i,a as q,aB as Ke,al as ve,b1 as Be,b2 as Ge,L as Ye}from"./main-Bmw7chmx.js";import{u as re}from"./useQuery-CraJ5e4a.js";import{u as Ve}from"./useMutation-DOeBEZLC.js";import{u as Ze}from"./useServerFn-eIrojyZs.js";import{I as Je}from"./input-DwS_qeNF.js";import{B as M}from"./button-BeDxX-zt.js";import{C as Xe,d as et}from"./card-b87ydQ_i.js";import{C as tt}from"./circle-znzk1Xn_.js";import{$ as nt,e as st}from"./react-photo-view.module-BHR-Ae6C.js";import{D as it,a as rt,b as ot,c as at,d as lt}from"./dialog-BNXI0hBV.js";import{T as ct,a as dt,b as ue,c as fe}from"./tabs-DnfH5pcV.js";import{u as Fe}from"./CartContext-Bg4THXp0.js";import{n as ut,o as ft}from"./product-config.server-fn-BLzwFzIy.js";import{M as we}from"./minus-PsvHo18U.js";import{P as Ne}from"./plus-BRqKgJb7.js";import{C as mt}from"./check-CQT23PIo.js";import{a as ht,b as pt}from"./photo.server-fn-mPqI9Cvx.js";import{g as xt,v as gt}from"./group.server-fn-BBl_FIcJ.js";import{L as vt}from"./lock-BWh_hFyI.js";import{S as yt}from"./shield-check-qFwXnSe9.js";import"./x-DJV1_On8.js";import"./index-BZvPXVC8.js";import"./index-JKXjBwWp.js";import"./index-DnTrZYry.js";const jt=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],bt=Ue("grid-3x3",jt),L=0,R=1,Pt=2,wt=0,he=1;function Nt(e,t,n){let s=e.list,r;for(;s;){if(s.index===n)return!1;if(t>s.high)break;r=s,s=s.next}return r||(e.list={index:n,high:t,next:s}),r&&(r.next={index:n,high:t,next:r.next}),!0}function Ct(e,t){let n=e.list;if(n.index===t)return n.next===null?wt:(e.list=n.next,he);let s=n;for(n=n.next;n!==null;){if(n.index===t)return s.next=n.next,he;s=n,n=n.next}}const w={low:0,max:0,high:0,C:Pt,P:void 0,R:void 0,L:void 0,list:void 0};w.P=w;w.L=w;w.R=w;function Q(e){const t=e.high;e.L===w&&e.R===w?e.max=t:e.L===w?e.max=Math.max(e.R.max,t):e.R===w?e.max=Math.max(e.L.max,t):e.max=Math.max(Math.max(e.L.max,e.R.max),t)}function te(e){let t=e;for(;t.P!==w;)Q(t.P),t=t.P}function V(e,t){if(t.R===w)return;const n=t.R;t.R=n.L,n.L!==w&&(n.L.P=t),n.P=t.P,t.P===w?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.L=t,t.P=n,Q(t),Q(n)}function Z(e,t){if(t.L===w)return;const n=t.L;t.L=n.R,n.R!==w&&(n.R.P=t),n.P=t.P,t.P===w?e.root=n:t===t.P.R?t.P.R=n:t.P.L=n,n.R=t,t.P=n,Q(t),Q(n)}function ne(e,t,n){t.P===w?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.P=t.P}function Rt(e,t){let n;for(;t!==w&&t.C===R;)t===t.P.L?(n=t.P.R,n.C===L&&(n.C=R,t.P.C=L,V(e,t.P),n=t.P.R),n.L.C===R&&n.R.C===R?(n.C=L,t=t.P):(n.R.C===R&&(n.L.C=R,n.C=L,Z(e,n),n=t.P.R),n.C=t.P.C,t.P.C=R,n.R.C=R,V(e,t.P),t=e.root)):(n=t.P.L,n.C===L&&(n.C=R,t.P.C=L,Z(e,t.P),n=t.P.L),n.R.C===R&&n.L.C===R?(n.C=L,t=t.P):(n.L.C===R&&(n.R.C=R,n.C=L,V(e,n),n=t.P.L),n.C=t.P.C,t.P.C=R,n.L.C=R,Z(e,t.P),t=e.root));t.C=R}function St(e){for(;e.L!==w;)e=e.L;return e}function Tt(e,t){let n;for(;t.P.C===L;)t.P===t.P.P.L?(n=t.P.P.R,n.C===L?(t.P.C=R,n.C=R,t.P.P.C=L,t=t.P.P):(t===t.P.R&&(t=t.P,V(e,t)),t.P.C=R,t.P.P.C=L,Z(e,t.P.P))):(n=t.P.P.L,n.C===L?(t.P.C=R,n.C=R,t.P.P.C=L,t=t.P.P):(t===t.P.L&&(t=t.P,Z(e,t)),t.P.C=R,t.P.P.C=L,V(e,t.P.P)));e.root.C=R}function kt(){const e={root:w,size:0},t={};return{insert(n,s,r){let o=e.root,a=w;for(;o!==w&&(a=o,n!==a.low);)n<o.low?o=o.L:o=o.R;if(n===a.low&&a!==w){if(!Nt(a,s,r))return;a.high=Math.max(a.high,s),Q(a),te(a),t[r]=a,e.size++;return}const l={low:n,high:s,max:s,C:L,P:a,L:w,R:w,list:{index:r,high:s,next:null}};a===w?e.root=l:(l.low<a.low?a.L=l:a.R=l,te(l)),Tt(e,l),t[r]=l,e.size++},remove(n){const s=t[n];if(s===void 0)return;delete t[n];const r=Ct(s,n);if(r===void 0)return;if(r===he){s.high=s.list.high,Q(s),te(s),e.size--;return}let o=s,a=o.C,l;s.L===w?(l=s.R,ne(e,s,s.R)):s.R===w?(l=s.L,ne(e,s,s.L)):(o=St(s.R),a=o.C,l=o.R,o.P===s?l.P=o:(ne(e,o,o.R),o.R=s.R,o.R.P=o),ne(e,s,o),o.L=s.L,o.L.P=o,o.C=s.C),Q(l),te(l),a===R&&Rt(e,l),e.size--},search(n,s,r){const o=[e.root];for(;o.length!==0;){const a=o.pop();if(!(a===w||n>a.max)&&(a.L!==w&&o.push(a.L),a.R!==w&&o.push(a.R),a.low<=s&&a.high>=n)){let l=a.list;for(;l!==null;)l.high>=n&&r(l.index,a.low),l=l.next}}},get size(){return e.size}}}const oe=e=>{const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),t},Lt=(e,t=100,n=!1)=>{const s=oe(e),r=p.useRef(),o=[t,n,s];function a(){r.current&&clearTimeout(r.current),r.current=void 0}p.useEffect(()=>a,o);function l(){r.current=void 0}return p.useCallback(function(){const d=arguments,{current:u}=r;if(u===void 0&&n)return r.current=setTimeout(l,t),s.current.apply(null,d);u&&clearTimeout(u),r.current=setTimeout(()=>{r.current=void 0,s.current.apply(null,d)},t)},o)},zt=(e,t,n)=>{const s=p.useState(e);return[s[0],Lt(s[1],t,n)]};function J(e,t,n,s){const r=p.useRef(n),o=p.useRef(s);p.useEffect(()=>{r.current=n,o.current=s}),p.useEffect(()=>{const a=e&&"current"in e?e.current:e;if(!a)return;let l=0;function d(...f){l||r.current.apply(this,f)}
1a.addEventListener(t,d);const u=o.current;return()=>{l=1,a.removeEventListener(t,d),u&&u()}},[e,t])}const Et={},X=typeof window>"u"?null:window,Mt=X&&typeof X.visualViewport<"u"?X.visualViewport:null,Ce=()=>[document.documentElement.clientWidth,document.documentElement.clientHeight],It=function(e){e===void 0&&(e=Et);const{wait:t,leading:n,initialWidth:s=0,initialHeight:r=0}=e,[o,a]=zt(typeof document>"u"?[s,r]:Ce,t,n),l=()=>a(Ce);return J(X,"resize",l),J(Mt,"resize",l),J(X,"orientationchange",l),o},ae=(e,t)=>{const n=t||Ft;let s,r;return function(){return s&&n(arguments,s)?r:r=e.apply(null,s=arguments)}},Ft=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3];class Re{constructor(){this.set=void 0,this.get=void 0;let t,n;this.get=s=>s===t?n:void 0,this.set=(s,r)=>{t=s,n=r}}}const me=e=>{try{return new e}catch{const n={};return{set(s,r){n[s]=r},get(s){return n[s]}}}},qt=e=>{const t=e.length,n=me(e[0]);let s,r,o,a;const l=t===1,d=m=>(s=n.get(m[0]))===void 0||l?s:s.get(m[1]),u=(m,h)=>(l?n.set(m[0],h):(s=n.get(m[0]))===void 0?(r=me(e[1]),r.set(m[1],h),n.set(m[0],r)):s.set(m[1],h),h),f=m=>{for(a=n,o=0;o<t;o++)if((a=a.get(m[o]))===void 0)return;return a},j=(m,h)=>{for(a=n,o=0;o<t-1;o++)(r=a.get(m[o]))===void 0&&(r=me(e[o+1]),a.set(m[o],r)),a=r;return a.set(m[t-1],h),h};return t<3?{g:d,s:u}:{g:f,s:j}},qe=(e,t)=>{let n;const{g:s,s:r}=qt(e);return function(){return(n=s(arguments))===void 0?r(arguments,t.apply(null,arguments)):n}},pe=new WeakMap;function Oe(){const e=p.useState(Ot)[1];return p.useRef(()=>e({})).current}const Ot={},se=p.createElement;function Dt(e){let{positioner:t,resizeObserver:n,items:s,as:r="div",id:o,className:a,style:l,role:d="grid",tabIndex:u=0,containerRef:f,itemAs:j="div",itemStyle:m,itemHeightEstimate:h=300,itemKey:N=Wt,overscanBy:v=2,scrollTop:C,isScrolling:z,height:S,render:I,onRender:K}=e,W=0,O;const le=Oe(),_=At(t,n),k=s.length,{columnWidth:A,columnCount:c,range:y,estimateHeight:b,size:P,shortestColumn:x}=t,g=P(),T=x(),E=[],D=d==="list"?"listitem":d==="grid"?"gridcell":void 0,B=oe(K);v=S*v;const je=C+v,ce=T<je&&g<k;if(y(Math.max(0,C-v/2),je,(F,$,ee)=>{const G=s[F],de=N(G,F),Pe={top:ee,left:$,width:A,writingMode:"horizontal-tb",position:"absolute"};E.push(se(j,{key:de,ref:_(F),role:D,style:typeof m=="object"&&m!==null?Object.assign({},Pe,m):Pe},Te(I,F,G,A))),O===void 0?(W=F,O=F):(W=Math.min(W,F),O=Math.max(O,F))}),ce){const F=Math.min(k-g,Math.ceil((C+v-T)/h*c));let $=g;const ee=_t(A);for(;$<g+F;$++){const G=s[$],de=N(G,$);E.push(se(j,{key:de,ref:_($),role:D,style:typeof m=="object"?Object.assign({},ee,m):ee},Te(I,$,G,A)))}}p.useEffect(()=>{typeof B.current=="function"&&O!==void 0&&B.current(W,O,s),Se="1"},[W,O,s,B]),p.useEffect(()=>{ce&&le()},[ce,t]);const be=$t(z,b(k,h));return se(r,{ref:f,key:Se,id:o,role:d,className:a,tabIndex:u,style:typeof l=="object"?Qt(be,l):be,children:E})}let Se="0";const Te=qe([Re,{},WeakMap,Re],(e,t,n,s)=>se(e,{index:t,data:n,width:s})),$t=ae((e,t)=>({position:"relative",width:"100%",maxWidth:"100%",height:Math.ceil(t),maxHeight:Math.ceil(t),willChange:e?"contents":void 0,pointerEvents:e?"none":void 0})),De=(e,t)=>e[0]===t[0]&&e[1]===t[1],Qt=ae((e,t)=>Object.assign({},e,t),De);function Wt(e,t){return t}const _t=ae(e=>({width:e,zIndex:-1e3,visibility:"hidden",position:"absolute",writingMode:"horizontal-tb"}),(e,t)=>e[0]===t[0]),At=ae((e,t)=>n=>s=>{s!==null&&(t&&(t.observe(s),pe.set(s,n)),e.get(n)===void 0&&e.set(n,s.offsetHeight))},De);let $e="undefined",H=typeof window!==$e?window:{},Ut=typeof performance!==$e?performance:Date,xe=()=>Ut.now(),Qe="AnimationFrame",ke="cancel"+Qe,Le="request"+Qe,ie=H[Le]&&H[Le].bind(H),ge=H[ke]&&H[ke].bind(H);function Ht(e){return clearTimeout(e)}if(!ie||!ge){let e=0;ie=t=>{let n=xe(),s=Math.max(e+1e3/60,n);return setTimeout(()=>{t(e=s)},s-n)},ge=Ht}const Kt=e=>{ge(e.v||-1)},Bt=(e,t)=>
1{const n=xe(),s={},r=()=>{xe()-n>=t?e.call(null):s.v=ie(r)};return s.v=ie(r),s},Gt=typeof performance<"u"?performance:Date,Yt=()=>Gt.now();function We(e,t=30,n=!1){const s=oe(e),r=1e3/t,o=p.useRef(0),a=p.useRef(),l=()=>a.current&&clearTimeout(a.current),d=[t,n,s];function u(){o.current=0,l()}return p.useEffect(()=>u,d),p.useCallback(function(){const f=arguments,j=Yt(),m=()=>{o.current=j,l(),s.current.apply(null,f)},h=o.current;if(n&&h===0)return m();if(j-h>r){if(h>0)return m();o.current=j}l(),a.current=setTimeout(()=>{m(),o.current=0},r)},d)}function Vt(e,t,n){const s=p.useState(e);return[s[0],We(s[1],t,n)]}const Y=typeof window>"u"?null:window,ze=()=>Y.scrollY!==void 0?Y.scrollY:Y.pageYOffset===void 0?0:Y.pageYOffset,Zt=(e=30)=>{const t=Vt(typeof window>"u"?0:ze,e,!0);return J(Y,"scroll",()=>t[1](ze())),t[0]};function Jt(e,t){e===void 0&&(e=0),t===void 0&&(t=12);const n=Zt(t),[s,r]=p.useState(!1),o=p.useRef(0);return p.useEffect(()=>{o.current===1&&r(!0);let a=!1;const l=Bt(()=>{a||r(!1)},40+1e3/t);return o.current=1,()=>{a=!0,Kt(l)}},[t,n]),{scrollTop:Math.max(0,n-e),isScrolling:s}}function Xt(e){const{scrollTop:t,isScrolling:n}=Jt(e.offset,e.scrollFps);return Dt({scrollTop:t,isScrolling:n,positioner:e.positioner,resizeObserver:e.resizeObserver,items:e.items,onRender:e.onRender,as:e.as,id:e.id,className:e.className,style:e.style,role:e.role,tabIndex:e.tabIndex,containerRef:e.containerRef,itemAs:e.itemAs,itemStyle:e.itemStyle,itemHeightEstimate:e.itemHeightEstimate,itemKey:e.itemKey,overscanBy:e.overscanBy,height:e.height,render:e.render})}const en=He[typeof document<"u"&&document.createElement!==void 0?"useLayoutEffect":"useEffect"];function tn(e,t){t===void 0&&(t=nn);const[n,s]=p.useState({offset:0,width:0});return en(()=>{const{current:r}=e;if(r!==null){let o=0,a=r;do o+=a.offsetTop||0,a=a.offsetParent;while(a);(o!==n.offset||r.offsetWidth!==n.width)&&s({offset:o,width:r.offsetWidth})}},t),n}const nn=[];function sn(e,t){let{width:n,columnWidth:s=200,columnGutter:r=0,rowGutter:o,columnCount:a,maxColumnCount:l,maxColumnWidth:d}=e;t===void 0&&(t=ln);const u=()=>{const[v,C]=an(n,s,r,a,l,d);return rn(C,v,r,o??r)},f=p.useRef();f.current===void 0&&(f.current=u());const j=p.useRef(t),m=[n,s,r,o,a,l,d],h=p.useRef(m),N=!m.every((v,C)=>h.current[C]===v);if(N||!t.every((v,C)=>j.current[C]===v)){const v=f.current,C=u();if(j.current=t,h.current=m,N){const z=v.size();for(let S=0;S<z;S++){const I=v.get(S);C.set(S,I!==void 0?I.height:0)}}f.current=C}return f.current}const rn=function(e,t,n,s){n===void 0&&(n=0),s===void 0&&(s=n);const r=kt(),o=new Array(e),a=[],l=new Array(e);for(let d=0;d<e;d++)o[d]=0,l[d]=[];return{columnCount:e,columnWidth:t,set:function(d,u){u===void 0&&(u=0);let f=0;for(let m=1;m<o.length;m++)o[m]<o[f]&&(f=m);const j=o[f]||0;o[f]=j+u+s,l[f].push(d),a[d]={left:f*(t+n),top:j,height:u,column:f},r.insert(j,j+u,d)},get:d=>a[d],update:d=>{const u=new Array(e);let f=0,j=0;for(;f<d.length-1;f++){const m=d[f],h=a[m];h.height=d[++f],r.remove(m),r.insert(h.top,h.top+h.height,m),u[h.column]=u[h.column]===void 0?m:Math.min(m,u[h.column])}for(f=0;f<u.length;f++){if(u[f]===void 0)continue;const m=l[f],h=on(m,u[f]),N=l[f][h],v=a[N];for(o[f]=v.top+v.height+s,j=h+1;j<m.length;j++){const C=m[j],z=a[C];z.top=o[f],o[f]=z.top+z.height+s,r.remove(C),r.insert(z.top,z.top+z.height,C)}}},range:(d,u,f)=>r.search(d,u,(j,m)=>f(j,a[j].left,m)),estimateHeight:(d,u)=>{const f=Math.max(0,Math.max.apply(null,o));return d===r.size?f:f+Math.ceil((d-r.size)/e)*u},shortestColumn:()=>o.length>1?Math.min.apply(null,o):o[0]||0,size(){return r.size},all(){return a}}},on=(e,t)=>{let n=0,s=e.length-1;for(;n<=s;){const r=n+s>>>1,o=e[r];if(o===t)return r;o<=t?n=r+1:s=r-1}return-1},an=function(e,t,n,s,r,o){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=8),s=s||Math.min(Math.floor((e+n)/(t+n)),r||1/0)||1;let a=Math.floor((e-n*(s-1))/s);return o!==void 0&&a>o&&(a=o),[a,s]},ln=[];var Ee=function(t){var n=[],s=null,r=function(){for(var a=arguments.length,l=new Array(a),d=0;d<a;d++)l[d]=arguments[d];n=l,!s&&(s=requestAnimationFrame(function(){s=null,t.apply(void 0,n)}))};return r.cancel=function(){s&&(cancelAnimationFrame(s),s=null)},r};
1function cn(e){const t=Oe(),n=un(e,t);function s(){return n.disconnect()}return p.useEffect(()=>s,[n]),n}function dn(e){e.cancel()}const un=qe([WeakMap],(e,t)=>{const n=[],s=Ee(()=>{n.length>0&&(e.update(n),t(n)),n.length=0}),r=u=>{const f=u.offsetHeight;if(f>0){const j=pe.get(u);if(j!==void 0){const m=e.get(j);m!==void 0&&f!==m.height&&n.push(j,f)}}s()},o=new Map,a=u=>{let f=0;for(;f<u.length;f++){const j=u[f],m=pe.get(j.target);if(m===void 0)continue;let h=o.get(m);h||(h=Ee(r),o.set(m,h)),h(j.target)}},l=new ResizeObserver(a),d=l.disconnect.bind(l);return l.disconnect=()=>{d(),o.forEach(dn)},l});function fn(e,t){var n;const{align:s="top",element:r=typeof window<"u"&&window,offset:o=0,height:a=typeof window<"u"?window.innerHeight:0}=t,l=oe({positioner:e,element:r,align:s,offset:o,height:a}),d=p.useRef(()=>{const h=l.current.element;return h&&"current"in h?h.current:h}).current,[u,f]=p.useReducer((h,N)=>{const v={position:h.position,index:h.index,prevTop:h.prevTop};if(N.type==="scrollToIndex"){var C;return{position:l.current.positioner.get((C=N.value)!==null&&C!==void 0?C:-1),index:N.value,prevTop:void 0}}else if(N.type==="setPosition")v.position=N.value;else if(N.type==="setPrevTop")v.prevTop=N.value;else if(N.type==="reset")return Me;return v},Me),j=We(f,15);J(d(),"scroll",()=>{if(!u.position&&u.index){const h=l.current.positioner.get(u.index);h&&f({type:"setPosition",value:h})}});const m=u.index!==void 0&&((n=l.current.positioner.get(u.index))===null||n===void 0?void 0:n.top);return p.useEffect(()=>{const h=d();if(!h)return;const{height:N,align:v,offset:C,positioner:z}=l.current;if(u.position){let S=u.position.top;v==="bottom"?S=S-N+u.position.height:v==="center"&&(S-=(N-u.position.height)/2),h.scrollTo(0,Math.max(0,S+=C));let I=!1;const K=setTimeout(()=>!I&&f({type:"reset"}),400);return()=>{I=!0,clearTimeout(K)}}else if(u.index!==void 0){let S=z.shortestColumn()/z.size()*u.index;u.prevTop&&(S=Math.max(S,u.prevTop+N)),h.scrollTo(0,S),j({type:"setPrevTop",value:S})}},[m,u,l,d,j]),p.useRef(h=>{f({type:"scrollToIndex",value:h})}).current}const Me={index:void 0,position:void 0,prevTop:void 0},mn=p.createElement;function hn(e){const t=p.useRef(null),n=It({initialWidth:e.ssrWidth,initialHeight:e.ssrHeight}),s=tn(t,n),r=Object.assign({offset:s.offset,width:s.width||n[0],height:n[1],containerRef:t},e);r.positioner=sn(r),r.resizeObserver=cn(r.positioner);const o=fn(r.positioner,{height:r.height,offset:s.offset,align:typeof e.scrollToIndex=="object"?e.scrollToIndex.align:void 0}),a=e.scrollToIndex&&(typeof e.scrollToIndex=="number"?e.scrollToIndex:e.scrollToIndex.index);return p.useEffect(()=>{a!==void 0&&o(a)},[a,o]),mn(Xt,r)}const pn=({data:e,isSelected:t,onToggleSelect:n})=>i.jsxs("div",{style:{aspectRatio:`${1/e.ratio}`},className:"relative group",children:[e.src?i.jsx("img",{src:e.src,alt:"Zdjecie",className:q("w-full h-auto rounded-lg shadow-md bg-slate-300 transition-all duration-200",t?"ring-4 ring-primary opacity-90 scale-[0.98]":"hover:scale-[1.01]")}):i.jsx("div",{className:q("w-full h-full rounded-lg shadow-md bg-slate-200 animate-pulse",t&&"ring-4 ring-primary")}),n&&i.jsx("button",{onClick:s=>{s.stopPropagation(),n()},className:q("absolute top-2 right-2 p-1 rounded-full bg-white/80 backdrop-blur-sm transition-all duration-200 hover:bg-white",t?"opacity-100 text-primary":"opacity-0 group-hover:opacity-100 text-muted-foreground"),children:t?i.jsx(Ke,{className:"w-6 h-6 fill-primary text-primary-foreground"}):i.jsx(tt,{className:"w-6 h-6"})})]});function U(e,t){if(e.length===0)return 0;const n=[...e].sort((r,o)=>o.minQuantity-r.minQuantity),s=n.find(r=>t>=r.minQuantity);return parseFloat(s?s.price:n[n.length-1].price)}const _e=({items:e,sessionId:t,groupId:n,onClose:s,trigger:r,lightbox:o})=>
1{const[a,l]=p.useState({}),[d,u]=p.useState({}),[f,j]=p.useState({}),{addItem:m}=Fe(),[h,N]=p.useState(!1),{data:v,isLoading:C}=re({queryKey:n?["group-product-config-public",t,n]:["session-product-config-public",t],queryFn:()=>n?ut({data:{photoSessionId:t,groupId:n}}):ft({data:{photoSessionId:t}}),staleTime:300*1e3,enabled:h});p.useEffect(()=>{h&&(l({}),u({}),j({}))},[h,e]);const z=c=>a[c]||0,S=(c,y)=>{l(b=>{const P=b[c]||0,x=Math.max(0,P+y);if(x===0){const{[c]:g,...T}=b;return T}return{...b,[c]:x}})},I=c=>{u(y=>({...y,[c]:(y[c]||0)+1}))},K=c=>{u(y=>{const b=y[c]||0,P=Math.max(0,b-1);if(P===0){const{[c]:x,...g}=y;return g}return{...y,[c]:P}})},W=c=>{j(y=>({...y,[c]:!y[c]}))},O=()=>{if(!v)return 0;let c=0;const y=e.length;return Object.entries(a).forEach(([b,P])=>{const x=v.prints.find(g=>g.id===b);if(x){const g=U(x.tiers,P*y);c+=g*P*y}}),Object.entries(d).forEach(([b,P])=>{for(const x of v.additionalProducts){const g=x.presets.find(T=>T.id===b);if(g){const D=(x.requiredPhotosCount>0?x.requiredPhotosCount:1)>1?P:P*y;c+=parseFloat(g.price)*D;break}}}),Object.entries(f).forEach(([b,P])=>
1{if(!P)return;const x=v.digital.find(g=>g.id===b);if(x){const g=U(x.tiers,y);c+=g*y}}),c},le=()=>{v&&(e.forEach(c=>{const y=c.src||"";Object.entries(a).forEach(([b,P])=>{const x=v.prints.find(g=>g.id===b);if(x){const g=P*e.length,T=U(x.tiers,g);m({type:"print",photoId:c.photoId,photoUrl:y,quantity:P,pricePerUnit:T,printsConfigId:x.id,sizeName:x.printSizeName,paperName:x.paperTypeName})}}),Object.entries(d).forEach(([b,P])=>{for(const x of v.additionalProducts){const g=x.presets.find(T=>T.id===b);if(g){(x.requiredPhotosCount>0?x.requiredPhotosCount:1)>1||m({type:"product",photoId:c.photoId,photoUrl:y,quantity:P,pricePerUnit:parseFloat(g.price),additionalProductPresetId:g.id,productName:`${x.templateName} â ${g.name}`});break}}}),Object.entries(f).forEach(([b,P])=>{if(!P)return;const x=v.digital.find(g=>g.id===b);if(x){const g=U(x.tiers,e.length);m({type:"digital",photoId:c.photoId,photoUrl:y,quantity:1,pricePerUnit:g,digitalFileConfigId:x.id,variant:x.variant})}})}),Object.entries(d).forEach(([c,y])=>{for(const b of v.additionalProducts){const P=b.presets.find(x=>x.id===c);if(P){const x=b.requiredPhotosCount>0?b.requiredPhotosCount:1;if(x>1)for(let g=0;g<y;g++){const T=g*x,E=e.slice(T,T+x);if(E.length<x)break;const D=E[0];m({type:"product",photoId:D.photoId,photoUrl:D.src||"",quantity:1,pricePerUnit:parseFloat(P.price),additionalProductPresetId:P.id,productName:`${b.templateName} â ${P.name} (${x} zdjÄÄ)`,photoIds:E.map(B=>B.photoId)})}break}}}),N(!1),s&&s())};if(!e||e.length===0)return null;const _=e.length>1,k=[];v?.printsPurchaseEnabled&&v.prints.length>0&&k.push("prints"),v?.additionalProductsPurchaseEnabled&&v.additionalProducts.length>0&&k.push("products"),v?.digitalFilePurchaseEnabled&&v.digital.length>0&&k.push("file");const A=k[0]||"prints";return i.jsxs(it,{open:h,onOpenChange:N,children:[i.jsx(rt,{asChild:!0,children:r||i.jsx(M,{variant:"default",children:"Kup"})}),i.jsx(ot,{className:q("p-0 w-screen h-2/3 sm:max-w-5xl border-0 overflow-hidden",o&&"z-[2100]"),overlayClassName:o?"z-[2100]":void 0,children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 h-full",children:[i.jsxs("div",{className:"col-span-1 relative flex items-center justify-center bg-black/5 overflow-hidden",children:[i.jsx("div",{className:"absolute top-0 left-0 w-full h-full -z-1 bg-white/20 backdrop-blur-md"}),_?i.jsxs("div",{className:"grid grid-cols-2 gap-2 p-4 w-full h-full content-center overflow-auto",children:[e.slice(0,4).map(c=>i.jsx(xn,{photoId:c.photoId,fallbackSrc:c.src},c.id)),e.length>4&&i.jsx("div",{className:"flex items-center justify-center bg-black/10 rounded-md",children:i.jsxs("span",{className:"font-bold text-muted-foreground",children:["+",e.length-4]})})]}):i.jsx(gn,{photoId:e[0].photoId,fallbackSrc:e[0].src})]}),i.jsxs("div",{className:"col-span-2 flex flex-col h-full overflow-hidden",children:[i.jsx("div",{className:"p-6 border-b shrink-0",children:i.jsx(at,{children:i.jsx(lt,{className:"text-2xl",children:_?`Dokonaj zakupu ${e.length} zdjÄÄ`:"Dokonaj zakupu zdjÄcia"})})}),C?i.jsx("div",{className:"flex-1 flex items-center justify-center",children:i.jsx(ve,{className:"h-8 w-8 animate-spin text-primary"})}):!v||k.length===0?i.jsx("div",{className:"flex-1 flex items-center justify-center text-center p-8",children:i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-lg font-medium",children:"Brak dostÄpnych produktów"}),i.jsx("p",{className:"text-muted-foreground",children:"Dla tej sesji nie skonfigurowano jeszcze oferty."})]})}):i.jsxs(ct,{defaultValue:A,className:"flex-1 flex flex-col overflow-hidden",children:[i.jsx("div",{className:"px-6 pt-6 pb-2 shrink-0",children:i.jsxs(dt,{className:q("grid w-full",`grid-cols-${k.length}`),children:[k.includes("prints")&&i.jsx(ue,{value:"prints",children:"Odbitki"}),k.includes("products")&&i.jsx(ue,{value:"products",children:"Produkty"}),k.includes("file")&&i.jsx(ue,{value:"file",children:"Plik elektroniczny"})]})}),k.includes("prints")&&i.jsx(fe,{value:"prints",className:"flex-1 overflow-y-auto px-6 pb-6 mt-4 outline-none",children:i.jsxs("div",{className:"space-y-4",children:[_&&i.jsxs("div",{className:"p-3 bg-blue-50 text-blue-700 text-sm rounded-md mb-4 flex items-center gap-2",children:[i.jsx(bt,{className:"w-4 h-4"}),"Wybrane opcje zostanÄ
zastosowane do wszystkich ",e.length," zdjÄÄ."]}),v.prints.map(c=>
1{const y=z(c.id),b=y*e.length,P=U(c.tiers,Math.max(b,1));return i.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-card shadow-sm hover:border-primary/50 transition-colors",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"font-semibold text-lg",children:c.printSizeName}),i.jsxs("span",{className:"text-sm text-muted-foreground",children:["Papier: ",c.paperTypeName]}),i.jsxs("span",{className:"text-sm text-muted-foreground",children:[P.toFixed(2)," PLN / szt.",c.tiers.length>1&&i.jsx("span",{className:"ml-1 text-xs text-primary",children:"(ceny od iloÅci)"})]})]}),i.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-md p-1",children:[i.jsx(M,{variant:"ghost",size:"icon-xs",onClick:()=>S(c.id,-1),className:"h-7 w-7",disabled:y===0,children:i.jsx(we,{className:"h-3 w-3"})}),i.jsx("span",{className:"w-8 text-center font-medium",children:y}),i.jsx(M,{variant:"ghost",size:"icon-xs",onClick:()=>S(c.id,1),className:"h-7 w-7",children:i.jsx(Ne,{className:"h-3 w-3"})})]})]},c.id)}),v.prints.some(c=>c.tiers.length>1)&&i.jsxs("div",{className:"border rounded-lg p-4 bg-muted/30",children:[i.jsx("h4",{className:"text-sm font-medium mb-2",children:"Progi cenowe:"}),v.prints.filter(c=>c.tiers.length>1).map(c=>i.jsxs("div",{className:"text-xs text-muted-foreground mb-1",children:[i.jsxs("span",{className:"font-medium",children:[c.printSizeName,"
1(",c.paperTypeName,"):"]})," ",[...c.tiers].sort((y,b)=>y.minQuantity-b.minQuantity).map((y,b)=>i.jsxs("span",{children:[b>0&&" | ",y.minQuantity,"+ szt. = ",parseFloat(y.price).toFixed(2)," PLN"]},y.id))]},c.id))]})]})}),k.includes("products")&&i.jsx(fe,{value:"products",className:"flex-1 overflow-y-auto px-6 pb-6 mt-4 outline-none",children:i.jsx("div",{className:"space-y-6",children:v.additionalProducts.map(c=>{const y=c.requiredPhotosCount>0?c.requiredPhotosCount:1,b=y>1,P=e.length>=y,x=b?Math.floor(e.length/y):e.length;return i.jsxs("div",{className:q("border rounded-lg overflow-hidden",!P&&b&&"opacity-60"),children:[i.jsxs("div",{className:"p-4 bg-card",children:[i.jsx("h3",{className:"font-semibold text-lg",children:c.templateName}),c.templateDescription&&i.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:c.templateDescription}),b&&i.jsxs("div",{className:q("text-xs mt-2 flex items-center gap-1.5 rounded-md px-2 py-1 w-fit",P?"bg-blue-50 text-blue-700":"bg-amber-50 text-amber-700"),children:[!P&&i.jsx(Be,{className:"w-3 h-3"}),P?`Wymaga ${y} zdjÄÄ na produkt â możesz utworzyÄ ${x} szt.`:`Wymaga ${y} zdjÄÄ â wybrano ${e.length}`,c.photoIncludedInPrice?" (zdjÄcie w cenie)":""]})]}),i.jsx("div",{className:"divide-y",children:c.presets.map(g=>{const T=d[g.id]||0,E=b&&!P,D=b?x:1/0;return i.jsxs("div",{className:q("flex items-center justify-between p-4 transition-colors",E?"opacity-50":"hover:bg-muted/30"),children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"font-medium",children:g.name}),g.description&&i.jsx("span",{className:"text-xs text-muted-foreground",children:g.description}),i.jsxs("span",{className:"text-sm font-semibold text-primary mt-0.5",children:[parseFloat(g.price).toFixed(2)," PLN",b&&P&&i.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["/ ",y," zdjÄÄ"]})]})]}),i.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-md p-1",children:[i.jsx(M,{variant:"ghost",size:"icon-xs",onClick:()=>K(g.id),className:"h-7 w-7",disabled:E||T===0,children:i.jsx(we,{className:"h-3 w-3"})}),i.jsx("span",{className:"w-8 text-center font-medium",children:T}),i.jsx(M,{variant:"ghost",size:"icon-xs",onClick:()=>I(g.id),className:"h-7 w-7",disabled:E||T>=D,children:i.jsx(Ne,{className:"h-3 w-3"})})]})]},g.id)})})]},c.id)})})}),k.includes("file")&&i.jsx(fe,{value:"file",className:"flex-1 overflow-y-auto px-6 pb-6 mt-4 outline-none",children:i.jsx("div",{className:"space-y-4",children:v.digital.map(c=>{const y=f[c.id]||!1,b=U(c.tiers,e.length),P=c.variant==="full"?"PeÅna rozdzielczoÅÄ":c.variant==="thumbnail"?"Miniaturka":c.variant;return i.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-6 border-2 border-dashed rounded-xl p-8",children:[i.jsx("div",{className:"p-4 bg-primary/10 rounded-full",children:i.jsx(mt,{className:q("h-12 w-12 transition-all",y?"text-primary":"text-muted-foreground/30")})}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("h3",{className:"text-2xl font-semibold tracking-tight",children:"Plik cyfrowy"}),i.jsx("p",{className:"text-muted-foreground max-w-sm mx-auto",children:P}),i.jsxs("p",{className:"text-xl font-bold text-primary pt-2",children:[b.toFixed(2)," PLN / szt."]}),c.tiers.length>1&&i.jsx("div",{className:"text-xs text-muted-foreground",children:[...c.tiers].sort((x,g)=>x.minQuantity-g.minQuantity).map((x,g)=>i.jsxs("span",{children:[g>0&&" | ",x.minQuantity,"+ = ",parseFloat(x.price).toFixed(2)," PLN"]},x.id))})]}),i.jsx(M,{size:"lg",variant:y?"secondary":"default",onClick:()=>W(c.id),className:"min-w-[200px]",children:y?"Wybrano":"Wybierz"})]},c.id)})})})]}),i.jsxs("div",{className:"border-t p-6 bg-muted/20 shrink-0",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{className:"text-sm text-muted-foreground",children:"Wybrane elementy zostanÄ
dodane do koszyka"}),i.jsxs("div",{className:"text-right",children:[i.jsx("div",{className:"text-sm text-muted-foreground",children:"CaÅkowita wartoÅÄ:"}),i.jsxs("div",{className:"font-bold text-2xl text-primary",children:[O().toFixed(2)," PLN"]})]})]}),i.jsxs("div",{className:"mt-4 flex justify-end gap-3",children:[i.jsx(M,{variant:"outline",onClick:()=>N(!1),children:"Anuluj"}),i.jsx(M,{className:"w-full sm:w-auto px-8",onClick:le,children:"Dodaj do koszyka"})]})]})]})]})})]})};function xn({photoId:e,fallbackSrc:t}){const{data:n}=ye(e),s=n||t;return i.jsx("div",{className:"relative aspect-square overflow-hidden rounded-md shadow-sm",children:s?i.jsx("img",{src:s,className:"w-full h-full object-cover"}):i.jsx("div",{className:"w-full h-full bg-slate-200 animate-pulse"})})}function gn({photoId:e,fallbackSrc:t}){const{data:n}=ye(e),s=n||t;return i.jsx(i.Fragment,{children:s?i.jsxs(i.Fragment,{children:[i.jsx("img",{src:s,className:"absolute top-0 left-0 w-full h-full -z-2 object-cover blur-sm op
1acity-50"}),i.jsx("img",{src:s,className:"max-w-full max-h-full shadow-lg object-contain p-4"})]}):i.jsx("div",{className:"w-32 h-32 bg-slate-200 animate-pulse rounded-lg"})})}const vn="_endClientPhotoProvider_dizrn_1",yn={endClientPhotoProvider:vn},jn=({items:e,sessionId:t,groupId:n,...s})=>{const r=({index:o})=>{const a=e?e[o]:void 0,l=a?[a]:[];return i.jsx("div",{children:i.jsx(_e,{items:l,sessionId:t,groupId:n,lightbox:!0})})};return i.jsx(nt,{photoWrapClassName:"bg-white",toolbarRender:r,className:q(yn.endClientPhotoProvider,s.className),...s})};function ye(e){return re({queryKey:["photo-thumbnail",e],queryFn:async()=>{const t=await ht({data:{photoId:e,variant:"thumbnail"}});return`data:${t.contentType};base64,${t.base64}`},staleTime:1800*1e3,gcTime:3600*1e3})}const Ae=p.createContext({selectedIds:new Set,toggleSelect:()=>{}}),bn=({data:e})=>{const{selectedIds:t,toggleSelect:n}=p.useContext(Ae),s=t.has(e.id),{data:r}=ye(e.photoId),o=r||e.src;return i.jsx(st,{src:o,children:i.jsx("div",{className:"m-2",children:i.jsx(pn,{data:{...e,src:o},isSelected:s,onToggleSelect:()=>n(e.id)})})})},Pn=({photos:e,sessionId:t,groupId:n})=>{const[s,r]=p.useState(new Set),o=d=>{const u=new Set(s);u.has(d)?u.delete(d):u.add(d),r(u)},a=p.useMemo(()=>e.map(d=>({id:d.id,src:"",ratio:d.height&&d.width?d.height/d.width:1,photoId:d.id,loading:!0})),[e]),l=p.useMemo(()=>a.filter(d=>s.has(d.id)),[s,a]);return i.jsx(Ae.Provider,{value:{selectedIds:s,toggleSelect:o},children:i.jsxs("div",{children:[i.jsx(jn,{items:a,sessionId:t,groupId:n,children:i.jsx(hn,{items:a,render:bn,columnCount:5})}),s.size>0&&i.jsx("div",{className:"fixed bottom-8 left-1/2 -translate-x-1/2 z-50",children:i.jsx(_e,{items:l,sessionId:t,groupId:n,onClose:()=>r(new Set),trigger:i.jsxs(M,{size:"lg",className:"shadow-xl rounded-full px-8 animate-in slide-in-from-bottom-4 zoom-in-95 duration-200",children:["Kup wybrane (",s.size,")"]})})})]})})};function Ie(e){return typeof window>"u"?!1:sessionStorage.getItem(`group_unlocked_${e}`)==="true"}function wn(e){sessionStorage.setItem(`group_unlocked_${e}`,"true")}function Nn(e){const t=new Map;function n(s){for(const r of s)t.set(r.id,r),n(r.children)}return n(e),t}function Cn(e,t){const n=[];let s=t.get(e);for(;s?.parentGroupId;){const o=t.get(s.parentGroupId);if(!o)break;n.unshift(o),s=o}for(const o of n)if(o.hasPassword&&!Ie(o.id))return o;const r=t.get(e);return r?.hasPassword&&!Ie(e)?r:null}function Jn(){const{groupId:e,sessionId:t}=Ge.useParams(),n=re({queryKey:["group-tree-public",t],queryFn:()=>xt({data:{photoSessionId:t}}),staleTime:300*1e3}),s=p.useMemo(()=>Nn(n.data??[]),[n.data]),[,r]=p.useState(0),o=Cn(e,s);return n.isLoading?i.jsx("div",{className:"flex items-center justify-center min-h-[50vh]",children:i.jsx(ve,{className:"h-8 w-8 animate-spin text-primary"})}):o?i.jsx(Rn,{lockedGroup:o,currentGroupId:e,sessionId:t,onUnlocked:()=>r(a=>a+1)}):i.jsx(Sn,{groupId:e,sessionId:t})}function Rn({lockedGroup:e,currentGroupId:t,sessionId:n,onUnlocked:s}){const[r,o]=p.useState(""),[a,l]=p.useState(null),d=e.id!==t,u=Ve({mutationFn:Ze(gt),onSuccess:j=>{j.valid?(wn(e.id),o(""),l(null),s()):l("NieprawidÅowe hasÅo.")},onError:()=>{l("WystÄ
piÅ bÅÄ
d.")}}),f=p.useCallback(j=>{j.preventDefault(),l(null),u.mutate({data:{groupId:e.id,password:r}})},[e.id,r,u]);return i.jsx("div",{className:"container mx-auto py-16 px-4 flex items-center justify-center min-h-[50vh]",children:i.jsx(Xe,{className:"w-full max-w-md",children:i.jsxs(et,{className:"space-y-6 pt-6",children:[i.jsxs("div",{className:"flex flex-col items-center text-center space-y-2",children:[i.jsx(vt,{className:"h-10 w-10 text-primary"}),i.jsx("h2",{className:"text-2xl font-display font-bold",children:"Grupa chroniona hasÅem"})]}),d&&i.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-amber-50 text-amber-800 px-3 py-2 text-sm",children:[i.jsx(yt,{className:"h-4 w-4 shrink-0"}),i.jsxs("span",{children:["Najpierw odblokuj grupÄ nadrzÄdnÄ
: ",i.jsx("strong",{children:e.name})]})]}),i.jsxs("form",{onSubmit:f,className:"space-y-4",children:[i.jsx(Je,{type:"password",value:r,onChange:j=>o(j.target.value),placeholder:d?`HasÅo grupy "${e.name}"`:"Wprowadź hasÅo grupy",autoFocus:!0,required:!0}),a&&i.jsx("p",{className:"text-sm text-destructive text-center",children:a}
1),i.jsx(M,{type:"submit",className:"w-full",disabled:u.isPending,children:u.isPending?"Sprawdzanie...":"Odblokuj"})]}),i.jsx("div",{className:"text-center",children:i.jsx(M,{variant:"link",asChild:!0,children:i.jsx(Ye,{to:"/session/$sessionId",params:{sessionId:n},children:"Powrót do listy grup"})})})]})})})}function Sn({groupId:e,sessionId:t}){const{setCurrentGroupId:n}=Fe();p.useEffect(()=>{n(e)},[e,n]);const{data:s,isLoading:r,error:o}=re({queryKey:["photos-public",e],queryFn:()=>pt({data:{groupId:e}}),staleTime:300*1e3});return r?i.jsx("div",{className:"flex items-center justify-center min-h-[50vh]",children:i.jsx(ve,{className:"h-8 w-8 animate-spin text-primary"})}):o||!s?i.jsx("div",{className:"flex items-center justify-center min-h-[50vh]",children:i.jsxs("div",{className:"text-center space-y-2",children:[i.jsx("h2",{className:"text-xl font-display font-bold",children:"Nie udaÅo siÄ zaÅadowaÄ zdjÄÄ"}),i.jsx("p",{className:"text-muted-foreground",children:"Spróbuj ponownie później."})]})}):s.length===0?i.jsx("div",{className:"flex items-center justify-center min-h-[50vh]",children:i.jsxs("div",{className:"text-center space-y-2",children:[i.jsx("h2",{className:"text-xl font-display font-bold",children:"Brak zdjÄÄ"}),i.jsx("p",{className:"text-muted-foreground",children:"W tej grupie nie ma jeszcze żadnych zdjÄÄ."})]})}):i.jsx("div",{children:i.jsx(Pn,{photos:s,sessionId:t,groupId:e})})}export{Jn as component};
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.