/*! * All material copyright ESRI, All Rights Reserved, unless otherwise specified. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details. * v1.0.0-beta.82 */ import{f as forceUpdate,h}from"./index-8ece2564.js";import{a as getElementDir}from"./dom-da697a3f.js";import{S as SLOTS}from"./resources-3c30f589.js";import{S as SLOTS$1}from"./resources-e8f918f0.js";var overflowActionsDebounceInMs=150;var groupBufferHeight=2;var getMaxActionCount=function(e){var t=e.height,o=e.actionHeight,r=e.groupCount;return Math.floor((t-r*groupBufferHeight)/o)};var getOverflowCount=function(e){var t=e.actionCount,o=e.actionHeight,r=e.height,n=e.groupCount;return Math.max(t-getMaxActionCount({height:r,actionHeight:o,groupCount:n}),0)};var queryActions=function(e){return Array.from(e.querySelectorAll("calcite-action")).filter((function(e){return e.closest("calcite-action-menu")?e.slot===SLOTS.trigger:true}))};var overflowActions=function(e){var t=e.actionGroups,o=e.expanded,r=e.overflowCount;var n=r;t.reverse().forEach((function(e){var t=0;var r=queryActions(e).reverse();r.forEach((function(e){if(e.slot===SLOTS$1.menuActions){e.removeAttribute("slot");e.textEnabled=o}}));if(n>0){r.some((function(e){var o=r.filter((function(e){return!e.slot}));if(o.length>1&&r.length>2&&!e.closest("calcite-action-menu")){e.textEnabled=true;e.setAttribute("slot",SLOTS$1.menuActions);t++;if(t>1){n--}}return n<1}))}forceUpdate(e)}))};var ICONS={chevronsLeft:"chevrons-left",chevronsRight:"chevrons-right"};function getCalcitePosition(e,t){var o;return e||((o=t.closest("calcite-shell-panel"))===null||o===void 0?void 0:o.position)||"start"}function toggleChildActionText(e){var t=e.parent,o=e.expanded;queryActions(t).filter((function(e){return e.slot!==SLOTS$1.menuActions})).forEach((function(e){return e.textEnabled=o}));t.querySelectorAll("calcite-action-group").forEach((function(e){return e.expanded=o}))}var setTooltipReference=function(e){var t=e.tooltip,o=e.referenceElement,r=e.expanded,n=e.ref;if(t){t.referenceElement=!r&&o?o:null}if(n){n(o)}return o};var ExpandToggle=function(e){var t=e.expanded,o=e.intlExpand,r=e.intlCollapse,n=e.toggle,i=e.el,a=e.position,c=e.tooltip,l=e.ref,u=e.scale;var f=getElementDir(i)==="rtl";var s=t?r:o;var v=[ICONS.chevronsLeft,ICONS.chevronsRight];if(f){v.reverse()}var g=getCalcitePosition(a,i)==="end";var p=g?v[1]:v[0];var d=g?v[0]:v[1];var m=h("calcite-action",{icon:t?p:d,onClick:n,ref:function(e){return setTooltipReference({tooltip:c,referenceElement:e,expanded:t,ref:l})},scale:u,text:s,textEnabled:t});return m};export{ExpandToggle as E,overflowActions as a,getOverflowCount as g,overflowActionsDebounceInMs as o,queryActions as q,toggleChildActionText as t};