import{o as e,r as t,t as n}from"./jsx-runtime-BbTa8W_M-1776590214964.js";import{t as r}from"./useTranslation-D1etqd9u-1776590214964.js";import{t as i}from"./chevron-left-BPh9np_P-1776590214964.js";import{t as a}from"./chevron-right-CQG1mCkM-1776590214964.js";var o=e(t(),1),s=n();function c({images:e,title:t}){let{t:n}=r(),c=e?.find(e=>e.is_main)||e?.[0],[l,u]=(0,o.useState)(c?`/storage/${c.path}`:`/placeholder.jpg`),d=(0,o.useRef)(null),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(!1),g=()=>{if(d.current){let{scrollLeft:e,scrollWidth:t,clientWidth:n}=d.current;p(Math.abs(e)>0),h(Math.ceil(Math.abs(e)+n)<t-5)}};(0,o.useEffect)(()=>(g(),window.addEventListener(`resize`,g),()=>window.removeEventListener(`resize`,g)),[e]);let _=e=>{if(d.current){let t=e===`left`?-150:150,n=document.documentElement.dir===`rtl`?e===`left`?150:-150:t;d.current.scrollBy({left:n,behavior:`smooth`}),setTimeout(g,300)}};return(0,s.jsxs)(`div`,{className:`lg:col-span-5 p-4 md:p-6 border-b lg:border-b-0 lg:border-r border-border/50`,children:[(0,s.jsx)(`div`,{className:`aspect-square rounded-lg overflow-hidden border border-border bg-white mb-4 flex items-center justify-center`,children:(0,s.jsx)(`img`,{src:l,alt:t,className:`w-full h-full object-contain`})}),e&&e.length>1&&(0,s.jsxs)(`div`,{className:`relative group w-full`,children:[f&&(0,s.jsx)(`button`,{onClick:()=>_(`left`),className:`absolute left-0 top-1/2 -translate-y-1/2 z-10 w-8 h-8 rounded-full bg-background/90 border shadow-md flex items-center justify-center hover:bg-muted text-primary -ml-2 transition-all opacity-0 group-hover:opacity-100`,children:(0,s.jsx)(i,{className:`w-5 h-5 rtl:rotate-180`})}),(0,s.jsx)(`div`,{ref:d,onScroll:g,className:`flex gap-2 overflow-x-auto py-1 no-scrollbar scroll-smooth relative px-1`,children:e.map((e,t)=>{let r=`/storage/${e.path}`;return(0,s.jsx)(`button`,{onMouseEnter:()=>u(r),onClick:()=>u(r),className:`shrink-0 w-16 h-16 rounded-md border-2 overflow-hidden transition-all bg-white ${l===r?`border-primary shadow-sm`:`border-transparent hover:border-primary/50`}`,children:(0,s.jsx)(`img`,{src:r,alt:n(`Thumbnail :number`,{number:t+1}),className:`w-full h-full object-contain p-1`})},t)})}),m&&(0,s.jsx)(`button`,{onClick:()=>_(`right`),className:`absolute right-0 top-1/2 -translate-y-1/2 z-10 w-8 h-8 rounded-full bg-background/90 border shadow-md flex items-center justify-center hover:bg-muted text-primary -mr-2 transition-all opacity-0 group-hover:opacity-100`,children:(0,s.jsx)(a,{className:`w-5 h-5 rtl:rotate-180`})})]})]})}export{c as default};