import{a as e,l as t}from"./preact.module-CNakwbc9.js";import{d as n,i as r,l as i,t as a}from"./hooks.module-BrXTvcfS.js";import{Ft as o,G as s,R as c}from"./content_renderer-DOj8g78V.js";import{n as l}from"./bootstrap.esm-DbsKxb7T.js";import{a as u}from"./i18n-BaLR3UdQ.js";import{t as d}from"./jsxRuntime.module-Cao1NCKs.js";import{t as f}from"./react_utils-Bz0ffU2Y.js";import{G as p}from"./hooks-ClTXKdUl.js";import{t as m}from"./modal_focustrap-BhwPuWvY.js";n(),t();function h({children:t,className:n,size:h,title:v,customTitleBarButtons:y,header:b,footer:x,footerStyle:S,footerAlignment:C,onShown:w,onSubmit:T,helpPageId:E,minWidth:D,maxWidth:O,zIndex:k,scrollable:A,onHidden:j,modalRef:M,formRef:N,bodyStyle:P,show:F,stackable:I,keepInDom:L,noFocus:R,sidebar:z,hideSidebarHeader:B,isFullPageOnMobile:V}){let H=p(M),U=a(),W=a();i(()=>{let e=H.current;if(!e)return;w&&e.addEventListener(`shown.bs.modal`,w);function t(){j(),W.current&&`focus`in W.current&&W.current.focus()}return e.addEventListener(`hidden.bs.modal`,t),()=>{w&&e.removeEventListener(`shown.bs.modal`,w),e.removeEventListener(`hidden.bs.modal`,t)}},[w,j]),i(()=>{F&&H.current?(W.current=document.activeElement,o($(H.current),!I,{focus:!R},k).then(e=>{U.current=l.getOrCreateInstance(e[0])})):U.current?.hide()},[F,H.current,R,k]),i(()=>{if(!(!F||!H.current))return m(H.current)},[F]);let G=r(()=>{let e={};return k&&(e.zIndex=k),e},[k]),K=r(()=>{let e={};return O&&(e.maxWidth=`${O}px`),D&&(e.minWidth=D),e},[O,D]);return d(`div`,{className:`modal fade mx-auto ${n}`,tabIndex:-1,style:G,role:`dialog`,ref:H,children:(F||L)&&d(f.Provider,{value:F,children:d(`div`,{className:c(`modal-dialog`,`modal-${h}`,{"modal-dialog-scrollable":A,"modal-dialog-full-page-on-mobile":V,"modal-content-with-sidebar":z}),style:K,role:`document`,children:d(`div`,{className:c(`modal-content`,z&&`modal-content-with-sidebar`),children:[z&&d(`div`,{className:`modal-sidebar`,children:[v&&!B&&d(`div`,{className:`modal-sidebar-header`,children:d(`h5`,{children:v})}),z]}),d(g,{sidebar:!!z,children:[d(`div`,{className:`modal-header`,children:[!v||typeof v==`string`?d(`h5`,{className:`modal-title`,children:v??d(e,{children:`\xA0`})}):v,b,E&&d(`button`,{className:`help-button`,type:`button`,title:u(`modal.help_title`),onClick:()=>s.triggerCommand(`openInPopup`,{noteIdOrPath:`_help_${E}`}),children:`?`}),y?.filter(e=>e!==null).map(e=>d(`button`,{type:`button`,className:c(`custom-title-bar-button bx`,e.iconClassName),title:e.title,onClick:e.onClick})),d(`button`,{type:`button`,className:`btn-close`,"data-bs-dismiss":`modal`,"aria-label":u(`modal.close`)})]}),T?d(`form`,{ref:N,onSubmit:e=>{e.preventDefault(),T()},children:d(_,{footer:x,bodyStyle:P,footerStyle:S,footerAlignment:C,children:t})}):d(_,{footer:x,bodyStyle:P,footerStyle:S,footerAlignment:C,children:t})]})]})})})})}function g({sidebar:t,children:n}){return t?d(`div`,{className:`modal-main`,children:n}):d(e,{children:n})}function _({children:t,footer:n,footerAlignment:i,bodyStyle:a,footerStyle:o}){let s=r(()=>{let e=o??{};return i===`between`&&(e.justifyContent=`space-between`),e},[o,i]);return d(e,{children:[d(`div`,{className:`modal-body`,style:a,children:t}),n&&d(`div`,{className:`modal-footer`,style:s,children:n})]})}export{h as t};