"use strict";const r=require("vue"),m=require("./unwrapElement.js"),d=require("./floating-ui.dom.js"),R=16,T=128;function j(a,p,e){var b;const v=()=>{var t;return(t=p.value)==null?void 0:t.isExpanded()},s=r.computed(()=>{var t;return(t=p.value)==null?void 0:t.getRootElement()}),x=[d.offset(e==null?void 0:e.offset),d.size({padding:R,apply({rects:t,elements:o,availableHeight:i,availableWidth:l}){Object.assign(o.floating.style,{width:"".concat(e!=null&&e.useAvailableWidth?l:t.reference.width,"px"),maxHeight:"".concat(Math.max(T,i),"px")})}}),d.flip({padding:R-1}),d.hide({strategy:"escaped"}),d.hide()],{floatingStyles:$,placement:H,middlewareData:n,update:B}=m.useFloating(a,s,{middleware:x,placement:(b=e==null?void 0:e.placement)!=null?b:"bottom"}),L=r.computed(()=>{var o,i;return!v()||!!((o=n.value.hide)!=null&&o.escaped)||((i=n.value.hide)==null?void 0:i.referenceHidden)?"hidden":"visible"});r.watch([$,L,H],([t,o,i])=>{var l,g,h,c,f;Object.assign((g=(l=s.value)==null?void 0:l.style)!=null?g:{},{visibility:o,position:t.position,top:"".concat(t.top,"px"),right:"unset",left:"".concat(t.left,"px"),transform:(h=t.transform)!=null?h:"none",borderTopLeftRadius:i==="bottom"&&o==="visible"?"0":"",borderTopRightRadius:i==="bottom"&&o==="visible"?"0":"",borderBottomLeftRadius:i==="top"&&o==="visible"?"0":"",borderBottomRightRadius:i==="top"&&o==="visible"?"0":""}),Object.assign((f=(c=m.unwrapElement(a.value))==null?void 0:c.style)!=null?f:{},{borderTopLeftRadius:i==="top"&&o==="visible"?"0":"",borderTopRightRadius:i==="top"&&o==="visible"?"0":"",borderBottomLeftRadius:i==="bottom"&&o==="visible"?"0":"",borderBottomRightRadius:i==="bottom"&&o==="visible"?"0":""})});let u=null;r.watch(v,t=>{if(t){if(!a.value||!s.value)return;u=d.autoUpdate("$el"in a.value?a.value.$el:a.value,s.value,B)}else u&&(u(),u=null)})}module.exports=j;
