tabler.js 259 KB

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