"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),React=require("react");const useSticky=e=>{let{width:t,position:o}=e??{},s=core.makeStyleResponsive("w",t),l=core.usePageStore(e=>"interaction"===e.sidebarMode),a=core.useCurrentDevice(),p=(e,t)=>({[`--left${t}`]:"top"==e?"0":"50%",[`--t${t}`]:"top"==e?"unset":"translateX(-50%)"}),i=React.useMemo(()=>({...p(o?.desktop,""),...p(o?.tablet??o?.desktop,"-tablet"),...p(o?.mobile??o?.tablet??o?.desktop,"-mobile")}),[o?.desktop,o?.mobile,o?.tablet]),b=React.useMemo(()=>{if(l&&o?.[a]==="top")return"40px"},[a,l,o]),d=React.useMemo(()=>({"--d":(e?.display?.desktop,"block"),"--d-tablet":(e?.display?.tablet??e?.display?.desktop,"block"),"--d-mobile":(e?.display?.mobile??e?.display?.tablet??e?.display?.desktop,"block")}),[e?.display?.desktop,e?.display?.mobile,e?.display?.tablet]),r=React.useMemo(()=>({"--top":b??"auto","--top-tablet":b??"auto","--top-mobile":b??"auto",[`--${o?.desktop}`]:b??"0px",[`--${o?.tablet??o?.desktop}-tablet`]:b??"0px",[`--${o?.mobile??o?.tablet??o?.desktop}-mobile`]:b??"0px"}),[b,o?.desktop,o?.mobile,o?.tablet]),k=e=>"top"==e?"sticky":"fixed",c=React.useMemo(()=>({"--pos":k(o?.desktop),"--pos-tablet":k(o?.tablet??o?.desktop),"--pos-mobile":k(o?.mobile??o?.tablet??o?.desktop)}),[o?.desktop,o?.mobile,o?.tablet]);return{w:s,displayStyle:r,positionStyle:c,getCSSAlign:i,makeDisplaySettingStyles:d}};exports.default=useSticky;
