tabler.js 289 KB

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