{"version":3,"file":"Gallery_GridLightbox.JatCsVdT.mjs","names":["React.useRef","React.useCallback"],"sources":["https:/framerusercontent.com/modules/kXt5TqBt4kX4RzlivZ4s/U0szc4F3qe7CZiD0L3g3/Gallery_GridLightbox.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{AnimatePresence,motion}from\"framer-motion\";// ==================== Store ====================\nconst useStore=createStore({filterCategory:\"\",activeTab:\"All\",open:false,active:0,images:[]});// ==================== Constants ====================\nconst ROOT_ATTR=\"data-gallery-root\";const ITEM_ATTR=\"data-gallery-item\";// ==================== URL Sync ====================\nlet _initialized=false;function initFromURL(setStore){if(typeof window===\"undefined\"||_initialized)return;_initialized=true;const scene=new URLSearchParams(window.location.search).get(\"scene\")?.trim()||\"All\";const isAll=scene.toLowerCase()===\"all\";setStore({activeTab:isAll?\"All\":scene,filterCategory:isAll?\"\":scene});}// ==================== HOCs ====================\n/** 1) CMS Grid - 右侧图片列表 */export function withFilter(Component){return props=>{const[store,setStore]=useStore();React.useEffect(()=>{initFromURL(setStore);},[]);const filter=store.filterCategory.trim();return /*#__PURE__*/_jsx(Component,{...props,[ROOT_ATTR]:\"1\",...filter&&{filter}});};}/** 2) Gallery Switch - 左侧分类切换器（大组件） */export function withFilterComponent(Component){return props=>{const[store,setStore]=useStore();React.useEffect(()=>{initFromURL(setStore);},[]);return /*#__PURE__*/_jsx(Component,{...props,variant:store.activeTab});};}/**\n * 3) Filter Text - 每个分类按钮（优化版）\n *\n * 改进点：\n * - 使用 onPointerDown 替代 onClick，响应更快\n * - 添加 onTap 支持 Framer Motion\n * - 使用 capture 阶段确保事件被捕获\n */export function withFilterText(Component){return props=>{const[store,setStore]=useStore();const tab=props[\"data-framer-name\"]||props.name||\"All\";const isAll=tab===\"All\";const isActive=store.activeTab===tab;// 使用 ref 来直接绑定事件，绕过 React 的合成事件\nconst ref=React.useRef(null);const doSwitch=React.useCallback(()=>{// 立即更新状态\nsetStore({activeTab:tab,filterCategory:isAll?\"\":tab});// 同步 URL\ntry{const url=new URL(window.location.href);if(isAll){url.searchParams.delete(\"scene\");}else{url.searchParams.set(\"scene\",tab);}window.history.replaceState({},\"\",url.toString());}catch{}},[tab,isAll,setStore]);// 直接绑定原生事件，更可靠\nReact.useEffect(()=>{const el=ref.current;if(!el)return;const handlePointerDown=e=>{e.stopPropagation();doSwitch();};// 使用 capture 阶段，确保最先收到事件\nel.addEventListener(\"pointerdown\",handlePointerDown,{capture:true});return()=>{el.removeEventListener(\"pointerdown\",handlePointerDown,{capture:true});};},[doSwitch]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{...props,variant:isActive?\"Active\":\"Default\",style:{...props.style,cursor:\"pointer\",pointerEvents:\"auto\",userSelect:\"none\",WebkitTapHighlightColor:\"transparent\"},// 同时保留这些作为备用\nonClick:doSwitch,onTap:doSwitch})});};}/**\n * 3b) 更简单的版本 - 如果上面的还是有问题，试试这个\n * 直接用一个透明覆盖层捕获点击\n */export function withFilterTextOverlay(Component){return props=>{const[store,setStore]=useStore();const tab=props[\"data-framer-name\"]||props.name||\"All\";const isAll=tab===\"All\";const isActive=store.activeTab===tab;const doSwitch=()=>{setStore({activeTab:tab,filterCategory:isAll?\"\":tab});try{const url=new URL(window.location.href);if(isAll){url.searchParams.delete(\"scene\");}else{url.searchParams.set(\"scene\",tab);}window.history.replaceState({},\"\",url.toString());}catch{}};return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",display:\"contents\"},children:[/*#__PURE__*/_jsx(Component,{...props,variant:isActive?\"Active\":\"Default\",style:{...props.style,pointerEvents:\"none\"}}),/*#__PURE__*/_jsx(\"div\",{onPointerDown:e=>{e.stopPropagation();e.preventDefault();doSwitch();},style:{position:\"absolute\",inset:0,cursor:\"pointer\",zIndex:10}})]});};}/** 4) Gallery Item */export function withGalleryItemLightbox(Component){return props=>{const[,setStore]=useStore();const handleClick=e=>{const clickedEl=e.target;const root=document.querySelector(`[${ROOT_ATTR}=\"1\"]`);if(!root)return;const allItems=Array.from(root.querySelectorAll(`[${ITEM_ATTR}=\"1\"]`));const clickedItem=clickedEl.closest(`[${ITEM_ATTR}=\"1\"]`);const list=[];let activeIndex=0;allItems.forEach(item=>{const img=item.querySelector(\"img\");const src=img?.currentSrc||img?.src;if(src){if(item===clickedItem)activeIndex=list.length;list.push(src);}});if(list.length){setStore({open:true,active:activeIndex,images:list});}};return /*#__PURE__*/_jsx(Component,{...props,[ITEM_ATTR]:\"1\",style:{...props.style,cursor:\"zoom-in\",pointerEvents:\"auto\"},onClick:handleClick});};}// ==================== Overlay ====================\nexport function GalleryOverlay(){const[store,setStore]=useStore();const{open,active,images}=store;const total=images.length;const close=React.useCallback(()=>setStore({open:false}),[setStore]);const prev=React.useCallback(()=>total&&setStore({active:(active-1+total)%total}),[active,total,setStore]);const next=React.useCallback(()=>total&&setStore({active:(active+1)%total}),[active,total,setStore]);React.useEffect(()=>{if(!open)return;const onKey=e=>{if(e.key===\"Escape\")close();if(e.key===\"ArrowLeft\")prev();if(e.key===\"ArrowRight\")next();};window.addEventListener(\"keydown\",onKey);return()=>window.removeEventListener(\"keydown\",onKey);},[open,close,prev,next]);if(!open||!total)return null;return /*#__PURE__*/_jsx(AnimatePresence,{children:/*#__PURE__*/_jsxs(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},onClick:e=>e.target===e.currentTarget&&close(),style:{position:\"fixed\",inset:0,zIndex:999999,background:\"rgba(0,0,0,0.86)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:[/*#__PURE__*/_jsx(IconButton,{onClick:close,style:{top:18,right:18},children:\"✕\"}),/*#__PURE__*/_jsx(motion.img,{src:images[active],initial:{opacity:0,scale:.985},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.985},transition:{type:\"spring\",stiffness:260,damping:28},draggable:false,style:{maxWidth:\"90vw\",maxHeight:\"82vh\",objectFit:\"contain\",borderRadius:18,boxShadow:\"0 24px 60px rgba(0,0,0,0.55)\",userSelect:\"none\"}},images[active]),/*#__PURE__*/_jsx(ArrowButton,{dir:\"left\",onClick:prev}),/*#__PURE__*/_jsx(ArrowButton,{dir:\"right\",onClick:next}),/*#__PURE__*/_jsx(ThumbnailBar,{images:images,active:active,onSelect:i=>setStore({active:i})})]})});}// ==================== Sub Components ====================\nfunction IconButton({onClick,style,children}){return /*#__PURE__*/_jsx(\"button\",{onClick:onClick,style:{position:\"absolute\",width:40,height:40,borderRadius:999,border:\"none\",background:\"rgba(255,255,255,0.16)\",backdropFilter:\"blur(10px)\",color:\"white\",cursor:\"pointer\",fontSize:18,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",...style},children:children});}function ArrowButton({dir,onClick}){const isLeft=dir===\"left\";return /*#__PURE__*/_jsx(\"button\",{onClick:e=>{e.stopPropagation();onClick();},style:{position:\"absolute\",top:\"50%\",transform:\"translateY(-50%)\",[isLeft?\"left\":\"right\"]:18,width:52,height:52,borderRadius:999,border:\"none\",background:\"rgba(255,255,255,0.14)\",backdropFilter:\"blur(10px)\",color:\"white\",cursor:\"pointer\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",fontSize:28,lineHeight:\"28px\"},children:isLeft?\"‹\":\"›\"});}function ThumbnailBar({images,active,onSelect}){return /*#__PURE__*/_jsx(\"div\",{onClick:e=>e.stopPropagation(),style:{position:\"absolute\",bottom:24,display:\"flex\",gap:10,padding:10,borderRadius:16,background:\"rgba(0,0,0,0.35)\",backdropFilter:\"blur(18px)\",maxWidth:\"80vw\",overflowX:\"auto\",scrollbarWidth:\"none\"},children:images.map((src,idx)=>/*#__PURE__*/_jsx(\"button\",{onClick:()=>onSelect(idx),style:{width:44,height:44,borderRadius:10,overflow:\"hidden\",border:idx===active?\"2px solid rgba(255,255,255,0.9)\":\"2px solid transparent\",opacity:idx===active?1:.65,background:\"transparent\",padding:0,cursor:\"pointer\",flex:\"0 0 auto\"},children:/*#__PURE__*/_jsx(\"img\",{src:src,draggable:false,style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\"}})},`${src}-${idx}`))});}\nexport const __FramerMetadata__ = {\"exports\":{\"withFilterText\":{\"type\":\"reactHoc\",\"name\":\"withFilterText\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFilterComponent\":{\"type\":\"reactHoc\",\"name\":\"withFilterComponent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFilterTextOverlay\":{\"type\":\"reactHoc\",\"name\":\"withFilterTextOverlay\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withGalleryItemLightbox\":{\"type\":\"reactHoc\",\"name\":\"withGalleryItemLightbox\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"GalleryOverlay\":{\"type\":\"reactComponent\",\"name\":\"GalleryOverlay\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFilter\":{\"type\":\"reactHoc\",\"name\":\"withFilter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Gallery_GridLightbox.map"],"mappings":"iQAGuB,SAAS,EAAY,EAAS,CAAC,GAAU,IAAS,QAAa,EAAa,OAAO,EAAa,GAAK,IAAM,EAAM,IAAI,gBAAgB,EAAO,SAAS,OAAO,CAAC,IAAI,QAAQ,EAAE,MAAM,EAAE,MAAY,EAAM,EAAM,aAAa,GAAG,MAAM,EAAS,CAAC,UAAU,EAAM,MAAM,EAAM,eAAe,EAAM,GAAG,EAAM,CAAC,CAClS,SAAgB,EAAW,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,EAAM,GAAU,GAAU,CAAC,MAAoB,CAAC,EAAY,EAAS,EAAG,EAAE,CAAC,CAAC,IAAM,EAAO,EAAM,eAAe,MAAM,CAAC,OAAoB,EAAK,EAAU,CAAC,GAAG,GAAO,GAAW,IAAI,GAA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