import{j as e,L,r as i,a as W,T,s as I}from"./index-nY9tUGNj.js";import{F as z}from"./index-BN0z_J3y.js";import{M as F,u as $,P as S,a as O,b as D,L as H,m as C}from"./proxy-BuGY5lsQ.js";import"./iconBase-B7xKm6cd.js";const K=()=>e.jsx("div",{className:"awards",children:e.jsx("div",{className:"breadcrumb-wrapper",children:e.jsx("div",{className:"container",children:e.jsxs("div",{className:"page-heading text-center",children:[e.jsx("h2",{children:"விருதுகள்"}),e.jsx("div",{children:e.jsxs("p",{children:[" ",e.jsx(L,{to:"/",children:"முகப்பு"}),e.jsxs("span",{children:[" ",e.jsx(z,{})," "]}),"விருதுகள்"]})})]})})})});class U extends i.Component{getSnapshotBeforeUpdate(a){const r=this.props.childRef.current;if(r&&a.isPresent&&!this.props.isPresent){const n=r.offsetParent,d=n instanceof HTMLElement&&n.offsetWidth||0,c=this.props.sizeRef.current;c.height=r.offsetHeight||0,c.width=r.offsetWidth||0,c.top=r.offsetTop,c.left=r.offsetLeft,c.right=d-c.width-c.left}return null}componentDidUpdate(){}render(){return this.props.children}}function Y({children:o,isPresent:a,anchorX:r}){const n=i.useId(),d=i.useRef(null),c=i.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:m}=i.useContext(F);return i.useInsertionEffect(()=>{const{width:g,height:t,top:j,left:l,right:f}=c.current;if(a||!d.current||!g||!t)return;const u=r==="left"?`left: ${l}`:`right: ${f}`;d.current.dataset.motionPopId=n;const s=document.createElement("style");return m&&(s.nonce=m),document.head.appendChild(s),s.sheet&&s.sheet.insertRule(`
          [data-motion-pop-id="${n}"] {
            position: absolute !important;
            width: ${g}px !important;
            height: ${t}px !important;
            ${u}px !important;
            top: ${j}px !important;
          }
        `),()=>{document.head.removeChild(s)}},[a]),e.jsx(U,{isPresent:a,childRef:d,sizeRef:c,children:i.cloneElement(o,{ref:d})})}const B=({children:o,initial:a,isPresent:r,onExitComplete:n,custom:d,presenceAffectsLayout:c,mode:m,anchorX:g})=>{const t=$(G),j=i.useId(),l=i.useCallback(u=>{t.set(u,!0);for(const s of t.values())if(!s)return;n&&n()},[t,n]),f=i.useMemo(()=>({id:j,initial:a,isPresent:r,custom:d,onExitComplete:l,register:u=>(t.set(u,!1),()=>t.delete(u))}),c?[Math.random(),l]:[r,l]);return i.useMemo(()=>{t.forEach((u,s)=>t.set(s,!1))},[r]),i.useEffect(()=>{!r&&!t.size&&n&&n()},[r]),m==="popLayout"&&(o=e.jsx(Y,{isPresent:r,anchorX:g,children:o})),e.jsx(S.Provider,{value:f,children:o})};function G(){return new Map}const y=o=>o.key||"";function P(o){const a=[];return i.Children.forEach(o,r=>{i.isValidElement(r)&&a.push(r)}),a}const V=({children:o,custom:a,initial:r=!0,onExitComplete:n,presenceAffectsLayout:d=!0,mode:c="sync",propagate:m=!1,anchorX:g="left"})=>{const[t,j]=O(m),l=i.useMemo(()=>P(o),[o]),f=m&&!t?[]:l.map(y),u=i.useRef(!0),s=i.useRef(l),x=$(()=>new Map),[A,M]=i.useState(l),[v,E]=i.useState(l);D(()=>{u.current=!1,s.current=l;for(let p=0;p<v.length;p++){const h=y(v[p]);f.includes(h)?x.delete(h):x.get(h)!==!0&&x.set(h,!1)}},[v,f.length,f.join("-")]);const b=[];if(l!==A){let p=[...l];for(let h=0;h<v.length;h++){const w=v[h],R=y(w);f.includes(R)||(p.splice(h,0,w),b.push(w))}return c==="wait"&&b.length&&(p=b),E(P(p)),M(l),null}const{forceRender:N}=i.useContext(H);return e.jsx(e.Fragment,{children:v.map(p=>{const h=y(p),w=m&&!t?!1:l===v||f.includes(h),R=()=>{if(x.has(h))x.set(h,!0);else return;let k=!0;x.forEach(_=>{_||(k=!1)}),k&&(N==null||N(),E(s.current),m&&(j==null||j()),n&&n())};return e.jsx(B,{isPresent:w,initial:!u.current||r?void 0:!1,custom:a,presenceAffectsLayout:d,mode:c,onExitComplete:w?void 0:R,anchorX:g,children:p},h)})})},X=()=>{var f,u;const{awards:o=[]}=i.useContext(T),[a,r]=i.useState("lifetime"),[n,d]=i.useState(0),c=o.filter(s=>s.award_category!=="Young Writers Award"),m=o.filter(s=>s.award_category==="Young Writers Award"),g=a==="lifetime"?c:m,t=g?[...g].sort((s,x)=>x.award_year-s.award_year):[];if(i.useEffect(()=>{d(0)},[a]),o.length===0)return e.jsx("p",{className:"text-center",children:"Loading awards..."});const j=()=>{d(s=>s===t.length-1?0:s+1)},l=()=>{d(s=>s===0?t.length-1:s-1)};return e.jsxs("div",{className:"container",children:[e.jsxs("div",{className:"text-center section-title",children:[e.jsx("h4",{children:a==="lifetime"?"வாழ்நாள் சாதனையாளர் விருது":"இளஞர் எழுத்தாளர் விருது"}),e.jsx("p",{children:a==="lifetime"?"கோயம்புத்தூர் புத்தகத் திருவிழாவின் சார்பில் ஒவ்வொரு ஆண்டும் தமிழ் இலக்கியத் துறையில் சாதனை படைத்த ஒரு எழுத்து ஆளுமைக்கு வாழ்நாள் சாதனையாளர் விருது வழங்கி சிறப்பிக்கப்பட்டு வருகிறது.":"இளஞர் எழுத்தாளர் விருது புதிய தலைமுறை எழுத்தாளர்களை ஊக்குவிக்க வழங்கப்படுகிறது."})]}),m.length>0&&e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("button",{className:`btn ${a==="lifetime"?"btn-awards-active":"btn-awards"} mx-2`,onClick:()=>r("lifetime"),children:"வாழ்நாள் சாதனையாளர் விருது"}),e.jsx("button",{className:`btn ${a==="youngWriters"?"btn-awards-active":"btn-awards"} mx-2`,onClick:()=>r("youngWriters"),children:"இளஞர் எழுத்தாளர் விருது"})]}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"timeline-tabs text-center mb-4",children:t.map((s,x)=>e.jsx("button",{className:`timeline-tab ${x===n?"active":""}`,onClick:()=>d(x),children:s.award_year},x))}),e.jsx("div",{className:"col-12 m-auto",children:e.jsxs("div",{className:"timeline-content text-center mb-5",children:[e.jsx(V,{mode:"wait",children:e.jsxs(C.div,{initial:{opacity:0,y:50},animate:{opacity:1,y:0},exit:{opacity:0,y:-50},transition:{duration:.6,ease:"easeInOut"},className:"row",children:[e.jsx("div",{children:e.jsx(C.img,{src:(f=t[n])!=null&&f.image_path?`${I}${t[n].image_path.startsWith("/")?t[n].image_path:`/${t[n].image_path}`}`:"/default-image.jpg",alt:((u=t[n])==null?void 0:u.name)||"Award Image",className:"img-fluid mb-3",initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},transition:{duration:.6,ease:"easeOut"}})}),e.jsx("div",{children:t[n]&&e.jsxs(e.Fragment,{children:[e.jsx(C.h3,{className:"timeline-year",children:t[n].award_year}),e.jsx(C.h4,{children:t[n].name})]})})]},n)}),t.length>1&&e.jsxs("div",{className:"timeline-nav d-flex justify-content-center mt-3",children:[e.jsx("button",{className:"btn btn-outline-dark me-2",onClick:l,children:"←"}),e.jsx("button",{className:"btn btn-outline-dark",onClick:j,children:"→"})]})]})})]})]})},q=W.memo(X),te=()=>e.jsxs("div",{children:[e.jsx(K,{}),e.jsx(q,{})]});export{te as default};
