import{g as t,r as o}from"../focus-93ksTIEs.js";import{isKwcModalActive as i}from"./overlayManager.js";import{secure as s}from"./overlayUtils.js";import"./tooltipLibrary.js";import"@kdcloudjs/kwc";import"./positionLibrary.js";import"../observable-tloG64m6.js";import"../empty_html-CjXB8rB4.js";import"../i18n-B98kiI7M.js";import"../normalize-C0Pp7GJL.js";import"./utilsPrivate.js";import"../client-Ddi3i8XR.js";import"../ssr-C2pjZzfv.js";import"./iso8601Utils.js";import"../colorValid-qIPgkqGp.js";import"./primitiveBubble.js";import"../kddsCommon-CucK_w70.js";import"./shadowBaseClassPrivate.js";import"../classSet-DY6Qvt6E.js";import"./ariaObserver.js";const r=["lightning-modal-header","lightning-modal-body","lightning-modal-footer","lightning-focus-trap","lightning-overlay-container"];function e(e){const{isModalClosing:a,lastFocusedElement:l}=this;if(!i()||a)return;let n=null;e.target&&"function"==typeof e.target.closest?n=e.target.closest(r.join(",")):e.relatedTarget&&"function"==typeof e.relatedTarget.closest&&(n=e.relatedTarget.closest(r.join(","))),n?(this.lastFocusedElement=t(),this.dispatchEvent(new CustomEvent("privatelightningmodallastfocus",{composed:!0,bubbles:!0,detail:{[s]:!0,privatelightningmodallastfocus:this.lastFocusedElement}}))):l&&(l.ariaHasPopup||o(l))}export{e as modalFocusinEventHandler};
