bootstrap.esm.js 133 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421
  1. /*!
  2. * Bootstrap v5.3.0-alpha2 (https://getbootstrap.com/)
  3. * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  4. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5. */
  6. import * as Popper from '@popperjs/core';
  7. /**
  8. * --------------------------------------------------------------------------
  9. * Bootstrap util/index.js
  10. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  11. * --------------------------------------------------------------------------
  12. */
  13. const MAX_UID = 1000000;
  14. const MILLISECONDS_MULTIPLIER = 1000;
  15. const TRANSITION_END = 'transitionend';
  16. /**
  17. * Properly escape IDs selectors to handle weird IDs
  18. * @param {string} selector
  19. * @returns {string}
  20. */
  21. const parseSelector = selector => {
  22. if (selector && window.CSS && window.CSS.escape) {
  23. // document.querySelector needs escaping to handle IDs (html5+) containing for instance /
  24. selector = selector.replace(/#([^\s"#']+)/g, (match, id) => `#${CSS.escape(id)}`);
  25. }
  26. return selector;
  27. };
  28. // Shout-out Angus Croll (https://goo.gl/pxwQGp)
  29. const toType = object => {
  30. if (object === null || object === undefined) {
  31. return `${object}`;
  32. }
  33. return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
  34. };
  35. /**
  36. * Public Util API
  37. */
  38. const getUID = prefix => {
  39. do {
  40. prefix += Math.floor(Math.random() * MAX_UID);
  41. } while (document.getElementById(prefix));
  42. return prefix;
  43. };
  44. const getTransitionDurationFromElement = element => {
  45. if (!element) {
  46. return 0;
  47. }
  48. // Get transition-duration of the element
  49. let {
  50. transitionDuration,
  51. transitionDelay
  52. } = window.getComputedStyle(element);
  53. const floatTransitionDuration = Number.parseFloat(transitionDuration);
  54. const floatTransitionDelay = Number.parseFloat(transitionDelay);
  55. // Return 0 if element or transition duration is not found
  56. if (!floatTransitionDuration && !floatTransitionDelay) {
  57. return 0;
  58. }
  59. // If multiple durations are defined, take the first
  60. transitionDuration = transitionDuration.split(',')[0];
  61. transitionDelay = transitionDelay.split(',')[0];
  62. return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  63. };
  64. const triggerTransitionEnd = element => {
  65. element.dispatchEvent(new Event(TRANSITION_END));
  66. };
  67. const isElement = object => {
  68. if (!object || typeof object !== 'object') {
  69. return false;
  70. }
  71. if (typeof object.jquery !== 'undefined') {
  72. object = object[0];
  73. }
  74. return typeof object.nodeType !== 'undefined';
  75. };
  76. const getElement = object => {
  77. // it's a jQuery object or a node element
  78. if (isElement(object)) {
  79. return object.jquery ? object[0] : object;
  80. }
  81. if (typeof object === 'string' && object.length > 0) {
  82. return document.querySelector(parseSelector(object));
  83. }
  84. return null;
  85. };
  86. const isVisible = element => {
  87. if (!isElement(element) || element.getClientRects().length === 0) {
  88. return false;
  89. }
  90. const elementIsVisible = getComputedStyle(element).getPropertyValue('visibility') === 'visible';
  91. // Handle `details` element as its content may falsie appear visible when it is closed
  92. const closedDetails = element.closest('details:not([open])');
  93. if (!closedDetails) {
  94. return elementIsVisible;
  95. }
  96. if (closedDetails !== element) {
  97. const summary = element.closest('summary');
  98. if (summary && summary.parentNode !== closedDetails) {
  99. return false;
  100. }
  101. if (summary === null) {
  102. return false;
  103. }
  104. }
  105. return elementIsVisible;
  106. };
  107. const isDisabled = element => {
  108. if (!element || element.nodeType !== Node.ELEMENT_NODE) {
  109. return true;
  110. }
  111. if (element.classList.contains('disabled')) {
  112. return true;
  113. }
  114. if (typeof element.disabled !== 'undefined') {
  115. return element.disabled;
  116. }
  117. return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
  118. };
  119. const findShadowRoot = element => {
  120. if (!document.documentElement.attachShadow) {
  121. return null;
  122. }
  123. // Can find the shadow root otherwise it'll return the document
  124. if (typeof element.getRootNode === 'function') {
  125. const root = element.getRootNode();
  126. return root instanceof ShadowRoot ? root : null;
  127. }
  128. if (element instanceof ShadowRoot) {
  129. return element;
  130. }
  131. // when we don't find a shadow root
  132. if (!element.parentNode) {
  133. return null;
  134. }
  135. return findShadowRoot(element.parentNode);
  136. };
  137. const noop = () => {};
  138. /**
  139. * Trick to restart an element's animation
  140. *
  141. * @param {HTMLElement} element
  142. * @return void
  143. *
  144. * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
  145. */
  146. const reflow = element => {
  147. element.offsetHeight; // eslint-disable-line no-unused-expressions
  148. };
  149. const getjQuery = () => {
  150. if (window.jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
  151. return window.jQuery;
  152. }
  153. return null;
  154. };
  155. const DOMContentLoadedCallbacks = [];
  156. const onDOMContentLoaded = callback => {
  157. if (document.readyState === 'loading') {
  158. // add listener on the first call when the document is in loading state
  159. if (!DOMContentLoadedCallbacks.length) {
  160. document.addEventListener('DOMContentLoaded', () => {
  161. for (const callback of DOMContentLoadedCallbacks) {
  162. callback();
  163. }
  164. });
  165. }
  166. DOMContentLoadedCallbacks.push(callback);
  167. } else {
  168. callback();
  169. }
  170. };
  171. const isRTL = () => document.documentElement.dir === 'rtl';
  172. const defineJQueryPlugin = plugin => {
  173. onDOMContentLoaded(() => {
  174. const $ = getjQuery();
  175. /* istanbul ignore if */
  176. if ($) {
  177. const name = plugin.NAME;
  178. const JQUERY_NO_CONFLICT = $.fn[name];
  179. $.fn[name] = plugin.jQueryInterface;
  180. $.fn[name].Constructor = plugin;
  181. $.fn[name].noConflict = () => {
  182. $.fn[name] = JQUERY_NO_CONFLICT;
  183. return plugin.jQueryInterface;
  184. };
  185. }
  186. });
  187. };
  188. const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
  189. return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue;
  190. };
  191. const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
  192. if (!waitForTransition) {
  193. execute(callback);
  194. return;
  195. }
  196. const durationPadding = 5;
  197. const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
  198. let called = false;
  199. const handler = ({
  200. target
  201. }) => {
  202. if (target !== transitionElement) {
  203. return;
  204. }
  205. called = true;
  206. transitionElement.removeEventListener(TRANSITION_END, handler);
  207. execute(callback);
  208. };
  209. transitionElement.addEventListener(TRANSITION_END, handler);
  210. setTimeout(() => {
  211. if (!called) {
  212. triggerTransitionEnd(transitionElement);
  213. }
  214. }, emulatedDuration);
  215. };
  216. /**
  217. * Return the previous/next element of a list.
  218. *
  219. * @param {array} list The list of elements
  220. * @param activeElement The active element
  221. * @param shouldGetNext Choose to get next or previous element
  222. * @param isCycleAllowed
  223. * @return {Element|elem} The proper element
  224. */
  225. const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
  226. const listLength = list.length;
  227. let index = list.indexOf(activeElement);
  228. // if the element does not exist in the list return an element
  229. // depending on the direction and if cycle is allowed
  230. if (index === -1) {
  231. return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
  232. }
  233. index += shouldGetNext ? 1 : -1;
  234. if (isCycleAllowed) {
  235. index = (index + listLength) % listLength;
  236. }
  237. return list[Math.max(0, Math.min(index, listLength - 1))];
  238. };
  239. /**
  240. * --------------------------------------------------------------------------
  241. * Bootstrap dom/event-handler.js
  242. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  243. * --------------------------------------------------------------------------
  244. */
  245. /**
  246. * Constants
  247. */
  248. const namespaceRegex = /[^.]*(?=\..*)\.|.*/;
  249. const stripNameRegex = /\..*/;
  250. const stripUidRegex = /::\d+$/;
  251. const eventRegistry = {}; // Events storage
  252. let uidEvent = 1;
  253. const customEvents = {
  254. mouseenter: 'mouseover',
  255. mouseleave: 'mouseout'
  256. };
  257. const nativeEvents = new Set(['click', 'dblclick', 'mouseup', 'mousedown', 'contextmenu', 'mousewheel', 'DOMMouseScroll', 'mouseover', 'mouseout', 'mousemove', 'selectstart', 'selectend', 'keydown', 'keypress', 'keyup', 'orientationchange', 'touchstart', 'touchmove', 'touchend', 'touchcancel', 'pointerdown', 'pointermove', 'pointerup', 'pointerleave', 'pointercancel', 'gesturestart', 'gesturechange', 'gestureend', 'focus', 'blur', 'change', 'reset', 'select', 'submit', 'focusin', 'focusout', 'load', 'unload', 'beforeunload', 'resize', 'move', 'DOMContentLoaded', 'readystatechange', 'error', 'abort', 'scroll']);
  258. /**
  259. * Private methods
  260. */
  261. function makeEventUid(element, uid) {
  262. return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++;
  263. }
  264. function getElementEvents(element) {
  265. const uid = makeEventUid(element);
  266. element.uidEvent = uid;
  267. eventRegistry[uid] = eventRegistry[uid] || {};
  268. return eventRegistry[uid];
  269. }
  270. function bootstrapHandler(element, fn) {
  271. return function handler(event) {
  272. hydrateObj(event, {
  273. delegateTarget: element
  274. });
  275. if (handler.oneOff) {
  276. EventHandler.off(element, event.type, fn);
  277. }
  278. return fn.apply(element, [event]);
  279. };
  280. }
  281. function bootstrapDelegationHandler(element, selector, fn) {
  282. return function handler(event) {
  283. const domElements = element.querySelectorAll(selector);
  284. for (let {
  285. target
  286. } = event; target && target !== this; target = target.parentNode) {
  287. for (const domElement of domElements) {
  288. if (domElement !== target) {
  289. continue;
  290. }
  291. hydrateObj(event, {
  292. delegateTarget: target
  293. });
  294. if (handler.oneOff) {
  295. EventHandler.off(element, event.type, selector, fn);
  296. }
  297. return fn.apply(target, [event]);
  298. }
  299. }
  300. };
  301. }
  302. function findHandler(events, callable, delegationSelector = null) {
  303. return Object.values(events).find(event => event.callable === callable && event.delegationSelector === delegationSelector);
  304. }
  305. function normalizeParameters(originalTypeEvent, handler, delegationFunction) {
  306. const isDelegated = typeof handler === 'string';
  307. // todo: tooltip passes `false` instead of selector, so we need to check
  308. const callable = isDelegated ? delegationFunction : handler || delegationFunction;
  309. let typeEvent = getTypeEvent(originalTypeEvent);
  310. if (!nativeEvents.has(typeEvent)) {
  311. typeEvent = originalTypeEvent;
  312. }
  313. return [isDelegated, callable, typeEvent];
  314. }
  315. function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) {
  316. if (typeof originalTypeEvent !== 'string' || !element) {
  317. return;
  318. }
  319. let [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
  320. // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position
  321. // this prevents the handler from being dispatched the same way as mouseover or mouseout does
  322. if (originalTypeEvent in customEvents) {
  323. const wrapFunction = fn => {
  324. return function (event) {
  325. if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) {
  326. return fn.call(this, event);
  327. }
  328. };
  329. };
  330. callable = wrapFunction(callable);
  331. }
  332. const events = getElementEvents(element);
  333. const handlers = events[typeEvent] || (events[typeEvent] = {});
  334. const previousFunction = findHandler(handlers, callable, isDelegated ? handler : null);
  335. if (previousFunction) {
  336. previousFunction.oneOff = previousFunction.oneOff && oneOff;
  337. return;
  338. }
  339. const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, ''));
  340. const fn = isDelegated ? bootstrapDelegationHandler(element, handler, callable) : bootstrapHandler(element, callable);
  341. fn.delegationSelector = isDelegated ? handler : null;
  342. fn.callable = callable;
  343. fn.oneOff = oneOff;
  344. fn.uidEvent = uid;
  345. handlers[uid] = fn;
  346. element.addEventListener(typeEvent, fn, isDelegated);
  347. }
  348. function removeHandler(element, events, typeEvent, handler, delegationSelector) {
  349. const fn = findHandler(events[typeEvent], handler, delegationSelector);
  350. if (!fn) {
  351. return;
  352. }
  353. element.removeEventListener(typeEvent, fn, Boolean(delegationSelector));
  354. delete events[typeEvent][fn.uidEvent];
  355. }
  356. function removeNamespacedHandlers(element, events, typeEvent, namespace) {
  357. const storeElementEvent = events[typeEvent] || {};
  358. for (const [handlerKey, event] of Object.entries(storeElementEvent)) {
  359. if (handlerKey.includes(namespace)) {
  360. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  361. }
  362. }
  363. }
  364. function getTypeEvent(event) {
  365. // allow to get the native events from namespaced events ('click.bs.button' --> 'click')
  366. event = event.replace(stripNameRegex, '');
  367. return customEvents[event] || event;
  368. }
  369. const EventHandler = {
  370. on(element, event, handler, delegationFunction) {
  371. addHandler(element, event, handler, delegationFunction, false);
  372. },
  373. one(element, event, handler, delegationFunction) {
  374. addHandler(element, event, handler, delegationFunction, true);
  375. },
  376. off(element, originalTypeEvent, handler, delegationFunction) {
  377. if (typeof originalTypeEvent !== 'string' || !element) {
  378. return;
  379. }
  380. const [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
  381. const inNamespace = typeEvent !== originalTypeEvent;
  382. const events = getElementEvents(element);
  383. const storeElementEvent = events[typeEvent] || {};
  384. const isNamespace = originalTypeEvent.startsWith('.');
  385. if (typeof callable !== 'undefined') {
  386. // Simplest case: handler is passed, remove that listener ONLY.
  387. if (!Object.keys(storeElementEvent).length) {
  388. return;
  389. }
  390. removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null);
  391. return;
  392. }
  393. if (isNamespace) {
  394. for (const elementEvent of Object.keys(events)) {
  395. removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1));
  396. }
  397. }
  398. for (const [keyHandlers, event] of Object.entries(storeElementEvent)) {
  399. const handlerKey = keyHandlers.replace(stripUidRegex, '');
  400. if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
  401. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  402. }
  403. }
  404. },
  405. trigger(element, event, args) {
  406. if (typeof event !== 'string' || !element) {
  407. return null;
  408. }
  409. const $ = getjQuery();
  410. const typeEvent = getTypeEvent(event);
  411. const inNamespace = event !== typeEvent;
  412. let jQueryEvent = null;
  413. let bubbles = true;
  414. let nativeDispatch = true;
  415. let defaultPrevented = false;
  416. if (inNamespace && $) {
  417. jQueryEvent = $.Event(event, args);
  418. $(element).trigger(jQueryEvent);
  419. bubbles = !jQueryEvent.isPropagationStopped();
  420. nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
  421. defaultPrevented = jQueryEvent.isDefaultPrevented();
  422. }
  423. let evt = new Event(event, {
  424. bubbles,
  425. cancelable: true
  426. });
  427. evt = hydrateObj(evt, args);
  428. if (defaultPrevented) {
  429. evt.preventDefault();
  430. }
  431. if (nativeDispatch) {
  432. element.dispatchEvent(evt);
  433. }
  434. if (evt.defaultPrevented && jQueryEvent) {
  435. jQueryEvent.preventDefault();
  436. }
  437. return evt;
  438. }
  439. };
  440. function hydrateObj(obj, meta = {}) {
  441. for (const [key, value] of Object.entries(meta)) {
  442. try {
  443. obj[key] = value;
  444. } catch (_unused) {
  445. Object.defineProperty(obj, key, {
  446. configurable: true,
  447. get() {
  448. return value;
  449. }
  450. });
  451. }
  452. }
  453. return obj;
  454. }
  455. /**
  456. * --------------------------------------------------------------------------
  457. * Bootstrap dom/data.js
  458. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  459. * --------------------------------------------------------------------------
  460. */
  461. /**
  462. * Constants
  463. */
  464. const elementMap = new Map();
  465. const Data = {
  466. set(element, key, instance) {
  467. if (!elementMap.has(element)) {
  468. elementMap.set(element, new Map());
  469. }
  470. const instanceMap = elementMap.get(element);
  471. // make it clear we only want one instance per element
  472. // can be removed later when multiple key/instances are fine to be used
  473. if (!instanceMap.has(key) && instanceMap.size !== 0) {
  474. // eslint-disable-next-line no-console
  475. console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`);
  476. return;
  477. }
  478. instanceMap.set(key, instance);
  479. },
  480. get(element, key) {
  481. if (elementMap.has(element)) {
  482. return elementMap.get(element).get(key) || null;
  483. }
  484. return null;
  485. },
  486. remove(element, key) {
  487. if (!elementMap.has(element)) {
  488. return;
  489. }
  490. const instanceMap = elementMap.get(element);
  491. instanceMap.delete(key);
  492. // free up element references if there are no instances left for an element
  493. if (instanceMap.size === 0) {
  494. elementMap.delete(element);
  495. }
  496. }
  497. };
  498. /**
  499. * --------------------------------------------------------------------------
  500. * Bootstrap dom/manipulator.js
  501. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  502. * --------------------------------------------------------------------------
  503. */
  504. function normalizeData(value) {
  505. if (value === 'true') {
  506. return true;
  507. }
  508. if (value === 'false') {
  509. return false;
  510. }
  511. if (value === Number(value).toString()) {
  512. return Number(value);
  513. }
  514. if (value === '' || value === 'null') {
  515. return null;
  516. }
  517. if (typeof value !== 'string') {
  518. return value;
  519. }
  520. try {
  521. return JSON.parse(decodeURIComponent(value));
  522. } catch (_unused) {
  523. return value;
  524. }
  525. }
  526. function normalizeDataKey(key) {
  527. return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`);
  528. }
  529. const Manipulator = {
  530. setDataAttribute(element, key, value) {
  531. element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value);
  532. },
  533. removeDataAttribute(element, key) {
  534. element.removeAttribute(`data-bs-${normalizeDataKey(key)}`);
  535. },
  536. getDataAttributes(element) {
  537. if (!element) {
  538. return {};
  539. }
  540. const attributes = {};
  541. const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs') && !key.startsWith('bsConfig'));
  542. for (const key of bsKeys) {
  543. let pureKey = key.replace(/^bs/, '');
  544. pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
  545. attributes[pureKey] = normalizeData(element.dataset[key]);
  546. }
  547. return attributes;
  548. },
  549. getDataAttribute(element, key) {
  550. return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`));
  551. }
  552. };
  553. /**
  554. * --------------------------------------------------------------------------
  555. * Bootstrap util/config.js
  556. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  557. * --------------------------------------------------------------------------
  558. */
  559. /**
  560. * Class definition
  561. */
  562. class Config {
  563. // Getters
  564. static get Default() {
  565. return {};
  566. }
  567. static get DefaultType() {
  568. return {};
  569. }
  570. static get NAME() {
  571. throw new Error('You have to implement the static method "NAME", for each component!');
  572. }
  573. _getConfig(config) {
  574. config = this._mergeConfigObj(config);
  575. config = this._configAfterMerge(config);
  576. this._typeCheckConfig(config);
  577. return config;
  578. }
  579. _configAfterMerge(config) {
  580. return config;
  581. }
  582. _mergeConfigObj(config, element) {
  583. const jsonConfig = isElement(element) ? Manipulator.getDataAttribute(element, 'config') : {}; // try to parse
  584. return {
  585. ...this.constructor.Default,
  586. ...(typeof jsonConfig === 'object' ? jsonConfig : {}),
  587. ...(isElement(element) ? Manipulator.getDataAttributes(element) : {}),
  588. ...(typeof config === 'object' ? config : {})
  589. };
  590. }
  591. _typeCheckConfig(config, configTypes = this.constructor.DefaultType) {
  592. for (const [property, expectedTypes] of Object.entries(configTypes)) {
  593. const value = config[property];
  594. const valueType = isElement(value) ? 'element' : toType(value);
  595. if (!new RegExp(expectedTypes).test(valueType)) {
  596. throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
  597. }
  598. }
  599. }
  600. }
  601. /**
  602. * --------------------------------------------------------------------------
  603. * Bootstrap base-component.js
  604. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  605. * --------------------------------------------------------------------------
  606. */
  607. /**
  608. * Constants
  609. */
  610. const VERSION = '5.3.0-alpha2';
  611. /**
  612. * Class definition
  613. */
  614. class BaseComponent extends Config {
  615. constructor(element, config) {
  616. super();
  617. element = getElement(element);
  618. if (!element) {
  619. return;
  620. }
  621. this._element = element;
  622. this._config = this._getConfig(config);
  623. Data.set(this._element, this.constructor.DATA_KEY, this);
  624. }
  625. // Public
  626. dispose() {
  627. Data.remove(this._element, this.constructor.DATA_KEY);
  628. EventHandler.off(this._element, this.constructor.EVENT_KEY);
  629. for (const propertyName of Object.getOwnPropertyNames(this)) {
  630. this[propertyName] = null;
  631. }
  632. }
  633. _queueCallback(callback, element, isAnimated = true) {
  634. executeAfterTransition(callback, element, isAnimated);
  635. }
  636. _getConfig(config) {
  637. config = this._mergeConfigObj(config, this._element);
  638. config = this._configAfterMerge(config);
  639. this._typeCheckConfig(config);
  640. return config;
  641. }
  642. // Static
  643. static getInstance(element) {
  644. return Data.get(getElement(element), this.DATA_KEY);
  645. }
  646. static getOrCreateInstance(element, config = {}) {
  647. return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
  648. }
  649. static get VERSION() {
  650. return VERSION;
  651. }
  652. static get DATA_KEY() {
  653. return `bs.${this.NAME}`;
  654. }
  655. static get EVENT_KEY() {
  656. return `.${this.DATA_KEY}`;
  657. }
  658. static eventName(name) {
  659. return `${name}${this.EVENT_KEY}`;
  660. }
  661. }
  662. /**
  663. * --------------------------------------------------------------------------
  664. * Bootstrap dom/selector-engine.js
  665. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  666. * --------------------------------------------------------------------------
  667. */
  668. const getSelector = element => {
  669. let selector = element.getAttribute('data-bs-target');
  670. if (!selector || selector === '#') {
  671. let hrefAttribute = element.getAttribute('href');
  672. // The only valid content that could double as a selector are IDs or classes,
  673. // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
  674. // `document.querySelector` will rightfully complain it is invalid.
  675. // See https://github.com/twbs/bootstrap/issues/32273
  676. if (!hrefAttribute || !hrefAttribute.includes('#') && !hrefAttribute.startsWith('.')) {
  677. return null;
  678. }
  679. // Just in case some CMS puts out a full URL with the anchor appended
  680. if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) {
  681. hrefAttribute = `#${hrefAttribute.split('#')[1]}`;
  682. }
  683. selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null;
  684. }
  685. return parseSelector(selector);
  686. };
  687. const SelectorEngine = {
  688. find(selector, element = document.documentElement) {
  689. return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
  690. },
  691. findOne(selector, element = document.documentElement) {
  692. return Element.prototype.querySelector.call(element, selector);
  693. },
  694. children(element, selector) {
  695. return [].concat(...element.children).filter(child => child.matches(selector));
  696. },
  697. parents(element, selector) {
  698. const parents = [];
  699. let ancestor = element.parentNode.closest(selector);
  700. while (ancestor) {
  701. parents.push(ancestor);
  702. ancestor = ancestor.parentNode.closest(selector);
  703. }
  704. return parents;
  705. },
  706. prev(element, selector) {
  707. let previous = element.previousElementSibling;
  708. while (previous) {
  709. if (previous.matches(selector)) {
  710. return [previous];
  711. }
  712. previous = previous.previousElementSibling;
  713. }
  714. return [];
  715. },
  716. // TODO: this is now unused; remove later along with prev()
  717. next(element, selector) {
  718. let next = element.nextElementSibling;
  719. while (next) {
  720. if (next.matches(selector)) {
  721. return [next];
  722. }
  723. next = next.nextElementSibling;
  724. }
  725. return [];
  726. },
  727. focusableChildren(element) {
  728. const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(',');
  729. return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
  730. },
  731. getSelectorFromElement(element) {
  732. const selector = getSelector(element);
  733. if (selector) {
  734. return SelectorEngine.findOne(selector) ? selector : null;
  735. }
  736. return null;
  737. },
  738. getElementFromSelector(element) {
  739. const selector = getSelector(element);
  740. return selector ? SelectorEngine.findOne(selector) : null;
  741. },
  742. getMultipleElementsFromSelector(element) {
  743. const selector = getSelector(element);
  744. return selector ? SelectorEngine.find(selector) : [];
  745. }
  746. };
  747. /**
  748. * --------------------------------------------------------------------------
  749. * Bootstrap util/component-functions.js
  750. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  751. * --------------------------------------------------------------------------
  752. */
  753. const enableDismissTrigger = (component, method = 'hide') => {
  754. const clickEvent = `click.dismiss${component.EVENT_KEY}`;
  755. const name = component.NAME;
  756. EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
  757. if (['A', 'AREA'].includes(this.tagName)) {
  758. event.preventDefault();
  759. }
  760. if (isDisabled(this)) {
  761. return;
  762. }
  763. const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`);
  764. const instance = component.getOrCreateInstance(target);
  765. // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
  766. instance[method]();
  767. });
  768. };
  769. /**
  770. * --------------------------------------------------------------------------
  771. * Bootstrap alert.js
  772. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  773. * --------------------------------------------------------------------------
  774. */
  775. /**
  776. * Constants
  777. */
  778. const NAME$f = 'alert';
  779. const DATA_KEY$a = 'bs.alert';
  780. const EVENT_KEY$b = `.${DATA_KEY$a}`;
  781. const EVENT_CLOSE = `close${EVENT_KEY$b}`;
  782. const EVENT_CLOSED = `closed${EVENT_KEY$b}`;
  783. const CLASS_NAME_FADE$5 = 'fade';
  784. const CLASS_NAME_SHOW$8 = 'show';
  785. /**
  786. * Class definition
  787. */
  788. class Alert extends BaseComponent {
  789. // Getters
  790. static get NAME() {
  791. return NAME$f;
  792. }
  793. // Public
  794. close() {
  795. const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
  796. if (closeEvent.defaultPrevented) {
  797. return;
  798. }
  799. this._element.classList.remove(CLASS_NAME_SHOW$8);
  800. const isAnimated = this._element.classList.contains(CLASS_NAME_FADE$5);
  801. this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
  802. }
  803. // Private
  804. _destroyElement() {
  805. this._element.remove();
  806. EventHandler.trigger(this._element, EVENT_CLOSED);
  807. this.dispose();
  808. }
  809. // Static
  810. static jQueryInterface(config) {
  811. return this.each(function () {
  812. const data = Alert.getOrCreateInstance(this);
  813. if (typeof config !== 'string') {
  814. return;
  815. }
  816. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  817. throw new TypeError(`No method named "${config}"`);
  818. }
  819. data[config](this);
  820. });
  821. }
  822. }
  823. /**
  824. * Data API implementation
  825. */
  826. enableDismissTrigger(Alert, 'close');
  827. /**
  828. * jQuery
  829. */
  830. defineJQueryPlugin(Alert);
  831. /**
  832. * --------------------------------------------------------------------------
  833. * Bootstrap button.js
  834. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  835. * --------------------------------------------------------------------------
  836. */
  837. /**
  838. * Constants
  839. */
  840. const NAME$e = 'button';
  841. const DATA_KEY$9 = 'bs.button';
  842. const EVENT_KEY$a = `.${DATA_KEY$9}`;
  843. const DATA_API_KEY$6 = '.data-api';
  844. const CLASS_NAME_ACTIVE$3 = 'active';
  845. const SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]';
  846. const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`;
  847. /**
  848. * Class definition
  849. */
  850. class Button extends BaseComponent {
  851. // Getters
  852. static get NAME() {
  853. return NAME$e;
  854. }
  855. // Public
  856. toggle() {
  857. // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
  858. this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE$3));
  859. }
  860. // Static
  861. static jQueryInterface(config) {
  862. return this.each(function () {
  863. const data = Button.getOrCreateInstance(this);
  864. if (config === 'toggle') {
  865. data[config]();
  866. }
  867. });
  868. }
  869. }
  870. /**
  871. * Data API implementation
  872. */
  873. EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, event => {
  874. event.preventDefault();
  875. const button = event.target.closest(SELECTOR_DATA_TOGGLE$5);
  876. const data = Button.getOrCreateInstance(button);
  877. data.toggle();
  878. });
  879. /**
  880. * jQuery
  881. */
  882. defineJQueryPlugin(Button);
  883. /**
  884. * --------------------------------------------------------------------------
  885. * Bootstrap util/swipe.js
  886. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  887. * --------------------------------------------------------------------------
  888. */
  889. /**
  890. * Constants
  891. */
  892. const NAME$d = 'swipe';
  893. const EVENT_KEY$9 = '.bs.swipe';
  894. const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$9}`;
  895. const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$9}`;
  896. const EVENT_TOUCHEND = `touchend${EVENT_KEY$9}`;
  897. const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$9}`;
  898. const EVENT_POINTERUP = `pointerup${EVENT_KEY$9}`;
  899. const POINTER_TYPE_TOUCH = 'touch';
  900. const POINTER_TYPE_PEN = 'pen';
  901. const CLASS_NAME_POINTER_EVENT = 'pointer-event';
  902. const SWIPE_THRESHOLD = 40;
  903. const Default$c = {
  904. endCallback: null,
  905. leftCallback: null,
  906. rightCallback: null
  907. };
  908. const DefaultType$c = {
  909. endCallback: '(function|null)',
  910. leftCallback: '(function|null)',
  911. rightCallback: '(function|null)'
  912. };
  913. /**
  914. * Class definition
  915. */
  916. class Swipe extends Config {
  917. constructor(element, config) {
  918. super();
  919. this._element = element;
  920. if (!element || !Swipe.isSupported()) {
  921. return;
  922. }
  923. this._config = this._getConfig(config);
  924. this._deltaX = 0;
  925. this._supportPointerEvents = Boolean(window.PointerEvent);
  926. this._initEvents();
  927. }
  928. // Getters
  929. static get Default() {
  930. return Default$c;
  931. }
  932. static get DefaultType() {
  933. return DefaultType$c;
  934. }
  935. static get NAME() {
  936. return NAME$d;
  937. }
  938. // Public
  939. dispose() {
  940. EventHandler.off(this._element, EVENT_KEY$9);
  941. }
  942. // Private
  943. _start(event) {
  944. if (!this._supportPointerEvents) {
  945. this._deltaX = event.touches[0].clientX;
  946. return;
  947. }
  948. if (this._eventIsPointerPenTouch(event)) {
  949. this._deltaX = event.clientX;
  950. }
  951. }
  952. _end(event) {
  953. if (this._eventIsPointerPenTouch(event)) {
  954. this._deltaX = event.clientX - this._deltaX;
  955. }
  956. this._handleSwipe();
  957. execute(this._config.endCallback);
  958. }
  959. _move(event) {
  960. this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX;
  961. }
  962. _handleSwipe() {
  963. const absDeltaX = Math.abs(this._deltaX);
  964. if (absDeltaX <= SWIPE_THRESHOLD) {
  965. return;
  966. }
  967. const direction = absDeltaX / this._deltaX;
  968. this._deltaX = 0;
  969. if (!direction) {
  970. return;
  971. }
  972. execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback);
  973. }
  974. _initEvents() {
  975. if (this._supportPointerEvents) {
  976. EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event));
  977. EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event));
  978. this._element.classList.add(CLASS_NAME_POINTER_EVENT);
  979. } else {
  980. EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event));
  981. EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event));
  982. EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event));
  983. }
  984. }
  985. _eventIsPointerPenTouch(event) {
  986. return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
  987. }
  988. // Static
  989. static isSupported() {
  990. return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  991. }
  992. }
  993. /**
  994. * --------------------------------------------------------------------------
  995. * Bootstrap carousel.js
  996. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  997. * --------------------------------------------------------------------------
  998. */
  999. /**
  1000. * Constants
  1001. */
  1002. const NAME$c = 'carousel';
  1003. const DATA_KEY$8 = 'bs.carousel';
  1004. const EVENT_KEY$8 = `.${DATA_KEY$8}`;
  1005. const DATA_API_KEY$5 = '.data-api';
  1006. const ARROW_LEFT_KEY$1 = 'ArrowLeft';
  1007. const ARROW_RIGHT_KEY$1 = 'ArrowRight';
  1008. const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  1009. const ORDER_NEXT = 'next';
  1010. const ORDER_PREV = 'prev';
  1011. const DIRECTION_LEFT = 'left';
  1012. const DIRECTION_RIGHT = 'right';
  1013. const EVENT_SLIDE = `slide${EVENT_KEY$8}`;
  1014. const EVENT_SLID = `slid${EVENT_KEY$8}`;
  1015. const EVENT_KEYDOWN$1 = `keydown${EVENT_KEY$8}`;
  1016. const EVENT_MOUSEENTER$1 = `mouseenter${EVENT_KEY$8}`;
  1017. const EVENT_MOUSELEAVE$1 = `mouseleave${EVENT_KEY$8}`;
  1018. const EVENT_DRAG_START = `dragstart${EVENT_KEY$8}`;
  1019. const EVENT_LOAD_DATA_API$3 = `load${EVENT_KEY$8}${DATA_API_KEY$5}`;
  1020. const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`;
  1021. const CLASS_NAME_CAROUSEL = 'carousel';
  1022. const CLASS_NAME_ACTIVE$2 = 'active';
  1023. const CLASS_NAME_SLIDE = 'slide';
  1024. const CLASS_NAME_END = 'carousel-item-end';
  1025. const CLASS_NAME_START = 'carousel-item-start';
  1026. const CLASS_NAME_NEXT = 'carousel-item-next';
  1027. const CLASS_NAME_PREV = 'carousel-item-prev';
  1028. const SELECTOR_ACTIVE = '.active';
  1029. const SELECTOR_ITEM = '.carousel-item';
  1030. const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
  1031. const SELECTOR_ITEM_IMG = '.carousel-item img';
  1032. const SELECTOR_INDICATORS = '.carousel-indicators';
  1033. const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
  1034. const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
  1035. const KEY_TO_DIRECTION = {
  1036. [ARROW_LEFT_KEY$1]: DIRECTION_RIGHT,
  1037. [ARROW_RIGHT_KEY$1]: DIRECTION_LEFT
  1038. };
  1039. const Default$b = {
  1040. interval: 5000,
  1041. keyboard: true,
  1042. pause: 'hover',
  1043. ride: false,
  1044. touch: true,
  1045. wrap: true
  1046. };
  1047. const DefaultType$b = {
  1048. interval: '(number|boolean)',
  1049. // TODO:v6 remove boolean support
  1050. keyboard: 'boolean',
  1051. pause: '(string|boolean)',
  1052. ride: '(boolean|string)',
  1053. touch: 'boolean',
  1054. wrap: 'boolean'
  1055. };
  1056. /**
  1057. * Class definition
  1058. */
  1059. class Carousel extends BaseComponent {
  1060. constructor(element, config) {
  1061. super(element, config);
  1062. this._interval = null;
  1063. this._activeElement = null;
  1064. this._isSliding = false;
  1065. this.touchTimeout = null;
  1066. this._swipeHelper = null;
  1067. this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
  1068. this._addEventListeners();
  1069. if (this._config.ride === CLASS_NAME_CAROUSEL) {
  1070. this.cycle();
  1071. }
  1072. }
  1073. // Getters
  1074. static get Default() {
  1075. return Default$b;
  1076. }
  1077. static get DefaultType() {
  1078. return DefaultType$b;
  1079. }
  1080. static get NAME() {
  1081. return NAME$c;
  1082. }
  1083. // Public
  1084. next() {
  1085. this._slide(ORDER_NEXT);
  1086. }
  1087. nextWhenVisible() {
  1088. // FIXME TODO use `document.visibilityState`
  1089. // Don't call next when the page isn't visible
  1090. // or the carousel or its parent isn't visible
  1091. if (!document.hidden && isVisible(this._element)) {
  1092. this.next();
  1093. }
  1094. }
  1095. prev() {
  1096. this._slide(ORDER_PREV);
  1097. }
  1098. pause() {
  1099. if (this._isSliding) {
  1100. triggerTransitionEnd(this._element);
  1101. }
  1102. this._clearInterval();
  1103. }
  1104. cycle() {
  1105. this._clearInterval();
  1106. this._updateInterval();
  1107. this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval);
  1108. }
  1109. _maybeEnableCycle() {
  1110. if (!this._config.ride) {
  1111. return;
  1112. }
  1113. if (this._isSliding) {
  1114. EventHandler.one(this._element, EVENT_SLID, () => this.cycle());
  1115. return;
  1116. }
  1117. this.cycle();
  1118. }
  1119. to(index) {
  1120. const items = this._getItems();
  1121. if (index > items.length - 1 || index < 0) {
  1122. return;
  1123. }
  1124. if (this._isSliding) {
  1125. EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
  1126. return;
  1127. }
  1128. const activeIndex = this._getItemIndex(this._getActive());
  1129. if (activeIndex === index) {
  1130. return;
  1131. }
  1132. const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
  1133. this._slide(order, items[index]);
  1134. }
  1135. dispose() {
  1136. if (this._swipeHelper) {
  1137. this._swipeHelper.dispose();
  1138. }
  1139. super.dispose();
  1140. }
  1141. // Private
  1142. _configAfterMerge(config) {
  1143. config.defaultInterval = config.interval;
  1144. return config;
  1145. }
  1146. _addEventListeners() {
  1147. if (this._config.keyboard) {
  1148. EventHandler.on(this._element, EVENT_KEYDOWN$1, event => this._keydown(event));
  1149. }
  1150. if (this._config.pause === 'hover') {
  1151. EventHandler.on(this._element, EVENT_MOUSEENTER$1, () => this.pause());
  1152. EventHandler.on(this._element, EVENT_MOUSELEAVE$1, () => this._maybeEnableCycle());
  1153. }
  1154. if (this._config.touch && Swipe.isSupported()) {
  1155. this._addTouchEventListeners();
  1156. }
  1157. }
  1158. _addTouchEventListeners() {
  1159. for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) {
  1160. EventHandler.on(img, EVENT_DRAG_START, event => event.preventDefault());
  1161. }
  1162. const endCallBack = () => {
  1163. if (this._config.pause !== 'hover') {
  1164. return;
  1165. }
  1166. // If it's a touch-enabled device, mouseenter/leave are fired as
  1167. // part of the mouse compatibility events on first tap - the carousel
  1168. // would stop cycling until user tapped out of it;
  1169. // here, we listen for touchend, explicitly pause the carousel
  1170. // (as if it's the second time we tap on it, mouseenter compat event
  1171. // is NOT fired) and after a timeout (to allow for mouse compatibility
  1172. // events to fire) we explicitly restart cycling
  1173. this.pause();
  1174. if (this.touchTimeout) {
  1175. clearTimeout(this.touchTimeout);
  1176. }
  1177. this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
  1178. };
  1179. const swipeConfig = {
  1180. leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
  1181. rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
  1182. endCallback: endCallBack
  1183. };
  1184. this._swipeHelper = new Swipe(this._element, swipeConfig);
  1185. }
  1186. _keydown(event) {
  1187. if (/input|textarea/i.test(event.target.tagName)) {
  1188. return;
  1189. }
  1190. const direction = KEY_TO_DIRECTION[event.key];
  1191. if (direction) {
  1192. event.preventDefault();
  1193. this._slide(this._directionToOrder(direction));
  1194. }
  1195. }
  1196. _getItemIndex(element) {
  1197. return this._getItems().indexOf(element);
  1198. }
  1199. _setActiveIndicatorElement(index) {
  1200. if (!this._indicatorsElement) {
  1201. return;
  1202. }
  1203. const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
  1204. activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2);
  1205. activeIndicator.removeAttribute('aria-current');
  1206. const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
  1207. if (newActiveIndicator) {
  1208. newActiveIndicator.classList.add(CLASS_NAME_ACTIVE$2);
  1209. newActiveIndicator.setAttribute('aria-current', 'true');
  1210. }
  1211. }
  1212. _updateInterval() {
  1213. const element = this._activeElement || this._getActive();
  1214. if (!element) {
  1215. return;
  1216. }
  1217. const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
  1218. this._config.interval = elementInterval || this._config.defaultInterval;
  1219. }
  1220. _slide(order, element = null) {
  1221. if (this._isSliding) {
  1222. return;
  1223. }
  1224. const activeElement = this._getActive();
  1225. const isNext = order === ORDER_NEXT;
  1226. const nextElement = element || getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap);
  1227. if (nextElement === activeElement) {
  1228. return;
  1229. }
  1230. const nextElementIndex = this._getItemIndex(nextElement);
  1231. const triggerEvent = eventName => {
  1232. return EventHandler.trigger(this._element, eventName, {
  1233. relatedTarget: nextElement,
  1234. direction: this._orderToDirection(order),
  1235. from: this._getItemIndex(activeElement),
  1236. to: nextElementIndex
  1237. });
  1238. };
  1239. const slideEvent = triggerEvent(EVENT_SLIDE);
  1240. if (slideEvent.defaultPrevented) {
  1241. return;
  1242. }
  1243. if (!activeElement || !nextElement) {
  1244. // Some weirdness is happening, so we bail
  1245. // todo: change tests that use empty divs to avoid this check
  1246. return;
  1247. }
  1248. const isCycling = Boolean(this._interval);
  1249. this.pause();
  1250. this._isSliding = true;
  1251. this._setActiveIndicatorElement(nextElementIndex);
  1252. this._activeElement = nextElement;
  1253. const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
  1254. const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
  1255. nextElement.classList.add(orderClassName);
  1256. reflow(nextElement);
  1257. activeElement.classList.add(directionalClassName);
  1258. nextElement.classList.add(directionalClassName);
  1259. const completeCallBack = () => {
  1260. nextElement.classList.remove(directionalClassName, orderClassName);
  1261. nextElement.classList.add(CLASS_NAME_ACTIVE$2);
  1262. activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName);
  1263. this._isSliding = false;
  1264. triggerEvent(EVENT_SLID);
  1265. };
  1266. this._queueCallback(completeCallBack, activeElement, this._isAnimated());
  1267. if (isCycling) {
  1268. this.cycle();
  1269. }
  1270. }
  1271. _isAnimated() {
  1272. return this._element.classList.contains(CLASS_NAME_SLIDE);
  1273. }
  1274. _getActive() {
  1275. return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
  1276. }
  1277. _getItems() {
  1278. return SelectorEngine.find(SELECTOR_ITEM, this._element);
  1279. }
  1280. _clearInterval() {
  1281. if (this._interval) {
  1282. clearInterval(this._interval);
  1283. this._interval = null;
  1284. }
  1285. }
  1286. _directionToOrder(direction) {
  1287. if (isRTL()) {
  1288. return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
  1289. }
  1290. return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
  1291. }
  1292. _orderToDirection(order) {
  1293. if (isRTL()) {
  1294. return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
  1295. }
  1296. return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
  1297. }
  1298. // Static
  1299. static jQueryInterface(config) {
  1300. return this.each(function () {
  1301. const data = Carousel.getOrCreateInstance(this, config);
  1302. if (typeof config === 'number') {
  1303. data.to(config);
  1304. return;
  1305. }
  1306. if (typeof config === 'string') {
  1307. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  1308. throw new TypeError(`No method named "${config}"`);
  1309. }
  1310. data[config]();
  1311. }
  1312. });
  1313. }
  1314. }
  1315. /**
  1316. * Data API implementation
  1317. */
  1318. EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, function (event) {
  1319. const target = SelectorEngine.getElementFromSelector(this);
  1320. if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
  1321. return;
  1322. }
  1323. event.preventDefault();
  1324. const carousel = Carousel.getOrCreateInstance(target);
  1325. const slideIndex = this.getAttribute('data-bs-slide-to');
  1326. if (slideIndex) {
  1327. carousel.to(slideIndex);
  1328. carousel._maybeEnableCycle();
  1329. return;
  1330. }
  1331. if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
  1332. carousel.next();
  1333. carousel._maybeEnableCycle();
  1334. return;
  1335. }
  1336. carousel.prev();
  1337. carousel._maybeEnableCycle();
  1338. });
  1339. EventHandler.on(window, EVENT_LOAD_DATA_API$3, () => {
  1340. const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
  1341. for (const carousel of carousels) {
  1342. Carousel.getOrCreateInstance(carousel);
  1343. }
  1344. });
  1345. /**
  1346. * jQuery
  1347. */
  1348. defineJQueryPlugin(Carousel);
  1349. /**
  1350. * --------------------------------------------------------------------------
  1351. * Bootstrap collapse.js
  1352. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1353. * --------------------------------------------------------------------------
  1354. */
  1355. /**
  1356. * Constants
  1357. */
  1358. const NAME$b = 'collapse';
  1359. const DATA_KEY$7 = 'bs.collapse';
  1360. const EVENT_KEY$7 = `.${DATA_KEY$7}`;
  1361. const DATA_API_KEY$4 = '.data-api';
  1362. const EVENT_SHOW$6 = `show${EVENT_KEY$7}`;
  1363. const EVENT_SHOWN$6 = `shown${EVENT_KEY$7}`;
  1364. const EVENT_HIDE$6 = `hide${EVENT_KEY$7}`;
  1365. const EVENT_HIDDEN$6 = `hidden${EVENT_KEY$7}`;
  1366. const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`;
  1367. const CLASS_NAME_SHOW$7 = 'show';
  1368. const CLASS_NAME_COLLAPSE = 'collapse';
  1369. const CLASS_NAME_COLLAPSING = 'collapsing';
  1370. const CLASS_NAME_COLLAPSED = 'collapsed';
  1371. const CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`;
  1372. const CLASS_NAME_HORIZONTAL = 'collapse-horizontal';
  1373. const WIDTH = 'width';
  1374. const HEIGHT = 'height';
  1375. const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing';
  1376. const SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]';
  1377. const Default$a = {
  1378. parent: null,
  1379. toggle: true
  1380. };
  1381. const DefaultType$a = {
  1382. parent: '(null|element)',
  1383. toggle: 'boolean'
  1384. };
  1385. /**
  1386. * Class definition
  1387. */
  1388. class Collapse extends BaseComponent {
  1389. constructor(element, config) {
  1390. super(element, config);
  1391. this._isTransitioning = false;
  1392. this._triggerArray = [];
  1393. const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$4);
  1394. for (const elem of toggleList) {
  1395. const selector = SelectorEngine.getSelectorFromElement(elem);
  1396. const filterElement = SelectorEngine.find(selector).filter(foundElement => foundElement === this._element);
  1397. if (selector !== null && filterElement.length) {
  1398. this._triggerArray.push(elem);
  1399. }
  1400. }
  1401. this._initializeChildren();
  1402. if (!this._config.parent) {
  1403. this._addAriaAndCollapsedClass(this._triggerArray, this._isShown());
  1404. }
  1405. if (this._config.toggle) {
  1406. this.toggle();
  1407. }
  1408. }
  1409. // Getters
  1410. static get Default() {
  1411. return Default$a;
  1412. }
  1413. static get DefaultType() {
  1414. return DefaultType$a;
  1415. }
  1416. static get NAME() {
  1417. return NAME$b;
  1418. }
  1419. // Public
  1420. toggle() {
  1421. if (this._isShown()) {
  1422. this.hide();
  1423. } else {
  1424. this.show();
  1425. }
  1426. }
  1427. show() {
  1428. if (this._isTransitioning || this._isShown()) {
  1429. return;
  1430. }
  1431. let activeChildren = [];
  1432. // find active children
  1433. if (this._config.parent) {
  1434. activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter(element => element !== this._element).map(element => Collapse.getOrCreateInstance(element, {
  1435. toggle: false
  1436. }));
  1437. }
  1438. if (activeChildren.length && activeChildren[0]._isTransitioning) {
  1439. return;
  1440. }
  1441. const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$6);
  1442. if (startEvent.defaultPrevented) {
  1443. return;
  1444. }
  1445. for (const activeInstance of activeChildren) {
  1446. activeInstance.hide();
  1447. }
  1448. const dimension = this._getDimension();
  1449. this._element.classList.remove(CLASS_NAME_COLLAPSE);
  1450. this._element.classList.add(CLASS_NAME_COLLAPSING);
  1451. this._element.style[dimension] = 0;
  1452. this._addAriaAndCollapsedClass(this._triggerArray, true);
  1453. this._isTransitioning = true;
  1454. const complete = () => {
  1455. this._isTransitioning = false;
  1456. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  1457. this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  1458. this._element.style[dimension] = '';
  1459. EventHandler.trigger(this._element, EVENT_SHOWN$6);
  1460. };
  1461. const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  1462. const scrollSize = `scroll${capitalizedDimension}`;
  1463. this._queueCallback(complete, this._element, true);
  1464. this._element.style[dimension] = `${this._element[scrollSize]}px`;
  1465. }
  1466. hide() {
  1467. if (this._isTransitioning || !this._isShown()) {
  1468. return;
  1469. }
  1470. const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$6);
  1471. if (startEvent.defaultPrevented) {
  1472. return;
  1473. }
  1474. const dimension = this._getDimension();
  1475. this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
  1476. reflow(this._element);
  1477. this._element.classList.add(CLASS_NAME_COLLAPSING);
  1478. this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  1479. for (const trigger of this._triggerArray) {
  1480. const element = SelectorEngine.getElementFromSelector(trigger);
  1481. if (element && !this._isShown(element)) {
  1482. this._addAriaAndCollapsedClass([trigger], false);
  1483. }
  1484. }
  1485. this._isTransitioning = true;
  1486. const complete = () => {
  1487. this._isTransitioning = false;
  1488. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  1489. this._element.classList.add(CLASS_NAME_COLLAPSE);
  1490. EventHandler.trigger(this._element, EVENT_HIDDEN$6);
  1491. };
  1492. this._element.style[dimension] = '';
  1493. this._queueCallback(complete, this._element, true);
  1494. }
  1495. _isShown(element = this._element) {
  1496. return element.classList.contains(CLASS_NAME_SHOW$7);
  1497. }
  1498. // Private
  1499. _configAfterMerge(config) {
  1500. config.toggle = Boolean(config.toggle); // Coerce string values
  1501. config.parent = getElement(config.parent);
  1502. return config;
  1503. }
  1504. _getDimension() {
  1505. return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT;
  1506. }
  1507. _initializeChildren() {
  1508. if (!this._config.parent) {
  1509. return;
  1510. }
  1511. const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$4);
  1512. for (const element of children) {
  1513. const selected = SelectorEngine.getElementFromSelector(element);
  1514. if (selected) {
  1515. this._addAriaAndCollapsedClass([element], this._isShown(selected));
  1516. }
  1517. }
  1518. }
  1519. _getFirstLevelChildren(selector) {
  1520. const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent);
  1521. // remove children if greater depth
  1522. return SelectorEngine.find(selector, this._config.parent).filter(element => !children.includes(element));
  1523. }
  1524. _addAriaAndCollapsedClass(triggerArray, isOpen) {
  1525. if (!triggerArray.length) {
  1526. return;
  1527. }
  1528. for (const element of triggerArray) {
  1529. element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen);
  1530. element.setAttribute('aria-expanded', isOpen);
  1531. }
  1532. }
  1533. // Static
  1534. static jQueryInterface(config) {
  1535. const _config = {};
  1536. if (typeof config === 'string' && /show|hide/.test(config)) {
  1537. _config.toggle = false;
  1538. }
  1539. return this.each(function () {
  1540. const data = Collapse.getOrCreateInstance(this, _config);
  1541. if (typeof config === 'string') {
  1542. if (typeof data[config] === 'undefined') {
  1543. throw new TypeError(`No method named "${config}"`);
  1544. }
  1545. data[config]();
  1546. }
  1547. });
  1548. }
  1549. }
  1550. /**
  1551. * Data API implementation
  1552. */
  1553. EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, function (event) {
  1554. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  1555. if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') {
  1556. event.preventDefault();
  1557. }
  1558. for (const element of SelectorEngine.getMultipleElementsFromSelector(this)) {
  1559. Collapse.getOrCreateInstance(element, {
  1560. toggle: false
  1561. }).toggle();
  1562. }
  1563. });
  1564. /**
  1565. * jQuery
  1566. */
  1567. defineJQueryPlugin(Collapse);
  1568. /**
  1569. * --------------------------------------------------------------------------
  1570. * Bootstrap dropdown.js
  1571. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1572. * --------------------------------------------------------------------------
  1573. */
  1574. /**
  1575. * Constants
  1576. */
  1577. const NAME$a = 'dropdown';
  1578. const DATA_KEY$6 = 'bs.dropdown';
  1579. const EVENT_KEY$6 = `.${DATA_KEY$6}`;
  1580. const DATA_API_KEY$3 = '.data-api';
  1581. const ESCAPE_KEY$2 = 'Escape';
  1582. const TAB_KEY$1 = 'Tab';
  1583. const ARROW_UP_KEY$1 = 'ArrowUp';
  1584. const ARROW_DOWN_KEY$1 = 'ArrowDown';
  1585. const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button
  1586. const EVENT_HIDE$5 = `hide${EVENT_KEY$6}`;
  1587. const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$6}`;
  1588. const EVENT_SHOW$5 = `show${EVENT_KEY$6}`;
  1589. const EVENT_SHOWN$5 = `shown${EVENT_KEY$6}`;
  1590. const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`;
  1591. const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$6}${DATA_API_KEY$3}`;
  1592. const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$6}${DATA_API_KEY$3}`;
  1593. const CLASS_NAME_SHOW$6 = 'show';
  1594. const CLASS_NAME_DROPUP = 'dropup';
  1595. const CLASS_NAME_DROPEND = 'dropend';
  1596. const CLASS_NAME_DROPSTART = 'dropstart';
  1597. const CLASS_NAME_DROPUP_CENTER = 'dropup-center';
  1598. const CLASS_NAME_DROPDOWN_CENTER = 'dropdown-center';
  1599. const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)';
  1600. const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE$3}.${CLASS_NAME_SHOW$6}`;
  1601. const SELECTOR_MENU = '.dropdown-menu';
  1602. const SELECTOR_NAVBAR = '.navbar';
  1603. const SELECTOR_NAVBAR_NAV = '.navbar-nav';
  1604. const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  1605. const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start';
  1606. const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end';
  1607. const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start';
  1608. const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end';
  1609. const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start';
  1610. const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start';
  1611. const PLACEMENT_TOPCENTER = 'top';
  1612. const PLACEMENT_BOTTOMCENTER = 'bottom';
  1613. const Default$9 = {
  1614. autoClose: true,
  1615. boundary: 'clippingParents',
  1616. display: 'dynamic',
  1617. offset: [0, 2],
  1618. popperConfig: null,
  1619. reference: 'toggle'
  1620. };
  1621. const DefaultType$9 = {
  1622. autoClose: '(boolean|string)',
  1623. boundary: '(string|element)',
  1624. display: 'string',
  1625. offset: '(array|string|function)',
  1626. popperConfig: '(null|object|function)',
  1627. reference: '(string|element|object)'
  1628. };
  1629. /**
  1630. * Class definition
  1631. */
  1632. class Dropdown extends BaseComponent {
  1633. constructor(element, config) {
  1634. super(element, config);
  1635. this._popper = null;
  1636. this._parent = this._element.parentNode; // dropdown wrapper
  1637. // todo: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
  1638. this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU)[0] || SelectorEngine.findOne(SELECTOR_MENU, this._parent);
  1639. this._inNavbar = this._detectNavbar();
  1640. }
  1641. // Getters
  1642. static get Default() {
  1643. return Default$9;
  1644. }
  1645. static get DefaultType() {
  1646. return DefaultType$9;
  1647. }
  1648. static get NAME() {
  1649. return NAME$a;
  1650. }
  1651. // Public
  1652. toggle() {
  1653. return this._isShown() ? this.hide() : this.show();
  1654. }
  1655. show() {
  1656. if (isDisabled(this._element) || this._isShown()) {
  1657. return;
  1658. }
  1659. const relatedTarget = {
  1660. relatedTarget: this._element
  1661. };
  1662. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$5, relatedTarget);
  1663. if (showEvent.defaultPrevented) {
  1664. return;
  1665. }
  1666. this._createPopper();
  1667. // If this is a touch-enabled device we add extra
  1668. // empty mouseover listeners to the body's immediate children;
  1669. // only needed because of broken event delegation on iOS
  1670. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  1671. if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {
  1672. for (const element of [].concat(...document.body.children)) {
  1673. EventHandler.on(element, 'mouseover', noop);
  1674. }
  1675. }
  1676. this._element.focus();
  1677. this._element.setAttribute('aria-expanded', true);
  1678. this._menu.classList.add(CLASS_NAME_SHOW$6);
  1679. this._element.classList.add(CLASS_NAME_SHOW$6);
  1680. EventHandler.trigger(this._element, EVENT_SHOWN$5, relatedTarget);
  1681. }
  1682. hide() {
  1683. if (isDisabled(this._element) || !this._isShown()) {
  1684. return;
  1685. }
  1686. const relatedTarget = {
  1687. relatedTarget: this._element
  1688. };
  1689. this._completeHide(relatedTarget);
  1690. }
  1691. dispose() {
  1692. if (this._popper) {
  1693. this._popper.destroy();
  1694. }
  1695. super.dispose();
  1696. }
  1697. update() {
  1698. this._inNavbar = this._detectNavbar();
  1699. if (this._popper) {
  1700. this._popper.update();
  1701. }
  1702. }
  1703. // Private
  1704. _completeHide(relatedTarget) {
  1705. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$5, relatedTarget);
  1706. if (hideEvent.defaultPrevented) {
  1707. return;
  1708. }
  1709. // If this is a touch-enabled device we remove the extra
  1710. // empty mouseover listeners we added for iOS support
  1711. if ('ontouchstart' in document.documentElement) {
  1712. for (const element of [].concat(...document.body.children)) {
  1713. EventHandler.off(element, 'mouseover', noop);
  1714. }
  1715. }
  1716. if (this._popper) {
  1717. this._popper.destroy();
  1718. }
  1719. this._menu.classList.remove(CLASS_NAME_SHOW$6);
  1720. this._element.classList.remove(CLASS_NAME_SHOW$6);
  1721. this._element.setAttribute('aria-expanded', 'false');
  1722. Manipulator.removeDataAttribute(this._menu, 'popper');
  1723. EventHandler.trigger(this._element, EVENT_HIDDEN$5, relatedTarget);
  1724. }
  1725. _getConfig(config) {
  1726. config = super._getConfig(config);
  1727. if (typeof config.reference === 'object' && !isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
  1728. // Popper virtual elements require a getBoundingClientRect method
  1729. throw new TypeError(`${NAME$a.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
  1730. }
  1731. return config;
  1732. }
  1733. _createPopper() {
  1734. if (typeof Popper === 'undefined') {
  1735. throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
  1736. }
  1737. let referenceElement = this._element;
  1738. if (this._config.reference === 'parent') {
  1739. referenceElement = this._parent;
  1740. } else if (isElement(this._config.reference)) {
  1741. referenceElement = getElement(this._config.reference);
  1742. } else if (typeof this._config.reference === 'object') {
  1743. referenceElement = this._config.reference;
  1744. }
  1745. const popperConfig = this._getPopperConfig();
  1746. this._popper = Popper.createPopper(referenceElement, this._menu, popperConfig);
  1747. }
  1748. _isShown() {
  1749. return this._menu.classList.contains(CLASS_NAME_SHOW$6);
  1750. }
  1751. _getPlacement() {
  1752. const parentDropdown = this._parent;
  1753. if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
  1754. return PLACEMENT_RIGHT;
  1755. }
  1756. if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
  1757. return PLACEMENT_LEFT;
  1758. }
  1759. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) {
  1760. return PLACEMENT_TOPCENTER;
  1761. }
  1762. if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) {
  1763. return PLACEMENT_BOTTOMCENTER;
  1764. }
  1765. // We need to trim the value because custom properties can also include spaces
  1766. const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
  1767. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
  1768. return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
  1769. }
  1770. return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
  1771. }
  1772. _detectNavbar() {
  1773. return this._element.closest(SELECTOR_NAVBAR) !== null;
  1774. }
  1775. _getOffset() {
  1776. const {
  1777. offset
  1778. } = this._config;
  1779. if (typeof offset === 'string') {
  1780. return offset.split(',').map(value => Number.parseInt(value, 10));
  1781. }
  1782. if (typeof offset === 'function') {
  1783. return popperData => offset(popperData, this._element);
  1784. }
  1785. return offset;
  1786. }
  1787. _getPopperConfig() {
  1788. const defaultBsPopperConfig = {
  1789. placement: this._getPlacement(),
  1790. modifiers: [{
  1791. name: 'preventOverflow',
  1792. options: {
  1793. boundary: this._config.boundary
  1794. }
  1795. }, {
  1796. name: 'offset',
  1797. options: {
  1798. offset: this._getOffset()
  1799. }
  1800. }]
  1801. };
  1802. // Disable Popper if we have a static display or Dropdown is in Navbar
  1803. if (this._inNavbar || this._config.display === 'static') {
  1804. Manipulator.setDataAttribute(this._menu, 'popper', 'static'); // todo:v6 remove
  1805. defaultBsPopperConfig.modifiers = [{
  1806. name: 'applyStyles',
  1807. enabled: false
  1808. }];
  1809. }
  1810. return {
  1811. ...defaultBsPopperConfig,
  1812. ...execute(this._config.popperConfig, [defaultBsPopperConfig])
  1813. };
  1814. }
  1815. _selectMenuItem({
  1816. key,
  1817. target
  1818. }) {
  1819. const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => isVisible(element));
  1820. if (!items.length) {
  1821. return;
  1822. }
  1823. // if target isn't included in items (e.g. when expanding the dropdown)
  1824. // allow cycling to get the last item in case key equals ARROW_UP_KEY
  1825. getNextActiveElement(items, target, key === ARROW_DOWN_KEY$1, !items.includes(target)).focus();
  1826. }
  1827. // Static
  1828. static jQueryInterface(config) {
  1829. return this.each(function () {
  1830. const data = Dropdown.getOrCreateInstance(this, config);
  1831. if (typeof config !== 'string') {
  1832. return;
  1833. }
  1834. if (typeof data[config] === 'undefined') {
  1835. throw new TypeError(`No method named "${config}"`);
  1836. }
  1837. data[config]();
  1838. });
  1839. }
  1840. static clearMenus(event) {
  1841. if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY$1) {
  1842. return;
  1843. }
  1844. const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN);
  1845. for (const toggle of openToggles) {
  1846. const context = Dropdown.getInstance(toggle);
  1847. if (!context || context._config.autoClose === false) {
  1848. continue;
  1849. }
  1850. const composedPath = event.composedPath();
  1851. const isMenuTarget = composedPath.includes(context._menu);
  1852. if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) {
  1853. continue;
  1854. }
  1855. // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu
  1856. if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) {
  1857. continue;
  1858. }
  1859. const relatedTarget = {
  1860. relatedTarget: context._element
  1861. };
  1862. if (event.type === 'click') {
  1863. relatedTarget.clickEvent = event;
  1864. }
  1865. context._completeHide(relatedTarget);
  1866. }
  1867. }
  1868. static dataApiKeydownHandler(event) {
  1869. // If not an UP | DOWN | ESCAPE key => not a dropdown command
  1870. // If input/textarea && if key is other than ESCAPE => not a dropdown command
  1871. const isInput = /input|textarea/i.test(event.target.tagName);
  1872. const isEscapeEvent = event.key === ESCAPE_KEY$2;
  1873. const isUpOrDownEvent = [ARROW_UP_KEY$1, ARROW_DOWN_KEY$1].includes(event.key);
  1874. if (!isUpOrDownEvent && !isEscapeEvent) {
  1875. return;
  1876. }
  1877. if (isInput && !isEscapeEvent) {
  1878. return;
  1879. }
  1880. event.preventDefault();
  1881. // todo: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
  1882. const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE$3) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$3)[0] || SelectorEngine.next(this, SELECTOR_DATA_TOGGLE$3)[0] || SelectorEngine.findOne(SELECTOR_DATA_TOGGLE$3, event.delegateTarget.parentNode);
  1883. const instance = Dropdown.getOrCreateInstance(getToggleButton);
  1884. if (isUpOrDownEvent) {
  1885. event.stopPropagation();
  1886. instance.show();
  1887. instance._selectMenuItem(event);
  1888. return;
  1889. }
  1890. if (instance._isShown()) {
  1891. // else is escape and we check if it is shown
  1892. event.stopPropagation();
  1893. instance.hide();
  1894. getToggleButton.focus();
  1895. }
  1896. }
  1897. }
  1898. /**
  1899. * Data API implementation
  1900. */
  1901. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
  1902. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
  1903. EventHandler.on(document, EVENT_CLICK_DATA_API$3, Dropdown.clearMenus);
  1904. EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
  1905. EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, function (event) {
  1906. event.preventDefault();
  1907. Dropdown.getOrCreateInstance(this).toggle();
  1908. });
  1909. /**
  1910. * jQuery
  1911. */
  1912. defineJQueryPlugin(Dropdown);
  1913. /**
  1914. * --------------------------------------------------------------------------
  1915. * Bootstrap util/scrollBar.js
  1916. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1917. * --------------------------------------------------------------------------
  1918. */
  1919. /**
  1920. * Constants
  1921. */
  1922. const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  1923. const SELECTOR_STICKY_CONTENT = '.sticky-top';
  1924. const PROPERTY_PADDING = 'padding-right';
  1925. const PROPERTY_MARGIN = 'margin-right';
  1926. /**
  1927. * Class definition
  1928. */
  1929. class ScrollBarHelper {
  1930. constructor() {
  1931. this._element = document.body;
  1932. }
  1933. // Public
  1934. getWidth() {
  1935. // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
  1936. const documentWidth = document.documentElement.clientWidth;
  1937. return Math.abs(window.innerWidth - documentWidth);
  1938. }
  1939. hide() {
  1940. const width = this.getWidth();
  1941. this._disableOverFlow();
  1942. // give padding to element to balance the hidden scrollbar width
  1943. this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  1944. // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth
  1945. this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  1946. this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width);
  1947. }
  1948. reset() {
  1949. this._resetElementAttributes(this._element, 'overflow');
  1950. this._resetElementAttributes(this._element, PROPERTY_PADDING);
  1951. this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING);
  1952. this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN);
  1953. }
  1954. isOverflowing() {
  1955. return this.getWidth() > 0;
  1956. }
  1957. // Private
  1958. _disableOverFlow() {
  1959. this._saveInitialAttribute(this._element, 'overflow');
  1960. this._element.style.overflow = 'hidden';
  1961. }
  1962. _setElementAttributes(selector, styleProperty, callback) {
  1963. const scrollbarWidth = this.getWidth();
  1964. const manipulationCallBack = element => {
  1965. if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
  1966. return;
  1967. }
  1968. this._saveInitialAttribute(element, styleProperty);
  1969. const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty);
  1970. element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`);
  1971. };
  1972. this._applyManipulationCallback(selector, manipulationCallBack);
  1973. }
  1974. _saveInitialAttribute(element, styleProperty) {
  1975. const actualValue = element.style.getPropertyValue(styleProperty);
  1976. if (actualValue) {
  1977. Manipulator.setDataAttribute(element, styleProperty, actualValue);
  1978. }
  1979. }
  1980. _resetElementAttributes(selector, styleProperty) {
  1981. const manipulationCallBack = element => {
  1982. const value = Manipulator.getDataAttribute(element, styleProperty);
  1983. // We only want to remove the property if the value is `null`; the value can also be zero
  1984. if (value === null) {
  1985. element.style.removeProperty(styleProperty);
  1986. return;
  1987. }
  1988. Manipulator.removeDataAttribute(element, styleProperty);
  1989. element.style.setProperty(styleProperty, value);
  1990. };
  1991. this._applyManipulationCallback(selector, manipulationCallBack);
  1992. }
  1993. _applyManipulationCallback(selector, callBack) {
  1994. if (isElement(selector)) {
  1995. callBack(selector);
  1996. return;
  1997. }
  1998. for (const sel of SelectorEngine.find(selector, this._element)) {
  1999. callBack(sel);
  2000. }
  2001. }
  2002. }
  2003. /**
  2004. * --------------------------------------------------------------------------
  2005. * Bootstrap util/backdrop.js
  2006. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2007. * --------------------------------------------------------------------------
  2008. */
  2009. /**
  2010. * Constants
  2011. */
  2012. const NAME$9 = 'backdrop';
  2013. const CLASS_NAME_FADE$4 = 'fade';
  2014. const CLASS_NAME_SHOW$5 = 'show';
  2015. const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$9}`;
  2016. const Default$8 = {
  2017. className: 'modal-backdrop',
  2018. clickCallback: null,
  2019. isAnimated: false,
  2020. isVisible: true,
  2021. // if false, we use the backdrop helper without adding any element to the dom
  2022. rootElement: 'body' // give the choice to place backdrop under different elements
  2023. };
  2024. const DefaultType$8 = {
  2025. className: 'string',
  2026. clickCallback: '(function|null)',
  2027. isAnimated: 'boolean',
  2028. isVisible: 'boolean',
  2029. rootElement: '(element|string)'
  2030. };
  2031. /**
  2032. * Class definition
  2033. */
  2034. class Backdrop extends Config {
  2035. constructor(config) {
  2036. super();
  2037. this._config = this._getConfig(config);
  2038. this._isAppended = false;
  2039. this._element = null;
  2040. }
  2041. // Getters
  2042. static get Default() {
  2043. return Default$8;
  2044. }
  2045. static get DefaultType() {
  2046. return DefaultType$8;
  2047. }
  2048. static get NAME() {
  2049. return NAME$9;
  2050. }
  2051. // Public
  2052. show(callback) {
  2053. if (!this._config.isVisible) {
  2054. execute(callback);
  2055. return;
  2056. }
  2057. this._append();
  2058. const element = this._getElement();
  2059. if (this._config.isAnimated) {
  2060. reflow(element);
  2061. }
  2062. element.classList.add(CLASS_NAME_SHOW$5);
  2063. this._emulateAnimation(() => {
  2064. execute(callback);
  2065. });
  2066. }
  2067. hide(callback) {
  2068. if (!this._config.isVisible) {
  2069. execute(callback);
  2070. return;
  2071. }
  2072. this._getElement().classList.remove(CLASS_NAME_SHOW$5);
  2073. this._emulateAnimation(() => {
  2074. this.dispose();
  2075. execute(callback);
  2076. });
  2077. }
  2078. dispose() {
  2079. if (!this._isAppended) {
  2080. return;
  2081. }
  2082. EventHandler.off(this._element, EVENT_MOUSEDOWN);
  2083. this._element.remove();
  2084. this._isAppended = false;
  2085. }
  2086. // Private
  2087. _getElement() {
  2088. if (!this._element) {
  2089. const backdrop = document.createElement('div');
  2090. backdrop.className = this._config.className;
  2091. if (this._config.isAnimated) {
  2092. backdrop.classList.add(CLASS_NAME_FADE$4);
  2093. }
  2094. this._element = backdrop;
  2095. }
  2096. return this._element;
  2097. }
  2098. _configAfterMerge(config) {
  2099. // use getElement() with the default "body" to get a fresh Element on each instantiation
  2100. config.rootElement = getElement(config.rootElement);
  2101. return config;
  2102. }
  2103. _append() {
  2104. if (this._isAppended) {
  2105. return;
  2106. }
  2107. const element = this._getElement();
  2108. this._config.rootElement.append(element);
  2109. EventHandler.on(element, EVENT_MOUSEDOWN, () => {
  2110. execute(this._config.clickCallback);
  2111. });
  2112. this._isAppended = true;
  2113. }
  2114. _emulateAnimation(callback) {
  2115. executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
  2116. }
  2117. }
  2118. /**
  2119. * --------------------------------------------------------------------------
  2120. * Bootstrap util/focustrap.js
  2121. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2122. * --------------------------------------------------------------------------
  2123. */
  2124. /**
  2125. * Constants
  2126. */
  2127. const NAME$8 = 'focustrap';
  2128. const DATA_KEY$5 = 'bs.focustrap';
  2129. const EVENT_KEY$5 = `.${DATA_KEY$5}`;
  2130. const EVENT_FOCUSIN$2 = `focusin${EVENT_KEY$5}`;
  2131. const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$5}`;
  2132. const TAB_KEY = 'Tab';
  2133. const TAB_NAV_FORWARD = 'forward';
  2134. const TAB_NAV_BACKWARD = 'backward';
  2135. const Default$7 = {
  2136. autofocus: true,
  2137. trapElement: null // The element to trap focus inside of
  2138. };
  2139. const DefaultType$7 = {
  2140. autofocus: 'boolean',
  2141. trapElement: 'element'
  2142. };
  2143. /**
  2144. * Class definition
  2145. */
  2146. class FocusTrap extends Config {
  2147. constructor(config) {
  2148. super();
  2149. this._config = this._getConfig(config);
  2150. this._isActive = false;
  2151. this._lastTabNavDirection = null;
  2152. }
  2153. // Getters
  2154. static get Default() {
  2155. return Default$7;
  2156. }
  2157. static get DefaultType() {
  2158. return DefaultType$7;
  2159. }
  2160. static get NAME() {
  2161. return NAME$8;
  2162. }
  2163. // Public
  2164. activate() {
  2165. if (this._isActive) {
  2166. return;
  2167. }
  2168. if (this._config.autofocus) {
  2169. this._config.trapElement.focus();
  2170. }
  2171. EventHandler.off(document, EVENT_KEY$5); // guard against infinite focus loop
  2172. EventHandler.on(document, EVENT_FOCUSIN$2, event => this._handleFocusin(event));
  2173. EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
  2174. this._isActive = true;
  2175. }
  2176. deactivate() {
  2177. if (!this._isActive) {
  2178. return;
  2179. }
  2180. this._isActive = false;
  2181. EventHandler.off(document, EVENT_KEY$5);
  2182. }
  2183. // Private
  2184. _handleFocusin(event) {
  2185. const {
  2186. trapElement
  2187. } = this._config;
  2188. if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {
  2189. return;
  2190. }
  2191. const elements = SelectorEngine.focusableChildren(trapElement);
  2192. if (elements.length === 0) {
  2193. trapElement.focus();
  2194. } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
  2195. elements[elements.length - 1].focus();
  2196. } else {
  2197. elements[0].focus();
  2198. }
  2199. }
  2200. _handleKeydown(event) {
  2201. if (event.key !== TAB_KEY) {
  2202. return;
  2203. }
  2204. this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
  2205. }
  2206. }
  2207. /**
  2208. * --------------------------------------------------------------------------
  2209. * Bootstrap modal.js
  2210. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2211. * --------------------------------------------------------------------------
  2212. */
  2213. /**
  2214. * Constants
  2215. */
  2216. const NAME$7 = 'modal';
  2217. const DATA_KEY$4 = 'bs.modal';
  2218. const EVENT_KEY$4 = `.${DATA_KEY$4}`;
  2219. const DATA_API_KEY$2 = '.data-api';
  2220. const ESCAPE_KEY$1 = 'Escape';
  2221. const EVENT_HIDE$4 = `hide${EVENT_KEY$4}`;
  2222. const EVENT_HIDE_PREVENTED$1 = `hidePrevented${EVENT_KEY$4}`;
  2223. const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$4}`;
  2224. const EVENT_SHOW$4 = `show${EVENT_KEY$4}`;
  2225. const EVENT_SHOWN$4 = `shown${EVENT_KEY$4}`;
  2226. const EVENT_RESIZE$1 = `resize${EVENT_KEY$4}`;
  2227. const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$4}`;
  2228. const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$4}`;
  2229. const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$4}`;
  2230. const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$4}${DATA_API_KEY$2}`;
  2231. const CLASS_NAME_OPEN = 'modal-open';
  2232. const CLASS_NAME_FADE$3 = 'fade';
  2233. const CLASS_NAME_SHOW$4 = 'show';
  2234. const CLASS_NAME_STATIC = 'modal-static';
  2235. const OPEN_SELECTOR$1 = '.modal.show';
  2236. const SELECTOR_DIALOG = '.modal-dialog';
  2237. const SELECTOR_MODAL_BODY = '.modal-body';
  2238. const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]';
  2239. const Default$6 = {
  2240. backdrop: true,
  2241. focus: true,
  2242. keyboard: true
  2243. };
  2244. const DefaultType$6 = {
  2245. backdrop: '(boolean|string)',
  2246. focus: 'boolean',
  2247. keyboard: 'boolean'
  2248. };
  2249. /**
  2250. * Class definition
  2251. */
  2252. class Modal extends BaseComponent {
  2253. constructor(element, config) {
  2254. super(element, config);
  2255. this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element);
  2256. this._backdrop = this._initializeBackDrop();
  2257. this._focustrap = this._initializeFocusTrap();
  2258. this._isShown = false;
  2259. this._isTransitioning = false;
  2260. this._scrollBar = new ScrollBarHelper();
  2261. this._addEventListeners();
  2262. }
  2263. // Getters
  2264. static get Default() {
  2265. return Default$6;
  2266. }
  2267. static get DefaultType() {
  2268. return DefaultType$6;
  2269. }
  2270. static get NAME() {
  2271. return NAME$7;
  2272. }
  2273. // Public
  2274. toggle(relatedTarget) {
  2275. return this._isShown ? this.hide() : this.show(relatedTarget);
  2276. }
  2277. show(relatedTarget) {
  2278. if (this._isShown || this._isTransitioning) {
  2279. return;
  2280. }
  2281. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, {
  2282. relatedTarget
  2283. });
  2284. if (showEvent.defaultPrevented) {
  2285. return;
  2286. }
  2287. this._isShown = true;
  2288. this._isTransitioning = true;
  2289. this._scrollBar.hide();
  2290. document.body.classList.add(CLASS_NAME_OPEN);
  2291. this._adjustDialog();
  2292. this._backdrop.show(() => this._showElement(relatedTarget));
  2293. }
  2294. hide() {
  2295. if (!this._isShown || this._isTransitioning) {
  2296. return;
  2297. }
  2298. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4);
  2299. if (hideEvent.defaultPrevented) {
  2300. return;
  2301. }
  2302. this._isShown = false;
  2303. this._isTransitioning = true;
  2304. this._focustrap.deactivate();
  2305. this._element.classList.remove(CLASS_NAME_SHOW$4);
  2306. this._queueCallback(() => this._hideModal(), this._element, this._isAnimated());
  2307. }
  2308. dispose() {
  2309. for (const htmlElement of [window, this._dialog]) {
  2310. EventHandler.off(htmlElement, EVENT_KEY$4);
  2311. }
  2312. this._backdrop.dispose();
  2313. this._focustrap.deactivate();
  2314. super.dispose();
  2315. }
  2316. handleUpdate() {
  2317. this._adjustDialog();
  2318. }
  2319. // Private
  2320. _initializeBackDrop() {
  2321. return new Backdrop({
  2322. isVisible: Boolean(this._config.backdrop),
  2323. // 'static' option will be translated to true, and booleans will keep their value,
  2324. isAnimated: this._isAnimated()
  2325. });
  2326. }
  2327. _initializeFocusTrap() {
  2328. return new FocusTrap({
  2329. trapElement: this._element
  2330. });
  2331. }
  2332. _showElement(relatedTarget) {
  2333. // try to append dynamic modal
  2334. if (!document.body.contains(this._element)) {
  2335. document.body.append(this._element);
  2336. }
  2337. this._element.style.display = 'block';
  2338. this._element.removeAttribute('aria-hidden');
  2339. this._element.setAttribute('aria-modal', true);
  2340. this._element.setAttribute('role', 'dialog');
  2341. this._element.scrollTop = 0;
  2342. const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
  2343. if (modalBody) {
  2344. modalBody.scrollTop = 0;
  2345. }
  2346. reflow(this._element);
  2347. this._element.classList.add(CLASS_NAME_SHOW$4);
  2348. const transitionComplete = () => {
  2349. if (this._config.focus) {
  2350. this._focustrap.activate();
  2351. }
  2352. this._isTransitioning = false;
  2353. EventHandler.trigger(this._element, EVENT_SHOWN$4, {
  2354. relatedTarget
  2355. });
  2356. };
  2357. this._queueCallback(transitionComplete, this._dialog, this._isAnimated());
  2358. }
  2359. _addEventListeners() {
  2360. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => {
  2361. if (event.key !== ESCAPE_KEY$1) {
  2362. return;
  2363. }
  2364. if (this._config.keyboard) {
  2365. this.hide();
  2366. return;
  2367. }
  2368. this._triggerBackdropTransition();
  2369. });
  2370. EventHandler.on(window, EVENT_RESIZE$1, () => {
  2371. if (this._isShown && !this._isTransitioning) {
  2372. this._adjustDialog();
  2373. }
  2374. });
  2375. EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => {
  2376. // a bad trick to segregate clicks that may start inside dialog but end outside, and avoid listen to scrollbar clicks
  2377. EventHandler.one(this._element, EVENT_CLICK_DISMISS, event2 => {
  2378. if (this._element !== event.target || this._element !== event2.target) {
  2379. return;
  2380. }
  2381. if (this._config.backdrop === 'static') {
  2382. this._triggerBackdropTransition();
  2383. return;
  2384. }
  2385. if (this._config.backdrop) {
  2386. this.hide();
  2387. }
  2388. });
  2389. });
  2390. }
  2391. _hideModal() {
  2392. this._element.style.display = 'none';
  2393. this._element.setAttribute('aria-hidden', true);
  2394. this._element.removeAttribute('aria-modal');
  2395. this._element.removeAttribute('role');
  2396. this._isTransitioning = false;
  2397. this._backdrop.hide(() => {
  2398. document.body.classList.remove(CLASS_NAME_OPEN);
  2399. this._resetAdjustments();
  2400. this._scrollBar.reset();
  2401. EventHandler.trigger(this._element, EVENT_HIDDEN$4);
  2402. });
  2403. }
  2404. _isAnimated() {
  2405. return this._element.classList.contains(CLASS_NAME_FADE$3);
  2406. }
  2407. _triggerBackdropTransition() {
  2408. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED$1);
  2409. if (hideEvent.defaultPrevented) {
  2410. return;
  2411. }
  2412. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  2413. const initialOverflowY = this._element.style.overflowY;
  2414. // return if the following background transition hasn't yet completed
  2415. if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) {
  2416. return;
  2417. }
  2418. if (!isModalOverflowing) {
  2419. this._element.style.overflowY = 'hidden';
  2420. }
  2421. this._element.classList.add(CLASS_NAME_STATIC);
  2422. this._queueCallback(() => {
  2423. this._element.classList.remove(CLASS_NAME_STATIC);
  2424. this._queueCallback(() => {
  2425. this._element.style.overflowY = initialOverflowY;
  2426. }, this._dialog);
  2427. }, this._dialog);
  2428. this._element.focus();
  2429. }
  2430. /**
  2431. * The following methods are used to handle overflowing modals
  2432. */
  2433. _adjustDialog() {
  2434. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  2435. const scrollbarWidth = this._scrollBar.getWidth();
  2436. const isBodyOverflowing = scrollbarWidth > 0;
  2437. if (isBodyOverflowing && !isModalOverflowing) {
  2438. const property = isRTL() ? 'paddingLeft' : 'paddingRight';
  2439. this._element.style[property] = `${scrollbarWidth}px`;
  2440. }
  2441. if (!isBodyOverflowing && isModalOverflowing) {
  2442. const property = isRTL() ? 'paddingRight' : 'paddingLeft';
  2443. this._element.style[property] = `${scrollbarWidth}px`;
  2444. }
  2445. }
  2446. _resetAdjustments() {
  2447. this._element.style.paddingLeft = '';
  2448. this._element.style.paddingRight = '';
  2449. }
  2450. // Static
  2451. static jQueryInterface(config, relatedTarget) {
  2452. return this.each(function () {
  2453. const data = Modal.getOrCreateInstance(this, config);
  2454. if (typeof config !== 'string') {
  2455. return;
  2456. }
  2457. if (typeof data[config] === 'undefined') {
  2458. throw new TypeError(`No method named "${config}"`);
  2459. }
  2460. data[config](relatedTarget);
  2461. });
  2462. }
  2463. }
  2464. /**
  2465. * Data API implementation
  2466. */
  2467. EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, function (event) {
  2468. const target = SelectorEngine.getElementFromSelector(this);
  2469. if (['A', 'AREA'].includes(this.tagName)) {
  2470. event.preventDefault();
  2471. }
  2472. EventHandler.one(target, EVENT_SHOW$4, showEvent => {
  2473. if (showEvent.defaultPrevented) {
  2474. // only register focus restorer if modal will actually get shown
  2475. return;
  2476. }
  2477. EventHandler.one(target, EVENT_HIDDEN$4, () => {
  2478. if (isVisible(this)) {
  2479. this.focus();
  2480. }
  2481. });
  2482. });
  2483. // avoid conflict when clicking modal toggler while another one is open
  2484. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1);
  2485. if (alreadyOpen) {
  2486. Modal.getInstance(alreadyOpen).hide();
  2487. }
  2488. const data = Modal.getOrCreateInstance(target);
  2489. data.toggle(this);
  2490. });
  2491. enableDismissTrigger(Modal);
  2492. /**
  2493. * jQuery
  2494. */
  2495. defineJQueryPlugin(Modal);
  2496. /**
  2497. * --------------------------------------------------------------------------
  2498. * Bootstrap offcanvas.js
  2499. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2500. * --------------------------------------------------------------------------
  2501. */
  2502. /**
  2503. * Constants
  2504. */
  2505. const NAME$6 = 'offcanvas';
  2506. const DATA_KEY$3 = 'bs.offcanvas';
  2507. const EVENT_KEY$3 = `.${DATA_KEY$3}`;
  2508. const DATA_API_KEY$1 = '.data-api';
  2509. const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$3}${DATA_API_KEY$1}`;
  2510. const ESCAPE_KEY = 'Escape';
  2511. const CLASS_NAME_SHOW$3 = 'show';
  2512. const CLASS_NAME_SHOWING$1 = 'showing';
  2513. const CLASS_NAME_HIDING = 'hiding';
  2514. const CLASS_NAME_BACKDROP = 'offcanvas-backdrop';
  2515. const OPEN_SELECTOR = '.offcanvas.show';
  2516. const EVENT_SHOW$3 = `show${EVENT_KEY$3}`;
  2517. const EVENT_SHOWN$3 = `shown${EVENT_KEY$3}`;
  2518. const EVENT_HIDE$3 = `hide${EVENT_KEY$3}`;
  2519. const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$3}`;
  2520. const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$3}`;
  2521. const EVENT_RESIZE = `resize${EVENT_KEY$3}`;
  2522. const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$3}${DATA_API_KEY$1}`;
  2523. const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$3}`;
  2524. const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]';
  2525. const Default$5 = {
  2526. backdrop: true,
  2527. keyboard: true,
  2528. scroll: false
  2529. };
  2530. const DefaultType$5 = {
  2531. backdrop: '(boolean|string)',
  2532. keyboard: 'boolean',
  2533. scroll: 'boolean'
  2534. };
  2535. /**
  2536. * Class definition
  2537. */
  2538. class Offcanvas extends BaseComponent {
  2539. constructor(element, config) {
  2540. super(element, config);
  2541. this._isShown = false;
  2542. this._backdrop = this._initializeBackDrop();
  2543. this._focustrap = this._initializeFocusTrap();
  2544. this._addEventListeners();
  2545. }
  2546. // Getters
  2547. static get Default() {
  2548. return Default$5;
  2549. }
  2550. static get DefaultType() {
  2551. return DefaultType$5;
  2552. }
  2553. static get NAME() {
  2554. return NAME$6;
  2555. }
  2556. // Public
  2557. toggle(relatedTarget) {
  2558. return this._isShown ? this.hide() : this.show(relatedTarget);
  2559. }
  2560. show(relatedTarget) {
  2561. if (this._isShown) {
  2562. return;
  2563. }
  2564. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, {
  2565. relatedTarget
  2566. });
  2567. if (showEvent.defaultPrevented) {
  2568. return;
  2569. }
  2570. this._isShown = true;
  2571. this._backdrop.show();
  2572. if (!this._config.scroll) {
  2573. new ScrollBarHelper().hide();
  2574. }
  2575. this._element.setAttribute('aria-modal', true);
  2576. this._element.setAttribute('role', 'dialog');
  2577. this._element.classList.add(CLASS_NAME_SHOWING$1);
  2578. const completeCallBack = () => {
  2579. if (!this._config.scroll || this._config.backdrop) {
  2580. this._focustrap.activate();
  2581. }
  2582. this._element.classList.add(CLASS_NAME_SHOW$3);
  2583. this._element.classList.remove(CLASS_NAME_SHOWING$1);
  2584. EventHandler.trigger(this._element, EVENT_SHOWN$3, {
  2585. relatedTarget
  2586. });
  2587. };
  2588. this._queueCallback(completeCallBack, this._element, true);
  2589. }
  2590. hide() {
  2591. if (!this._isShown) {
  2592. return;
  2593. }
  2594. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3);
  2595. if (hideEvent.defaultPrevented) {
  2596. return;
  2597. }
  2598. this._focustrap.deactivate();
  2599. this._element.blur();
  2600. this._isShown = false;
  2601. this._element.classList.add(CLASS_NAME_HIDING);
  2602. this._backdrop.hide();
  2603. const completeCallback = () => {
  2604. this._element.classList.remove(CLASS_NAME_SHOW$3, CLASS_NAME_HIDING);
  2605. this._element.removeAttribute('aria-modal');
  2606. this._element.removeAttribute('role');
  2607. if (!this._config.scroll) {
  2608. new ScrollBarHelper().reset();
  2609. }
  2610. EventHandler.trigger(this._element, EVENT_HIDDEN$3);
  2611. };
  2612. this._queueCallback(completeCallback, this._element, true);
  2613. }
  2614. dispose() {
  2615. this._backdrop.dispose();
  2616. this._focustrap.deactivate();
  2617. super.dispose();
  2618. }
  2619. // Private
  2620. _initializeBackDrop() {
  2621. const clickCallback = () => {
  2622. if (this._config.backdrop === 'static') {
  2623. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  2624. return;
  2625. }
  2626. this.hide();
  2627. };
  2628. // 'static' option will be translated to true, and booleans will keep their value
  2629. const isVisible = Boolean(this._config.backdrop);
  2630. return new Backdrop({
  2631. className: CLASS_NAME_BACKDROP,
  2632. isVisible,
  2633. isAnimated: true,
  2634. rootElement: this._element.parentNode,
  2635. clickCallback: isVisible ? clickCallback : null
  2636. });
  2637. }
  2638. _initializeFocusTrap() {
  2639. return new FocusTrap({
  2640. trapElement: this._element
  2641. });
  2642. }
  2643. _addEventListeners() {
  2644. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
  2645. if (event.key !== ESCAPE_KEY) {
  2646. return;
  2647. }
  2648. if (this._config.keyboard) {
  2649. this.hide();
  2650. return;
  2651. }
  2652. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  2653. });
  2654. }
  2655. // Static
  2656. static jQueryInterface(config) {
  2657. return this.each(function () {
  2658. const data = Offcanvas.getOrCreateInstance(this, config);
  2659. if (typeof config !== 'string') {
  2660. return;
  2661. }
  2662. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  2663. throw new TypeError(`No method named "${config}"`);
  2664. }
  2665. data[config](this);
  2666. });
  2667. }
  2668. }
  2669. /**
  2670. * Data API implementation
  2671. */
  2672. EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, function (event) {
  2673. const target = SelectorEngine.getElementFromSelector(this);
  2674. if (['A', 'AREA'].includes(this.tagName)) {
  2675. event.preventDefault();
  2676. }
  2677. if (isDisabled(this)) {
  2678. return;
  2679. }
  2680. EventHandler.one(target, EVENT_HIDDEN$3, () => {
  2681. // focus on trigger when it is closed
  2682. if (isVisible(this)) {
  2683. this.focus();
  2684. }
  2685. });
  2686. // avoid conflict when clicking a toggler of an offcanvas, while another is open
  2687. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR);
  2688. if (alreadyOpen && alreadyOpen !== target) {
  2689. Offcanvas.getInstance(alreadyOpen).hide();
  2690. }
  2691. const data = Offcanvas.getOrCreateInstance(target);
  2692. data.toggle(this);
  2693. });
  2694. EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
  2695. for (const selector of SelectorEngine.find(OPEN_SELECTOR)) {
  2696. Offcanvas.getOrCreateInstance(selector).show();
  2697. }
  2698. });
  2699. EventHandler.on(window, EVENT_RESIZE, () => {
  2700. for (const element of SelectorEngine.find('[aria-modal][class*=show][class*=offcanvas-]')) {
  2701. if (getComputedStyle(element).position !== 'fixed') {
  2702. Offcanvas.getOrCreateInstance(element).hide();
  2703. }
  2704. }
  2705. });
  2706. enableDismissTrigger(Offcanvas);
  2707. /**
  2708. * jQuery
  2709. */
  2710. defineJQueryPlugin(Offcanvas);
  2711. /**
  2712. * --------------------------------------------------------------------------
  2713. * Bootstrap util/sanitizer.js
  2714. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2715. * --------------------------------------------------------------------------
  2716. */
  2717. const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
  2718. const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  2719. /**
  2720. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  2721. *
  2722. * Shout-out to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
  2723. */
  2724. const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i;
  2725. /**
  2726. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  2727. *
  2728. * Shout-out to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
  2729. */
  2730. const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i;
  2731. const allowedAttribute = (attribute, allowedAttributeList) => {
  2732. const attributeName = attribute.nodeName.toLowerCase();
  2733. if (allowedAttributeList.includes(attributeName)) {
  2734. if (uriAttributes.has(attributeName)) {
  2735. return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue) || DATA_URL_PATTERN.test(attribute.nodeValue));
  2736. }
  2737. return true;
  2738. }
  2739. // Check if a regular expression validates the attribute.
  2740. return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp).some(regex => regex.test(attributeName));
  2741. };
  2742. const DefaultAllowlist = {
  2743. // Global attributes allowed on any supplied element below.
  2744. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  2745. a: ['target', 'href', 'title', 'rel'],
  2746. area: [],
  2747. b: [],
  2748. br: [],
  2749. col: [],
  2750. code: [],
  2751. div: [],
  2752. em: [],
  2753. hr: [],
  2754. h1: [],
  2755. h2: [],
  2756. h3: [],
  2757. h4: [],
  2758. h5: [],
  2759. h6: [],
  2760. i: [],
  2761. img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
  2762. li: [],
  2763. ol: [],
  2764. p: [],
  2765. pre: [],
  2766. s: [],
  2767. small: [],
  2768. span: [],
  2769. sub: [],
  2770. sup: [],
  2771. strong: [],
  2772. u: [],
  2773. ul: []
  2774. };
  2775. function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {
  2776. if (!unsafeHtml.length) {
  2777. return unsafeHtml;
  2778. }
  2779. if (sanitizeFunction && typeof sanitizeFunction === 'function') {
  2780. return sanitizeFunction(unsafeHtml);
  2781. }
  2782. const domParser = new window.DOMParser();
  2783. const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  2784. const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
  2785. for (const element of elements) {
  2786. const elementName = element.nodeName.toLowerCase();
  2787. if (!Object.keys(allowList).includes(elementName)) {
  2788. element.remove();
  2789. continue;
  2790. }
  2791. const attributeList = [].concat(...element.attributes);
  2792. const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []);
  2793. for (const attribute of attributeList) {
  2794. if (!allowedAttribute(attribute, allowedAttributes)) {
  2795. element.removeAttribute(attribute.nodeName);
  2796. }
  2797. }
  2798. }
  2799. return createdDocument.body.innerHTML;
  2800. }
  2801. /**
  2802. * --------------------------------------------------------------------------
  2803. * Bootstrap util/template-factory.js
  2804. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2805. * --------------------------------------------------------------------------
  2806. */
  2807. /**
  2808. * Constants
  2809. */
  2810. const NAME$5 = 'TemplateFactory';
  2811. const Default$4 = {
  2812. allowList: DefaultAllowlist,
  2813. content: {},
  2814. // { selector : text , selector2 : text2 , }
  2815. extraClass: '',
  2816. html: false,
  2817. sanitize: true,
  2818. sanitizeFn: null,
  2819. template: '<div></div>'
  2820. };
  2821. const DefaultType$4 = {
  2822. allowList: 'object',
  2823. content: 'object',
  2824. extraClass: '(string|function)',
  2825. html: 'boolean',
  2826. sanitize: 'boolean',
  2827. sanitizeFn: '(null|function)',
  2828. template: 'string'
  2829. };
  2830. const DefaultContentType = {
  2831. entry: '(string|element|function|null)',
  2832. selector: '(string|element)'
  2833. };
  2834. /**
  2835. * Class definition
  2836. */
  2837. class TemplateFactory extends Config {
  2838. constructor(config) {
  2839. super();
  2840. this._config = this._getConfig(config);
  2841. }
  2842. // Getters
  2843. static get Default() {
  2844. return Default$4;
  2845. }
  2846. static get DefaultType() {
  2847. return DefaultType$4;
  2848. }
  2849. static get NAME() {
  2850. return NAME$5;
  2851. }
  2852. // Public
  2853. getContent() {
  2854. return Object.values(this._config.content).map(config => this._resolvePossibleFunction(config)).filter(Boolean);
  2855. }
  2856. hasContent() {
  2857. return this.getContent().length > 0;
  2858. }
  2859. changeContent(content) {
  2860. this._checkContent(content);
  2861. this._config.content = {
  2862. ...this._config.content,
  2863. ...content
  2864. };
  2865. return this;
  2866. }
  2867. toHtml() {
  2868. const templateWrapper = document.createElement('div');
  2869. templateWrapper.innerHTML = this._maybeSanitize(this._config.template);
  2870. for (const [selector, text] of Object.entries(this._config.content)) {
  2871. this._setContent(templateWrapper, text, selector);
  2872. }
  2873. const template = templateWrapper.children[0];
  2874. const extraClass = this._resolvePossibleFunction(this._config.extraClass);
  2875. if (extraClass) {
  2876. template.classList.add(...extraClass.split(' '));
  2877. }
  2878. return template;
  2879. }
  2880. // Private
  2881. _typeCheckConfig(config) {
  2882. super._typeCheckConfig(config);
  2883. this._checkContent(config.content);
  2884. }
  2885. _checkContent(arg) {
  2886. for (const [selector, content] of Object.entries(arg)) {
  2887. super._typeCheckConfig({
  2888. selector,
  2889. entry: content
  2890. }, DefaultContentType);
  2891. }
  2892. }
  2893. _setContent(template, content, selector) {
  2894. const templateElement = SelectorEngine.findOne(selector, template);
  2895. if (!templateElement) {
  2896. return;
  2897. }
  2898. content = this._resolvePossibleFunction(content);
  2899. if (!content) {
  2900. templateElement.remove();
  2901. return;
  2902. }
  2903. if (isElement(content)) {
  2904. this._putElementInTemplate(getElement(content), templateElement);
  2905. return;
  2906. }
  2907. if (this._config.html) {
  2908. templateElement.innerHTML = this._maybeSanitize(content);
  2909. return;
  2910. }
  2911. templateElement.textContent = content;
  2912. }
  2913. _maybeSanitize(arg) {
  2914. return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
  2915. }
  2916. _resolvePossibleFunction(arg) {
  2917. return execute(arg, [this]);
  2918. }
  2919. _putElementInTemplate(element, templateElement) {
  2920. if (this._config.html) {
  2921. templateElement.innerHTML = '';
  2922. templateElement.append(element);
  2923. return;
  2924. }
  2925. templateElement.textContent = element.textContent;
  2926. }
  2927. }
  2928. /**
  2929. * --------------------------------------------------------------------------
  2930. * Bootstrap tooltip.js
  2931. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2932. * --------------------------------------------------------------------------
  2933. */
  2934. /**
  2935. * Constants
  2936. */
  2937. const NAME$4 = 'tooltip';
  2938. const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
  2939. const CLASS_NAME_FADE$2 = 'fade';
  2940. const CLASS_NAME_MODAL = 'modal';
  2941. const CLASS_NAME_SHOW$2 = 'show';
  2942. const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
  2943. const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
  2944. const EVENT_MODAL_HIDE = 'hide.bs.modal';
  2945. const TRIGGER_HOVER = 'hover';
  2946. const TRIGGER_FOCUS = 'focus';
  2947. const TRIGGER_CLICK = 'click';
  2948. const TRIGGER_MANUAL = 'manual';
  2949. const EVENT_HIDE$2 = 'hide';
  2950. const EVENT_HIDDEN$2 = 'hidden';
  2951. const EVENT_SHOW$2 = 'show';
  2952. const EVENT_SHOWN$2 = 'shown';
  2953. const EVENT_INSERTED = 'inserted';
  2954. const EVENT_CLICK$1 = 'click';
  2955. const EVENT_FOCUSIN$1 = 'focusin';
  2956. const EVENT_FOCUSOUT$1 = 'focusout';
  2957. const EVENT_MOUSEENTER = 'mouseenter';
  2958. const EVENT_MOUSELEAVE = 'mouseleave';
  2959. const AttachmentMap = {
  2960. AUTO: 'auto',
  2961. TOP: 'top',
  2962. RIGHT: isRTL() ? 'left' : 'right',
  2963. BOTTOM: 'bottom',
  2964. LEFT: isRTL() ? 'right' : 'left'
  2965. };
  2966. const Default$3 = {
  2967. allowList: DefaultAllowlist,
  2968. animation: true,
  2969. boundary: 'clippingParents',
  2970. container: false,
  2971. customClass: '',
  2972. delay: 0,
  2973. fallbackPlacements: ['top', 'right', 'bottom', 'left'],
  2974. html: false,
  2975. offset: [0, 0],
  2976. placement: 'top',
  2977. popperConfig: null,
  2978. sanitize: true,
  2979. sanitizeFn: null,
  2980. selector: false,
  2981. template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>',
  2982. title: '',
  2983. trigger: 'hover focus'
  2984. };
  2985. const DefaultType$3 = {
  2986. allowList: 'object',
  2987. animation: 'boolean',
  2988. boundary: '(string|element)',
  2989. container: '(string|element|boolean)',
  2990. customClass: '(string|function)',
  2991. delay: '(number|object)',
  2992. fallbackPlacements: 'array',
  2993. html: 'boolean',
  2994. offset: '(array|string|function)',
  2995. placement: '(string|function)',
  2996. popperConfig: '(null|object|function)',
  2997. sanitize: 'boolean',
  2998. sanitizeFn: '(null|function)',
  2999. selector: '(string|boolean)',
  3000. template: 'string',
  3001. title: '(string|element|function)',
  3002. trigger: 'string'
  3003. };
  3004. /**
  3005. * Class definition
  3006. */
  3007. class Tooltip extends BaseComponent {
  3008. constructor(element, config) {
  3009. if (typeof Popper === 'undefined') {
  3010. throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
  3011. }
  3012. super(element, config);
  3013. // Private
  3014. this._isEnabled = true;
  3015. this._timeout = 0;
  3016. this._isHovered = null;
  3017. this._activeTrigger = {};
  3018. this._popper = null;
  3019. this._templateFactory = null;
  3020. this._newContent = null;
  3021. // Protected
  3022. this.tip = null;
  3023. this._setListeners();
  3024. if (!this._config.selector) {
  3025. this._fixTitle();
  3026. }
  3027. }
  3028. // Getters
  3029. static get Default() {
  3030. return Default$3;
  3031. }
  3032. static get DefaultType() {
  3033. return DefaultType$3;
  3034. }
  3035. static get NAME() {
  3036. return NAME$4;
  3037. }
  3038. // Public
  3039. enable() {
  3040. this._isEnabled = true;
  3041. }
  3042. disable() {
  3043. this._isEnabled = false;
  3044. }
  3045. toggleEnabled() {
  3046. this._isEnabled = !this._isEnabled;
  3047. }
  3048. toggle() {
  3049. if (!this._isEnabled) {
  3050. return;
  3051. }
  3052. this._activeTrigger.click = !this._activeTrigger.click;
  3053. if (this._isShown()) {
  3054. this._leave();
  3055. return;
  3056. }
  3057. this._enter();
  3058. }
  3059. dispose() {
  3060. clearTimeout(this._timeout);
  3061. EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  3062. if (this._element.getAttribute('data-bs-original-title')) {
  3063. this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'));
  3064. }
  3065. this._disposePopper();
  3066. super.dispose();
  3067. }
  3068. show() {
  3069. if (this._element.style.display === 'none') {
  3070. throw new Error('Please use show on visible elements');
  3071. }
  3072. if (!(this._isWithContent() && this._isEnabled)) {
  3073. return;
  3074. }
  3075. const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW$2));
  3076. const shadowRoot = findShadowRoot(this._element);
  3077. const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element);
  3078. if (showEvent.defaultPrevented || !isInTheDom) {
  3079. return;
  3080. }
  3081. // todo v6 remove this OR make it optional
  3082. this._disposePopper();
  3083. const tip = this._getTipElement();
  3084. this._element.setAttribute('aria-describedby', tip.getAttribute('id'));
  3085. const {
  3086. container
  3087. } = this._config;
  3088. if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
  3089. container.append(tip);
  3090. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
  3091. }
  3092. this._popper = this._createPopper(tip);
  3093. tip.classList.add(CLASS_NAME_SHOW$2);
  3094. // If this is a touch-enabled device we add extra
  3095. // empty mouseover listeners to the body's immediate children;
  3096. // only needed because of broken event delegation on iOS
  3097. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3098. if ('ontouchstart' in document.documentElement) {
  3099. for (const element of [].concat(...document.body.children)) {
  3100. EventHandler.on(element, 'mouseover', noop);
  3101. }
  3102. }
  3103. const complete = () => {
  3104. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN$2));
  3105. if (this._isHovered === false) {
  3106. this._leave();
  3107. }
  3108. this._isHovered = false;
  3109. };
  3110. this._queueCallback(complete, this.tip, this._isAnimated());
  3111. }
  3112. hide() {
  3113. if (!this._isShown()) {
  3114. return;
  3115. }
  3116. const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE$2));
  3117. if (hideEvent.defaultPrevented) {
  3118. return;
  3119. }
  3120. const tip = this._getTipElement();
  3121. tip.classList.remove(CLASS_NAME_SHOW$2);
  3122. // If this is a touch-enabled device we remove the extra
  3123. // empty mouseover listeners we added for iOS support
  3124. if ('ontouchstart' in document.documentElement) {
  3125. for (const element of [].concat(...document.body.children)) {
  3126. EventHandler.off(element, 'mouseover', noop);
  3127. }
  3128. }
  3129. this._activeTrigger[TRIGGER_CLICK] = false;
  3130. this._activeTrigger[TRIGGER_FOCUS] = false;
  3131. this._activeTrigger[TRIGGER_HOVER] = false;
  3132. this._isHovered = null; // it is a trick to support manual triggering
  3133. const complete = () => {
  3134. if (this._isWithActiveTrigger()) {
  3135. return;
  3136. }
  3137. if (!this._isHovered) {
  3138. this._disposePopper();
  3139. }
  3140. this._element.removeAttribute('aria-describedby');
  3141. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN$2));
  3142. };
  3143. this._queueCallback(complete, this.tip, this._isAnimated());
  3144. }
  3145. update() {
  3146. if (this._popper) {
  3147. this._popper.update();
  3148. }
  3149. }
  3150. // Protected
  3151. _isWithContent() {
  3152. return Boolean(this._getTitle());
  3153. }
  3154. _getTipElement() {
  3155. if (!this.tip) {
  3156. this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
  3157. }
  3158. return this.tip;
  3159. }
  3160. _createTipElement(content) {
  3161. const tip = this._getTemplateFactory(content).toHtml();
  3162. // todo: remove this check on v6
  3163. if (!tip) {
  3164. return null;
  3165. }
  3166. tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2);
  3167. // todo: on v6 the following can be achieved with CSS only
  3168. tip.classList.add(`bs-${this.constructor.NAME}-auto`);
  3169. const tipId = getUID(this.constructor.NAME).toString();
  3170. tip.setAttribute('id', tipId);
  3171. if (this._isAnimated()) {
  3172. tip.classList.add(CLASS_NAME_FADE$2);
  3173. }
  3174. return tip;
  3175. }
  3176. setContent(content) {
  3177. this._newContent = content;
  3178. if (this._isShown()) {
  3179. this._disposePopper();
  3180. this.show();
  3181. }
  3182. }
  3183. _getTemplateFactory(content) {
  3184. if (this._templateFactory) {
  3185. this._templateFactory.changeContent(content);
  3186. } else {
  3187. this._templateFactory = new TemplateFactory({
  3188. ...this._config,
  3189. // the `content` var has to be after `this._config`
  3190. // to override config.content in case of popover
  3191. content,
  3192. extraClass: this._resolvePossibleFunction(this._config.customClass)
  3193. });
  3194. }
  3195. return this._templateFactory;
  3196. }
  3197. _getContentForTemplate() {
  3198. return {
  3199. [SELECTOR_TOOLTIP_INNER]: this._getTitle()
  3200. };
  3201. }
  3202. _getTitle() {
  3203. return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-bs-original-title');
  3204. }
  3205. // Private
  3206. _initializeOnDelegatedTarget(event) {
  3207. return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
  3208. }
  3209. _isAnimated() {
  3210. return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE$2);
  3211. }
  3212. _isShown() {
  3213. return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW$2);
  3214. }
  3215. _createPopper(tip) {
  3216. const placement = execute(this._config.placement, [this, tip, this._element]);
  3217. const attachment = AttachmentMap[placement.toUpperCase()];
  3218. return Popper.createPopper(this._element, tip, this._getPopperConfig(attachment));
  3219. }
  3220. _getOffset() {
  3221. const {
  3222. offset
  3223. } = this._config;
  3224. if (typeof offset === 'string') {
  3225. return offset.split(',').map(value => Number.parseInt(value, 10));
  3226. }
  3227. if (typeof offset === 'function') {
  3228. return popperData => offset(popperData, this._element);
  3229. }
  3230. return offset;
  3231. }
  3232. _resolvePossibleFunction(arg) {
  3233. return execute(arg, [this._element]);
  3234. }
  3235. _getPopperConfig(attachment) {
  3236. const defaultBsPopperConfig = {
  3237. placement: attachment,
  3238. modifiers: [{
  3239. name: 'flip',
  3240. options: {
  3241. fallbackPlacements: this._config.fallbackPlacements
  3242. }
  3243. }, {
  3244. name: 'offset',
  3245. options: {
  3246. offset: this._getOffset()
  3247. }
  3248. }, {
  3249. name: 'preventOverflow',
  3250. options: {
  3251. boundary: this._config.boundary
  3252. }
  3253. }, {
  3254. name: 'arrow',
  3255. options: {
  3256. element: `.${this.constructor.NAME}-arrow`
  3257. }
  3258. }, {
  3259. name: 'preSetPlacement',
  3260. enabled: true,
  3261. phase: 'beforeMain',
  3262. fn: data => {
  3263. // Pre-set Popper's placement attribute in order to read the arrow sizes properly.
  3264. // Otherwise, Popper mixes up the width and height dimensions since the initial arrow style is for top placement
  3265. this._getTipElement().setAttribute('data-popper-placement', data.state.placement);
  3266. }
  3267. }]
  3268. };
  3269. return {
  3270. ...defaultBsPopperConfig,
  3271. ...execute(this._config.popperConfig, [defaultBsPopperConfig])
  3272. };
  3273. }
  3274. _setListeners() {
  3275. const triggers = this._config.trigger.split(' ');
  3276. for (const trigger of triggers) {
  3277. if (trigger === 'click') {
  3278. EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK$1), this._config.selector, event => {
  3279. const context = this._initializeOnDelegatedTarget(event);
  3280. context.toggle();
  3281. });
  3282. } else if (trigger !== TRIGGER_MANUAL) {
  3283. const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN$1);
  3284. const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT$1);
  3285. EventHandler.on(this._element, eventIn, this._config.selector, event => {
  3286. const context = this._initializeOnDelegatedTarget(event);
  3287. context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
  3288. context._enter();
  3289. });
  3290. EventHandler.on(this._element, eventOut, this._config.selector, event => {
  3291. const context = this._initializeOnDelegatedTarget(event);
  3292. context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
  3293. context._leave();
  3294. });
  3295. }
  3296. }
  3297. this._hideModalHandler = () => {
  3298. if (this._element) {
  3299. this.hide();
  3300. }
  3301. };
  3302. EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  3303. }
  3304. _fixTitle() {
  3305. const title = this._element.getAttribute('title');
  3306. if (!title) {
  3307. return;
  3308. }
  3309. if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {
  3310. this._element.setAttribute('aria-label', title);
  3311. }
  3312. this._element.setAttribute('data-bs-original-title', title); // DO NOT USE IT. Is only for backwards compatibility
  3313. this._element.removeAttribute('title');
  3314. }
  3315. _enter() {
  3316. if (this._isShown() || this._isHovered) {
  3317. this._isHovered = true;
  3318. return;
  3319. }
  3320. this._isHovered = true;
  3321. this._setTimeout(() => {
  3322. if (this._isHovered) {
  3323. this.show();
  3324. }
  3325. }, this._config.delay.show);
  3326. }
  3327. _leave() {
  3328. if (this._isWithActiveTrigger()) {
  3329. return;
  3330. }
  3331. this._isHovered = false;
  3332. this._setTimeout(() => {
  3333. if (!this._isHovered) {
  3334. this.hide();
  3335. }
  3336. }, this._config.delay.hide);
  3337. }
  3338. _setTimeout(handler, timeout) {
  3339. clearTimeout(this._timeout);
  3340. this._timeout = setTimeout(handler, timeout);
  3341. }
  3342. _isWithActiveTrigger() {
  3343. return Object.values(this._activeTrigger).includes(true);
  3344. }
  3345. _getConfig(config) {
  3346. const dataAttributes = Manipulator.getDataAttributes(this._element);
  3347. for (const dataAttribute of Object.keys(dataAttributes)) {
  3348. if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) {
  3349. delete dataAttributes[dataAttribute];
  3350. }
  3351. }
  3352. config = {
  3353. ...dataAttributes,
  3354. ...(typeof config === 'object' && config ? config : {})
  3355. };
  3356. config = this._mergeConfigObj(config);
  3357. config = this._configAfterMerge(config);
  3358. this._typeCheckConfig(config);
  3359. return config;
  3360. }
  3361. _configAfterMerge(config) {
  3362. config.container = config.container === false ? document.body : getElement(config.container);
  3363. if (typeof config.delay === 'number') {
  3364. config.delay = {
  3365. show: config.delay,
  3366. hide: config.delay
  3367. };
  3368. }
  3369. if (typeof config.title === 'number') {
  3370. config.title = config.title.toString();
  3371. }
  3372. if (typeof config.content === 'number') {
  3373. config.content = config.content.toString();
  3374. }
  3375. return config;
  3376. }
  3377. _getDelegateConfig() {
  3378. const config = {};
  3379. for (const [key, value] of Object.entries(this._config)) {
  3380. if (this.constructor.Default[key] !== value) {
  3381. config[key] = value;
  3382. }
  3383. }
  3384. config.selector = false;
  3385. config.trigger = 'manual';
  3386. // In the future can be replaced with:
  3387. // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
  3388. // `Object.fromEntries(keysWithDifferentValues)`
  3389. return config;
  3390. }
  3391. _disposePopper() {
  3392. if (this._popper) {
  3393. this._popper.destroy();
  3394. this._popper = null;
  3395. }
  3396. if (this.tip) {
  3397. this.tip.remove();
  3398. this.tip = null;
  3399. }
  3400. }
  3401. // Static
  3402. static jQueryInterface(config) {
  3403. return this.each(function () {
  3404. const data = Tooltip.getOrCreateInstance(this, config);
  3405. if (typeof config !== 'string') {
  3406. return;
  3407. }
  3408. if (typeof data[config] === 'undefined') {
  3409. throw new TypeError(`No method named "${config}"`);
  3410. }
  3411. data[config]();
  3412. });
  3413. }
  3414. }
  3415. /**
  3416. * jQuery
  3417. */
  3418. defineJQueryPlugin(Tooltip);
  3419. /**
  3420. * --------------------------------------------------------------------------
  3421. * Bootstrap popover.js
  3422. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3423. * --------------------------------------------------------------------------
  3424. */
  3425. /**
  3426. * Constants
  3427. */
  3428. const NAME$3 = 'popover';
  3429. const SELECTOR_TITLE = '.popover-header';
  3430. const SELECTOR_CONTENT = '.popover-body';
  3431. const Default$2 = {
  3432. ...Tooltip.Default,
  3433. content: '',
  3434. offset: [0, 8],
  3435. placement: 'right',
  3436. template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>',
  3437. trigger: 'click'
  3438. };
  3439. const DefaultType$2 = {
  3440. ...Tooltip.DefaultType,
  3441. content: '(null|string|element|function)'
  3442. };
  3443. /**
  3444. * Class definition
  3445. */
  3446. class Popover extends Tooltip {
  3447. // Getters
  3448. static get Default() {
  3449. return Default$2;
  3450. }
  3451. static get DefaultType() {
  3452. return DefaultType$2;
  3453. }
  3454. static get NAME() {
  3455. return NAME$3;
  3456. }
  3457. // Overrides
  3458. _isWithContent() {
  3459. return this._getTitle() || this._getContent();
  3460. }
  3461. // Private
  3462. _getContentForTemplate() {
  3463. return {
  3464. [SELECTOR_TITLE]: this._getTitle(),
  3465. [SELECTOR_CONTENT]: this._getContent()
  3466. };
  3467. }
  3468. _getContent() {
  3469. return this._resolvePossibleFunction(this._config.content);
  3470. }
  3471. // Static
  3472. static jQueryInterface(config) {
  3473. return this.each(function () {
  3474. const data = Popover.getOrCreateInstance(this, config);
  3475. if (typeof config !== 'string') {
  3476. return;
  3477. }
  3478. if (typeof data[config] === 'undefined') {
  3479. throw new TypeError(`No method named "${config}"`);
  3480. }
  3481. data[config]();
  3482. });
  3483. }
  3484. }
  3485. /**
  3486. * jQuery
  3487. */
  3488. defineJQueryPlugin(Popover);
  3489. /**
  3490. * --------------------------------------------------------------------------
  3491. * Bootstrap scrollspy.js
  3492. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3493. * --------------------------------------------------------------------------
  3494. */
  3495. /**
  3496. * Constants
  3497. */
  3498. const NAME$2 = 'scrollspy';
  3499. const DATA_KEY$2 = 'bs.scrollspy';
  3500. const EVENT_KEY$2 = `.${DATA_KEY$2}`;
  3501. const DATA_API_KEY = '.data-api';
  3502. const EVENT_ACTIVATE = `activate${EVENT_KEY$2}`;
  3503. const EVENT_CLICK = `click${EVENT_KEY$2}`;
  3504. const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$2}${DATA_API_KEY}`;
  3505. const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
  3506. const CLASS_NAME_ACTIVE$1 = 'active';
  3507. const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
  3508. const SELECTOR_TARGET_LINKS = '[href]';
  3509. const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
  3510. const SELECTOR_NAV_LINKS = '.nav-link';
  3511. const SELECTOR_NAV_ITEMS = '.nav-item';
  3512. const SELECTOR_LIST_ITEMS = '.list-group-item';
  3513. const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`;
  3514. const SELECTOR_DROPDOWN = '.dropdown';
  3515. const SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle';
  3516. const Default$1 = {
  3517. offset: null,
  3518. // TODO: v6 @deprecated, keep it for backwards compatibility reasons
  3519. rootMargin: '0px 0px -25%',
  3520. smoothScroll: false,
  3521. target: null,
  3522. threshold: [0.1, 0.5, 1]
  3523. };
  3524. const DefaultType$1 = {
  3525. offset: '(number|null)',
  3526. // TODO v6 @deprecated, keep it for backwards compatibility reasons
  3527. rootMargin: 'string',
  3528. smoothScroll: 'boolean',
  3529. target: 'element',
  3530. threshold: 'array'
  3531. };
  3532. /**
  3533. * Class definition
  3534. */
  3535. class ScrollSpy extends BaseComponent {
  3536. constructor(element, config) {
  3537. super(element, config);
  3538. // this._element is the observablesContainer and config.target the menu links wrapper
  3539. this._targetLinks = new Map();
  3540. this._observableSections = new Map();
  3541. this._rootElement = getComputedStyle(this._element).overflowY === 'visible' ? null : this._element;
  3542. this._activeTarget = null;
  3543. this._observer = null;
  3544. this._previousScrollData = {
  3545. visibleEntryTop: 0,
  3546. parentScrollTop: 0
  3547. };
  3548. this.refresh(); // initialize
  3549. }
  3550. // Getters
  3551. static get Default() {
  3552. return Default$1;
  3553. }
  3554. static get DefaultType() {
  3555. return DefaultType$1;
  3556. }
  3557. static get NAME() {
  3558. return NAME$2;
  3559. }
  3560. // Public
  3561. refresh() {
  3562. this._initializeTargetsAndObservables();
  3563. this._maybeEnableSmoothScroll();
  3564. if (this._observer) {
  3565. this._observer.disconnect();
  3566. } else {
  3567. this._observer = this._getNewObserver();
  3568. }
  3569. for (const section of this._observableSections.values()) {
  3570. this._observer.observe(section);
  3571. }
  3572. }
  3573. dispose() {
  3574. this._observer.disconnect();
  3575. super.dispose();
  3576. }
  3577. // Private
  3578. _configAfterMerge(config) {
  3579. // TODO: on v6 target should be given explicitly & remove the {target: 'ss-target'} case
  3580. config.target = getElement(config.target) || document.body;
  3581. // TODO: v6 Only for backwards compatibility reasons. Use rootMargin only
  3582. config.rootMargin = config.offset ? `${config.offset}px 0px -30%` : config.rootMargin;
  3583. if (typeof config.threshold === 'string') {
  3584. config.threshold = config.threshold.split(',').map(value => Number.parseFloat(value));
  3585. }
  3586. return config;
  3587. }
  3588. _maybeEnableSmoothScroll() {
  3589. if (!this._config.smoothScroll) {
  3590. return;
  3591. }
  3592. // unregister any previous listeners
  3593. EventHandler.off(this._config.target, EVENT_CLICK);
  3594. EventHandler.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, event => {
  3595. const observableSection = this._observableSections.get(event.target.hash);
  3596. if (observableSection) {
  3597. event.preventDefault();
  3598. const root = this._rootElement || window;
  3599. const height = observableSection.offsetTop - this._element.offsetTop;
  3600. if (root.scrollTo) {
  3601. root.scrollTo({
  3602. top: height,
  3603. behavior: 'smooth'
  3604. });
  3605. return;
  3606. }
  3607. // Chrome 60 doesn't support `scrollTo`
  3608. root.scrollTop = height;
  3609. }
  3610. });
  3611. }
  3612. _getNewObserver() {
  3613. const options = {
  3614. root: this._rootElement,
  3615. threshold: this._config.threshold,
  3616. rootMargin: this._config.rootMargin
  3617. };
  3618. return new IntersectionObserver(entries => this._observerCallback(entries), options);
  3619. }
  3620. // The logic of selection
  3621. _observerCallback(entries) {
  3622. const targetElement = entry => this._targetLinks.get(`#${entry.target.id}`);
  3623. const activate = entry => {
  3624. this._previousScrollData.visibleEntryTop = entry.target.offsetTop;
  3625. this._process(targetElement(entry));
  3626. };
  3627. const parentScrollTop = (this._rootElement || document.documentElement).scrollTop;
  3628. const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop;
  3629. this._previousScrollData.parentScrollTop = parentScrollTop;
  3630. for (const entry of entries) {
  3631. if (!entry.isIntersecting) {
  3632. this._activeTarget = null;
  3633. this._clearActiveClass(targetElement(entry));
  3634. continue;
  3635. }
  3636. const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop;
  3637. // if we are scrolling down, pick the bigger offsetTop
  3638. if (userScrollsDown && entryIsLowerThanPrevious) {
  3639. activate(entry);
  3640. // if parent isn't scrolled, let's keep the first visible item, breaking the iteration
  3641. if (!parentScrollTop) {
  3642. return;
  3643. }
  3644. continue;
  3645. }
  3646. // if we are scrolling up, pick the smallest offsetTop
  3647. if (!userScrollsDown && !entryIsLowerThanPrevious) {
  3648. activate(entry);
  3649. }
  3650. }
  3651. }
  3652. _initializeTargetsAndObservables() {
  3653. this._targetLinks = new Map();
  3654. this._observableSections = new Map();
  3655. const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target);
  3656. for (const anchor of targetLinks) {
  3657. // ensure that the anchor has an id and is not disabled
  3658. if (!anchor.hash || isDisabled(anchor)) {
  3659. continue;
  3660. }
  3661. const observableSection = SelectorEngine.findOne(anchor.hash, this._element);
  3662. // ensure that the observableSection exists & is visible
  3663. if (isVisible(observableSection)) {
  3664. this._targetLinks.set(anchor.hash, anchor);
  3665. this._observableSections.set(anchor.hash, observableSection);
  3666. }
  3667. }
  3668. }
  3669. _process(target) {
  3670. if (this._activeTarget === target) {
  3671. return;
  3672. }
  3673. this._clearActiveClass(this._config.target);
  3674. this._activeTarget = target;
  3675. target.classList.add(CLASS_NAME_ACTIVE$1);
  3676. this._activateParents(target);
  3677. EventHandler.trigger(this._element, EVENT_ACTIVATE, {
  3678. relatedTarget: target
  3679. });
  3680. }
  3681. _activateParents(target) {
  3682. // Activate dropdown parents
  3683. if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
  3684. SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, target.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE$1);
  3685. return;
  3686. }
  3687. for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) {
  3688. // Set triggered links parents as active
  3689. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  3690. for (const item of SelectorEngine.prev(listGroup, SELECTOR_LINK_ITEMS)) {
  3691. item.classList.add(CLASS_NAME_ACTIVE$1);
  3692. }
  3693. }
  3694. }
  3695. _clearActiveClass(parent) {
  3696. parent.classList.remove(CLASS_NAME_ACTIVE$1);
  3697. const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE$1}`, parent);
  3698. for (const node of activeNodes) {
  3699. node.classList.remove(CLASS_NAME_ACTIVE$1);
  3700. }
  3701. }
  3702. // Static
  3703. static jQueryInterface(config) {
  3704. return this.each(function () {
  3705. const data = ScrollSpy.getOrCreateInstance(this, config);
  3706. if (typeof config !== 'string') {
  3707. return;
  3708. }
  3709. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  3710. throw new TypeError(`No method named "${config}"`);
  3711. }
  3712. data[config]();
  3713. });
  3714. }
  3715. }
  3716. /**
  3717. * Data API implementation
  3718. */
  3719. EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => {
  3720. for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) {
  3721. ScrollSpy.getOrCreateInstance(spy);
  3722. }
  3723. });
  3724. /**
  3725. * jQuery
  3726. */
  3727. defineJQueryPlugin(ScrollSpy);
  3728. /**
  3729. * --------------------------------------------------------------------------
  3730. * Bootstrap tab.js
  3731. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3732. * --------------------------------------------------------------------------
  3733. */
  3734. /**
  3735. * Constants
  3736. */
  3737. const NAME$1 = 'tab';
  3738. const DATA_KEY$1 = 'bs.tab';
  3739. const EVENT_KEY$1 = `.${DATA_KEY$1}`;
  3740. const EVENT_HIDE$1 = `hide${EVENT_KEY$1}`;
  3741. const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$1}`;
  3742. const EVENT_SHOW$1 = `show${EVENT_KEY$1}`;
  3743. const EVENT_SHOWN$1 = `shown${EVENT_KEY$1}`;
  3744. const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}`;
  3745. const EVENT_KEYDOWN = `keydown${EVENT_KEY$1}`;
  3746. const EVENT_LOAD_DATA_API = `load${EVENT_KEY$1}`;
  3747. const ARROW_LEFT_KEY = 'ArrowLeft';
  3748. const ARROW_RIGHT_KEY = 'ArrowRight';
  3749. const ARROW_UP_KEY = 'ArrowUp';
  3750. const ARROW_DOWN_KEY = 'ArrowDown';
  3751. const CLASS_NAME_ACTIVE = 'active';
  3752. const CLASS_NAME_FADE$1 = 'fade';
  3753. const CLASS_NAME_SHOW$1 = 'show';
  3754. const CLASS_DROPDOWN = 'dropdown';
  3755. const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
  3756. const SELECTOR_DROPDOWN_MENU = '.dropdown-menu';
  3757. const NOT_SELECTOR_DROPDOWN_TOGGLE = ':not(.dropdown-toggle)';
  3758. const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]';
  3759. const SELECTOR_OUTER = '.nav-item, .list-group-item';
  3760. const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`;
  3761. const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; // todo:v6: could be only `tab`
  3762. const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`;
  3763. const SELECTOR_DATA_TOGGLE_ACTIVE = `.${CLASS_NAME_ACTIVE}[data-bs-toggle="tab"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="pill"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="list"]`;
  3764. /**
  3765. * Class definition
  3766. */
  3767. class Tab extends BaseComponent {
  3768. constructor(element) {
  3769. super(element);
  3770. this._parent = this._element.closest(SELECTOR_TAB_PANEL);
  3771. if (!this._parent) {
  3772. return;
  3773. // todo: should Throw exception on v6
  3774. // throw new TypeError(`${element.outerHTML} has not a valid parent ${SELECTOR_INNER_ELEM}`)
  3775. }
  3776. // Set up initial aria attributes
  3777. this._setInitialAttributes(this._parent, this._getChildren());
  3778. EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
  3779. }
  3780. // Getters
  3781. static get NAME() {
  3782. return NAME$1;
  3783. }
  3784. // Public
  3785. show() {
  3786. // Shows this elem and deactivate the active sibling if exists
  3787. const innerElem = this._element;
  3788. if (this._elemIsActive(innerElem)) {
  3789. return;
  3790. }
  3791. // Search for active tab on same parent to deactivate it
  3792. const active = this._getActiveElem();
  3793. const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE$1, {
  3794. relatedTarget: innerElem
  3795. }) : null;
  3796. const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW$1, {
  3797. relatedTarget: active
  3798. });
  3799. if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) {
  3800. return;
  3801. }
  3802. this._deactivate(active, innerElem);
  3803. this._activate(innerElem, active);
  3804. }
  3805. // Private
  3806. _activate(element, relatedElem) {
  3807. if (!element) {
  3808. return;
  3809. }
  3810. element.classList.add(CLASS_NAME_ACTIVE);
  3811. this._activate(SelectorEngine.getElementFromSelector(element)); // Search and activate/show the proper section
  3812. const complete = () => {
  3813. if (element.getAttribute('role') !== 'tab') {
  3814. element.classList.add(CLASS_NAME_SHOW$1);
  3815. return;
  3816. }
  3817. element.removeAttribute('tabindex');
  3818. element.setAttribute('aria-selected', true);
  3819. this._toggleDropDown(element, true);
  3820. EventHandler.trigger(element, EVENT_SHOWN$1, {
  3821. relatedTarget: relatedElem
  3822. });
  3823. };
  3824. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  3825. }
  3826. _deactivate(element, relatedElem) {
  3827. if (!element) {
  3828. return;
  3829. }
  3830. element.classList.remove(CLASS_NAME_ACTIVE);
  3831. element.blur();
  3832. this._deactivate(SelectorEngine.getElementFromSelector(element)); // Search and deactivate the shown section too
  3833. const complete = () => {
  3834. if (element.getAttribute('role') !== 'tab') {
  3835. element.classList.remove(CLASS_NAME_SHOW$1);
  3836. return;
  3837. }
  3838. element.setAttribute('aria-selected', false);
  3839. element.setAttribute('tabindex', '-1');
  3840. this._toggleDropDown(element, false);
  3841. EventHandler.trigger(element, EVENT_HIDDEN$1, {
  3842. relatedTarget: relatedElem
  3843. });
  3844. };
  3845. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  3846. }
  3847. _keydown(event) {
  3848. if (![ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key)) {
  3849. return;
  3850. }
  3851. event.stopPropagation(); // stopPropagation/preventDefault both added to support up/down keys without scrolling the page
  3852. event.preventDefault();
  3853. const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key);
  3854. const nextActiveElement = getNextActiveElement(this._getChildren().filter(element => !isDisabled(element)), event.target, isNext, true);
  3855. if (nextActiveElement) {
  3856. nextActiveElement.focus({
  3857. preventScroll: true
  3858. });
  3859. Tab.getOrCreateInstance(nextActiveElement).show();
  3860. }
  3861. }
  3862. _getChildren() {
  3863. // collection of inner elements
  3864. return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent);
  3865. }
  3866. _getActiveElem() {
  3867. return this._getChildren().find(child => this._elemIsActive(child)) || null;
  3868. }
  3869. _setInitialAttributes(parent, children) {
  3870. this._setAttributeIfNotExists(parent, 'role', 'tablist');
  3871. for (const child of children) {
  3872. this._setInitialAttributesOnChild(child);
  3873. }
  3874. }
  3875. _setInitialAttributesOnChild(child) {
  3876. child = this._getInnerElement(child);
  3877. const isActive = this._elemIsActive(child);
  3878. const outerElem = this._getOuterElement(child);
  3879. child.setAttribute('aria-selected', isActive);
  3880. if (outerElem !== child) {
  3881. this._setAttributeIfNotExists(outerElem, 'role', 'presentation');
  3882. }
  3883. if (!isActive) {
  3884. child.setAttribute('tabindex', '-1');
  3885. }
  3886. this._setAttributeIfNotExists(child, 'role', 'tab');
  3887. // set attributes to the related panel too
  3888. this._setInitialAttributesOnTargetPanel(child);
  3889. }
  3890. _setInitialAttributesOnTargetPanel(child) {
  3891. const target = SelectorEngine.getElementFromSelector(child);
  3892. if (!target) {
  3893. return;
  3894. }
  3895. this._setAttributeIfNotExists(target, 'role', 'tabpanel');
  3896. if (child.id) {
  3897. this._setAttributeIfNotExists(target, 'aria-labelledby', `${child.id}`);
  3898. }
  3899. }
  3900. _toggleDropDown(element, open) {
  3901. const outerElem = this._getOuterElement(element);
  3902. if (!outerElem.classList.contains(CLASS_DROPDOWN)) {
  3903. return;
  3904. }
  3905. const toggle = (selector, className) => {
  3906. const element = SelectorEngine.findOne(selector, outerElem);
  3907. if (element) {
  3908. element.classList.toggle(className, open);
  3909. }
  3910. };
  3911. toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE);
  3912. toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW$1);
  3913. outerElem.setAttribute('aria-expanded', open);
  3914. }
  3915. _setAttributeIfNotExists(element, attribute, value) {
  3916. if (!element.hasAttribute(attribute)) {
  3917. element.setAttribute(attribute, value);
  3918. }
  3919. }
  3920. _elemIsActive(elem) {
  3921. return elem.classList.contains(CLASS_NAME_ACTIVE);
  3922. }
  3923. // Try to get the inner element (usually the .nav-link)
  3924. _getInnerElement(elem) {
  3925. return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem);
  3926. }
  3927. // Try to get the outer element (usually the .nav-item)
  3928. _getOuterElement(elem) {
  3929. return elem.closest(SELECTOR_OUTER) || elem;
  3930. }
  3931. // Static
  3932. static jQueryInterface(config) {
  3933. return this.each(function () {
  3934. const data = Tab.getOrCreateInstance(this);
  3935. if (typeof config !== 'string') {
  3936. return;
  3937. }
  3938. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  3939. throw new TypeError(`No method named "${config}"`);
  3940. }
  3941. data[config]();
  3942. });
  3943. }
  3944. }
  3945. /**
  3946. * Data API implementation
  3947. */
  3948. EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
  3949. if (['A', 'AREA'].includes(this.tagName)) {
  3950. event.preventDefault();
  3951. }
  3952. if (isDisabled(this)) {
  3953. return;
  3954. }
  3955. Tab.getOrCreateInstance(this).show();
  3956. });
  3957. /**
  3958. * Initialize on focus
  3959. */
  3960. EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
  3961. for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) {
  3962. Tab.getOrCreateInstance(element);
  3963. }
  3964. });
  3965. /**
  3966. * jQuery
  3967. */
  3968. defineJQueryPlugin(Tab);
  3969. /**
  3970. * --------------------------------------------------------------------------
  3971. * Bootstrap toast.js
  3972. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3973. * --------------------------------------------------------------------------
  3974. */
  3975. /**
  3976. * Constants
  3977. */
  3978. const NAME = 'toast';
  3979. const DATA_KEY = 'bs.toast';
  3980. const EVENT_KEY = `.${DATA_KEY}`;
  3981. const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`;
  3982. const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`;
  3983. const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
  3984. const EVENT_FOCUSOUT = `focusout${EVENT_KEY}`;
  3985. const EVENT_HIDE = `hide${EVENT_KEY}`;
  3986. const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
  3987. const EVENT_SHOW = `show${EVENT_KEY}`;
  3988. const EVENT_SHOWN = `shown${EVENT_KEY}`;
  3989. const CLASS_NAME_FADE = 'fade';
  3990. const CLASS_NAME_HIDE = 'hide'; // @deprecated - kept here only for backwards compatibility
  3991. const CLASS_NAME_SHOW = 'show';
  3992. const CLASS_NAME_SHOWING = 'showing';
  3993. const DefaultType = {
  3994. animation: 'boolean',
  3995. autohide: 'boolean',
  3996. delay: 'number'
  3997. };
  3998. const Default = {
  3999. animation: true,
  4000. autohide: true,
  4001. delay: 5000
  4002. };
  4003. /**
  4004. * Class definition
  4005. */
  4006. class Toast extends BaseComponent {
  4007. constructor(element, config) {
  4008. super(element, config);
  4009. this._timeout = null;
  4010. this._hasMouseInteraction = false;
  4011. this._hasKeyboardInteraction = false;
  4012. this._setListeners();
  4013. }
  4014. // Getters
  4015. static get Default() {
  4016. return Default;
  4017. }
  4018. static get DefaultType() {
  4019. return DefaultType;
  4020. }
  4021. static get NAME() {
  4022. return NAME;
  4023. }
  4024. // Public
  4025. show() {
  4026. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW);
  4027. if (showEvent.defaultPrevented) {
  4028. return;
  4029. }
  4030. this._clearTimeout();
  4031. if (this._config.animation) {
  4032. this._element.classList.add(CLASS_NAME_FADE);
  4033. }
  4034. const complete = () => {
  4035. this._element.classList.remove(CLASS_NAME_SHOWING);
  4036. EventHandler.trigger(this._element, EVENT_SHOWN);
  4037. this._maybeScheduleHide();
  4038. };
  4039. this._element.classList.remove(CLASS_NAME_HIDE); // @deprecated
  4040. reflow(this._element);
  4041. this._element.classList.add(CLASS_NAME_SHOW, CLASS_NAME_SHOWING);
  4042. this._queueCallback(complete, this._element, this._config.animation);
  4043. }
  4044. hide() {
  4045. if (!this.isShown()) {
  4046. return;
  4047. }
  4048. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
  4049. if (hideEvent.defaultPrevented) {
  4050. return;
  4051. }
  4052. const complete = () => {
  4053. this._element.classList.add(CLASS_NAME_HIDE); // @deprecated
  4054. this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW);
  4055. EventHandler.trigger(this._element, EVENT_HIDDEN);
  4056. };
  4057. this._element.classList.add(CLASS_NAME_SHOWING);
  4058. this._queueCallback(complete, this._element, this._config.animation);
  4059. }
  4060. dispose() {
  4061. this._clearTimeout();
  4062. if (this.isShown()) {
  4063. this._element.classList.remove(CLASS_NAME_SHOW);
  4064. }
  4065. super.dispose();
  4066. }
  4067. isShown() {
  4068. return this._element.classList.contains(CLASS_NAME_SHOW);
  4069. }
  4070. // Private
  4071. _maybeScheduleHide() {
  4072. if (!this._config.autohide) {
  4073. return;
  4074. }
  4075. if (this._hasMouseInteraction || this._hasKeyboardInteraction) {
  4076. return;
  4077. }
  4078. this._timeout = setTimeout(() => {
  4079. this.hide();
  4080. }, this._config.delay);
  4081. }
  4082. _onInteraction(event, isInteracting) {
  4083. switch (event.type) {
  4084. case 'mouseover':
  4085. case 'mouseout':
  4086. {
  4087. this._hasMouseInteraction = isInteracting;
  4088. break;
  4089. }
  4090. case 'focusin':
  4091. case 'focusout':
  4092. {
  4093. this._hasKeyboardInteraction = isInteracting;
  4094. break;
  4095. }
  4096. }
  4097. if (isInteracting) {
  4098. this._clearTimeout();
  4099. return;
  4100. }
  4101. const nextElement = event.relatedTarget;
  4102. if (this._element === nextElement || this._element.contains(nextElement)) {
  4103. return;
  4104. }
  4105. this._maybeScheduleHide();
  4106. }
  4107. _setListeners() {
  4108. EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true));
  4109. EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false));
  4110. EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true));
  4111. EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false));
  4112. }
  4113. _clearTimeout() {
  4114. clearTimeout(this._timeout);
  4115. this._timeout = null;
  4116. }
  4117. // Static
  4118. static jQueryInterface(config) {
  4119. return this.each(function () {
  4120. const data = Toast.getOrCreateInstance(this, config);
  4121. if (typeof config === 'string') {
  4122. if (typeof data[config] === 'undefined') {
  4123. throw new TypeError(`No method named "${config}"`);
  4124. }
  4125. data[config](this);
  4126. }
  4127. });
  4128. }
  4129. }
  4130. /**
  4131. * Data API implementation
  4132. */
  4133. enableDismissTrigger(Toast);
  4134. /**
  4135. * jQuery
  4136. */
  4137. defineJQueryPlugin(Toast);
  4138. export { Alert, Button, Carousel, Collapse, Dropdown, Modal, Offcanvas, Popover, ScrollSpy, Tab, Toast, Tooltip };
  4139. //# sourceMappingURL=bootstrap.esm.js.map