import{d as R,af as b,c as n,r as k,w as T,e as s,f as i,g as u,ac as V,m as y,a7 as S,F as E,l as O,M as q,a8 as v,p as d,j as M}from"./NkN6QURX.js";import{u as D}from"./DzxYJzkk.js";import{S as G,a as J}from"./CK1rB-uI.js";import{P as Q}from"./6CMiP8Mk.js";import{A as U}from"./BiJ0g2Iz.js";import"./lFwaJC54.js";const W=["data-content-key"],X=["data-content-key"],Y=["src"],Z=["src"],ee=["src"],re=R({__name:"HomeHeroMachineryLayout2",props:{content:{default:()=>[]},editable:{type:Boolean,default:!1},activeKey:{default:null},onContentClick:{},textStyle:{},className:{},onButtonClick:{}},setup(w){const l=w,{resolveKey:x,interactive:N,isActive:C,handleClick:B}=D({content:b(l,"content"),activeKey:b(l,"activeKey"),editable:b(l,"editable"),onContentClick:l.onContentClick,textStyle:l.textStyle}),a=n(()=>(l.content||[]).find(e=>e?.type==="swiper-image-only")),c=n(()=>{const e=a.value?.data;return Array.isArray(e)&&e.length>0?e:[]}),A=[U,Q],f=k(null),r=k(0),p=n(()=>c.value.length>1),h=n(()=>c.value.length>1),m=k(!1),I=n(()=>{if(l.editable||c.value.length<=1)return!1;const e=Number(a.value?.duration);return!Number.isFinite(e)||e<=0?!1:{delay:Math.max(1,Math.floor(e))*1e3,disableOnInteraction:!1}}),K=n(()=>c.value.length<=1?!1:{clickable:!0});function j(e){f.value=e,r.value=p.value?e.realIndex:e.activeIndex}function P(e){r.value=p.value?e.realIndex:e.activeIndex}function $(){h.value&&f.value?.slidePrev()}function L(){h.value&&f.value?.slideNext()}T(()=>c.value.length,e=>{const t=f.value;if(t&&t.update(),!e){r.value=0;return}r.value>=e&&(r.value=0),t&&(p.value&&typeof t.slideToLoop=="function"?t.slideToLoop(r.value,0):t.slideTo(r.value,0))});const z=n(()=>a.value?x(a.value):""),F=n(()=>!!(l.editable&&a.value&&C(a.value)));function _(e){const t=z.value;return t?`${t}__slide_${e}__image`:""}function H(e){if(!l.editable)return!1;const t=_(e);return t&&l.activeKey===t?!0:F.value}return(e,t)=>(i(),s("section",{class:d(["font-sans",w.className])},[u("article",{class:d(["relative overflow-hidden text-white",[{mark:w.editable&&a.value&&v(C)(a.value)}]]),"data-content-key":a.value&&v(x)(a.value)||void 0,onClick:t[2]||(t[2]=o=>a.value&&v(B)(a.value))},[u("div",{class:"relative overflow-hidden",onMouseenter:t[0]||(t[0]=o=>m.value=!0),onMouseleave:t[1]||(t[1]=o=>m.value=!1)},[V(v(J),{class:"home-hero-swiper",modules:A,"slides-per-view":1,loop:p.value,autoplay:I.value,pagination:K.value,onSwiper:j,onSlideChange:P},{default:S(()=>[(i(!0),s(E,null,O(c.value,(o,g)=>(i(),q(v(G),{key:g},{default:S(()=>[u("div",{class:d(["relative w-full",[{"cursor-pointer":v(N),mark:H(g)}]]),"data-content-key":_(g)||void 0},[o.video?(i(),s("video",{key:0,src:o.video,class:d(["home-hero-swiper__video block w-full object-contain",{"home-hero-swiper__video--has-mobile-cover":o.cover}]),autoplay:"",muted:"",loop:"",playsinline:"",preload:"metadata"},null,10,Y)):y("",!0),o.video&&o.cover?(i(),s("img",{key:1,src:o.cover,alt:"",class:"home-hero-swiper__mobile-cover hidden w-full object-contain",draggable:"false"},null,8,Z)):o.image?(i(),s("img",{key:2,src:o.image,alt:"",class:"block w-full object-contain",draggable:"false"},null,8,ee)):y("",!0)],10,X)]),_:2},1024))),128))]),_:1},8,["loop","autoplay","pagination"]),h.value?(i(),s("button",{key:0,type:"button",class:d(["absolute left-6 top-1/2 z-10 -translate-y-1/2 h-14 w-14 rounded-full bg-black/50 text-white shadow-sm transition-opacity flex justify-center items-center",m.value?"opacity-100":"opacity-0 pointer-events-none"]),"aria-label":"上一张",onClick:M($,["stop"])},[...t[3]||(t[3]=[u("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor","stroke-width":"2"},[u("path",{d:"M15 6l-6 6 6 6"})],-1)])],2)):y("",!0),h.value?(i(),s("button",{key:1,type:"button",class:d(["absolute right-4 top-1/2 z-10 -translate-y-1/2 h-14 w-14 rounded-full bg-black/50 text-white shadow-sm transition-opacity flex justify-center items-center",m.value?"opacity-100":"opacity-0 pointer-events-none"]),"aria-label":"下一张",onClick:M(L,["stop"])},[...t[4]||(t[4]=[u("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor","stroke-width":"2"},[u("path",{d:"M9 6l6 6-6 6"})],-1)])],2)):y("",!0)],32)],10,W)],2))}});export{re as default};
