tabler.esm.js 250 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475
  1. /*!
  2. * Tabler v1.0.0-beta18 (https://tabler.io)
  3. * @version 1.0.0-beta18
  4. * @link https://tabler.io
  5. * Copyright 2018-2023 The Tabler Authors
  6. * Copyright 2018-2023 codecalm.net Paweł Kuna
  7. * Licensed under MIT (https://github.com/tabler/tabler/blob/master/LICENSE)
  8. */
  9. var e=new Map;function t(t){var o=e.get(t);o&&o.destroy();}function o(t){var o=e.get(t);o&&o.update();}var r=null;"undefined"==typeof window?((r=function(e){return e}).destroy=function(e){return e},r.update=function(e){return e}):((r=function(t,o){return t&&Array.prototype.forEach.call(t.length?t:[t],function(t){return function(t){if(t&&t.nodeName&&"TEXTAREA"===t.nodeName&&!e.has(t)){var o,r=null,n=window.getComputedStyle(t),i=(o=t.value,function(){a({testForHeightReduction:""===o||!t.value.startsWith(o),restoreTextAlign:null}),o=t.value;}),l=function(o){t.removeEventListener("autosize:destroy",l),t.removeEventListener("autosize:update",s),t.removeEventListener("input",i),window.removeEventListener("resize",s),Object.keys(o).forEach(function(e){return t.style[e]=o[e]}),e.delete(t);}.bind(t,{height:t.style.height,resize:t.style.resize,textAlign:t.style.textAlign,overflowY:t.style.overflowY,overflowX:t.style.overflowX,wordWrap:t.style.wordWrap});t.addEventListener("autosize:destroy",l),t.addEventListener("autosize:update",s),t.addEventListener("input",i),window.addEventListener("resize",s),t.style.overflowX="hidden",t.style.wordWrap="break-word",e.set(t,{destroy:l,update:s}),s();}function a(e){var o,i,l=e.restoreTextAlign,s=void 0===l?null:l,d=e.testForHeightReduction,u=void 0===d||d,c=n.overflowY;if(0!==t.scrollHeight&&("vertical"===n.resize?t.style.resize="none":"both"===n.resize&&(t.style.resize="horizontal"),u&&(o=function(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push([e.parentNode,e.parentNode.scrollTop]),e=e.parentNode;return function(){return t.forEach(function(e){var t=e[0],o=e[1];t.style.scrollBehavior="auto",t.scrollTop=o,t.style.scrollBehavior=null;})}}(t),t.style.height=""),i="content-box"===n.boxSizing?t.scrollHeight-(parseFloat(n.paddingTop)+parseFloat(n.paddingBottom)):t.scrollHeight+parseFloat(n.borderTopWidth)+parseFloat(n.borderBottomWidth),"none"!==n.maxHeight&&i>parseFloat(n.maxHeight)?("hidden"===n.overflowY&&(t.style.overflow="scroll"),i=parseFloat(n.maxHeight)):"hidden"!==n.overflowY&&(t.style.overflow="hidden"),t.style.height=i+"px",s&&(t.style.textAlign=s),o&&o(),r!==i&&(t.dispatchEvent(new Event("autosize:resized",{bubbles:!0})),r=i),c!==n.overflow&&!s)){var v=n.textAlign;"hidden"===n.overflow&&(t.style.textAlign="start"===v?"end":"start"),a({restoreTextAlign:v,testForHeightReduction:!0});}}function s(){a({testForHeightReduction:!0,restoreTextAlign:null});}}(t)}),t}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],t),e},r.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],o),e});var n=r;
  10. var elements = document.querySelectorAll('[data-bs-toggle="autosize"]');
  11. if (elements.length) {
  12. elements.forEach(function (element) {
  13. n(element);
  14. });
  15. }
  16. function _objectWithoutPropertiesLoose(source, excluded) {
  17. if (source == null) return {};
  18. var target = {};
  19. var sourceKeys = Object.keys(source);
  20. var key, i;
  21. for (i = 0; i < sourceKeys.length; i++) {
  22. key = sourceKeys[i];
  23. if (excluded.indexOf(key) >= 0) continue;
  24. target[key] = source[key];
  25. }
  26. return target;
  27. }
  28. function IMask(el) {
  29. let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  30. return new IMask.InputMask(el, opts);
  31. }
  32. class ChangeDetails {
  33. constructor(details) {
  34. Object.assign(this, {
  35. inserted: '',
  36. rawInserted: '',
  37. skip: false,
  38. tailShift: 0
  39. }, details);
  40. }
  41. aggregate(details) {
  42. this.rawInserted += details.rawInserted;
  43. this.skip = this.skip || details.skip;
  44. this.inserted += details.inserted;
  45. this.tailShift += details.tailShift;
  46. return this;
  47. }
  48. get offset() {
  49. return this.tailShift + this.inserted.length;
  50. }
  51. }
  52. IMask.ChangeDetails = ChangeDetails;
  53. function isString(str) {
  54. return typeof str === 'string' || str instanceof String;
  55. }
  56. const DIRECTION = {
  57. NONE: 'NONE',
  58. LEFT: 'LEFT',
  59. FORCE_LEFT: 'FORCE_LEFT',
  60. RIGHT: 'RIGHT',
  61. FORCE_RIGHT: 'FORCE_RIGHT'
  62. };
  63. function forceDirection(direction) {
  64. switch (direction) {
  65. case DIRECTION.LEFT:
  66. return DIRECTION.FORCE_LEFT;
  67. case DIRECTION.RIGHT:
  68. return DIRECTION.FORCE_RIGHT;
  69. default:
  70. return direction;
  71. }
  72. }
  73. function escapeRegExp(str) {
  74. return str.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
  75. }
  76. function normalizePrepare(prep) {
  77. return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
  78. }
  79. function objectIncludes(b, a) {
  80. if (a === b) return true;
  81. var arrA = Array.isArray(a),
  82. arrB = Array.isArray(b),
  83. i;
  84. if (arrA && arrB) {
  85. if (a.length != b.length) return false;
  86. for (i = 0; i < a.length; i++) if (!objectIncludes(a[i], b[i])) return false;
  87. return true;
  88. }
  89. if (arrA != arrB) return false;
  90. if (a && b && typeof a === 'object' && typeof b === 'object') {
  91. var dateA = a instanceof Date,
  92. dateB = b instanceof Date;
  93. if (dateA && dateB) return a.getTime() == b.getTime();
  94. if (dateA != dateB) return false;
  95. var regexpA = a instanceof RegExp,
  96. regexpB = b instanceof RegExp;
  97. if (regexpA && regexpB) return a.toString() == b.toString();
  98. if (regexpA != regexpB) return false;
  99. var keys = Object.keys(a);
  100. for (i = 0; i < keys.length; i++)
  101. if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
  102. for (i = 0; i < keys.length; i++) if (!objectIncludes(b[keys[i]], a[keys[i]])) return false;
  103. return true;
  104. } else if (a && b && typeof a === 'function' && typeof b === 'function') {
  105. return a.toString() === b.toString();
  106. }
  107. return false;
  108. }
  109. class ActionDetails {
  110. constructor(value, cursorPos, oldValue, oldSelection) {
  111. this.value = value;
  112. this.cursorPos = cursorPos;
  113. this.oldValue = oldValue;
  114. this.oldSelection = oldSelection;
  115. while (this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos)) {
  116. --this.oldSelection.start;
  117. }
  118. }
  119. get startChangePos() {
  120. return Math.min(this.cursorPos, this.oldSelection.start);
  121. }
  122. get insertedCount() {
  123. return this.cursorPos - this.startChangePos;
  124. }
  125. get inserted() {
  126. return this.value.substr(this.startChangePos, this.insertedCount);
  127. }
  128. get removedCount() {
  129. return Math.max(this.oldSelection.end - this.startChangePos ||
  130. this.oldValue.length - this.value.length, 0);
  131. }
  132. get removed() {
  133. return this.oldValue.substr(this.startChangePos, this.removedCount);
  134. }
  135. get head() {
  136. return this.value.substring(0, this.startChangePos);
  137. }
  138. get tail() {
  139. return this.value.substring(this.startChangePos + this.insertedCount);
  140. }
  141. get removeDirection() {
  142. if (!this.removedCount || this.insertedCount) return DIRECTION.NONE;
  143. return (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) &&
  144. this.oldSelection.end === this.oldSelection.start ? DIRECTION.RIGHT : DIRECTION.LEFT;
  145. }
  146. }
  147. class ContinuousTailDetails {
  148. constructor() {
  149. let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  150. let from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  151. let stop = arguments.length > 2 ? arguments[2] : undefined;
  152. this.value = value;
  153. this.from = from;
  154. this.stop = stop;
  155. }
  156. toString() {
  157. return this.value;
  158. }
  159. extend(tail) {
  160. this.value += String(tail);
  161. }
  162. appendTo(masked) {
  163. return masked.append(this.toString(), {
  164. tail: true
  165. }).aggregate(masked._appendPlaceholder());
  166. }
  167. get state() {
  168. return {
  169. value: this.value,
  170. from: this.from,
  171. stop: this.stop
  172. };
  173. }
  174. set state(state) {
  175. Object.assign(this, state);
  176. }
  177. unshift(beforePos) {
  178. if (!this.value.length || beforePos != null && this.from >= beforePos) return '';
  179. const shiftChar = this.value[0];
  180. this.value = this.value.slice(1);
  181. return shiftChar;
  182. }
  183. shift() {
  184. if (!this.value.length) return '';
  185. const shiftChar = this.value[this.value.length - 1];
  186. this.value = this.value.slice(0, -1);
  187. return shiftChar;
  188. }
  189. }
  190. class Masked {
  191. constructor(opts) {
  192. this._value = '';
  193. this._update(Object.assign({}, Masked.DEFAULTS, opts));
  194. this.isInitialized = true;
  195. }
  196. updateOptions(opts) {
  197. if (!Object.keys(opts).length) return;
  198. this.withValueRefresh(this._update.bind(this, opts));
  199. }
  200. _update(opts) {
  201. Object.assign(this, opts);
  202. }
  203. get state() {
  204. return {
  205. _value: this.value
  206. };
  207. }
  208. set state(state) {
  209. this._value = state._value;
  210. }
  211. reset() {
  212. this._value = '';
  213. }
  214. get value() {
  215. return this._value;
  216. }
  217. set value(value) {
  218. this.resolve(value);
  219. }
  220. resolve(value) {
  221. this.reset();
  222. this.append(value, {
  223. input: true
  224. }, '');
  225. this.doCommit();
  226. return this.value;
  227. }
  228. get unmaskedValue() {
  229. return this.value;
  230. }
  231. set unmaskedValue(value) {
  232. this.reset();
  233. this.append(value, {}, '');
  234. this.doCommit();
  235. }
  236. get typedValue() {
  237. return this.doParse(this.value);
  238. }
  239. set typedValue(value) {
  240. this.value = this.doFormat(value);
  241. }
  242. get rawInputValue() {
  243. return this.extractInput(0, this.value.length, {
  244. raw: true
  245. });
  246. }
  247. set rawInputValue(value) {
  248. this.reset();
  249. this.append(value, {
  250. raw: true
  251. }, '');
  252. this.doCommit();
  253. }
  254. get displayValue() {
  255. return this.value;
  256. }
  257. get isComplete() {
  258. return true;
  259. }
  260. get isFilled() {
  261. return this.isComplete;
  262. }
  263. nearestInputPos(cursorPos, direction) {
  264. return cursorPos;
  265. }
  266. totalInputPositions() {
  267. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  268. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  269. return Math.min(this.value.length, toPos - fromPos);
  270. }
  271. extractInput() {
  272. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  273. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  274. return this.value.slice(fromPos, toPos);
  275. }
  276. extractTail() {
  277. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  278. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  279. return new ContinuousTailDetails(this.extractInput(fromPos, toPos), fromPos);
  280. }
  281. appendTail(tail) {
  282. if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
  283. return tail.appendTo(this);
  284. }
  285. _appendCharRaw(ch) {
  286. if (!ch) return new ChangeDetails();
  287. this._value += ch;
  288. return new ChangeDetails({
  289. inserted: ch,
  290. rawInserted: ch
  291. });
  292. }
  293. _appendChar(ch) {
  294. let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  295. let checkTail = arguments.length > 2 ? arguments[2] : undefined;
  296. const consistentState = this.state;
  297. let details;
  298. [ch, details] = normalizePrepare(this.doPrepare(ch, flags));
  299. details = details.aggregate(this._appendCharRaw(ch, flags));
  300. if (details.inserted) {
  301. let consistentTail;
  302. let appended = this.doValidate(flags) !== false;
  303. if (appended && checkTail != null) {
  304. const beforeTailState = this.state;
  305. if (this.overwrite === true) {
  306. consistentTail = checkTail.state;
  307. checkTail.unshift(this.value.length - details.tailShift);
  308. }
  309. let tailDetails = this.appendTail(checkTail);
  310. appended = tailDetails.rawInserted === checkTail.toString();
  311. if (!(appended && tailDetails.inserted) && this.overwrite === 'shift') {
  312. this.state = beforeTailState;
  313. consistentTail = checkTail.state;
  314. checkTail.shift();
  315. tailDetails = this.appendTail(checkTail);
  316. appended = tailDetails.rawInserted === checkTail.toString();
  317. }
  318. if (appended && tailDetails.inserted) this.state = beforeTailState;
  319. }
  320. if (!appended) {
  321. details = new ChangeDetails();
  322. this.state = consistentState;
  323. if (checkTail && consistentTail) checkTail.state = consistentTail;
  324. }
  325. }
  326. return details;
  327. }
  328. _appendPlaceholder() {
  329. return new ChangeDetails();
  330. }
  331. _appendEager() {
  332. return new ChangeDetails();
  333. }
  334. append(str, flags, tail) {
  335. if (!isString(str)) throw new Error('value should be string');
  336. const details = new ChangeDetails();
  337. const checkTail = isString(tail) ? new ContinuousTailDetails(String(tail)) : tail;
  338. if (flags !== null && flags !== void 0 && flags.tail) flags._beforeTailState = this.state;
  339. for (let ci = 0; ci < str.length; ++ci) {
  340. const d = this._appendChar(str[ci], flags, checkTail);
  341. if (!d.rawInserted && !this.doSkipInvalid(str[ci], flags, checkTail)) break;
  342. details.aggregate(d);
  343. }
  344. if (checkTail != null) {
  345. details.tailShift += this.appendTail(checkTail).tailShift;
  346. }
  347. if ((this.eager === true || this.eager === 'append') && flags !== null && flags !== void 0 && flags.input && str) {
  348. details.aggregate(this._appendEager());
  349. }
  350. return details;
  351. }
  352. remove() {
  353. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  354. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  355. this._value = this.value.slice(0, fromPos) + this.value.slice(toPos);
  356. return new ChangeDetails();
  357. }
  358. withValueRefresh(fn) {
  359. if (this._refreshing || !this.isInitialized) return fn();
  360. this._refreshing = true;
  361. const rawInput = this.rawInputValue;
  362. const value = this.value;
  363. const ret = fn();
  364. this.rawInputValue = rawInput;
  365. if (this.value && this.value !== value && value.indexOf(this.value) === 0) {
  366. this.append(value.slice(this.value.length), {}, '');
  367. }
  368. delete this._refreshing;
  369. return ret;
  370. }
  371. runIsolated(fn) {
  372. if (this._isolated || !this.isInitialized) return fn(this);
  373. this._isolated = true;
  374. const state = this.state;
  375. const ret = fn(this);
  376. this.state = state;
  377. delete this._isolated;
  378. return ret;
  379. }
  380. doSkipInvalid(ch) {
  381. return this.skipInvalid;
  382. }
  383. doPrepare(str) {
  384. let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  385. return this.prepare ? this.prepare(str, this, flags) : str;
  386. }
  387. doValidate(flags) {
  388. return (!this.validate || this.validate(this.value, this, flags)) && (!this.parent || this.parent.doValidate(flags));
  389. }
  390. doCommit() {
  391. if (this.commit) this.commit(this.value, this);
  392. }
  393. doFormat(value) {
  394. return this.format ? this.format(value, this) : value;
  395. }
  396. doParse(str) {
  397. return this.parse ? this.parse(str, this) : str;
  398. }
  399. splice(start, deleteCount, inserted, removeDirection) {
  400. let flags = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
  401. input: true
  402. };
  403. const tailPos = start + deleteCount;
  404. const tail = this.extractTail(tailPos);
  405. const eagerRemove = this.eager === true || this.eager === 'remove';
  406. let oldRawValue;
  407. if (eagerRemove) {
  408. removeDirection = forceDirection(removeDirection);
  409. oldRawValue = this.extractInput(0, tailPos, {
  410. raw: true
  411. });
  412. }
  413. let startChangePos = start;
  414. const details = new ChangeDetails();
  415. if (removeDirection !== DIRECTION.NONE) {
  416. startChangePos = this.nearestInputPos(start, deleteCount > 1 && start !== 0 && !eagerRemove ? DIRECTION.NONE : removeDirection);
  417. details.tailShift = startChangePos - start;
  418. }
  419. details.aggregate(this.remove(startChangePos));
  420. if (eagerRemove && removeDirection !== DIRECTION.NONE && oldRawValue === this.rawInputValue) {
  421. if (removeDirection === DIRECTION.FORCE_LEFT) {
  422. let valLength;
  423. while (oldRawValue === this.rawInputValue && (valLength = this.value.length)) {
  424. details.aggregate(new ChangeDetails({
  425. tailShift: -1
  426. })).aggregate(this.remove(valLength - 1));
  427. }
  428. } else if (removeDirection === DIRECTION.FORCE_RIGHT) {
  429. tail.unshift();
  430. }
  431. }
  432. return details.aggregate(this.append(inserted, flags, tail));
  433. }
  434. maskEquals(mask) {
  435. return this.mask === mask;
  436. }
  437. typedValueEquals(value) {
  438. const tval = this.typedValue;
  439. return value === tval || Masked.EMPTY_VALUES.includes(value) && Masked.EMPTY_VALUES.includes(tval) || this.doFormat(value) === this.doFormat(this.typedValue);
  440. }
  441. }
  442. Masked.DEFAULTS = {
  443. format: String,
  444. parse: v => v,
  445. skipInvalid: true
  446. };
  447. Masked.EMPTY_VALUES = [undefined, null, ''];
  448. IMask.Masked = Masked;
  449. function maskedClass(mask) {
  450. if (mask == null) {
  451. throw new Error('mask property should be defined');
  452. }
  453. if (mask instanceof RegExp) return IMask.MaskedRegExp;
  454. if (isString(mask)) return IMask.MaskedPattern;
  455. if (mask instanceof Date || mask === Date) return IMask.MaskedDate;
  456. if (mask instanceof Number || typeof mask === 'number' || mask === Number) return IMask.MaskedNumber;
  457. if (Array.isArray(mask) || mask === Array) return IMask.MaskedDynamic;
  458. if (IMask.Masked && mask.prototype instanceof IMask.Masked) return mask;
  459. if (mask instanceof IMask.Masked) return mask.constructor;
  460. if (mask instanceof Function) return IMask.MaskedFunction;
  461. console.warn('Mask not found for mask', mask);
  462. return IMask.Masked;
  463. }
  464. function createMask(opts) {
  465. if (IMask.Masked && opts instanceof IMask.Masked) return opts;
  466. opts = Object.assign({}, opts);
  467. const mask = opts.mask;
  468. if (IMask.Masked && mask instanceof IMask.Masked) return mask;
  469. const MaskedClass = maskedClass(mask);
  470. if (!MaskedClass) throw new Error('Masked class is not found for provided mask, appropriate module needs to be import manually before creating mask.');
  471. return new MaskedClass(opts);
  472. }
  473. IMask.createMask = createMask;
  474. const _excluded$4 = ["parent", "isOptional", "placeholderChar", "displayChar", "lazy", "eager"];
  475. const DEFAULT_INPUT_DEFINITIONS = {
  476. '0': /\d/,
  477. 'a': /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
  478. '*': /./
  479. };
  480. class PatternInputDefinition {
  481. constructor(opts) {
  482. const {
  483. parent,
  484. isOptional,
  485. placeholderChar,
  486. displayChar,
  487. lazy,
  488. eager
  489. } = opts,
  490. maskOpts = _objectWithoutPropertiesLoose(opts, _excluded$4);
  491. this.masked = createMask(maskOpts);
  492. Object.assign(this, {
  493. parent,
  494. isOptional,
  495. placeholderChar,
  496. displayChar,
  497. lazy,
  498. eager
  499. });
  500. }
  501. reset() {
  502. this.isFilled = false;
  503. this.masked.reset();
  504. }
  505. remove() {
  506. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  507. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  508. if (fromPos === 0 && toPos >= 1) {
  509. this.isFilled = false;
  510. return this.masked.remove(fromPos, toPos);
  511. }
  512. return new ChangeDetails();
  513. }
  514. get value() {
  515. return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : '');
  516. }
  517. get unmaskedValue() {
  518. return this.masked.unmaskedValue;
  519. }
  520. get displayValue() {
  521. return this.masked.value && this.displayChar || this.value;
  522. }
  523. get isComplete() {
  524. return Boolean(this.masked.value) || this.isOptional;
  525. }
  526. _appendChar(ch) {
  527. let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  528. if (this.isFilled) return new ChangeDetails();
  529. const state = this.masked.state;
  530. const details = this.masked._appendChar(ch, flags);
  531. if (details.inserted && this.doValidate(flags) === false) {
  532. details.inserted = details.rawInserted = '';
  533. this.masked.state = state;
  534. }
  535. if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {
  536. details.inserted = this.placeholderChar;
  537. }
  538. details.skip = !details.inserted && !this.isOptional;
  539. this.isFilled = Boolean(details.inserted);
  540. return details;
  541. }
  542. append() {
  543. return this.masked.append(...arguments);
  544. }
  545. _appendPlaceholder() {
  546. const details = new ChangeDetails();
  547. if (this.isFilled || this.isOptional) return details;
  548. this.isFilled = true;
  549. details.inserted = this.placeholderChar;
  550. return details;
  551. }
  552. _appendEager() {
  553. return new ChangeDetails();
  554. }
  555. extractTail() {
  556. return this.masked.extractTail(...arguments);
  557. }
  558. appendTail() {
  559. return this.masked.appendTail(...arguments);
  560. }
  561. extractInput() {
  562. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  563. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  564. let flags = arguments.length > 2 ? arguments[2] : undefined;
  565. return this.masked.extractInput(fromPos, toPos, flags);
  566. }
  567. nearestInputPos(cursorPos) {
  568. let direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
  569. const minPos = 0;
  570. const maxPos = this.value.length;
  571. const boundPos = Math.min(Math.max(cursorPos, minPos), maxPos);
  572. switch (direction) {
  573. case DIRECTION.LEFT:
  574. case DIRECTION.FORCE_LEFT:
  575. return this.isComplete ? boundPos : minPos;
  576. case DIRECTION.RIGHT:
  577. case DIRECTION.FORCE_RIGHT:
  578. return this.isComplete ? boundPos : maxPos;
  579. case DIRECTION.NONE:
  580. default:
  581. return boundPos;
  582. }
  583. }
  584. totalInputPositions() {
  585. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  586. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  587. return this.value.slice(fromPos, toPos).length;
  588. }
  589. doValidate() {
  590. return this.masked.doValidate(...arguments) && (!this.parent || this.parent.doValidate(...arguments));
  591. }
  592. doCommit() {
  593. this.masked.doCommit();
  594. }
  595. get state() {
  596. return {
  597. masked: this.masked.state,
  598. isFilled: this.isFilled
  599. };
  600. }
  601. set state(state) {
  602. this.masked.state = state.masked;
  603. this.isFilled = state.isFilled;
  604. }
  605. }
  606. class PatternFixedDefinition {
  607. constructor(opts) {
  608. Object.assign(this, opts);
  609. this._value = '';
  610. this.isFixed = true;
  611. }
  612. get value() {
  613. return this._value;
  614. }
  615. get unmaskedValue() {
  616. return this.isUnmasking ? this.value : '';
  617. }
  618. get displayValue() {
  619. return this.value;
  620. }
  621. reset() {
  622. this._isRawInput = false;
  623. this._value = '';
  624. }
  625. remove() {
  626. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  627. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
  628. this._value = this._value.slice(0, fromPos) + this._value.slice(toPos);
  629. if (!this._value) this._isRawInput = false;
  630. return new ChangeDetails();
  631. }
  632. nearestInputPos(cursorPos) {
  633. let direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
  634. const minPos = 0;
  635. const maxPos = this._value.length;
  636. switch (direction) {
  637. case DIRECTION.LEFT:
  638. case DIRECTION.FORCE_LEFT:
  639. return minPos;
  640. case DIRECTION.NONE:
  641. case DIRECTION.RIGHT:
  642. case DIRECTION.FORCE_RIGHT:
  643. default:
  644. return maxPos;
  645. }
  646. }
  647. totalInputPositions() {
  648. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  649. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
  650. return this._isRawInput ? toPos - fromPos : 0;
  651. }
  652. extractInput() {
  653. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  654. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
  655. let flags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  656. return flags.raw && this._isRawInput && this._value.slice(fromPos, toPos) || '';
  657. }
  658. get isComplete() {
  659. return true;
  660. }
  661. get isFilled() {
  662. return Boolean(this._value);
  663. }
  664. _appendChar(ch) {
  665. let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  666. const details = new ChangeDetails();
  667. if (this.isFilled) return details;
  668. const appendEager = this.eager === true || this.eager === 'append';
  669. const appended = this.char === ch;
  670. const isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;
  671. if (isResolved) details.rawInserted = this.char;
  672. this._value = details.inserted = this.char;
  673. this._isRawInput = isResolved && (flags.raw || flags.input);
  674. return details;
  675. }
  676. _appendEager() {
  677. return this._appendChar(this.char, {
  678. tail: true
  679. });
  680. }
  681. _appendPlaceholder() {
  682. const details = new ChangeDetails();
  683. if (this.isFilled) return details;
  684. this._value = details.inserted = this.char;
  685. return details;
  686. }
  687. extractTail() {
  688. arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  689. return new ContinuousTailDetails('');
  690. }
  691. appendTail(tail) {
  692. if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
  693. return tail.appendTo(this);
  694. }
  695. append(str, flags, tail) {
  696. const details = this._appendChar(str[0], flags);
  697. if (tail != null) {
  698. details.tailShift += this.appendTail(tail).tailShift;
  699. }
  700. return details;
  701. }
  702. doCommit() {}
  703. get state() {
  704. return {
  705. _value: this._value,
  706. _isRawInput: this._isRawInput
  707. };
  708. }
  709. set state(state) {
  710. Object.assign(this, state);
  711. }
  712. }
  713. const _excluded$3 = ["chunks"];
  714. class ChunksTailDetails {
  715. constructor() {
  716. let chunks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  717. let from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  718. this.chunks = chunks;
  719. this.from = from;
  720. }
  721. toString() {
  722. return this.chunks.map(String).join('');
  723. }
  724. extend(tailChunk) {
  725. if (!String(tailChunk)) return;
  726. if (isString(tailChunk)) tailChunk = new ContinuousTailDetails(String(tailChunk));
  727. const lastChunk = this.chunks[this.chunks.length - 1];
  728. const extendLast = lastChunk && (
  729. lastChunk.stop === tailChunk.stop || tailChunk.stop == null) &&
  730. tailChunk.from === lastChunk.from + lastChunk.toString().length;
  731. if (tailChunk instanceof ContinuousTailDetails) {
  732. if (extendLast) {
  733. lastChunk.extend(tailChunk.toString());
  734. } else {
  735. this.chunks.push(tailChunk);
  736. }
  737. } else if (tailChunk instanceof ChunksTailDetails) {
  738. if (tailChunk.stop == null) {
  739. let firstTailChunk;
  740. while (tailChunk.chunks.length && tailChunk.chunks[0].stop == null) {
  741. firstTailChunk = tailChunk.chunks.shift();
  742. firstTailChunk.from += tailChunk.from;
  743. this.extend(firstTailChunk);
  744. }
  745. }
  746. if (tailChunk.toString()) {
  747. tailChunk.stop = tailChunk.blockIndex;
  748. this.chunks.push(tailChunk);
  749. }
  750. }
  751. }
  752. appendTo(masked) {
  753. if (!(masked instanceof IMask.MaskedPattern)) {
  754. const tail = new ContinuousTailDetails(this.toString());
  755. return tail.appendTo(masked);
  756. }
  757. const details = new ChangeDetails();
  758. for (let ci = 0; ci < this.chunks.length && !details.skip; ++ci) {
  759. const chunk = this.chunks[ci];
  760. const lastBlockIter = masked._mapPosToBlock(masked.value.length);
  761. const stop = chunk.stop;
  762. let chunkBlock;
  763. if (stop != null && (
  764. !lastBlockIter || lastBlockIter.index <= stop)) {
  765. if (chunk instanceof ChunksTailDetails ||
  766. masked._stops.indexOf(stop) >= 0) {
  767. const phDetails = masked._appendPlaceholder(stop);
  768. details.aggregate(phDetails);
  769. }
  770. chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop];
  771. }
  772. if (chunkBlock) {
  773. const tailDetails = chunkBlock.appendTail(chunk);
  774. tailDetails.skip = false;
  775. details.aggregate(tailDetails);
  776. masked._value += tailDetails.inserted;
  777. const remainChars = chunk.toString().slice(tailDetails.rawInserted.length);
  778. if (remainChars) details.aggregate(masked.append(remainChars, {
  779. tail: true
  780. }));
  781. } else {
  782. details.aggregate(masked.append(chunk.toString(), {
  783. tail: true
  784. }));
  785. }
  786. }
  787. return details;
  788. }
  789. get state() {
  790. return {
  791. chunks: this.chunks.map(c => c.state),
  792. from: this.from,
  793. stop: this.stop,
  794. blockIndex: this.blockIndex
  795. };
  796. }
  797. set state(state) {
  798. const {
  799. chunks
  800. } = state,
  801. props = _objectWithoutPropertiesLoose(state, _excluded$3);
  802. Object.assign(this, props);
  803. this.chunks = chunks.map(cstate => {
  804. const chunk = "chunks" in cstate ? new ChunksTailDetails() : new ContinuousTailDetails();
  805. chunk.state = cstate;
  806. return chunk;
  807. });
  808. }
  809. unshift(beforePos) {
  810. if (!this.chunks.length || beforePos != null && this.from >= beforePos) return '';
  811. const chunkShiftPos = beforePos != null ? beforePos - this.from : beforePos;
  812. let ci = 0;
  813. while (ci < this.chunks.length) {
  814. const chunk = this.chunks[ci];
  815. const shiftChar = chunk.unshift(chunkShiftPos);
  816. if (chunk.toString()) {
  817. if (!shiftChar) break;
  818. ++ci;
  819. } else {
  820. this.chunks.splice(ci, 1);
  821. }
  822. if (shiftChar) return shiftChar;
  823. }
  824. return '';
  825. }
  826. shift() {
  827. if (!this.chunks.length) return '';
  828. let ci = this.chunks.length - 1;
  829. while (0 <= ci) {
  830. const chunk = this.chunks[ci];
  831. const shiftChar = chunk.shift();
  832. if (chunk.toString()) {
  833. if (!shiftChar) break;
  834. --ci;
  835. } else {
  836. this.chunks.splice(ci, 1);
  837. }
  838. if (shiftChar) return shiftChar;
  839. }
  840. return '';
  841. }
  842. }
  843. class PatternCursor {
  844. constructor(masked, pos) {
  845. this.masked = masked;
  846. this._log = [];
  847. const {
  848. offset,
  849. index
  850. } = masked._mapPosToBlock(pos) || (pos < 0 ?
  851. {
  852. index: 0,
  853. offset: 0
  854. } :
  855. {
  856. index: this.masked._blocks.length,
  857. offset: 0
  858. });
  859. this.offset = offset;
  860. this.index = index;
  861. this.ok = false;
  862. }
  863. get block() {
  864. return this.masked._blocks[this.index];
  865. }
  866. get pos() {
  867. return this.masked._blockStartPos(this.index) + this.offset;
  868. }
  869. get state() {
  870. return {
  871. index: this.index,
  872. offset: this.offset,
  873. ok: this.ok
  874. };
  875. }
  876. set state(s) {
  877. Object.assign(this, s);
  878. }
  879. pushState() {
  880. this._log.push(this.state);
  881. }
  882. popState() {
  883. const s = this._log.pop();
  884. this.state = s;
  885. return s;
  886. }
  887. bindBlock() {
  888. if (this.block) return;
  889. if (this.index < 0) {
  890. this.index = 0;
  891. this.offset = 0;
  892. }
  893. if (this.index >= this.masked._blocks.length) {
  894. this.index = this.masked._blocks.length - 1;
  895. this.offset = this.block.value.length;
  896. }
  897. }
  898. _pushLeft(fn) {
  899. this.pushState();
  900. for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block) === null || _this$block === void 0 ? void 0 : _this$block.value.length) || 0) {
  901. var _this$block;
  902. if (fn()) return this.ok = true;
  903. }
  904. return this.ok = false;
  905. }
  906. _pushRight(fn) {
  907. this.pushState();
  908. for (this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0) {
  909. if (fn()) return this.ok = true;
  910. }
  911. return this.ok = false;
  912. }
  913. pushLeftBeforeFilled() {
  914. return this._pushLeft(() => {
  915. if (this.block.isFixed || !this.block.value) return;
  916. this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_LEFT);
  917. if (this.offset !== 0) return true;
  918. });
  919. }
  920. pushLeftBeforeInput() {
  921. return this._pushLeft(() => {
  922. if (this.block.isFixed) return;
  923. this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);
  924. return true;
  925. });
  926. }
  927. pushLeftBeforeRequired() {
  928. return this._pushLeft(() => {
  929. if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
  930. this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);
  931. return true;
  932. });
  933. }
  934. pushRightBeforeFilled() {
  935. return this._pushRight(() => {
  936. if (this.block.isFixed || !this.block.value) return;
  937. this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_RIGHT);
  938. if (this.offset !== this.block.value.length) return true;
  939. });
  940. }
  941. pushRightBeforeInput() {
  942. return this._pushRight(() => {
  943. if (this.block.isFixed) return;
  944. this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
  945. return true;
  946. });
  947. }
  948. pushRightBeforeRequired() {
  949. return this._pushRight(() => {
  950. if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
  951. this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
  952. return true;
  953. });
  954. }
  955. }
  956. class MaskedRegExp extends Masked {
  957. _update(opts) {
  958. if (opts.mask) opts.validate = value => value.search(opts.mask) >= 0;
  959. super._update(opts);
  960. }
  961. }
  962. IMask.MaskedRegExp = MaskedRegExp;
  963. const _excluded$2 = ["_blocks"];
  964. class MaskedPattern extends Masked {
  965. constructor() {
  966. let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  967. opts.definitions = Object.assign({}, DEFAULT_INPUT_DEFINITIONS, opts.definitions);
  968. super(Object.assign({}, MaskedPattern.DEFAULTS, opts));
  969. }
  970. _update() {
  971. let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  972. opts.definitions = Object.assign({}, this.definitions, opts.definitions);
  973. super._update(opts);
  974. this._rebuildMask();
  975. }
  976. _rebuildMask() {
  977. const defs = this.definitions;
  978. this._blocks = [];
  979. this._stops = [];
  980. this._maskedBlocks = {};
  981. let pattern = this.mask;
  982. if (!pattern || !defs) return;
  983. let unmaskingBlock = false;
  984. let optionalBlock = false;
  985. for (let i = 0; i < pattern.length; ++i) {
  986. var _defs$char, _defs$char2;
  987. if (this.blocks) {
  988. const p = pattern.slice(i);
  989. const bNames = Object.keys(this.blocks).filter(bName => p.indexOf(bName) === 0);
  990. bNames.sort((a, b) => b.length - a.length);
  991. const bName = bNames[0];
  992. if (bName) {
  993. const maskedBlock = createMask(Object.assign({
  994. parent: this,
  995. lazy: this.lazy,
  996. eager: this.eager,
  997. placeholderChar: this.placeholderChar,
  998. displayChar: this.displayChar,
  999. overwrite: this.overwrite
  1000. }, this.blocks[bName]));
  1001. if (maskedBlock) {
  1002. this._blocks.push(maskedBlock);
  1003. if (!this._maskedBlocks[bName]) this._maskedBlocks[bName] = [];
  1004. this._maskedBlocks[bName].push(this._blocks.length - 1);
  1005. }
  1006. i += bName.length - 1;
  1007. continue;
  1008. }
  1009. }
  1010. let char = pattern[i];
  1011. let isInput = (char in defs);
  1012. if (char === MaskedPattern.STOP_CHAR) {
  1013. this._stops.push(this._blocks.length);
  1014. continue;
  1015. }
  1016. if (char === '{' || char === '}') {
  1017. unmaskingBlock = !unmaskingBlock;
  1018. continue;
  1019. }
  1020. if (char === '[' || char === ']') {
  1021. optionalBlock = !optionalBlock;
  1022. continue;
  1023. }
  1024. if (char === MaskedPattern.ESCAPE_CHAR) {
  1025. ++i;
  1026. char = pattern[i];
  1027. if (!char) break;
  1028. isInput = false;
  1029. }
  1030. const maskOpts = (_defs$char = defs[char]) !== null && _defs$char !== void 0 && _defs$char.mask && !(((_defs$char2 = defs[char]) === null || _defs$char2 === void 0 ? void 0 : _defs$char2.mask.prototype) instanceof IMask.Masked) ? defs[char] : {
  1031. mask: defs[char]
  1032. };
  1033. const def = isInput ? new PatternInputDefinition(Object.assign({
  1034. parent: this,
  1035. isOptional: optionalBlock,
  1036. lazy: this.lazy,
  1037. eager: this.eager,
  1038. placeholderChar: this.placeholderChar,
  1039. displayChar: this.displayChar
  1040. }, maskOpts)) : new PatternFixedDefinition({
  1041. char,
  1042. eager: this.eager,
  1043. isUnmasking: unmaskingBlock
  1044. });
  1045. this._blocks.push(def);
  1046. }
  1047. }
  1048. get state() {
  1049. return Object.assign({}, super.state, {
  1050. _blocks: this._blocks.map(b => b.state)
  1051. });
  1052. }
  1053. set state(state) {
  1054. const {
  1055. _blocks
  1056. } = state,
  1057. maskedState = _objectWithoutPropertiesLoose(state, _excluded$2);
  1058. this._blocks.forEach((b, bi) => b.state = _blocks[bi]);
  1059. super.state = maskedState;
  1060. }
  1061. reset() {
  1062. super.reset();
  1063. this._blocks.forEach(b => b.reset());
  1064. }
  1065. get isComplete() {
  1066. return this._blocks.every(b => b.isComplete);
  1067. }
  1068. get isFilled() {
  1069. return this._blocks.every(b => b.isFilled);
  1070. }
  1071. get isFixed() {
  1072. return this._blocks.every(b => b.isFixed);
  1073. }
  1074. get isOptional() {
  1075. return this._blocks.every(b => b.isOptional);
  1076. }
  1077. doCommit() {
  1078. this._blocks.forEach(b => b.doCommit());
  1079. super.doCommit();
  1080. }
  1081. get unmaskedValue() {
  1082. return this._blocks.reduce((str, b) => str += b.unmaskedValue, '');
  1083. }
  1084. set unmaskedValue(unmaskedValue) {
  1085. super.unmaskedValue = unmaskedValue;
  1086. }
  1087. get value() {
  1088. return this._blocks.reduce((str, b) => str += b.value, '');
  1089. }
  1090. set value(value) {
  1091. super.value = value;
  1092. }
  1093. get displayValue() {
  1094. return this._blocks.reduce((str, b) => str += b.displayValue, '');
  1095. }
  1096. appendTail(tail) {
  1097. return super.appendTail(tail).aggregate(this._appendPlaceholder());
  1098. }
  1099. _appendEager() {
  1100. var _this$_mapPosToBlock;
  1101. const details = new ChangeDetails();
  1102. let startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.value.length)) === null || _this$_mapPosToBlock === void 0 ? void 0 : _this$_mapPosToBlock.index;
  1103. if (startBlockIndex == null) return details;
  1104. if (this._blocks[startBlockIndex].isFilled) ++startBlockIndex;
  1105. for (let bi = startBlockIndex; bi < this._blocks.length; ++bi) {
  1106. const d = this._blocks[bi]._appendEager();
  1107. if (!d.inserted) break;
  1108. details.aggregate(d);
  1109. }
  1110. return details;
  1111. }
  1112. _appendCharRaw(ch) {
  1113. let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1114. const blockIter = this._mapPosToBlock(this.value.length);
  1115. const details = new ChangeDetails();
  1116. if (!blockIter) return details;
  1117. for (let bi = blockIter.index;; ++bi) {
  1118. var _flags$_beforeTailSta, _flags$_beforeTailSta2;
  1119. const block = this._blocks[bi];
  1120. if (!block) break;
  1121. const blockDetails = block._appendChar(ch, Object.assign({}, flags, {
  1122. _beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) === null || _flags$_beforeTailSta === void 0 ? void 0 : (_flags$_beforeTailSta2 = _flags$_beforeTailSta._blocks) === null || _flags$_beforeTailSta2 === void 0 ? void 0 : _flags$_beforeTailSta2[bi]
  1123. }));
  1124. const skip = blockDetails.skip;
  1125. details.aggregate(blockDetails);
  1126. if (skip || blockDetails.rawInserted) break;
  1127. }
  1128. return details;
  1129. }
  1130. extractTail() {
  1131. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1132. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  1133. const chunkTail = new ChunksTailDetails();
  1134. if (fromPos === toPos) return chunkTail;
  1135. this._forEachBlocksInRange(fromPos, toPos, (b, bi, bFromPos, bToPos) => {
  1136. const blockChunk = b.extractTail(bFromPos, bToPos);
  1137. blockChunk.stop = this._findStopBefore(bi);
  1138. blockChunk.from = this._blockStartPos(bi);
  1139. if (blockChunk instanceof ChunksTailDetails) blockChunk.blockIndex = bi;
  1140. chunkTail.extend(blockChunk);
  1141. });
  1142. return chunkTail;
  1143. }
  1144. extractInput() {
  1145. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1146. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  1147. let flags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1148. if (fromPos === toPos) return '';
  1149. let input = '';
  1150. this._forEachBlocksInRange(fromPos, toPos, (b, _, fromPos, toPos) => {
  1151. input += b.extractInput(fromPos, toPos, flags);
  1152. });
  1153. return input;
  1154. }
  1155. _findStopBefore(blockIndex) {
  1156. let stopBefore;
  1157. for (let si = 0; si < this._stops.length; ++si) {
  1158. const stop = this._stops[si];
  1159. if (stop <= blockIndex) stopBefore = stop;else break;
  1160. }
  1161. return stopBefore;
  1162. }
  1163. _appendPlaceholder(toBlockIndex) {
  1164. const details = new ChangeDetails();
  1165. if (this.lazy && toBlockIndex == null) return details;
  1166. const startBlockIter = this._mapPosToBlock(this.value.length);
  1167. if (!startBlockIter) return details;
  1168. const startBlockIndex = startBlockIter.index;
  1169. const endBlockIndex = toBlockIndex != null ? toBlockIndex : this._blocks.length;
  1170. this._blocks.slice(startBlockIndex, endBlockIndex).forEach(b => {
  1171. if (!b.lazy || toBlockIndex != null) {
  1172. const args = b._blocks != null ? [b._blocks.length] : [];
  1173. const bDetails = b._appendPlaceholder(...args);
  1174. this._value += bDetails.inserted;
  1175. details.aggregate(bDetails);
  1176. }
  1177. });
  1178. return details;
  1179. }
  1180. _mapPosToBlock(pos) {
  1181. let accVal = '';
  1182. for (let bi = 0; bi < this._blocks.length; ++bi) {
  1183. const block = this._blocks[bi];
  1184. const blockStartPos = accVal.length;
  1185. accVal += block.value;
  1186. if (pos <= accVal.length) {
  1187. return {
  1188. index: bi,
  1189. offset: pos - blockStartPos
  1190. };
  1191. }
  1192. }
  1193. }
  1194. _blockStartPos(blockIndex) {
  1195. return this._blocks.slice(0, blockIndex).reduce((pos, b) => pos += b.value.length, 0);
  1196. }
  1197. _forEachBlocksInRange(fromPos) {
  1198. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  1199. let fn = arguments.length > 2 ? arguments[2] : undefined;
  1200. const fromBlockIter = this._mapPosToBlock(fromPos);
  1201. if (fromBlockIter) {
  1202. const toBlockIter = this._mapPosToBlock(toPos);
  1203. const isSameBlock = toBlockIter && fromBlockIter.index === toBlockIter.index;
  1204. const fromBlockStartPos = fromBlockIter.offset;
  1205. const fromBlockEndPos = toBlockIter && isSameBlock ? toBlockIter.offset : this._blocks[fromBlockIter.index].value.length;
  1206. fn(this._blocks[fromBlockIter.index], fromBlockIter.index, fromBlockStartPos, fromBlockEndPos);
  1207. if (toBlockIter && !isSameBlock) {
  1208. for (let bi = fromBlockIter.index + 1; bi < toBlockIter.index; ++bi) {
  1209. fn(this._blocks[bi], bi, 0, this._blocks[bi].value.length);
  1210. }
  1211. fn(this._blocks[toBlockIter.index], toBlockIter.index, 0, toBlockIter.offset);
  1212. }
  1213. }
  1214. }
  1215. remove() {
  1216. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1217. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  1218. const removeDetails = super.remove(fromPos, toPos);
  1219. this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {
  1220. removeDetails.aggregate(b.remove(bFromPos, bToPos));
  1221. });
  1222. return removeDetails;
  1223. }
  1224. nearestInputPos(cursorPos) {
  1225. let direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
  1226. if (!this._blocks.length) return 0;
  1227. const cursor = new PatternCursor(this, cursorPos);
  1228. if (direction === DIRECTION.NONE) {
  1229. if (cursor.pushRightBeforeInput()) return cursor.pos;
  1230. cursor.popState();
  1231. if (cursor.pushLeftBeforeInput()) return cursor.pos;
  1232. return this.value.length;
  1233. }
  1234. if (direction === DIRECTION.LEFT || direction === DIRECTION.FORCE_LEFT) {
  1235. if (direction === DIRECTION.LEFT) {
  1236. cursor.pushRightBeforeFilled();
  1237. if (cursor.ok && cursor.pos === cursorPos) return cursorPos;
  1238. cursor.popState();
  1239. }
  1240. cursor.pushLeftBeforeInput();
  1241. cursor.pushLeftBeforeRequired();
  1242. cursor.pushLeftBeforeFilled();
  1243. if (direction === DIRECTION.LEFT) {
  1244. cursor.pushRightBeforeInput();
  1245. cursor.pushRightBeforeRequired();
  1246. if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
  1247. cursor.popState();
  1248. if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
  1249. cursor.popState();
  1250. }
  1251. if (cursor.ok) return cursor.pos;
  1252. if (direction === DIRECTION.FORCE_LEFT) return 0;
  1253. cursor.popState();
  1254. if (cursor.ok) return cursor.pos;
  1255. cursor.popState();
  1256. if (cursor.ok) return cursor.pos;
  1257. return 0;
  1258. }
  1259. if (direction === DIRECTION.RIGHT || direction === DIRECTION.FORCE_RIGHT) {
  1260. cursor.pushRightBeforeInput();
  1261. cursor.pushRightBeforeRequired();
  1262. if (cursor.pushRightBeforeFilled()) return cursor.pos;
  1263. if (direction === DIRECTION.FORCE_RIGHT) return this.value.length;
  1264. cursor.popState();
  1265. if (cursor.ok) return cursor.pos;
  1266. cursor.popState();
  1267. if (cursor.ok) return cursor.pos;
  1268. return this.nearestInputPos(cursorPos, DIRECTION.LEFT);
  1269. }
  1270. return cursorPos;
  1271. }
  1272. totalInputPositions() {
  1273. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1274. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  1275. let total = 0;
  1276. this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {
  1277. total += b.totalInputPositions(bFromPos, bToPos);
  1278. });
  1279. return total;
  1280. }
  1281. maskedBlock(name) {
  1282. return this.maskedBlocks(name)[0];
  1283. }
  1284. maskedBlocks(name) {
  1285. const indices = this._maskedBlocks[name];
  1286. if (!indices) return [];
  1287. return indices.map(gi => this._blocks[gi]);
  1288. }
  1289. }
  1290. MaskedPattern.DEFAULTS = {
  1291. lazy: true,
  1292. placeholderChar: '_'
  1293. };
  1294. MaskedPattern.STOP_CHAR = '`';
  1295. MaskedPattern.ESCAPE_CHAR = '\\';
  1296. MaskedPattern.InputDefinition = PatternInputDefinition;
  1297. MaskedPattern.FixedDefinition = PatternFixedDefinition;
  1298. IMask.MaskedPattern = MaskedPattern;
  1299. class MaskedRange extends MaskedPattern {
  1300. get _matchFrom() {
  1301. return this.maxLength - String(this.from).length;
  1302. }
  1303. _update(opts) {
  1304. opts = Object.assign({
  1305. to: this.to || 0,
  1306. from: this.from || 0,
  1307. maxLength: this.maxLength || 0
  1308. }, opts);
  1309. let maxLength = String(opts.to).length;
  1310. if (opts.maxLength != null) maxLength = Math.max(maxLength, opts.maxLength);
  1311. opts.maxLength = maxLength;
  1312. const fromStr = String(opts.from).padStart(maxLength, '0');
  1313. const toStr = String(opts.to).padStart(maxLength, '0');
  1314. let sameCharsCount = 0;
  1315. while (sameCharsCount < toStr.length && toStr[sameCharsCount] === fromStr[sameCharsCount]) ++sameCharsCount;
  1316. opts.mask = toStr.slice(0, sameCharsCount).replace(/0/g, '\\0') + '0'.repeat(maxLength - sameCharsCount);
  1317. super._update(opts);
  1318. }
  1319. get isComplete() {
  1320. return super.isComplete && Boolean(this.value);
  1321. }
  1322. boundaries(str) {
  1323. let minstr = '';
  1324. let maxstr = '';
  1325. const [, placeholder, num] = str.match(/^(\D*)(\d*)(\D*)/) || [];
  1326. if (num) {
  1327. minstr = '0'.repeat(placeholder.length) + num;
  1328. maxstr = '9'.repeat(placeholder.length) + num;
  1329. }
  1330. minstr = minstr.padEnd(this.maxLength, '0');
  1331. maxstr = maxstr.padEnd(this.maxLength, '9');
  1332. return [minstr, maxstr];
  1333. }
  1334. doPrepare(ch) {
  1335. let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1336. let details;
  1337. [ch, details] = normalizePrepare(super.doPrepare(ch.replace(/\D/g, ''), flags));
  1338. if (!this.autofix || !ch) return ch;
  1339. const fromStr = String(this.from).padStart(this.maxLength, '0');
  1340. const toStr = String(this.to).padStart(this.maxLength, '0');
  1341. let nextVal = this.value + ch;
  1342. if (nextVal.length > this.maxLength) return '';
  1343. const [minstr, maxstr] = this.boundaries(nextVal);
  1344. if (Number(maxstr) < this.from) return fromStr[nextVal.length - 1];
  1345. if (Number(minstr) > this.to) {
  1346. if (this.autofix === 'pad' && nextVal.length < this.maxLength) {
  1347. return ['', details.aggregate(this.append(fromStr[nextVal.length - 1] + ch, flags))];
  1348. }
  1349. return toStr[nextVal.length - 1];
  1350. }
  1351. return ch;
  1352. }
  1353. doValidate() {
  1354. const str = this.value;
  1355. const firstNonZero = str.search(/[^0]/);
  1356. if (firstNonZero === -1 && str.length <= this._matchFrom) return true;
  1357. const [minstr, maxstr] = this.boundaries(str);
  1358. return this.from <= Number(maxstr) && Number(minstr) <= this.to && super.doValidate(...arguments);
  1359. }
  1360. }
  1361. IMask.MaskedRange = MaskedRange;
  1362. class MaskedDate extends MaskedPattern {
  1363. constructor(opts) {
  1364. super(Object.assign({}, MaskedDate.DEFAULTS, opts));
  1365. }
  1366. _update(opts) {
  1367. if (opts.mask === Date) delete opts.mask;
  1368. if (opts.pattern) opts.mask = opts.pattern;
  1369. const blocks = opts.blocks;
  1370. opts.blocks = Object.assign({}, MaskedDate.GET_DEFAULT_BLOCKS());
  1371. if (opts.min) opts.blocks.Y.from = opts.min.getFullYear();
  1372. if (opts.max) opts.blocks.Y.to = opts.max.getFullYear();
  1373. if (opts.min && opts.max && opts.blocks.Y.from === opts.blocks.Y.to) {
  1374. opts.blocks.m.from = opts.min.getMonth() + 1;
  1375. opts.blocks.m.to = opts.max.getMonth() + 1;
  1376. if (opts.blocks.m.from === opts.blocks.m.to) {
  1377. opts.blocks.d.from = opts.min.getDate();
  1378. opts.blocks.d.to = opts.max.getDate();
  1379. }
  1380. }
  1381. Object.assign(opts.blocks, this.blocks, blocks);
  1382. Object.keys(opts.blocks).forEach(bk => {
  1383. const b = opts.blocks[bk];
  1384. if (!('autofix' in b) && 'autofix' in opts) b.autofix = opts.autofix;
  1385. });
  1386. super._update(opts);
  1387. }
  1388. doValidate() {
  1389. const date = this.date;
  1390. return super.doValidate(...arguments) && (!this.isComplete || this.isDateExist(this.value) && date != null && (this.min == null || this.min <= date) && (this.max == null || date <= this.max));
  1391. }
  1392. isDateExist(str) {
  1393. return this.format(this.parse(str, this), this).indexOf(str) >= 0;
  1394. }
  1395. get date() {
  1396. return this.typedValue;
  1397. }
  1398. set date(date) {
  1399. this.typedValue = date;
  1400. }
  1401. get typedValue() {
  1402. return this.isComplete ? super.typedValue : null;
  1403. }
  1404. set typedValue(value) {
  1405. super.typedValue = value;
  1406. }
  1407. maskEquals(mask) {
  1408. return mask === Date || super.maskEquals(mask);
  1409. }
  1410. }
  1411. MaskedDate.DEFAULTS = {
  1412. pattern: 'd{.}`m{.}`Y',
  1413. format: date => {
  1414. if (!date) return '';
  1415. const day = String(date.getDate()).padStart(2, '0');
  1416. const month = String(date.getMonth() + 1).padStart(2, '0');
  1417. const year = date.getFullYear();
  1418. return [day, month, year].join('.');
  1419. },
  1420. parse: str => {
  1421. const [day, month, year] = str.split('.');
  1422. return new Date(year, month - 1, day);
  1423. }
  1424. };
  1425. MaskedDate.GET_DEFAULT_BLOCKS = () => ({
  1426. d: {
  1427. mask: MaskedRange,
  1428. from: 1,
  1429. to: 31,
  1430. maxLength: 2
  1431. },
  1432. m: {
  1433. mask: MaskedRange,
  1434. from: 1,
  1435. to: 12,
  1436. maxLength: 2
  1437. },
  1438. Y: {
  1439. mask: MaskedRange,
  1440. from: 1900,
  1441. to: 9999
  1442. }
  1443. });
  1444. IMask.MaskedDate = MaskedDate;
  1445. class MaskElement {
  1446. get selectionStart() {
  1447. let start;
  1448. try {
  1449. start = this._unsafeSelectionStart;
  1450. } catch (e) {}
  1451. return start != null ? start : this.value.length;
  1452. }
  1453. get selectionEnd() {
  1454. let end;
  1455. try {
  1456. end = this._unsafeSelectionEnd;
  1457. } catch (e) {}
  1458. return end != null ? end : this.value.length;
  1459. }
  1460. select(start, end) {
  1461. if (start == null || end == null || start === this.selectionStart && end === this.selectionEnd) return;
  1462. try {
  1463. this._unsafeSelect(start, end);
  1464. } catch (e) {}
  1465. }
  1466. _unsafeSelect(start, end) {}
  1467. get isActive() {
  1468. return false;
  1469. }
  1470. bindEvents(handlers) {}
  1471. unbindEvents() {}
  1472. }
  1473. IMask.MaskElement = MaskElement;
  1474. class HTMLMaskElement extends MaskElement {
  1475. constructor(input) {
  1476. super();
  1477. this.input = input;
  1478. this._handlers = {};
  1479. }
  1480. get rootElement() {
  1481. var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
  1482. return (_this$input$getRootNo = (_this$input$getRootNo2 = (_this$input = this.input).getRootNode) === null || _this$input$getRootNo2 === void 0 ? void 0 : _this$input$getRootNo2.call(_this$input)) !== null && _this$input$getRootNo !== void 0 ? _this$input$getRootNo : document;
  1483. }
  1484. get isActive() {
  1485. return this.input === this.rootElement.activeElement;
  1486. }
  1487. get _unsafeSelectionStart() {
  1488. return this.input.selectionStart;
  1489. }
  1490. get _unsafeSelectionEnd() {
  1491. return this.input.selectionEnd;
  1492. }
  1493. _unsafeSelect(start, end) {
  1494. this.input.setSelectionRange(start, end);
  1495. }
  1496. get value() {
  1497. return this.input.value;
  1498. }
  1499. set value(value) {
  1500. this.input.value = value;
  1501. }
  1502. bindEvents(handlers) {
  1503. Object.keys(handlers).forEach(event => this._toggleEventHandler(HTMLMaskElement.EVENTS_MAP[event], handlers[event]));
  1504. }
  1505. unbindEvents() {
  1506. Object.keys(this._handlers).forEach(event => this._toggleEventHandler(event));
  1507. }
  1508. _toggleEventHandler(event, handler) {
  1509. if (this._handlers[event]) {
  1510. this.input.removeEventListener(event, this._handlers[event]);
  1511. delete this._handlers[event];
  1512. }
  1513. if (handler) {
  1514. this.input.addEventListener(event, handler);
  1515. this._handlers[event] = handler;
  1516. }
  1517. }
  1518. }
  1519. HTMLMaskElement.EVENTS_MAP = {
  1520. selectionChange: 'keydown',
  1521. input: 'input',
  1522. drop: 'drop',
  1523. click: 'click',
  1524. focus: 'focus',
  1525. commit: 'blur'
  1526. };
  1527. IMask.HTMLMaskElement = HTMLMaskElement;
  1528. class HTMLContenteditableMaskElement extends HTMLMaskElement {
  1529. get _unsafeSelectionStart() {
  1530. const root = this.rootElement;
  1531. const selection = root.getSelection && root.getSelection();
  1532. const anchorOffset = selection && selection.anchorOffset;
  1533. const focusOffset = selection && selection.focusOffset;
  1534. if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
  1535. return anchorOffset;
  1536. }
  1537. return focusOffset;
  1538. }
  1539. get _unsafeSelectionEnd() {
  1540. const root = this.rootElement;
  1541. const selection = root.getSelection && root.getSelection();
  1542. const anchorOffset = selection && selection.anchorOffset;
  1543. const focusOffset = selection && selection.focusOffset;
  1544. if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
  1545. return anchorOffset;
  1546. }
  1547. return focusOffset;
  1548. }
  1549. _unsafeSelect(start, end) {
  1550. if (!this.rootElement.createRange) return;
  1551. const range = this.rootElement.createRange();
  1552. range.setStart(this.input.firstChild || this.input, start);
  1553. range.setEnd(this.input.lastChild || this.input, end);
  1554. const root = this.rootElement;
  1555. const selection = root.getSelection && root.getSelection();
  1556. if (selection) {
  1557. selection.removeAllRanges();
  1558. selection.addRange(range);
  1559. }
  1560. }
  1561. get value() {
  1562. return this.input.textContent;
  1563. }
  1564. set value(value) {
  1565. this.input.textContent = value;
  1566. }
  1567. }
  1568. IMask.HTMLContenteditableMaskElement = HTMLContenteditableMaskElement;
  1569. const _excluded$1 = ["mask"];
  1570. class InputMask {
  1571. constructor(el, opts) {
  1572. this.el = el instanceof MaskElement ? el : el.isContentEditable && el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' ? new HTMLContenteditableMaskElement(el) : new HTMLMaskElement(el);
  1573. this.masked = createMask(opts);
  1574. this._listeners = {};
  1575. this._value = '';
  1576. this._unmaskedValue = '';
  1577. this._saveSelection = this._saveSelection.bind(this);
  1578. this._onInput = this._onInput.bind(this);
  1579. this._onChange = this._onChange.bind(this);
  1580. this._onDrop = this._onDrop.bind(this);
  1581. this._onFocus = this._onFocus.bind(this);
  1582. this._onClick = this._onClick.bind(this);
  1583. this.alignCursor = this.alignCursor.bind(this);
  1584. this.alignCursorFriendly = this.alignCursorFriendly.bind(this);
  1585. this._bindEvents();
  1586. this.updateValue();
  1587. this._onChange();
  1588. }
  1589. get mask() {
  1590. return this.masked.mask;
  1591. }
  1592. maskEquals(mask) {
  1593. var _this$masked;
  1594. return mask == null || ((_this$masked = this.masked) === null || _this$masked === void 0 ? void 0 : _this$masked.maskEquals(mask));
  1595. }
  1596. set mask(mask) {
  1597. if (this.maskEquals(mask)) return;
  1598. if (!(mask instanceof IMask.Masked) && this.masked.constructor === maskedClass(mask)) {
  1599. this.masked.updateOptions({
  1600. mask
  1601. });
  1602. return;
  1603. }
  1604. const masked = createMask({
  1605. mask
  1606. });
  1607. masked.unmaskedValue = this.masked.unmaskedValue;
  1608. this.masked = masked;
  1609. }
  1610. get value() {
  1611. return this._value;
  1612. }
  1613. set value(str) {
  1614. if (this.value === str) return;
  1615. this.masked.value = str;
  1616. this.updateControl();
  1617. this.alignCursor();
  1618. }
  1619. get unmaskedValue() {
  1620. return this._unmaskedValue;
  1621. }
  1622. set unmaskedValue(str) {
  1623. if (this.unmaskedValue === str) return;
  1624. this.masked.unmaskedValue = str;
  1625. this.updateControl();
  1626. this.alignCursor();
  1627. }
  1628. get typedValue() {
  1629. return this.masked.typedValue;
  1630. }
  1631. set typedValue(val) {
  1632. if (this.masked.typedValueEquals(val)) return;
  1633. this.masked.typedValue = val;
  1634. this.updateControl();
  1635. this.alignCursor();
  1636. }
  1637. get displayValue() {
  1638. return this.masked.displayValue;
  1639. }
  1640. _bindEvents() {
  1641. this.el.bindEvents({
  1642. selectionChange: this._saveSelection,
  1643. input: this._onInput,
  1644. drop: this._onDrop,
  1645. click: this._onClick,
  1646. focus: this._onFocus,
  1647. commit: this._onChange
  1648. });
  1649. }
  1650. _unbindEvents() {
  1651. if (this.el) this.el.unbindEvents();
  1652. }
  1653. _fireEvent(ev) {
  1654. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1655. args[_key - 1] = arguments[_key];
  1656. }
  1657. const listeners = this._listeners[ev];
  1658. if (!listeners) return;
  1659. listeners.forEach(l => l(...args));
  1660. }
  1661. get selectionStart() {
  1662. return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
  1663. }
  1664. get cursorPos() {
  1665. return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
  1666. }
  1667. set cursorPos(pos) {
  1668. if (!this.el || !this.el.isActive) return;
  1669. this.el.select(pos, pos);
  1670. this._saveSelection();
  1671. }
  1672. _saveSelection(
  1673. ) {
  1674. if (this.displayValue !== this.el.value) {
  1675. console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.');
  1676. }
  1677. this._selection = {
  1678. start: this.selectionStart,
  1679. end: this.cursorPos
  1680. };
  1681. }
  1682. updateValue() {
  1683. this.masked.value = this.el.value;
  1684. this._value = this.masked.value;
  1685. }
  1686. updateControl() {
  1687. const newUnmaskedValue = this.masked.unmaskedValue;
  1688. const newValue = this.masked.value;
  1689. const newDisplayValue = this.displayValue;
  1690. const isChanged = this.unmaskedValue !== newUnmaskedValue || this.value !== newValue;
  1691. this._unmaskedValue = newUnmaskedValue;
  1692. this._value = newValue;
  1693. if (this.el.value !== newDisplayValue) this.el.value = newDisplayValue;
  1694. if (isChanged) this._fireChangeEvents();
  1695. }
  1696. updateOptions(opts) {
  1697. const {
  1698. mask
  1699. } = opts,
  1700. restOpts = _objectWithoutPropertiesLoose(opts, _excluded$1);
  1701. const updateMask = !this.maskEquals(mask);
  1702. const updateOpts = !objectIncludes(this.masked, restOpts);
  1703. if (updateMask) this.mask = mask;
  1704. if (updateOpts) this.masked.updateOptions(restOpts);
  1705. if (updateMask || updateOpts) this.updateControl();
  1706. }
  1707. updateCursor(cursorPos) {
  1708. if (cursorPos == null) return;
  1709. this.cursorPos = cursorPos;
  1710. this._delayUpdateCursor(cursorPos);
  1711. }
  1712. _delayUpdateCursor(cursorPos) {
  1713. this._abortUpdateCursor();
  1714. this._changingCursorPos = cursorPos;
  1715. this._cursorChanging = setTimeout(() => {
  1716. if (!this.el) return;
  1717. this.cursorPos = this._changingCursorPos;
  1718. this._abortUpdateCursor();
  1719. }, 10);
  1720. }
  1721. _fireChangeEvents() {
  1722. this._fireEvent('accept', this._inputEvent);
  1723. if (this.masked.isComplete) this._fireEvent('complete', this._inputEvent);
  1724. }
  1725. _abortUpdateCursor() {
  1726. if (this._cursorChanging) {
  1727. clearTimeout(this._cursorChanging);
  1728. delete this._cursorChanging;
  1729. }
  1730. }
  1731. alignCursor() {
  1732. this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT));
  1733. }
  1734. alignCursorFriendly() {
  1735. if (this.selectionStart !== this.cursorPos) return;
  1736. this.alignCursor();
  1737. }
  1738. on(ev, handler) {
  1739. if (!this._listeners[ev]) this._listeners[ev] = [];
  1740. this._listeners[ev].push(handler);
  1741. return this;
  1742. }
  1743. off(ev, handler) {
  1744. if (!this._listeners[ev]) return this;
  1745. if (!handler) {
  1746. delete this._listeners[ev];
  1747. return this;
  1748. }
  1749. const hIndex = this._listeners[ev].indexOf(handler);
  1750. if (hIndex >= 0) this._listeners[ev].splice(hIndex, 1);
  1751. return this;
  1752. }
  1753. _onInput(e) {
  1754. this._inputEvent = e;
  1755. this._abortUpdateCursor();
  1756. if (!this._selection) return this.updateValue();
  1757. const details = new ActionDetails(
  1758. this.el.value, this.cursorPos,
  1759. this.displayValue, this._selection);
  1760. const oldRawValue = this.masked.rawInputValue;
  1761. const offset = this.masked.splice(details.startChangePos, details.removed.length, details.inserted, details.removeDirection, {
  1762. input: true,
  1763. raw: true
  1764. }).offset;
  1765. const removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;
  1766. let cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);
  1767. if (removeDirection !== DIRECTION.NONE) cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);
  1768. this.updateControl();
  1769. this.updateCursor(cursorPos);
  1770. delete this._inputEvent;
  1771. }
  1772. _onChange() {
  1773. if (this.displayValue !== this.el.value) {
  1774. this.updateValue();
  1775. }
  1776. this.masked.doCommit();
  1777. this.updateControl();
  1778. this._saveSelection();
  1779. }
  1780. _onDrop(ev) {
  1781. ev.preventDefault();
  1782. ev.stopPropagation();
  1783. }
  1784. _onFocus(ev) {
  1785. this.alignCursorFriendly();
  1786. }
  1787. _onClick(ev) {
  1788. this.alignCursorFriendly();
  1789. }
  1790. destroy() {
  1791. this._unbindEvents();
  1792. this._listeners.length = 0;
  1793. delete this.el;
  1794. }
  1795. }
  1796. IMask.InputMask = InputMask;
  1797. class MaskedEnum extends MaskedPattern {
  1798. _update(opts) {
  1799. if (opts.enum) opts.mask = '*'.repeat(opts.enum[0].length);
  1800. super._update(opts);
  1801. }
  1802. doValidate() {
  1803. return this.enum.some(e => e.indexOf(this.unmaskedValue) >= 0) && super.doValidate(...arguments);
  1804. }
  1805. }
  1806. IMask.MaskedEnum = MaskedEnum;
  1807. class MaskedNumber extends Masked {
  1808. constructor(opts) {
  1809. super(Object.assign({}, MaskedNumber.DEFAULTS, opts));
  1810. }
  1811. _update(opts) {
  1812. super._update(opts);
  1813. this._updateRegExps();
  1814. }
  1815. _updateRegExps() {
  1816. let start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
  1817. let mid = '\\d*';
  1818. let end = (this.scale ? "(".concat(escapeRegExp(this.radix), "\\d{0,").concat(this.scale, "})?") : '') + '$';
  1819. this._numberRegExp = new RegExp(start + mid + end);
  1820. this._mapToRadixRegExp = new RegExp("[".concat(this.mapToRadix.map(escapeRegExp).join(''), "]"), 'g');
  1821. this._thousandsSeparatorRegExp = new RegExp(escapeRegExp(this.thousandsSeparator), 'g');
  1822. }
  1823. _removeThousandsSeparators(value) {
  1824. return value.replace(this._thousandsSeparatorRegExp, '');
  1825. }
  1826. _insertThousandsSeparators(value) {
  1827. const parts = value.split(this.radix);
  1828. parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator);
  1829. return parts.join(this.radix);
  1830. }
  1831. doPrepare(ch) {
  1832. let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1833. ch = this._removeThousandsSeparators(this.scale && this.mapToRadix.length && (
  1834. flags.input && flags.raw || !flags.input && !flags.raw) ? ch.replace(this._mapToRadixRegExp, this.radix) : ch);
  1835. const [prepCh, details] = normalizePrepare(super.doPrepare(ch, flags));
  1836. if (ch && !prepCh) details.skip = true;
  1837. return [prepCh, details];
  1838. }
  1839. _separatorsCount(to) {
  1840. let extendOnSeparators = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1841. let count = 0;
  1842. for (let pos = 0; pos < to; ++pos) {
  1843. if (this._value.indexOf(this.thousandsSeparator, pos) === pos) {
  1844. ++count;
  1845. if (extendOnSeparators) to += this.thousandsSeparator.length;
  1846. }
  1847. }
  1848. return count;
  1849. }
  1850. _separatorsCountFromSlice() {
  1851. let slice = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._value;
  1852. return this._separatorsCount(this._removeThousandsSeparators(slice).length, true);
  1853. }
  1854. extractInput() {
  1855. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1856. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  1857. let flags = arguments.length > 2 ? arguments[2] : undefined;
  1858. [fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
  1859. return this._removeThousandsSeparators(super.extractInput(fromPos, toPos, flags));
  1860. }
  1861. _appendCharRaw(ch) {
  1862. let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1863. if (!this.thousandsSeparator) return super._appendCharRaw(ch, flags);
  1864. const prevBeforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
  1865. const prevBeforeTailSeparatorsCount = this._separatorsCountFromSlice(prevBeforeTailValue);
  1866. this._value = this._removeThousandsSeparators(this.value);
  1867. const appendDetails = super._appendCharRaw(ch, flags);
  1868. this._value = this._insertThousandsSeparators(this._value);
  1869. const beforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
  1870. const beforeTailSeparatorsCount = this._separatorsCountFromSlice(beforeTailValue);
  1871. appendDetails.tailShift += (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length;
  1872. appendDetails.skip = !appendDetails.rawInserted && ch === this.thousandsSeparator;
  1873. return appendDetails;
  1874. }
  1875. _findSeparatorAround(pos) {
  1876. if (this.thousandsSeparator) {
  1877. const searchFrom = pos - this.thousandsSeparator.length + 1;
  1878. const separatorPos = this.value.indexOf(this.thousandsSeparator, searchFrom);
  1879. if (separatorPos <= pos) return separatorPos;
  1880. }
  1881. return -1;
  1882. }
  1883. _adjustRangeWithSeparators(from, to) {
  1884. const separatorAroundFromPos = this._findSeparatorAround(from);
  1885. if (separatorAroundFromPos >= 0) from = separatorAroundFromPos;
  1886. const separatorAroundToPos = this._findSeparatorAround(to);
  1887. if (separatorAroundToPos >= 0) to = separatorAroundToPos + this.thousandsSeparator.length;
  1888. return [from, to];
  1889. }
  1890. remove() {
  1891. let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1892. let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
  1893. [fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
  1894. const valueBeforePos = this.value.slice(0, fromPos);
  1895. const valueAfterPos = this.value.slice(toPos);
  1896. const prevBeforeTailSeparatorsCount = this._separatorsCount(valueBeforePos.length);
  1897. this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(valueBeforePos + valueAfterPos));
  1898. const beforeTailSeparatorsCount = this._separatorsCountFromSlice(valueBeforePos);
  1899. return new ChangeDetails({
  1900. tailShift: (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length
  1901. });
  1902. }
  1903. nearestInputPos(cursorPos, direction) {
  1904. if (!this.thousandsSeparator) return cursorPos;
  1905. switch (direction) {
  1906. case DIRECTION.NONE:
  1907. case DIRECTION.LEFT:
  1908. case DIRECTION.FORCE_LEFT:
  1909. {
  1910. const separatorAtLeftPos = this._findSeparatorAround(cursorPos - 1);
  1911. if (separatorAtLeftPos >= 0) {
  1912. const separatorAtLeftEndPos = separatorAtLeftPos + this.thousandsSeparator.length;
  1913. if (cursorPos < separatorAtLeftEndPos || this.value.length <= separatorAtLeftEndPos || direction === DIRECTION.FORCE_LEFT) {
  1914. return separatorAtLeftPos;
  1915. }
  1916. }
  1917. break;
  1918. }
  1919. case DIRECTION.RIGHT:
  1920. case DIRECTION.FORCE_RIGHT:
  1921. {
  1922. const separatorAtRightPos = this._findSeparatorAround(cursorPos);
  1923. if (separatorAtRightPos >= 0) {
  1924. return separatorAtRightPos + this.thousandsSeparator.length;
  1925. }
  1926. }
  1927. }
  1928. return cursorPos;
  1929. }
  1930. doValidate(flags) {
  1931. let valid = Boolean(this._removeThousandsSeparators(this.value).match(this._numberRegExp));
  1932. if (valid) {
  1933. const number = this.number;
  1934. valid = valid && !isNaN(number) && (
  1935. this.min == null || this.min >= 0 || this.min <= this.number) && (
  1936. this.max == null || this.max <= 0 || this.number <= this.max);
  1937. }
  1938. return valid && super.doValidate(flags);
  1939. }
  1940. doCommit() {
  1941. if (this.value) {
  1942. const number = this.number;
  1943. let validnum = number;
  1944. if (this.min != null) validnum = Math.max(validnum, this.min);
  1945. if (this.max != null) validnum = Math.min(validnum, this.max);
  1946. if (validnum !== number) this.unmaskedValue = this.doFormat(validnum);
  1947. let formatted = this.value;
  1948. if (this.normalizeZeros) formatted = this._normalizeZeros(formatted);
  1949. if (this.padFractionalZeros && this.scale > 0) formatted = this._padFractionalZeros(formatted);
  1950. this._value = formatted;
  1951. }
  1952. super.doCommit();
  1953. }
  1954. _normalizeZeros(value) {
  1955. const parts = this._removeThousandsSeparators(value).split(this.radix);
  1956. parts[0] = parts[0].replace(/^(\D*)(0*)(\d*)/, (match, sign, zeros, num) => sign + num);
  1957. if (value.length && !/\d$/.test(parts[0])) parts[0] = parts[0] + '0';
  1958. if (parts.length > 1) {
  1959. parts[1] = parts[1].replace(/0*$/, '');
  1960. if (!parts[1].length) parts.length = 1;
  1961. }
  1962. return this._insertThousandsSeparators(parts.join(this.radix));
  1963. }
  1964. _padFractionalZeros(value) {
  1965. if (!value) return value;
  1966. const parts = value.split(this.radix);
  1967. if (parts.length < 2) parts.push('');
  1968. parts[1] = parts[1].padEnd(this.scale, '0');
  1969. return parts.join(this.radix);
  1970. }
  1971. doSkipInvalid(ch) {
  1972. let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1973. let checkTail = arguments.length > 2 ? arguments[2] : undefined;
  1974. const dropFractional = this.scale === 0 && ch !== this.thousandsSeparator && (ch === this.radix || ch === MaskedNumber.UNMASKED_RADIX || this.mapToRadix.includes(ch));
  1975. return super.doSkipInvalid(ch, flags, checkTail) && !dropFractional;
  1976. }
  1977. get unmaskedValue() {
  1978. return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, MaskedNumber.UNMASKED_RADIX);
  1979. }
  1980. set unmaskedValue(unmaskedValue) {
  1981. super.unmaskedValue = unmaskedValue;
  1982. }
  1983. get typedValue() {
  1984. return this.doParse(this.unmaskedValue);
  1985. }
  1986. set typedValue(n) {
  1987. this.rawInputValue = this.doFormat(n).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
  1988. }
  1989. get number() {
  1990. return this.typedValue;
  1991. }
  1992. set number(number) {
  1993. this.typedValue = number;
  1994. }
  1995. get allowNegative() {
  1996. return this.signed || this.min != null && this.min < 0 || this.max != null && this.max < 0;
  1997. }
  1998. typedValueEquals(value) {
  1999. return (super.typedValueEquals(value) || MaskedNumber.EMPTY_VALUES.includes(value) && MaskedNumber.EMPTY_VALUES.includes(this.typedValue)) && !(value === 0 && this.value === '');
  2000. }
  2001. }
  2002. MaskedNumber.UNMASKED_RADIX = '.';
  2003. MaskedNumber.DEFAULTS = {
  2004. radix: ',',
  2005. thousandsSeparator: '',
  2006. mapToRadix: [MaskedNumber.UNMASKED_RADIX],
  2007. scale: 2,
  2008. signed: false,
  2009. normalizeZeros: true,
  2010. padFractionalZeros: false,
  2011. parse: Number,
  2012. format: n => n.toLocaleString('en-US', {
  2013. useGrouping: false,
  2014. maximumFractionDigits: 20
  2015. })
  2016. };
  2017. MaskedNumber.EMPTY_VALUES = [...Masked.EMPTY_VALUES, 0];
  2018. IMask.MaskedNumber = MaskedNumber;
  2019. class MaskedFunction extends Masked {
  2020. _update(opts) {
  2021. if (opts.mask) opts.validate = opts.mask;
  2022. super._update(opts);
  2023. }
  2024. }
  2025. IMask.MaskedFunction = MaskedFunction;
  2026. const _excluded = ["compiledMasks", "currentMaskRef", "currentMask"],
  2027. _excluded2 = ["mask"];
  2028. class MaskedDynamic extends Masked {
  2029. constructor(opts) {
  2030. super(Object.assign({}, MaskedDynamic.DEFAULTS, opts));
  2031. this.currentMask = null;
  2032. }
  2033. _update(opts) {
  2034. super._update(opts);
  2035. if ('mask' in opts) {
  2036. this.compiledMasks = Array.isArray(opts.mask) ? opts.mask.map(m => createMask(m)) : [];
  2037. }
  2038. }
  2039. _appendCharRaw(ch) {
  2040. let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2041. const details = this._applyDispatch(ch, flags);
  2042. if (this.currentMask) {
  2043. details.aggregate(this.currentMask._appendChar(ch, this.currentMaskFlags(flags)));
  2044. }
  2045. return details;
  2046. }
  2047. _applyDispatch() {
  2048. let appended = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  2049. let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2050. let tail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  2051. const prevValueBeforeTail = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._value : this.value;
  2052. const inputValue = this.rawInputValue;
  2053. const insertValue = flags.tail && flags._beforeTailState != null ?
  2054. flags._beforeTailState._rawInputValue : inputValue;
  2055. const tailValue = inputValue.slice(insertValue.length);
  2056. const prevMask = this.currentMask;
  2057. const details = new ChangeDetails();
  2058. const prevMaskState = prevMask === null || prevMask === void 0 ? void 0 : prevMask.state;
  2059. this.currentMask = this.doDispatch(appended, Object.assign({}, flags), tail);
  2060. if (this.currentMask) {
  2061. if (this.currentMask !== prevMask) {
  2062. this.currentMask.reset();
  2063. if (insertValue) {
  2064. const d = this.currentMask.append(insertValue, {
  2065. raw: true
  2066. });
  2067. details.tailShift = d.inserted.length - prevValueBeforeTail.length;
  2068. }
  2069. if (tailValue) {
  2070. details.tailShift += this.currentMask.append(tailValue, {
  2071. raw: true,
  2072. tail: true
  2073. }).tailShift;
  2074. }
  2075. } else {
  2076. this.currentMask.state = prevMaskState;
  2077. }
  2078. }
  2079. return details;
  2080. }
  2081. _appendPlaceholder() {
  2082. const details = this._applyDispatch(...arguments);
  2083. if (this.currentMask) {
  2084. details.aggregate(this.currentMask._appendPlaceholder());
  2085. }
  2086. return details;
  2087. }
  2088. _appendEager() {
  2089. const details = this._applyDispatch(...arguments);
  2090. if (this.currentMask) {
  2091. details.aggregate(this.currentMask._appendEager());
  2092. }
  2093. return details;
  2094. }
  2095. appendTail(tail) {
  2096. const details = new ChangeDetails();
  2097. if (tail) details.aggregate(this._applyDispatch('', {}, tail));
  2098. return details.aggregate(this.currentMask ? this.currentMask.appendTail(tail) : super.appendTail(tail));
  2099. }
  2100. currentMaskFlags(flags) {
  2101. var _flags$_beforeTailSta, _flags$_beforeTailSta2;
  2102. return Object.assign({}, flags, {
  2103. _beforeTailState: ((_flags$_beforeTailSta = flags._beforeTailState) === null || _flags$_beforeTailSta === void 0 ? void 0 : _flags$_beforeTailSta.currentMaskRef) === this.currentMask && ((_flags$_beforeTailSta2 = flags._beforeTailState) === null || _flags$_beforeTailSta2 === void 0 ? void 0 : _flags$_beforeTailSta2.currentMask) || flags._beforeTailState
  2104. });
  2105. }
  2106. doDispatch(appended) {
  2107. let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2108. let tail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  2109. return this.dispatch(appended, this, flags, tail);
  2110. }
  2111. doValidate(flags) {
  2112. return super.doValidate(flags) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(flags)));
  2113. }
  2114. doPrepare(str) {
  2115. let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2116. let [s, details] = normalizePrepare(super.doPrepare(str, flags));
  2117. if (this.currentMask) {
  2118. let currentDetails;
  2119. [s, currentDetails] = normalizePrepare(super.doPrepare(s, this.currentMaskFlags(flags)));
  2120. details = details.aggregate(currentDetails);
  2121. }
  2122. return [s, details];
  2123. }
  2124. reset() {
  2125. var _this$currentMask;
  2126. (_this$currentMask = this.currentMask) === null || _this$currentMask === void 0 ? void 0 : _this$currentMask.reset();
  2127. this.compiledMasks.forEach(m => m.reset());
  2128. }
  2129. get value() {
  2130. return this.currentMask ? this.currentMask.value : '';
  2131. }
  2132. set value(value) {
  2133. super.value = value;
  2134. }
  2135. get unmaskedValue() {
  2136. return this.currentMask ? this.currentMask.unmaskedValue : '';
  2137. }
  2138. set unmaskedValue(unmaskedValue) {
  2139. super.unmaskedValue = unmaskedValue;
  2140. }
  2141. get typedValue() {
  2142. return this.currentMask ? this.currentMask.typedValue : '';
  2143. }
  2144. set typedValue(value) {
  2145. let unmaskedValue = String(value);
  2146. if (this.currentMask) {
  2147. this.currentMask.typedValue = value;
  2148. unmaskedValue = this.currentMask.unmaskedValue;
  2149. }
  2150. this.unmaskedValue = unmaskedValue;
  2151. }
  2152. get displayValue() {
  2153. return this.currentMask ? this.currentMask.displayValue : '';
  2154. }
  2155. get isComplete() {
  2156. var _this$currentMask2;
  2157. return Boolean((_this$currentMask2 = this.currentMask) === null || _this$currentMask2 === void 0 ? void 0 : _this$currentMask2.isComplete);
  2158. }
  2159. get isFilled() {
  2160. var _this$currentMask3;
  2161. return Boolean((_this$currentMask3 = this.currentMask) === null || _this$currentMask3 === void 0 ? void 0 : _this$currentMask3.isFilled);
  2162. }
  2163. remove() {
  2164. const details = new ChangeDetails();
  2165. if (this.currentMask) {
  2166. details.aggregate(this.currentMask.remove(...arguments))
  2167. .aggregate(this._applyDispatch());
  2168. }
  2169. return details;
  2170. }
  2171. get state() {
  2172. var _this$currentMask4;
  2173. return Object.assign({}, super.state, {
  2174. _rawInputValue: this.rawInputValue,
  2175. compiledMasks: this.compiledMasks.map(m => m.state),
  2176. currentMaskRef: this.currentMask,
  2177. currentMask: (_this$currentMask4 = this.currentMask) === null || _this$currentMask4 === void 0 ? void 0 : _this$currentMask4.state
  2178. });
  2179. }
  2180. set state(state) {
  2181. const {
  2182. compiledMasks,
  2183. currentMaskRef,
  2184. currentMask
  2185. } = state,
  2186. maskedState = _objectWithoutPropertiesLoose(state, _excluded);
  2187. this.compiledMasks.forEach((m, mi) => m.state = compiledMasks[mi]);
  2188. if (currentMaskRef != null) {
  2189. this.currentMask = currentMaskRef;
  2190. this.currentMask.state = currentMask;
  2191. }
  2192. super.state = maskedState;
  2193. }
  2194. extractInput() {
  2195. return this.currentMask ? this.currentMask.extractInput(...arguments) : '';
  2196. }
  2197. extractTail() {
  2198. return this.currentMask ? this.currentMask.extractTail(...arguments) : super.extractTail(...arguments);
  2199. }
  2200. doCommit() {
  2201. if (this.currentMask) this.currentMask.doCommit();
  2202. super.doCommit();
  2203. }
  2204. nearestInputPos() {
  2205. return this.currentMask ? this.currentMask.nearestInputPos(...arguments) : super.nearestInputPos(...arguments);
  2206. }
  2207. get overwrite() {
  2208. return this.currentMask ? this.currentMask.overwrite : super.overwrite;
  2209. }
  2210. set overwrite(overwrite) {
  2211. console.warn('"overwrite" option is not available in dynamic mask, use this option in siblings');
  2212. }
  2213. get eager() {
  2214. return this.currentMask ? this.currentMask.eager : super.eager;
  2215. }
  2216. set eager(eager) {
  2217. console.warn('"eager" option is not available in dynamic mask, use this option in siblings');
  2218. }
  2219. get skipInvalid() {
  2220. return this.currentMask ? this.currentMask.skipInvalid : super.skipInvalid;
  2221. }
  2222. set skipInvalid(skipInvalid) {
  2223. if (this.isInitialized || skipInvalid !== Masked.DEFAULTS.skipInvalid) {
  2224. console.warn('"skipInvalid" option is not available in dynamic mask, use this option in siblings');
  2225. }
  2226. }
  2227. maskEquals(mask) {
  2228. return Array.isArray(mask) && this.compiledMasks.every((m, mi) => {
  2229. if (!mask[mi]) return;
  2230. const _mask$mi = mask[mi],
  2231. {
  2232. mask: oldMask
  2233. } = _mask$mi,
  2234. restOpts = _objectWithoutPropertiesLoose(_mask$mi, _excluded2);
  2235. return objectIncludes(m, restOpts) && m.maskEquals(oldMask);
  2236. });
  2237. }
  2238. typedValueEquals(value) {
  2239. var _this$currentMask5;
  2240. return Boolean((_this$currentMask5 = this.currentMask) === null || _this$currentMask5 === void 0 ? void 0 : _this$currentMask5.typedValueEquals(value));
  2241. }
  2242. }
  2243. MaskedDynamic.DEFAULTS = {
  2244. dispatch: (appended, masked, flags, tail) => {
  2245. if (!masked.compiledMasks.length) return;
  2246. const inputValue = masked.rawInputValue;
  2247. const inputs = masked.compiledMasks.map((m, index) => {
  2248. const isCurrent = masked.currentMask === m;
  2249. const startInputPos = isCurrent ? m.value.length : m.nearestInputPos(m.value.length, DIRECTION.FORCE_LEFT);
  2250. if (m.rawInputValue !== inputValue) {
  2251. m.reset();
  2252. m.append(inputValue, {
  2253. raw: true
  2254. });
  2255. } else if (!isCurrent) {
  2256. m.remove(startInputPos);
  2257. }
  2258. m.append(appended, masked.currentMaskFlags(flags));
  2259. m.appendTail(tail);
  2260. return {
  2261. index,
  2262. weight: m.rawInputValue.length,
  2263. totalInputPositions: m.totalInputPositions(0, Math.max(startInputPos, m.nearestInputPos(m.value.length, DIRECTION.FORCE_LEFT)))
  2264. };
  2265. });
  2266. inputs.sort((i1, i2) => i2.weight - i1.weight || i2.totalInputPositions - i1.totalInputPositions);
  2267. return masked.compiledMasks[inputs[0].index];
  2268. }
  2269. };
  2270. IMask.MaskedDynamic = MaskedDynamic;
  2271. const PIPE_TYPE = {
  2272. MASKED: 'value',
  2273. UNMASKED: 'unmaskedValue',
  2274. TYPED: 'typedValue'
  2275. };
  2276. function createPipe(mask) {
  2277. let from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PIPE_TYPE.MASKED;
  2278. let to = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : PIPE_TYPE.MASKED;
  2279. const masked = createMask(mask);
  2280. return value => masked.runIsolated(m => {
  2281. m[from] = value;
  2282. return m[to];
  2283. });
  2284. }
  2285. function pipe(value) {
  2286. for (var _len = arguments.length, pipeArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  2287. pipeArgs[_key - 1] = arguments[_key];
  2288. }
  2289. return createPipe(...pipeArgs)(value);
  2290. }
  2291. IMask.PIPE_TYPE = PIPE_TYPE;
  2292. IMask.createPipe = createPipe;
  2293. IMask.pipe = pipe;
  2294. try {
  2295. globalThis.IMask = IMask;
  2296. } catch (e) {}
  2297. var maskElementList = [].slice.call(document.querySelectorAll('[data-mask]'));
  2298. maskElementList.map(function (maskEl) {
  2299. return new IMask(maskEl, {
  2300. mask: maskEl.dataset.mask,
  2301. lazy: maskEl.dataset['mask-visible'] === 'true'
  2302. });
  2303. });
  2304. var top = 'top';
  2305. var bottom = 'bottom';
  2306. var right = 'right';
  2307. var left = 'left';
  2308. var auto = 'auto';
  2309. var basePlacements = [top, bottom, right, left];
  2310. var start = 'start';
  2311. var end = 'end';
  2312. var clippingParents = 'clippingParents';
  2313. var viewport = 'viewport';
  2314. var popper = 'popper';
  2315. var reference = 'reference';
  2316. var variationPlacements = basePlacements.reduce(function (acc, placement) {
  2317. return acc.concat([placement + "-" + start, placement + "-" + end]);
  2318. }, []);
  2319. var placements = [].concat(basePlacements, [auto]).reduce(function (acc, placement) {
  2320. return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
  2321. }, []);
  2322. var beforeRead = 'beforeRead';
  2323. var read = 'read';
  2324. var afterRead = 'afterRead';
  2325. var beforeMain = 'beforeMain';
  2326. var main = 'main';
  2327. var afterMain = 'afterMain';
  2328. var beforeWrite = 'beforeWrite';
  2329. var write = 'write';
  2330. var afterWrite = 'afterWrite';
  2331. var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
  2332. function getNodeName(element) {
  2333. return element ? (element.nodeName || '').toLowerCase() : null;
  2334. }
  2335. function getWindow(node) {
  2336. if (node == null) {
  2337. return window;
  2338. }
  2339. if (node.toString() !== '[object Window]') {
  2340. var ownerDocument = node.ownerDocument;
  2341. return ownerDocument ? ownerDocument.defaultView || window : window;
  2342. }
  2343. return node;
  2344. }
  2345. function isElement$1(node) {
  2346. var OwnElement = getWindow(node).Element;
  2347. return node instanceof OwnElement || node instanceof Element;
  2348. }
  2349. function isHTMLElement(node) {
  2350. var OwnElement = getWindow(node).HTMLElement;
  2351. return node instanceof OwnElement || node instanceof HTMLElement;
  2352. }
  2353. function isShadowRoot(node) {
  2354. if (typeof ShadowRoot === 'undefined') {
  2355. return false;
  2356. }
  2357. var OwnElement = getWindow(node).ShadowRoot;
  2358. return node instanceof OwnElement || node instanceof ShadowRoot;
  2359. }
  2360. function applyStyles(_ref) {
  2361. var state = _ref.state;
  2362. Object.keys(state.elements).forEach(function (name) {
  2363. var style = state.styles[name] || {};
  2364. var attributes = state.attributes[name] || {};
  2365. var element = state.elements[name];
  2366. if (!isHTMLElement(element) || !getNodeName(element)) {
  2367. return;
  2368. }
  2369. Object.assign(element.style, style);
  2370. Object.keys(attributes).forEach(function (name) {
  2371. var value = attributes[name];
  2372. if (value === false) {
  2373. element.removeAttribute(name);
  2374. } else {
  2375. element.setAttribute(name, value === true ? '' : value);
  2376. }
  2377. });
  2378. });
  2379. }
  2380. function effect$2(_ref2) {
  2381. var state = _ref2.state;
  2382. var initialStyles = {
  2383. popper: {
  2384. position: state.options.strategy,
  2385. left: '0',
  2386. top: '0',
  2387. margin: '0'
  2388. },
  2389. arrow: {
  2390. position: 'absolute'
  2391. },
  2392. reference: {}
  2393. };
  2394. Object.assign(state.elements.popper.style, initialStyles.popper);
  2395. state.styles = initialStyles;
  2396. if (state.elements.arrow) {
  2397. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  2398. }
  2399. return function () {
  2400. Object.keys(state.elements).forEach(function (name) {
  2401. var element = state.elements[name];
  2402. var attributes = state.attributes[name] || {};
  2403. var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
  2404. var style = styleProperties.reduce(function (style, property) {
  2405. style[property] = '';
  2406. return style;
  2407. }, {});
  2408. if (!isHTMLElement(element) || !getNodeName(element)) {
  2409. return;
  2410. }
  2411. Object.assign(element.style, style);
  2412. Object.keys(attributes).forEach(function (attribute) {
  2413. element.removeAttribute(attribute);
  2414. });
  2415. });
  2416. };
  2417. }
  2418. var applyStyles$1 = {
  2419. name: 'applyStyles',
  2420. enabled: true,
  2421. phase: 'write',
  2422. fn: applyStyles,
  2423. effect: effect$2,
  2424. requires: ['computeStyles']
  2425. };
  2426. function getBasePlacement(placement) {
  2427. return placement.split('-')[0];
  2428. }
  2429. var max = Math.max;
  2430. var min = Math.min;
  2431. var round = Math.round;
  2432. function getUAString() {
  2433. var uaData = navigator.userAgentData;
  2434. if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
  2435. return uaData.brands.map(function (item) {
  2436. return item.brand + "/" + item.version;
  2437. }).join(' ');
  2438. }
  2439. return navigator.userAgent;
  2440. }
  2441. function isLayoutViewport() {
  2442. return !/^((?!chrome|android).)*safari/i.test(getUAString());
  2443. }
  2444. function getBoundingClientRect(element, includeScale, isFixedStrategy) {
  2445. if (includeScale === void 0) {
  2446. includeScale = false;
  2447. }
  2448. if (isFixedStrategy === void 0) {
  2449. isFixedStrategy = false;
  2450. }
  2451. var clientRect = element.getBoundingClientRect();
  2452. var scaleX = 1;
  2453. var scaleY = 1;
  2454. if (includeScale && isHTMLElement(element)) {
  2455. scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
  2456. scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
  2457. }
  2458. var _ref = isElement$1(element) ? getWindow(element) : window,
  2459. visualViewport = _ref.visualViewport;
  2460. var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
  2461. var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
  2462. var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
  2463. var width = clientRect.width / scaleX;
  2464. var height = clientRect.height / scaleY;
  2465. return {
  2466. width: width,
  2467. height: height,
  2468. top: y,
  2469. right: x + width,
  2470. bottom: y + height,
  2471. left: x,
  2472. x: x,
  2473. y: y
  2474. };
  2475. }
  2476. function getLayoutRect(element) {
  2477. var clientRect = getBoundingClientRect(element);
  2478. var width = element.offsetWidth;
  2479. var height = element.offsetHeight;
  2480. if (Math.abs(clientRect.width - width) <= 1) {
  2481. width = clientRect.width;
  2482. }
  2483. if (Math.abs(clientRect.height - height) <= 1) {
  2484. height = clientRect.height;
  2485. }
  2486. return {
  2487. x: element.offsetLeft,
  2488. y: element.offsetTop,
  2489. width: width,
  2490. height: height
  2491. };
  2492. }
  2493. function contains(parent, child) {
  2494. var rootNode = child.getRootNode && child.getRootNode();
  2495. if (parent.contains(child)) {
  2496. return true;
  2497. }
  2498. else if (rootNode && isShadowRoot(rootNode)) {
  2499. var next = child;
  2500. do {
  2501. if (next && parent.isSameNode(next)) {
  2502. return true;
  2503. }
  2504. next = next.parentNode || next.host;
  2505. } while (next);
  2506. }
  2507. return false;
  2508. }
  2509. function getComputedStyle$1(element) {
  2510. return getWindow(element).getComputedStyle(element);
  2511. }
  2512. function isTableElement(element) {
  2513. return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
  2514. }
  2515. function getDocumentElement(element) {
  2516. return ((isElement$1(element) ? element.ownerDocument :
  2517. element.document) || window.document).documentElement;
  2518. }
  2519. function getParentNode(element) {
  2520. if (getNodeName(element) === 'html') {
  2521. return element;
  2522. }
  2523. return (
  2524. element.assignedSlot ||
  2525. element.parentNode || (
  2526. isShadowRoot(element) ? element.host : null) ||
  2527. getDocumentElement(element)
  2528. );
  2529. }
  2530. function getTrueOffsetParent(element) {
  2531. if (!isHTMLElement(element) ||
  2532. getComputedStyle$1(element).position === 'fixed') {
  2533. return null;
  2534. }
  2535. return element.offsetParent;
  2536. }
  2537. function getContainingBlock(element) {
  2538. var isFirefox = /firefox/i.test(getUAString());
  2539. var isIE = /Trident/i.test(getUAString());
  2540. if (isIE && isHTMLElement(element)) {
  2541. var elementCss = getComputedStyle$1(element);
  2542. if (elementCss.position === 'fixed') {
  2543. return null;
  2544. }
  2545. }
  2546. var currentNode = getParentNode(element);
  2547. if (isShadowRoot(currentNode)) {
  2548. currentNode = currentNode.host;
  2549. }
  2550. while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
  2551. var css = getComputedStyle$1(currentNode);
  2552. if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
  2553. return currentNode;
  2554. } else {
  2555. currentNode = currentNode.parentNode;
  2556. }
  2557. }
  2558. return null;
  2559. }
  2560. function getOffsetParent(element) {
  2561. var window = getWindow(element);
  2562. var offsetParent = getTrueOffsetParent(element);
  2563. while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
  2564. offsetParent = getTrueOffsetParent(offsetParent);
  2565. }
  2566. if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static')) {
  2567. return window;
  2568. }
  2569. return offsetParent || getContainingBlock(element) || window;
  2570. }
  2571. function getMainAxisFromPlacement(placement) {
  2572. return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
  2573. }
  2574. function within(min$1, value, max$1) {
  2575. return max(min$1, min(value, max$1));
  2576. }
  2577. function withinMaxClamp(min, value, max) {
  2578. var v = within(min, value, max);
  2579. return v > max ? max : v;
  2580. }
  2581. function getFreshSideObject() {
  2582. return {
  2583. top: 0,
  2584. right: 0,
  2585. bottom: 0,
  2586. left: 0
  2587. };
  2588. }
  2589. function mergePaddingObject(paddingObject) {
  2590. return Object.assign({}, getFreshSideObject(), paddingObject);
  2591. }
  2592. function expandToHashMap(value, keys) {
  2593. return keys.reduce(function (hashMap, key) {
  2594. hashMap[key] = value;
  2595. return hashMap;
  2596. }, {});
  2597. }
  2598. var toPaddingObject = function toPaddingObject(padding, state) {
  2599. padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
  2600. placement: state.placement
  2601. })) : padding;
  2602. return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  2603. };
  2604. function arrow(_ref) {
  2605. var _state$modifiersData$;
  2606. var state = _ref.state,
  2607. name = _ref.name,
  2608. options = _ref.options;
  2609. var arrowElement = state.elements.arrow;
  2610. var popperOffsets = state.modifiersData.popperOffsets;
  2611. var basePlacement = getBasePlacement(state.placement);
  2612. var axis = getMainAxisFromPlacement(basePlacement);
  2613. var isVertical = [left, right].indexOf(basePlacement) >= 0;
  2614. var len = isVertical ? 'height' : 'width';
  2615. if (!arrowElement || !popperOffsets) {
  2616. return;
  2617. }
  2618. var paddingObject = toPaddingObject(options.padding, state);
  2619. var arrowRect = getLayoutRect(arrowElement);
  2620. var minProp = axis === 'y' ? top : left;
  2621. var maxProp = axis === 'y' ? bottom : right;
  2622. var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
  2623. var startDiff = popperOffsets[axis] - state.rects.reference[axis];
  2624. var arrowOffsetParent = getOffsetParent(arrowElement);
  2625. var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
  2626. var centerToReference = endDiff / 2 - startDiff / 2;
  2627. var min = paddingObject[minProp];
  2628. var max = clientSize - arrowRect[len] - paddingObject[maxProp];
  2629. var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
  2630. var offset = within(min, center, max);
  2631. var axisProp = axis;
  2632. state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
  2633. }
  2634. function effect$1(_ref2) {
  2635. var state = _ref2.state,
  2636. options = _ref2.options;
  2637. var _options$element = options.element,
  2638. arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
  2639. if (arrowElement == null) {
  2640. return;
  2641. }
  2642. if (typeof arrowElement === 'string') {
  2643. arrowElement = state.elements.popper.querySelector(arrowElement);
  2644. if (!arrowElement) {
  2645. return;
  2646. }
  2647. }
  2648. if (!contains(state.elements.popper, arrowElement)) {
  2649. return;
  2650. }
  2651. state.elements.arrow = arrowElement;
  2652. }
  2653. var arrow$1 = {
  2654. name: 'arrow',
  2655. enabled: true,
  2656. phase: 'main',
  2657. fn: arrow,
  2658. effect: effect$1,
  2659. requires: ['popperOffsets'],
  2660. requiresIfExists: ['preventOverflow']
  2661. };
  2662. function getVariation(placement) {
  2663. return placement.split('-')[1];
  2664. }
  2665. var unsetSides = {
  2666. top: 'auto',
  2667. right: 'auto',
  2668. bottom: 'auto',
  2669. left: 'auto'
  2670. };
  2671. function roundOffsetsByDPR(_ref, win) {
  2672. var x = _ref.x,
  2673. y = _ref.y;
  2674. var dpr = win.devicePixelRatio || 1;
  2675. return {
  2676. x: round(x * dpr) / dpr || 0,
  2677. y: round(y * dpr) / dpr || 0
  2678. };
  2679. }
  2680. function mapToStyles(_ref2) {
  2681. var _Object$assign2;
  2682. var popper = _ref2.popper,
  2683. popperRect = _ref2.popperRect,
  2684. placement = _ref2.placement,
  2685. variation = _ref2.variation,
  2686. offsets = _ref2.offsets,
  2687. position = _ref2.position,
  2688. gpuAcceleration = _ref2.gpuAcceleration,
  2689. adaptive = _ref2.adaptive,
  2690. roundOffsets = _ref2.roundOffsets,
  2691. isFixed = _ref2.isFixed;
  2692. var _offsets$x = offsets.x,
  2693. x = _offsets$x === void 0 ? 0 : _offsets$x,
  2694. _offsets$y = offsets.y,
  2695. y = _offsets$y === void 0 ? 0 : _offsets$y;
  2696. var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
  2697. x: x,
  2698. y: y
  2699. }) : {
  2700. x: x,
  2701. y: y
  2702. };
  2703. x = _ref3.x;
  2704. y = _ref3.y;
  2705. var hasX = offsets.hasOwnProperty('x');
  2706. var hasY = offsets.hasOwnProperty('y');
  2707. var sideX = left;
  2708. var sideY = top;
  2709. var win = window;
  2710. if (adaptive) {
  2711. var offsetParent = getOffsetParent(popper);
  2712. var heightProp = 'clientHeight';
  2713. var widthProp = 'clientWidth';
  2714. if (offsetParent === getWindow(popper)) {
  2715. offsetParent = getDocumentElement(popper);
  2716. if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
  2717. heightProp = 'scrollHeight';
  2718. widthProp = 'scrollWidth';
  2719. }
  2720. }
  2721. offsetParent = offsetParent;
  2722. if (placement === top || (placement === left || placement === right) && variation === end) {
  2723. sideY = bottom;
  2724. var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height :
  2725. offsetParent[heightProp];
  2726. y -= offsetY - popperRect.height;
  2727. y *= gpuAcceleration ? 1 : -1;
  2728. }
  2729. if (placement === left || (placement === top || placement === bottom) && variation === end) {
  2730. sideX = right;
  2731. var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width :
  2732. offsetParent[widthProp];
  2733. x -= offsetX - popperRect.width;
  2734. x *= gpuAcceleration ? 1 : -1;
  2735. }
  2736. }
  2737. var commonStyles = Object.assign({
  2738. position: position
  2739. }, adaptive && unsetSides);
  2740. var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
  2741. x: x,
  2742. y: y
  2743. }, getWindow(popper)) : {
  2744. x: x,
  2745. y: y
  2746. };
  2747. x = _ref4.x;
  2748. y = _ref4.y;
  2749. if (gpuAcceleration) {
  2750. var _Object$assign;
  2751. return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
  2752. }
  2753. return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
  2754. }
  2755. function computeStyles(_ref5) {
  2756. var state = _ref5.state,
  2757. options = _ref5.options;
  2758. var _options$gpuAccelerat = options.gpuAcceleration,
  2759. gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
  2760. _options$adaptive = options.adaptive,
  2761. adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
  2762. _options$roundOffsets = options.roundOffsets,
  2763. roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
  2764. var commonStyles = {
  2765. placement: getBasePlacement(state.placement),
  2766. variation: getVariation(state.placement),
  2767. popper: state.elements.popper,
  2768. popperRect: state.rects.popper,
  2769. gpuAcceleration: gpuAcceleration,
  2770. isFixed: state.options.strategy === 'fixed'
  2771. };
  2772. if (state.modifiersData.popperOffsets != null) {
  2773. state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
  2774. offsets: state.modifiersData.popperOffsets,
  2775. position: state.options.strategy,
  2776. adaptive: adaptive,
  2777. roundOffsets: roundOffsets
  2778. })));
  2779. }
  2780. if (state.modifiersData.arrow != null) {
  2781. state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
  2782. offsets: state.modifiersData.arrow,
  2783. position: 'absolute',
  2784. adaptive: false,
  2785. roundOffsets: roundOffsets
  2786. })));
  2787. }
  2788. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  2789. 'data-popper-placement': state.placement
  2790. });
  2791. }
  2792. var computeStyles$1 = {
  2793. name: 'computeStyles',
  2794. enabled: true,
  2795. phase: 'beforeWrite',
  2796. fn: computeStyles,
  2797. data: {}
  2798. };
  2799. var passive = {
  2800. passive: true
  2801. };
  2802. function effect(_ref) {
  2803. var state = _ref.state,
  2804. instance = _ref.instance,
  2805. options = _ref.options;
  2806. var _options$scroll = options.scroll,
  2807. scroll = _options$scroll === void 0 ? true : _options$scroll,
  2808. _options$resize = options.resize,
  2809. resize = _options$resize === void 0 ? true : _options$resize;
  2810. var window = getWindow(state.elements.popper);
  2811. var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
  2812. if (scroll) {
  2813. scrollParents.forEach(function (scrollParent) {
  2814. scrollParent.addEventListener('scroll', instance.update, passive);
  2815. });
  2816. }
  2817. if (resize) {
  2818. window.addEventListener('resize', instance.update, passive);
  2819. }
  2820. return function () {
  2821. if (scroll) {
  2822. scrollParents.forEach(function (scrollParent) {
  2823. scrollParent.removeEventListener('scroll', instance.update, passive);
  2824. });
  2825. }
  2826. if (resize) {
  2827. window.removeEventListener('resize', instance.update, passive);
  2828. }
  2829. };
  2830. }
  2831. var eventListeners = {
  2832. name: 'eventListeners',
  2833. enabled: true,
  2834. phase: 'write',
  2835. fn: function fn() {},
  2836. effect: effect,
  2837. data: {}
  2838. };
  2839. var hash$1 = {
  2840. left: 'right',
  2841. right: 'left',
  2842. bottom: 'top',
  2843. top: 'bottom'
  2844. };
  2845. function getOppositePlacement(placement) {
  2846. return placement.replace(/left|right|bottom|top/g, function (matched) {
  2847. return hash$1[matched];
  2848. });
  2849. }
  2850. var hash = {
  2851. start: 'end',
  2852. end: 'start'
  2853. };
  2854. function getOppositeVariationPlacement(placement) {
  2855. return placement.replace(/start|end/g, function (matched) {
  2856. return hash[matched];
  2857. });
  2858. }
  2859. function getWindowScroll(node) {
  2860. var win = getWindow(node);
  2861. var scrollLeft = win.pageXOffset;
  2862. var scrollTop = win.pageYOffset;
  2863. return {
  2864. scrollLeft: scrollLeft,
  2865. scrollTop: scrollTop
  2866. };
  2867. }
  2868. function getWindowScrollBarX(element) {
  2869. return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
  2870. }
  2871. function getViewportRect(element, strategy) {
  2872. var win = getWindow(element);
  2873. var html = getDocumentElement(element);
  2874. var visualViewport = win.visualViewport;
  2875. var width = html.clientWidth;
  2876. var height = html.clientHeight;
  2877. var x = 0;
  2878. var y = 0;
  2879. if (visualViewport) {
  2880. width = visualViewport.width;
  2881. height = visualViewport.height;
  2882. var layoutViewport = isLayoutViewport();
  2883. if (layoutViewport || !layoutViewport && strategy === 'fixed') {
  2884. x = visualViewport.offsetLeft;
  2885. y = visualViewport.offsetTop;
  2886. }
  2887. }
  2888. return {
  2889. width: width,
  2890. height: height,
  2891. x: x + getWindowScrollBarX(element),
  2892. y: y
  2893. };
  2894. }
  2895. function getDocumentRect(element) {
  2896. var _element$ownerDocumen;
  2897. var html = getDocumentElement(element);
  2898. var winScroll = getWindowScroll(element);
  2899. var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
  2900. var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
  2901. var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
  2902. var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
  2903. var y = -winScroll.scrollTop;
  2904. if (getComputedStyle$1(body || html).direction === 'rtl') {
  2905. x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
  2906. }
  2907. return {
  2908. width: width,
  2909. height: height,
  2910. x: x,
  2911. y: y
  2912. };
  2913. }
  2914. function isScrollParent(element) {
  2915. var _getComputedStyle = getComputedStyle$1(element),
  2916. overflow = _getComputedStyle.overflow,
  2917. overflowX = _getComputedStyle.overflowX,
  2918. overflowY = _getComputedStyle.overflowY;
  2919. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
  2920. }
  2921. function getScrollParent(node) {
  2922. if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
  2923. return node.ownerDocument.body;
  2924. }
  2925. if (isHTMLElement(node) && isScrollParent(node)) {
  2926. return node;
  2927. }
  2928. return getScrollParent(getParentNode(node));
  2929. }
  2930. function listScrollParents(element, list) {
  2931. var _element$ownerDocumen;
  2932. if (list === void 0) {
  2933. list = [];
  2934. }
  2935. var scrollParent = getScrollParent(element);
  2936. var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
  2937. var win = getWindow(scrollParent);
  2938. var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
  2939. var updatedList = list.concat(target);
  2940. return isBody ? updatedList :
  2941. updatedList.concat(listScrollParents(getParentNode(target)));
  2942. }
  2943. function rectToClientRect(rect) {
  2944. return Object.assign({}, rect, {
  2945. left: rect.x,
  2946. top: rect.y,
  2947. right: rect.x + rect.width,
  2948. bottom: rect.y + rect.height
  2949. });
  2950. }
  2951. function getInnerBoundingClientRect(element, strategy) {
  2952. var rect = getBoundingClientRect(element, false, strategy === 'fixed');
  2953. rect.top = rect.top + element.clientTop;
  2954. rect.left = rect.left + element.clientLeft;
  2955. rect.bottom = rect.top + element.clientHeight;
  2956. rect.right = rect.left + element.clientWidth;
  2957. rect.width = element.clientWidth;
  2958. rect.height = element.clientHeight;
  2959. rect.x = rect.left;
  2960. rect.y = rect.top;
  2961. return rect;
  2962. }
  2963. function getClientRectFromMixedType(element, clippingParent, strategy) {
  2964. return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
  2965. }
  2966. function getClippingParents(element) {
  2967. var clippingParents = listScrollParents(getParentNode(element));
  2968. var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle$1(element).position) >= 0;
  2969. var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
  2970. if (!isElement$1(clipperElement)) {
  2971. return [];
  2972. }
  2973. return clippingParents.filter(function (clippingParent) {
  2974. return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
  2975. });
  2976. }
  2977. function getClippingRect(element, boundary, rootBoundary, strategy) {
  2978. var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
  2979. var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
  2980. var firstClippingParent = clippingParents[0];
  2981. var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
  2982. var rect = getClientRectFromMixedType(element, clippingParent, strategy);
  2983. accRect.top = max(rect.top, accRect.top);
  2984. accRect.right = min(rect.right, accRect.right);
  2985. accRect.bottom = min(rect.bottom, accRect.bottom);
  2986. accRect.left = max(rect.left, accRect.left);
  2987. return accRect;
  2988. }, getClientRectFromMixedType(element, firstClippingParent, strategy));
  2989. clippingRect.width = clippingRect.right - clippingRect.left;
  2990. clippingRect.height = clippingRect.bottom - clippingRect.top;
  2991. clippingRect.x = clippingRect.left;
  2992. clippingRect.y = clippingRect.top;
  2993. return clippingRect;
  2994. }
  2995. function computeOffsets(_ref) {
  2996. var reference = _ref.reference,
  2997. element = _ref.element,
  2998. placement = _ref.placement;
  2999. var basePlacement = placement ? getBasePlacement(placement) : null;
  3000. var variation = placement ? getVariation(placement) : null;
  3001. var commonX = reference.x + reference.width / 2 - element.width / 2;
  3002. var commonY = reference.y + reference.height / 2 - element.height / 2;
  3003. var offsets;
  3004. switch (basePlacement) {
  3005. case top:
  3006. offsets = {
  3007. x: commonX,
  3008. y: reference.y - element.height
  3009. };
  3010. break;
  3011. case bottom:
  3012. offsets = {
  3013. x: commonX,
  3014. y: reference.y + reference.height
  3015. };
  3016. break;
  3017. case right:
  3018. offsets = {
  3019. x: reference.x + reference.width,
  3020. y: commonY
  3021. };
  3022. break;
  3023. case left:
  3024. offsets = {
  3025. x: reference.x - element.width,
  3026. y: commonY
  3027. };
  3028. break;
  3029. default:
  3030. offsets = {
  3031. x: reference.x,
  3032. y: reference.y
  3033. };
  3034. }
  3035. var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
  3036. if (mainAxis != null) {
  3037. var len = mainAxis === 'y' ? 'height' : 'width';
  3038. switch (variation) {
  3039. case start:
  3040. offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
  3041. break;
  3042. case end:
  3043. offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
  3044. break;
  3045. }
  3046. }
  3047. return offsets;
  3048. }
  3049. function detectOverflow(state, options) {
  3050. if (options === void 0) {
  3051. options = {};
  3052. }
  3053. var _options = options,
  3054. _options$placement = _options.placement,
  3055. placement = _options$placement === void 0 ? state.placement : _options$placement,
  3056. _options$strategy = _options.strategy,
  3057. strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
  3058. _options$boundary = _options.boundary,
  3059. boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
  3060. _options$rootBoundary = _options.rootBoundary,
  3061. rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
  3062. _options$elementConte = _options.elementContext,
  3063. elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
  3064. _options$altBoundary = _options.altBoundary,
  3065. altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
  3066. _options$padding = _options.padding,
  3067. padding = _options$padding === void 0 ? 0 : _options$padding;
  3068. var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  3069. var altContext = elementContext === popper ? reference : popper;
  3070. var popperRect = state.rects.popper;
  3071. var element = state.elements[altBoundary ? altContext : elementContext];
  3072. var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
  3073. var referenceClientRect = getBoundingClientRect(state.elements.reference);
  3074. var popperOffsets = computeOffsets({
  3075. reference: referenceClientRect,
  3076. element: popperRect,
  3077. strategy: 'absolute',
  3078. placement: placement
  3079. });
  3080. var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
  3081. var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
  3082. var overflowOffsets = {
  3083. top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
  3084. bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
  3085. left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
  3086. right: elementClientRect.right - clippingClientRect.right + paddingObject.right
  3087. };
  3088. var offsetData = state.modifiersData.offset;
  3089. if (elementContext === popper && offsetData) {
  3090. var offset = offsetData[placement];
  3091. Object.keys(overflowOffsets).forEach(function (key) {
  3092. var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
  3093. var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
  3094. overflowOffsets[key] += offset[axis] * multiply;
  3095. });
  3096. }
  3097. return overflowOffsets;
  3098. }
  3099. function computeAutoPlacement(state, options) {
  3100. if (options === void 0) {
  3101. options = {};
  3102. }
  3103. var _options = options,
  3104. placement = _options.placement,
  3105. boundary = _options.boundary,
  3106. rootBoundary = _options.rootBoundary,
  3107. padding = _options.padding,
  3108. flipVariations = _options.flipVariations,
  3109. _options$allowedAutoP = _options.allowedAutoPlacements,
  3110. allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
  3111. var variation = getVariation(placement);
  3112. var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
  3113. return getVariation(placement) === variation;
  3114. }) : basePlacements;
  3115. var allowedPlacements = placements$1.filter(function (placement) {
  3116. return allowedAutoPlacements.indexOf(placement) >= 0;
  3117. });
  3118. if (allowedPlacements.length === 0) {
  3119. allowedPlacements = placements$1;
  3120. }
  3121. var overflows = allowedPlacements.reduce(function (acc, placement) {
  3122. acc[placement] = detectOverflow(state, {
  3123. placement: placement,
  3124. boundary: boundary,
  3125. rootBoundary: rootBoundary,
  3126. padding: padding
  3127. })[getBasePlacement(placement)];
  3128. return acc;
  3129. }, {});
  3130. return Object.keys(overflows).sort(function (a, b) {
  3131. return overflows[a] - overflows[b];
  3132. });
  3133. }
  3134. function getExpandedFallbackPlacements(placement) {
  3135. if (getBasePlacement(placement) === auto) {
  3136. return [];
  3137. }
  3138. var oppositePlacement = getOppositePlacement(placement);
  3139. return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
  3140. }
  3141. function flip(_ref) {
  3142. var state = _ref.state,
  3143. options = _ref.options,
  3144. name = _ref.name;
  3145. if (state.modifiersData[name]._skip) {
  3146. return;
  3147. }
  3148. var _options$mainAxis = options.mainAxis,
  3149. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  3150. _options$altAxis = options.altAxis,
  3151. checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
  3152. specifiedFallbackPlacements = options.fallbackPlacements,
  3153. padding = options.padding,
  3154. boundary = options.boundary,
  3155. rootBoundary = options.rootBoundary,
  3156. altBoundary = options.altBoundary,
  3157. _options$flipVariatio = options.flipVariations,
  3158. flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
  3159. allowedAutoPlacements = options.allowedAutoPlacements;
  3160. var preferredPlacement = state.options.placement;
  3161. var basePlacement = getBasePlacement(preferredPlacement);
  3162. var isBasePlacement = basePlacement === preferredPlacement;
  3163. var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
  3164. var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
  3165. return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
  3166. placement: placement,
  3167. boundary: boundary,
  3168. rootBoundary: rootBoundary,
  3169. padding: padding,
  3170. flipVariations: flipVariations,
  3171. allowedAutoPlacements: allowedAutoPlacements
  3172. }) : placement);
  3173. }, []);
  3174. var referenceRect = state.rects.reference;
  3175. var popperRect = state.rects.popper;
  3176. var checksMap = new Map();
  3177. var makeFallbackChecks = true;
  3178. var firstFittingPlacement = placements[0];
  3179. for (var i = 0; i < placements.length; i++) {
  3180. var placement = placements[i];
  3181. var _basePlacement = getBasePlacement(placement);
  3182. var isStartVariation = getVariation(placement) === start;
  3183. var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
  3184. var len = isVertical ? 'width' : 'height';
  3185. var overflow = detectOverflow(state, {
  3186. placement: placement,
  3187. boundary: boundary,
  3188. rootBoundary: rootBoundary,
  3189. altBoundary: altBoundary,
  3190. padding: padding
  3191. });
  3192. var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
  3193. if (referenceRect[len] > popperRect[len]) {
  3194. mainVariationSide = getOppositePlacement(mainVariationSide);
  3195. }
  3196. var altVariationSide = getOppositePlacement(mainVariationSide);
  3197. var checks = [];
  3198. if (checkMainAxis) {
  3199. checks.push(overflow[_basePlacement] <= 0);
  3200. }
  3201. if (checkAltAxis) {
  3202. checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
  3203. }
  3204. if (checks.every(function (check) {
  3205. return check;
  3206. })) {
  3207. firstFittingPlacement = placement;
  3208. makeFallbackChecks = false;
  3209. break;
  3210. }
  3211. checksMap.set(placement, checks);
  3212. }
  3213. if (makeFallbackChecks) {
  3214. var numberOfChecks = flipVariations ? 3 : 1;
  3215. var _loop = function _loop(_i) {
  3216. var fittingPlacement = placements.find(function (placement) {
  3217. var checks = checksMap.get(placement);
  3218. if (checks) {
  3219. return checks.slice(0, _i).every(function (check) {
  3220. return check;
  3221. });
  3222. }
  3223. });
  3224. if (fittingPlacement) {
  3225. firstFittingPlacement = fittingPlacement;
  3226. return "break";
  3227. }
  3228. };
  3229. for (var _i = numberOfChecks; _i > 0; _i--) {
  3230. var _ret = _loop(_i);
  3231. if (_ret === "break") break;
  3232. }
  3233. }
  3234. if (state.placement !== firstFittingPlacement) {
  3235. state.modifiersData[name]._skip = true;
  3236. state.placement = firstFittingPlacement;
  3237. state.reset = true;
  3238. }
  3239. }
  3240. var flip$1 = {
  3241. name: 'flip',
  3242. enabled: true,
  3243. phase: 'main',
  3244. fn: flip,
  3245. requiresIfExists: ['offset'],
  3246. data: {
  3247. _skip: false
  3248. }
  3249. };
  3250. function getSideOffsets(overflow, rect, preventedOffsets) {
  3251. if (preventedOffsets === void 0) {
  3252. preventedOffsets = {
  3253. x: 0,
  3254. y: 0
  3255. };
  3256. }
  3257. return {
  3258. top: overflow.top - rect.height - preventedOffsets.y,
  3259. right: overflow.right - rect.width + preventedOffsets.x,
  3260. bottom: overflow.bottom - rect.height + preventedOffsets.y,
  3261. left: overflow.left - rect.width - preventedOffsets.x
  3262. };
  3263. }
  3264. function isAnySideFullyClipped(overflow) {
  3265. return [top, right, bottom, left].some(function (side) {
  3266. return overflow[side] >= 0;
  3267. });
  3268. }
  3269. function hide(_ref) {
  3270. var state = _ref.state,
  3271. name = _ref.name;
  3272. var referenceRect = state.rects.reference;
  3273. var popperRect = state.rects.popper;
  3274. var preventedOffsets = state.modifiersData.preventOverflow;
  3275. var referenceOverflow = detectOverflow(state, {
  3276. elementContext: 'reference'
  3277. });
  3278. var popperAltOverflow = detectOverflow(state, {
  3279. altBoundary: true
  3280. });
  3281. var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
  3282. var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
  3283. var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
  3284. var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
  3285. state.modifiersData[name] = {
  3286. referenceClippingOffsets: referenceClippingOffsets,
  3287. popperEscapeOffsets: popperEscapeOffsets,
  3288. isReferenceHidden: isReferenceHidden,
  3289. hasPopperEscaped: hasPopperEscaped
  3290. };
  3291. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  3292. 'data-popper-reference-hidden': isReferenceHidden,
  3293. 'data-popper-escaped': hasPopperEscaped
  3294. });
  3295. }
  3296. var hide$1 = {
  3297. name: 'hide',
  3298. enabled: true,
  3299. phase: 'main',
  3300. requiresIfExists: ['preventOverflow'],
  3301. fn: hide
  3302. };
  3303. function distanceAndSkiddingToXY(placement, rects, offset) {
  3304. var basePlacement = getBasePlacement(placement);
  3305. var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
  3306. var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
  3307. placement: placement
  3308. })) : offset,
  3309. skidding = _ref[0],
  3310. distance = _ref[1];
  3311. skidding = skidding || 0;
  3312. distance = (distance || 0) * invertDistance;
  3313. return [left, right].indexOf(basePlacement) >= 0 ? {
  3314. x: distance,
  3315. y: skidding
  3316. } : {
  3317. x: skidding,
  3318. y: distance
  3319. };
  3320. }
  3321. function offset(_ref2) {
  3322. var state = _ref2.state,
  3323. options = _ref2.options,
  3324. name = _ref2.name;
  3325. var _options$offset = options.offset,
  3326. offset = _options$offset === void 0 ? [0, 0] : _options$offset;
  3327. var data = placements.reduce(function (acc, placement) {
  3328. acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
  3329. return acc;
  3330. }, {});
  3331. var _data$state$placement = data[state.placement],
  3332. x = _data$state$placement.x,
  3333. y = _data$state$placement.y;
  3334. if (state.modifiersData.popperOffsets != null) {
  3335. state.modifiersData.popperOffsets.x += x;
  3336. state.modifiersData.popperOffsets.y += y;
  3337. }
  3338. state.modifiersData[name] = data;
  3339. }
  3340. var offset$1 = {
  3341. name: 'offset',
  3342. enabled: true,
  3343. phase: 'main',
  3344. requires: ['popperOffsets'],
  3345. fn: offset
  3346. };
  3347. function popperOffsets(_ref) {
  3348. var state = _ref.state,
  3349. name = _ref.name;
  3350. state.modifiersData[name] = computeOffsets({
  3351. reference: state.rects.reference,
  3352. element: state.rects.popper,
  3353. strategy: 'absolute',
  3354. placement: state.placement
  3355. });
  3356. }
  3357. var popperOffsets$1 = {
  3358. name: 'popperOffsets',
  3359. enabled: true,
  3360. phase: 'read',
  3361. fn: popperOffsets,
  3362. data: {}
  3363. };
  3364. function getAltAxis(axis) {
  3365. return axis === 'x' ? 'y' : 'x';
  3366. }
  3367. function preventOverflow(_ref) {
  3368. var state = _ref.state,
  3369. options = _ref.options,
  3370. name = _ref.name;
  3371. var _options$mainAxis = options.mainAxis,
  3372. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  3373. _options$altAxis = options.altAxis,
  3374. checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
  3375. boundary = options.boundary,
  3376. rootBoundary = options.rootBoundary,
  3377. altBoundary = options.altBoundary,
  3378. padding = options.padding,
  3379. _options$tether = options.tether,
  3380. tether = _options$tether === void 0 ? true : _options$tether,
  3381. _options$tetherOffset = options.tetherOffset,
  3382. tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
  3383. var overflow = detectOverflow(state, {
  3384. boundary: boundary,
  3385. rootBoundary: rootBoundary,
  3386. padding: padding,
  3387. altBoundary: altBoundary
  3388. });
  3389. var basePlacement = getBasePlacement(state.placement);
  3390. var variation = getVariation(state.placement);
  3391. var isBasePlacement = !variation;
  3392. var mainAxis = getMainAxisFromPlacement(basePlacement);
  3393. var altAxis = getAltAxis(mainAxis);
  3394. var popperOffsets = state.modifiersData.popperOffsets;
  3395. var referenceRect = state.rects.reference;
  3396. var popperRect = state.rects.popper;
  3397. var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
  3398. placement: state.placement
  3399. })) : tetherOffset;
  3400. var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
  3401. mainAxis: tetherOffsetValue,
  3402. altAxis: tetherOffsetValue
  3403. } : Object.assign({
  3404. mainAxis: 0,
  3405. altAxis: 0
  3406. }, tetherOffsetValue);
  3407. var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
  3408. var data = {
  3409. x: 0,
  3410. y: 0
  3411. };
  3412. if (!popperOffsets) {
  3413. return;
  3414. }
  3415. if (checkMainAxis) {
  3416. var _offsetModifierState$;
  3417. var mainSide = mainAxis === 'y' ? top : left;
  3418. var altSide = mainAxis === 'y' ? bottom : right;
  3419. var len = mainAxis === 'y' ? 'height' : 'width';
  3420. var offset = popperOffsets[mainAxis];
  3421. var min$1 = offset + overflow[mainSide];
  3422. var max$1 = offset - overflow[altSide];
  3423. var additive = tether ? -popperRect[len] / 2 : 0;
  3424. var minLen = variation === start ? referenceRect[len] : popperRect[len];
  3425. var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
  3426. var arrowElement = state.elements.arrow;
  3427. var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
  3428. width: 0,
  3429. height: 0
  3430. };
  3431. var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
  3432. var arrowPaddingMin = arrowPaddingObject[mainSide];
  3433. var arrowPaddingMax = arrowPaddingObject[altSide];
  3434. var arrowLen = within(0, referenceRect[len], arrowRect[len]);
  3435. var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
  3436. var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
  3437. var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
  3438. var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
  3439. var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
  3440. var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
  3441. var tetherMax = offset + maxOffset - offsetModifierValue;
  3442. var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
  3443. popperOffsets[mainAxis] = preventedOffset;
  3444. data[mainAxis] = preventedOffset - offset;
  3445. }
  3446. if (checkAltAxis) {
  3447. var _offsetModifierState$2;
  3448. var _mainSide = mainAxis === 'x' ? top : left;
  3449. var _altSide = mainAxis === 'x' ? bottom : right;
  3450. var _offset = popperOffsets[altAxis];
  3451. var _len = altAxis === 'y' ? 'height' : 'width';
  3452. var _min = _offset + overflow[_mainSide];
  3453. var _max = _offset - overflow[_altSide];
  3454. var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
  3455. var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
  3456. var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
  3457. var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
  3458. var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
  3459. popperOffsets[altAxis] = _preventedOffset;
  3460. data[altAxis] = _preventedOffset - _offset;
  3461. }
  3462. state.modifiersData[name] = data;
  3463. }
  3464. var preventOverflow$1 = {
  3465. name: 'preventOverflow',
  3466. enabled: true,
  3467. phase: 'main',
  3468. fn: preventOverflow,
  3469. requiresIfExists: ['offset']
  3470. };
  3471. function getHTMLElementScroll(element) {
  3472. return {
  3473. scrollLeft: element.scrollLeft,
  3474. scrollTop: element.scrollTop
  3475. };
  3476. }
  3477. function getNodeScroll(node) {
  3478. if (node === getWindow(node) || !isHTMLElement(node)) {
  3479. return getWindowScroll(node);
  3480. } else {
  3481. return getHTMLElementScroll(node);
  3482. }
  3483. }
  3484. function isElementScaled(element) {
  3485. var rect = element.getBoundingClientRect();
  3486. var scaleX = round(rect.width) / element.offsetWidth || 1;
  3487. var scaleY = round(rect.height) / element.offsetHeight || 1;
  3488. return scaleX !== 1 || scaleY !== 1;
  3489. }
  3490. function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
  3491. if (isFixed === void 0) {
  3492. isFixed = false;
  3493. }
  3494. var isOffsetParentAnElement = isHTMLElement(offsetParent);
  3495. var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
  3496. var documentElement = getDocumentElement(offsetParent);
  3497. var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
  3498. var scroll = {
  3499. scrollLeft: 0,
  3500. scrollTop: 0
  3501. };
  3502. var offsets = {
  3503. x: 0,
  3504. y: 0
  3505. };
  3506. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  3507. if (getNodeName(offsetParent) !== 'body' ||
  3508. isScrollParent(documentElement)) {
  3509. scroll = getNodeScroll(offsetParent);
  3510. }
  3511. if (isHTMLElement(offsetParent)) {
  3512. offsets = getBoundingClientRect(offsetParent, true);
  3513. offsets.x += offsetParent.clientLeft;
  3514. offsets.y += offsetParent.clientTop;
  3515. } else if (documentElement) {
  3516. offsets.x = getWindowScrollBarX(documentElement);
  3517. }
  3518. }
  3519. return {
  3520. x: rect.left + scroll.scrollLeft - offsets.x,
  3521. y: rect.top + scroll.scrollTop - offsets.y,
  3522. width: rect.width,
  3523. height: rect.height
  3524. };
  3525. }
  3526. function order(modifiers) {
  3527. var map = new Map();
  3528. var visited = new Set();
  3529. var result = [];
  3530. modifiers.forEach(function (modifier) {
  3531. map.set(modifier.name, modifier);
  3532. });
  3533. function sort(modifier) {
  3534. visited.add(modifier.name);
  3535. var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
  3536. requires.forEach(function (dep) {
  3537. if (!visited.has(dep)) {
  3538. var depModifier = map.get(dep);
  3539. if (depModifier) {
  3540. sort(depModifier);
  3541. }
  3542. }
  3543. });
  3544. result.push(modifier);
  3545. }
  3546. modifiers.forEach(function (modifier) {
  3547. if (!visited.has(modifier.name)) {
  3548. sort(modifier);
  3549. }
  3550. });
  3551. return result;
  3552. }
  3553. function orderModifiers(modifiers) {
  3554. var orderedModifiers = order(modifiers);
  3555. return modifierPhases.reduce(function (acc, phase) {
  3556. return acc.concat(orderedModifiers.filter(function (modifier) {
  3557. return modifier.phase === phase;
  3558. }));
  3559. }, []);
  3560. }
  3561. function debounce(fn) {
  3562. var pending;
  3563. return function () {
  3564. if (!pending) {
  3565. pending = new Promise(function (resolve) {
  3566. Promise.resolve().then(function () {
  3567. pending = undefined;
  3568. resolve(fn());
  3569. });
  3570. });
  3571. }
  3572. return pending;
  3573. };
  3574. }
  3575. function mergeByName(modifiers) {
  3576. var merged = modifiers.reduce(function (merged, current) {
  3577. var existing = merged[current.name];
  3578. merged[current.name] = existing ? Object.assign({}, existing, current, {
  3579. options: Object.assign({}, existing.options, current.options),
  3580. data: Object.assign({}, existing.data, current.data)
  3581. }) : current;
  3582. return merged;
  3583. }, {});
  3584. return Object.keys(merged).map(function (key) {
  3585. return merged[key];
  3586. });
  3587. }
  3588. var DEFAULT_OPTIONS = {
  3589. placement: 'bottom',
  3590. modifiers: [],
  3591. strategy: 'absolute'
  3592. };
  3593. function areValidElements() {
  3594. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3595. args[_key] = arguments[_key];
  3596. }
  3597. return !args.some(function (element) {
  3598. return !(element && typeof element.getBoundingClientRect === 'function');
  3599. });
  3600. }
  3601. function popperGenerator(generatorOptions) {
  3602. if (generatorOptions === void 0) {
  3603. generatorOptions = {};
  3604. }
  3605. var _generatorOptions = generatorOptions,
  3606. _generatorOptions$def = _generatorOptions.defaultModifiers,
  3607. defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
  3608. _generatorOptions$def2 = _generatorOptions.defaultOptions,
  3609. defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
  3610. return function createPopper(reference, popper, options) {
  3611. if (options === void 0) {
  3612. options = defaultOptions;
  3613. }
  3614. var state = {
  3615. placement: 'bottom',
  3616. orderedModifiers: [],
  3617. options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
  3618. modifiersData: {},
  3619. elements: {
  3620. reference: reference,
  3621. popper: popper
  3622. },
  3623. attributes: {},
  3624. styles: {}
  3625. };
  3626. var effectCleanupFns = [];
  3627. var isDestroyed = false;
  3628. var instance = {
  3629. state: state,
  3630. setOptions: function setOptions(setOptionsAction) {
  3631. var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
  3632. cleanupModifierEffects();
  3633. state.options = Object.assign({}, defaultOptions, state.options, options);
  3634. state.scrollParents = {
  3635. reference: isElement$1(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
  3636. popper: listScrollParents(popper)
  3637. };
  3638. var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers)));
  3639. state.orderedModifiers = orderedModifiers.filter(function (m) {
  3640. return m.enabled;
  3641. });
  3642. runModifierEffects();
  3643. return instance.update();
  3644. },
  3645. forceUpdate: function forceUpdate() {
  3646. if (isDestroyed) {
  3647. return;
  3648. }
  3649. var _state$elements = state.elements,
  3650. reference = _state$elements.reference,
  3651. popper = _state$elements.popper;
  3652. if (!areValidElements(reference, popper)) {
  3653. return;
  3654. }
  3655. state.rects = {
  3656. reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
  3657. popper: getLayoutRect(popper)
  3658. };
  3659. state.reset = false;
  3660. state.placement = state.options.placement;
  3661. state.orderedModifiers.forEach(function (modifier) {
  3662. return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
  3663. });
  3664. for (var index = 0; index < state.orderedModifiers.length; index++) {
  3665. if (state.reset === true) {
  3666. state.reset = false;
  3667. index = -1;
  3668. continue;
  3669. }
  3670. var _state$orderedModifie = state.orderedModifiers[index],
  3671. fn = _state$orderedModifie.fn,
  3672. _state$orderedModifie2 = _state$orderedModifie.options,
  3673. _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
  3674. name = _state$orderedModifie.name;
  3675. if (typeof fn === 'function') {
  3676. state = fn({
  3677. state: state,
  3678. options: _options,
  3679. name: name,
  3680. instance: instance
  3681. }) || state;
  3682. }
  3683. }
  3684. },
  3685. update: debounce(function () {
  3686. return new Promise(function (resolve) {
  3687. instance.forceUpdate();
  3688. resolve(state);
  3689. });
  3690. }),
  3691. destroy: function destroy() {
  3692. cleanupModifierEffects();
  3693. isDestroyed = true;
  3694. }
  3695. };
  3696. if (!areValidElements(reference, popper)) {
  3697. return instance;
  3698. }
  3699. instance.setOptions(options).then(function (state) {
  3700. if (!isDestroyed && options.onFirstUpdate) {
  3701. options.onFirstUpdate(state);
  3702. }
  3703. });
  3704. function runModifierEffects() {
  3705. state.orderedModifiers.forEach(function (_ref3) {
  3706. var name = _ref3.name,
  3707. _ref3$options = _ref3.options,
  3708. options = _ref3$options === void 0 ? {} : _ref3$options,
  3709. effect = _ref3.effect;
  3710. if (typeof effect === 'function') {
  3711. var cleanupFn = effect({
  3712. state: state,
  3713. name: name,
  3714. instance: instance,
  3715. options: options
  3716. });
  3717. var noopFn = function noopFn() {};
  3718. effectCleanupFns.push(cleanupFn || noopFn);
  3719. }
  3720. });
  3721. }
  3722. function cleanupModifierEffects() {
  3723. effectCleanupFns.forEach(function (fn) {
  3724. return fn();
  3725. });
  3726. effectCleanupFns = [];
  3727. }
  3728. return instance;
  3729. };
  3730. }
  3731. var createPopper$2 = popperGenerator();
  3732. var defaultModifiers$1 = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1];
  3733. var createPopper$1 = popperGenerator({
  3734. defaultModifiers: defaultModifiers$1
  3735. });
  3736. var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
  3737. var createPopper = popperGenerator({
  3738. defaultModifiers: defaultModifiers
  3739. });
  3740. var Popper = /*#__PURE__*/Object.freeze({
  3741. __proto__: null,
  3742. popperGenerator: popperGenerator,
  3743. detectOverflow: detectOverflow,
  3744. createPopperBase: createPopper$2,
  3745. createPopper: createPopper,
  3746. createPopperLite: createPopper$1,
  3747. top: top,
  3748. bottom: bottom,
  3749. right: right,
  3750. left: left,
  3751. auto: auto,
  3752. basePlacements: basePlacements,
  3753. start: start,
  3754. end: end,
  3755. clippingParents: clippingParents,
  3756. viewport: viewport,
  3757. popper: popper,
  3758. reference: reference,
  3759. variationPlacements: variationPlacements,
  3760. placements: placements,
  3761. beforeRead: beforeRead,
  3762. read: read,
  3763. afterRead: afterRead,
  3764. beforeMain: beforeMain,
  3765. main: main,
  3766. afterMain: afterMain,
  3767. beforeWrite: beforeWrite,
  3768. write: write,
  3769. afterWrite: afterWrite,
  3770. modifierPhases: modifierPhases,
  3771. applyStyles: applyStyles$1,
  3772. arrow: arrow$1,
  3773. computeStyles: computeStyles$1,
  3774. eventListeners: eventListeners,
  3775. flip: flip$1,
  3776. hide: hide$1,
  3777. offset: offset$1,
  3778. popperOffsets: popperOffsets$1,
  3779. preventOverflow: preventOverflow$1
  3780. });
  3781. /*!
  3782. * Bootstrap v5.3.0-alpha3 (https://getbootstrap.com/)
  3783. * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  3784. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3785. */
  3786. const elementMap = new Map();
  3787. const Data = {
  3788. set(element, key, instance) {
  3789. if (!elementMap.has(element)) {
  3790. elementMap.set(element, new Map());
  3791. }
  3792. const instanceMap = elementMap.get(element);
  3793. if (!instanceMap.has(key) && instanceMap.size !== 0) {
  3794. console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`);
  3795. return;
  3796. }
  3797. instanceMap.set(key, instance);
  3798. },
  3799. get(element, key) {
  3800. if (elementMap.has(element)) {
  3801. return elementMap.get(element).get(key) || null;
  3802. }
  3803. return null;
  3804. },
  3805. remove(element, key) {
  3806. if (!elementMap.has(element)) {
  3807. return;
  3808. }
  3809. const instanceMap = elementMap.get(element);
  3810. instanceMap.delete(key);
  3811. if (instanceMap.size === 0) {
  3812. elementMap.delete(element);
  3813. }
  3814. }
  3815. };
  3816. const MAX_UID = 1000000;
  3817. const MILLISECONDS_MULTIPLIER = 1000;
  3818. const TRANSITION_END = 'transitionend';
  3819. const parseSelector = selector => {
  3820. if (selector && window.CSS && window.CSS.escape) {
  3821. selector = selector.replace(/#([^\s"#']+)/g, (match, id) => `#${CSS.escape(id)}`);
  3822. }
  3823. return selector;
  3824. };
  3825. const toType = object => {
  3826. if (object === null || object === undefined) {
  3827. return `${object}`;
  3828. }
  3829. return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
  3830. };
  3831. const getUID = prefix => {
  3832. do {
  3833. prefix += Math.floor(Math.random() * MAX_UID);
  3834. } while (document.getElementById(prefix));
  3835. return prefix;
  3836. };
  3837. const getTransitionDurationFromElement = element => {
  3838. if (!element) {
  3839. return 0;
  3840. }
  3841. let {
  3842. transitionDuration,
  3843. transitionDelay
  3844. } = window.getComputedStyle(element);
  3845. const floatTransitionDuration = Number.parseFloat(transitionDuration);
  3846. const floatTransitionDelay = Number.parseFloat(transitionDelay);
  3847. if (!floatTransitionDuration && !floatTransitionDelay) {
  3848. return 0;
  3849. }
  3850. transitionDuration = transitionDuration.split(',')[0];
  3851. transitionDelay = transitionDelay.split(',')[0];
  3852. return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  3853. };
  3854. const triggerTransitionEnd = element => {
  3855. element.dispatchEvent(new Event(TRANSITION_END));
  3856. };
  3857. const isElement = object => {
  3858. if (!object || typeof object !== 'object') {
  3859. return false;
  3860. }
  3861. if (typeof object.jquery !== 'undefined') {
  3862. object = object[0];
  3863. }
  3864. return typeof object.nodeType !== 'undefined';
  3865. };
  3866. const getElement = object => {
  3867. if (isElement(object)) {
  3868. return object.jquery ? object[0] : object;
  3869. }
  3870. if (typeof object === 'string' && object.length > 0) {
  3871. return document.querySelector(parseSelector(object));
  3872. }
  3873. return null;
  3874. };
  3875. const isVisible = element => {
  3876. if (!isElement(element) || element.getClientRects().length === 0) {
  3877. return false;
  3878. }
  3879. const elementIsVisible = getComputedStyle(element).getPropertyValue('visibility') === 'visible';
  3880. const closedDetails = element.closest('details:not([open])');
  3881. if (!closedDetails) {
  3882. return elementIsVisible;
  3883. }
  3884. if (closedDetails !== element) {
  3885. const summary = element.closest('summary');
  3886. if (summary && summary.parentNode !== closedDetails) {
  3887. return false;
  3888. }
  3889. if (summary === null) {
  3890. return false;
  3891. }
  3892. }
  3893. return elementIsVisible;
  3894. };
  3895. const isDisabled = element => {
  3896. if (!element || element.nodeType !== Node.ELEMENT_NODE) {
  3897. return true;
  3898. }
  3899. if (element.classList.contains('disabled')) {
  3900. return true;
  3901. }
  3902. if (typeof element.disabled !== 'undefined') {
  3903. return element.disabled;
  3904. }
  3905. return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
  3906. };
  3907. const findShadowRoot = element => {
  3908. if (!document.documentElement.attachShadow) {
  3909. return null;
  3910. }
  3911. if (typeof element.getRootNode === 'function') {
  3912. const root = element.getRootNode();
  3913. return root instanceof ShadowRoot ? root : null;
  3914. }
  3915. if (element instanceof ShadowRoot) {
  3916. return element;
  3917. }
  3918. if (!element.parentNode) {
  3919. return null;
  3920. }
  3921. return findShadowRoot(element.parentNode);
  3922. };
  3923. const noop = () => {};
  3924. const reflow = element => {
  3925. element.offsetHeight;
  3926. };
  3927. const getjQuery = () => {
  3928. if (window.jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
  3929. return window.jQuery;
  3930. }
  3931. return null;
  3932. };
  3933. const DOMContentLoadedCallbacks = [];
  3934. const onDOMContentLoaded = callback => {
  3935. if (document.readyState === 'loading') {
  3936. if (!DOMContentLoadedCallbacks.length) {
  3937. document.addEventListener('DOMContentLoaded', () => {
  3938. for (const callback of DOMContentLoadedCallbacks) {
  3939. callback();
  3940. }
  3941. });
  3942. }
  3943. DOMContentLoadedCallbacks.push(callback);
  3944. } else {
  3945. callback();
  3946. }
  3947. };
  3948. const isRTL = () => document.documentElement.dir === 'rtl';
  3949. const defineJQueryPlugin = plugin => {
  3950. onDOMContentLoaded(() => {
  3951. const $ = getjQuery();
  3952. if ($) {
  3953. const name = plugin.NAME;
  3954. const JQUERY_NO_CONFLICT = $.fn[name];
  3955. $.fn[name] = plugin.jQueryInterface;
  3956. $.fn[name].Constructor = plugin;
  3957. $.fn[name].noConflict = () => {
  3958. $.fn[name] = JQUERY_NO_CONFLICT;
  3959. return plugin.jQueryInterface;
  3960. };
  3961. }
  3962. });
  3963. };
  3964. const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
  3965. return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue;
  3966. };
  3967. const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
  3968. if (!waitForTransition) {
  3969. execute(callback);
  3970. return;
  3971. }
  3972. const durationPadding = 5;
  3973. const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
  3974. let called = false;
  3975. const handler = ({
  3976. target
  3977. }) => {
  3978. if (target !== transitionElement) {
  3979. return;
  3980. }
  3981. called = true;
  3982. transitionElement.removeEventListener(TRANSITION_END, handler);
  3983. execute(callback);
  3984. };
  3985. transitionElement.addEventListener(TRANSITION_END, handler);
  3986. setTimeout(() => {
  3987. if (!called) {
  3988. triggerTransitionEnd(transitionElement);
  3989. }
  3990. }, emulatedDuration);
  3991. };
  3992. const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
  3993. const listLength = list.length;
  3994. let index = list.indexOf(activeElement);
  3995. if (index === -1) {
  3996. return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
  3997. }
  3998. index += shouldGetNext ? 1 : -1;
  3999. if (isCycleAllowed) {
  4000. index = (index + listLength) % listLength;
  4001. }
  4002. return list[Math.max(0, Math.min(index, listLength - 1))];
  4003. };
  4004. const namespaceRegex = /[^.]*(?=\..*)\.|.*/;
  4005. const stripNameRegex = /\..*/;
  4006. const stripUidRegex = /::\d+$/;
  4007. const eventRegistry = {};
  4008. let uidEvent = 1;
  4009. const customEvents = {
  4010. mouseenter: 'mouseover',
  4011. mouseleave: 'mouseout'
  4012. };
  4013. 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']);
  4014. function makeEventUid(element, uid) {
  4015. return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++;
  4016. }
  4017. function getElementEvents(element) {
  4018. const uid = makeEventUid(element);
  4019. element.uidEvent = uid;
  4020. eventRegistry[uid] = eventRegistry[uid] || {};
  4021. return eventRegistry[uid];
  4022. }
  4023. function bootstrapHandler(element, fn) {
  4024. return function handler(event) {
  4025. hydrateObj(event, {
  4026. delegateTarget: element
  4027. });
  4028. if (handler.oneOff) {
  4029. EventHandler.off(element, event.type, fn);
  4030. }
  4031. return fn.apply(element, [event]);
  4032. };
  4033. }
  4034. function bootstrapDelegationHandler(element, selector, fn) {
  4035. return function handler(event) {
  4036. const domElements = element.querySelectorAll(selector);
  4037. for (let {
  4038. target
  4039. } = event; target && target !== this; target = target.parentNode) {
  4040. for (const domElement of domElements) {
  4041. if (domElement !== target) {
  4042. continue;
  4043. }
  4044. hydrateObj(event, {
  4045. delegateTarget: target
  4046. });
  4047. if (handler.oneOff) {
  4048. EventHandler.off(element, event.type, selector, fn);
  4049. }
  4050. return fn.apply(target, [event]);
  4051. }
  4052. }
  4053. };
  4054. }
  4055. function findHandler(events, callable, delegationSelector = null) {
  4056. return Object.values(events).find(event => event.callable === callable && event.delegationSelector === delegationSelector);
  4057. }
  4058. function normalizeParameters(originalTypeEvent, handler, delegationFunction) {
  4059. const isDelegated = typeof handler === 'string';
  4060. const callable = isDelegated ? delegationFunction : handler || delegationFunction;
  4061. let typeEvent = getTypeEvent(originalTypeEvent);
  4062. if (!nativeEvents.has(typeEvent)) {
  4063. typeEvent = originalTypeEvent;
  4064. }
  4065. return [isDelegated, callable, typeEvent];
  4066. }
  4067. function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) {
  4068. if (typeof originalTypeEvent !== 'string' || !element) {
  4069. return;
  4070. }
  4071. let [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
  4072. if (originalTypeEvent in customEvents) {
  4073. const wrapFunction = fn => {
  4074. return function (event) {
  4075. if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) {
  4076. return fn.call(this, event);
  4077. }
  4078. };
  4079. };
  4080. callable = wrapFunction(callable);
  4081. }
  4082. const events = getElementEvents(element);
  4083. const handlers = events[typeEvent] || (events[typeEvent] = {});
  4084. const previousFunction = findHandler(handlers, callable, isDelegated ? handler : null);
  4085. if (previousFunction) {
  4086. previousFunction.oneOff = previousFunction.oneOff && oneOff;
  4087. return;
  4088. }
  4089. const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, ''));
  4090. const fn = isDelegated ? bootstrapDelegationHandler(element, handler, callable) : bootstrapHandler(element, callable);
  4091. fn.delegationSelector = isDelegated ? handler : null;
  4092. fn.callable = callable;
  4093. fn.oneOff = oneOff;
  4094. fn.uidEvent = uid;
  4095. handlers[uid] = fn;
  4096. element.addEventListener(typeEvent, fn, isDelegated);
  4097. }
  4098. function removeHandler(element, events, typeEvent, handler, delegationSelector) {
  4099. const fn = findHandler(events[typeEvent], handler, delegationSelector);
  4100. if (!fn) {
  4101. return;
  4102. }
  4103. element.removeEventListener(typeEvent, fn, Boolean(delegationSelector));
  4104. delete events[typeEvent][fn.uidEvent];
  4105. }
  4106. function removeNamespacedHandlers(element, events, typeEvent, namespace) {
  4107. const storeElementEvent = events[typeEvent] || {};
  4108. for (const [handlerKey, event] of Object.entries(storeElementEvent)) {
  4109. if (handlerKey.includes(namespace)) {
  4110. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  4111. }
  4112. }
  4113. }
  4114. function getTypeEvent(event) {
  4115. event = event.replace(stripNameRegex, '');
  4116. return customEvents[event] || event;
  4117. }
  4118. const EventHandler = {
  4119. on(element, event, handler, delegationFunction) {
  4120. addHandler(element, event, handler, delegationFunction, false);
  4121. },
  4122. one(element, event, handler, delegationFunction) {
  4123. addHandler(element, event, handler, delegationFunction, true);
  4124. },
  4125. off(element, originalTypeEvent, handler, delegationFunction) {
  4126. if (typeof originalTypeEvent !== 'string' || !element) {
  4127. return;
  4128. }
  4129. const [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
  4130. const inNamespace = typeEvent !== originalTypeEvent;
  4131. const events = getElementEvents(element);
  4132. const storeElementEvent = events[typeEvent] || {};
  4133. const isNamespace = originalTypeEvent.startsWith('.');
  4134. if (typeof callable !== 'undefined') {
  4135. if (!Object.keys(storeElementEvent).length) {
  4136. return;
  4137. }
  4138. removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null);
  4139. return;
  4140. }
  4141. if (isNamespace) {
  4142. for (const elementEvent of Object.keys(events)) {
  4143. removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1));
  4144. }
  4145. }
  4146. for (const [keyHandlers, event] of Object.entries(storeElementEvent)) {
  4147. const handlerKey = keyHandlers.replace(stripUidRegex, '');
  4148. if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
  4149. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  4150. }
  4151. }
  4152. },
  4153. trigger(element, event, args) {
  4154. if (typeof event !== 'string' || !element) {
  4155. return null;
  4156. }
  4157. const $ = getjQuery();
  4158. const typeEvent = getTypeEvent(event);
  4159. const inNamespace = event !== typeEvent;
  4160. let jQueryEvent = null;
  4161. let bubbles = true;
  4162. let nativeDispatch = true;
  4163. let defaultPrevented = false;
  4164. if (inNamespace && $) {
  4165. jQueryEvent = $.Event(event, args);
  4166. $(element).trigger(jQueryEvent);
  4167. bubbles = !jQueryEvent.isPropagationStopped();
  4168. nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
  4169. defaultPrevented = jQueryEvent.isDefaultPrevented();
  4170. }
  4171. const evt = hydrateObj(new Event(event, {
  4172. bubbles,
  4173. cancelable: true
  4174. }), args);
  4175. if (defaultPrevented) {
  4176. evt.preventDefault();
  4177. }
  4178. if (nativeDispatch) {
  4179. element.dispatchEvent(evt);
  4180. }
  4181. if (evt.defaultPrevented && jQueryEvent) {
  4182. jQueryEvent.preventDefault();
  4183. }
  4184. return evt;
  4185. }
  4186. };
  4187. function hydrateObj(obj, meta = {}) {
  4188. for (const [key, value] of Object.entries(meta)) {
  4189. try {
  4190. obj[key] = value;
  4191. } catch (_unused) {
  4192. Object.defineProperty(obj, key, {
  4193. configurable: true,
  4194. get() {
  4195. return value;
  4196. }
  4197. });
  4198. }
  4199. }
  4200. return obj;
  4201. }
  4202. function normalizeData(value) {
  4203. if (value === 'true') {
  4204. return true;
  4205. }
  4206. if (value === 'false') {
  4207. return false;
  4208. }
  4209. if (value === Number(value).toString()) {
  4210. return Number(value);
  4211. }
  4212. if (value === '' || value === 'null') {
  4213. return null;
  4214. }
  4215. if (typeof value !== 'string') {
  4216. return value;
  4217. }
  4218. try {
  4219. return JSON.parse(decodeURIComponent(value));
  4220. } catch (_unused) {
  4221. return value;
  4222. }
  4223. }
  4224. function normalizeDataKey(key) {
  4225. return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`);
  4226. }
  4227. const Manipulator = {
  4228. setDataAttribute(element, key, value) {
  4229. element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value);
  4230. },
  4231. removeDataAttribute(element, key) {
  4232. element.removeAttribute(`data-bs-${normalizeDataKey(key)}`);
  4233. },
  4234. getDataAttributes(element) {
  4235. if (!element) {
  4236. return {};
  4237. }
  4238. const attributes = {};
  4239. const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs') && !key.startsWith('bsConfig'));
  4240. for (const key of bsKeys) {
  4241. let pureKey = key.replace(/^bs/, '');
  4242. pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
  4243. attributes[pureKey] = normalizeData(element.dataset[key]);
  4244. }
  4245. return attributes;
  4246. },
  4247. getDataAttribute(element, key) {
  4248. return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`));
  4249. }
  4250. };
  4251. class Config {
  4252. static get Default() {
  4253. return {};
  4254. }
  4255. static get DefaultType() {
  4256. return {};
  4257. }
  4258. static get NAME() {
  4259. throw new Error('You have to implement the static method "NAME", for each component!');
  4260. }
  4261. _getConfig(config) {
  4262. config = this._mergeConfigObj(config);
  4263. config = this._configAfterMerge(config);
  4264. this._typeCheckConfig(config);
  4265. return config;
  4266. }
  4267. _configAfterMerge(config) {
  4268. return config;
  4269. }
  4270. _mergeConfigObj(config, element) {
  4271. const jsonConfig = isElement(element) ? Manipulator.getDataAttribute(element, 'config') : {};
  4272. return {
  4273. ...this.constructor.Default,
  4274. ...(typeof jsonConfig === 'object' ? jsonConfig : {}),
  4275. ...(isElement(element) ? Manipulator.getDataAttributes(element) : {}),
  4276. ...(typeof config === 'object' ? config : {})
  4277. };
  4278. }
  4279. _typeCheckConfig(config, configTypes = this.constructor.DefaultType) {
  4280. for (const [property, expectedTypes] of Object.entries(configTypes)) {
  4281. const value = config[property];
  4282. const valueType = isElement(value) ? 'element' : toType(value);
  4283. if (!new RegExp(expectedTypes).test(valueType)) {
  4284. throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
  4285. }
  4286. }
  4287. }
  4288. }
  4289. const VERSION = '5.3.0-alpha2';
  4290. class BaseComponent extends Config {
  4291. constructor(element, config) {
  4292. super();
  4293. element = getElement(element);
  4294. if (!element) {
  4295. return;
  4296. }
  4297. this._element = element;
  4298. this._config = this._getConfig(config);
  4299. Data.set(this._element, this.constructor.DATA_KEY, this);
  4300. }
  4301. dispose() {
  4302. Data.remove(this._element, this.constructor.DATA_KEY);
  4303. EventHandler.off(this._element, this.constructor.EVENT_KEY);
  4304. for (const propertyName of Object.getOwnPropertyNames(this)) {
  4305. this[propertyName] = null;
  4306. }
  4307. }
  4308. _queueCallback(callback, element, isAnimated = true) {
  4309. executeAfterTransition(callback, element, isAnimated);
  4310. }
  4311. _getConfig(config) {
  4312. config = this._mergeConfigObj(config, this._element);
  4313. config = this._configAfterMerge(config);
  4314. this._typeCheckConfig(config);
  4315. return config;
  4316. }
  4317. static getInstance(element) {
  4318. return Data.get(getElement(element), this.DATA_KEY);
  4319. }
  4320. static getOrCreateInstance(element, config = {}) {
  4321. return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
  4322. }
  4323. static get VERSION() {
  4324. return VERSION;
  4325. }
  4326. static get DATA_KEY() {
  4327. return `bs.${this.NAME}`;
  4328. }
  4329. static get EVENT_KEY() {
  4330. return `.${this.DATA_KEY}`;
  4331. }
  4332. static eventName(name) {
  4333. return `${name}${this.EVENT_KEY}`;
  4334. }
  4335. }
  4336. const getSelector = element => {
  4337. let selector = element.getAttribute('data-bs-target');
  4338. if (!selector || selector === '#') {
  4339. let hrefAttribute = element.getAttribute('href');
  4340. if (!hrefAttribute || !hrefAttribute.includes('#') && !hrefAttribute.startsWith('.')) {
  4341. return null;
  4342. }
  4343. if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) {
  4344. hrefAttribute = `#${hrefAttribute.split('#')[1]}`;
  4345. }
  4346. selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null;
  4347. }
  4348. return parseSelector(selector);
  4349. };
  4350. const SelectorEngine = {
  4351. find(selector, element = document.documentElement) {
  4352. return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
  4353. },
  4354. findOne(selector, element = document.documentElement) {
  4355. return Element.prototype.querySelector.call(element, selector);
  4356. },
  4357. children(element, selector) {
  4358. return [].concat(...element.children).filter(child => child.matches(selector));
  4359. },
  4360. parents(element, selector) {
  4361. const parents = [];
  4362. let ancestor = element.parentNode.closest(selector);
  4363. while (ancestor) {
  4364. parents.push(ancestor);
  4365. ancestor = ancestor.parentNode.closest(selector);
  4366. }
  4367. return parents;
  4368. },
  4369. prev(element, selector) {
  4370. let previous = element.previousElementSibling;
  4371. while (previous) {
  4372. if (previous.matches(selector)) {
  4373. return [previous];
  4374. }
  4375. previous = previous.previousElementSibling;
  4376. }
  4377. return [];
  4378. },
  4379. next(element, selector) {
  4380. let next = element.nextElementSibling;
  4381. while (next) {
  4382. if (next.matches(selector)) {
  4383. return [next];
  4384. }
  4385. next = next.nextElementSibling;
  4386. }
  4387. return [];
  4388. },
  4389. focusableChildren(element) {
  4390. const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(',');
  4391. return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
  4392. },
  4393. getSelectorFromElement(element) {
  4394. const selector = getSelector(element);
  4395. if (selector) {
  4396. return SelectorEngine.findOne(selector) ? selector : null;
  4397. }
  4398. return null;
  4399. },
  4400. getElementFromSelector(element) {
  4401. const selector = getSelector(element);
  4402. return selector ? SelectorEngine.findOne(selector) : null;
  4403. },
  4404. getMultipleElementsFromSelector(element) {
  4405. const selector = getSelector(element);
  4406. return selector ? SelectorEngine.find(selector) : [];
  4407. }
  4408. };
  4409. const enableDismissTrigger = (component, method = 'hide') => {
  4410. const clickEvent = `click.dismiss${component.EVENT_KEY}`;
  4411. const name = component.NAME;
  4412. EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
  4413. if (['A', 'AREA'].includes(this.tagName)) {
  4414. event.preventDefault();
  4415. }
  4416. if (isDisabled(this)) {
  4417. return;
  4418. }
  4419. const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`);
  4420. const instance = component.getOrCreateInstance(target);
  4421. instance[method]();
  4422. });
  4423. };
  4424. const NAME$f = 'alert';
  4425. const DATA_KEY$a = 'bs.alert';
  4426. const EVENT_KEY$b = `.${DATA_KEY$a}`;
  4427. const EVENT_CLOSE = `close${EVENT_KEY$b}`;
  4428. const EVENT_CLOSED = `closed${EVENT_KEY$b}`;
  4429. const CLASS_NAME_FADE$5 = 'fade';
  4430. const CLASS_NAME_SHOW$8 = 'show';
  4431. class Alert extends BaseComponent {
  4432. static get NAME() {
  4433. return NAME$f;
  4434. }
  4435. close() {
  4436. const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
  4437. if (closeEvent.defaultPrevented) {
  4438. return;
  4439. }
  4440. this._element.classList.remove(CLASS_NAME_SHOW$8);
  4441. const isAnimated = this._element.classList.contains(CLASS_NAME_FADE$5);
  4442. this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
  4443. }
  4444. _destroyElement() {
  4445. this._element.remove();
  4446. EventHandler.trigger(this._element, EVENT_CLOSED);
  4447. this.dispose();
  4448. }
  4449. static jQueryInterface(config) {
  4450. return this.each(function () {
  4451. const data = Alert.getOrCreateInstance(this);
  4452. if (typeof config !== 'string') {
  4453. return;
  4454. }
  4455. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  4456. throw new TypeError(`No method named "${config}"`);
  4457. }
  4458. data[config](this);
  4459. });
  4460. }
  4461. }
  4462. enableDismissTrigger(Alert, 'close');
  4463. defineJQueryPlugin(Alert);
  4464. const NAME$e = 'button';
  4465. const DATA_KEY$9 = 'bs.button';
  4466. const EVENT_KEY$a = `.${DATA_KEY$9}`;
  4467. const DATA_API_KEY$6 = '.data-api';
  4468. const CLASS_NAME_ACTIVE$3 = 'active';
  4469. const SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]';
  4470. const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`;
  4471. class Button extends BaseComponent {
  4472. static get NAME() {
  4473. return NAME$e;
  4474. }
  4475. toggle() {
  4476. this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE$3));
  4477. }
  4478. static jQueryInterface(config) {
  4479. return this.each(function () {
  4480. const data = Button.getOrCreateInstance(this);
  4481. if (config === 'toggle') {
  4482. data[config]();
  4483. }
  4484. });
  4485. }
  4486. }
  4487. EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, event => {
  4488. event.preventDefault();
  4489. const button = event.target.closest(SELECTOR_DATA_TOGGLE$5);
  4490. const data = Button.getOrCreateInstance(button);
  4491. data.toggle();
  4492. });
  4493. defineJQueryPlugin(Button);
  4494. const NAME$d = 'swipe';
  4495. const EVENT_KEY$9 = '.bs.swipe';
  4496. const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$9}`;
  4497. const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$9}`;
  4498. const EVENT_TOUCHEND = `touchend${EVENT_KEY$9}`;
  4499. const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$9}`;
  4500. const EVENT_POINTERUP = `pointerup${EVENT_KEY$9}`;
  4501. const POINTER_TYPE_TOUCH = 'touch';
  4502. const POINTER_TYPE_PEN = 'pen';
  4503. const CLASS_NAME_POINTER_EVENT = 'pointer-event';
  4504. const SWIPE_THRESHOLD = 40;
  4505. const Default$c = {
  4506. endCallback: null,
  4507. leftCallback: null,
  4508. rightCallback: null
  4509. };
  4510. const DefaultType$c = {
  4511. endCallback: '(function|null)',
  4512. leftCallback: '(function|null)',
  4513. rightCallback: '(function|null)'
  4514. };
  4515. class Swipe extends Config {
  4516. constructor(element, config) {
  4517. super();
  4518. this._element = element;
  4519. if (!element || !Swipe.isSupported()) {
  4520. return;
  4521. }
  4522. this._config = this._getConfig(config);
  4523. this._deltaX = 0;
  4524. this._supportPointerEvents = Boolean(window.PointerEvent);
  4525. this._initEvents();
  4526. }
  4527. static get Default() {
  4528. return Default$c;
  4529. }
  4530. static get DefaultType() {
  4531. return DefaultType$c;
  4532. }
  4533. static get NAME() {
  4534. return NAME$d;
  4535. }
  4536. dispose() {
  4537. EventHandler.off(this._element, EVENT_KEY$9);
  4538. }
  4539. _start(event) {
  4540. if (!this._supportPointerEvents) {
  4541. this._deltaX = event.touches[0].clientX;
  4542. return;
  4543. }
  4544. if (this._eventIsPointerPenTouch(event)) {
  4545. this._deltaX = event.clientX;
  4546. }
  4547. }
  4548. _end(event) {
  4549. if (this._eventIsPointerPenTouch(event)) {
  4550. this._deltaX = event.clientX - this._deltaX;
  4551. }
  4552. this._handleSwipe();
  4553. execute(this._config.endCallback);
  4554. }
  4555. _move(event) {
  4556. this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX;
  4557. }
  4558. _handleSwipe() {
  4559. const absDeltaX = Math.abs(this._deltaX);
  4560. if (absDeltaX <= SWIPE_THRESHOLD) {
  4561. return;
  4562. }
  4563. const direction = absDeltaX / this._deltaX;
  4564. this._deltaX = 0;
  4565. if (!direction) {
  4566. return;
  4567. }
  4568. execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback);
  4569. }
  4570. _initEvents() {
  4571. if (this._supportPointerEvents) {
  4572. EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event));
  4573. EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event));
  4574. this._element.classList.add(CLASS_NAME_POINTER_EVENT);
  4575. } else {
  4576. EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event));
  4577. EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event));
  4578. EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event));
  4579. }
  4580. }
  4581. _eventIsPointerPenTouch(event) {
  4582. return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
  4583. }
  4584. static isSupported() {
  4585. return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  4586. }
  4587. }
  4588. const NAME$c = 'carousel';
  4589. const DATA_KEY$8 = 'bs.carousel';
  4590. const EVENT_KEY$8 = `.${DATA_KEY$8}`;
  4591. const DATA_API_KEY$5 = '.data-api';
  4592. const ARROW_LEFT_KEY$1 = 'ArrowLeft';
  4593. const ARROW_RIGHT_KEY$1 = 'ArrowRight';
  4594. const TOUCHEVENT_COMPAT_WAIT = 500;
  4595. const ORDER_NEXT = 'next';
  4596. const ORDER_PREV = 'prev';
  4597. const DIRECTION_LEFT = 'left';
  4598. const DIRECTION_RIGHT = 'right';
  4599. const EVENT_SLIDE = `slide${EVENT_KEY$8}`;
  4600. const EVENT_SLID = `slid${EVENT_KEY$8}`;
  4601. const EVENT_KEYDOWN$1 = `keydown${EVENT_KEY$8}`;
  4602. const EVENT_MOUSEENTER$1 = `mouseenter${EVENT_KEY$8}`;
  4603. const EVENT_MOUSELEAVE$1 = `mouseleave${EVENT_KEY$8}`;
  4604. const EVENT_DRAG_START = `dragstart${EVENT_KEY$8}`;
  4605. const EVENT_LOAD_DATA_API$3 = `load${EVENT_KEY$8}${DATA_API_KEY$5}`;
  4606. const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`;
  4607. const CLASS_NAME_CAROUSEL = 'carousel';
  4608. const CLASS_NAME_ACTIVE$2 = 'active';
  4609. const CLASS_NAME_SLIDE = 'slide';
  4610. const CLASS_NAME_END = 'carousel-item-end';
  4611. const CLASS_NAME_START = 'carousel-item-start';
  4612. const CLASS_NAME_NEXT = 'carousel-item-next';
  4613. const CLASS_NAME_PREV = 'carousel-item-prev';
  4614. const SELECTOR_ACTIVE = '.active';
  4615. const SELECTOR_ITEM = '.carousel-item';
  4616. const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
  4617. const SELECTOR_ITEM_IMG = '.carousel-item img';
  4618. const SELECTOR_INDICATORS = '.carousel-indicators';
  4619. const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
  4620. const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
  4621. const KEY_TO_DIRECTION = {
  4622. [ARROW_LEFT_KEY$1]: DIRECTION_RIGHT,
  4623. [ARROW_RIGHT_KEY$1]: DIRECTION_LEFT
  4624. };
  4625. const Default$b = {
  4626. interval: 5000,
  4627. keyboard: true,
  4628. pause: 'hover',
  4629. ride: false,
  4630. touch: true,
  4631. wrap: true
  4632. };
  4633. const DefaultType$b = {
  4634. interval: '(number|boolean)',
  4635. keyboard: 'boolean',
  4636. pause: '(string|boolean)',
  4637. ride: '(boolean|string)',
  4638. touch: 'boolean',
  4639. wrap: 'boolean'
  4640. };
  4641. class Carousel extends BaseComponent {
  4642. constructor(element, config) {
  4643. super(element, config);
  4644. this._interval = null;
  4645. this._activeElement = null;
  4646. this._isSliding = false;
  4647. this.touchTimeout = null;
  4648. this._swipeHelper = null;
  4649. this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
  4650. this._addEventListeners();
  4651. if (this._config.ride === CLASS_NAME_CAROUSEL) {
  4652. this.cycle();
  4653. }
  4654. }
  4655. static get Default() {
  4656. return Default$b;
  4657. }
  4658. static get DefaultType() {
  4659. return DefaultType$b;
  4660. }
  4661. static get NAME() {
  4662. return NAME$c;
  4663. }
  4664. next() {
  4665. this._slide(ORDER_NEXT);
  4666. }
  4667. nextWhenVisible() {
  4668. if (!document.hidden && isVisible(this._element)) {
  4669. this.next();
  4670. }
  4671. }
  4672. prev() {
  4673. this._slide(ORDER_PREV);
  4674. }
  4675. pause() {
  4676. if (this._isSliding) {
  4677. triggerTransitionEnd(this._element);
  4678. }
  4679. this._clearInterval();
  4680. }
  4681. cycle() {
  4682. this._clearInterval();
  4683. this._updateInterval();
  4684. this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval);
  4685. }
  4686. _maybeEnableCycle() {
  4687. if (!this._config.ride) {
  4688. return;
  4689. }
  4690. if (this._isSliding) {
  4691. EventHandler.one(this._element, EVENT_SLID, () => this.cycle());
  4692. return;
  4693. }
  4694. this.cycle();
  4695. }
  4696. to(index) {
  4697. const items = this._getItems();
  4698. if (index > items.length - 1 || index < 0) {
  4699. return;
  4700. }
  4701. if (this._isSliding) {
  4702. EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
  4703. return;
  4704. }
  4705. const activeIndex = this._getItemIndex(this._getActive());
  4706. if (activeIndex === index) {
  4707. return;
  4708. }
  4709. const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
  4710. this._slide(order, items[index]);
  4711. }
  4712. dispose() {
  4713. if (this._swipeHelper) {
  4714. this._swipeHelper.dispose();
  4715. }
  4716. super.dispose();
  4717. }
  4718. _configAfterMerge(config) {
  4719. config.defaultInterval = config.interval;
  4720. return config;
  4721. }
  4722. _addEventListeners() {
  4723. if (this._config.keyboard) {
  4724. EventHandler.on(this._element, EVENT_KEYDOWN$1, event => this._keydown(event));
  4725. }
  4726. if (this._config.pause === 'hover') {
  4727. EventHandler.on(this._element, EVENT_MOUSEENTER$1, () => this.pause());
  4728. EventHandler.on(this._element, EVENT_MOUSELEAVE$1, () => this._maybeEnableCycle());
  4729. }
  4730. if (this._config.touch && Swipe.isSupported()) {
  4731. this._addTouchEventListeners();
  4732. }
  4733. }
  4734. _addTouchEventListeners() {
  4735. for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) {
  4736. EventHandler.on(img, EVENT_DRAG_START, event => event.preventDefault());
  4737. }
  4738. const endCallBack = () => {
  4739. if (this._config.pause !== 'hover') {
  4740. return;
  4741. }
  4742. this.pause();
  4743. if (this.touchTimeout) {
  4744. clearTimeout(this.touchTimeout);
  4745. }
  4746. this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
  4747. };
  4748. const swipeConfig = {
  4749. leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
  4750. rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
  4751. endCallback: endCallBack
  4752. };
  4753. this._swipeHelper = new Swipe(this._element, swipeConfig);
  4754. }
  4755. _keydown(event) {
  4756. if (/input|textarea/i.test(event.target.tagName)) {
  4757. return;
  4758. }
  4759. const direction = KEY_TO_DIRECTION[event.key];
  4760. if (direction) {
  4761. event.preventDefault();
  4762. this._slide(this._directionToOrder(direction));
  4763. }
  4764. }
  4765. _getItemIndex(element) {
  4766. return this._getItems().indexOf(element);
  4767. }
  4768. _setActiveIndicatorElement(index) {
  4769. if (!this._indicatorsElement) {
  4770. return;
  4771. }
  4772. const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
  4773. activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2);
  4774. activeIndicator.removeAttribute('aria-current');
  4775. const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
  4776. if (newActiveIndicator) {
  4777. newActiveIndicator.classList.add(CLASS_NAME_ACTIVE$2);
  4778. newActiveIndicator.setAttribute('aria-current', 'true');
  4779. }
  4780. }
  4781. _updateInterval() {
  4782. const element = this._activeElement || this._getActive();
  4783. if (!element) {
  4784. return;
  4785. }
  4786. const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
  4787. this._config.interval = elementInterval || this._config.defaultInterval;
  4788. }
  4789. _slide(order, element = null) {
  4790. if (this._isSliding) {
  4791. return;
  4792. }
  4793. const activeElement = this._getActive();
  4794. const isNext = order === ORDER_NEXT;
  4795. const nextElement = element || getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap);
  4796. if (nextElement === activeElement) {
  4797. return;
  4798. }
  4799. const nextElementIndex = this._getItemIndex(nextElement);
  4800. const triggerEvent = eventName => {
  4801. return EventHandler.trigger(this._element, eventName, {
  4802. relatedTarget: nextElement,
  4803. direction: this._orderToDirection(order),
  4804. from: this._getItemIndex(activeElement),
  4805. to: nextElementIndex
  4806. });
  4807. };
  4808. const slideEvent = triggerEvent(EVENT_SLIDE);
  4809. if (slideEvent.defaultPrevented) {
  4810. return;
  4811. }
  4812. if (!activeElement || !nextElement) {
  4813. return;
  4814. }
  4815. const isCycling = Boolean(this._interval);
  4816. this.pause();
  4817. this._isSliding = true;
  4818. this._setActiveIndicatorElement(nextElementIndex);
  4819. this._activeElement = nextElement;
  4820. const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
  4821. const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
  4822. nextElement.classList.add(orderClassName);
  4823. reflow(nextElement);
  4824. activeElement.classList.add(directionalClassName);
  4825. nextElement.classList.add(directionalClassName);
  4826. const completeCallBack = () => {
  4827. nextElement.classList.remove(directionalClassName, orderClassName);
  4828. nextElement.classList.add(CLASS_NAME_ACTIVE$2);
  4829. activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName);
  4830. this._isSliding = false;
  4831. triggerEvent(EVENT_SLID);
  4832. };
  4833. this._queueCallback(completeCallBack, activeElement, this._isAnimated());
  4834. if (isCycling) {
  4835. this.cycle();
  4836. }
  4837. }
  4838. _isAnimated() {
  4839. return this._element.classList.contains(CLASS_NAME_SLIDE);
  4840. }
  4841. _getActive() {
  4842. return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
  4843. }
  4844. _getItems() {
  4845. return SelectorEngine.find(SELECTOR_ITEM, this._element);
  4846. }
  4847. _clearInterval() {
  4848. if (this._interval) {
  4849. clearInterval(this._interval);
  4850. this._interval = null;
  4851. }
  4852. }
  4853. _directionToOrder(direction) {
  4854. if (isRTL()) {
  4855. return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
  4856. }
  4857. return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
  4858. }
  4859. _orderToDirection(order) {
  4860. if (isRTL()) {
  4861. return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
  4862. }
  4863. return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
  4864. }
  4865. static jQueryInterface(config) {
  4866. return this.each(function () {
  4867. const data = Carousel.getOrCreateInstance(this, config);
  4868. if (typeof config === 'number') {
  4869. data.to(config);
  4870. return;
  4871. }
  4872. if (typeof config === 'string') {
  4873. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  4874. throw new TypeError(`No method named "${config}"`);
  4875. }
  4876. data[config]();
  4877. }
  4878. });
  4879. }
  4880. }
  4881. EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, function (event) {
  4882. const target = SelectorEngine.getElementFromSelector(this);
  4883. if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
  4884. return;
  4885. }
  4886. event.preventDefault();
  4887. const carousel = Carousel.getOrCreateInstance(target);
  4888. const slideIndex = this.getAttribute('data-bs-slide-to');
  4889. if (slideIndex) {
  4890. carousel.to(slideIndex);
  4891. carousel._maybeEnableCycle();
  4892. return;
  4893. }
  4894. if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
  4895. carousel.next();
  4896. carousel._maybeEnableCycle();
  4897. return;
  4898. }
  4899. carousel.prev();
  4900. carousel._maybeEnableCycle();
  4901. });
  4902. EventHandler.on(window, EVENT_LOAD_DATA_API$3, () => {
  4903. const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
  4904. for (const carousel of carousels) {
  4905. Carousel.getOrCreateInstance(carousel);
  4906. }
  4907. });
  4908. defineJQueryPlugin(Carousel);
  4909. const NAME$b = 'collapse';
  4910. const DATA_KEY$7 = 'bs.collapse';
  4911. const EVENT_KEY$7 = `.${DATA_KEY$7}`;
  4912. const DATA_API_KEY$4 = '.data-api';
  4913. const EVENT_SHOW$6 = `show${EVENT_KEY$7}`;
  4914. const EVENT_SHOWN$6 = `shown${EVENT_KEY$7}`;
  4915. const EVENT_HIDE$6 = `hide${EVENT_KEY$7}`;
  4916. const EVENT_HIDDEN$6 = `hidden${EVENT_KEY$7}`;
  4917. const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`;
  4918. const CLASS_NAME_SHOW$7 = 'show';
  4919. const CLASS_NAME_COLLAPSE = 'collapse';
  4920. const CLASS_NAME_COLLAPSING = 'collapsing';
  4921. const CLASS_NAME_COLLAPSED = 'collapsed';
  4922. const CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`;
  4923. const CLASS_NAME_HORIZONTAL = 'collapse-horizontal';
  4924. const WIDTH = 'width';
  4925. const HEIGHT = 'height';
  4926. const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing';
  4927. const SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]';
  4928. const Default$a = {
  4929. parent: null,
  4930. toggle: true
  4931. };
  4932. const DefaultType$a = {
  4933. parent: '(null|element)',
  4934. toggle: 'boolean'
  4935. };
  4936. class Collapse extends BaseComponent {
  4937. constructor(element, config) {
  4938. super(element, config);
  4939. this._isTransitioning = false;
  4940. this._triggerArray = [];
  4941. const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$4);
  4942. for (const elem of toggleList) {
  4943. const selector = SelectorEngine.getSelectorFromElement(elem);
  4944. const filterElement = SelectorEngine.find(selector).filter(foundElement => foundElement === this._element);
  4945. if (selector !== null && filterElement.length) {
  4946. this._triggerArray.push(elem);
  4947. }
  4948. }
  4949. this._initializeChildren();
  4950. if (!this._config.parent) {
  4951. this._addAriaAndCollapsedClass(this._triggerArray, this._isShown());
  4952. }
  4953. if (this._config.toggle) {
  4954. this.toggle();
  4955. }
  4956. }
  4957. static get Default() {
  4958. return Default$a;
  4959. }
  4960. static get DefaultType() {
  4961. return DefaultType$a;
  4962. }
  4963. static get NAME() {
  4964. return NAME$b;
  4965. }
  4966. toggle() {
  4967. if (this._isShown()) {
  4968. this.hide();
  4969. } else {
  4970. this.show();
  4971. }
  4972. }
  4973. show() {
  4974. if (this._isTransitioning || this._isShown()) {
  4975. return;
  4976. }
  4977. let activeChildren = [];
  4978. if (this._config.parent) {
  4979. activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter(element => element !== this._element).map(element => Collapse.getOrCreateInstance(element, {
  4980. toggle: false
  4981. }));
  4982. }
  4983. if (activeChildren.length && activeChildren[0]._isTransitioning) {
  4984. return;
  4985. }
  4986. const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$6);
  4987. if (startEvent.defaultPrevented) {
  4988. return;
  4989. }
  4990. for (const activeInstance of activeChildren) {
  4991. activeInstance.hide();
  4992. }
  4993. const dimension = this._getDimension();
  4994. this._element.classList.remove(CLASS_NAME_COLLAPSE);
  4995. this._element.classList.add(CLASS_NAME_COLLAPSING);
  4996. this._element.style[dimension] = 0;
  4997. this._addAriaAndCollapsedClass(this._triggerArray, true);
  4998. this._isTransitioning = true;
  4999. const complete = () => {
  5000. this._isTransitioning = false;
  5001. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  5002. this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  5003. this._element.style[dimension] = '';
  5004. EventHandler.trigger(this._element, EVENT_SHOWN$6);
  5005. };
  5006. const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  5007. const scrollSize = `scroll${capitalizedDimension}`;
  5008. this._queueCallback(complete, this._element, true);
  5009. this._element.style[dimension] = `${this._element[scrollSize]}px`;
  5010. }
  5011. hide() {
  5012. if (this._isTransitioning || !this._isShown()) {
  5013. return;
  5014. }
  5015. const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$6);
  5016. if (startEvent.defaultPrevented) {
  5017. return;
  5018. }
  5019. const dimension = this._getDimension();
  5020. this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
  5021. reflow(this._element);
  5022. this._element.classList.add(CLASS_NAME_COLLAPSING);
  5023. this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  5024. for (const trigger of this._triggerArray) {
  5025. const element = SelectorEngine.getElementFromSelector(trigger);
  5026. if (element && !this._isShown(element)) {
  5027. this._addAriaAndCollapsedClass([trigger], false);
  5028. }
  5029. }
  5030. this._isTransitioning = true;
  5031. const complete = () => {
  5032. this._isTransitioning = false;
  5033. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  5034. this._element.classList.add(CLASS_NAME_COLLAPSE);
  5035. EventHandler.trigger(this._element, EVENT_HIDDEN$6);
  5036. };
  5037. this._element.style[dimension] = '';
  5038. this._queueCallback(complete, this._element, true);
  5039. }
  5040. _isShown(element = this._element) {
  5041. return element.classList.contains(CLASS_NAME_SHOW$7);
  5042. }
  5043. _configAfterMerge(config) {
  5044. config.toggle = Boolean(config.toggle);
  5045. config.parent = getElement(config.parent);
  5046. return config;
  5047. }
  5048. _getDimension() {
  5049. return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT;
  5050. }
  5051. _initializeChildren() {
  5052. if (!this._config.parent) {
  5053. return;
  5054. }
  5055. const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$4);
  5056. for (const element of children) {
  5057. const selected = SelectorEngine.getElementFromSelector(element);
  5058. if (selected) {
  5059. this._addAriaAndCollapsedClass([element], this._isShown(selected));
  5060. }
  5061. }
  5062. }
  5063. _getFirstLevelChildren(selector) {
  5064. const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent);
  5065. return SelectorEngine.find(selector, this._config.parent).filter(element => !children.includes(element));
  5066. }
  5067. _addAriaAndCollapsedClass(triggerArray, isOpen) {
  5068. if (!triggerArray.length) {
  5069. return;
  5070. }
  5071. for (const element of triggerArray) {
  5072. element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen);
  5073. element.setAttribute('aria-expanded', isOpen);
  5074. }
  5075. }
  5076. static jQueryInterface(config) {
  5077. const _config = {};
  5078. if (typeof config === 'string' && /show|hide/.test(config)) {
  5079. _config.toggle = false;
  5080. }
  5081. return this.each(function () {
  5082. const data = Collapse.getOrCreateInstance(this, _config);
  5083. if (typeof config === 'string') {
  5084. if (typeof data[config] === 'undefined') {
  5085. throw new TypeError(`No method named "${config}"`);
  5086. }
  5087. data[config]();
  5088. }
  5089. });
  5090. }
  5091. }
  5092. EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, function (event) {
  5093. if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') {
  5094. event.preventDefault();
  5095. }
  5096. for (const element of SelectorEngine.getMultipleElementsFromSelector(this)) {
  5097. Collapse.getOrCreateInstance(element, {
  5098. toggle: false
  5099. }).toggle();
  5100. }
  5101. });
  5102. defineJQueryPlugin(Collapse);
  5103. const NAME$a = 'dropdown';
  5104. const DATA_KEY$6 = 'bs.dropdown';
  5105. const EVENT_KEY$6 = `.${DATA_KEY$6}`;
  5106. const DATA_API_KEY$3 = '.data-api';
  5107. const ESCAPE_KEY$2 = 'Escape';
  5108. const TAB_KEY$1 = 'Tab';
  5109. const ARROW_UP_KEY$1 = 'ArrowUp';
  5110. const ARROW_DOWN_KEY$1 = 'ArrowDown';
  5111. const RIGHT_MOUSE_BUTTON = 2;
  5112. const EVENT_HIDE$5 = `hide${EVENT_KEY$6}`;
  5113. const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$6}`;
  5114. const EVENT_SHOW$5 = `show${EVENT_KEY$6}`;
  5115. const EVENT_SHOWN$5 = `shown${EVENT_KEY$6}`;
  5116. const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`;
  5117. const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$6}${DATA_API_KEY$3}`;
  5118. const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$6}${DATA_API_KEY$3}`;
  5119. const CLASS_NAME_SHOW$6 = 'show';
  5120. const CLASS_NAME_DROPUP = 'dropup';
  5121. const CLASS_NAME_DROPEND = 'dropend';
  5122. const CLASS_NAME_DROPSTART = 'dropstart';
  5123. const CLASS_NAME_DROPUP_CENTER = 'dropup-center';
  5124. const CLASS_NAME_DROPDOWN_CENTER = 'dropdown-center';
  5125. const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)';
  5126. const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE$3}.${CLASS_NAME_SHOW$6}`;
  5127. const SELECTOR_MENU = '.dropdown-menu';
  5128. const SELECTOR_NAVBAR = '.navbar';
  5129. const SELECTOR_NAVBAR_NAV = '.navbar-nav';
  5130. const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  5131. const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start';
  5132. const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end';
  5133. const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start';
  5134. const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end';
  5135. const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start';
  5136. const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start';
  5137. const PLACEMENT_TOPCENTER = 'top';
  5138. const PLACEMENT_BOTTOMCENTER = 'bottom';
  5139. const Default$9 = {
  5140. autoClose: true,
  5141. boundary: 'clippingParents',
  5142. display: 'dynamic',
  5143. offset: [0, 2],
  5144. popperConfig: null,
  5145. reference: 'toggle'
  5146. };
  5147. const DefaultType$9 = {
  5148. autoClose: '(boolean|string)',
  5149. boundary: '(string|element)',
  5150. display: 'string',
  5151. offset: '(array|string|function)',
  5152. popperConfig: '(null|object|function)',
  5153. reference: '(string|element|object)'
  5154. };
  5155. class Dropdown extends BaseComponent {
  5156. constructor(element, config) {
  5157. super(element, config);
  5158. this._popper = null;
  5159. this._parent = this._element.parentNode;
  5160. this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU)[0] || SelectorEngine.findOne(SELECTOR_MENU, this._parent);
  5161. this._inNavbar = this._detectNavbar();
  5162. }
  5163. static get Default() {
  5164. return Default$9;
  5165. }
  5166. static get DefaultType() {
  5167. return DefaultType$9;
  5168. }
  5169. static get NAME() {
  5170. return NAME$a;
  5171. }
  5172. toggle() {
  5173. return this._isShown() ? this.hide() : this.show();
  5174. }
  5175. show() {
  5176. if (isDisabled(this._element) || this._isShown()) {
  5177. return;
  5178. }
  5179. const relatedTarget = {
  5180. relatedTarget: this._element
  5181. };
  5182. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$5, relatedTarget);
  5183. if (showEvent.defaultPrevented) {
  5184. return;
  5185. }
  5186. this._createPopper();
  5187. if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {
  5188. for (const element of [].concat(...document.body.children)) {
  5189. EventHandler.on(element, 'mouseover', noop);
  5190. }
  5191. }
  5192. this._element.focus();
  5193. this._element.setAttribute('aria-expanded', true);
  5194. this._menu.classList.add(CLASS_NAME_SHOW$6);
  5195. this._element.classList.add(CLASS_NAME_SHOW$6);
  5196. EventHandler.trigger(this._element, EVENT_SHOWN$5, relatedTarget);
  5197. }
  5198. hide() {
  5199. if (isDisabled(this._element) || !this._isShown()) {
  5200. return;
  5201. }
  5202. const relatedTarget = {
  5203. relatedTarget: this._element
  5204. };
  5205. this._completeHide(relatedTarget);
  5206. }
  5207. dispose() {
  5208. if (this._popper) {
  5209. this._popper.destroy();
  5210. }
  5211. super.dispose();
  5212. }
  5213. update() {
  5214. this._inNavbar = this._detectNavbar();
  5215. if (this._popper) {
  5216. this._popper.update();
  5217. }
  5218. }
  5219. _completeHide(relatedTarget) {
  5220. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$5, relatedTarget);
  5221. if (hideEvent.defaultPrevented) {
  5222. return;
  5223. }
  5224. if ('ontouchstart' in document.documentElement) {
  5225. for (const element of [].concat(...document.body.children)) {
  5226. EventHandler.off(element, 'mouseover', noop);
  5227. }
  5228. }
  5229. if (this._popper) {
  5230. this._popper.destroy();
  5231. }
  5232. this._menu.classList.remove(CLASS_NAME_SHOW$6);
  5233. this._element.classList.remove(CLASS_NAME_SHOW$6);
  5234. this._element.setAttribute('aria-expanded', 'false');
  5235. Manipulator.removeDataAttribute(this._menu, 'popper');
  5236. EventHandler.trigger(this._element, EVENT_HIDDEN$5, relatedTarget);
  5237. }
  5238. _getConfig(config) {
  5239. config = super._getConfig(config);
  5240. if (typeof config.reference === 'object' && !isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
  5241. throw new TypeError(`${NAME$a.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
  5242. }
  5243. return config;
  5244. }
  5245. _createPopper() {
  5246. if (typeof Popper === 'undefined') {
  5247. throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
  5248. }
  5249. let referenceElement = this._element;
  5250. if (this._config.reference === 'parent') {
  5251. referenceElement = this._parent;
  5252. } else if (isElement(this._config.reference)) {
  5253. referenceElement = getElement(this._config.reference);
  5254. } else if (typeof this._config.reference === 'object') {
  5255. referenceElement = this._config.reference;
  5256. }
  5257. const popperConfig = this._getPopperConfig();
  5258. this._popper = createPopper(referenceElement, this._menu, popperConfig);
  5259. }
  5260. _isShown() {
  5261. return this._menu.classList.contains(CLASS_NAME_SHOW$6);
  5262. }
  5263. _getPlacement() {
  5264. const parentDropdown = this._parent;
  5265. if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
  5266. return PLACEMENT_RIGHT;
  5267. }
  5268. if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
  5269. return PLACEMENT_LEFT;
  5270. }
  5271. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) {
  5272. return PLACEMENT_TOPCENTER;
  5273. }
  5274. if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) {
  5275. return PLACEMENT_BOTTOMCENTER;
  5276. }
  5277. const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
  5278. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
  5279. return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
  5280. }
  5281. return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
  5282. }
  5283. _detectNavbar() {
  5284. return this._element.closest(SELECTOR_NAVBAR) !== null;
  5285. }
  5286. _getOffset() {
  5287. const {
  5288. offset
  5289. } = this._config;
  5290. if (typeof offset === 'string') {
  5291. return offset.split(',').map(value => Number.parseInt(value, 10));
  5292. }
  5293. if (typeof offset === 'function') {
  5294. return popperData => offset(popperData, this._element);
  5295. }
  5296. return offset;
  5297. }
  5298. _getPopperConfig() {
  5299. const defaultBsPopperConfig = {
  5300. placement: this._getPlacement(),
  5301. modifiers: [{
  5302. name: 'preventOverflow',
  5303. options: {
  5304. boundary: this._config.boundary
  5305. }
  5306. }, {
  5307. name: 'offset',
  5308. options: {
  5309. offset: this._getOffset()
  5310. }
  5311. }]
  5312. };
  5313. if (this._inNavbar || this._config.display === 'static') {
  5314. Manipulator.setDataAttribute(this._menu, 'popper', 'static');
  5315. defaultBsPopperConfig.modifiers = [{
  5316. name: 'applyStyles',
  5317. enabled: false
  5318. }];
  5319. }
  5320. return {
  5321. ...defaultBsPopperConfig,
  5322. ...execute(this._config.popperConfig, [defaultBsPopperConfig])
  5323. };
  5324. }
  5325. _selectMenuItem({
  5326. key,
  5327. target
  5328. }) {
  5329. const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => isVisible(element));
  5330. if (!items.length) {
  5331. return;
  5332. }
  5333. getNextActiveElement(items, target, key === ARROW_DOWN_KEY$1, !items.includes(target)).focus();
  5334. }
  5335. static jQueryInterface(config) {
  5336. return this.each(function () {
  5337. const data = Dropdown.getOrCreateInstance(this, config);
  5338. if (typeof config !== 'string') {
  5339. return;
  5340. }
  5341. if (typeof data[config] === 'undefined') {
  5342. throw new TypeError(`No method named "${config}"`);
  5343. }
  5344. data[config]();
  5345. });
  5346. }
  5347. static clearMenus(event) {
  5348. if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY$1) {
  5349. return;
  5350. }
  5351. const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN);
  5352. for (const toggle of openToggles) {
  5353. const context = Dropdown.getInstance(toggle);
  5354. if (!context || context._config.autoClose === false) {
  5355. continue;
  5356. }
  5357. const composedPath = event.composedPath();
  5358. const isMenuTarget = composedPath.includes(context._menu);
  5359. if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) {
  5360. continue;
  5361. }
  5362. if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) {
  5363. continue;
  5364. }
  5365. const relatedTarget = {
  5366. relatedTarget: context._element
  5367. };
  5368. if (event.type === 'click') {
  5369. relatedTarget.clickEvent = event;
  5370. }
  5371. context._completeHide(relatedTarget);
  5372. }
  5373. }
  5374. static dataApiKeydownHandler(event) {
  5375. const isInput = /input|textarea/i.test(event.target.tagName);
  5376. const isEscapeEvent = event.key === ESCAPE_KEY$2;
  5377. const isUpOrDownEvent = [ARROW_UP_KEY$1, ARROW_DOWN_KEY$1].includes(event.key);
  5378. if (!isUpOrDownEvent && !isEscapeEvent) {
  5379. return;
  5380. }
  5381. if (isInput && !isEscapeEvent) {
  5382. return;
  5383. }
  5384. event.preventDefault();
  5385. 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);
  5386. const instance = Dropdown.getOrCreateInstance(getToggleButton);
  5387. if (isUpOrDownEvent) {
  5388. event.stopPropagation();
  5389. instance.show();
  5390. instance._selectMenuItem(event);
  5391. return;
  5392. }
  5393. if (instance._isShown()) {
  5394. event.stopPropagation();
  5395. instance.hide();
  5396. getToggleButton.focus();
  5397. }
  5398. }
  5399. }
  5400. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
  5401. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
  5402. EventHandler.on(document, EVENT_CLICK_DATA_API$3, Dropdown.clearMenus);
  5403. EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
  5404. EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, function (event) {
  5405. event.preventDefault();
  5406. Dropdown.getOrCreateInstance(this).toggle();
  5407. });
  5408. defineJQueryPlugin(Dropdown);
  5409. const NAME$9 = 'backdrop';
  5410. const CLASS_NAME_FADE$4 = 'fade';
  5411. const CLASS_NAME_SHOW$5 = 'show';
  5412. const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$9}`;
  5413. const Default$8 = {
  5414. className: 'modal-backdrop',
  5415. clickCallback: null,
  5416. isAnimated: false,
  5417. isVisible: true,
  5418. rootElement: 'body'
  5419. };
  5420. const DefaultType$8 = {
  5421. className: 'string',
  5422. clickCallback: '(function|null)',
  5423. isAnimated: 'boolean',
  5424. isVisible: 'boolean',
  5425. rootElement: '(element|string)'
  5426. };
  5427. class Backdrop extends Config {
  5428. constructor(config) {
  5429. super();
  5430. this._config = this._getConfig(config);
  5431. this._isAppended = false;
  5432. this._element = null;
  5433. }
  5434. static get Default() {
  5435. return Default$8;
  5436. }
  5437. static get DefaultType() {
  5438. return DefaultType$8;
  5439. }
  5440. static get NAME() {
  5441. return NAME$9;
  5442. }
  5443. show(callback) {
  5444. if (!this._config.isVisible) {
  5445. execute(callback);
  5446. return;
  5447. }
  5448. this._append();
  5449. const element = this._getElement();
  5450. if (this._config.isAnimated) {
  5451. reflow(element);
  5452. }
  5453. element.classList.add(CLASS_NAME_SHOW$5);
  5454. this._emulateAnimation(() => {
  5455. execute(callback);
  5456. });
  5457. }
  5458. hide(callback) {
  5459. if (!this._config.isVisible) {
  5460. execute(callback);
  5461. return;
  5462. }
  5463. this._getElement().classList.remove(CLASS_NAME_SHOW$5);
  5464. this._emulateAnimation(() => {
  5465. this.dispose();
  5466. execute(callback);
  5467. });
  5468. }
  5469. dispose() {
  5470. if (!this._isAppended) {
  5471. return;
  5472. }
  5473. EventHandler.off(this._element, EVENT_MOUSEDOWN);
  5474. this._element.remove();
  5475. this._isAppended = false;
  5476. }
  5477. _getElement() {
  5478. if (!this._element) {
  5479. const backdrop = document.createElement('div');
  5480. backdrop.className = this._config.className;
  5481. if (this._config.isAnimated) {
  5482. backdrop.classList.add(CLASS_NAME_FADE$4);
  5483. }
  5484. this._element = backdrop;
  5485. }
  5486. return this._element;
  5487. }
  5488. _configAfterMerge(config) {
  5489. config.rootElement = getElement(config.rootElement);
  5490. return config;
  5491. }
  5492. _append() {
  5493. if (this._isAppended) {
  5494. return;
  5495. }
  5496. const element = this._getElement();
  5497. this._config.rootElement.append(element);
  5498. EventHandler.on(element, EVENT_MOUSEDOWN, () => {
  5499. execute(this._config.clickCallback);
  5500. });
  5501. this._isAppended = true;
  5502. }
  5503. _emulateAnimation(callback) {
  5504. executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
  5505. }
  5506. }
  5507. const NAME$8 = 'focustrap';
  5508. const DATA_KEY$5 = 'bs.focustrap';
  5509. const EVENT_KEY$5 = `.${DATA_KEY$5}`;
  5510. const EVENT_FOCUSIN$2 = `focusin${EVENT_KEY$5}`;
  5511. const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$5}`;
  5512. const TAB_KEY = 'Tab';
  5513. const TAB_NAV_FORWARD = 'forward';
  5514. const TAB_NAV_BACKWARD = 'backward';
  5515. const Default$7 = {
  5516. autofocus: true,
  5517. trapElement: null
  5518. };
  5519. const DefaultType$7 = {
  5520. autofocus: 'boolean',
  5521. trapElement: 'element'
  5522. };
  5523. class FocusTrap extends Config {
  5524. constructor(config) {
  5525. super();
  5526. this._config = this._getConfig(config);
  5527. this._isActive = false;
  5528. this._lastTabNavDirection = null;
  5529. }
  5530. static get Default() {
  5531. return Default$7;
  5532. }
  5533. static get DefaultType() {
  5534. return DefaultType$7;
  5535. }
  5536. static get NAME() {
  5537. return NAME$8;
  5538. }
  5539. activate() {
  5540. if (this._isActive) {
  5541. return;
  5542. }
  5543. if (this._config.autofocus) {
  5544. this._config.trapElement.focus();
  5545. }
  5546. EventHandler.off(document, EVENT_KEY$5);
  5547. EventHandler.on(document, EVENT_FOCUSIN$2, event => this._handleFocusin(event));
  5548. EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
  5549. this._isActive = true;
  5550. }
  5551. deactivate() {
  5552. if (!this._isActive) {
  5553. return;
  5554. }
  5555. this._isActive = false;
  5556. EventHandler.off(document, EVENT_KEY$5);
  5557. }
  5558. _handleFocusin(event) {
  5559. const {
  5560. trapElement
  5561. } = this._config;
  5562. if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {
  5563. return;
  5564. }
  5565. const elements = SelectorEngine.focusableChildren(trapElement);
  5566. if (elements.length === 0) {
  5567. trapElement.focus();
  5568. } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
  5569. elements[elements.length - 1].focus();
  5570. } else {
  5571. elements[0].focus();
  5572. }
  5573. }
  5574. _handleKeydown(event) {
  5575. if (event.key !== TAB_KEY) {
  5576. return;
  5577. }
  5578. this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
  5579. }
  5580. }
  5581. const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  5582. const SELECTOR_STICKY_CONTENT = '.sticky-top';
  5583. const PROPERTY_PADDING = 'padding-right';
  5584. const PROPERTY_MARGIN = 'margin-right';
  5585. class ScrollBarHelper {
  5586. constructor() {
  5587. this._element = document.body;
  5588. }
  5589. getWidth() {
  5590. const documentWidth = document.documentElement.clientWidth;
  5591. return Math.abs(window.innerWidth - documentWidth);
  5592. }
  5593. hide() {
  5594. const width = this.getWidth();
  5595. this._disableOverFlow();
  5596. this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  5597. this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  5598. this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width);
  5599. }
  5600. reset() {
  5601. this._resetElementAttributes(this._element, 'overflow');
  5602. this._resetElementAttributes(this._element, PROPERTY_PADDING);
  5603. this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING);
  5604. this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN);
  5605. }
  5606. isOverflowing() {
  5607. return this.getWidth() > 0;
  5608. }
  5609. _disableOverFlow() {
  5610. this._saveInitialAttribute(this._element, 'overflow');
  5611. this._element.style.overflow = 'hidden';
  5612. }
  5613. _setElementAttributes(selector, styleProperty, callback) {
  5614. const scrollbarWidth = this.getWidth();
  5615. const manipulationCallBack = element => {
  5616. if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
  5617. return;
  5618. }
  5619. this._saveInitialAttribute(element, styleProperty);
  5620. const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty);
  5621. element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`);
  5622. };
  5623. this._applyManipulationCallback(selector, manipulationCallBack);
  5624. }
  5625. _saveInitialAttribute(element, styleProperty) {
  5626. const actualValue = element.style.getPropertyValue(styleProperty);
  5627. if (actualValue) {
  5628. Manipulator.setDataAttribute(element, styleProperty, actualValue);
  5629. }
  5630. }
  5631. _resetElementAttributes(selector, styleProperty) {
  5632. const manipulationCallBack = element => {
  5633. const value = Manipulator.getDataAttribute(element, styleProperty);
  5634. if (value === null) {
  5635. element.style.removeProperty(styleProperty);
  5636. return;
  5637. }
  5638. Manipulator.removeDataAttribute(element, styleProperty);
  5639. element.style.setProperty(styleProperty, value);
  5640. };
  5641. this._applyManipulationCallback(selector, manipulationCallBack);
  5642. }
  5643. _applyManipulationCallback(selector, callBack) {
  5644. if (isElement(selector)) {
  5645. callBack(selector);
  5646. return;
  5647. }
  5648. for (const sel of SelectorEngine.find(selector, this._element)) {
  5649. callBack(sel);
  5650. }
  5651. }
  5652. }
  5653. const NAME$7 = 'modal';
  5654. const DATA_KEY$4 = 'bs.modal';
  5655. const EVENT_KEY$4 = `.${DATA_KEY$4}`;
  5656. const DATA_API_KEY$2 = '.data-api';
  5657. const ESCAPE_KEY$1 = 'Escape';
  5658. const EVENT_HIDE$4 = `hide${EVENT_KEY$4}`;
  5659. const EVENT_HIDE_PREVENTED$1 = `hidePrevented${EVENT_KEY$4}`;
  5660. const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$4}`;
  5661. const EVENT_SHOW$4 = `show${EVENT_KEY$4}`;
  5662. const EVENT_SHOWN$4 = `shown${EVENT_KEY$4}`;
  5663. const EVENT_RESIZE$1 = `resize${EVENT_KEY$4}`;
  5664. const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$4}`;
  5665. const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$4}`;
  5666. const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$4}`;
  5667. const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$4}${DATA_API_KEY$2}`;
  5668. const CLASS_NAME_OPEN = 'modal-open';
  5669. const CLASS_NAME_FADE$3 = 'fade';
  5670. const CLASS_NAME_SHOW$4 = 'show';
  5671. const CLASS_NAME_STATIC = 'modal-static';
  5672. const OPEN_SELECTOR$1 = '.modal.show';
  5673. const SELECTOR_DIALOG = '.modal-dialog';
  5674. const SELECTOR_MODAL_BODY = '.modal-body';
  5675. const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]';
  5676. const Default$6 = {
  5677. backdrop: true,
  5678. focus: true,
  5679. keyboard: true
  5680. };
  5681. const DefaultType$6 = {
  5682. backdrop: '(boolean|string)',
  5683. focus: 'boolean',
  5684. keyboard: 'boolean'
  5685. };
  5686. class Modal extends BaseComponent {
  5687. constructor(element, config) {
  5688. super(element, config);
  5689. this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element);
  5690. this._backdrop = this._initializeBackDrop();
  5691. this._focustrap = this._initializeFocusTrap();
  5692. this._isShown = false;
  5693. this._isTransitioning = false;
  5694. this._scrollBar = new ScrollBarHelper();
  5695. this._addEventListeners();
  5696. }
  5697. static get Default() {
  5698. return Default$6;
  5699. }
  5700. static get DefaultType() {
  5701. return DefaultType$6;
  5702. }
  5703. static get NAME() {
  5704. return NAME$7;
  5705. }
  5706. toggle(relatedTarget) {
  5707. return this._isShown ? this.hide() : this.show(relatedTarget);
  5708. }
  5709. show(relatedTarget) {
  5710. if (this._isShown || this._isTransitioning) {
  5711. return;
  5712. }
  5713. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, {
  5714. relatedTarget
  5715. });
  5716. if (showEvent.defaultPrevented) {
  5717. return;
  5718. }
  5719. this._isShown = true;
  5720. this._isTransitioning = true;
  5721. this._scrollBar.hide();
  5722. document.body.classList.add(CLASS_NAME_OPEN);
  5723. this._adjustDialog();
  5724. this._backdrop.show(() => this._showElement(relatedTarget));
  5725. }
  5726. hide() {
  5727. if (!this._isShown || this._isTransitioning) {
  5728. return;
  5729. }
  5730. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4);
  5731. if (hideEvent.defaultPrevented) {
  5732. return;
  5733. }
  5734. this._isShown = false;
  5735. this._isTransitioning = true;
  5736. this._focustrap.deactivate();
  5737. this._element.classList.remove(CLASS_NAME_SHOW$4);
  5738. this._queueCallback(() => this._hideModal(), this._element, this._isAnimated());
  5739. }
  5740. dispose() {
  5741. EventHandler.off(window, EVENT_KEY$4);
  5742. EventHandler.off(this._dialog, EVENT_KEY$4);
  5743. this._backdrop.dispose();
  5744. this._focustrap.deactivate();
  5745. super.dispose();
  5746. }
  5747. handleUpdate() {
  5748. this._adjustDialog();
  5749. }
  5750. _initializeBackDrop() {
  5751. return new Backdrop({
  5752. isVisible: Boolean(this._config.backdrop),
  5753. isAnimated: this._isAnimated()
  5754. });
  5755. }
  5756. _initializeFocusTrap() {
  5757. return new FocusTrap({
  5758. trapElement: this._element
  5759. });
  5760. }
  5761. _showElement(relatedTarget) {
  5762. if (!document.body.contains(this._element)) {
  5763. document.body.append(this._element);
  5764. }
  5765. this._element.style.display = 'block';
  5766. this._element.removeAttribute('aria-hidden');
  5767. this._element.setAttribute('aria-modal', true);
  5768. this._element.setAttribute('role', 'dialog');
  5769. this._element.scrollTop = 0;
  5770. const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
  5771. if (modalBody) {
  5772. modalBody.scrollTop = 0;
  5773. }
  5774. reflow(this._element);
  5775. this._element.classList.add(CLASS_NAME_SHOW$4);
  5776. const transitionComplete = () => {
  5777. if (this._config.focus) {
  5778. this._focustrap.activate();
  5779. }
  5780. this._isTransitioning = false;
  5781. EventHandler.trigger(this._element, EVENT_SHOWN$4, {
  5782. relatedTarget
  5783. });
  5784. };
  5785. this._queueCallback(transitionComplete, this._dialog, this._isAnimated());
  5786. }
  5787. _addEventListeners() {
  5788. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => {
  5789. if (event.key !== ESCAPE_KEY$1) {
  5790. return;
  5791. }
  5792. if (this._config.keyboard) {
  5793. this.hide();
  5794. return;
  5795. }
  5796. this._triggerBackdropTransition();
  5797. });
  5798. EventHandler.on(window, EVENT_RESIZE$1, () => {
  5799. if (this._isShown && !this._isTransitioning) {
  5800. this._adjustDialog();
  5801. }
  5802. });
  5803. EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => {
  5804. EventHandler.one(this._element, EVENT_CLICK_DISMISS, event2 => {
  5805. if (this._element !== event.target || this._element !== event2.target) {
  5806. return;
  5807. }
  5808. if (this._config.backdrop === 'static') {
  5809. this._triggerBackdropTransition();
  5810. return;
  5811. }
  5812. if (this._config.backdrop) {
  5813. this.hide();
  5814. }
  5815. });
  5816. });
  5817. }
  5818. _hideModal() {
  5819. this._element.style.display = 'none';
  5820. this._element.setAttribute('aria-hidden', true);
  5821. this._element.removeAttribute('aria-modal');
  5822. this._element.removeAttribute('role');
  5823. this._isTransitioning = false;
  5824. this._backdrop.hide(() => {
  5825. document.body.classList.remove(CLASS_NAME_OPEN);
  5826. this._resetAdjustments();
  5827. this._scrollBar.reset();
  5828. EventHandler.trigger(this._element, EVENT_HIDDEN$4);
  5829. });
  5830. }
  5831. _isAnimated() {
  5832. return this._element.classList.contains(CLASS_NAME_FADE$3);
  5833. }
  5834. _triggerBackdropTransition() {
  5835. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED$1);
  5836. if (hideEvent.defaultPrevented) {
  5837. return;
  5838. }
  5839. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  5840. const initialOverflowY = this._element.style.overflowY;
  5841. if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) {
  5842. return;
  5843. }
  5844. if (!isModalOverflowing) {
  5845. this._element.style.overflowY = 'hidden';
  5846. }
  5847. this._element.classList.add(CLASS_NAME_STATIC);
  5848. this._queueCallback(() => {
  5849. this._element.classList.remove(CLASS_NAME_STATIC);
  5850. this._queueCallback(() => {
  5851. this._element.style.overflowY = initialOverflowY;
  5852. }, this._dialog);
  5853. }, this._dialog);
  5854. this._element.focus();
  5855. }
  5856. _adjustDialog() {
  5857. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  5858. const scrollbarWidth = this._scrollBar.getWidth();
  5859. const isBodyOverflowing = scrollbarWidth > 0;
  5860. if (isBodyOverflowing && !isModalOverflowing) {
  5861. const property = isRTL() ? 'paddingLeft' : 'paddingRight';
  5862. this._element.style[property] = `${scrollbarWidth}px`;
  5863. }
  5864. if (!isBodyOverflowing && isModalOverflowing) {
  5865. const property = isRTL() ? 'paddingRight' : 'paddingLeft';
  5866. this._element.style[property] = `${scrollbarWidth}px`;
  5867. }
  5868. }
  5869. _resetAdjustments() {
  5870. this._element.style.paddingLeft = '';
  5871. this._element.style.paddingRight = '';
  5872. }
  5873. static jQueryInterface(config, relatedTarget) {
  5874. return this.each(function () {
  5875. const data = Modal.getOrCreateInstance(this, config);
  5876. if (typeof config !== 'string') {
  5877. return;
  5878. }
  5879. if (typeof data[config] === 'undefined') {
  5880. throw new TypeError(`No method named "${config}"`);
  5881. }
  5882. data[config](relatedTarget);
  5883. });
  5884. }
  5885. }
  5886. EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, function (event) {
  5887. const target = SelectorEngine.getElementFromSelector(this);
  5888. if (['A', 'AREA'].includes(this.tagName)) {
  5889. event.preventDefault();
  5890. }
  5891. EventHandler.one(target, EVENT_SHOW$4, showEvent => {
  5892. if (showEvent.defaultPrevented) {
  5893. return;
  5894. }
  5895. EventHandler.one(target, EVENT_HIDDEN$4, () => {
  5896. if (isVisible(this)) {
  5897. this.focus();
  5898. }
  5899. });
  5900. });
  5901. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1);
  5902. if (alreadyOpen) {
  5903. Modal.getInstance(alreadyOpen).hide();
  5904. }
  5905. const data = Modal.getOrCreateInstance(target);
  5906. data.toggle(this);
  5907. });
  5908. enableDismissTrigger(Modal);
  5909. defineJQueryPlugin(Modal);
  5910. const NAME$6 = 'offcanvas';
  5911. const DATA_KEY$3 = 'bs.offcanvas';
  5912. const EVENT_KEY$3 = `.${DATA_KEY$3}`;
  5913. const DATA_API_KEY$1 = '.data-api';
  5914. const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$3}${DATA_API_KEY$1}`;
  5915. const ESCAPE_KEY = 'Escape';
  5916. const CLASS_NAME_SHOW$3 = 'show';
  5917. const CLASS_NAME_SHOWING$1 = 'showing';
  5918. const CLASS_NAME_HIDING = 'hiding';
  5919. const CLASS_NAME_BACKDROP = 'offcanvas-backdrop';
  5920. const OPEN_SELECTOR = '.offcanvas.show';
  5921. const EVENT_SHOW$3 = `show${EVENT_KEY$3}`;
  5922. const EVENT_SHOWN$3 = `shown${EVENT_KEY$3}`;
  5923. const EVENT_HIDE$3 = `hide${EVENT_KEY$3}`;
  5924. const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$3}`;
  5925. const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$3}`;
  5926. const EVENT_RESIZE = `resize${EVENT_KEY$3}`;
  5927. const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$3}${DATA_API_KEY$1}`;
  5928. const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$3}`;
  5929. const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]';
  5930. const Default$5 = {
  5931. backdrop: true,
  5932. keyboard: true,
  5933. scroll: false
  5934. };
  5935. const DefaultType$5 = {
  5936. backdrop: '(boolean|string)',
  5937. keyboard: 'boolean',
  5938. scroll: 'boolean'
  5939. };
  5940. class Offcanvas extends BaseComponent {
  5941. constructor(element, config) {
  5942. super(element, config);
  5943. this._isShown = false;
  5944. this._backdrop = this._initializeBackDrop();
  5945. this._focustrap = this._initializeFocusTrap();
  5946. this._addEventListeners();
  5947. }
  5948. static get Default() {
  5949. return Default$5;
  5950. }
  5951. static get DefaultType() {
  5952. return DefaultType$5;
  5953. }
  5954. static get NAME() {
  5955. return NAME$6;
  5956. }
  5957. toggle(relatedTarget) {
  5958. return this._isShown ? this.hide() : this.show(relatedTarget);
  5959. }
  5960. show(relatedTarget) {
  5961. if (this._isShown) {
  5962. return;
  5963. }
  5964. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, {
  5965. relatedTarget
  5966. });
  5967. if (showEvent.defaultPrevented) {
  5968. return;
  5969. }
  5970. this._isShown = true;
  5971. this._backdrop.show();
  5972. if (!this._config.scroll) {
  5973. new ScrollBarHelper().hide();
  5974. }
  5975. this._element.setAttribute('aria-modal', true);
  5976. this._element.setAttribute('role', 'dialog');
  5977. this._element.classList.add(CLASS_NAME_SHOWING$1);
  5978. const completeCallBack = () => {
  5979. if (!this._config.scroll || this._config.backdrop) {
  5980. this._focustrap.activate();
  5981. }
  5982. this._element.classList.add(CLASS_NAME_SHOW$3);
  5983. this._element.classList.remove(CLASS_NAME_SHOWING$1);
  5984. EventHandler.trigger(this._element, EVENT_SHOWN$3, {
  5985. relatedTarget
  5986. });
  5987. };
  5988. this._queueCallback(completeCallBack, this._element, true);
  5989. }
  5990. hide() {
  5991. if (!this._isShown) {
  5992. return;
  5993. }
  5994. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3);
  5995. if (hideEvent.defaultPrevented) {
  5996. return;
  5997. }
  5998. this._focustrap.deactivate();
  5999. this._element.blur();
  6000. this._isShown = false;
  6001. this._element.classList.add(CLASS_NAME_HIDING);
  6002. this._backdrop.hide();
  6003. const completeCallback = () => {
  6004. this._element.classList.remove(CLASS_NAME_SHOW$3, CLASS_NAME_HIDING);
  6005. this._element.removeAttribute('aria-modal');
  6006. this._element.removeAttribute('role');
  6007. if (!this._config.scroll) {
  6008. new ScrollBarHelper().reset();
  6009. }
  6010. EventHandler.trigger(this._element, EVENT_HIDDEN$3);
  6011. };
  6012. this._queueCallback(completeCallback, this._element, true);
  6013. }
  6014. dispose() {
  6015. this._backdrop.dispose();
  6016. this._focustrap.deactivate();
  6017. super.dispose();
  6018. }
  6019. _initializeBackDrop() {
  6020. const clickCallback = () => {
  6021. if (this._config.backdrop === 'static') {
  6022. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  6023. return;
  6024. }
  6025. this.hide();
  6026. };
  6027. const isVisible = Boolean(this._config.backdrop);
  6028. return new Backdrop({
  6029. className: CLASS_NAME_BACKDROP,
  6030. isVisible,
  6031. isAnimated: true,
  6032. rootElement: this._element.parentNode,
  6033. clickCallback: isVisible ? clickCallback : null
  6034. });
  6035. }
  6036. _initializeFocusTrap() {
  6037. return new FocusTrap({
  6038. trapElement: this._element
  6039. });
  6040. }
  6041. _addEventListeners() {
  6042. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
  6043. if (event.key !== ESCAPE_KEY) {
  6044. return;
  6045. }
  6046. if (this._config.keyboard) {
  6047. this.hide();
  6048. return;
  6049. }
  6050. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  6051. });
  6052. }
  6053. static jQueryInterface(config) {
  6054. return this.each(function () {
  6055. const data = Offcanvas.getOrCreateInstance(this, config);
  6056. if (typeof config !== 'string') {
  6057. return;
  6058. }
  6059. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  6060. throw new TypeError(`No method named "${config}"`);
  6061. }
  6062. data[config](this);
  6063. });
  6064. }
  6065. }
  6066. EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, function (event) {
  6067. const target = SelectorEngine.getElementFromSelector(this);
  6068. if (['A', 'AREA'].includes(this.tagName)) {
  6069. event.preventDefault();
  6070. }
  6071. if (isDisabled(this)) {
  6072. return;
  6073. }
  6074. EventHandler.one(target, EVENT_HIDDEN$3, () => {
  6075. if (isVisible(this)) {
  6076. this.focus();
  6077. }
  6078. });
  6079. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR);
  6080. if (alreadyOpen && alreadyOpen !== target) {
  6081. Offcanvas.getInstance(alreadyOpen).hide();
  6082. }
  6083. const data = Offcanvas.getOrCreateInstance(target);
  6084. data.toggle(this);
  6085. });
  6086. EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
  6087. for (const selector of SelectorEngine.find(OPEN_SELECTOR)) {
  6088. Offcanvas.getOrCreateInstance(selector).show();
  6089. }
  6090. });
  6091. EventHandler.on(window, EVENT_RESIZE, () => {
  6092. for (const element of SelectorEngine.find('[aria-modal][class*=show][class*=offcanvas-]')) {
  6093. if (getComputedStyle(element).position !== 'fixed') {
  6094. Offcanvas.getOrCreateInstance(element).hide();
  6095. }
  6096. }
  6097. });
  6098. enableDismissTrigger(Offcanvas);
  6099. defineJQueryPlugin(Offcanvas);
  6100. const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
  6101. const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i;
  6102. 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;
  6103. const allowedAttribute = (attribute, allowedAttributeList) => {
  6104. const attributeName = attribute.nodeName.toLowerCase();
  6105. if (allowedAttributeList.includes(attributeName)) {
  6106. if (uriAttributes.has(attributeName)) {
  6107. return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue) || DATA_URL_PATTERN.test(attribute.nodeValue));
  6108. }
  6109. return true;
  6110. }
  6111. return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp).some(regex => regex.test(attributeName));
  6112. };
  6113. const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  6114. const DefaultAllowlist = {
  6115. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  6116. a: ['target', 'href', 'title', 'rel'],
  6117. area: [],
  6118. b: [],
  6119. br: [],
  6120. col: [],
  6121. code: [],
  6122. div: [],
  6123. em: [],
  6124. hr: [],
  6125. h1: [],
  6126. h2: [],
  6127. h3: [],
  6128. h4: [],
  6129. h5: [],
  6130. h6: [],
  6131. i: [],
  6132. img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
  6133. li: [],
  6134. ol: [],
  6135. p: [],
  6136. pre: [],
  6137. s: [],
  6138. small: [],
  6139. span: [],
  6140. sub: [],
  6141. sup: [],
  6142. strong: [],
  6143. u: [],
  6144. ul: []
  6145. };
  6146. function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {
  6147. if (!unsafeHtml.length) {
  6148. return unsafeHtml;
  6149. }
  6150. if (sanitizeFunction && typeof sanitizeFunction === 'function') {
  6151. return sanitizeFunction(unsafeHtml);
  6152. }
  6153. const domParser = new window.DOMParser();
  6154. const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  6155. const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
  6156. for (const element of elements) {
  6157. const elementName = element.nodeName.toLowerCase();
  6158. if (!Object.keys(allowList).includes(elementName)) {
  6159. element.remove();
  6160. continue;
  6161. }
  6162. const attributeList = [].concat(...element.attributes);
  6163. const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []);
  6164. for (const attribute of attributeList) {
  6165. if (!allowedAttribute(attribute, allowedAttributes)) {
  6166. element.removeAttribute(attribute.nodeName);
  6167. }
  6168. }
  6169. }
  6170. return createdDocument.body.innerHTML;
  6171. }
  6172. const NAME$5 = 'TemplateFactory';
  6173. const Default$4 = {
  6174. allowList: DefaultAllowlist,
  6175. content: {},
  6176. extraClass: '',
  6177. html: false,
  6178. sanitize: true,
  6179. sanitizeFn: null,
  6180. template: '<div></div>'
  6181. };
  6182. const DefaultType$4 = {
  6183. allowList: 'object',
  6184. content: 'object',
  6185. extraClass: '(string|function)',
  6186. html: 'boolean',
  6187. sanitize: 'boolean',
  6188. sanitizeFn: '(null|function)',
  6189. template: 'string'
  6190. };
  6191. const DefaultContentType = {
  6192. entry: '(string|element|function|null)',
  6193. selector: '(string|element)'
  6194. };
  6195. class TemplateFactory extends Config {
  6196. constructor(config) {
  6197. super();
  6198. this._config = this._getConfig(config);
  6199. }
  6200. static get Default() {
  6201. return Default$4;
  6202. }
  6203. static get DefaultType() {
  6204. return DefaultType$4;
  6205. }
  6206. static get NAME() {
  6207. return NAME$5;
  6208. }
  6209. getContent() {
  6210. return Object.values(this._config.content).map(config => this._resolvePossibleFunction(config)).filter(Boolean);
  6211. }
  6212. hasContent() {
  6213. return this.getContent().length > 0;
  6214. }
  6215. changeContent(content) {
  6216. this._checkContent(content);
  6217. this._config.content = {
  6218. ...this._config.content,
  6219. ...content
  6220. };
  6221. return this;
  6222. }
  6223. toHtml() {
  6224. const templateWrapper = document.createElement('div');
  6225. templateWrapper.innerHTML = this._maybeSanitize(this._config.template);
  6226. for (const [selector, text] of Object.entries(this._config.content)) {
  6227. this._setContent(templateWrapper, text, selector);
  6228. }
  6229. const template = templateWrapper.children[0];
  6230. const extraClass = this._resolvePossibleFunction(this._config.extraClass);
  6231. if (extraClass) {
  6232. template.classList.add(...extraClass.split(' '));
  6233. }
  6234. return template;
  6235. }
  6236. _typeCheckConfig(config) {
  6237. super._typeCheckConfig(config);
  6238. this._checkContent(config.content);
  6239. }
  6240. _checkContent(arg) {
  6241. for (const [selector, content] of Object.entries(arg)) {
  6242. super._typeCheckConfig({
  6243. selector,
  6244. entry: content
  6245. }, DefaultContentType);
  6246. }
  6247. }
  6248. _setContent(template, content, selector) {
  6249. const templateElement = SelectorEngine.findOne(selector, template);
  6250. if (!templateElement) {
  6251. return;
  6252. }
  6253. content = this._resolvePossibleFunction(content);
  6254. if (!content) {
  6255. templateElement.remove();
  6256. return;
  6257. }
  6258. if (isElement(content)) {
  6259. this._putElementInTemplate(getElement(content), templateElement);
  6260. return;
  6261. }
  6262. if (this._config.html) {
  6263. templateElement.innerHTML = this._maybeSanitize(content);
  6264. return;
  6265. }
  6266. templateElement.textContent = content;
  6267. }
  6268. _maybeSanitize(arg) {
  6269. return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
  6270. }
  6271. _resolvePossibleFunction(arg) {
  6272. return execute(arg, [this]);
  6273. }
  6274. _putElementInTemplate(element, templateElement) {
  6275. if (this._config.html) {
  6276. templateElement.innerHTML = '';
  6277. templateElement.append(element);
  6278. return;
  6279. }
  6280. templateElement.textContent = element.textContent;
  6281. }
  6282. }
  6283. const NAME$4 = 'tooltip';
  6284. const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
  6285. const CLASS_NAME_FADE$2 = 'fade';
  6286. const CLASS_NAME_MODAL = 'modal';
  6287. const CLASS_NAME_SHOW$2 = 'show';
  6288. const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
  6289. const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
  6290. const EVENT_MODAL_HIDE = 'hide.bs.modal';
  6291. const TRIGGER_HOVER = 'hover';
  6292. const TRIGGER_FOCUS = 'focus';
  6293. const TRIGGER_CLICK = 'click';
  6294. const TRIGGER_MANUAL = 'manual';
  6295. const EVENT_HIDE$2 = 'hide';
  6296. const EVENT_HIDDEN$2 = 'hidden';
  6297. const EVENT_SHOW$2 = 'show';
  6298. const EVENT_SHOWN$2 = 'shown';
  6299. const EVENT_INSERTED = 'inserted';
  6300. const EVENT_CLICK$1 = 'click';
  6301. const EVENT_FOCUSIN$1 = 'focusin';
  6302. const EVENT_FOCUSOUT$1 = 'focusout';
  6303. const EVENT_MOUSEENTER = 'mouseenter';
  6304. const EVENT_MOUSELEAVE = 'mouseleave';
  6305. const AttachmentMap = {
  6306. AUTO: 'auto',
  6307. TOP: 'top',
  6308. RIGHT: isRTL() ? 'left' : 'right',
  6309. BOTTOM: 'bottom',
  6310. LEFT: isRTL() ? 'right' : 'left'
  6311. };
  6312. const Default$3 = {
  6313. allowList: DefaultAllowlist,
  6314. animation: true,
  6315. boundary: 'clippingParents',
  6316. container: false,
  6317. customClass: '',
  6318. delay: 0,
  6319. fallbackPlacements: ['top', 'right', 'bottom', 'left'],
  6320. html: false,
  6321. offset: [0, 6],
  6322. placement: 'top',
  6323. popperConfig: null,
  6324. sanitize: true,
  6325. sanitizeFn: null,
  6326. selector: false,
  6327. template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>',
  6328. title: '',
  6329. trigger: 'hover focus'
  6330. };
  6331. const DefaultType$3 = {
  6332. allowList: 'object',
  6333. animation: 'boolean',
  6334. boundary: '(string|element)',
  6335. container: '(string|element|boolean)',
  6336. customClass: '(string|function)',
  6337. delay: '(number|object)',
  6338. fallbackPlacements: 'array',
  6339. html: 'boolean',
  6340. offset: '(array|string|function)',
  6341. placement: '(string|function)',
  6342. popperConfig: '(null|object|function)',
  6343. sanitize: 'boolean',
  6344. sanitizeFn: '(null|function)',
  6345. selector: '(string|boolean)',
  6346. template: 'string',
  6347. title: '(string|element|function)',
  6348. trigger: 'string'
  6349. };
  6350. class Tooltip extends BaseComponent {
  6351. constructor(element, config) {
  6352. if (typeof Popper === 'undefined') {
  6353. throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
  6354. }
  6355. super(element, config);
  6356. this._isEnabled = true;
  6357. this._timeout = 0;
  6358. this._isHovered = null;
  6359. this._activeTrigger = {};
  6360. this._popper = null;
  6361. this._templateFactory = null;
  6362. this._newContent = null;
  6363. this.tip = null;
  6364. this._setListeners();
  6365. if (!this._config.selector) {
  6366. this._fixTitle();
  6367. }
  6368. }
  6369. static get Default() {
  6370. return Default$3;
  6371. }
  6372. static get DefaultType() {
  6373. return DefaultType$3;
  6374. }
  6375. static get NAME() {
  6376. return NAME$4;
  6377. }
  6378. enable() {
  6379. this._isEnabled = true;
  6380. }
  6381. disable() {
  6382. this._isEnabled = false;
  6383. }
  6384. toggleEnabled() {
  6385. this._isEnabled = !this._isEnabled;
  6386. }
  6387. toggle() {
  6388. if (!this._isEnabled) {
  6389. return;
  6390. }
  6391. this._activeTrigger.click = !this._activeTrigger.click;
  6392. if (this._isShown()) {
  6393. this._leave();
  6394. return;
  6395. }
  6396. this._enter();
  6397. }
  6398. dispose() {
  6399. clearTimeout(this._timeout);
  6400. EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  6401. if (this._element.getAttribute('data-bs-original-title')) {
  6402. this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'));
  6403. }
  6404. this._disposePopper();
  6405. super.dispose();
  6406. }
  6407. show() {
  6408. if (this._element.style.display === 'none') {
  6409. throw new Error('Please use show on visible elements');
  6410. }
  6411. if (!(this._isWithContent() && this._isEnabled)) {
  6412. return;
  6413. }
  6414. const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW$2));
  6415. const shadowRoot = findShadowRoot(this._element);
  6416. const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element);
  6417. if (showEvent.defaultPrevented || !isInTheDom) {
  6418. return;
  6419. }
  6420. this._disposePopper();
  6421. const tip = this._getTipElement();
  6422. this._element.setAttribute('aria-describedby', tip.getAttribute('id'));
  6423. const {
  6424. container
  6425. } = this._config;
  6426. if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
  6427. container.append(tip);
  6428. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
  6429. }
  6430. this._popper = this._createPopper(tip);
  6431. tip.classList.add(CLASS_NAME_SHOW$2);
  6432. if ('ontouchstart' in document.documentElement) {
  6433. for (const element of [].concat(...document.body.children)) {
  6434. EventHandler.on(element, 'mouseover', noop);
  6435. }
  6436. }
  6437. const complete = () => {
  6438. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN$2));
  6439. if (this._isHovered === false) {
  6440. this._leave();
  6441. }
  6442. this._isHovered = false;
  6443. };
  6444. this._queueCallback(complete, this.tip, this._isAnimated());
  6445. }
  6446. hide() {
  6447. if (!this._isShown()) {
  6448. return;
  6449. }
  6450. const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE$2));
  6451. if (hideEvent.defaultPrevented) {
  6452. return;
  6453. }
  6454. const tip = this._getTipElement();
  6455. tip.classList.remove(CLASS_NAME_SHOW$2);
  6456. if ('ontouchstart' in document.documentElement) {
  6457. for (const element of [].concat(...document.body.children)) {
  6458. EventHandler.off(element, 'mouseover', noop);
  6459. }
  6460. }
  6461. this._activeTrigger[TRIGGER_CLICK] = false;
  6462. this._activeTrigger[TRIGGER_FOCUS] = false;
  6463. this._activeTrigger[TRIGGER_HOVER] = false;
  6464. this._isHovered = null;
  6465. const complete = () => {
  6466. if (this._isWithActiveTrigger()) {
  6467. return;
  6468. }
  6469. if (!this._isHovered) {
  6470. this._disposePopper();
  6471. }
  6472. this._element.removeAttribute('aria-describedby');
  6473. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN$2));
  6474. };
  6475. this._queueCallback(complete, this.tip, this._isAnimated());
  6476. }
  6477. update() {
  6478. if (this._popper) {
  6479. this._popper.update();
  6480. }
  6481. }
  6482. _isWithContent() {
  6483. return Boolean(this._getTitle());
  6484. }
  6485. _getTipElement() {
  6486. if (!this.tip) {
  6487. this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
  6488. }
  6489. return this.tip;
  6490. }
  6491. _createTipElement(content) {
  6492. const tip = this._getTemplateFactory(content).toHtml();
  6493. if (!tip) {
  6494. return null;
  6495. }
  6496. tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2);
  6497. tip.classList.add(`bs-${this.constructor.NAME}-auto`);
  6498. const tipId = getUID(this.constructor.NAME).toString();
  6499. tip.setAttribute('id', tipId);
  6500. if (this._isAnimated()) {
  6501. tip.classList.add(CLASS_NAME_FADE$2);
  6502. }
  6503. return tip;
  6504. }
  6505. setContent(content) {
  6506. this._newContent = content;
  6507. if (this._isShown()) {
  6508. this._disposePopper();
  6509. this.show();
  6510. }
  6511. }
  6512. _getTemplateFactory(content) {
  6513. if (this._templateFactory) {
  6514. this._templateFactory.changeContent(content);
  6515. } else {
  6516. this._templateFactory = new TemplateFactory({
  6517. ...this._config,
  6518. content,
  6519. extraClass: this._resolvePossibleFunction(this._config.customClass)
  6520. });
  6521. }
  6522. return this._templateFactory;
  6523. }
  6524. _getContentForTemplate() {
  6525. return {
  6526. [SELECTOR_TOOLTIP_INNER]: this._getTitle()
  6527. };
  6528. }
  6529. _getTitle() {
  6530. return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-bs-original-title');
  6531. }
  6532. _initializeOnDelegatedTarget(event) {
  6533. return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
  6534. }
  6535. _isAnimated() {
  6536. return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE$2);
  6537. }
  6538. _isShown() {
  6539. return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW$2);
  6540. }
  6541. _createPopper(tip) {
  6542. const placement = execute(this._config.placement, [this, tip, this._element]);
  6543. const attachment = AttachmentMap[placement.toUpperCase()];
  6544. return createPopper(this._element, tip, this._getPopperConfig(attachment));
  6545. }
  6546. _getOffset() {
  6547. const {
  6548. offset
  6549. } = this._config;
  6550. if (typeof offset === 'string') {
  6551. return offset.split(',').map(value => Number.parseInt(value, 10));
  6552. }
  6553. if (typeof offset === 'function') {
  6554. return popperData => offset(popperData, this._element);
  6555. }
  6556. return offset;
  6557. }
  6558. _resolvePossibleFunction(arg) {
  6559. return execute(arg, [this._element]);
  6560. }
  6561. _getPopperConfig(attachment) {
  6562. const defaultBsPopperConfig = {
  6563. placement: attachment,
  6564. modifiers: [{
  6565. name: 'flip',
  6566. options: {
  6567. fallbackPlacements: this._config.fallbackPlacements
  6568. }
  6569. }, {
  6570. name: 'offset',
  6571. options: {
  6572. offset: this._getOffset()
  6573. }
  6574. }, {
  6575. name: 'preventOverflow',
  6576. options: {
  6577. boundary: this._config.boundary
  6578. }
  6579. }, {
  6580. name: 'arrow',
  6581. options: {
  6582. element: `.${this.constructor.NAME}-arrow`
  6583. }
  6584. }, {
  6585. name: 'preSetPlacement',
  6586. enabled: true,
  6587. phase: 'beforeMain',
  6588. fn: data => {
  6589. this._getTipElement().setAttribute('data-popper-placement', data.state.placement);
  6590. }
  6591. }]
  6592. };
  6593. return {
  6594. ...defaultBsPopperConfig,
  6595. ...execute(this._config.popperConfig, [defaultBsPopperConfig])
  6596. };
  6597. }
  6598. _setListeners() {
  6599. const triggers = this._config.trigger.split(' ');
  6600. for (const trigger of triggers) {
  6601. if (trigger === 'click') {
  6602. EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK$1), this._config.selector, event => {
  6603. const context = this._initializeOnDelegatedTarget(event);
  6604. context.toggle();
  6605. });
  6606. } else if (trigger !== TRIGGER_MANUAL) {
  6607. const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN$1);
  6608. const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT$1);
  6609. EventHandler.on(this._element, eventIn, this._config.selector, event => {
  6610. const context = this._initializeOnDelegatedTarget(event);
  6611. context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
  6612. context._enter();
  6613. });
  6614. EventHandler.on(this._element, eventOut, this._config.selector, event => {
  6615. const context = this._initializeOnDelegatedTarget(event);
  6616. context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
  6617. context._leave();
  6618. });
  6619. }
  6620. }
  6621. this._hideModalHandler = () => {
  6622. if (this._element) {
  6623. this.hide();
  6624. }
  6625. };
  6626. EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  6627. }
  6628. _fixTitle() {
  6629. const title = this._element.getAttribute('title');
  6630. if (!title) {
  6631. return;
  6632. }
  6633. if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {
  6634. this._element.setAttribute('aria-label', title);
  6635. }
  6636. this._element.setAttribute('data-bs-original-title', title);
  6637. this._element.removeAttribute('title');
  6638. }
  6639. _enter() {
  6640. if (this._isShown() || this._isHovered) {
  6641. this._isHovered = true;
  6642. return;
  6643. }
  6644. this._isHovered = true;
  6645. this._setTimeout(() => {
  6646. if (this._isHovered) {
  6647. this.show();
  6648. }
  6649. }, this._config.delay.show);
  6650. }
  6651. _leave() {
  6652. if (this._isWithActiveTrigger()) {
  6653. return;
  6654. }
  6655. this._isHovered = false;
  6656. this._setTimeout(() => {
  6657. if (!this._isHovered) {
  6658. this.hide();
  6659. }
  6660. }, this._config.delay.hide);
  6661. }
  6662. _setTimeout(handler, timeout) {
  6663. clearTimeout(this._timeout);
  6664. this._timeout = setTimeout(handler, timeout);
  6665. }
  6666. _isWithActiveTrigger() {
  6667. return Object.values(this._activeTrigger).includes(true);
  6668. }
  6669. _getConfig(config) {
  6670. const dataAttributes = Manipulator.getDataAttributes(this._element);
  6671. for (const dataAttribute of Object.keys(dataAttributes)) {
  6672. if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) {
  6673. delete dataAttributes[dataAttribute];
  6674. }
  6675. }
  6676. config = {
  6677. ...dataAttributes,
  6678. ...(typeof config === 'object' && config ? config : {})
  6679. };
  6680. config = this._mergeConfigObj(config);
  6681. config = this._configAfterMerge(config);
  6682. this._typeCheckConfig(config);
  6683. return config;
  6684. }
  6685. _configAfterMerge(config) {
  6686. config.container = config.container === false ? document.body : getElement(config.container);
  6687. if (typeof config.delay === 'number') {
  6688. config.delay = {
  6689. show: config.delay,
  6690. hide: config.delay
  6691. };
  6692. }
  6693. if (typeof config.title === 'number') {
  6694. config.title = config.title.toString();
  6695. }
  6696. if (typeof config.content === 'number') {
  6697. config.content = config.content.toString();
  6698. }
  6699. return config;
  6700. }
  6701. _getDelegateConfig() {
  6702. const config = {};
  6703. for (const [key, value] of Object.entries(this._config)) {
  6704. if (this.constructor.Default[key] !== value) {
  6705. config[key] = value;
  6706. }
  6707. }
  6708. config.selector = false;
  6709. config.trigger = 'manual';
  6710. return config;
  6711. }
  6712. _disposePopper() {
  6713. if (this._popper) {
  6714. this._popper.destroy();
  6715. this._popper = null;
  6716. }
  6717. if (this.tip) {
  6718. this.tip.remove();
  6719. this.tip = null;
  6720. }
  6721. }
  6722. static jQueryInterface(config) {
  6723. return this.each(function () {
  6724. const data = Tooltip.getOrCreateInstance(this, config);
  6725. if (typeof config !== 'string') {
  6726. return;
  6727. }
  6728. if (typeof data[config] === 'undefined') {
  6729. throw new TypeError(`No method named "${config}"`);
  6730. }
  6731. data[config]();
  6732. });
  6733. }
  6734. }
  6735. defineJQueryPlugin(Tooltip);
  6736. const NAME$3 = 'popover';
  6737. const SELECTOR_TITLE = '.popover-header';
  6738. const SELECTOR_CONTENT = '.popover-body';
  6739. const Default$2 = {
  6740. ...Tooltip.Default,
  6741. content: '',
  6742. offset: [0, 8],
  6743. placement: 'right',
  6744. template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>',
  6745. trigger: 'click'
  6746. };
  6747. const DefaultType$2 = {
  6748. ...Tooltip.DefaultType,
  6749. content: '(null|string|element|function)'
  6750. };
  6751. class Popover extends Tooltip {
  6752. static get Default() {
  6753. return Default$2;
  6754. }
  6755. static get DefaultType() {
  6756. return DefaultType$2;
  6757. }
  6758. static get NAME() {
  6759. return NAME$3;
  6760. }
  6761. _isWithContent() {
  6762. return this._getTitle() || this._getContent();
  6763. }
  6764. _getContentForTemplate() {
  6765. return {
  6766. [SELECTOR_TITLE]: this._getTitle(),
  6767. [SELECTOR_CONTENT]: this._getContent()
  6768. };
  6769. }
  6770. _getContent() {
  6771. return this._resolvePossibleFunction(this._config.content);
  6772. }
  6773. static jQueryInterface(config) {
  6774. return this.each(function () {
  6775. const data = Popover.getOrCreateInstance(this, config);
  6776. if (typeof config !== 'string') {
  6777. return;
  6778. }
  6779. if (typeof data[config] === 'undefined') {
  6780. throw new TypeError(`No method named "${config}"`);
  6781. }
  6782. data[config]();
  6783. });
  6784. }
  6785. }
  6786. defineJQueryPlugin(Popover);
  6787. const NAME$2 = 'scrollspy';
  6788. const DATA_KEY$2 = 'bs.scrollspy';
  6789. const EVENT_KEY$2 = `.${DATA_KEY$2}`;
  6790. const DATA_API_KEY = '.data-api';
  6791. const EVENT_ACTIVATE = `activate${EVENT_KEY$2}`;
  6792. const EVENT_CLICK = `click${EVENT_KEY$2}`;
  6793. const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$2}${DATA_API_KEY}`;
  6794. const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
  6795. const CLASS_NAME_ACTIVE$1 = 'active';
  6796. const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
  6797. const SELECTOR_TARGET_LINKS = '[href]';
  6798. const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
  6799. const SELECTOR_NAV_LINKS = '.nav-link';
  6800. const SELECTOR_NAV_ITEMS = '.nav-item';
  6801. const SELECTOR_LIST_ITEMS = '.list-group-item';
  6802. const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`;
  6803. const SELECTOR_DROPDOWN = '.dropdown';
  6804. const SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle';
  6805. const Default$1 = {
  6806. offset: null,
  6807. rootMargin: '0px 0px -25%',
  6808. smoothScroll: false,
  6809. target: null,
  6810. threshold: [0.1, 0.5, 1]
  6811. };
  6812. const DefaultType$1 = {
  6813. offset: '(number|null)',
  6814. rootMargin: 'string',
  6815. smoothScroll: 'boolean',
  6816. target: 'element',
  6817. threshold: 'array'
  6818. };
  6819. class ScrollSpy extends BaseComponent {
  6820. constructor(element, config) {
  6821. super(element, config);
  6822. this._targetLinks = new Map();
  6823. this._observableSections = new Map();
  6824. this._rootElement = getComputedStyle(this._element).overflowY === 'visible' ? null : this._element;
  6825. this._activeTarget = null;
  6826. this._observer = null;
  6827. this._previousScrollData = {
  6828. visibleEntryTop: 0,
  6829. parentScrollTop: 0
  6830. };
  6831. this.refresh();
  6832. }
  6833. static get Default() {
  6834. return Default$1;
  6835. }
  6836. static get DefaultType() {
  6837. return DefaultType$1;
  6838. }
  6839. static get NAME() {
  6840. return NAME$2;
  6841. }
  6842. refresh() {
  6843. this._initializeTargetsAndObservables();
  6844. this._maybeEnableSmoothScroll();
  6845. if (this._observer) {
  6846. this._observer.disconnect();
  6847. } else {
  6848. this._observer = this._getNewObserver();
  6849. }
  6850. for (const section of this._observableSections.values()) {
  6851. this._observer.observe(section);
  6852. }
  6853. }
  6854. dispose() {
  6855. this._observer.disconnect();
  6856. super.dispose();
  6857. }
  6858. _configAfterMerge(config) {
  6859. config.target = getElement(config.target) || document.body;
  6860. config.rootMargin = config.offset ? `${config.offset}px 0px -30%` : config.rootMargin;
  6861. if (typeof config.threshold === 'string') {
  6862. config.threshold = config.threshold.split(',').map(value => Number.parseFloat(value));
  6863. }
  6864. return config;
  6865. }
  6866. _maybeEnableSmoothScroll() {
  6867. if (!this._config.smoothScroll) {
  6868. return;
  6869. }
  6870. EventHandler.off(this._config.target, EVENT_CLICK);
  6871. EventHandler.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, event => {
  6872. const observableSection = this._observableSections.get(event.target.hash);
  6873. if (observableSection) {
  6874. event.preventDefault();
  6875. const root = this._rootElement || window;
  6876. const height = observableSection.offsetTop - this._element.offsetTop;
  6877. if (root.scrollTo) {
  6878. root.scrollTo({
  6879. top: height,
  6880. behavior: 'smooth'
  6881. });
  6882. return;
  6883. }
  6884. root.scrollTop = height;
  6885. }
  6886. });
  6887. }
  6888. _getNewObserver() {
  6889. const options = {
  6890. root: this._rootElement,
  6891. threshold: this._config.threshold,
  6892. rootMargin: this._config.rootMargin
  6893. };
  6894. return new IntersectionObserver(entries => this._observerCallback(entries), options);
  6895. }
  6896. _observerCallback(entries) {
  6897. const targetElement = entry => this._targetLinks.get(`#${entry.target.id}`);
  6898. const activate = entry => {
  6899. this._previousScrollData.visibleEntryTop = entry.target.offsetTop;
  6900. this._process(targetElement(entry));
  6901. };
  6902. const parentScrollTop = (this._rootElement || document.documentElement).scrollTop;
  6903. const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop;
  6904. this._previousScrollData.parentScrollTop = parentScrollTop;
  6905. for (const entry of entries) {
  6906. if (!entry.isIntersecting) {
  6907. this._activeTarget = null;
  6908. this._clearActiveClass(targetElement(entry));
  6909. continue;
  6910. }
  6911. const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop;
  6912. if (userScrollsDown && entryIsLowerThanPrevious) {
  6913. activate(entry);
  6914. if (!parentScrollTop) {
  6915. return;
  6916. }
  6917. continue;
  6918. }
  6919. if (!userScrollsDown && !entryIsLowerThanPrevious) {
  6920. activate(entry);
  6921. }
  6922. }
  6923. }
  6924. _initializeTargetsAndObservables() {
  6925. this._targetLinks = new Map();
  6926. this._observableSections = new Map();
  6927. const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target);
  6928. for (const anchor of targetLinks) {
  6929. if (!anchor.hash || isDisabled(anchor)) {
  6930. continue;
  6931. }
  6932. const observableSection = SelectorEngine.findOne(anchor.hash, this._element);
  6933. if (isVisible(observableSection)) {
  6934. this._targetLinks.set(anchor.hash, anchor);
  6935. this._observableSections.set(anchor.hash, observableSection);
  6936. }
  6937. }
  6938. }
  6939. _process(target) {
  6940. if (this._activeTarget === target) {
  6941. return;
  6942. }
  6943. this._clearActiveClass(this._config.target);
  6944. this._activeTarget = target;
  6945. target.classList.add(CLASS_NAME_ACTIVE$1);
  6946. this._activateParents(target);
  6947. EventHandler.trigger(this._element, EVENT_ACTIVATE, {
  6948. relatedTarget: target
  6949. });
  6950. }
  6951. _activateParents(target) {
  6952. if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
  6953. SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, target.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE$1);
  6954. return;
  6955. }
  6956. for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) {
  6957. for (const item of SelectorEngine.prev(listGroup, SELECTOR_LINK_ITEMS)) {
  6958. item.classList.add(CLASS_NAME_ACTIVE$1);
  6959. }
  6960. }
  6961. }
  6962. _clearActiveClass(parent) {
  6963. parent.classList.remove(CLASS_NAME_ACTIVE$1);
  6964. const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE$1}`, parent);
  6965. for (const node of activeNodes) {
  6966. node.classList.remove(CLASS_NAME_ACTIVE$1);
  6967. }
  6968. }
  6969. static jQueryInterface(config) {
  6970. return this.each(function () {
  6971. const data = ScrollSpy.getOrCreateInstance(this, config);
  6972. if (typeof config !== 'string') {
  6973. return;
  6974. }
  6975. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  6976. throw new TypeError(`No method named "${config}"`);
  6977. }
  6978. data[config]();
  6979. });
  6980. }
  6981. }
  6982. EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => {
  6983. for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) {
  6984. ScrollSpy.getOrCreateInstance(spy);
  6985. }
  6986. });
  6987. defineJQueryPlugin(ScrollSpy);
  6988. const NAME$1 = 'tab';
  6989. const DATA_KEY$1 = 'bs.tab';
  6990. const EVENT_KEY$1 = `.${DATA_KEY$1}`;
  6991. const EVENT_HIDE$1 = `hide${EVENT_KEY$1}`;
  6992. const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$1}`;
  6993. const EVENT_SHOW$1 = `show${EVENT_KEY$1}`;
  6994. const EVENT_SHOWN$1 = `shown${EVENT_KEY$1}`;
  6995. const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}`;
  6996. const EVENT_KEYDOWN = `keydown${EVENT_KEY$1}`;
  6997. const EVENT_LOAD_DATA_API = `load${EVENT_KEY$1}`;
  6998. const ARROW_LEFT_KEY = 'ArrowLeft';
  6999. const ARROW_RIGHT_KEY = 'ArrowRight';
  7000. const ARROW_UP_KEY = 'ArrowUp';
  7001. const ARROW_DOWN_KEY = 'ArrowDown';
  7002. const CLASS_NAME_ACTIVE = 'active';
  7003. const CLASS_NAME_FADE$1 = 'fade';
  7004. const CLASS_NAME_SHOW$1 = 'show';
  7005. const CLASS_DROPDOWN = 'dropdown';
  7006. const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
  7007. const SELECTOR_DROPDOWN_MENU = '.dropdown-menu';
  7008. const NOT_SELECTOR_DROPDOWN_TOGGLE = ':not(.dropdown-toggle)';
  7009. const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]';
  7010. const SELECTOR_OUTER = '.nav-item, .list-group-item';
  7011. const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`;
  7012. const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]';
  7013. const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`;
  7014. 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"]`;
  7015. class Tab extends BaseComponent {
  7016. constructor(element) {
  7017. super(element);
  7018. this._parent = this._element.closest(SELECTOR_TAB_PANEL);
  7019. if (!this._parent) {
  7020. return;
  7021. }
  7022. this._setInitialAttributes(this._parent, this._getChildren());
  7023. EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
  7024. }
  7025. static get NAME() {
  7026. return NAME$1;
  7027. }
  7028. show() {
  7029. const innerElem = this._element;
  7030. if (this._elemIsActive(innerElem)) {
  7031. return;
  7032. }
  7033. const active = this._getActiveElem();
  7034. const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE$1, {
  7035. relatedTarget: innerElem
  7036. }) : null;
  7037. const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW$1, {
  7038. relatedTarget: active
  7039. });
  7040. if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) {
  7041. return;
  7042. }
  7043. this._deactivate(active, innerElem);
  7044. this._activate(innerElem, active);
  7045. }
  7046. _activate(element, relatedElem) {
  7047. if (!element) {
  7048. return;
  7049. }
  7050. element.classList.add(CLASS_NAME_ACTIVE);
  7051. this._activate(SelectorEngine.getElementFromSelector(element));
  7052. const complete = () => {
  7053. if (element.getAttribute('role') !== 'tab') {
  7054. element.classList.add(CLASS_NAME_SHOW$1);
  7055. return;
  7056. }
  7057. element.removeAttribute('tabindex');
  7058. element.setAttribute('aria-selected', true);
  7059. this._toggleDropDown(element, true);
  7060. EventHandler.trigger(element, EVENT_SHOWN$1, {
  7061. relatedTarget: relatedElem
  7062. });
  7063. };
  7064. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  7065. }
  7066. _deactivate(element, relatedElem) {
  7067. if (!element) {
  7068. return;
  7069. }
  7070. element.classList.remove(CLASS_NAME_ACTIVE);
  7071. element.blur();
  7072. this._deactivate(SelectorEngine.getElementFromSelector(element));
  7073. const complete = () => {
  7074. if (element.getAttribute('role') !== 'tab') {
  7075. element.classList.remove(CLASS_NAME_SHOW$1);
  7076. return;
  7077. }
  7078. element.setAttribute('aria-selected', false);
  7079. element.setAttribute('tabindex', '-1');
  7080. this._toggleDropDown(element, false);
  7081. EventHandler.trigger(element, EVENT_HIDDEN$1, {
  7082. relatedTarget: relatedElem
  7083. });
  7084. };
  7085. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  7086. }
  7087. _keydown(event) {
  7088. if (![ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key)) {
  7089. return;
  7090. }
  7091. event.stopPropagation();
  7092. event.preventDefault();
  7093. const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key);
  7094. const nextActiveElement = getNextActiveElement(this._getChildren().filter(element => !isDisabled(element)), event.target, isNext, true);
  7095. if (nextActiveElement) {
  7096. nextActiveElement.focus({
  7097. preventScroll: true
  7098. });
  7099. Tab.getOrCreateInstance(nextActiveElement).show();
  7100. }
  7101. }
  7102. _getChildren() {
  7103. return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent);
  7104. }
  7105. _getActiveElem() {
  7106. return this._getChildren().find(child => this._elemIsActive(child)) || null;
  7107. }
  7108. _setInitialAttributes(parent, children) {
  7109. this._setAttributeIfNotExists(parent, 'role', 'tablist');
  7110. for (const child of children) {
  7111. this._setInitialAttributesOnChild(child);
  7112. }
  7113. }
  7114. _setInitialAttributesOnChild(child) {
  7115. child = this._getInnerElement(child);
  7116. const isActive = this._elemIsActive(child);
  7117. const outerElem = this._getOuterElement(child);
  7118. child.setAttribute('aria-selected', isActive);
  7119. if (outerElem !== child) {
  7120. this._setAttributeIfNotExists(outerElem, 'role', 'presentation');
  7121. }
  7122. if (!isActive) {
  7123. child.setAttribute('tabindex', '-1');
  7124. }
  7125. this._setAttributeIfNotExists(child, 'role', 'tab');
  7126. this._setInitialAttributesOnTargetPanel(child);
  7127. }
  7128. _setInitialAttributesOnTargetPanel(child) {
  7129. const target = SelectorEngine.getElementFromSelector(child);
  7130. if (!target) {
  7131. return;
  7132. }
  7133. this._setAttributeIfNotExists(target, 'role', 'tabpanel');
  7134. if (child.id) {
  7135. this._setAttributeIfNotExists(target, 'aria-labelledby', `${child.id}`);
  7136. }
  7137. }
  7138. _toggleDropDown(element, open) {
  7139. const outerElem = this._getOuterElement(element);
  7140. if (!outerElem.classList.contains(CLASS_DROPDOWN)) {
  7141. return;
  7142. }
  7143. const toggle = (selector, className) => {
  7144. const element = SelectorEngine.findOne(selector, outerElem);
  7145. if (element) {
  7146. element.classList.toggle(className, open);
  7147. }
  7148. };
  7149. toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE);
  7150. toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW$1);
  7151. outerElem.setAttribute('aria-expanded', open);
  7152. }
  7153. _setAttributeIfNotExists(element, attribute, value) {
  7154. if (!element.hasAttribute(attribute)) {
  7155. element.setAttribute(attribute, value);
  7156. }
  7157. }
  7158. _elemIsActive(elem) {
  7159. return elem.classList.contains(CLASS_NAME_ACTIVE);
  7160. }
  7161. _getInnerElement(elem) {
  7162. return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem);
  7163. }
  7164. _getOuterElement(elem) {
  7165. return elem.closest(SELECTOR_OUTER) || elem;
  7166. }
  7167. static jQueryInterface(config) {
  7168. return this.each(function () {
  7169. const data = Tab.getOrCreateInstance(this);
  7170. if (typeof config !== 'string') {
  7171. return;
  7172. }
  7173. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  7174. throw new TypeError(`No method named "${config}"`);
  7175. }
  7176. data[config]();
  7177. });
  7178. }
  7179. }
  7180. EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
  7181. if (['A', 'AREA'].includes(this.tagName)) {
  7182. event.preventDefault();
  7183. }
  7184. if (isDisabled(this)) {
  7185. return;
  7186. }
  7187. Tab.getOrCreateInstance(this).show();
  7188. });
  7189. EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
  7190. for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) {
  7191. Tab.getOrCreateInstance(element);
  7192. }
  7193. });
  7194. defineJQueryPlugin(Tab);
  7195. const NAME = 'toast';
  7196. const DATA_KEY = 'bs.toast';
  7197. const EVENT_KEY = `.${DATA_KEY}`;
  7198. const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`;
  7199. const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`;
  7200. const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
  7201. const EVENT_FOCUSOUT = `focusout${EVENT_KEY}`;
  7202. const EVENT_HIDE = `hide${EVENT_KEY}`;
  7203. const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
  7204. const EVENT_SHOW = `show${EVENT_KEY}`;
  7205. const EVENT_SHOWN = `shown${EVENT_KEY}`;
  7206. const CLASS_NAME_FADE = 'fade';
  7207. const CLASS_NAME_HIDE = 'hide';
  7208. const CLASS_NAME_SHOW = 'show';
  7209. const CLASS_NAME_SHOWING = 'showing';
  7210. const DefaultType = {
  7211. animation: 'boolean',
  7212. autohide: 'boolean',
  7213. delay: 'number'
  7214. };
  7215. const Default = {
  7216. animation: true,
  7217. autohide: true,
  7218. delay: 5000
  7219. };
  7220. class Toast extends BaseComponent {
  7221. constructor(element, config) {
  7222. super(element, config);
  7223. this._timeout = null;
  7224. this._hasMouseInteraction = false;
  7225. this._hasKeyboardInteraction = false;
  7226. this._setListeners();
  7227. }
  7228. static get Default() {
  7229. return Default;
  7230. }
  7231. static get DefaultType() {
  7232. return DefaultType;
  7233. }
  7234. static get NAME() {
  7235. return NAME;
  7236. }
  7237. show() {
  7238. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW);
  7239. if (showEvent.defaultPrevented) {
  7240. return;
  7241. }
  7242. this._clearTimeout();
  7243. if (this._config.animation) {
  7244. this._element.classList.add(CLASS_NAME_FADE);
  7245. }
  7246. const complete = () => {
  7247. this._element.classList.remove(CLASS_NAME_SHOWING);
  7248. EventHandler.trigger(this._element, EVENT_SHOWN);
  7249. this._maybeScheduleHide();
  7250. };
  7251. this._element.classList.remove(CLASS_NAME_HIDE);
  7252. reflow(this._element);
  7253. this._element.classList.add(CLASS_NAME_SHOW, CLASS_NAME_SHOWING);
  7254. this._queueCallback(complete, this._element, this._config.animation);
  7255. }
  7256. hide() {
  7257. if (!this.isShown()) {
  7258. return;
  7259. }
  7260. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
  7261. if (hideEvent.defaultPrevented) {
  7262. return;
  7263. }
  7264. const complete = () => {
  7265. this._element.classList.add(CLASS_NAME_HIDE);
  7266. this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW);
  7267. EventHandler.trigger(this._element, EVENT_HIDDEN);
  7268. };
  7269. this._element.classList.add(CLASS_NAME_SHOWING);
  7270. this._queueCallback(complete, this._element, this._config.animation);
  7271. }
  7272. dispose() {
  7273. this._clearTimeout();
  7274. if (this.isShown()) {
  7275. this._element.classList.remove(CLASS_NAME_SHOW);
  7276. }
  7277. super.dispose();
  7278. }
  7279. isShown() {
  7280. return this._element.classList.contains(CLASS_NAME_SHOW);
  7281. }
  7282. _maybeScheduleHide() {
  7283. if (!this._config.autohide) {
  7284. return;
  7285. }
  7286. if (this._hasMouseInteraction || this._hasKeyboardInteraction) {
  7287. return;
  7288. }
  7289. this._timeout = setTimeout(() => {
  7290. this.hide();
  7291. }, this._config.delay);
  7292. }
  7293. _onInteraction(event, isInteracting) {
  7294. switch (event.type) {
  7295. case 'mouseover':
  7296. case 'mouseout':
  7297. {
  7298. this._hasMouseInteraction = isInteracting;
  7299. break;
  7300. }
  7301. case 'focusin':
  7302. case 'focusout':
  7303. {
  7304. this._hasKeyboardInteraction = isInteracting;
  7305. break;
  7306. }
  7307. }
  7308. if (isInteracting) {
  7309. this._clearTimeout();
  7310. return;
  7311. }
  7312. const nextElement = event.relatedTarget;
  7313. if (this._element === nextElement || this._element.contains(nextElement)) {
  7314. return;
  7315. }
  7316. this._maybeScheduleHide();
  7317. }
  7318. _setListeners() {
  7319. EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true));
  7320. EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false));
  7321. EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true));
  7322. EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false));
  7323. }
  7324. _clearTimeout() {
  7325. clearTimeout(this._timeout);
  7326. this._timeout = null;
  7327. }
  7328. static jQueryInterface(config) {
  7329. return this.each(function () {
  7330. const data = Toast.getOrCreateInstance(this, config);
  7331. if (typeof config === 'string') {
  7332. if (typeof data[config] === 'undefined') {
  7333. throw new TypeError(`No method named "${config}"`);
  7334. }
  7335. data[config](this);
  7336. }
  7337. });
  7338. }
  7339. }
  7340. enableDismissTrigger(Toast);
  7341. defineJQueryPlugin(Toast);
  7342. var dropdownTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="dropdown"]'));
  7343. dropdownTriggerList.map(function (dropdownTriggerEl) {
  7344. var options = {
  7345. boundary: dropdownTriggerEl.getAttribute('data-bs-boundary') === 'viewport' ? document.querySelector('.btn') : 'clippingParents'
  7346. };
  7347. return new Dropdown(dropdownTriggerEl, options);
  7348. });
  7349. var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
  7350. tooltipTriggerList.map(function (tooltipTriggerEl) {
  7351. var _ref, _tooltipTriggerEl$get;
  7352. var options = {
  7353. delay: {
  7354. show: 50,
  7355. hide: 50
  7356. },
  7357. html: (_ref = tooltipTriggerEl.getAttribute("data-bs-html") === "true") !== null && _ref !== void 0 ? _ref : false,
  7358. placement: (_tooltipTriggerEl$get = tooltipTriggerEl.getAttribute('data-bs-placement')) !== null && _tooltipTriggerEl$get !== void 0 ? _tooltipTriggerEl$get : 'auto'
  7359. };
  7360. return new Tooltip(tooltipTriggerEl, options);
  7361. });
  7362. var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'));
  7363. popoverTriggerList.map(function (popoverTriggerEl) {
  7364. var _ref, _popoverTriggerEl$get;
  7365. var options = {
  7366. delay: {
  7367. show: 50,
  7368. hide: 50
  7369. },
  7370. html: (_ref = popoverTriggerEl.getAttribute('data-bs-html') === "true") !== null && _ref !== void 0 ? _ref : false,
  7371. placement: (_popoverTriggerEl$get = popoverTriggerEl.getAttribute('data-bs-placement')) !== null && _popoverTriggerEl$get !== void 0 ? _popoverTriggerEl$get : 'auto'
  7372. };
  7373. return new Popover(popoverTriggerEl, options);
  7374. });
  7375. var switchesTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="switch-icon"]'));
  7376. switchesTriggerList.map(function (switchTriggerEl) {
  7377. switchTriggerEl.addEventListener('click', function (e) {
  7378. e.stopPropagation();
  7379. switchTriggerEl.classList.toggle('active');
  7380. });
  7381. });
  7382. var toastsTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="toast"]'));
  7383. toastsTriggerList.map(function (toastTriggerEl) {
  7384. return new Toast(toastTriggerEl);
  7385. });