tabler.esm.js 264 KB

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