tabler.js 259 KB

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