mdc.drawer.js 292 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE
  7. */
  8. (function webpackUniversalModuleDefinition(root, factory) {
  9. if(typeof exports === 'object' && typeof module === 'object')
  10. module.exports = factory();
  11. else if(typeof define === 'function' && define.amd)
  12. define("@material/drawer", [], factory);
  13. else if(typeof exports === 'object')
  14. exports["drawer"] = factory();
  15. else
  16. root["mdc"] = root["mdc"] || {}, root["mdc"]["drawer"] = factory();
  17. })(this, function() {
  18. return /******/ (function(modules) { // webpackBootstrap
  19. /******/ // The module cache
  20. /******/ var installedModules = {};
  21. /******/
  22. /******/ // The require function
  23. /******/ function __webpack_require__(moduleId) {
  24. /******/
  25. /******/ // Check if module is in cache
  26. /******/ if(installedModules[moduleId]) {
  27. /******/ return installedModules[moduleId].exports;
  28. /******/ }
  29. /******/ // Create a new module (and put it into the cache)
  30. /******/ var module = installedModules[moduleId] = {
  31. /******/ i: moduleId,
  32. /******/ l: false,
  33. /******/ exports: {}
  34. /******/ };
  35. /******/
  36. /******/ // Execute the module function
  37. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  38. /******/
  39. /******/ // Flag the module as loaded
  40. /******/ module.l = true;
  41. /******/
  42. /******/ // Return the exports of the module
  43. /******/ return module.exports;
  44. /******/ }
  45. /******/
  46. /******/
  47. /******/ // expose the modules object (__webpack_modules__)
  48. /******/ __webpack_require__.m = modules;
  49. /******/
  50. /******/ // expose the module cache
  51. /******/ __webpack_require__.c = installedModules;
  52. /******/
  53. /******/ // define getter function for harmony exports
  54. /******/ __webpack_require__.d = function(exports, name, getter) {
  55. /******/ if(!__webpack_require__.o(exports, name)) {
  56. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  57. /******/ }
  58. /******/ };
  59. /******/
  60. /******/ // define __esModule on exports
  61. /******/ __webpack_require__.r = function(exports) {
  62. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  63. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  64. /******/ }
  65. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  66. /******/ };
  67. /******/
  68. /******/ // create a fake namespace object
  69. /******/ // mode & 1: value is a module id, require it
  70. /******/ // mode & 2: merge all properties of value into the ns
  71. /******/ // mode & 4: return value when already ns object
  72. /******/ // mode & 8|1: behave like require
  73. /******/ __webpack_require__.t = function(value, mode) {
  74. /******/ if(mode & 1) value = __webpack_require__(value);
  75. /******/ if(mode & 8) return value;
  76. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  77. /******/ var ns = Object.create(null);
  78. /******/ __webpack_require__.r(ns);
  79. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  80. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  81. /******/ return ns;
  82. /******/ };
  83. /******/
  84. /******/ // getDefaultExport function for compatibility with non-harmony modules
  85. /******/ __webpack_require__.n = function(module) {
  86. /******/ var getter = module && module.__esModule ?
  87. /******/ function getDefault() { return module['default']; } :
  88. /******/ function getModuleExports() { return module; };
  89. /******/ __webpack_require__.d(getter, 'a', getter);
  90. /******/ return getter;
  91. /******/ };
  92. /******/
  93. /******/ // Object.prototype.hasOwnProperty.call
  94. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  95. /******/
  96. /******/ // __webpack_public_path__
  97. /******/ __webpack_require__.p = "";
  98. /******/
  99. /******/
  100. /******/ // Load entry module and return exports
  101. /******/ return __webpack_require__(__webpack_require__.s = "./packages/mdc-drawer/index.ts");
  102. /******/ })
  103. /************************************************************************/
  104. /******/ ({
  105. /***/ "./node_modules/process/browser.js":
  106. /*!*****************************************!*\
  107. !*** ./node_modules/process/browser.js ***!
  108. \*****************************************/
  109. /*! no static exports found */
  110. /***/ (function(module, exports) {
  111. // shim for using process in browser
  112. var process = module.exports = {};
  113. // cached from whatever global is present so that test runners that stub it
  114. // don't break things. But we need to wrap it in a try catch in case it is
  115. // wrapped in strict mode code which doesn't define any globals. It's inside a
  116. // function because try/catches deoptimize in certain engines.
  117. var cachedSetTimeout;
  118. var cachedClearTimeout;
  119. function defaultSetTimout() {
  120. throw new Error('setTimeout has not been defined');
  121. }
  122. function defaultClearTimeout () {
  123. throw new Error('clearTimeout has not been defined');
  124. }
  125. (function () {
  126. try {
  127. if (typeof setTimeout === 'function') {
  128. cachedSetTimeout = setTimeout;
  129. } else {
  130. cachedSetTimeout = defaultSetTimout;
  131. }
  132. } catch (e) {
  133. cachedSetTimeout = defaultSetTimout;
  134. }
  135. try {
  136. if (typeof clearTimeout === 'function') {
  137. cachedClearTimeout = clearTimeout;
  138. } else {
  139. cachedClearTimeout = defaultClearTimeout;
  140. }
  141. } catch (e) {
  142. cachedClearTimeout = defaultClearTimeout;
  143. }
  144. } ())
  145. function runTimeout(fun) {
  146. if (cachedSetTimeout === setTimeout) {
  147. //normal enviroments in sane situations
  148. return setTimeout(fun, 0);
  149. }
  150. // if setTimeout wasn't available but was latter defined
  151. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  152. cachedSetTimeout = setTimeout;
  153. return setTimeout(fun, 0);
  154. }
  155. try {
  156. // when when somebody has screwed with setTimeout but no I.E. maddness
  157. return cachedSetTimeout(fun, 0);
  158. } catch(e){
  159. try {
  160. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  161. return cachedSetTimeout.call(null, fun, 0);
  162. } catch(e){
  163. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  164. return cachedSetTimeout.call(this, fun, 0);
  165. }
  166. }
  167. }
  168. function runClearTimeout(marker) {
  169. if (cachedClearTimeout === clearTimeout) {
  170. //normal enviroments in sane situations
  171. return clearTimeout(marker);
  172. }
  173. // if clearTimeout wasn't available but was latter defined
  174. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  175. cachedClearTimeout = clearTimeout;
  176. return clearTimeout(marker);
  177. }
  178. try {
  179. // when when somebody has screwed with setTimeout but no I.E. maddness
  180. return cachedClearTimeout(marker);
  181. } catch (e){
  182. try {
  183. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  184. return cachedClearTimeout.call(null, marker);
  185. } catch (e){
  186. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  187. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  188. return cachedClearTimeout.call(this, marker);
  189. }
  190. }
  191. }
  192. var queue = [];
  193. var draining = false;
  194. var currentQueue;
  195. var queueIndex = -1;
  196. function cleanUpNextTick() {
  197. if (!draining || !currentQueue) {
  198. return;
  199. }
  200. draining = false;
  201. if (currentQueue.length) {
  202. queue = currentQueue.concat(queue);
  203. } else {
  204. queueIndex = -1;
  205. }
  206. if (queue.length) {
  207. drainQueue();
  208. }
  209. }
  210. function drainQueue() {
  211. if (draining) {
  212. return;
  213. }
  214. var timeout = runTimeout(cleanUpNextTick);
  215. draining = true;
  216. var len = queue.length;
  217. while(len) {
  218. currentQueue = queue;
  219. queue = [];
  220. while (++queueIndex < len) {
  221. if (currentQueue) {
  222. currentQueue[queueIndex].run();
  223. }
  224. }
  225. queueIndex = -1;
  226. len = queue.length;
  227. }
  228. currentQueue = null;
  229. draining = false;
  230. runClearTimeout(timeout);
  231. }
  232. process.nextTick = function (fun) {
  233. var args = new Array(arguments.length - 1);
  234. if (arguments.length > 1) {
  235. for (var i = 1; i < arguments.length; i++) {
  236. args[i - 1] = arguments[i];
  237. }
  238. }
  239. queue.push(new Item(fun, args));
  240. if (queue.length === 1 && !draining) {
  241. runTimeout(drainQueue);
  242. }
  243. };
  244. // v8 likes predictible objects
  245. function Item(fun, array) {
  246. this.fun = fun;
  247. this.array = array;
  248. }
  249. Item.prototype.run = function () {
  250. this.fun.apply(null, this.array);
  251. };
  252. process.title = 'browser';
  253. process.browser = true;
  254. process.env = {};
  255. process.argv = [];
  256. process.version = ''; // empty string to avoid regexp issues
  257. process.versions = {};
  258. function noop() {}
  259. process.on = noop;
  260. process.addListener = noop;
  261. process.once = noop;
  262. process.off = noop;
  263. process.removeListener = noop;
  264. process.removeAllListeners = noop;
  265. process.emit = noop;
  266. process.prependListener = noop;
  267. process.prependOnceListener = noop;
  268. process.listeners = function (name) { return [] }
  269. process.binding = function (name) {
  270. throw new Error('process.binding is not supported');
  271. };
  272. process.cwd = function () { return '/' };
  273. process.chdir = function (dir) {
  274. throw new Error('process.chdir is not supported');
  275. };
  276. process.umask = function() { return 0; };
  277. /***/ }),
  278. /***/ "./node_modules/safevalues/builders/attribute_builders.js":
  279. /*!****************************************************************!*\
  280. !*** ./node_modules/safevalues/builders/attribute_builders.js ***!
  281. \****************************************************************/
  282. /*! no static exports found */
  283. /***/ (function(module, exports, __webpack_require__) {
  284. "use strict";
  285. /**
  286. * @license
  287. * SPDX-License-Identifier: Apache-2.0
  288. */
  289. Object.defineProperty(exports, "__esModule", { value: true });
  290. exports.safeAttrPrefix = void 0;
  291. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  292. var attribute_impl_1 = __webpack_require__(/*! ../internals/attribute_impl */ "./node_modules/safevalues/internals/attribute_impl.js");
  293. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  294. var sensitive_attributes_1 = __webpack_require__(/*! ./sensitive_attributes */ "./node_modules/safevalues/builders/sensitive_attributes.js");
  295. /**
  296. * Creates a SafeAttributePrefix object from a template literal with no
  297. * interpolations for attributes that share a common prefix guaranteed to be not
  298. * security sensitive.
  299. *
  300. * The template literal is a prefix that makes it obvious this attribute is not
  301. * security sensitive. If it doesn't, this function will throw.
  302. */
  303. function safeAttrPrefix(templ) {
  304. if (true) {
  305. (0, string_literal_1.assertIsTemplateObject)(templ, true, 'safeAttr is a template literal tag function ' +
  306. 'and should be called using the tagged template syntax. ' +
  307. 'For example, safeAttr`foo`;');
  308. }
  309. var attrPrefix = templ[0].toLowerCase();
  310. if (true) {
  311. if (attrPrefix.indexOf('on') === 0 || 'on'.indexOf(attrPrefix) === 0) {
  312. throw new Error("Prefix '".concat(templ[0], "' does not guarantee the attribute ") +
  313. "to be safe as it is also a prefix for event handler attributes" +
  314. "Please use 'addEventListener' to set event handlers.");
  315. }
  316. sensitive_attributes_1.SECURITY_SENSITIVE_ATTRIBUTES.forEach(function (sensitiveAttr) {
  317. if (sensitiveAttr.indexOf(attrPrefix) === 0) {
  318. throw new Error("Prefix '".concat(templ[0], "' does not guarantee the attribute ") +
  319. "to be safe as it is also a prefix for " +
  320. "the security sensitive attribute '".concat(sensitiveAttr, "'. ") +
  321. "Please use native or safe DOM APIs to set the attribute.");
  322. }
  323. });
  324. }
  325. return (0, attribute_impl_1.createAttributePrefix)(attrPrefix);
  326. }
  327. exports.safeAttrPrefix = safeAttrPrefix;
  328. /***/ }),
  329. /***/ "./node_modules/safevalues/builders/html_builders.js":
  330. /*!***********************************************************!*\
  331. !*** ./node_modules/safevalues/builders/html_builders.js ***!
  332. \***********************************************************/
  333. /*! no static exports found */
  334. /***/ (function(module, exports, __webpack_require__) {
  335. "use strict";
  336. /**
  337. * @license
  338. * SPDX-License-Identifier: Apache-2.0
  339. */
  340. Object.defineProperty(exports, "__esModule", { value: true });
  341. exports.concatHtmls = exports.createScriptSrc = exports.createScript = exports.htmlEscape = void 0;
  342. var html_impl_1 = __webpack_require__(/*! ../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  343. var resource_url_impl_1 = __webpack_require__(/*! ../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  344. var script_impl_1 = __webpack_require__(/*! ../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  345. /**
  346. * Returns HTML-escaped text as a `SafeHtml` object.
  347. *
  348. * Available options:
  349. * - `preserveSpaces` turns every second consecutive space character into its
  350. * HTML entity representation (`&#160;`).
  351. * - `preserveNewlines` turns newline characters into breaks (`<br>`).
  352. * - `preserveTabs` wraps tab characters in a span with style=white-space:pre.
  353. */
  354. function htmlEscape(text, options) {
  355. if (options === void 0) { options = {}; }
  356. var htmlEscapedString = htmlEscapeToString(text);
  357. if (options.preserveSpaces) {
  358. // Do this first to ensure we preserve spaces after newlines and tabs.
  359. htmlEscapedString =
  360. htmlEscapedString.replace(/(^|[\r\n\t ]) /g, '$1&#160;');
  361. }
  362. if (options.preserveNewlines) {
  363. htmlEscapedString = htmlEscapedString.replace(/(\r\n|\n|\r)/g, '<br>');
  364. }
  365. if (options.preserveTabs) {
  366. htmlEscapedString = htmlEscapedString.replace(/(\t+)/g, '<span style="white-space:pre">$1</span>');
  367. }
  368. return (0, html_impl_1.createHtml)(htmlEscapedString);
  369. }
  370. exports.htmlEscape = htmlEscape;
  371. /**
  372. * Creates a `SafeHtml` representing a script tag with inline script content.
  373. */
  374. function createScript(script, options) {
  375. if (options === void 0) { options = {}; }
  376. var unwrappedScript = (0, script_impl_1.unwrapScript)(script).toString();
  377. var stringTag = "<script";
  378. if (options.id) {
  379. stringTag += " id=\"".concat(htmlEscapeToString(options.id), "\"");
  380. }
  381. if (options.nonce) {
  382. stringTag += " nonce=\"".concat(htmlEscapeToString(options.nonce), "\"");
  383. }
  384. if (options.type) {
  385. stringTag += " type=\"".concat(htmlEscapeToString(options.type), "\"");
  386. }
  387. stringTag += ">".concat(unwrappedScript, "</script>");
  388. return (0, html_impl_1.createHtml)(stringTag);
  389. }
  390. exports.createScript = createScript;
  391. /**
  392. * Creates a `SafeHtml` representing a script tag with the src attribute.
  393. * This also supports CSP nonces and async loading.
  394. */
  395. function createScriptSrc(src, async, nonce) {
  396. var unwrappedSrc = (0, resource_url_impl_1.unwrapResourceUrl)(src).toString();
  397. var stringTag = "<script src=\"".concat(htmlEscapeToString(unwrappedSrc), "\"");
  398. if (async) {
  399. stringTag += ' async';
  400. }
  401. if (nonce) {
  402. stringTag += " nonce=\"".concat(htmlEscapeToString(nonce), "\"");
  403. }
  404. stringTag += '>\x3c/script>';
  405. return (0, html_impl_1.createHtml)(stringTag);
  406. }
  407. exports.createScriptSrc = createScriptSrc;
  408. /**
  409. * HTML-escapes the given text (`&`, `<`, `>`, `"` and `'`).
  410. */
  411. function htmlEscapeToString(text) {
  412. var escaped = text.replace(/&/g, '&amp;')
  413. .replace(/</g, '&lt;')
  414. .replace(/>/g, '&gt;')
  415. .replace(/"/g, '&quot;')
  416. .replace(/'/g, '&apos;');
  417. return escaped;
  418. }
  419. /** Creates a `SafeHtml` value by concatenating multiple `SafeHtml`s. */
  420. function concatHtmls(htmls) {
  421. return (0, html_impl_1.createHtml)(htmls.map(html_impl_1.unwrapHtml).join(''));
  422. }
  423. exports.concatHtmls = concatHtmls;
  424. /***/ }),
  425. /***/ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js":
  426. /*!***************************************************************************!*\
  427. !*** ./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js ***!
  428. \***************************************************************************/
  429. /*! no static exports found */
  430. /***/ (function(module, exports, __webpack_require__) {
  431. "use strict";
  432. /**
  433. * @license
  434. * SPDX-License-Identifier: Apache-2.0
  435. */
  436. var __values = (this && this.__values) || function(o) {
  437. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  438. if (m) return m.call(o);
  439. if (o && typeof o.length === "number") return {
  440. next: function () {
  441. if (o && i >= o.length) o = void 0;
  442. return { value: o && o[i++], done: !o };
  443. }
  444. };
  445. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  446. };
  447. var __read = (this && this.__read) || function (o, n) {
  448. var m = typeof Symbol === "function" && o[Symbol.iterator];
  449. if (!m) return o;
  450. var i = m.call(o), r, ar = [], e;
  451. try {
  452. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  453. }
  454. catch (error) { e = { error: error }; }
  455. finally {
  456. try {
  457. if (r && !r.done && (m = i["return"])) m.call(i);
  458. }
  459. finally { if (e) throw e.error; }
  460. }
  461. return ar;
  462. };
  463. Object.defineProperty(exports, "__esModule", { value: true });
  464. exports.sanitizeHtmlToFragment = exports.sanitizeHtmlAssertUnchanged = exports.sanitizeHtml = exports.HtmlSanitizerImpl = void 0;
  465. __webpack_require__(/*! ../../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  466. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  467. /* g3_import_pure from '../../internals/pure' */
  468. var secrets_1 = __webpack_require__(/*! ../../internals/secrets */ "./node_modules/safevalues/internals/secrets.js");
  469. var url_sanitizer_1 = __webpack_require__(/*! ../url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  470. var inert_fragment_1 = __webpack_require__(/*! ./inert_fragment */ "./node_modules/safevalues/builders/html_sanitizer/inert_fragment.js");
  471. var no_clobber_1 = __webpack_require__(/*! ./no_clobber */ "./node_modules/safevalues/builders/html_sanitizer/no_clobber.js");
  472. var default_sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/default_sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js");
  473. var sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js");
  474. /** Implementation for `HtmlSanitizer` */
  475. var HtmlSanitizerImpl = /** @class */ (function () {
  476. function HtmlSanitizerImpl(sanitizerTable, token) {
  477. this.sanitizerTable = sanitizerTable;
  478. this.changes = [];
  479. (0, secrets_1.ensureTokenIsValid)(token);
  480. }
  481. HtmlSanitizerImpl.prototype.sanitizeAssertUnchanged = function (html) {
  482. this.changes = [];
  483. var sanitizedHtml = this.sanitize(html);
  484. if (this.changes.length !== 0) {
  485. var message = '';
  486. if (true) {
  487. message =
  488. "Unexpected change to HTML value as a result of sanitization. " +
  489. "Input: \"".concat(html, "\", sanitized output: \"").concat(sanitizedHtml, "\"\n") +
  490. "List of changes:".concat(this.changes.join('\n'));
  491. }
  492. throw new Error(message);
  493. }
  494. return sanitizedHtml;
  495. };
  496. HtmlSanitizerImpl.prototype.sanitize = function (html) {
  497. var fakeRoot = document.createElement('span');
  498. fakeRoot.appendChild(this.sanitizeToFragment(html));
  499. // XML serialization is preferred over HTML serialization as it is
  500. // stricter and makes sure all attributes are properly escaped, avoiding
  501. // cases where the tree might mutate when parsed again later due to the
  502. // complexities of the HTML parsing algorithm
  503. var serializedNewTree = new XMLSerializer().serializeToString(fakeRoot);
  504. // We remove the outer most element as this is the span node created as
  505. // the root for the sanitized tree and contains a spurious xmlns attribute
  506. // from the XML serialization step.
  507. serializedNewTree = serializedNewTree.slice(serializedNewTree.indexOf('>') + 1, serializedNewTree.lastIndexOf('</'));
  508. return (0, html_impl_1.createHtml)(serializedNewTree);
  509. };
  510. HtmlSanitizerImpl.prototype.sanitizeToFragment = function (html) {
  511. var _this = this;
  512. var dirtyFragment = (0, inert_fragment_1.createInertFragment)(html);
  513. var treeWalker = document.createTreeWalker(dirtyFragment, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,
  514. // IE10 and IE11 won't accept a proper `NodeFilter` interface, and
  515. // expect the filtering function to be passed directly. It seems that
  516. // other browsers also do not mind getting the function directly. see
  517. // https://stackoverflow.com/q/38245898
  518. (function (n) { return _this.nodeFilter(n); }),
  519. // @ts-ignore: error TS2554: Expected 1-3 arguments, but got 4.
  520. false);
  521. // `nextNode` is called so we skip the root `DocumentFragment`.
  522. var currentNode = treeWalker.nextNode();
  523. // We create a root element to attach all the children of the body to. We
  524. // use div as it as a semantic-free, generic container and does not
  525. // represent anything. This is removed when we serialize the tree back
  526. // into a string.
  527. var sanitizedFragment = document.createDocumentFragment();
  528. var sanitizedParent = sanitizedFragment;
  529. while (currentNode !== null) {
  530. var sanitizedNode = void 0;
  531. if ((0, no_clobber_1.isText)(currentNode)) {
  532. sanitizedNode = this.sanitizeTextNode(currentNode);
  533. }
  534. else if ((0, no_clobber_1.isElement)(currentNode)) {
  535. sanitizedNode = this.sanitizeElementNode(currentNode);
  536. }
  537. else {
  538. throw new Error('Node is not of type text or element');
  539. }
  540. sanitizedParent.appendChild(sanitizedNode);
  541. // Advance iterator while keeping track of the sanitized parent for the
  542. // current node
  543. currentNode = treeWalker.firstChild();
  544. if (currentNode) {
  545. sanitizedParent = sanitizedNode;
  546. }
  547. else {
  548. while (!(currentNode = treeWalker.nextSibling())) {
  549. if (!(currentNode = treeWalker.parentNode())) {
  550. break;
  551. }
  552. sanitizedParent = sanitizedParent.parentNode;
  553. }
  554. }
  555. }
  556. return sanitizedFragment;
  557. };
  558. HtmlSanitizerImpl.prototype.sanitizeTextNode = function (textNode) {
  559. return document.createTextNode(textNode.data);
  560. };
  561. HtmlSanitizerImpl.prototype.sanitizeElementNode = function (elementNode) {
  562. var e_1, _a;
  563. var elementName = (0, no_clobber_1.getNodeName)(elementNode);
  564. var newNode = document.createElement(elementName);
  565. var dirtyAttributes = elementNode.attributes;
  566. try {
  567. for (var dirtyAttributes_1 = __values(dirtyAttributes), dirtyAttributes_1_1 = dirtyAttributes_1.next(); !dirtyAttributes_1_1.done; dirtyAttributes_1_1 = dirtyAttributes_1.next()) {
  568. var _b = dirtyAttributes_1_1.value, name_1 = _b.name, value = _b.value;
  569. var policy = this.sanitizerTable.getAttributePolicy(name_1, elementName);
  570. if (!this.satisfiesAllConditions(policy.conditions, dirtyAttributes)) {
  571. this.recordChange("Not all conditions satisfied for attribute: ".concat(name_1, "."));
  572. continue;
  573. }
  574. switch (policy.policyAction) {
  575. case sanitizer_table_1.AttributePolicyAction.KEEP:
  576. newNode.setAttribute(name_1, value);
  577. break;
  578. case sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL:
  579. var sanitizedAttrUrl = (0, url_sanitizer_1.restrictivelySanitizeUrl)(value);
  580. if (sanitizedAttrUrl !== value) {
  581. this.recordChange("Url in attribute ".concat(name_1, " was modified during sanitization. Original url:\"").concat(value, "\" was sanitized to: \"").concat(sanitizedAttrUrl, "\""));
  582. }
  583. newNode.setAttribute(name_1, sanitizedAttrUrl);
  584. break;
  585. case sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE:
  586. // We don't consider changing the case of an attribute value to be a
  587. // semantic change
  588. newNode.setAttribute(name_1, value.toLowerCase());
  589. break;
  590. case sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_STYLE:
  591. newNode.setAttribute(name_1, value);
  592. break;
  593. case sanitizer_table_1.AttributePolicyAction.DROP:
  594. this.recordChange("Attribute: ".concat(name_1, " was dropped"));
  595. break;
  596. default:
  597. checkExhaustive(policy.policyAction, 'Unhandled AttributePolicyAction case');
  598. }
  599. }
  600. }
  601. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  602. finally {
  603. try {
  604. if (dirtyAttributes_1_1 && !dirtyAttributes_1_1.done && (_a = dirtyAttributes_1.return)) _a.call(dirtyAttributes_1);
  605. }
  606. finally { if (e_1) throw e_1.error; }
  607. }
  608. return newNode;
  609. };
  610. HtmlSanitizerImpl.prototype.nodeFilter = function (node) {
  611. if ((0, no_clobber_1.isText)(node)) {
  612. return NodeFilter.FILTER_ACCEPT;
  613. }
  614. else if (!(0, no_clobber_1.isElement)(node)) {
  615. // Getting a node that is neither an `Element` or a `Text` node. This is
  616. // likely due to something that is not supposed to be an element in user
  617. // code but recognized as such by the TreeWalker (e.g. a polyfill for
  618. // other kind of nodes). Since we can't recognize it as an element, we
  619. // drop the node, but we don't record it as a meaningful change.
  620. return NodeFilter.FILTER_REJECT;
  621. }
  622. var nodeName = (0, no_clobber_1.getNodeName)(node);
  623. if (nodeName === null) {
  624. this.recordChange("Node name was null for node: ".concat(node));
  625. return NodeFilter.FILTER_REJECT;
  626. }
  627. if (this.sanitizerTable.isAllowedElement(nodeName)) {
  628. return NodeFilter.FILTER_ACCEPT;
  629. }
  630. this.recordChange("Element: ".concat(nodeName, " was dropped"));
  631. return NodeFilter.FILTER_REJECT;
  632. };
  633. HtmlSanitizerImpl.prototype.recordChange = function (errorMessage) {
  634. if (true) {
  635. this.changes.push(errorMessage);
  636. }
  637. else {}
  638. };
  639. HtmlSanitizerImpl.prototype.satisfiesAllConditions = function (conditions, attrs) {
  640. var e_2, _a;
  641. var _b;
  642. if (!conditions) {
  643. return true;
  644. }
  645. try {
  646. for (var conditions_1 = __values(conditions), conditions_1_1 = conditions_1.next(); !conditions_1_1.done; conditions_1_1 = conditions_1.next()) {
  647. var _c = __read(conditions_1_1.value, 2), attrName = _c[0], expectedValues = _c[1];
  648. var value = (_b = attrs.getNamedItem(attrName)) === null || _b === void 0 ? void 0 : _b.value;
  649. if (value && !expectedValues.has(value)) {
  650. return false;
  651. }
  652. }
  653. }
  654. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  655. finally {
  656. try {
  657. if (conditions_1_1 && !conditions_1_1.done && (_a = conditions_1.return)) _a.call(conditions_1);
  658. }
  659. finally { if (e_2) throw e_2.error; }
  660. }
  661. return true;
  662. };
  663. return HtmlSanitizerImpl;
  664. }());
  665. exports.HtmlSanitizerImpl = HtmlSanitizerImpl;
  666. var defaultHtmlSanitizer =
  667. /* #__PURE__ */ (function () { return new HtmlSanitizerImpl(default_sanitizer_table_1.defaultSanitizerTable, secrets_1.secretToken); })();
  668. /** Sanitizes untrusted html using the default sanitizer configuration. */
  669. function sanitizeHtml(html) {
  670. return defaultHtmlSanitizer.sanitize(html);
  671. }
  672. exports.sanitizeHtml = sanitizeHtml;
  673. /**
  674. * Sanitizes untrusted html using the default sanitizer configuration. Throws
  675. * an error if the html was changed.
  676. */
  677. function sanitizeHtmlAssertUnchanged(html) {
  678. return defaultHtmlSanitizer.sanitizeAssertUnchanged(html);
  679. }
  680. exports.sanitizeHtmlAssertUnchanged = sanitizeHtmlAssertUnchanged;
  681. /**
  682. * Sanitizes untrusted html using the default sanitizer configuration. Throws
  683. * an error if the html was changed.
  684. */
  685. function sanitizeHtmlToFragment(html) {
  686. return defaultHtmlSanitizer.sanitizeToFragment(html);
  687. }
  688. exports.sanitizeHtmlToFragment = sanitizeHtmlToFragment;
  689. function checkExhaustive(value, msg) {
  690. if (msg === void 0) { msg = "unexpected value ".concat(value, "!"); }
  691. throw new Error(msg);
  692. }
  693. /***/ }),
  694. /***/ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer_builder.js":
  695. /*!***********************************************************************************!*\
  696. !*** ./node_modules/safevalues/builders/html_sanitizer/html_sanitizer_builder.js ***!
  697. \***********************************************************************************/
  698. /*! no static exports found */
  699. /***/ (function(module, exports, __webpack_require__) {
  700. "use strict";
  701. /**
  702. * @license
  703. * SPDX-License-Identifier: Apache-2.0
  704. */
  705. var __values = (this && this.__values) || function(o) {
  706. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  707. if (m) return m.call(o);
  708. if (o && typeof o.length === "number") return {
  709. next: function () {
  710. if (o && i >= o.length) o = void 0;
  711. return { value: o && o[i++], done: !o };
  712. }
  713. };
  714. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  715. };
  716. var __read = (this && this.__read) || function (o, n) {
  717. var m = typeof Symbol === "function" && o[Symbol.iterator];
  718. if (!m) return o;
  719. var i = m.call(o), r, ar = [], e;
  720. try {
  721. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  722. }
  723. catch (error) { e = { error: error }; }
  724. finally {
  725. try {
  726. if (r && !r.done && (m = i["return"])) m.call(i);
  727. }
  728. finally { if (e) throw e.error; }
  729. }
  730. return ar;
  731. };
  732. Object.defineProperty(exports, "__esModule", { value: true });
  733. exports.HtmlSanitizerBuilder = void 0;
  734. var secrets_1 = __webpack_require__(/*! ../../internals/secrets */ "./node_modules/safevalues/internals/secrets.js");
  735. var html_sanitizer_1 = __webpack_require__(/*! ./html_sanitizer */ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js");
  736. var default_sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/default_sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js");
  737. var sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js");
  738. /** This class allows modifications to the default sanitizer configuration. */
  739. var HtmlSanitizerBuilder = /** @class */ (function () {
  740. function HtmlSanitizerBuilder() {
  741. // To denote if the builder has called build() and therefore should make no
  742. // further changes to the sanitizer table.
  743. this.calledBuild = false;
  744. this.sanitizerTable = default_sanitizer_table_1.defaultSanitizerTable;
  745. }
  746. /** Builder option to restrict allowed elements to a smaller subset. */
  747. HtmlSanitizerBuilder.prototype.onlyAllowElements = function (elementSet) {
  748. var e_1, _a;
  749. var allowedElements = new Set();
  750. var allowedElementPolicies = new Map();
  751. try {
  752. for (var elementSet_1 = __values(elementSet), elementSet_1_1 = elementSet_1.next(); !elementSet_1_1.done; elementSet_1_1 = elementSet_1.next()) {
  753. var element = elementSet_1_1.value;
  754. element = element.toUpperCase();
  755. if (!this.sanitizerTable.isAllowedElement(element)) {
  756. throw new Error("Element: ".concat(element, ", is not allowed by html5_contract.textpb"));
  757. }
  758. var elementPolicy = this.sanitizerTable.elementPolicies.get(element);
  759. if (elementPolicy !== undefined) {
  760. allowedElementPolicies.set(element, elementPolicy);
  761. }
  762. else {
  763. allowedElements.add(element);
  764. }
  765. }
  766. }
  767. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  768. finally {
  769. try {
  770. if (elementSet_1_1 && !elementSet_1_1.done && (_a = elementSet_1.return)) _a.call(elementSet_1);
  771. }
  772. finally { if (e_1) throw e_1.error; }
  773. }
  774. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(allowedElements, allowedElementPolicies, this.sanitizerTable.allowedGlobalAttributes, this.sanitizerTable.globalAttributePolicies);
  775. return this;
  776. };
  777. /**
  778. * Builder option to restrict allowed attributes to a smaller subset.
  779. *
  780. * If the attribute isn't currently allowed then it won't be added.
  781. */
  782. HtmlSanitizerBuilder.prototype.onlyAllowAttributes = function (attributeSet) {
  783. var e_2, _a, e_3, _b, e_4, _c;
  784. var allowedGlobalAttributes = new Set();
  785. var globalAttributePolicies = new Map();
  786. var elementPolicies = new Map();
  787. try {
  788. for (var attributeSet_1 = __values(attributeSet), attributeSet_1_1 = attributeSet_1.next(); !attributeSet_1_1.done; attributeSet_1_1 = attributeSet_1.next()) {
  789. var attribute = attributeSet_1_1.value;
  790. if (this.sanitizerTable.allowedGlobalAttributes.has(attribute)) {
  791. allowedGlobalAttributes.add(attribute);
  792. }
  793. if (this.sanitizerTable.globalAttributePolicies.has(attribute)) {
  794. globalAttributePolicies.set(attribute, this.sanitizerTable.globalAttributePolicies.get(attribute));
  795. }
  796. }
  797. }
  798. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  799. finally {
  800. try {
  801. if (attributeSet_1_1 && !attributeSet_1_1.done && (_a = attributeSet_1.return)) _a.call(attributeSet_1);
  802. }
  803. finally { if (e_2) throw e_2.error; }
  804. }
  805. try {
  806. for (var _d = __values(this.sanitizerTable
  807. .elementPolicies.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
  808. var _f = __read(_e.value, 2), elementName = _f[0], originalElementPolicy = _f[1];
  809. var newElementPolicy = new Map();
  810. try {
  811. for (var _g = (e_4 = void 0, __values(originalElementPolicy
  812. .entries())), _h = _g.next(); !_h.done; _h = _g.next()) {
  813. var _j = __read(_h.value, 2), attribute = _j[0], attributePolicy = _j[1];
  814. if (attributeSet.has(attribute)) {
  815. newElementPolicy.set(attribute, attributePolicy);
  816. }
  817. }
  818. }
  819. catch (e_4_1) { e_4 = { error: e_4_1 }; }
  820. finally {
  821. try {
  822. if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
  823. }
  824. finally { if (e_4) throw e_4.error; }
  825. }
  826. elementPolicies.set(elementName, newElementPolicy);
  827. }
  828. }
  829. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  830. finally {
  831. try {
  832. if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
  833. }
  834. finally { if (e_3) throw e_3.error; }
  835. }
  836. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, elementPolicies, allowedGlobalAttributes, globalAttributePolicies);
  837. return this;
  838. };
  839. /**
  840. * Allows the set of data attributes passed.
  841. *
  842. * These values must be prefixed with "data-"
  843. *
  844. * If called with onlyAllowElements or onlyAllowAttributes, those methods must
  845. * be called first.
  846. */
  847. HtmlSanitizerBuilder.prototype.allowDataAttributes = function (attributes) {
  848. var e_5, _a;
  849. var allowedGlobalAttributes = new Set(this.sanitizerTable.allowedGlobalAttributes);
  850. try {
  851. for (var attributes_1 = __values(attributes), attributes_1_1 = attributes_1.next(); !attributes_1_1.done; attributes_1_1 = attributes_1.next()) {
  852. var attribute = attributes_1_1.value;
  853. if (attribute.indexOf('data-') !== 0) {
  854. throw new Error("data attribute: ".concat(attribute, " does not begin with the prefix \"data-\""));
  855. }
  856. allowedGlobalAttributes.add(attribute);
  857. }
  858. }
  859. catch (e_5_1) { e_5 = { error: e_5_1 }; }
  860. finally {
  861. try {
  862. if (attributes_1_1 && !attributes_1_1.done && (_a = attributes_1.return)) _a.call(attributes_1);
  863. }
  864. finally { if (e_5) throw e_5.error; }
  865. }
  866. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, allowedGlobalAttributes, this.sanitizerTable.globalAttributePolicies);
  867. return this;
  868. };
  869. /**
  870. * Preserves style attributes. Note that the sanitizer won't parse and
  871. * sanitize the values but keep them as they are. In particular this means
  872. * that the code will be able to call functions that could do undesirable
  873. * things (e.g. `url` to trigger a network request), as well as any custom
  874. * properties or functions defined by the application.
  875. */
  876. HtmlSanitizerBuilder.prototype.allowStyleAttributes = function () {
  877. var globalAttributePolicies = new Map(this.sanitizerTable.globalAttributePolicies);
  878. globalAttributePolicies.set('style', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_STYLE });
  879. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, this.sanitizerTable.allowedGlobalAttributes, globalAttributePolicies);
  880. return this;
  881. };
  882. /**
  883. * Preserves the class attribute on all elements. This means contents can
  884. * adopt CSS styles from other page elements and possibly mask themselves as
  885. * legitimate UI elements, which can lead to phishing.
  886. */
  887. HtmlSanitizerBuilder.prototype.allowClassAttributes = function () {
  888. var globalAttributePolicies = new Map(this.sanitizerTable.globalAttributePolicies);
  889. globalAttributePolicies.set('class', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP });
  890. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, this.sanitizerTable.allowedGlobalAttributes, globalAttributePolicies);
  891. return this;
  892. };
  893. /**
  894. * Preserves id attributes. This carries moderate risk as it allows an
  895. * element to override other elements with the same ID.
  896. */
  897. HtmlSanitizerBuilder.prototype.allowIdAttributes = function () {
  898. var globalAttributePolicies = new Map(this.sanitizerTable.globalAttributePolicies);
  899. globalAttributePolicies.set('id', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP });
  900. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, this.sanitizerTable.allowedGlobalAttributes, globalAttributePolicies);
  901. return this;
  902. };
  903. HtmlSanitizerBuilder.prototype.build = function () {
  904. if (this.calledBuild) {
  905. throw new Error('this sanitizer has already called build');
  906. }
  907. this.calledBuild = true;
  908. return new html_sanitizer_1.HtmlSanitizerImpl(this.sanitizerTable, secrets_1.secretToken);
  909. };
  910. return HtmlSanitizerBuilder;
  911. }());
  912. exports.HtmlSanitizerBuilder = HtmlSanitizerBuilder;
  913. /***/ }),
  914. /***/ "./node_modules/safevalues/builders/html_sanitizer/inert_fragment.js":
  915. /*!***************************************************************************!*\
  916. !*** ./node_modules/safevalues/builders/html_sanitizer/inert_fragment.js ***!
  917. \***************************************************************************/
  918. /*! no static exports found */
  919. /***/ (function(module, exports, __webpack_require__) {
  920. "use strict";
  921. /**
  922. * @license
  923. * SPDX-License-Identifier: Apache-2.0
  924. */
  925. Object.defineProperty(exports, "__esModule", { value: true });
  926. exports.createInertFragment = void 0;
  927. var element_1 = __webpack_require__(/*! ../../dom/elements/element */ "./node_modules/safevalues/dom/elements/element.js");
  928. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  929. /**
  930. * Returns a fragment that contains the parsed HTML for `dirtyHtml` without
  931. * executing any of the potential payload.
  932. */
  933. function createInertFragment(dirtyHtml) {
  934. var template = document.createElement('template');
  935. // This call is only used to create an inert tree for the sanitizer to
  936. // further process and is never returned directly to the caller. We can't use
  937. // a reviewed conversion in order to avoid an import loop.
  938. var temporarySafeHtml = (0, html_impl_1.createHtml)(dirtyHtml);
  939. (0, element_1.setInnerHtml)(template, temporarySafeHtml);
  940. return template.content;
  941. }
  942. exports.createInertFragment = createInertFragment;
  943. /***/ }),
  944. /***/ "./node_modules/safevalues/builders/html_sanitizer/no_clobber.js":
  945. /*!***********************************************************************!*\
  946. !*** ./node_modules/safevalues/builders/html_sanitizer/no_clobber.js ***!
  947. \***********************************************************************/
  948. /*! no static exports found */
  949. /***/ (function(module, exports, __webpack_require__) {
  950. "use strict";
  951. /**
  952. * @license
  953. * SPDX-License-Identifier: Apache-2.0
  954. */
  955. Object.defineProperty(exports, "__esModule", { value: true });
  956. exports.isElement = exports.isText = exports.getNodeName = void 0;
  957. /**
  958. * Library that provides safe getters for different node properties and
  959. * checks for clobbering.
  960. */
  961. /** Gets a reasonable nodeName, even for clobbered nodes. */
  962. function getNodeName(node) {
  963. var nodeName = node.nodeName;
  964. // If the property is clobbered, assume it is an `HTMLFormElement`.
  965. return (typeof nodeName === 'string') ? nodeName : 'FORM';
  966. }
  967. exports.getNodeName = getNodeName;
  968. /** Returns true if the object passed is a Text node. */
  969. function isText(node) {
  970. // The property cannot get clobbered on Text nodes.
  971. return node.nodeType === Node.TEXT_NODE;
  972. }
  973. exports.isText = isText;
  974. /** Returns true if the object passed is an Element node. */
  975. function isElement(node) {
  976. var nodeType = node.nodeType;
  977. // If the property is clobbered, we can assume it is an `HTMLFormElement`, and
  978. // thus an `Element`.
  979. return (nodeType === Node.ELEMENT_NODE) || (typeof nodeType !== 'number');
  980. }
  981. exports.isElement = isElement;
  982. /***/ }),
  983. /***/ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js":
  984. /*!****************************************************************************************************!*\
  985. !*** ./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js ***!
  986. \****************************************************************************************************/
  987. /*! no static exports found */
  988. /***/ (function(module, exports, __webpack_require__) {
  989. "use strict";
  990. /**
  991. * @license
  992. * SPDX-License-Identifier: Apache-2.0
  993. */
  994. Object.defineProperty(exports, "__esModule", { value: true });
  995. exports.defaultSanitizerTable = void 0;
  996. var sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js");
  997. /**
  998. * GENERATED CODE, DO NOT MODIFY
  999. * This SanitizerTable was generated from the checked in html contract:
  1000. * webutil/html/types/codegen/html5_contract.textpb
  1001. *
  1002. * You can regenerate this file with:
  1003. * webutil/html/types/codegen/update_generated_source_files.sh
  1004. */
  1005. exports.defaultSanitizerTable = new sanitizer_table_1.SanitizerTable(new Set([
  1006. 'ARTICLE', 'SECTION', 'NAV', 'ASIDE', 'H1', 'H2',
  1007. 'H3', 'H4', 'H5', 'H6', 'HEADER', 'FOOTER',
  1008. 'ADDRESS', 'P', 'HR', 'PRE', 'BLOCKQUOTE', 'OL',
  1009. 'UL', 'LH', 'LI', 'DL', 'DT', 'DD',
  1010. 'FIGURE', 'FIGCAPTION', 'MAIN', 'DIV', 'EM', 'STRONG',
  1011. 'SMALL', 'S', 'CITE', 'Q', 'DFN', 'ABBR',
  1012. 'RUBY', 'RB', 'RT', 'RTC', 'RP', 'DATA',
  1013. 'TIME', 'CODE', 'VAR', 'SAMP', 'KBD', 'SUB',
  1014. 'SUP', 'I', 'B', 'U', 'MARK', 'BDI',
  1015. 'BDO', 'SPAN', 'BR', 'WBR', 'INS', 'DEL',
  1016. 'PICTURE', 'PARAM', 'TRACK', 'MAP', 'TABLE', 'CAPTION',
  1017. 'COLGROUP', 'COL', 'TBODY', 'THEAD', 'TFOOT', 'TR',
  1018. 'TD', 'TH', 'SELECT', 'DATALIST', 'OPTGROUP', 'OPTION',
  1019. 'OUTPUT', 'PROGRESS', 'METER', 'FIELDSET', 'LEGEND', 'DETAILS',
  1020. 'SUMMARY', 'MENU', 'DIALOG', 'SLOT', 'CANVAS', 'FONT',
  1021. 'CENTER',
  1022. ]), new Map([
  1023. [
  1024. 'A', new Map([
  1025. ['href', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1026. ])
  1027. ],
  1028. [
  1029. 'AREA', new Map([
  1030. ['href', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1031. ])
  1032. ],
  1033. [
  1034. 'LINK', new Map([
  1035. [
  1036. 'href', {
  1037. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL,
  1038. conditions: new Map([[
  1039. 'rel', new Set([
  1040. 'alternate',
  1041. 'author',
  1042. 'bookmark',
  1043. 'canonical',
  1044. 'cite',
  1045. 'help',
  1046. 'icon',
  1047. 'license',
  1048. 'next',
  1049. 'prefetch',
  1050. 'dns-prefetch',
  1051. 'prerender',
  1052. 'preconnect',
  1053. 'preload',
  1054. 'prev',
  1055. 'search',
  1056. 'subresource',
  1057. ])
  1058. ]])
  1059. }
  1060. ],
  1061. ])
  1062. ],
  1063. [
  1064. 'SOURCE', new Map([
  1065. ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1066. ])
  1067. ],
  1068. [
  1069. 'IMG', new Map([
  1070. ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1071. ])
  1072. ],
  1073. [
  1074. 'VIDEO', new Map([
  1075. ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1076. ])
  1077. ],
  1078. [
  1079. 'AUDIO', new Map([
  1080. ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1081. ])
  1082. ],
  1083. ]), new Set([
  1084. 'title',
  1085. 'aria-atomic',
  1086. 'aria-autocomplete',
  1087. 'aria-busy',
  1088. 'aria-checked',
  1089. 'aria-current',
  1090. 'aria-disabled',
  1091. 'aria-dropeffect',
  1092. 'aria-expanded',
  1093. 'aria-haspopup',
  1094. 'aria-hidden',
  1095. 'aria-invalid',
  1096. 'aria-label',
  1097. 'aria-level',
  1098. 'aria-live',
  1099. 'aria-multiline',
  1100. 'aria-multiselectable',
  1101. 'aria-orientation',
  1102. 'aria-posinset',
  1103. 'aria-pressed',
  1104. 'aria-readonly',
  1105. 'aria-relevant',
  1106. 'aria-required',
  1107. 'aria-selected',
  1108. 'aria-setsize',
  1109. 'aria-sort',
  1110. 'aria-valuemax',
  1111. 'aria-valuemin',
  1112. 'aria-valuenow',
  1113. 'aria-valuetext',
  1114. 'alt',
  1115. 'align',
  1116. 'autocapitalize',
  1117. 'autocomplete',
  1118. 'autocorrect',
  1119. 'autofocus',
  1120. 'autoplay',
  1121. 'bgcolor',
  1122. 'border',
  1123. 'cellpadding',
  1124. 'cellspacing',
  1125. 'checked',
  1126. 'color',
  1127. 'cols',
  1128. 'colspan',
  1129. 'controls',
  1130. 'datetime',
  1131. 'disabled',
  1132. 'download',
  1133. 'draggable',
  1134. 'enctype',
  1135. 'face',
  1136. 'formenctype',
  1137. 'frameborder',
  1138. 'height',
  1139. 'hreflang',
  1140. 'hidden',
  1141. 'ismap',
  1142. 'label',
  1143. 'lang',
  1144. 'loop',
  1145. 'max',
  1146. 'maxlength',
  1147. 'media',
  1148. 'minlength',
  1149. 'min',
  1150. 'multiple',
  1151. 'muted',
  1152. 'nonce',
  1153. 'open',
  1154. 'placeholder',
  1155. 'preload',
  1156. 'rel',
  1157. 'required',
  1158. 'reversed',
  1159. 'role',
  1160. 'rows',
  1161. 'rowspan',
  1162. 'selected',
  1163. 'shape',
  1164. 'size',
  1165. 'sizes',
  1166. 'slot',
  1167. 'span',
  1168. 'spellcheck',
  1169. 'start',
  1170. 'step',
  1171. 'summary',
  1172. 'translate',
  1173. 'type',
  1174. 'valign',
  1175. 'value',
  1176. 'width',
  1177. 'wrap',
  1178. 'itemscope',
  1179. 'itemtype',
  1180. 'itemid',
  1181. 'itemprop',
  1182. 'itemref',
  1183. ]), new Map([
  1184. [
  1185. 'dir', {
  1186. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
  1187. conditions: new Map([[
  1188. 'dir', new Set([
  1189. 'auto',
  1190. 'ltr',
  1191. 'rtl',
  1192. ])
  1193. ]])
  1194. }
  1195. ],
  1196. [
  1197. 'async', {
  1198. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
  1199. conditions: new Map([[
  1200. 'async', new Set([
  1201. 'async',
  1202. ])
  1203. ]])
  1204. }
  1205. ],
  1206. ['cite', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1207. [
  1208. 'loading', {
  1209. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
  1210. conditions: new Map([[
  1211. 'loading', new Set([
  1212. 'eager',
  1213. 'lazy',
  1214. ])
  1215. ]])
  1216. }
  1217. ],
  1218. ['poster', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1219. [
  1220. 'target', {
  1221. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
  1222. conditions: new Map([[
  1223. 'target', new Set([
  1224. '_self',
  1225. '_blank',
  1226. ])
  1227. ]])
  1228. }
  1229. ],
  1230. ]));
  1231. /***/ }),
  1232. /***/ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js":
  1233. /*!********************************************************************************************!*\
  1234. !*** ./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js ***!
  1235. \********************************************************************************************/
  1236. /*! no static exports found */
  1237. /***/ (function(module, exports, __webpack_require__) {
  1238. "use strict";
  1239. /**
  1240. * @license
  1241. * SPDX-License-Identifier: Apache-2.0
  1242. */
  1243. Object.defineProperty(exports, "__esModule", { value: true });
  1244. exports.AttributePolicyAction = exports.SanitizerTable = void 0;
  1245. /** Class for holding element and attribute policies used for sanitization. */
  1246. var SanitizerTable = /** @class */ (function () {
  1247. function SanitizerTable(allowedElements, elementPolicies, allowedGlobalAttributes, globalAttributePolicies) {
  1248. this.allowedElements = allowedElements;
  1249. this.elementPolicies = elementPolicies;
  1250. this.allowedGlobalAttributes = allowedGlobalAttributes;
  1251. this.globalAttributePolicies = globalAttributePolicies;
  1252. }
  1253. SanitizerTable.prototype.isAllowedElement = function (elementName) {
  1254. // Note: `HTMLFormElement`s are always dropped, supporting them is very
  1255. // costly because of the DOM clobberring they can cause. The additional code
  1256. // size required to properly work around DOM clobberring issues is large and
  1257. // shouldn't be put on every user of the sanitizer. Thoroughly review
  1258. // b/210975025 and the CLs linked there before you start allowing form
  1259. // elements.
  1260. return elementName.toLowerCase() !== 'form' &&
  1261. (this.allowedElements.has(elementName) ||
  1262. this.elementPolicies.has(elementName));
  1263. };
  1264. SanitizerTable.prototype.getAttributePolicy = function (attributeName, elementName) {
  1265. var elementPolicy = this.elementPolicies.get(elementName);
  1266. if (elementPolicy === null || elementPolicy === void 0 ? void 0 : elementPolicy.has(attributeName)) {
  1267. return elementPolicy.get(attributeName);
  1268. }
  1269. if (this.allowedGlobalAttributes.has(attributeName)) {
  1270. return { policyAction: AttributePolicyAction.KEEP };
  1271. }
  1272. var globalPolicy = this.globalAttributePolicies.get(attributeName);
  1273. return globalPolicy || { policyAction: AttributePolicyAction.DROP };
  1274. };
  1275. return SanitizerTable;
  1276. }());
  1277. exports.SanitizerTable = SanitizerTable;
  1278. /**
  1279. * Values derived from
  1280. * https://godoc.corp.google.com/pkg/google3/third_party/safehtml/sanitizer/policy#AttributePolicy
  1281. */
  1282. var AttributePolicyAction;
  1283. (function (AttributePolicyAction) {
  1284. AttributePolicyAction[AttributePolicyAction["DROP"] = 0] = "DROP";
  1285. AttributePolicyAction[AttributePolicyAction["KEEP"] = 1] = "KEEP";
  1286. AttributePolicyAction[AttributePolicyAction["KEEP_AND_SANITIZE_URL"] = 2] = "KEEP_AND_SANITIZE_URL";
  1287. AttributePolicyAction[AttributePolicyAction["KEEP_AND_NORMALIZE"] = 3] = "KEEP_AND_NORMALIZE";
  1288. AttributePolicyAction[AttributePolicyAction["KEEP_AND_SANITIZE_STYLE"] = 4] = "KEEP_AND_SANITIZE_STYLE";
  1289. })(AttributePolicyAction = exports.AttributePolicyAction || (exports.AttributePolicyAction = {}));
  1290. /***/ }),
  1291. /***/ "./node_modules/safevalues/builders/resource_url_builders.js":
  1292. /*!*******************************************************************!*\
  1293. !*** ./node_modules/safevalues/builders/resource_url_builders.js ***!
  1294. \*******************************************************************/
  1295. /*! no static exports found */
  1296. /***/ (function(module, exports, __webpack_require__) {
  1297. "use strict";
  1298. /**
  1299. * @license
  1300. * SPDX-License-Identifier: Apache-2.0
  1301. */
  1302. Object.defineProperty(exports, "__esModule", { value: true });
  1303. exports.blobUrlFromScript = exports.replaceFragment = exports.appendParams = exports.trustedResourceUrl = void 0;
  1304. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1305. var resource_url_impl_1 = __webpack_require__(/*! ../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  1306. var script_impl_1 = __webpack_require__(/*! ../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  1307. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  1308. /**
  1309. * Check whether the base url contains a valid origin,
  1310. *
  1311. * A string for an origin must contain only alphanumeric or any of the
  1312. * following: `-.:`, and must not be an IP address. Remember that, as per the
  1313. * documentation for TrustedResourceUrl, the origin must be trustworthy.
  1314. *
  1315. * @param base The base url that contains an origin.
  1316. */
  1317. function hasValidOrigin(base) {
  1318. if (!(/^https:\/\//.test(base) || /^\/\//.test(base))) {
  1319. return false;
  1320. }
  1321. var originStart = base.indexOf('//') + 2;
  1322. var originEnd = base.indexOf('/', originStart);
  1323. // If the base url only contains the prefix (e.g. //), or the slash
  1324. // for the origin is right after the prefix (e.g. ///), the origin is
  1325. // missing.
  1326. if (originEnd <= originStart) {
  1327. throw new Error("Can't interpolate data in a url's origin, " +
  1328. "Please make sure to fully specify the origin, terminated with '/'.");
  1329. }
  1330. var origin = base.substring(originStart, originEnd);
  1331. if (!/^[0-9a-z.:-]+$/i.test(origin)) {
  1332. throw new Error('The origin contains unsupported characters.');
  1333. }
  1334. if (!/^[^:]*(:[0-9]+)?$/i.test(origin)) {
  1335. throw new Error('Invalid port number.');
  1336. }
  1337. if (!/(^|\.)[a-z][^.]*$/i.test(origin)) {
  1338. throw new Error('The top-level domain must start with a letter.');
  1339. }
  1340. return true;
  1341. }
  1342. /**
  1343. * Check whether the base url contains a valid about url at its beginning.
  1344. *
  1345. * An about url is either exactly 'about:blank' or 'about:blank#<str>' where
  1346. * <str> can be an arbitrary string.
  1347. *
  1348. * @param base The base url.
  1349. */
  1350. function isValidAboutUrl(base) {
  1351. if (!/^about:blank/.test(base)) {
  1352. return false;
  1353. }
  1354. if (base !== 'about:blank' && !/^about:blank#/.test(base)) {
  1355. throw new Error('The about url is invalid.');
  1356. }
  1357. return true;
  1358. }
  1359. /**
  1360. * Check whether the base url contains a valid path start at its beginning.
  1361. *
  1362. * A valid path start is either a '/' or a '/' followed by at least one
  1363. * character that is not '/' or '\'.
  1364. *
  1365. * @param base The base url.
  1366. */
  1367. function isValidPathStart(base) {
  1368. if (!/^\//.test(base)) {
  1369. return false;
  1370. }
  1371. if ((base === '/') ||
  1372. (base.length > 1 && base[1] !== '/' && base[1] !== '\\')) {
  1373. return true;
  1374. }
  1375. throw new Error('The path start in the url is invalid.');
  1376. }
  1377. /**
  1378. * Builds TrustedResourceUrl from a template literal.
  1379. *
  1380. * This factory is a template literal tag function. It should be called with
  1381. * a template literal, with or without embedded expressions. For example,
  1382. * trustedResourceUrl`//example.com/${bar}`;
  1383. * or
  1384. * trustedResourceUrl`//example.com`;
  1385. *
  1386. * When this function is called with a template literal without any embedded
  1387. * expressions, the template string may contain anything as the whole URL is
  1388. * a compile-time string constant.
  1389. *
  1390. * When this function is called with a template literal that contains embedded
  1391. * expressions, the template must start with one of the following:
  1392. * - `https://<origin>/`
  1393. * - `//<origin>/`
  1394. * - `/<pathStart>`
  1395. * - `about:blank`
  1396. * - `data:`
  1397. *
  1398. * `<origin>` must contain only alphanumeric or any of the following: `-.:`.
  1399. * Remember that, as per the documentation for TrustedResourceUrl, the origin
  1400. * must be trustworthy. An origin of "example.com" could be set with this
  1401. * method, but would tie the security of your site to the security of
  1402. * example.com. Similarly, formats that potentially cover redirects hosted
  1403. * on a trusted origin are problematic, since that could lead to untrusted
  1404. * origins.
  1405. *
  1406. * `<pathStart>` is either an empty string, or a non empty string that does not
  1407. * start with '/' or '\'.
  1408. * In other words, `/<pathStart>` is either a '/' or a
  1409. * '/' followed by at least one character that is not '/' or '\'.
  1410. *
  1411. * `data:` (data URL) does not allow embedded expressions in the template
  1412. * literal input.
  1413. *
  1414. * All embedded expressions are URL encoded when they are interpolated. Do not
  1415. * embed expressions that are already URL encoded as they will be double encoded
  1416. * by the builder.
  1417. *
  1418. * @param templateObj This contains the literal part of the template literal.
  1419. * @param rest This represents the template's embedded expressions.
  1420. */
  1421. function trustedResourceUrl(templateObj) {
  1422. var rest = [];
  1423. for (var _i = 1; _i < arguments.length; _i++) {
  1424. rest[_i - 1] = arguments[_i];
  1425. }
  1426. // Check if templateObj is actually from a template literal.
  1427. if (true) {
  1428. (0, string_literal_1.assertIsTemplateObject)(templateObj, true, 'trustedResourceUrl is a template literal tag function and ' +
  1429. 'can only be called as such (e.g. trustedResourceUrl`/somepath.js`)');
  1430. }
  1431. if (rest.length === 0) {
  1432. return (0, resource_url_impl_1.createResourceUrl)(templateObj[0]);
  1433. }
  1434. var base = templateObj[0].toLowerCase();
  1435. if (true) {
  1436. if (/^data:/.test(base)) {
  1437. throw new Error('Data URLs cannot have expressions in the template literal input.');
  1438. }
  1439. if (!hasValidOrigin(base) && !isValidPathStart(base) &&
  1440. !isValidAboutUrl(base)) {
  1441. throw new Error('Trying to interpolate expressions in an unsupported url format.');
  1442. }
  1443. }
  1444. var urlParts = [templateObj[0]];
  1445. for (var i = 0; i < rest.length; i++) {
  1446. urlParts.push(encodeURIComponent(rest[i]));
  1447. urlParts.push(templateObj[i + 1]);
  1448. }
  1449. return (0, resource_url_impl_1.createResourceUrl)(urlParts.join(''));
  1450. }
  1451. exports.trustedResourceUrl = trustedResourceUrl;
  1452. /**
  1453. * Creates a new TrustedResourceUrl with params added to the URL's search
  1454. * parameters.
  1455. *
  1456. * @param params What to add to the URL. Parameters with value `null` or
  1457. * `undefined` are skipped. Both keys and values will be encoded. Do not pass
  1458. * pre-encoded values as this will result them being double encoded. If the
  1459. * value is an array then the same parameter is added for every element in the
  1460. * array.
  1461. */
  1462. function appendParams(trustedUrl, params) {
  1463. var url = (0, resource_url_impl_1.unwrapResourceUrl)(trustedUrl).toString();
  1464. if (/#/.test(url)) {
  1465. var message = '';
  1466. if (true) {
  1467. message = "Found a hash in url (".concat(url, "), appending not supported");
  1468. }
  1469. throw new Error(message);
  1470. }
  1471. var separator = /\?/.test(url) ? '&' : '?';
  1472. // for-of has a big polyfill.
  1473. // tslint:disable-next-line:ban-iterable-foreach
  1474. params.forEach(function (value, key) {
  1475. var values = (value instanceof Array) ? value : [value];
  1476. for (var i = 0; i < values.length; i++) {
  1477. var v = values[i];
  1478. if (v === null || v === undefined) {
  1479. continue;
  1480. }
  1481. url += separator + encodeURIComponent(key) + '=' +
  1482. encodeURIComponent(String(v));
  1483. separator = '&';
  1484. }
  1485. });
  1486. return (0, resource_url_impl_1.createResourceUrl)(url);
  1487. }
  1488. exports.appendParams = appendParams;
  1489. var BEFORE_FRAGMENT_REGEXP = /[^#]*/;
  1490. /**
  1491. * Creates a new TrustedResourceUrl based on an existing one but with the
  1492. * addition of a fragment (the part after `#`). If the URL already has a
  1493. * fragment, it is replaced with the new one.
  1494. * @param fragment The fragment to add to the URL, verbatim, without the leading
  1495. * `#`. No additional escaping is applied.
  1496. */
  1497. function replaceFragment(trustedUrl, fragment) {
  1498. var urlString = (0, resource_url_impl_1.unwrapResourceUrl)(trustedUrl).toString();
  1499. return (0, resource_url_impl_1.createResourceUrl)(BEFORE_FRAGMENT_REGEXP.exec(urlString)[0] + '#' + fragment);
  1500. }
  1501. exports.replaceFragment = replaceFragment;
  1502. /**
  1503. * Creates a `TrustedResourceUrl` by generating a `Blob` from a
  1504. * `SafeScript` and then calling `URL.createObjectURL` with that `Blob`.
  1505. *
  1506. * Caller must call `URL.revokeObjectUrl()` on the stringified url to
  1507. * release the underlying `Blob`.
  1508. */
  1509. function blobUrlFromScript(safeScript) {
  1510. var scriptContent = (0, script_impl_1.unwrapScript)(safeScript).toString();
  1511. var blob = new Blob([scriptContent], { type: 'text/javascript' });
  1512. return (0, resource_url_impl_1.createResourceUrl)(URL.createObjectURL(blob));
  1513. }
  1514. exports.blobUrlFromScript = blobUrlFromScript;
  1515. /***/ }),
  1516. /***/ "./node_modules/safevalues/builders/script_builders.js":
  1517. /*!*************************************************************!*\
  1518. !*** ./node_modules/safevalues/builders/script_builders.js ***!
  1519. \*************************************************************/
  1520. /*! no static exports found */
  1521. /***/ (function(module, exports, __webpack_require__) {
  1522. "use strict";
  1523. /**
  1524. * @license
  1525. * SPDX-License-Identifier: Apache-2.0
  1526. */
  1527. Object.defineProperty(exports, "__esModule", { value: true });
  1528. exports.safeScriptWithArgs = exports.scriptFromJson = exports.concatScripts = exports.safeScript = void 0;
  1529. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1530. var script_impl_1 = __webpack_require__(/*! ../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  1531. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  1532. /**
  1533. * Creates a SafeScript object from a template literal (without any embedded
  1534. * expressions).
  1535. *
  1536. * This function is a template literal tag function. It should be called with
  1537. * a template literal that does not contain any expressions. For example,
  1538. * safeScript`foo`;
  1539. *
  1540. * @param templateObj This contains the literal part of the template literal.
  1541. */
  1542. function safeScript(templateObj) {
  1543. if (true) {
  1544. (0, string_literal_1.assertIsTemplateObject)(templateObj, false, 'safeScript is a template literal tag function ' +
  1545. 'that only accepts template literals without expressions. ' +
  1546. 'For example, safeScript`foo`;');
  1547. }
  1548. return (0, script_impl_1.createScript)(templateObj[0]);
  1549. }
  1550. exports.safeScript = safeScript;
  1551. /** Creates a `SafeScript` value by concatenating multiple `SafeScript`s. */
  1552. function concatScripts(scripts) {
  1553. return (0, script_impl_1.createScript)(scripts.map(script_impl_1.unwrapScript).join(''));
  1554. }
  1555. exports.concatScripts = concatScripts;
  1556. /**
  1557. * Converts a serializable value into JSON that is safe to interpolate into a
  1558. * script context. In particular it escapes < characters so that a value of
  1559. * "</script>" doesn't break out of the context.
  1560. * @param value The value to serialize.
  1561. */
  1562. function scriptFromJson(value) {
  1563. return (0, script_impl_1.createScript)(JSON.stringify(value).replace(/</g, '\\x3c'));
  1564. }
  1565. exports.scriptFromJson = scriptFromJson;
  1566. /**
  1567. * Creates a `SafeScript` object from a template literal (without any embedded
  1568. * expressions) along with additional arguments that the script should have
  1569. * access to. These arguments will be JSON-encoded and passed to the script as
  1570. * a function call.
  1571. * @example
  1572. * ```ts
  1573. * safeScriptWithArgs`function (name, props) {
  1574. * console.log(name + ' is ' + props.age);
  1575. * }`('Bob', { 'age': 42 })
  1576. * ```
  1577. * would return a `SafeScript` that represents the following code:
  1578. * ```js
  1579. * (function (name, props) {
  1580. * console.log(name + ' is ' + props.age);
  1581. * })("Bob",{"age":42})
  1582. * ```
  1583. * @note Be careful when passing objects as arguments, as unquoted property
  1584. * names may be changed during compilation.
  1585. * @param templateObj This contains the literal part of the template literal.
  1586. * @param emptyArgs Expressions that evaluate to the empty string to enable
  1587. * inline comments.
  1588. */
  1589. function safeScriptWithArgs(templateObj) {
  1590. var emptyArgs = [];
  1591. for (var _i = 1; _i < arguments.length; _i++) {
  1592. emptyArgs[_i - 1] = arguments[_i];
  1593. }
  1594. if (true) {
  1595. if (emptyArgs.some(function (a) { return a !== ''; })) {
  1596. throw new Error('safeScriptWithArgs only allows empty string expressions ' +
  1597. 'to enable inline comments.');
  1598. }
  1599. (0, string_literal_1.assertIsTemplateObject)(templateObj, true, 'safeScriptWithArgs is a template literal tag function ' +
  1600. 'that only accepts template literals. ' +
  1601. 'For example, safeScriptWithArgs`foo`;');
  1602. }
  1603. return function () {
  1604. var argValues = [];
  1605. for (var _i = 0; _i < arguments.length; _i++) {
  1606. argValues[_i] = arguments[_i];
  1607. }
  1608. var values = argValues.map(function (v) { return scriptFromJson(v).toString(); });
  1609. return (0, script_impl_1.createScript)("(".concat(templateObj.join(''), ")(").concat(values.join(','), ")"));
  1610. };
  1611. }
  1612. exports.safeScriptWithArgs = safeScriptWithArgs;
  1613. /***/ }),
  1614. /***/ "./node_modules/safevalues/builders/sensitive_attributes.js":
  1615. /*!******************************************************************!*\
  1616. !*** ./node_modules/safevalues/builders/sensitive_attributes.js ***!
  1617. \******************************************************************/
  1618. /*! no static exports found */
  1619. /***/ (function(module, exports, __webpack_require__) {
  1620. "use strict";
  1621. /**
  1622. * @license
  1623. * SPDX-License-Identifier: Apache-2.0
  1624. */
  1625. Object.defineProperty(exports, "__esModule", { value: true });
  1626. exports.SECURITY_SENSITIVE_ATTRIBUTES = void 0;
  1627. // AUTOGENERATED. DO NOT EDIT.
  1628. /**
  1629. * Security sensitive attribute names that should not be set through
  1630. * `setAttribute` or similar functions.
  1631. */
  1632. exports.SECURITY_SENSITIVE_ATTRIBUTES = [
  1633. 'href',
  1634. 'rel',
  1635. 'src',
  1636. 'srcdoc',
  1637. 'action',
  1638. 'formaction',
  1639. 'sandbox',
  1640. 'cite',
  1641. 'poster',
  1642. 'icon',
  1643. ];
  1644. /***/ }),
  1645. /***/ "./node_modules/safevalues/builders/style_builders.js":
  1646. /*!************************************************************!*\
  1647. !*** ./node_modules/safevalues/builders/style_builders.js ***!
  1648. \************************************************************/
  1649. /*! no static exports found */
  1650. /***/ (function(module, exports, __webpack_require__) {
  1651. "use strict";
  1652. /**
  1653. * @license
  1654. * SPDX-License-Identifier: Apache-2.0
  1655. */
  1656. Object.defineProperty(exports, "__esModule", { value: true });
  1657. exports.concatStyles = exports.safeStyle = void 0;
  1658. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1659. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  1660. var style_impl_1 = __webpack_require__(/*! ../internals/style_impl */ "./node_modules/safevalues/internals/style_impl.js");
  1661. /**
  1662. * Creates a SafeStyle object from a template literal (without any embedded
  1663. * expressions).
  1664. *
  1665. * ` style` should be in the format
  1666. * ` name: value; [name: value; ...]` and must not have any < or >
  1667. * characters in it. This is so that SafeStyle's contract is preserved,
  1668. * allowing the SafeStyle to correctly be interpreted as a sequence of CSS
  1669. * declarations and without affecting the syntactic structure of any
  1670. * surrounding CSS and HTML.
  1671. *
  1672. * This function is a template literal tag function. It should be called with
  1673. * a template literal that does not contain any expressions. For example,
  1674. * safeStyle`foo`;
  1675. * This function first checks if it is called with a literal template, and
  1676. * then performs basic sanity checks on the format of ` style`
  1677. * but does not constrain the format of ` name} and {@code value`, except
  1678. * for disallowing tag characters.
  1679. *
  1680. * @param templateObj This contains the literal part of the template literal.
  1681. */
  1682. function safeStyle(templateObj) {
  1683. if (true) {
  1684. (0, string_literal_1.assertIsTemplateObject)(templateObj, false, 'safeStyle is a template literal tag function ' +
  1685. 'that only accepts template literals without expressions. ' +
  1686. 'For example, safeStyle`foo`;');
  1687. }
  1688. var style = templateObj[0];
  1689. if (true) {
  1690. if (/[<>]/.test(style)) {
  1691. throw new Error('Forbidden characters in style string: ' + style);
  1692. }
  1693. if (!/;$/.test(style)) {
  1694. throw new Error('Style string does not end with ";": ' + style);
  1695. }
  1696. if (!/:/.test(style)) {
  1697. throw new Error('Style string should contain one or more ":": ' + style);
  1698. }
  1699. }
  1700. return (0, style_impl_1.createStyle)(style);
  1701. }
  1702. exports.safeStyle = safeStyle;
  1703. /** Creates a `SafeStyle` value by concatenating multiple `SafeStyle`s. */
  1704. function concatStyles(styles) {
  1705. return (0, style_impl_1.createStyle)(styles.map(style_impl_1.unwrapStyle).join(''));
  1706. }
  1707. exports.concatStyles = concatStyles;
  1708. /***/ }),
  1709. /***/ "./node_modules/safevalues/builders/style_sheet_builders.js":
  1710. /*!******************************************************************!*\
  1711. !*** ./node_modules/safevalues/builders/style_sheet_builders.js ***!
  1712. \******************************************************************/
  1713. /*! no static exports found */
  1714. /***/ (function(module, exports, __webpack_require__) {
  1715. "use strict";
  1716. /**
  1717. * @license
  1718. * SPDX-License-Identifier: Apache-2.0
  1719. */
  1720. Object.defineProperty(exports, "__esModule", { value: true });
  1721. exports.concatStyleSheets = exports.safeStyleSheet = void 0;
  1722. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1723. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  1724. var style_sheet_impl_1 = __webpack_require__(/*! ../internals/style_sheet_impl */ "./node_modules/safevalues/internals/style_sheet_impl.js");
  1725. /**
  1726. * Creates a SafeStyleSheet object from a template literal (without any
  1727. * embedded expressions).
  1728. *
  1729. * This function is a template literal tag function. It should be called with
  1730. * a template literal that does not contain any expressions. For example,
  1731. * safeStyleSheet`foo`;
  1732. * The argument must not have any < or > characters in it. This is so that
  1733. * SafeStyleSheet's contract is preserved, allowing the SafeStyleSheet to
  1734. * correctly be interpreted as a sequence of CSS declarations and without
  1735. * affecting the syntactic structure of any surrounding CSS and HTML.
  1736. *
  1737. * @param templateObj This contains the literal part of the template literal.
  1738. */
  1739. function safeStyleSheet(templateObj) {
  1740. if (true) {
  1741. (0, string_literal_1.assertIsTemplateObject)(templateObj, false, 'safeStyleSheet is a template literal tag ' +
  1742. 'function that only accepts template literals without ' +
  1743. 'expressions. For example, safeStyleSheet`foo`;');
  1744. }
  1745. var styleSheet = templateObj[0];
  1746. if (true) {
  1747. if (/[<>]/.test(styleSheet)) {
  1748. throw new Error('Forbidden characters in styleSheet string: ' + styleSheet);
  1749. }
  1750. }
  1751. return (0, style_sheet_impl_1.createStyleSheet)(styleSheet);
  1752. }
  1753. exports.safeStyleSheet = safeStyleSheet;
  1754. /**
  1755. * Creates a `SafeStyleSheet` value by concatenating multiple `SafeStyleSheet`s.
  1756. */
  1757. function concatStyleSheets(sheets) {
  1758. return (0, style_sheet_impl_1.createStyleSheet)(sheets.map(style_sheet_impl_1.unwrapStyleSheet).join(''));
  1759. }
  1760. exports.concatStyleSheets = concatStyleSheets;
  1761. /***/ }),
  1762. /***/ "./node_modules/safevalues/builders/url_sanitizer.js":
  1763. /*!***********************************************************!*\
  1764. !*** ./node_modules/safevalues/builders/url_sanitizer.js ***!
  1765. \***********************************************************/
  1766. /*! no static exports found */
  1767. /***/ (function(module, exports, __webpack_require__) {
  1768. "use strict";
  1769. /**
  1770. * @license
  1771. * SPDX-License-Identifier: Apache-2.0
  1772. */
  1773. Object.defineProperty(exports, "__esModule", { value: true });
  1774. exports.restrictivelySanitizeUrl = exports.unwrapUrlOrSanitize = exports.sanitizeJavascriptUrl = void 0;
  1775. /**
  1776. * @fileoverview Provides functions to enforce the SafeUrl contract at the sink
  1777. * level.
  1778. */
  1779. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1780. function extractScheme(url) {
  1781. var parsedUrl;
  1782. try {
  1783. parsedUrl = new URL(url);
  1784. }
  1785. catch (e) {
  1786. // According to https://url.spec.whatwg.org/#constructors, the URL
  1787. // constructor with one parameter throws if `url` is not absolute. In this
  1788. // case, we are sure that no explicit scheme (javascript: ) is set.
  1789. // This can also be a URL parsing error, but in this case the URL won't be
  1790. // run anyway.
  1791. return 'https:';
  1792. }
  1793. return parsedUrl.protocol;
  1794. }
  1795. // We can't use an ES6 Set here because gws somehow depends on this code and
  1796. // doesn't want to pay the cost of a polyfill.
  1797. var ALLOWED_SCHEMES = ['data:', 'http:', 'https:', 'mailto:', 'ftp:'];
  1798. /**
  1799. * Checks that the URL scheme is not javascript.
  1800. * The URL parsing relies on the URL API in browsers that support it.
  1801. * @param url The URL to sanitize for a SafeUrl sink.
  1802. * @return undefined if url has a javascript: scheme, the original URL
  1803. * otherwise.
  1804. */
  1805. function sanitizeJavascriptUrl(url) {
  1806. var parsedScheme = extractScheme(url);
  1807. if (parsedScheme === 'javascript:') {
  1808. if (true) {
  1809. console.error("A URL with content '".concat(url, "' was sanitized away."));
  1810. }
  1811. return undefined;
  1812. }
  1813. return url;
  1814. }
  1815. exports.sanitizeJavascriptUrl = sanitizeJavascriptUrl;
  1816. /**
  1817. * Adapter to sanitize string URLs in DOM sink wrappers.
  1818. * @return undefined if the URL was sanitized.
  1819. */
  1820. function unwrapUrlOrSanitize(url) {
  1821. return sanitizeJavascriptUrl(url);
  1822. }
  1823. exports.unwrapUrlOrSanitize = unwrapUrlOrSanitize;
  1824. /**
  1825. * Sanitizes a URL restrictively.
  1826. * This sanitizer protects against XSS and potentially other uncommon and
  1827. * undesirable schemes that an attacker could use for e.g. phishing (tel:,
  1828. * callto: ssh: etc schemes). This sanitizer is primarily meant to be used by
  1829. * the HTML sanitizer.
  1830. */
  1831. function restrictivelySanitizeUrl(url) {
  1832. var parsedScheme = extractScheme(url);
  1833. if (parsedScheme !== undefined &&
  1834. ALLOWED_SCHEMES.indexOf(parsedScheme.toLowerCase()) !== -1) {
  1835. return url;
  1836. }
  1837. return 'about:invalid#zClosurez';
  1838. }
  1839. exports.restrictivelySanitizeUrl = restrictivelySanitizeUrl;
  1840. /***/ }),
  1841. /***/ "./node_modules/safevalues/dom/elements/anchor.js":
  1842. /*!********************************************************!*\
  1843. !*** ./node_modules/safevalues/dom/elements/anchor.js ***!
  1844. \********************************************************/
  1845. /*! no static exports found */
  1846. /***/ (function(module, exports, __webpack_require__) {
  1847. "use strict";
  1848. /**
  1849. * @license
  1850. * SPDX-License-Identifier: Apache-2.0
  1851. */
  1852. Object.defineProperty(exports, "__esModule", { value: true });
  1853. exports.setHref = void 0;
  1854. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  1855. /**
  1856. * Sets the Href attribute from the given Url.
  1857. */
  1858. function setHref(anchor, url) {
  1859. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  1860. if (sanitizedUrl !== undefined) {
  1861. anchor.href = sanitizedUrl;
  1862. }
  1863. }
  1864. exports.setHref = setHref;
  1865. /***/ }),
  1866. /***/ "./node_modules/safevalues/dom/elements/area.js":
  1867. /*!******************************************************!*\
  1868. !*** ./node_modules/safevalues/dom/elements/area.js ***!
  1869. \******************************************************/
  1870. /*! no static exports found */
  1871. /***/ (function(module, exports, __webpack_require__) {
  1872. "use strict";
  1873. /**
  1874. * @license
  1875. * SPDX-License-Identifier: Apache-2.0
  1876. */
  1877. Object.defineProperty(exports, "__esModule", { value: true });
  1878. exports.setHref = void 0;
  1879. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  1880. /**
  1881. * Sets the Href attribute from the given Url.
  1882. */
  1883. function setHref(area, url) {
  1884. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  1885. if (sanitizedUrl !== undefined) {
  1886. area.href = sanitizedUrl;
  1887. }
  1888. }
  1889. exports.setHref = setHref;
  1890. /***/ }),
  1891. /***/ "./node_modules/safevalues/dom/elements/button.js":
  1892. /*!********************************************************!*\
  1893. !*** ./node_modules/safevalues/dom/elements/button.js ***!
  1894. \********************************************************/
  1895. /*! no static exports found */
  1896. /***/ (function(module, exports, __webpack_require__) {
  1897. "use strict";
  1898. /**
  1899. * @license
  1900. * SPDX-License-Identifier: Apache-2.0
  1901. */
  1902. Object.defineProperty(exports, "__esModule", { value: true });
  1903. exports.setFormaction = void 0;
  1904. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  1905. /**
  1906. * Sets the Formaction attribute from the given Url.
  1907. */
  1908. function setFormaction(button, url) {
  1909. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  1910. if (sanitizedUrl !== undefined) {
  1911. button.formAction = sanitizedUrl;
  1912. }
  1913. }
  1914. exports.setFormaction = setFormaction;
  1915. /***/ }),
  1916. /***/ "./node_modules/safevalues/dom/elements/element.js":
  1917. /*!*********************************************************!*\
  1918. !*** ./node_modules/safevalues/dom/elements/element.js ***!
  1919. \*********************************************************/
  1920. /*! no static exports found */
  1921. /***/ (function(module, exports, __webpack_require__) {
  1922. "use strict";
  1923. /**
  1924. * @license
  1925. * SPDX-License-Identifier: Apache-2.0
  1926. */
  1927. var __read = (this && this.__read) || function (o, n) {
  1928. var m = typeof Symbol === "function" && o[Symbol.iterator];
  1929. if (!m) return o;
  1930. var i = m.call(o), r, ar = [], e;
  1931. try {
  1932. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  1933. }
  1934. catch (error) { e = { error: error }; }
  1935. finally {
  1936. try {
  1937. if (r && !r.done && (m = i["return"])) m.call(i);
  1938. }
  1939. finally { if (e) throw e.error; }
  1940. }
  1941. return ar;
  1942. };
  1943. var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
  1944. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  1945. if (ar || !(i in from)) {
  1946. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  1947. ar[i] = from[i];
  1948. }
  1949. }
  1950. return to.concat(ar || Array.prototype.slice.call(from));
  1951. };
  1952. Object.defineProperty(exports, "__esModule", { value: true });
  1953. exports.setPrefixedAttribute = exports.buildPrefixedAttributeSetter = exports.insertAdjacentHtml = exports.setCssText = exports.setOuterHtml = exports.setInnerHtml = void 0;
  1954. /**
  1955. * @fileoverview This contains safe wrappers for properties that aren't specific
  1956. * to one kind of HTMLElement (like innerHTML), plus other setters and functions
  1957. * that are not tied to elements (like location.href or Worker constructor).
  1958. */
  1959. var attribute_impl_1 = __webpack_require__(/*! ../../internals/attribute_impl */ "./node_modules/safevalues/internals/attribute_impl.js");
  1960. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  1961. var style_impl_1 = __webpack_require__(/*! ../../internals/style_impl */ "./node_modules/safevalues/internals/style_impl.js");
  1962. /**
  1963. * Safely set {@link Element.innerHTML} on a given ShadowRoot or Element which
  1964. * may not be a `<script>` element or a `<style>` element.
  1965. */
  1966. function setInnerHtml(elOrRoot, v) {
  1967. if (isElement(elOrRoot)) {
  1968. throwIfScriptOrStyle(elOrRoot);
  1969. }
  1970. elOrRoot.innerHTML = (0, html_impl_1.unwrapHtml)(v);
  1971. }
  1972. exports.setInnerHtml = setInnerHtml;
  1973. /**
  1974. * Safely set {@link Element.outerHTML} for the given Element.
  1975. */
  1976. function setOuterHtml(e, v) {
  1977. var parent = e.parentElement;
  1978. if (parent !== null) {
  1979. throwIfScriptOrStyle(parent);
  1980. }
  1981. e.outerHTML = (0, html_impl_1.unwrapHtml)(v);
  1982. }
  1983. exports.setOuterHtml = setOuterHtml;
  1984. /**
  1985. * Set `ElementCSSInlineStyle.cssText` for the given `ElementCSSInlineStyle`.
  1986. */
  1987. function setCssText(e, v) {
  1988. e.style.cssText = (0, style_impl_1.unwrapStyle)(v);
  1989. }
  1990. exports.setCssText = setCssText;
  1991. /**
  1992. * Safely call {@link Element.insertAdjacentHTML} for the given Element.
  1993. */
  1994. function insertAdjacentHtml(element, position, v) {
  1995. var tagContext = (position === 'beforebegin' || position === 'afterend') ?
  1996. element.parentElement :
  1997. element;
  1998. if (tagContext !== null) {
  1999. throwIfScriptOrStyle(tagContext);
  2000. }
  2001. element.insertAdjacentHTML(position, (0, html_impl_1.unwrapHtml)(v));
  2002. }
  2003. exports.insertAdjacentHtml = insertAdjacentHtml;
  2004. /**
  2005. * Given a set of known-to-be-safe prefixes (e.g., "data-", "aria-", "js"),
  2006. * return a setter function that allows you to set attributes on an element,
  2007. * as long as the names of the attributes to be set has one of the prefixes.
  2008. *
  2009. * The returned setter ensures that setting any dangerous attribute, e.g.,
  2010. * "src", "href" will cause an exception. This is intended to be used as the
  2011. * safe alterantive of `Element#setAttribute`, when applications need to set
  2012. * attributes that do not have security implications and do not have a
  2013. * corresponding DOM property.
  2014. */
  2015. function buildPrefixedAttributeSetter(prefix) {
  2016. var otherPrefixes = [];
  2017. for (var _i = 1; _i < arguments.length; _i++) {
  2018. otherPrefixes[_i - 1] = arguments[_i];
  2019. }
  2020. var prefixes = __spreadArray([prefix], __read(otherPrefixes), false);
  2021. return function (e, attr, value) {
  2022. setPrefixedAttribute(prefixes, e, attr, value);
  2023. };
  2024. }
  2025. exports.buildPrefixedAttributeSetter = buildPrefixedAttributeSetter;
  2026. /**
  2027. * The safe alternative to Element#setAttribute. The function takes a list of
  2028. * `SafeAttributePrefix`, making developer intention explicit. The attribute
  2029. * to be set must has one of the safe prefixes, otherwise the function throws
  2030. * an Error.
  2031. */
  2032. function setPrefixedAttribute(attrPrefixes, e, attr, value) {
  2033. if (attrPrefixes.length === 0) {
  2034. throw new Error('No prefixes are provided');
  2035. }
  2036. var prefixes = attrPrefixes.map(function (s) { return (0, attribute_impl_1.unwrapAttributePrefix)(s); });
  2037. var attrLower = attr.toLowerCase();
  2038. if (prefixes.every(function (p) { return attrLower.indexOf(p) !== 0; })) {
  2039. throw new Error("Attribute \"".concat(attr, "\" does not match any of the allowed prefixes."));
  2040. }
  2041. e.setAttribute(attr, value);
  2042. }
  2043. exports.setPrefixedAttribute = setPrefixedAttribute;
  2044. function throwIfScriptOrStyle(element) {
  2045. if (element.tagName.toLowerCase() === 'script') {
  2046. throw new Error('Use setTextContent with a SafeScript.');
  2047. }
  2048. else if (element.tagName.toLowerCase() === 'style') {
  2049. throw new Error('Use setTextContent with a SafeStyleSheet.');
  2050. }
  2051. }
  2052. function isElement(elOrRoot) {
  2053. return elOrRoot.tagName !== undefined;
  2054. }
  2055. /***/ }),
  2056. /***/ "./node_modules/safevalues/dom/elements/embed.js":
  2057. /*!*******************************************************!*\
  2058. !*** ./node_modules/safevalues/dom/elements/embed.js ***!
  2059. \*******************************************************/
  2060. /*! no static exports found */
  2061. /***/ (function(module, exports, __webpack_require__) {
  2062. "use strict";
  2063. /**
  2064. * @license
  2065. * SPDX-License-Identifier: Apache-2.0
  2066. */
  2067. Object.defineProperty(exports, "__esModule", { value: true });
  2068. exports.setSrc = void 0;
  2069. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2070. /**
  2071. * Sets the Src attribute from the given SafeUrl.
  2072. */
  2073. function setSrc(embedEl, url) {
  2074. embedEl.src = (0, resource_url_impl_1.unwrapResourceUrl)(url);
  2075. }
  2076. exports.setSrc = setSrc;
  2077. /***/ }),
  2078. /***/ "./node_modules/safevalues/dom/elements/form.js":
  2079. /*!******************************************************!*\
  2080. !*** ./node_modules/safevalues/dom/elements/form.js ***!
  2081. \******************************************************/
  2082. /*! no static exports found */
  2083. /***/ (function(module, exports, __webpack_require__) {
  2084. "use strict";
  2085. /**
  2086. * @license
  2087. * SPDX-License-Identifier: Apache-2.0
  2088. */
  2089. Object.defineProperty(exports, "__esModule", { value: true });
  2090. exports.setAction = void 0;
  2091. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2092. /**
  2093. * Sets the Action attribute from the given Url.
  2094. */
  2095. function setAction(form, url) {
  2096. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2097. if (sanitizedUrl !== undefined) {
  2098. form.action = sanitizedUrl;
  2099. }
  2100. }
  2101. exports.setAction = setAction;
  2102. /***/ }),
  2103. /***/ "./node_modules/safevalues/dom/elements/iframe.js":
  2104. /*!********************************************************!*\
  2105. !*** ./node_modules/safevalues/dom/elements/iframe.js ***!
  2106. \********************************************************/
  2107. /*! no static exports found */
  2108. /***/ (function(module, exports, __webpack_require__) {
  2109. "use strict";
  2110. /**
  2111. * @license
  2112. * SPDX-License-Identifier: Apache-2.0
  2113. */
  2114. Object.defineProperty(exports, "__esModule", { value: true });
  2115. exports.setSrcdoc = exports.setSrc = void 0;
  2116. /**
  2117. * @fileoverview Safe iframe helpers and go/intents-for-iframes-for-closure
  2118. */
  2119. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2120. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2121. /** Sets the Src attribute using a TrustedResourceUrl */
  2122. function setSrc(iframe, v) {
  2123. iframe.src = (0, resource_url_impl_1.unwrapResourceUrl)(v).toString();
  2124. }
  2125. exports.setSrc = setSrc;
  2126. /** Sets the Srcdoc attribute using a SafeHtml */
  2127. function setSrcdoc(iframe, v) {
  2128. iframe.srcdoc = (0, html_impl_1.unwrapHtml)(v);
  2129. }
  2130. exports.setSrcdoc = setSrcdoc;
  2131. /***/ }),
  2132. /***/ "./node_modules/safevalues/dom/elements/input.js":
  2133. /*!*******************************************************!*\
  2134. !*** ./node_modules/safevalues/dom/elements/input.js ***!
  2135. \*******************************************************/
  2136. /*! no static exports found */
  2137. /***/ (function(module, exports, __webpack_require__) {
  2138. "use strict";
  2139. /**
  2140. * @license
  2141. * SPDX-License-Identifier: Apache-2.0
  2142. */
  2143. Object.defineProperty(exports, "__esModule", { value: true });
  2144. exports.setFormaction = void 0;
  2145. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2146. /**
  2147. * Sets the Formaction attribute from the given Url.
  2148. */
  2149. function setFormaction(input, url) {
  2150. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2151. if (sanitizedUrl !== undefined) {
  2152. input.formAction = sanitizedUrl;
  2153. }
  2154. }
  2155. exports.setFormaction = setFormaction;
  2156. /***/ }),
  2157. /***/ "./node_modules/safevalues/dom/elements/link.js":
  2158. /*!******************************************************!*\
  2159. !*** ./node_modules/safevalues/dom/elements/link.js ***!
  2160. \******************************************************/
  2161. /*! no static exports found */
  2162. /***/ (function(module, exports, __webpack_require__) {
  2163. "use strict";
  2164. /**
  2165. * @license
  2166. * SPDX-License-Identifier: Apache-2.0
  2167. */
  2168. Object.defineProperty(exports, "__esModule", { value: true });
  2169. exports.setHrefAndRel = void 0;
  2170. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2171. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2172. var SAFE_URL_REL_VALUES = [
  2173. 'alternate',
  2174. 'author',
  2175. 'bookmark',
  2176. 'canonical',
  2177. 'cite',
  2178. 'help',
  2179. 'icon',
  2180. 'license',
  2181. 'next',
  2182. 'prefetch',
  2183. 'dns-prefetch',
  2184. 'prerender',
  2185. 'preconnect',
  2186. 'preload',
  2187. 'prev',
  2188. 'search',
  2189. 'subresource',
  2190. ];
  2191. function setHrefAndRel(link, url, rel) {
  2192. if (url instanceof resource_url_impl_1.TrustedResourceUrl) {
  2193. link.href = (0, resource_url_impl_1.unwrapResourceUrl)(url).toString();
  2194. }
  2195. else {
  2196. if (SAFE_URL_REL_VALUES.indexOf(rel) === -1) {
  2197. throw new Error("TrustedResourceUrl href attribute required with rel=\"".concat(rel, "\""));
  2198. }
  2199. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2200. if (sanitizedUrl === undefined) {
  2201. return;
  2202. }
  2203. link.href = sanitizedUrl;
  2204. }
  2205. link.rel = rel;
  2206. }
  2207. exports.setHrefAndRel = setHrefAndRel;
  2208. /***/ }),
  2209. /***/ "./node_modules/safevalues/dom/elements/object.js":
  2210. /*!********************************************************!*\
  2211. !*** ./node_modules/safevalues/dom/elements/object.js ***!
  2212. \********************************************************/
  2213. /*! no static exports found */
  2214. /***/ (function(module, exports, __webpack_require__) {
  2215. "use strict";
  2216. /**
  2217. * @license
  2218. * SPDX-License-Identifier: Apache-2.0
  2219. */
  2220. Object.defineProperty(exports, "__esModule", { value: true });
  2221. exports.setData = void 0;
  2222. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2223. /** Sets the data attribute using a TrustedResourceUrl */
  2224. function setData(obj, v) {
  2225. obj.data = (0, resource_url_impl_1.unwrapResourceUrl)(v);
  2226. }
  2227. exports.setData = setData;
  2228. /***/ }),
  2229. /***/ "./node_modules/safevalues/dom/elements/script.js":
  2230. /*!********************************************************!*\
  2231. !*** ./node_modules/safevalues/dom/elements/script.js ***!
  2232. \********************************************************/
  2233. /*! no static exports found */
  2234. /***/ (function(module, exports, __webpack_require__) {
  2235. "use strict";
  2236. /**
  2237. * @license
  2238. * SPDX-License-Identifier: Apache-2.0
  2239. */
  2240. Object.defineProperty(exports, "__esModule", { value: true });
  2241. exports.setSrc = exports.setTextContent = void 0;
  2242. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2243. var script_impl_1 = __webpack_require__(/*! ../../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  2244. /** Returns CSP nonce, if set for any script tag. */
  2245. function getScriptNonceFromWindow(win) {
  2246. var _a;
  2247. var doc = win.document;
  2248. // document.querySelector can be undefined in non-browser environments.
  2249. var script = (_a = doc.querySelector) === null || _a === void 0 ? void 0 : _a.call(doc, 'script[nonce]');
  2250. if (script) {
  2251. // Try to get the nonce from the IDL property first, because browsers that
  2252. // implement additional nonce protection features (currently only Chrome) to
  2253. // prevent nonce stealing via CSS do not expose the nonce via attributes.
  2254. // See https://github.com/whatwg/html/issues/2369
  2255. return script['nonce'] || script.getAttribute('nonce') || '';
  2256. }
  2257. return '';
  2258. }
  2259. /** Propagates CSP nonce to dynamically created scripts. */
  2260. function setNonceForScriptElement(script) {
  2261. var win = script.ownerDocument && script.ownerDocument.defaultView;
  2262. var nonce = getScriptNonceFromWindow(win || window);
  2263. if (nonce) {
  2264. script.setAttribute('nonce', nonce);
  2265. }
  2266. }
  2267. /** Sets textContent from the given SafeScript. */
  2268. function setTextContent(script, v) {
  2269. script.textContent = (0, script_impl_1.unwrapScript)(v);
  2270. setNonceForScriptElement(script);
  2271. }
  2272. exports.setTextContent = setTextContent;
  2273. /** Sets the Src attribute using a TrustedResourceUrl */
  2274. function setSrc(script, v) {
  2275. script.src = (0, resource_url_impl_1.unwrapResourceUrl)(v);
  2276. setNonceForScriptElement(script);
  2277. }
  2278. exports.setSrc = setSrc;
  2279. /***/ }),
  2280. /***/ "./node_modules/safevalues/dom/elements/style.js":
  2281. /*!*******************************************************!*\
  2282. !*** ./node_modules/safevalues/dom/elements/style.js ***!
  2283. \*******************************************************/
  2284. /*! no static exports found */
  2285. /***/ (function(module, exports, __webpack_require__) {
  2286. "use strict";
  2287. /**
  2288. * @license
  2289. * SPDX-License-Identifier: Apache-2.0
  2290. */
  2291. Object.defineProperty(exports, "__esModule", { value: true });
  2292. exports.setTextContent = void 0;
  2293. var style_sheet_impl_1 = __webpack_require__(/*! ../../internals/style_sheet_impl */ "./node_modules/safevalues/internals/style_sheet_impl.js");
  2294. /** Safe setters for `HTMLStyleElement`s. */
  2295. function setTextContent(elem, safeStyleSheet) {
  2296. elem.textContent = (0, style_sheet_impl_1.unwrapStyleSheet)(safeStyleSheet);
  2297. }
  2298. exports.setTextContent = setTextContent;
  2299. /***/ }),
  2300. /***/ "./node_modules/safevalues/dom/globals/document.js":
  2301. /*!*********************************************************!*\
  2302. !*** ./node_modules/safevalues/dom/globals/document.js ***!
  2303. \*********************************************************/
  2304. /*! no static exports found */
  2305. /***/ (function(module, exports, __webpack_require__) {
  2306. "use strict";
  2307. /**
  2308. * @license
  2309. * SPDX-License-Identifier: Apache-2.0
  2310. */
  2311. Object.defineProperty(exports, "__esModule", { value: true });
  2312. exports.execCommandInsertHtml = exports.execCommand = exports.write = void 0;
  2313. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2314. /**
  2315. * write safely calls {@link Document.write} on the given {@link Document} with
  2316. * the given {@link SafeHtml}.
  2317. */
  2318. function write(doc, text) {
  2319. doc.write((0, html_impl_1.unwrapHtml)(text));
  2320. }
  2321. exports.write = write;
  2322. /**
  2323. * Safely calls {@link Document.execCommand}. When command is insertHtml, a
  2324. * SafeHtml must be passed in as value.
  2325. */
  2326. function execCommand(doc, command, value) {
  2327. var commandString = String(command);
  2328. var valueArgument = value;
  2329. if (commandString.toLowerCase() === 'inserthtml') {
  2330. valueArgument = (0, html_impl_1.unwrapHtml)(value);
  2331. }
  2332. return doc.execCommand(commandString, /* showUi= */ false, valueArgument);
  2333. }
  2334. exports.execCommand = execCommand;
  2335. /**
  2336. * Safely calls {@link Document.execCommand}('insertHtml').
  2337. * @deprecated Use safeDocument.execCommand.
  2338. */
  2339. function execCommandInsertHtml(doc, html) {
  2340. return doc.execCommand('insertHTML', /* showUi= */ false, (0, html_impl_1.unwrapHtml)(html));
  2341. }
  2342. exports.execCommandInsertHtml = execCommandInsertHtml;
  2343. /***/ }),
  2344. /***/ "./node_modules/safevalues/dom/globals/dom_parser.js":
  2345. /*!***********************************************************!*\
  2346. !*** ./node_modules/safevalues/dom/globals/dom_parser.js ***!
  2347. \***********************************************************/
  2348. /*! no static exports found */
  2349. /***/ (function(module, exports, __webpack_require__) {
  2350. "use strict";
  2351. /**
  2352. * @license
  2353. * SPDX-License-Identifier: Apache-2.0
  2354. */
  2355. Object.defineProperty(exports, "__esModule", { value: true });
  2356. exports.parseFromString = exports.parseHtml = void 0;
  2357. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2358. /** Safely parses a string using the HTML parser. */
  2359. function parseHtml(parser, html) {
  2360. return parseFromString(parser, html, 'text/html');
  2361. }
  2362. exports.parseHtml = parseHtml;
  2363. /** Safely parses a string using the HTML or XML parser. */
  2364. function parseFromString(parser, content, contentType) {
  2365. return parser.parseFromString((0, html_impl_1.unwrapHtml)(content), contentType);
  2366. }
  2367. exports.parseFromString = parseFromString;
  2368. /***/ }),
  2369. /***/ "./node_modules/safevalues/dom/globals/global.js":
  2370. /*!*******************************************************!*\
  2371. !*** ./node_modules/safevalues/dom/globals/global.js ***!
  2372. \*******************************************************/
  2373. /*! no static exports found */
  2374. /***/ (function(module, exports, __webpack_require__) {
  2375. "use strict";
  2376. /**
  2377. * @license
  2378. * SPDX-License-Identifier: Apache-2.0
  2379. */
  2380. Object.defineProperty(exports, "__esModule", { value: true });
  2381. exports.globalEval = void 0;
  2382. var script_impl_1 = __webpack_require__(/*! ../../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  2383. /**
  2384. * Evaluates a SafeScript value in the given scope using eval.
  2385. *
  2386. * Strongly consider avoiding this, as eval blocks CSP adoption and does not
  2387. * benefit from compiler optimizations.
  2388. */
  2389. function globalEval(win, script) {
  2390. var trustedScript = (0, script_impl_1.unwrapScript)(script);
  2391. var result = win.eval(trustedScript);
  2392. if (result === trustedScript) {
  2393. // https://crbug.com/1024786 manifesting in workers.
  2394. result = win.eval(trustedScript.toString());
  2395. }
  2396. return result;
  2397. }
  2398. exports.globalEval = globalEval;
  2399. /***/ }),
  2400. /***/ "./node_modules/safevalues/dom/globals/location.js":
  2401. /*!*********************************************************!*\
  2402. !*** ./node_modules/safevalues/dom/globals/location.js ***!
  2403. \*********************************************************/
  2404. /*! no static exports found */
  2405. /***/ (function(module, exports, __webpack_require__) {
  2406. "use strict";
  2407. /**
  2408. * @license
  2409. * SPDX-License-Identifier: Apache-2.0
  2410. */
  2411. Object.defineProperty(exports, "__esModule", { value: true });
  2412. exports.assign = exports.replace = exports.setHref = void 0;
  2413. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2414. /**
  2415. * setHref safely sets {@link Location.href} on the given {@link Location} with
  2416. * given {@link Url}.
  2417. */
  2418. function setHref(loc, url) {
  2419. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2420. if (sanitizedUrl !== undefined) {
  2421. loc.href = sanitizedUrl;
  2422. }
  2423. }
  2424. exports.setHref = setHref;
  2425. /**
  2426. * replace safely calls {@link Location.replace} on the given {@link Location}
  2427. * with given {@link Url}.
  2428. */
  2429. function replace(loc, url) {
  2430. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2431. if (sanitizedUrl !== undefined) {
  2432. loc.replace(sanitizedUrl);
  2433. }
  2434. }
  2435. exports.replace = replace;
  2436. /**
  2437. * assign safely calls {@link Location.assign} on the given {@link Location}
  2438. * with given {@link Url}.
  2439. */
  2440. function assign(loc, url) {
  2441. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2442. if (sanitizedUrl !== undefined) {
  2443. loc.assign(sanitizedUrl);
  2444. }
  2445. }
  2446. exports.assign = assign;
  2447. /***/ }),
  2448. /***/ "./node_modules/safevalues/dom/globals/range.js":
  2449. /*!******************************************************!*\
  2450. !*** ./node_modules/safevalues/dom/globals/range.js ***!
  2451. \******************************************************/
  2452. /*! no static exports found */
  2453. /***/ (function(module, exports, __webpack_require__) {
  2454. "use strict";
  2455. /**
  2456. * @license
  2457. * SPDX-License-Identifier: Apache-2.0
  2458. */
  2459. Object.defineProperty(exports, "__esModule", { value: true });
  2460. exports.createContextualFragment = void 0;
  2461. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2462. /** Safely creates a contextualFragment. */
  2463. function createContextualFragment(range, html) {
  2464. return range.createContextualFragment((0, html_impl_1.unwrapHtml)(html));
  2465. }
  2466. exports.createContextualFragment = createContextualFragment;
  2467. /***/ }),
  2468. /***/ "./node_modules/safevalues/dom/globals/service_worker_container.js":
  2469. /*!*************************************************************************!*\
  2470. !*** ./node_modules/safevalues/dom/globals/service_worker_container.js ***!
  2471. \*************************************************************************/
  2472. /*! no static exports found */
  2473. /***/ (function(module, exports, __webpack_require__) {
  2474. "use strict";
  2475. /**
  2476. * @license
  2477. * SPDX-License-Identifier: Apache-2.0
  2478. */
  2479. Object.defineProperty(exports, "__esModule", { value: true });
  2480. exports.register = void 0;
  2481. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2482. /** Safely registers a service worker by URL */
  2483. function register(container, scriptURL, options) {
  2484. return container.register((0, resource_url_impl_1.unwrapResourceUrl)(scriptURL), options);
  2485. }
  2486. exports.register = register;
  2487. /***/ }),
  2488. /***/ "./node_modules/safevalues/dom/globals/window.js":
  2489. /*!*******************************************************!*\
  2490. !*** ./node_modules/safevalues/dom/globals/window.js ***!
  2491. \*******************************************************/
  2492. /*! no static exports found */
  2493. /***/ (function(module, exports, __webpack_require__) {
  2494. "use strict";
  2495. /**
  2496. * @license
  2497. * SPDX-License-Identifier: Apache-2.0
  2498. */
  2499. Object.defineProperty(exports, "__esModule", { value: true });
  2500. exports.open = void 0;
  2501. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2502. /**
  2503. * open calls {@link Window.open} on the given {@link Window}, given a
  2504. * target {@link Url}.
  2505. */
  2506. function open(win, url, target, features) {
  2507. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2508. if (sanitizedUrl !== undefined) {
  2509. return win.open(sanitizedUrl, target, features);
  2510. }
  2511. return null;
  2512. }
  2513. exports.open = open;
  2514. /***/ }),
  2515. /***/ "./node_modules/safevalues/dom/globals/worker.js":
  2516. /*!*******************************************************!*\
  2517. !*** ./node_modules/safevalues/dom/globals/worker.js ***!
  2518. \*******************************************************/
  2519. /*! no static exports found */
  2520. /***/ (function(module, exports, __webpack_require__) {
  2521. "use strict";
  2522. /**
  2523. * @license
  2524. * SPDX-License-Identifier: Apache-2.0
  2525. */
  2526. var __read = (this && this.__read) || function (o, n) {
  2527. var m = typeof Symbol === "function" && o[Symbol.iterator];
  2528. if (!m) return o;
  2529. var i = m.call(o), r, ar = [], e;
  2530. try {
  2531. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  2532. }
  2533. catch (error) { e = { error: error }; }
  2534. finally {
  2535. try {
  2536. if (r && !r.done && (m = i["return"])) m.call(i);
  2537. }
  2538. finally { if (e) throw e.error; }
  2539. }
  2540. return ar;
  2541. };
  2542. var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
  2543. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  2544. if (ar || !(i in from)) {
  2545. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  2546. ar[i] = from[i];
  2547. }
  2548. }
  2549. return to.concat(ar || Array.prototype.slice.call(from));
  2550. };
  2551. Object.defineProperty(exports, "__esModule", { value: true });
  2552. exports.importScripts = exports.createShared = exports.create = void 0;
  2553. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2554. /**
  2555. * Safely creates a Web Worker.
  2556. *
  2557. * Example usage:
  2558. * const trustedResourceUrl = trustedResourceUrl`/safe_script.js`;
  2559. * safedom.safeWorker.create(trustedResourceUrl);
  2560. * which is a safe alternative to
  2561. * new Worker(url);
  2562. * The latter can result in loading untrusted code.
  2563. */
  2564. function create(url, options) {
  2565. return new Worker((0, resource_url_impl_1.unwrapResourceUrl)(url), options);
  2566. }
  2567. exports.create = create;
  2568. /** Safely creates a shared Web Worker. */
  2569. function createShared(url, options) {
  2570. return new SharedWorker((0, resource_url_impl_1.unwrapResourceUrl)(url), options);
  2571. }
  2572. exports.createShared = createShared;
  2573. /** Safely calls importScripts */
  2574. function importScripts(scope) {
  2575. var urls = [];
  2576. for (var _i = 1; _i < arguments.length; _i++) {
  2577. urls[_i - 1] = arguments[_i];
  2578. }
  2579. scope.importScripts.apply(scope, __spreadArray([], __read(urls.map(function (url) { return (0, resource_url_impl_1.unwrapResourceUrl)(url); })), false));
  2580. }
  2581. exports.importScripts = importScripts;
  2582. /***/ }),
  2583. /***/ "./node_modules/safevalues/dom/index.js":
  2584. /*!**********************************************!*\
  2585. !*** ./node_modules/safevalues/dom/index.js ***!
  2586. \**********************************************/
  2587. /*! no static exports found */
  2588. /***/ (function(module, exports, __webpack_require__) {
  2589. "use strict";
  2590. /**
  2591. * @license
  2592. * SPDX-License-Identifier: Apache-2.0
  2593. */
  2594. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  2595. if (k2 === undefined) k2 = k;
  2596. var desc = Object.getOwnPropertyDescriptor(m, k);
  2597. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  2598. desc = { enumerable: true, get: function() { return m[k]; } };
  2599. }
  2600. Object.defineProperty(o, k2, desc);
  2601. }) : (function(o, m, k, k2) {
  2602. if (k2 === undefined) k2 = k;
  2603. o[k2] = m[k];
  2604. }));
  2605. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  2606. Object.defineProperty(o, "default", { enumerable: true, value: v });
  2607. }) : function(o, v) {
  2608. o["default"] = v;
  2609. });
  2610. var __importStar = (this && this.__importStar) || function (mod) {
  2611. if (mod && mod.__esModule) return mod;
  2612. var result = {};
  2613. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  2614. __setModuleDefault(result, mod);
  2615. return result;
  2616. };
  2617. Object.defineProperty(exports, "__esModule", { value: true });
  2618. exports.safeWorker = exports.safeWindow = exports.safeServiceWorkerContainer = exports.safeRange = exports.safeLocation = exports.safeGlobal = exports.safeDomParser = exports.safeDocument = exports.safeStyleEl = exports.safeScriptEl = exports.safeObjectEl = exports.safeLinkEl = exports.safeInputEl = exports.safeIframeEl = exports.safeFormEl = exports.safeEmbedEl = exports.safeElement = exports.safeButtonEl = exports.safeAreaEl = exports.safeAnchorEl = void 0;
  2619. /**
  2620. * @fileoverview This file re-exports all of the wrappers to ensure that we have
  2621. * a clearly defined interface.
  2622. */
  2623. exports.safeAnchorEl = __importStar(__webpack_require__(/*! ./elements/anchor */ "./node_modules/safevalues/dom/elements/anchor.js"));
  2624. exports.safeAreaEl = __importStar(__webpack_require__(/*! ./elements/area */ "./node_modules/safevalues/dom/elements/area.js"));
  2625. exports.safeButtonEl = __importStar(__webpack_require__(/*! ./elements/button */ "./node_modules/safevalues/dom/elements/button.js"));
  2626. exports.safeElement = __importStar(__webpack_require__(/*! ./elements/element */ "./node_modules/safevalues/dom/elements/element.js"));
  2627. exports.safeEmbedEl = __importStar(__webpack_require__(/*! ./elements/embed */ "./node_modules/safevalues/dom/elements/embed.js"));
  2628. exports.safeFormEl = __importStar(__webpack_require__(/*! ./elements/form */ "./node_modules/safevalues/dom/elements/form.js"));
  2629. exports.safeIframeEl = __importStar(__webpack_require__(/*! ./elements/iframe */ "./node_modules/safevalues/dom/elements/iframe.js"));
  2630. exports.safeInputEl = __importStar(__webpack_require__(/*! ./elements/input */ "./node_modules/safevalues/dom/elements/input.js"));
  2631. exports.safeLinkEl = __importStar(__webpack_require__(/*! ./elements/link */ "./node_modules/safevalues/dom/elements/link.js"));
  2632. exports.safeObjectEl = __importStar(__webpack_require__(/*! ./elements/object */ "./node_modules/safevalues/dom/elements/object.js"));
  2633. exports.safeScriptEl = __importStar(__webpack_require__(/*! ./elements/script */ "./node_modules/safevalues/dom/elements/script.js"));
  2634. exports.safeStyleEl = __importStar(__webpack_require__(/*! ./elements/style */ "./node_modules/safevalues/dom/elements/style.js"));
  2635. exports.safeDocument = __importStar(__webpack_require__(/*! ./globals/document */ "./node_modules/safevalues/dom/globals/document.js"));
  2636. exports.safeDomParser = __importStar(__webpack_require__(/*! ./globals/dom_parser */ "./node_modules/safevalues/dom/globals/dom_parser.js"));
  2637. exports.safeGlobal = __importStar(__webpack_require__(/*! ./globals/global */ "./node_modules/safevalues/dom/globals/global.js"));
  2638. exports.safeLocation = __importStar(__webpack_require__(/*! ./globals/location */ "./node_modules/safevalues/dom/globals/location.js"));
  2639. exports.safeRange = __importStar(__webpack_require__(/*! ./globals/range */ "./node_modules/safevalues/dom/globals/range.js"));
  2640. exports.safeServiceWorkerContainer = __importStar(__webpack_require__(/*! ./globals/service_worker_container */ "./node_modules/safevalues/dom/globals/service_worker_container.js"));
  2641. exports.safeWindow = __importStar(__webpack_require__(/*! ./globals/window */ "./node_modules/safevalues/dom/globals/window.js"));
  2642. exports.safeWorker = __importStar(__webpack_require__(/*! ./globals/worker */ "./node_modules/safevalues/dom/globals/worker.js"));
  2643. /***/ }),
  2644. /***/ "./node_modules/safevalues/environment/dev.js":
  2645. /*!****************************************************!*\
  2646. !*** ./node_modules/safevalues/environment/dev.js ***!
  2647. \****************************************************/
  2648. /*! no static exports found */
  2649. /***/ (function(module, exports, __webpack_require__) {
  2650. "use strict";
  2651. /* WEBPACK VAR INJECTION */(function(process) {
  2652. /**
  2653. * @license
  2654. * SPDX-License-Identifier: Apache-2.0
  2655. */
  2656. /**
  2657. * Ensure process.env.NODE_ENV is set even when not running under Webpack or
  2658. * Node. Terser will strip this out of production binaries.
  2659. */
  2660. /*#__PURE__*/ (function () {
  2661. if (typeof process === 'undefined') {
  2662. window.process = { env: { NODE_ENV: 'development' } };
  2663. }
  2664. })();
  2665. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  2666. /***/ }),
  2667. /***/ "./node_modules/safevalues/index.js":
  2668. /*!******************************************!*\
  2669. !*** ./node_modules/safevalues/index.js ***!
  2670. \******************************************/
  2671. /*! no static exports found */
  2672. /***/ (function(module, exports, __webpack_require__) {
  2673. "use strict";
  2674. /**
  2675. * @license
  2676. * SPDX-License-Identifier: Apache-2.0
  2677. */
  2678. Object.defineProperty(exports, "__esModule", { value: true });
  2679. exports.unwrapStyleSheet = exports.SafeStyleSheet = exports.isStyleSheet = exports.unwrapStyle = exports.SafeStyle = exports.isStyle = exports.unwrapScript = exports.SafeScript = exports.isScript = exports.EMPTY_SCRIPT = exports.unwrapResourceUrl = exports.TrustedResourceUrl = exports.isResourceUrl = exports.unwrapHtml = exports.SafeHtml = exports.isHtml = exports.EMPTY_HTML = exports.unwrapAttributePrefix = exports.SafeAttributePrefix = exports.safeStyleSheet = exports.concatStyleSheets = exports.safeStyle = exports.concatStyles = exports.scriptFromJson = exports.safeScriptWithArgs = exports.safeScript = exports.concatScripts = exports.trustedResourceUrl = exports.replaceFragment = exports.blobUrlFromScript = exports.appendParams = exports.HtmlSanitizerBuilder = exports.sanitizeHtmlToFragment = exports.sanitizeHtmlAssertUnchanged = exports.sanitizeHtml = exports.htmlEscape = exports.createScriptSrc = exports.createScript = exports.concatHtmls = exports.safeAttrPrefix = void 0;
  2680. /** Safe builders */
  2681. var attribute_builders_1 = __webpack_require__(/*! ./builders/attribute_builders */ "./node_modules/safevalues/builders/attribute_builders.js");
  2682. Object.defineProperty(exports, "safeAttrPrefix", { enumerable: true, get: function () { return attribute_builders_1.safeAttrPrefix; } });
  2683. var html_builders_1 = __webpack_require__(/*! ./builders/html_builders */ "./node_modules/safevalues/builders/html_builders.js");
  2684. Object.defineProperty(exports, "concatHtmls", { enumerable: true, get: function () { return html_builders_1.concatHtmls; } });
  2685. Object.defineProperty(exports, "createScript", { enumerable: true, get: function () { return html_builders_1.createScript; } });
  2686. Object.defineProperty(exports, "createScriptSrc", { enumerable: true, get: function () { return html_builders_1.createScriptSrc; } });
  2687. Object.defineProperty(exports, "htmlEscape", { enumerable: true, get: function () { return html_builders_1.htmlEscape; } });
  2688. var html_sanitizer_1 = __webpack_require__(/*! ./builders/html_sanitizer/html_sanitizer */ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js");
  2689. Object.defineProperty(exports, "sanitizeHtml", { enumerable: true, get: function () { return html_sanitizer_1.sanitizeHtml; } });
  2690. Object.defineProperty(exports, "sanitizeHtmlAssertUnchanged", { enumerable: true, get: function () { return html_sanitizer_1.sanitizeHtmlAssertUnchanged; } });
  2691. Object.defineProperty(exports, "sanitizeHtmlToFragment", { enumerable: true, get: function () { return html_sanitizer_1.sanitizeHtmlToFragment; } });
  2692. var html_sanitizer_builder_1 = __webpack_require__(/*! ./builders/html_sanitizer/html_sanitizer_builder */ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer_builder.js");
  2693. Object.defineProperty(exports, "HtmlSanitizerBuilder", { enumerable: true, get: function () { return html_sanitizer_builder_1.HtmlSanitizerBuilder; } });
  2694. var resource_url_builders_1 = __webpack_require__(/*! ./builders/resource_url_builders */ "./node_modules/safevalues/builders/resource_url_builders.js");
  2695. Object.defineProperty(exports, "appendParams", { enumerable: true, get: function () { return resource_url_builders_1.appendParams; } });
  2696. Object.defineProperty(exports, "blobUrlFromScript", { enumerable: true, get: function () { return resource_url_builders_1.blobUrlFromScript; } });
  2697. Object.defineProperty(exports, "replaceFragment", { enumerable: true, get: function () { return resource_url_builders_1.replaceFragment; } });
  2698. Object.defineProperty(exports, "trustedResourceUrl", { enumerable: true, get: function () { return resource_url_builders_1.trustedResourceUrl; } });
  2699. var script_builders_1 = __webpack_require__(/*! ./builders/script_builders */ "./node_modules/safevalues/builders/script_builders.js");
  2700. Object.defineProperty(exports, "concatScripts", { enumerable: true, get: function () { return script_builders_1.concatScripts; } });
  2701. Object.defineProperty(exports, "safeScript", { enumerable: true, get: function () { return script_builders_1.safeScript; } });
  2702. Object.defineProperty(exports, "safeScriptWithArgs", { enumerable: true, get: function () { return script_builders_1.safeScriptWithArgs; } });
  2703. Object.defineProperty(exports, "scriptFromJson", { enumerable: true, get: function () { return script_builders_1.scriptFromJson; } });
  2704. var style_builders_1 = __webpack_require__(/*! ./builders/style_builders */ "./node_modules/safevalues/builders/style_builders.js");
  2705. Object.defineProperty(exports, "concatStyles", { enumerable: true, get: function () { return style_builders_1.concatStyles; } });
  2706. Object.defineProperty(exports, "safeStyle", { enumerable: true, get: function () { return style_builders_1.safeStyle; } });
  2707. var style_sheet_builders_1 = __webpack_require__(/*! ./builders/style_sheet_builders */ "./node_modules/safevalues/builders/style_sheet_builders.js");
  2708. Object.defineProperty(exports, "concatStyleSheets", { enumerable: true, get: function () { return style_sheet_builders_1.concatStyleSheets; } });
  2709. Object.defineProperty(exports, "safeStyleSheet", { enumerable: true, get: function () { return style_sheet_builders_1.safeStyleSheet; } });
  2710. /** Types, constants and unwrappers */
  2711. var attribute_impl_1 = __webpack_require__(/*! ./internals/attribute_impl */ "./node_modules/safevalues/internals/attribute_impl.js");
  2712. Object.defineProperty(exports, "SafeAttributePrefix", { enumerable: true, get: function () { return attribute_impl_1.SafeAttributePrefix; } });
  2713. Object.defineProperty(exports, "unwrapAttributePrefix", { enumerable: true, get: function () { return attribute_impl_1.unwrapAttributePrefix; } });
  2714. var html_impl_1 = __webpack_require__(/*! ./internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2715. Object.defineProperty(exports, "EMPTY_HTML", { enumerable: true, get: function () { return html_impl_1.EMPTY_HTML; } });
  2716. Object.defineProperty(exports, "isHtml", { enumerable: true, get: function () { return html_impl_1.isHtml; } });
  2717. Object.defineProperty(exports, "SafeHtml", { enumerable: true, get: function () { return html_impl_1.SafeHtml; } });
  2718. Object.defineProperty(exports, "unwrapHtml", { enumerable: true, get: function () { return html_impl_1.unwrapHtml; } });
  2719. var resource_url_impl_1 = __webpack_require__(/*! ./internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2720. Object.defineProperty(exports, "isResourceUrl", { enumerable: true, get: function () { return resource_url_impl_1.isResourceUrl; } });
  2721. Object.defineProperty(exports, "TrustedResourceUrl", { enumerable: true, get: function () { return resource_url_impl_1.TrustedResourceUrl; } });
  2722. Object.defineProperty(exports, "unwrapResourceUrl", { enumerable: true, get: function () { return resource_url_impl_1.unwrapResourceUrl; } });
  2723. var script_impl_1 = __webpack_require__(/*! ./internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  2724. Object.defineProperty(exports, "EMPTY_SCRIPT", { enumerable: true, get: function () { return script_impl_1.EMPTY_SCRIPT; } });
  2725. Object.defineProperty(exports, "isScript", { enumerable: true, get: function () { return script_impl_1.isScript; } });
  2726. Object.defineProperty(exports, "SafeScript", { enumerable: true, get: function () { return script_impl_1.SafeScript; } });
  2727. Object.defineProperty(exports, "unwrapScript", { enumerable: true, get: function () { return script_impl_1.unwrapScript; } });
  2728. var style_impl_1 = __webpack_require__(/*! ./internals/style_impl */ "./node_modules/safevalues/internals/style_impl.js");
  2729. Object.defineProperty(exports, "isStyle", { enumerable: true, get: function () { return style_impl_1.isStyle; } });
  2730. Object.defineProperty(exports, "SafeStyle", { enumerable: true, get: function () { return style_impl_1.SafeStyle; } });
  2731. Object.defineProperty(exports, "unwrapStyle", { enumerable: true, get: function () { return style_impl_1.unwrapStyle; } });
  2732. var style_sheet_impl_1 = __webpack_require__(/*! ./internals/style_sheet_impl */ "./node_modules/safevalues/internals/style_sheet_impl.js");
  2733. Object.defineProperty(exports, "isStyleSheet", { enumerable: true, get: function () { return style_sheet_impl_1.isStyleSheet; } });
  2734. Object.defineProperty(exports, "SafeStyleSheet", { enumerable: true, get: function () { return style_sheet_impl_1.SafeStyleSheet; } });
  2735. Object.defineProperty(exports, "unwrapStyleSheet", { enumerable: true, get: function () { return style_sheet_impl_1.unwrapStyleSheet; } });
  2736. /***/ }),
  2737. /***/ "./node_modules/safevalues/internals/attribute_impl.js":
  2738. /*!*************************************************************!*\
  2739. !*** ./node_modules/safevalues/internals/attribute_impl.js ***!
  2740. \*************************************************************/
  2741. /*! no static exports found */
  2742. /***/ (function(module, exports, __webpack_require__) {
  2743. "use strict";
  2744. /**
  2745. * @license
  2746. * SPDX-License-Identifier: Apache-2.0
  2747. */
  2748. var __extends = (this && this.__extends) || (function () {
  2749. var extendStatics = function (d, b) {
  2750. extendStatics = Object.setPrototypeOf ||
  2751. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2752. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  2753. return extendStatics(d, b);
  2754. };
  2755. return function (d, b) {
  2756. if (typeof b !== "function" && b !== null)
  2757. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  2758. extendStatics(d, b);
  2759. function __() { this.constructor = d; }
  2760. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2761. };
  2762. })();
  2763. Object.defineProperty(exports, "__esModule", { value: true });
  2764. exports.unwrapAttributePrefix = exports.createAttributePrefix = exports.SafeAttributePrefix = void 0;
  2765. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  2766. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  2767. /** A prefix with which an attribute is safe to set using plain strings. */
  2768. var SafeAttributePrefix = /** @class */ (function () {
  2769. function SafeAttributePrefix() {
  2770. }
  2771. return SafeAttributePrefix;
  2772. }());
  2773. exports.SafeAttributePrefix = SafeAttributePrefix;
  2774. /** Implementation for `SafeAttributePrefix` */
  2775. var AttributePrefixImpl = /** @class */ (function (_super) {
  2776. __extends(AttributePrefixImpl, _super);
  2777. function AttributePrefixImpl(attrPrefix, token) {
  2778. var _this = _super.call(this) || this;
  2779. if (true) {
  2780. (0, secrets_1.ensureTokenIsValid)(token);
  2781. }
  2782. _this.privateDoNotAccessOrElseWrappedAttrPrefix = attrPrefix;
  2783. return _this;
  2784. }
  2785. AttributePrefixImpl.prototype.toString = function () {
  2786. return this.privateDoNotAccessOrElseWrappedAttrPrefix;
  2787. };
  2788. return AttributePrefixImpl;
  2789. }(SafeAttributePrefix));
  2790. /**
  2791. * Builds a new `SafeAttribute` from the given string, without enforcing
  2792. * safety guarantees. This shouldn't be exposed to application developers, and
  2793. * must only be used as a step towards safe builders or safe constants.
  2794. */
  2795. function createAttributePrefix(attrPrefix) {
  2796. return new AttributePrefixImpl(attrPrefix, secrets_1.secretToken);
  2797. }
  2798. exports.createAttributePrefix = createAttributePrefix;
  2799. /**
  2800. * Returns the string value of the passed `SafeAttributePrefix` object while
  2801. * ensuring it has the correct type.
  2802. */
  2803. function unwrapAttributePrefix(value) {
  2804. if (value instanceof AttributePrefixImpl) {
  2805. return value.privateDoNotAccessOrElseWrappedAttrPrefix;
  2806. }
  2807. else {
  2808. var message = '';
  2809. if (true) {
  2810. message = 'Unexpected type when unwrapping SafeAttributePrefix';
  2811. }
  2812. throw new Error(message);
  2813. }
  2814. }
  2815. exports.unwrapAttributePrefix = unwrapAttributePrefix;
  2816. /***/ }),
  2817. /***/ "./node_modules/safevalues/internals/html_impl.js":
  2818. /*!********************************************************!*\
  2819. !*** ./node_modules/safevalues/internals/html_impl.js ***!
  2820. \********************************************************/
  2821. /*! no static exports found */
  2822. /***/ (function(module, exports, __webpack_require__) {
  2823. "use strict";
  2824. /**
  2825. * @license
  2826. * SPDX-License-Identifier: Apache-2.0
  2827. */
  2828. Object.defineProperty(exports, "__esModule", { value: true });
  2829. exports.unwrapHtml = exports.isHtml = exports.EMPTY_HTML = exports.createHtml = exports.SafeHtml = void 0;
  2830. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  2831. /* g3_import_pure from './pure' */
  2832. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  2833. var trusted_types_1 = __webpack_require__(/*! ./trusted_types */ "./node_modules/safevalues/internals/trusted_types.js");
  2834. /**
  2835. * Runtime implementation of `TrustedHTML` in browsers that don't support it.
  2836. */
  2837. var HtmlImpl = /** @class */ (function () {
  2838. function HtmlImpl(html, token) {
  2839. if (true) {
  2840. (0, secrets_1.ensureTokenIsValid)(token);
  2841. }
  2842. this.privateDoNotAccessOrElseWrappedHtml = html;
  2843. }
  2844. HtmlImpl.prototype.toString = function () {
  2845. return this.privateDoNotAccessOrElseWrappedHtml.toString();
  2846. };
  2847. return HtmlImpl;
  2848. }());
  2849. function createHtmlInternal(html, trusted) {
  2850. return (trusted !== null && trusted !== void 0 ? trusted : new HtmlImpl(html, secrets_1.secretToken));
  2851. }
  2852. var GlobalTrustedHTML = (typeof window !== undefined) ? window.TrustedHTML : undefined;
  2853. /**
  2854. * Also exports the constructor so that instanceof checks work.
  2855. */
  2856. exports.SafeHtml = (GlobalTrustedHTML !== null && GlobalTrustedHTML !== void 0 ? GlobalTrustedHTML : HtmlImpl);
  2857. /**
  2858. * Builds a new `SafeHtml` from the given string, without enforcing safety
  2859. * guarantees. It may cause side effects by creating a Trusted Types policy.
  2860. * This shouldn't be exposed to application developers, and must only be used as
  2861. * a step towards safe builders or safe constants.
  2862. */
  2863. function createHtml(html) {
  2864. var _a;
  2865. /** @noinline */
  2866. var noinlineHtml = html;
  2867. return createHtmlInternal(noinlineHtml, (_a = (0, trusted_types_1.getTrustedTypesPolicy)()) === null || _a === void 0 ? void 0 : _a.createHTML(noinlineHtml));
  2868. }
  2869. exports.createHtml = createHtml;
  2870. /**
  2871. * An empty `SafeHtml` constant.
  2872. * Unlike the function above, using this will not create a policy.
  2873. */
  2874. exports.EMPTY_HTML =
  2875. /* #__PURE__ */ (function () { var _a; return createHtmlInternal('', (_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.emptyHTML); })();
  2876. /**
  2877. * Checks if the given value is a `SafeHtml` instance.
  2878. */
  2879. function isHtml(value) {
  2880. return value instanceof exports.SafeHtml;
  2881. }
  2882. exports.isHtml = isHtml;
  2883. /**
  2884. * Returns the value of the passed `SafeHtml` object while ensuring it
  2885. * has the correct type.
  2886. *
  2887. * Returns a native `TrustedHTML` or a string if Trusted Types are disabled.
  2888. */
  2889. function unwrapHtml(value) {
  2890. var _a;
  2891. if ((_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.isHTML(value)) {
  2892. return value;
  2893. }
  2894. else if (value instanceof HtmlImpl) {
  2895. return value.privateDoNotAccessOrElseWrappedHtml;
  2896. }
  2897. else {
  2898. var message = '';
  2899. if (true) {
  2900. message = 'Unexpected type when unwrapping SafeHtml';
  2901. }
  2902. throw new Error(message);
  2903. }
  2904. }
  2905. exports.unwrapHtml = unwrapHtml;
  2906. /***/ }),
  2907. /***/ "./node_modules/safevalues/internals/resource_url_impl.js":
  2908. /*!****************************************************************!*\
  2909. !*** ./node_modules/safevalues/internals/resource_url_impl.js ***!
  2910. \****************************************************************/
  2911. /*! no static exports found */
  2912. /***/ (function(module, exports, __webpack_require__) {
  2913. "use strict";
  2914. /**
  2915. * @license
  2916. * SPDX-License-Identifier: Apache-2.0
  2917. */
  2918. Object.defineProperty(exports, "__esModule", { value: true });
  2919. exports.unwrapResourceUrl = exports.isResourceUrl = exports.createResourceUrl = exports.TrustedResourceUrl = void 0;
  2920. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  2921. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  2922. var trusted_types_1 = __webpack_require__(/*! ./trusted_types */ "./node_modules/safevalues/internals/trusted_types.js");
  2923. /**
  2924. * Runtime implementation of `TrustedScriptURL` in browsers that don't support
  2925. * it.
  2926. */
  2927. var ResourceUrlImpl = /** @class */ (function () {
  2928. function ResourceUrlImpl(url, token) {
  2929. if (true) {
  2930. (0, secrets_1.ensureTokenIsValid)(token);
  2931. }
  2932. this.privateDoNotAccessOrElseWrappedResourceUrl = url;
  2933. }
  2934. ResourceUrlImpl.prototype.toString = function () {
  2935. return this.privateDoNotAccessOrElseWrappedResourceUrl.toString();
  2936. };
  2937. return ResourceUrlImpl;
  2938. }());
  2939. var GlobalTrustedScriptURL = (typeof window !== undefined) ? window.TrustedScriptURL : undefined;
  2940. /**
  2941. * Also exports the constructor so that instanceof checks work.
  2942. */
  2943. exports.TrustedResourceUrl = (GlobalTrustedScriptURL !== null && GlobalTrustedScriptURL !== void 0 ? GlobalTrustedScriptURL : ResourceUrlImpl);
  2944. /**
  2945. * Builds a new `TrustedResourceUrl` from the given string, without
  2946. * enforcing safety guarantees. It may cause side effects by creating a Trusted
  2947. * Types policy. This shouldn't be exposed to application developers, and must
  2948. * only be used as a step towards safe builders or safe constants.
  2949. */
  2950. function createResourceUrl(url) {
  2951. var _a;
  2952. /** @noinline */
  2953. var noinlineUrl = url;
  2954. var trustedScriptURL = (_a = (0, trusted_types_1.getTrustedTypesPolicy)()) === null || _a === void 0 ? void 0 : _a.createScriptURL(noinlineUrl);
  2955. return (trustedScriptURL !== null && trustedScriptURL !== void 0 ? trustedScriptURL : new ResourceUrlImpl(noinlineUrl, secrets_1.secretToken));
  2956. }
  2957. exports.createResourceUrl = createResourceUrl;
  2958. /**
  2959. * Checks if the given value is a `TrustedResourceUrl` instance.
  2960. */
  2961. function isResourceUrl(value) {
  2962. return value instanceof exports.TrustedResourceUrl;
  2963. }
  2964. exports.isResourceUrl = isResourceUrl;
  2965. /**
  2966. * Returns the value of the passed `TrustedResourceUrl` object while ensuring it
  2967. * has the correct type.
  2968. *
  2969. * Returns a native `TrustedScriptURL` or a string if Trusted Types are
  2970. * disabled.
  2971. */
  2972. function unwrapResourceUrl(value) {
  2973. var _a;
  2974. if ((_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.isScriptURL(value)) {
  2975. return value;
  2976. }
  2977. else if (value instanceof ResourceUrlImpl) {
  2978. return value.privateDoNotAccessOrElseWrappedResourceUrl;
  2979. }
  2980. else {
  2981. var message = '';
  2982. if (true) {
  2983. message = 'Unexpected type when unwrapping TrustedResourceUrl';
  2984. }
  2985. throw new Error(message);
  2986. }
  2987. }
  2988. exports.unwrapResourceUrl = unwrapResourceUrl;
  2989. /***/ }),
  2990. /***/ "./node_modules/safevalues/internals/script_impl.js":
  2991. /*!**********************************************************!*\
  2992. !*** ./node_modules/safevalues/internals/script_impl.js ***!
  2993. \**********************************************************/
  2994. /*! no static exports found */
  2995. /***/ (function(module, exports, __webpack_require__) {
  2996. "use strict";
  2997. /**
  2998. * @license
  2999. * SPDX-License-Identifier: Apache-2.0
  3000. */
  3001. Object.defineProperty(exports, "__esModule", { value: true });
  3002. exports.unwrapScript = exports.isScript = exports.EMPTY_SCRIPT = exports.createScript = exports.SafeScript = void 0;
  3003. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  3004. /* g3_import_pure from './pure' */
  3005. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  3006. var trusted_types_1 = __webpack_require__(/*! ./trusted_types */ "./node_modules/safevalues/internals/trusted_types.js");
  3007. /**
  3008. * Runtime implementation of `TrustedScript` in browswers that don't support it.
  3009. * script element.
  3010. */
  3011. var ScriptImpl = /** @class */ (function () {
  3012. function ScriptImpl(script, token) {
  3013. if (true) {
  3014. (0, secrets_1.ensureTokenIsValid)(token);
  3015. }
  3016. this.privateDoNotAccessOrElseWrappedScript = script;
  3017. }
  3018. ScriptImpl.prototype.toString = function () {
  3019. return this.privateDoNotAccessOrElseWrappedScript.toString();
  3020. };
  3021. return ScriptImpl;
  3022. }());
  3023. function createScriptInternal(script, trusted) {
  3024. return (trusted !== null && trusted !== void 0 ? trusted : new ScriptImpl(script, secrets_1.secretToken));
  3025. }
  3026. var GlobalTrustedScript = (typeof window !== undefined) ? window.TrustedScript : undefined;
  3027. /**
  3028. * Also exports the constructor so that instanceof checks work.
  3029. */
  3030. exports.SafeScript = (GlobalTrustedScript !== null && GlobalTrustedScript !== void 0 ? GlobalTrustedScript : ScriptImpl);
  3031. /**
  3032. * Builds a new `SafeScript` from the given string, without enforcing
  3033. * safety guarantees. It may cause side effects by creating a Trusted Types
  3034. * policy. This shouldn't be exposed to application developers, and must only be
  3035. * used as a step towards safe builders or safe constants.
  3036. */
  3037. function createScript(script) {
  3038. var _a;
  3039. /** @noinline */
  3040. var noinlineScript = script;
  3041. return createScriptInternal(noinlineScript, (_a = (0, trusted_types_1.getTrustedTypesPolicy)()) === null || _a === void 0 ? void 0 : _a.createScript(noinlineScript));
  3042. }
  3043. exports.createScript = createScript;
  3044. /**
  3045. * An empty `SafeScript` constant.
  3046. * Unlike the functions above, using this will not create a policy.
  3047. */
  3048. exports.EMPTY_SCRIPT =
  3049. /* #__PURE__ */ (function () { var _a; return createScriptInternal('', (_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.emptyScript); })();
  3050. /**
  3051. * Checks if the given value is a `SafeScript` instance.
  3052. */
  3053. function isScript(value) {
  3054. return value instanceof exports.SafeScript;
  3055. }
  3056. exports.isScript = isScript;
  3057. /**
  3058. * Returns the value of the passed `SafeScript` object while ensuring it
  3059. * has the correct type.
  3060. *
  3061. * Returns a native `TrustedScript` or a string if Trusted Types are disabled.
  3062. */
  3063. function unwrapScript(value) {
  3064. var _a;
  3065. if ((_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.isScript(value)) {
  3066. return value;
  3067. }
  3068. else if (value instanceof ScriptImpl) {
  3069. return value.privateDoNotAccessOrElseWrappedScript;
  3070. }
  3071. else {
  3072. var message = '';
  3073. if (true) {
  3074. message = 'Unexpected type when unwrapping SafeScript';
  3075. }
  3076. throw new Error(message);
  3077. }
  3078. }
  3079. exports.unwrapScript = unwrapScript;
  3080. /***/ }),
  3081. /***/ "./node_modules/safevalues/internals/secrets.js":
  3082. /*!******************************************************!*\
  3083. !*** ./node_modules/safevalues/internals/secrets.js ***!
  3084. \******************************************************/
  3085. /*! no static exports found */
  3086. /***/ (function(module, exports, __webpack_require__) {
  3087. "use strict";
  3088. /**
  3089. * @license
  3090. * SPDX-License-Identifier: Apache-2.0
  3091. */
  3092. Object.defineProperty(exports, "__esModule", { value: true });
  3093. exports.ensureTokenIsValid = exports.secretToken = void 0;
  3094. /**
  3095. * A secret token that must be passed to safe type constructors. It is only
  3096. * accessible from within safevalues, ensuring that unrestricted safe type
  3097. * creation is only possible within safevalues. In particular, this prevents
  3098. * forgery such as `safeHtmlValue.constructor('javascript:evil')`.
  3099. */
  3100. exports.secretToken = {};
  3101. /**
  3102. * Asserts that the given token matches the secret safevalues token. An
  3103. * exception is thrown if that is not the case.
  3104. */
  3105. function ensureTokenIsValid(token) {
  3106. if (token !== exports.secretToken) {
  3107. throw new Error('Bad secret');
  3108. }
  3109. }
  3110. exports.ensureTokenIsValid = ensureTokenIsValid;
  3111. /***/ }),
  3112. /***/ "./node_modules/safevalues/internals/string_literal.js":
  3113. /*!*************************************************************!*\
  3114. !*** ./node_modules/safevalues/internals/string_literal.js ***!
  3115. \*************************************************************/
  3116. /*! no static exports found */
  3117. /***/ (function(module, exports, __webpack_require__) {
  3118. "use strict";
  3119. /**
  3120. * @license
  3121. * SPDX-License-Identifier: Apache-2.0
  3122. */
  3123. Object.defineProperty(exports, "__esModule", { value: true });
  3124. exports.assertIsTemplateObject = void 0;
  3125. /**
  3126. * An object of type TemplateStringsArray represents the literal part(s) of a
  3127. * template literal. This function checks if a TemplateStringsArray object is
  3128. * actually from a template literal.
  3129. *
  3130. * @param templateObj This contains the literal part of the template literal.
  3131. * @param hasExprs If true, the input template may contain embedded expressions.
  3132. * @param errorMsg The custom error message in case any checks fail.
  3133. */
  3134. function assertIsTemplateObject(templateObj, hasExprs, errorMsg) {
  3135. if (!Array.isArray(templateObj) || !Array.isArray(templateObj.raw) ||
  3136. (!hasExprs && templateObj.length !== 1)) {
  3137. throw new TypeError(errorMsg);
  3138. }
  3139. }
  3140. exports.assertIsTemplateObject = assertIsTemplateObject;
  3141. /***/ }),
  3142. /***/ "./node_modules/safevalues/internals/style_impl.js":
  3143. /*!*********************************************************!*\
  3144. !*** ./node_modules/safevalues/internals/style_impl.js ***!
  3145. \*********************************************************/
  3146. /*! no static exports found */
  3147. /***/ (function(module, exports, __webpack_require__) {
  3148. "use strict";
  3149. /**
  3150. * @license
  3151. * SPDX-License-Identifier: Apache-2.0
  3152. */
  3153. var __extends = (this && this.__extends) || (function () {
  3154. var extendStatics = function (d, b) {
  3155. extendStatics = Object.setPrototypeOf ||
  3156. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3157. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  3158. return extendStatics(d, b);
  3159. };
  3160. return function (d, b) {
  3161. if (typeof b !== "function" && b !== null)
  3162. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  3163. extendStatics(d, b);
  3164. function __() { this.constructor = d; }
  3165. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3166. };
  3167. })();
  3168. Object.defineProperty(exports, "__esModule", { value: true });
  3169. exports.unwrapStyle = exports.isStyle = exports.createStyle = exports.SafeStyle = void 0;
  3170. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  3171. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  3172. /**
  3173. * Sequence of CSS declarations safe to use in style contexts in an HTML
  3174. * document or in DOM APIs.
  3175. */
  3176. var SafeStyle = /** @class */ (function () {
  3177. function SafeStyle() {
  3178. }
  3179. return SafeStyle;
  3180. }());
  3181. exports.SafeStyle = SafeStyle;
  3182. /** Implementation for `SafeStyle` */
  3183. var StyleImpl = /** @class */ (function (_super) {
  3184. __extends(StyleImpl, _super);
  3185. function StyleImpl(style, token) {
  3186. var _this = _super.call(this) || this;
  3187. if (true) {
  3188. (0, secrets_1.ensureTokenIsValid)(token);
  3189. }
  3190. _this.privateDoNotAccessOrElseWrappedStyle = style;
  3191. return _this;
  3192. }
  3193. StyleImpl.prototype.toString = function () {
  3194. return this.privateDoNotAccessOrElseWrappedStyle;
  3195. };
  3196. return StyleImpl;
  3197. }(SafeStyle));
  3198. /**
  3199. * Builds a new `SafeStyle` from the given string, without enforcing
  3200. * safety guarantees. This shouldn't be exposed to application developers, and
  3201. * must only be used as a step towards safe builders or safe constants.
  3202. */
  3203. function createStyle(style) {
  3204. return new StyleImpl(style, secrets_1.secretToken);
  3205. }
  3206. exports.createStyle = createStyle;
  3207. /**
  3208. * Checks if the given value is a `SafeStyle` instance.
  3209. */
  3210. function isStyle(value) {
  3211. return value instanceof StyleImpl;
  3212. }
  3213. exports.isStyle = isStyle;
  3214. /**
  3215. * Returns the string value of the passed `SafeStyle` object while ensuring it
  3216. * has the correct type.
  3217. */
  3218. function unwrapStyle(value) {
  3219. if (value instanceof StyleImpl) {
  3220. return value.privateDoNotAccessOrElseWrappedStyle;
  3221. }
  3222. else {
  3223. var message = '';
  3224. if (true) {
  3225. message = 'Unexpected type when unwrapping SafeStyle';
  3226. }
  3227. throw new Error(message);
  3228. }
  3229. }
  3230. exports.unwrapStyle = unwrapStyle;
  3231. /***/ }),
  3232. /***/ "./node_modules/safevalues/internals/style_sheet_impl.js":
  3233. /*!***************************************************************!*\
  3234. !*** ./node_modules/safevalues/internals/style_sheet_impl.js ***!
  3235. \***************************************************************/
  3236. /*! no static exports found */
  3237. /***/ (function(module, exports, __webpack_require__) {
  3238. "use strict";
  3239. /**
  3240. * @license
  3241. * SPDX-License-Identifier: Apache-2.0
  3242. */
  3243. var __extends = (this && this.__extends) || (function () {
  3244. var extendStatics = function (d, b) {
  3245. extendStatics = Object.setPrototypeOf ||
  3246. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3247. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  3248. return extendStatics(d, b);
  3249. };
  3250. return function (d, b) {
  3251. if (typeof b !== "function" && b !== null)
  3252. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  3253. extendStatics(d, b);
  3254. function __() { this.constructor = d; }
  3255. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3256. };
  3257. })();
  3258. Object.defineProperty(exports, "__esModule", { value: true });
  3259. exports.unwrapStyleSheet = exports.isStyleSheet = exports.createStyleSheet = exports.SafeStyleSheet = void 0;
  3260. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  3261. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  3262. /**
  3263. * A complete CSS style sheet, safe to use in style contexts in an HTML document
  3264. * or DOM APIs.
  3265. */
  3266. var SafeStyleSheet = /** @class */ (function () {
  3267. function SafeStyleSheet() {
  3268. }
  3269. return SafeStyleSheet;
  3270. }());
  3271. exports.SafeStyleSheet = SafeStyleSheet;
  3272. /** Implementation for `SafeStyleSheet` */
  3273. var StyleSheetImpl = /** @class */ (function (_super) {
  3274. __extends(StyleSheetImpl, _super);
  3275. function StyleSheetImpl(styleSheet, token) {
  3276. var _this = _super.call(this) || this;
  3277. if (true) {
  3278. (0, secrets_1.ensureTokenIsValid)(token);
  3279. }
  3280. _this.privateDoNotAccessOrElseWrappedStyleSheet = styleSheet;
  3281. return _this;
  3282. }
  3283. StyleSheetImpl.prototype.toString = function () {
  3284. return this.privateDoNotAccessOrElseWrappedStyleSheet;
  3285. };
  3286. return StyleSheetImpl;
  3287. }(SafeStyleSheet));
  3288. /**
  3289. * Builds a new `SafeStyleSheet` from the given string, without enforcing
  3290. * safety guarantees. This shouldn't be exposed to application developers, and
  3291. * must only be used as a step towards safe builders or safe constants.
  3292. */
  3293. function createStyleSheet(styleSheet) {
  3294. return new StyleSheetImpl(styleSheet, secrets_1.secretToken);
  3295. }
  3296. exports.createStyleSheet = createStyleSheet;
  3297. /**
  3298. * Checks if the given value is a `SafeStyleSheet` instance.
  3299. */
  3300. function isStyleSheet(value) {
  3301. return value instanceof StyleSheetImpl;
  3302. }
  3303. exports.isStyleSheet = isStyleSheet;
  3304. /**
  3305. * Returns the string value of the passed `SafeStyleSheet` object while
  3306. * ensuring it has the correct type.
  3307. */
  3308. function unwrapStyleSheet(value) {
  3309. if (value instanceof StyleSheetImpl) {
  3310. return value.privateDoNotAccessOrElseWrappedStyleSheet;
  3311. }
  3312. else {
  3313. var message = '';
  3314. if (true) {
  3315. message = 'Unexpected type when unwrapping SafeStyleSheet';
  3316. }
  3317. throw new Error(message);
  3318. }
  3319. }
  3320. exports.unwrapStyleSheet = unwrapStyleSheet;
  3321. /***/ }),
  3322. /***/ "./node_modules/safevalues/internals/trusted_types.js":
  3323. /*!************************************************************!*\
  3324. !*** ./node_modules/safevalues/internals/trusted_types.js ***!
  3325. \************************************************************/
  3326. /*! no static exports found */
  3327. /***/ (function(module, exports, __webpack_require__) {
  3328. "use strict";
  3329. /**
  3330. * @license
  3331. * SPDX-License-Identifier: Apache-2.0
  3332. */
  3333. Object.defineProperty(exports, "__esModule", { value: true });
  3334. exports.TEST_ONLY = exports.getTrustedTypesPolicy = exports.getTrustedTypes = void 0;
  3335. /**
  3336. * The name of the Trusted Types policy used by TS safevalues, or empty
  3337. * to disable Trusted Types. This duplicates the 'google#safe', but
  3338. * can be overridden in tests.
  3339. */
  3340. var trustedTypesPolicyName = 'google#safe';
  3341. /** Helper to retrieve the value of `window.trustedTypes`. */
  3342. function trustedTypes() {
  3343. if (typeof window !== 'undefined') {
  3344. return window.trustedTypes;
  3345. }
  3346. return undefined;
  3347. }
  3348. /**
  3349. * Returns window.trustedTypes if Trusted Types are enabled and supported, or
  3350. * null otherwise.
  3351. */
  3352. function getTrustedTypes() {
  3353. var _a;
  3354. return (trustedTypesPolicyName !== '') ? ((_a = trustedTypes()) !== null && _a !== void 0 ? _a : null) : null;
  3355. }
  3356. exports.getTrustedTypes = getTrustedTypes;
  3357. /**
  3358. * The Trusted Types policy used by TS safevalues, or null if Trusted Types
  3359. * are not enabled/supported, or undefined if the policy has not been created
  3360. * yet.
  3361. */
  3362. var trustedTypesPolicy;
  3363. /**
  3364. * Returns the Trusted Types policy used by TS safevalues, or null if Trusted
  3365. * Types are not enabled/supported. The first call to this function will
  3366. * create the policy.
  3367. */
  3368. function getTrustedTypesPolicy() {
  3369. var _a, _b;
  3370. if (trustedTypesPolicy === undefined) {
  3371. try {
  3372. trustedTypesPolicy =
  3373. (_b = (_a = getTrustedTypes()) === null || _a === void 0 ? void 0 : _a.createPolicy(trustedTypesPolicyName, {
  3374. createHTML: function (s) { return s; },
  3375. createScript: function (s) { return s; },
  3376. createScriptURL: function (s) { return s; }
  3377. })) !== null && _b !== void 0 ? _b : null;
  3378. }
  3379. catch (_c) {
  3380. // In Chromium versions before 81, trustedTypes.createPolicy throws if
  3381. // called with a name that is already registered, even if no CSP is set.
  3382. // Until users have largely migrated to 81 or above, catch the error not
  3383. // to break the applications functionally. In such case, the code will
  3384. // fall back to using regular Safe Types.
  3385. trustedTypesPolicy = null;
  3386. }
  3387. }
  3388. return trustedTypesPolicy;
  3389. }
  3390. exports.getTrustedTypesPolicy = getTrustedTypesPolicy;
  3391. /** Helpers for tests. */
  3392. exports.TEST_ONLY = {
  3393. resetDefaults: function () {
  3394. trustedTypesPolicy = undefined;
  3395. trustedTypesPolicyName = 'google#safe';
  3396. },
  3397. setTrustedTypesPolicyName: function (name) {
  3398. trustedTypesPolicyName = name;
  3399. },
  3400. };
  3401. /***/ }),
  3402. /***/ "./packages/mdc-base/component.ts":
  3403. /*!****************************************!*\
  3404. !*** ./packages/mdc-base/component.ts ***!
  3405. \****************************************/
  3406. /*! no static exports found */
  3407. /***/ (function(module, exports, __webpack_require__) {
  3408. "use strict";
  3409. /**
  3410. * @license
  3411. * Copyright 2016 Google Inc.
  3412. *
  3413. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3414. * of this software and associated documentation files (the "Software"), to deal
  3415. * in the Software without restriction, including without limitation the rights
  3416. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3417. * copies of the Software, and to permit persons to whom the Software is
  3418. * furnished to do so, subject to the following conditions:
  3419. *
  3420. * The above copyright notice and this permission notice shall be included in
  3421. * all copies or substantial portions of the Software.
  3422. *
  3423. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3424. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3425. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3426. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3427. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3428. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3429. * THE SOFTWARE.
  3430. */
  3431. var __makeTemplateObject = this && this.__makeTemplateObject || function (cooked, raw) {
  3432. if (Object.defineProperty) {
  3433. Object.defineProperty(cooked, "raw", { value: raw });
  3434. } else {
  3435. cooked.raw = raw;
  3436. }
  3437. return cooked;
  3438. };
  3439. var __read = this && this.__read || function (o, n) {
  3440. var m = typeof Symbol === "function" && o[Symbol.iterator];
  3441. if (!m) return o;
  3442. var i = m.call(o),
  3443. r,
  3444. ar = [],
  3445. e;
  3446. try {
  3447. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  3448. ar.push(r.value);
  3449. }
  3450. } catch (error) {
  3451. e = { error: error };
  3452. } finally {
  3453. try {
  3454. if (r && !r.done && (m = i["return"])) m.call(i);
  3455. } finally {
  3456. if (e) throw e.error;
  3457. }
  3458. }
  3459. return ar;
  3460. };
  3461. var __spreadArray = this && this.__spreadArray || function (to, from) {
  3462. for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
  3463. to[j] = from[i];
  3464. }return to;
  3465. };
  3466. Object.defineProperty(exports, "__esModule", { value: true });
  3467. exports.MDCComponent = void 0;
  3468. var safevalues_1 = __webpack_require__(/*! safevalues */ "./node_modules/safevalues/index.js");
  3469. var dom_1 = __webpack_require__(/*! safevalues/dom */ "./node_modules/safevalues/dom/index.js");
  3470. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
  3471. function toCamelCase(str) {
  3472. // tslint:disable-next-line:enforce-name-casing
  3473. return String(str).replace(/\-([a-z])/g, function (_, match) {
  3474. return match.toUpperCase();
  3475. });
  3476. }
  3477. /** MDC Component base */
  3478. var MDCComponent = /** @class */function () {
  3479. function MDCComponent(root, foundation) {
  3480. var args = [];
  3481. for (var _i = 2; _i < arguments.length; _i++) {
  3482. args[_i - 2] = arguments[_i];
  3483. }
  3484. this.root = root;
  3485. this.initialize.apply(this, __spreadArray([], __read(args)));
  3486. // Note that we initialize foundation here and not within the constructor's
  3487. // default param so that this.root is defined and can be used within the
  3488. // foundation class.
  3489. this.foundation = foundation === undefined ? this.getDefaultFoundation() : foundation;
  3490. this.foundation.init();
  3491. this.initialSyncWithDOM();
  3492. }
  3493. MDCComponent.attachTo = function (root) {
  3494. // Subclasses which extend MDCBase should provide an attachTo() method that
  3495. // takes a root element and returns an instantiated component with its root
  3496. // set to that element. Also note that in the cases of subclasses, an
  3497. // explicit foundation class will not have to be passed in; it will simply
  3498. // be initialized from getDefaultFoundation().
  3499. return new MDCComponent(root, new foundation_1.MDCFoundation({}));
  3500. };
  3501. /* istanbul ignore next: method param only exists for typing purposes; it does
  3502. * not need to be unit tested */
  3503. // tslint:disable-next-line:enforce-name-casing
  3504. MDCComponent.prototype.initialize = function () {
  3505. var _args = [];
  3506. for (var _i = 0; _i < arguments.length; _i++) {
  3507. _args[_i] = arguments[_i];
  3508. }
  3509. // Subclasses can override this to do any additional setup work that would
  3510. // be considered part of a "constructor". Essentially, it is a hook into the
  3511. // parent constructor before the foundation is initialized. Any additional
  3512. // arguments besides root and foundation will be passed in here.
  3513. };
  3514. MDCComponent.prototype.getDefaultFoundation = function () {
  3515. // Subclasses must override this method to return a properly configured
  3516. // foundation class for the component.
  3517. throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
  3518. };
  3519. MDCComponent.prototype.initialSyncWithDOM = function () {
  3520. // Subclasses should override this method if they need to perform work to
  3521. // synchronize with a host DOM object. An example of this would be a form
  3522. // control wrapper that needs to synchronize its internal state to some
  3523. // property or attribute of the host DOM. Please note: this is *not* the
  3524. // place to perform DOM reads/writes that would cause layout / paint, as
  3525. // this is called synchronously from within the constructor.
  3526. };
  3527. MDCComponent.prototype.destroy = function () {
  3528. // Subclasses may implement this method to release any resources /
  3529. // deregister any listeners they have attached. An example of this might be
  3530. // deregistering a resize event from the window object.
  3531. this.foundation.destroy();
  3532. };
  3533. MDCComponent.prototype.listen = function (evtType, handler, options) {
  3534. this.root.addEventListener(evtType, handler, options);
  3535. };
  3536. MDCComponent.prototype.unlisten = function (evtType, handler, options) {
  3537. this.root.removeEventListener(evtType, handler, options);
  3538. };
  3539. /**
  3540. * Fires a cross-browser-compatible custom event from the component root of
  3541. * the given type, with the given data.
  3542. */
  3543. MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
  3544. if (shouldBubble === void 0) {
  3545. shouldBubble = false;
  3546. }
  3547. var evt;
  3548. if (typeof CustomEvent === 'function') {
  3549. evt = new CustomEvent(evtType, {
  3550. bubbles: shouldBubble,
  3551. detail: evtData
  3552. });
  3553. } else {
  3554. evt = document.createEvent('CustomEvent');
  3555. evt.initCustomEvent(evtType, shouldBubble, false, evtData);
  3556. }
  3557. this.root.dispatchEvent(evt);
  3558. };
  3559. /**
  3560. * This is a intermediate fix to allow components to use safevalues. This
  3561. * limits setAttribute to setting tabindex, data attributes, and aria
  3562. * attributes.
  3563. *
  3564. * TODO(b/263990206): remove this method and add these directly in each
  3565. * component. This will remove this abstraction and make it clear that the
  3566. * caller can't set any attribute.
  3567. */
  3568. MDCComponent.prototype.safeSetAttribute = function (element, attribute, value) {
  3569. if (attribute.toLowerCase() === 'tabindex') {
  3570. element.tabIndex = Number(value);
  3571. } else if (attribute.indexOf('data-') === 0) {
  3572. var dataKey = toCamelCase(attribute.replace(/^data-/, ''));
  3573. element.dataset[dataKey] = value;
  3574. } else {
  3575. dom_1.safeElement.setPrefixedAttribute([safevalues_1.safeAttrPrefix(templateObject_1 || (templateObject_1 = __makeTemplateObject(["aria-"], ["aria-"]))), safevalues_1.safeAttrPrefix(templateObject_2 || (templateObject_2 = __makeTemplateObject(["role"], ["role"])))], element, attribute, value);
  3576. }
  3577. };
  3578. return MDCComponent;
  3579. }();
  3580. exports.MDCComponent = MDCComponent;
  3581. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  3582. exports.default = MDCComponent;
  3583. var templateObject_1, templateObject_2;
  3584. /***/ }),
  3585. /***/ "./packages/mdc-base/foundation.ts":
  3586. /*!*****************************************!*\
  3587. !*** ./packages/mdc-base/foundation.ts ***!
  3588. \*****************************************/
  3589. /*! no static exports found */
  3590. /***/ (function(module, exports, __webpack_require__) {
  3591. "use strict";
  3592. /**
  3593. * @license
  3594. * Copyright 2016 Google Inc.
  3595. *
  3596. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3597. * of this software and associated documentation files (the "Software"), to deal
  3598. * in the Software without restriction, including without limitation the rights
  3599. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3600. * copies of the Software, and to permit persons to whom the Software is
  3601. * furnished to do so, subject to the following conditions:
  3602. *
  3603. * The above copyright notice and this permission notice shall be included in
  3604. * all copies or substantial portions of the Software.
  3605. *
  3606. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3607. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3608. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3609. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3610. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3611. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3612. * THE SOFTWARE.
  3613. */
  3614. Object.defineProperty(exports, "__esModule", { value: true });
  3615. exports.MDCFoundation = void 0;
  3616. /** MDC Foundation */
  3617. var MDCFoundation = /** @class */function () {
  3618. function MDCFoundation(adapter) {
  3619. if (adapter === void 0) {
  3620. adapter = {};
  3621. }
  3622. this.adapter = adapter;
  3623. }
  3624. Object.defineProperty(MDCFoundation, "cssClasses", {
  3625. get: function get() {
  3626. // Classes extending MDCFoundation should implement this method to return an
  3627. // object which exports every CSS class the foundation class needs as a
  3628. // property. e.g. {ACTIVE: 'mdc-component--active'}
  3629. return {};
  3630. },
  3631. enumerable: false,
  3632. configurable: true
  3633. });
  3634. Object.defineProperty(MDCFoundation, "strings", {
  3635. get: function get() {
  3636. // Classes extending MDCFoundation should implement this method to return an
  3637. // object which exports all semantic strings as constants. e.g. {ARIA_ROLE:
  3638. // 'tablist'}
  3639. return {};
  3640. },
  3641. enumerable: false,
  3642. configurable: true
  3643. });
  3644. Object.defineProperty(MDCFoundation, "numbers", {
  3645. get: function get() {
  3646. // Classes extending MDCFoundation should implement this method to return an
  3647. // object which exports all of its semantic numbers as constants.
  3648. // e.g. {ANIMATION_DELAY_MS: 350}
  3649. return {};
  3650. },
  3651. enumerable: false,
  3652. configurable: true
  3653. });
  3654. Object.defineProperty(MDCFoundation, "defaultAdapter", {
  3655. get: function get() {
  3656. // Classes extending MDCFoundation may choose to implement this getter in
  3657. // order to provide a convenient way of viewing the necessary methods of an
  3658. // adapter. In the future, this could also be used for adapter validation.
  3659. return {};
  3660. },
  3661. enumerable: false,
  3662. configurable: true
  3663. });
  3664. MDCFoundation.prototype.init = function () {
  3665. // Subclasses should override this method to perform initialization routines
  3666. // (registering events, etc.)
  3667. };
  3668. MDCFoundation.prototype.destroy = function () {
  3669. // Subclasses should override this method to perform de-initialization
  3670. // routines (de-registering events, etc.)
  3671. };
  3672. return MDCFoundation;
  3673. }();
  3674. exports.MDCFoundation = MDCFoundation;
  3675. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  3676. exports.default = MDCFoundation;
  3677. /***/ }),
  3678. /***/ "./packages/mdc-dom/focus-trap.ts":
  3679. /*!****************************************!*\
  3680. !*** ./packages/mdc-dom/focus-trap.ts ***!
  3681. \****************************************/
  3682. /*! no static exports found */
  3683. /***/ (function(module, exports, __webpack_require__) {
  3684. "use strict";
  3685. /**
  3686. * @license
  3687. * Copyright 2020 Google Inc.
  3688. *
  3689. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3690. * of this software and associated documentation files (the "Software"), to deal
  3691. * in the Software without restriction, including without limitation the rights
  3692. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3693. * copies of the Software, and to permit persons to whom the Software is
  3694. * furnished to do so, subject to the following conditions:
  3695. *
  3696. * The above copyright notice and this permission notice shall be included in
  3697. * all copies or substantial portions of the Software.
  3698. *
  3699. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3700. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3701. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3702. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3703. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3704. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3705. * THE SOFTWARE.
  3706. */
  3707. Object.defineProperty(exports, "__esModule", { value: true });
  3708. exports.FocusTrap = void 0;
  3709. var FOCUS_SENTINEL_CLASS = 'mdc-dom-focus-sentinel';
  3710. /**
  3711. * Utility to trap focus in a given root element, e.g. for modal components such
  3712. * as dialogs. The root should have at least one focusable child element,
  3713. * for setting initial focus when trapping focus.
  3714. * Also tracks the previously focused element, and restores focus to that
  3715. * element when releasing focus.
  3716. */
  3717. var FocusTrap = /** @class */function () {
  3718. function FocusTrap(root, options) {
  3719. if (options === void 0) {
  3720. options = {};
  3721. }
  3722. this.root = root;
  3723. this.options = options;
  3724. // Previously focused element before trapping focus.
  3725. this.elFocusedBeforeTrapFocus = null;
  3726. }
  3727. /**
  3728. * Traps focus in `root`. Also focuses on either `initialFocusEl` if set;
  3729. * otherwises sets initial focus to the first focusable child element.
  3730. */
  3731. FocusTrap.prototype.trapFocus = function () {
  3732. var focusableEls = this.getFocusableElements(this.root);
  3733. if (focusableEls.length === 0) {
  3734. throw new Error('FocusTrap: Element must have at least one focusable child.');
  3735. }
  3736. this.elFocusedBeforeTrapFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
  3737. this.wrapTabFocus(this.root);
  3738. if (!this.options.skipInitialFocus) {
  3739. this.focusInitialElement(focusableEls, this.options.initialFocusEl);
  3740. }
  3741. };
  3742. /**
  3743. * Releases focus from `root`. Also restores focus to the previously focused
  3744. * element.
  3745. */
  3746. FocusTrap.prototype.releaseFocus = function () {
  3747. Array.from(this.root.querySelectorAll("." + FOCUS_SENTINEL_CLASS)).forEach(function (sentinelEl) {
  3748. sentinelEl.parentElement.removeChild(sentinelEl);
  3749. });
  3750. if (!this.options.skipRestoreFocus && this.elFocusedBeforeTrapFocus) {
  3751. this.elFocusedBeforeTrapFocus.focus();
  3752. }
  3753. };
  3754. /**
  3755. * Wraps tab focus within `el` by adding two hidden sentinel divs which are
  3756. * used to mark the beginning and the end of the tabbable region. When
  3757. * focused, these sentinel elements redirect focus to the first/last
  3758. * children elements of the tabbable region, ensuring that focus is trapped
  3759. * within that region.
  3760. */
  3761. FocusTrap.prototype.wrapTabFocus = function (el) {
  3762. var _this = this;
  3763. var sentinelStart = this.createSentinel();
  3764. var sentinelEnd = this.createSentinel();
  3765. sentinelStart.addEventListener('focus', function () {
  3766. var focusableEls = _this.getFocusableElements(el);
  3767. if (focusableEls.length > 0) {
  3768. focusableEls[focusableEls.length - 1].focus();
  3769. }
  3770. });
  3771. sentinelEnd.addEventListener('focus', function () {
  3772. var focusableEls = _this.getFocusableElements(el);
  3773. if (focusableEls.length > 0) {
  3774. focusableEls[0].focus();
  3775. }
  3776. });
  3777. el.insertBefore(sentinelStart, el.children[0]);
  3778. el.appendChild(sentinelEnd);
  3779. };
  3780. /**
  3781. * Focuses on `initialFocusEl` if defined and a child of the root element.
  3782. * Otherwise, focuses on the first focusable child element of the root.
  3783. */
  3784. FocusTrap.prototype.focusInitialElement = function (focusableEls, initialFocusEl) {
  3785. var focusIndex = 0;
  3786. if (initialFocusEl) {
  3787. focusIndex = Math.max(focusableEls.indexOf(initialFocusEl), 0);
  3788. }
  3789. focusableEls[focusIndex].focus();
  3790. };
  3791. FocusTrap.prototype.getFocusableElements = function (root) {
  3792. var focusableEls = Array.from(root.querySelectorAll('[autofocus], [tabindex], a, input, textarea, select, button'));
  3793. return focusableEls.filter(function (el) {
  3794. var isDisabledOrHidden = el.getAttribute('aria-disabled') === 'true' || el.getAttribute('disabled') != null || el.getAttribute('hidden') != null || el.getAttribute('aria-hidden') === 'true';
  3795. var isTabbableAndVisible = el.tabIndex >= 0 && el.getBoundingClientRect().width > 0 && !el.classList.contains(FOCUS_SENTINEL_CLASS) && !isDisabledOrHidden;
  3796. var isProgrammaticallyHidden = false;
  3797. if (isTabbableAndVisible) {
  3798. var style = getComputedStyle(el);
  3799. isProgrammaticallyHidden = style.display === 'none' || style.visibility === 'hidden';
  3800. }
  3801. return isTabbableAndVisible && !isProgrammaticallyHidden;
  3802. });
  3803. };
  3804. FocusTrap.prototype.createSentinel = function () {
  3805. var sentinel = document.createElement('div');
  3806. sentinel.setAttribute('tabindex', '0');
  3807. // Don't announce in screen readers.
  3808. sentinel.setAttribute('aria-hidden', 'true');
  3809. sentinel.classList.add(FOCUS_SENTINEL_CLASS);
  3810. return sentinel;
  3811. };
  3812. return FocusTrap;
  3813. }();
  3814. exports.FocusTrap = FocusTrap;
  3815. /***/ }),
  3816. /***/ "./packages/mdc-dom/keyboard.ts":
  3817. /*!**************************************!*\
  3818. !*** ./packages/mdc-dom/keyboard.ts ***!
  3819. \**************************************/
  3820. /*! no static exports found */
  3821. /***/ (function(module, exports, __webpack_require__) {
  3822. "use strict";
  3823. /**
  3824. * @license
  3825. * Copyright 2020 Google Inc.
  3826. *
  3827. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3828. * of this software and associated documentation files (the "Software"), to deal
  3829. * in the Software without restriction, including without limitation the rights
  3830. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3831. * copies of the Software, and to permit persons to whom the Software is
  3832. * furnished to do so, subject to the following conditions:
  3833. *
  3834. * The above copyright notice and this permission notice shall be included in
  3835. * all copies or substantial portions of the Software.
  3836. *
  3837. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3838. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3839. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3840. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3841. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3842. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3843. * THE SOFTWARE.
  3844. */
  3845. Object.defineProperty(exports, "__esModule", { value: true });
  3846. exports.isNavigationEvent = exports.normalizeKey = exports.KEY = void 0;
  3847. /**
  3848. * KEY provides normalized string values for keys.
  3849. */
  3850. exports.KEY = {
  3851. UNKNOWN: 'Unknown',
  3852. BACKSPACE: 'Backspace',
  3853. ENTER: 'Enter',
  3854. SPACEBAR: 'Spacebar',
  3855. PAGE_UP: 'PageUp',
  3856. PAGE_DOWN: 'PageDown',
  3857. END: 'End',
  3858. HOME: 'Home',
  3859. ARROW_LEFT: 'ArrowLeft',
  3860. ARROW_UP: 'ArrowUp',
  3861. ARROW_RIGHT: 'ArrowRight',
  3862. ARROW_DOWN: 'ArrowDown',
  3863. DELETE: 'Delete',
  3864. ESCAPE: 'Escape',
  3865. TAB: 'Tab'
  3866. };
  3867. var normalizedKeys = new Set();
  3868. // IE11 has no support for new Map with iterable so we need to initialize this
  3869. // by hand.
  3870. normalizedKeys.add(exports.KEY.BACKSPACE);
  3871. normalizedKeys.add(exports.KEY.ENTER);
  3872. normalizedKeys.add(exports.KEY.SPACEBAR);
  3873. normalizedKeys.add(exports.KEY.PAGE_UP);
  3874. normalizedKeys.add(exports.KEY.PAGE_DOWN);
  3875. normalizedKeys.add(exports.KEY.END);
  3876. normalizedKeys.add(exports.KEY.HOME);
  3877. normalizedKeys.add(exports.KEY.ARROW_LEFT);
  3878. normalizedKeys.add(exports.KEY.ARROW_UP);
  3879. normalizedKeys.add(exports.KEY.ARROW_RIGHT);
  3880. normalizedKeys.add(exports.KEY.ARROW_DOWN);
  3881. normalizedKeys.add(exports.KEY.DELETE);
  3882. normalizedKeys.add(exports.KEY.ESCAPE);
  3883. normalizedKeys.add(exports.KEY.TAB);
  3884. var KEY_CODE = {
  3885. BACKSPACE: 8,
  3886. ENTER: 13,
  3887. SPACEBAR: 32,
  3888. PAGE_UP: 33,
  3889. PAGE_DOWN: 34,
  3890. END: 35,
  3891. HOME: 36,
  3892. ARROW_LEFT: 37,
  3893. ARROW_UP: 38,
  3894. ARROW_RIGHT: 39,
  3895. ARROW_DOWN: 40,
  3896. DELETE: 46,
  3897. ESCAPE: 27,
  3898. TAB: 9
  3899. };
  3900. var mappedKeyCodes = new Map();
  3901. // IE11 has no support for new Map with iterable so we need to initialize this
  3902. // by hand.
  3903. mappedKeyCodes.set(KEY_CODE.BACKSPACE, exports.KEY.BACKSPACE);
  3904. mappedKeyCodes.set(KEY_CODE.ENTER, exports.KEY.ENTER);
  3905. mappedKeyCodes.set(KEY_CODE.SPACEBAR, exports.KEY.SPACEBAR);
  3906. mappedKeyCodes.set(KEY_CODE.PAGE_UP, exports.KEY.PAGE_UP);
  3907. mappedKeyCodes.set(KEY_CODE.PAGE_DOWN, exports.KEY.PAGE_DOWN);
  3908. mappedKeyCodes.set(KEY_CODE.END, exports.KEY.END);
  3909. mappedKeyCodes.set(KEY_CODE.HOME, exports.KEY.HOME);
  3910. mappedKeyCodes.set(KEY_CODE.ARROW_LEFT, exports.KEY.ARROW_LEFT);
  3911. mappedKeyCodes.set(KEY_CODE.ARROW_UP, exports.KEY.ARROW_UP);
  3912. mappedKeyCodes.set(KEY_CODE.ARROW_RIGHT, exports.KEY.ARROW_RIGHT);
  3913. mappedKeyCodes.set(KEY_CODE.ARROW_DOWN, exports.KEY.ARROW_DOWN);
  3914. mappedKeyCodes.set(KEY_CODE.DELETE, exports.KEY.DELETE);
  3915. mappedKeyCodes.set(KEY_CODE.ESCAPE, exports.KEY.ESCAPE);
  3916. mappedKeyCodes.set(KEY_CODE.TAB, exports.KEY.TAB);
  3917. var navigationKeys = new Set();
  3918. // IE11 has no support for new Set with iterable so we need to initialize this
  3919. // by hand.
  3920. navigationKeys.add(exports.KEY.PAGE_UP);
  3921. navigationKeys.add(exports.KEY.PAGE_DOWN);
  3922. navigationKeys.add(exports.KEY.END);
  3923. navigationKeys.add(exports.KEY.HOME);
  3924. navigationKeys.add(exports.KEY.ARROW_LEFT);
  3925. navigationKeys.add(exports.KEY.ARROW_UP);
  3926. navigationKeys.add(exports.KEY.ARROW_RIGHT);
  3927. navigationKeys.add(exports.KEY.ARROW_DOWN);
  3928. /**
  3929. * normalizeKey returns the normalized string for a navigational action.
  3930. */
  3931. function normalizeKey(evt) {
  3932. var key = evt.key;
  3933. // If the event already has a normalized key, return it
  3934. if (normalizedKeys.has(key)) {
  3935. return key;
  3936. }
  3937. // tslint:disable-next-line:deprecation
  3938. var mappedKey = mappedKeyCodes.get(evt.keyCode);
  3939. if (mappedKey) {
  3940. return mappedKey;
  3941. }
  3942. return exports.KEY.UNKNOWN;
  3943. }
  3944. exports.normalizeKey = normalizeKey;
  3945. /**
  3946. * isNavigationEvent returns whether the event is a navigation event
  3947. */
  3948. function isNavigationEvent(evt) {
  3949. return navigationKeys.has(normalizeKey(evt));
  3950. }
  3951. exports.isNavigationEvent = isNavigationEvent;
  3952. /***/ }),
  3953. /***/ "./packages/mdc-dom/ponyfill.ts":
  3954. /*!**************************************!*\
  3955. !*** ./packages/mdc-dom/ponyfill.ts ***!
  3956. \**************************************/
  3957. /*! no static exports found */
  3958. /***/ (function(module, exports, __webpack_require__) {
  3959. "use strict";
  3960. /**
  3961. * @license
  3962. * Copyright 2018 Google Inc.
  3963. *
  3964. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3965. * of this software and associated documentation files (the "Software"), to deal
  3966. * in the Software without restriction, including without limitation the rights
  3967. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3968. * copies of the Software, and to permit persons to whom the Software is
  3969. * furnished to do so, subject to the following conditions:
  3970. *
  3971. * The above copyright notice and this permission notice shall be included in
  3972. * all copies or substantial portions of the Software.
  3973. *
  3974. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3975. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3976. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3977. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3978. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3979. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3980. * THE SOFTWARE.
  3981. */
  3982. Object.defineProperty(exports, "__esModule", { value: true });
  3983. exports.estimateScrollWidth = exports.matches = exports.closest = void 0;
  3984. /**
  3985. * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global
  3986. * prototype chain. This makes ponyfills safer than traditional polyfills,
  3987. * especially for libraries like MDC.
  3988. */
  3989. function closest(element, selector) {
  3990. if (element.closest) {
  3991. return element.closest(selector);
  3992. }
  3993. var el = element;
  3994. while (el) {
  3995. if (matches(el, selector)) {
  3996. return el;
  3997. }
  3998. el = el.parentElement;
  3999. }
  4000. return null;
  4001. }
  4002. exports.closest = closest;
  4003. /** Element.matches with support for webkit and IE. */
  4004. function matches(element, selector) {
  4005. var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
  4006. return nativeMatches.call(element, selector);
  4007. }
  4008. exports.matches = matches;
  4009. /**
  4010. * Used to compute the estimated scroll width of elements. When an element is
  4011. * hidden due to display: none; being applied to a parent element, the width is
  4012. * returned as 0. However, the element will have a true width once no longer
  4013. * inside a display: none context. This method computes an estimated width when
  4014. * the element is hidden or returns the true width when the element is visble.
  4015. * @param {Element} element the element whose width to estimate
  4016. */
  4017. function estimateScrollWidth(element) {
  4018. // Check the offsetParent. If the element inherits display: none from any
  4019. // parent, the offsetParent property will be null (see
  4020. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
  4021. // This check ensures we only clone the node when necessary.
  4022. var htmlEl = element;
  4023. if (htmlEl.offsetParent !== null) {
  4024. return htmlEl.scrollWidth;
  4025. }
  4026. var clone = htmlEl.cloneNode(true);
  4027. clone.style.setProperty('position', 'absolute');
  4028. clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
  4029. document.documentElement.appendChild(clone);
  4030. var scrollWidth = clone.scrollWidth;
  4031. document.documentElement.removeChild(clone);
  4032. return scrollWidth;
  4033. }
  4034. exports.estimateScrollWidth = estimateScrollWidth;
  4035. /***/ }),
  4036. /***/ "./packages/mdc-drawer/adapter.ts":
  4037. /*!****************************************!*\
  4038. !*** ./packages/mdc-drawer/adapter.ts ***!
  4039. \****************************************/
  4040. /*! no static exports found */
  4041. /***/ (function(module, exports, __webpack_require__) {
  4042. "use strict";
  4043. /**
  4044. * @license
  4045. * Copyright 2018 Google Inc.
  4046. *
  4047. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4048. * of this software and associated documentation files (the "Software"), to deal
  4049. * in the Software without restriction, including without limitation the rights
  4050. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4051. * copies of the Software, and to permit persons to whom the Software is
  4052. * furnished to do so, subject to the following conditions:
  4053. *
  4054. * The above copyright notice and this permission notice shall be included in
  4055. * all copies or substantial portions of the Software.
  4056. *
  4057. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4058. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4059. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4060. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4061. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4062. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4063. * THE SOFTWARE.
  4064. */
  4065. Object.defineProperty(exports, "__esModule", { value: true });
  4066. /***/ }),
  4067. /***/ "./packages/mdc-drawer/component.ts":
  4068. /*!******************************************!*\
  4069. !*** ./packages/mdc-drawer/component.ts ***!
  4070. \******************************************/
  4071. /*! no static exports found */
  4072. /***/ (function(module, exports, __webpack_require__) {
  4073. "use strict";
  4074. /**
  4075. * @license
  4076. * Copyright 2016 Google Inc.
  4077. *
  4078. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4079. * of this software and associated documentation files (the "Software"), to deal
  4080. * in the Software without restriction, including without limitation the rights
  4081. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4082. * copies of the Software, and to permit persons to whom the Software is
  4083. * furnished to do so, subject to the following conditions:
  4084. *
  4085. * The above copyright notice and this permission notice shall be included in
  4086. * all copies or substantial portions of the Software.
  4087. *
  4088. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4089. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4090. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4091. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4092. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4093. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4094. * THE SOFTWARE.
  4095. */
  4096. var __extends = this && this.__extends || function () {
  4097. var _extendStatics = function extendStatics(d, b) {
  4098. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4099. d.__proto__ = b;
  4100. } || function (d, b) {
  4101. for (var p in b) {
  4102. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  4103. }
  4104. };
  4105. return _extendStatics(d, b);
  4106. };
  4107. return function (d, b) {
  4108. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  4109. _extendStatics(d, b);
  4110. function __() {
  4111. this.constructor = d;
  4112. }
  4113. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4114. };
  4115. }();
  4116. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  4117. if (k2 === undefined) k2 = k;
  4118. Object.defineProperty(o, k2, { enumerable: true, get: function get() {
  4119. return m[k];
  4120. } });
  4121. } : function (o, m, k, k2) {
  4122. if (k2 === undefined) k2 = k;
  4123. o[k2] = m[k];
  4124. });
  4125. var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
  4126. Object.defineProperty(o, "default", { enumerable: true, value: v });
  4127. } : function (o, v) {
  4128. o["default"] = v;
  4129. });
  4130. var __importStar = this && this.__importStar || function (mod) {
  4131. if (mod && mod.__esModule) return mod;
  4132. var result = {};
  4133. if (mod != null) for (var k in mod) {
  4134. if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  4135. }__setModuleDefault(result, mod);
  4136. return result;
  4137. };
  4138. Object.defineProperty(exports, "__esModule", { value: true });
  4139. exports.MDCDrawer = void 0;
  4140. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  4141. var focus_trap_1 = __webpack_require__(/*! @material/dom/focus-trap */ "./packages/mdc-dom/focus-trap.ts");
  4142. var component_2 = __webpack_require__(/*! @material/list/component */ "./packages/mdc-list/component.ts");
  4143. var foundation_1 = __webpack_require__(/*! ./dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts");
  4144. var foundation_2 = __webpack_require__(/*! ./modal/foundation */ "./packages/mdc-drawer/modal/foundation.ts");
  4145. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-drawer/util.ts"));
  4146. var cssClasses = foundation_1.MDCDismissibleDrawerFoundation.cssClasses,
  4147. strings = foundation_1.MDCDismissibleDrawerFoundation.strings;
  4148. /**
  4149. * @events `MDCDrawer:closed {}` Emits when the navigation drawer has closed.
  4150. * @events `MDCDrawer:opened {}` Emits when the navigation drawer has opened.
  4151. */
  4152. var MDCDrawer = /** @class */function (_super) {
  4153. __extends(MDCDrawer, _super);
  4154. function MDCDrawer() {
  4155. return _super !== null && _super.apply(this, arguments) || this;
  4156. }
  4157. MDCDrawer.attachTo = function (root) {
  4158. return new MDCDrawer(root);
  4159. };
  4160. Object.defineProperty(MDCDrawer.prototype, "open", {
  4161. /**
  4162. * @return boolean Proxies to the foundation's `open`/`close` methods.
  4163. * Also returns true if drawer is in the open position.
  4164. */
  4165. get: function get() {
  4166. return this.foundation.isOpen();
  4167. },
  4168. /**
  4169. * Toggles the drawer open and closed.
  4170. */
  4171. set: function set(isOpen) {
  4172. if (isOpen) {
  4173. this.foundation.open();
  4174. } else {
  4175. this.foundation.close();
  4176. }
  4177. },
  4178. enumerable: false,
  4179. configurable: true
  4180. });
  4181. Object.defineProperty(MDCDrawer.prototype, "list", {
  4182. // initialSyncWithDOM()
  4183. get: function get() {
  4184. return this.innerList;
  4185. },
  4186. enumerable: false,
  4187. configurable: true
  4188. });
  4189. MDCDrawer.prototype.initialize = function (focusTrapFactory, listFactory) {
  4190. if (focusTrapFactory === void 0) {
  4191. focusTrapFactory = function focusTrapFactory(el) {
  4192. return new focus_trap_1.FocusTrap(el);
  4193. };
  4194. }
  4195. if (listFactory === void 0) {
  4196. listFactory = function listFactory(el) {
  4197. return new component_2.MDCList(el);
  4198. };
  4199. }
  4200. var listEl = this.root.querySelector(strings.LIST_SELECTOR);
  4201. if (listEl) {
  4202. this.innerList = listFactory(listEl);
  4203. this.innerList.wrapFocus = true;
  4204. }
  4205. this.focusTrapFactory = focusTrapFactory;
  4206. };
  4207. MDCDrawer.prototype.initialSyncWithDOM = function () {
  4208. var _this = this;
  4209. var MODAL = cssClasses.MODAL;
  4210. var SCRIM_SELECTOR = strings.SCRIM_SELECTOR;
  4211. this.scrim = this.root.parentNode.querySelector(SCRIM_SELECTOR);
  4212. if (this.scrim && this.root.classList.contains(MODAL)) {
  4213. this.handleScrimClick = function () {
  4214. _this.foundation.handleScrimClick();
  4215. };
  4216. this.scrim.addEventListener('click', this.handleScrimClick);
  4217. this.focusTrap = util.createFocusTrapInstance(this.root, this.focusTrapFactory);
  4218. }
  4219. this.handleKeydown = function (evt) {
  4220. _this.foundation.handleKeydown(evt);
  4221. };
  4222. this.handleTransitionEnd = function (evt) {
  4223. _this.foundation.handleTransitionEnd(evt);
  4224. };
  4225. this.listen('keydown', this.handleKeydown);
  4226. this.listen('transitionend', this.handleTransitionEnd);
  4227. };
  4228. MDCDrawer.prototype.destroy = function () {
  4229. this.unlisten('keydown', this.handleKeydown);
  4230. this.unlisten('transitionend', this.handleTransitionEnd);
  4231. if (this.innerList) {
  4232. this.innerList.destroy();
  4233. }
  4234. var MODAL = cssClasses.MODAL;
  4235. if (this.scrim && this.handleScrimClick && this.root.classList.contains(MODAL)) {
  4236. this.scrim.removeEventListener('click', this.handleScrimClick);
  4237. // Ensure drawer is closed to hide scrim and release focus
  4238. this.open = false;
  4239. }
  4240. };
  4241. MDCDrawer.prototype.getDefaultFoundation = function () {
  4242. var _this = this;
  4243. // DO NOT INLINE this variable. For backward compatibility, foundations take
  4244. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  4245. // methods, we need a separate, strongly typed adapter variable.
  4246. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  4247. var adapter = {
  4248. addClass: function addClass(className) {
  4249. _this.root.classList.add(className);
  4250. },
  4251. removeClass: function removeClass(className) {
  4252. _this.root.classList.remove(className);
  4253. },
  4254. hasClass: function hasClass(className) {
  4255. return _this.root.classList.contains(className);
  4256. },
  4257. elementHasClass: function elementHasClass(element, className) {
  4258. return element.classList.contains(className);
  4259. },
  4260. saveFocus: function saveFocus() {
  4261. _this.previousFocus = document.activeElement;
  4262. },
  4263. restoreFocus: function restoreFocus() {
  4264. var previousFocus = _this.previousFocus;
  4265. if (previousFocus && previousFocus.focus && _this.root.contains(document.activeElement)) {
  4266. previousFocus.focus();
  4267. }
  4268. },
  4269. focusActiveNavigationItem: function focusActiveNavigationItem() {
  4270. var activeNavItemEl = _this.root.querySelector(strings.LIST_ITEM_ACTIVATED_SELECTOR);
  4271. if (activeNavItemEl) {
  4272. activeNavItemEl.focus();
  4273. }
  4274. },
  4275. notifyClose: function notifyClose() {
  4276. _this.emit(strings.CLOSE_EVENT, {}, true /* shouldBubble */);
  4277. },
  4278. notifyOpen: function notifyOpen() {
  4279. _this.emit(strings.OPEN_EVENT, {}, true /* shouldBubble */);
  4280. },
  4281. trapFocus: function trapFocus() {
  4282. _this.focusTrap.trapFocus();
  4283. },
  4284. releaseFocus: function releaseFocus() {
  4285. _this.focusTrap.releaseFocus();
  4286. }
  4287. };
  4288. // tslint:enable:object-literal-sort-keys
  4289. var DISMISSIBLE = cssClasses.DISMISSIBLE,
  4290. MODAL = cssClasses.MODAL;
  4291. if (this.root.classList.contains(DISMISSIBLE)) {
  4292. return new foundation_1.MDCDismissibleDrawerFoundation(adapter);
  4293. } else if (this.root.classList.contains(MODAL)) {
  4294. return new foundation_2.MDCModalDrawerFoundation(adapter);
  4295. } else {
  4296. throw new Error("MDCDrawer: Failed to instantiate component. Supported variants are " + DISMISSIBLE + " and " + MODAL + ".");
  4297. }
  4298. };
  4299. return MDCDrawer;
  4300. }(component_1.MDCComponent);
  4301. exports.MDCDrawer = MDCDrawer;
  4302. /***/ }),
  4303. /***/ "./packages/mdc-drawer/constants.ts":
  4304. /*!******************************************!*\
  4305. !*** ./packages/mdc-drawer/constants.ts ***!
  4306. \******************************************/
  4307. /*! no static exports found */
  4308. /***/ (function(module, exports, __webpack_require__) {
  4309. "use strict";
  4310. /**
  4311. * @license
  4312. * Copyright 2016 Google Inc.
  4313. *
  4314. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4315. * of this software and associated documentation files (the "Software"), to deal
  4316. * in the Software without restriction, including without limitation the rights
  4317. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4318. * copies of the Software, and to permit persons to whom the Software is
  4319. * furnished to do so, subject to the following conditions:
  4320. *
  4321. * The above copyright notice and this permission notice shall be included in
  4322. * all copies or substantial portions of the Software.
  4323. *
  4324. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4325. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4326. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4327. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4328. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4329. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4330. * THE SOFTWARE.
  4331. */
  4332. Object.defineProperty(exports, "__esModule", { value: true });
  4333. exports.strings = exports.cssClasses = void 0;
  4334. var cssClasses = {
  4335. ANIMATE: 'mdc-drawer--animate',
  4336. CLOSING: 'mdc-drawer--closing',
  4337. DISMISSIBLE: 'mdc-drawer--dismissible',
  4338. MODAL: 'mdc-drawer--modal',
  4339. OPEN: 'mdc-drawer--open',
  4340. OPENING: 'mdc-drawer--opening',
  4341. ROOT: 'mdc-drawer'
  4342. };
  4343. exports.cssClasses = cssClasses;
  4344. var strings = {
  4345. APP_CONTENT_SELECTOR: '.mdc-drawer-app-content',
  4346. CLOSE_EVENT: 'MDCDrawer:closed',
  4347. OPEN_EVENT: 'MDCDrawer:opened',
  4348. SCRIM_SELECTOR: '.mdc-drawer-scrim',
  4349. LIST_SELECTOR: '.mdc-list,.mdc-deprecated-list',
  4350. LIST_ITEM_ACTIVATED_SELECTOR: '.mdc-list-item--activated,.mdc-deprecated-list-item--activated'
  4351. };
  4352. exports.strings = strings;
  4353. /***/ }),
  4354. /***/ "./packages/mdc-drawer/dismissible/foundation.ts":
  4355. /*!*******************************************************!*\
  4356. !*** ./packages/mdc-drawer/dismissible/foundation.ts ***!
  4357. \*******************************************************/
  4358. /*! no static exports found */
  4359. /***/ (function(module, exports, __webpack_require__) {
  4360. "use strict";
  4361. /**
  4362. * @license
  4363. * Copyright 2018 Google Inc.
  4364. *
  4365. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4366. * of this software and associated documentation files (the "Software"), to deal
  4367. * in the Software without restriction, including without limitation the rights
  4368. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4369. * copies of the Software, and to permit persons to whom the Software is
  4370. * furnished to do so, subject to the following conditions:
  4371. *
  4372. * The above copyright notice and this permission notice shall be included in
  4373. * all copies or substantial portions of the Software.
  4374. *
  4375. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4376. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4377. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4378. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4379. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4380. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4381. * THE SOFTWARE.
  4382. */
  4383. var __extends = this && this.__extends || function () {
  4384. var _extendStatics = function extendStatics(d, b) {
  4385. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4386. d.__proto__ = b;
  4387. } || function (d, b) {
  4388. for (var p in b) {
  4389. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  4390. }
  4391. };
  4392. return _extendStatics(d, b);
  4393. };
  4394. return function (d, b) {
  4395. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  4396. _extendStatics(d, b);
  4397. function __() {
  4398. this.constructor = d;
  4399. }
  4400. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4401. };
  4402. }();
  4403. var __assign = this && this.__assign || function () {
  4404. __assign = Object.assign || function (t) {
  4405. for (var s, i = 1, n = arguments.length; i < n; i++) {
  4406. s = arguments[i];
  4407. for (var p in s) {
  4408. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  4409. }
  4410. }
  4411. return t;
  4412. };
  4413. return __assign.apply(this, arguments);
  4414. };
  4415. Object.defineProperty(exports, "__esModule", { value: true });
  4416. exports.MDCDismissibleDrawerFoundation = void 0;
  4417. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  4418. var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-drawer/constants.ts");
  4419. /** MDC Dismissible Drawer Foundation */
  4420. var MDCDismissibleDrawerFoundation = /** @class */function (_super) {
  4421. __extends(MDCDismissibleDrawerFoundation, _super);
  4422. function MDCDismissibleDrawerFoundation(adapter) {
  4423. var _this = _super.call(this, __assign(__assign({}, MDCDismissibleDrawerFoundation.defaultAdapter), adapter)) || this;
  4424. _this.animationFrame = 0;
  4425. _this.animationTimer = 0;
  4426. return _this;
  4427. }
  4428. Object.defineProperty(MDCDismissibleDrawerFoundation, "strings", {
  4429. get: function get() {
  4430. return constants_1.strings;
  4431. },
  4432. enumerable: false,
  4433. configurable: true
  4434. });
  4435. Object.defineProperty(MDCDismissibleDrawerFoundation, "cssClasses", {
  4436. get: function get() {
  4437. return constants_1.cssClasses;
  4438. },
  4439. enumerable: false,
  4440. configurable: true
  4441. });
  4442. Object.defineProperty(MDCDismissibleDrawerFoundation, "defaultAdapter", {
  4443. get: function get() {
  4444. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  4445. return {
  4446. addClass: function addClass() {
  4447. return undefined;
  4448. },
  4449. removeClass: function removeClass() {
  4450. return undefined;
  4451. },
  4452. hasClass: function hasClass() {
  4453. return false;
  4454. },
  4455. elementHasClass: function elementHasClass() {
  4456. return false;
  4457. },
  4458. notifyClose: function notifyClose() {
  4459. return undefined;
  4460. },
  4461. notifyOpen: function notifyOpen() {
  4462. return undefined;
  4463. },
  4464. saveFocus: function saveFocus() {
  4465. return undefined;
  4466. },
  4467. restoreFocus: function restoreFocus() {
  4468. return undefined;
  4469. },
  4470. focusActiveNavigationItem: function focusActiveNavigationItem() {
  4471. return undefined;
  4472. },
  4473. trapFocus: function trapFocus() {
  4474. return undefined;
  4475. },
  4476. releaseFocus: function releaseFocus() {
  4477. return undefined;
  4478. }
  4479. };
  4480. // tslint:enable:object-literal-sort-keys
  4481. },
  4482. enumerable: false,
  4483. configurable: true
  4484. });
  4485. MDCDismissibleDrawerFoundation.prototype.destroy = function () {
  4486. if (this.animationFrame) {
  4487. cancelAnimationFrame(this.animationFrame);
  4488. }
  4489. if (this.animationTimer) {
  4490. clearTimeout(this.animationTimer);
  4491. }
  4492. };
  4493. /**
  4494. * Opens the drawer from the closed state.
  4495. */
  4496. MDCDismissibleDrawerFoundation.prototype.open = function () {
  4497. var _this = this;
  4498. if (this.isOpen() || this.isOpening() || this.isClosing()) {
  4499. return;
  4500. }
  4501. this.adapter.addClass(constants_1.cssClasses.OPEN);
  4502. this.adapter.addClass(constants_1.cssClasses.ANIMATE);
  4503. // Wait a frame once display is no longer "none", to establish basis for
  4504. // animation
  4505. this.runNextAnimationFrame(function () {
  4506. _this.adapter.addClass(constants_1.cssClasses.OPENING);
  4507. });
  4508. this.adapter.saveFocus();
  4509. };
  4510. /**
  4511. * Closes the drawer from the open state.
  4512. */
  4513. MDCDismissibleDrawerFoundation.prototype.close = function () {
  4514. if (!this.isOpen() || this.isOpening() || this.isClosing()) {
  4515. return;
  4516. }
  4517. this.adapter.addClass(constants_1.cssClasses.CLOSING);
  4518. };
  4519. /**
  4520. * Returns true if the drawer is in the open position.
  4521. * @return true if drawer is in open state.
  4522. */
  4523. MDCDismissibleDrawerFoundation.prototype.isOpen = function () {
  4524. return this.adapter.hasClass(constants_1.cssClasses.OPEN);
  4525. };
  4526. /**
  4527. * Returns true if the drawer is animating open.
  4528. * @return true if drawer is animating open.
  4529. */
  4530. MDCDismissibleDrawerFoundation.prototype.isOpening = function () {
  4531. return this.adapter.hasClass(constants_1.cssClasses.OPENING) || this.adapter.hasClass(constants_1.cssClasses.ANIMATE);
  4532. };
  4533. /**
  4534. * Returns true if the drawer is animating closed.
  4535. * @return true if drawer is animating closed.
  4536. */
  4537. MDCDismissibleDrawerFoundation.prototype.isClosing = function () {
  4538. return this.adapter.hasClass(constants_1.cssClasses.CLOSING);
  4539. };
  4540. /**
  4541. * Keydown handler to close drawer when key is escape.
  4542. */
  4543. MDCDismissibleDrawerFoundation.prototype.handleKeydown = function (evt) {
  4544. var keyCode = evt.keyCode,
  4545. key = evt.key;
  4546. var isEscape = key === 'Escape' || keyCode === 27;
  4547. if (isEscape) {
  4548. this.close();
  4549. }
  4550. };
  4551. /**
  4552. * Handles the `transitionend` event when the drawer finishes opening/closing.
  4553. */
  4554. MDCDismissibleDrawerFoundation.prototype.handleTransitionEnd = function (evt) {
  4555. var OPENING = constants_1.cssClasses.OPENING,
  4556. CLOSING = constants_1.cssClasses.CLOSING,
  4557. OPEN = constants_1.cssClasses.OPEN,
  4558. ANIMATE = constants_1.cssClasses.ANIMATE,
  4559. ROOT = constants_1.cssClasses.ROOT;
  4560. // In Edge, transitionend on ripple pseudo-elements yields a target without
  4561. // classList, so check for Element first.
  4562. var isRootElement = this.isElement(evt.target) && this.adapter.elementHasClass(evt.target, ROOT);
  4563. if (!isRootElement) {
  4564. return;
  4565. }
  4566. if (this.isClosing()) {
  4567. this.adapter.removeClass(OPEN);
  4568. this.closed();
  4569. this.adapter.restoreFocus();
  4570. this.adapter.notifyClose();
  4571. } else {
  4572. this.adapter.focusActiveNavigationItem();
  4573. this.opened();
  4574. this.adapter.notifyOpen();
  4575. }
  4576. this.adapter.removeClass(ANIMATE);
  4577. this.adapter.removeClass(OPENING);
  4578. this.adapter.removeClass(CLOSING);
  4579. };
  4580. /**
  4581. * Extension point for when drawer finishes open animation.
  4582. */
  4583. MDCDismissibleDrawerFoundation.prototype.opened = function () {}; // tslint:disable-line:no-empty
  4584. /**
  4585. * Extension point for when drawer finishes close animation.
  4586. */
  4587. MDCDismissibleDrawerFoundation.prototype.closed = function () {}; // tslint:disable-line:no-empty
  4588. /**
  4589. * Runs the given logic on the next animation frame, using setTimeout to
  4590. * factor in Firefox reflow behavior.
  4591. */
  4592. MDCDismissibleDrawerFoundation.prototype.runNextAnimationFrame = function (callback) {
  4593. var _this = this;
  4594. cancelAnimationFrame(this.animationFrame);
  4595. this.animationFrame = requestAnimationFrame(function () {
  4596. _this.animationFrame = 0;
  4597. clearTimeout(_this.animationTimer);
  4598. _this.animationTimer = setTimeout(callback, 0);
  4599. });
  4600. };
  4601. MDCDismissibleDrawerFoundation.prototype.isElement = function (element) {
  4602. // In Edge, transitionend on ripple pseudo-elements yields a target without
  4603. // classList.
  4604. return Boolean(element.classList);
  4605. };
  4606. return MDCDismissibleDrawerFoundation;
  4607. }(foundation_1.MDCFoundation);
  4608. exports.MDCDismissibleDrawerFoundation = MDCDismissibleDrawerFoundation;
  4609. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  4610. exports.default = MDCDismissibleDrawerFoundation;
  4611. /***/ }),
  4612. /***/ "./packages/mdc-drawer/index.ts":
  4613. /*!**************************************!*\
  4614. !*** ./packages/mdc-drawer/index.ts ***!
  4615. \**************************************/
  4616. /*! no static exports found */
  4617. /***/ (function(module, exports, __webpack_require__) {
  4618. "use strict";
  4619. /**
  4620. * @license
  4621. * Copyright 2019 Google Inc.
  4622. *
  4623. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4624. * of this software and associated documentation files (the "Software"), to deal
  4625. * in the Software without restriction, including without limitation the rights
  4626. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4627. * copies of the Software, and to permit persons to whom the Software is
  4628. * furnished to do so, subject to the following conditions:
  4629. *
  4630. * The above copyright notice and this permission notice shall be included in
  4631. * all copies or substantial portions of the Software.
  4632. *
  4633. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4634. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4635. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4636. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4637. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4638. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4639. * THE SOFTWARE.
  4640. */
  4641. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  4642. if (k2 === undefined) k2 = k;
  4643. Object.defineProperty(o, k2, { enumerable: true, get: function get() {
  4644. return m[k];
  4645. } });
  4646. } : function (o, m, k, k2) {
  4647. if (k2 === undefined) k2 = k;
  4648. o[k2] = m[k];
  4649. });
  4650. var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
  4651. Object.defineProperty(o, "default", { enumerable: true, value: v });
  4652. } : function (o, v) {
  4653. o["default"] = v;
  4654. });
  4655. var __importStar = this && this.__importStar || function (mod) {
  4656. if (mod && mod.__esModule) return mod;
  4657. var result = {};
  4658. if (mod != null) for (var k in mod) {
  4659. if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  4660. }__setModuleDefault(result, mod);
  4661. return result;
  4662. };
  4663. var __exportStar = this && this.__exportStar || function (m, exports) {
  4664. for (var p in m) {
  4665. if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  4666. }
  4667. };
  4668. Object.defineProperty(exports, "__esModule", { value: true });
  4669. exports.util = void 0;
  4670. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-drawer/util.ts"));
  4671. exports.util = util;
  4672. __exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-drawer/adapter.ts"), exports);
  4673. __exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-drawer/component.ts"), exports);
  4674. __exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-drawer/constants.ts"), exports);
  4675. __exportStar(__webpack_require__(/*! ./dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts"), exports);
  4676. __exportStar(__webpack_require__(/*! ./modal/foundation */ "./packages/mdc-drawer/modal/foundation.ts"), exports);
  4677. /***/ }),
  4678. /***/ "./packages/mdc-drawer/modal/foundation.ts":
  4679. /*!*************************************************!*\
  4680. !*** ./packages/mdc-drawer/modal/foundation.ts ***!
  4681. \*************************************************/
  4682. /*! no static exports found */
  4683. /***/ (function(module, exports, __webpack_require__) {
  4684. "use strict";
  4685. /**
  4686. * @license
  4687. * Copyright 2018 Google Inc.
  4688. *
  4689. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4690. * of this software and associated documentation files (the "Software"), to deal
  4691. * in the Software without restriction, including without limitation the rights
  4692. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4693. * copies of the Software, and to permit persons to whom the Software is
  4694. * furnished to do so, subject to the following conditions:
  4695. *
  4696. * The above copyright notice and this permission notice shall be included in
  4697. * all copies or substantial portions of the Software.
  4698. *
  4699. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4700. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4701. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4702. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4703. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4704. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4705. * THE SOFTWARE.
  4706. */
  4707. var __extends = this && this.__extends || function () {
  4708. var _extendStatics = function extendStatics(d, b) {
  4709. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4710. d.__proto__ = b;
  4711. } || function (d, b) {
  4712. for (var p in b) {
  4713. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  4714. }
  4715. };
  4716. return _extendStatics(d, b);
  4717. };
  4718. return function (d, b) {
  4719. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  4720. _extendStatics(d, b);
  4721. function __() {
  4722. this.constructor = d;
  4723. }
  4724. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4725. };
  4726. }();
  4727. Object.defineProperty(exports, "__esModule", { value: true });
  4728. exports.MDCModalDrawerFoundation = void 0;
  4729. var foundation_1 = __webpack_require__(/*! ../dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts");
  4730. /* istanbul ignore next: subclass is not a branch statement */
  4731. var MDCModalDrawerFoundation = /** @class */function (_super) {
  4732. __extends(MDCModalDrawerFoundation, _super);
  4733. function MDCModalDrawerFoundation() {
  4734. return _super !== null && _super.apply(this, arguments) || this;
  4735. }
  4736. /**
  4737. * Handles click event on scrim.
  4738. */
  4739. MDCModalDrawerFoundation.prototype.handleScrimClick = function () {
  4740. this.close();
  4741. };
  4742. /**
  4743. * Called when drawer finishes open animation.
  4744. */
  4745. MDCModalDrawerFoundation.prototype.opened = function () {
  4746. this.adapter.trapFocus();
  4747. };
  4748. /**
  4749. * Called when drawer finishes close animation.
  4750. */
  4751. MDCModalDrawerFoundation.prototype.closed = function () {
  4752. this.adapter.releaseFocus();
  4753. };
  4754. return MDCModalDrawerFoundation;
  4755. }(foundation_1.MDCDismissibleDrawerFoundation);
  4756. exports.MDCModalDrawerFoundation = MDCModalDrawerFoundation;
  4757. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  4758. exports.default = MDCModalDrawerFoundation;
  4759. /***/ }),
  4760. /***/ "./packages/mdc-drawer/util.ts":
  4761. /*!*************************************!*\
  4762. !*** ./packages/mdc-drawer/util.ts ***!
  4763. \*************************************/
  4764. /*! no static exports found */
  4765. /***/ (function(module, exports, __webpack_require__) {
  4766. "use strict";
  4767. /**
  4768. * @license
  4769. * Copyright 2016 Google Inc.
  4770. *
  4771. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4772. * of this software and associated documentation files (the "Software"), to deal
  4773. * in the Software without restriction, including without limitation the rights
  4774. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4775. * copies of the Software, and to permit persons to whom the Software is
  4776. * furnished to do so, subject to the following conditions:
  4777. *
  4778. * The above copyright notice and this permission notice shall be included in
  4779. * all copies or substantial portions of the Software.
  4780. *
  4781. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4782. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4783. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4784. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4785. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4786. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4787. * THE SOFTWARE.
  4788. */
  4789. Object.defineProperty(exports, "__esModule", { value: true });
  4790. exports.createFocusTrapInstance = void 0;
  4791. function createFocusTrapInstance(surfaceEl, focusTrapFactory) {
  4792. return focusTrapFactory(surfaceEl, {
  4793. // Component handles focusing on active nav item.
  4794. skipInitialFocus: true
  4795. });
  4796. }
  4797. exports.createFocusTrapInstance = createFocusTrapInstance;
  4798. /***/ }),
  4799. /***/ "./packages/mdc-list/component.ts":
  4800. /*!****************************************!*\
  4801. !*** ./packages/mdc-list/component.ts ***!
  4802. \****************************************/
  4803. /*! no static exports found */
  4804. /***/ (function(module, exports, __webpack_require__) {
  4805. "use strict";
  4806. /**
  4807. * @license
  4808. * Copyright 2018 Google Inc.
  4809. *
  4810. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4811. * of this software and associated documentation files (the "Software"), to deal
  4812. * in the Software without restriction, including without limitation the rights
  4813. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4814. * copies of the Software, and to permit persons to whom the Software is
  4815. * furnished to do so, subject to the following conditions:
  4816. *
  4817. * The above copyright notice and this permission notice shall be included in
  4818. * all copies or substantial portions of the Software.
  4819. *
  4820. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4821. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4822. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4823. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4824. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4825. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4826. * THE SOFTWARE.
  4827. */
  4828. var __extends = this && this.__extends || function () {
  4829. var _extendStatics = function extendStatics(d, b) {
  4830. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4831. d.__proto__ = b;
  4832. } || function (d, b) {
  4833. for (var p in b) {
  4834. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  4835. }
  4836. };
  4837. return _extendStatics(d, b);
  4838. };
  4839. return function (d, b) {
  4840. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  4841. _extendStatics(d, b);
  4842. function __() {
  4843. this.constructor = d;
  4844. }
  4845. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4846. };
  4847. }();
  4848. Object.defineProperty(exports, "__esModule", { value: true });
  4849. exports.MDCList = void 0;
  4850. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  4851. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  4852. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
  4853. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-list/foundation.ts");
  4854. /** MDC List */
  4855. var MDCList = /** @class */function (_super) {
  4856. __extends(MDCList, _super);
  4857. function MDCList() {
  4858. return _super !== null && _super.apply(this, arguments) || this;
  4859. }
  4860. Object.defineProperty(MDCList.prototype, "vertical", {
  4861. set: function set(value) {
  4862. this.foundation.setVerticalOrientation(value);
  4863. },
  4864. enumerable: false,
  4865. configurable: true
  4866. });
  4867. Object.defineProperty(MDCList.prototype, "listElements", {
  4868. get: function get() {
  4869. return Array.from(this.root.querySelectorAll("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS]));
  4870. },
  4871. enumerable: false,
  4872. configurable: true
  4873. });
  4874. Object.defineProperty(MDCList.prototype, "wrapFocus", {
  4875. set: function set(value) {
  4876. this.foundation.setWrapFocus(value);
  4877. },
  4878. enumerable: false,
  4879. configurable: true
  4880. });
  4881. Object.defineProperty(MDCList.prototype, "typeaheadInProgress", {
  4882. /**
  4883. * @return Whether typeahead is currently matching a user-specified prefix.
  4884. */
  4885. get: function get() {
  4886. return this.foundation.isTypeaheadInProgress();
  4887. },
  4888. enumerable: false,
  4889. configurable: true
  4890. });
  4891. Object.defineProperty(MDCList.prototype, "hasTypeahead", {
  4892. /**
  4893. * Sets whether typeahead functionality is enabled on the list.
  4894. * @param hasTypeahead Whether typeahead is enabled.
  4895. */
  4896. set: function set(hasTypeahead) {
  4897. this.foundation.setHasTypeahead(hasTypeahead);
  4898. },
  4899. enumerable: false,
  4900. configurable: true
  4901. });
  4902. Object.defineProperty(MDCList.prototype, "singleSelection", {
  4903. set: function set(isSingleSelectionList) {
  4904. this.foundation.setSingleSelection(isSingleSelectionList);
  4905. },
  4906. enumerable: false,
  4907. configurable: true
  4908. });
  4909. Object.defineProperty(MDCList.prototype, "disabledItemsFocusable", {
  4910. set: function set(areDisabledItemsFocusable) {
  4911. this.foundation.setDisabledItemsFocusable(areDisabledItemsFocusable);
  4912. },
  4913. enumerable: false,
  4914. configurable: true
  4915. });
  4916. Object.defineProperty(MDCList.prototype, "selectedIndex", {
  4917. get: function get() {
  4918. return this.foundation.getSelectedIndex();
  4919. },
  4920. set: function set(index) {
  4921. this.foundation.setSelectedIndex(index);
  4922. },
  4923. enumerable: false,
  4924. configurable: true
  4925. });
  4926. MDCList.attachTo = function (root) {
  4927. return new MDCList(root);
  4928. };
  4929. MDCList.prototype.initialSyncWithDOM = function () {
  4930. this.isEvolutionEnabled = constants_1.evolutionAttribute in this.root.dataset;
  4931. if (this.isEvolutionEnabled) {
  4932. this.classNameMap = constants_1.evolutionClassNameMap;
  4933. } else if (ponyfill_1.matches(this.root, constants_1.strings.DEPRECATED_SELECTOR)) {
  4934. this.classNameMap = constants_1.deprecatedClassNameMap;
  4935. } else {
  4936. this.classNameMap = Object.values(constants_1.cssClasses).reduce(function (obj, className) {
  4937. obj[className] = className;
  4938. return obj;
  4939. }, {});
  4940. }
  4941. this.handleClick = this.handleClickEvent.bind(this);
  4942. this.handleKeydown = this.handleKeydownEvent.bind(this);
  4943. this.focusInEventListener = this.handleFocusInEvent.bind(this);
  4944. this.focusOutEventListener = this.handleFocusOutEvent.bind(this);
  4945. this.listen('keydown', this.handleKeydown);
  4946. this.listen('click', this.handleClick);
  4947. this.listen('focusin', this.focusInEventListener);
  4948. this.listen('focusout', this.focusOutEventListener);
  4949. this.layout();
  4950. this.initializeListType();
  4951. this.ensureFocusable();
  4952. };
  4953. MDCList.prototype.destroy = function () {
  4954. this.unlisten('keydown', this.handleKeydown);
  4955. this.unlisten('click', this.handleClick);
  4956. this.unlisten('focusin', this.focusInEventListener);
  4957. this.unlisten('focusout', this.focusOutEventListener);
  4958. };
  4959. MDCList.prototype.layout = function () {
  4960. var direction = this.root.getAttribute(constants_1.strings.ARIA_ORIENTATION);
  4961. this.vertical = direction !== constants_1.strings.ARIA_ORIENTATION_HORIZONTAL;
  4962. var itemSelector = "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not([tabindex])";
  4963. var childSelector = constants_1.strings.FOCUSABLE_CHILD_ELEMENTS;
  4964. // List items need to have at least tabindex=-1 to be focusable.
  4965. var itemEls = this.root.querySelectorAll(itemSelector);
  4966. if (itemEls.length) {
  4967. Array.prototype.forEach.call(itemEls, function (el) {
  4968. el.setAttribute('tabindex', '-1');
  4969. });
  4970. }
  4971. // Child button/a elements are not tabbable until the list item is focused.
  4972. var focusableChildEls = this.root.querySelectorAll(childSelector);
  4973. if (focusableChildEls.length) {
  4974. Array.prototype.forEach.call(focusableChildEls, function (el) {
  4975. el.setAttribute('tabindex', '-1');
  4976. });
  4977. }
  4978. if (this.isEvolutionEnabled) {
  4979. this.foundation.setUseSelectedAttribute(true);
  4980. }
  4981. this.foundation.layout();
  4982. };
  4983. /**
  4984. * Extracts the primary text from a list item.
  4985. * @param item The list item element.
  4986. * @return The primary text in the element.
  4987. */
  4988. MDCList.prototype.getPrimaryText = function (item) {
  4989. var _a;
  4990. var primaryText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS]);
  4991. if (this.isEvolutionEnabled || primaryText) {
  4992. return (_a = primaryText === null || primaryText === void 0 ? void 0 : primaryText.textContent) !== null && _a !== void 0 ? _a : '';
  4993. }
  4994. var singleLineText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_TEXT_CLASS]);
  4995. return singleLineText && singleLineText.textContent || '';
  4996. };
  4997. /**
  4998. * Initialize selectedIndex value based on pre-selected list items.
  4999. */
  5000. MDCList.prototype.initializeListType = function () {
  5001. var _this = this;
  5002. this.isInteractive = ponyfill_1.matches(this.root, constants_1.strings.ARIA_INTERACTIVE_ROLES_SELECTOR);
  5003. if (this.isEvolutionEnabled && this.isInteractive) {
  5004. var selection = Array.from(this.root.querySelectorAll(constants_1.strings.SELECTED_ITEM_SELECTOR), function (listItem) {
  5005. return _this.listElements.indexOf(listItem);
  5006. });
  5007. if (ponyfill_1.matches(this.root, constants_1.strings.ARIA_MULTI_SELECTABLE_SELECTOR)) {
  5008. this.selectedIndex = selection;
  5009. } else if (selection.length > 0) {
  5010. this.selectedIndex = selection[0];
  5011. }
  5012. return;
  5013. }
  5014. var checkboxListItems = this.root.querySelectorAll(constants_1.strings.ARIA_ROLE_CHECKBOX_SELECTOR);
  5015. var radioSelectedListItem = this.root.querySelector(constants_1.strings.ARIA_CHECKED_RADIO_SELECTOR);
  5016. if (checkboxListItems.length) {
  5017. var preselectedItems = this.root.querySelectorAll(constants_1.strings.ARIA_CHECKED_CHECKBOX_SELECTOR);
  5018. this.selectedIndex = Array.from(preselectedItems, function (listItem) {
  5019. return _this.listElements.indexOf(listItem);
  5020. });
  5021. } else if (radioSelectedListItem) {
  5022. this.selectedIndex = this.listElements.indexOf(radioSelectedListItem);
  5023. }
  5024. };
  5025. /**
  5026. * Updates the list item at itemIndex to the desired isEnabled state.
  5027. * @param itemIndex Index of the list item
  5028. * @param isEnabled Sets the list item to enabled or disabled.
  5029. */
  5030. MDCList.prototype.setEnabled = function (itemIndex, isEnabled) {
  5031. this.foundation.setEnabled(itemIndex, isEnabled);
  5032. };
  5033. /**
  5034. * Given the next desired character from the user, adds it to the typeahead
  5035. * buffer. Then, attempts to find the next option matching the buffer. Wraps
  5036. * around if at the end of options.
  5037. *
  5038. * @param nextChar The next character to add to the prefix buffer.
  5039. * @param startingIndex The index from which to start matching. Defaults to
  5040. * the currently focused index.
  5041. * @return The index of the matched item.
  5042. */
  5043. MDCList.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
  5044. return this.foundation.typeaheadMatchItem(nextChar, startingIndex, /** skipFocus */true);
  5045. };
  5046. MDCList.prototype.getDefaultFoundation = function () {
  5047. var _this = this;
  5048. // DO NOT INLINE this variable. For backward compatibility, foundations take
  5049. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  5050. // methods, we need a separate, strongly typed adapter variable.
  5051. var adapter = {
  5052. addClassForElementIndex: function addClassForElementIndex(index, className) {
  5053. var element = _this.listElements[index];
  5054. if (element) {
  5055. element.classList.add(_this.classNameMap[className]);
  5056. }
  5057. },
  5058. focusItemAtIndex: function focusItemAtIndex(index) {
  5059. var _a;
  5060. (_a = _this.listElements[index]) === null || _a === void 0 ? void 0 : _a.focus();
  5061. },
  5062. getAttributeForElementIndex: function getAttributeForElementIndex(index, attr) {
  5063. return _this.listElements[index].getAttribute(attr);
  5064. },
  5065. getFocusedElementIndex: function getFocusedElementIndex() {
  5066. return _this.listElements.indexOf(document.activeElement);
  5067. },
  5068. getListItemCount: function getListItemCount() {
  5069. return _this.listElements.length;
  5070. },
  5071. getPrimaryTextAtIndex: function getPrimaryTextAtIndex(index) {
  5072. return _this.getPrimaryText(_this.listElements[index]);
  5073. },
  5074. hasCheckboxAtIndex: function hasCheckboxAtIndex(index) {
  5075. var listItem = _this.listElements[index];
  5076. return !!listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
  5077. },
  5078. hasRadioAtIndex: function hasRadioAtIndex(index) {
  5079. var listItem = _this.listElements[index];
  5080. return !!listItem.querySelector(constants_1.strings.RADIO_SELECTOR);
  5081. },
  5082. isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex(index) {
  5083. var listItem = _this.listElements[index];
  5084. var toggleEl = listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
  5085. return toggleEl.checked;
  5086. },
  5087. isFocusInsideList: function isFocusInsideList() {
  5088. return _this.root !== document.activeElement && _this.root.contains(document.activeElement);
  5089. },
  5090. isRootFocused: function isRootFocused() {
  5091. return document.activeElement === _this.root;
  5092. },
  5093. listItemAtIndexHasClass: function listItemAtIndexHasClass(index, className) {
  5094. return _this.listElements[index].classList.contains(_this.classNameMap[className]);
  5095. },
  5096. notifyAction: function notifyAction(index) {
  5097. _this.emit(constants_1.strings.ACTION_EVENT, { index: index }, /** shouldBubble */true);
  5098. },
  5099. notifySelectionChange: function notifySelectionChange(changedIndices) {
  5100. _this.emit(constants_1.strings.SELECTION_CHANGE_EVENT, { changedIndices: changedIndices },
  5101. /** shouldBubble */true);
  5102. },
  5103. removeClassForElementIndex: function removeClassForElementIndex(index, className) {
  5104. var element = _this.listElements[index];
  5105. if (element) {
  5106. element.classList.remove(_this.classNameMap[className]);
  5107. }
  5108. },
  5109. setAttributeForElementIndex: function setAttributeForElementIndex(index, attr, value) {
  5110. var element = _this.listElements[index];
  5111. if (element) {
  5112. _this.safeSetAttribute(element, attr, value);
  5113. }
  5114. },
  5115. setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex(index, isChecked) {
  5116. var listItem = _this.listElements[index];
  5117. var toggleEl = listItem.querySelector(constants_1.strings.CHECKBOX_RADIO_SELECTOR);
  5118. toggleEl.checked = isChecked;
  5119. var event = document.createEvent('Event');
  5120. event.initEvent('change', true, true);
  5121. toggleEl.dispatchEvent(event);
  5122. },
  5123. setTabIndexForListItemChildren: function setTabIndexForListItemChildren(listItemIndex, tabIndexValue) {
  5124. var element = _this.listElements[listItemIndex];
  5125. var selector = constants_1.strings.CHILD_ELEMENTS_TO_TOGGLE_TABINDEX;
  5126. Array.prototype.forEach.call(element.querySelectorAll(selector), function (el) {
  5127. el.tabIndex = Number(tabIndexValue);
  5128. });
  5129. }
  5130. };
  5131. return new foundation_1.MDCListFoundation(adapter);
  5132. };
  5133. /**
  5134. * Ensures that at least one item is focusable if the list is interactive and
  5135. * doesn't specify a suitable tabindex.
  5136. */
  5137. MDCList.prototype.ensureFocusable = function () {
  5138. if (this.isEvolutionEnabled && this.isInteractive) {
  5139. if (!this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + "[tabindex=\"0\"]")) {
  5140. var index = this.initialFocusIndex();
  5141. if (index !== -1) {
  5142. this.listElements[index].tabIndex = 0;
  5143. }
  5144. }
  5145. }
  5146. };
  5147. MDCList.prototype.initialFocusIndex = function () {
  5148. if (this.selectedIndex instanceof Array && this.selectedIndex.length > 0) {
  5149. return this.selectedIndex[0];
  5150. }
  5151. if (typeof this.selectedIndex === 'number' && this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
  5152. return this.selectedIndex;
  5153. }
  5154. var el = this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not(." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS] + ")");
  5155. if (el === null) {
  5156. return -1;
  5157. }
  5158. return this.getListItemIndex(el);
  5159. };
  5160. /**
  5161. * Used to figure out which list item this event is targeting. Or returns -1
  5162. * if there is no list item
  5163. */
  5164. MDCList.prototype.getListItemIndex = function (el) {
  5165. var nearestParent = ponyfill_1.closest(el, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ", ." + this.classNameMap[constants_1.cssClasses.ROOT]);
  5166. // Get the index of the element if it is a list item.
  5167. if (nearestParent && ponyfill_1.matches(nearestParent, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS])) {
  5168. return this.listElements.indexOf(nearestParent);
  5169. }
  5170. return -1;
  5171. };
  5172. /**
  5173. * Used to figure out which element was clicked before sending the event to
  5174. * the foundation.
  5175. */
  5176. MDCList.prototype.handleFocusInEvent = function (evt) {
  5177. var index = this.getListItemIndex(evt.target);
  5178. this.foundation.handleFocusIn(index);
  5179. };
  5180. /**
  5181. * Used to figure out which element was clicked before sending the event to
  5182. * the foundation.
  5183. */
  5184. MDCList.prototype.handleFocusOutEvent = function (evt) {
  5185. var index = this.getListItemIndex(evt.target);
  5186. this.foundation.handleFocusOut(index);
  5187. };
  5188. /**
  5189. * Used to figure out which element was focused when keydown event occurred
  5190. * before sending the event to the foundation.
  5191. */
  5192. MDCList.prototype.handleKeydownEvent = function (evt) {
  5193. var index = this.getListItemIndex(evt.target);
  5194. var target = evt.target;
  5195. this.foundation.handleKeydown(evt, target.classList.contains(this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS]), index);
  5196. };
  5197. /**
  5198. * Used to figure out which element was clicked before sending the event to
  5199. * the foundation.
  5200. */
  5201. MDCList.prototype.handleClickEvent = function (evt) {
  5202. var index = this.getListItemIndex(evt.target);
  5203. var target = evt.target;
  5204. this.foundation.handleClick(index, ponyfill_1.matches(target, constants_1.strings.CHECKBOX_RADIO_SELECTOR), evt);
  5205. };
  5206. return MDCList;
  5207. }(component_1.MDCComponent);
  5208. exports.MDCList = MDCList;
  5209. /***/ }),
  5210. /***/ "./packages/mdc-list/constants.ts":
  5211. /*!****************************************!*\
  5212. !*** ./packages/mdc-list/constants.ts ***!
  5213. \****************************************/
  5214. /*! no static exports found */
  5215. /***/ (function(module, exports, __webpack_require__) {
  5216. "use strict";
  5217. /**
  5218. * @license
  5219. * Copyright 2018 Google Inc.
  5220. *
  5221. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5222. * of this software and associated documentation files (the "Software"), to deal
  5223. * in the Software without restriction, including without limitation the rights
  5224. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5225. * copies of the Software, and to permit persons to whom the Software is
  5226. * furnished to do so, subject to the following conditions:
  5227. *
  5228. * The above copyright notice and this permission notice shall be included in
  5229. * all copies or substantial portions of the Software.
  5230. *
  5231. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5232. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5233. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5234. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5235. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5236. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5237. * THE SOFTWARE.
  5238. */
  5239. var _a, _b;
  5240. Object.defineProperty(exports, "__esModule", { value: true });
  5241. exports.evolutionClassNameMap = exports.evolutionAttribute = exports.deprecatedClassNameMap = exports.numbers = exports.cssClasses = exports.strings = void 0;
  5242. var cssClasses = {
  5243. LIST_ITEM_ACTIVATED_CLASS: 'mdc-list-item--activated',
  5244. LIST_ITEM_CLASS: 'mdc-list-item',
  5245. LIST_ITEM_DISABLED_CLASS: 'mdc-list-item--disabled',
  5246. LIST_ITEM_SELECTED_CLASS: 'mdc-list-item--selected',
  5247. LIST_ITEM_TEXT_CLASS: 'mdc-list-item__text',
  5248. LIST_ITEM_PRIMARY_TEXT_CLASS: 'mdc-list-item__primary-text',
  5249. ROOT: 'mdc-list'
  5250. };
  5251. exports.cssClasses = cssClasses;
  5252. var evolutionClassNameMap = (_a = {}, _a["" + cssClasses.LIST_ITEM_ACTIVATED_CLASS] = 'mdc-list-item--activated', _a["" + cssClasses.LIST_ITEM_CLASS] = 'mdc-list-item', _a["" + cssClasses.LIST_ITEM_DISABLED_CLASS] = 'mdc-list-item--disabled', _a["" + cssClasses.LIST_ITEM_SELECTED_CLASS] = 'mdc-list-item--selected', _a["" + cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS] = 'mdc-list-item__primary-text', _a["" + cssClasses.ROOT] = 'mdc-list', _a);
  5253. exports.evolutionClassNameMap = evolutionClassNameMap;
  5254. var deprecatedClassNameMap = (_b = {}, _b["" + cssClasses.LIST_ITEM_ACTIVATED_CLASS] = 'mdc-deprecated-list-item--activated', _b["" + cssClasses.LIST_ITEM_CLASS] = 'mdc-deprecated-list-item', _b["" + cssClasses.LIST_ITEM_DISABLED_CLASS] = 'mdc-deprecated-list-item--disabled', _b["" + cssClasses.LIST_ITEM_SELECTED_CLASS] = 'mdc-deprecated-list-item--selected', _b["" + cssClasses.LIST_ITEM_TEXT_CLASS] = 'mdc-deprecated-list-item__text', _b["" + cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS] = 'mdc-deprecated-list-item__primary-text', _b["" + cssClasses.ROOT] = 'mdc-deprecated-list', _b);
  5255. exports.deprecatedClassNameMap = deprecatedClassNameMap;
  5256. var strings = {
  5257. ACTION_EVENT: 'MDCList:action',
  5258. SELECTION_CHANGE_EVENT: 'MDCList:selectionChange',
  5259. ARIA_CHECKED: 'aria-checked',
  5260. ARIA_CHECKED_CHECKBOX_SELECTOR: '[role="checkbox"][aria-checked="true"]',
  5261. ARIA_CHECKED_RADIO_SELECTOR: '[role="radio"][aria-checked="true"]',
  5262. ARIA_CURRENT: 'aria-current',
  5263. ARIA_DISABLED: 'aria-disabled',
  5264. ARIA_ORIENTATION: 'aria-orientation',
  5265. ARIA_ORIENTATION_HORIZONTAL: 'horizontal',
  5266. ARIA_ROLE_CHECKBOX_SELECTOR: '[role="checkbox"]',
  5267. ARIA_SELECTED: 'aria-selected',
  5268. ARIA_INTERACTIVE_ROLES_SELECTOR: '[role="listbox"], [role="menu"]',
  5269. ARIA_MULTI_SELECTABLE_SELECTOR: '[aria-multiselectable="true"]',
  5270. CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"], input[type="radio"]',
  5271. CHECKBOX_SELECTOR: 'input[type="checkbox"]',
  5272. CHILD_ELEMENTS_TO_TOGGLE_TABINDEX: "\n ." + cssClasses.LIST_ITEM_CLASS + " button:not(:disabled),\n ." + cssClasses.LIST_ITEM_CLASS + " a,\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " button:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " a\n ",
  5273. DEPRECATED_SELECTOR: '.mdc-deprecated-list',
  5274. FOCUSABLE_CHILD_ELEMENTS: "\n ." + cssClasses.LIST_ITEM_CLASS + " button:not(:disabled),\n ." + cssClasses.LIST_ITEM_CLASS + " a,\n ." + cssClasses.LIST_ITEM_CLASS + " input[type=\"radio\"]:not(:disabled),\n ." + cssClasses.LIST_ITEM_CLASS + " input[type=\"checkbox\"]:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " button:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " a,\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " input[type=\"radio\"]:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " input[type=\"checkbox\"]:not(:disabled)\n ",
  5275. RADIO_SELECTOR: 'input[type="radio"]',
  5276. SELECTED_ITEM_SELECTOR: '[aria-selected="true"], [aria-current="true"]'
  5277. };
  5278. exports.strings = strings;
  5279. var numbers = {
  5280. UNSET_INDEX: -1,
  5281. TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS: 300
  5282. };
  5283. exports.numbers = numbers;
  5284. var evolutionAttribute = 'evolution';
  5285. exports.evolutionAttribute = evolutionAttribute;
  5286. /***/ }),
  5287. /***/ "./packages/mdc-list/events.ts":
  5288. /*!*************************************!*\
  5289. !*** ./packages/mdc-list/events.ts ***!
  5290. \*************************************/
  5291. /*! no static exports found */
  5292. /***/ (function(module, exports, __webpack_require__) {
  5293. "use strict";
  5294. /**
  5295. * @license
  5296. * Copyright 2020 Google Inc.
  5297. *
  5298. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5299. * of this software and associated documentation files (the "Software"), to deal
  5300. * in the Software without restriction, including without limitation the rights
  5301. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5302. * copies of the Software, and to permit persons to whom the Software is
  5303. * furnished to do so, subject to the following conditions:
  5304. *
  5305. * The above copyright notice and this permission notice shall be included in
  5306. * all copies or substantial portions of the Software.
  5307. *
  5308. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5309. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5310. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5311. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5312. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5313. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5314. * THE SOFTWARE.
  5315. */
  5316. Object.defineProperty(exports, "__esModule", { value: true });
  5317. exports.preventDefaultEvent = void 0;
  5318. var ELEMENTS_KEY_ALLOWED_IN = ['input', 'button', 'textarea', 'select'];
  5319. /**
  5320. * Ensures that preventDefault is only called if the containing element
  5321. * doesn't consume the event, and it will cause an unintended scroll.
  5322. *
  5323. * @param evt keyboard event to be prevented.
  5324. */
  5325. var preventDefaultEvent = function preventDefaultEvent(evt) {
  5326. var target = evt.target;
  5327. if (!target) {
  5328. return;
  5329. }
  5330. var tagName = ("" + target.tagName).toLowerCase();
  5331. if (ELEMENTS_KEY_ALLOWED_IN.indexOf(tagName) === -1) {
  5332. evt.preventDefault();
  5333. }
  5334. };
  5335. exports.preventDefaultEvent = preventDefaultEvent;
  5336. /***/ }),
  5337. /***/ "./packages/mdc-list/foundation.ts":
  5338. /*!*****************************************!*\
  5339. !*** ./packages/mdc-list/foundation.ts ***!
  5340. \*****************************************/
  5341. /*! no static exports found */
  5342. /***/ (function(module, exports, __webpack_require__) {
  5343. "use strict";
  5344. /**
  5345. * @license
  5346. * Copyright 2018 Google Inc.
  5347. *
  5348. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5349. * of this software and associated documentation files (the "Software"), to deal
  5350. * in the Software without restriction, including without limitation the rights
  5351. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5352. * copies of the Software, and to permit persons to whom the Software is
  5353. * furnished to do so, subject to the following conditions:
  5354. *
  5355. * The above copyright notice and this permission notice shall be included in
  5356. * all copies or substantial portions of the Software.
  5357. *
  5358. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5359. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5360. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5361. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5362. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5363. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5364. * THE SOFTWARE.
  5365. */
  5366. var __extends = this && this.__extends || function () {
  5367. var _extendStatics = function extendStatics(d, b) {
  5368. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  5369. d.__proto__ = b;
  5370. } || function (d, b) {
  5371. for (var p in b) {
  5372. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  5373. }
  5374. };
  5375. return _extendStatics(d, b);
  5376. };
  5377. return function (d, b) {
  5378. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  5379. _extendStatics(d, b);
  5380. function __() {
  5381. this.constructor = d;
  5382. }
  5383. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5384. };
  5385. }();
  5386. var __assign = this && this.__assign || function () {
  5387. __assign = Object.assign || function (t) {
  5388. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5389. s = arguments[i];
  5390. for (var p in s) {
  5391. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  5392. }
  5393. }
  5394. return t;
  5395. };
  5396. return __assign.apply(this, arguments);
  5397. };
  5398. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  5399. if (k2 === undefined) k2 = k;
  5400. Object.defineProperty(o, k2, { enumerable: true, get: function get() {
  5401. return m[k];
  5402. } });
  5403. } : function (o, m, k, k2) {
  5404. if (k2 === undefined) k2 = k;
  5405. o[k2] = m[k];
  5406. });
  5407. var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
  5408. Object.defineProperty(o, "default", { enumerable: true, value: v });
  5409. } : function (o, v) {
  5410. o["default"] = v;
  5411. });
  5412. var __importStar = this && this.__importStar || function (mod) {
  5413. if (mod && mod.__esModule) return mod;
  5414. var result = {};
  5415. if (mod != null) for (var k in mod) {
  5416. if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  5417. }__setModuleDefault(result, mod);
  5418. return result;
  5419. };
  5420. var __read = this && this.__read || function (o, n) {
  5421. var m = typeof Symbol === "function" && o[Symbol.iterator];
  5422. if (!m) return o;
  5423. var i = m.call(o),
  5424. r,
  5425. ar = [],
  5426. e;
  5427. try {
  5428. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  5429. ar.push(r.value);
  5430. }
  5431. } catch (error) {
  5432. e = { error: error };
  5433. } finally {
  5434. try {
  5435. if (r && !r.done && (m = i["return"])) m.call(i);
  5436. } finally {
  5437. if (e) throw e.error;
  5438. }
  5439. }
  5440. return ar;
  5441. };
  5442. var __spreadArray = this && this.__spreadArray || function (to, from) {
  5443. for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
  5444. to[j] = from[i];
  5445. }return to;
  5446. };
  5447. var __values = this && this.__values || function (o) {
  5448. var s = typeof Symbol === "function" && Symbol.iterator,
  5449. m = s && o[s],
  5450. i = 0;
  5451. if (m) return m.call(o);
  5452. if (o && typeof o.length === "number") return {
  5453. next: function next() {
  5454. if (o && i >= o.length) o = void 0;
  5455. return { value: o && o[i++], done: !o };
  5456. }
  5457. };
  5458. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  5459. };
  5460. Object.defineProperty(exports, "__esModule", { value: true });
  5461. exports.MDCListFoundation = void 0;
  5462. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  5463. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  5464. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
  5465. var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
  5466. var typeahead = __importStar(__webpack_require__(/*! ./typeahead */ "./packages/mdc-list/typeahead.ts"));
  5467. function isNumberArray(selectedIndex) {
  5468. return selectedIndex instanceof Array;
  5469. }
  5470. /** List of modifier keys to consider while handling keyboard events. */
  5471. var handledModifierKeys = ['Alt', 'Control', 'Meta', 'Shift'];
  5472. /** Checks if the event has the given modifier keys. */
  5473. function createModifierChecker(event) {
  5474. var eventModifiers = new Set(event ? handledModifierKeys.filter(function (m) {
  5475. return event.getModifierState(m);
  5476. }) : []);
  5477. return function (modifiers) {
  5478. return modifiers.every(function (m) {
  5479. return eventModifiers.has(m);
  5480. }) && modifiers.length === eventModifiers.size;
  5481. };
  5482. }
  5483. /** MDC List Foundation */
  5484. var MDCListFoundation = /** @class */function (_super) {
  5485. __extends(MDCListFoundation, _super);
  5486. function MDCListFoundation(adapter) {
  5487. var _this = _super.call(this, __assign(__assign({}, MDCListFoundation.defaultAdapter), adapter)) || this;
  5488. _this.wrapFocus = false;
  5489. _this.isVertical = true;
  5490. _this.isSingleSelectionList = false;
  5491. _this.areDisabledItemsFocusable = false;
  5492. _this.selectedIndex = constants_1.numbers.UNSET_INDEX;
  5493. _this.focusedItemIndex = constants_1.numbers.UNSET_INDEX;
  5494. _this.useActivatedClass = false;
  5495. _this.useSelectedAttr = false;
  5496. _this.ariaCurrentAttrValue = null;
  5497. _this.isCheckboxList = false;
  5498. _this.isRadioList = false;
  5499. _this.lastSelectedIndex = null;
  5500. _this.hasTypeahead = false;
  5501. // Transiently holds current typeahead prefix from user.
  5502. _this.typeaheadState = typeahead.initState();
  5503. _this.sortedIndexByFirstChar = new Map();
  5504. return _this;
  5505. }
  5506. Object.defineProperty(MDCListFoundation, "strings", {
  5507. get: function get() {
  5508. return constants_1.strings;
  5509. },
  5510. enumerable: false,
  5511. configurable: true
  5512. });
  5513. Object.defineProperty(MDCListFoundation, "cssClasses", {
  5514. get: function get() {
  5515. return constants_1.cssClasses;
  5516. },
  5517. enumerable: false,
  5518. configurable: true
  5519. });
  5520. Object.defineProperty(MDCListFoundation, "numbers", {
  5521. get: function get() {
  5522. return constants_1.numbers;
  5523. },
  5524. enumerable: false,
  5525. configurable: true
  5526. });
  5527. Object.defineProperty(MDCListFoundation, "defaultAdapter", {
  5528. get: function get() {
  5529. return {
  5530. addClassForElementIndex: function addClassForElementIndex() {
  5531. return undefined;
  5532. },
  5533. focusItemAtIndex: function focusItemAtIndex() {
  5534. return undefined;
  5535. },
  5536. getAttributeForElementIndex: function getAttributeForElementIndex() {
  5537. return null;
  5538. },
  5539. getFocusedElementIndex: function getFocusedElementIndex() {
  5540. return 0;
  5541. },
  5542. getListItemCount: function getListItemCount() {
  5543. return 0;
  5544. },
  5545. hasCheckboxAtIndex: function hasCheckboxAtIndex() {
  5546. return false;
  5547. },
  5548. hasRadioAtIndex: function hasRadioAtIndex() {
  5549. return false;
  5550. },
  5551. isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex() {
  5552. return false;
  5553. },
  5554. isFocusInsideList: function isFocusInsideList() {
  5555. return false;
  5556. },
  5557. isRootFocused: function isRootFocused() {
  5558. return false;
  5559. },
  5560. listItemAtIndexHasClass: function listItemAtIndexHasClass() {
  5561. return false;
  5562. },
  5563. notifyAction: function notifyAction() {
  5564. return undefined;
  5565. },
  5566. notifySelectionChange: function notifySelectionChange() {},
  5567. removeClassForElementIndex: function removeClassForElementIndex() {
  5568. return undefined;
  5569. },
  5570. setAttributeForElementIndex: function setAttributeForElementIndex() {
  5571. return undefined;
  5572. },
  5573. setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex() {
  5574. return undefined;
  5575. },
  5576. setTabIndexForListItemChildren: function setTabIndexForListItemChildren() {
  5577. return undefined;
  5578. },
  5579. getPrimaryTextAtIndex: function getPrimaryTextAtIndex() {
  5580. return '';
  5581. }
  5582. };
  5583. },
  5584. enumerable: false,
  5585. configurable: true
  5586. });
  5587. MDCListFoundation.prototype.layout = function () {
  5588. if (this.adapter.getListItemCount() === 0) {
  5589. return;
  5590. }
  5591. // TODO(b/172274142): consider all items when determining the list's type.
  5592. if (this.adapter.hasCheckboxAtIndex(0)) {
  5593. this.isCheckboxList = true;
  5594. this.selectedIndex = [];
  5595. } else if (this.adapter.hasRadioAtIndex(0)) {
  5596. this.isRadioList = true;
  5597. } else {
  5598. this.maybeInitializeSingleSelection();
  5599. }
  5600. if (this.hasTypeahead) {
  5601. this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
  5602. }
  5603. };
  5604. /** Returns the index of the item that was last focused. */
  5605. MDCListFoundation.prototype.getFocusedItemIndex = function () {
  5606. return this.focusedItemIndex;
  5607. };
  5608. /** Toggles focus wrapping with keyboard navigation. */
  5609. MDCListFoundation.prototype.setWrapFocus = function (value) {
  5610. this.wrapFocus = value;
  5611. };
  5612. /**
  5613. * Toggles orientation direction for keyboard navigation (true for vertical,
  5614. * false for horizontal).
  5615. */
  5616. MDCListFoundation.prototype.setVerticalOrientation = function (value) {
  5617. this.isVertical = value;
  5618. };
  5619. /** Toggles single-selection behavior. */
  5620. MDCListFoundation.prototype.setSingleSelection = function (value) {
  5621. this.isSingleSelectionList = value;
  5622. if (value) {
  5623. this.maybeInitializeSingleSelection();
  5624. this.selectedIndex = this.getSelectedIndexFromDOM();
  5625. }
  5626. };
  5627. MDCListFoundation.prototype.setDisabledItemsFocusable = function (value) {
  5628. this.areDisabledItemsFocusable = value;
  5629. };
  5630. /**
  5631. * Automatically determines whether the list is single selection list. If so,
  5632. * initializes the internal state to match the selected item.
  5633. */
  5634. MDCListFoundation.prototype.maybeInitializeSingleSelection = function () {
  5635. var selectedItemIndex = this.getSelectedIndexFromDOM();
  5636. if (selectedItemIndex === constants_1.numbers.UNSET_INDEX) return;
  5637. var hasActivatedClass = this.adapter.listItemAtIndexHasClass(selectedItemIndex, constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
  5638. if (hasActivatedClass) {
  5639. this.setUseActivatedClass(true);
  5640. }
  5641. this.isSingleSelectionList = true;
  5642. this.selectedIndex = selectedItemIndex;
  5643. };
  5644. /** @return Index of the first selected item based on the DOM state. */
  5645. MDCListFoundation.prototype.getSelectedIndexFromDOM = function () {
  5646. var selectedIndex = constants_1.numbers.UNSET_INDEX;
  5647. var listItemsCount = this.adapter.getListItemCount();
  5648. for (var i = 0; i < listItemsCount; i++) {
  5649. var hasSelectedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS);
  5650. var hasActivatedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
  5651. if (!(hasSelectedClass || hasActivatedClass)) {
  5652. continue;
  5653. }
  5654. selectedIndex = i;
  5655. break;
  5656. }
  5657. return selectedIndex;
  5658. };
  5659. /**
  5660. * Sets whether typeahead is enabled on the list.
  5661. * @param hasTypeahead Whether typeahead is enabled.
  5662. */
  5663. MDCListFoundation.prototype.setHasTypeahead = function (hasTypeahead) {
  5664. this.hasTypeahead = hasTypeahead;
  5665. if (hasTypeahead) {
  5666. this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
  5667. }
  5668. };
  5669. /**
  5670. * @return Whether typeahead is currently matching a user-specified prefix.
  5671. */
  5672. MDCListFoundation.prototype.isTypeaheadInProgress = function () {
  5673. return this.hasTypeahead && typeahead.isTypingInProgress(this.typeaheadState);
  5674. };
  5675. /** Toggle use of the "activated" CSS class. */
  5676. MDCListFoundation.prototype.setUseActivatedClass = function (useActivated) {
  5677. this.useActivatedClass = useActivated;
  5678. };
  5679. /**
  5680. * Toggles use of the selected attribute (true for aria-selected, false for
  5681. * aria-checked).
  5682. */
  5683. MDCListFoundation.prototype.setUseSelectedAttribute = function (useSelected) {
  5684. this.useSelectedAttr = useSelected;
  5685. };
  5686. MDCListFoundation.prototype.getSelectedIndex = function () {
  5687. return this.selectedIndex;
  5688. };
  5689. MDCListFoundation.prototype.setSelectedIndex = function (index, options) {
  5690. if (options === void 0) {
  5691. options = {};
  5692. }
  5693. if (!this.isIndexValid(index)) {
  5694. return;
  5695. }
  5696. if (this.isCheckboxList) {
  5697. this.setCheckboxAtIndex(index, options);
  5698. } else if (this.isRadioList) {
  5699. this.setRadioAtIndex(index, options);
  5700. } else {
  5701. this.setSingleSelectionAtIndex(index, options);
  5702. }
  5703. };
  5704. /**
  5705. * Focus in handler for the list items.
  5706. */
  5707. MDCListFoundation.prototype.handleFocusIn = function (listItemIndex) {
  5708. if (listItemIndex >= 0) {
  5709. this.focusedItemIndex = listItemIndex;
  5710. this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '0');
  5711. this.adapter.setTabIndexForListItemChildren(listItemIndex, '0');
  5712. }
  5713. };
  5714. /**
  5715. * Focus out handler for the list items.
  5716. */
  5717. MDCListFoundation.prototype.handleFocusOut = function (listItemIndex) {
  5718. var _this = this;
  5719. if (listItemIndex >= 0) {
  5720. this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '-1');
  5721. this.adapter.setTabIndexForListItemChildren(listItemIndex, '-1');
  5722. }
  5723. /**
  5724. * Between Focusout & Focusin some browsers do not have focus on any
  5725. * element. Setting a delay to wait till the focus is moved to next element.
  5726. */
  5727. setTimeout(function () {
  5728. if (!_this.adapter.isFocusInsideList()) {
  5729. _this.setTabindexToFirstSelectedOrFocusedItem();
  5730. }
  5731. }, 0);
  5732. };
  5733. MDCListFoundation.prototype.isIndexDisabled = function (index) {
  5734. return this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  5735. };
  5736. /**
  5737. * Key handler for the list.
  5738. */
  5739. MDCListFoundation.prototype.handleKeydown = function (event, isRootListItem, listItemIndex) {
  5740. var _this = this;
  5741. var _a;
  5742. var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
  5743. var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
  5744. var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
  5745. var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
  5746. var isHome = keyboard_1.normalizeKey(event) === 'Home';
  5747. var isEnd = keyboard_1.normalizeKey(event) === 'End';
  5748. var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
  5749. var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
  5750. // The keys for forward and back differ based on list orientation.
  5751. var isForward = this.isVertical && isArrowDown || !this.isVertical && isArrowRight;
  5752. var isBack = this.isVertical && isArrowUp || !this.isVertical && isArrowLeft;
  5753. // Have to check both upper and lower case, because having caps lock on
  5754. // affects the value.
  5755. var isLetterA = event.key === 'A' || event.key === 'a';
  5756. var eventHasModifiers = createModifierChecker(event);
  5757. if (this.adapter.isRootFocused()) {
  5758. if ((isBack || isEnd) && eventHasModifiers([])) {
  5759. event.preventDefault();
  5760. this.focusLastElement();
  5761. } else if ((isForward || isHome) && eventHasModifiers([])) {
  5762. event.preventDefault();
  5763. this.focusFirstElement();
  5764. } else if (isBack && eventHasModifiers(['Shift']) && this.isCheckboxList) {
  5765. event.preventDefault();
  5766. var focusedIndex = this.focusLastElement();
  5767. if (focusedIndex !== -1) {
  5768. this.setSelectedIndexOnAction(focusedIndex, false);
  5769. }
  5770. } else if (isForward && eventHasModifiers(['Shift']) && this.isCheckboxList) {
  5771. event.preventDefault();
  5772. var focusedIndex = this.focusFirstElement();
  5773. if (focusedIndex !== -1) {
  5774. this.setSelectedIndexOnAction(focusedIndex, false);
  5775. }
  5776. }
  5777. if (this.hasTypeahead) {
  5778. var handleKeydownOpts = {
  5779. event: event,
  5780. focusItemAtIndex: function focusItemAtIndex(index) {
  5781. _this.focusItemAtIndex(index);
  5782. },
  5783. focusedItemIndex: -1,
  5784. isTargetListItem: isRootListItem,
  5785. sortedIndexByFirstChar: this.sortedIndexByFirstChar,
  5786. isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
  5787. return _this.isIndexDisabled(index);
  5788. }
  5789. };
  5790. typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
  5791. }
  5792. return;
  5793. }
  5794. var currentIndex = this.adapter.getFocusedElementIndex();
  5795. if (currentIndex === -1) {
  5796. currentIndex = listItemIndex;
  5797. if (currentIndex < 0) {
  5798. // If this event doesn't have a mdc-list-item ancestor from the
  5799. // current list (not from a sublist), return early.
  5800. return;
  5801. }
  5802. }
  5803. if (isForward && eventHasModifiers([])) {
  5804. events_1.preventDefaultEvent(event);
  5805. this.focusNextElement(currentIndex);
  5806. } else if (isBack && eventHasModifiers([])) {
  5807. events_1.preventDefaultEvent(event);
  5808. this.focusPrevElement(currentIndex);
  5809. } else if (isForward && eventHasModifiers(['Shift']) && this.isCheckboxList) {
  5810. events_1.preventDefaultEvent(event);
  5811. var focusedIndex = this.focusNextElement(currentIndex);
  5812. if (focusedIndex !== -1) {
  5813. this.setSelectedIndexOnAction(focusedIndex, false);
  5814. }
  5815. } else if (isBack && eventHasModifiers(['Shift']) && this.isCheckboxList) {
  5816. events_1.preventDefaultEvent(event);
  5817. var focusedIndex = this.focusPrevElement(currentIndex);
  5818. if (focusedIndex !== -1) {
  5819. this.setSelectedIndexOnAction(focusedIndex, false);
  5820. }
  5821. } else if (isHome && eventHasModifiers([])) {
  5822. events_1.preventDefaultEvent(event);
  5823. this.focusFirstElement();
  5824. } else if (isEnd && eventHasModifiers([])) {
  5825. events_1.preventDefaultEvent(event);
  5826. this.focusLastElement();
  5827. } else if (isHome && eventHasModifiers(['Control', 'Shift']) && this.isCheckboxList) {
  5828. events_1.preventDefaultEvent(event);
  5829. if (this.isIndexDisabled(currentIndex)) {
  5830. return;
  5831. }
  5832. this.focusFirstElement();
  5833. this.toggleCheckboxRange(0, currentIndex, currentIndex);
  5834. } else if (isEnd && eventHasModifiers(['Control', 'Shift']) && this.isCheckboxList) {
  5835. events_1.preventDefaultEvent(event);
  5836. if (this.isIndexDisabled(currentIndex)) {
  5837. return;
  5838. }
  5839. this.focusLastElement();
  5840. this.toggleCheckboxRange(currentIndex, this.adapter.getListItemCount() - 1, currentIndex);
  5841. } else if (isLetterA && eventHasModifiers(['Control']) && this.isCheckboxList) {
  5842. event.preventDefault();
  5843. this.checkboxListToggleAll(this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex, true);
  5844. } else if ((isEnter || isSpace) && (eventHasModifiers([]) || eventHasModifiers(['Alt']))) {
  5845. if (isRootListItem) {
  5846. // Return early if enter key is pressed on anchor element which triggers
  5847. // synthetic MouseEvent event.
  5848. var target = event.target;
  5849. if (target && target.tagName === 'A' && isEnter) {
  5850. return;
  5851. }
  5852. events_1.preventDefaultEvent(event);
  5853. if (this.isIndexDisabled(currentIndex)) {
  5854. return;
  5855. }
  5856. if (!this.isTypeaheadInProgress()) {
  5857. if (this.isSelectableList()) {
  5858. this.setSelectedIndexOnAction(currentIndex, false);
  5859. }
  5860. this.adapter.notifyAction(currentIndex);
  5861. }
  5862. }
  5863. } else if ((isEnter || isSpace) && eventHasModifiers(['Shift']) && this.isCheckboxList) {
  5864. // Return early if enter key is pressed on anchor element which triggers
  5865. // synthetic MouseEvent event.
  5866. var target = event.target;
  5867. if (target && target.tagName === 'A' && isEnter) {
  5868. return;
  5869. }
  5870. events_1.preventDefaultEvent(event);
  5871. if (this.isIndexDisabled(currentIndex)) {
  5872. return;
  5873. }
  5874. if (!this.isTypeaheadInProgress()) {
  5875. this.toggleCheckboxRange((_a = this.lastSelectedIndex) !== null && _a !== void 0 ? _a : currentIndex, currentIndex, currentIndex);
  5876. this.adapter.notifyAction(currentIndex);
  5877. }
  5878. }
  5879. if (this.hasTypeahead) {
  5880. var handleKeydownOpts = {
  5881. event: event,
  5882. focusItemAtIndex: function focusItemAtIndex(index) {
  5883. _this.focusItemAtIndex(index);
  5884. },
  5885. focusedItemIndex: this.focusedItemIndex,
  5886. isTargetListItem: isRootListItem,
  5887. sortedIndexByFirstChar: this.sortedIndexByFirstChar,
  5888. isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
  5889. return _this.isIndexDisabled(index);
  5890. }
  5891. };
  5892. typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
  5893. }
  5894. };
  5895. /**
  5896. * Click handler for the list.
  5897. *
  5898. * @param index Index for the item that has been clicked.
  5899. * @param isCheckboxAlreadyUpdatedInAdapter Whether the checkbox for
  5900. * the list item has already been updated in the adapter. This attribute
  5901. * should be set to `true` when e.g. the click event directly landed on
  5902. * the underlying native checkbox element which would cause the checked
  5903. * state to be already toggled within `adapter.isCheckboxCheckedAtIndex`.
  5904. */
  5905. MDCListFoundation.prototype.handleClick = function (index, isCheckboxAlreadyUpdatedInAdapter, event) {
  5906. var _a;
  5907. var eventHasModifiers = createModifierChecker(event);
  5908. if (index === constants_1.numbers.UNSET_INDEX) {
  5909. return;
  5910. }
  5911. if (this.isIndexDisabled(index)) {
  5912. return;
  5913. }
  5914. if (eventHasModifiers([])) {
  5915. if (this.isSelectableList()) {
  5916. this.setSelectedIndexOnAction(index, isCheckboxAlreadyUpdatedInAdapter);
  5917. }
  5918. this.adapter.notifyAction(index);
  5919. } else if (this.isCheckboxList && eventHasModifiers(['Shift'])) {
  5920. this.toggleCheckboxRange((_a = this.lastSelectedIndex) !== null && _a !== void 0 ? _a : index, index, index);
  5921. this.adapter.notifyAction(index);
  5922. }
  5923. };
  5924. /**
  5925. * Focuses the next element on the list.
  5926. */
  5927. MDCListFoundation.prototype.focusNextElement = function (index) {
  5928. var count = this.adapter.getListItemCount();
  5929. var nextIndex = index;
  5930. var firstChecked = null;
  5931. do {
  5932. nextIndex++;
  5933. if (nextIndex >= count) {
  5934. if (this.wrapFocus) {
  5935. nextIndex = 0;
  5936. } else {
  5937. // Return early because last item is already focused.
  5938. return index;
  5939. }
  5940. }
  5941. if (nextIndex === firstChecked) {
  5942. return -1;
  5943. }
  5944. firstChecked = firstChecked !== null && firstChecked !== void 0 ? firstChecked : nextIndex;
  5945. } while (!this.areDisabledItemsFocusable && this.isIndexDisabled(nextIndex));
  5946. this.focusItemAtIndex(nextIndex);
  5947. return nextIndex;
  5948. };
  5949. /**
  5950. * Focuses the previous element on the list.
  5951. */
  5952. MDCListFoundation.prototype.focusPrevElement = function (index) {
  5953. var count = this.adapter.getListItemCount();
  5954. var prevIndex = index;
  5955. var firstChecked = null;
  5956. do {
  5957. prevIndex--;
  5958. if (prevIndex < 0) {
  5959. if (this.wrapFocus) {
  5960. prevIndex = count - 1;
  5961. } else {
  5962. // Return early because first item is already focused.
  5963. return index;
  5964. }
  5965. }
  5966. if (prevIndex === firstChecked) {
  5967. return -1;
  5968. }
  5969. firstChecked = firstChecked !== null && firstChecked !== void 0 ? firstChecked : prevIndex;
  5970. } while (!this.areDisabledItemsFocusable && this.isIndexDisabled(prevIndex));
  5971. this.focusItemAtIndex(prevIndex);
  5972. return prevIndex;
  5973. };
  5974. MDCListFoundation.prototype.focusFirstElement = function () {
  5975. // Pass -1 to `focusNextElement`, since it will incremement to 0 and focus
  5976. // the first element.
  5977. return this.focusNextElement(-1);
  5978. };
  5979. MDCListFoundation.prototype.focusLastElement = function () {
  5980. // Pass the length of the list to `focusNextElement` since it will decrement
  5981. // to length - 1 and focus the last element.
  5982. return this.focusPrevElement(this.adapter.getListItemCount());
  5983. };
  5984. MDCListFoundation.prototype.focusInitialElement = function () {
  5985. var initialIndex = this.getFirstSelectedOrFocusedItemIndex();
  5986. if (initialIndex !== constants_1.numbers.UNSET_INDEX) {
  5987. this.focusItemAtIndex(initialIndex);
  5988. }
  5989. return initialIndex;
  5990. };
  5991. /**
  5992. * @param itemIndex Index of the list item
  5993. * @param isEnabled Sets the list item to enabled or disabled.
  5994. */
  5995. MDCListFoundation.prototype.setEnabled = function (itemIndex, isEnabled) {
  5996. if (!this.isIndexValid(itemIndex, false)) {
  5997. return;
  5998. }
  5999. if (isEnabled) {
  6000. this.adapter.removeClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  6001. this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'false');
  6002. } else {
  6003. this.adapter.addClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  6004. this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'true');
  6005. }
  6006. };
  6007. MDCListFoundation.prototype.setSingleSelectionAtIndex = function (index, options) {
  6008. if (options === void 0) {
  6009. options = {};
  6010. }
  6011. if (this.selectedIndex === index && !options.forceUpdate) {
  6012. return;
  6013. }
  6014. var selectedClassName = constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS;
  6015. if (this.useActivatedClass) {
  6016. selectedClassName = constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS;
  6017. }
  6018. if (this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
  6019. this.adapter.removeClassForElementIndex(this.selectedIndex, selectedClassName);
  6020. }
  6021. this.setAriaForSingleSelectionAtIndex(index);
  6022. this.setTabindexAtIndex(index);
  6023. if (index !== constants_1.numbers.UNSET_INDEX) {
  6024. this.adapter.addClassForElementIndex(index, selectedClassName);
  6025. }
  6026. this.selectedIndex = index;
  6027. // If the selected value has changed through user interaction,
  6028. // we want to notify the selection change to the adapter.
  6029. if (options.isUserInteraction && !options.forceUpdate) {
  6030. this.adapter.notifySelectionChange([index]);
  6031. }
  6032. };
  6033. /**
  6034. * Sets aria attribute for single selection at given index.
  6035. */
  6036. MDCListFoundation.prototype.setAriaForSingleSelectionAtIndex = function (index) {
  6037. // Detect the presence of aria-current and get the value only during list
  6038. // initialization when it is in unset state.
  6039. if (this.selectedIndex === constants_1.numbers.UNSET_INDEX && index !== constants_1.numbers.UNSET_INDEX) {
  6040. this.ariaCurrentAttrValue = this.adapter.getAttributeForElementIndex(index, constants_1.strings.ARIA_CURRENT);
  6041. }
  6042. var isAriaCurrent = this.ariaCurrentAttrValue !== null;
  6043. var ariaAttribute = isAriaCurrent ? constants_1.strings.ARIA_CURRENT : constants_1.strings.ARIA_SELECTED;
  6044. if (this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
  6045. this.adapter.setAttributeForElementIndex(this.selectedIndex, ariaAttribute, 'false');
  6046. }
  6047. if (index !== constants_1.numbers.UNSET_INDEX) {
  6048. var ariaAttributeValue = isAriaCurrent ? this.ariaCurrentAttrValue : 'true';
  6049. this.adapter.setAttributeForElementIndex(index, ariaAttribute, ariaAttributeValue);
  6050. }
  6051. };
  6052. /**
  6053. * Returns the attribute to use for indicating selection status.
  6054. */
  6055. MDCListFoundation.prototype.getSelectionAttribute = function () {
  6056. return this.useSelectedAttr ? constants_1.strings.ARIA_SELECTED : constants_1.strings.ARIA_CHECKED;
  6057. };
  6058. /**
  6059. * Toggles radio at give index. Radio doesn't change the checked state if it
  6060. * is already checked.
  6061. */
  6062. MDCListFoundation.prototype.setRadioAtIndex = function (index, options) {
  6063. if (options === void 0) {
  6064. options = {};
  6065. }
  6066. var selectionAttribute = this.getSelectionAttribute();
  6067. this.adapter.setCheckedCheckboxOrRadioAtIndex(index, true);
  6068. if (this.selectedIndex === index && !options.forceUpdate) {
  6069. return;
  6070. }
  6071. if (this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
  6072. this.adapter.setAttributeForElementIndex(this.selectedIndex, selectionAttribute, 'false');
  6073. }
  6074. this.adapter.setAttributeForElementIndex(index, selectionAttribute, 'true');
  6075. this.selectedIndex = index;
  6076. // If the selected value has changed through user interaction,
  6077. // we want to notify the selection change to the adapter.
  6078. if (options.isUserInteraction && !options.forceUpdate) {
  6079. this.adapter.notifySelectionChange([index]);
  6080. }
  6081. };
  6082. MDCListFoundation.prototype.setCheckboxAtIndex = function (indices, options) {
  6083. if (options === void 0) {
  6084. options = {};
  6085. }
  6086. var currentIndex = this.selectedIndex;
  6087. // If this update is not triggered by a user interaction, we do not
  6088. // need to know about the currently selected indices and can avoid
  6089. // constructing the `Set` for performance reasons.
  6090. var currentlySelected = options.isUserInteraction ? new Set(currentIndex === constants_1.numbers.UNSET_INDEX ? [] : currentIndex) : null;
  6091. var selectionAttribute = this.getSelectionAttribute();
  6092. var changedIndices = [];
  6093. for (var i = 0; i < this.adapter.getListItemCount(); i++) {
  6094. if (options.omitDisabledItems && this.isIndexDisabled(i)) {
  6095. continue;
  6096. }
  6097. var previousIsChecked = currentlySelected === null || currentlySelected === void 0 ? void 0 : currentlySelected.has(i);
  6098. var newIsChecked = indices.indexOf(i) >= 0;
  6099. // If the selection has changed for this item, we keep track of it
  6100. // so that we can notify the adapter.
  6101. if (newIsChecked !== previousIsChecked) {
  6102. changedIndices.push(i);
  6103. }
  6104. this.adapter.setCheckedCheckboxOrRadioAtIndex(i, newIsChecked);
  6105. this.adapter.setAttributeForElementIndex(i, selectionAttribute, newIsChecked ? 'true' : 'false');
  6106. }
  6107. this.selectedIndex = options.omitDisabledItems ? this.resolveSelectedIndices(indices) : indices;
  6108. // If the selected value has changed through user interaction,
  6109. // we want to notify the selection change to the adapter.
  6110. if (options.isUserInteraction && changedIndices.length) {
  6111. this.adapter.notifySelectionChange(changedIndices);
  6112. }
  6113. };
  6114. /**
  6115. * Helper method for ensuring that the list of selected indices remains
  6116. * accurate when calling setCheckboxAtIndex with omitDisabledItems set to
  6117. * true.
  6118. */
  6119. MDCListFoundation.prototype.resolveSelectedIndices = function (setCheckedItems) {
  6120. var _this = this;
  6121. var currentlySelectedItems = this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex;
  6122. var currentlySelectedDisabledItems = currentlySelectedItems.filter(function (i) {
  6123. return _this.isIndexDisabled(i);
  6124. });
  6125. var enabledSetCheckedItems = setCheckedItems.filter(function (i) {
  6126. return !_this.isIndexDisabled(i);
  6127. });
  6128. // Updated selectedIndex should be the enabled setCheckedItems + any missing
  6129. // selected disabled items.
  6130. var updatedSelectedItems = __spreadArray([], __read(new Set(__spreadArray(__spreadArray([], __read(enabledSetCheckedItems)), __read(currentlySelectedDisabledItems)))));
  6131. return updatedSelectedItems.sort(function (a, b) {
  6132. return a - b;
  6133. });
  6134. };
  6135. /**
  6136. * Toggles the state of all checkboxes in the given range (inclusive) based
  6137. * on the state of the checkbox at the `toggleIndex`. To determine whether
  6138. * to set the given range to checked or unchecked, read the value of the
  6139. * checkbox at the `toggleIndex` and negate it. Then apply that new checked
  6140. * state to all checkboxes in the range.
  6141. * @param fromIndex The start of the range of checkboxes to toggle
  6142. * @param toIndex The end of the range of checkboxes to toggle
  6143. * @param toggleIndex The index that will be used to determine the new state
  6144. * of the given checkbox range.
  6145. */
  6146. MDCListFoundation.prototype.toggleCheckboxRange = function (fromIndex, toIndex, toggleIndex) {
  6147. this.lastSelectedIndex = toggleIndex;
  6148. var currentlySelected = new Set(this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex);
  6149. var newIsChecked = !(currentlySelected === null || currentlySelected === void 0 ? void 0 : currentlySelected.has(toggleIndex));
  6150. var _a = __read([fromIndex, toIndex].sort(), 2),
  6151. startIndex = _a[0],
  6152. endIndex = _a[1];
  6153. var selectionAttribute = this.getSelectionAttribute();
  6154. var changedIndices = [];
  6155. for (var i = startIndex; i <= endIndex; i++) {
  6156. if (this.isIndexDisabled(i)) {
  6157. continue;
  6158. }
  6159. var previousIsChecked = currentlySelected.has(i);
  6160. // If the selection has changed for this item, we keep track of it
  6161. // so that we can notify the adapter.
  6162. if (newIsChecked !== previousIsChecked) {
  6163. changedIndices.push(i);
  6164. this.adapter.setCheckedCheckboxOrRadioAtIndex(i, newIsChecked);
  6165. this.adapter.setAttributeForElementIndex(i, selectionAttribute, "" + newIsChecked);
  6166. if (newIsChecked) {
  6167. currentlySelected.add(i);
  6168. } else {
  6169. currentlySelected.delete(i);
  6170. }
  6171. }
  6172. }
  6173. // If the selected value has changed, update and notify the selection
  6174. // change to the adapter.
  6175. if (changedIndices.length) {
  6176. this.selectedIndex = __spreadArray([], __read(currentlySelected));
  6177. this.adapter.notifySelectionChange(changedIndices);
  6178. }
  6179. };
  6180. MDCListFoundation.prototype.setTabindexAtIndex = function (index) {
  6181. if (this.focusedItemIndex === constants_1.numbers.UNSET_INDEX && index !== 0 && index !== constants_1.numbers.UNSET_INDEX) {
  6182. // If some list item was selected set first list item's tabindex to -1.
  6183. // Generally, tabindex is set to 0 on first list item of list that has
  6184. // no preselected items.
  6185. this.adapter.setAttributeForElementIndex(0, 'tabindex', '-1');
  6186. } else if (this.focusedItemIndex >= 0 && this.focusedItemIndex !== index) {
  6187. this.adapter.setAttributeForElementIndex(this.focusedItemIndex, 'tabindex', '-1');
  6188. }
  6189. // Set the previous selection's tabindex to -1. We need this because
  6190. // in selection menus that are not visible, programmatically setting an
  6191. // option will not change focus but will change where tabindex should be
  6192. // 0.
  6193. if (!(this.selectedIndex instanceof Array) && this.selectedIndex !== index && this.focusedItemIndex !== constants_1.numbers.UNSET_INDEX) {
  6194. this.adapter.setAttributeForElementIndex(this.selectedIndex, 'tabindex', '-1');
  6195. }
  6196. if (index !== constants_1.numbers.UNSET_INDEX) {
  6197. this.adapter.setAttributeForElementIndex(index, 'tabindex', '0');
  6198. }
  6199. };
  6200. /**
  6201. * @return Return true if it is single selectin list, checkbox list or radio
  6202. * list.
  6203. */
  6204. MDCListFoundation.prototype.isSelectableList = function () {
  6205. return this.isSingleSelectionList || this.isCheckboxList || this.isRadioList;
  6206. };
  6207. MDCListFoundation.prototype.setTabindexToFirstSelectedOrFocusedItem = function () {
  6208. var targetIndex = this.getFirstSelectedOrFocusedItemIndex();
  6209. this.setTabindexAtIndex(targetIndex);
  6210. };
  6211. MDCListFoundation.prototype.getFirstSelectedOrFocusedItemIndex = function () {
  6212. var e_1, _a;
  6213. var firstFocusableListItem = this.getFirstEnabledItem();
  6214. if (this.adapter.getListItemCount() === 0) {
  6215. return constants_1.numbers.UNSET_INDEX;
  6216. }
  6217. // Action lists retain focus on the most recently focused item.
  6218. if (!this.isSelectableList()) {
  6219. return Math.max(this.focusedItemIndex, firstFocusableListItem);
  6220. }
  6221. // Single-selection lists focus the selected item.
  6222. if (typeof this.selectedIndex === 'number' && this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
  6223. return this.areDisabledItemsFocusable && this.isIndexDisabled(this.selectedIndex) ? firstFocusableListItem : this.selectedIndex;
  6224. }
  6225. // Multiple-selection lists focus the first enabled selected item.
  6226. if (isNumberArray(this.selectedIndex) && this.selectedIndex.length > 0) {
  6227. var sorted = __spreadArray([], __read(this.selectedIndex)).sort(function (a, b) {
  6228. return a - b;
  6229. });
  6230. try {
  6231. for (var sorted_1 = __values(sorted), sorted_1_1 = sorted_1.next(); !sorted_1_1.done; sorted_1_1 = sorted_1.next()) {
  6232. var index = sorted_1_1.value;
  6233. if (this.isIndexDisabled(index) && !this.areDisabledItemsFocusable) {
  6234. continue;
  6235. } else {
  6236. return index;
  6237. }
  6238. }
  6239. } catch (e_1_1) {
  6240. e_1 = { error: e_1_1 };
  6241. } finally {
  6242. try {
  6243. if (sorted_1_1 && !sorted_1_1.done && (_a = sorted_1.return)) _a.call(sorted_1);
  6244. } finally {
  6245. if (e_1) throw e_1.error;
  6246. }
  6247. }
  6248. }
  6249. // Selection lists without a selection focus the first item.
  6250. return firstFocusableListItem;
  6251. };
  6252. MDCListFoundation.prototype.getFirstEnabledItem = function () {
  6253. var listSize = this.adapter.getListItemCount();
  6254. var i = 0;
  6255. while (i < listSize) {
  6256. if (!this.isIndexDisabled(i)) {
  6257. break;
  6258. }
  6259. i++;
  6260. }
  6261. return i === listSize ? constants_1.numbers.UNSET_INDEX : i;
  6262. };
  6263. MDCListFoundation.prototype.isIndexValid = function (index, validateListType) {
  6264. var _this = this;
  6265. if (validateListType === void 0) {
  6266. validateListType = true;
  6267. }
  6268. if (index instanceof Array) {
  6269. if (!this.isCheckboxList && validateListType) {
  6270. throw new Error('MDCListFoundation: Array of index is only supported for checkbox based list');
  6271. }
  6272. if (index.length === 0) {
  6273. return true;
  6274. } else {
  6275. return index.some(function (i) {
  6276. return _this.isIndexInRange(i);
  6277. });
  6278. }
  6279. } else if (typeof index === 'number') {
  6280. if (this.isCheckboxList && validateListType) {
  6281. throw new Error("MDCListFoundation: Expected array of index for checkbox based list but got number: " + index);
  6282. }
  6283. return this.isIndexInRange(index) || this.isSingleSelectionList && index === constants_1.numbers.UNSET_INDEX;
  6284. } else {
  6285. return false;
  6286. }
  6287. };
  6288. MDCListFoundation.prototype.isIndexInRange = function (index) {
  6289. var listSize = this.adapter.getListItemCount();
  6290. return index >= 0 && index < listSize;
  6291. };
  6292. /**
  6293. * Sets selected index on user action, toggles checkboxes in checkbox lists
  6294. * by default, unless `isCheckboxAlreadyUpdatedInAdapter` is set to `true`.
  6295. *
  6296. * In cases where `isCheckboxAlreadyUpdatedInAdapter` is set to `true`, the
  6297. * UI is just updated to reflect the value returned by the adapter.
  6298. *
  6299. * When calling this, make sure user interaction does not toggle disabled
  6300. * list items.
  6301. */
  6302. MDCListFoundation.prototype.setSelectedIndexOnAction = function (index, isCheckboxAlreadyUpdatedInAdapter) {
  6303. this.lastSelectedIndex = index;
  6304. if (this.isCheckboxList) {
  6305. this.toggleCheckboxAtIndex(index, isCheckboxAlreadyUpdatedInAdapter);
  6306. this.adapter.notifySelectionChange([index]);
  6307. } else {
  6308. this.setSelectedIndex(index, { isUserInteraction: true });
  6309. }
  6310. };
  6311. MDCListFoundation.prototype.toggleCheckboxAtIndex = function (index, isCheckboxAlreadyUpdatedInAdapter) {
  6312. var selectionAttribute = this.getSelectionAttribute();
  6313. var adapterIsChecked = this.adapter.isCheckboxCheckedAtIndex(index);
  6314. // By default the checked value from the adapter is toggled unless the
  6315. // checked state in the adapter has already been updated beforehand.
  6316. // This can be happen when the underlying native checkbox has already
  6317. // been updated through the native click event.
  6318. var newCheckedValue;
  6319. if (isCheckboxAlreadyUpdatedInAdapter) {
  6320. newCheckedValue = adapterIsChecked;
  6321. } else {
  6322. newCheckedValue = !adapterIsChecked;
  6323. this.adapter.setCheckedCheckboxOrRadioAtIndex(index, newCheckedValue);
  6324. }
  6325. this.adapter.setAttributeForElementIndex(index, selectionAttribute, newCheckedValue ? 'true' : 'false');
  6326. // If none of the checkbox items are selected and selectedIndex is not
  6327. // initialized then provide a default value.
  6328. var selectedIndexes = this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex.slice();
  6329. if (newCheckedValue) {
  6330. selectedIndexes.push(index);
  6331. } else {
  6332. selectedIndexes = selectedIndexes.filter(function (i) {
  6333. return i !== index;
  6334. });
  6335. }
  6336. this.selectedIndex = selectedIndexes;
  6337. };
  6338. MDCListFoundation.prototype.focusItemAtIndex = function (index) {
  6339. this.adapter.focusItemAtIndex(index);
  6340. this.focusedItemIndex = index;
  6341. };
  6342. MDCListFoundation.prototype.getEnabledListItemCount = function () {
  6343. var listSize = this.adapter.getListItemCount();
  6344. var adjustedCount = 0;
  6345. for (var i = 0; i < listSize; i++) {
  6346. if (!this.isIndexDisabled(i)) {
  6347. adjustedCount++;
  6348. }
  6349. }
  6350. return adjustedCount;
  6351. };
  6352. MDCListFoundation.prototype.checkboxListToggleAll = function (currentlySelectedIndices, isUserInteraction) {
  6353. var _this = this;
  6354. var enabledListItemCount = this.getEnabledListItemCount();
  6355. var totalListItemCount = this.adapter.getListItemCount();
  6356. var currentlyEnabledSelectedIndices = currentlySelectedIndices.filter(function (i) {
  6357. return !_this.isIndexDisabled(i);
  6358. });
  6359. // If all items are selected, deselect everything.
  6360. // We check >= rather than === to `enabledListItemCount` since a disabled
  6361. // item could be selected, and we don't take that into consideration when
  6362. // toggling the other checkbox values.
  6363. if (currentlyEnabledSelectedIndices.length >= enabledListItemCount) {
  6364. // Use omitDisabledItems option to ensure disabled selected items are not
  6365. // de-selected.
  6366. this.setCheckboxAtIndex([], { isUserInteraction: isUserInteraction, omitDisabledItems: true });
  6367. } else {
  6368. // Otherwise select all enabled options.
  6369. var allIndexes = [];
  6370. for (var i = 0; i < totalListItemCount; i++) {
  6371. if (!this.isIndexDisabled(i) || currentlySelectedIndices.indexOf(i) > -1) {
  6372. allIndexes.push(i);
  6373. }
  6374. }
  6375. // Use omitDisabledItems option to ensure disabled selected items are not
  6376. // de-selected.
  6377. this.setCheckboxAtIndex(allIndexes, { isUserInteraction: isUserInteraction, omitDisabledItems: true });
  6378. }
  6379. };
  6380. /**
  6381. * Given the next desired character from the user, adds it to the typeahead
  6382. * buffer. Then, attempts to find the next option matching the buffer. Wraps
  6383. * around if at the end of options.
  6384. *
  6385. * @param nextChar The next character to add to the prefix buffer.
  6386. * @param startingIndex The index from which to start matching. Only
  6387. * relevant when starting a new match sequence. To start a new match
  6388. * sequence, clear the buffer using `clearTypeaheadBuffer`, or wait for
  6389. * the buffer to clear after a set interval defined in list foundation.
  6390. * Defaults to the currently focused index.
  6391. * @return The index of the matched item, or -1 if no match.
  6392. */
  6393. MDCListFoundation.prototype.typeaheadMatchItem = function (nextChar, startingIndex, skipFocus) {
  6394. var _this = this;
  6395. if (skipFocus === void 0) {
  6396. skipFocus = false;
  6397. }
  6398. var opts = {
  6399. focusItemAtIndex: function focusItemAtIndex(index) {
  6400. _this.focusItemAtIndex(index);
  6401. },
  6402. focusedItemIndex: startingIndex ? startingIndex : this.focusedItemIndex,
  6403. nextChar: nextChar,
  6404. sortedIndexByFirstChar: this.sortedIndexByFirstChar,
  6405. skipFocus: skipFocus,
  6406. isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
  6407. return _this.isIndexDisabled(index);
  6408. }
  6409. };
  6410. return typeahead.matchItem(opts, this.typeaheadState);
  6411. };
  6412. /**
  6413. * Initializes the MDCListTextAndIndex data structure by indexing the
  6414. * current list items by primary text.
  6415. *
  6416. * @return The primary texts of all the list items sorted by first
  6417. * character.
  6418. */
  6419. MDCListFoundation.prototype.typeaheadInitSortedIndex = function () {
  6420. return typeahead.initSortedIndex(this.adapter.getListItemCount(), this.adapter.getPrimaryTextAtIndex);
  6421. };
  6422. /**
  6423. * Clears the typeahead buffer.
  6424. */
  6425. MDCListFoundation.prototype.clearTypeaheadBuffer = function () {
  6426. typeahead.clearBuffer(this.typeaheadState);
  6427. };
  6428. return MDCListFoundation;
  6429. }(foundation_1.MDCFoundation);
  6430. exports.MDCListFoundation = MDCListFoundation;
  6431. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  6432. exports.default = MDCListFoundation;
  6433. /***/ }),
  6434. /***/ "./packages/mdc-list/typeahead.ts":
  6435. /*!****************************************!*\
  6436. !*** ./packages/mdc-list/typeahead.ts ***!
  6437. \****************************************/
  6438. /*! no static exports found */
  6439. /***/ (function(module, exports, __webpack_require__) {
  6440. "use strict";
  6441. /**
  6442. * @license
  6443. * Copyright 2020 Google Inc.
  6444. *
  6445. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6446. * of this software and associated documentation files (the "Software"), to deal
  6447. * in the Software without restriction, including without limitation the rights
  6448. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6449. * copies of the Software, and to permit persons to whom the Software is
  6450. * furnished to do so, subject to the following conditions:
  6451. *
  6452. * The above copyright notice and this permission notice shall be included in
  6453. * all copies or substantial portions of the Software.
  6454. *
  6455. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6456. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6457. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6458. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6459. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6460. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6461. * THE SOFTWARE.
  6462. */
  6463. Object.defineProperty(exports, "__esModule", { value: true });
  6464. exports.handleKeydown = exports.clearBuffer = exports.isTypingInProgress = exports.matchItem = exports.initSortedIndex = exports.initState = void 0;
  6465. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  6466. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
  6467. var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
  6468. /**
  6469. * Initializes a state object for typeahead. Use the same reference for calls to
  6470. * typeahead functions.
  6471. *
  6472. * @return The current state of the typeahead process. Each state reference
  6473. * represents a typeahead instance as the reference is typically mutated
  6474. * in-place.
  6475. */
  6476. function initState() {
  6477. var state = {
  6478. bufferClearTimeout: 0,
  6479. currentFirstChar: '',
  6480. sortedIndexCursor: 0,
  6481. typeaheadBuffer: ''
  6482. };
  6483. return state;
  6484. }
  6485. exports.initState = initState;
  6486. /**
  6487. * Initializes typeahead state by indexing the current list items by primary
  6488. * text into the sortedIndexByFirstChar data structure.
  6489. *
  6490. * @param listItemCount numer of items in the list
  6491. * @param getPrimaryTextByItemIndex function that returns the primary text at a
  6492. * given index
  6493. *
  6494. * @return Map that maps the first character of the primary text to the full
  6495. * list text and its index
  6496. */
  6497. function initSortedIndex(listItemCount, getPrimaryTextByItemIndex) {
  6498. var sortedIndexByFirstChar = new Map();
  6499. // Aggregate item text to index mapping
  6500. for (var i = 0; i < listItemCount; i++) {
  6501. var primaryText = getPrimaryTextByItemIndex(i).trim();
  6502. if (!primaryText) {
  6503. continue;
  6504. }
  6505. var firstChar = primaryText[0].toLowerCase();
  6506. if (!sortedIndexByFirstChar.has(firstChar)) {
  6507. sortedIndexByFirstChar.set(firstChar, []);
  6508. }
  6509. sortedIndexByFirstChar.get(firstChar).push({ text: primaryText.toLowerCase(), index: i });
  6510. }
  6511. // Sort the mapping
  6512. // TODO(b/157162694): Investigate replacing forEach with Map.values()
  6513. sortedIndexByFirstChar.forEach(function (values) {
  6514. values.sort(function (first, second) {
  6515. return first.index - second.index;
  6516. });
  6517. });
  6518. return sortedIndexByFirstChar;
  6519. }
  6520. exports.initSortedIndex = initSortedIndex;
  6521. /**
  6522. * Given the next desired character from the user, it attempts to find the next
  6523. * list option matching the buffer. Wraps around if at the end of options.
  6524. *
  6525. * @param opts Options and accessors
  6526. * - nextChar - the next character to match against items
  6527. * - sortedIndexByFirstChar - output of `initSortedIndex(...)`
  6528. * - focusedItemIndex - the index of the currently focused item
  6529. * - focusItemAtIndex - function that focuses a list item at given index
  6530. * - skipFocus - whether or not to focus the matched item
  6531. * - isItemAtIndexDisabled - function that determines whether an item at a
  6532. * given index is disabled
  6533. * @param state The typeahead state instance. See `initState`.
  6534. *
  6535. * @return The index of the matched item, or -1 if no match.
  6536. */
  6537. function matchItem(opts, state) {
  6538. var nextChar = opts.nextChar,
  6539. focusItemAtIndex = opts.focusItemAtIndex,
  6540. sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
  6541. focusedItemIndex = opts.focusedItemIndex,
  6542. skipFocus = opts.skipFocus,
  6543. isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
  6544. clearTimeout(state.bufferClearTimeout);
  6545. state.bufferClearTimeout = setTimeout(function () {
  6546. clearBuffer(state);
  6547. }, constants_1.numbers.TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS);
  6548. state.typeaheadBuffer = state.typeaheadBuffer + nextChar;
  6549. var index;
  6550. if (state.typeaheadBuffer.length === 1) {
  6551. index = matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state);
  6552. } else {
  6553. index = matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state);
  6554. }
  6555. if (index !== -1 && !skipFocus) {
  6556. focusItemAtIndex(index);
  6557. }
  6558. return index;
  6559. }
  6560. exports.matchItem = matchItem;
  6561. /**
  6562. * Matches the user's single input character in the buffer to the
  6563. * next option that begins with such character. Wraps around if at
  6564. * end of options. Returns -1 if no match is found.
  6565. */
  6566. function matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state) {
  6567. var firstChar = state.typeaheadBuffer[0];
  6568. var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
  6569. if (!itemsMatchingFirstChar) {
  6570. return -1;
  6571. }
  6572. // Has the same firstChar been recently matched?
  6573. // Also, did starting index remain the same between key presses?
  6574. // If both hold true, simply increment index.
  6575. if (firstChar === state.currentFirstChar && itemsMatchingFirstChar[state.sortedIndexCursor].index === focusedItemIndex) {
  6576. state.sortedIndexCursor = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
  6577. var newIndex = itemsMatchingFirstChar[state.sortedIndexCursor].index;
  6578. if (!isItemAtIndexDisabled(newIndex)) {
  6579. return newIndex;
  6580. }
  6581. }
  6582. // If we're here, it means one of the following happened:
  6583. // - either firstChar or startingIndex has changed, invalidating the
  6584. // cursor.
  6585. // - The next item of typeahead is disabled, so we have to look further.
  6586. state.currentFirstChar = firstChar;
  6587. var newCursorPosition = -1;
  6588. var cursorPosition;
  6589. // Find the first non-disabled item as a fallback.
  6590. for (cursorPosition = 0; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
  6591. if (!isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
  6592. newCursorPosition = cursorPosition;
  6593. break;
  6594. }
  6595. }
  6596. // Advance cursor to first item matching the firstChar that is positioned
  6597. // after starting item. Cursor is unchanged from fallback if there's no
  6598. // such item.
  6599. for (; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
  6600. if (itemsMatchingFirstChar[cursorPosition].index > focusedItemIndex && !isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
  6601. newCursorPosition = cursorPosition;
  6602. break;
  6603. }
  6604. }
  6605. if (newCursorPosition !== -1) {
  6606. state.sortedIndexCursor = newCursorPosition;
  6607. return itemsMatchingFirstChar[state.sortedIndexCursor].index;
  6608. }
  6609. return -1;
  6610. }
  6611. /**
  6612. * Attempts to find the next item that matches all of the typeahead buffer.
  6613. * Wraps around if at end of options. Returns -1 if no match is found.
  6614. */
  6615. function matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state) {
  6616. var firstChar = state.typeaheadBuffer[0];
  6617. var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
  6618. if (!itemsMatchingFirstChar) {
  6619. return -1;
  6620. }
  6621. // Do nothing if text already matches
  6622. var startingItem = itemsMatchingFirstChar[state.sortedIndexCursor];
  6623. if (startingItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0 && !isItemAtIndexDisabled(startingItem.index)) {
  6624. return startingItem.index;
  6625. }
  6626. // Find next item that matches completely; if no match, we'll eventually
  6627. // loop around to same position
  6628. var cursorPosition = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
  6629. var nextCursorPosition = -1;
  6630. while (cursorPosition !== state.sortedIndexCursor) {
  6631. var currentItem = itemsMatchingFirstChar[cursorPosition];
  6632. var matches = currentItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0;
  6633. var isEnabled = !isItemAtIndexDisabled(currentItem.index);
  6634. if (matches && isEnabled) {
  6635. nextCursorPosition = cursorPosition;
  6636. break;
  6637. }
  6638. cursorPosition = (cursorPosition + 1) % itemsMatchingFirstChar.length;
  6639. }
  6640. if (nextCursorPosition !== -1) {
  6641. state.sortedIndexCursor = nextCursorPosition;
  6642. return itemsMatchingFirstChar[state.sortedIndexCursor].index;
  6643. }
  6644. return -1;
  6645. }
  6646. /**
  6647. * Whether or not the given typeahead instaance state is currently typing.
  6648. *
  6649. * @param state The typeahead state instance. See `initState`.
  6650. */
  6651. function isTypingInProgress(state) {
  6652. return state.typeaheadBuffer.length > 0;
  6653. }
  6654. exports.isTypingInProgress = isTypingInProgress;
  6655. /**
  6656. * Clears the typeahaed buffer so that it resets item matching to the first
  6657. * character.
  6658. *
  6659. * @param state The typeahead state instance. See `initState`.
  6660. */
  6661. function clearBuffer(state) {
  6662. state.typeaheadBuffer = '';
  6663. }
  6664. exports.clearBuffer = clearBuffer;
  6665. /**
  6666. * Given a keydown event, it calculates whether or not to automatically focus a
  6667. * list item depending on what was typed mimicking the typeahead functionality
  6668. * of a standard <select> element that is open.
  6669. *
  6670. * @param opts Options and accessors
  6671. * - event - the KeyboardEvent to handle and parse
  6672. * - sortedIndexByFirstChar - output of `initSortedIndex(...)`
  6673. * - focusedItemIndex - the index of the currently focused item
  6674. * - focusItemAtIndex - function that focuses a list item at given index
  6675. * - isItemAtFocusedIndexDisabled - whether or not the currently focused item
  6676. * is disabled
  6677. * - isTargetListItem - whether or not the event target is a list item
  6678. * @param state The typeahead state instance. See `initState`.
  6679. *
  6680. * @return index of the item matched by the keydown. -1 if not matched.
  6681. */
  6682. function handleKeydown(opts, state) {
  6683. var event = opts.event,
  6684. isTargetListItem = opts.isTargetListItem,
  6685. focusedItemIndex = opts.focusedItemIndex,
  6686. focusItemAtIndex = opts.focusItemAtIndex,
  6687. sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
  6688. isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
  6689. var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
  6690. var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
  6691. var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
  6692. var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
  6693. var isHome = keyboard_1.normalizeKey(event) === 'Home';
  6694. var isEnd = keyboard_1.normalizeKey(event) === 'End';
  6695. var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
  6696. var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
  6697. if (event.altKey || event.ctrlKey || event.metaKey || isArrowLeft || isArrowUp || isArrowRight || isArrowDown || isHome || isEnd || isEnter) {
  6698. return -1;
  6699. }
  6700. var isCharacterKey = !isSpace && event.key.length === 1;
  6701. if (isCharacterKey) {
  6702. events_1.preventDefaultEvent(event);
  6703. var matchItemOpts = {
  6704. focusItemAtIndex: focusItemAtIndex,
  6705. focusedItemIndex: focusedItemIndex,
  6706. nextChar: event.key.toLowerCase(),
  6707. sortedIndexByFirstChar: sortedIndexByFirstChar,
  6708. skipFocus: false,
  6709. isItemAtIndexDisabled: isItemAtIndexDisabled
  6710. };
  6711. return matchItem(matchItemOpts, state);
  6712. }
  6713. if (!isSpace) {
  6714. return -1;
  6715. }
  6716. if (isTargetListItem) {
  6717. events_1.preventDefaultEvent(event);
  6718. }
  6719. var typeaheadOnListItem = isTargetListItem && isTypingInProgress(state);
  6720. if (typeaheadOnListItem) {
  6721. var matchItemOpts = {
  6722. focusItemAtIndex: focusItemAtIndex,
  6723. focusedItemIndex: focusedItemIndex,
  6724. nextChar: ' ',
  6725. sortedIndexByFirstChar: sortedIndexByFirstChar,
  6726. skipFocus: false,
  6727. isItemAtIndexDisabled: isItemAtIndexDisabled
  6728. };
  6729. // space participates in typeahead matching if in rapid typing mode
  6730. return matchItem(matchItemOpts, state);
  6731. }
  6732. return -1;
  6733. }
  6734. exports.handleKeydown = handleKeydown;
  6735. /***/ })
  6736. /******/ });
  6737. });
  6738. //# sourceMappingURL=mdc.drawer.js.map