{"version":3,"file":"index-BgHXvgZT.js","sources":["../../../app/javascript/src/animations/animateHeight/index.js"],"sourcesContent":["const easeOutCubic = ( t ) => ( t - 1 ) ** 3 + 1;\n\nconst animateHeight = ({\n container, content, duration, maxHeight = Infinity,\n}) => ({\n open,\n minHeight = 0,\n callback = null,\n}) => {\n let openHeight = 0;\n if ( content ) {\n const contentStyle = getComputedStyle( content );\n openHeight = Math.min(\n content.offsetHeight\n + parseInt( contentStyle.marginTop, 10 )\n + parseInt( contentStyle.marginBottom, 10 ),\n maxHeight,\n );\n }\n const elasticHeight = openHeight - minHeight;\n\n let start = null;\n const animate = ( timestamp ) => {\n if ( !start ) {\n start = timestamp;\n }\n const progress = timestamp - start;\n\n // step\n if ( progress < duration ) {\n container.style.height = !open\n ? `${minHeight + easeOutCubic( progress / duration ) * elasticHeight}px` // open\n : `${minHeight + ( 1 - easeOutCubic( progress / duration )) * elasticHeight}px`; // close\n\n requestAnimationFrame( animate );\n } else {\n // finish\n if ( !open ) {\n container.style.removeProperty( 'height' );\n } else {\n container.style.height = minHeight;\n }\n\n if ( callback ) {\n callback();\n }\n }\n };\n\n requestAnimationFrame( animate );\n};\n\nexport default animateHeight;\n"],"names":["easeOutCubic","t","animateHeight","container","content","duration","maxHeight","open","minHeight","callback","openHeight","contentStyle","elasticHeight","start","animate","timestamp","progress"],"mappings":"AAAA,MAAMA,EAAiBC,IAASA,EAAI,IAAO,EAAI,EAEzCC,EAAgB,CAAC,CACrB,UAAAC,EAAW,QAAAC,EAAS,SAAAC,EAAU,UAAAC,EAAY,GAC5C,IAAM,CAAC,CACL,KAAAC,EACA,UAAAC,EAAY,EACZ,SAAAC,EAAW,IACb,IAAM,CACJ,IAAIC,EAAa,EACjB,GAAKN,EAAU,CACb,MAAMO,EAAe,iBAAkBP,CAAS,EAChDM,EAAa,KAAK,IAChBN,EAAQ,aACJ,SAAUO,EAAa,UAAW,EAAE,EACpC,SAAUA,EAAa,aAAc,EAAI,EAC7CL,CACD,CACL,CACE,MAAMM,EAAgBF,EAAaF,EAEnC,IAAIK,EAAQ,KACZ,MAAMC,EAAYC,GAAe,CACzBF,IACJA,EAAQE,GAEV,MAAMC,EAAWD,EAAYF,EAGxBG,EAAWX,GACdF,EAAU,MAAM,OAAUI,EAEtB,GAAGC,GAAc,EAAIR,EAAcgB,EAAWX,CAAU,GAAIO,CAAa,KADzE,GAAGJ,EAAYR,EAAcgB,EAAWX,CAAU,EAAGO,CAAa,KAGtE,sBAAuBE,CAAS,IAG1BP,EAGJJ,EAAU,MAAM,OAASK,EAFzBL,EAAU,MAAM,eAAgB,QAAU,EAKvCM,GACHA,EAAU,EAGf,EAED,sBAAuBK,CAAS,CAClC"}