tabler.js 273 KB

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