{"version":3,"file":"CurtainReveal.BtRKA3sA.mjs","names":["useState","useLayoutEffect","useEffect"],"sources":["https:/framerusercontent.com/modules/C3Ay5PCOPWB0KXFydsMv/7AmJfrbwgiGvaBA2yGS0/CurtainReveal.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useLayoutEffect,useState}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";// Come per il preloader della Home: persiste durante le navigazioni interne\n// di Framer e si azzera quando si ricarica realmente la pagina del browser.\n// Tiene traccia delle pagine già viste, così About e Archive hanno\n// ciascuna la propria tenda.\nconst WINDOW_FLAG=\"__marianoCurtainShownPaths\";function currentPath(){return window.location.pathname.replace(/\\/+$/,\"\")||\"/\";}// Nel browser decide prima che la pagina venga disegnata (niente frame di tenda);\n// durante la generazione della pagina sul server usa l'effetto normale.\nconst useIsomorphicLayoutEffect=typeof window!==\"undefined\"?useLayoutEffect:useEffect;// True quando la tenda di questa pagina è già stata mostrata\n// dall'ultimo ricaricamento del browser.\nfunction alreadyShownHere(){if(typeof window===\"undefined\")return false;const shownPaths=window[WINDOW_FLAG];return Boolean(shownPaths&&shownPaths[currentPath()]);}/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicWidth 1440\n * @framerIntrinsicHeight 900\n */export default function CurtainReveal(props){const{duration,curtainColor,panelCount,oncePerSession,style}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const[revealed,setRevealed]=useState(false);// Se la tenda di questa pagina è già stata vista, il componente nasce\n// già nascosto: così non compare nemmeno per un frame.\nconst[visible,setVisible]=useState(()=>isCanvas||!(oncePerSession&&alreadyShownHere()));const count=Math.max(2,Math.min(12,Math.round(panelCount)));const animationDuration=Math.max(250,duration);useIsomorphicLayoutEffect(()=>{// Keep a still curtain in the editor so the component remains selectable.\nif(isCanvas)return;// Salta la tenda per chi ha attivato \"riduci movimento\" nel sistema\n// e, se l'opzione è attiva, per le pagine già viste dall'ultimo ricaricamento.\nconst browserWindow=window;const shownPaths=browserWindow[WINDOW_FLAG]||(browserWindow[WINDOW_FLAG]={});const path=currentPath();const prefersReducedMotion=typeof window.matchMedia===\"function\"&&window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;if(prefersReducedMotion||oncePerSession&&shownPaths[path]){// Anche senza tenda la pagina parte dall'inizio, invece di\n// ereditare la posizione di scroll della pagina precedente.\n// Ripetuto dopo il primo frame perché Framer, chiudendo il menu,\n// può ripristinare la vecchia posizione con un attimo di ritardo.\nconst toTop=()=>window.scrollTo(0,0);toTop();const topFrame=window.requestAnimationFrame(toTop);const topTimer=window.setTimeout(toTop,120);setVisible(false);return()=>{window.cancelAnimationFrame(topFrame);window.clearTimeout(topTimer);};}shownPaths[path]=true;// Due frame: il primo disegna la tenda chiusa, il secondo avvia\n// l'apertura, così l'animazione parte sempre.\nlet frame=window.requestAnimationFrame(()=>{frame=window.requestAnimationFrame(()=>setRevealed(true));});const finishTimer=window.setTimeout(()=>setVisible(false),animationDuration+60);return()=>{window.cancelAnimationFrame(frame);window.clearTimeout(finishTimer);};},[animationDuration,isCanvas,oncePerSession]);useEffect(()=>{if(!visible||isCanvas)return;const html=document.documentElement;const body=document.body;// La tenda introduce la pagina: parte sempre dall'inizio, così non\n// eredita la posizione di scroll della pagina precedente.\nwindow.scrollTo(0,0);const scrollY=0;const previous={htmlOverflow:html.style.overflow,bodyOverflow:body.style.overflow,bodyPosition:body.style.position,bodyTop:body.style.top,bodyWidth:body.style.width};html.style.overflow=\"hidden\";body.style.overflow=\"hidden\";body.style.position=\"fixed\";body.style.top=`-${scrollY}px`;body.style.width=\"100%\";return()=>{html.style.overflow=previous.htmlOverflow;body.style.overflow=previous.bodyOverflow;body.style.position=previous.bodyPosition;body.style.top=previous.bodyTop;body.style.width=previous.bodyWidth;window.scrollTo(0,scrollY);};},[visible,isCanvas]);if(!visible)return null;return /*#__PURE__*/_jsxs(\"div\",{className:`cr-root${revealed?\" cr-revealed\":\"\"}`,\"aria-hidden\":\"true\",style:{...style,position:isCanvas?\"absolute\":\"fixed\",inset:0,width:isCanvas?style?.width??\"100%\":\"100vw\",height:isCanvas?style?.height??900:\"100svh\",zIndex:2147483e3,overflow:\"hidden\",isolation:\"isolate\",pointerEvents:\"auto\",background:\"transparent\",[\"--cr-duration\"]:`${animationDuration}ms`,[\"--cr-curtain\"]:curtainColor},children:[/*#__PURE__*/_jsx(\"style\",{children:`\n                .cr-root,.cr-root *{box-sizing:border-box}\n                .cr-curtain-panel{position:absolute;z-index:1;top:0;bottom:0;background:var(--cr-curtain);box-shadow:inset 1px 0 rgba(255,255,255,.14),inset -1px 0 rgba(255,255,255,.14);transform:translate3d(0,0,0);transition-property:transform;transition-timing-function:cubic-bezier(.76,0,.24,1);will-change:transform;pointer-events:none}\n                .cr-revealed .cr-curtain-panel{transform:translate3d(0,-105%,0)}\n                @media(prefers-reduced-motion:reduce){.cr-curtain-panel{transition-duration:1ms!important;transition-delay:0ms!important}}\n            `}),Array.from({length:count},(_,index)=>{const center=(count-1)/2;const delay=Math.abs(index-center)*animationDuration*.035;return /*#__PURE__*/_jsx(\"span\",{className:\"cr-curtain-panel\",style:{left:`calc(${index/count*100}% - 1px)`,width:`calc(${100/count}% + 2px)`,transitionDelay:`${delay}ms`,transitionDuration:`${Math.max(1,animationDuration-delay)}ms`}},index);})]});}Object.assign(CurtainReveal,{defaultProps:{duration:1300,curtainColor:\"#F04427\",panelCount:5,oncePerSession:true}});addPropertyControls(CurtainReveal,{duration:{type:ControlType.Number,title:\"Durata (ms)\",min:250,max:6e3,step:50,unit:\"ms\",defaultValue:1300},curtainColor:{type:ControlType.Color,title:\"Colore tenda\",defaultValue:\"#F04427\"},panelCount:{type:ControlType.Number,title:\"Pannelli\",min:2,max:12,step:1,defaultValue:5},oncePerSession:{type:ControlType.Boolean,title:\"Solo prima visita\",enabledTitle:\"S\\xec\",disabledTitle:\"No\",defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CurtainReveal\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerIntrinsicWidth\":\"1440\",\"framerIntrinsicHeight\":\"900\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CurtainReveal.map"],"mappings":"oNAI+C,SAAS,GAAa,CAAC,OAAO,EAAO,SAAS,SAAS,QAAQ,OAAO,EAAE,GAAG,GAAI,CAI9H,SAAS,GAAkB,CAAC,GAAU,IAAS,OAAY,MAAO,GAAM,IAAM,EAAW,EAAO,GAAa,MAAO,GAAQ,GAAY,EAAW,EAAY,GAAI,CAKhK,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,WAAS,eAAa,aAAW,iBAAe,SAAO,EAAY,EAAS,EAAa,QAAQ,IAAI,EAAa,OAAY,CAAC,EAAS,GAAaA,EAAS,EAAK,EAEpN,CAAC,EAAQ,GAAYA,MAAa,GAAU,EAAE,GAAgB,EAAiB,EAAE,EAAQ,EAAM,KAAK,IAAI,EAAE,KAAK,IAAI,GAAG,KAAK,MAAM,CAAU,CAAC,CAAC,EAAQ,EAAkB,KAAK,IAAI,IAAI,CAAQ,EAW+a,OAX7a,MAA8B,CACjO,GAAG,EAAS,OAEZ,IAAM,EAAc,EAAa,EAAW,EAAc,KAAe,EAAc,GAAa,CAAC,GAAS,EAAK,EAAY,EAAkI,GAArG,OAAO,EAAO,YAAa,YAAY,EAAO,WAAW,kCAAkC,CAAC,CAAC,SAAiC,GAAgB,EAAW,GAAM,CAI3T,IAAM,MAAU,EAAO,SAAS,EAAE,CAAC,EAAE,EAAM,EAAE,IAAM,EAAS,EAAO,sBAAsB,CAAK,EAAQ,EAAS,EAAO,WAAW,EAAM,GAAG,EAAoB,OAAlB,EAAW,EAAK,MAAY,CAAC,EAAO,qBAAqB,CAAQ,EAAE,EAAO,aAAa,CAAQ,CAAE,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