runner.js 501 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468
  1. /*
  2. Stencil Hydrate Runner v4.20.0 | MIT Licensed | https://stenciljs.com
  3. */
  4. var __defProp = Object.defineProperty;
  5. var __export = (target, all) => {
  6. for (var name in all)
  7. __defProp(target, name, { get: all[name], enumerable: true });
  8. };
  9. // src/runtime/runtime-constants.ts
  10. var CONTENT_REF_ID = "r";
  11. var ORG_LOCATION_ID = "o";
  12. var SLOT_NODE_ID = "s";
  13. var TEXT_NODE_ID = "t";
  14. var XLINK_NS = "http://www.w3.org/1999/xlink";
  15. // src/mock-doc/attribute.ts
  16. var attrHandler = {
  17. get(obj, prop) {
  18. if (prop in obj) {
  19. return obj[prop];
  20. }
  21. if (typeof prop !== "symbol" && !isNaN(prop)) {
  22. return obj.__items[prop];
  23. }
  24. return void 0;
  25. }
  26. };
  27. var createAttributeProxy = (caseInsensitive) => new Proxy(new MockAttributeMap(caseInsensitive), attrHandler);
  28. var MockAttributeMap = class {
  29. constructor(caseInsensitive = false) {
  30. this.caseInsensitive = caseInsensitive;
  31. this.__items = [];
  32. }
  33. get length() {
  34. return this.__items.length;
  35. }
  36. item(index) {
  37. return this.__items[index] || null;
  38. }
  39. setNamedItem(attr) {
  40. attr.namespaceURI = null;
  41. this.setNamedItemNS(attr);
  42. }
  43. setNamedItemNS(attr) {
  44. if (attr != null && attr.value != null) {
  45. attr.value = String(attr.value);
  46. }
  47. const existingAttr = this.__items.find((a) => a.name === attr.name && a.namespaceURI === attr.namespaceURI);
  48. if (existingAttr != null) {
  49. existingAttr.value = attr.value;
  50. } else {
  51. this.__items.push(attr);
  52. }
  53. }
  54. getNamedItem(attrName) {
  55. if (this.caseInsensitive) {
  56. attrName = attrName.toLowerCase();
  57. }
  58. return this.getNamedItemNS(null, attrName);
  59. }
  60. getNamedItemNS(namespaceURI, attrName) {
  61. namespaceURI = getNamespaceURI(namespaceURI);
  62. return this.__items.find((attr) => attr.name === attrName && getNamespaceURI(attr.namespaceURI) === namespaceURI) || null;
  63. }
  64. removeNamedItem(attr) {
  65. this.removeNamedItemNS(attr);
  66. }
  67. removeNamedItemNS(attr) {
  68. for (let i = 0, ii = this.__items.length; i < ii; i++) {
  69. if (this.__items[i].name === attr.name && this.__items[i].namespaceURI === attr.namespaceURI) {
  70. this.__items.splice(i, 1);
  71. break;
  72. }
  73. }
  74. }
  75. [Symbol.iterator]() {
  76. let i = 0;
  77. return {
  78. next: () => ({
  79. done: i === this.length,
  80. value: this.item(i++)
  81. })
  82. };
  83. }
  84. get [Symbol.toStringTag]() {
  85. return "MockAttributeMap";
  86. }
  87. };
  88. function getNamespaceURI(namespaceURI) {
  89. return namespaceURI === XLINK_NS ? null : namespaceURI;
  90. }
  91. function cloneAttributes(srcAttrs, sortByName = false) {
  92. const dstAttrs = new MockAttributeMap(srcAttrs.caseInsensitive);
  93. if (srcAttrs != null) {
  94. const attrLen = srcAttrs.length;
  95. if (sortByName && attrLen > 1) {
  96. const sortedAttrs = [];
  97. for (let i = 0; i < attrLen; i++) {
  98. const srcAttr = srcAttrs.item(i);
  99. const dstAttr = new MockAttr(srcAttr.name, srcAttr.value, srcAttr.namespaceURI);
  100. sortedAttrs.push(dstAttr);
  101. }
  102. sortedAttrs.sort(sortAttributes).forEach((attr) => {
  103. dstAttrs.setNamedItemNS(attr);
  104. });
  105. } else {
  106. for (let i = 0; i < attrLen; i++) {
  107. const srcAttr = srcAttrs.item(i);
  108. const dstAttr = new MockAttr(srcAttr.name, srcAttr.value, srcAttr.namespaceURI);
  109. dstAttrs.setNamedItemNS(dstAttr);
  110. }
  111. }
  112. }
  113. return dstAttrs;
  114. }
  115. function sortAttributes(a, b) {
  116. if (a.name < b.name) return -1;
  117. if (a.name > b.name) return 1;
  118. return 0;
  119. }
  120. var MockAttr = class {
  121. constructor(attrName, attrValue, namespaceURI = null) {
  122. this._name = attrName;
  123. this._value = String(attrValue);
  124. this._namespaceURI = namespaceURI;
  125. }
  126. get name() {
  127. return this._name;
  128. }
  129. set name(value) {
  130. this._name = value;
  131. }
  132. get value() {
  133. return this._value;
  134. }
  135. set value(value) {
  136. this._value = String(value);
  137. }
  138. get nodeName() {
  139. return this._name;
  140. }
  141. set nodeName(value) {
  142. this._name = value;
  143. }
  144. get nodeValue() {
  145. return this._value;
  146. }
  147. set nodeValue(value) {
  148. this._value = String(value);
  149. }
  150. get namespaceURI() {
  151. return this._namespaceURI;
  152. }
  153. set namespaceURI(namespaceURI) {
  154. this._namespaceURI = namespaceURI;
  155. }
  156. };
  157. // src/mock-doc/class-list.ts
  158. var MockClassList = class {
  159. constructor(elm) {
  160. this.elm = elm;
  161. }
  162. add(...classNames) {
  163. const clsNames = getItems(this.elm);
  164. let updated = false;
  165. classNames.forEach((className) => {
  166. className = String(className);
  167. validateClass(className);
  168. if (clsNames.includes(className) === false) {
  169. clsNames.push(className);
  170. updated = true;
  171. }
  172. });
  173. if (updated) {
  174. this.elm.setAttributeNS(null, "class", clsNames.join(" "));
  175. }
  176. }
  177. remove(...classNames) {
  178. const clsNames = getItems(this.elm);
  179. let updated = false;
  180. classNames.forEach((className) => {
  181. className = String(className);
  182. validateClass(className);
  183. const index = clsNames.indexOf(className);
  184. if (index > -1) {
  185. clsNames.splice(index, 1);
  186. updated = true;
  187. }
  188. });
  189. if (updated) {
  190. this.elm.setAttributeNS(null, "class", clsNames.filter((c) => c.length > 0).join(" "));
  191. }
  192. }
  193. contains(className) {
  194. className = String(className);
  195. return getItems(this.elm).includes(className);
  196. }
  197. toggle(className) {
  198. className = String(className);
  199. if (this.contains(className) === true) {
  200. this.remove(className);
  201. } else {
  202. this.add(className);
  203. }
  204. }
  205. get length() {
  206. return getItems(this.elm).length;
  207. }
  208. item(index) {
  209. return getItems(this.elm)[index];
  210. }
  211. toString() {
  212. return getItems(this.elm).join(" ");
  213. }
  214. };
  215. function validateClass(className) {
  216. if (className === "") {
  217. throw new Error("The token provided must not be empty.");
  218. }
  219. if (/\s/.test(className)) {
  220. throw new Error(
  221. `The token provided ('${className}') contains HTML space characters, which are not valid in tokens.`
  222. );
  223. }
  224. }
  225. function getItems(elm) {
  226. const className = elm.getAttribute("class");
  227. if (typeof className === "string" && className.length > 0) {
  228. return className.trim().split(" ").filter((c) => c.length > 0);
  229. }
  230. return [];
  231. }
  232. // src/mock-doc/css-style-declaration.ts
  233. var MockCSSStyleDeclaration = class {
  234. constructor() {
  235. this._styles = /* @__PURE__ */ new Map();
  236. }
  237. setProperty(prop, value) {
  238. prop = jsCaseToCssCase(prop);
  239. if (value == null || value === "") {
  240. this._styles.delete(prop);
  241. } else {
  242. this._styles.set(prop, String(value));
  243. }
  244. }
  245. getPropertyValue(prop) {
  246. prop = jsCaseToCssCase(prop);
  247. return String(this._styles.get(prop) || "");
  248. }
  249. removeProperty(prop) {
  250. prop = jsCaseToCssCase(prop);
  251. this._styles.delete(prop);
  252. }
  253. get length() {
  254. return this._styles.size;
  255. }
  256. get cssText() {
  257. const cssText = [];
  258. this._styles.forEach((value, prop) => {
  259. cssText.push(`${prop}: ${value};`);
  260. });
  261. return cssText.join(" ").trim();
  262. }
  263. set cssText(cssText) {
  264. if (cssText == null || cssText === "") {
  265. this._styles.clear();
  266. return;
  267. }
  268. cssText.split(";").forEach((rule) => {
  269. rule = rule.trim();
  270. if (rule.length > 0) {
  271. const splt = rule.split(":");
  272. if (splt.length > 1) {
  273. const prop = splt[0].trim();
  274. const value = splt.slice(1).join(":").trim();
  275. if (prop !== "" && value !== "") {
  276. this._styles.set(jsCaseToCssCase(prop), value);
  277. }
  278. }
  279. }
  280. });
  281. }
  282. };
  283. function createCSSStyleDeclaration() {
  284. return new Proxy(new MockCSSStyleDeclaration(), cssProxyHandler);
  285. }
  286. var cssProxyHandler = {
  287. get(cssStyle, prop) {
  288. if (prop in cssStyle) {
  289. return cssStyle[prop];
  290. }
  291. prop = cssCaseToJsCase(prop);
  292. return cssStyle.getPropertyValue(prop);
  293. },
  294. set(cssStyle, prop, value) {
  295. if (prop in cssStyle) {
  296. cssStyle[prop] = value;
  297. } else {
  298. cssStyle.setProperty(prop, value);
  299. }
  300. return true;
  301. }
  302. };
  303. function cssCaseToJsCase(str) {
  304. if (str.length > 1 && str.includes("-") === true) {
  305. str = str.toLowerCase().split("-").map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join("");
  306. str = str.slice(0, 1).toLowerCase() + str.slice(1);
  307. }
  308. return str;
  309. }
  310. function jsCaseToCssCase(str) {
  311. if (str.length > 1 && str.includes("-") === false && /[A-Z]/.test(str) === true) {
  312. str = str.replace(/([A-Z])/g, (g) => " " + g[0]).trim().replace(/ /g, "-").toLowerCase();
  313. }
  314. return str;
  315. }
  316. // src/mock-doc/custom-element-registry.ts
  317. var MockCustomElementRegistry = class {
  318. constructor(win) {
  319. this.win = win;
  320. }
  321. define(tagName, cstr, options) {
  322. if (tagName.toLowerCase() !== tagName) {
  323. throw new Error(
  324. `Failed to execute 'define' on 'CustomElementRegistry': "${tagName}" is not a valid custom element name`
  325. );
  326. }
  327. if (this.__registry == null) {
  328. this.__registry = /* @__PURE__ */ new Map();
  329. }
  330. this.__registry.set(tagName, { cstr, options });
  331. if (this.__whenDefined != null) {
  332. const whenDefinedResolveFns = this.__whenDefined.get(tagName);
  333. if (whenDefinedResolveFns != null) {
  334. whenDefinedResolveFns.forEach((whenDefinedResolveFn) => {
  335. whenDefinedResolveFn();
  336. });
  337. whenDefinedResolveFns.length = 0;
  338. this.__whenDefined.delete(tagName);
  339. }
  340. }
  341. const doc = this.win.document;
  342. if (doc != null) {
  343. const hosts = doc.querySelectorAll(tagName);
  344. hosts.forEach((host) => {
  345. if (upgradedElements.has(host) === false) {
  346. tempDisableCallbacks.add(doc);
  347. const upgradedCmp = createCustomElement(this, doc, tagName);
  348. for (let i = 0; i < host.childNodes.length; i++) {
  349. const childNode = host.childNodes[i];
  350. childNode.remove();
  351. upgradedCmp.appendChild(childNode);
  352. }
  353. tempDisableCallbacks.delete(doc);
  354. if (proxyElements.has(host)) {
  355. proxyElements.set(host, upgradedCmp);
  356. }
  357. }
  358. fireConnectedCallback(host);
  359. });
  360. }
  361. }
  362. get(tagName) {
  363. if (this.__registry != null) {
  364. const def = this.__registry.get(tagName.toLowerCase());
  365. if (def != null) {
  366. return def.cstr;
  367. }
  368. }
  369. return void 0;
  370. }
  371. getName(cstr) {
  372. for (const [tagName, def] of this.__registry.entries()) {
  373. if (def.cstr === cstr) {
  374. return tagName;
  375. }
  376. }
  377. return void 0;
  378. }
  379. upgrade(_rootNode) {
  380. }
  381. clear() {
  382. if (this.__registry != null) {
  383. this.__registry.clear();
  384. }
  385. if (this.__whenDefined != null) {
  386. this.__whenDefined.clear();
  387. }
  388. }
  389. whenDefined(tagName) {
  390. tagName = tagName.toLowerCase();
  391. if (this.__registry != null && this.__registry.has(tagName) === true) {
  392. return Promise.resolve(this.__registry.get(tagName).cstr);
  393. }
  394. return new Promise((resolve) => {
  395. if (this.__whenDefined == null) {
  396. this.__whenDefined = /* @__PURE__ */ new Map();
  397. }
  398. let whenDefinedResolveFns = this.__whenDefined.get(tagName);
  399. if (whenDefinedResolveFns == null) {
  400. whenDefinedResolveFns = [];
  401. this.__whenDefined.set(tagName, whenDefinedResolveFns);
  402. }
  403. whenDefinedResolveFns.push(resolve);
  404. });
  405. }
  406. };
  407. function createCustomElement(customElements, ownerDocument, tagName) {
  408. const Cstr = customElements.get(tagName);
  409. if (Cstr != null) {
  410. const cmp = new Cstr(ownerDocument);
  411. cmp.nodeName = tagName.toUpperCase();
  412. upgradedElements.add(cmp);
  413. return cmp;
  414. }
  415. const host = new Proxy(
  416. {},
  417. {
  418. get(obj, prop) {
  419. const elm2 = proxyElements.get(host);
  420. if (elm2 != null) {
  421. return elm2[prop];
  422. }
  423. return obj[prop];
  424. },
  425. set(obj, prop, val) {
  426. const elm2 = proxyElements.get(host);
  427. if (elm2 != null) {
  428. elm2[prop] = val;
  429. } else {
  430. obj[prop] = val;
  431. }
  432. return true;
  433. },
  434. has(obj, prop) {
  435. const elm2 = proxyElements.get(host);
  436. if (prop in elm2) {
  437. return true;
  438. }
  439. if (prop in obj) {
  440. return true;
  441. }
  442. return false;
  443. }
  444. }
  445. );
  446. const elm = new MockHTMLElement(ownerDocument, tagName);
  447. proxyElements.set(host, elm);
  448. return host;
  449. }
  450. var proxyElements = /* @__PURE__ */ new WeakMap();
  451. var upgradedElements = /* @__PURE__ */ new WeakSet();
  452. function connectNode(ownerDocument, node) {
  453. node.ownerDocument = ownerDocument;
  454. if (node.nodeType === 1 /* ELEMENT_NODE */) {
  455. if (ownerDocument != null && node.nodeName.includes("-")) {
  456. const win = ownerDocument.defaultView;
  457. if (win != null && typeof node.connectedCallback === "function" && node.isConnected) {
  458. fireConnectedCallback(node);
  459. }
  460. const shadowRoot = node.shadowRoot;
  461. if (shadowRoot != null) {
  462. shadowRoot.childNodes.forEach((childNode) => {
  463. connectNode(ownerDocument, childNode);
  464. });
  465. }
  466. }
  467. node.childNodes.forEach((childNode) => {
  468. connectNode(ownerDocument, childNode);
  469. });
  470. } else {
  471. node.childNodes.forEach((childNode) => {
  472. childNode.ownerDocument = ownerDocument;
  473. });
  474. }
  475. }
  476. function fireConnectedCallback(node) {
  477. if (typeof node.connectedCallback === "function") {
  478. if (tempDisableCallbacks.has(node.ownerDocument) === false) {
  479. try {
  480. node.connectedCallback();
  481. } catch (e) {
  482. console.error(e);
  483. }
  484. }
  485. }
  486. }
  487. function disconnectNode(node) {
  488. if (node.nodeType === 1 /* ELEMENT_NODE */) {
  489. if (node.nodeName.includes("-") === true && typeof node.disconnectedCallback === "function") {
  490. if (tempDisableCallbacks.has(node.ownerDocument) === false) {
  491. try {
  492. node.disconnectedCallback();
  493. } catch (e) {
  494. console.error(e);
  495. }
  496. }
  497. }
  498. node.childNodes.forEach(disconnectNode);
  499. }
  500. }
  501. function attributeChanged(node, attrName, oldValue, newValue) {
  502. attrName = attrName.toLowerCase();
  503. const observedAttributes = node.constructor.observedAttributes;
  504. if (Array.isArray(observedAttributes) === true && observedAttributes.some((obs) => obs.toLowerCase() === attrName) === true) {
  505. try {
  506. node.attributeChangedCallback(attrName, oldValue, newValue);
  507. } catch (e) {
  508. console.error(e);
  509. }
  510. }
  511. }
  512. function checkAttributeChanged(node) {
  513. return node.nodeName.includes("-") === true && typeof node.attributeChangedCallback === "function";
  514. }
  515. var tempDisableCallbacks = /* @__PURE__ */ new Set();
  516. // src/mock-doc/dataset.ts
  517. function dataset(elm) {
  518. const ds = {};
  519. const attributes = elm.attributes;
  520. const attrLen = attributes.length;
  521. for (let i = 0; i < attrLen; i++) {
  522. const attr = attributes.item(i);
  523. const nodeName = attr.nodeName;
  524. if (nodeName.startsWith("data-")) {
  525. ds[dashToPascalCase(nodeName)] = attr.nodeValue;
  526. }
  527. }
  528. return new Proxy(ds, {
  529. get(_obj, camelCaseProp) {
  530. return ds[camelCaseProp];
  531. },
  532. set(_obj, camelCaseProp, value) {
  533. const dataAttr = toDataAttribute(camelCaseProp);
  534. elm.setAttribute(dataAttr, value);
  535. return true;
  536. }
  537. });
  538. }
  539. function toDataAttribute(str) {
  540. return "data-" + String(str).replace(/([A-Z0-9])/g, (g) => " " + g[0]).trim().replace(/ /g, "-").toLowerCase();
  541. }
  542. function dashToPascalCase(str) {
  543. str = String(str).slice(5);
  544. return str.split("-").map((segment, index) => {
  545. if (index === 0) {
  546. return segment.charAt(0).toLowerCase() + segment.slice(1);
  547. }
  548. return segment.charAt(0).toUpperCase() + segment.slice(1);
  549. }).join("");
  550. }
  551. // src/mock-doc/event.ts
  552. var MockEvent = class {
  553. constructor(type, eventInitDict) {
  554. this.bubbles = false;
  555. this.cancelBubble = false;
  556. this.cancelable = false;
  557. this.composed = false;
  558. this.currentTarget = null;
  559. this.defaultPrevented = false;
  560. this.srcElement = null;
  561. this.target = null;
  562. if (typeof type !== "string") {
  563. throw new Error(`Event type required`);
  564. }
  565. this.type = type;
  566. this.timeStamp = Date.now();
  567. if (eventInitDict != null) {
  568. Object.assign(this, eventInitDict);
  569. }
  570. }
  571. preventDefault() {
  572. this.defaultPrevented = true;
  573. }
  574. stopPropagation() {
  575. this.cancelBubble = true;
  576. }
  577. stopImmediatePropagation() {
  578. this.cancelBubble = true;
  579. }
  580. /**
  581. * @ref https://developer.mozilla.org/en-US/docs/Web/API/Event/composedPath
  582. * @returns a composed path of the event
  583. */
  584. composedPath() {
  585. const composedPath = [];
  586. let currentElement = this.target;
  587. while (currentElement) {
  588. composedPath.push(currentElement);
  589. if (!currentElement.parentElement && currentElement.nodeName === "#document" /* DOCUMENT_NODE */) {
  590. composedPath.push(currentElement.defaultView);
  591. break;
  592. }
  593. if (currentElement.parentElement == null && currentElement.tagName === "HTML") {
  594. currentElement = currentElement.ownerDocument;
  595. } else {
  596. currentElement = currentElement.parentElement;
  597. }
  598. }
  599. return composedPath;
  600. }
  601. };
  602. var MockCustomEvent = class extends MockEvent {
  603. constructor(type, customEventInitDic) {
  604. super(type);
  605. this.detail = null;
  606. if (customEventInitDic != null) {
  607. Object.assign(this, customEventInitDic);
  608. }
  609. }
  610. };
  611. var MockKeyboardEvent = class extends MockEvent {
  612. constructor(type, keyboardEventInitDic) {
  613. super(type);
  614. this.code = "";
  615. this.key = "";
  616. this.altKey = false;
  617. this.ctrlKey = false;
  618. this.metaKey = false;
  619. this.shiftKey = false;
  620. this.location = 0;
  621. this.repeat = false;
  622. if (keyboardEventInitDic != null) {
  623. Object.assign(this, keyboardEventInitDic);
  624. }
  625. }
  626. };
  627. var MockMouseEvent = class extends MockEvent {
  628. constructor(type, mouseEventInitDic) {
  629. super(type);
  630. this.screenX = 0;
  631. this.screenY = 0;
  632. this.clientX = 0;
  633. this.clientY = 0;
  634. this.ctrlKey = false;
  635. this.shiftKey = false;
  636. this.altKey = false;
  637. this.metaKey = false;
  638. this.button = 0;
  639. this.buttons = 0;
  640. this.relatedTarget = null;
  641. if (mouseEventInitDic != null) {
  642. Object.assign(this, mouseEventInitDic);
  643. }
  644. }
  645. };
  646. var MockUIEvent = class extends MockEvent {
  647. constructor(type, uiEventInitDic) {
  648. super(type);
  649. this.detail = null;
  650. this.view = null;
  651. if (uiEventInitDic != null) {
  652. Object.assign(this, uiEventInitDic);
  653. }
  654. }
  655. };
  656. var MockFocusEvent = class extends MockUIEvent {
  657. constructor(type, focusEventInitDic) {
  658. super(type);
  659. this.relatedTarget = null;
  660. if (focusEventInitDic != null) {
  661. Object.assign(this, focusEventInitDic);
  662. }
  663. }
  664. };
  665. var MockEventListener = class {
  666. constructor(type, handler) {
  667. this.type = type;
  668. this.handler = handler;
  669. }
  670. };
  671. function addEventListener(elm, type, handler) {
  672. const target = elm;
  673. if (target.__listeners == null) {
  674. target.__listeners = [];
  675. }
  676. target.__listeners.push(new MockEventListener(type, handler));
  677. }
  678. function removeEventListener(elm, type, handler) {
  679. const target = elm;
  680. if (target != null && Array.isArray(target.__listeners) === true) {
  681. const elmListener = target.__listeners.find((e) => e.type === type && e.handler === handler);
  682. if (elmListener != null) {
  683. const index = target.__listeners.indexOf(elmListener);
  684. target.__listeners.splice(index, 1);
  685. }
  686. }
  687. }
  688. function resetEventListeners(target) {
  689. if (target != null && target.__listeners != null) {
  690. target.__listeners = null;
  691. }
  692. }
  693. function triggerEventListener(elm, ev) {
  694. if (elm == null || ev.cancelBubble === true) {
  695. return;
  696. }
  697. const target = elm;
  698. ev.currentTarget = elm;
  699. if (Array.isArray(target.__listeners) === true) {
  700. const listeners = target.__listeners.filter((e) => e.type === ev.type);
  701. listeners.forEach((listener) => {
  702. try {
  703. listener.handler.call(target, ev);
  704. } catch (err2) {
  705. console.error(err2);
  706. }
  707. });
  708. }
  709. if (ev.bubbles === false) {
  710. return;
  711. }
  712. if (elm.nodeName === "#document" /* DOCUMENT_NODE */) {
  713. triggerEventListener(elm.defaultView, ev);
  714. } else if (elm.parentElement == null && elm.tagName === "HTML") {
  715. triggerEventListener(elm.ownerDocument, ev);
  716. } else {
  717. triggerEventListener(elm.parentElement, ev);
  718. }
  719. }
  720. function dispatchEvent(currentTarget, ev) {
  721. ev.target = currentTarget;
  722. triggerEventListener(currentTarget, ev);
  723. return true;
  724. }
  725. // node_modules/parse5/dist/common/unicode.js
  726. var UNDEFINED_CODE_POINTS = /* @__PURE__ */ new Set([
  727. 65534,
  728. 65535,
  729. 131070,
  730. 131071,
  731. 196606,
  732. 196607,
  733. 262142,
  734. 262143,
  735. 327678,
  736. 327679,
  737. 393214,
  738. 393215,
  739. 458750,
  740. 458751,
  741. 524286,
  742. 524287,
  743. 589822,
  744. 589823,
  745. 655358,
  746. 655359,
  747. 720894,
  748. 720895,
  749. 786430,
  750. 786431,
  751. 851966,
  752. 851967,
  753. 917502,
  754. 917503,
  755. 983038,
  756. 983039,
  757. 1048574,
  758. 1048575,
  759. 1114110,
  760. 1114111
  761. ]);
  762. var REPLACEMENT_CHARACTER = "\uFFFD";
  763. var CODE_POINTS;
  764. (function(CODE_POINTS2) {
  765. CODE_POINTS2[CODE_POINTS2["EOF"] = -1] = "EOF";
  766. CODE_POINTS2[CODE_POINTS2["NULL"] = 0] = "NULL";
  767. CODE_POINTS2[CODE_POINTS2["TABULATION"] = 9] = "TABULATION";
  768. CODE_POINTS2[CODE_POINTS2["CARRIAGE_RETURN"] = 13] = "CARRIAGE_RETURN";
  769. CODE_POINTS2[CODE_POINTS2["LINE_FEED"] = 10] = "LINE_FEED";
  770. CODE_POINTS2[CODE_POINTS2["FORM_FEED"] = 12] = "FORM_FEED";
  771. CODE_POINTS2[CODE_POINTS2["SPACE"] = 32] = "SPACE";
  772. CODE_POINTS2[CODE_POINTS2["EXCLAMATION_MARK"] = 33] = "EXCLAMATION_MARK";
  773. CODE_POINTS2[CODE_POINTS2["QUOTATION_MARK"] = 34] = "QUOTATION_MARK";
  774. CODE_POINTS2[CODE_POINTS2["NUMBER_SIGN"] = 35] = "NUMBER_SIGN";
  775. CODE_POINTS2[CODE_POINTS2["AMPERSAND"] = 38] = "AMPERSAND";
  776. CODE_POINTS2[CODE_POINTS2["APOSTROPHE"] = 39] = "APOSTROPHE";
  777. CODE_POINTS2[CODE_POINTS2["HYPHEN_MINUS"] = 45] = "HYPHEN_MINUS";
  778. CODE_POINTS2[CODE_POINTS2["SOLIDUS"] = 47] = "SOLIDUS";
  779. CODE_POINTS2[CODE_POINTS2["DIGIT_0"] = 48] = "DIGIT_0";
  780. CODE_POINTS2[CODE_POINTS2["DIGIT_9"] = 57] = "DIGIT_9";
  781. CODE_POINTS2[CODE_POINTS2["SEMICOLON"] = 59] = "SEMICOLON";
  782. CODE_POINTS2[CODE_POINTS2["LESS_THAN_SIGN"] = 60] = "LESS_THAN_SIGN";
  783. CODE_POINTS2[CODE_POINTS2["EQUALS_SIGN"] = 61] = "EQUALS_SIGN";
  784. CODE_POINTS2[CODE_POINTS2["GREATER_THAN_SIGN"] = 62] = "GREATER_THAN_SIGN";
  785. CODE_POINTS2[CODE_POINTS2["QUESTION_MARK"] = 63] = "QUESTION_MARK";
  786. CODE_POINTS2[CODE_POINTS2["LATIN_CAPITAL_A"] = 65] = "LATIN_CAPITAL_A";
  787. CODE_POINTS2[CODE_POINTS2["LATIN_CAPITAL_F"] = 70] = "LATIN_CAPITAL_F";
  788. CODE_POINTS2[CODE_POINTS2["LATIN_CAPITAL_X"] = 88] = "LATIN_CAPITAL_X";
  789. CODE_POINTS2[CODE_POINTS2["LATIN_CAPITAL_Z"] = 90] = "LATIN_CAPITAL_Z";
  790. CODE_POINTS2[CODE_POINTS2["RIGHT_SQUARE_BRACKET"] = 93] = "RIGHT_SQUARE_BRACKET";
  791. CODE_POINTS2[CODE_POINTS2["GRAVE_ACCENT"] = 96] = "GRAVE_ACCENT";
  792. CODE_POINTS2[CODE_POINTS2["LATIN_SMALL_A"] = 97] = "LATIN_SMALL_A";
  793. CODE_POINTS2[CODE_POINTS2["LATIN_SMALL_F"] = 102] = "LATIN_SMALL_F";
  794. CODE_POINTS2[CODE_POINTS2["LATIN_SMALL_X"] = 120] = "LATIN_SMALL_X";
  795. CODE_POINTS2[CODE_POINTS2["LATIN_SMALL_Z"] = 122] = "LATIN_SMALL_Z";
  796. CODE_POINTS2[CODE_POINTS2["REPLACEMENT_CHARACTER"] = 65533] = "REPLACEMENT_CHARACTER";
  797. })(CODE_POINTS = CODE_POINTS || (CODE_POINTS = {}));
  798. var SEQUENCES = {
  799. DASH_DASH: "--",
  800. CDATA_START: "[CDATA[",
  801. DOCTYPE: "doctype",
  802. SCRIPT: "script",
  803. PUBLIC: "public",
  804. SYSTEM: "system"
  805. };
  806. function isSurrogate(cp) {
  807. return cp >= 55296 && cp <= 57343;
  808. }
  809. function isSurrogatePair(cp) {
  810. return cp >= 56320 && cp <= 57343;
  811. }
  812. function getSurrogatePairCodePoint(cp1, cp2) {
  813. return (cp1 - 55296) * 1024 + 9216 + cp2;
  814. }
  815. function isControlCodePoint(cp) {
  816. return cp !== 32 && cp !== 10 && cp !== 13 && cp !== 9 && cp !== 12 && cp >= 1 && cp <= 31 || cp >= 127 && cp <= 159;
  817. }
  818. function isUndefinedCodePoint(cp) {
  819. return cp >= 64976 && cp <= 65007 || UNDEFINED_CODE_POINTS.has(cp);
  820. }
  821. // node_modules/parse5/dist/common/error-codes.js
  822. var ERR;
  823. (function(ERR2) {
  824. ERR2["controlCharacterInInputStream"] = "control-character-in-input-stream";
  825. ERR2["noncharacterInInputStream"] = "noncharacter-in-input-stream";
  826. ERR2["surrogateInInputStream"] = "surrogate-in-input-stream";
  827. ERR2["nonVoidHtmlElementStartTagWithTrailingSolidus"] = "non-void-html-element-start-tag-with-trailing-solidus";
  828. ERR2["endTagWithAttributes"] = "end-tag-with-attributes";
  829. ERR2["endTagWithTrailingSolidus"] = "end-tag-with-trailing-solidus";
  830. ERR2["unexpectedSolidusInTag"] = "unexpected-solidus-in-tag";
  831. ERR2["unexpectedNullCharacter"] = "unexpected-null-character";
  832. ERR2["unexpectedQuestionMarkInsteadOfTagName"] = "unexpected-question-mark-instead-of-tag-name";
  833. ERR2["invalidFirstCharacterOfTagName"] = "invalid-first-character-of-tag-name";
  834. ERR2["unexpectedEqualsSignBeforeAttributeName"] = "unexpected-equals-sign-before-attribute-name";
  835. ERR2["missingEndTagName"] = "missing-end-tag-name";
  836. ERR2["unexpectedCharacterInAttributeName"] = "unexpected-character-in-attribute-name";
  837. ERR2["unknownNamedCharacterReference"] = "unknown-named-character-reference";
  838. ERR2["missingSemicolonAfterCharacterReference"] = "missing-semicolon-after-character-reference";
  839. ERR2["unexpectedCharacterAfterDoctypeSystemIdentifier"] = "unexpected-character-after-doctype-system-identifier";
  840. ERR2["unexpectedCharacterInUnquotedAttributeValue"] = "unexpected-character-in-unquoted-attribute-value";
  841. ERR2["eofBeforeTagName"] = "eof-before-tag-name";
  842. ERR2["eofInTag"] = "eof-in-tag";
  843. ERR2["missingAttributeValue"] = "missing-attribute-value";
  844. ERR2["missingWhitespaceBetweenAttributes"] = "missing-whitespace-between-attributes";
  845. ERR2["missingWhitespaceAfterDoctypePublicKeyword"] = "missing-whitespace-after-doctype-public-keyword";
  846. ERR2["missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers"] = "missing-whitespace-between-doctype-public-and-system-identifiers";
  847. ERR2["missingWhitespaceAfterDoctypeSystemKeyword"] = "missing-whitespace-after-doctype-system-keyword";
  848. ERR2["missingQuoteBeforeDoctypePublicIdentifier"] = "missing-quote-before-doctype-public-identifier";
  849. ERR2["missingQuoteBeforeDoctypeSystemIdentifier"] = "missing-quote-before-doctype-system-identifier";
  850. ERR2["missingDoctypePublicIdentifier"] = "missing-doctype-public-identifier";
  851. ERR2["missingDoctypeSystemIdentifier"] = "missing-doctype-system-identifier";
  852. ERR2["abruptDoctypePublicIdentifier"] = "abrupt-doctype-public-identifier";
  853. ERR2["abruptDoctypeSystemIdentifier"] = "abrupt-doctype-system-identifier";
  854. ERR2["cdataInHtmlContent"] = "cdata-in-html-content";
  855. ERR2["incorrectlyOpenedComment"] = "incorrectly-opened-comment";
  856. ERR2["eofInScriptHtmlCommentLikeText"] = "eof-in-script-html-comment-like-text";
  857. ERR2["eofInDoctype"] = "eof-in-doctype";
  858. ERR2["nestedComment"] = "nested-comment";
  859. ERR2["abruptClosingOfEmptyComment"] = "abrupt-closing-of-empty-comment";
  860. ERR2["eofInComment"] = "eof-in-comment";
  861. ERR2["incorrectlyClosedComment"] = "incorrectly-closed-comment";
  862. ERR2["eofInCdata"] = "eof-in-cdata";
  863. ERR2["absenceOfDigitsInNumericCharacterReference"] = "absence-of-digits-in-numeric-character-reference";
  864. ERR2["nullCharacterReference"] = "null-character-reference";
  865. ERR2["surrogateCharacterReference"] = "surrogate-character-reference";
  866. ERR2["characterReferenceOutsideUnicodeRange"] = "character-reference-outside-unicode-range";
  867. ERR2["controlCharacterReference"] = "control-character-reference";
  868. ERR2["noncharacterCharacterReference"] = "noncharacter-character-reference";
  869. ERR2["missingWhitespaceBeforeDoctypeName"] = "missing-whitespace-before-doctype-name";
  870. ERR2["missingDoctypeName"] = "missing-doctype-name";
  871. ERR2["invalidCharacterSequenceAfterDoctypeName"] = "invalid-character-sequence-after-doctype-name";
  872. ERR2["duplicateAttribute"] = "duplicate-attribute";
  873. ERR2["nonConformingDoctype"] = "non-conforming-doctype";
  874. ERR2["missingDoctype"] = "missing-doctype";
  875. ERR2["misplacedDoctype"] = "misplaced-doctype";
  876. ERR2["endTagWithoutMatchingOpenElement"] = "end-tag-without-matching-open-element";
  877. ERR2["closingOfElementWithOpenChildElements"] = "closing-of-element-with-open-child-elements";
  878. ERR2["disallowedContentInNoscriptInHead"] = "disallowed-content-in-noscript-in-head";
  879. ERR2["openElementsLeftAfterEof"] = "open-elements-left-after-eof";
  880. ERR2["abandonedHeadElementChild"] = "abandoned-head-element-child";
  881. ERR2["misplacedStartTagForHeadElement"] = "misplaced-start-tag-for-head-element";
  882. ERR2["nestedNoscriptInHead"] = "nested-noscript-in-head";
  883. ERR2["eofInElementThatCanContainOnlyText"] = "eof-in-element-that-can-contain-only-text";
  884. })(ERR = ERR || (ERR = {}));
  885. // node_modules/parse5/dist/tokenizer/preprocessor.js
  886. var DEFAULT_BUFFER_WATERLINE = 1 << 16;
  887. var Preprocessor = class {
  888. constructor(handler) {
  889. this.handler = handler;
  890. this.html = "";
  891. this.pos = -1;
  892. this.lastGapPos = -2;
  893. this.gapStack = [];
  894. this.skipNextNewLine = false;
  895. this.lastChunkWritten = false;
  896. this.endOfChunkHit = false;
  897. this.bufferWaterline = DEFAULT_BUFFER_WATERLINE;
  898. this.isEol = false;
  899. this.lineStartPos = 0;
  900. this.droppedBufferSize = 0;
  901. this.line = 1;
  902. this.lastErrOffset = -1;
  903. }
  904. /** The column on the current line. If we just saw a gap (eg. a surrogate pair), return the index before. */
  905. get col() {
  906. return this.pos - this.lineStartPos + Number(this.lastGapPos !== this.pos);
  907. }
  908. get offset() {
  909. return this.droppedBufferSize + this.pos;
  910. }
  911. getError(code) {
  912. const { line, col, offset } = this;
  913. return {
  914. code,
  915. startLine: line,
  916. endLine: line,
  917. startCol: col,
  918. endCol: col,
  919. startOffset: offset,
  920. endOffset: offset
  921. };
  922. }
  923. _err(code) {
  924. if (this.handler.onParseError && this.lastErrOffset !== this.offset) {
  925. this.lastErrOffset = this.offset;
  926. this.handler.onParseError(this.getError(code));
  927. }
  928. }
  929. _addGap() {
  930. this.gapStack.push(this.lastGapPos);
  931. this.lastGapPos = this.pos;
  932. }
  933. _processSurrogate(cp) {
  934. if (this.pos !== this.html.length - 1) {
  935. const nextCp = this.html.charCodeAt(this.pos + 1);
  936. if (isSurrogatePair(nextCp)) {
  937. this.pos++;
  938. this._addGap();
  939. return getSurrogatePairCodePoint(cp, nextCp);
  940. }
  941. } else if (!this.lastChunkWritten) {
  942. this.endOfChunkHit = true;
  943. return CODE_POINTS.EOF;
  944. }
  945. this._err(ERR.surrogateInInputStream);
  946. return cp;
  947. }
  948. willDropParsedChunk() {
  949. return this.pos > this.bufferWaterline;
  950. }
  951. dropParsedChunk() {
  952. if (this.willDropParsedChunk()) {
  953. this.html = this.html.substring(this.pos);
  954. this.lineStartPos -= this.pos;
  955. this.droppedBufferSize += this.pos;
  956. this.pos = 0;
  957. this.lastGapPos = -2;
  958. this.gapStack.length = 0;
  959. }
  960. }
  961. write(chunk, isLastChunk) {
  962. if (this.html.length > 0) {
  963. this.html += chunk;
  964. } else {
  965. this.html = chunk;
  966. }
  967. this.endOfChunkHit = false;
  968. this.lastChunkWritten = isLastChunk;
  969. }
  970. insertHtmlAtCurrentPos(chunk) {
  971. this.html = this.html.substring(0, this.pos + 1) + chunk + this.html.substring(this.pos + 1);
  972. this.endOfChunkHit = false;
  973. }
  974. startsWith(pattern, caseSensitive) {
  975. if (this.pos + pattern.length > this.html.length) {
  976. this.endOfChunkHit = !this.lastChunkWritten;
  977. return false;
  978. }
  979. if (caseSensitive) {
  980. return this.html.startsWith(pattern, this.pos);
  981. }
  982. for (let i = 0; i < pattern.length; i++) {
  983. const cp = this.html.charCodeAt(this.pos + i) | 32;
  984. if (cp !== pattern.charCodeAt(i)) {
  985. return false;
  986. }
  987. }
  988. return true;
  989. }
  990. peek(offset) {
  991. const pos = this.pos + offset;
  992. if (pos >= this.html.length) {
  993. this.endOfChunkHit = !this.lastChunkWritten;
  994. return CODE_POINTS.EOF;
  995. }
  996. const code = this.html.charCodeAt(pos);
  997. return code === CODE_POINTS.CARRIAGE_RETURN ? CODE_POINTS.LINE_FEED : code;
  998. }
  999. advance() {
  1000. this.pos++;
  1001. if (this.isEol) {
  1002. this.isEol = false;
  1003. this.line++;
  1004. this.lineStartPos = this.pos;
  1005. }
  1006. if (this.pos >= this.html.length) {
  1007. this.endOfChunkHit = !this.lastChunkWritten;
  1008. return CODE_POINTS.EOF;
  1009. }
  1010. let cp = this.html.charCodeAt(this.pos);
  1011. if (cp === CODE_POINTS.CARRIAGE_RETURN) {
  1012. this.isEol = true;
  1013. this.skipNextNewLine = true;
  1014. return CODE_POINTS.LINE_FEED;
  1015. }
  1016. if (cp === CODE_POINTS.LINE_FEED) {
  1017. this.isEol = true;
  1018. if (this.skipNextNewLine) {
  1019. this.line--;
  1020. this.skipNextNewLine = false;
  1021. this._addGap();
  1022. return this.advance();
  1023. }
  1024. }
  1025. this.skipNextNewLine = false;
  1026. if (isSurrogate(cp)) {
  1027. cp = this._processSurrogate(cp);
  1028. }
  1029. const isCommonValidRange = this.handler.onParseError === null || cp > 31 && cp < 127 || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.CARRIAGE_RETURN || cp > 159 && cp < 64976;
  1030. if (!isCommonValidRange) {
  1031. this._checkForProblematicCharacters(cp);
  1032. }
  1033. return cp;
  1034. }
  1035. _checkForProblematicCharacters(cp) {
  1036. if (isControlCodePoint(cp)) {
  1037. this._err(ERR.controlCharacterInInputStream);
  1038. } else if (isUndefinedCodePoint(cp)) {
  1039. this._err(ERR.noncharacterInInputStream);
  1040. }
  1041. }
  1042. retreat(count) {
  1043. this.pos -= count;
  1044. while (this.pos < this.lastGapPos) {
  1045. this.lastGapPos = this.gapStack.pop();
  1046. this.pos--;
  1047. }
  1048. this.isEol = false;
  1049. }
  1050. };
  1051. // node_modules/parse5/dist/common/token.js
  1052. var token_exports = {};
  1053. __export(token_exports, {
  1054. TokenType: () => TokenType,
  1055. getTokenAttr: () => getTokenAttr
  1056. });
  1057. var TokenType;
  1058. (function(TokenType2) {
  1059. TokenType2[TokenType2["CHARACTER"] = 0] = "CHARACTER";
  1060. TokenType2[TokenType2["NULL_CHARACTER"] = 1] = "NULL_CHARACTER";
  1061. TokenType2[TokenType2["WHITESPACE_CHARACTER"] = 2] = "WHITESPACE_CHARACTER";
  1062. TokenType2[TokenType2["START_TAG"] = 3] = "START_TAG";
  1063. TokenType2[TokenType2["END_TAG"] = 4] = "END_TAG";
  1064. TokenType2[TokenType2["COMMENT"] = 5] = "COMMENT";
  1065. TokenType2[TokenType2["DOCTYPE"] = 6] = "DOCTYPE";
  1066. TokenType2[TokenType2["EOF"] = 7] = "EOF";
  1067. TokenType2[TokenType2["HIBERNATION"] = 8] = "HIBERNATION";
  1068. })(TokenType = TokenType || (TokenType = {}));
  1069. function getTokenAttr(token, attrName) {
  1070. for (let i = token.attrs.length - 1; i >= 0; i--) {
  1071. if (token.attrs[i].name === attrName) {
  1072. return token.attrs[i].value;
  1073. }
  1074. }
  1075. return null;
  1076. }
  1077. // node_modules/entities/lib/esm/generated/decode-data-html.js
  1078. var decode_data_html_default = new Uint16Array(
  1079. // prettier-ignore
  1080. '\u1D41<\xD5\u0131\u028A\u049D\u057B\u05D0\u0675\u06DE\u07A2\u07D6\u080F\u0A4A\u0A91\u0DA1\u0E6D\u0F09\u0F26\u10CA\u1228\u12E1\u1415\u149D\u14C3\u14DF\u1525\0\0\0\0\0\0\u156B\u16CD\u198D\u1C12\u1DDD\u1F7E\u2060\u21B0\u228D\u23C0\u23FB\u2442\u2824\u2912\u2D08\u2E48\u2FCE\u3016\u32BA\u3639\u37AC\u38FE\u3A28\u3A71\u3AE0\u3B2E\u0800EMabcfglmnoprstu\\bfms\x7F\x84\x8B\x90\x95\x98\xA6\xB3\xB9\xC8\xCFlig\u803B\xC6\u40C6P\u803B&\u4026cute\u803B\xC1\u40C1reve;\u4102\u0100iyx}rc\u803B\xC2\u40C2;\u4410r;\uC000\u{1D504}rave\u803B\xC0\u40C0pha;\u4391acr;\u4100d;\u6A53\u0100gp\x9D\xA1on;\u4104f;\uC000\u{1D538}plyFunction;\u6061ing\u803B\xC5\u40C5\u0100cs\xBE\xC3r;\uC000\u{1D49C}ign;\u6254ilde\u803B\xC3\u40C3ml\u803B\xC4\u40C4\u0400aceforsu\xE5\xFB\xFE\u0117\u011C\u0122\u0127\u012A\u0100cr\xEA\xF2kslash;\u6216\u0176\xF6\xF8;\u6AE7ed;\u6306y;\u4411\u0180crt\u0105\u010B\u0114ause;\u6235noullis;\u612Ca;\u4392r;\uC000\u{1D505}pf;\uC000\u{1D539}eve;\u42D8c\xF2\u0113mpeq;\u624E\u0700HOacdefhilorsu\u014D\u0151\u0156\u0180\u019E\u01A2\u01B5\u01B7\u01BA\u01DC\u0215\u0273\u0278\u027Ecy;\u4427PY\u803B\xA9\u40A9\u0180cpy\u015D\u0162\u017Aute;\u4106\u0100;i\u0167\u0168\u62D2talDifferentialD;\u6145leys;\u612D\u0200aeio\u0189\u018E\u0194\u0198ron;\u410Cdil\u803B\xC7\u40C7rc;\u4108nint;\u6230ot;\u410A\u0100dn\u01A7\u01ADilla;\u40B8terDot;\u40B7\xF2\u017Fi;\u43A7rcle\u0200DMPT\u01C7\u01CB\u01D1\u01D6ot;\u6299inus;\u6296lus;\u6295imes;\u6297o\u0100cs\u01E2\u01F8kwiseContourIntegral;\u6232eCurly\u0100DQ\u0203\u020FoubleQuote;\u601Duote;\u6019\u0200lnpu\u021E\u0228\u0247\u0255on\u0100;e\u0225\u0226\u6237;\u6A74\u0180git\u022F\u0236\u023Aruent;\u6261nt;\u622FourIntegral;\u622E\u0100fr\u024C\u024E;\u6102oduct;\u6210nterClockwiseContourIntegral;\u6233oss;\u6A2Fcr;\uC000\u{1D49E}p\u0100;C\u0284\u0285\u62D3ap;\u624D\u0580DJSZacefios\u02A0\u02AC\u02B0\u02B4\u02B8\u02CB\u02D7\u02E1\u02E6\u0333\u048D\u0100;o\u0179\u02A5trahd;\u6911cy;\u4402cy;\u4405cy;\u440F\u0180grs\u02BF\u02C4\u02C7ger;\u6021r;\u61A1hv;\u6AE4\u0100ay\u02D0\u02D5ron;\u410E;\u4414l\u0100;t\u02DD\u02DE\u6207a;\u4394r;\uC000\u{1D507}\u0100af\u02EB\u0327\u0100cm\u02F0\u0322ritical\u0200ADGT\u0300\u0306\u0316\u031Ccute;\u40B4o\u0174\u030B\u030D;\u42D9bleAcute;\u42DDrave;\u4060ilde;\u42DCond;\u62C4ferentialD;\u6146\u0470\u033D\0\0\0\u0342\u0354\0\u0405f;\uC000\u{1D53B}\u0180;DE\u0348\u0349\u034D\u40A8ot;\u60DCqual;\u6250ble\u0300CDLRUV\u0363\u0372\u0382\u03CF\u03E2\u03F8ontourIntegra\xEC\u0239o\u0274\u0379\0\0\u037B\xBB\u0349nArrow;\u61D3\u0100eo\u0387\u03A4ft\u0180ART\u0390\u0396\u03A1rrow;\u61D0ightArrow;\u61D4e\xE5\u02CAng\u0100LR\u03AB\u03C4eft\u0100AR\u03B3\u03B9rrow;\u67F8ightArrow;\u67FAightArrow;\u67F9ight\u0100AT\u03D8\u03DErrow;\u61D2ee;\u62A8p\u0241\u03E9\0\0\u03EFrrow;\u61D1ownArrow;\u61D5erticalBar;\u6225n\u0300ABLRTa\u0412\u042A\u0430\u045E\u047F\u037Crrow\u0180;BU\u041D\u041E\u0422\u6193ar;\u6913pArrow;\u61F5reve;\u4311eft\u02D2\u043A\0\u0446\0\u0450ightVector;\u6950eeVector;\u695Eector\u0100;B\u0459\u045A\u61BDar;\u6956ight\u01D4\u0467\0\u0471eeVector;\u695Fector\u0100;B\u047A\u047B\u61C1ar;\u6957ee\u0100;A\u0486\u0487\u62A4rrow;\u61A7\u0100ct\u0492\u0497r;\uC000\u{1D49F}rok;\u4110\u0800NTacdfglmopqstux\u04BD\u04C0\u04C4\u04CB\u04DE\u04E2\u04E7\u04EE\u04F5\u0521\u052F\u0536\u0552\u055D\u0560\u0565G;\u414AH\u803B\xD0\u40D0cute\u803B\xC9\u40C9\u0180aiy\u04D2\u04D7\u04DCron;\u411Arc\u803B\xCA\u40CA;\u442Dot;\u4116r;\uC000\u{1D508}rave\u803B\xC8\u40C8ement;\u6208\u0100ap\u04FA\u04FEcr;\u4112ty\u0253\u0506\0\0\u0512mallSquare;\u65FBerySmallSquare;\u65AB\u0100gp\u0526\u052Aon;\u4118f;\uC000\u{1D53C}silon;\u4395u\u0100ai\u053C\u0549l\u0100;T\u0542\u0543\u6A75ilde;\u6242librium;\u61CC\u0100ci\u0557\u055Ar;\u6130m;\u6A73a;\u4397ml\u803B\xCB\u40CB\u0100ip\u056A\u056Fsts;\u6203onentialE;\u6147\u0280cfios\u0585\u0588\u058D\u05B2\u05CCy;\u4424r;\uC000\u{1D509}lled\u0253\u0597\0\0\u05A3mallSquare;\u65FCerySmallSquare;\u65AA\u0370\u05BA\0\u05BF\0\0\u05C4f;\uC000\u{1D53D}All;\u6200riertrf;\u6131c\xF2\u05CB\u0600JTabcdfgorst\u05E8\u05EC\u05EF\u05FA\u0600\u0612\u0616\u061B\u061D\u0623\u066C\u0672cy;\u4403\u803B>\u403Emma\u0100;d\u05F7\u05F8\u4393;\u43DCreve;\u411E\u0180eiy\u0607\u060C\u0610dil;\u4122rc;\u411C;\u4413ot;\u4120r;\uC000\u{1D50A};\u62D9pf;\uC000\u{1D53E}eater\u0300EFGLST\u0635\u0644\u064E\u0656\u065B\u0666qual\u0100;L\u063E\u063F\u6265ess;\u62DBullEqual;\u6267reater;\u6AA2ess;\u6277lantEqual;\u6A7Eilde;\u6273cr;\uC000\u{1D4A2};\u626B\u0400Aacfiosu\u0685\u068B\u0696\u069B\u069E\u06AA\u06BE\u06CARDcy;\u442A\u0100ct\u0690\u0694ek;\u42C7;\u405Eirc;\u4124r;\u610ClbertSpace;\u610B\u01F0\u06AF\0\u06B2f;\u610DizontalLine;\u6500\u0100ct\u06C3\u06C5\xF2\u06A9rok;\u4126mp\u0144\u06D0\u06D8ownHum\xF0\u012Fqual;\u624F\u0700EJOacdfgmnostu\u06FA\u06FE\u0703\u0707\u070E\u071A\u071E\u0721\u0728\u0744\u0778\u078B\u078F\u0795cy;\u4415lig;\u4132cy;\u4401cute\u803B\xCD\u40CD\u0100iy\u0713\u0718rc\u803B\xCE\u40CE;\u4418ot;\u4130r;\u6111rave\u803B\xCC\u40CC\u0180;ap\u0720\u072F\u073F\u0100cg\u0734\u0737r;\u412AinaryI;\u6148lie\xF3\u03DD\u01F4\u0749\0\u0762\u0100;e\u074D\u074E\u622C\u0100gr\u0753\u0758ral;\u622Bsection;\u62C2isible\u0100CT\u076C\u0772omma;\u6063imes;\u6062\u0180gpt\u077F\u0783\u0788on;\u412Ef;\uC000\u{1D540}a;\u4399cr;\u6110ilde;\u4128\u01EB\u079A\0\u079Ecy;\u4406l\u803B\xCF\u40CF\u0280cfosu\u07AC\u07B7\u07BC\u07C2\u07D0\u0100iy\u07B1\u07B5rc;\u4134;\u4419r;\uC000\u{1D50D}pf;\uC000\u{1D541}\u01E3\u07C7\0\u07CCr;\uC000\u{1D4A5}rcy;\u4408kcy;\u4404\u0380HJacfos\u07E4\u07E8\u07EC\u07F1\u07FD\u0802\u0808cy;\u4425cy;\u440Cppa;\u439A\u0100ey\u07F6\u07FBdil;\u4136;\u441Ar;\uC000\u{1D50E}pf;\uC000\u{1D542}cr;\uC000\u{1D4A6}\u0580JTaceflmost\u0825\u0829\u082C\u0850\u0863\u09B3\u09B8\u09C7\u09CD\u0A37\u0A47cy;\u4409\u803B<\u403C\u0280cmnpr\u0837\u083C\u0841\u0844\u084Dute;\u4139bda;\u439Bg;\u67EAlacetrf;\u6112r;\u619E\u0180aey\u0857\u085C\u0861ron;\u413Ddil;\u413B;\u441B\u0100fs\u0868\u0970t\u0500ACDFRTUVar\u087E\u08A9\u08B1\u08E0\u08E6\u08FC\u092F\u095B\u0390\u096A\u0100nr\u0883\u088FgleBracket;\u67E8row\u0180;BR\u0899\u089A\u089E\u6190ar;\u61E4ightArrow;\u61C6eiling;\u6308o\u01F5\u08B7\0\u08C3bleBracket;\u67E6n\u01D4\u08C8\0\u08D2eeVector;\u6961ector\u0100;B\u08DB\u08DC\u61C3ar;\u6959loor;\u630Aight\u0100AV\u08EF\u08F5rrow;\u6194ector;\u694E\u0100er\u0901\u0917e\u0180;AV\u0909\u090A\u0910\u62A3rrow;\u61A4ector;\u695Aiangle\u0180;BE\u0924\u0925\u0929\u62B2ar;\u69CFqual;\u62B4p\u0180DTV\u0937\u0942\u094CownVector;\u6951eeVector;\u6960ector\u0100;B\u0956\u0957\u61BFar;\u6958ector\u0100;B\u0965\u0966\u61BCar;\u6952ight\xE1\u039Cs\u0300EFGLST\u097E\u098B\u0995\u099D\u09A2\u09ADqualGreater;\u62DAullEqual;\u6266reater;\u6276ess;\u6AA1lantEqual;\u6A7Dilde;\u6272r;\uC000\u{1D50F}\u0100;e\u09BD\u09BE\u62D8ftarrow;\u61DAidot;\u413F\u0180npw\u09D4\u0A16\u0A1Bg\u0200LRlr\u09DE\u09F7\u0A02\u0A10eft\u0100AR\u09E6\u09ECrrow;\u67F5ightArrow;\u67F7ightArrow;\u67F6eft\u0100ar\u03B3\u0A0Aight\xE1\u03BFight\xE1\u03CAf;\uC000\u{1D543}er\u0100LR\u0A22\u0A2CeftArrow;\u6199ightArrow;\u6198\u0180cht\u0A3E\u0A40\u0A42\xF2\u084C;\u61B0rok;\u4141;\u626A\u0400acefiosu\u0A5A\u0A5D\u0A60\u0A77\u0A7C\u0A85\u0A8B\u0A8Ep;\u6905y;\u441C\u0100dl\u0A65\u0A6FiumSpace;\u605Flintrf;\u6133r;\uC000\u{1D510}nusPlus;\u6213pf;\uC000\u{1D544}c\xF2\u0A76;\u439C\u0480Jacefostu\u0AA3\u0AA7\u0AAD\u0AC0\u0B14\u0B19\u0D91\u0D97\u0D9Ecy;\u440Acute;\u4143\u0180aey\u0AB4\u0AB9\u0ABEron;\u4147dil;\u4145;\u441D\u0180gsw\u0AC7\u0AF0\u0B0Eative\u0180MTV\u0AD3\u0ADF\u0AE8ediumSpace;\u600Bhi\u0100cn\u0AE6\u0AD8\xEB\u0AD9eryThi\xEE\u0AD9ted\u0100GL\u0AF8\u0B06reaterGreate\xF2\u0673essLes\xF3\u0A48Line;\u400Ar;\uC000\u{1D511}\u0200Bnpt\u0B22\u0B28\u0B37\u0B3Areak;\u6060BreakingSpace;\u40A0f;\u6115\u0680;CDEGHLNPRSTV\u0B55\u0B56\u0B6A\u0B7C\u0BA1\u0BEB\u0C04\u0C5E\u0C84\u0CA6\u0CD8\u0D61\u0D85\u6AEC\u0100ou\u0B5B\u0B64ngruent;\u6262pCap;\u626DoubleVerticalBar;\u6226\u0180lqx\u0B83\u0B8A\u0B9Bement;\u6209ual\u0100;T\u0B92\u0B93\u6260ilde;\uC000\u2242\u0338ists;\u6204reater\u0380;EFGLST\u0BB6\u0BB7\u0BBD\u0BC9\u0BD3\u0BD8\u0BE5\u626Fqual;\u6271ullEqual;\uC000\u2267\u0338reater;\uC000\u226B\u0338ess;\u6279lantEqual;\uC000\u2A7E\u0338ilde;\u6275ump\u0144\u0BF2\u0BFDownHump;\uC000\u224E\u0338qual;\uC000\u224F\u0338e\u0100fs\u0C0A\u0C27tTriangle\u0180;BE\u0C1A\u0C1B\u0C21\u62EAar;\uC000\u29CF\u0338qual;\u62ECs\u0300;EGLST\u0C35\u0C36\u0C3C\u0C44\u0C4B\u0C58\u626Equal;\u6270reater;\u6278ess;\uC000\u226A\u0338lantEqual;\uC000\u2A7D\u0338ilde;\u6274ested\u0100GL\u0C68\u0C79reaterGreater;\uC000\u2AA2\u0338essLess;\uC000\u2AA1\u0338recedes\u0180;ES\u0C92\u0C93\u0C9B\u6280qual;\uC000\u2AAF\u0338lantEqual;\u62E0\u0100ei\u0CAB\u0CB9verseElement;\u620CghtTriangle\u0180;BE\u0CCB\u0CCC\u0CD2\u62EBar;\uC000\u29D0\u0338qual;\u62ED\u0100qu\u0CDD\u0D0CuareSu\u0100bp\u0CE8\u0CF9set\u0100;E\u0CF0\u0CF3\uC000\u228F\u0338qual;\u62E2erset\u0100;E\u0D03\u0D06\uC000\u2290\u0338qual;\u62E3\u0180bcp\u0D13\u0D24\u0D4Eset\u0100;E\u0D1B\u0D1E\uC000\u2282\u20D2qual;\u6288ceeds\u0200;EST\u0D32\u0D33\u0D3B\u0D46\u6281qual;\uC000\u2AB0\u0338lantEqual;\u62E1ilde;\uC000\u227F\u0338erset\u0100;E\u0D58\u0D5B\uC000\u2283\u20D2qual;\u6289ilde\u0200;EFT\u0D6E\u0D6F\u0D75\u0D7F\u6241qual;\u6244ullEqual;\u6247ilde;\u6249erticalBar;\u6224cr;\uC000\u{1D4A9}ilde\u803B\xD1\u40D1;\u439D\u0700Eacdfgmoprstuv\u0DBD\u0DC2\u0DC9\u0DD5\u0DDB\u0DE0\u0DE7\u0DFC\u0E02\u0E20\u0E22\u0E32\u0E3F\u0E44lig;\u4152cute\u803B\xD3\u40D3\u0100iy\u0DCE\u0DD3rc\u803B\xD4\u40D4;\u441Eblac;\u4150r;\uC000\u{1D512}rave\u803B\xD2\u40D2\u0180aei\u0DEE\u0DF2\u0DF6cr;\u414Cga;\u43A9cron;\u439Fpf;\uC000\u{1D546}enCurly\u0100DQ\u0E0E\u0E1AoubleQuote;\u601Cuote;\u6018;\u6A54\u0100cl\u0E27\u0E2Cr;\uC000\u{1D4AA}ash\u803B\xD8\u40D8i\u016C\u0E37\u0E3Cde\u803B\xD5\u40D5es;\u6A37ml\u803B\xD6\u40D6er\u0100BP\u0E4B\u0E60\u0100ar\u0E50\u0E53r;\u603Eac\u0100ek\u0E5A\u0E5C;\u63DEet;\u63B4arenthesis;\u63DC\u0480acfhilors\u0E7F\u0E87\u0E8A\u0E8F\u0E92\u0E94\u0E9D\u0EB0\u0EFCrtialD;\u6202y;\u441Fr;\uC000\u{1D513}i;\u43A6;\u43A0usMinus;\u40B1\u0100ip\u0EA2\u0EADncareplan\xE5\u069Df;\u6119\u0200;eio\u0EB9\u0EBA\u0EE0\u0EE4\u6ABBcedes\u0200;EST\u0EC8\u0EC9\u0ECF\u0EDA\u627Aqual;\u6AAFlantEqual;\u627Cilde;\u627Eme;\u6033\u0100dp\u0EE9\u0EEEuct;\u620Fortion\u0100;a\u0225\u0EF9l;\u621D\u0100ci\u0F01\u0F06r;\uC000\u{1D4AB};\u43A8\u0200Ufos\u0F11\u0F16\u0F1B\u0F1FOT\u803B"\u4022r;\uC000\u{1D514}pf;\u611Acr;\uC000\u{1D4AC}\u0600BEacefhiorsu\u0F3E\u0F43\u0F47\u0F60\u0F73\u0FA7\u0FAA\u0FAD\u1096\u10A9\u10B4\u10BEarr;\u6910G\u803B\xAE\u40AE\u0180cnr\u0F4E\u0F53\u0F56ute;\u4154g;\u67EBr\u0100;t\u0F5C\u0F5D\u61A0l;\u6916\u0180aey\u0F67\u0F6C\u0F71ron;\u4158dil;\u4156;\u4420\u0100;v\u0F78\u0F79\u611Cerse\u0100EU\u0F82\u0F99\u0100lq\u0F87\u0F8Eement;\u620Builibrium;\u61CBpEquilibrium;\u696Fr\xBB\u0F79o;\u43A1ght\u0400ACDFTUVa\u0FC1\u0FEB\u0FF3\u1022\u1028\u105B\u1087\u03D8\u0100nr\u0FC6\u0FD2gleBracket;\u67E9row\u0180;BL\u0FDC\u0FDD\u0FE1\u6192ar;\u61E5eftArrow;\u61C4eiling;\u6309o\u01F5\u0FF9\0\u1005bleBracket;\u67E7n\u01D4\u100A\0\u1014eeVector;\u695Dector\u0100;B\u101D\u101E\u61C2ar;\u6955loor;\u630B\u0100er\u102D\u1043e\u0180;AV\u1035\u1036\u103C\u62A2rrow;\u61A6ector;\u695Biangle\u0180;BE\u1050\u1051\u1055\u62B3ar;\u69D0qual;\u62B5p\u0180DTV\u1063\u106E\u1078ownVector;\u694FeeVector;\u695Cector\u0100;B\u1082\u1083\u61BEar;\u6954ector\u0100;B\u1091\u1092\u61C0ar;\u6953\u0100pu\u109B\u109Ef;\u611DndImplies;\u6970ightarrow;\u61DB\u0100ch\u10B9\u10BCr;\u611B;\u61B1leDelayed;\u69F4\u0680HOacfhimoqstu\u10E4\u10F1\u10F7\u10FD\u1119\u111E\u1151\u1156\u1161\u1167\u11B5\u11BB\u11BF\u0100Cc\u10E9\u10EEHcy;\u4429y;\u4428FTcy;\u442Ccute;\u415A\u0280;aeiy\u1108\u1109\u110E\u1113\u1117\u6ABCron;\u4160dil;\u415Erc;\u415C;\u4421r;\uC000\u{1D516}ort\u0200DLRU\u112A\u1134\u113E\u1149ownArrow\xBB\u041EeftArrow\xBB\u089AightArrow\xBB\u0FDDpArrow;\u6191gma;\u43A3allCircle;\u6218pf;\uC000\u{1D54A}\u0272\u116D\0\0\u1170t;\u621Aare\u0200;ISU\u117B\u117C\u1189\u11AF\u65A1ntersection;\u6293u\u0100bp\u118F\u119Eset\u0100;E\u1197\u1198\u628Fqual;\u6291erset\u0100;E\u11A8\u11A9\u6290qual;\u6292nion;\u6294cr;\uC000\u{1D4AE}ar;\u62C6\u0200bcmp\u11C8\u11DB\u1209\u120B\u0100;s\u11CD\u11CE\u62D0et\u0100;E\u11CD\u11D5qual;\u6286\u0100ch\u11E0\u1205eeds\u0200;EST\u11ED\u11EE\u11F4\u11FF\u627Bqual;\u6AB0lantEqual;\u627Dilde;\u627FTh\xE1\u0F8C;\u6211\u0180;es\u1212\u1213\u1223\u62D1rset\u0100;E\u121C\u121D\u6283qual;\u6287et\xBB\u1213\u0580HRSacfhiors\u123E\u1244\u1249\u1255\u125E\u1271\u1276\u129F\u12C2\u12C8\u12D1ORN\u803B\xDE\u40DEADE;\u6122\u0100Hc\u124E\u1252cy;\u440By;\u4426\u0100bu\u125A\u125C;\u4009;\u43A4\u0180aey\u1265\u126A\u126Fron;\u4164dil;\u4162;\u4422r;\uC000\u{1D517}\u0100ei\u127B\u1289\u01F2\u1280\0\u1287efore;\u6234a;\u4398\u0100cn\u128E\u1298kSpace;\uC000\u205F\u200ASpace;\u6009lde\u0200;EFT\u12AB\u12AC\u12B2\u12BC\u623Cqual;\u6243ullEqual;\u6245ilde;\u6248pf;\uC000\u{1D54B}ipleDot;\u60DB\u0100ct\u12D6\u12DBr;\uC000\u{1D4AF}rok;\u4166\u0AE1\u12F7\u130E\u131A\u1326\0\u132C\u1331\0\0\0\0\0\u1338\u133D\u1377\u1385\0\u13FF\u1404\u140A\u1410\u0100cr\u12FB\u1301ute\u803B\xDA\u40DAr\u0100;o\u1307\u1308\u619Fcir;\u6949r\u01E3\u1313\0\u1316y;\u440Eve;\u416C\u0100iy\u131E\u1323rc\u803B\xDB\u40DB;\u4423blac;\u4170r;\uC000\u{1D518}rave\u803B\xD9\u40D9acr;\u416A\u0100di\u1341\u1369er\u0100BP\u1348\u135D\u0100ar\u134D\u1350r;\u405Fac\u0100ek\u1357\u1359;\u63DFet;\u63B5arenthesis;\u63DDon\u0100;P\u1370\u1371\u62C3lus;\u628E\u0100gp\u137B\u137Fon;\u4172f;\uC000\u{1D54C}\u0400ADETadps\u1395\u13AE\u13B8\u13C4\u03E8\u13D2\u13D7\u13F3rrow\u0180;BD\u1150\u13A0\u13A4ar;\u6912ownArrow;\u61C5ownArrow;\u6195quilibrium;\u696Eee\u0100;A\u13CB\u13CC\u62A5rrow;\u61A5own\xE1\u03F3er\u0100LR\u13DE\u13E8eftArrow;\u6196ightArrow;\u6197i\u0100;l\u13F9\u13FA\u43D2on;\u43A5ing;\u416Ecr;\uC000\u{1D4B0}ilde;\u4168ml\u803B\xDC\u40DC\u0480Dbcdefosv\u1427\u142C\u1430\u1433\u143E\u1485\u148A\u1490\u1496ash;\u62ABar;\u6AEBy;\u4412ash\u0100;l\u143B\u143C\u62A9;\u6AE6\u0100er\u1443\u1445;\u62C1\u0180bty\u144C\u1450\u147Aar;\u6016\u0100;i\u144F\u1455cal\u0200BLST\u1461\u1465\u146A\u1474ar;\u6223ine;\u407Ceparator;\u6758ilde;\u6240ThinSpace;\u600Ar;\uC000\u{1D519}pf;\uC000\u{1D54D}cr;\uC000\u{1D4B1}dash;\u62AA\u0280cefos\u14A7\u14AC\u14B1\u14B6\u14BCirc;\u4174dge;\u62C0r;\uC000\u{1D51A}pf;\uC000\u{1D54E}cr;\uC000\u{1D4B2}\u0200fios\u14CB\u14D0\u14D2\u14D8r;\uC000\u{1D51B};\u439Epf;\uC000\u{1D54F}cr;\uC000\u{1D4B3}\u0480AIUacfosu\u14F1\u14F5\u14F9\u14FD\u1504\u150F\u1514\u151A\u1520cy;\u442Fcy;\u4407cy;\u442Ecute\u803B\xDD\u40DD\u0100iy\u1509\u150Drc;\u4176;\u442Br;\uC000\u{1D51C}pf;\uC000\u{1D550}cr;\uC000\u{1D4B4}ml;\u4178\u0400Hacdefos\u1535\u1539\u153F\u154B\u154F\u155D\u1560\u1564cy;\u4416cute;\u4179\u0100ay\u1544\u1549ron;\u417D;\u4417ot;\u417B\u01F2\u1554\0\u155BoWidt\xE8\u0AD9a;\u4396r;\u6128pf;\u6124cr;\uC000\u{1D4B5}\u0BE1\u1583\u158A\u1590\0\u15B0\u15B6\u15BF\0\0\0\0\u15C6\u15DB\u15EB\u165F\u166D\0\u1695\u169B\u16B2\u16B9\0\u16BEcute\u803B\xE1\u40E1reve;\u4103\u0300;Ediuy\u159C\u159D\u15A1\u15A3\u15A8\u15AD\u623E;\uC000\u223E\u0333;\u623Frc\u803B\xE2\u40E2te\u80BB\xB4\u0306;\u4430lig\u803B\xE6\u40E6\u0100;r\xB2\u15BA;\uC000\u{1D51E}rave\u803B\xE0\u40E0\u0100ep\u15CA\u15D6\u0100fp\u15CF\u15D4sym;\u6135\xE8\u15D3ha;\u43B1\u0100ap\u15DFc\u0100cl\u15E4\u15E7r;\u4101g;\u6A3F\u0264\u15F0\0\0\u160A\u0280;adsv\u15FA\u15FB\u15FF\u1601\u1607\u6227nd;\u6A55;\u6A5Clope;\u6A58;\u6A5A\u0380;elmrsz\u1618\u1619\u161B\u161E\u163F\u164F\u1659\u6220;\u69A4e\xBB\u1619sd\u0100;a\u1625\u1626\u6221\u0461\u1630\u1632\u1634\u1636\u1638\u163A\u163C\u163E;\u69A8;\u69A9;\u69AA;\u69AB;\u69AC;\u69AD;\u69AE;\u69AFt\u0100;v\u1645\u1646\u621Fb\u0100;d\u164C\u164D\u62BE;\u699D\u0100pt\u1654\u1657h;\u6222\xBB\xB9arr;\u637C\u0100gp\u1663\u1667on;\u4105f;\uC000\u{1D552}\u0380;Eaeiop\u12C1\u167B\u167D\u1682\u1684\u1687\u168A;\u6A70cir;\u6A6F;\u624Ad;\u624Bs;\u4027rox\u0100;e\u12C1\u1692\xF1\u1683ing\u803B\xE5\u40E5\u0180cty\u16A1\u16A6\u16A8r;\uC000\u{1D4B6};\u402Amp\u0100;e\u12C1\u16AF\xF1\u0288ilde\u803B\xE3\u40E3ml\u803B\xE4\u40E4\u0100ci\u16C2\u16C8onin\xF4\u0272nt;\u6A11\u0800Nabcdefiklnoprsu\u16ED\u16F1\u1730\u173C\u1743\u1748\u1778\u177D\u17E0\u17E6\u1839\u1850\u170D\u193D\u1948\u1970ot;\u6AED\u0100cr\u16F6\u171Ek\u0200ceps\u1700\u1705\u170D\u1713ong;\u624Cpsilon;\u43F6rime;\u6035im\u0100;e\u171A\u171B\u623Dq;\u62CD\u0176\u1722\u1726ee;\u62BDed\u0100;g\u172C\u172D\u6305e\xBB\u172Drk\u0100;t\u135C\u1737brk;\u63B6\u0100oy\u1701\u1741;\u4431quo;\u601E\u0280cmprt\u1753\u175B\u1761\u1764\u1768aus\u0100;e\u010A\u0109ptyv;\u69B0s\xE9\u170Cno\xF5\u0113\u0180ahw\u176F\u1771\u1773;\u43B2;\u6136een;\u626Cr;\uC000\u{1D51F}g\u0380costuvw\u178D\u179D\u17B3\u17C1\u17D5\u17DB\u17DE\u0180aiu\u1794\u1796\u179A\xF0\u0760rc;\u65EFp\xBB\u1371\u0180dpt\u17A4\u17A8\u17ADot;\u6A00lus;\u6A01imes;\u6A02\u0271\u17B9\0\0\u17BEcup;\u6A06ar;\u6605riangle\u0100du\u17CD\u17D2own;\u65BDp;\u65B3plus;\u6A04e\xE5\u1444\xE5\u14ADarow;\u690D\u0180ako\u17ED\u1826\u1835\u0100cn\u17F2\u1823k\u0180lst\u17FA\u05AB\u1802ozenge;\u69EBriangle\u0200;dlr\u1812\u1813\u1818\u181D\u65B4own;\u65BEeft;\u65C2ight;\u65B8k;\u6423\u01B1\u182B\0\u1833\u01B2\u182F\0\u1831;\u6592;\u65914;\u6593ck;\u6588\u0100eo\u183E\u184D\u0100;q\u1843\u1846\uC000=\u20E5uiv;\uC000\u2261\u20E5t;\u6310\u0200ptwx\u1859\u185E\u1867\u186Cf;\uC000\u{1D553}\u0100;t\u13CB\u1863om\xBB\u13CCtie;\u62C8\u0600DHUVbdhmptuv\u1885\u1896\u18AA\u18BB\u18D7\u18DB\u18EC\u18FF\u1905\u190A\u1910\u1921\u0200LRlr\u188E\u1890\u1892\u1894;\u6557;\u6554;\u6556;\u6553\u0280;DUdu\u18A1\u18A2\u18A4\u18A6\u18A8\u6550;\u6566;\u6569;\u6564;\u6567\u0200LRlr\u18B3\u18B5\u18B7\u18B9;\u655D;\u655A;\u655C;\u6559\u0380;HLRhlr\u18CA\u18CB\u18CD\u18CF\u18D1\u18D3\u18D5\u6551;\u656C;\u6563;\u6560;\u656B;\u6562;\u655Fox;\u69C9\u0200LRlr\u18E4\u18E6\u18E8\u18EA;\u6555;\u6552;\u6510;\u650C\u0280;DUdu\u06BD\u18F7\u18F9\u18FB\u18FD;\u6565;\u6568;\u652C;\u6534inus;\u629Flus;\u629Eimes;\u62A0\u0200LRlr\u1919\u191B\u191D\u191F;\u655B;\u6558;\u6518;\u6514\u0380;HLRhlr\u1930\u1931\u1933\u1935\u1937\u1939\u193B\u6502;\u656A;\u6561;\u655E;\u653C;\u6524;\u651C\u0100ev\u0123\u1942bar\u803B\xA6\u40A6\u0200ceio\u1951\u1956\u195A\u1960r;\uC000\u{1D4B7}mi;\u604Fm\u0100;e\u171A\u171Cl\u0180;bh\u1968\u1969\u196B\u405C;\u69C5sub;\u67C8\u016C\u1974\u197El\u0100;e\u1979\u197A\u6022t\xBB\u197Ap\u0180;Ee\u012F\u1985\u1987;\u6AAE\u0100;q\u06DC\u06DB\u0CE1\u19A7\0\u19E8\u1A11\u1A15\u1A32\0\u1A37\u1A50\0\0\u1AB4\0\0\u1AC1\0\0\u1B21\u1B2E\u1B4D\u1B52\0\u1BFD\0\u1C0C\u0180cpr\u19AD\u19B2\u19DDute;\u4107\u0300;abcds\u19BF\u19C0\u19C4\u19CA\u19D5\u19D9\u6229nd;\u6A44rcup;\u6A49\u0100au\u19CF\u19D2p;\u6A4Bp;\u6A47ot;\u6A40;\uC000\u2229\uFE00\u0100eo\u19E2\u19E5t;\u6041\xEE\u0693\u0200aeiu\u19F0\u19FB\u1A01\u1A05\u01F0\u19F5\0\u19F8s;\u6A4Don;\u410Ddil\u803B\xE7\u40E7rc;\u4109ps\u0100;s\u1A0C\u1A0D\u6A4Cm;\u6A50ot;\u410B\u0180dmn\u1A1B\u1A20\u1A26il\u80BB\xB8\u01ADptyv;\u69B2t\u8100\xA2;e\u1A2D\u1A2E\u40A2r\xE4\u01B2r;\uC000\u{1D520}\u0180cei\u1A3D\u1A40\u1A4Dy;\u4447ck\u0100;m\u1A47\u1A48\u6713ark\xBB\u1A48;\u43C7r\u0380;Ecefms\u1A5F\u1A60\u1A62\u1A6B\u1AA4\u1AAA\u1AAE\u65CB;\u69C3\u0180;el\u1A69\u1A6A\u1A6D\u42C6q;\u6257e\u0261\u1A74\0\0\u1A88rrow\u0100lr\u1A7C\u1A81eft;\u61BAight;\u61BB\u0280RSacd\u1A92\u1A94\u1A96\u1A9A\u1A9F\xBB\u0F47;\u64C8st;\u629Birc;\u629Aash;\u629Dnint;\u6A10id;\u6AEFcir;\u69C2ubs\u0100;u\u1ABB\u1ABC\u6663it\xBB\u1ABC\u02EC\u1AC7\u1AD4\u1AFA\0\u1B0Aon\u0100;e\u1ACD\u1ACE\u403A\u0100;q\xC7\xC6\u026D\u1AD9\0\0\u1AE2a\u0100;t\u1ADE\u1ADF\u402C;\u4040\u0180;fl\u1AE8\u1AE9\u1AEB\u6201\xEE\u1160e\u0100mx\u1AF1\u1AF6ent\xBB\u1AE9e\xF3\u024D\u01E7\u1AFE\0\u1B07\u0100;d\u12BB\u1B02ot;\u6A6Dn\xF4\u0246\u0180fry\u1B10\u1B14\u1B17;\uC000\u{1D554}o\xE4\u0254\u8100\xA9;s\u0155\u1B1Dr;\u6117\u0100ao\u1B25\u1B29rr;\u61B5ss;\u6717\u0100cu\u1B32\u1B37r;\uC000\u{1D4B8}\u0100bp\u1B3C\u1B44\u0100;e\u1B41\u1B42\u6ACF;\u6AD1\u0100;e\u1B49\u1B4A\u6AD0;\u6AD2dot;\u62EF\u0380delprvw\u1B60\u1B6C\u1B77\u1B82\u1BAC\u1BD4\u1BF9arr\u0100lr\u1B68\u1B6A;\u6938;\u6935\u0270\u1B72\0\0\u1B75r;\u62DEc;\u62DFarr\u0100;p\u1B7F\u1B80\u61B6;\u693D\u0300;bcdos\u1B8F\u1B90\u1B96\u1BA1\u1BA5\u1BA8\u622Arcap;\u6A48\u0100au\u1B9B\u1B9Ep;\u6A46p;\u6A4Aot;\u628Dr;\u6A45;\uC000\u222A\uFE00\u0200alrv\u1BB5\u1BBF\u1BDE\u1BE3rr\u0100;m\u1BBC\u1BBD\u61B7;\u693Cy\u0180evw\u1BC7\u1BD4\u1BD8q\u0270\u1BCE\0\0\u1BD2re\xE3\u1B73u\xE3\u1B75ee;\u62CEedge;\u62CFen\u803B\xA4\u40A4earrow\u0100lr\u1BEE\u1BF3eft\xBB\u1B80ight\xBB\u1BBDe\xE4\u1BDD\u0100ci\u1C01\u1C07onin\xF4\u01F7nt;\u6231lcty;\u632D\u0980AHabcdefhijlorstuwz\u1C38\u1C3B\u1C3F\u1C5D\u1C69\u1C75\u1C8A\u1C9E\u1CAC\u1CB7\u1CFB\u1CFF\u1D0D\u1D7B\u1D91\u1DAB\u1DBB\u1DC6\u1DCDr\xF2\u0381ar;\u6965\u0200glrs\u1C48\u1C4D\u1C52\u1C54ger;\u6020eth;\u6138\xF2\u1133h\u0100;v\u1C5A\u1C5B\u6010\xBB\u090A\u016B\u1C61\u1C67arow;\u690Fa\xE3\u0315\u0100ay\u1C6E\u1C73ron;\u410F;\u4434\u0180;ao\u0332\u1C7C\u1C84\u0100gr\u02BF\u1C81r;\u61CAtseq;\u6A77\u0180glm\u1C91\u1C94\u1C98\u803B\xB0\u40B0ta;\u43B4ptyv;\u69B1\u0100ir\u1CA3\u1CA8sht;\u697F;\uC000\u{1D521}ar\u0100lr\u1CB3\u1CB5\xBB\u08DC\xBB\u101E\u0280aegsv\u1CC2\u0378\u1CD6\u1CDC\u1CE0m\u0180;os\u0326\u1CCA\u1CD4nd\u0100;s\u0326\u1CD1uit;\u6666amma;\u43DDin;\u62F2\u0180;io\u1CE7\u1CE8\u1CF8\u40F7de\u8100\xF7;o\u1CE7\u1CF0ntimes;\u62C7n\xF8\u1CF7cy;\u4452c\u026F\u1D06\0\0\u1D0Arn;\u631Eop;\u630D\u0280lptuw\u1D18\u1D1D\u1D22\u1D49\u1D55lar;\u4024f;\uC000\u{1D555}\u0280;emps\u030B\u1D2D\u1D37\u1D3D\u1D42q\u0100;d\u0352\u1D33ot;\u6251inus;\u6238lus;\u6214quare;\u62A1blebarwedg\xE5\xFAn\u0180adh\u112E\u1D5D\u1D67ownarrow\xF3\u1C83arpoon\u0100lr\u1D72\u1D76ef\xF4\u1CB4igh\xF4\u1CB6\u0162\u1D7F\u1D85karo\xF7\u0F42\u026F\u1D8A\0\0\u1D8Ern;\u631Fop;\u630C\u0180cot\u1D98\u1DA3\u1DA6\u0100ry\u1D9D\u1DA1;\uC000\u{1D4B9};\u4455l;\u69F6rok;\u4111\u0100dr\u1DB0\u1DB4ot;\u62F1i\u0100;f\u1DBA\u1816\u65BF\u0100ah\u1DC0\u1DC3r\xF2\u0429a\xF2\u0FA6angle;\u69A6\u0100ci\u1DD2\u1DD5y;\u445Fgrarr;\u67FF\u0900Dacdefglmnopqrstux\u1E01\u1E09\u1E19\u1E38\u0578\u1E3C\u1E49\u1E61\u1E7E\u1EA5\u1EAF\u1EBD\u1EE1\u1F2A\u1F37\u1F44\u1F4E\u1F5A\u0100Do\u1E06\u1D34o\xF4\u1C89\u0100cs\u1E0E\u1E14ute\u803B\xE9\u40E9ter;\u6A6E\u0200aioy\u1E22\u1E27\u1E31\u1E36ron;\u411Br\u0100;c\u1E2D\u1E2E\u6256\u803B\xEA\u40EAlon;\u6255;\u444Dot;\u4117\u0100Dr\u1E41\u1E45ot;\u6252;\uC000\u{1D522}\u0180;rs\u1E50\u1E51\u1E57\u6A9Aave\u803B\xE8\u40E8\u0100;d\u1E5C\u1E5D\u6A96ot;\u6A98\u0200;ils\u1E6A\u1E6B\u1E72\u1E74\u6A99nters;\u63E7;\u6113\u0100;d\u1E79\u1E7A\u6A95ot;\u6A97\u0180aps\u1E85\u1E89\u1E97cr;\u4113ty\u0180;sv\u1E92\u1E93\u1E95\u6205et\xBB\u1E93p\u01001;\u1E9D\u1EA4\u0133\u1EA1\u1EA3;\u6004;\u6005\u6003\u0100gs\u1EAA\u1EAC;\u414Bp;\u6002\u0100gp\u1EB4\u1EB8on;\u4119f;\uC000\u{1D556}\u0180als\u1EC4\u1ECE\u1ED2r\u0100;s\u1ECA\u1ECB\u62D5l;\u69E3us;\u6A71i\u0180;lv\u1EDA\u1EDB\u1EDF\u43B5on\xBB\u1EDB;\u43F5\u0200csuv\u1EEA\u1EF3\u1F0B\u1F23\u0100io\u1EEF\u1E31rc\xBB\u1E2E\u0269\u1EF9\0\0\u1EFB\xED\u0548ant\u0100gl\u1F02\u1F06tr\xBB\u1E5Dess\xBB\u1E7A\u0180aei\u1F12\u1F16\u1F1Als;\u403Dst;\u625Fv\u0100;D\u0235\u1F20D;\u6A78parsl;\u69E5\u0100Da\u1F2F\u1F33ot;\u6253rr;\u6971\u0180cdi\u1F3E\u1F41\u1EF8r;\u612Fo\xF4\u0352\u0100ah\u1F49\u1F4B;\u43B7\u803B\xF0\u40F0\u0100mr\u1F53\u1F57l\u803B\xEB\u40EBo;\u60AC\u0180cip\u1F61\u1F64\u1F67l;\u4021s\xF4\u056E\u0100eo\u1F6C\u1F74ctatio\xEE\u0559nential\xE5\u0579\u09E1\u1F92\0\u1F9E\0\u1FA1\u1FA7\0\0\u1FC6\u1FCC\0\u1FD3\0\u1FE6\u1FEA\u2000\0\u2008\u205Allingdotse\xF1\u1E44y;\u4444male;\u6640\u0180ilr\u1FAD\u1FB3\u1FC1lig;\u8000\uFB03\u0269\u1FB9\0\0\u1FBDg;\u8000\uFB00ig;\u8000\uFB04;\uC000\u{1D523}lig;\u8000\uFB01lig;\uC000fj\u0180alt\u1FD9\u1FDC\u1FE1t;\u666Dig;\u8000\uFB02ns;\u65B1of;\u4192\u01F0\u1FEE\0\u1FF3f;\uC000\u{1D557}\u0100ak\u05BF\u1FF7\u0100;v\u1FFC\u1FFD\u62D4;\u6AD9artint;\u6A0D\u0100ao\u200C\u2055\u0100cs\u2011\u2052\u03B1\u201A\u2030\u2038\u2045\u2048\0\u2050\u03B2\u2022\u2025\u2027\u202A\u202C\0\u202E\u803B\xBD\u40BD;\u6153\u803B\xBC\u40BC;\u6155;\u6159;\u615B\u01B3\u2034\0\u2036;\u6154;\u6156\u02B4\u203E\u2041\0\0\u2043\u803B\xBE\u40BE;\u6157;\u615C5;\u6158\u01B6\u204C\0\u204E;\u615A;\u615D8;\u615El;\u6044wn;\u6322cr;\uC000\u{1D4BB}\u0880Eabcdefgijlnorstv\u2082\u2089\u209F\u20A5\u20B0\u20B4\u20F0\u20F5\u20FA\u20FF\u2103\u2112\u2138\u0317\u213E\u2152\u219E\u0100;l\u064D\u2087;\u6A8C\u0180cmp\u2090\u2095\u209Dute;\u41F5ma\u0100;d\u209C\u1CDA\u43B3;\u6A86reve;\u411F\u0100iy\u20AA\u20AErc;\u411D;\u4433ot;\u4121\u0200;lqs\u063E\u0642\u20BD\u20C9\u0180;qs\u063E\u064C\u20C4lan\xF4\u0665\u0200;cdl\u0665\u20D2\u20D5\u20E5c;\u6AA9ot\u0100;o\u20DC\u20DD\u6A80\u0100;l\u20E2\u20E3\u6A82;\u6A84\u0100;e\u20EA\u20ED\uC000\u22DB\uFE00s;\u6A94r;\uC000\u{1D524}\u0100;g\u0673\u061Bmel;\u6137cy;\u4453\u0200;Eaj\u065A\u210C\u210E\u2110;\u6A92;\u6AA5;\u6AA4\u0200Eaes\u211B\u211D\u2129\u2134;\u6269p\u0100;p\u2123\u2124\u6A8Arox\xBB\u2124\u0100;q\u212E\u212F\u6A88\u0100;q\u212E\u211Bim;\u62E7pf;\uC000\u{1D558}\u0100ci\u2143\u2146r;\u610Am\u0180;el\u066B\u214E\u2150;\u6A8E;\u6A90\u8300>;cdlqr\u05EE\u2160\u216A\u216E\u2173\u2179\u0100ci\u2165\u2167;\u6AA7r;\u6A7Aot;\u62D7Par;\u6995uest;\u6A7C\u0280adels\u2184\u216A\u2190\u0656\u219B\u01F0\u2189\0\u218Epro\xF8\u209Er;\u6978q\u0100lq\u063F\u2196les\xF3\u2088i\xED\u066B\u0100en\u21A3\u21ADrtneqq;\uC000\u2269\uFE00\xC5\u21AA\u0500Aabcefkosy\u21C4\u21C7\u21F1\u21F5\u21FA\u2218\u221D\u222F\u2268\u227Dr\xF2\u03A0\u0200ilmr\u21D0\u21D4\u21D7\u21DBrs\xF0\u1484f\xBB\u2024il\xF4\u06A9\u0100dr\u21E0\u21E4cy;\u444A\u0180;cw\u08F4\u21EB\u21EFir;\u6948;\u61ADar;\u610Firc;\u4125\u0180alr\u2201\u220E\u2213rts\u0100;u\u2209\u220A\u6665it\xBB\u220Alip;\u6026con;\u62B9r;\uC000\u{1D525}s\u0100ew\u2223\u2229arow;\u6925arow;\u6926\u0280amopr\u223A\u223E\u2243\u225E\u2263rr;\u61FFtht;\u623Bk\u0100lr\u2249\u2253eftarrow;\u61A9ightarrow;\u61AAf;\uC000\u{1D559}bar;\u6015\u0180clt\u226F\u2274\u2278r;\uC000\u{1D4BD}as\xE8\u21F4rok;\u4127\u0100bp\u2282\u2287ull;\u6043hen\xBB\u1C5B\u0AE1\u22A3\0\u22AA\0\u22B8\u22C5\u22CE\0\u22D5\u22F3\0\0\u22F8\u2322\u2367\u2362\u237F\0\u2386\u23AA\u23B4cute\u803B\xED\u40ED\u0180;iy\u0771\u22B0\u22B5rc\u803B\xEE\u40EE;\u4438\u0100cx\u22BC\u22BFy;\u4435cl\u803B\xA1\u40A1\u0100fr\u039F\u22C9;\uC000\u{1D526}rave\u803B\xEC\u40EC\u0200;ino\u073E\u22DD\u22E9\u22EE\u0100in\u22E2\u22E6nt;\u6A0Ct;\u622Dfin;\u69DCta;\u6129lig;\u4133\u0180aop\u22FE\u231A\u231D\u0180cgt\u2305\u2308\u2317r;\u412B\u0180elp\u071F\u230F\u2313in\xE5\u078Ear\xF4\u0720h;\u4131f;\u62B7ed;\u41B5\u0280;cfot\u04F4\u232C\u2331\u233D\u2341are;\u6105in\u0100;t\u2338\u2339\u621Eie;\u69DDdo\xF4\u2319\u0280;celp\u0757\u234C\u2350\u235B\u2361al;\u62BA\u0100gr\u2355\u2359er\xF3\u1563\xE3\u234Darhk;\u6A17rod;\u6A3C\u0200cgpt\u236F\u2372\u2376\u237By;\u4451on;\u412Ff;\uC000\u{1D55A}a;\u43B9uest\u803B\xBF\u40BF\u0100ci\u238A\u238Fr;\uC000\u{1D4BE}n\u0280;Edsv\u04F4\u239B\u239D\u23A1\u04F3;\u62F9ot;\u62F5\u0100;v\u23A6\u23A7\u62F4;\u62F3\u0100;i\u0777\u23AElde;\u4129\u01EB\u23B8\0\u23BCcy;\u4456l\u803B\xEF\u40EF\u0300cfmosu\u23CC\u23D7\u23DC\u23E1\u23E7\u23F5\u0100iy\u23D1\u23D5rc;\u4135;\u4439r;\uC000\u{1D527}ath;\u4237pf;\uC000\u{1D55B}\u01E3\u23EC\0\u23F1r;\uC000\u{1D4BF}rcy;\u4458kcy;\u4454\u0400acfghjos\u240B\u2416\u2422\u2427\u242D\u2431\u2435\u243Bppa\u0100;v\u2413\u2414\u43BA;\u43F0\u0100ey\u241B\u2420dil;\u4137;\u443Ar;\uC000\u{1D528}reen;\u4138cy;\u4445cy;\u445Cpf;\uC000\u{1D55C}cr;\uC000\u{1D4C0}\u0B80ABEHabcdefghjlmnoprstuv\u2470\u2481\u2486\u248D\u2491\u250E\u253D\u255A\u2580\u264E\u265E\u2665\u2679\u267D\u269A\u26B2\u26D8\u275D\u2768\u278B\u27C0\u2801\u2812\u0180art\u2477\u247A\u247Cr\xF2\u09C6\xF2\u0395ail;\u691Barr;\u690E\u0100;g\u0994\u248B;\u6A8Bar;\u6962\u0963\u24A5\0\u24AA\0\u24B1\0\0\0\0\0\u24B5\u24BA\0\u24C6\u24C8\u24CD\0\u24F9ute;\u413Amptyv;\u69B4ra\xEE\u084Cbda;\u43BBg\u0180;dl\u088E\u24C1\u24C3;\u6991\xE5\u088E;\u6A85uo\u803B\xAB\u40ABr\u0400;bfhlpst\u0899\u24DE\u24E6\u24E9\u24EB\u24EE\u24F1\u24F5\u0100;f\u089D\u24E3s;\u691Fs;\u691D\xEB\u2252p;\u61ABl;\u6939im;\u6973l;\u61A2\u0180;ae\u24FF\u2500\u2504\u6AABil;\u6919\u0100;s\u2509\u250A\u6AAD;\uC000\u2AAD\uFE00\u0180abr\u2515\u2519\u251Drr;\u690Crk;\u6772\u0100ak\u2522\u252Cc\u0100ek\u2528\u252A;\u407B;\u405B\u0100es\u2531\u2533;\u698Bl\u0100du\u2539\u253B;\u698F;\u698D\u0200aeuy\u2546\u254B\u2556\u2558ron;\u413E\u0100di\u2550\u2554il;\u413C\xEC\u08B0\xE2\u2529;\u443B\u0200cqrs\u2563\u2566\u256D\u257Da;\u6936uo\u0100;r\u0E19\u1746\u0100du\u2572\u2577har;\u6967shar;\u694Bh;\u61B2\u0280;fgqs\u258B\u258C\u0989\u25F3\u25FF\u6264t\u0280ahlrt\u2598\u25A4\u25B7\u25C2\u25E8rrow\u0100;t\u0899\u25A1a\xE9\u24F6arpoon\u0100du\u25AF\u25B4own\xBB\u045Ap\xBB\u0966eftarrows;\u61C7ight\u0180ahs\u25CD\u25D6\u25DErrow\u0100;s\u08F4\u08A7arpoon\xF3\u0F98quigarro\xF7\u21F0hreetimes;\u62CB\u0180;qs\u258B\u0993\u25FAlan\xF4\u09AC\u0280;cdgs\u09AC\u260A\u260D\u261D\u2628c;\u6AA8ot\u0100;o\u2614\u2615\u6A7F\u0100;r\u261A\u261B\u6A81;\u6A83\u0100;e\u2622\u2625\uC000\u22DA\uFE00s;\u6A93\u0280adegs\u2633\u2639\u263D\u2649\u264Bppro\xF8\u24C6ot;\u62D6q\u0100gq\u2643\u2645\xF4\u0989gt\xF2\u248C\xF4\u099Bi\xED\u09B2\u0180ilr\u2655\u08E1\u265Asht;\u697C;\uC000\u{1D529}\u0100;E\u099C\u2663;\u6A91\u0161\u2669\u2676r\u0100du\u25B2\u266E\u0100;l\u0965\u2673;\u696Alk;\u6584cy;\u4459\u0280;acht\u0A48\u2688\u268B\u2691\u2696r\xF2\u25C1orne\xF2\u1D08ard;\u696Bri;\u65FA\u0100io\u269F\u26A4dot;\u4140ust\u0100;a\u26AC\u26AD\u63B0che\xBB\u26AD\u0200Eaes\u26BB\u26BD\u26C9\u26D4;\u6268p\u0100;p\u26C3\u26C4\u6A89rox\xBB\u26C4\u0100;q\u26CE\u26CF\u6A87\u0100;q\u26CE\u26BBim;\u62E6\u0400abnoptwz\u26E9\u26F4\u26F7\u271A\u272F\u2741\u2747\u2750\u0100nr\u26EE\u26F1g;\u67ECr;\u61FDr\xEB\u08C1g\u0180lmr\u26FF\u270D\u2714eft\u0100ar\u09E6\u2707ight\xE1\u09F2apsto;\u67FCight\xE1\u09FDparrow\u0100lr\u2725\u2729ef\xF4\u24EDight;\u61AC\u0180afl\u2736\u2739\u273Dr;\u6985;\uC000\u{1D55D}us;\u6A2Dimes;\u6A34\u0161\u274B\u274Fst;\u6217\xE1\u134E\u0180;ef\u2757\u2758\u1800\u65CAnge\xBB\u2758ar\u0100;l\u2764\u2765\u4028t;\u6993\u0280achmt\u2773\u2776\u277C\u2785\u2787r\xF2\u08A8orne\xF2\u1D8Car\u0100;d\u0F98\u2783;\u696D;\u600Eri;\u62BF\u0300achiqt\u2798\u279D\u0A40\u27A2\u27AE\u27BBquo;\u6039r;\uC000\u{1D4C1}m\u0180;eg\u09B2\u27AA\u27AC;\u6A8D;\u6A8F\u0100bu\u252A\u27B3o\u0100;r\u0E1F\u27B9;\u601Arok;\u4142\u8400<;cdhilqr\u082B\u27D2\u2639\u27DC\u27E0\u27E5\u27EA\u27F0\u0100ci\u27D7\u27D9;\u6AA6r;\u6A79re\xE5\u25F2mes;\u62C9arr;\u6976uest;\u6A7B\u0100Pi\u27F5\u27F9ar;\u6996\u0180;ef\u2800\u092D\u181B\u65C3r\u0100du\u2807\u280Dshar;\u694Ahar;\u6966\u0100en\u2817\u2821rtneqq;\uC000\u2268\uFE00\xC5\u281E\u0700Dacdefhilnopsu\u2840\u2845\u2882\u288E\u2893\u28A0\u28A5\u28A8\u28DA\u28E2\u28E4\u0A83\u28F3\u2902Dot;\u623A\u0200clpr\u284E\u2852\u2863\u287Dr\u803B\xAF\u40AF\u0100et\u2857\u2859;\u6642\u0100;e\u285E\u285F\u6720se\xBB\u285F\u0100;s\u103B\u2868to\u0200;dlu\u103B\u2873\u2877\u287Bow\xEE\u048Cef\xF4\u090F\xF0\u13D1ker;\u65AE\u0100oy\u2887\u288Cmma;\u6A29;\u443Cash;\u6014asuredangle\xBB\u1626r;\uC000\u{1D52A}o;\u6127\u0180cdn\u28AF\u28B4\u28C9ro\u803B\xB5\u40B5\u0200;acd\u1464\u28BD\u28C0\u28C4s\xF4\u16A7ir;\u6AF0ot\u80BB\xB7\u01B5us\u0180;bd\u28D2\u1903\u28D3\u6212\u0100;u\u1D3C\u28D8;\u6A2A\u0163\u28DE\u28E1p;\u6ADB\xF2\u2212\xF0\u0A81\u0100dp\u28E9\u28EEels;\u62A7f;\uC000\u{1D55E}\u0100ct\u28F8\u28FDr;\uC000\u{1D4C2}pos\xBB\u159D\u0180;lm\u2909\u290A\u290D\u43BCtimap;\u62B8\u0C00GLRVabcdefghijlmoprstuvw\u2942\u2953\u297E\u2989\u2998\u29DA\u29E9\u2A15\u2A1A\u2A58\u2A5D\u2A83\u2A95\u2AA4\u2AA8\u2B04\u2B07\u2B44\u2B7F\u2BAE\u2C34\u2C67\u2C7C\u2CE9\u0100gt\u2947\u294B;\uC000\u22D9\u0338\u0100;v\u2950\u0BCF\uC000\u226B\u20D2\u0180elt\u295A\u2972\u2976ft\u0100ar\u2961\u2967rrow;\u61CDightarrow;\u61CE;\uC000\u22D8\u0338\u0100;v\u297B\u0C47\uC000\u226A\u20D2ightarrow;\u61CF\u0100Dd\u298E\u2993ash;\u62AFash;\u62AE\u0280bcnpt\u29A3\u29A7\u29AC\u29B1\u29CCla\xBB\u02DEute;\u4144g;\uC000\u2220\u20D2\u0280;Eiop\u0D84\u29BC\u29C0\u29C5\u29C8;\uC000\u2A70\u0338d;\uC000\u224B\u0338s;\u4149ro\xF8\u0D84ur\u0100;a\u29D3\u29D4\u666El\u0100;s\u29D3\u0B38\u01F3\u29DF\0\u29E3p\u80BB\xA0\u0B37mp\u0100;e\u0BF9\u0C00\u0280aeouy\u29F4\u29FE\u2A03\u2A10\u2A13\u01F0\u29F9\0\u29FB;\u6A43on;\u4148dil;\u4146ng\u0100;d\u0D7E\u2A0Aot;\uC000\u2A6D\u0338p;\u6A42;\u443Dash;\u6013\u0380;Aadqsx\u0B92\u2A29\u2A2D\u2A3B\u2A41\u2A45\u2A50rr;\u61D7r\u0100hr\u2A33\u2A36k;\u6924\u0100;o\u13F2\u13F0ot;\uC000\u2250\u0338ui\xF6\u0B63\u0100ei\u2A4A\u2A4Ear;\u6928\xED\u0B98ist\u0100;s\u0BA0\u0B9Fr;\uC000\u{1D52B}\u0200Eest\u0BC5\u2A66\u2A79\u2A7C\u0180;qs\u0BBC\u2A6D\u0BE1\u0180;qs\u0BBC\u0BC5\u2A74lan\xF4\u0BE2i\xED\u0BEA\u0100;r\u0BB6\u2A81\xBB\u0BB7\u0180Aap\u2A8A\u2A8D\u2A91r\xF2\u2971rr;\u61AEar;\u6AF2\u0180;sv\u0F8D\u2A9C\u0F8C\u0100;d\u2AA1\u2AA2\u62FC;\u62FAcy;\u445A\u0380AEadest\u2AB7\u2ABA\u2ABE\u2AC2\u2AC5\u2AF6\u2AF9r\xF2\u2966;\uC000\u2266\u0338rr;\u619Ar;\u6025\u0200;fqs\u0C3B\u2ACE\u2AE3\u2AEFt\u0100ar\u2AD4\u2AD9rro\xF7\u2AC1ightarro\xF7\u2A90\u0180;qs\u0C3B\u2ABA\u2AEAlan\xF4\u0C55\u0100;s\u0C55\u2AF4\xBB\u0C36i\xED\u0C5D\u0100;r\u0C35\u2AFEi\u0100;e\u0C1A\u0C25i\xE4\u0D90\u0100pt\u2B0C\u2B11f;\uC000\u{1D55F}\u8180\xAC;in\u2B19\u2B1A\u2B36\u40ACn\u0200;Edv\u0B89\u2B24\u2B28\u2B2E;\uC000\u22F9\u0338ot;\uC000\u22F5\u0338\u01E1\u0B89\u2B33\u2B35;\u62F7;\u62F6i\u0100;v\u0CB8\u2B3C\u01E1\u0CB8\u2B41\u2B43;\u62FE;\u62FD\u0180aor\u2B4B\u2B63\u2B69r\u0200;ast\u0B7B\u2B55\u2B5A\u2B5Flle\xEC\u0B7Bl;\uC000\u2AFD\u20E5;\uC000\u2202\u0338lint;\u6A14\u0180;ce\u0C92\u2B70\u2B73u\xE5\u0CA5\u0100;c\u0C98\u2B78\u0100;e\u0C92\u2B7D\xF1\u0C98\u0200Aait\u2B88\u2B8B\u2B9D\u2BA7r\xF2\u2988rr\u0180;cw\u2B94\u2B95\u2B99\u619B;\uC000\u2933\u0338;\uC000\u219D\u0338ghtarrow\xBB\u2B95ri\u0100;e\u0CCB\u0CD6\u0380chimpqu\u2BBD\u2BCD\u2BD9\u2B04\u0B78\u2BE4\u2BEF\u0200;cer\u0D32\u2BC6\u0D37\u2BC9u\xE5\u0D45;\uC000\u{1D4C3}ort\u026D\u2B05\0\0\u2BD6ar\xE1\u2B56m\u0100;e\u0D6E\u2BDF\u0100;q\u0D74\u0D73su\u0100bp\u2BEB\u2BED\xE5\u0CF8\xE5\u0D0B\u0180bcp\u2BF6\u2C11\u2C19\u0200;Ees\u2BFF\u2C00\u0D22\u2C04\u6284;\uC000\u2AC5\u0338et\u0100;e\u0D1B\u2C0Bq\u0100;q\u0D23\u2C00c\u0100;e\u0D32\u2C17\xF1\u0D38\u0200;Ees\u2C22\u2C23\u0D5F\u2C27\u6285;\uC000\u2AC6\u0338et\u0100;e\u0D58\u2C2Eq\u0100;q\u0D60\u2C23\u0200gilr\u2C3D\u2C3F\u2C45\u2C47\xEC\u0BD7lde\u803B\xF1\u40F1\xE7\u0C43iangle\u0100lr\u2C52\u2C5Ceft\u0100;e\u0C1A\u2C5A\xF1\u0C26ight\u0100;e\u0CCB\u2C65\xF1\u0CD7\u0100;m\u2C6C\u2C6D\u43BD\u0180;es\u2C74\u2C75\u2C79\u4023ro;\u6116p;\u6007\u0480DHadgilrs\u2C8F\u2C94\u2C99\u2C9E\u2CA3\u2CB0\u2CB6\u2CD3\u2CE3ash;\u62ADarr;\u6904p;\uC000\u224D\u20D2ash;\u62AC\u0100et\u2CA8\u2CAC;\uC000\u2265\u20D2;\uC000>\u20D2nfin;\u69DE\u0180Aet\u2CBD\u2CC1\u2CC5rr;\u6902;\uC000\u2264\u20D2\u0100;r\u2CCA\u2CCD\uC000<\u20D2ie;\uC000\u22B4\u20D2\u0100At\u2CD8\u2CDCrr;\u6903rie;\uC000\u22B5\u20D2im;\uC000\u223C\u20D2\u0180Aan\u2CF0\u2CF4\u2D02rr;\u61D6r\u0100hr\u2CFA\u2CFDk;\u6923\u0100;o\u13E7\u13E5ear;\u6927\u1253\u1A95\0\0\0\0\0\0\0\0\0\0\0\0\0\u2D2D\0\u2D38\u2D48\u2D60\u2D65\u2D72\u2D84\u1B07\0\0\u2D8D\u2DAB\0\u2DC8\u2DCE\0\u2DDC\u2E19\u2E2B\u2E3E\u2E43\u0100cs\u2D31\u1A97ute\u803B\xF3\u40F3\u0100iy\u2D3C\u2D45r\u0100;c\u1A9E\u2D42\u803B\xF4\u40F4;\u443E\u0280abios\u1AA0\u2D52\u2D57\u01C8\u2D5Alac;\u4151v;\u6A38old;\u69BClig;\u4153\u0100cr\u2D69\u2D6Dir;\u69BF;\uC000\u{1D52C}\u036F\u2D79\0\0\u2D7C\0\u2D82n;\u42DBave\u803B\xF2\u40F2;\u69C1\u0100bm\u2D88\u0DF4ar;\u69B5\u0200acit\u2D95\u2D98\u2DA5\u2DA8r\xF2\u1A80\u0100ir\u2D9D\u2DA0r;\u69BEoss;\u69BBn\xE5\u0E52;\u69C0\u0180aei\u2DB1\u2DB5\u2DB9cr;\u414Dga;\u43C9\u0180cdn\u2DC0\u2DC5\u01CDron;\u43BF;\u69B6pf;\uC000\u{1D560}\u0180ael\u2DD4\u2DD7\u01D2r;\u69B7rp;\u69B9\u0380;adiosv\u2DEA\u2DEB\u2DEE\u2E08\u2E0D\u2E10\u2E16\u6228r\xF2\u1A86\u0200;efm\u2DF7\u2DF8\u2E02\u2E05\u6A5Dr\u0100;o\u2DFE\u2DFF\u6134f\xBB\u2DFF\u803B\xAA\u40AA\u803B\xBA\u40BAgof;\u62B6r;\u6A56lope;\u6A57;\u6A5B\u0180clo\u2E1F\u2E21\u2E27\xF2\u2E01ash\u803B\xF8\u40F8l;\u6298i\u016C\u2E2F\u2E34de\u803B\xF5\u40F5es\u0100;a\u01DB\u2E3As;\u6A36ml\u803B\xF6\u40F6bar;\u633D\u0AE1\u2E5E\0\u2E7D\0\u2E80\u2E9D\0\u2EA2\u2EB9\0\0\u2ECB\u0E9C\0\u2F13\0\0\u2F2B\u2FBC\0\u2FC8r\u0200;ast\u0403\u2E67\u2E72\u0E85\u8100\xB6;l\u2E6D\u2E6E\u40B6le\xEC\u0403\u0269\u2E78\0\0\u2E7Bm;\u6AF3;\u6AFDy;\u443Fr\u0280cimpt\u2E8B\u2E8F\u2E93\u1865\u2E97nt;\u4025od;\u402Eil;\u6030enk;\u6031r;\uC000\u{1D52D}\u0180imo\u2EA8\u2EB0\u2EB4\u0100;v\u2EAD\u2EAE\u43C6;\u43D5ma\xF4\u0A76ne;\u660E\u0180;tv\u2EBF\u2EC0\u2EC8\u43C0chfork\xBB\u1FFD;\u43D6\u0100au\u2ECF\u2EDFn\u0100ck\u2ED5\u2EDDk\u0100;h\u21F4\u2EDB;\u610E\xF6\u21F4s\u0480;abcdemst\u2EF3\u2EF4\u1908\u2EF9\u2EFD\u2F04\u2F06\u2F0A\u2F0E\u402Bcir;\u6A23ir;\u6A22\u0100ou\u1D40\u2F02;\u6A25;\u6A72n\u80BB\xB1\u0E9Dim;\u6A26wo;\u6A27\u0180ipu\u2F19\u2F20\u2F25ntint;\u6A15f;\uC000\u{1D561}nd\u803B\xA3\u40A3\u0500;Eaceinosu\u0EC8\u2F3F\u2F41\u2F44\u2F47\u2F81\u2F89\u2F92\u2F7E\u2FB6;\u6AB3p;\u6AB7u\xE5\u0ED9\u0100;c\u0ECE\u2F4C\u0300;acens\u0EC8\u2F59\u2F5F\u2F66\u2F68\u2F7Eppro\xF8\u2F43urlye\xF1\u0ED9\xF1\u0ECE\u0180aes\u2F6F\u2F76\u2F7Approx;\u6AB9qq;\u6AB5im;\u62E8i\xED\u0EDFme\u0100;s\u2F88\u0EAE\u6032\u0180Eas\u2F78\u2F90\u2F7A\xF0\u2F75\u0180dfp\u0EEC\u2F99\u2FAF\u0180als\u2FA0\u2FA5\u2FAAlar;\u632Eine;\u6312urf;\u6313\u0100;t\u0EFB\u2FB4\xEF\u0EFBrel;\u62B0\u0100ci\u2FC0\u2FC5r;\uC000\u{1D4C5};\u43C8ncsp;\u6008\u0300fiopsu\u2FDA\u22E2\u2FDF\u2FE5\u2FEB\u2FF1r;\uC000\u{1D52E}pf;\uC000\u{1D562}rime;\u6057cr;\uC000\u{1D4C6}\u0180aeo\u2FF8\u3009\u3013t\u0100ei\u2FFE\u3005rnion\xF3\u06B0nt;\u6A16st\u0100;e\u3010\u3011\u403F\xF1\u1F19\xF4\u0F14\u0A80ABHabcdefhilmnoprstux\u3040\u3051\u3055\u3059\u30E0\u310E\u312B\u3147\u3162\u3172\u318E\u3206\u3215\u3224\u3229\u3258\u326E\u3272\u3290\u32B0\u32B7\u0180art\u3047\u304A\u304Cr\xF2\u10B3\xF2\u03DDail;\u691Car\xF2\u1C65ar;\u6964\u0380cdenqrt\u3068\u3075\u3078\u307F\u308F\u3094\u30CC\u0100eu\u306D\u3071;\uC000\u223D\u0331te;\u4155i\xE3\u116Emptyv;\u69B3g\u0200;del\u0FD1\u3089\u308B\u308D;\u6992;\u69A5\xE5\u0FD1uo\u803B\xBB\u40BBr\u0580;abcfhlpstw\u0FDC\u30AC\u30AF\u30B7\u30B9\u30BC\u30BE\u30C0\u30C3\u30C7\u30CAp;\u6975\u0100;f\u0FE0\u30B4s;\u6920;\u6933s;\u691E\xEB\u225D\xF0\u272El;\u6945im;\u6974l;\u61A3;\u619D\u0100ai\u30D1\u30D5il;\u691Ao\u0100;n\u30DB\u30DC\u6236al\xF3\u0F1E\u0180abr\u30E7\u30EA\u30EEr\xF2\u17E5rk;\u6773\u0100ak\u30F3\u30FDc\u0100ek\u30F9\u30FB;\u407D;\u405D\u0100es\u3102\u3104;\u698Cl\u0100du\u310A\u310C;\u698E;\u6990\u0200aeuy\u3117\u311C\u3127\u3129ron;\u4159\u0100di\u3121\u3125il;\u4157\xEC\u0FF2\xE2\u30FA;\u4440\u0200clqs\u3134\u3137\u313D\u3144a;\u6937dhar;\u6969uo\u0100;r\u020E\u020Dh;\u61B3\u0180acg\u314E\u315F\u0F44l\u0200;ips\u0F78\u3158\u315B\u109Cn\xE5\u10BBar\xF4\u0FA9t;\u65AD\u0180ilr\u3169\u1023\u316Esht;\u697D;\uC000\u{1D52F}\u0100ao\u3177\u3186r\u0100du\u317D\u317F\xBB\u047B\u0100;l\u1091\u3184;\u696C\u0100;v\u318B\u318C\u43C1;\u43F1\u0180gns\u3195\u31F9\u31FCht\u0300ahlrst\u31A4\u31B0\u31C2\u31D8\u31E4\u31EErrow\u0100;t\u0FDC\u31ADa\xE9\u30C8arpoon\u0100du\u31BB\u31BFow\xEE\u317Ep\xBB\u1092eft\u0100ah\u31CA\u31D0rrow\xF3\u0FEAarpoon\xF3\u0551ightarrows;\u61C9quigarro\xF7\u30CBhreetimes;\u62CCg;\u42DAingdotse\xF1\u1F32\u0180ahm\u320D\u3210\u3213r\xF2\u0FEAa\xF2\u0551;\u600Foust\u0100;a\u321E\u321F\u63B1che\xBB\u321Fmid;\u6AEE\u0200abpt\u3232\u323D\u3240\u3252\u0100nr\u3237\u323Ag;\u67EDr;\u61FEr\xEB\u1003\u0180afl\u3247\u324A\u324Er;\u6986;\uC000\u{1D563}us;\u6A2Eimes;\u6A35\u0100ap\u325D\u3267r\u0100;g\u3263\u3264\u4029t;\u6994olint;\u6A12ar\xF2\u31E3\u0200achq\u327B\u3280\u10BC\u3285quo;\u603Ar;\uC000\u{1D4C7}\u0100bu\u30FB\u328Ao\u0100;r\u0214\u0213\u0180hir\u3297\u329B\u32A0re\xE5\u31F8mes;\u62CAi\u0200;efl\u32AA\u1059\u1821\u32AB\u65B9tri;\u69CEluhar;\u6968;\u611E\u0D61\u32D5\u32DB\u32DF\u332C\u3338\u3371\0\u337A\u33A4\0\0\u33EC\u33F0\0\u3428\u3448\u345A\u34AD\u34B1\u34CA\u34F1\0\u3616\0\0\u3633cute;\u415Bqu\xEF\u27BA\u0500;Eaceinpsy\u11ED\u32F3\u32F5\u32FF\u3302\u330B\u330F\u331F\u3326\u3329;\u6AB4\u01F0\u32FA\0\u32FC;\u6AB8on;\u4161u\xE5\u11FE\u0100;d\u11F3\u3307il;\u415Frc;\u415D\u0180Eas\u3316\u3318\u331B;\u6AB6p;\u6ABAim;\u62E9olint;\u6A13i\xED\u1204;\u4441ot\u0180;be\u3334\u1D47\u3335\u62C5;\u6A66\u0380Aacmstx\u3346\u334A\u3357\u335B\u335E\u3363\u336Drr;\u61D8r\u0100hr\u3350\u3352\xEB\u2228\u0100;o\u0A36\u0A34t\u803B\xA7\u40A7i;\u403Bwar;\u6929m\u0100in\u3369\xF0nu\xF3\xF1t;\u6736r\u0100;o\u3376\u2055\uC000\u{1D530}\u0200acoy\u3382\u3386\u3391\u33A0rp;\u666F\u0100hy\u338B\u338Fcy;\u4449;\u4448rt\u026D\u3399\0\0\u339Ci\xE4\u1464ara\xEC\u2E6F\u803B\xAD\u40AD\u0100gm\u33A8\u33B4ma\u0180;fv\u33B1\u33B2\u33B2\u43C3;\u43C2\u0400;deglnpr\u12AB\u33C5\u33C9\u33CE\u33D6\u33DE\u33E1\u33E6ot;\u6A6A\u0100;q\u12B1\u12B0\u0100;E\u33D3\u33D4\u6A9E;\u6AA0\u0100;E\u33DB\u33DC\u6A9D;\u6A9Fe;\u6246lus;\u6A24arr;\u6972ar\xF2\u113D\u0200aeit\u33F8\u3408\u340F\u3417\u0100ls\u33FD\u3404lsetm\xE9\u336Ahp;\u6A33parsl;\u69E4\u0100dl\u1463\u3414e;\u6323\u0100;e\u341C\u341D\u6AAA\u0100;s\u3422\u3423\u6AAC;\uC000\u2AAC\uFE00\u0180flp\u342E\u3433\u3442tcy;\u444C\u0100;b\u3438\u3439\u402F\u0100;a\u343E\u343F\u69C4r;\u633Ff;\uC000\u{1D564}a\u0100dr\u344D\u0402es\u0100;u\u3454\u3455\u6660it\xBB\u3455\u0180csu\u3460\u3479\u349F\u0100au\u3465\u346Fp\u0100;s\u1188\u346B;\uC000\u2293\uFE00p\u0100;s\u11B4\u3475;\uC000\u2294\uFE00u\u0100bp\u347F\u348F\u0180;es\u1197\u119C\u3486et\u0100;e\u1197\u348D\xF1\u119D\u0180;es\u11A8\u11AD\u3496et\u0100;e\u11A8\u349D\xF1\u11AE\u0180;af\u117B\u34A6\u05B0r\u0165\u34AB\u05B1\xBB\u117Car\xF2\u1148\u0200cemt\u34B9\u34BE\u34C2\u34C5r;\uC000\u{1D4C8}tm\xEE\xF1i\xEC\u3415ar\xE6\u11BE\u0100ar\u34CE\u34D5r\u0100;f\u34D4\u17BF\u6606\u0100an\u34DA\u34EDight\u0100ep\u34E3\u34EApsilo\xEE\u1EE0h\xE9\u2EAFs\xBB\u2852\u0280bcmnp\u34FB\u355E\u1209\u358B\u358E\u0480;Edemnprs\u350E\u350F\u3511\u3515\u351E\u3523\u352C\u3531\u3536\u6282;\u6AC5ot;\u6ABD\u0100;d\u11DA\u351Aot;\u6AC3ult;\u6AC1\u0100Ee\u3528\u352A;\u6ACB;\u628Alus;\u6ABFarr;\u6979\u0180eiu\u353D\u3552\u3555t\u0180;en\u350E\u3545\u354Bq\u0100;q\u11DA\u350Feq\u0100;q\u352B\u3528m;\u6AC7\u0100bp\u355A\u355C;\u6AD5;\u6AD3c\u0300;acens\u11ED\u356C\u3572\u3579\u357B\u3326ppro\xF8\u32FAurlye\xF1\u11FE\xF1\u11F3\u0180aes\u3582\u3588\u331Bppro\xF8\u331Aq\xF1\u3317g;\u666A\u0680123;Edehlmnps\u35A9\u35AC\u35AF\u121C\u35B2\u35B4\u35C0\u35C9\u35D5\u35DA\u35DF\u35E8\u35ED\u803B\xB9\u40B9\u803B\xB2\u40B2\u803B\xB3\u40B3;\u6AC6\u0100os\u35B9\u35BCt;\u6ABEub;\u6AD8\u0100;d\u1222\u35C5ot;\u6AC4s\u0100ou\u35CF\u35D2l;\u67C9b;\u6AD7arr;\u697Bult;\u6AC2\u0100Ee\u35E4\u35E6;\u6ACC;\u628Blus;\u6AC0\u0180eiu\u35F4\u3609\u360Ct\u0180;en\u121C\u35FC\u3602q\u0100;q\u1222\u35B2eq\u0100;q\u35E7\u35E4m;\u6AC8\u0100bp\u3611\u3613;\u6AD4;\u6AD6\u0180Aan\u361C\u3620\u362Drr;\u61D9r\u0100hr\u3626\u3628\xEB\u222E\u0100;o\u0A2B\u0A29war;\u692Alig\u803B\xDF\u40DF\u0BE1\u3651\u365D\u3660\u12CE\u3673\u3679\0\u367E\u36C2\0\0\0\0\0\u36DB\u3703\0\u3709\u376C\0\0\0\u3787\u0272\u3656\0\0\u365Bget;\u6316;\u43C4r\xEB\u0E5F\u0180aey\u3666\u366B\u3670ron;\u4165dil;\u4163;\u4442lrec;\u6315r;\uC000\u{1D531}\u0200eiko\u3686\u369D\u36B5\u36BC\u01F2\u368B\0\u3691e\u01004f\u1284\u1281a\u0180;sv\u3698\u3699\u369B\u43B8ym;\u43D1\u0100cn\u36A2\u36B2k\u0100as\u36A8\u36AEppro\xF8\u12C1im\xBB\u12ACs\xF0\u129E\u0100as\u36BA\u36AE\xF0\u12C1rn\u803B\xFE\u40FE\u01EC\u031F\u36C6\u22E7es\u8180\xD7;bd\u36CF\u36D0\u36D8\u40D7\u0100;a\u190F\u36D5r;\u6A31;\u6A30\u0180eps\u36E1\u36E3\u3700\xE1\u2A4D\u0200;bcf\u0486\u36EC\u36F0\u36F4ot;\u6336ir;\u6AF1\u0100;o\u36F9\u36FC\uC000\u{1D565}rk;\u6ADA\xE1\u3362rime;\u6034\u0180aip\u370F\u3712\u3764d\xE5\u1248\u0380adempst\u3721\u374D\u3740\u3751\u3757\u375C\u375Fngle\u0280;dlqr\u3730\u3731\u3736\u3740\u3742\u65B5own\xBB\u1DBBeft\u0100;e\u2800\u373E\xF1\u092E;\u625Cight\u0100;e\u32AA\u374B\xF1\u105Aot;\u65ECinus;\u6A3Alus;\u6A39b;\u69CDime;\u6A3Bezium;\u63E2\u0180cht\u3772\u377D\u3781\u0100ry\u3777\u377B;\uC000\u{1D4C9};\u4446cy;\u445Brok;\u4167\u0100io\u378B\u378Ex\xF4\u1777head\u0100lr\u3797\u37A0eftarro\xF7\u084Fightarrow\xBB\u0F5D\u0900AHabcdfghlmoprstuw\u37D0\u37D3\u37D7\u37E4\u37F0\u37FC\u380E\u381C\u3823\u3834\u3851\u385D\u386B\u38A9\u38CC\u38D2\u38EA\u38F6r\xF2\u03EDar;\u6963\u0100cr\u37DC\u37E2ute\u803B\xFA\u40FA\xF2\u1150r\u01E3\u37EA\0\u37EDy;\u445Eve;\u416D\u0100iy\u37F5\u37FArc\u803B\xFB\u40FB;\u4443\u0180abh\u3803\u3806\u380Br\xF2\u13ADlac;\u4171a\xF2\u13C3\u0100ir\u3813\u3818sht;\u697E;\uC000\u{1D532}rave\u803B\xF9\u40F9\u0161\u3827\u3831r\u0100lr\u382C\u382E\xBB\u0957\xBB\u1083lk;\u6580\u0100ct\u3839\u384D\u026F\u383F\0\0\u384Arn\u0100;e\u3845\u3846\u631Cr\xBB\u3846op;\u630Fri;\u65F8\u0100al\u3856\u385Acr;\u416B\u80BB\xA8\u0349\u0100gp\u3862\u3866on;\u4173f;\uC000\u{1D566}\u0300adhlsu\u114B\u3878\u387D\u1372\u3891\u38A0own\xE1\u13B3arpoon\u0100lr\u3888\u388Cef\xF4\u382Digh\xF4\u382Fi\u0180;hl\u3899\u389A\u389C\u43C5\xBB\u13FAon\xBB\u389Aparrows;\u61C8\u0180cit\u38B0\u38C4\u38C8\u026F\u38B6\0\0\u38C1rn\u0100;e\u38BC\u38BD\u631Dr\xBB\u38BDop;\u630Eng;\u416Fri;\u65F9cr;\uC000\u{1D4CA}\u0180dir\u38D9\u38DD\u38E2ot;\u62F0lde;\u4169i\u0100;f\u3730\u38E8\xBB\u1813\u0100am\u38EF\u38F2r\xF2\u38A8l\u803B\xFC\u40FCangle;\u69A7\u0780ABDacdeflnoprsz\u391C\u391F\u3929\u392D\u39B5\u39B8\u39BD\u39DF\u39E4\u39E8\u39F3\u39F9\u39FD\u3A01\u3A20r\xF2\u03F7ar\u0100;v\u3926\u3927\u6AE8;\u6AE9as\xE8\u03E1\u0100nr\u3932\u3937grt;\u699C\u0380eknprst\u34E3\u3946\u394B\u3952\u395D\u3964\u3996app\xE1\u2415othin\xE7\u1E96\u0180hir\u34EB\u2EC8\u3959op\xF4\u2FB5\u0100;h\u13B7\u3962\xEF\u318D\u0100iu\u3969\u396Dgm\xE1\u33B3\u0100bp\u3972\u3984setneq\u0100;q\u397D\u3980\uC000\u228A\uFE00;\uC000\u2ACB\uFE00setneq\u0100;q\u398F\u3992\uC000\u228B\uFE00;\uC000\u2ACC\uFE00\u0100hr\u399B\u399Fet\xE1\u369Ciangle\u0100lr\u39AA\u39AFeft\xBB\u0925ight\xBB\u1051y;\u4432ash\xBB\u1036\u0180elr\u39C4\u39D2\u39D7\u0180;be\u2DEA\u39CB\u39CFar;\u62BBq;\u625Alip;\u62EE\u0100bt\u39DC\u1468a\xF2\u1469r;\uC000\u{1D533}tr\xE9\u39AEsu\u0100bp\u39EF\u39F1\xBB\u0D1C\xBB\u0D59pf;\uC000\u{1D567}ro\xF0\u0EFBtr\xE9\u39B4\u0100cu\u3A06\u3A0Br;\uC000\u{1D4CB}\u0100bp\u3A10\u3A18n\u0100Ee\u3980\u3A16\xBB\u397En\u0100Ee\u3992\u3A1E\xBB\u3990igzag;\u699A\u0380cefoprs\u3A36\u3A3B\u3A56\u3A5B\u3A54\u3A61\u3A6Airc;\u4175\u0100di\u3A40\u3A51\u0100bg\u3A45\u3A49ar;\u6A5Fe\u0100;q\u15FA\u3A4F;\u6259erp;\u6118r;\uC000\u{1D534}pf;\uC000\u{1D568}\u0100;e\u1479\u3A66at\xE8\u1479cr;\uC000\u{1D4CC}\u0AE3\u178E\u3A87\0\u3A8B\0\u3A90\u3A9B\0\0\u3A9D\u3AA8\u3AAB\u3AAF\0\0\u3AC3\u3ACE\0\u3AD8\u17DC\u17DFtr\xE9\u17D1r;\uC000\u{1D535}\u0100Aa\u3A94\u3A97r\xF2\u03C3r\xF2\u09F6;\u43BE\u0100Aa\u3AA1\u3AA4r\xF2\u03B8r\xF2\u09EBa\xF0\u2713is;\u62FB\u0180dpt\u17A4\u3AB5\u3ABE\u0100fl\u3ABA\u17A9;\uC000\u{1D569}im\xE5\u17B2\u0100Aa\u3AC7\u3ACAr\xF2\u03CEr\xF2\u0A01\u0100cq\u3AD2\u17B8r;\uC000\u{1D4CD}\u0100pt\u17D6\u3ADCr\xE9\u17D4\u0400acefiosu\u3AF0\u3AFD\u3B08\u3B0C\u3B11\u3B15\u3B1B\u3B21c\u0100uy\u3AF6\u3AFBte\u803B\xFD\u40FD;\u444F\u0100iy\u3B02\u3B06rc;\u4177;\u444Bn\u803B\xA5\u40A5r;\uC000\u{1D536}cy;\u4457pf;\uC000\u{1D56A}cr;\uC000\u{1D4CE}\u0100cm\u3B26\u3B29y;\u444El\u803B\xFF\u40FF\u0500acdefhiosw\u3B42\u3B48\u3B54\u3B58\u3B64\u3B69\u3B6D\u3B74\u3B7A\u3B80cute;\u417A\u0100ay\u3B4D\u3B52ron;\u417E;\u4437ot;\u417C\u0100et\u3B5D\u3B61tr\xE6\u155Fa;\u43B6r;\uC000\u{1D537}cy;\u4436grarr;\u61DDpf;\uC000\u{1D56B}cr;\uC000\u{1D4CF}\u0100jn\u3B85\u3B87;\u600Dj;\u600C'.split("").map((c) => c.charCodeAt(0))
  1081. );
  1082. // node_modules/entities/lib/esm/generated/decode-data-xml.js
  1083. var decode_data_xml_default = new Uint16Array(
  1084. // prettier-ignore
  1085. "\u0200aglq \x1B\u026D\0\0p;\u4026os;\u4027t;\u403Et;\u403Cuot;\u4022".split("").map((c) => c.charCodeAt(0))
  1086. );
  1087. // node_modules/entities/lib/esm/decode_codepoint.js
  1088. var _a;
  1089. var decodeMap = /* @__PURE__ */ new Map([
  1090. [0, 65533],
  1091. // C1 Unicode control character reference replacements
  1092. [128, 8364],
  1093. [130, 8218],
  1094. [131, 402],
  1095. [132, 8222],
  1096. [133, 8230],
  1097. [134, 8224],
  1098. [135, 8225],
  1099. [136, 710],
  1100. [137, 8240],
  1101. [138, 352],
  1102. [139, 8249],
  1103. [140, 338],
  1104. [142, 381],
  1105. [145, 8216],
  1106. [146, 8217],
  1107. [147, 8220],
  1108. [148, 8221],
  1109. [149, 8226],
  1110. [150, 8211],
  1111. [151, 8212],
  1112. [152, 732],
  1113. [153, 8482],
  1114. [154, 353],
  1115. [155, 8250],
  1116. [156, 339],
  1117. [158, 382],
  1118. [159, 376]
  1119. ]);
  1120. var fromCodePoint = (
  1121. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins
  1122. (_a = String.fromCodePoint) !== null && _a !== void 0 ? _a : function(codePoint) {
  1123. let output = "";
  1124. if (codePoint > 65535) {
  1125. codePoint -= 65536;
  1126. output += String.fromCharCode(codePoint >>> 10 & 1023 | 55296);
  1127. codePoint = 56320 | codePoint & 1023;
  1128. }
  1129. output += String.fromCharCode(codePoint);
  1130. return output;
  1131. }
  1132. );
  1133. function replaceCodePoint(codePoint) {
  1134. var _a2;
  1135. if (codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111) {
  1136. return 65533;
  1137. }
  1138. return (_a2 = decodeMap.get(codePoint)) !== null && _a2 !== void 0 ? _a2 : codePoint;
  1139. }
  1140. // node_modules/entities/lib/esm/decode.js
  1141. var CharCodes;
  1142. (function(CharCodes2) {
  1143. CharCodes2[CharCodes2["NUM"] = 35] = "NUM";
  1144. CharCodes2[CharCodes2["SEMI"] = 59] = "SEMI";
  1145. CharCodes2[CharCodes2["EQUALS"] = 61] = "EQUALS";
  1146. CharCodes2[CharCodes2["ZERO"] = 48] = "ZERO";
  1147. CharCodes2[CharCodes2["NINE"] = 57] = "NINE";
  1148. CharCodes2[CharCodes2["LOWER_A"] = 97] = "LOWER_A";
  1149. CharCodes2[CharCodes2["LOWER_F"] = 102] = "LOWER_F";
  1150. CharCodes2[CharCodes2["LOWER_X"] = 120] = "LOWER_X";
  1151. CharCodes2[CharCodes2["LOWER_Z"] = 122] = "LOWER_Z";
  1152. CharCodes2[CharCodes2["UPPER_A"] = 65] = "UPPER_A";
  1153. CharCodes2[CharCodes2["UPPER_F"] = 70] = "UPPER_F";
  1154. CharCodes2[CharCodes2["UPPER_Z"] = 90] = "UPPER_Z";
  1155. })(CharCodes || (CharCodes = {}));
  1156. var TO_LOWER_BIT = 32;
  1157. var BinTrieFlags;
  1158. (function(BinTrieFlags2) {
  1159. BinTrieFlags2[BinTrieFlags2["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
  1160. BinTrieFlags2[BinTrieFlags2["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
  1161. BinTrieFlags2[BinTrieFlags2["JUMP_TABLE"] = 127] = "JUMP_TABLE";
  1162. })(BinTrieFlags || (BinTrieFlags = {}));
  1163. function isNumber(code) {
  1164. return code >= CharCodes.ZERO && code <= CharCodes.NINE;
  1165. }
  1166. function isHexadecimalCharacter(code) {
  1167. return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F;
  1168. }
  1169. function isAsciiAlphaNumeric(code) {
  1170. return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z || isNumber(code);
  1171. }
  1172. function isEntityInAttributeInvalidEnd(code) {
  1173. return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
  1174. }
  1175. var EntityDecoderState;
  1176. (function(EntityDecoderState2) {
  1177. EntityDecoderState2[EntityDecoderState2["EntityStart"] = 0] = "EntityStart";
  1178. EntityDecoderState2[EntityDecoderState2["NumericStart"] = 1] = "NumericStart";
  1179. EntityDecoderState2[EntityDecoderState2["NumericDecimal"] = 2] = "NumericDecimal";
  1180. EntityDecoderState2[EntityDecoderState2["NumericHex"] = 3] = "NumericHex";
  1181. EntityDecoderState2[EntityDecoderState2["NamedEntity"] = 4] = "NamedEntity";
  1182. })(EntityDecoderState || (EntityDecoderState = {}));
  1183. var DecodingMode;
  1184. (function(DecodingMode2) {
  1185. DecodingMode2[DecodingMode2["Legacy"] = 0] = "Legacy";
  1186. DecodingMode2[DecodingMode2["Strict"] = 1] = "Strict";
  1187. DecodingMode2[DecodingMode2["Attribute"] = 2] = "Attribute";
  1188. })(DecodingMode || (DecodingMode = {}));
  1189. var EntityDecoder = class {
  1190. constructor(decodeTree, emitCodePoint, errors) {
  1191. this.decodeTree = decodeTree;
  1192. this.emitCodePoint = emitCodePoint;
  1193. this.errors = errors;
  1194. this.state = EntityDecoderState.EntityStart;
  1195. this.consumed = 1;
  1196. this.result = 0;
  1197. this.treeIndex = 0;
  1198. this.excess = 1;
  1199. this.decodeMode = DecodingMode.Strict;
  1200. }
  1201. /** Resets the instance to make it reusable. */
  1202. startEntity(decodeMode) {
  1203. this.decodeMode = decodeMode;
  1204. this.state = EntityDecoderState.EntityStart;
  1205. this.result = 0;
  1206. this.treeIndex = 0;
  1207. this.excess = 1;
  1208. this.consumed = 1;
  1209. }
  1210. /**
  1211. * Write an entity to the decoder. This can be called multiple times with partial entities.
  1212. * If the entity is incomplete, the decoder will return -1.
  1213. *
  1214. * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
  1215. * entity is incomplete, and resume when the next string is written.
  1216. *
  1217. * @param string The string containing the entity (or a continuation of the entity).
  1218. * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
  1219. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  1220. */
  1221. write(str, offset) {
  1222. switch (this.state) {
  1223. case EntityDecoderState.EntityStart: {
  1224. if (str.charCodeAt(offset) === CharCodes.NUM) {
  1225. this.state = EntityDecoderState.NumericStart;
  1226. this.consumed += 1;
  1227. return this.stateNumericStart(str, offset + 1);
  1228. }
  1229. this.state = EntityDecoderState.NamedEntity;
  1230. return this.stateNamedEntity(str, offset);
  1231. }
  1232. case EntityDecoderState.NumericStart: {
  1233. return this.stateNumericStart(str, offset);
  1234. }
  1235. case EntityDecoderState.NumericDecimal: {
  1236. return this.stateNumericDecimal(str, offset);
  1237. }
  1238. case EntityDecoderState.NumericHex: {
  1239. return this.stateNumericHex(str, offset);
  1240. }
  1241. case EntityDecoderState.NamedEntity: {
  1242. return this.stateNamedEntity(str, offset);
  1243. }
  1244. }
  1245. }
  1246. /**
  1247. * Switches between the numeric decimal and hexadecimal states.
  1248. *
  1249. * Equivalent to the `Numeric character reference state` in the HTML spec.
  1250. *
  1251. * @param str The string containing the entity (or a continuation of the entity).
  1252. * @param offset The current offset.
  1253. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  1254. */
  1255. stateNumericStart(str, offset) {
  1256. if (offset >= str.length) {
  1257. return -1;
  1258. }
  1259. if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
  1260. this.state = EntityDecoderState.NumericHex;
  1261. this.consumed += 1;
  1262. return this.stateNumericHex(str, offset + 1);
  1263. }
  1264. this.state = EntityDecoderState.NumericDecimal;
  1265. return this.stateNumericDecimal(str, offset);
  1266. }
  1267. addToNumericResult(str, start, end, base) {
  1268. if (start !== end) {
  1269. const digitCount = end - start;
  1270. this.result = this.result * Math.pow(base, digitCount) + parseInt(str.substr(start, digitCount), base);
  1271. this.consumed += digitCount;
  1272. }
  1273. }
  1274. /**
  1275. * Parses a hexadecimal numeric entity.
  1276. *
  1277. * Equivalent to the `Hexademical character reference state` in the HTML spec.
  1278. *
  1279. * @param str The string containing the entity (or a continuation of the entity).
  1280. * @param offset The current offset.
  1281. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  1282. */
  1283. stateNumericHex(str, offset) {
  1284. const startIdx = offset;
  1285. while (offset < str.length) {
  1286. const char = str.charCodeAt(offset);
  1287. if (isNumber(char) || isHexadecimalCharacter(char)) {
  1288. offset += 1;
  1289. } else {
  1290. this.addToNumericResult(str, startIdx, offset, 16);
  1291. return this.emitNumericEntity(char, 3);
  1292. }
  1293. }
  1294. this.addToNumericResult(str, startIdx, offset, 16);
  1295. return -1;
  1296. }
  1297. /**
  1298. * Parses a decimal numeric entity.
  1299. *
  1300. * Equivalent to the `Decimal character reference state` in the HTML spec.
  1301. *
  1302. * @param str The string containing the entity (or a continuation of the entity).
  1303. * @param offset The current offset.
  1304. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  1305. */
  1306. stateNumericDecimal(str, offset) {
  1307. const startIdx = offset;
  1308. while (offset < str.length) {
  1309. const char = str.charCodeAt(offset);
  1310. if (isNumber(char)) {
  1311. offset += 1;
  1312. } else {
  1313. this.addToNumericResult(str, startIdx, offset, 10);
  1314. return this.emitNumericEntity(char, 2);
  1315. }
  1316. }
  1317. this.addToNumericResult(str, startIdx, offset, 10);
  1318. return -1;
  1319. }
  1320. /**
  1321. * Validate and emit a numeric entity.
  1322. *
  1323. * Implements the logic from the `Hexademical character reference start
  1324. * state` and `Numeric character reference end state` in the HTML spec.
  1325. *
  1326. * @param lastCp The last code point of the entity. Used to see if the
  1327. * entity was terminated with a semicolon.
  1328. * @param expectedLength The minimum number of characters that should be
  1329. * consumed. Used to validate that at least one digit
  1330. * was consumed.
  1331. * @returns The number of characters that were consumed.
  1332. */
  1333. emitNumericEntity(lastCp, expectedLength) {
  1334. var _a2;
  1335. if (this.consumed <= expectedLength) {
  1336. (_a2 = this.errors) === null || _a2 === void 0 ? void 0 : _a2.absenceOfDigitsInNumericCharacterReference(this.consumed);
  1337. return 0;
  1338. }
  1339. if (lastCp === CharCodes.SEMI) {
  1340. this.consumed += 1;
  1341. } else if (this.decodeMode === DecodingMode.Strict) {
  1342. return 0;
  1343. }
  1344. this.emitCodePoint(replaceCodePoint(this.result), this.consumed);
  1345. if (this.errors) {
  1346. if (lastCp !== CharCodes.SEMI) {
  1347. this.errors.missingSemicolonAfterCharacterReference();
  1348. }
  1349. this.errors.validateNumericCharacterReference(this.result);
  1350. }
  1351. return this.consumed;
  1352. }
  1353. /**
  1354. * Parses a named entity.
  1355. *
  1356. * Equivalent to the `Named character reference state` in the HTML spec.
  1357. *
  1358. * @param str The string containing the entity (or a continuation of the entity).
  1359. * @param offset The current offset.
  1360. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  1361. */
  1362. stateNamedEntity(str, offset) {
  1363. const { decodeTree } = this;
  1364. let current = decodeTree[this.treeIndex];
  1365. let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  1366. for (; offset < str.length; offset++, this.excess++) {
  1367. const char = str.charCodeAt(offset);
  1368. this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
  1369. if (this.treeIndex < 0) {
  1370. return this.result === 0 || // If we are parsing an attribute
  1371. this.decodeMode === DecodingMode.Attribute && // We shouldn't have consumed any characters after the entity,
  1372. (valueLength === 0 || // And there should be no invalid characters.
  1373. isEntityInAttributeInvalidEnd(char)) ? 0 : this.emitNotTerminatedNamedEntity();
  1374. }
  1375. current = decodeTree[this.treeIndex];
  1376. valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  1377. if (valueLength !== 0) {
  1378. if (char === CharCodes.SEMI) {
  1379. return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
  1380. }
  1381. if (this.decodeMode !== DecodingMode.Strict) {
  1382. this.result = this.treeIndex;
  1383. this.consumed += this.excess;
  1384. this.excess = 0;
  1385. }
  1386. }
  1387. }
  1388. return -1;
  1389. }
  1390. /**
  1391. * Emit a named entity that was not terminated with a semicolon.
  1392. *
  1393. * @returns The number of characters consumed.
  1394. */
  1395. emitNotTerminatedNamedEntity() {
  1396. var _a2;
  1397. const { result, decodeTree } = this;
  1398. const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
  1399. this.emitNamedEntityData(result, valueLength, this.consumed);
  1400. (_a2 = this.errors) === null || _a2 === void 0 ? void 0 : _a2.missingSemicolonAfterCharacterReference();
  1401. return this.consumed;
  1402. }
  1403. /**
  1404. * Emit a named entity.
  1405. *
  1406. * @param result The index of the entity in the decode tree.
  1407. * @param valueLength The number of bytes in the entity.
  1408. * @param consumed The number of characters consumed.
  1409. *
  1410. * @returns The number of characters consumed.
  1411. */
  1412. emitNamedEntityData(result, valueLength, consumed) {
  1413. const { decodeTree } = this;
  1414. this.emitCodePoint(valueLength === 1 ? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH : decodeTree[result + 1], consumed);
  1415. if (valueLength === 3) {
  1416. this.emitCodePoint(decodeTree[result + 2], consumed);
  1417. }
  1418. return consumed;
  1419. }
  1420. /**
  1421. * Signal to the parser that the end of the input was reached.
  1422. *
  1423. * Remaining data will be emitted and relevant errors will be produced.
  1424. *
  1425. * @returns The number of characters consumed.
  1426. */
  1427. end() {
  1428. var _a2;
  1429. switch (this.state) {
  1430. case EntityDecoderState.NamedEntity: {
  1431. return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;
  1432. }
  1433. case EntityDecoderState.NumericDecimal: {
  1434. return this.emitNumericEntity(0, 2);
  1435. }
  1436. case EntityDecoderState.NumericHex: {
  1437. return this.emitNumericEntity(0, 3);
  1438. }
  1439. case EntityDecoderState.NumericStart: {
  1440. (_a2 = this.errors) === null || _a2 === void 0 ? void 0 : _a2.absenceOfDigitsInNumericCharacterReference(this.consumed);
  1441. return 0;
  1442. }
  1443. case EntityDecoderState.EntityStart: {
  1444. return 0;
  1445. }
  1446. }
  1447. }
  1448. };
  1449. function getDecoder(decodeTree) {
  1450. let ret = "";
  1451. const decoder = new EntityDecoder(decodeTree, (str) => ret += fromCodePoint(str));
  1452. return function decodeWithTrie(str, decodeMode) {
  1453. let lastIndex = 0;
  1454. let offset = 0;
  1455. while ((offset = str.indexOf("&", offset)) >= 0) {
  1456. ret += str.slice(lastIndex, offset);
  1457. decoder.startEntity(decodeMode);
  1458. const len = decoder.write(
  1459. str,
  1460. // Skip the "&"
  1461. offset + 1
  1462. );
  1463. if (len < 0) {
  1464. lastIndex = offset + decoder.end();
  1465. break;
  1466. }
  1467. lastIndex = offset + len;
  1468. offset = len === 0 ? lastIndex + 1 : lastIndex;
  1469. }
  1470. const result = ret + str.slice(lastIndex);
  1471. ret = "";
  1472. return result;
  1473. };
  1474. }
  1475. function determineBranch(decodeTree, current, nodeIdx, char) {
  1476. const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
  1477. const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
  1478. if (branchCount === 0) {
  1479. return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;
  1480. }
  1481. if (jumpOffset) {
  1482. const value = char - jumpOffset;
  1483. return value < 0 || value >= branchCount ? -1 : decodeTree[nodeIdx + value] - 1;
  1484. }
  1485. let lo = nodeIdx;
  1486. let hi = lo + branchCount - 1;
  1487. while (lo <= hi) {
  1488. const mid = lo + hi >>> 1;
  1489. const midVal = decodeTree[mid];
  1490. if (midVal < char) {
  1491. lo = mid + 1;
  1492. } else if (midVal > char) {
  1493. hi = mid - 1;
  1494. } else {
  1495. return decodeTree[mid + branchCount];
  1496. }
  1497. }
  1498. return -1;
  1499. }
  1500. var htmlDecoder = getDecoder(decode_data_html_default);
  1501. var xmlDecoder = getDecoder(decode_data_xml_default);
  1502. // node_modules/parse5/dist/common/html.js
  1503. var html_exports = {};
  1504. __export(html_exports, {
  1505. ATTRS: () => ATTRS,
  1506. DOCUMENT_MODE: () => DOCUMENT_MODE,
  1507. NS: () => NS,
  1508. SPECIAL_ELEMENTS: () => SPECIAL_ELEMENTS,
  1509. TAG_ID: () => TAG_ID,
  1510. TAG_NAMES: () => TAG_NAMES,
  1511. getTagID: () => getTagID,
  1512. hasUnescapedText: () => hasUnescapedText,
  1513. isNumberedHeader: () => isNumberedHeader
  1514. });
  1515. var NS;
  1516. (function(NS2) {
  1517. NS2["HTML"] = "http://www.w3.org/1999/xhtml";
  1518. NS2["MATHML"] = "http://www.w3.org/1998/Math/MathML";
  1519. NS2["SVG"] = "http://www.w3.org/2000/svg";
  1520. NS2["XLINK"] = "http://www.w3.org/1999/xlink";
  1521. NS2["XML"] = "http://www.w3.org/XML/1998/namespace";
  1522. NS2["XMLNS"] = "http://www.w3.org/2000/xmlns/";
  1523. })(NS = NS || (NS = {}));
  1524. var ATTRS;
  1525. (function(ATTRS2) {
  1526. ATTRS2["TYPE"] = "type";
  1527. ATTRS2["ACTION"] = "action";
  1528. ATTRS2["ENCODING"] = "encoding";
  1529. ATTRS2["PROMPT"] = "prompt";
  1530. ATTRS2["NAME"] = "name";
  1531. ATTRS2["COLOR"] = "color";
  1532. ATTRS2["FACE"] = "face";
  1533. ATTRS2["SIZE"] = "size";
  1534. })(ATTRS = ATTRS || (ATTRS = {}));
  1535. var DOCUMENT_MODE;
  1536. (function(DOCUMENT_MODE2) {
  1537. DOCUMENT_MODE2["NO_QUIRKS"] = "no-quirks";
  1538. DOCUMENT_MODE2["QUIRKS"] = "quirks";
  1539. DOCUMENT_MODE2["LIMITED_QUIRKS"] = "limited-quirks";
  1540. })(DOCUMENT_MODE = DOCUMENT_MODE || (DOCUMENT_MODE = {}));
  1541. var TAG_NAMES;
  1542. (function(TAG_NAMES2) {
  1543. TAG_NAMES2["A"] = "a";
  1544. TAG_NAMES2["ADDRESS"] = "address";
  1545. TAG_NAMES2["ANNOTATION_XML"] = "annotation-xml";
  1546. TAG_NAMES2["APPLET"] = "applet";
  1547. TAG_NAMES2["AREA"] = "area";
  1548. TAG_NAMES2["ARTICLE"] = "article";
  1549. TAG_NAMES2["ASIDE"] = "aside";
  1550. TAG_NAMES2["B"] = "b";
  1551. TAG_NAMES2["BASE"] = "base";
  1552. TAG_NAMES2["BASEFONT"] = "basefont";
  1553. TAG_NAMES2["BGSOUND"] = "bgsound";
  1554. TAG_NAMES2["BIG"] = "big";
  1555. TAG_NAMES2["BLOCKQUOTE"] = "blockquote";
  1556. TAG_NAMES2["BODY"] = "body";
  1557. TAG_NAMES2["BR"] = "br";
  1558. TAG_NAMES2["BUTTON"] = "button";
  1559. TAG_NAMES2["CAPTION"] = "caption";
  1560. TAG_NAMES2["CENTER"] = "center";
  1561. TAG_NAMES2["CODE"] = "code";
  1562. TAG_NAMES2["COL"] = "col";
  1563. TAG_NAMES2["COLGROUP"] = "colgroup";
  1564. TAG_NAMES2["DD"] = "dd";
  1565. TAG_NAMES2["DESC"] = "desc";
  1566. TAG_NAMES2["DETAILS"] = "details";
  1567. TAG_NAMES2["DIALOG"] = "dialog";
  1568. TAG_NAMES2["DIR"] = "dir";
  1569. TAG_NAMES2["DIV"] = "div";
  1570. TAG_NAMES2["DL"] = "dl";
  1571. TAG_NAMES2["DT"] = "dt";
  1572. TAG_NAMES2["EM"] = "em";
  1573. TAG_NAMES2["EMBED"] = "embed";
  1574. TAG_NAMES2["FIELDSET"] = "fieldset";
  1575. TAG_NAMES2["FIGCAPTION"] = "figcaption";
  1576. TAG_NAMES2["FIGURE"] = "figure";
  1577. TAG_NAMES2["FONT"] = "font";
  1578. TAG_NAMES2["FOOTER"] = "footer";
  1579. TAG_NAMES2["FOREIGN_OBJECT"] = "foreignObject";
  1580. TAG_NAMES2["FORM"] = "form";
  1581. TAG_NAMES2["FRAME"] = "frame";
  1582. TAG_NAMES2["FRAMESET"] = "frameset";
  1583. TAG_NAMES2["H1"] = "h1";
  1584. TAG_NAMES2["H2"] = "h2";
  1585. TAG_NAMES2["H3"] = "h3";
  1586. TAG_NAMES2["H4"] = "h4";
  1587. TAG_NAMES2["H5"] = "h5";
  1588. TAG_NAMES2["H6"] = "h6";
  1589. TAG_NAMES2["HEAD"] = "head";
  1590. TAG_NAMES2["HEADER"] = "header";
  1591. TAG_NAMES2["HGROUP"] = "hgroup";
  1592. TAG_NAMES2["HR"] = "hr";
  1593. TAG_NAMES2["HTML"] = "html";
  1594. TAG_NAMES2["I"] = "i";
  1595. TAG_NAMES2["IMG"] = "img";
  1596. TAG_NAMES2["IMAGE"] = "image";
  1597. TAG_NAMES2["INPUT"] = "input";
  1598. TAG_NAMES2["IFRAME"] = "iframe";
  1599. TAG_NAMES2["KEYGEN"] = "keygen";
  1600. TAG_NAMES2["LABEL"] = "label";
  1601. TAG_NAMES2["LI"] = "li";
  1602. TAG_NAMES2["LINK"] = "link";
  1603. TAG_NAMES2["LISTING"] = "listing";
  1604. TAG_NAMES2["MAIN"] = "main";
  1605. TAG_NAMES2["MALIGNMARK"] = "malignmark";
  1606. TAG_NAMES2["MARQUEE"] = "marquee";
  1607. TAG_NAMES2["MATH"] = "math";
  1608. TAG_NAMES2["MENU"] = "menu";
  1609. TAG_NAMES2["META"] = "meta";
  1610. TAG_NAMES2["MGLYPH"] = "mglyph";
  1611. TAG_NAMES2["MI"] = "mi";
  1612. TAG_NAMES2["MO"] = "mo";
  1613. TAG_NAMES2["MN"] = "mn";
  1614. TAG_NAMES2["MS"] = "ms";
  1615. TAG_NAMES2["MTEXT"] = "mtext";
  1616. TAG_NAMES2["NAV"] = "nav";
  1617. TAG_NAMES2["NOBR"] = "nobr";
  1618. TAG_NAMES2["NOFRAMES"] = "noframes";
  1619. TAG_NAMES2["NOEMBED"] = "noembed";
  1620. TAG_NAMES2["NOSCRIPT"] = "noscript";
  1621. TAG_NAMES2["OBJECT"] = "object";
  1622. TAG_NAMES2["OL"] = "ol";
  1623. TAG_NAMES2["OPTGROUP"] = "optgroup";
  1624. TAG_NAMES2["OPTION"] = "option";
  1625. TAG_NAMES2["P"] = "p";
  1626. TAG_NAMES2["PARAM"] = "param";
  1627. TAG_NAMES2["PLAINTEXT"] = "plaintext";
  1628. TAG_NAMES2["PRE"] = "pre";
  1629. TAG_NAMES2["RB"] = "rb";
  1630. TAG_NAMES2["RP"] = "rp";
  1631. TAG_NAMES2["RT"] = "rt";
  1632. TAG_NAMES2["RTC"] = "rtc";
  1633. TAG_NAMES2["RUBY"] = "ruby";
  1634. TAG_NAMES2["S"] = "s";
  1635. TAG_NAMES2["SCRIPT"] = "script";
  1636. TAG_NAMES2["SECTION"] = "section";
  1637. TAG_NAMES2["SELECT"] = "select";
  1638. TAG_NAMES2["SOURCE"] = "source";
  1639. TAG_NAMES2["SMALL"] = "small";
  1640. TAG_NAMES2["SPAN"] = "span";
  1641. TAG_NAMES2["STRIKE"] = "strike";
  1642. TAG_NAMES2["STRONG"] = "strong";
  1643. TAG_NAMES2["STYLE"] = "style";
  1644. TAG_NAMES2["SUB"] = "sub";
  1645. TAG_NAMES2["SUMMARY"] = "summary";
  1646. TAG_NAMES2["SUP"] = "sup";
  1647. TAG_NAMES2["TABLE"] = "table";
  1648. TAG_NAMES2["TBODY"] = "tbody";
  1649. TAG_NAMES2["TEMPLATE"] = "template";
  1650. TAG_NAMES2["TEXTAREA"] = "textarea";
  1651. TAG_NAMES2["TFOOT"] = "tfoot";
  1652. TAG_NAMES2["TD"] = "td";
  1653. TAG_NAMES2["TH"] = "th";
  1654. TAG_NAMES2["THEAD"] = "thead";
  1655. TAG_NAMES2["TITLE"] = "title";
  1656. TAG_NAMES2["TR"] = "tr";
  1657. TAG_NAMES2["TRACK"] = "track";
  1658. TAG_NAMES2["TT"] = "tt";
  1659. TAG_NAMES2["U"] = "u";
  1660. TAG_NAMES2["UL"] = "ul";
  1661. TAG_NAMES2["SVG"] = "svg";
  1662. TAG_NAMES2["VAR"] = "var";
  1663. TAG_NAMES2["WBR"] = "wbr";
  1664. TAG_NAMES2["XMP"] = "xmp";
  1665. })(TAG_NAMES = TAG_NAMES || (TAG_NAMES = {}));
  1666. var TAG_ID;
  1667. (function(TAG_ID2) {
  1668. TAG_ID2[TAG_ID2["UNKNOWN"] = 0] = "UNKNOWN";
  1669. TAG_ID2[TAG_ID2["A"] = 1] = "A";
  1670. TAG_ID2[TAG_ID2["ADDRESS"] = 2] = "ADDRESS";
  1671. TAG_ID2[TAG_ID2["ANNOTATION_XML"] = 3] = "ANNOTATION_XML";
  1672. TAG_ID2[TAG_ID2["APPLET"] = 4] = "APPLET";
  1673. TAG_ID2[TAG_ID2["AREA"] = 5] = "AREA";
  1674. TAG_ID2[TAG_ID2["ARTICLE"] = 6] = "ARTICLE";
  1675. TAG_ID2[TAG_ID2["ASIDE"] = 7] = "ASIDE";
  1676. TAG_ID2[TAG_ID2["B"] = 8] = "B";
  1677. TAG_ID2[TAG_ID2["BASE"] = 9] = "BASE";
  1678. TAG_ID2[TAG_ID2["BASEFONT"] = 10] = "BASEFONT";
  1679. TAG_ID2[TAG_ID2["BGSOUND"] = 11] = "BGSOUND";
  1680. TAG_ID2[TAG_ID2["BIG"] = 12] = "BIG";
  1681. TAG_ID2[TAG_ID2["BLOCKQUOTE"] = 13] = "BLOCKQUOTE";
  1682. TAG_ID2[TAG_ID2["BODY"] = 14] = "BODY";
  1683. TAG_ID2[TAG_ID2["BR"] = 15] = "BR";
  1684. TAG_ID2[TAG_ID2["BUTTON"] = 16] = "BUTTON";
  1685. TAG_ID2[TAG_ID2["CAPTION"] = 17] = "CAPTION";
  1686. TAG_ID2[TAG_ID2["CENTER"] = 18] = "CENTER";
  1687. TAG_ID2[TAG_ID2["CODE"] = 19] = "CODE";
  1688. TAG_ID2[TAG_ID2["COL"] = 20] = "COL";
  1689. TAG_ID2[TAG_ID2["COLGROUP"] = 21] = "COLGROUP";
  1690. TAG_ID2[TAG_ID2["DD"] = 22] = "DD";
  1691. TAG_ID2[TAG_ID2["DESC"] = 23] = "DESC";
  1692. TAG_ID2[TAG_ID2["DETAILS"] = 24] = "DETAILS";
  1693. TAG_ID2[TAG_ID2["DIALOG"] = 25] = "DIALOG";
  1694. TAG_ID2[TAG_ID2["DIR"] = 26] = "DIR";
  1695. TAG_ID2[TAG_ID2["DIV"] = 27] = "DIV";
  1696. TAG_ID2[TAG_ID2["DL"] = 28] = "DL";
  1697. TAG_ID2[TAG_ID2["DT"] = 29] = "DT";
  1698. TAG_ID2[TAG_ID2["EM"] = 30] = "EM";
  1699. TAG_ID2[TAG_ID2["EMBED"] = 31] = "EMBED";
  1700. TAG_ID2[TAG_ID2["FIELDSET"] = 32] = "FIELDSET";
  1701. TAG_ID2[TAG_ID2["FIGCAPTION"] = 33] = "FIGCAPTION";
  1702. TAG_ID2[TAG_ID2["FIGURE"] = 34] = "FIGURE";
  1703. TAG_ID2[TAG_ID2["FONT"] = 35] = "FONT";
  1704. TAG_ID2[TAG_ID2["FOOTER"] = 36] = "FOOTER";
  1705. TAG_ID2[TAG_ID2["FOREIGN_OBJECT"] = 37] = "FOREIGN_OBJECT";
  1706. TAG_ID2[TAG_ID2["FORM"] = 38] = "FORM";
  1707. TAG_ID2[TAG_ID2["FRAME"] = 39] = "FRAME";
  1708. TAG_ID2[TAG_ID2["FRAMESET"] = 40] = "FRAMESET";
  1709. TAG_ID2[TAG_ID2["H1"] = 41] = "H1";
  1710. TAG_ID2[TAG_ID2["H2"] = 42] = "H2";
  1711. TAG_ID2[TAG_ID2["H3"] = 43] = "H3";
  1712. TAG_ID2[TAG_ID2["H4"] = 44] = "H4";
  1713. TAG_ID2[TAG_ID2["H5"] = 45] = "H5";
  1714. TAG_ID2[TAG_ID2["H6"] = 46] = "H6";
  1715. TAG_ID2[TAG_ID2["HEAD"] = 47] = "HEAD";
  1716. TAG_ID2[TAG_ID2["HEADER"] = 48] = "HEADER";
  1717. TAG_ID2[TAG_ID2["HGROUP"] = 49] = "HGROUP";
  1718. TAG_ID2[TAG_ID2["HR"] = 50] = "HR";
  1719. TAG_ID2[TAG_ID2["HTML"] = 51] = "HTML";
  1720. TAG_ID2[TAG_ID2["I"] = 52] = "I";
  1721. TAG_ID2[TAG_ID2["IMG"] = 53] = "IMG";
  1722. TAG_ID2[TAG_ID2["IMAGE"] = 54] = "IMAGE";
  1723. TAG_ID2[TAG_ID2["INPUT"] = 55] = "INPUT";
  1724. TAG_ID2[TAG_ID2["IFRAME"] = 56] = "IFRAME";
  1725. TAG_ID2[TAG_ID2["KEYGEN"] = 57] = "KEYGEN";
  1726. TAG_ID2[TAG_ID2["LABEL"] = 58] = "LABEL";
  1727. TAG_ID2[TAG_ID2["LI"] = 59] = "LI";
  1728. TAG_ID2[TAG_ID2["LINK"] = 60] = "LINK";
  1729. TAG_ID2[TAG_ID2["LISTING"] = 61] = "LISTING";
  1730. TAG_ID2[TAG_ID2["MAIN"] = 62] = "MAIN";
  1731. TAG_ID2[TAG_ID2["MALIGNMARK"] = 63] = "MALIGNMARK";
  1732. TAG_ID2[TAG_ID2["MARQUEE"] = 64] = "MARQUEE";
  1733. TAG_ID2[TAG_ID2["MATH"] = 65] = "MATH";
  1734. TAG_ID2[TAG_ID2["MENU"] = 66] = "MENU";
  1735. TAG_ID2[TAG_ID2["META"] = 67] = "META";
  1736. TAG_ID2[TAG_ID2["MGLYPH"] = 68] = "MGLYPH";
  1737. TAG_ID2[TAG_ID2["MI"] = 69] = "MI";
  1738. TAG_ID2[TAG_ID2["MO"] = 70] = "MO";
  1739. TAG_ID2[TAG_ID2["MN"] = 71] = "MN";
  1740. TAG_ID2[TAG_ID2["MS"] = 72] = "MS";
  1741. TAG_ID2[TAG_ID2["MTEXT"] = 73] = "MTEXT";
  1742. TAG_ID2[TAG_ID2["NAV"] = 74] = "NAV";
  1743. TAG_ID2[TAG_ID2["NOBR"] = 75] = "NOBR";
  1744. TAG_ID2[TAG_ID2["NOFRAMES"] = 76] = "NOFRAMES";
  1745. TAG_ID2[TAG_ID2["NOEMBED"] = 77] = "NOEMBED";
  1746. TAG_ID2[TAG_ID2["NOSCRIPT"] = 78] = "NOSCRIPT";
  1747. TAG_ID2[TAG_ID2["OBJECT"] = 79] = "OBJECT";
  1748. TAG_ID2[TAG_ID2["OL"] = 80] = "OL";
  1749. TAG_ID2[TAG_ID2["OPTGROUP"] = 81] = "OPTGROUP";
  1750. TAG_ID2[TAG_ID2["OPTION"] = 82] = "OPTION";
  1751. TAG_ID2[TAG_ID2["P"] = 83] = "P";
  1752. TAG_ID2[TAG_ID2["PARAM"] = 84] = "PARAM";
  1753. TAG_ID2[TAG_ID2["PLAINTEXT"] = 85] = "PLAINTEXT";
  1754. TAG_ID2[TAG_ID2["PRE"] = 86] = "PRE";
  1755. TAG_ID2[TAG_ID2["RB"] = 87] = "RB";
  1756. TAG_ID2[TAG_ID2["RP"] = 88] = "RP";
  1757. TAG_ID2[TAG_ID2["RT"] = 89] = "RT";
  1758. TAG_ID2[TAG_ID2["RTC"] = 90] = "RTC";
  1759. TAG_ID2[TAG_ID2["RUBY"] = 91] = "RUBY";
  1760. TAG_ID2[TAG_ID2["S"] = 92] = "S";
  1761. TAG_ID2[TAG_ID2["SCRIPT"] = 93] = "SCRIPT";
  1762. TAG_ID2[TAG_ID2["SECTION"] = 94] = "SECTION";
  1763. TAG_ID2[TAG_ID2["SELECT"] = 95] = "SELECT";
  1764. TAG_ID2[TAG_ID2["SOURCE"] = 96] = "SOURCE";
  1765. TAG_ID2[TAG_ID2["SMALL"] = 97] = "SMALL";
  1766. TAG_ID2[TAG_ID2["SPAN"] = 98] = "SPAN";
  1767. TAG_ID2[TAG_ID2["STRIKE"] = 99] = "STRIKE";
  1768. TAG_ID2[TAG_ID2["STRONG"] = 100] = "STRONG";
  1769. TAG_ID2[TAG_ID2["STYLE"] = 101] = "STYLE";
  1770. TAG_ID2[TAG_ID2["SUB"] = 102] = "SUB";
  1771. TAG_ID2[TAG_ID2["SUMMARY"] = 103] = "SUMMARY";
  1772. TAG_ID2[TAG_ID2["SUP"] = 104] = "SUP";
  1773. TAG_ID2[TAG_ID2["TABLE"] = 105] = "TABLE";
  1774. TAG_ID2[TAG_ID2["TBODY"] = 106] = "TBODY";
  1775. TAG_ID2[TAG_ID2["TEMPLATE"] = 107] = "TEMPLATE";
  1776. TAG_ID2[TAG_ID2["TEXTAREA"] = 108] = "TEXTAREA";
  1777. TAG_ID2[TAG_ID2["TFOOT"] = 109] = "TFOOT";
  1778. TAG_ID2[TAG_ID2["TD"] = 110] = "TD";
  1779. TAG_ID2[TAG_ID2["TH"] = 111] = "TH";
  1780. TAG_ID2[TAG_ID2["THEAD"] = 112] = "THEAD";
  1781. TAG_ID2[TAG_ID2["TITLE"] = 113] = "TITLE";
  1782. TAG_ID2[TAG_ID2["TR"] = 114] = "TR";
  1783. TAG_ID2[TAG_ID2["TRACK"] = 115] = "TRACK";
  1784. TAG_ID2[TAG_ID2["TT"] = 116] = "TT";
  1785. TAG_ID2[TAG_ID2["U"] = 117] = "U";
  1786. TAG_ID2[TAG_ID2["UL"] = 118] = "UL";
  1787. TAG_ID2[TAG_ID2["SVG"] = 119] = "SVG";
  1788. TAG_ID2[TAG_ID2["VAR"] = 120] = "VAR";
  1789. TAG_ID2[TAG_ID2["WBR"] = 121] = "WBR";
  1790. TAG_ID2[TAG_ID2["XMP"] = 122] = "XMP";
  1791. })(TAG_ID = TAG_ID || (TAG_ID = {}));
  1792. var TAG_NAME_TO_ID = /* @__PURE__ */ new Map([
  1793. [TAG_NAMES.A, TAG_ID.A],
  1794. [TAG_NAMES.ADDRESS, TAG_ID.ADDRESS],
  1795. [TAG_NAMES.ANNOTATION_XML, TAG_ID.ANNOTATION_XML],
  1796. [TAG_NAMES.APPLET, TAG_ID.APPLET],
  1797. [TAG_NAMES.AREA, TAG_ID.AREA],
  1798. [TAG_NAMES.ARTICLE, TAG_ID.ARTICLE],
  1799. [TAG_NAMES.ASIDE, TAG_ID.ASIDE],
  1800. [TAG_NAMES.B, TAG_ID.B],
  1801. [TAG_NAMES.BASE, TAG_ID.BASE],
  1802. [TAG_NAMES.BASEFONT, TAG_ID.BASEFONT],
  1803. [TAG_NAMES.BGSOUND, TAG_ID.BGSOUND],
  1804. [TAG_NAMES.BIG, TAG_ID.BIG],
  1805. [TAG_NAMES.BLOCKQUOTE, TAG_ID.BLOCKQUOTE],
  1806. [TAG_NAMES.BODY, TAG_ID.BODY],
  1807. [TAG_NAMES.BR, TAG_ID.BR],
  1808. [TAG_NAMES.BUTTON, TAG_ID.BUTTON],
  1809. [TAG_NAMES.CAPTION, TAG_ID.CAPTION],
  1810. [TAG_NAMES.CENTER, TAG_ID.CENTER],
  1811. [TAG_NAMES.CODE, TAG_ID.CODE],
  1812. [TAG_NAMES.COL, TAG_ID.COL],
  1813. [TAG_NAMES.COLGROUP, TAG_ID.COLGROUP],
  1814. [TAG_NAMES.DD, TAG_ID.DD],
  1815. [TAG_NAMES.DESC, TAG_ID.DESC],
  1816. [TAG_NAMES.DETAILS, TAG_ID.DETAILS],
  1817. [TAG_NAMES.DIALOG, TAG_ID.DIALOG],
  1818. [TAG_NAMES.DIR, TAG_ID.DIR],
  1819. [TAG_NAMES.DIV, TAG_ID.DIV],
  1820. [TAG_NAMES.DL, TAG_ID.DL],
  1821. [TAG_NAMES.DT, TAG_ID.DT],
  1822. [TAG_NAMES.EM, TAG_ID.EM],
  1823. [TAG_NAMES.EMBED, TAG_ID.EMBED],
  1824. [TAG_NAMES.FIELDSET, TAG_ID.FIELDSET],
  1825. [TAG_NAMES.FIGCAPTION, TAG_ID.FIGCAPTION],
  1826. [TAG_NAMES.FIGURE, TAG_ID.FIGURE],
  1827. [TAG_NAMES.FONT, TAG_ID.FONT],
  1828. [TAG_NAMES.FOOTER, TAG_ID.FOOTER],
  1829. [TAG_NAMES.FOREIGN_OBJECT, TAG_ID.FOREIGN_OBJECT],
  1830. [TAG_NAMES.FORM, TAG_ID.FORM],
  1831. [TAG_NAMES.FRAME, TAG_ID.FRAME],
  1832. [TAG_NAMES.FRAMESET, TAG_ID.FRAMESET],
  1833. [TAG_NAMES.H1, TAG_ID.H1],
  1834. [TAG_NAMES.H2, TAG_ID.H2],
  1835. [TAG_NAMES.H3, TAG_ID.H3],
  1836. [TAG_NAMES.H4, TAG_ID.H4],
  1837. [TAG_NAMES.H5, TAG_ID.H5],
  1838. [TAG_NAMES.H6, TAG_ID.H6],
  1839. [TAG_NAMES.HEAD, TAG_ID.HEAD],
  1840. [TAG_NAMES.HEADER, TAG_ID.HEADER],
  1841. [TAG_NAMES.HGROUP, TAG_ID.HGROUP],
  1842. [TAG_NAMES.HR, TAG_ID.HR],
  1843. [TAG_NAMES.HTML, TAG_ID.HTML],
  1844. [TAG_NAMES.I, TAG_ID.I],
  1845. [TAG_NAMES.IMG, TAG_ID.IMG],
  1846. [TAG_NAMES.IMAGE, TAG_ID.IMAGE],
  1847. [TAG_NAMES.INPUT, TAG_ID.INPUT],
  1848. [TAG_NAMES.IFRAME, TAG_ID.IFRAME],
  1849. [TAG_NAMES.KEYGEN, TAG_ID.KEYGEN],
  1850. [TAG_NAMES.LABEL, TAG_ID.LABEL],
  1851. [TAG_NAMES.LI, TAG_ID.LI],
  1852. [TAG_NAMES.LINK, TAG_ID.LINK],
  1853. [TAG_NAMES.LISTING, TAG_ID.LISTING],
  1854. [TAG_NAMES.MAIN, TAG_ID.MAIN],
  1855. [TAG_NAMES.MALIGNMARK, TAG_ID.MALIGNMARK],
  1856. [TAG_NAMES.MARQUEE, TAG_ID.MARQUEE],
  1857. [TAG_NAMES.MATH, TAG_ID.MATH],
  1858. [TAG_NAMES.MENU, TAG_ID.MENU],
  1859. [TAG_NAMES.META, TAG_ID.META],
  1860. [TAG_NAMES.MGLYPH, TAG_ID.MGLYPH],
  1861. [TAG_NAMES.MI, TAG_ID.MI],
  1862. [TAG_NAMES.MO, TAG_ID.MO],
  1863. [TAG_NAMES.MN, TAG_ID.MN],
  1864. [TAG_NAMES.MS, TAG_ID.MS],
  1865. [TAG_NAMES.MTEXT, TAG_ID.MTEXT],
  1866. [TAG_NAMES.NAV, TAG_ID.NAV],
  1867. [TAG_NAMES.NOBR, TAG_ID.NOBR],
  1868. [TAG_NAMES.NOFRAMES, TAG_ID.NOFRAMES],
  1869. [TAG_NAMES.NOEMBED, TAG_ID.NOEMBED],
  1870. [TAG_NAMES.NOSCRIPT, TAG_ID.NOSCRIPT],
  1871. [TAG_NAMES.OBJECT, TAG_ID.OBJECT],
  1872. [TAG_NAMES.OL, TAG_ID.OL],
  1873. [TAG_NAMES.OPTGROUP, TAG_ID.OPTGROUP],
  1874. [TAG_NAMES.OPTION, TAG_ID.OPTION],
  1875. [TAG_NAMES.P, TAG_ID.P],
  1876. [TAG_NAMES.PARAM, TAG_ID.PARAM],
  1877. [TAG_NAMES.PLAINTEXT, TAG_ID.PLAINTEXT],
  1878. [TAG_NAMES.PRE, TAG_ID.PRE],
  1879. [TAG_NAMES.RB, TAG_ID.RB],
  1880. [TAG_NAMES.RP, TAG_ID.RP],
  1881. [TAG_NAMES.RT, TAG_ID.RT],
  1882. [TAG_NAMES.RTC, TAG_ID.RTC],
  1883. [TAG_NAMES.RUBY, TAG_ID.RUBY],
  1884. [TAG_NAMES.S, TAG_ID.S],
  1885. [TAG_NAMES.SCRIPT, TAG_ID.SCRIPT],
  1886. [TAG_NAMES.SECTION, TAG_ID.SECTION],
  1887. [TAG_NAMES.SELECT, TAG_ID.SELECT],
  1888. [TAG_NAMES.SOURCE, TAG_ID.SOURCE],
  1889. [TAG_NAMES.SMALL, TAG_ID.SMALL],
  1890. [TAG_NAMES.SPAN, TAG_ID.SPAN],
  1891. [TAG_NAMES.STRIKE, TAG_ID.STRIKE],
  1892. [TAG_NAMES.STRONG, TAG_ID.STRONG],
  1893. [TAG_NAMES.STYLE, TAG_ID.STYLE],
  1894. [TAG_NAMES.SUB, TAG_ID.SUB],
  1895. [TAG_NAMES.SUMMARY, TAG_ID.SUMMARY],
  1896. [TAG_NAMES.SUP, TAG_ID.SUP],
  1897. [TAG_NAMES.TABLE, TAG_ID.TABLE],
  1898. [TAG_NAMES.TBODY, TAG_ID.TBODY],
  1899. [TAG_NAMES.TEMPLATE, TAG_ID.TEMPLATE],
  1900. [TAG_NAMES.TEXTAREA, TAG_ID.TEXTAREA],
  1901. [TAG_NAMES.TFOOT, TAG_ID.TFOOT],
  1902. [TAG_NAMES.TD, TAG_ID.TD],
  1903. [TAG_NAMES.TH, TAG_ID.TH],
  1904. [TAG_NAMES.THEAD, TAG_ID.THEAD],
  1905. [TAG_NAMES.TITLE, TAG_ID.TITLE],
  1906. [TAG_NAMES.TR, TAG_ID.TR],
  1907. [TAG_NAMES.TRACK, TAG_ID.TRACK],
  1908. [TAG_NAMES.TT, TAG_ID.TT],
  1909. [TAG_NAMES.U, TAG_ID.U],
  1910. [TAG_NAMES.UL, TAG_ID.UL],
  1911. [TAG_NAMES.SVG, TAG_ID.SVG],
  1912. [TAG_NAMES.VAR, TAG_ID.VAR],
  1913. [TAG_NAMES.WBR, TAG_ID.WBR],
  1914. [TAG_NAMES.XMP, TAG_ID.XMP]
  1915. ]);
  1916. function getTagID(tagName) {
  1917. var _a2;
  1918. return (_a2 = TAG_NAME_TO_ID.get(tagName)) !== null && _a2 !== void 0 ? _a2 : TAG_ID.UNKNOWN;
  1919. }
  1920. var $ = TAG_ID;
  1921. var SPECIAL_ELEMENTS = {
  1922. [NS.HTML]: /* @__PURE__ */ new Set([
  1923. $.ADDRESS,
  1924. $.APPLET,
  1925. $.AREA,
  1926. $.ARTICLE,
  1927. $.ASIDE,
  1928. $.BASE,
  1929. $.BASEFONT,
  1930. $.BGSOUND,
  1931. $.BLOCKQUOTE,
  1932. $.BODY,
  1933. $.BR,
  1934. $.BUTTON,
  1935. $.CAPTION,
  1936. $.CENTER,
  1937. $.COL,
  1938. $.COLGROUP,
  1939. $.DD,
  1940. $.DETAILS,
  1941. $.DIR,
  1942. $.DIV,
  1943. $.DL,
  1944. $.DT,
  1945. $.EMBED,
  1946. $.FIELDSET,
  1947. $.FIGCAPTION,
  1948. $.FIGURE,
  1949. $.FOOTER,
  1950. $.FORM,
  1951. $.FRAME,
  1952. $.FRAMESET,
  1953. $.H1,
  1954. $.H2,
  1955. $.H3,
  1956. $.H4,
  1957. $.H5,
  1958. $.H6,
  1959. $.HEAD,
  1960. $.HEADER,
  1961. $.HGROUP,
  1962. $.HR,
  1963. $.HTML,
  1964. $.IFRAME,
  1965. $.IMG,
  1966. $.INPUT,
  1967. $.LI,
  1968. $.LINK,
  1969. $.LISTING,
  1970. $.MAIN,
  1971. $.MARQUEE,
  1972. $.MENU,
  1973. $.META,
  1974. $.NAV,
  1975. $.NOEMBED,
  1976. $.NOFRAMES,
  1977. $.NOSCRIPT,
  1978. $.OBJECT,
  1979. $.OL,
  1980. $.P,
  1981. $.PARAM,
  1982. $.PLAINTEXT,
  1983. $.PRE,
  1984. $.SCRIPT,
  1985. $.SECTION,
  1986. $.SELECT,
  1987. $.SOURCE,
  1988. $.STYLE,
  1989. $.SUMMARY,
  1990. $.TABLE,
  1991. $.TBODY,
  1992. $.TD,
  1993. $.TEMPLATE,
  1994. $.TEXTAREA,
  1995. $.TFOOT,
  1996. $.TH,
  1997. $.THEAD,
  1998. $.TITLE,
  1999. $.TR,
  2000. $.TRACK,
  2001. $.UL,
  2002. $.WBR,
  2003. $.XMP
  2004. ]),
  2005. [NS.MATHML]: /* @__PURE__ */ new Set([$.MI, $.MO, $.MN, $.MS, $.MTEXT, $.ANNOTATION_XML]),
  2006. [NS.SVG]: /* @__PURE__ */ new Set([$.TITLE, $.FOREIGN_OBJECT, $.DESC]),
  2007. [NS.XLINK]: /* @__PURE__ */ new Set(),
  2008. [NS.XML]: /* @__PURE__ */ new Set(),
  2009. [NS.XMLNS]: /* @__PURE__ */ new Set()
  2010. };
  2011. function isNumberedHeader(tn) {
  2012. return tn === $.H1 || tn === $.H2 || tn === $.H3 || tn === $.H4 || tn === $.H5 || tn === $.H6;
  2013. }
  2014. var UNESCAPED_TEXT = /* @__PURE__ */ new Set([
  2015. TAG_NAMES.STYLE,
  2016. TAG_NAMES.SCRIPT,
  2017. TAG_NAMES.XMP,
  2018. TAG_NAMES.IFRAME,
  2019. TAG_NAMES.NOEMBED,
  2020. TAG_NAMES.NOFRAMES,
  2021. TAG_NAMES.PLAINTEXT
  2022. ]);
  2023. function hasUnescapedText(tn, scriptingEnabled) {
  2024. return UNESCAPED_TEXT.has(tn) || scriptingEnabled && tn === TAG_NAMES.NOSCRIPT;
  2025. }
  2026. // node_modules/parse5/dist/tokenizer/index.js
  2027. var C1_CONTROLS_REFERENCE_REPLACEMENTS = /* @__PURE__ */ new Map([
  2028. [128, 8364],
  2029. [130, 8218],
  2030. [131, 402],
  2031. [132, 8222],
  2032. [133, 8230],
  2033. [134, 8224],
  2034. [135, 8225],
  2035. [136, 710],
  2036. [137, 8240],
  2037. [138, 352],
  2038. [139, 8249],
  2039. [140, 338],
  2040. [142, 381],
  2041. [145, 8216],
  2042. [146, 8217],
  2043. [147, 8220],
  2044. [148, 8221],
  2045. [149, 8226],
  2046. [150, 8211],
  2047. [151, 8212],
  2048. [152, 732],
  2049. [153, 8482],
  2050. [154, 353],
  2051. [155, 8250],
  2052. [156, 339],
  2053. [158, 382],
  2054. [159, 376]
  2055. ]);
  2056. var State;
  2057. (function(State2) {
  2058. State2[State2["DATA"] = 0] = "DATA";
  2059. State2[State2["RCDATA"] = 1] = "RCDATA";
  2060. State2[State2["RAWTEXT"] = 2] = "RAWTEXT";
  2061. State2[State2["SCRIPT_DATA"] = 3] = "SCRIPT_DATA";
  2062. State2[State2["PLAINTEXT"] = 4] = "PLAINTEXT";
  2063. State2[State2["TAG_OPEN"] = 5] = "TAG_OPEN";
  2064. State2[State2["END_TAG_OPEN"] = 6] = "END_TAG_OPEN";
  2065. State2[State2["TAG_NAME"] = 7] = "TAG_NAME";
  2066. State2[State2["RCDATA_LESS_THAN_SIGN"] = 8] = "RCDATA_LESS_THAN_SIGN";
  2067. State2[State2["RCDATA_END_TAG_OPEN"] = 9] = "RCDATA_END_TAG_OPEN";
  2068. State2[State2["RCDATA_END_TAG_NAME"] = 10] = "RCDATA_END_TAG_NAME";
  2069. State2[State2["RAWTEXT_LESS_THAN_SIGN"] = 11] = "RAWTEXT_LESS_THAN_SIGN";
  2070. State2[State2["RAWTEXT_END_TAG_OPEN"] = 12] = "RAWTEXT_END_TAG_OPEN";
  2071. State2[State2["RAWTEXT_END_TAG_NAME"] = 13] = "RAWTEXT_END_TAG_NAME";
  2072. State2[State2["SCRIPT_DATA_LESS_THAN_SIGN"] = 14] = "SCRIPT_DATA_LESS_THAN_SIGN";
  2073. State2[State2["SCRIPT_DATA_END_TAG_OPEN"] = 15] = "SCRIPT_DATA_END_TAG_OPEN";
  2074. State2[State2["SCRIPT_DATA_END_TAG_NAME"] = 16] = "SCRIPT_DATA_END_TAG_NAME";
  2075. State2[State2["SCRIPT_DATA_ESCAPE_START"] = 17] = "SCRIPT_DATA_ESCAPE_START";
  2076. State2[State2["SCRIPT_DATA_ESCAPE_START_DASH"] = 18] = "SCRIPT_DATA_ESCAPE_START_DASH";
  2077. State2[State2["SCRIPT_DATA_ESCAPED"] = 19] = "SCRIPT_DATA_ESCAPED";
  2078. State2[State2["SCRIPT_DATA_ESCAPED_DASH"] = 20] = "SCRIPT_DATA_ESCAPED_DASH";
  2079. State2[State2["SCRIPT_DATA_ESCAPED_DASH_DASH"] = 21] = "SCRIPT_DATA_ESCAPED_DASH_DASH";
  2080. State2[State2["SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN"] = 22] = "SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN";
  2081. State2[State2["SCRIPT_DATA_ESCAPED_END_TAG_OPEN"] = 23] = "SCRIPT_DATA_ESCAPED_END_TAG_OPEN";
  2082. State2[State2["SCRIPT_DATA_ESCAPED_END_TAG_NAME"] = 24] = "SCRIPT_DATA_ESCAPED_END_TAG_NAME";
  2083. State2[State2["SCRIPT_DATA_DOUBLE_ESCAPE_START"] = 25] = "SCRIPT_DATA_DOUBLE_ESCAPE_START";
  2084. State2[State2["SCRIPT_DATA_DOUBLE_ESCAPED"] = 26] = "SCRIPT_DATA_DOUBLE_ESCAPED";
  2085. State2[State2["SCRIPT_DATA_DOUBLE_ESCAPED_DASH"] = 27] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH";
  2086. State2[State2["SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH"] = 28] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH";
  2087. State2[State2["SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN"] = 29] = "SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN";
  2088. State2[State2["SCRIPT_DATA_DOUBLE_ESCAPE_END"] = 30] = "SCRIPT_DATA_DOUBLE_ESCAPE_END";
  2089. State2[State2["BEFORE_ATTRIBUTE_NAME"] = 31] = "BEFORE_ATTRIBUTE_NAME";
  2090. State2[State2["ATTRIBUTE_NAME"] = 32] = "ATTRIBUTE_NAME";
  2091. State2[State2["AFTER_ATTRIBUTE_NAME"] = 33] = "AFTER_ATTRIBUTE_NAME";
  2092. State2[State2["BEFORE_ATTRIBUTE_VALUE"] = 34] = "BEFORE_ATTRIBUTE_VALUE";
  2093. State2[State2["ATTRIBUTE_VALUE_DOUBLE_QUOTED"] = 35] = "ATTRIBUTE_VALUE_DOUBLE_QUOTED";
  2094. State2[State2["ATTRIBUTE_VALUE_SINGLE_QUOTED"] = 36] = "ATTRIBUTE_VALUE_SINGLE_QUOTED";
  2095. State2[State2["ATTRIBUTE_VALUE_UNQUOTED"] = 37] = "ATTRIBUTE_VALUE_UNQUOTED";
  2096. State2[State2["AFTER_ATTRIBUTE_VALUE_QUOTED"] = 38] = "AFTER_ATTRIBUTE_VALUE_QUOTED";
  2097. State2[State2["SELF_CLOSING_START_TAG"] = 39] = "SELF_CLOSING_START_TAG";
  2098. State2[State2["BOGUS_COMMENT"] = 40] = "BOGUS_COMMENT";
  2099. State2[State2["MARKUP_DECLARATION_OPEN"] = 41] = "MARKUP_DECLARATION_OPEN";
  2100. State2[State2["COMMENT_START"] = 42] = "COMMENT_START";
  2101. State2[State2["COMMENT_START_DASH"] = 43] = "COMMENT_START_DASH";
  2102. State2[State2["COMMENT"] = 44] = "COMMENT";
  2103. State2[State2["COMMENT_LESS_THAN_SIGN"] = 45] = "COMMENT_LESS_THAN_SIGN";
  2104. State2[State2["COMMENT_LESS_THAN_SIGN_BANG"] = 46] = "COMMENT_LESS_THAN_SIGN_BANG";
  2105. State2[State2["COMMENT_LESS_THAN_SIGN_BANG_DASH"] = 47] = "COMMENT_LESS_THAN_SIGN_BANG_DASH";
  2106. State2[State2["COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH"] = 48] = "COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH";
  2107. State2[State2["COMMENT_END_DASH"] = 49] = "COMMENT_END_DASH";
  2108. State2[State2["COMMENT_END"] = 50] = "COMMENT_END";
  2109. State2[State2["COMMENT_END_BANG"] = 51] = "COMMENT_END_BANG";
  2110. State2[State2["DOCTYPE"] = 52] = "DOCTYPE";
  2111. State2[State2["BEFORE_DOCTYPE_NAME"] = 53] = "BEFORE_DOCTYPE_NAME";
  2112. State2[State2["DOCTYPE_NAME"] = 54] = "DOCTYPE_NAME";
  2113. State2[State2["AFTER_DOCTYPE_NAME"] = 55] = "AFTER_DOCTYPE_NAME";
  2114. State2[State2["AFTER_DOCTYPE_PUBLIC_KEYWORD"] = 56] = "AFTER_DOCTYPE_PUBLIC_KEYWORD";
  2115. State2[State2["BEFORE_DOCTYPE_PUBLIC_IDENTIFIER"] = 57] = "BEFORE_DOCTYPE_PUBLIC_IDENTIFIER";
  2116. State2[State2["DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED"] = 58] = "DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED";
  2117. State2[State2["DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED"] = 59] = "DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED";
  2118. State2[State2["AFTER_DOCTYPE_PUBLIC_IDENTIFIER"] = 60] = "AFTER_DOCTYPE_PUBLIC_IDENTIFIER";
  2119. State2[State2["BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS"] = 61] = "BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS";
  2120. State2[State2["AFTER_DOCTYPE_SYSTEM_KEYWORD"] = 62] = "AFTER_DOCTYPE_SYSTEM_KEYWORD";
  2121. State2[State2["BEFORE_DOCTYPE_SYSTEM_IDENTIFIER"] = 63] = "BEFORE_DOCTYPE_SYSTEM_IDENTIFIER";
  2122. State2[State2["DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED"] = 64] = "DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED";
  2123. State2[State2["DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED"] = 65] = "DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED";
  2124. State2[State2["AFTER_DOCTYPE_SYSTEM_IDENTIFIER"] = 66] = "AFTER_DOCTYPE_SYSTEM_IDENTIFIER";
  2125. State2[State2["BOGUS_DOCTYPE"] = 67] = "BOGUS_DOCTYPE";
  2126. State2[State2["CDATA_SECTION"] = 68] = "CDATA_SECTION";
  2127. State2[State2["CDATA_SECTION_BRACKET"] = 69] = "CDATA_SECTION_BRACKET";
  2128. State2[State2["CDATA_SECTION_END"] = 70] = "CDATA_SECTION_END";
  2129. State2[State2["CHARACTER_REFERENCE"] = 71] = "CHARACTER_REFERENCE";
  2130. State2[State2["NAMED_CHARACTER_REFERENCE"] = 72] = "NAMED_CHARACTER_REFERENCE";
  2131. State2[State2["AMBIGUOUS_AMPERSAND"] = 73] = "AMBIGUOUS_AMPERSAND";
  2132. State2[State2["NUMERIC_CHARACTER_REFERENCE"] = 74] = "NUMERIC_CHARACTER_REFERENCE";
  2133. State2[State2["HEXADEMICAL_CHARACTER_REFERENCE_START"] = 75] = "HEXADEMICAL_CHARACTER_REFERENCE_START";
  2134. State2[State2["HEXADEMICAL_CHARACTER_REFERENCE"] = 76] = "HEXADEMICAL_CHARACTER_REFERENCE";
  2135. State2[State2["DECIMAL_CHARACTER_REFERENCE"] = 77] = "DECIMAL_CHARACTER_REFERENCE";
  2136. State2[State2["NUMERIC_CHARACTER_REFERENCE_END"] = 78] = "NUMERIC_CHARACTER_REFERENCE_END";
  2137. })(State || (State = {}));
  2138. var TokenizerMode = {
  2139. DATA: State.DATA,
  2140. RCDATA: State.RCDATA,
  2141. RAWTEXT: State.RAWTEXT,
  2142. SCRIPT_DATA: State.SCRIPT_DATA,
  2143. PLAINTEXT: State.PLAINTEXT,
  2144. CDATA_SECTION: State.CDATA_SECTION
  2145. };
  2146. function isAsciiDigit(cp) {
  2147. return cp >= CODE_POINTS.DIGIT_0 && cp <= CODE_POINTS.DIGIT_9;
  2148. }
  2149. function isAsciiUpper(cp) {
  2150. return cp >= CODE_POINTS.LATIN_CAPITAL_A && cp <= CODE_POINTS.LATIN_CAPITAL_Z;
  2151. }
  2152. function isAsciiLower(cp) {
  2153. return cp >= CODE_POINTS.LATIN_SMALL_A && cp <= CODE_POINTS.LATIN_SMALL_Z;
  2154. }
  2155. function isAsciiLetter(cp) {
  2156. return isAsciiLower(cp) || isAsciiUpper(cp);
  2157. }
  2158. function isAsciiAlphaNumeric2(cp) {
  2159. return isAsciiLetter(cp) || isAsciiDigit(cp);
  2160. }
  2161. function isAsciiUpperHexDigit(cp) {
  2162. return cp >= CODE_POINTS.LATIN_CAPITAL_A && cp <= CODE_POINTS.LATIN_CAPITAL_F;
  2163. }
  2164. function isAsciiLowerHexDigit(cp) {
  2165. return cp >= CODE_POINTS.LATIN_SMALL_A && cp <= CODE_POINTS.LATIN_SMALL_F;
  2166. }
  2167. function isAsciiHexDigit(cp) {
  2168. return isAsciiDigit(cp) || isAsciiUpperHexDigit(cp) || isAsciiLowerHexDigit(cp);
  2169. }
  2170. function toAsciiLower(cp) {
  2171. return cp + 32;
  2172. }
  2173. function isWhitespace(cp) {
  2174. return cp === CODE_POINTS.SPACE || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.TABULATION || cp === CODE_POINTS.FORM_FEED;
  2175. }
  2176. function isEntityInAttributeInvalidEnd2(nextCp) {
  2177. return nextCp === CODE_POINTS.EQUALS_SIGN || isAsciiAlphaNumeric2(nextCp);
  2178. }
  2179. function isScriptDataDoubleEscapeSequenceEnd(cp) {
  2180. return isWhitespace(cp) || cp === CODE_POINTS.SOLIDUS || cp === CODE_POINTS.GREATER_THAN_SIGN;
  2181. }
  2182. var Tokenizer = class {
  2183. constructor(options, handler) {
  2184. this.options = options;
  2185. this.handler = handler;
  2186. this.paused = false;
  2187. this.inLoop = false;
  2188. this.inForeignNode = false;
  2189. this.lastStartTagName = "";
  2190. this.active = false;
  2191. this.state = State.DATA;
  2192. this.returnState = State.DATA;
  2193. this.charRefCode = -1;
  2194. this.consumedAfterSnapshot = -1;
  2195. this.currentCharacterToken = null;
  2196. this.currentToken = null;
  2197. this.currentAttr = { name: "", value: "" };
  2198. this.preprocessor = new Preprocessor(handler);
  2199. this.currentLocation = this.getCurrentLocation(-1);
  2200. }
  2201. //Errors
  2202. _err(code) {
  2203. var _a2, _b;
  2204. (_b = (_a2 = this.handler).onParseError) === null || _b === void 0 ? void 0 : _b.call(_a2, this.preprocessor.getError(code));
  2205. }
  2206. // NOTE: `offset` may never run across line boundaries.
  2207. getCurrentLocation(offset) {
  2208. if (!this.options.sourceCodeLocationInfo) {
  2209. return null;
  2210. }
  2211. return {
  2212. startLine: this.preprocessor.line,
  2213. startCol: this.preprocessor.col - offset,
  2214. startOffset: this.preprocessor.offset - offset,
  2215. endLine: -1,
  2216. endCol: -1,
  2217. endOffset: -1
  2218. };
  2219. }
  2220. _runParsingLoop() {
  2221. if (this.inLoop)
  2222. return;
  2223. this.inLoop = true;
  2224. while (this.active && !this.paused) {
  2225. this.consumedAfterSnapshot = 0;
  2226. const cp = this._consume();
  2227. if (!this._ensureHibernation()) {
  2228. this._callState(cp);
  2229. }
  2230. }
  2231. this.inLoop = false;
  2232. }
  2233. //API
  2234. pause() {
  2235. this.paused = true;
  2236. }
  2237. resume(writeCallback) {
  2238. if (!this.paused) {
  2239. throw new Error("Parser was already resumed");
  2240. }
  2241. this.paused = false;
  2242. if (this.inLoop)
  2243. return;
  2244. this._runParsingLoop();
  2245. if (!this.paused) {
  2246. writeCallback === null || writeCallback === void 0 ? void 0 : writeCallback();
  2247. }
  2248. }
  2249. write(chunk, isLastChunk, writeCallback) {
  2250. this.active = true;
  2251. this.preprocessor.write(chunk, isLastChunk);
  2252. this._runParsingLoop();
  2253. if (!this.paused) {
  2254. writeCallback === null || writeCallback === void 0 ? void 0 : writeCallback();
  2255. }
  2256. }
  2257. insertHtmlAtCurrentPos(chunk) {
  2258. this.active = true;
  2259. this.preprocessor.insertHtmlAtCurrentPos(chunk);
  2260. this._runParsingLoop();
  2261. }
  2262. //Hibernation
  2263. _ensureHibernation() {
  2264. if (this.preprocessor.endOfChunkHit) {
  2265. this._unconsume(this.consumedAfterSnapshot);
  2266. this.active = false;
  2267. return true;
  2268. }
  2269. return false;
  2270. }
  2271. //Consumption
  2272. _consume() {
  2273. this.consumedAfterSnapshot++;
  2274. return this.preprocessor.advance();
  2275. }
  2276. _unconsume(count) {
  2277. this.consumedAfterSnapshot -= count;
  2278. this.preprocessor.retreat(count);
  2279. }
  2280. _reconsumeInState(state, cp) {
  2281. this.state = state;
  2282. this._callState(cp);
  2283. }
  2284. _advanceBy(count) {
  2285. this.consumedAfterSnapshot += count;
  2286. for (let i = 0; i < count; i++) {
  2287. this.preprocessor.advance();
  2288. }
  2289. }
  2290. _consumeSequenceIfMatch(pattern, caseSensitive) {
  2291. if (this.preprocessor.startsWith(pattern, caseSensitive)) {
  2292. this._advanceBy(pattern.length - 1);
  2293. return true;
  2294. }
  2295. return false;
  2296. }
  2297. //Token creation
  2298. _createStartTagToken() {
  2299. this.currentToken = {
  2300. type: TokenType.START_TAG,
  2301. tagName: "",
  2302. tagID: TAG_ID.UNKNOWN,
  2303. selfClosing: false,
  2304. ackSelfClosing: false,
  2305. attrs: [],
  2306. location: this.getCurrentLocation(1)
  2307. };
  2308. }
  2309. _createEndTagToken() {
  2310. this.currentToken = {
  2311. type: TokenType.END_TAG,
  2312. tagName: "",
  2313. tagID: TAG_ID.UNKNOWN,
  2314. selfClosing: false,
  2315. ackSelfClosing: false,
  2316. attrs: [],
  2317. location: this.getCurrentLocation(2)
  2318. };
  2319. }
  2320. _createCommentToken(offset) {
  2321. this.currentToken = {
  2322. type: TokenType.COMMENT,
  2323. data: "",
  2324. location: this.getCurrentLocation(offset)
  2325. };
  2326. }
  2327. _createDoctypeToken(initialName) {
  2328. this.currentToken = {
  2329. type: TokenType.DOCTYPE,
  2330. name: initialName,
  2331. forceQuirks: false,
  2332. publicId: null,
  2333. systemId: null,
  2334. location: this.currentLocation
  2335. };
  2336. }
  2337. _createCharacterToken(type, chars) {
  2338. this.currentCharacterToken = {
  2339. type,
  2340. chars,
  2341. location: this.currentLocation
  2342. };
  2343. }
  2344. //Tag attributes
  2345. _createAttr(attrNameFirstCh) {
  2346. this.currentAttr = {
  2347. name: attrNameFirstCh,
  2348. value: ""
  2349. };
  2350. this.currentLocation = this.getCurrentLocation(0);
  2351. }
  2352. _leaveAttrName() {
  2353. var _a2;
  2354. var _b;
  2355. const token = this.currentToken;
  2356. if (getTokenAttr(token, this.currentAttr.name) === null) {
  2357. token.attrs.push(this.currentAttr);
  2358. if (token.location && this.currentLocation) {
  2359. const attrLocations = (_a2 = (_b = token.location).attrs) !== null && _a2 !== void 0 ? _a2 : _b.attrs = /* @__PURE__ */ Object.create(null);
  2360. attrLocations[this.currentAttr.name] = this.currentLocation;
  2361. this._leaveAttrValue();
  2362. }
  2363. } else {
  2364. this._err(ERR.duplicateAttribute);
  2365. }
  2366. }
  2367. _leaveAttrValue() {
  2368. if (this.currentLocation) {
  2369. this.currentLocation.endLine = this.preprocessor.line;
  2370. this.currentLocation.endCol = this.preprocessor.col;
  2371. this.currentLocation.endOffset = this.preprocessor.offset;
  2372. }
  2373. }
  2374. //Token emission
  2375. prepareToken(ct) {
  2376. this._emitCurrentCharacterToken(ct.location);
  2377. this.currentToken = null;
  2378. if (ct.location) {
  2379. ct.location.endLine = this.preprocessor.line;
  2380. ct.location.endCol = this.preprocessor.col + 1;
  2381. ct.location.endOffset = this.preprocessor.offset + 1;
  2382. }
  2383. this.currentLocation = this.getCurrentLocation(-1);
  2384. }
  2385. emitCurrentTagToken() {
  2386. const ct = this.currentToken;
  2387. this.prepareToken(ct);
  2388. ct.tagID = getTagID(ct.tagName);
  2389. if (ct.type === TokenType.START_TAG) {
  2390. this.lastStartTagName = ct.tagName;
  2391. this.handler.onStartTag(ct);
  2392. } else {
  2393. if (ct.attrs.length > 0) {
  2394. this._err(ERR.endTagWithAttributes);
  2395. }
  2396. if (ct.selfClosing) {
  2397. this._err(ERR.endTagWithTrailingSolidus);
  2398. }
  2399. this.handler.onEndTag(ct);
  2400. }
  2401. this.preprocessor.dropParsedChunk();
  2402. }
  2403. emitCurrentComment(ct) {
  2404. this.prepareToken(ct);
  2405. this.handler.onComment(ct);
  2406. this.preprocessor.dropParsedChunk();
  2407. }
  2408. emitCurrentDoctype(ct) {
  2409. this.prepareToken(ct);
  2410. this.handler.onDoctype(ct);
  2411. this.preprocessor.dropParsedChunk();
  2412. }
  2413. _emitCurrentCharacterToken(nextLocation) {
  2414. if (this.currentCharacterToken) {
  2415. if (nextLocation && this.currentCharacterToken.location) {
  2416. this.currentCharacterToken.location.endLine = nextLocation.startLine;
  2417. this.currentCharacterToken.location.endCol = nextLocation.startCol;
  2418. this.currentCharacterToken.location.endOffset = nextLocation.startOffset;
  2419. }
  2420. switch (this.currentCharacterToken.type) {
  2421. case TokenType.CHARACTER: {
  2422. this.handler.onCharacter(this.currentCharacterToken);
  2423. break;
  2424. }
  2425. case TokenType.NULL_CHARACTER: {
  2426. this.handler.onNullCharacter(this.currentCharacterToken);
  2427. break;
  2428. }
  2429. case TokenType.WHITESPACE_CHARACTER: {
  2430. this.handler.onWhitespaceCharacter(this.currentCharacterToken);
  2431. break;
  2432. }
  2433. }
  2434. this.currentCharacterToken = null;
  2435. }
  2436. }
  2437. _emitEOFToken() {
  2438. const location2 = this.getCurrentLocation(0);
  2439. if (location2) {
  2440. location2.endLine = location2.startLine;
  2441. location2.endCol = location2.startCol;
  2442. location2.endOffset = location2.startOffset;
  2443. }
  2444. this._emitCurrentCharacterToken(location2);
  2445. this.handler.onEof({ type: TokenType.EOF, location: location2 });
  2446. this.active = false;
  2447. }
  2448. //Characters emission
  2449. //OPTIMIZATION: specification uses only one type of character tokens (one token per character).
  2450. //This causes a huge memory overhead and a lot of unnecessary parser loops. parse5 uses 3 groups of characters.
  2451. //If we have a sequence of characters that belong to the same group, the parser can process it
  2452. //as a single solid character token.
  2453. //So, there are 3 types of character tokens in parse5:
  2454. //1)TokenType.NULL_CHARACTER - \u0000-character sequences (e.g. '\u0000\u0000\u0000')
  2455. //2)TokenType.WHITESPACE_CHARACTER - any whitespace/new-line character sequences (e.g. '\n \r\t \f')
  2456. //3)TokenType.CHARACTER - any character sequence which don't belong to groups 1 and 2 (e.g. 'abcdef1234@@#$%^')
  2457. _appendCharToCurrentCharacterToken(type, ch) {
  2458. if (this.currentCharacterToken) {
  2459. if (this.currentCharacterToken.type !== type) {
  2460. this.currentLocation = this.getCurrentLocation(0);
  2461. this._emitCurrentCharacterToken(this.currentLocation);
  2462. this.preprocessor.dropParsedChunk();
  2463. } else {
  2464. this.currentCharacterToken.chars += ch;
  2465. return;
  2466. }
  2467. }
  2468. this._createCharacterToken(type, ch);
  2469. }
  2470. _emitCodePoint(cp) {
  2471. const type = isWhitespace(cp) ? TokenType.WHITESPACE_CHARACTER : cp === CODE_POINTS.NULL ? TokenType.NULL_CHARACTER : TokenType.CHARACTER;
  2472. this._appendCharToCurrentCharacterToken(type, String.fromCodePoint(cp));
  2473. }
  2474. //NOTE: used when we emit characters explicitly.
  2475. //This is always for non-whitespace and non-null characters, which allows us to avoid additional checks.
  2476. _emitChars(ch) {
  2477. this._appendCharToCurrentCharacterToken(TokenType.CHARACTER, ch);
  2478. }
  2479. // Character reference helpers
  2480. _matchNamedCharacterReference(cp) {
  2481. let result = null;
  2482. let excess = 0;
  2483. let withoutSemicolon = false;
  2484. for (let i = 0, current = decode_data_html_default[0]; i >= 0; cp = this._consume()) {
  2485. i = determineBranch(decode_data_html_default, current, i + 1, cp);
  2486. if (i < 0)
  2487. break;
  2488. excess += 1;
  2489. current = decode_data_html_default[i];
  2490. const masked = current & BinTrieFlags.VALUE_LENGTH;
  2491. if (masked) {
  2492. const valueLength = (masked >> 14) - 1;
  2493. if (cp !== CODE_POINTS.SEMICOLON && this._isCharacterReferenceInAttribute() && isEntityInAttributeInvalidEnd2(this.preprocessor.peek(1))) {
  2494. result = [CODE_POINTS.AMPERSAND];
  2495. i += valueLength;
  2496. } else {
  2497. result = valueLength === 0 ? [decode_data_html_default[i] & ~BinTrieFlags.VALUE_LENGTH] : valueLength === 1 ? [decode_data_html_default[++i]] : [decode_data_html_default[++i], decode_data_html_default[++i]];
  2498. excess = 0;
  2499. withoutSemicolon = cp !== CODE_POINTS.SEMICOLON;
  2500. }
  2501. if (valueLength === 0) {
  2502. this._consume();
  2503. break;
  2504. }
  2505. }
  2506. }
  2507. this._unconsume(excess);
  2508. if (withoutSemicolon && !this.preprocessor.endOfChunkHit) {
  2509. this._err(ERR.missingSemicolonAfterCharacterReference);
  2510. }
  2511. this._unconsume(1);
  2512. return result;
  2513. }
  2514. _isCharacterReferenceInAttribute() {
  2515. return this.returnState === State.ATTRIBUTE_VALUE_DOUBLE_QUOTED || this.returnState === State.ATTRIBUTE_VALUE_SINGLE_QUOTED || this.returnState === State.ATTRIBUTE_VALUE_UNQUOTED;
  2516. }
  2517. _flushCodePointConsumedAsCharacterReference(cp) {
  2518. if (this._isCharacterReferenceInAttribute()) {
  2519. this.currentAttr.value += String.fromCodePoint(cp);
  2520. } else {
  2521. this._emitCodePoint(cp);
  2522. }
  2523. }
  2524. // Calling states this way turns out to be much faster than any other approach.
  2525. _callState(cp) {
  2526. switch (this.state) {
  2527. case State.DATA: {
  2528. this._stateData(cp);
  2529. break;
  2530. }
  2531. case State.RCDATA: {
  2532. this._stateRcdata(cp);
  2533. break;
  2534. }
  2535. case State.RAWTEXT: {
  2536. this._stateRawtext(cp);
  2537. break;
  2538. }
  2539. case State.SCRIPT_DATA: {
  2540. this._stateScriptData(cp);
  2541. break;
  2542. }
  2543. case State.PLAINTEXT: {
  2544. this._statePlaintext(cp);
  2545. break;
  2546. }
  2547. case State.TAG_OPEN: {
  2548. this._stateTagOpen(cp);
  2549. break;
  2550. }
  2551. case State.END_TAG_OPEN: {
  2552. this._stateEndTagOpen(cp);
  2553. break;
  2554. }
  2555. case State.TAG_NAME: {
  2556. this._stateTagName(cp);
  2557. break;
  2558. }
  2559. case State.RCDATA_LESS_THAN_SIGN: {
  2560. this._stateRcdataLessThanSign(cp);
  2561. break;
  2562. }
  2563. case State.RCDATA_END_TAG_OPEN: {
  2564. this._stateRcdataEndTagOpen(cp);
  2565. break;
  2566. }
  2567. case State.RCDATA_END_TAG_NAME: {
  2568. this._stateRcdataEndTagName(cp);
  2569. break;
  2570. }
  2571. case State.RAWTEXT_LESS_THAN_SIGN: {
  2572. this._stateRawtextLessThanSign(cp);
  2573. break;
  2574. }
  2575. case State.RAWTEXT_END_TAG_OPEN: {
  2576. this._stateRawtextEndTagOpen(cp);
  2577. break;
  2578. }
  2579. case State.RAWTEXT_END_TAG_NAME: {
  2580. this._stateRawtextEndTagName(cp);
  2581. break;
  2582. }
  2583. case State.SCRIPT_DATA_LESS_THAN_SIGN: {
  2584. this._stateScriptDataLessThanSign(cp);
  2585. break;
  2586. }
  2587. case State.SCRIPT_DATA_END_TAG_OPEN: {
  2588. this._stateScriptDataEndTagOpen(cp);
  2589. break;
  2590. }
  2591. case State.SCRIPT_DATA_END_TAG_NAME: {
  2592. this._stateScriptDataEndTagName(cp);
  2593. break;
  2594. }
  2595. case State.SCRIPT_DATA_ESCAPE_START: {
  2596. this._stateScriptDataEscapeStart(cp);
  2597. break;
  2598. }
  2599. case State.SCRIPT_DATA_ESCAPE_START_DASH: {
  2600. this._stateScriptDataEscapeStartDash(cp);
  2601. break;
  2602. }
  2603. case State.SCRIPT_DATA_ESCAPED: {
  2604. this._stateScriptDataEscaped(cp);
  2605. break;
  2606. }
  2607. case State.SCRIPT_DATA_ESCAPED_DASH: {
  2608. this._stateScriptDataEscapedDash(cp);
  2609. break;
  2610. }
  2611. case State.SCRIPT_DATA_ESCAPED_DASH_DASH: {
  2612. this._stateScriptDataEscapedDashDash(cp);
  2613. break;
  2614. }
  2615. case State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {
  2616. this._stateScriptDataEscapedLessThanSign(cp);
  2617. break;
  2618. }
  2619. case State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN: {
  2620. this._stateScriptDataEscapedEndTagOpen(cp);
  2621. break;
  2622. }
  2623. case State.SCRIPT_DATA_ESCAPED_END_TAG_NAME: {
  2624. this._stateScriptDataEscapedEndTagName(cp);
  2625. break;
  2626. }
  2627. case State.SCRIPT_DATA_DOUBLE_ESCAPE_START: {
  2628. this._stateScriptDataDoubleEscapeStart(cp);
  2629. break;
  2630. }
  2631. case State.SCRIPT_DATA_DOUBLE_ESCAPED: {
  2632. this._stateScriptDataDoubleEscaped(cp);
  2633. break;
  2634. }
  2635. case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH: {
  2636. this._stateScriptDataDoubleEscapedDash(cp);
  2637. break;
  2638. }
  2639. case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: {
  2640. this._stateScriptDataDoubleEscapedDashDash(cp);
  2641. break;
  2642. }
  2643. case State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: {
  2644. this._stateScriptDataDoubleEscapedLessThanSign(cp);
  2645. break;
  2646. }
  2647. case State.SCRIPT_DATA_DOUBLE_ESCAPE_END: {
  2648. this._stateScriptDataDoubleEscapeEnd(cp);
  2649. break;
  2650. }
  2651. case State.BEFORE_ATTRIBUTE_NAME: {
  2652. this._stateBeforeAttributeName(cp);
  2653. break;
  2654. }
  2655. case State.ATTRIBUTE_NAME: {
  2656. this._stateAttributeName(cp);
  2657. break;
  2658. }
  2659. case State.AFTER_ATTRIBUTE_NAME: {
  2660. this._stateAfterAttributeName(cp);
  2661. break;
  2662. }
  2663. case State.BEFORE_ATTRIBUTE_VALUE: {
  2664. this._stateBeforeAttributeValue(cp);
  2665. break;
  2666. }
  2667. case State.ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
  2668. this._stateAttributeValueDoubleQuoted(cp);
  2669. break;
  2670. }
  2671. case State.ATTRIBUTE_VALUE_SINGLE_QUOTED: {
  2672. this._stateAttributeValueSingleQuoted(cp);
  2673. break;
  2674. }
  2675. case State.ATTRIBUTE_VALUE_UNQUOTED: {
  2676. this._stateAttributeValueUnquoted(cp);
  2677. break;
  2678. }
  2679. case State.AFTER_ATTRIBUTE_VALUE_QUOTED: {
  2680. this._stateAfterAttributeValueQuoted(cp);
  2681. break;
  2682. }
  2683. case State.SELF_CLOSING_START_TAG: {
  2684. this._stateSelfClosingStartTag(cp);
  2685. break;
  2686. }
  2687. case State.BOGUS_COMMENT: {
  2688. this._stateBogusComment(cp);
  2689. break;
  2690. }
  2691. case State.MARKUP_DECLARATION_OPEN: {
  2692. this._stateMarkupDeclarationOpen(cp);
  2693. break;
  2694. }
  2695. case State.COMMENT_START: {
  2696. this._stateCommentStart(cp);
  2697. break;
  2698. }
  2699. case State.COMMENT_START_DASH: {
  2700. this._stateCommentStartDash(cp);
  2701. break;
  2702. }
  2703. case State.COMMENT: {
  2704. this._stateComment(cp);
  2705. break;
  2706. }
  2707. case State.COMMENT_LESS_THAN_SIGN: {
  2708. this._stateCommentLessThanSign(cp);
  2709. break;
  2710. }
  2711. case State.COMMENT_LESS_THAN_SIGN_BANG: {
  2712. this._stateCommentLessThanSignBang(cp);
  2713. break;
  2714. }
  2715. case State.COMMENT_LESS_THAN_SIGN_BANG_DASH: {
  2716. this._stateCommentLessThanSignBangDash(cp);
  2717. break;
  2718. }
  2719. case State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH: {
  2720. this._stateCommentLessThanSignBangDashDash(cp);
  2721. break;
  2722. }
  2723. case State.COMMENT_END_DASH: {
  2724. this._stateCommentEndDash(cp);
  2725. break;
  2726. }
  2727. case State.COMMENT_END: {
  2728. this._stateCommentEnd(cp);
  2729. break;
  2730. }
  2731. case State.COMMENT_END_BANG: {
  2732. this._stateCommentEndBang(cp);
  2733. break;
  2734. }
  2735. case State.DOCTYPE: {
  2736. this._stateDoctype(cp);
  2737. break;
  2738. }
  2739. case State.BEFORE_DOCTYPE_NAME: {
  2740. this._stateBeforeDoctypeName(cp);
  2741. break;
  2742. }
  2743. case State.DOCTYPE_NAME: {
  2744. this._stateDoctypeName(cp);
  2745. break;
  2746. }
  2747. case State.AFTER_DOCTYPE_NAME: {
  2748. this._stateAfterDoctypeName(cp);
  2749. break;
  2750. }
  2751. case State.AFTER_DOCTYPE_PUBLIC_KEYWORD: {
  2752. this._stateAfterDoctypePublicKeyword(cp);
  2753. break;
  2754. }
  2755. case State.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: {
  2756. this._stateBeforeDoctypePublicIdentifier(cp);
  2757. break;
  2758. }
  2759. case State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: {
  2760. this._stateDoctypePublicIdentifierDoubleQuoted(cp);
  2761. break;
  2762. }
  2763. case State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {
  2764. this._stateDoctypePublicIdentifierSingleQuoted(cp);
  2765. break;
  2766. }
  2767. case State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER: {
  2768. this._stateAfterDoctypePublicIdentifier(cp);
  2769. break;
  2770. }
  2771. case State.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {
  2772. this._stateBetweenDoctypePublicAndSystemIdentifiers(cp);
  2773. break;
  2774. }
  2775. case State.AFTER_DOCTYPE_SYSTEM_KEYWORD: {
  2776. this._stateAfterDoctypeSystemKeyword(cp);
  2777. break;
  2778. }
  2779. case State.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: {
  2780. this._stateBeforeDoctypeSystemIdentifier(cp);
  2781. break;
  2782. }
  2783. case State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: {
  2784. this._stateDoctypeSystemIdentifierDoubleQuoted(cp);
  2785. break;
  2786. }
  2787. case State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {
  2788. this._stateDoctypeSystemIdentifierSingleQuoted(cp);
  2789. break;
  2790. }
  2791. case State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {
  2792. this._stateAfterDoctypeSystemIdentifier(cp);
  2793. break;
  2794. }
  2795. case State.BOGUS_DOCTYPE: {
  2796. this._stateBogusDoctype(cp);
  2797. break;
  2798. }
  2799. case State.CDATA_SECTION: {
  2800. this._stateCdataSection(cp);
  2801. break;
  2802. }
  2803. case State.CDATA_SECTION_BRACKET: {
  2804. this._stateCdataSectionBracket(cp);
  2805. break;
  2806. }
  2807. case State.CDATA_SECTION_END: {
  2808. this._stateCdataSectionEnd(cp);
  2809. break;
  2810. }
  2811. case State.CHARACTER_REFERENCE: {
  2812. this._stateCharacterReference(cp);
  2813. break;
  2814. }
  2815. case State.NAMED_CHARACTER_REFERENCE: {
  2816. this._stateNamedCharacterReference(cp);
  2817. break;
  2818. }
  2819. case State.AMBIGUOUS_AMPERSAND: {
  2820. this._stateAmbiguousAmpersand(cp);
  2821. break;
  2822. }
  2823. case State.NUMERIC_CHARACTER_REFERENCE: {
  2824. this._stateNumericCharacterReference(cp);
  2825. break;
  2826. }
  2827. case State.HEXADEMICAL_CHARACTER_REFERENCE_START: {
  2828. this._stateHexademicalCharacterReferenceStart(cp);
  2829. break;
  2830. }
  2831. case State.HEXADEMICAL_CHARACTER_REFERENCE: {
  2832. this._stateHexademicalCharacterReference(cp);
  2833. break;
  2834. }
  2835. case State.DECIMAL_CHARACTER_REFERENCE: {
  2836. this._stateDecimalCharacterReference(cp);
  2837. break;
  2838. }
  2839. case State.NUMERIC_CHARACTER_REFERENCE_END: {
  2840. this._stateNumericCharacterReferenceEnd(cp);
  2841. break;
  2842. }
  2843. default: {
  2844. throw new Error("Unknown state");
  2845. }
  2846. }
  2847. }
  2848. // State machine
  2849. // Data state
  2850. //------------------------------------------------------------------
  2851. _stateData(cp) {
  2852. switch (cp) {
  2853. case CODE_POINTS.LESS_THAN_SIGN: {
  2854. this.state = State.TAG_OPEN;
  2855. break;
  2856. }
  2857. case CODE_POINTS.AMPERSAND: {
  2858. this.returnState = State.DATA;
  2859. this.state = State.CHARACTER_REFERENCE;
  2860. break;
  2861. }
  2862. case CODE_POINTS.NULL: {
  2863. this._err(ERR.unexpectedNullCharacter);
  2864. this._emitCodePoint(cp);
  2865. break;
  2866. }
  2867. case CODE_POINTS.EOF: {
  2868. this._emitEOFToken();
  2869. break;
  2870. }
  2871. default: {
  2872. this._emitCodePoint(cp);
  2873. }
  2874. }
  2875. }
  2876. // RCDATA state
  2877. //------------------------------------------------------------------
  2878. _stateRcdata(cp) {
  2879. switch (cp) {
  2880. case CODE_POINTS.AMPERSAND: {
  2881. this.returnState = State.RCDATA;
  2882. this.state = State.CHARACTER_REFERENCE;
  2883. break;
  2884. }
  2885. case CODE_POINTS.LESS_THAN_SIGN: {
  2886. this.state = State.RCDATA_LESS_THAN_SIGN;
  2887. break;
  2888. }
  2889. case CODE_POINTS.NULL: {
  2890. this._err(ERR.unexpectedNullCharacter);
  2891. this._emitChars(REPLACEMENT_CHARACTER);
  2892. break;
  2893. }
  2894. case CODE_POINTS.EOF: {
  2895. this._emitEOFToken();
  2896. break;
  2897. }
  2898. default: {
  2899. this._emitCodePoint(cp);
  2900. }
  2901. }
  2902. }
  2903. // RAWTEXT state
  2904. //------------------------------------------------------------------
  2905. _stateRawtext(cp) {
  2906. switch (cp) {
  2907. case CODE_POINTS.LESS_THAN_SIGN: {
  2908. this.state = State.RAWTEXT_LESS_THAN_SIGN;
  2909. break;
  2910. }
  2911. case CODE_POINTS.NULL: {
  2912. this._err(ERR.unexpectedNullCharacter);
  2913. this._emitChars(REPLACEMENT_CHARACTER);
  2914. break;
  2915. }
  2916. case CODE_POINTS.EOF: {
  2917. this._emitEOFToken();
  2918. break;
  2919. }
  2920. default: {
  2921. this._emitCodePoint(cp);
  2922. }
  2923. }
  2924. }
  2925. // Script data state
  2926. //------------------------------------------------------------------
  2927. _stateScriptData(cp) {
  2928. switch (cp) {
  2929. case CODE_POINTS.LESS_THAN_SIGN: {
  2930. this.state = State.SCRIPT_DATA_LESS_THAN_SIGN;
  2931. break;
  2932. }
  2933. case CODE_POINTS.NULL: {
  2934. this._err(ERR.unexpectedNullCharacter);
  2935. this._emitChars(REPLACEMENT_CHARACTER);
  2936. break;
  2937. }
  2938. case CODE_POINTS.EOF: {
  2939. this._emitEOFToken();
  2940. break;
  2941. }
  2942. default: {
  2943. this._emitCodePoint(cp);
  2944. }
  2945. }
  2946. }
  2947. // PLAINTEXT state
  2948. //------------------------------------------------------------------
  2949. _statePlaintext(cp) {
  2950. switch (cp) {
  2951. case CODE_POINTS.NULL: {
  2952. this._err(ERR.unexpectedNullCharacter);
  2953. this._emitChars(REPLACEMENT_CHARACTER);
  2954. break;
  2955. }
  2956. case CODE_POINTS.EOF: {
  2957. this._emitEOFToken();
  2958. break;
  2959. }
  2960. default: {
  2961. this._emitCodePoint(cp);
  2962. }
  2963. }
  2964. }
  2965. // Tag open state
  2966. //------------------------------------------------------------------
  2967. _stateTagOpen(cp) {
  2968. if (isAsciiLetter(cp)) {
  2969. this._createStartTagToken();
  2970. this.state = State.TAG_NAME;
  2971. this._stateTagName(cp);
  2972. } else
  2973. switch (cp) {
  2974. case CODE_POINTS.EXCLAMATION_MARK: {
  2975. this.state = State.MARKUP_DECLARATION_OPEN;
  2976. break;
  2977. }
  2978. case CODE_POINTS.SOLIDUS: {
  2979. this.state = State.END_TAG_OPEN;
  2980. break;
  2981. }
  2982. case CODE_POINTS.QUESTION_MARK: {
  2983. this._err(ERR.unexpectedQuestionMarkInsteadOfTagName);
  2984. this._createCommentToken(1);
  2985. this.state = State.BOGUS_COMMENT;
  2986. this._stateBogusComment(cp);
  2987. break;
  2988. }
  2989. case CODE_POINTS.EOF: {
  2990. this._err(ERR.eofBeforeTagName);
  2991. this._emitChars("<");
  2992. this._emitEOFToken();
  2993. break;
  2994. }
  2995. default: {
  2996. this._err(ERR.invalidFirstCharacterOfTagName);
  2997. this._emitChars("<");
  2998. this.state = State.DATA;
  2999. this._stateData(cp);
  3000. }
  3001. }
  3002. }
  3003. // End tag open state
  3004. //------------------------------------------------------------------
  3005. _stateEndTagOpen(cp) {
  3006. if (isAsciiLetter(cp)) {
  3007. this._createEndTagToken();
  3008. this.state = State.TAG_NAME;
  3009. this._stateTagName(cp);
  3010. } else
  3011. switch (cp) {
  3012. case CODE_POINTS.GREATER_THAN_SIGN: {
  3013. this._err(ERR.missingEndTagName);
  3014. this.state = State.DATA;
  3015. break;
  3016. }
  3017. case CODE_POINTS.EOF: {
  3018. this._err(ERR.eofBeforeTagName);
  3019. this._emitChars("</");
  3020. this._emitEOFToken();
  3021. break;
  3022. }
  3023. default: {
  3024. this._err(ERR.invalidFirstCharacterOfTagName);
  3025. this._createCommentToken(2);
  3026. this.state = State.BOGUS_COMMENT;
  3027. this._stateBogusComment(cp);
  3028. }
  3029. }
  3030. }
  3031. // Tag name state
  3032. //------------------------------------------------------------------
  3033. _stateTagName(cp) {
  3034. const token = this.currentToken;
  3035. switch (cp) {
  3036. case CODE_POINTS.SPACE:
  3037. case CODE_POINTS.LINE_FEED:
  3038. case CODE_POINTS.TABULATION:
  3039. case CODE_POINTS.FORM_FEED: {
  3040. this.state = State.BEFORE_ATTRIBUTE_NAME;
  3041. break;
  3042. }
  3043. case CODE_POINTS.SOLIDUS: {
  3044. this.state = State.SELF_CLOSING_START_TAG;
  3045. break;
  3046. }
  3047. case CODE_POINTS.GREATER_THAN_SIGN: {
  3048. this.state = State.DATA;
  3049. this.emitCurrentTagToken();
  3050. break;
  3051. }
  3052. case CODE_POINTS.NULL: {
  3053. this._err(ERR.unexpectedNullCharacter);
  3054. token.tagName += REPLACEMENT_CHARACTER;
  3055. break;
  3056. }
  3057. case CODE_POINTS.EOF: {
  3058. this._err(ERR.eofInTag);
  3059. this._emitEOFToken();
  3060. break;
  3061. }
  3062. default: {
  3063. token.tagName += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
  3064. }
  3065. }
  3066. }
  3067. // RCDATA less-than sign state
  3068. //------------------------------------------------------------------
  3069. _stateRcdataLessThanSign(cp) {
  3070. if (cp === CODE_POINTS.SOLIDUS) {
  3071. this.state = State.RCDATA_END_TAG_OPEN;
  3072. } else {
  3073. this._emitChars("<");
  3074. this.state = State.RCDATA;
  3075. this._stateRcdata(cp);
  3076. }
  3077. }
  3078. // RCDATA end tag open state
  3079. //------------------------------------------------------------------
  3080. _stateRcdataEndTagOpen(cp) {
  3081. if (isAsciiLetter(cp)) {
  3082. this.state = State.RCDATA_END_TAG_NAME;
  3083. this._stateRcdataEndTagName(cp);
  3084. } else {
  3085. this._emitChars("</");
  3086. this.state = State.RCDATA;
  3087. this._stateRcdata(cp);
  3088. }
  3089. }
  3090. handleSpecialEndTag(_cp) {
  3091. if (!this.preprocessor.startsWith(this.lastStartTagName, false)) {
  3092. return !this._ensureHibernation();
  3093. }
  3094. this._createEndTagToken();
  3095. const token = this.currentToken;
  3096. token.tagName = this.lastStartTagName;
  3097. const cp = this.preprocessor.peek(this.lastStartTagName.length);
  3098. switch (cp) {
  3099. case CODE_POINTS.SPACE:
  3100. case CODE_POINTS.LINE_FEED:
  3101. case CODE_POINTS.TABULATION:
  3102. case CODE_POINTS.FORM_FEED: {
  3103. this._advanceBy(this.lastStartTagName.length);
  3104. this.state = State.BEFORE_ATTRIBUTE_NAME;
  3105. return false;
  3106. }
  3107. case CODE_POINTS.SOLIDUS: {
  3108. this._advanceBy(this.lastStartTagName.length);
  3109. this.state = State.SELF_CLOSING_START_TAG;
  3110. return false;
  3111. }
  3112. case CODE_POINTS.GREATER_THAN_SIGN: {
  3113. this._advanceBy(this.lastStartTagName.length);
  3114. this.emitCurrentTagToken();
  3115. this.state = State.DATA;
  3116. return false;
  3117. }
  3118. default: {
  3119. return !this._ensureHibernation();
  3120. }
  3121. }
  3122. }
  3123. // RCDATA end tag name state
  3124. //------------------------------------------------------------------
  3125. _stateRcdataEndTagName(cp) {
  3126. if (this.handleSpecialEndTag(cp)) {
  3127. this._emitChars("</");
  3128. this.state = State.RCDATA;
  3129. this._stateRcdata(cp);
  3130. }
  3131. }
  3132. // RAWTEXT less-than sign state
  3133. //------------------------------------------------------------------
  3134. _stateRawtextLessThanSign(cp) {
  3135. if (cp === CODE_POINTS.SOLIDUS) {
  3136. this.state = State.RAWTEXT_END_TAG_OPEN;
  3137. } else {
  3138. this._emitChars("<");
  3139. this.state = State.RAWTEXT;
  3140. this._stateRawtext(cp);
  3141. }
  3142. }
  3143. // RAWTEXT end tag open state
  3144. //------------------------------------------------------------------
  3145. _stateRawtextEndTagOpen(cp) {
  3146. if (isAsciiLetter(cp)) {
  3147. this.state = State.RAWTEXT_END_TAG_NAME;
  3148. this._stateRawtextEndTagName(cp);
  3149. } else {
  3150. this._emitChars("</");
  3151. this.state = State.RAWTEXT;
  3152. this._stateRawtext(cp);
  3153. }
  3154. }
  3155. // RAWTEXT end tag name state
  3156. //------------------------------------------------------------------
  3157. _stateRawtextEndTagName(cp) {
  3158. if (this.handleSpecialEndTag(cp)) {
  3159. this._emitChars("</");
  3160. this.state = State.RAWTEXT;
  3161. this._stateRawtext(cp);
  3162. }
  3163. }
  3164. // Script data less-than sign state
  3165. //------------------------------------------------------------------
  3166. _stateScriptDataLessThanSign(cp) {
  3167. switch (cp) {
  3168. case CODE_POINTS.SOLIDUS: {
  3169. this.state = State.SCRIPT_DATA_END_TAG_OPEN;
  3170. break;
  3171. }
  3172. case CODE_POINTS.EXCLAMATION_MARK: {
  3173. this.state = State.SCRIPT_DATA_ESCAPE_START;
  3174. this._emitChars("<!");
  3175. break;
  3176. }
  3177. default: {
  3178. this._emitChars("<");
  3179. this.state = State.SCRIPT_DATA;
  3180. this._stateScriptData(cp);
  3181. }
  3182. }
  3183. }
  3184. // Script data end tag open state
  3185. //------------------------------------------------------------------
  3186. _stateScriptDataEndTagOpen(cp) {
  3187. if (isAsciiLetter(cp)) {
  3188. this.state = State.SCRIPT_DATA_END_TAG_NAME;
  3189. this._stateScriptDataEndTagName(cp);
  3190. } else {
  3191. this._emitChars("</");
  3192. this.state = State.SCRIPT_DATA;
  3193. this._stateScriptData(cp);
  3194. }
  3195. }
  3196. // Script data end tag name state
  3197. //------------------------------------------------------------------
  3198. _stateScriptDataEndTagName(cp) {
  3199. if (this.handleSpecialEndTag(cp)) {
  3200. this._emitChars("</");
  3201. this.state = State.SCRIPT_DATA;
  3202. this._stateScriptData(cp);
  3203. }
  3204. }
  3205. // Script data escape start state
  3206. //------------------------------------------------------------------
  3207. _stateScriptDataEscapeStart(cp) {
  3208. if (cp === CODE_POINTS.HYPHEN_MINUS) {
  3209. this.state = State.SCRIPT_DATA_ESCAPE_START_DASH;
  3210. this._emitChars("-");
  3211. } else {
  3212. this.state = State.SCRIPT_DATA;
  3213. this._stateScriptData(cp);
  3214. }
  3215. }
  3216. // Script data escape start dash state
  3217. //------------------------------------------------------------------
  3218. _stateScriptDataEscapeStartDash(cp) {
  3219. if (cp === CODE_POINTS.HYPHEN_MINUS) {
  3220. this.state = State.SCRIPT_DATA_ESCAPED_DASH_DASH;
  3221. this._emitChars("-");
  3222. } else {
  3223. this.state = State.SCRIPT_DATA;
  3224. this._stateScriptData(cp);
  3225. }
  3226. }
  3227. // Script data escaped state
  3228. //------------------------------------------------------------------
  3229. _stateScriptDataEscaped(cp) {
  3230. switch (cp) {
  3231. case CODE_POINTS.HYPHEN_MINUS: {
  3232. this.state = State.SCRIPT_DATA_ESCAPED_DASH;
  3233. this._emitChars("-");
  3234. break;
  3235. }
  3236. case CODE_POINTS.LESS_THAN_SIGN: {
  3237. this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
  3238. break;
  3239. }
  3240. case CODE_POINTS.NULL: {
  3241. this._err(ERR.unexpectedNullCharacter);
  3242. this._emitChars(REPLACEMENT_CHARACTER);
  3243. break;
  3244. }
  3245. case CODE_POINTS.EOF: {
  3246. this._err(ERR.eofInScriptHtmlCommentLikeText);
  3247. this._emitEOFToken();
  3248. break;
  3249. }
  3250. default: {
  3251. this._emitCodePoint(cp);
  3252. }
  3253. }
  3254. }
  3255. // Script data escaped dash state
  3256. //------------------------------------------------------------------
  3257. _stateScriptDataEscapedDash(cp) {
  3258. switch (cp) {
  3259. case CODE_POINTS.HYPHEN_MINUS: {
  3260. this.state = State.SCRIPT_DATA_ESCAPED_DASH_DASH;
  3261. this._emitChars("-");
  3262. break;
  3263. }
  3264. case CODE_POINTS.LESS_THAN_SIGN: {
  3265. this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
  3266. break;
  3267. }
  3268. case CODE_POINTS.NULL: {
  3269. this._err(ERR.unexpectedNullCharacter);
  3270. this.state = State.SCRIPT_DATA_ESCAPED;
  3271. this._emitChars(REPLACEMENT_CHARACTER);
  3272. break;
  3273. }
  3274. case CODE_POINTS.EOF: {
  3275. this._err(ERR.eofInScriptHtmlCommentLikeText);
  3276. this._emitEOFToken();
  3277. break;
  3278. }
  3279. default: {
  3280. this.state = State.SCRIPT_DATA_ESCAPED;
  3281. this._emitCodePoint(cp);
  3282. }
  3283. }
  3284. }
  3285. // Script data escaped dash dash state
  3286. //------------------------------------------------------------------
  3287. _stateScriptDataEscapedDashDash(cp) {
  3288. switch (cp) {
  3289. case CODE_POINTS.HYPHEN_MINUS: {
  3290. this._emitChars("-");
  3291. break;
  3292. }
  3293. case CODE_POINTS.LESS_THAN_SIGN: {
  3294. this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
  3295. break;
  3296. }
  3297. case CODE_POINTS.GREATER_THAN_SIGN: {
  3298. this.state = State.SCRIPT_DATA;
  3299. this._emitChars(">");
  3300. break;
  3301. }
  3302. case CODE_POINTS.NULL: {
  3303. this._err(ERR.unexpectedNullCharacter);
  3304. this.state = State.SCRIPT_DATA_ESCAPED;
  3305. this._emitChars(REPLACEMENT_CHARACTER);
  3306. break;
  3307. }
  3308. case CODE_POINTS.EOF: {
  3309. this._err(ERR.eofInScriptHtmlCommentLikeText);
  3310. this._emitEOFToken();
  3311. break;
  3312. }
  3313. default: {
  3314. this.state = State.SCRIPT_DATA_ESCAPED;
  3315. this._emitCodePoint(cp);
  3316. }
  3317. }
  3318. }
  3319. // Script data escaped less-than sign state
  3320. //------------------------------------------------------------------
  3321. _stateScriptDataEscapedLessThanSign(cp) {
  3322. if (cp === CODE_POINTS.SOLIDUS) {
  3323. this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN;
  3324. } else if (isAsciiLetter(cp)) {
  3325. this._emitChars("<");
  3326. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_START;
  3327. this._stateScriptDataDoubleEscapeStart(cp);
  3328. } else {
  3329. this._emitChars("<");
  3330. this.state = State.SCRIPT_DATA_ESCAPED;
  3331. this._stateScriptDataEscaped(cp);
  3332. }
  3333. }
  3334. // Script data escaped end tag open state
  3335. //------------------------------------------------------------------
  3336. _stateScriptDataEscapedEndTagOpen(cp) {
  3337. if (isAsciiLetter(cp)) {
  3338. this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_NAME;
  3339. this._stateScriptDataEscapedEndTagName(cp);
  3340. } else {
  3341. this._emitChars("</");
  3342. this.state = State.SCRIPT_DATA_ESCAPED;
  3343. this._stateScriptDataEscaped(cp);
  3344. }
  3345. }
  3346. // Script data escaped end tag name state
  3347. //------------------------------------------------------------------
  3348. _stateScriptDataEscapedEndTagName(cp) {
  3349. if (this.handleSpecialEndTag(cp)) {
  3350. this._emitChars("</");
  3351. this.state = State.SCRIPT_DATA_ESCAPED;
  3352. this._stateScriptDataEscaped(cp);
  3353. }
  3354. }
  3355. // Script data double escape start state
  3356. //------------------------------------------------------------------
  3357. _stateScriptDataDoubleEscapeStart(cp) {
  3358. if (this.preprocessor.startsWith(SEQUENCES.SCRIPT, false) && isScriptDataDoubleEscapeSequenceEnd(this.preprocessor.peek(SEQUENCES.SCRIPT.length))) {
  3359. this._emitCodePoint(cp);
  3360. for (let i = 0; i < SEQUENCES.SCRIPT.length; i++) {
  3361. this._emitCodePoint(this._consume());
  3362. }
  3363. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  3364. } else if (!this._ensureHibernation()) {
  3365. this.state = State.SCRIPT_DATA_ESCAPED;
  3366. this._stateScriptDataEscaped(cp);
  3367. }
  3368. }
  3369. // Script data double escaped state
  3370. //------------------------------------------------------------------
  3371. _stateScriptDataDoubleEscaped(cp) {
  3372. switch (cp) {
  3373. case CODE_POINTS.HYPHEN_MINUS: {
  3374. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH;
  3375. this._emitChars("-");
  3376. break;
  3377. }
  3378. case CODE_POINTS.LESS_THAN_SIGN: {
  3379. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
  3380. this._emitChars("<");
  3381. break;
  3382. }
  3383. case CODE_POINTS.NULL: {
  3384. this._err(ERR.unexpectedNullCharacter);
  3385. this._emitChars(REPLACEMENT_CHARACTER);
  3386. break;
  3387. }
  3388. case CODE_POINTS.EOF: {
  3389. this._err(ERR.eofInScriptHtmlCommentLikeText);
  3390. this._emitEOFToken();
  3391. break;
  3392. }
  3393. default: {
  3394. this._emitCodePoint(cp);
  3395. }
  3396. }
  3397. }
  3398. // Script data double escaped dash state
  3399. //------------------------------------------------------------------
  3400. _stateScriptDataDoubleEscapedDash(cp) {
  3401. switch (cp) {
  3402. case CODE_POINTS.HYPHEN_MINUS: {
  3403. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH;
  3404. this._emitChars("-");
  3405. break;
  3406. }
  3407. case CODE_POINTS.LESS_THAN_SIGN: {
  3408. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
  3409. this._emitChars("<");
  3410. break;
  3411. }
  3412. case CODE_POINTS.NULL: {
  3413. this._err(ERR.unexpectedNullCharacter);
  3414. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  3415. this._emitChars(REPLACEMENT_CHARACTER);
  3416. break;
  3417. }
  3418. case CODE_POINTS.EOF: {
  3419. this._err(ERR.eofInScriptHtmlCommentLikeText);
  3420. this._emitEOFToken();
  3421. break;
  3422. }
  3423. default: {
  3424. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  3425. this._emitCodePoint(cp);
  3426. }
  3427. }
  3428. }
  3429. // Script data double escaped dash dash state
  3430. //------------------------------------------------------------------
  3431. _stateScriptDataDoubleEscapedDashDash(cp) {
  3432. switch (cp) {
  3433. case CODE_POINTS.HYPHEN_MINUS: {
  3434. this._emitChars("-");
  3435. break;
  3436. }
  3437. case CODE_POINTS.LESS_THAN_SIGN: {
  3438. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
  3439. this._emitChars("<");
  3440. break;
  3441. }
  3442. case CODE_POINTS.GREATER_THAN_SIGN: {
  3443. this.state = State.SCRIPT_DATA;
  3444. this._emitChars(">");
  3445. break;
  3446. }
  3447. case CODE_POINTS.NULL: {
  3448. this._err(ERR.unexpectedNullCharacter);
  3449. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  3450. this._emitChars(REPLACEMENT_CHARACTER);
  3451. break;
  3452. }
  3453. case CODE_POINTS.EOF: {
  3454. this._err(ERR.eofInScriptHtmlCommentLikeText);
  3455. this._emitEOFToken();
  3456. break;
  3457. }
  3458. default: {
  3459. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  3460. this._emitCodePoint(cp);
  3461. }
  3462. }
  3463. }
  3464. // Script data double escaped less-than sign state
  3465. //------------------------------------------------------------------
  3466. _stateScriptDataDoubleEscapedLessThanSign(cp) {
  3467. if (cp === CODE_POINTS.SOLIDUS) {
  3468. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_END;
  3469. this._emitChars("/");
  3470. } else {
  3471. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  3472. this._stateScriptDataDoubleEscaped(cp);
  3473. }
  3474. }
  3475. // Script data double escape end state
  3476. //------------------------------------------------------------------
  3477. _stateScriptDataDoubleEscapeEnd(cp) {
  3478. if (this.preprocessor.startsWith(SEQUENCES.SCRIPT, false) && isScriptDataDoubleEscapeSequenceEnd(this.preprocessor.peek(SEQUENCES.SCRIPT.length))) {
  3479. this._emitCodePoint(cp);
  3480. for (let i = 0; i < SEQUENCES.SCRIPT.length; i++) {
  3481. this._emitCodePoint(this._consume());
  3482. }
  3483. this.state = State.SCRIPT_DATA_ESCAPED;
  3484. } else if (!this._ensureHibernation()) {
  3485. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  3486. this._stateScriptDataDoubleEscaped(cp);
  3487. }
  3488. }
  3489. // Before attribute name state
  3490. //------------------------------------------------------------------
  3491. _stateBeforeAttributeName(cp) {
  3492. switch (cp) {
  3493. case CODE_POINTS.SPACE:
  3494. case CODE_POINTS.LINE_FEED:
  3495. case CODE_POINTS.TABULATION:
  3496. case CODE_POINTS.FORM_FEED: {
  3497. break;
  3498. }
  3499. case CODE_POINTS.SOLIDUS:
  3500. case CODE_POINTS.GREATER_THAN_SIGN:
  3501. case CODE_POINTS.EOF: {
  3502. this.state = State.AFTER_ATTRIBUTE_NAME;
  3503. this._stateAfterAttributeName(cp);
  3504. break;
  3505. }
  3506. case CODE_POINTS.EQUALS_SIGN: {
  3507. this._err(ERR.unexpectedEqualsSignBeforeAttributeName);
  3508. this._createAttr("=");
  3509. this.state = State.ATTRIBUTE_NAME;
  3510. break;
  3511. }
  3512. default: {
  3513. this._createAttr("");
  3514. this.state = State.ATTRIBUTE_NAME;
  3515. this._stateAttributeName(cp);
  3516. }
  3517. }
  3518. }
  3519. // Attribute name state
  3520. //------------------------------------------------------------------
  3521. _stateAttributeName(cp) {
  3522. switch (cp) {
  3523. case CODE_POINTS.SPACE:
  3524. case CODE_POINTS.LINE_FEED:
  3525. case CODE_POINTS.TABULATION:
  3526. case CODE_POINTS.FORM_FEED:
  3527. case CODE_POINTS.SOLIDUS:
  3528. case CODE_POINTS.GREATER_THAN_SIGN:
  3529. case CODE_POINTS.EOF: {
  3530. this._leaveAttrName();
  3531. this.state = State.AFTER_ATTRIBUTE_NAME;
  3532. this._stateAfterAttributeName(cp);
  3533. break;
  3534. }
  3535. case CODE_POINTS.EQUALS_SIGN: {
  3536. this._leaveAttrName();
  3537. this.state = State.BEFORE_ATTRIBUTE_VALUE;
  3538. break;
  3539. }
  3540. case CODE_POINTS.QUOTATION_MARK:
  3541. case CODE_POINTS.APOSTROPHE:
  3542. case CODE_POINTS.LESS_THAN_SIGN: {
  3543. this._err(ERR.unexpectedCharacterInAttributeName);
  3544. this.currentAttr.name += String.fromCodePoint(cp);
  3545. break;
  3546. }
  3547. case CODE_POINTS.NULL: {
  3548. this._err(ERR.unexpectedNullCharacter);
  3549. this.currentAttr.name += REPLACEMENT_CHARACTER;
  3550. break;
  3551. }
  3552. default: {
  3553. this.currentAttr.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
  3554. }
  3555. }
  3556. }
  3557. // After attribute name state
  3558. //------------------------------------------------------------------
  3559. _stateAfterAttributeName(cp) {
  3560. switch (cp) {
  3561. case CODE_POINTS.SPACE:
  3562. case CODE_POINTS.LINE_FEED:
  3563. case CODE_POINTS.TABULATION:
  3564. case CODE_POINTS.FORM_FEED: {
  3565. break;
  3566. }
  3567. case CODE_POINTS.SOLIDUS: {
  3568. this.state = State.SELF_CLOSING_START_TAG;
  3569. break;
  3570. }
  3571. case CODE_POINTS.EQUALS_SIGN: {
  3572. this.state = State.BEFORE_ATTRIBUTE_VALUE;
  3573. break;
  3574. }
  3575. case CODE_POINTS.GREATER_THAN_SIGN: {
  3576. this.state = State.DATA;
  3577. this.emitCurrentTagToken();
  3578. break;
  3579. }
  3580. case CODE_POINTS.EOF: {
  3581. this._err(ERR.eofInTag);
  3582. this._emitEOFToken();
  3583. break;
  3584. }
  3585. default: {
  3586. this._createAttr("");
  3587. this.state = State.ATTRIBUTE_NAME;
  3588. this._stateAttributeName(cp);
  3589. }
  3590. }
  3591. }
  3592. // Before attribute value state
  3593. //------------------------------------------------------------------
  3594. _stateBeforeAttributeValue(cp) {
  3595. switch (cp) {
  3596. case CODE_POINTS.SPACE:
  3597. case CODE_POINTS.LINE_FEED:
  3598. case CODE_POINTS.TABULATION:
  3599. case CODE_POINTS.FORM_FEED: {
  3600. break;
  3601. }
  3602. case CODE_POINTS.QUOTATION_MARK: {
  3603. this.state = State.ATTRIBUTE_VALUE_DOUBLE_QUOTED;
  3604. break;
  3605. }
  3606. case CODE_POINTS.APOSTROPHE: {
  3607. this.state = State.ATTRIBUTE_VALUE_SINGLE_QUOTED;
  3608. break;
  3609. }
  3610. case CODE_POINTS.GREATER_THAN_SIGN: {
  3611. this._err(ERR.missingAttributeValue);
  3612. this.state = State.DATA;
  3613. this.emitCurrentTagToken();
  3614. break;
  3615. }
  3616. default: {
  3617. this.state = State.ATTRIBUTE_VALUE_UNQUOTED;
  3618. this._stateAttributeValueUnquoted(cp);
  3619. }
  3620. }
  3621. }
  3622. // Attribute value (double-quoted) state
  3623. //------------------------------------------------------------------
  3624. _stateAttributeValueDoubleQuoted(cp) {
  3625. switch (cp) {
  3626. case CODE_POINTS.QUOTATION_MARK: {
  3627. this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;
  3628. break;
  3629. }
  3630. case CODE_POINTS.AMPERSAND: {
  3631. this.returnState = State.ATTRIBUTE_VALUE_DOUBLE_QUOTED;
  3632. this.state = State.CHARACTER_REFERENCE;
  3633. break;
  3634. }
  3635. case CODE_POINTS.NULL: {
  3636. this._err(ERR.unexpectedNullCharacter);
  3637. this.currentAttr.value += REPLACEMENT_CHARACTER;
  3638. break;
  3639. }
  3640. case CODE_POINTS.EOF: {
  3641. this._err(ERR.eofInTag);
  3642. this._emitEOFToken();
  3643. break;
  3644. }
  3645. default: {
  3646. this.currentAttr.value += String.fromCodePoint(cp);
  3647. }
  3648. }
  3649. }
  3650. // Attribute value (single-quoted) state
  3651. //------------------------------------------------------------------
  3652. _stateAttributeValueSingleQuoted(cp) {
  3653. switch (cp) {
  3654. case CODE_POINTS.APOSTROPHE: {
  3655. this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;
  3656. break;
  3657. }
  3658. case CODE_POINTS.AMPERSAND: {
  3659. this.returnState = State.ATTRIBUTE_VALUE_SINGLE_QUOTED;
  3660. this.state = State.CHARACTER_REFERENCE;
  3661. break;
  3662. }
  3663. case CODE_POINTS.NULL: {
  3664. this._err(ERR.unexpectedNullCharacter);
  3665. this.currentAttr.value += REPLACEMENT_CHARACTER;
  3666. break;
  3667. }
  3668. case CODE_POINTS.EOF: {
  3669. this._err(ERR.eofInTag);
  3670. this._emitEOFToken();
  3671. break;
  3672. }
  3673. default: {
  3674. this.currentAttr.value += String.fromCodePoint(cp);
  3675. }
  3676. }
  3677. }
  3678. // Attribute value (unquoted) state
  3679. //------------------------------------------------------------------
  3680. _stateAttributeValueUnquoted(cp) {
  3681. switch (cp) {
  3682. case CODE_POINTS.SPACE:
  3683. case CODE_POINTS.LINE_FEED:
  3684. case CODE_POINTS.TABULATION:
  3685. case CODE_POINTS.FORM_FEED: {
  3686. this._leaveAttrValue();
  3687. this.state = State.BEFORE_ATTRIBUTE_NAME;
  3688. break;
  3689. }
  3690. case CODE_POINTS.AMPERSAND: {
  3691. this.returnState = State.ATTRIBUTE_VALUE_UNQUOTED;
  3692. this.state = State.CHARACTER_REFERENCE;
  3693. break;
  3694. }
  3695. case CODE_POINTS.GREATER_THAN_SIGN: {
  3696. this._leaveAttrValue();
  3697. this.state = State.DATA;
  3698. this.emitCurrentTagToken();
  3699. break;
  3700. }
  3701. case CODE_POINTS.NULL: {
  3702. this._err(ERR.unexpectedNullCharacter);
  3703. this.currentAttr.value += REPLACEMENT_CHARACTER;
  3704. break;
  3705. }
  3706. case CODE_POINTS.QUOTATION_MARK:
  3707. case CODE_POINTS.APOSTROPHE:
  3708. case CODE_POINTS.LESS_THAN_SIGN:
  3709. case CODE_POINTS.EQUALS_SIGN:
  3710. case CODE_POINTS.GRAVE_ACCENT: {
  3711. this._err(ERR.unexpectedCharacterInUnquotedAttributeValue);
  3712. this.currentAttr.value += String.fromCodePoint(cp);
  3713. break;
  3714. }
  3715. case CODE_POINTS.EOF: {
  3716. this._err(ERR.eofInTag);
  3717. this._emitEOFToken();
  3718. break;
  3719. }
  3720. default: {
  3721. this.currentAttr.value += String.fromCodePoint(cp);
  3722. }
  3723. }
  3724. }
  3725. // After attribute value (quoted) state
  3726. //------------------------------------------------------------------
  3727. _stateAfterAttributeValueQuoted(cp) {
  3728. switch (cp) {
  3729. case CODE_POINTS.SPACE:
  3730. case CODE_POINTS.LINE_FEED:
  3731. case CODE_POINTS.TABULATION:
  3732. case CODE_POINTS.FORM_FEED: {
  3733. this._leaveAttrValue();
  3734. this.state = State.BEFORE_ATTRIBUTE_NAME;
  3735. break;
  3736. }
  3737. case CODE_POINTS.SOLIDUS: {
  3738. this._leaveAttrValue();
  3739. this.state = State.SELF_CLOSING_START_TAG;
  3740. break;
  3741. }
  3742. case CODE_POINTS.GREATER_THAN_SIGN: {
  3743. this._leaveAttrValue();
  3744. this.state = State.DATA;
  3745. this.emitCurrentTagToken();
  3746. break;
  3747. }
  3748. case CODE_POINTS.EOF: {
  3749. this._err(ERR.eofInTag);
  3750. this._emitEOFToken();
  3751. break;
  3752. }
  3753. default: {
  3754. this._err(ERR.missingWhitespaceBetweenAttributes);
  3755. this.state = State.BEFORE_ATTRIBUTE_NAME;
  3756. this._stateBeforeAttributeName(cp);
  3757. }
  3758. }
  3759. }
  3760. // Self-closing start tag state
  3761. //------------------------------------------------------------------
  3762. _stateSelfClosingStartTag(cp) {
  3763. switch (cp) {
  3764. case CODE_POINTS.GREATER_THAN_SIGN: {
  3765. const token = this.currentToken;
  3766. token.selfClosing = true;
  3767. this.state = State.DATA;
  3768. this.emitCurrentTagToken();
  3769. break;
  3770. }
  3771. case CODE_POINTS.EOF: {
  3772. this._err(ERR.eofInTag);
  3773. this._emitEOFToken();
  3774. break;
  3775. }
  3776. default: {
  3777. this._err(ERR.unexpectedSolidusInTag);
  3778. this.state = State.BEFORE_ATTRIBUTE_NAME;
  3779. this._stateBeforeAttributeName(cp);
  3780. }
  3781. }
  3782. }
  3783. // Bogus comment state
  3784. //------------------------------------------------------------------
  3785. _stateBogusComment(cp) {
  3786. const token = this.currentToken;
  3787. switch (cp) {
  3788. case CODE_POINTS.GREATER_THAN_SIGN: {
  3789. this.state = State.DATA;
  3790. this.emitCurrentComment(token);
  3791. break;
  3792. }
  3793. case CODE_POINTS.EOF: {
  3794. this.emitCurrentComment(token);
  3795. this._emitEOFToken();
  3796. break;
  3797. }
  3798. case CODE_POINTS.NULL: {
  3799. this._err(ERR.unexpectedNullCharacter);
  3800. token.data += REPLACEMENT_CHARACTER;
  3801. break;
  3802. }
  3803. default: {
  3804. token.data += String.fromCodePoint(cp);
  3805. }
  3806. }
  3807. }
  3808. // Markup declaration open state
  3809. //------------------------------------------------------------------
  3810. _stateMarkupDeclarationOpen(cp) {
  3811. if (this._consumeSequenceIfMatch(SEQUENCES.DASH_DASH, true)) {
  3812. this._createCommentToken(SEQUENCES.DASH_DASH.length + 1);
  3813. this.state = State.COMMENT_START;
  3814. } else if (this._consumeSequenceIfMatch(SEQUENCES.DOCTYPE, false)) {
  3815. this.currentLocation = this.getCurrentLocation(SEQUENCES.DOCTYPE.length + 1);
  3816. this.state = State.DOCTYPE;
  3817. } else if (this._consumeSequenceIfMatch(SEQUENCES.CDATA_START, true)) {
  3818. if (this.inForeignNode) {
  3819. this.state = State.CDATA_SECTION;
  3820. } else {
  3821. this._err(ERR.cdataInHtmlContent);
  3822. this._createCommentToken(SEQUENCES.CDATA_START.length + 1);
  3823. this.currentToken.data = "[CDATA[";
  3824. this.state = State.BOGUS_COMMENT;
  3825. }
  3826. } else if (!this._ensureHibernation()) {
  3827. this._err(ERR.incorrectlyOpenedComment);
  3828. this._createCommentToken(2);
  3829. this.state = State.BOGUS_COMMENT;
  3830. this._stateBogusComment(cp);
  3831. }
  3832. }
  3833. // Comment start state
  3834. //------------------------------------------------------------------
  3835. _stateCommentStart(cp) {
  3836. switch (cp) {
  3837. case CODE_POINTS.HYPHEN_MINUS: {
  3838. this.state = State.COMMENT_START_DASH;
  3839. break;
  3840. }
  3841. case CODE_POINTS.GREATER_THAN_SIGN: {
  3842. this._err(ERR.abruptClosingOfEmptyComment);
  3843. this.state = State.DATA;
  3844. const token = this.currentToken;
  3845. this.emitCurrentComment(token);
  3846. break;
  3847. }
  3848. default: {
  3849. this.state = State.COMMENT;
  3850. this._stateComment(cp);
  3851. }
  3852. }
  3853. }
  3854. // Comment start dash state
  3855. //------------------------------------------------------------------
  3856. _stateCommentStartDash(cp) {
  3857. const token = this.currentToken;
  3858. switch (cp) {
  3859. case CODE_POINTS.HYPHEN_MINUS: {
  3860. this.state = State.COMMENT_END;
  3861. break;
  3862. }
  3863. case CODE_POINTS.GREATER_THAN_SIGN: {
  3864. this._err(ERR.abruptClosingOfEmptyComment);
  3865. this.state = State.DATA;
  3866. this.emitCurrentComment(token);
  3867. break;
  3868. }
  3869. case CODE_POINTS.EOF: {
  3870. this._err(ERR.eofInComment);
  3871. this.emitCurrentComment(token);
  3872. this._emitEOFToken();
  3873. break;
  3874. }
  3875. default: {
  3876. token.data += "-";
  3877. this.state = State.COMMENT;
  3878. this._stateComment(cp);
  3879. }
  3880. }
  3881. }
  3882. // Comment state
  3883. //------------------------------------------------------------------
  3884. _stateComment(cp) {
  3885. const token = this.currentToken;
  3886. switch (cp) {
  3887. case CODE_POINTS.HYPHEN_MINUS: {
  3888. this.state = State.COMMENT_END_DASH;
  3889. break;
  3890. }
  3891. case CODE_POINTS.LESS_THAN_SIGN: {
  3892. token.data += "<";
  3893. this.state = State.COMMENT_LESS_THAN_SIGN;
  3894. break;
  3895. }
  3896. case CODE_POINTS.NULL: {
  3897. this._err(ERR.unexpectedNullCharacter);
  3898. token.data += REPLACEMENT_CHARACTER;
  3899. break;
  3900. }
  3901. case CODE_POINTS.EOF: {
  3902. this._err(ERR.eofInComment);
  3903. this.emitCurrentComment(token);
  3904. this._emitEOFToken();
  3905. break;
  3906. }
  3907. default: {
  3908. token.data += String.fromCodePoint(cp);
  3909. }
  3910. }
  3911. }
  3912. // Comment less-than sign state
  3913. //------------------------------------------------------------------
  3914. _stateCommentLessThanSign(cp) {
  3915. const token = this.currentToken;
  3916. switch (cp) {
  3917. case CODE_POINTS.EXCLAMATION_MARK: {
  3918. token.data += "!";
  3919. this.state = State.COMMENT_LESS_THAN_SIGN_BANG;
  3920. break;
  3921. }
  3922. case CODE_POINTS.LESS_THAN_SIGN: {
  3923. token.data += "<";
  3924. break;
  3925. }
  3926. default: {
  3927. this.state = State.COMMENT;
  3928. this._stateComment(cp);
  3929. }
  3930. }
  3931. }
  3932. // Comment less-than sign bang state
  3933. //------------------------------------------------------------------
  3934. _stateCommentLessThanSignBang(cp) {
  3935. if (cp === CODE_POINTS.HYPHEN_MINUS) {
  3936. this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH;
  3937. } else {
  3938. this.state = State.COMMENT;
  3939. this._stateComment(cp);
  3940. }
  3941. }
  3942. // Comment less-than sign bang dash state
  3943. //------------------------------------------------------------------
  3944. _stateCommentLessThanSignBangDash(cp) {
  3945. if (cp === CODE_POINTS.HYPHEN_MINUS) {
  3946. this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH;
  3947. } else {
  3948. this.state = State.COMMENT_END_DASH;
  3949. this._stateCommentEndDash(cp);
  3950. }
  3951. }
  3952. // Comment less-than sign bang dash dash state
  3953. //------------------------------------------------------------------
  3954. _stateCommentLessThanSignBangDashDash(cp) {
  3955. if (cp !== CODE_POINTS.GREATER_THAN_SIGN && cp !== CODE_POINTS.EOF) {
  3956. this._err(ERR.nestedComment);
  3957. }
  3958. this.state = State.COMMENT_END;
  3959. this._stateCommentEnd(cp);
  3960. }
  3961. // Comment end dash state
  3962. //------------------------------------------------------------------
  3963. _stateCommentEndDash(cp) {
  3964. const token = this.currentToken;
  3965. switch (cp) {
  3966. case CODE_POINTS.HYPHEN_MINUS: {
  3967. this.state = State.COMMENT_END;
  3968. break;
  3969. }
  3970. case CODE_POINTS.EOF: {
  3971. this._err(ERR.eofInComment);
  3972. this.emitCurrentComment(token);
  3973. this._emitEOFToken();
  3974. break;
  3975. }
  3976. default: {
  3977. token.data += "-";
  3978. this.state = State.COMMENT;
  3979. this._stateComment(cp);
  3980. }
  3981. }
  3982. }
  3983. // Comment end state
  3984. //------------------------------------------------------------------
  3985. _stateCommentEnd(cp) {
  3986. const token = this.currentToken;
  3987. switch (cp) {
  3988. case CODE_POINTS.GREATER_THAN_SIGN: {
  3989. this.state = State.DATA;
  3990. this.emitCurrentComment(token);
  3991. break;
  3992. }
  3993. case CODE_POINTS.EXCLAMATION_MARK: {
  3994. this.state = State.COMMENT_END_BANG;
  3995. break;
  3996. }
  3997. case CODE_POINTS.HYPHEN_MINUS: {
  3998. token.data += "-";
  3999. break;
  4000. }
  4001. case CODE_POINTS.EOF: {
  4002. this._err(ERR.eofInComment);
  4003. this.emitCurrentComment(token);
  4004. this._emitEOFToken();
  4005. break;
  4006. }
  4007. default: {
  4008. token.data += "--";
  4009. this.state = State.COMMENT;
  4010. this._stateComment(cp);
  4011. }
  4012. }
  4013. }
  4014. // Comment end bang state
  4015. //------------------------------------------------------------------
  4016. _stateCommentEndBang(cp) {
  4017. const token = this.currentToken;
  4018. switch (cp) {
  4019. case CODE_POINTS.HYPHEN_MINUS: {
  4020. token.data += "--!";
  4021. this.state = State.COMMENT_END_DASH;
  4022. break;
  4023. }
  4024. case CODE_POINTS.GREATER_THAN_SIGN: {
  4025. this._err(ERR.incorrectlyClosedComment);
  4026. this.state = State.DATA;
  4027. this.emitCurrentComment(token);
  4028. break;
  4029. }
  4030. case CODE_POINTS.EOF: {
  4031. this._err(ERR.eofInComment);
  4032. this.emitCurrentComment(token);
  4033. this._emitEOFToken();
  4034. break;
  4035. }
  4036. default: {
  4037. token.data += "--!";
  4038. this.state = State.COMMENT;
  4039. this._stateComment(cp);
  4040. }
  4041. }
  4042. }
  4043. // DOCTYPE state
  4044. //------------------------------------------------------------------
  4045. _stateDoctype(cp) {
  4046. switch (cp) {
  4047. case CODE_POINTS.SPACE:
  4048. case CODE_POINTS.LINE_FEED:
  4049. case CODE_POINTS.TABULATION:
  4050. case CODE_POINTS.FORM_FEED: {
  4051. this.state = State.BEFORE_DOCTYPE_NAME;
  4052. break;
  4053. }
  4054. case CODE_POINTS.GREATER_THAN_SIGN: {
  4055. this.state = State.BEFORE_DOCTYPE_NAME;
  4056. this._stateBeforeDoctypeName(cp);
  4057. break;
  4058. }
  4059. case CODE_POINTS.EOF: {
  4060. this._err(ERR.eofInDoctype);
  4061. this._createDoctypeToken(null);
  4062. const token = this.currentToken;
  4063. token.forceQuirks = true;
  4064. this.emitCurrentDoctype(token);
  4065. this._emitEOFToken();
  4066. break;
  4067. }
  4068. default: {
  4069. this._err(ERR.missingWhitespaceBeforeDoctypeName);
  4070. this.state = State.BEFORE_DOCTYPE_NAME;
  4071. this._stateBeforeDoctypeName(cp);
  4072. }
  4073. }
  4074. }
  4075. // Before DOCTYPE name state
  4076. //------------------------------------------------------------------
  4077. _stateBeforeDoctypeName(cp) {
  4078. if (isAsciiUpper(cp)) {
  4079. this._createDoctypeToken(String.fromCharCode(toAsciiLower(cp)));
  4080. this.state = State.DOCTYPE_NAME;
  4081. } else
  4082. switch (cp) {
  4083. case CODE_POINTS.SPACE:
  4084. case CODE_POINTS.LINE_FEED:
  4085. case CODE_POINTS.TABULATION:
  4086. case CODE_POINTS.FORM_FEED: {
  4087. break;
  4088. }
  4089. case CODE_POINTS.NULL: {
  4090. this._err(ERR.unexpectedNullCharacter);
  4091. this._createDoctypeToken(REPLACEMENT_CHARACTER);
  4092. this.state = State.DOCTYPE_NAME;
  4093. break;
  4094. }
  4095. case CODE_POINTS.GREATER_THAN_SIGN: {
  4096. this._err(ERR.missingDoctypeName);
  4097. this._createDoctypeToken(null);
  4098. const token = this.currentToken;
  4099. token.forceQuirks = true;
  4100. this.emitCurrentDoctype(token);
  4101. this.state = State.DATA;
  4102. break;
  4103. }
  4104. case CODE_POINTS.EOF: {
  4105. this._err(ERR.eofInDoctype);
  4106. this._createDoctypeToken(null);
  4107. const token = this.currentToken;
  4108. token.forceQuirks = true;
  4109. this.emitCurrentDoctype(token);
  4110. this._emitEOFToken();
  4111. break;
  4112. }
  4113. default: {
  4114. this._createDoctypeToken(String.fromCodePoint(cp));
  4115. this.state = State.DOCTYPE_NAME;
  4116. }
  4117. }
  4118. }
  4119. // DOCTYPE name state
  4120. //------------------------------------------------------------------
  4121. _stateDoctypeName(cp) {
  4122. const token = this.currentToken;
  4123. switch (cp) {
  4124. case CODE_POINTS.SPACE:
  4125. case CODE_POINTS.LINE_FEED:
  4126. case CODE_POINTS.TABULATION:
  4127. case CODE_POINTS.FORM_FEED: {
  4128. this.state = State.AFTER_DOCTYPE_NAME;
  4129. break;
  4130. }
  4131. case CODE_POINTS.GREATER_THAN_SIGN: {
  4132. this.state = State.DATA;
  4133. this.emitCurrentDoctype(token);
  4134. break;
  4135. }
  4136. case CODE_POINTS.NULL: {
  4137. this._err(ERR.unexpectedNullCharacter);
  4138. token.name += REPLACEMENT_CHARACTER;
  4139. break;
  4140. }
  4141. case CODE_POINTS.EOF: {
  4142. this._err(ERR.eofInDoctype);
  4143. token.forceQuirks = true;
  4144. this.emitCurrentDoctype(token);
  4145. this._emitEOFToken();
  4146. break;
  4147. }
  4148. default: {
  4149. token.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
  4150. }
  4151. }
  4152. }
  4153. // After DOCTYPE name state
  4154. //------------------------------------------------------------------
  4155. _stateAfterDoctypeName(cp) {
  4156. const token = this.currentToken;
  4157. switch (cp) {
  4158. case CODE_POINTS.SPACE:
  4159. case CODE_POINTS.LINE_FEED:
  4160. case CODE_POINTS.TABULATION:
  4161. case CODE_POINTS.FORM_FEED: {
  4162. break;
  4163. }
  4164. case CODE_POINTS.GREATER_THAN_SIGN: {
  4165. this.state = State.DATA;
  4166. this.emitCurrentDoctype(token);
  4167. break;
  4168. }
  4169. case CODE_POINTS.EOF: {
  4170. this._err(ERR.eofInDoctype);
  4171. token.forceQuirks = true;
  4172. this.emitCurrentDoctype(token);
  4173. this._emitEOFToken();
  4174. break;
  4175. }
  4176. default: {
  4177. if (this._consumeSequenceIfMatch(SEQUENCES.PUBLIC, false)) {
  4178. this.state = State.AFTER_DOCTYPE_PUBLIC_KEYWORD;
  4179. } else if (this._consumeSequenceIfMatch(SEQUENCES.SYSTEM, false)) {
  4180. this.state = State.AFTER_DOCTYPE_SYSTEM_KEYWORD;
  4181. } else if (!this._ensureHibernation()) {
  4182. this._err(ERR.invalidCharacterSequenceAfterDoctypeName);
  4183. token.forceQuirks = true;
  4184. this.state = State.BOGUS_DOCTYPE;
  4185. this._stateBogusDoctype(cp);
  4186. }
  4187. }
  4188. }
  4189. }
  4190. // After DOCTYPE public keyword state
  4191. //------------------------------------------------------------------
  4192. _stateAfterDoctypePublicKeyword(cp) {
  4193. const token = this.currentToken;
  4194. switch (cp) {
  4195. case CODE_POINTS.SPACE:
  4196. case CODE_POINTS.LINE_FEED:
  4197. case CODE_POINTS.TABULATION:
  4198. case CODE_POINTS.FORM_FEED: {
  4199. this.state = State.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;
  4200. break;
  4201. }
  4202. case CODE_POINTS.QUOTATION_MARK: {
  4203. this._err(ERR.missingWhitespaceAfterDoctypePublicKeyword);
  4204. token.publicId = "";
  4205. this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;
  4206. break;
  4207. }
  4208. case CODE_POINTS.APOSTROPHE: {
  4209. this._err(ERR.missingWhitespaceAfterDoctypePublicKeyword);
  4210. token.publicId = "";
  4211. this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;
  4212. break;
  4213. }
  4214. case CODE_POINTS.GREATER_THAN_SIGN: {
  4215. this._err(ERR.missingDoctypePublicIdentifier);
  4216. token.forceQuirks = true;
  4217. this.state = State.DATA;
  4218. this.emitCurrentDoctype(token);
  4219. break;
  4220. }
  4221. case CODE_POINTS.EOF: {
  4222. this._err(ERR.eofInDoctype);
  4223. token.forceQuirks = true;
  4224. this.emitCurrentDoctype(token);
  4225. this._emitEOFToken();
  4226. break;
  4227. }
  4228. default: {
  4229. this._err(ERR.missingQuoteBeforeDoctypePublicIdentifier);
  4230. token.forceQuirks = true;
  4231. this.state = State.BOGUS_DOCTYPE;
  4232. this._stateBogusDoctype(cp);
  4233. }
  4234. }
  4235. }
  4236. // Before DOCTYPE public identifier state
  4237. //------------------------------------------------------------------
  4238. _stateBeforeDoctypePublicIdentifier(cp) {
  4239. const token = this.currentToken;
  4240. switch (cp) {
  4241. case CODE_POINTS.SPACE:
  4242. case CODE_POINTS.LINE_FEED:
  4243. case CODE_POINTS.TABULATION:
  4244. case CODE_POINTS.FORM_FEED: {
  4245. break;
  4246. }
  4247. case CODE_POINTS.QUOTATION_MARK: {
  4248. token.publicId = "";
  4249. this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;
  4250. break;
  4251. }
  4252. case CODE_POINTS.APOSTROPHE: {
  4253. token.publicId = "";
  4254. this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;
  4255. break;
  4256. }
  4257. case CODE_POINTS.GREATER_THAN_SIGN: {
  4258. this._err(ERR.missingDoctypePublicIdentifier);
  4259. token.forceQuirks = true;
  4260. this.state = State.DATA;
  4261. this.emitCurrentDoctype(token);
  4262. break;
  4263. }
  4264. case CODE_POINTS.EOF: {
  4265. this._err(ERR.eofInDoctype);
  4266. token.forceQuirks = true;
  4267. this.emitCurrentDoctype(token);
  4268. this._emitEOFToken();
  4269. break;
  4270. }
  4271. default: {
  4272. this._err(ERR.missingQuoteBeforeDoctypePublicIdentifier);
  4273. token.forceQuirks = true;
  4274. this.state = State.BOGUS_DOCTYPE;
  4275. this._stateBogusDoctype(cp);
  4276. }
  4277. }
  4278. }
  4279. // DOCTYPE public identifier (double-quoted) state
  4280. //------------------------------------------------------------------
  4281. _stateDoctypePublicIdentifierDoubleQuoted(cp) {
  4282. const token = this.currentToken;
  4283. switch (cp) {
  4284. case CODE_POINTS.QUOTATION_MARK: {
  4285. this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
  4286. break;
  4287. }
  4288. case CODE_POINTS.NULL: {
  4289. this._err(ERR.unexpectedNullCharacter);
  4290. token.publicId += REPLACEMENT_CHARACTER;
  4291. break;
  4292. }
  4293. case CODE_POINTS.GREATER_THAN_SIGN: {
  4294. this._err(ERR.abruptDoctypePublicIdentifier);
  4295. token.forceQuirks = true;
  4296. this.emitCurrentDoctype(token);
  4297. this.state = State.DATA;
  4298. break;
  4299. }
  4300. case CODE_POINTS.EOF: {
  4301. this._err(ERR.eofInDoctype);
  4302. token.forceQuirks = true;
  4303. this.emitCurrentDoctype(token);
  4304. this._emitEOFToken();
  4305. break;
  4306. }
  4307. default: {
  4308. token.publicId += String.fromCodePoint(cp);
  4309. }
  4310. }
  4311. }
  4312. // DOCTYPE public identifier (single-quoted) state
  4313. //------------------------------------------------------------------
  4314. _stateDoctypePublicIdentifierSingleQuoted(cp) {
  4315. const token = this.currentToken;
  4316. switch (cp) {
  4317. case CODE_POINTS.APOSTROPHE: {
  4318. this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
  4319. break;
  4320. }
  4321. case CODE_POINTS.NULL: {
  4322. this._err(ERR.unexpectedNullCharacter);
  4323. token.publicId += REPLACEMENT_CHARACTER;
  4324. break;
  4325. }
  4326. case CODE_POINTS.GREATER_THAN_SIGN: {
  4327. this._err(ERR.abruptDoctypePublicIdentifier);
  4328. token.forceQuirks = true;
  4329. this.emitCurrentDoctype(token);
  4330. this.state = State.DATA;
  4331. break;
  4332. }
  4333. case CODE_POINTS.EOF: {
  4334. this._err(ERR.eofInDoctype);
  4335. token.forceQuirks = true;
  4336. this.emitCurrentDoctype(token);
  4337. this._emitEOFToken();
  4338. break;
  4339. }
  4340. default: {
  4341. token.publicId += String.fromCodePoint(cp);
  4342. }
  4343. }
  4344. }
  4345. // After DOCTYPE public identifier state
  4346. //------------------------------------------------------------------
  4347. _stateAfterDoctypePublicIdentifier(cp) {
  4348. const token = this.currentToken;
  4349. switch (cp) {
  4350. case CODE_POINTS.SPACE:
  4351. case CODE_POINTS.LINE_FEED:
  4352. case CODE_POINTS.TABULATION:
  4353. case CODE_POINTS.FORM_FEED: {
  4354. this.state = State.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;
  4355. break;
  4356. }
  4357. case CODE_POINTS.GREATER_THAN_SIGN: {
  4358. this.state = State.DATA;
  4359. this.emitCurrentDoctype(token);
  4360. break;
  4361. }
  4362. case CODE_POINTS.QUOTATION_MARK: {
  4363. this._err(ERR.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers);
  4364. token.systemId = "";
  4365. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
  4366. break;
  4367. }
  4368. case CODE_POINTS.APOSTROPHE: {
  4369. this._err(ERR.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers);
  4370. token.systemId = "";
  4371. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
  4372. break;
  4373. }
  4374. case CODE_POINTS.EOF: {
  4375. this._err(ERR.eofInDoctype);
  4376. token.forceQuirks = true;
  4377. this.emitCurrentDoctype(token);
  4378. this._emitEOFToken();
  4379. break;
  4380. }
  4381. default: {
  4382. this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
  4383. token.forceQuirks = true;
  4384. this.state = State.BOGUS_DOCTYPE;
  4385. this._stateBogusDoctype(cp);
  4386. }
  4387. }
  4388. }
  4389. // Between DOCTYPE public and system identifiers state
  4390. //------------------------------------------------------------------
  4391. _stateBetweenDoctypePublicAndSystemIdentifiers(cp) {
  4392. const token = this.currentToken;
  4393. switch (cp) {
  4394. case CODE_POINTS.SPACE:
  4395. case CODE_POINTS.LINE_FEED:
  4396. case CODE_POINTS.TABULATION:
  4397. case CODE_POINTS.FORM_FEED: {
  4398. break;
  4399. }
  4400. case CODE_POINTS.GREATER_THAN_SIGN: {
  4401. this.emitCurrentDoctype(token);
  4402. this.state = State.DATA;
  4403. break;
  4404. }
  4405. case CODE_POINTS.QUOTATION_MARK: {
  4406. token.systemId = "";
  4407. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
  4408. break;
  4409. }
  4410. case CODE_POINTS.APOSTROPHE: {
  4411. token.systemId = "";
  4412. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
  4413. break;
  4414. }
  4415. case CODE_POINTS.EOF: {
  4416. this._err(ERR.eofInDoctype);
  4417. token.forceQuirks = true;
  4418. this.emitCurrentDoctype(token);
  4419. this._emitEOFToken();
  4420. break;
  4421. }
  4422. default: {
  4423. this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
  4424. token.forceQuirks = true;
  4425. this.state = State.BOGUS_DOCTYPE;
  4426. this._stateBogusDoctype(cp);
  4427. }
  4428. }
  4429. }
  4430. // After DOCTYPE system keyword state
  4431. //------------------------------------------------------------------
  4432. _stateAfterDoctypeSystemKeyword(cp) {
  4433. const token = this.currentToken;
  4434. switch (cp) {
  4435. case CODE_POINTS.SPACE:
  4436. case CODE_POINTS.LINE_FEED:
  4437. case CODE_POINTS.TABULATION:
  4438. case CODE_POINTS.FORM_FEED: {
  4439. this.state = State.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;
  4440. break;
  4441. }
  4442. case CODE_POINTS.QUOTATION_MARK: {
  4443. this._err(ERR.missingWhitespaceAfterDoctypeSystemKeyword);
  4444. token.systemId = "";
  4445. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
  4446. break;
  4447. }
  4448. case CODE_POINTS.APOSTROPHE: {
  4449. this._err(ERR.missingWhitespaceAfterDoctypeSystemKeyword);
  4450. token.systemId = "";
  4451. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
  4452. break;
  4453. }
  4454. case CODE_POINTS.GREATER_THAN_SIGN: {
  4455. this._err(ERR.missingDoctypeSystemIdentifier);
  4456. token.forceQuirks = true;
  4457. this.state = State.DATA;
  4458. this.emitCurrentDoctype(token);
  4459. break;
  4460. }
  4461. case CODE_POINTS.EOF: {
  4462. this._err(ERR.eofInDoctype);
  4463. token.forceQuirks = true;
  4464. this.emitCurrentDoctype(token);
  4465. this._emitEOFToken();
  4466. break;
  4467. }
  4468. default: {
  4469. this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
  4470. token.forceQuirks = true;
  4471. this.state = State.BOGUS_DOCTYPE;
  4472. this._stateBogusDoctype(cp);
  4473. }
  4474. }
  4475. }
  4476. // Before DOCTYPE system identifier state
  4477. //------------------------------------------------------------------
  4478. _stateBeforeDoctypeSystemIdentifier(cp) {
  4479. const token = this.currentToken;
  4480. switch (cp) {
  4481. case CODE_POINTS.SPACE:
  4482. case CODE_POINTS.LINE_FEED:
  4483. case CODE_POINTS.TABULATION:
  4484. case CODE_POINTS.FORM_FEED: {
  4485. break;
  4486. }
  4487. case CODE_POINTS.QUOTATION_MARK: {
  4488. token.systemId = "";
  4489. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
  4490. break;
  4491. }
  4492. case CODE_POINTS.APOSTROPHE: {
  4493. token.systemId = "";
  4494. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
  4495. break;
  4496. }
  4497. case CODE_POINTS.GREATER_THAN_SIGN: {
  4498. this._err(ERR.missingDoctypeSystemIdentifier);
  4499. token.forceQuirks = true;
  4500. this.state = State.DATA;
  4501. this.emitCurrentDoctype(token);
  4502. break;
  4503. }
  4504. case CODE_POINTS.EOF: {
  4505. this._err(ERR.eofInDoctype);
  4506. token.forceQuirks = true;
  4507. this.emitCurrentDoctype(token);
  4508. this._emitEOFToken();
  4509. break;
  4510. }
  4511. default: {
  4512. this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
  4513. token.forceQuirks = true;
  4514. this.state = State.BOGUS_DOCTYPE;
  4515. this._stateBogusDoctype(cp);
  4516. }
  4517. }
  4518. }
  4519. // DOCTYPE system identifier (double-quoted) state
  4520. //------------------------------------------------------------------
  4521. _stateDoctypeSystemIdentifierDoubleQuoted(cp) {
  4522. const token = this.currentToken;
  4523. switch (cp) {
  4524. case CODE_POINTS.QUOTATION_MARK: {
  4525. this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
  4526. break;
  4527. }
  4528. case CODE_POINTS.NULL: {
  4529. this._err(ERR.unexpectedNullCharacter);
  4530. token.systemId += REPLACEMENT_CHARACTER;
  4531. break;
  4532. }
  4533. case CODE_POINTS.GREATER_THAN_SIGN: {
  4534. this._err(ERR.abruptDoctypeSystemIdentifier);
  4535. token.forceQuirks = true;
  4536. this.emitCurrentDoctype(token);
  4537. this.state = State.DATA;
  4538. break;
  4539. }
  4540. case CODE_POINTS.EOF: {
  4541. this._err(ERR.eofInDoctype);
  4542. token.forceQuirks = true;
  4543. this.emitCurrentDoctype(token);
  4544. this._emitEOFToken();
  4545. break;
  4546. }
  4547. default: {
  4548. token.systemId += String.fromCodePoint(cp);
  4549. }
  4550. }
  4551. }
  4552. // DOCTYPE system identifier (single-quoted) state
  4553. //------------------------------------------------------------------
  4554. _stateDoctypeSystemIdentifierSingleQuoted(cp) {
  4555. const token = this.currentToken;
  4556. switch (cp) {
  4557. case CODE_POINTS.APOSTROPHE: {
  4558. this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
  4559. break;
  4560. }
  4561. case CODE_POINTS.NULL: {
  4562. this._err(ERR.unexpectedNullCharacter);
  4563. token.systemId += REPLACEMENT_CHARACTER;
  4564. break;
  4565. }
  4566. case CODE_POINTS.GREATER_THAN_SIGN: {
  4567. this._err(ERR.abruptDoctypeSystemIdentifier);
  4568. token.forceQuirks = true;
  4569. this.emitCurrentDoctype(token);
  4570. this.state = State.DATA;
  4571. break;
  4572. }
  4573. case CODE_POINTS.EOF: {
  4574. this._err(ERR.eofInDoctype);
  4575. token.forceQuirks = true;
  4576. this.emitCurrentDoctype(token);
  4577. this._emitEOFToken();
  4578. break;
  4579. }
  4580. default: {
  4581. token.systemId += String.fromCodePoint(cp);
  4582. }
  4583. }
  4584. }
  4585. // After DOCTYPE system identifier state
  4586. //------------------------------------------------------------------
  4587. _stateAfterDoctypeSystemIdentifier(cp) {
  4588. const token = this.currentToken;
  4589. switch (cp) {
  4590. case CODE_POINTS.SPACE:
  4591. case CODE_POINTS.LINE_FEED:
  4592. case CODE_POINTS.TABULATION:
  4593. case CODE_POINTS.FORM_FEED: {
  4594. break;
  4595. }
  4596. case CODE_POINTS.GREATER_THAN_SIGN: {
  4597. this.emitCurrentDoctype(token);
  4598. this.state = State.DATA;
  4599. break;
  4600. }
  4601. case CODE_POINTS.EOF: {
  4602. this._err(ERR.eofInDoctype);
  4603. token.forceQuirks = true;
  4604. this.emitCurrentDoctype(token);
  4605. this._emitEOFToken();
  4606. break;
  4607. }
  4608. default: {
  4609. this._err(ERR.unexpectedCharacterAfterDoctypeSystemIdentifier);
  4610. this.state = State.BOGUS_DOCTYPE;
  4611. this._stateBogusDoctype(cp);
  4612. }
  4613. }
  4614. }
  4615. // Bogus DOCTYPE state
  4616. //------------------------------------------------------------------
  4617. _stateBogusDoctype(cp) {
  4618. const token = this.currentToken;
  4619. switch (cp) {
  4620. case CODE_POINTS.GREATER_THAN_SIGN: {
  4621. this.emitCurrentDoctype(token);
  4622. this.state = State.DATA;
  4623. break;
  4624. }
  4625. case CODE_POINTS.NULL: {
  4626. this._err(ERR.unexpectedNullCharacter);
  4627. break;
  4628. }
  4629. case CODE_POINTS.EOF: {
  4630. this.emitCurrentDoctype(token);
  4631. this._emitEOFToken();
  4632. break;
  4633. }
  4634. default:
  4635. }
  4636. }
  4637. // CDATA section state
  4638. //------------------------------------------------------------------
  4639. _stateCdataSection(cp) {
  4640. switch (cp) {
  4641. case CODE_POINTS.RIGHT_SQUARE_BRACKET: {
  4642. this.state = State.CDATA_SECTION_BRACKET;
  4643. break;
  4644. }
  4645. case CODE_POINTS.EOF: {
  4646. this._err(ERR.eofInCdata);
  4647. this._emitEOFToken();
  4648. break;
  4649. }
  4650. default: {
  4651. this._emitCodePoint(cp);
  4652. }
  4653. }
  4654. }
  4655. // CDATA section bracket state
  4656. //------------------------------------------------------------------
  4657. _stateCdataSectionBracket(cp) {
  4658. if (cp === CODE_POINTS.RIGHT_SQUARE_BRACKET) {
  4659. this.state = State.CDATA_SECTION_END;
  4660. } else {
  4661. this._emitChars("]");
  4662. this.state = State.CDATA_SECTION;
  4663. this._stateCdataSection(cp);
  4664. }
  4665. }
  4666. // CDATA section end state
  4667. //------------------------------------------------------------------
  4668. _stateCdataSectionEnd(cp) {
  4669. switch (cp) {
  4670. case CODE_POINTS.GREATER_THAN_SIGN: {
  4671. this.state = State.DATA;
  4672. break;
  4673. }
  4674. case CODE_POINTS.RIGHT_SQUARE_BRACKET: {
  4675. this._emitChars("]");
  4676. break;
  4677. }
  4678. default: {
  4679. this._emitChars("]]");
  4680. this.state = State.CDATA_SECTION;
  4681. this._stateCdataSection(cp);
  4682. }
  4683. }
  4684. }
  4685. // Character reference state
  4686. //------------------------------------------------------------------
  4687. _stateCharacterReference(cp) {
  4688. if (cp === CODE_POINTS.NUMBER_SIGN) {
  4689. this.state = State.NUMERIC_CHARACTER_REFERENCE;
  4690. } else if (isAsciiAlphaNumeric2(cp)) {
  4691. this.state = State.NAMED_CHARACTER_REFERENCE;
  4692. this._stateNamedCharacterReference(cp);
  4693. } else {
  4694. this._flushCodePointConsumedAsCharacterReference(CODE_POINTS.AMPERSAND);
  4695. this._reconsumeInState(this.returnState, cp);
  4696. }
  4697. }
  4698. // Named character reference state
  4699. //------------------------------------------------------------------
  4700. _stateNamedCharacterReference(cp) {
  4701. const matchResult = this._matchNamedCharacterReference(cp);
  4702. if (this._ensureHibernation()) {
  4703. } else if (matchResult) {
  4704. for (let i = 0; i < matchResult.length; i++) {
  4705. this._flushCodePointConsumedAsCharacterReference(matchResult[i]);
  4706. }
  4707. this.state = this.returnState;
  4708. } else {
  4709. this._flushCodePointConsumedAsCharacterReference(CODE_POINTS.AMPERSAND);
  4710. this.state = State.AMBIGUOUS_AMPERSAND;
  4711. }
  4712. }
  4713. // Ambiguos ampersand state
  4714. //------------------------------------------------------------------
  4715. _stateAmbiguousAmpersand(cp) {
  4716. if (isAsciiAlphaNumeric2(cp)) {
  4717. this._flushCodePointConsumedAsCharacterReference(cp);
  4718. } else {
  4719. if (cp === CODE_POINTS.SEMICOLON) {
  4720. this._err(ERR.unknownNamedCharacterReference);
  4721. }
  4722. this._reconsumeInState(this.returnState, cp);
  4723. }
  4724. }
  4725. // Numeric character reference state
  4726. //------------------------------------------------------------------
  4727. _stateNumericCharacterReference(cp) {
  4728. this.charRefCode = 0;
  4729. if (cp === CODE_POINTS.LATIN_SMALL_X || cp === CODE_POINTS.LATIN_CAPITAL_X) {
  4730. this.state = State.HEXADEMICAL_CHARACTER_REFERENCE_START;
  4731. } else if (isAsciiDigit(cp)) {
  4732. this.state = State.DECIMAL_CHARACTER_REFERENCE;
  4733. this._stateDecimalCharacterReference(cp);
  4734. } else {
  4735. this._err(ERR.absenceOfDigitsInNumericCharacterReference);
  4736. this._flushCodePointConsumedAsCharacterReference(CODE_POINTS.AMPERSAND);
  4737. this._flushCodePointConsumedAsCharacterReference(CODE_POINTS.NUMBER_SIGN);
  4738. this._reconsumeInState(this.returnState, cp);
  4739. }
  4740. }
  4741. // Hexademical character reference start state
  4742. //------------------------------------------------------------------
  4743. _stateHexademicalCharacterReferenceStart(cp) {
  4744. if (isAsciiHexDigit(cp)) {
  4745. this.state = State.HEXADEMICAL_CHARACTER_REFERENCE;
  4746. this._stateHexademicalCharacterReference(cp);
  4747. } else {
  4748. this._err(ERR.absenceOfDigitsInNumericCharacterReference);
  4749. this._flushCodePointConsumedAsCharacterReference(CODE_POINTS.AMPERSAND);
  4750. this._flushCodePointConsumedAsCharacterReference(CODE_POINTS.NUMBER_SIGN);
  4751. this._unconsume(2);
  4752. this.state = this.returnState;
  4753. }
  4754. }
  4755. // Hexademical character reference state
  4756. //------------------------------------------------------------------
  4757. _stateHexademicalCharacterReference(cp) {
  4758. if (isAsciiUpperHexDigit(cp)) {
  4759. this.charRefCode = this.charRefCode * 16 + cp - 55;
  4760. } else if (isAsciiLowerHexDigit(cp)) {
  4761. this.charRefCode = this.charRefCode * 16 + cp - 87;
  4762. } else if (isAsciiDigit(cp)) {
  4763. this.charRefCode = this.charRefCode * 16 + cp - 48;
  4764. } else if (cp === CODE_POINTS.SEMICOLON) {
  4765. this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
  4766. } else {
  4767. this._err(ERR.missingSemicolonAfterCharacterReference);
  4768. this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
  4769. this._stateNumericCharacterReferenceEnd(cp);
  4770. }
  4771. }
  4772. // Decimal character reference state
  4773. //------------------------------------------------------------------
  4774. _stateDecimalCharacterReference(cp) {
  4775. if (isAsciiDigit(cp)) {
  4776. this.charRefCode = this.charRefCode * 10 + cp - 48;
  4777. } else if (cp === CODE_POINTS.SEMICOLON) {
  4778. this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
  4779. } else {
  4780. this._err(ERR.missingSemicolonAfterCharacterReference);
  4781. this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
  4782. this._stateNumericCharacterReferenceEnd(cp);
  4783. }
  4784. }
  4785. // Numeric character reference end state
  4786. //------------------------------------------------------------------
  4787. _stateNumericCharacterReferenceEnd(cp) {
  4788. if (this.charRefCode === CODE_POINTS.NULL) {
  4789. this._err(ERR.nullCharacterReference);
  4790. this.charRefCode = CODE_POINTS.REPLACEMENT_CHARACTER;
  4791. } else if (this.charRefCode > 1114111) {
  4792. this._err(ERR.characterReferenceOutsideUnicodeRange);
  4793. this.charRefCode = CODE_POINTS.REPLACEMENT_CHARACTER;
  4794. } else if (isSurrogate(this.charRefCode)) {
  4795. this._err(ERR.surrogateCharacterReference);
  4796. this.charRefCode = CODE_POINTS.REPLACEMENT_CHARACTER;
  4797. } else if (isUndefinedCodePoint(this.charRefCode)) {
  4798. this._err(ERR.noncharacterCharacterReference);
  4799. } else if (isControlCodePoint(this.charRefCode) || this.charRefCode === CODE_POINTS.CARRIAGE_RETURN) {
  4800. this._err(ERR.controlCharacterReference);
  4801. const replacement = C1_CONTROLS_REFERENCE_REPLACEMENTS.get(this.charRefCode);
  4802. if (replacement !== void 0) {
  4803. this.charRefCode = replacement;
  4804. }
  4805. }
  4806. this._flushCodePointConsumedAsCharacterReference(this.charRefCode);
  4807. this._reconsumeInState(this.returnState, cp);
  4808. }
  4809. };
  4810. // node_modules/parse5/dist/parser/open-element-stack.js
  4811. var IMPLICIT_END_TAG_REQUIRED = /* @__PURE__ */ new Set([TAG_ID.DD, TAG_ID.DT, TAG_ID.LI, TAG_ID.OPTGROUP, TAG_ID.OPTION, TAG_ID.P, TAG_ID.RB, TAG_ID.RP, TAG_ID.RT, TAG_ID.RTC]);
  4812. var IMPLICIT_END_TAG_REQUIRED_THOROUGHLY = /* @__PURE__ */ new Set([
  4813. ...IMPLICIT_END_TAG_REQUIRED,
  4814. TAG_ID.CAPTION,
  4815. TAG_ID.COLGROUP,
  4816. TAG_ID.TBODY,
  4817. TAG_ID.TD,
  4818. TAG_ID.TFOOT,
  4819. TAG_ID.TH,
  4820. TAG_ID.THEAD,
  4821. TAG_ID.TR
  4822. ]);
  4823. var SCOPING_ELEMENT_NS = /* @__PURE__ */ new Map([
  4824. [TAG_ID.APPLET, NS.HTML],
  4825. [TAG_ID.CAPTION, NS.HTML],
  4826. [TAG_ID.HTML, NS.HTML],
  4827. [TAG_ID.MARQUEE, NS.HTML],
  4828. [TAG_ID.OBJECT, NS.HTML],
  4829. [TAG_ID.TABLE, NS.HTML],
  4830. [TAG_ID.TD, NS.HTML],
  4831. [TAG_ID.TEMPLATE, NS.HTML],
  4832. [TAG_ID.TH, NS.HTML],
  4833. [TAG_ID.ANNOTATION_XML, NS.MATHML],
  4834. [TAG_ID.MI, NS.MATHML],
  4835. [TAG_ID.MN, NS.MATHML],
  4836. [TAG_ID.MO, NS.MATHML],
  4837. [TAG_ID.MS, NS.MATHML],
  4838. [TAG_ID.MTEXT, NS.MATHML],
  4839. [TAG_ID.DESC, NS.SVG],
  4840. [TAG_ID.FOREIGN_OBJECT, NS.SVG],
  4841. [TAG_ID.TITLE, NS.SVG]
  4842. ]);
  4843. var NAMED_HEADERS = [TAG_ID.H1, TAG_ID.H2, TAG_ID.H3, TAG_ID.H4, TAG_ID.H5, TAG_ID.H6];
  4844. var TABLE_ROW_CONTEXT = [TAG_ID.TR, TAG_ID.TEMPLATE, TAG_ID.HTML];
  4845. var TABLE_BODY_CONTEXT = [TAG_ID.TBODY, TAG_ID.TFOOT, TAG_ID.THEAD, TAG_ID.TEMPLATE, TAG_ID.HTML];
  4846. var TABLE_CONTEXT = [TAG_ID.TABLE, TAG_ID.TEMPLATE, TAG_ID.HTML];
  4847. var TABLE_CELLS = [TAG_ID.TD, TAG_ID.TH];
  4848. var OpenElementStack = class {
  4849. get currentTmplContentOrNode() {
  4850. return this._isInTemplate() ? this.treeAdapter.getTemplateContent(this.current) : this.current;
  4851. }
  4852. constructor(document, treeAdapter, handler) {
  4853. this.treeAdapter = treeAdapter;
  4854. this.handler = handler;
  4855. this.items = [];
  4856. this.tagIDs = [];
  4857. this.stackTop = -1;
  4858. this.tmplCount = 0;
  4859. this.currentTagId = TAG_ID.UNKNOWN;
  4860. this.current = document;
  4861. }
  4862. //Index of element
  4863. _indexOf(element) {
  4864. return this.items.lastIndexOf(element, this.stackTop);
  4865. }
  4866. //Update current element
  4867. _isInTemplate() {
  4868. return this.currentTagId === TAG_ID.TEMPLATE && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML;
  4869. }
  4870. _updateCurrentElement() {
  4871. this.current = this.items[this.stackTop];
  4872. this.currentTagId = this.tagIDs[this.stackTop];
  4873. }
  4874. //Mutations
  4875. push(element, tagID) {
  4876. this.stackTop++;
  4877. this.items[this.stackTop] = element;
  4878. this.current = element;
  4879. this.tagIDs[this.stackTop] = tagID;
  4880. this.currentTagId = tagID;
  4881. if (this._isInTemplate()) {
  4882. this.tmplCount++;
  4883. }
  4884. this.handler.onItemPush(element, tagID, true);
  4885. }
  4886. pop() {
  4887. const popped = this.current;
  4888. if (this.tmplCount > 0 && this._isInTemplate()) {
  4889. this.tmplCount--;
  4890. }
  4891. this.stackTop--;
  4892. this._updateCurrentElement();
  4893. this.handler.onItemPop(popped, true);
  4894. }
  4895. replace(oldElement, newElement) {
  4896. const idx = this._indexOf(oldElement);
  4897. this.items[idx] = newElement;
  4898. if (idx === this.stackTop) {
  4899. this.current = newElement;
  4900. }
  4901. }
  4902. insertAfter(referenceElement, newElement, newElementID) {
  4903. const insertionIdx = this._indexOf(referenceElement) + 1;
  4904. this.items.splice(insertionIdx, 0, newElement);
  4905. this.tagIDs.splice(insertionIdx, 0, newElementID);
  4906. this.stackTop++;
  4907. if (insertionIdx === this.stackTop) {
  4908. this._updateCurrentElement();
  4909. }
  4910. this.handler.onItemPush(this.current, this.currentTagId, insertionIdx === this.stackTop);
  4911. }
  4912. popUntilTagNamePopped(tagName) {
  4913. let targetIdx = this.stackTop + 1;
  4914. do {
  4915. targetIdx = this.tagIDs.lastIndexOf(tagName, targetIdx - 1);
  4916. } while (targetIdx > 0 && this.treeAdapter.getNamespaceURI(this.items[targetIdx]) !== NS.HTML);
  4917. this.shortenToLength(targetIdx < 0 ? 0 : targetIdx);
  4918. }
  4919. shortenToLength(idx) {
  4920. while (this.stackTop >= idx) {
  4921. const popped = this.current;
  4922. if (this.tmplCount > 0 && this._isInTemplate()) {
  4923. this.tmplCount -= 1;
  4924. }
  4925. this.stackTop--;
  4926. this._updateCurrentElement();
  4927. this.handler.onItemPop(popped, this.stackTop < idx);
  4928. }
  4929. }
  4930. popUntilElementPopped(element) {
  4931. const idx = this._indexOf(element);
  4932. this.shortenToLength(idx < 0 ? 0 : idx);
  4933. }
  4934. popUntilPopped(tagNames, targetNS) {
  4935. const idx = this._indexOfTagNames(tagNames, targetNS);
  4936. this.shortenToLength(idx < 0 ? 0 : idx);
  4937. }
  4938. popUntilNumberedHeaderPopped() {
  4939. this.popUntilPopped(NAMED_HEADERS, NS.HTML);
  4940. }
  4941. popUntilTableCellPopped() {
  4942. this.popUntilPopped(TABLE_CELLS, NS.HTML);
  4943. }
  4944. popAllUpToHtmlElement() {
  4945. this.tmplCount = 0;
  4946. this.shortenToLength(1);
  4947. }
  4948. _indexOfTagNames(tagNames, namespace) {
  4949. for (let i = this.stackTop; i >= 0; i--) {
  4950. if (tagNames.includes(this.tagIDs[i]) && this.treeAdapter.getNamespaceURI(this.items[i]) === namespace) {
  4951. return i;
  4952. }
  4953. }
  4954. return -1;
  4955. }
  4956. clearBackTo(tagNames, targetNS) {
  4957. const idx = this._indexOfTagNames(tagNames, targetNS);
  4958. this.shortenToLength(idx + 1);
  4959. }
  4960. clearBackToTableContext() {
  4961. this.clearBackTo(TABLE_CONTEXT, NS.HTML);
  4962. }
  4963. clearBackToTableBodyContext() {
  4964. this.clearBackTo(TABLE_BODY_CONTEXT, NS.HTML);
  4965. }
  4966. clearBackToTableRowContext() {
  4967. this.clearBackTo(TABLE_ROW_CONTEXT, NS.HTML);
  4968. }
  4969. remove(element) {
  4970. const idx = this._indexOf(element);
  4971. if (idx >= 0) {
  4972. if (idx === this.stackTop) {
  4973. this.pop();
  4974. } else {
  4975. this.items.splice(idx, 1);
  4976. this.tagIDs.splice(idx, 1);
  4977. this.stackTop--;
  4978. this._updateCurrentElement();
  4979. this.handler.onItemPop(element, false);
  4980. }
  4981. }
  4982. }
  4983. //Search
  4984. tryPeekProperlyNestedBodyElement() {
  4985. return this.stackTop >= 1 && this.tagIDs[1] === TAG_ID.BODY ? this.items[1] : null;
  4986. }
  4987. contains(element) {
  4988. return this._indexOf(element) > -1;
  4989. }
  4990. getCommonAncestor(element) {
  4991. const elementIdx = this._indexOf(element) - 1;
  4992. return elementIdx >= 0 ? this.items[elementIdx] : null;
  4993. }
  4994. isRootHtmlElementCurrent() {
  4995. return this.stackTop === 0 && this.tagIDs[0] === TAG_ID.HTML;
  4996. }
  4997. //Element in scope
  4998. hasInScope(tagName) {
  4999. for (let i = this.stackTop; i >= 0; i--) {
  5000. const tn = this.tagIDs[i];
  5001. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  5002. if (tn === tagName && ns === NS.HTML) {
  5003. return true;
  5004. }
  5005. if (SCOPING_ELEMENT_NS.get(tn) === ns) {
  5006. return false;
  5007. }
  5008. }
  5009. return true;
  5010. }
  5011. hasNumberedHeaderInScope() {
  5012. for (let i = this.stackTop; i >= 0; i--) {
  5013. const tn = this.tagIDs[i];
  5014. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  5015. if (isNumberedHeader(tn) && ns === NS.HTML) {
  5016. return true;
  5017. }
  5018. if (SCOPING_ELEMENT_NS.get(tn) === ns) {
  5019. return false;
  5020. }
  5021. }
  5022. return true;
  5023. }
  5024. hasInListItemScope(tagName) {
  5025. for (let i = this.stackTop; i >= 0; i--) {
  5026. const tn = this.tagIDs[i];
  5027. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  5028. if (tn === tagName && ns === NS.HTML) {
  5029. return true;
  5030. }
  5031. if ((tn === TAG_ID.UL || tn === TAG_ID.OL) && ns === NS.HTML || SCOPING_ELEMENT_NS.get(tn) === ns) {
  5032. return false;
  5033. }
  5034. }
  5035. return true;
  5036. }
  5037. hasInButtonScope(tagName) {
  5038. for (let i = this.stackTop; i >= 0; i--) {
  5039. const tn = this.tagIDs[i];
  5040. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  5041. if (tn === tagName && ns === NS.HTML) {
  5042. return true;
  5043. }
  5044. if (tn === TAG_ID.BUTTON && ns === NS.HTML || SCOPING_ELEMENT_NS.get(tn) === ns) {
  5045. return false;
  5046. }
  5047. }
  5048. return true;
  5049. }
  5050. hasInTableScope(tagName) {
  5051. for (let i = this.stackTop; i >= 0; i--) {
  5052. const tn = this.tagIDs[i];
  5053. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  5054. if (ns !== NS.HTML) {
  5055. continue;
  5056. }
  5057. if (tn === tagName) {
  5058. return true;
  5059. }
  5060. if (tn === TAG_ID.TABLE || tn === TAG_ID.TEMPLATE || tn === TAG_ID.HTML) {
  5061. return false;
  5062. }
  5063. }
  5064. return true;
  5065. }
  5066. hasTableBodyContextInTableScope() {
  5067. for (let i = this.stackTop; i >= 0; i--) {
  5068. const tn = this.tagIDs[i];
  5069. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  5070. if (ns !== NS.HTML) {
  5071. continue;
  5072. }
  5073. if (tn === TAG_ID.TBODY || tn === TAG_ID.THEAD || tn === TAG_ID.TFOOT) {
  5074. return true;
  5075. }
  5076. if (tn === TAG_ID.TABLE || tn === TAG_ID.HTML) {
  5077. return false;
  5078. }
  5079. }
  5080. return true;
  5081. }
  5082. hasInSelectScope(tagName) {
  5083. for (let i = this.stackTop; i >= 0; i--) {
  5084. const tn = this.tagIDs[i];
  5085. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  5086. if (ns !== NS.HTML) {
  5087. continue;
  5088. }
  5089. if (tn === tagName) {
  5090. return true;
  5091. }
  5092. if (tn !== TAG_ID.OPTION && tn !== TAG_ID.OPTGROUP) {
  5093. return false;
  5094. }
  5095. }
  5096. return true;
  5097. }
  5098. //Implied end tags
  5099. generateImpliedEndTags() {
  5100. while (IMPLICIT_END_TAG_REQUIRED.has(this.currentTagId)) {
  5101. this.pop();
  5102. }
  5103. }
  5104. generateImpliedEndTagsThoroughly() {
  5105. while (IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) {
  5106. this.pop();
  5107. }
  5108. }
  5109. generateImpliedEndTagsWithExclusion(exclusionId) {
  5110. while (this.currentTagId !== exclusionId && IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) {
  5111. this.pop();
  5112. }
  5113. }
  5114. };
  5115. // node_modules/parse5/dist/parser/formatting-element-list.js
  5116. var NOAH_ARK_CAPACITY = 3;
  5117. var EntryType;
  5118. (function(EntryType2) {
  5119. EntryType2[EntryType2["Marker"] = 0] = "Marker";
  5120. EntryType2[EntryType2["Element"] = 1] = "Element";
  5121. })(EntryType = EntryType || (EntryType = {}));
  5122. var MARKER = { type: EntryType.Marker };
  5123. var FormattingElementList = class {
  5124. constructor(treeAdapter) {
  5125. this.treeAdapter = treeAdapter;
  5126. this.entries = [];
  5127. this.bookmark = null;
  5128. }
  5129. //Noah Ark's condition
  5130. //OPTIMIZATION: at first we try to find possible candidates for exclusion using
  5131. //lightweight heuristics without thorough attributes check.
  5132. _getNoahArkConditionCandidates(newElement, neAttrs) {
  5133. const candidates = [];
  5134. const neAttrsLength = neAttrs.length;
  5135. const neTagName = this.treeAdapter.getTagName(newElement);
  5136. const neNamespaceURI = this.treeAdapter.getNamespaceURI(newElement);
  5137. for (let i = 0; i < this.entries.length; i++) {
  5138. const entry = this.entries[i];
  5139. if (entry.type === EntryType.Marker) {
  5140. break;
  5141. }
  5142. const { element } = entry;
  5143. if (this.treeAdapter.getTagName(element) === neTagName && this.treeAdapter.getNamespaceURI(element) === neNamespaceURI) {
  5144. const elementAttrs = this.treeAdapter.getAttrList(element);
  5145. if (elementAttrs.length === neAttrsLength) {
  5146. candidates.push({ idx: i, attrs: elementAttrs });
  5147. }
  5148. }
  5149. }
  5150. return candidates;
  5151. }
  5152. _ensureNoahArkCondition(newElement) {
  5153. if (this.entries.length < NOAH_ARK_CAPACITY)
  5154. return;
  5155. const neAttrs = this.treeAdapter.getAttrList(newElement);
  5156. const candidates = this._getNoahArkConditionCandidates(newElement, neAttrs);
  5157. if (candidates.length < NOAH_ARK_CAPACITY)
  5158. return;
  5159. const neAttrsMap = new Map(neAttrs.map((neAttr) => [neAttr.name, neAttr.value]));
  5160. let validCandidates = 0;
  5161. for (let i = 0; i < candidates.length; i++) {
  5162. const candidate = candidates[i];
  5163. if (candidate.attrs.every((cAttr) => neAttrsMap.get(cAttr.name) === cAttr.value)) {
  5164. validCandidates += 1;
  5165. if (validCandidates >= NOAH_ARK_CAPACITY) {
  5166. this.entries.splice(candidate.idx, 1);
  5167. }
  5168. }
  5169. }
  5170. }
  5171. //Mutations
  5172. insertMarker() {
  5173. this.entries.unshift(MARKER);
  5174. }
  5175. pushElement(element, token) {
  5176. this._ensureNoahArkCondition(element);
  5177. this.entries.unshift({
  5178. type: EntryType.Element,
  5179. element,
  5180. token
  5181. });
  5182. }
  5183. insertElementAfterBookmark(element, token) {
  5184. const bookmarkIdx = this.entries.indexOf(this.bookmark);
  5185. this.entries.splice(bookmarkIdx, 0, {
  5186. type: EntryType.Element,
  5187. element,
  5188. token
  5189. });
  5190. }
  5191. removeEntry(entry) {
  5192. const entryIndex = this.entries.indexOf(entry);
  5193. if (entryIndex >= 0) {
  5194. this.entries.splice(entryIndex, 1);
  5195. }
  5196. }
  5197. /**
  5198. * Clears the list of formatting elements up to the last marker.
  5199. *
  5200. * @see https://html.spec.whatwg.org/multipage/parsing.html#clear-the-list-of-active-formatting-elements-up-to-the-last-marker
  5201. */
  5202. clearToLastMarker() {
  5203. const markerIdx = this.entries.indexOf(MARKER);
  5204. if (markerIdx >= 0) {
  5205. this.entries.splice(0, markerIdx + 1);
  5206. } else {
  5207. this.entries.length = 0;
  5208. }
  5209. }
  5210. //Search
  5211. getElementEntryInScopeWithTagName(tagName) {
  5212. const entry = this.entries.find((entry2) => entry2.type === EntryType.Marker || this.treeAdapter.getTagName(entry2.element) === tagName);
  5213. return entry && entry.type === EntryType.Element ? entry : null;
  5214. }
  5215. getElementEntry(element) {
  5216. return this.entries.find((entry) => entry.type === EntryType.Element && entry.element === element);
  5217. }
  5218. };
  5219. // node_modules/parse5/dist/tree-adapters/default.js
  5220. function createTextNode(value) {
  5221. return {
  5222. nodeName: "#text",
  5223. value,
  5224. parentNode: null
  5225. };
  5226. }
  5227. var defaultTreeAdapter = {
  5228. //Node construction
  5229. createDocument() {
  5230. return {
  5231. nodeName: "#document",
  5232. mode: DOCUMENT_MODE.NO_QUIRKS,
  5233. childNodes: []
  5234. };
  5235. },
  5236. createDocumentFragment() {
  5237. return {
  5238. nodeName: "#document-fragment",
  5239. childNodes: []
  5240. };
  5241. },
  5242. createElement(tagName, namespaceURI, attrs) {
  5243. return {
  5244. nodeName: tagName,
  5245. tagName,
  5246. attrs,
  5247. namespaceURI,
  5248. childNodes: [],
  5249. parentNode: null
  5250. };
  5251. },
  5252. createCommentNode(data) {
  5253. return {
  5254. nodeName: "#comment",
  5255. data,
  5256. parentNode: null
  5257. };
  5258. },
  5259. //Tree mutation
  5260. appendChild(parentNode, newNode) {
  5261. parentNode.childNodes.push(newNode);
  5262. newNode.parentNode = parentNode;
  5263. },
  5264. insertBefore(parentNode, newNode, referenceNode) {
  5265. const insertionIdx = parentNode.childNodes.indexOf(referenceNode);
  5266. parentNode.childNodes.splice(insertionIdx, 0, newNode);
  5267. newNode.parentNode = parentNode;
  5268. },
  5269. setTemplateContent(templateElement, contentElement) {
  5270. templateElement.content = contentElement;
  5271. },
  5272. getTemplateContent(templateElement) {
  5273. return templateElement.content;
  5274. },
  5275. setDocumentType(document, name, publicId, systemId) {
  5276. const doctypeNode = document.childNodes.find((node) => node.nodeName === "#documentType");
  5277. if (doctypeNode) {
  5278. doctypeNode.name = name;
  5279. doctypeNode.publicId = publicId;
  5280. doctypeNode.systemId = systemId;
  5281. } else {
  5282. const node = {
  5283. nodeName: "#documentType",
  5284. name,
  5285. publicId,
  5286. systemId,
  5287. parentNode: null
  5288. };
  5289. defaultTreeAdapter.appendChild(document, node);
  5290. }
  5291. },
  5292. setDocumentMode(document, mode) {
  5293. document.mode = mode;
  5294. },
  5295. getDocumentMode(document) {
  5296. return document.mode;
  5297. },
  5298. detachNode(node) {
  5299. if (node.parentNode) {
  5300. const idx = node.parentNode.childNodes.indexOf(node);
  5301. node.parentNode.childNodes.splice(idx, 1);
  5302. node.parentNode = null;
  5303. }
  5304. },
  5305. insertText(parentNode, text) {
  5306. if (parentNode.childNodes.length > 0) {
  5307. const prevNode = parentNode.childNodes[parentNode.childNodes.length - 1];
  5308. if (defaultTreeAdapter.isTextNode(prevNode)) {
  5309. prevNode.value += text;
  5310. return;
  5311. }
  5312. }
  5313. defaultTreeAdapter.appendChild(parentNode, createTextNode(text));
  5314. },
  5315. insertTextBefore(parentNode, text, referenceNode) {
  5316. const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
  5317. if (prevNode && defaultTreeAdapter.isTextNode(prevNode)) {
  5318. prevNode.value += text;
  5319. } else {
  5320. defaultTreeAdapter.insertBefore(parentNode, createTextNode(text), referenceNode);
  5321. }
  5322. },
  5323. adoptAttributes(recipient, attrs) {
  5324. const recipientAttrsMap = new Set(recipient.attrs.map((attr) => attr.name));
  5325. for (let j = 0; j < attrs.length; j++) {
  5326. if (!recipientAttrsMap.has(attrs[j].name)) {
  5327. recipient.attrs.push(attrs[j]);
  5328. }
  5329. }
  5330. },
  5331. //Tree traversing
  5332. getFirstChild(node) {
  5333. return node.childNodes[0];
  5334. },
  5335. getChildNodes(node) {
  5336. return node.childNodes;
  5337. },
  5338. getParentNode(node) {
  5339. return node.parentNode;
  5340. },
  5341. getAttrList(element) {
  5342. return element.attrs;
  5343. },
  5344. //Node data
  5345. getTagName(element) {
  5346. return element.tagName;
  5347. },
  5348. getNamespaceURI(element) {
  5349. return element.namespaceURI;
  5350. },
  5351. getTextNodeContent(textNode) {
  5352. return textNode.value;
  5353. },
  5354. getCommentNodeContent(commentNode) {
  5355. return commentNode.data;
  5356. },
  5357. getDocumentTypeNodeName(doctypeNode) {
  5358. return doctypeNode.name;
  5359. },
  5360. getDocumentTypeNodePublicId(doctypeNode) {
  5361. return doctypeNode.publicId;
  5362. },
  5363. getDocumentTypeNodeSystemId(doctypeNode) {
  5364. return doctypeNode.systemId;
  5365. },
  5366. //Node types
  5367. isTextNode(node) {
  5368. return node.nodeName === "#text";
  5369. },
  5370. isCommentNode(node) {
  5371. return node.nodeName === "#comment";
  5372. },
  5373. isDocumentTypeNode(node) {
  5374. return node.nodeName === "#documentType";
  5375. },
  5376. isElementNode(node) {
  5377. return Object.prototype.hasOwnProperty.call(node, "tagName");
  5378. },
  5379. // Source code location
  5380. setNodeSourceCodeLocation(node, location2) {
  5381. node.sourceCodeLocation = location2;
  5382. },
  5383. getNodeSourceCodeLocation(node) {
  5384. return node.sourceCodeLocation;
  5385. },
  5386. updateNodeSourceCodeLocation(node, endLocation) {
  5387. node.sourceCodeLocation = { ...node.sourceCodeLocation, ...endLocation };
  5388. }
  5389. };
  5390. // node_modules/parse5/dist/common/doctype.js
  5391. var VALID_DOCTYPE_NAME = "html";
  5392. var VALID_SYSTEM_ID = "about:legacy-compat";
  5393. var QUIRKS_MODE_SYSTEM_ID = "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd";
  5394. var QUIRKS_MODE_PUBLIC_ID_PREFIXES = [
  5395. "+//silmaril//dtd html pro v0r11 19970101//",
  5396. "-//as//dtd html 3.0 aswedit + extensions//",
  5397. "-//advasoft ltd//dtd html 3.0 aswedit + extensions//",
  5398. "-//ietf//dtd html 2.0 level 1//",
  5399. "-//ietf//dtd html 2.0 level 2//",
  5400. "-//ietf//dtd html 2.0 strict level 1//",
  5401. "-//ietf//dtd html 2.0 strict level 2//",
  5402. "-//ietf//dtd html 2.0 strict//",
  5403. "-//ietf//dtd html 2.0//",
  5404. "-//ietf//dtd html 2.1e//",
  5405. "-//ietf//dtd html 3.0//",
  5406. "-//ietf//dtd html 3.2 final//",
  5407. "-//ietf//dtd html 3.2//",
  5408. "-//ietf//dtd html 3//",
  5409. "-//ietf//dtd html level 0//",
  5410. "-//ietf//dtd html level 1//",
  5411. "-//ietf//dtd html level 2//",
  5412. "-//ietf//dtd html level 3//",
  5413. "-//ietf//dtd html strict level 0//",
  5414. "-//ietf//dtd html strict level 1//",
  5415. "-//ietf//dtd html strict level 2//",
  5416. "-//ietf//dtd html strict level 3//",
  5417. "-//ietf//dtd html strict//",
  5418. "-//ietf//dtd html//",
  5419. "-//metrius//dtd metrius presentational//",
  5420. "-//microsoft//dtd internet explorer 2.0 html strict//",
  5421. "-//microsoft//dtd internet explorer 2.0 html//",
  5422. "-//microsoft//dtd internet explorer 2.0 tables//",
  5423. "-//microsoft//dtd internet explorer 3.0 html strict//",
  5424. "-//microsoft//dtd internet explorer 3.0 html//",
  5425. "-//microsoft//dtd internet explorer 3.0 tables//",
  5426. "-//netscape comm. corp.//dtd html//",
  5427. "-//netscape comm. corp.//dtd strict html//",
  5428. "-//o'reilly and associates//dtd html 2.0//",
  5429. "-//o'reilly and associates//dtd html extended 1.0//",
  5430. "-//o'reilly and associates//dtd html extended relaxed 1.0//",
  5431. "-//sq//dtd html 2.0 hotmetal + extensions//",
  5432. "-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//",
  5433. "-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//",
  5434. "-//spyglass//dtd html 2.0 extended//",
  5435. "-//sun microsystems corp.//dtd hotjava html//",
  5436. "-//sun microsystems corp.//dtd hotjava strict html//",
  5437. "-//w3c//dtd html 3 1995-03-24//",
  5438. "-//w3c//dtd html 3.2 draft//",
  5439. "-//w3c//dtd html 3.2 final//",
  5440. "-//w3c//dtd html 3.2//",
  5441. "-//w3c//dtd html 3.2s draft//",
  5442. "-//w3c//dtd html 4.0 frameset//",
  5443. "-//w3c//dtd html 4.0 transitional//",
  5444. "-//w3c//dtd html experimental 19960712//",
  5445. "-//w3c//dtd html experimental 970421//",
  5446. "-//w3c//dtd w3 html//",
  5447. "-//w3o//dtd w3 html 3.0//",
  5448. "-//webtechs//dtd mozilla html 2.0//",
  5449. "-//webtechs//dtd mozilla html//"
  5450. ];
  5451. var QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES = [
  5452. ...QUIRKS_MODE_PUBLIC_ID_PREFIXES,
  5453. "-//w3c//dtd html 4.01 frameset//",
  5454. "-//w3c//dtd html 4.01 transitional//"
  5455. ];
  5456. var QUIRKS_MODE_PUBLIC_IDS = /* @__PURE__ */ new Set([
  5457. "-//w3o//dtd w3 html strict 3.0//en//",
  5458. "-/w3c/dtd html 4.0 transitional/en",
  5459. "html"
  5460. ]);
  5461. var LIMITED_QUIRKS_PUBLIC_ID_PREFIXES = ["-//w3c//dtd xhtml 1.0 frameset//", "-//w3c//dtd xhtml 1.0 transitional//"];
  5462. var LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES = [
  5463. ...LIMITED_QUIRKS_PUBLIC_ID_PREFIXES,
  5464. "-//w3c//dtd html 4.01 frameset//",
  5465. "-//w3c//dtd html 4.01 transitional//"
  5466. ];
  5467. function hasPrefix(publicId, prefixes) {
  5468. return prefixes.some((prefix) => publicId.startsWith(prefix));
  5469. }
  5470. function isConforming(token) {
  5471. return token.name === VALID_DOCTYPE_NAME && token.publicId === null && (token.systemId === null || token.systemId === VALID_SYSTEM_ID);
  5472. }
  5473. function getDocumentMode(token) {
  5474. if (token.name !== VALID_DOCTYPE_NAME) {
  5475. return DOCUMENT_MODE.QUIRKS;
  5476. }
  5477. const { systemId } = token;
  5478. if (systemId && systemId.toLowerCase() === QUIRKS_MODE_SYSTEM_ID) {
  5479. return DOCUMENT_MODE.QUIRKS;
  5480. }
  5481. let { publicId } = token;
  5482. if (publicId !== null) {
  5483. publicId = publicId.toLowerCase();
  5484. if (QUIRKS_MODE_PUBLIC_IDS.has(publicId)) {
  5485. return DOCUMENT_MODE.QUIRKS;
  5486. }
  5487. let prefixes = systemId === null ? QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES : QUIRKS_MODE_PUBLIC_ID_PREFIXES;
  5488. if (hasPrefix(publicId, prefixes)) {
  5489. return DOCUMENT_MODE.QUIRKS;
  5490. }
  5491. prefixes = systemId === null ? LIMITED_QUIRKS_PUBLIC_ID_PREFIXES : LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES;
  5492. if (hasPrefix(publicId, prefixes)) {
  5493. return DOCUMENT_MODE.LIMITED_QUIRKS;
  5494. }
  5495. }
  5496. return DOCUMENT_MODE.NO_QUIRKS;
  5497. }
  5498. // node_modules/parse5/dist/common/foreign-content.js
  5499. var foreign_content_exports = {};
  5500. __export(foreign_content_exports, {
  5501. SVG_TAG_NAMES_ADJUSTMENT_MAP: () => SVG_TAG_NAMES_ADJUSTMENT_MAP,
  5502. adjustTokenMathMLAttrs: () => adjustTokenMathMLAttrs,
  5503. adjustTokenSVGAttrs: () => adjustTokenSVGAttrs,
  5504. adjustTokenSVGTagName: () => adjustTokenSVGTagName,
  5505. adjustTokenXMLAttrs: () => adjustTokenXMLAttrs,
  5506. causesExit: () => causesExit,
  5507. isIntegrationPoint: () => isIntegrationPoint
  5508. });
  5509. var MIME_TYPES = {
  5510. TEXT_HTML: "text/html",
  5511. APPLICATION_XML: "application/xhtml+xml"
  5512. };
  5513. var DEFINITION_URL_ATTR = "definitionurl";
  5514. var ADJUSTED_DEFINITION_URL_ATTR = "definitionURL";
  5515. var SVG_ATTRS_ADJUSTMENT_MAP = new Map([
  5516. "attributeName",
  5517. "attributeType",
  5518. "baseFrequency",
  5519. "baseProfile",
  5520. "calcMode",
  5521. "clipPathUnits",
  5522. "diffuseConstant",
  5523. "edgeMode",
  5524. "filterUnits",
  5525. "glyphRef",
  5526. "gradientTransform",
  5527. "gradientUnits",
  5528. "kernelMatrix",
  5529. "kernelUnitLength",
  5530. "keyPoints",
  5531. "keySplines",
  5532. "keyTimes",
  5533. "lengthAdjust",
  5534. "limitingConeAngle",
  5535. "markerHeight",
  5536. "markerUnits",
  5537. "markerWidth",
  5538. "maskContentUnits",
  5539. "maskUnits",
  5540. "numOctaves",
  5541. "pathLength",
  5542. "patternContentUnits",
  5543. "patternTransform",
  5544. "patternUnits",
  5545. "pointsAtX",
  5546. "pointsAtY",
  5547. "pointsAtZ",
  5548. "preserveAlpha",
  5549. "preserveAspectRatio",
  5550. "primitiveUnits",
  5551. "refX",
  5552. "refY",
  5553. "repeatCount",
  5554. "repeatDur",
  5555. "requiredExtensions",
  5556. "requiredFeatures",
  5557. "specularConstant",
  5558. "specularExponent",
  5559. "spreadMethod",
  5560. "startOffset",
  5561. "stdDeviation",
  5562. "stitchTiles",
  5563. "surfaceScale",
  5564. "systemLanguage",
  5565. "tableValues",
  5566. "targetX",
  5567. "targetY",
  5568. "textLength",
  5569. "viewBox",
  5570. "viewTarget",
  5571. "xChannelSelector",
  5572. "yChannelSelector",
  5573. "zoomAndPan"
  5574. ].map((attr) => [attr.toLowerCase(), attr]));
  5575. var XML_ATTRS_ADJUSTMENT_MAP = /* @__PURE__ */ new Map([
  5576. ["xlink:actuate", { prefix: "xlink", name: "actuate", namespace: NS.XLINK }],
  5577. ["xlink:arcrole", { prefix: "xlink", name: "arcrole", namespace: NS.XLINK }],
  5578. ["xlink:href", { prefix: "xlink", name: "href", namespace: NS.XLINK }],
  5579. ["xlink:role", { prefix: "xlink", name: "role", namespace: NS.XLINK }],
  5580. ["xlink:show", { prefix: "xlink", name: "show", namespace: NS.XLINK }],
  5581. ["xlink:title", { prefix: "xlink", name: "title", namespace: NS.XLINK }],
  5582. ["xlink:type", { prefix: "xlink", name: "type", namespace: NS.XLINK }],
  5583. ["xml:base", { prefix: "xml", name: "base", namespace: NS.XML }],
  5584. ["xml:lang", { prefix: "xml", name: "lang", namespace: NS.XML }],
  5585. ["xml:space", { prefix: "xml", name: "space", namespace: NS.XML }],
  5586. ["xmlns", { prefix: "", name: "xmlns", namespace: NS.XMLNS }],
  5587. ["xmlns:xlink", { prefix: "xmlns", name: "xlink", namespace: NS.XMLNS }]
  5588. ]);
  5589. var SVG_TAG_NAMES_ADJUSTMENT_MAP = new Map([
  5590. "altGlyph",
  5591. "altGlyphDef",
  5592. "altGlyphItem",
  5593. "animateColor",
  5594. "animateMotion",
  5595. "animateTransform",
  5596. "clipPath",
  5597. "feBlend",
  5598. "feColorMatrix",
  5599. "feComponentTransfer",
  5600. "feComposite",
  5601. "feConvolveMatrix",
  5602. "feDiffuseLighting",
  5603. "feDisplacementMap",
  5604. "feDistantLight",
  5605. "feFlood",
  5606. "feFuncA",
  5607. "feFuncB",
  5608. "feFuncG",
  5609. "feFuncR",
  5610. "feGaussianBlur",
  5611. "feImage",
  5612. "feMerge",
  5613. "feMergeNode",
  5614. "feMorphology",
  5615. "feOffset",
  5616. "fePointLight",
  5617. "feSpecularLighting",
  5618. "feSpotLight",
  5619. "feTile",
  5620. "feTurbulence",
  5621. "foreignObject",
  5622. "glyphRef",
  5623. "linearGradient",
  5624. "radialGradient",
  5625. "textPath"
  5626. ].map((tn) => [tn.toLowerCase(), tn]));
  5627. var EXITS_FOREIGN_CONTENT = /* @__PURE__ */ new Set([
  5628. TAG_ID.B,
  5629. TAG_ID.BIG,
  5630. TAG_ID.BLOCKQUOTE,
  5631. TAG_ID.BODY,
  5632. TAG_ID.BR,
  5633. TAG_ID.CENTER,
  5634. TAG_ID.CODE,
  5635. TAG_ID.DD,
  5636. TAG_ID.DIV,
  5637. TAG_ID.DL,
  5638. TAG_ID.DT,
  5639. TAG_ID.EM,
  5640. TAG_ID.EMBED,
  5641. TAG_ID.H1,
  5642. TAG_ID.H2,
  5643. TAG_ID.H3,
  5644. TAG_ID.H4,
  5645. TAG_ID.H5,
  5646. TAG_ID.H6,
  5647. TAG_ID.HEAD,
  5648. TAG_ID.HR,
  5649. TAG_ID.I,
  5650. TAG_ID.IMG,
  5651. TAG_ID.LI,
  5652. TAG_ID.LISTING,
  5653. TAG_ID.MENU,
  5654. TAG_ID.META,
  5655. TAG_ID.NOBR,
  5656. TAG_ID.OL,
  5657. TAG_ID.P,
  5658. TAG_ID.PRE,
  5659. TAG_ID.RUBY,
  5660. TAG_ID.S,
  5661. TAG_ID.SMALL,
  5662. TAG_ID.SPAN,
  5663. TAG_ID.STRONG,
  5664. TAG_ID.STRIKE,
  5665. TAG_ID.SUB,
  5666. TAG_ID.SUP,
  5667. TAG_ID.TABLE,
  5668. TAG_ID.TT,
  5669. TAG_ID.U,
  5670. TAG_ID.UL,
  5671. TAG_ID.VAR
  5672. ]);
  5673. function causesExit(startTagToken) {
  5674. const tn = startTagToken.tagID;
  5675. const isFontWithAttrs = tn === TAG_ID.FONT && startTagToken.attrs.some(({ name }) => name === ATTRS.COLOR || name === ATTRS.SIZE || name === ATTRS.FACE);
  5676. return isFontWithAttrs || EXITS_FOREIGN_CONTENT.has(tn);
  5677. }
  5678. function adjustTokenMathMLAttrs(token) {
  5679. for (let i = 0; i < token.attrs.length; i++) {
  5680. if (token.attrs[i].name === DEFINITION_URL_ATTR) {
  5681. token.attrs[i].name = ADJUSTED_DEFINITION_URL_ATTR;
  5682. break;
  5683. }
  5684. }
  5685. }
  5686. function adjustTokenSVGAttrs(token) {
  5687. for (let i = 0; i < token.attrs.length; i++) {
  5688. const adjustedAttrName = SVG_ATTRS_ADJUSTMENT_MAP.get(token.attrs[i].name);
  5689. if (adjustedAttrName != null) {
  5690. token.attrs[i].name = adjustedAttrName;
  5691. }
  5692. }
  5693. }
  5694. function adjustTokenXMLAttrs(token) {
  5695. for (let i = 0; i < token.attrs.length; i++) {
  5696. const adjustedAttrEntry = XML_ATTRS_ADJUSTMENT_MAP.get(token.attrs[i].name);
  5697. if (adjustedAttrEntry) {
  5698. token.attrs[i].prefix = adjustedAttrEntry.prefix;
  5699. token.attrs[i].name = adjustedAttrEntry.name;
  5700. token.attrs[i].namespace = adjustedAttrEntry.namespace;
  5701. }
  5702. }
  5703. }
  5704. function adjustTokenSVGTagName(token) {
  5705. const adjustedTagName = SVG_TAG_NAMES_ADJUSTMENT_MAP.get(token.tagName);
  5706. if (adjustedTagName != null) {
  5707. token.tagName = adjustedTagName;
  5708. token.tagID = getTagID(token.tagName);
  5709. }
  5710. }
  5711. function isMathMLTextIntegrationPoint(tn, ns) {
  5712. return ns === NS.MATHML && (tn === TAG_ID.MI || tn === TAG_ID.MO || tn === TAG_ID.MN || tn === TAG_ID.MS || tn === TAG_ID.MTEXT);
  5713. }
  5714. function isHtmlIntegrationPoint(tn, ns, attrs) {
  5715. if (ns === NS.MATHML && tn === TAG_ID.ANNOTATION_XML) {
  5716. for (let i = 0; i < attrs.length; i++) {
  5717. if (attrs[i].name === ATTRS.ENCODING) {
  5718. const value = attrs[i].value.toLowerCase();
  5719. return value === MIME_TYPES.TEXT_HTML || value === MIME_TYPES.APPLICATION_XML;
  5720. }
  5721. }
  5722. }
  5723. return ns === NS.SVG && (tn === TAG_ID.FOREIGN_OBJECT || tn === TAG_ID.DESC || tn === TAG_ID.TITLE);
  5724. }
  5725. function isIntegrationPoint(tn, ns, attrs, foreignNS) {
  5726. return (!foreignNS || foreignNS === NS.HTML) && isHtmlIntegrationPoint(tn, ns, attrs) || (!foreignNS || foreignNS === NS.MATHML) && isMathMLTextIntegrationPoint(tn, ns);
  5727. }
  5728. // node_modules/parse5/dist/parser/index.js
  5729. var HIDDEN_INPUT_TYPE = "hidden";
  5730. var AA_OUTER_LOOP_ITER = 8;
  5731. var AA_INNER_LOOP_ITER = 3;
  5732. var InsertionMode;
  5733. (function(InsertionMode2) {
  5734. InsertionMode2[InsertionMode2["INITIAL"] = 0] = "INITIAL";
  5735. InsertionMode2[InsertionMode2["BEFORE_HTML"] = 1] = "BEFORE_HTML";
  5736. InsertionMode2[InsertionMode2["BEFORE_HEAD"] = 2] = "BEFORE_HEAD";
  5737. InsertionMode2[InsertionMode2["IN_HEAD"] = 3] = "IN_HEAD";
  5738. InsertionMode2[InsertionMode2["IN_HEAD_NO_SCRIPT"] = 4] = "IN_HEAD_NO_SCRIPT";
  5739. InsertionMode2[InsertionMode2["AFTER_HEAD"] = 5] = "AFTER_HEAD";
  5740. InsertionMode2[InsertionMode2["IN_BODY"] = 6] = "IN_BODY";
  5741. InsertionMode2[InsertionMode2["TEXT"] = 7] = "TEXT";
  5742. InsertionMode2[InsertionMode2["IN_TABLE"] = 8] = "IN_TABLE";
  5743. InsertionMode2[InsertionMode2["IN_TABLE_TEXT"] = 9] = "IN_TABLE_TEXT";
  5744. InsertionMode2[InsertionMode2["IN_CAPTION"] = 10] = "IN_CAPTION";
  5745. InsertionMode2[InsertionMode2["IN_COLUMN_GROUP"] = 11] = "IN_COLUMN_GROUP";
  5746. InsertionMode2[InsertionMode2["IN_TABLE_BODY"] = 12] = "IN_TABLE_BODY";
  5747. InsertionMode2[InsertionMode2["IN_ROW"] = 13] = "IN_ROW";
  5748. InsertionMode2[InsertionMode2["IN_CELL"] = 14] = "IN_CELL";
  5749. InsertionMode2[InsertionMode2["IN_SELECT"] = 15] = "IN_SELECT";
  5750. InsertionMode2[InsertionMode2["IN_SELECT_IN_TABLE"] = 16] = "IN_SELECT_IN_TABLE";
  5751. InsertionMode2[InsertionMode2["IN_TEMPLATE"] = 17] = "IN_TEMPLATE";
  5752. InsertionMode2[InsertionMode2["AFTER_BODY"] = 18] = "AFTER_BODY";
  5753. InsertionMode2[InsertionMode2["IN_FRAMESET"] = 19] = "IN_FRAMESET";
  5754. InsertionMode2[InsertionMode2["AFTER_FRAMESET"] = 20] = "AFTER_FRAMESET";
  5755. InsertionMode2[InsertionMode2["AFTER_AFTER_BODY"] = 21] = "AFTER_AFTER_BODY";
  5756. InsertionMode2[InsertionMode2["AFTER_AFTER_FRAMESET"] = 22] = "AFTER_AFTER_FRAMESET";
  5757. })(InsertionMode || (InsertionMode = {}));
  5758. var BASE_LOC = {
  5759. startLine: -1,
  5760. startCol: -1,
  5761. startOffset: -1,
  5762. endLine: -1,
  5763. endCol: -1,
  5764. endOffset: -1
  5765. };
  5766. var TABLE_STRUCTURE_TAGS = /* @__PURE__ */ new Set([TAG_ID.TABLE, TAG_ID.TBODY, TAG_ID.TFOOT, TAG_ID.THEAD, TAG_ID.TR]);
  5767. var defaultParserOptions = {
  5768. scriptingEnabled: true,
  5769. sourceCodeLocationInfo: false,
  5770. treeAdapter: defaultTreeAdapter,
  5771. onParseError: null
  5772. };
  5773. var Parser = class {
  5774. constructor(options, document, fragmentContext = null, scriptHandler = null) {
  5775. this.fragmentContext = fragmentContext;
  5776. this.scriptHandler = scriptHandler;
  5777. this.currentToken = null;
  5778. this.stopped = false;
  5779. this.insertionMode = InsertionMode.INITIAL;
  5780. this.originalInsertionMode = InsertionMode.INITIAL;
  5781. this.headElement = null;
  5782. this.formElement = null;
  5783. this.currentNotInHTML = false;
  5784. this.tmplInsertionModeStack = [];
  5785. this.pendingCharacterTokens = [];
  5786. this.hasNonWhitespacePendingCharacterToken = false;
  5787. this.framesetOk = true;
  5788. this.skipNextNewLine = false;
  5789. this.fosterParentingEnabled = false;
  5790. this.options = {
  5791. ...defaultParserOptions,
  5792. ...options
  5793. };
  5794. this.treeAdapter = this.options.treeAdapter;
  5795. this.onParseError = this.options.onParseError;
  5796. if (this.onParseError) {
  5797. this.options.sourceCodeLocationInfo = true;
  5798. }
  5799. this.document = document !== null && document !== void 0 ? document : this.treeAdapter.createDocument();
  5800. this.tokenizer = new Tokenizer(this.options, this);
  5801. this.activeFormattingElements = new FormattingElementList(this.treeAdapter);
  5802. this.fragmentContextID = fragmentContext ? getTagID(this.treeAdapter.getTagName(fragmentContext)) : TAG_ID.UNKNOWN;
  5803. this._setContextModes(fragmentContext !== null && fragmentContext !== void 0 ? fragmentContext : this.document, this.fragmentContextID);
  5804. this.openElements = new OpenElementStack(this.document, this.treeAdapter, this);
  5805. }
  5806. // API
  5807. static parse(html, options) {
  5808. const parser = new this(options);
  5809. parser.tokenizer.write(html, true);
  5810. return parser.document;
  5811. }
  5812. static getFragmentParser(fragmentContext, options) {
  5813. const opts = {
  5814. ...defaultParserOptions,
  5815. ...options
  5816. };
  5817. fragmentContext !== null && fragmentContext !== void 0 ? fragmentContext : fragmentContext = opts.treeAdapter.createElement(TAG_NAMES.TEMPLATE, NS.HTML, []);
  5818. const documentMock = opts.treeAdapter.createElement("documentmock", NS.HTML, []);
  5819. const parser = new this(opts, documentMock, fragmentContext);
  5820. if (parser.fragmentContextID === TAG_ID.TEMPLATE) {
  5821. parser.tmplInsertionModeStack.unshift(InsertionMode.IN_TEMPLATE);
  5822. }
  5823. parser._initTokenizerForFragmentParsing();
  5824. parser._insertFakeRootElement();
  5825. parser._resetInsertionMode();
  5826. parser._findFormInFragmentContext();
  5827. return parser;
  5828. }
  5829. getFragment() {
  5830. const rootElement = this.treeAdapter.getFirstChild(this.document);
  5831. const fragment = this.treeAdapter.createDocumentFragment();
  5832. this._adoptNodes(rootElement, fragment);
  5833. return fragment;
  5834. }
  5835. //Errors
  5836. _err(token, code, beforeToken) {
  5837. var _a2;
  5838. if (!this.onParseError)
  5839. return;
  5840. const loc = (_a2 = token.location) !== null && _a2 !== void 0 ? _a2 : BASE_LOC;
  5841. const err2 = {
  5842. code,
  5843. startLine: loc.startLine,
  5844. startCol: loc.startCol,
  5845. startOffset: loc.startOffset,
  5846. endLine: beforeToken ? loc.startLine : loc.endLine,
  5847. endCol: beforeToken ? loc.startCol : loc.endCol,
  5848. endOffset: beforeToken ? loc.startOffset : loc.endOffset
  5849. };
  5850. this.onParseError(err2);
  5851. }
  5852. //Stack events
  5853. onItemPush(node, tid, isTop) {
  5854. var _a2, _b;
  5855. (_b = (_a2 = this.treeAdapter).onItemPush) === null || _b === void 0 ? void 0 : _b.call(_a2, node);
  5856. if (isTop && this.openElements.stackTop > 0)
  5857. this._setContextModes(node, tid);
  5858. }
  5859. onItemPop(node, isTop) {
  5860. var _a2, _b;
  5861. if (this.options.sourceCodeLocationInfo) {
  5862. this._setEndLocation(node, this.currentToken);
  5863. }
  5864. (_b = (_a2 = this.treeAdapter).onItemPop) === null || _b === void 0 ? void 0 : _b.call(_a2, node, this.openElements.current);
  5865. if (isTop) {
  5866. let current;
  5867. let currentTagId;
  5868. if (this.openElements.stackTop === 0 && this.fragmentContext) {
  5869. current = this.fragmentContext;
  5870. currentTagId = this.fragmentContextID;
  5871. } else {
  5872. ({ current, currentTagId } = this.openElements);
  5873. }
  5874. this._setContextModes(current, currentTagId);
  5875. }
  5876. }
  5877. _setContextModes(current, tid) {
  5878. const isHTML = current === this.document || this.treeAdapter.getNamespaceURI(current) === NS.HTML;
  5879. this.currentNotInHTML = !isHTML;
  5880. this.tokenizer.inForeignNode = !isHTML && !this._isIntegrationPoint(tid, current);
  5881. }
  5882. _switchToTextParsing(currentToken, nextTokenizerState) {
  5883. this._insertElement(currentToken, NS.HTML);
  5884. this.tokenizer.state = nextTokenizerState;
  5885. this.originalInsertionMode = this.insertionMode;
  5886. this.insertionMode = InsertionMode.TEXT;
  5887. }
  5888. switchToPlaintextParsing() {
  5889. this.insertionMode = InsertionMode.TEXT;
  5890. this.originalInsertionMode = InsertionMode.IN_BODY;
  5891. this.tokenizer.state = TokenizerMode.PLAINTEXT;
  5892. }
  5893. //Fragment parsing
  5894. _getAdjustedCurrentElement() {
  5895. return this.openElements.stackTop === 0 && this.fragmentContext ? this.fragmentContext : this.openElements.current;
  5896. }
  5897. _findFormInFragmentContext() {
  5898. let node = this.fragmentContext;
  5899. while (node) {
  5900. if (this.treeAdapter.getTagName(node) === TAG_NAMES.FORM) {
  5901. this.formElement = node;
  5902. break;
  5903. }
  5904. node = this.treeAdapter.getParentNode(node);
  5905. }
  5906. }
  5907. _initTokenizerForFragmentParsing() {
  5908. if (!this.fragmentContext || this.treeAdapter.getNamespaceURI(this.fragmentContext) !== NS.HTML) {
  5909. return;
  5910. }
  5911. switch (this.fragmentContextID) {
  5912. case TAG_ID.TITLE:
  5913. case TAG_ID.TEXTAREA: {
  5914. this.tokenizer.state = TokenizerMode.RCDATA;
  5915. break;
  5916. }
  5917. case TAG_ID.STYLE:
  5918. case TAG_ID.XMP:
  5919. case TAG_ID.IFRAME:
  5920. case TAG_ID.NOEMBED:
  5921. case TAG_ID.NOFRAMES:
  5922. case TAG_ID.NOSCRIPT: {
  5923. this.tokenizer.state = TokenizerMode.RAWTEXT;
  5924. break;
  5925. }
  5926. case TAG_ID.SCRIPT: {
  5927. this.tokenizer.state = TokenizerMode.SCRIPT_DATA;
  5928. break;
  5929. }
  5930. case TAG_ID.PLAINTEXT: {
  5931. this.tokenizer.state = TokenizerMode.PLAINTEXT;
  5932. break;
  5933. }
  5934. default:
  5935. }
  5936. }
  5937. //Tree mutation
  5938. _setDocumentType(token) {
  5939. const name = token.name || "";
  5940. const publicId = token.publicId || "";
  5941. const systemId = token.systemId || "";
  5942. this.treeAdapter.setDocumentType(this.document, name, publicId, systemId);
  5943. if (token.location) {
  5944. const documentChildren = this.treeAdapter.getChildNodes(this.document);
  5945. const docTypeNode = documentChildren.find((node) => this.treeAdapter.isDocumentTypeNode(node));
  5946. if (docTypeNode) {
  5947. this.treeAdapter.setNodeSourceCodeLocation(docTypeNode, token.location);
  5948. }
  5949. }
  5950. }
  5951. _attachElementToTree(element, location2) {
  5952. if (this.options.sourceCodeLocationInfo) {
  5953. const loc = location2 && {
  5954. ...location2,
  5955. startTag: location2
  5956. };
  5957. this.treeAdapter.setNodeSourceCodeLocation(element, loc);
  5958. }
  5959. if (this._shouldFosterParentOnInsertion()) {
  5960. this._fosterParentElement(element);
  5961. } else {
  5962. const parent = this.openElements.currentTmplContentOrNode;
  5963. this.treeAdapter.appendChild(parent, element);
  5964. }
  5965. }
  5966. _appendElement(token, namespaceURI) {
  5967. const element = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
  5968. this._attachElementToTree(element, token.location);
  5969. }
  5970. _insertElement(token, namespaceURI) {
  5971. const element = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
  5972. this._attachElementToTree(element, token.location);
  5973. this.openElements.push(element, token.tagID);
  5974. }
  5975. _insertFakeElement(tagName, tagID) {
  5976. const element = this.treeAdapter.createElement(tagName, NS.HTML, []);
  5977. this._attachElementToTree(element, null);
  5978. this.openElements.push(element, tagID);
  5979. }
  5980. _insertTemplate(token) {
  5981. const tmpl = this.treeAdapter.createElement(token.tagName, NS.HTML, token.attrs);
  5982. const content = this.treeAdapter.createDocumentFragment();
  5983. this.treeAdapter.setTemplateContent(tmpl, content);
  5984. this._attachElementToTree(tmpl, token.location);
  5985. this.openElements.push(tmpl, token.tagID);
  5986. if (this.options.sourceCodeLocationInfo)
  5987. this.treeAdapter.setNodeSourceCodeLocation(content, null);
  5988. }
  5989. _insertFakeRootElement() {
  5990. const element = this.treeAdapter.createElement(TAG_NAMES.HTML, NS.HTML, []);
  5991. if (this.options.sourceCodeLocationInfo)
  5992. this.treeAdapter.setNodeSourceCodeLocation(element, null);
  5993. this.treeAdapter.appendChild(this.openElements.current, element);
  5994. this.openElements.push(element, TAG_ID.HTML);
  5995. }
  5996. _appendCommentNode(token, parent) {
  5997. const commentNode = this.treeAdapter.createCommentNode(token.data);
  5998. this.treeAdapter.appendChild(parent, commentNode);
  5999. if (this.options.sourceCodeLocationInfo) {
  6000. this.treeAdapter.setNodeSourceCodeLocation(commentNode, token.location);
  6001. }
  6002. }
  6003. _insertCharacters(token) {
  6004. let parent;
  6005. let beforeElement;
  6006. if (this._shouldFosterParentOnInsertion()) {
  6007. ({ parent, beforeElement } = this._findFosterParentingLocation());
  6008. if (beforeElement) {
  6009. this.treeAdapter.insertTextBefore(parent, token.chars, beforeElement);
  6010. } else {
  6011. this.treeAdapter.insertText(parent, token.chars);
  6012. }
  6013. } else {
  6014. parent = this.openElements.currentTmplContentOrNode;
  6015. this.treeAdapter.insertText(parent, token.chars);
  6016. }
  6017. if (!token.location)
  6018. return;
  6019. const siblings = this.treeAdapter.getChildNodes(parent);
  6020. const textNodeIdx = beforeElement ? siblings.lastIndexOf(beforeElement) : siblings.length;
  6021. const textNode = siblings[textNodeIdx - 1];
  6022. const tnLoc = this.treeAdapter.getNodeSourceCodeLocation(textNode);
  6023. if (tnLoc) {
  6024. const { endLine, endCol, endOffset } = token.location;
  6025. this.treeAdapter.updateNodeSourceCodeLocation(textNode, { endLine, endCol, endOffset });
  6026. } else if (this.options.sourceCodeLocationInfo) {
  6027. this.treeAdapter.setNodeSourceCodeLocation(textNode, token.location);
  6028. }
  6029. }
  6030. _adoptNodes(donor, recipient) {
  6031. for (let child = this.treeAdapter.getFirstChild(donor); child; child = this.treeAdapter.getFirstChild(donor)) {
  6032. this.treeAdapter.detachNode(child);
  6033. this.treeAdapter.appendChild(recipient, child);
  6034. }
  6035. }
  6036. _setEndLocation(element, closingToken) {
  6037. if (this.treeAdapter.getNodeSourceCodeLocation(element) && closingToken.location) {
  6038. const ctLoc = closingToken.location;
  6039. const tn = this.treeAdapter.getTagName(element);
  6040. const endLoc = (
  6041. // NOTE: For cases like <p> <p> </p> - First 'p' closes without a closing
  6042. // tag and for cases like <td> <p> </td> - 'p' closes without a closing tag.
  6043. closingToken.type === TokenType.END_TAG && tn === closingToken.tagName ? {
  6044. endTag: { ...ctLoc },
  6045. endLine: ctLoc.endLine,
  6046. endCol: ctLoc.endCol,
  6047. endOffset: ctLoc.endOffset
  6048. } : {
  6049. endLine: ctLoc.startLine,
  6050. endCol: ctLoc.startCol,
  6051. endOffset: ctLoc.startOffset
  6052. }
  6053. );
  6054. this.treeAdapter.updateNodeSourceCodeLocation(element, endLoc);
  6055. }
  6056. }
  6057. //Token processing
  6058. shouldProcessStartTagTokenInForeignContent(token) {
  6059. if (!this.currentNotInHTML)
  6060. return false;
  6061. let current;
  6062. let currentTagId;
  6063. if (this.openElements.stackTop === 0 && this.fragmentContext) {
  6064. current = this.fragmentContext;
  6065. currentTagId = this.fragmentContextID;
  6066. } else {
  6067. ({ current, currentTagId } = this.openElements);
  6068. }
  6069. if (token.tagID === TAG_ID.SVG && this.treeAdapter.getTagName(current) === TAG_NAMES.ANNOTATION_XML && this.treeAdapter.getNamespaceURI(current) === NS.MATHML) {
  6070. return false;
  6071. }
  6072. return (
  6073. // Check that `current` is not an integration point for HTML or MathML elements.
  6074. this.tokenizer.inForeignNode || // If it _is_ an integration point, then we might have to check that it is not an HTML
  6075. // integration point.
  6076. (token.tagID === TAG_ID.MGLYPH || token.tagID === TAG_ID.MALIGNMARK) && !this._isIntegrationPoint(currentTagId, current, NS.HTML)
  6077. );
  6078. }
  6079. _processToken(token) {
  6080. switch (token.type) {
  6081. case TokenType.CHARACTER: {
  6082. this.onCharacter(token);
  6083. break;
  6084. }
  6085. case TokenType.NULL_CHARACTER: {
  6086. this.onNullCharacter(token);
  6087. break;
  6088. }
  6089. case TokenType.COMMENT: {
  6090. this.onComment(token);
  6091. break;
  6092. }
  6093. case TokenType.DOCTYPE: {
  6094. this.onDoctype(token);
  6095. break;
  6096. }
  6097. case TokenType.START_TAG: {
  6098. this._processStartTag(token);
  6099. break;
  6100. }
  6101. case TokenType.END_TAG: {
  6102. this.onEndTag(token);
  6103. break;
  6104. }
  6105. case TokenType.EOF: {
  6106. this.onEof(token);
  6107. break;
  6108. }
  6109. case TokenType.WHITESPACE_CHARACTER: {
  6110. this.onWhitespaceCharacter(token);
  6111. break;
  6112. }
  6113. }
  6114. }
  6115. //Integration points
  6116. _isIntegrationPoint(tid, element, foreignNS) {
  6117. const ns = this.treeAdapter.getNamespaceURI(element);
  6118. const attrs = this.treeAdapter.getAttrList(element);
  6119. return isIntegrationPoint(tid, ns, attrs, foreignNS);
  6120. }
  6121. //Active formatting elements reconstruction
  6122. _reconstructActiveFormattingElements() {
  6123. const listLength = this.activeFormattingElements.entries.length;
  6124. if (listLength) {
  6125. const endIndex = this.activeFormattingElements.entries.findIndex((entry) => entry.type === EntryType.Marker || this.openElements.contains(entry.element));
  6126. const unopenIdx = endIndex < 0 ? listLength - 1 : endIndex - 1;
  6127. for (let i = unopenIdx; i >= 0; i--) {
  6128. const entry = this.activeFormattingElements.entries[i];
  6129. this._insertElement(entry.token, this.treeAdapter.getNamespaceURI(entry.element));
  6130. entry.element = this.openElements.current;
  6131. }
  6132. }
  6133. }
  6134. //Close elements
  6135. _closeTableCell() {
  6136. this.openElements.generateImpliedEndTags();
  6137. this.openElements.popUntilTableCellPopped();
  6138. this.activeFormattingElements.clearToLastMarker();
  6139. this.insertionMode = InsertionMode.IN_ROW;
  6140. }
  6141. _closePElement() {
  6142. this.openElements.generateImpliedEndTagsWithExclusion(TAG_ID.P);
  6143. this.openElements.popUntilTagNamePopped(TAG_ID.P);
  6144. }
  6145. //Insertion modes
  6146. _resetInsertionMode() {
  6147. for (let i = this.openElements.stackTop; i >= 0; i--) {
  6148. switch (i === 0 && this.fragmentContext ? this.fragmentContextID : this.openElements.tagIDs[i]) {
  6149. case TAG_ID.TR: {
  6150. this.insertionMode = InsertionMode.IN_ROW;
  6151. return;
  6152. }
  6153. case TAG_ID.TBODY:
  6154. case TAG_ID.THEAD:
  6155. case TAG_ID.TFOOT: {
  6156. this.insertionMode = InsertionMode.IN_TABLE_BODY;
  6157. return;
  6158. }
  6159. case TAG_ID.CAPTION: {
  6160. this.insertionMode = InsertionMode.IN_CAPTION;
  6161. return;
  6162. }
  6163. case TAG_ID.COLGROUP: {
  6164. this.insertionMode = InsertionMode.IN_COLUMN_GROUP;
  6165. return;
  6166. }
  6167. case TAG_ID.TABLE: {
  6168. this.insertionMode = InsertionMode.IN_TABLE;
  6169. return;
  6170. }
  6171. case TAG_ID.BODY: {
  6172. this.insertionMode = InsertionMode.IN_BODY;
  6173. return;
  6174. }
  6175. case TAG_ID.FRAMESET: {
  6176. this.insertionMode = InsertionMode.IN_FRAMESET;
  6177. return;
  6178. }
  6179. case TAG_ID.SELECT: {
  6180. this._resetInsertionModeForSelect(i);
  6181. return;
  6182. }
  6183. case TAG_ID.TEMPLATE: {
  6184. this.insertionMode = this.tmplInsertionModeStack[0];
  6185. return;
  6186. }
  6187. case TAG_ID.HTML: {
  6188. this.insertionMode = this.headElement ? InsertionMode.AFTER_HEAD : InsertionMode.BEFORE_HEAD;
  6189. return;
  6190. }
  6191. case TAG_ID.TD:
  6192. case TAG_ID.TH: {
  6193. if (i > 0) {
  6194. this.insertionMode = InsertionMode.IN_CELL;
  6195. return;
  6196. }
  6197. break;
  6198. }
  6199. case TAG_ID.HEAD: {
  6200. if (i > 0) {
  6201. this.insertionMode = InsertionMode.IN_HEAD;
  6202. return;
  6203. }
  6204. break;
  6205. }
  6206. }
  6207. }
  6208. this.insertionMode = InsertionMode.IN_BODY;
  6209. }
  6210. _resetInsertionModeForSelect(selectIdx) {
  6211. if (selectIdx > 0) {
  6212. for (let i = selectIdx - 1; i > 0; i--) {
  6213. const tn = this.openElements.tagIDs[i];
  6214. if (tn === TAG_ID.TEMPLATE) {
  6215. break;
  6216. } else if (tn === TAG_ID.TABLE) {
  6217. this.insertionMode = InsertionMode.IN_SELECT_IN_TABLE;
  6218. return;
  6219. }
  6220. }
  6221. }
  6222. this.insertionMode = InsertionMode.IN_SELECT;
  6223. }
  6224. //Foster parenting
  6225. _isElementCausesFosterParenting(tn) {
  6226. return TABLE_STRUCTURE_TAGS.has(tn);
  6227. }
  6228. _shouldFosterParentOnInsertion() {
  6229. return this.fosterParentingEnabled && this._isElementCausesFosterParenting(this.openElements.currentTagId);
  6230. }
  6231. _findFosterParentingLocation() {
  6232. for (let i = this.openElements.stackTop; i >= 0; i--) {
  6233. const openElement = this.openElements.items[i];
  6234. switch (this.openElements.tagIDs[i]) {
  6235. case TAG_ID.TEMPLATE: {
  6236. if (this.treeAdapter.getNamespaceURI(openElement) === NS.HTML) {
  6237. return { parent: this.treeAdapter.getTemplateContent(openElement), beforeElement: null };
  6238. }
  6239. break;
  6240. }
  6241. case TAG_ID.TABLE: {
  6242. const parent = this.treeAdapter.getParentNode(openElement);
  6243. if (parent) {
  6244. return { parent, beforeElement: openElement };
  6245. }
  6246. return { parent: this.openElements.items[i - 1], beforeElement: null };
  6247. }
  6248. default:
  6249. }
  6250. }
  6251. return { parent: this.openElements.items[0], beforeElement: null };
  6252. }
  6253. _fosterParentElement(element) {
  6254. const location2 = this._findFosterParentingLocation();
  6255. if (location2.beforeElement) {
  6256. this.treeAdapter.insertBefore(location2.parent, element, location2.beforeElement);
  6257. } else {
  6258. this.treeAdapter.appendChild(location2.parent, element);
  6259. }
  6260. }
  6261. //Special elements
  6262. _isSpecialElement(element, id) {
  6263. const ns = this.treeAdapter.getNamespaceURI(element);
  6264. return SPECIAL_ELEMENTS[ns].has(id);
  6265. }
  6266. onCharacter(token) {
  6267. this.skipNextNewLine = false;
  6268. if (this.tokenizer.inForeignNode) {
  6269. characterInForeignContent(this, token);
  6270. return;
  6271. }
  6272. switch (this.insertionMode) {
  6273. case InsertionMode.INITIAL: {
  6274. tokenInInitialMode(this, token);
  6275. break;
  6276. }
  6277. case InsertionMode.BEFORE_HTML: {
  6278. tokenBeforeHtml(this, token);
  6279. break;
  6280. }
  6281. case InsertionMode.BEFORE_HEAD: {
  6282. tokenBeforeHead(this, token);
  6283. break;
  6284. }
  6285. case InsertionMode.IN_HEAD: {
  6286. tokenInHead(this, token);
  6287. break;
  6288. }
  6289. case InsertionMode.IN_HEAD_NO_SCRIPT: {
  6290. tokenInHeadNoScript(this, token);
  6291. break;
  6292. }
  6293. case InsertionMode.AFTER_HEAD: {
  6294. tokenAfterHead(this, token);
  6295. break;
  6296. }
  6297. case InsertionMode.IN_BODY:
  6298. case InsertionMode.IN_CAPTION:
  6299. case InsertionMode.IN_CELL:
  6300. case InsertionMode.IN_TEMPLATE: {
  6301. characterInBody(this, token);
  6302. break;
  6303. }
  6304. case InsertionMode.TEXT:
  6305. case InsertionMode.IN_SELECT:
  6306. case InsertionMode.IN_SELECT_IN_TABLE: {
  6307. this._insertCharacters(token);
  6308. break;
  6309. }
  6310. case InsertionMode.IN_TABLE:
  6311. case InsertionMode.IN_TABLE_BODY:
  6312. case InsertionMode.IN_ROW: {
  6313. characterInTable(this, token);
  6314. break;
  6315. }
  6316. case InsertionMode.IN_TABLE_TEXT: {
  6317. characterInTableText(this, token);
  6318. break;
  6319. }
  6320. case InsertionMode.IN_COLUMN_GROUP: {
  6321. tokenInColumnGroup(this, token);
  6322. break;
  6323. }
  6324. case InsertionMode.AFTER_BODY: {
  6325. tokenAfterBody(this, token);
  6326. break;
  6327. }
  6328. case InsertionMode.AFTER_AFTER_BODY: {
  6329. tokenAfterAfterBody(this, token);
  6330. break;
  6331. }
  6332. default:
  6333. }
  6334. }
  6335. onNullCharacter(token) {
  6336. this.skipNextNewLine = false;
  6337. if (this.tokenizer.inForeignNode) {
  6338. nullCharacterInForeignContent(this, token);
  6339. return;
  6340. }
  6341. switch (this.insertionMode) {
  6342. case InsertionMode.INITIAL: {
  6343. tokenInInitialMode(this, token);
  6344. break;
  6345. }
  6346. case InsertionMode.BEFORE_HTML: {
  6347. tokenBeforeHtml(this, token);
  6348. break;
  6349. }
  6350. case InsertionMode.BEFORE_HEAD: {
  6351. tokenBeforeHead(this, token);
  6352. break;
  6353. }
  6354. case InsertionMode.IN_HEAD: {
  6355. tokenInHead(this, token);
  6356. break;
  6357. }
  6358. case InsertionMode.IN_HEAD_NO_SCRIPT: {
  6359. tokenInHeadNoScript(this, token);
  6360. break;
  6361. }
  6362. case InsertionMode.AFTER_HEAD: {
  6363. tokenAfterHead(this, token);
  6364. break;
  6365. }
  6366. case InsertionMode.TEXT: {
  6367. this._insertCharacters(token);
  6368. break;
  6369. }
  6370. case InsertionMode.IN_TABLE:
  6371. case InsertionMode.IN_TABLE_BODY:
  6372. case InsertionMode.IN_ROW: {
  6373. characterInTable(this, token);
  6374. break;
  6375. }
  6376. case InsertionMode.IN_COLUMN_GROUP: {
  6377. tokenInColumnGroup(this, token);
  6378. break;
  6379. }
  6380. case InsertionMode.AFTER_BODY: {
  6381. tokenAfterBody(this, token);
  6382. break;
  6383. }
  6384. case InsertionMode.AFTER_AFTER_BODY: {
  6385. tokenAfterAfterBody(this, token);
  6386. break;
  6387. }
  6388. default:
  6389. }
  6390. }
  6391. onComment(token) {
  6392. this.skipNextNewLine = false;
  6393. if (this.currentNotInHTML) {
  6394. appendComment(this, token);
  6395. return;
  6396. }
  6397. switch (this.insertionMode) {
  6398. case InsertionMode.INITIAL:
  6399. case InsertionMode.BEFORE_HTML:
  6400. case InsertionMode.BEFORE_HEAD:
  6401. case InsertionMode.IN_HEAD:
  6402. case InsertionMode.IN_HEAD_NO_SCRIPT:
  6403. case InsertionMode.AFTER_HEAD:
  6404. case InsertionMode.IN_BODY:
  6405. case InsertionMode.IN_TABLE:
  6406. case InsertionMode.IN_CAPTION:
  6407. case InsertionMode.IN_COLUMN_GROUP:
  6408. case InsertionMode.IN_TABLE_BODY:
  6409. case InsertionMode.IN_ROW:
  6410. case InsertionMode.IN_CELL:
  6411. case InsertionMode.IN_SELECT:
  6412. case InsertionMode.IN_SELECT_IN_TABLE:
  6413. case InsertionMode.IN_TEMPLATE:
  6414. case InsertionMode.IN_FRAMESET:
  6415. case InsertionMode.AFTER_FRAMESET: {
  6416. appendComment(this, token);
  6417. break;
  6418. }
  6419. case InsertionMode.IN_TABLE_TEXT: {
  6420. tokenInTableText(this, token);
  6421. break;
  6422. }
  6423. case InsertionMode.AFTER_BODY: {
  6424. appendCommentToRootHtmlElement(this, token);
  6425. break;
  6426. }
  6427. case InsertionMode.AFTER_AFTER_BODY:
  6428. case InsertionMode.AFTER_AFTER_FRAMESET: {
  6429. appendCommentToDocument(this, token);
  6430. break;
  6431. }
  6432. default:
  6433. }
  6434. }
  6435. onDoctype(token) {
  6436. this.skipNextNewLine = false;
  6437. switch (this.insertionMode) {
  6438. case InsertionMode.INITIAL: {
  6439. doctypeInInitialMode(this, token);
  6440. break;
  6441. }
  6442. case InsertionMode.BEFORE_HEAD:
  6443. case InsertionMode.IN_HEAD:
  6444. case InsertionMode.IN_HEAD_NO_SCRIPT:
  6445. case InsertionMode.AFTER_HEAD: {
  6446. this._err(token, ERR.misplacedDoctype);
  6447. break;
  6448. }
  6449. case InsertionMode.IN_TABLE_TEXT: {
  6450. tokenInTableText(this, token);
  6451. break;
  6452. }
  6453. default:
  6454. }
  6455. }
  6456. onStartTag(token) {
  6457. this.skipNextNewLine = false;
  6458. this.currentToken = token;
  6459. this._processStartTag(token);
  6460. if (token.selfClosing && !token.ackSelfClosing) {
  6461. this._err(token, ERR.nonVoidHtmlElementStartTagWithTrailingSolidus);
  6462. }
  6463. }
  6464. /**
  6465. * Processes a given start tag.
  6466. *
  6467. * `onStartTag` checks if a self-closing tag was recognized. When a token
  6468. * is moved inbetween multiple insertion modes, this check for self-closing
  6469. * could lead to false positives. To avoid this, `_processStartTag` is used
  6470. * for nested calls.
  6471. *
  6472. * @param token The token to process.
  6473. */
  6474. _processStartTag(token) {
  6475. if (this.shouldProcessStartTagTokenInForeignContent(token)) {
  6476. startTagInForeignContent(this, token);
  6477. } else {
  6478. this._startTagOutsideForeignContent(token);
  6479. }
  6480. }
  6481. _startTagOutsideForeignContent(token) {
  6482. switch (this.insertionMode) {
  6483. case InsertionMode.INITIAL: {
  6484. tokenInInitialMode(this, token);
  6485. break;
  6486. }
  6487. case InsertionMode.BEFORE_HTML: {
  6488. startTagBeforeHtml(this, token);
  6489. break;
  6490. }
  6491. case InsertionMode.BEFORE_HEAD: {
  6492. startTagBeforeHead(this, token);
  6493. break;
  6494. }
  6495. case InsertionMode.IN_HEAD: {
  6496. startTagInHead(this, token);
  6497. break;
  6498. }
  6499. case InsertionMode.IN_HEAD_NO_SCRIPT: {
  6500. startTagInHeadNoScript(this, token);
  6501. break;
  6502. }
  6503. case InsertionMode.AFTER_HEAD: {
  6504. startTagAfterHead(this, token);
  6505. break;
  6506. }
  6507. case InsertionMode.IN_BODY: {
  6508. startTagInBody(this, token);
  6509. break;
  6510. }
  6511. case InsertionMode.IN_TABLE: {
  6512. startTagInTable(this, token);
  6513. break;
  6514. }
  6515. case InsertionMode.IN_TABLE_TEXT: {
  6516. tokenInTableText(this, token);
  6517. break;
  6518. }
  6519. case InsertionMode.IN_CAPTION: {
  6520. startTagInCaption(this, token);
  6521. break;
  6522. }
  6523. case InsertionMode.IN_COLUMN_GROUP: {
  6524. startTagInColumnGroup(this, token);
  6525. break;
  6526. }
  6527. case InsertionMode.IN_TABLE_BODY: {
  6528. startTagInTableBody(this, token);
  6529. break;
  6530. }
  6531. case InsertionMode.IN_ROW: {
  6532. startTagInRow(this, token);
  6533. break;
  6534. }
  6535. case InsertionMode.IN_CELL: {
  6536. startTagInCell(this, token);
  6537. break;
  6538. }
  6539. case InsertionMode.IN_SELECT: {
  6540. startTagInSelect(this, token);
  6541. break;
  6542. }
  6543. case InsertionMode.IN_SELECT_IN_TABLE: {
  6544. startTagInSelectInTable(this, token);
  6545. break;
  6546. }
  6547. case InsertionMode.IN_TEMPLATE: {
  6548. startTagInTemplate(this, token);
  6549. break;
  6550. }
  6551. case InsertionMode.AFTER_BODY: {
  6552. startTagAfterBody(this, token);
  6553. break;
  6554. }
  6555. case InsertionMode.IN_FRAMESET: {
  6556. startTagInFrameset(this, token);
  6557. break;
  6558. }
  6559. case InsertionMode.AFTER_FRAMESET: {
  6560. startTagAfterFrameset(this, token);
  6561. break;
  6562. }
  6563. case InsertionMode.AFTER_AFTER_BODY: {
  6564. startTagAfterAfterBody(this, token);
  6565. break;
  6566. }
  6567. case InsertionMode.AFTER_AFTER_FRAMESET: {
  6568. startTagAfterAfterFrameset(this, token);
  6569. break;
  6570. }
  6571. default:
  6572. }
  6573. }
  6574. onEndTag(token) {
  6575. this.skipNextNewLine = false;
  6576. this.currentToken = token;
  6577. if (this.currentNotInHTML) {
  6578. endTagInForeignContent(this, token);
  6579. } else {
  6580. this._endTagOutsideForeignContent(token);
  6581. }
  6582. }
  6583. _endTagOutsideForeignContent(token) {
  6584. switch (this.insertionMode) {
  6585. case InsertionMode.INITIAL: {
  6586. tokenInInitialMode(this, token);
  6587. break;
  6588. }
  6589. case InsertionMode.BEFORE_HTML: {
  6590. endTagBeforeHtml(this, token);
  6591. break;
  6592. }
  6593. case InsertionMode.BEFORE_HEAD: {
  6594. endTagBeforeHead(this, token);
  6595. break;
  6596. }
  6597. case InsertionMode.IN_HEAD: {
  6598. endTagInHead(this, token);
  6599. break;
  6600. }
  6601. case InsertionMode.IN_HEAD_NO_SCRIPT: {
  6602. endTagInHeadNoScript(this, token);
  6603. break;
  6604. }
  6605. case InsertionMode.AFTER_HEAD: {
  6606. endTagAfterHead(this, token);
  6607. break;
  6608. }
  6609. case InsertionMode.IN_BODY: {
  6610. endTagInBody(this, token);
  6611. break;
  6612. }
  6613. case InsertionMode.TEXT: {
  6614. endTagInText(this, token);
  6615. break;
  6616. }
  6617. case InsertionMode.IN_TABLE: {
  6618. endTagInTable(this, token);
  6619. break;
  6620. }
  6621. case InsertionMode.IN_TABLE_TEXT: {
  6622. tokenInTableText(this, token);
  6623. break;
  6624. }
  6625. case InsertionMode.IN_CAPTION: {
  6626. endTagInCaption(this, token);
  6627. break;
  6628. }
  6629. case InsertionMode.IN_COLUMN_GROUP: {
  6630. endTagInColumnGroup(this, token);
  6631. break;
  6632. }
  6633. case InsertionMode.IN_TABLE_BODY: {
  6634. endTagInTableBody(this, token);
  6635. break;
  6636. }
  6637. case InsertionMode.IN_ROW: {
  6638. endTagInRow(this, token);
  6639. break;
  6640. }
  6641. case InsertionMode.IN_CELL: {
  6642. endTagInCell(this, token);
  6643. break;
  6644. }
  6645. case InsertionMode.IN_SELECT: {
  6646. endTagInSelect(this, token);
  6647. break;
  6648. }
  6649. case InsertionMode.IN_SELECT_IN_TABLE: {
  6650. endTagInSelectInTable(this, token);
  6651. break;
  6652. }
  6653. case InsertionMode.IN_TEMPLATE: {
  6654. endTagInTemplate(this, token);
  6655. break;
  6656. }
  6657. case InsertionMode.AFTER_BODY: {
  6658. endTagAfterBody(this, token);
  6659. break;
  6660. }
  6661. case InsertionMode.IN_FRAMESET: {
  6662. endTagInFrameset(this, token);
  6663. break;
  6664. }
  6665. case InsertionMode.AFTER_FRAMESET: {
  6666. endTagAfterFrameset(this, token);
  6667. break;
  6668. }
  6669. case InsertionMode.AFTER_AFTER_BODY: {
  6670. tokenAfterAfterBody(this, token);
  6671. break;
  6672. }
  6673. default:
  6674. }
  6675. }
  6676. onEof(token) {
  6677. switch (this.insertionMode) {
  6678. case InsertionMode.INITIAL: {
  6679. tokenInInitialMode(this, token);
  6680. break;
  6681. }
  6682. case InsertionMode.BEFORE_HTML: {
  6683. tokenBeforeHtml(this, token);
  6684. break;
  6685. }
  6686. case InsertionMode.BEFORE_HEAD: {
  6687. tokenBeforeHead(this, token);
  6688. break;
  6689. }
  6690. case InsertionMode.IN_HEAD: {
  6691. tokenInHead(this, token);
  6692. break;
  6693. }
  6694. case InsertionMode.IN_HEAD_NO_SCRIPT: {
  6695. tokenInHeadNoScript(this, token);
  6696. break;
  6697. }
  6698. case InsertionMode.AFTER_HEAD: {
  6699. tokenAfterHead(this, token);
  6700. break;
  6701. }
  6702. case InsertionMode.IN_BODY:
  6703. case InsertionMode.IN_TABLE:
  6704. case InsertionMode.IN_CAPTION:
  6705. case InsertionMode.IN_COLUMN_GROUP:
  6706. case InsertionMode.IN_TABLE_BODY:
  6707. case InsertionMode.IN_ROW:
  6708. case InsertionMode.IN_CELL:
  6709. case InsertionMode.IN_SELECT:
  6710. case InsertionMode.IN_SELECT_IN_TABLE: {
  6711. eofInBody(this, token);
  6712. break;
  6713. }
  6714. case InsertionMode.TEXT: {
  6715. eofInText(this, token);
  6716. break;
  6717. }
  6718. case InsertionMode.IN_TABLE_TEXT: {
  6719. tokenInTableText(this, token);
  6720. break;
  6721. }
  6722. case InsertionMode.IN_TEMPLATE: {
  6723. eofInTemplate(this, token);
  6724. break;
  6725. }
  6726. case InsertionMode.AFTER_BODY:
  6727. case InsertionMode.IN_FRAMESET:
  6728. case InsertionMode.AFTER_FRAMESET:
  6729. case InsertionMode.AFTER_AFTER_BODY:
  6730. case InsertionMode.AFTER_AFTER_FRAMESET: {
  6731. stopParsing(this, token);
  6732. break;
  6733. }
  6734. default:
  6735. }
  6736. }
  6737. onWhitespaceCharacter(token) {
  6738. if (this.skipNextNewLine) {
  6739. this.skipNextNewLine = false;
  6740. if (token.chars.charCodeAt(0) === CODE_POINTS.LINE_FEED) {
  6741. if (token.chars.length === 1) {
  6742. return;
  6743. }
  6744. token.chars = token.chars.substr(1);
  6745. }
  6746. }
  6747. if (this.tokenizer.inForeignNode) {
  6748. this._insertCharacters(token);
  6749. return;
  6750. }
  6751. switch (this.insertionMode) {
  6752. case InsertionMode.IN_HEAD:
  6753. case InsertionMode.IN_HEAD_NO_SCRIPT:
  6754. case InsertionMode.AFTER_HEAD:
  6755. case InsertionMode.TEXT:
  6756. case InsertionMode.IN_COLUMN_GROUP:
  6757. case InsertionMode.IN_SELECT:
  6758. case InsertionMode.IN_SELECT_IN_TABLE:
  6759. case InsertionMode.IN_FRAMESET:
  6760. case InsertionMode.AFTER_FRAMESET: {
  6761. this._insertCharacters(token);
  6762. break;
  6763. }
  6764. case InsertionMode.IN_BODY:
  6765. case InsertionMode.IN_CAPTION:
  6766. case InsertionMode.IN_CELL:
  6767. case InsertionMode.IN_TEMPLATE:
  6768. case InsertionMode.AFTER_BODY:
  6769. case InsertionMode.AFTER_AFTER_BODY:
  6770. case InsertionMode.AFTER_AFTER_FRAMESET: {
  6771. whitespaceCharacterInBody(this, token);
  6772. break;
  6773. }
  6774. case InsertionMode.IN_TABLE:
  6775. case InsertionMode.IN_TABLE_BODY:
  6776. case InsertionMode.IN_ROW: {
  6777. characterInTable(this, token);
  6778. break;
  6779. }
  6780. case InsertionMode.IN_TABLE_TEXT: {
  6781. whitespaceCharacterInTableText(this, token);
  6782. break;
  6783. }
  6784. default:
  6785. }
  6786. }
  6787. };
  6788. function aaObtainFormattingElementEntry(p, token) {
  6789. let formattingElementEntry = p.activeFormattingElements.getElementEntryInScopeWithTagName(token.tagName);
  6790. if (formattingElementEntry) {
  6791. if (!p.openElements.contains(formattingElementEntry.element)) {
  6792. p.activeFormattingElements.removeEntry(formattingElementEntry);
  6793. formattingElementEntry = null;
  6794. } else if (!p.openElements.hasInScope(token.tagID)) {
  6795. formattingElementEntry = null;
  6796. }
  6797. } else {
  6798. genericEndTagInBody(p, token);
  6799. }
  6800. return formattingElementEntry;
  6801. }
  6802. function aaObtainFurthestBlock(p, formattingElementEntry) {
  6803. let furthestBlock = null;
  6804. let idx = p.openElements.stackTop;
  6805. for (; idx >= 0; idx--) {
  6806. const element = p.openElements.items[idx];
  6807. if (element === formattingElementEntry.element) {
  6808. break;
  6809. }
  6810. if (p._isSpecialElement(element, p.openElements.tagIDs[idx])) {
  6811. furthestBlock = element;
  6812. }
  6813. }
  6814. if (!furthestBlock) {
  6815. p.openElements.shortenToLength(idx < 0 ? 0 : idx);
  6816. p.activeFormattingElements.removeEntry(formattingElementEntry);
  6817. }
  6818. return furthestBlock;
  6819. }
  6820. function aaInnerLoop(p, furthestBlock, formattingElement) {
  6821. let lastElement = furthestBlock;
  6822. let nextElement = p.openElements.getCommonAncestor(furthestBlock);
  6823. for (let i = 0, element = nextElement; element !== formattingElement; i++, element = nextElement) {
  6824. nextElement = p.openElements.getCommonAncestor(element);
  6825. const elementEntry = p.activeFormattingElements.getElementEntry(element);
  6826. const counterOverflow = elementEntry && i >= AA_INNER_LOOP_ITER;
  6827. const shouldRemoveFromOpenElements = !elementEntry || counterOverflow;
  6828. if (shouldRemoveFromOpenElements) {
  6829. if (counterOverflow) {
  6830. p.activeFormattingElements.removeEntry(elementEntry);
  6831. }
  6832. p.openElements.remove(element);
  6833. } else {
  6834. element = aaRecreateElementFromEntry(p, elementEntry);
  6835. if (lastElement === furthestBlock) {
  6836. p.activeFormattingElements.bookmark = elementEntry;
  6837. }
  6838. p.treeAdapter.detachNode(lastElement);
  6839. p.treeAdapter.appendChild(element, lastElement);
  6840. lastElement = element;
  6841. }
  6842. }
  6843. return lastElement;
  6844. }
  6845. function aaRecreateElementFromEntry(p, elementEntry) {
  6846. const ns = p.treeAdapter.getNamespaceURI(elementEntry.element);
  6847. const newElement = p.treeAdapter.createElement(elementEntry.token.tagName, ns, elementEntry.token.attrs);
  6848. p.openElements.replace(elementEntry.element, newElement);
  6849. elementEntry.element = newElement;
  6850. return newElement;
  6851. }
  6852. function aaInsertLastNodeInCommonAncestor(p, commonAncestor, lastElement) {
  6853. const tn = p.treeAdapter.getTagName(commonAncestor);
  6854. const tid = getTagID(tn);
  6855. if (p._isElementCausesFosterParenting(tid)) {
  6856. p._fosterParentElement(lastElement);
  6857. } else {
  6858. const ns = p.treeAdapter.getNamespaceURI(commonAncestor);
  6859. if (tid === TAG_ID.TEMPLATE && ns === NS.HTML) {
  6860. commonAncestor = p.treeAdapter.getTemplateContent(commonAncestor);
  6861. }
  6862. p.treeAdapter.appendChild(commonAncestor, lastElement);
  6863. }
  6864. }
  6865. function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {
  6866. const ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element);
  6867. const { token } = formattingElementEntry;
  6868. const newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);
  6869. p._adoptNodes(furthestBlock, newElement);
  6870. p.treeAdapter.appendChild(furthestBlock, newElement);
  6871. p.activeFormattingElements.insertElementAfterBookmark(newElement, token);
  6872. p.activeFormattingElements.removeEntry(formattingElementEntry);
  6873. p.openElements.remove(formattingElementEntry.element);
  6874. p.openElements.insertAfter(furthestBlock, newElement, token.tagID);
  6875. }
  6876. function callAdoptionAgency(p, token) {
  6877. for (let i = 0; i < AA_OUTER_LOOP_ITER; i++) {
  6878. const formattingElementEntry = aaObtainFormattingElementEntry(p, token);
  6879. if (!formattingElementEntry) {
  6880. break;
  6881. }
  6882. const furthestBlock = aaObtainFurthestBlock(p, formattingElementEntry);
  6883. if (!furthestBlock) {
  6884. break;
  6885. }
  6886. p.activeFormattingElements.bookmark = formattingElementEntry;
  6887. const lastElement = aaInnerLoop(p, furthestBlock, formattingElementEntry.element);
  6888. const commonAncestor = p.openElements.getCommonAncestor(formattingElementEntry.element);
  6889. p.treeAdapter.detachNode(lastElement);
  6890. if (commonAncestor)
  6891. aaInsertLastNodeInCommonAncestor(p, commonAncestor, lastElement);
  6892. aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry);
  6893. }
  6894. }
  6895. function appendComment(p, token) {
  6896. p._appendCommentNode(token, p.openElements.currentTmplContentOrNode);
  6897. }
  6898. function appendCommentToRootHtmlElement(p, token) {
  6899. p._appendCommentNode(token, p.openElements.items[0]);
  6900. }
  6901. function appendCommentToDocument(p, token) {
  6902. p._appendCommentNode(token, p.document);
  6903. }
  6904. function stopParsing(p, token) {
  6905. p.stopped = true;
  6906. if (token.location) {
  6907. const target = p.fragmentContext ? 0 : 2;
  6908. for (let i = p.openElements.stackTop; i >= target; i--) {
  6909. p._setEndLocation(p.openElements.items[i], token);
  6910. }
  6911. if (!p.fragmentContext && p.openElements.stackTop >= 0) {
  6912. const htmlElement = p.openElements.items[0];
  6913. const htmlLocation = p.treeAdapter.getNodeSourceCodeLocation(htmlElement);
  6914. if (htmlLocation && !htmlLocation.endTag) {
  6915. p._setEndLocation(htmlElement, token);
  6916. if (p.openElements.stackTop >= 1) {
  6917. const bodyElement = p.openElements.items[1];
  6918. const bodyLocation = p.treeAdapter.getNodeSourceCodeLocation(bodyElement);
  6919. if (bodyLocation && !bodyLocation.endTag) {
  6920. p._setEndLocation(bodyElement, token);
  6921. }
  6922. }
  6923. }
  6924. }
  6925. }
  6926. }
  6927. function doctypeInInitialMode(p, token) {
  6928. p._setDocumentType(token);
  6929. const mode = token.forceQuirks ? DOCUMENT_MODE.QUIRKS : getDocumentMode(token);
  6930. if (!isConforming(token)) {
  6931. p._err(token, ERR.nonConformingDoctype);
  6932. }
  6933. p.treeAdapter.setDocumentMode(p.document, mode);
  6934. p.insertionMode = InsertionMode.BEFORE_HTML;
  6935. }
  6936. function tokenInInitialMode(p, token) {
  6937. p._err(token, ERR.missingDoctype, true);
  6938. p.treeAdapter.setDocumentMode(p.document, DOCUMENT_MODE.QUIRKS);
  6939. p.insertionMode = InsertionMode.BEFORE_HTML;
  6940. p._processToken(token);
  6941. }
  6942. function startTagBeforeHtml(p, token) {
  6943. if (token.tagID === TAG_ID.HTML) {
  6944. p._insertElement(token, NS.HTML);
  6945. p.insertionMode = InsertionMode.BEFORE_HEAD;
  6946. } else {
  6947. tokenBeforeHtml(p, token);
  6948. }
  6949. }
  6950. function endTagBeforeHtml(p, token) {
  6951. const tn = token.tagID;
  6952. if (tn === TAG_ID.HTML || tn === TAG_ID.HEAD || tn === TAG_ID.BODY || tn === TAG_ID.BR) {
  6953. tokenBeforeHtml(p, token);
  6954. }
  6955. }
  6956. function tokenBeforeHtml(p, token) {
  6957. p._insertFakeRootElement();
  6958. p.insertionMode = InsertionMode.BEFORE_HEAD;
  6959. p._processToken(token);
  6960. }
  6961. function startTagBeforeHead(p, token) {
  6962. switch (token.tagID) {
  6963. case TAG_ID.HTML: {
  6964. startTagInBody(p, token);
  6965. break;
  6966. }
  6967. case TAG_ID.HEAD: {
  6968. p._insertElement(token, NS.HTML);
  6969. p.headElement = p.openElements.current;
  6970. p.insertionMode = InsertionMode.IN_HEAD;
  6971. break;
  6972. }
  6973. default: {
  6974. tokenBeforeHead(p, token);
  6975. }
  6976. }
  6977. }
  6978. function endTagBeforeHead(p, token) {
  6979. const tn = token.tagID;
  6980. if (tn === TAG_ID.HEAD || tn === TAG_ID.BODY || tn === TAG_ID.HTML || tn === TAG_ID.BR) {
  6981. tokenBeforeHead(p, token);
  6982. } else {
  6983. p._err(token, ERR.endTagWithoutMatchingOpenElement);
  6984. }
  6985. }
  6986. function tokenBeforeHead(p, token) {
  6987. p._insertFakeElement(TAG_NAMES.HEAD, TAG_ID.HEAD);
  6988. p.headElement = p.openElements.current;
  6989. p.insertionMode = InsertionMode.IN_HEAD;
  6990. p._processToken(token);
  6991. }
  6992. function startTagInHead(p, token) {
  6993. switch (token.tagID) {
  6994. case TAG_ID.HTML: {
  6995. startTagInBody(p, token);
  6996. break;
  6997. }
  6998. case TAG_ID.BASE:
  6999. case TAG_ID.BASEFONT:
  7000. case TAG_ID.BGSOUND:
  7001. case TAG_ID.LINK:
  7002. case TAG_ID.META: {
  7003. p._appendElement(token, NS.HTML);
  7004. token.ackSelfClosing = true;
  7005. break;
  7006. }
  7007. case TAG_ID.TITLE: {
  7008. p._switchToTextParsing(token, TokenizerMode.RCDATA);
  7009. break;
  7010. }
  7011. case TAG_ID.NOSCRIPT: {
  7012. if (p.options.scriptingEnabled) {
  7013. p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
  7014. } else {
  7015. p._insertElement(token, NS.HTML);
  7016. p.insertionMode = InsertionMode.IN_HEAD_NO_SCRIPT;
  7017. }
  7018. break;
  7019. }
  7020. case TAG_ID.NOFRAMES:
  7021. case TAG_ID.STYLE: {
  7022. p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
  7023. break;
  7024. }
  7025. case TAG_ID.SCRIPT: {
  7026. p._switchToTextParsing(token, TokenizerMode.SCRIPT_DATA);
  7027. break;
  7028. }
  7029. case TAG_ID.TEMPLATE: {
  7030. p._insertTemplate(token);
  7031. p.activeFormattingElements.insertMarker();
  7032. p.framesetOk = false;
  7033. p.insertionMode = InsertionMode.IN_TEMPLATE;
  7034. p.tmplInsertionModeStack.unshift(InsertionMode.IN_TEMPLATE);
  7035. break;
  7036. }
  7037. case TAG_ID.HEAD: {
  7038. p._err(token, ERR.misplacedStartTagForHeadElement);
  7039. break;
  7040. }
  7041. default: {
  7042. tokenInHead(p, token);
  7043. }
  7044. }
  7045. }
  7046. function endTagInHead(p, token) {
  7047. switch (token.tagID) {
  7048. case TAG_ID.HEAD: {
  7049. p.openElements.pop();
  7050. p.insertionMode = InsertionMode.AFTER_HEAD;
  7051. break;
  7052. }
  7053. case TAG_ID.BODY:
  7054. case TAG_ID.BR:
  7055. case TAG_ID.HTML: {
  7056. tokenInHead(p, token);
  7057. break;
  7058. }
  7059. case TAG_ID.TEMPLATE: {
  7060. templateEndTagInHead(p, token);
  7061. break;
  7062. }
  7063. default: {
  7064. p._err(token, ERR.endTagWithoutMatchingOpenElement);
  7065. }
  7066. }
  7067. }
  7068. function templateEndTagInHead(p, token) {
  7069. if (p.openElements.tmplCount > 0) {
  7070. p.openElements.generateImpliedEndTagsThoroughly();
  7071. if (p.openElements.currentTagId !== TAG_ID.TEMPLATE) {
  7072. p._err(token, ERR.closingOfElementWithOpenChildElements);
  7073. }
  7074. p.openElements.popUntilTagNamePopped(TAG_ID.TEMPLATE);
  7075. p.activeFormattingElements.clearToLastMarker();
  7076. p.tmplInsertionModeStack.shift();
  7077. p._resetInsertionMode();
  7078. } else {
  7079. p._err(token, ERR.endTagWithoutMatchingOpenElement);
  7080. }
  7081. }
  7082. function tokenInHead(p, token) {
  7083. p.openElements.pop();
  7084. p.insertionMode = InsertionMode.AFTER_HEAD;
  7085. p._processToken(token);
  7086. }
  7087. function startTagInHeadNoScript(p, token) {
  7088. switch (token.tagID) {
  7089. case TAG_ID.HTML: {
  7090. startTagInBody(p, token);
  7091. break;
  7092. }
  7093. case TAG_ID.BASEFONT:
  7094. case TAG_ID.BGSOUND:
  7095. case TAG_ID.HEAD:
  7096. case TAG_ID.LINK:
  7097. case TAG_ID.META:
  7098. case TAG_ID.NOFRAMES:
  7099. case TAG_ID.STYLE: {
  7100. startTagInHead(p, token);
  7101. break;
  7102. }
  7103. case TAG_ID.NOSCRIPT: {
  7104. p._err(token, ERR.nestedNoscriptInHead);
  7105. break;
  7106. }
  7107. default: {
  7108. tokenInHeadNoScript(p, token);
  7109. }
  7110. }
  7111. }
  7112. function endTagInHeadNoScript(p, token) {
  7113. switch (token.tagID) {
  7114. case TAG_ID.NOSCRIPT: {
  7115. p.openElements.pop();
  7116. p.insertionMode = InsertionMode.IN_HEAD;
  7117. break;
  7118. }
  7119. case TAG_ID.BR: {
  7120. tokenInHeadNoScript(p, token);
  7121. break;
  7122. }
  7123. default: {
  7124. p._err(token, ERR.endTagWithoutMatchingOpenElement);
  7125. }
  7126. }
  7127. }
  7128. function tokenInHeadNoScript(p, token) {
  7129. const errCode = token.type === TokenType.EOF ? ERR.openElementsLeftAfterEof : ERR.disallowedContentInNoscriptInHead;
  7130. p._err(token, errCode);
  7131. p.openElements.pop();
  7132. p.insertionMode = InsertionMode.IN_HEAD;
  7133. p._processToken(token);
  7134. }
  7135. function startTagAfterHead(p, token) {
  7136. switch (token.tagID) {
  7137. case TAG_ID.HTML: {
  7138. startTagInBody(p, token);
  7139. break;
  7140. }
  7141. case TAG_ID.BODY: {
  7142. p._insertElement(token, NS.HTML);
  7143. p.framesetOk = false;
  7144. p.insertionMode = InsertionMode.IN_BODY;
  7145. break;
  7146. }
  7147. case TAG_ID.FRAMESET: {
  7148. p._insertElement(token, NS.HTML);
  7149. p.insertionMode = InsertionMode.IN_FRAMESET;
  7150. break;
  7151. }
  7152. case TAG_ID.BASE:
  7153. case TAG_ID.BASEFONT:
  7154. case TAG_ID.BGSOUND:
  7155. case TAG_ID.LINK:
  7156. case TAG_ID.META:
  7157. case TAG_ID.NOFRAMES:
  7158. case TAG_ID.SCRIPT:
  7159. case TAG_ID.STYLE:
  7160. case TAG_ID.TEMPLATE:
  7161. case TAG_ID.TITLE: {
  7162. p._err(token, ERR.abandonedHeadElementChild);
  7163. p.openElements.push(p.headElement, TAG_ID.HEAD);
  7164. startTagInHead(p, token);
  7165. p.openElements.remove(p.headElement);
  7166. break;
  7167. }
  7168. case TAG_ID.HEAD: {
  7169. p._err(token, ERR.misplacedStartTagForHeadElement);
  7170. break;
  7171. }
  7172. default: {
  7173. tokenAfterHead(p, token);
  7174. }
  7175. }
  7176. }
  7177. function endTagAfterHead(p, token) {
  7178. switch (token.tagID) {
  7179. case TAG_ID.BODY:
  7180. case TAG_ID.HTML:
  7181. case TAG_ID.BR: {
  7182. tokenAfterHead(p, token);
  7183. break;
  7184. }
  7185. case TAG_ID.TEMPLATE: {
  7186. templateEndTagInHead(p, token);
  7187. break;
  7188. }
  7189. default: {
  7190. p._err(token, ERR.endTagWithoutMatchingOpenElement);
  7191. }
  7192. }
  7193. }
  7194. function tokenAfterHead(p, token) {
  7195. p._insertFakeElement(TAG_NAMES.BODY, TAG_ID.BODY);
  7196. p.insertionMode = InsertionMode.IN_BODY;
  7197. modeInBody(p, token);
  7198. }
  7199. function modeInBody(p, token) {
  7200. switch (token.type) {
  7201. case TokenType.CHARACTER: {
  7202. characterInBody(p, token);
  7203. break;
  7204. }
  7205. case TokenType.WHITESPACE_CHARACTER: {
  7206. whitespaceCharacterInBody(p, token);
  7207. break;
  7208. }
  7209. case TokenType.COMMENT: {
  7210. appendComment(p, token);
  7211. break;
  7212. }
  7213. case TokenType.START_TAG: {
  7214. startTagInBody(p, token);
  7215. break;
  7216. }
  7217. case TokenType.END_TAG: {
  7218. endTagInBody(p, token);
  7219. break;
  7220. }
  7221. case TokenType.EOF: {
  7222. eofInBody(p, token);
  7223. break;
  7224. }
  7225. default:
  7226. }
  7227. }
  7228. function whitespaceCharacterInBody(p, token) {
  7229. p._reconstructActiveFormattingElements();
  7230. p._insertCharacters(token);
  7231. }
  7232. function characterInBody(p, token) {
  7233. p._reconstructActiveFormattingElements();
  7234. p._insertCharacters(token);
  7235. p.framesetOk = false;
  7236. }
  7237. function htmlStartTagInBody(p, token) {
  7238. if (p.openElements.tmplCount === 0) {
  7239. p.treeAdapter.adoptAttributes(p.openElements.items[0], token.attrs);
  7240. }
  7241. }
  7242. function bodyStartTagInBody(p, token) {
  7243. const bodyElement = p.openElements.tryPeekProperlyNestedBodyElement();
  7244. if (bodyElement && p.openElements.tmplCount === 0) {
  7245. p.framesetOk = false;
  7246. p.treeAdapter.adoptAttributes(bodyElement, token.attrs);
  7247. }
  7248. }
  7249. function framesetStartTagInBody(p, token) {
  7250. const bodyElement = p.openElements.tryPeekProperlyNestedBodyElement();
  7251. if (p.framesetOk && bodyElement) {
  7252. p.treeAdapter.detachNode(bodyElement);
  7253. p.openElements.popAllUpToHtmlElement();
  7254. p._insertElement(token, NS.HTML);
  7255. p.insertionMode = InsertionMode.IN_FRAMESET;
  7256. }
  7257. }
  7258. function addressStartTagInBody(p, token) {
  7259. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  7260. p._closePElement();
  7261. }
  7262. p._insertElement(token, NS.HTML);
  7263. }
  7264. function numberedHeaderStartTagInBody(p, token) {
  7265. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  7266. p._closePElement();
  7267. }
  7268. if (isNumberedHeader(p.openElements.currentTagId)) {
  7269. p.openElements.pop();
  7270. }
  7271. p._insertElement(token, NS.HTML);
  7272. }
  7273. function preStartTagInBody(p, token) {
  7274. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  7275. p._closePElement();
  7276. }
  7277. p._insertElement(token, NS.HTML);
  7278. p.skipNextNewLine = true;
  7279. p.framesetOk = false;
  7280. }
  7281. function formStartTagInBody(p, token) {
  7282. const inTemplate = p.openElements.tmplCount > 0;
  7283. if (!p.formElement || inTemplate) {
  7284. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  7285. p._closePElement();
  7286. }
  7287. p._insertElement(token, NS.HTML);
  7288. if (!inTemplate) {
  7289. p.formElement = p.openElements.current;
  7290. }
  7291. }
  7292. }
  7293. function listItemStartTagInBody(p, token) {
  7294. p.framesetOk = false;
  7295. const tn = token.tagID;
  7296. for (let i = p.openElements.stackTop; i >= 0; i--) {
  7297. const elementId = p.openElements.tagIDs[i];
  7298. if (tn === TAG_ID.LI && elementId === TAG_ID.LI || (tn === TAG_ID.DD || tn === TAG_ID.DT) && (elementId === TAG_ID.DD || elementId === TAG_ID.DT)) {
  7299. p.openElements.generateImpliedEndTagsWithExclusion(elementId);
  7300. p.openElements.popUntilTagNamePopped(elementId);
  7301. break;
  7302. }
  7303. if (elementId !== TAG_ID.ADDRESS && elementId !== TAG_ID.DIV && elementId !== TAG_ID.P && p._isSpecialElement(p.openElements.items[i], elementId)) {
  7304. break;
  7305. }
  7306. }
  7307. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  7308. p._closePElement();
  7309. }
  7310. p._insertElement(token, NS.HTML);
  7311. }
  7312. function plaintextStartTagInBody(p, token) {
  7313. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  7314. p._closePElement();
  7315. }
  7316. p._insertElement(token, NS.HTML);
  7317. p.tokenizer.state = TokenizerMode.PLAINTEXT;
  7318. }
  7319. function buttonStartTagInBody(p, token) {
  7320. if (p.openElements.hasInScope(TAG_ID.BUTTON)) {
  7321. p.openElements.generateImpliedEndTags();
  7322. p.openElements.popUntilTagNamePopped(TAG_ID.BUTTON);
  7323. }
  7324. p._reconstructActiveFormattingElements();
  7325. p._insertElement(token, NS.HTML);
  7326. p.framesetOk = false;
  7327. }
  7328. function aStartTagInBody(p, token) {
  7329. const activeElementEntry = p.activeFormattingElements.getElementEntryInScopeWithTagName(TAG_NAMES.A);
  7330. if (activeElementEntry) {
  7331. callAdoptionAgency(p, token);
  7332. p.openElements.remove(activeElementEntry.element);
  7333. p.activeFormattingElements.removeEntry(activeElementEntry);
  7334. }
  7335. p._reconstructActiveFormattingElements();
  7336. p._insertElement(token, NS.HTML);
  7337. p.activeFormattingElements.pushElement(p.openElements.current, token);
  7338. }
  7339. function bStartTagInBody(p, token) {
  7340. p._reconstructActiveFormattingElements();
  7341. p._insertElement(token, NS.HTML);
  7342. p.activeFormattingElements.pushElement(p.openElements.current, token);
  7343. }
  7344. function nobrStartTagInBody(p, token) {
  7345. p._reconstructActiveFormattingElements();
  7346. if (p.openElements.hasInScope(TAG_ID.NOBR)) {
  7347. callAdoptionAgency(p, token);
  7348. p._reconstructActiveFormattingElements();
  7349. }
  7350. p._insertElement(token, NS.HTML);
  7351. p.activeFormattingElements.pushElement(p.openElements.current, token);
  7352. }
  7353. function appletStartTagInBody(p, token) {
  7354. p._reconstructActiveFormattingElements();
  7355. p._insertElement(token, NS.HTML);
  7356. p.activeFormattingElements.insertMarker();
  7357. p.framesetOk = false;
  7358. }
  7359. function tableStartTagInBody(p, token) {
  7360. if (p.treeAdapter.getDocumentMode(p.document) !== DOCUMENT_MODE.QUIRKS && p.openElements.hasInButtonScope(TAG_ID.P)) {
  7361. p._closePElement();
  7362. }
  7363. p._insertElement(token, NS.HTML);
  7364. p.framesetOk = false;
  7365. p.insertionMode = InsertionMode.IN_TABLE;
  7366. }
  7367. function areaStartTagInBody(p, token) {
  7368. p._reconstructActiveFormattingElements();
  7369. p._appendElement(token, NS.HTML);
  7370. p.framesetOk = false;
  7371. token.ackSelfClosing = true;
  7372. }
  7373. function isHiddenInput(token) {
  7374. const inputType = getTokenAttr(token, ATTRS.TYPE);
  7375. return inputType != null && inputType.toLowerCase() === HIDDEN_INPUT_TYPE;
  7376. }
  7377. function inputStartTagInBody(p, token) {
  7378. p._reconstructActiveFormattingElements();
  7379. p._appendElement(token, NS.HTML);
  7380. if (!isHiddenInput(token)) {
  7381. p.framesetOk = false;
  7382. }
  7383. token.ackSelfClosing = true;
  7384. }
  7385. function paramStartTagInBody(p, token) {
  7386. p._appendElement(token, NS.HTML);
  7387. token.ackSelfClosing = true;
  7388. }
  7389. function hrStartTagInBody(p, token) {
  7390. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  7391. p._closePElement();
  7392. }
  7393. p._appendElement(token, NS.HTML);
  7394. p.framesetOk = false;
  7395. token.ackSelfClosing = true;
  7396. }
  7397. function imageStartTagInBody(p, token) {
  7398. token.tagName = TAG_NAMES.IMG;
  7399. token.tagID = TAG_ID.IMG;
  7400. areaStartTagInBody(p, token);
  7401. }
  7402. function textareaStartTagInBody(p, token) {
  7403. p._insertElement(token, NS.HTML);
  7404. p.skipNextNewLine = true;
  7405. p.tokenizer.state = TokenizerMode.RCDATA;
  7406. p.originalInsertionMode = p.insertionMode;
  7407. p.framesetOk = false;
  7408. p.insertionMode = InsertionMode.TEXT;
  7409. }
  7410. function xmpStartTagInBody(p, token) {
  7411. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  7412. p._closePElement();
  7413. }
  7414. p._reconstructActiveFormattingElements();
  7415. p.framesetOk = false;
  7416. p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
  7417. }
  7418. function iframeStartTagInBody(p, token) {
  7419. p.framesetOk = false;
  7420. p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
  7421. }
  7422. function noembedStartTagInBody(p, token) {
  7423. p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
  7424. }
  7425. function selectStartTagInBody(p, token) {
  7426. p._reconstructActiveFormattingElements();
  7427. p._insertElement(token, NS.HTML);
  7428. p.framesetOk = false;
  7429. p.insertionMode = p.insertionMode === InsertionMode.IN_TABLE || p.insertionMode === InsertionMode.IN_CAPTION || p.insertionMode === InsertionMode.IN_TABLE_BODY || p.insertionMode === InsertionMode.IN_ROW || p.insertionMode === InsertionMode.IN_CELL ? InsertionMode.IN_SELECT_IN_TABLE : InsertionMode.IN_SELECT;
  7430. }
  7431. function optgroupStartTagInBody(p, token) {
  7432. if (p.openElements.currentTagId === TAG_ID.OPTION) {
  7433. p.openElements.pop();
  7434. }
  7435. p._reconstructActiveFormattingElements();
  7436. p._insertElement(token, NS.HTML);
  7437. }
  7438. function rbStartTagInBody(p, token) {
  7439. if (p.openElements.hasInScope(TAG_ID.RUBY)) {
  7440. p.openElements.generateImpliedEndTags();
  7441. }
  7442. p._insertElement(token, NS.HTML);
  7443. }
  7444. function rtStartTagInBody(p, token) {
  7445. if (p.openElements.hasInScope(TAG_ID.RUBY)) {
  7446. p.openElements.generateImpliedEndTagsWithExclusion(TAG_ID.RTC);
  7447. }
  7448. p._insertElement(token, NS.HTML);
  7449. }
  7450. function mathStartTagInBody(p, token) {
  7451. p._reconstructActiveFormattingElements();
  7452. adjustTokenMathMLAttrs(token);
  7453. adjustTokenXMLAttrs(token);
  7454. if (token.selfClosing) {
  7455. p._appendElement(token, NS.MATHML);
  7456. } else {
  7457. p._insertElement(token, NS.MATHML);
  7458. }
  7459. token.ackSelfClosing = true;
  7460. }
  7461. function svgStartTagInBody(p, token) {
  7462. p._reconstructActiveFormattingElements();
  7463. adjustTokenSVGAttrs(token);
  7464. adjustTokenXMLAttrs(token);
  7465. if (token.selfClosing) {
  7466. p._appendElement(token, NS.SVG);
  7467. } else {
  7468. p._insertElement(token, NS.SVG);
  7469. }
  7470. token.ackSelfClosing = true;
  7471. }
  7472. function genericStartTagInBody(p, token) {
  7473. p._reconstructActiveFormattingElements();
  7474. p._insertElement(token, NS.HTML);
  7475. }
  7476. function startTagInBody(p, token) {
  7477. switch (token.tagID) {
  7478. case TAG_ID.I:
  7479. case TAG_ID.S:
  7480. case TAG_ID.B:
  7481. case TAG_ID.U:
  7482. case TAG_ID.EM:
  7483. case TAG_ID.TT:
  7484. case TAG_ID.BIG:
  7485. case TAG_ID.CODE:
  7486. case TAG_ID.FONT:
  7487. case TAG_ID.SMALL:
  7488. case TAG_ID.STRIKE:
  7489. case TAG_ID.STRONG: {
  7490. bStartTagInBody(p, token);
  7491. break;
  7492. }
  7493. case TAG_ID.A: {
  7494. aStartTagInBody(p, token);
  7495. break;
  7496. }
  7497. case TAG_ID.H1:
  7498. case TAG_ID.H2:
  7499. case TAG_ID.H3:
  7500. case TAG_ID.H4:
  7501. case TAG_ID.H5:
  7502. case TAG_ID.H6: {
  7503. numberedHeaderStartTagInBody(p, token);
  7504. break;
  7505. }
  7506. case TAG_ID.P:
  7507. case TAG_ID.DL:
  7508. case TAG_ID.OL:
  7509. case TAG_ID.UL:
  7510. case TAG_ID.DIV:
  7511. case TAG_ID.DIR:
  7512. case TAG_ID.NAV:
  7513. case TAG_ID.MAIN:
  7514. case TAG_ID.MENU:
  7515. case TAG_ID.ASIDE:
  7516. case TAG_ID.CENTER:
  7517. case TAG_ID.FIGURE:
  7518. case TAG_ID.FOOTER:
  7519. case TAG_ID.HEADER:
  7520. case TAG_ID.HGROUP:
  7521. case TAG_ID.DIALOG:
  7522. case TAG_ID.DETAILS:
  7523. case TAG_ID.ADDRESS:
  7524. case TAG_ID.ARTICLE:
  7525. case TAG_ID.SECTION:
  7526. case TAG_ID.SUMMARY:
  7527. case TAG_ID.FIELDSET:
  7528. case TAG_ID.BLOCKQUOTE:
  7529. case TAG_ID.FIGCAPTION: {
  7530. addressStartTagInBody(p, token);
  7531. break;
  7532. }
  7533. case TAG_ID.LI:
  7534. case TAG_ID.DD:
  7535. case TAG_ID.DT: {
  7536. listItemStartTagInBody(p, token);
  7537. break;
  7538. }
  7539. case TAG_ID.BR:
  7540. case TAG_ID.IMG:
  7541. case TAG_ID.WBR:
  7542. case TAG_ID.AREA:
  7543. case TAG_ID.EMBED:
  7544. case TAG_ID.KEYGEN: {
  7545. areaStartTagInBody(p, token);
  7546. break;
  7547. }
  7548. case TAG_ID.HR: {
  7549. hrStartTagInBody(p, token);
  7550. break;
  7551. }
  7552. case TAG_ID.RB:
  7553. case TAG_ID.RTC: {
  7554. rbStartTagInBody(p, token);
  7555. break;
  7556. }
  7557. case TAG_ID.RT:
  7558. case TAG_ID.RP: {
  7559. rtStartTagInBody(p, token);
  7560. break;
  7561. }
  7562. case TAG_ID.PRE:
  7563. case TAG_ID.LISTING: {
  7564. preStartTagInBody(p, token);
  7565. break;
  7566. }
  7567. case TAG_ID.XMP: {
  7568. xmpStartTagInBody(p, token);
  7569. break;
  7570. }
  7571. case TAG_ID.SVG: {
  7572. svgStartTagInBody(p, token);
  7573. break;
  7574. }
  7575. case TAG_ID.HTML: {
  7576. htmlStartTagInBody(p, token);
  7577. break;
  7578. }
  7579. case TAG_ID.BASE:
  7580. case TAG_ID.LINK:
  7581. case TAG_ID.META:
  7582. case TAG_ID.STYLE:
  7583. case TAG_ID.TITLE:
  7584. case TAG_ID.SCRIPT:
  7585. case TAG_ID.BGSOUND:
  7586. case TAG_ID.BASEFONT:
  7587. case TAG_ID.TEMPLATE: {
  7588. startTagInHead(p, token);
  7589. break;
  7590. }
  7591. case TAG_ID.BODY: {
  7592. bodyStartTagInBody(p, token);
  7593. break;
  7594. }
  7595. case TAG_ID.FORM: {
  7596. formStartTagInBody(p, token);
  7597. break;
  7598. }
  7599. case TAG_ID.NOBR: {
  7600. nobrStartTagInBody(p, token);
  7601. break;
  7602. }
  7603. case TAG_ID.MATH: {
  7604. mathStartTagInBody(p, token);
  7605. break;
  7606. }
  7607. case TAG_ID.TABLE: {
  7608. tableStartTagInBody(p, token);
  7609. break;
  7610. }
  7611. case TAG_ID.INPUT: {
  7612. inputStartTagInBody(p, token);
  7613. break;
  7614. }
  7615. case TAG_ID.PARAM:
  7616. case TAG_ID.TRACK:
  7617. case TAG_ID.SOURCE: {
  7618. paramStartTagInBody(p, token);
  7619. break;
  7620. }
  7621. case TAG_ID.IMAGE: {
  7622. imageStartTagInBody(p, token);
  7623. break;
  7624. }
  7625. case TAG_ID.BUTTON: {
  7626. buttonStartTagInBody(p, token);
  7627. break;
  7628. }
  7629. case TAG_ID.APPLET:
  7630. case TAG_ID.OBJECT:
  7631. case TAG_ID.MARQUEE: {
  7632. appletStartTagInBody(p, token);
  7633. break;
  7634. }
  7635. case TAG_ID.IFRAME: {
  7636. iframeStartTagInBody(p, token);
  7637. break;
  7638. }
  7639. case TAG_ID.SELECT: {
  7640. selectStartTagInBody(p, token);
  7641. break;
  7642. }
  7643. case TAG_ID.OPTION:
  7644. case TAG_ID.OPTGROUP: {
  7645. optgroupStartTagInBody(p, token);
  7646. break;
  7647. }
  7648. case TAG_ID.NOEMBED: {
  7649. noembedStartTagInBody(p, token);
  7650. break;
  7651. }
  7652. case TAG_ID.FRAMESET: {
  7653. framesetStartTagInBody(p, token);
  7654. break;
  7655. }
  7656. case TAG_ID.TEXTAREA: {
  7657. textareaStartTagInBody(p, token);
  7658. break;
  7659. }
  7660. case TAG_ID.NOSCRIPT: {
  7661. if (p.options.scriptingEnabled) {
  7662. noembedStartTagInBody(p, token);
  7663. } else {
  7664. genericStartTagInBody(p, token);
  7665. }
  7666. break;
  7667. }
  7668. case TAG_ID.PLAINTEXT: {
  7669. plaintextStartTagInBody(p, token);
  7670. break;
  7671. }
  7672. case TAG_ID.COL:
  7673. case TAG_ID.TH:
  7674. case TAG_ID.TD:
  7675. case TAG_ID.TR:
  7676. case TAG_ID.HEAD:
  7677. case TAG_ID.FRAME:
  7678. case TAG_ID.TBODY:
  7679. case TAG_ID.TFOOT:
  7680. case TAG_ID.THEAD:
  7681. case TAG_ID.CAPTION:
  7682. case TAG_ID.COLGROUP: {
  7683. break;
  7684. }
  7685. default: {
  7686. genericStartTagInBody(p, token);
  7687. }
  7688. }
  7689. }
  7690. function bodyEndTagInBody(p, token) {
  7691. if (p.openElements.hasInScope(TAG_ID.BODY)) {
  7692. p.insertionMode = InsertionMode.AFTER_BODY;
  7693. if (p.options.sourceCodeLocationInfo) {
  7694. const bodyElement = p.openElements.tryPeekProperlyNestedBodyElement();
  7695. if (bodyElement) {
  7696. p._setEndLocation(bodyElement, token);
  7697. }
  7698. }
  7699. }
  7700. }
  7701. function htmlEndTagInBody(p, token) {
  7702. if (p.openElements.hasInScope(TAG_ID.BODY)) {
  7703. p.insertionMode = InsertionMode.AFTER_BODY;
  7704. endTagAfterBody(p, token);
  7705. }
  7706. }
  7707. function addressEndTagInBody(p, token) {
  7708. const tn = token.tagID;
  7709. if (p.openElements.hasInScope(tn)) {
  7710. p.openElements.generateImpliedEndTags();
  7711. p.openElements.popUntilTagNamePopped(tn);
  7712. }
  7713. }
  7714. function formEndTagInBody(p) {
  7715. const inTemplate = p.openElements.tmplCount > 0;
  7716. const { formElement } = p;
  7717. if (!inTemplate) {
  7718. p.formElement = null;
  7719. }
  7720. if ((formElement || inTemplate) && p.openElements.hasInScope(TAG_ID.FORM)) {
  7721. p.openElements.generateImpliedEndTags();
  7722. if (inTemplate) {
  7723. p.openElements.popUntilTagNamePopped(TAG_ID.FORM);
  7724. } else if (formElement) {
  7725. p.openElements.remove(formElement);
  7726. }
  7727. }
  7728. }
  7729. function pEndTagInBody(p) {
  7730. if (!p.openElements.hasInButtonScope(TAG_ID.P)) {
  7731. p._insertFakeElement(TAG_NAMES.P, TAG_ID.P);
  7732. }
  7733. p._closePElement();
  7734. }
  7735. function liEndTagInBody(p) {
  7736. if (p.openElements.hasInListItemScope(TAG_ID.LI)) {
  7737. p.openElements.generateImpliedEndTagsWithExclusion(TAG_ID.LI);
  7738. p.openElements.popUntilTagNamePopped(TAG_ID.LI);
  7739. }
  7740. }
  7741. function ddEndTagInBody(p, token) {
  7742. const tn = token.tagID;
  7743. if (p.openElements.hasInScope(tn)) {
  7744. p.openElements.generateImpliedEndTagsWithExclusion(tn);
  7745. p.openElements.popUntilTagNamePopped(tn);
  7746. }
  7747. }
  7748. function numberedHeaderEndTagInBody(p) {
  7749. if (p.openElements.hasNumberedHeaderInScope()) {
  7750. p.openElements.generateImpliedEndTags();
  7751. p.openElements.popUntilNumberedHeaderPopped();
  7752. }
  7753. }
  7754. function appletEndTagInBody(p, token) {
  7755. const tn = token.tagID;
  7756. if (p.openElements.hasInScope(tn)) {
  7757. p.openElements.generateImpliedEndTags();
  7758. p.openElements.popUntilTagNamePopped(tn);
  7759. p.activeFormattingElements.clearToLastMarker();
  7760. }
  7761. }
  7762. function brEndTagInBody(p) {
  7763. p._reconstructActiveFormattingElements();
  7764. p._insertFakeElement(TAG_NAMES.BR, TAG_ID.BR);
  7765. p.openElements.pop();
  7766. p.framesetOk = false;
  7767. }
  7768. function genericEndTagInBody(p, token) {
  7769. const tn = token.tagName;
  7770. const tid = token.tagID;
  7771. for (let i = p.openElements.stackTop; i > 0; i--) {
  7772. const element = p.openElements.items[i];
  7773. const elementId = p.openElements.tagIDs[i];
  7774. if (tid === elementId && (tid !== TAG_ID.UNKNOWN || p.treeAdapter.getTagName(element) === tn)) {
  7775. p.openElements.generateImpliedEndTagsWithExclusion(tid);
  7776. if (p.openElements.stackTop >= i)
  7777. p.openElements.shortenToLength(i);
  7778. break;
  7779. }
  7780. if (p._isSpecialElement(element, elementId)) {
  7781. break;
  7782. }
  7783. }
  7784. }
  7785. function endTagInBody(p, token) {
  7786. switch (token.tagID) {
  7787. case TAG_ID.A:
  7788. case TAG_ID.B:
  7789. case TAG_ID.I:
  7790. case TAG_ID.S:
  7791. case TAG_ID.U:
  7792. case TAG_ID.EM:
  7793. case TAG_ID.TT:
  7794. case TAG_ID.BIG:
  7795. case TAG_ID.CODE:
  7796. case TAG_ID.FONT:
  7797. case TAG_ID.NOBR:
  7798. case TAG_ID.SMALL:
  7799. case TAG_ID.STRIKE:
  7800. case TAG_ID.STRONG: {
  7801. callAdoptionAgency(p, token);
  7802. break;
  7803. }
  7804. case TAG_ID.P: {
  7805. pEndTagInBody(p);
  7806. break;
  7807. }
  7808. case TAG_ID.DL:
  7809. case TAG_ID.UL:
  7810. case TAG_ID.OL:
  7811. case TAG_ID.DIR:
  7812. case TAG_ID.DIV:
  7813. case TAG_ID.NAV:
  7814. case TAG_ID.PRE:
  7815. case TAG_ID.MAIN:
  7816. case TAG_ID.MENU:
  7817. case TAG_ID.ASIDE:
  7818. case TAG_ID.BUTTON:
  7819. case TAG_ID.CENTER:
  7820. case TAG_ID.FIGURE:
  7821. case TAG_ID.FOOTER:
  7822. case TAG_ID.HEADER:
  7823. case TAG_ID.HGROUP:
  7824. case TAG_ID.DIALOG:
  7825. case TAG_ID.ADDRESS:
  7826. case TAG_ID.ARTICLE:
  7827. case TAG_ID.DETAILS:
  7828. case TAG_ID.SECTION:
  7829. case TAG_ID.SUMMARY:
  7830. case TAG_ID.LISTING:
  7831. case TAG_ID.FIELDSET:
  7832. case TAG_ID.BLOCKQUOTE:
  7833. case TAG_ID.FIGCAPTION: {
  7834. addressEndTagInBody(p, token);
  7835. break;
  7836. }
  7837. case TAG_ID.LI: {
  7838. liEndTagInBody(p);
  7839. break;
  7840. }
  7841. case TAG_ID.DD:
  7842. case TAG_ID.DT: {
  7843. ddEndTagInBody(p, token);
  7844. break;
  7845. }
  7846. case TAG_ID.H1:
  7847. case TAG_ID.H2:
  7848. case TAG_ID.H3:
  7849. case TAG_ID.H4:
  7850. case TAG_ID.H5:
  7851. case TAG_ID.H6: {
  7852. numberedHeaderEndTagInBody(p);
  7853. break;
  7854. }
  7855. case TAG_ID.BR: {
  7856. brEndTagInBody(p);
  7857. break;
  7858. }
  7859. case TAG_ID.BODY: {
  7860. bodyEndTagInBody(p, token);
  7861. break;
  7862. }
  7863. case TAG_ID.HTML: {
  7864. htmlEndTagInBody(p, token);
  7865. break;
  7866. }
  7867. case TAG_ID.FORM: {
  7868. formEndTagInBody(p);
  7869. break;
  7870. }
  7871. case TAG_ID.APPLET:
  7872. case TAG_ID.OBJECT:
  7873. case TAG_ID.MARQUEE: {
  7874. appletEndTagInBody(p, token);
  7875. break;
  7876. }
  7877. case TAG_ID.TEMPLATE: {
  7878. templateEndTagInHead(p, token);
  7879. break;
  7880. }
  7881. default: {
  7882. genericEndTagInBody(p, token);
  7883. }
  7884. }
  7885. }
  7886. function eofInBody(p, token) {
  7887. if (p.tmplInsertionModeStack.length > 0) {
  7888. eofInTemplate(p, token);
  7889. } else {
  7890. stopParsing(p, token);
  7891. }
  7892. }
  7893. function endTagInText(p, token) {
  7894. var _a2;
  7895. if (token.tagID === TAG_ID.SCRIPT) {
  7896. (_a2 = p.scriptHandler) === null || _a2 === void 0 ? void 0 : _a2.call(p, p.openElements.current);
  7897. }
  7898. p.openElements.pop();
  7899. p.insertionMode = p.originalInsertionMode;
  7900. }
  7901. function eofInText(p, token) {
  7902. p._err(token, ERR.eofInElementThatCanContainOnlyText);
  7903. p.openElements.pop();
  7904. p.insertionMode = p.originalInsertionMode;
  7905. p.onEof(token);
  7906. }
  7907. function characterInTable(p, token) {
  7908. if (TABLE_STRUCTURE_TAGS.has(p.openElements.currentTagId)) {
  7909. p.pendingCharacterTokens.length = 0;
  7910. p.hasNonWhitespacePendingCharacterToken = false;
  7911. p.originalInsertionMode = p.insertionMode;
  7912. p.insertionMode = InsertionMode.IN_TABLE_TEXT;
  7913. switch (token.type) {
  7914. case TokenType.CHARACTER: {
  7915. characterInTableText(p, token);
  7916. break;
  7917. }
  7918. case TokenType.WHITESPACE_CHARACTER: {
  7919. whitespaceCharacterInTableText(p, token);
  7920. break;
  7921. }
  7922. }
  7923. } else {
  7924. tokenInTable(p, token);
  7925. }
  7926. }
  7927. function captionStartTagInTable(p, token) {
  7928. p.openElements.clearBackToTableContext();
  7929. p.activeFormattingElements.insertMarker();
  7930. p._insertElement(token, NS.HTML);
  7931. p.insertionMode = InsertionMode.IN_CAPTION;
  7932. }
  7933. function colgroupStartTagInTable(p, token) {
  7934. p.openElements.clearBackToTableContext();
  7935. p._insertElement(token, NS.HTML);
  7936. p.insertionMode = InsertionMode.IN_COLUMN_GROUP;
  7937. }
  7938. function colStartTagInTable(p, token) {
  7939. p.openElements.clearBackToTableContext();
  7940. p._insertFakeElement(TAG_NAMES.COLGROUP, TAG_ID.COLGROUP);
  7941. p.insertionMode = InsertionMode.IN_COLUMN_GROUP;
  7942. startTagInColumnGroup(p, token);
  7943. }
  7944. function tbodyStartTagInTable(p, token) {
  7945. p.openElements.clearBackToTableContext();
  7946. p._insertElement(token, NS.HTML);
  7947. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  7948. }
  7949. function tdStartTagInTable(p, token) {
  7950. p.openElements.clearBackToTableContext();
  7951. p._insertFakeElement(TAG_NAMES.TBODY, TAG_ID.TBODY);
  7952. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  7953. startTagInTableBody(p, token);
  7954. }
  7955. function tableStartTagInTable(p, token) {
  7956. if (p.openElements.hasInTableScope(TAG_ID.TABLE)) {
  7957. p.openElements.popUntilTagNamePopped(TAG_ID.TABLE);
  7958. p._resetInsertionMode();
  7959. p._processStartTag(token);
  7960. }
  7961. }
  7962. function inputStartTagInTable(p, token) {
  7963. if (isHiddenInput(token)) {
  7964. p._appendElement(token, NS.HTML);
  7965. } else {
  7966. tokenInTable(p, token);
  7967. }
  7968. token.ackSelfClosing = true;
  7969. }
  7970. function formStartTagInTable(p, token) {
  7971. if (!p.formElement && p.openElements.tmplCount === 0) {
  7972. p._insertElement(token, NS.HTML);
  7973. p.formElement = p.openElements.current;
  7974. p.openElements.pop();
  7975. }
  7976. }
  7977. function startTagInTable(p, token) {
  7978. switch (token.tagID) {
  7979. case TAG_ID.TD:
  7980. case TAG_ID.TH:
  7981. case TAG_ID.TR: {
  7982. tdStartTagInTable(p, token);
  7983. break;
  7984. }
  7985. case TAG_ID.STYLE:
  7986. case TAG_ID.SCRIPT:
  7987. case TAG_ID.TEMPLATE: {
  7988. startTagInHead(p, token);
  7989. break;
  7990. }
  7991. case TAG_ID.COL: {
  7992. colStartTagInTable(p, token);
  7993. break;
  7994. }
  7995. case TAG_ID.FORM: {
  7996. formStartTagInTable(p, token);
  7997. break;
  7998. }
  7999. case TAG_ID.TABLE: {
  8000. tableStartTagInTable(p, token);
  8001. break;
  8002. }
  8003. case TAG_ID.TBODY:
  8004. case TAG_ID.TFOOT:
  8005. case TAG_ID.THEAD: {
  8006. tbodyStartTagInTable(p, token);
  8007. break;
  8008. }
  8009. case TAG_ID.INPUT: {
  8010. inputStartTagInTable(p, token);
  8011. break;
  8012. }
  8013. case TAG_ID.CAPTION: {
  8014. captionStartTagInTable(p, token);
  8015. break;
  8016. }
  8017. case TAG_ID.COLGROUP: {
  8018. colgroupStartTagInTable(p, token);
  8019. break;
  8020. }
  8021. default: {
  8022. tokenInTable(p, token);
  8023. }
  8024. }
  8025. }
  8026. function endTagInTable(p, token) {
  8027. switch (token.tagID) {
  8028. case TAG_ID.TABLE: {
  8029. if (p.openElements.hasInTableScope(TAG_ID.TABLE)) {
  8030. p.openElements.popUntilTagNamePopped(TAG_ID.TABLE);
  8031. p._resetInsertionMode();
  8032. }
  8033. break;
  8034. }
  8035. case TAG_ID.TEMPLATE: {
  8036. templateEndTagInHead(p, token);
  8037. break;
  8038. }
  8039. case TAG_ID.BODY:
  8040. case TAG_ID.CAPTION:
  8041. case TAG_ID.COL:
  8042. case TAG_ID.COLGROUP:
  8043. case TAG_ID.HTML:
  8044. case TAG_ID.TBODY:
  8045. case TAG_ID.TD:
  8046. case TAG_ID.TFOOT:
  8047. case TAG_ID.TH:
  8048. case TAG_ID.THEAD:
  8049. case TAG_ID.TR: {
  8050. break;
  8051. }
  8052. default: {
  8053. tokenInTable(p, token);
  8054. }
  8055. }
  8056. }
  8057. function tokenInTable(p, token) {
  8058. const savedFosterParentingState = p.fosterParentingEnabled;
  8059. p.fosterParentingEnabled = true;
  8060. modeInBody(p, token);
  8061. p.fosterParentingEnabled = savedFosterParentingState;
  8062. }
  8063. function whitespaceCharacterInTableText(p, token) {
  8064. p.pendingCharacterTokens.push(token);
  8065. }
  8066. function characterInTableText(p, token) {
  8067. p.pendingCharacterTokens.push(token);
  8068. p.hasNonWhitespacePendingCharacterToken = true;
  8069. }
  8070. function tokenInTableText(p, token) {
  8071. let i = 0;
  8072. if (p.hasNonWhitespacePendingCharacterToken) {
  8073. for (; i < p.pendingCharacterTokens.length; i++) {
  8074. tokenInTable(p, p.pendingCharacterTokens[i]);
  8075. }
  8076. } else {
  8077. for (; i < p.pendingCharacterTokens.length; i++) {
  8078. p._insertCharacters(p.pendingCharacterTokens[i]);
  8079. }
  8080. }
  8081. p.insertionMode = p.originalInsertionMode;
  8082. p._processToken(token);
  8083. }
  8084. var TABLE_VOID_ELEMENTS = /* @__PURE__ */ new Set([TAG_ID.CAPTION, TAG_ID.COL, TAG_ID.COLGROUP, TAG_ID.TBODY, TAG_ID.TD, TAG_ID.TFOOT, TAG_ID.TH, TAG_ID.THEAD, TAG_ID.TR]);
  8085. function startTagInCaption(p, token) {
  8086. const tn = token.tagID;
  8087. if (TABLE_VOID_ELEMENTS.has(tn)) {
  8088. if (p.openElements.hasInTableScope(TAG_ID.CAPTION)) {
  8089. p.openElements.generateImpliedEndTags();
  8090. p.openElements.popUntilTagNamePopped(TAG_ID.CAPTION);
  8091. p.activeFormattingElements.clearToLastMarker();
  8092. p.insertionMode = InsertionMode.IN_TABLE;
  8093. startTagInTable(p, token);
  8094. }
  8095. } else {
  8096. startTagInBody(p, token);
  8097. }
  8098. }
  8099. function endTagInCaption(p, token) {
  8100. const tn = token.tagID;
  8101. switch (tn) {
  8102. case TAG_ID.CAPTION:
  8103. case TAG_ID.TABLE: {
  8104. if (p.openElements.hasInTableScope(TAG_ID.CAPTION)) {
  8105. p.openElements.generateImpliedEndTags();
  8106. p.openElements.popUntilTagNamePopped(TAG_ID.CAPTION);
  8107. p.activeFormattingElements.clearToLastMarker();
  8108. p.insertionMode = InsertionMode.IN_TABLE;
  8109. if (tn === TAG_ID.TABLE) {
  8110. endTagInTable(p, token);
  8111. }
  8112. }
  8113. break;
  8114. }
  8115. case TAG_ID.BODY:
  8116. case TAG_ID.COL:
  8117. case TAG_ID.COLGROUP:
  8118. case TAG_ID.HTML:
  8119. case TAG_ID.TBODY:
  8120. case TAG_ID.TD:
  8121. case TAG_ID.TFOOT:
  8122. case TAG_ID.TH:
  8123. case TAG_ID.THEAD:
  8124. case TAG_ID.TR: {
  8125. break;
  8126. }
  8127. default: {
  8128. endTagInBody(p, token);
  8129. }
  8130. }
  8131. }
  8132. function startTagInColumnGroup(p, token) {
  8133. switch (token.tagID) {
  8134. case TAG_ID.HTML: {
  8135. startTagInBody(p, token);
  8136. break;
  8137. }
  8138. case TAG_ID.COL: {
  8139. p._appendElement(token, NS.HTML);
  8140. token.ackSelfClosing = true;
  8141. break;
  8142. }
  8143. case TAG_ID.TEMPLATE: {
  8144. startTagInHead(p, token);
  8145. break;
  8146. }
  8147. default: {
  8148. tokenInColumnGroup(p, token);
  8149. }
  8150. }
  8151. }
  8152. function endTagInColumnGroup(p, token) {
  8153. switch (token.tagID) {
  8154. case TAG_ID.COLGROUP: {
  8155. if (p.openElements.currentTagId === TAG_ID.COLGROUP) {
  8156. p.openElements.pop();
  8157. p.insertionMode = InsertionMode.IN_TABLE;
  8158. }
  8159. break;
  8160. }
  8161. case TAG_ID.TEMPLATE: {
  8162. templateEndTagInHead(p, token);
  8163. break;
  8164. }
  8165. case TAG_ID.COL: {
  8166. break;
  8167. }
  8168. default: {
  8169. tokenInColumnGroup(p, token);
  8170. }
  8171. }
  8172. }
  8173. function tokenInColumnGroup(p, token) {
  8174. if (p.openElements.currentTagId === TAG_ID.COLGROUP) {
  8175. p.openElements.pop();
  8176. p.insertionMode = InsertionMode.IN_TABLE;
  8177. p._processToken(token);
  8178. }
  8179. }
  8180. function startTagInTableBody(p, token) {
  8181. switch (token.tagID) {
  8182. case TAG_ID.TR: {
  8183. p.openElements.clearBackToTableBodyContext();
  8184. p._insertElement(token, NS.HTML);
  8185. p.insertionMode = InsertionMode.IN_ROW;
  8186. break;
  8187. }
  8188. case TAG_ID.TH:
  8189. case TAG_ID.TD: {
  8190. p.openElements.clearBackToTableBodyContext();
  8191. p._insertFakeElement(TAG_NAMES.TR, TAG_ID.TR);
  8192. p.insertionMode = InsertionMode.IN_ROW;
  8193. startTagInRow(p, token);
  8194. break;
  8195. }
  8196. case TAG_ID.CAPTION:
  8197. case TAG_ID.COL:
  8198. case TAG_ID.COLGROUP:
  8199. case TAG_ID.TBODY:
  8200. case TAG_ID.TFOOT:
  8201. case TAG_ID.THEAD: {
  8202. if (p.openElements.hasTableBodyContextInTableScope()) {
  8203. p.openElements.clearBackToTableBodyContext();
  8204. p.openElements.pop();
  8205. p.insertionMode = InsertionMode.IN_TABLE;
  8206. startTagInTable(p, token);
  8207. }
  8208. break;
  8209. }
  8210. default: {
  8211. startTagInTable(p, token);
  8212. }
  8213. }
  8214. }
  8215. function endTagInTableBody(p, token) {
  8216. const tn = token.tagID;
  8217. switch (token.tagID) {
  8218. case TAG_ID.TBODY:
  8219. case TAG_ID.TFOOT:
  8220. case TAG_ID.THEAD: {
  8221. if (p.openElements.hasInTableScope(tn)) {
  8222. p.openElements.clearBackToTableBodyContext();
  8223. p.openElements.pop();
  8224. p.insertionMode = InsertionMode.IN_TABLE;
  8225. }
  8226. break;
  8227. }
  8228. case TAG_ID.TABLE: {
  8229. if (p.openElements.hasTableBodyContextInTableScope()) {
  8230. p.openElements.clearBackToTableBodyContext();
  8231. p.openElements.pop();
  8232. p.insertionMode = InsertionMode.IN_TABLE;
  8233. endTagInTable(p, token);
  8234. }
  8235. break;
  8236. }
  8237. case TAG_ID.BODY:
  8238. case TAG_ID.CAPTION:
  8239. case TAG_ID.COL:
  8240. case TAG_ID.COLGROUP:
  8241. case TAG_ID.HTML:
  8242. case TAG_ID.TD:
  8243. case TAG_ID.TH:
  8244. case TAG_ID.TR: {
  8245. break;
  8246. }
  8247. default: {
  8248. endTagInTable(p, token);
  8249. }
  8250. }
  8251. }
  8252. function startTagInRow(p, token) {
  8253. switch (token.tagID) {
  8254. case TAG_ID.TH:
  8255. case TAG_ID.TD: {
  8256. p.openElements.clearBackToTableRowContext();
  8257. p._insertElement(token, NS.HTML);
  8258. p.insertionMode = InsertionMode.IN_CELL;
  8259. p.activeFormattingElements.insertMarker();
  8260. break;
  8261. }
  8262. case TAG_ID.CAPTION:
  8263. case TAG_ID.COL:
  8264. case TAG_ID.COLGROUP:
  8265. case TAG_ID.TBODY:
  8266. case TAG_ID.TFOOT:
  8267. case TAG_ID.THEAD:
  8268. case TAG_ID.TR: {
  8269. if (p.openElements.hasInTableScope(TAG_ID.TR)) {
  8270. p.openElements.clearBackToTableRowContext();
  8271. p.openElements.pop();
  8272. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  8273. startTagInTableBody(p, token);
  8274. }
  8275. break;
  8276. }
  8277. default: {
  8278. startTagInTable(p, token);
  8279. }
  8280. }
  8281. }
  8282. function endTagInRow(p, token) {
  8283. switch (token.tagID) {
  8284. case TAG_ID.TR: {
  8285. if (p.openElements.hasInTableScope(TAG_ID.TR)) {
  8286. p.openElements.clearBackToTableRowContext();
  8287. p.openElements.pop();
  8288. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  8289. }
  8290. break;
  8291. }
  8292. case TAG_ID.TABLE: {
  8293. if (p.openElements.hasInTableScope(TAG_ID.TR)) {
  8294. p.openElements.clearBackToTableRowContext();
  8295. p.openElements.pop();
  8296. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  8297. endTagInTableBody(p, token);
  8298. }
  8299. break;
  8300. }
  8301. case TAG_ID.TBODY:
  8302. case TAG_ID.TFOOT:
  8303. case TAG_ID.THEAD: {
  8304. if (p.openElements.hasInTableScope(token.tagID) || p.openElements.hasInTableScope(TAG_ID.TR)) {
  8305. p.openElements.clearBackToTableRowContext();
  8306. p.openElements.pop();
  8307. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  8308. endTagInTableBody(p, token);
  8309. }
  8310. break;
  8311. }
  8312. case TAG_ID.BODY:
  8313. case TAG_ID.CAPTION:
  8314. case TAG_ID.COL:
  8315. case TAG_ID.COLGROUP:
  8316. case TAG_ID.HTML:
  8317. case TAG_ID.TD:
  8318. case TAG_ID.TH: {
  8319. break;
  8320. }
  8321. default: {
  8322. endTagInTable(p, token);
  8323. }
  8324. }
  8325. }
  8326. function startTagInCell(p, token) {
  8327. const tn = token.tagID;
  8328. if (TABLE_VOID_ELEMENTS.has(tn)) {
  8329. if (p.openElements.hasInTableScope(TAG_ID.TD) || p.openElements.hasInTableScope(TAG_ID.TH)) {
  8330. p._closeTableCell();
  8331. startTagInRow(p, token);
  8332. }
  8333. } else {
  8334. startTagInBody(p, token);
  8335. }
  8336. }
  8337. function endTagInCell(p, token) {
  8338. const tn = token.tagID;
  8339. switch (tn) {
  8340. case TAG_ID.TD:
  8341. case TAG_ID.TH: {
  8342. if (p.openElements.hasInTableScope(tn)) {
  8343. p.openElements.generateImpliedEndTags();
  8344. p.openElements.popUntilTagNamePopped(tn);
  8345. p.activeFormattingElements.clearToLastMarker();
  8346. p.insertionMode = InsertionMode.IN_ROW;
  8347. }
  8348. break;
  8349. }
  8350. case TAG_ID.TABLE:
  8351. case TAG_ID.TBODY:
  8352. case TAG_ID.TFOOT:
  8353. case TAG_ID.THEAD:
  8354. case TAG_ID.TR: {
  8355. if (p.openElements.hasInTableScope(tn)) {
  8356. p._closeTableCell();
  8357. endTagInRow(p, token);
  8358. }
  8359. break;
  8360. }
  8361. case TAG_ID.BODY:
  8362. case TAG_ID.CAPTION:
  8363. case TAG_ID.COL:
  8364. case TAG_ID.COLGROUP:
  8365. case TAG_ID.HTML: {
  8366. break;
  8367. }
  8368. default: {
  8369. endTagInBody(p, token);
  8370. }
  8371. }
  8372. }
  8373. function startTagInSelect(p, token) {
  8374. switch (token.tagID) {
  8375. case TAG_ID.HTML: {
  8376. startTagInBody(p, token);
  8377. break;
  8378. }
  8379. case TAG_ID.OPTION: {
  8380. if (p.openElements.currentTagId === TAG_ID.OPTION) {
  8381. p.openElements.pop();
  8382. }
  8383. p._insertElement(token, NS.HTML);
  8384. break;
  8385. }
  8386. case TAG_ID.OPTGROUP: {
  8387. if (p.openElements.currentTagId === TAG_ID.OPTION) {
  8388. p.openElements.pop();
  8389. }
  8390. if (p.openElements.currentTagId === TAG_ID.OPTGROUP) {
  8391. p.openElements.pop();
  8392. }
  8393. p._insertElement(token, NS.HTML);
  8394. break;
  8395. }
  8396. case TAG_ID.INPUT:
  8397. case TAG_ID.KEYGEN:
  8398. case TAG_ID.TEXTAREA:
  8399. case TAG_ID.SELECT: {
  8400. if (p.openElements.hasInSelectScope(TAG_ID.SELECT)) {
  8401. p.openElements.popUntilTagNamePopped(TAG_ID.SELECT);
  8402. p._resetInsertionMode();
  8403. if (token.tagID !== TAG_ID.SELECT) {
  8404. p._processStartTag(token);
  8405. }
  8406. }
  8407. break;
  8408. }
  8409. case TAG_ID.SCRIPT:
  8410. case TAG_ID.TEMPLATE: {
  8411. startTagInHead(p, token);
  8412. break;
  8413. }
  8414. default:
  8415. }
  8416. }
  8417. function endTagInSelect(p, token) {
  8418. switch (token.tagID) {
  8419. case TAG_ID.OPTGROUP: {
  8420. if (p.openElements.stackTop > 0 && p.openElements.currentTagId === TAG_ID.OPTION && p.openElements.tagIDs[p.openElements.stackTop - 1] === TAG_ID.OPTGROUP) {
  8421. p.openElements.pop();
  8422. }
  8423. if (p.openElements.currentTagId === TAG_ID.OPTGROUP) {
  8424. p.openElements.pop();
  8425. }
  8426. break;
  8427. }
  8428. case TAG_ID.OPTION: {
  8429. if (p.openElements.currentTagId === TAG_ID.OPTION) {
  8430. p.openElements.pop();
  8431. }
  8432. break;
  8433. }
  8434. case TAG_ID.SELECT: {
  8435. if (p.openElements.hasInSelectScope(TAG_ID.SELECT)) {
  8436. p.openElements.popUntilTagNamePopped(TAG_ID.SELECT);
  8437. p._resetInsertionMode();
  8438. }
  8439. break;
  8440. }
  8441. case TAG_ID.TEMPLATE: {
  8442. templateEndTagInHead(p, token);
  8443. break;
  8444. }
  8445. default:
  8446. }
  8447. }
  8448. function startTagInSelectInTable(p, token) {
  8449. const tn = token.tagID;
  8450. if (tn === TAG_ID.CAPTION || tn === TAG_ID.TABLE || tn === TAG_ID.TBODY || tn === TAG_ID.TFOOT || tn === TAG_ID.THEAD || tn === TAG_ID.TR || tn === TAG_ID.TD || tn === TAG_ID.TH) {
  8451. p.openElements.popUntilTagNamePopped(TAG_ID.SELECT);
  8452. p._resetInsertionMode();
  8453. p._processStartTag(token);
  8454. } else {
  8455. startTagInSelect(p, token);
  8456. }
  8457. }
  8458. function endTagInSelectInTable(p, token) {
  8459. const tn = token.tagID;
  8460. if (tn === TAG_ID.CAPTION || tn === TAG_ID.TABLE || tn === TAG_ID.TBODY || tn === TAG_ID.TFOOT || tn === TAG_ID.THEAD || tn === TAG_ID.TR || tn === TAG_ID.TD || tn === TAG_ID.TH) {
  8461. if (p.openElements.hasInTableScope(tn)) {
  8462. p.openElements.popUntilTagNamePopped(TAG_ID.SELECT);
  8463. p._resetInsertionMode();
  8464. p.onEndTag(token);
  8465. }
  8466. } else {
  8467. endTagInSelect(p, token);
  8468. }
  8469. }
  8470. function startTagInTemplate(p, token) {
  8471. switch (token.tagID) {
  8472. case TAG_ID.BASE:
  8473. case TAG_ID.BASEFONT:
  8474. case TAG_ID.BGSOUND:
  8475. case TAG_ID.LINK:
  8476. case TAG_ID.META:
  8477. case TAG_ID.NOFRAMES:
  8478. case TAG_ID.SCRIPT:
  8479. case TAG_ID.STYLE:
  8480. case TAG_ID.TEMPLATE:
  8481. case TAG_ID.TITLE: {
  8482. startTagInHead(p, token);
  8483. break;
  8484. }
  8485. case TAG_ID.CAPTION:
  8486. case TAG_ID.COLGROUP:
  8487. case TAG_ID.TBODY:
  8488. case TAG_ID.TFOOT:
  8489. case TAG_ID.THEAD: {
  8490. p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE;
  8491. p.insertionMode = InsertionMode.IN_TABLE;
  8492. startTagInTable(p, token);
  8493. break;
  8494. }
  8495. case TAG_ID.COL: {
  8496. p.tmplInsertionModeStack[0] = InsertionMode.IN_COLUMN_GROUP;
  8497. p.insertionMode = InsertionMode.IN_COLUMN_GROUP;
  8498. startTagInColumnGroup(p, token);
  8499. break;
  8500. }
  8501. case TAG_ID.TR: {
  8502. p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE_BODY;
  8503. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  8504. startTagInTableBody(p, token);
  8505. break;
  8506. }
  8507. case TAG_ID.TD:
  8508. case TAG_ID.TH: {
  8509. p.tmplInsertionModeStack[0] = InsertionMode.IN_ROW;
  8510. p.insertionMode = InsertionMode.IN_ROW;
  8511. startTagInRow(p, token);
  8512. break;
  8513. }
  8514. default: {
  8515. p.tmplInsertionModeStack[0] = InsertionMode.IN_BODY;
  8516. p.insertionMode = InsertionMode.IN_BODY;
  8517. startTagInBody(p, token);
  8518. }
  8519. }
  8520. }
  8521. function endTagInTemplate(p, token) {
  8522. if (token.tagID === TAG_ID.TEMPLATE) {
  8523. templateEndTagInHead(p, token);
  8524. }
  8525. }
  8526. function eofInTemplate(p, token) {
  8527. if (p.openElements.tmplCount > 0) {
  8528. p.openElements.popUntilTagNamePopped(TAG_ID.TEMPLATE);
  8529. p.activeFormattingElements.clearToLastMarker();
  8530. p.tmplInsertionModeStack.shift();
  8531. p._resetInsertionMode();
  8532. p.onEof(token);
  8533. } else {
  8534. stopParsing(p, token);
  8535. }
  8536. }
  8537. function startTagAfterBody(p, token) {
  8538. if (token.tagID === TAG_ID.HTML) {
  8539. startTagInBody(p, token);
  8540. } else {
  8541. tokenAfterBody(p, token);
  8542. }
  8543. }
  8544. function endTagAfterBody(p, token) {
  8545. var _a2;
  8546. if (token.tagID === TAG_ID.HTML) {
  8547. if (!p.fragmentContext) {
  8548. p.insertionMode = InsertionMode.AFTER_AFTER_BODY;
  8549. }
  8550. if (p.options.sourceCodeLocationInfo && p.openElements.tagIDs[0] === TAG_ID.HTML) {
  8551. p._setEndLocation(p.openElements.items[0], token);
  8552. const bodyElement = p.openElements.items[1];
  8553. if (bodyElement && !((_a2 = p.treeAdapter.getNodeSourceCodeLocation(bodyElement)) === null || _a2 === void 0 ? void 0 : _a2.endTag)) {
  8554. p._setEndLocation(bodyElement, token);
  8555. }
  8556. }
  8557. } else {
  8558. tokenAfterBody(p, token);
  8559. }
  8560. }
  8561. function tokenAfterBody(p, token) {
  8562. p.insertionMode = InsertionMode.IN_BODY;
  8563. modeInBody(p, token);
  8564. }
  8565. function startTagInFrameset(p, token) {
  8566. switch (token.tagID) {
  8567. case TAG_ID.HTML: {
  8568. startTagInBody(p, token);
  8569. break;
  8570. }
  8571. case TAG_ID.FRAMESET: {
  8572. p._insertElement(token, NS.HTML);
  8573. break;
  8574. }
  8575. case TAG_ID.FRAME: {
  8576. p._appendElement(token, NS.HTML);
  8577. token.ackSelfClosing = true;
  8578. break;
  8579. }
  8580. case TAG_ID.NOFRAMES: {
  8581. startTagInHead(p, token);
  8582. break;
  8583. }
  8584. default:
  8585. }
  8586. }
  8587. function endTagInFrameset(p, token) {
  8588. if (token.tagID === TAG_ID.FRAMESET && !p.openElements.isRootHtmlElementCurrent()) {
  8589. p.openElements.pop();
  8590. if (!p.fragmentContext && p.openElements.currentTagId !== TAG_ID.FRAMESET) {
  8591. p.insertionMode = InsertionMode.AFTER_FRAMESET;
  8592. }
  8593. }
  8594. }
  8595. function startTagAfterFrameset(p, token) {
  8596. switch (token.tagID) {
  8597. case TAG_ID.HTML: {
  8598. startTagInBody(p, token);
  8599. break;
  8600. }
  8601. case TAG_ID.NOFRAMES: {
  8602. startTagInHead(p, token);
  8603. break;
  8604. }
  8605. default:
  8606. }
  8607. }
  8608. function endTagAfterFrameset(p, token) {
  8609. if (token.tagID === TAG_ID.HTML) {
  8610. p.insertionMode = InsertionMode.AFTER_AFTER_FRAMESET;
  8611. }
  8612. }
  8613. function startTagAfterAfterBody(p, token) {
  8614. if (token.tagID === TAG_ID.HTML) {
  8615. startTagInBody(p, token);
  8616. } else {
  8617. tokenAfterAfterBody(p, token);
  8618. }
  8619. }
  8620. function tokenAfterAfterBody(p, token) {
  8621. p.insertionMode = InsertionMode.IN_BODY;
  8622. modeInBody(p, token);
  8623. }
  8624. function startTagAfterAfterFrameset(p, token) {
  8625. switch (token.tagID) {
  8626. case TAG_ID.HTML: {
  8627. startTagInBody(p, token);
  8628. break;
  8629. }
  8630. case TAG_ID.NOFRAMES: {
  8631. startTagInHead(p, token);
  8632. break;
  8633. }
  8634. default:
  8635. }
  8636. }
  8637. function nullCharacterInForeignContent(p, token) {
  8638. token.chars = REPLACEMENT_CHARACTER;
  8639. p._insertCharacters(token);
  8640. }
  8641. function characterInForeignContent(p, token) {
  8642. p._insertCharacters(token);
  8643. p.framesetOk = false;
  8644. }
  8645. function popUntilHtmlOrIntegrationPoint(p) {
  8646. while (p.treeAdapter.getNamespaceURI(p.openElements.current) !== NS.HTML && !p._isIntegrationPoint(p.openElements.currentTagId, p.openElements.current)) {
  8647. p.openElements.pop();
  8648. }
  8649. }
  8650. function startTagInForeignContent(p, token) {
  8651. if (causesExit(token)) {
  8652. popUntilHtmlOrIntegrationPoint(p);
  8653. p._startTagOutsideForeignContent(token);
  8654. } else {
  8655. const current = p._getAdjustedCurrentElement();
  8656. const currentNs = p.treeAdapter.getNamespaceURI(current);
  8657. if (currentNs === NS.MATHML) {
  8658. adjustTokenMathMLAttrs(token);
  8659. } else if (currentNs === NS.SVG) {
  8660. adjustTokenSVGTagName(token);
  8661. adjustTokenSVGAttrs(token);
  8662. }
  8663. adjustTokenXMLAttrs(token);
  8664. if (token.selfClosing) {
  8665. p._appendElement(token, currentNs);
  8666. } else {
  8667. p._insertElement(token, currentNs);
  8668. }
  8669. token.ackSelfClosing = true;
  8670. }
  8671. }
  8672. function endTagInForeignContent(p, token) {
  8673. if (token.tagID === TAG_ID.P || token.tagID === TAG_ID.BR) {
  8674. popUntilHtmlOrIntegrationPoint(p);
  8675. p._endTagOutsideForeignContent(token);
  8676. return;
  8677. }
  8678. for (let i = p.openElements.stackTop; i > 0; i--) {
  8679. const element = p.openElements.items[i];
  8680. if (p.treeAdapter.getNamespaceURI(element) === NS.HTML) {
  8681. p._endTagOutsideForeignContent(token);
  8682. break;
  8683. }
  8684. const tagName = p.treeAdapter.getTagName(element);
  8685. if (tagName.toLowerCase() === token.tagName) {
  8686. token.tagName = tagName;
  8687. p.openElements.shortenToLength(i);
  8688. break;
  8689. }
  8690. }
  8691. }
  8692. // node_modules/entities/lib/esm/escape.js
  8693. var xmlCodeMap = /* @__PURE__ */ new Map([
  8694. [34, "&quot;"],
  8695. [38, "&amp;"],
  8696. [39, "&apos;"],
  8697. [60, "&lt;"],
  8698. [62, "&gt;"]
  8699. ]);
  8700. var getCodePoint = (
  8701. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
  8702. String.prototype.codePointAt != null ? (str, index) => str.codePointAt(index) : (
  8703. // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  8704. (c, index) => (c.charCodeAt(index) & 64512) === 55296 ? (c.charCodeAt(index) - 55296) * 1024 + c.charCodeAt(index + 1) - 56320 + 65536 : c.charCodeAt(index)
  8705. )
  8706. );
  8707. function getEscaper(regex, map2) {
  8708. return function escape(data) {
  8709. let match;
  8710. let lastIdx = 0;
  8711. let result = "";
  8712. while (match = regex.exec(data)) {
  8713. if (lastIdx !== match.index) {
  8714. result += data.substring(lastIdx, match.index);
  8715. }
  8716. result += map2.get(match[0].charCodeAt(0));
  8717. lastIdx = match.index + 1;
  8718. }
  8719. return result + data.substring(lastIdx);
  8720. };
  8721. }
  8722. var escapeUTF8 = getEscaper(/[&<>'"]/g, xmlCodeMap);
  8723. var escapeAttribute = getEscaper(/["&\u00A0]/g, /* @__PURE__ */ new Map([
  8724. [34, "&quot;"],
  8725. [38, "&amp;"],
  8726. [160, "&nbsp;"]
  8727. ]));
  8728. var escapeText = getEscaper(/[&<>\u00A0]/g, /* @__PURE__ */ new Map([
  8729. [38, "&amp;"],
  8730. [60, "&lt;"],
  8731. [62, "&gt;"],
  8732. [160, "&nbsp;"]
  8733. ]));
  8734. // node_modules/parse5/dist/serializer/index.js
  8735. var VOID_ELEMENTS = /* @__PURE__ */ new Set([
  8736. TAG_NAMES.AREA,
  8737. TAG_NAMES.BASE,
  8738. TAG_NAMES.BASEFONT,
  8739. TAG_NAMES.BGSOUND,
  8740. TAG_NAMES.BR,
  8741. TAG_NAMES.COL,
  8742. TAG_NAMES.EMBED,
  8743. TAG_NAMES.FRAME,
  8744. TAG_NAMES.HR,
  8745. TAG_NAMES.IMG,
  8746. TAG_NAMES.INPUT,
  8747. TAG_NAMES.KEYGEN,
  8748. TAG_NAMES.LINK,
  8749. TAG_NAMES.META,
  8750. TAG_NAMES.PARAM,
  8751. TAG_NAMES.SOURCE,
  8752. TAG_NAMES.TRACK,
  8753. TAG_NAMES.WBR
  8754. ]);
  8755. // node_modules/parse5/dist/index.js
  8756. function parse(html, options) {
  8757. return Parser.parse(html, options);
  8758. }
  8759. function parseFragment(fragmentContext, html, options) {
  8760. if (typeof fragmentContext === "string") {
  8761. options = html;
  8762. html = fragmentContext;
  8763. fragmentContext = null;
  8764. }
  8765. const parser = Parser.getFragmentParser(fragmentContext, options);
  8766. parser.tokenizer.write(html, true);
  8767. return parser.getFragment();
  8768. }
  8769. // src/mock-doc/parse-util.ts
  8770. var docParser = /* @__PURE__ */ new WeakMap();
  8771. function parseDocumentUtil(ownerDocument, html) {
  8772. const doc = parse(html.trim(), getParser(ownerDocument));
  8773. doc.documentElement = doc.firstElementChild;
  8774. doc.head = doc.documentElement.firstElementChild;
  8775. doc.body = doc.head.nextElementSibling;
  8776. return doc;
  8777. }
  8778. function parseFragmentUtil(ownerDocument, html) {
  8779. if (typeof html === "string") {
  8780. html = html.trim();
  8781. } else {
  8782. html = "";
  8783. }
  8784. const frag = parseFragment(html, getParser(ownerDocument));
  8785. return frag;
  8786. }
  8787. function getParser(ownerDocument) {
  8788. let parseOptions = docParser.get(ownerDocument);
  8789. if (parseOptions != null) {
  8790. return parseOptions;
  8791. }
  8792. const treeAdapter = {
  8793. createDocument() {
  8794. const doc = ownerDocument.createElement("#document" /* DOCUMENT_NODE */);
  8795. doc["x-mode"] = "no-quirks";
  8796. return doc;
  8797. },
  8798. setNodeSourceCodeLocation(node, location2) {
  8799. node.sourceCodeLocation = location2;
  8800. },
  8801. getNodeSourceCodeLocation(node) {
  8802. return node.sourceCodeLocation;
  8803. },
  8804. createDocumentFragment() {
  8805. return ownerDocument.createDocumentFragment();
  8806. },
  8807. createElement(tagName, namespaceURI, attrs) {
  8808. const elm = ownerDocument.createElementNS(namespaceURI, tagName);
  8809. for (let i = 0; i < attrs.length; i++) {
  8810. const attr = attrs[i];
  8811. if (attr.namespace == null || attr.namespace === "http://www.w3.org/1999/xhtml") {
  8812. elm.setAttribute(attr.name, attr.value);
  8813. } else {
  8814. elm.setAttributeNS(attr.namespace, attr.name, attr.value);
  8815. }
  8816. }
  8817. return elm;
  8818. },
  8819. createCommentNode(data) {
  8820. return ownerDocument.createComment(data);
  8821. },
  8822. appendChild(parentNode, newNode) {
  8823. parentNode.appendChild(newNode);
  8824. },
  8825. insertBefore(parentNode, newNode, referenceNode) {
  8826. parentNode.insertBefore(newNode, referenceNode);
  8827. },
  8828. setTemplateContent(templateElement, contentElement) {
  8829. templateElement.content = contentElement;
  8830. },
  8831. getTemplateContent(templateElement) {
  8832. return templateElement.content;
  8833. },
  8834. setDocumentType(doc, name, publicId, systemId) {
  8835. let doctypeNode = doc.childNodes.find((n) => n.nodeType === 10 /* DOCUMENT_TYPE_NODE */);
  8836. if (doctypeNode == null) {
  8837. doctypeNode = ownerDocument.createDocumentTypeNode();
  8838. doc.insertBefore(doctypeNode, doc.firstChild);
  8839. }
  8840. doctypeNode.nodeValue = "!DOCTYPE";
  8841. doctypeNode["x-name"] = name;
  8842. doctypeNode["x-publicId"] = publicId;
  8843. doctypeNode["x-systemId"] = systemId;
  8844. },
  8845. setDocumentMode(doc, mode) {
  8846. doc["x-mode"] = mode;
  8847. },
  8848. getDocumentMode(doc) {
  8849. return doc["x-mode"];
  8850. },
  8851. detachNode(node) {
  8852. node.remove();
  8853. },
  8854. insertText(parentNode, text) {
  8855. const lastChild = parentNode.lastChild;
  8856. if (lastChild != null && lastChild.nodeType === 3 /* TEXT_NODE */) {
  8857. lastChild.nodeValue += text;
  8858. } else {
  8859. parentNode.appendChild(ownerDocument.createTextNode(text));
  8860. }
  8861. },
  8862. insertTextBefore(parentNode, text, referenceNode) {
  8863. const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
  8864. if (prevNode != null && prevNode.nodeType === 3 /* TEXT_NODE */) {
  8865. prevNode.nodeValue += text;
  8866. } else {
  8867. parentNode.insertBefore(ownerDocument.createTextNode(text), referenceNode);
  8868. }
  8869. },
  8870. adoptAttributes(recipient, attrs) {
  8871. for (let i = 0; i < attrs.length; i++) {
  8872. const attr = attrs[i];
  8873. if (recipient.hasAttributeNS(attr.namespace, attr.name) === false) {
  8874. recipient.setAttributeNS(attr.namespace, attr.name, attr.value);
  8875. }
  8876. }
  8877. },
  8878. getFirstChild(node) {
  8879. return node.childNodes[0];
  8880. },
  8881. getChildNodes(node) {
  8882. return node.childNodes;
  8883. },
  8884. getParentNode(node) {
  8885. return node.parentNode;
  8886. },
  8887. getAttrList(element) {
  8888. const attrs = element.attributes.__items.map((attr) => {
  8889. return {
  8890. name: attr.name,
  8891. value: attr.value,
  8892. namespace: attr.namespaceURI,
  8893. prefix: null
  8894. };
  8895. });
  8896. return attrs;
  8897. },
  8898. getTagName(element) {
  8899. if (element.namespaceURI === "http://www.w3.org/1999/xhtml") {
  8900. return element.nodeName.toLowerCase();
  8901. } else {
  8902. return element.nodeName;
  8903. }
  8904. },
  8905. getNamespaceURI(element) {
  8906. return element.namespaceURI;
  8907. },
  8908. getTextNodeContent(textNode) {
  8909. return textNode.nodeValue;
  8910. },
  8911. getCommentNodeContent(commentNode) {
  8912. return commentNode.nodeValue;
  8913. },
  8914. getDocumentTypeNodeName(doctypeNode) {
  8915. return doctypeNode["x-name"];
  8916. },
  8917. getDocumentTypeNodePublicId(doctypeNode) {
  8918. return doctypeNode["x-publicId"];
  8919. },
  8920. getDocumentTypeNodeSystemId(doctypeNode) {
  8921. return doctypeNode["x-systemId"];
  8922. },
  8923. // @ts-ignore - a `MockNode` will never be assignable to a `TreeAdapterTypeMap['text']`. As a result, we cannot
  8924. // complete this function signature
  8925. isTextNode(node) {
  8926. return node.nodeType === 3 /* TEXT_NODE */;
  8927. },
  8928. // @ts-ignore - a `MockNode` will never be assignable to a `TreeAdapterTypeMap['comment']`. As a result, we cannot
  8929. // complete this function signature (which requires its return type to be a type predicate)
  8930. isCommentNode(node) {
  8931. return node.nodeType === 8 /* COMMENT_NODE */;
  8932. },
  8933. // @ts-ignore - a `MockNode` will never be assignable to a `TreeAdapterTypeMap['document']`. As a result, we cannot
  8934. // complete this function signature (which requires its return type to be a type predicate)
  8935. isDocumentTypeNode(node) {
  8936. return node.nodeType === 10 /* DOCUMENT_TYPE_NODE */;
  8937. },
  8938. // @ts-ignore - a `MockNode` will never be assignable to a `TreeAdapterTypeMap['element']`. As a result, we cannot
  8939. // complete this function signature (which requires its return type to be a type predicate)
  8940. isElementNode(node) {
  8941. return node.nodeType === 1 /* ELEMENT_NODE */;
  8942. }
  8943. };
  8944. parseOptions = {
  8945. treeAdapter
  8946. };
  8947. docParser.set(ownerDocument, parseOptions);
  8948. return parseOptions;
  8949. }
  8950. // src/mock-doc/third-party/jquery.ts
  8951. var jquery_default = (
  8952. /*!
  8953. * jQuery JavaScript Library v4.0.0-pre+9352011a7.dirty +selector
  8954. * https://jquery.com/
  8955. *
  8956. * Copyright OpenJS Foundation and other contributors
  8957. * Released under the MIT license
  8958. * https://jquery.org/license
  8959. *
  8960. * Date: 2023-12-11T17:55Z
  8961. */
  8962. function(global2, factory) {
  8963. "use strict";
  8964. if (true) {
  8965. return factory(global2, true);
  8966. } else {
  8967. factory(global2);
  8968. }
  8969. }({
  8970. document: {
  8971. createElement() {
  8972. return {};
  8973. },
  8974. nodeType: 9,
  8975. documentElement: {
  8976. nodeType: 1,
  8977. nodeName: "HTML"
  8978. }
  8979. }
  8980. }, function(window, noGlobal) {
  8981. "use strict";
  8982. if (!window.document) {
  8983. throw new Error("jQuery requires a window with a document");
  8984. }
  8985. var arr = [];
  8986. var getProto = Object.getPrototypeOf;
  8987. var slice = arr.slice;
  8988. var flat = arr.flat ? function(array) {
  8989. return arr.flat.call(array);
  8990. } : function(array) {
  8991. return arr.concat.apply([], array);
  8992. };
  8993. var push = arr.push;
  8994. var indexOf = arr.indexOf;
  8995. var class2type = {};
  8996. var toString = class2type.toString;
  8997. var hasOwn = class2type.hasOwnProperty;
  8998. var fnToString = hasOwn.toString;
  8999. var ObjectFunctionString = fnToString.call(Object);
  9000. var support = {};
  9001. function toType(obj) {
  9002. if (obj == null) {
  9003. return obj + "";
  9004. }
  9005. return typeof obj === "object" ? class2type[toString.call(obj)] || "object" : typeof obj;
  9006. }
  9007. function isWindow(obj) {
  9008. return obj != null && obj === obj.window;
  9009. }
  9010. function isArrayLike(obj) {
  9011. var length = !!obj && obj.length, type = toType(obj);
  9012. if (typeof obj === "function" || isWindow(obj)) {
  9013. return false;
  9014. }
  9015. return type === "array" || length === 0 || typeof length === "number" && length > 0 && length - 1 in obj;
  9016. }
  9017. var document = window.document;
  9018. var preservedScriptAttributes = {
  9019. type: true,
  9020. src: true,
  9021. nonce: true,
  9022. noModule: true
  9023. };
  9024. function DOMEval(code, node, doc) {
  9025. doc = doc || document;
  9026. var i2, script = doc.createElement("script");
  9027. script.text = code;
  9028. if (node) {
  9029. for (i2 in preservedScriptAttributes) {
  9030. if (node[i2]) {
  9031. script[i2] = node[i2];
  9032. }
  9033. }
  9034. }
  9035. doc.head.appendChild(script).parentNode.removeChild(script);
  9036. }
  9037. const jQuery = {};
  9038. var version = "4.0.0-pre+9352011a7.dirty +selector", rhtmlSuffix = /HTML$/i, jQueryOrig = function(selector, context) {
  9039. return new jQuery.fn.init(selector, context);
  9040. };
  9041. jQuery.fn = jQuery.prototype = {
  9042. // The current version of jQuery being used
  9043. jquery: version,
  9044. constructor: jQuery,
  9045. // The default length of a jQuery object is 0
  9046. length: 0,
  9047. toArray: function() {
  9048. return slice.call(this);
  9049. },
  9050. // Get the Nth element in the matched element set OR
  9051. // Get the whole matched element set as a clean array
  9052. get: function(num) {
  9053. if (num == null) {
  9054. return slice.call(this);
  9055. }
  9056. return num < 0 ? this[num + this.length] : this[num];
  9057. },
  9058. // Take an array of elements and push it onto the stack
  9059. // (returning the new matched element set)
  9060. pushStack: function(elems) {
  9061. var ret = jQuery.merge(this.constructor(), elems);
  9062. ret.prevObject = this;
  9063. return ret;
  9064. },
  9065. // Execute a callback for every element in the matched set.
  9066. each: function(callback) {
  9067. return jQuery.each(this, callback);
  9068. },
  9069. map: function(callback) {
  9070. return this.pushStack(jQuery.map(this, function(elem, i2) {
  9071. return callback.call(elem, i2, elem);
  9072. }));
  9073. },
  9074. slice: function() {
  9075. return this.pushStack(slice.apply(this, arguments));
  9076. },
  9077. first: function() {
  9078. return this.eq(0);
  9079. },
  9080. last: function() {
  9081. return this.eq(-1);
  9082. },
  9083. even: function() {
  9084. return this.pushStack(jQuery.grep(this, function(_elem, i2) {
  9085. return (i2 + 1) % 2;
  9086. }));
  9087. },
  9088. odd: function() {
  9089. return this.pushStack(jQuery.grep(this, function(_elem, i2) {
  9090. return i2 % 2;
  9091. }));
  9092. },
  9093. eq: function(i2) {
  9094. var len = this.length, j = +i2 + (i2 < 0 ? len : 0);
  9095. return this.pushStack(j >= 0 && j < len ? [this[j]] : []);
  9096. },
  9097. end: function() {
  9098. return this.prevObject || this.constructor();
  9099. }
  9100. };
  9101. jQuery.extend = jQuery.fn.extend = function() {
  9102. var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i2 = 1, length = arguments.length, deep = false;
  9103. if (typeof target === "boolean") {
  9104. deep = target;
  9105. target = arguments[i2] || {};
  9106. i2++;
  9107. }
  9108. if (typeof target !== "object" && typeof target !== "function") {
  9109. target = {};
  9110. }
  9111. if (i2 === length) {
  9112. target = this;
  9113. i2--;
  9114. }
  9115. for (; i2 < length; i2++) {
  9116. if ((options = arguments[i2]) != null) {
  9117. for (name in options) {
  9118. copy = options[name];
  9119. if (name === "__proto__" || target === copy) {
  9120. continue;
  9121. }
  9122. if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) {
  9123. src = target[name];
  9124. if (copyIsArray && !Array.isArray(src)) {
  9125. clone = [];
  9126. } else if (!copyIsArray && !jQuery.isPlainObject(src)) {
  9127. clone = {};
  9128. } else {
  9129. clone = src;
  9130. }
  9131. copyIsArray = false;
  9132. target[name] = jQuery.extend(deep, clone, copy);
  9133. } else if (copy !== void 0) {
  9134. target[name] = copy;
  9135. }
  9136. }
  9137. }
  9138. }
  9139. return target;
  9140. };
  9141. jQuery.extend({
  9142. // Unique for each copy of jQuery on the page
  9143. expando: "jQuery" + (version + Math.random()).replace(/\D/g, ""),
  9144. // Assume jQuery is ready without the ready module
  9145. isReady: true,
  9146. error: function(msg) {
  9147. throw new Error(msg);
  9148. },
  9149. noop: function() {
  9150. },
  9151. isPlainObject: function(obj) {
  9152. var proto, Ctor;
  9153. if (!obj || toString.call(obj) !== "[object Object]") {
  9154. return false;
  9155. }
  9156. proto = getProto(obj);
  9157. if (!proto) {
  9158. return true;
  9159. }
  9160. Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
  9161. return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
  9162. },
  9163. isEmptyObject: function(obj) {
  9164. var name;
  9165. for (name in obj) {
  9166. return false;
  9167. }
  9168. return true;
  9169. },
  9170. // Evaluates a script in a provided context; falls back to the global one
  9171. // if not specified.
  9172. globalEval: function(code, options, doc) {
  9173. DOMEval(code, { nonce: options && options.nonce }, doc);
  9174. },
  9175. each: function(obj, callback) {
  9176. var length, i2 = 0;
  9177. if (isArrayLike(obj)) {
  9178. length = obj.length;
  9179. for (; i2 < length; i2++) {
  9180. if (callback.call(obj[i2], i2, obj[i2]) === false) {
  9181. break;
  9182. }
  9183. }
  9184. } else {
  9185. for (i2 in obj) {
  9186. if (callback.call(obj[i2], i2, obj[i2]) === false) {
  9187. break;
  9188. }
  9189. }
  9190. }
  9191. return obj;
  9192. },
  9193. // Retrieve the text value of an array of DOM nodes
  9194. text: function(elem) {
  9195. var node, ret = "", i2 = 0, nodeType = elem.nodeType;
  9196. if (!nodeType) {
  9197. while (node = elem[i2++]) {
  9198. ret += jQuery.text(node);
  9199. }
  9200. }
  9201. if (nodeType === 1 || nodeType === 11) {
  9202. return elem.textContent;
  9203. }
  9204. if (nodeType === 9) {
  9205. return elem.documentElement.textContent;
  9206. }
  9207. if (nodeType === 3 || nodeType === 4) {
  9208. return elem.nodeValue;
  9209. }
  9210. return ret;
  9211. },
  9212. // results is for internal usage only
  9213. makeArray: function(arr2, results) {
  9214. var ret = results || [];
  9215. if (arr2 != null) {
  9216. if (isArrayLike(Object(arr2))) {
  9217. jQuery.merge(
  9218. ret,
  9219. typeof arr2 === "string" ? [arr2] : arr2
  9220. );
  9221. } else {
  9222. push.call(ret, arr2);
  9223. }
  9224. }
  9225. return ret;
  9226. },
  9227. inArray: function(elem, arr2, i2) {
  9228. return arr2 == null ? -1 : indexOf.call(arr2, elem, i2);
  9229. },
  9230. isXMLDoc: function(elem) {
  9231. var namespace = elem && elem.namespaceURI, docElem = elem && (elem.ownerDocument || elem).documentElement;
  9232. return !rhtmlSuffix.test(namespace || docElem && docElem.nodeName || "HTML");
  9233. },
  9234. // Note: an element does not contain itself
  9235. contains: function(a, b) {
  9236. var bup = b && b.parentNode;
  9237. return a === bup || !!(bup && bup.nodeType === 1 && // Support: IE 9 - 11+
  9238. // IE doesn't have `contains` on SVG.
  9239. (a.contains ? a.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16));
  9240. },
  9241. merge: function(first, second) {
  9242. var len = +second.length, j = 0, i2 = first.length;
  9243. for (; j < len; j++) {
  9244. first[i2++] = second[j];
  9245. }
  9246. first.length = i2;
  9247. return first;
  9248. },
  9249. grep: function(elems, callback, invert) {
  9250. var callbackInverse, matches3 = [], i2 = 0, length = elems.length, callbackExpect = !invert;
  9251. for (; i2 < length; i2++) {
  9252. callbackInverse = !callback(elems[i2], i2);
  9253. if (callbackInverse !== callbackExpect) {
  9254. matches3.push(elems[i2]);
  9255. }
  9256. }
  9257. return matches3;
  9258. },
  9259. // arg is for internal usage only
  9260. map: function(elems, callback, arg) {
  9261. var length, value, i2 = 0, ret = [];
  9262. if (isArrayLike(elems)) {
  9263. length = elems.length;
  9264. for (; i2 < length; i2++) {
  9265. value = callback(elems[i2], i2, arg);
  9266. if (value != null) {
  9267. ret.push(value);
  9268. }
  9269. }
  9270. } else {
  9271. for (i2 in elems) {
  9272. value = callback(elems[i2], i2, arg);
  9273. if (value != null) {
  9274. ret.push(value);
  9275. }
  9276. }
  9277. }
  9278. return flat(ret);
  9279. },
  9280. // A global GUID counter for objects
  9281. guid: 1,
  9282. // jQuery.support is not used in Core but other projects attach their
  9283. // properties to it so it needs to exist.
  9284. support
  9285. });
  9286. if (typeof Symbol === "function") {
  9287. jQuery.fn[Symbol.iterator] = arr[Symbol.iterator];
  9288. }
  9289. jQuery.each(
  9290. "Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),
  9291. function(_i, name) {
  9292. class2type["[object " + name + "]"] = name.toLowerCase();
  9293. }
  9294. );
  9295. function nodeName(elem, name) {
  9296. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  9297. }
  9298. var pop = arr.pop;
  9299. var whitespace = "[\\x20\\t\\r\\n\\f]";
  9300. var isIE = document.documentMode;
  9301. try {
  9302. document.querySelector(":has(*,:jqfake)");
  9303. support.cssHas = false;
  9304. } catch (e) {
  9305. support.cssHas = true;
  9306. }
  9307. var rbuggyQSA = [];
  9308. if (isIE) {
  9309. rbuggyQSA.push(
  9310. // Support: IE 9 - 11+
  9311. // IE's :disabled selector does not pick up the children of disabled fieldsets
  9312. ":enabled",
  9313. ":disabled",
  9314. // Support: IE 11+
  9315. // IE 11 doesn't find elements on a `[name='']` query in some cases.
  9316. // Adding a temporary attribute to the document before the selection works
  9317. // around the issue.
  9318. "\\[" + whitespace + "*name" + whitespace + "*=" + whitespace + `*(?:''|"")`
  9319. );
  9320. }
  9321. if (!support.cssHas) {
  9322. rbuggyQSA.push(":has");
  9323. }
  9324. rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|"));
  9325. var rtrimCSS = new RegExp(
  9326. "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$",
  9327. "g"
  9328. );
  9329. var identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+";
  9330. var booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped";
  9331. var rleadingCombinator = new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*");
  9332. var rdescend = new RegExp(whitespace + "|>");
  9333. var rsibling = /[+~]/;
  9334. var documentElement = document.documentElement;
  9335. var matches2 = documentElement.matches || documentElement.msMatchesSelector;
  9336. function createCache() {
  9337. var keys = [];
  9338. function cache(key, value) {
  9339. if (keys.push(key + " ") > jQuery.expr.cacheLength) {
  9340. delete cache[keys.shift()];
  9341. }
  9342. return cache[key + " "] = value;
  9343. }
  9344. return cache;
  9345. }
  9346. function testContext(context) {
  9347. return context && typeof context.getElementsByTagName !== "undefined" && context;
  9348. }
  9349. var attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + // Operator (capture 2)
  9350. "*([*^$|!~]?=)" + whitespace + // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  9351. `*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(` + identifier + "))|)" + whitespace + "*\\]";
  9352. var pseudos = ":(" + identifier + `)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|` + attributes + ")*)|.*)\\)|)";
  9353. var filterMatchExpr = {
  9354. ID: new RegExp("^#(" + identifier + ")"),
  9355. CLASS: new RegExp("^\\.(" + identifier + ")"),
  9356. TAG: new RegExp("^(" + identifier + "|[*])"),
  9357. ATTR: new RegExp("^" + attributes),
  9358. PSEUDO: new RegExp("^" + pseudos),
  9359. CHILD: new RegExp(
  9360. "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)",
  9361. "i"
  9362. )
  9363. };
  9364. var rpseudo = new RegExp(pseudos);
  9365. var runescape = new RegExp("\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g"), funescape = function(escape, nonHex) {
  9366. var high = "0x" + escape.slice(1) - 65536;
  9367. if (nonHex) {
  9368. return nonHex;
  9369. }
  9370. return high < 0 ? String.fromCharCode(high + 65536) : String.fromCharCode(high >> 10 | 55296, high & 1023 | 56320);
  9371. };
  9372. function unescapeSelector(sel) {
  9373. return sel.replace(runescape, funescape);
  9374. }
  9375. function selectorError(msg) {
  9376. jQuery.error("Syntax error, unrecognized expression: " + msg);
  9377. }
  9378. var rcomma = new RegExp("^" + whitespace + "*," + whitespace + "*");
  9379. var tokenCache = createCache();
  9380. function tokenize(selector, parseOnly) {
  9381. var matched, match, tokens, type, soFar, groups, preFilters, cached = tokenCache[selector + " "];
  9382. if (cached) {
  9383. return parseOnly ? 0 : cached.slice(0);
  9384. }
  9385. soFar = selector;
  9386. groups = [];
  9387. preFilters = jQuery.expr.preFilter;
  9388. while (soFar) {
  9389. if (!matched || (match = rcomma.exec(soFar))) {
  9390. if (match) {
  9391. soFar = soFar.slice(match[0].length) || soFar;
  9392. }
  9393. groups.push(tokens = []);
  9394. }
  9395. matched = false;
  9396. if (match = rleadingCombinator.exec(soFar)) {
  9397. matched = match.shift();
  9398. tokens.push({
  9399. value: matched,
  9400. // Cast descendant combinators to space
  9401. type: match[0].replace(rtrimCSS, " ")
  9402. });
  9403. soFar = soFar.slice(matched.length);
  9404. }
  9405. for (type in filterMatchExpr) {
  9406. if ((match = jQuery.expr.match[type].exec(soFar)) && (!preFilters[type] || (match = preFilters[type](match)))) {
  9407. matched = match.shift();
  9408. tokens.push({
  9409. value: matched,
  9410. type,
  9411. matches: match
  9412. });
  9413. soFar = soFar.slice(matched.length);
  9414. }
  9415. }
  9416. if (!matched) {
  9417. break;
  9418. }
  9419. }
  9420. if (parseOnly) {
  9421. return soFar.length;
  9422. }
  9423. return soFar ? selectorError(selector) : (
  9424. // Cache the tokens
  9425. tokenCache(selector, groups).slice(0)
  9426. );
  9427. }
  9428. var preFilter = {
  9429. ATTR: function(match) {
  9430. match[1] = unescapeSelector(match[1]);
  9431. match[3] = unescapeSelector(match[3] || match[4] || match[5] || "");
  9432. if (match[2] === "~=") {
  9433. match[3] = " " + match[3] + " ";
  9434. }
  9435. return match.slice(0, 4);
  9436. },
  9437. CHILD: function(match) {
  9438. match[1] = match[1].toLowerCase();
  9439. if (match[1].slice(0, 3) === "nth") {
  9440. if (!match[3]) {
  9441. selectorError(match[0]);
  9442. }
  9443. match[4] = +(match[4] ? match[5] + (match[6] || 1) : 2 * (match[3] === "even" || match[3] === "odd"));
  9444. match[5] = +(match[7] + match[8] || match[3] === "odd");
  9445. } else if (match[3]) {
  9446. selectorError(match[0]);
  9447. }
  9448. return match;
  9449. },
  9450. PSEUDO: function(match) {
  9451. var excess, unquoted = !match[6] && match[2];
  9452. if (filterMatchExpr.CHILD.test(match[0])) {
  9453. return null;
  9454. }
  9455. if (match[3]) {
  9456. match[2] = match[4] || match[5] || "";
  9457. } else if (unquoted && rpseudo.test(unquoted) && // Get excess from tokenize (recursively)
  9458. (excess = tokenize(unquoted, true)) && // advance to the next closing parenthesis
  9459. (excess = unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)) {
  9460. match[0] = match[0].slice(0, excess);
  9461. match[2] = unquoted.slice(0, excess);
  9462. }
  9463. return match.slice(0, 3);
  9464. }
  9465. };
  9466. function toSelector(tokens) {
  9467. var i2 = 0, len = tokens.length, selector = "";
  9468. for (; i2 < len; i2++) {
  9469. selector += tokens[i2].value;
  9470. }
  9471. return selector;
  9472. }
  9473. var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;
  9474. function fcssescape(ch, asCodePoint) {
  9475. if (asCodePoint) {
  9476. if (ch === "\0") {
  9477. return "\uFFFD";
  9478. }
  9479. return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16) + " ";
  9480. }
  9481. return "\\" + ch;
  9482. }
  9483. jQuery.escapeSelector = function(sel) {
  9484. return (sel + "").replace(rcssescape, fcssescape);
  9485. };
  9486. var sort = arr.sort;
  9487. var splice = arr.splice;
  9488. var hasDuplicate;
  9489. function sortOrder(a, b) {
  9490. if (a === b) {
  9491. hasDuplicate = true;
  9492. return 0;
  9493. }
  9494. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  9495. if (compare) {
  9496. return compare;
  9497. }
  9498. compare = (a.ownerDocument || a) == (b.ownerDocument || b) ? a.compareDocumentPosition(b) : (
  9499. // Otherwise we know they are disconnected
  9500. 1
  9501. );
  9502. if (compare & 1) {
  9503. if (a == document || a.ownerDocument == document && jQuery.contains(document, a)) {
  9504. return -1;
  9505. }
  9506. if (b == document || b.ownerDocument == document && jQuery.contains(document, b)) {
  9507. return 1;
  9508. }
  9509. return 0;
  9510. }
  9511. return compare & 4 ? -1 : 1;
  9512. }
  9513. jQuery.uniqueSort = function(results) {
  9514. var elem, duplicates = [], j = 0, i2 = 0;
  9515. hasDuplicate = false;
  9516. sort.call(results, sortOrder);
  9517. if (hasDuplicate) {
  9518. while (elem = results[i2++]) {
  9519. if (elem === results[i2]) {
  9520. j = duplicates.push(i2);
  9521. }
  9522. }
  9523. while (j--) {
  9524. splice.call(results, duplicates[j], 1);
  9525. }
  9526. }
  9527. return results;
  9528. };
  9529. jQuery.fn.uniqueSort = function() {
  9530. return this.pushStack(jQuery.uniqueSort(slice.apply(this)));
  9531. };
  9532. var i, outermostContext, document$1, documentElement$1, documentIsHTML, dirruns = 0, done = 0, classCache = createCache(), compilerCache = createCache(), nonnativeSelectorCache = createCache(), rwhitespace = new RegExp(whitespace + "+", "g"), ridentifier = new RegExp("^" + identifier + "$"), matchExpr = jQuery.extend({
  9533. bool: new RegExp("^(?:" + booleans + ")$", "i"),
  9534. // For use in libraries implementing .is()
  9535. // We use this for POS matching in `select`
  9536. needsContext: new RegExp("^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i")
  9537. }, filterMatchExpr), rinputs = /^(?:input|select|textarea|button)$/i, rheader = /^h\d$/i, rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, unloadHandler = function() {
  9538. setDocument();
  9539. }, inDisabledFieldset = addCombinator(
  9540. function(elem) {
  9541. return elem.disabled === true && nodeName(elem, "fieldset");
  9542. },
  9543. { dir: "parentNode", next: "legend" }
  9544. );
  9545. function find(selector, context, results, seed) {
  9546. var m, i2, elem, nid, match, groups, newSelector, newContext = context && context.ownerDocument, nodeType = context ? context.nodeType : 9;
  9547. results = results || [];
  9548. if (typeof selector !== "string" || !selector || nodeType !== 1 && nodeType !== 9 && nodeType !== 11) {
  9549. return results;
  9550. }
  9551. if (false) {
  9552. setDocument(context);
  9553. context = context || document$1;
  9554. if (documentIsHTML) {
  9555. if (nodeType !== 11 && (match = rquickExpr.exec(selector))) {
  9556. if (m = match[1]) {
  9557. if (nodeType === 9) {
  9558. if (elem = context.getElementById(m)) {
  9559. push.call(results, elem);
  9560. }
  9561. return results;
  9562. } else {
  9563. if (newContext && (elem = newContext.getElementById(m)) && jQuery.contains(context, elem)) {
  9564. push.call(results, elem);
  9565. return results;
  9566. }
  9567. }
  9568. } else if (match[2]) {
  9569. push.apply(results, context.getElementsByTagName(selector));
  9570. return results;
  9571. } else if ((m = match[3]) && context.getElementsByClassName) {
  9572. push.apply(results, context.getElementsByClassName(m));
  9573. return results;
  9574. }
  9575. }
  9576. if (!nonnativeSelectorCache[selector + " "] && (!rbuggyQSA || !rbuggyQSA.test(selector))) {
  9577. newSelector = selector;
  9578. newContext = context;
  9579. if (nodeType === 1 && (rdescend.test(selector) || rleadingCombinator.test(selector))) {
  9580. newContext = rsibling.test(selector) && testContext(context.parentNode) || context;
  9581. if (newContext != context || isIE) {
  9582. if (nid = context.getAttribute("id")) {
  9583. nid = jQuery.escapeSelector(nid);
  9584. } else {
  9585. context.setAttribute("id", nid = jQuery.expando);
  9586. }
  9587. }
  9588. groups = tokenize(selector);
  9589. i2 = groups.length;
  9590. while (i2--) {
  9591. groups[i2] = (nid ? "#" + nid : ":scope") + " " + toSelector(groups[i2]);
  9592. }
  9593. newSelector = groups.join(",");
  9594. }
  9595. try {
  9596. push.apply(
  9597. results,
  9598. newContext.querySelectorAll(newSelector)
  9599. );
  9600. return results;
  9601. } catch (qsaError) {
  9602. nonnativeSelectorCache(selector, true);
  9603. } finally {
  9604. if (nid === jQuery.expando) {
  9605. context.removeAttribute("id");
  9606. }
  9607. }
  9608. }
  9609. }
  9610. }
  9611. return select(selector.replace(rtrimCSS, "$1"), context, results, seed);
  9612. }
  9613. function markFunction(fn) {
  9614. fn[jQuery.expando] = true;
  9615. return fn;
  9616. }
  9617. function createInputPseudo(type) {
  9618. return function(elem) {
  9619. return nodeName(elem, "input") && elem.type === type;
  9620. };
  9621. }
  9622. function createButtonPseudo(type) {
  9623. return function(elem) {
  9624. return (nodeName(elem, "input") || nodeName(elem, "button")) && elem.type === type;
  9625. };
  9626. }
  9627. function createDisabledPseudo(disabled) {
  9628. return function(elem) {
  9629. if ("form" in elem) {
  9630. if (elem.parentNode && elem.disabled === false) {
  9631. if ("label" in elem) {
  9632. if ("label" in elem.parentNode) {
  9633. return elem.parentNode.disabled === disabled;
  9634. } else {
  9635. return elem.disabled === disabled;
  9636. }
  9637. }
  9638. return elem.isDisabled === disabled || // Where there is no isDisabled, check manually
  9639. elem.isDisabled !== !disabled && inDisabledFieldset(elem) === disabled;
  9640. }
  9641. return elem.disabled === disabled;
  9642. } else if ("label" in elem) {
  9643. return elem.disabled === disabled;
  9644. }
  9645. return false;
  9646. };
  9647. }
  9648. function createPositionalPseudo(fn) {
  9649. return markFunction(function(argument) {
  9650. argument = +argument;
  9651. return markFunction(function(seed, matches3) {
  9652. var j, matchIndexes = fn([], seed.length, argument), i2 = matchIndexes.length;
  9653. while (i2--) {
  9654. if (seed[j = matchIndexes[i2]]) {
  9655. seed[j] = !(matches3[j] = seed[j]);
  9656. }
  9657. }
  9658. });
  9659. });
  9660. }
  9661. function setDocument(node) {
  9662. var subWindow, doc = node ? node.ownerDocument || node : document;
  9663. if (doc == document$1 || doc.nodeType !== 9) {
  9664. return;
  9665. }
  9666. document$1 = doc;
  9667. documentElement$1 = document$1.documentElement;
  9668. documentIsHTML = !jQuery.isXMLDoc(document$1);
  9669. if (isIE && document != document$1 && (subWindow = document$1.defaultView) && subWindow.top !== subWindow) {
  9670. subWindow.addEventListener("unload", unloadHandler);
  9671. }
  9672. }
  9673. find.matches = function(expr, elements) {
  9674. return find(expr, null, null, elements);
  9675. };
  9676. find.matchesSelector = function(elem, expr) {
  9677. setDocument(elem);
  9678. if (documentIsHTML && !nonnativeSelectorCache[expr + " "] && (!rbuggyQSA || !rbuggyQSA.test(expr))) {
  9679. try {
  9680. return matches2.call(elem, expr);
  9681. } catch (e) {
  9682. nonnativeSelectorCache(expr, true);
  9683. }
  9684. }
  9685. return find(expr, document$1, null, [elem]).length > 0;
  9686. };
  9687. jQuery.expr = {
  9688. // Can be adjusted by the user
  9689. cacheLength: 50,
  9690. createPseudo: markFunction,
  9691. match: matchExpr,
  9692. find: {
  9693. ID: function(id, context) {
  9694. if (typeof context.getElementById !== "undefined" && documentIsHTML) {
  9695. var elem = context.getElementById(id);
  9696. return elem ? [elem] : [];
  9697. }
  9698. },
  9699. TAG: function(tag, context) {
  9700. if (typeof context.getElementsByTagName !== "undefined") {
  9701. return context.getElementsByTagName(tag);
  9702. } else {
  9703. return context.querySelectorAll(tag);
  9704. }
  9705. },
  9706. CLASS: function(className, context) {
  9707. if (typeof context.getElementsByClassName !== "undefined" && documentIsHTML) {
  9708. return context.getElementsByClassName(className);
  9709. }
  9710. }
  9711. },
  9712. relative: {
  9713. ">": { dir: "parentNode", first: true },
  9714. " ": { dir: "parentNode" },
  9715. "+": { dir: "previousSibling", first: true },
  9716. "~": { dir: "previousSibling" }
  9717. },
  9718. preFilter,
  9719. filter: {
  9720. ID: function(id) {
  9721. var attrId = unescapeSelector(id);
  9722. return function(elem) {
  9723. return elem.getAttribute("id") === attrId;
  9724. };
  9725. },
  9726. TAG: function(nodeNameSelector) {
  9727. var expectedNodeName = unescapeSelector(nodeNameSelector).toLowerCase();
  9728. return nodeNameSelector === "*" ? function() {
  9729. return true;
  9730. } : function(elem) {
  9731. return nodeName(elem, expectedNodeName);
  9732. };
  9733. },
  9734. CLASS: function(className) {
  9735. var pattern = classCache[className + " "];
  9736. return pattern || (pattern = new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)")) && classCache(className, function(elem) {
  9737. return pattern.test(
  9738. typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || ""
  9739. );
  9740. });
  9741. },
  9742. ATTR: function(name, operator, check) {
  9743. return function(elem) {
  9744. var result = elem.getAttribute(name);
  9745. if (result == null) {
  9746. return operator === "!=";
  9747. }
  9748. if (!operator) {
  9749. return true;
  9750. }
  9751. result += "";
  9752. if (operator === "=") {
  9753. return result === check;
  9754. }
  9755. if (operator === "!=") {
  9756. return result !== check;
  9757. }
  9758. if (operator === "^=") {
  9759. return check && result.indexOf(check) === 0;
  9760. }
  9761. if (operator === "*=") {
  9762. return check && result.indexOf(check) > -1;
  9763. }
  9764. if (operator === "$=") {
  9765. return check && result.slice(-check.length) === check;
  9766. }
  9767. if (operator === "~=") {
  9768. return (" " + result.replace(rwhitespace, " ") + " ").indexOf(check) > -1;
  9769. }
  9770. if (operator === "|=") {
  9771. return result === check || result.slice(0, check.length + 1) === check + "-";
  9772. }
  9773. return false;
  9774. };
  9775. },
  9776. CHILD: function(type, what, _argument, first, last) {
  9777. var simple = type.slice(0, 3) !== "nth", forward = type.slice(-4) !== "last", ofType = what === "of-type";
  9778. return first === 1 && last === 0 ? (
  9779. // Shortcut for :nth-*(n)
  9780. function(elem) {
  9781. return !!elem.parentNode;
  9782. }
  9783. ) : function(elem, _context, xml) {
  9784. var cache, outerCache, node, nodeIndex, start, dir = simple !== forward ? "nextSibling" : "previousSibling", parent = elem.parentNode, name = ofType && elem.nodeName.toLowerCase(), useCache = !xml && !ofType, diff = false;
  9785. if (parent) {
  9786. if (simple) {
  9787. while (dir) {
  9788. node = elem;
  9789. while (node = node[dir]) {
  9790. if (ofType ? nodeName(node, name) : node.nodeType === 1) {
  9791. return false;
  9792. }
  9793. }
  9794. start = dir = type === "only" && !start && "nextSibling";
  9795. }
  9796. return true;
  9797. }
  9798. start = [forward ? parent.firstChild : parent.lastChild];
  9799. if (forward && useCache) {
  9800. outerCache = parent[jQuery.expando] || (parent[jQuery.expando] = {});
  9801. cache = outerCache[type] || [];
  9802. nodeIndex = cache[0] === dirruns && cache[1];
  9803. diff = nodeIndex && cache[2];
  9804. node = nodeIndex && parent.childNodes[nodeIndex];
  9805. while (node = ++nodeIndex && node && node[dir] || // Fallback to seeking `elem` from the start
  9806. (diff = nodeIndex = 0) || start.pop()) {
  9807. if (node.nodeType === 1 && ++diff && node === elem) {
  9808. outerCache[type] = [dirruns, nodeIndex, diff];
  9809. break;
  9810. }
  9811. }
  9812. } else {
  9813. if (useCache) {
  9814. outerCache = elem[jQuery.expando] || (elem[jQuery.expando] = {});
  9815. cache = outerCache[type] || [];
  9816. nodeIndex = cache[0] === dirruns && cache[1];
  9817. diff = nodeIndex;
  9818. }
  9819. if (diff === false) {
  9820. while (node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop()) {
  9821. if ((ofType ? nodeName(node, name) : node.nodeType === 1) && ++diff) {
  9822. if (useCache) {
  9823. outerCache = node[jQuery.expando] || (node[jQuery.expando] = {});
  9824. outerCache[type] = [dirruns, diff];
  9825. }
  9826. if (node === elem) {
  9827. break;
  9828. }
  9829. }
  9830. }
  9831. }
  9832. }
  9833. diff -= last;
  9834. return diff === first || diff % first === 0 && diff / first >= 0;
  9835. }
  9836. };
  9837. },
  9838. PSEUDO: function(pseudo, argument) {
  9839. var fn = jQuery.expr.pseudos[pseudo] || jQuery.expr.setFilters[pseudo.toLowerCase()] || selectorError("unsupported pseudo: " + pseudo);
  9840. if (fn[jQuery.expando]) {
  9841. return fn(argument);
  9842. }
  9843. return fn;
  9844. }
  9845. },
  9846. pseudos: {
  9847. // Potentially complex pseudos
  9848. not: markFunction(function(selector) {
  9849. var input = [], results = [], matcher = compile(selector.replace(rtrimCSS, "$1"));
  9850. return matcher[jQuery.expando] ? markFunction(function(seed, matches3, _context, xml) {
  9851. var elem, unmatched = matcher(seed, null, xml, []), i2 = seed.length;
  9852. while (i2--) {
  9853. if (elem = unmatched[i2]) {
  9854. seed[i2] = !(matches3[i2] = elem);
  9855. }
  9856. }
  9857. }) : function(elem, _context, xml) {
  9858. input[0] = elem;
  9859. matcher(input, null, xml, results);
  9860. input[0] = null;
  9861. return !results.pop();
  9862. };
  9863. }),
  9864. has: markFunction(function(selector) {
  9865. return function(elem) {
  9866. return find(selector, elem).length > 0;
  9867. };
  9868. }),
  9869. contains: markFunction(function(text) {
  9870. text = unescapeSelector(text);
  9871. return function(elem) {
  9872. return (elem.textContent || jQuery.text(elem)).indexOf(text) > -1;
  9873. };
  9874. }),
  9875. // "Whether an element is represented by a :lang() selector
  9876. // is based solely on the element's language value
  9877. // being equal to the identifier C,
  9878. // or beginning with the identifier C immediately followed by "-".
  9879. // The matching of C against the element's language value is performed case-insensitively.
  9880. // The identifier C does not have to be a valid language name."
  9881. // https://www.w3.org/TR/selectors/#lang-pseudo
  9882. lang: markFunction(function(lang) {
  9883. if (!ridentifier.test(lang || "")) {
  9884. selectorError("unsupported lang: " + lang);
  9885. }
  9886. lang = unescapeSelector(lang).toLowerCase();
  9887. return function(elem) {
  9888. var elemLang;
  9889. do {
  9890. if (elemLang = documentIsHTML ? elem.lang : elem.getAttribute("xml:lang") || elem.getAttribute("lang")) {
  9891. elemLang = elemLang.toLowerCase();
  9892. return elemLang === lang || elemLang.indexOf(lang + "-") === 0;
  9893. }
  9894. } while ((elem = elem.parentNode) && elem.nodeType === 1);
  9895. return false;
  9896. };
  9897. }),
  9898. // Miscellaneous
  9899. target: function(elem) {
  9900. var hash = window.location && window.location.hash;
  9901. return hash && hash.slice(1) === elem.id;
  9902. },
  9903. root: function(elem) {
  9904. return elem === documentElement$1;
  9905. },
  9906. focus: function(elem) {
  9907. return elem === document$1.activeElement && document$1.hasFocus() && !!(elem.type || elem.href || ~elem.tabIndex);
  9908. },
  9909. // Boolean properties
  9910. enabled: createDisabledPseudo(false),
  9911. disabled: createDisabledPseudo(true),
  9912. checked: function(elem) {
  9913. return nodeName(elem, "input") && !!elem.checked || nodeName(elem, "option") && !!elem.selected;
  9914. },
  9915. selected: function(elem) {
  9916. if (isIE && elem.parentNode) {
  9917. elem.parentNode.selectedIndex;
  9918. }
  9919. return elem.selected === true;
  9920. },
  9921. // Contents
  9922. empty: function(elem) {
  9923. for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
  9924. if (elem.nodeType < 6) {
  9925. return false;
  9926. }
  9927. }
  9928. return true;
  9929. },
  9930. parent: function(elem) {
  9931. return !jQuery.expr.pseudos.empty(elem);
  9932. },
  9933. // Element/input types
  9934. header: function(elem) {
  9935. return rheader.test(elem.nodeName);
  9936. },
  9937. input: function(elem) {
  9938. return rinputs.test(elem.nodeName);
  9939. },
  9940. button: function(elem) {
  9941. return nodeName(elem, "input") && elem.type === "button" || nodeName(elem, "button");
  9942. },
  9943. text: function(elem) {
  9944. return nodeName(elem, "input") && elem.type === "text";
  9945. },
  9946. // Position-in-collection
  9947. first: createPositionalPseudo(function() {
  9948. return [0];
  9949. }),
  9950. last: createPositionalPseudo(function(_matchIndexes, length) {
  9951. return [length - 1];
  9952. }),
  9953. eq: createPositionalPseudo(function(_matchIndexes, length, argument) {
  9954. return [argument < 0 ? argument + length : argument];
  9955. }),
  9956. even: createPositionalPseudo(function(matchIndexes, length) {
  9957. var i2 = 0;
  9958. for (; i2 < length; i2 += 2) {
  9959. matchIndexes.push(i2);
  9960. }
  9961. return matchIndexes;
  9962. }),
  9963. odd: createPositionalPseudo(function(matchIndexes, length) {
  9964. var i2 = 1;
  9965. for (; i2 < length; i2 += 2) {
  9966. matchIndexes.push(i2);
  9967. }
  9968. return matchIndexes;
  9969. }),
  9970. lt: createPositionalPseudo(function(matchIndexes, length, argument) {
  9971. var i2;
  9972. if (argument < 0) {
  9973. i2 = argument + length;
  9974. } else if (argument > length) {
  9975. i2 = length;
  9976. } else {
  9977. i2 = argument;
  9978. }
  9979. for (; --i2 >= 0; ) {
  9980. matchIndexes.push(i2);
  9981. }
  9982. return matchIndexes;
  9983. }),
  9984. gt: createPositionalPseudo(function(matchIndexes, length, argument) {
  9985. var i2 = argument < 0 ? argument + length : argument;
  9986. for (; ++i2 < length; ) {
  9987. matchIndexes.push(i2);
  9988. }
  9989. return matchIndexes;
  9990. })
  9991. }
  9992. };
  9993. jQuery.expr.pseudos.nth = jQuery.expr.pseudos.eq;
  9994. for (i in { radio: true, checkbox: true, file: true, password: true, image: true }) {
  9995. jQuery.expr.pseudos[i] = createInputPseudo(i);
  9996. }
  9997. for (i in { submit: true, reset: true }) {
  9998. jQuery.expr.pseudos[i] = createButtonPseudo(i);
  9999. }
  10000. function setFilters() {
  10001. }
  10002. setFilters.prototype = jQuery.expr.filters = jQuery.expr.pseudos;
  10003. jQuery.expr.setFilters = new setFilters();
  10004. function addCombinator(matcher, combinator, base) {
  10005. var dir = combinator.dir, skip = combinator.next, key = skip || dir, checkNonElements = base && key === "parentNode", doneName = done++;
  10006. return combinator.first ? (
  10007. // Check against closest ancestor/preceding element
  10008. function(elem, context, xml) {
  10009. while (elem = elem[dir]) {
  10010. if (elem.nodeType === 1 || checkNonElements) {
  10011. return matcher(elem, context, xml);
  10012. }
  10013. }
  10014. return false;
  10015. }
  10016. ) : (
  10017. // Check against all ancestor/preceding elements
  10018. function(elem, context, xml) {
  10019. var oldCache, outerCache, newCache = [dirruns, doneName];
  10020. if (xml) {
  10021. while (elem = elem[dir]) {
  10022. if (elem.nodeType === 1 || checkNonElements) {
  10023. if (matcher(elem, context, xml)) {
  10024. return true;
  10025. }
  10026. }
  10027. }
  10028. } else {
  10029. while (elem = elem[dir]) {
  10030. if (elem.nodeType === 1 || checkNonElements) {
  10031. outerCache = elem[jQuery.expando] || (elem[jQuery.expando] = {});
  10032. if (skip && nodeName(elem, skip)) {
  10033. elem = elem[dir] || elem;
  10034. } else if ((oldCache = outerCache[key]) && oldCache[0] === dirruns && oldCache[1] === doneName) {
  10035. return newCache[2] = oldCache[2];
  10036. } else {
  10037. outerCache[key] = newCache;
  10038. if (newCache[2] = matcher(elem, context, xml)) {
  10039. return true;
  10040. }
  10041. }
  10042. }
  10043. }
  10044. }
  10045. return false;
  10046. }
  10047. );
  10048. }
  10049. function elementMatcher(matchers) {
  10050. return matchers.length > 1 ? function(elem, context, xml) {
  10051. var i2 = matchers.length;
  10052. while (i2--) {
  10053. if (!matchers[i2](elem, context, xml)) {
  10054. return false;
  10055. }
  10056. }
  10057. return true;
  10058. } : matchers[0];
  10059. }
  10060. function multipleContexts(selector, contexts, results) {
  10061. var i2 = 0, len = contexts.length;
  10062. for (; i2 < len; i2++) {
  10063. find(selector, contexts[i2], results);
  10064. }
  10065. return results;
  10066. }
  10067. function condense(unmatched, map2, filter, context, xml) {
  10068. var elem, newUnmatched = [], i2 = 0, len = unmatched.length, mapped = map2 != null;
  10069. for (; i2 < len; i2++) {
  10070. if (elem = unmatched[i2]) {
  10071. if (!filter || filter(elem, context, xml)) {
  10072. newUnmatched.push(elem);
  10073. if (mapped) {
  10074. map2.push(i2);
  10075. }
  10076. }
  10077. }
  10078. }
  10079. return newUnmatched;
  10080. }
  10081. function setMatcher(preFilter2, selector, matcher, postFilter, postFinder, postSelector) {
  10082. if (postFilter && !postFilter[jQuery.expando]) {
  10083. postFilter = setMatcher(postFilter);
  10084. }
  10085. if (postFinder && !postFinder[jQuery.expando]) {
  10086. postFinder = setMatcher(postFinder, postSelector);
  10087. }
  10088. return markFunction(function(seed, results, context, xml) {
  10089. var temp, i2, elem, matcherOut, preMap = [], postMap = [], preexisting = results.length, elems = seed || multipleContexts(
  10090. selector || "*",
  10091. context.nodeType ? [context] : context,
  10092. []
  10093. ), matcherIn = preFilter2 && (seed || !selector) ? condense(elems, preMap, preFilter2, context, xml) : elems;
  10094. if (matcher) {
  10095. matcherOut = postFinder || (seed ? preFilter2 : preexisting || postFilter) ? (
  10096. // ...intermediate processing is necessary
  10097. []
  10098. ) : (
  10099. // ...otherwise use results directly
  10100. results
  10101. );
  10102. matcher(matcherIn, matcherOut, context, xml);
  10103. } else {
  10104. matcherOut = matcherIn;
  10105. }
  10106. if (postFilter) {
  10107. temp = condense(matcherOut, postMap);
  10108. postFilter(temp, [], context, xml);
  10109. i2 = temp.length;
  10110. while (i2--) {
  10111. if (elem = temp[i2]) {
  10112. matcherOut[postMap[i2]] = !(matcherIn[postMap[i2]] = elem);
  10113. }
  10114. }
  10115. }
  10116. if (seed) {
  10117. if (postFinder || preFilter2) {
  10118. if (postFinder) {
  10119. temp = [];
  10120. i2 = matcherOut.length;
  10121. while (i2--) {
  10122. if (elem = matcherOut[i2]) {
  10123. temp.push(matcherIn[i2] = elem);
  10124. }
  10125. }
  10126. postFinder(null, matcherOut = [], temp, xml);
  10127. }
  10128. i2 = matcherOut.length;
  10129. while (i2--) {
  10130. if ((elem = matcherOut[i2]) && (temp = postFinder ? indexOf.call(seed, elem) : preMap[i2]) > -1) {
  10131. seed[temp] = !(results[temp] = elem);
  10132. }
  10133. }
  10134. }
  10135. } else {
  10136. matcherOut = condense(
  10137. matcherOut === results ? matcherOut.splice(preexisting, matcherOut.length) : matcherOut
  10138. );
  10139. if (postFinder) {
  10140. postFinder(null, results, matcherOut, xml);
  10141. } else {
  10142. push.apply(results, matcherOut);
  10143. }
  10144. }
  10145. });
  10146. }
  10147. function matcherFromTokens(tokens) {
  10148. var checkContext, matcher, j, len = tokens.length, leadingRelative = jQuery.expr.relative[tokens[0].type], implicitRelative = leadingRelative || jQuery.expr.relative[" "], i2 = leadingRelative ? 1 : 0, matchContext = addCombinator(function(elem) {
  10149. return elem === checkContext;
  10150. }, implicitRelative, true), matchAnyContext = addCombinator(function(elem) {
  10151. return indexOf.call(checkContext, elem) > -1;
  10152. }, implicitRelative, true), matchers = [function(elem, context, xml) {
  10153. var ret = !leadingRelative && (xml || context != outermostContext) || ((checkContext = context).nodeType ? matchContext(elem, context, xml) : matchAnyContext(elem, context, xml));
  10154. checkContext = null;
  10155. return ret;
  10156. }];
  10157. for (; i2 < len; i2++) {
  10158. if (matcher = jQuery.expr.relative[tokens[i2].type]) {
  10159. matchers = [addCombinator(elementMatcher(matchers), matcher)];
  10160. } else {
  10161. matcher = jQuery.expr.filter[tokens[i2].type].apply(null, tokens[i2].matches);
  10162. if (matcher[jQuery.expando]) {
  10163. j = ++i2;
  10164. for (; j < len; j++) {
  10165. if (jQuery.expr.relative[tokens[j].type]) {
  10166. break;
  10167. }
  10168. }
  10169. return setMatcher(
  10170. i2 > 1 && elementMatcher(matchers),
  10171. i2 > 1 && toSelector(
  10172. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  10173. tokens.slice(0, i2 - 1).concat({ value: tokens[i2 - 2].type === " " ? "*" : "" })
  10174. ).replace(rtrimCSS, "$1"),
  10175. matcher,
  10176. i2 < j && matcherFromTokens(tokens.slice(i2, j)),
  10177. j < len && matcherFromTokens(tokens = tokens.slice(j)),
  10178. j < len && toSelector(tokens)
  10179. );
  10180. }
  10181. matchers.push(matcher);
  10182. }
  10183. }
  10184. return elementMatcher(matchers);
  10185. }
  10186. function matcherFromGroupMatchers(elementMatchers, setMatchers) {
  10187. var bySet = setMatchers.length > 0, byElement = elementMatchers.length > 0, superMatcher = function(seed, context, xml, results, outermost) {
  10188. var elem, j, matcher, matchedCount = 0, i2 = "0", unmatched = seed && [], setMatched = [], contextBackup = outermostContext, elems = seed || byElement && jQuery.expr.find.TAG("*", outermost), dirrunsUnique = dirruns += contextBackup == null ? 1 : Math.random() || 0.1;
  10189. if (outermost) {
  10190. outermostContext = context == document$1 || context || outermost;
  10191. }
  10192. for (; (elem = elems[i2]) != null; i2++) {
  10193. if (byElement && elem) {
  10194. j = 0;
  10195. if (!context && elem.ownerDocument != document$1) {
  10196. setDocument(elem);
  10197. xml = !documentIsHTML;
  10198. }
  10199. while (matcher = elementMatchers[j++]) {
  10200. if (matcher(elem, context || document$1, xml)) {
  10201. push.call(results, elem);
  10202. break;
  10203. }
  10204. }
  10205. if (outermost) {
  10206. dirruns = dirrunsUnique;
  10207. }
  10208. }
  10209. if (bySet) {
  10210. if (elem = !matcher && elem) {
  10211. matchedCount--;
  10212. }
  10213. if (seed) {
  10214. unmatched.push(elem);
  10215. }
  10216. }
  10217. }
  10218. matchedCount += i2;
  10219. if (bySet && i2 !== matchedCount) {
  10220. j = 0;
  10221. while (matcher = setMatchers[j++]) {
  10222. matcher(unmatched, setMatched, context, xml);
  10223. }
  10224. if (seed) {
  10225. if (matchedCount > 0) {
  10226. while (i2--) {
  10227. if (!(unmatched[i2] || setMatched[i2])) {
  10228. setMatched[i2] = pop.call(results);
  10229. }
  10230. }
  10231. }
  10232. setMatched = condense(setMatched);
  10233. }
  10234. push.apply(results, setMatched);
  10235. if (outermost && !seed && setMatched.length > 0 && matchedCount + setMatchers.length > 1) {
  10236. jQuery.uniqueSort(results);
  10237. }
  10238. }
  10239. if (outermost) {
  10240. dirruns = dirrunsUnique;
  10241. outermostContext = contextBackup;
  10242. }
  10243. return unmatched;
  10244. };
  10245. return bySet ? markFunction(superMatcher) : superMatcher;
  10246. }
  10247. function compile(selector, match) {
  10248. var i2, setMatchers = [], elementMatchers = [], cached = compilerCache[selector + " "];
  10249. if (!cached) {
  10250. if (!match) {
  10251. match = tokenize(selector);
  10252. }
  10253. i2 = match.length;
  10254. while (i2--) {
  10255. cached = matcherFromTokens(match[i2]);
  10256. if (cached[jQuery.expando]) {
  10257. setMatchers.push(cached);
  10258. } else {
  10259. elementMatchers.push(cached);
  10260. }
  10261. }
  10262. cached = compilerCache(
  10263. selector,
  10264. matcherFromGroupMatchers(elementMatchers, setMatchers)
  10265. );
  10266. cached.selector = selector;
  10267. }
  10268. return cached;
  10269. }
  10270. function select(selector, context, results, seed) {
  10271. var i2, tokens, token, type, find2, compiled = typeof selector === "function" && selector, match = !seed && tokenize(selector = compiled.selector || selector);
  10272. results = results || [];
  10273. if (match.length === 1) {
  10274. tokens = match[0] = match[0].slice(0);
  10275. if (tokens.length > 2 && (token = tokens[0]).type === "ID" && context.nodeType === 9 && documentIsHTML && jQuery.expr.relative[tokens[1].type]) {
  10276. context = (jQuery.expr.find.ID(
  10277. unescapeSelector(token.matches[0]),
  10278. context
  10279. ) || [])[0];
  10280. if (!context) {
  10281. return results;
  10282. } else if (compiled) {
  10283. context = context.parentNode;
  10284. }
  10285. selector = selector.slice(tokens.shift().value.length);
  10286. }
  10287. i2 = matchExpr.needsContext.test(selector) ? 0 : tokens.length;
  10288. while (i2--) {
  10289. token = tokens[i2];
  10290. if (jQuery.expr.relative[type = token.type]) {
  10291. break;
  10292. }
  10293. if (find2 = jQuery.expr.find[type]) {
  10294. if (seed = find2(
  10295. unescapeSelector(token.matches[0]),
  10296. rsibling.test(tokens[0].type) && testContext(context.parentNode) || context
  10297. )) {
  10298. tokens.splice(i2, 1);
  10299. selector = seed.length && toSelector(tokens);
  10300. if (!selector) {
  10301. push.apply(results, seed);
  10302. return results;
  10303. }
  10304. break;
  10305. }
  10306. }
  10307. }
  10308. }
  10309. (compiled || compile(selector, match))(
  10310. seed,
  10311. context,
  10312. !documentIsHTML,
  10313. results,
  10314. !context || rsibling.test(selector) && testContext(context.parentNode) || context
  10315. );
  10316. return results;
  10317. }
  10318. setDocument();
  10319. jQuery.find = find;
  10320. find.compile = compile;
  10321. find.select = select;
  10322. find.setDocument = setDocument;
  10323. find.tokenize = tokenize;
  10324. return jQuery;
  10325. })
  10326. );
  10327. // src/mock-doc/selector.ts
  10328. function matches(selector, elm) {
  10329. try {
  10330. const r = jquery_default.find(selector, void 0, void 0, [elm]);
  10331. return r.length > 0;
  10332. } catch (e) {
  10333. updateSelectorError(selector, e);
  10334. throw e;
  10335. }
  10336. }
  10337. function selectOne(selector, elm) {
  10338. try {
  10339. const r = jquery_default.find(selector, elm, void 0, void 0);
  10340. return r[0] || null;
  10341. } catch (e) {
  10342. updateSelectorError(selector, e);
  10343. throw e;
  10344. }
  10345. }
  10346. function selectAll(selector, elm) {
  10347. try {
  10348. return jquery_default.find(selector, elm, void 0, void 0);
  10349. } catch (e) {
  10350. updateSelectorError(selector, e);
  10351. throw e;
  10352. }
  10353. }
  10354. var PROBLEMATIC_SELECTORS = [":scope", ":where", ":is"];
  10355. function updateSelectorError(selector, e) {
  10356. const selectorsPresent = PROBLEMATIC_SELECTORS.filter((s) => selector.includes(s));
  10357. if (selectorsPresent.length > 0 && e.message) {
  10358. e.message = `At present jQuery does not support the ${humanReadableList(selectorsPresent)} ${selectorsPresent.length === 1 ? "selector" : "selectors"}.
  10359. If you need this in your test, consider writing an end-to-end test instead.
  10360. ` + e.message;
  10361. }
  10362. }
  10363. function humanReadableList(items) {
  10364. if (items.length <= 1) {
  10365. return items.join("");
  10366. }
  10367. return `${items.slice(0, items.length - 1).join(", ")} and ${items[items.length - 1]}`;
  10368. }
  10369. // src/mock-doc/serialize-node.ts
  10370. function normalizeSerializationOptions(opts = {}) {
  10371. return {
  10372. ...opts,
  10373. outerHtml: typeof opts.outerHtml !== "boolean" ? false : opts.outerHtml,
  10374. ...opts.prettyHtml ? {
  10375. indentSpaces: typeof opts.indentSpaces !== "number" ? 2 : opts.indentSpaces,
  10376. newLines: typeof opts.newLines !== "boolean" ? true : opts.newLines
  10377. } : {
  10378. prettyHtml: false,
  10379. indentSpaces: typeof opts.indentSpaces !== "number" ? 0 : opts.indentSpaces,
  10380. newLines: typeof opts.newLines !== "boolean" ? false : opts.newLines
  10381. },
  10382. approximateLineWidth: typeof opts.approximateLineWidth !== "number" ? -1 : opts.approximateLineWidth,
  10383. removeEmptyAttributes: typeof opts.removeEmptyAttributes !== "boolean" ? true : opts.removeEmptyAttributes,
  10384. removeAttributeQuotes: typeof opts.removeAttributeQuotes !== "boolean" ? false : opts.removeAttributeQuotes,
  10385. removeBooleanAttributeQuotes: typeof opts.removeBooleanAttributeQuotes !== "boolean" ? false : opts.removeBooleanAttributeQuotes,
  10386. removeHtmlComments: typeof opts.removeHtmlComments !== "boolean" ? false : opts.removeHtmlComments,
  10387. serializeShadowRoot: typeof opts.serializeShadowRoot !== "boolean" ? true : opts.serializeShadowRoot,
  10388. fullDocument: typeof opts.fullDocument !== "boolean" ? true : opts.fullDocument
  10389. };
  10390. }
  10391. function serializeNodeToHtml(elm, serializationOptions = {}) {
  10392. const opts = normalizeSerializationOptions(serializationOptions);
  10393. const output = {
  10394. currentLineWidth: 0,
  10395. indent: 0,
  10396. isWithinBody: false,
  10397. text: []
  10398. };
  10399. let renderedNode = "";
  10400. const children = !opts.fullDocument && elm.body ? Array.from(elm.body.childNodes) : opts.outerHtml ? [elm] : Array.from(elm.childNodes);
  10401. for (let i = 0, ii = children.length; i < ii; i++) {
  10402. const child = children[i];
  10403. const chunks = Array.from(streamToHtml(child, opts, output));
  10404. renderedNode += chunks.join("");
  10405. }
  10406. return renderedNode.trim();
  10407. }
  10408. var shadowRootTag = "mock:shadow-root";
  10409. function* streamToHtml(node, opts, output) {
  10410. var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
  10411. const isShadowRoot = node.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */;
  10412. if (node.nodeType === 1 /* ELEMENT_NODE */ || isShadowRoot) {
  10413. const tagName = isShadowRoot ? shadowRootTag : getTagName(node);
  10414. if (tagName === "body") {
  10415. output.isWithinBody = true;
  10416. }
  10417. const ignoreTag = opts.excludeTags != null && opts.excludeTags.includes(tagName);
  10418. if (ignoreTag === false) {
  10419. const isWithinWhitespaceSensitiveNode = opts.newLines || ((_a2 = opts.indentSpaces) != null ? _a2 : 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
  10420. if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
  10421. yield "\n";
  10422. output.currentLineWidth = 0;
  10423. }
  10424. if (((_b = opts.indentSpaces) != null ? _b : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
  10425. for (let i = 0; i < output.indent; i++) {
  10426. yield " ";
  10427. }
  10428. output.currentLineWidth += output.indent;
  10429. }
  10430. const tag = tagName === shadowRootTag ? "template" : tagName;
  10431. yield "<" + tag;
  10432. output.currentLineWidth += tag.length + 1;
  10433. if (tag === "template") {
  10434. const mode = ` shadowrootmode="open"`;
  10435. yield mode;
  10436. output.currentLineWidth += mode.length;
  10437. }
  10438. const attrsLength = node.attributes.length;
  10439. const attributes = opts.prettyHtml && attrsLength > 1 ? cloneAttributes(node.attributes, true) : node.attributes;
  10440. for (let i = 0; i < attrsLength; i++) {
  10441. const attr = attributes.item(i);
  10442. const attrName = attr.name;
  10443. if (attrName === "style") {
  10444. continue;
  10445. }
  10446. let attrValue = attr.value;
  10447. if (opts.removeEmptyAttributes && attrValue === "" && REMOVE_EMPTY_ATTR.has(attrName)) {
  10448. continue;
  10449. }
  10450. const attrNamespaceURI = attr.namespaceURI;
  10451. if (attrNamespaceURI == null) {
  10452. output.currentLineWidth += attrName.length + 1;
  10453. if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth > opts.approximateLineWidth) {
  10454. yield "\n" + attrName;
  10455. output.currentLineWidth = 0;
  10456. } else {
  10457. yield " " + attrName;
  10458. }
  10459. } else if (attrNamespaceURI === "http://www.w3.org/XML/1998/namespace") {
  10460. yield " xml:" + attrName;
  10461. output.currentLineWidth += attrName.length + 5;
  10462. } else if (attrNamespaceURI === "http://www.w3.org/2000/xmlns/") {
  10463. if (attrName !== "xmlns") {
  10464. yield " xmlns:" + attrName;
  10465. output.currentLineWidth += attrName.length + 7;
  10466. } else {
  10467. yield " " + attrName;
  10468. output.currentLineWidth += attrName.length + 1;
  10469. }
  10470. } else if (attrNamespaceURI === XLINK_NS) {
  10471. yield " xlink:" + attrName;
  10472. output.currentLineWidth += attrName.length + 7;
  10473. } else {
  10474. yield " " + attrNamespaceURI + ":" + attrName;
  10475. output.currentLineWidth += attrNamespaceURI.length + attrName.length + 2;
  10476. }
  10477. if (opts.prettyHtml && attrName === "class") {
  10478. attrValue = attr.value = attrValue.split(" ").filter((t) => t !== "").sort().join(" ").trim();
  10479. }
  10480. if (attrValue === "") {
  10481. if (opts.removeBooleanAttributeQuotes && BOOLEAN_ATTR.has(attrName)) {
  10482. continue;
  10483. }
  10484. if (opts.removeEmptyAttributes && attrName.startsWith("data-")) {
  10485. continue;
  10486. }
  10487. }
  10488. if (opts.removeAttributeQuotes && CAN_REMOVE_ATTR_QUOTES.test(attrValue)) {
  10489. yield "=" + escapeString(attrValue, true);
  10490. output.currentLineWidth += attrValue.length + 1;
  10491. } else {
  10492. yield '="' + escapeString(attrValue, true) + '"';
  10493. output.currentLineWidth += attrValue.length + 3;
  10494. }
  10495. }
  10496. if (node.hasAttribute("style")) {
  10497. const cssText = node.style.cssText;
  10498. if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth + cssText.length + 10 > opts.approximateLineWidth) {
  10499. yield `
  10500. style="${cssText}">`;
  10501. output.currentLineWidth = 0;
  10502. } else {
  10503. yield ` style="${cssText}">`;
  10504. output.currentLineWidth += cssText.length + 10;
  10505. }
  10506. } else {
  10507. yield ">";
  10508. output.currentLineWidth += 1;
  10509. }
  10510. }
  10511. if (EMPTY_ELEMENTS.has(tagName) === false) {
  10512. const shadowRoot = node.shadowRoot;
  10513. if (shadowRoot != null && opts.serializeShadowRoot) {
  10514. output.indent = output.indent + ((_c = opts.indentSpaces) != null ? _c : 0);
  10515. yield* streamToHtml(shadowRoot, opts, output);
  10516. output.indent = output.indent - ((_d = opts.indentSpaces) != null ? _d : 0);
  10517. if (opts.newLines && (node.childNodes.length === 0 || node.childNodes.length === 1 && node.childNodes[0].nodeType === 3 /* TEXT_NODE */ && ((_e = node.childNodes[0].nodeValue) == null ? void 0 : _e.trim()) === "")) {
  10518. yield "\n";
  10519. output.currentLineWidth = 0;
  10520. for (let i = 0; i < output.indent; i++) {
  10521. yield " ";
  10522. }
  10523. output.currentLineWidth += output.indent;
  10524. }
  10525. }
  10526. if (opts.excludeTagContent == null || opts.excludeTagContent.includes(tagName) === false) {
  10527. const tag = tagName === shadowRootTag ? "template" : tagName;
  10528. const childNodes = tagName === "template" ? node.content.childNodes : node.childNodes;
  10529. const childNodeLength = childNodes.length;
  10530. if (childNodeLength > 0) {
  10531. if (childNodeLength === 1 && childNodes[0].nodeType === 3 /* TEXT_NODE */ && (typeof childNodes[0].nodeValue !== "string" || childNodes[0].nodeValue.trim() === "")) {
  10532. } else {
  10533. const isWithinWhitespaceSensitiveNode = opts.newLines || ((_f = opts.indentSpaces) != null ? _f : 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
  10534. if (!isWithinWhitespaceSensitiveNode && ((_g = opts.indentSpaces) != null ? _g : 0) > 0 && ignoreTag === false) {
  10535. output.indent = output.indent + ((_h = opts.indentSpaces) != null ? _h : 0);
  10536. }
  10537. for (let i = 0; i < childNodeLength; i++) {
  10538. yield* streamToHtml(childNodes[i], opts, output);
  10539. }
  10540. if (ignoreTag === false) {
  10541. if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
  10542. yield "\n";
  10543. output.currentLineWidth = 0;
  10544. }
  10545. if (((_i = opts.indentSpaces) != null ? _i : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
  10546. output.indent = output.indent - ((_j = opts.indentSpaces) != null ? _j : 0);
  10547. for (let i = 0; i < output.indent; i++) {
  10548. yield " ";
  10549. }
  10550. output.currentLineWidth += output.indent;
  10551. }
  10552. }
  10553. }
  10554. }
  10555. if (ignoreTag === false) {
  10556. yield "</" + tag + ">";
  10557. output.currentLineWidth += tag.length + 3;
  10558. }
  10559. }
  10560. }
  10561. if (((_k = opts.approximateLineWidth) != null ? _k : 0) > 0 && STRUCTURE_ELEMENTS.has(tagName)) {
  10562. yield "\n";
  10563. output.currentLineWidth = 0;
  10564. }
  10565. if (tagName === "body") {
  10566. output.isWithinBody = false;
  10567. }
  10568. } else if (node.nodeType === 3 /* TEXT_NODE */) {
  10569. let textContent = node.nodeValue;
  10570. if (typeof textContent === "string") {
  10571. const trimmedTextContent = textContent.trim();
  10572. if (trimmedTextContent === "") {
  10573. if (isWithinWhitespaceSensitive(node)) {
  10574. yield textContent;
  10575. output.currentLineWidth += textContent.length;
  10576. } else if (((_l = opts.approximateLineWidth) != null ? _l : 0) > 0 && !output.isWithinBody) {
  10577. } else if (!opts.prettyHtml) {
  10578. output.currentLineWidth += 1;
  10579. if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth > opts.approximateLineWidth) {
  10580. yield "\n";
  10581. output.currentLineWidth = 0;
  10582. } else {
  10583. yield " ";
  10584. }
  10585. }
  10586. } else {
  10587. const isWithinWhitespaceSensitiveNode = opts.newLines || ((_m = opts.indentSpaces) != null ? _m : 0) > 0 || opts.prettyHtml ? isWithinWhitespaceSensitive(node) : false;
  10588. if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
  10589. yield "\n";
  10590. output.currentLineWidth = 0;
  10591. }
  10592. if (((_n = opts.indentSpaces) != null ? _n : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
  10593. for (let i = 0; i < output.indent; i++) {
  10594. yield " ";
  10595. }
  10596. output.currentLineWidth += output.indent;
  10597. }
  10598. let textContentLength = textContent.length;
  10599. if (textContentLength > 0) {
  10600. const parentTagName = node.parentNode != null && node.parentNode.nodeType === 1 /* ELEMENT_NODE */ ? node.parentNode.nodeName : null;
  10601. if (typeof parentTagName === "string" && NON_ESCAPABLE_CONTENT.has(parentTagName)) {
  10602. if (isWithinWhitespaceSensitive(node)) {
  10603. yield textContent;
  10604. } else {
  10605. yield trimmedTextContent;
  10606. textContentLength = trimmedTextContent.length;
  10607. }
  10608. output.currentLineWidth += textContentLength;
  10609. } else {
  10610. if (opts.prettyHtml && !isWithinWhitespaceSensitiveNode) {
  10611. yield escapeString(textContent.replace(/\s\s+/g, " ").trim(), false);
  10612. output.currentLineWidth += textContentLength;
  10613. } else {
  10614. if (isWithinWhitespaceSensitive(node)) {
  10615. output.currentLineWidth += textContentLength;
  10616. } else {
  10617. if (/\s/.test(textContent.charAt(0))) {
  10618. textContent = " " + textContent.trimLeft();
  10619. }
  10620. textContentLength = textContent.length;
  10621. if (textContentLength > 1) {
  10622. if (/\s/.test(textContent.charAt(textContentLength - 1))) {
  10623. if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth + textContentLength > opts.approximateLineWidth) {
  10624. textContent = textContent.trimRight() + "\n";
  10625. output.currentLineWidth = 0;
  10626. } else {
  10627. textContent = textContent.trimRight() + " ";
  10628. }
  10629. }
  10630. }
  10631. output.currentLineWidth += textContentLength;
  10632. }
  10633. yield escapeString(textContent, false);
  10634. }
  10635. }
  10636. }
  10637. }
  10638. }
  10639. } else if (node.nodeType === 8 /* COMMENT_NODE */) {
  10640. const nodeValue = node.nodeValue;
  10641. const isHydrateAnnotation = (nodeValue == null ? void 0 : nodeValue.startsWith(CONTENT_REF_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(ORG_LOCATION_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(SLOT_NODE_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(TEXT_NODE_ID + "."));
  10642. if (opts.removeHtmlComments && !isHydrateAnnotation) {
  10643. return;
  10644. }
  10645. const isWithinWhitespaceSensitiveNode = opts.newLines || ((_o = opts.indentSpaces) != null ? _o : 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
  10646. if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
  10647. yield "\n";
  10648. output.currentLineWidth = 0;
  10649. }
  10650. if (((_p = opts.indentSpaces) != null ? _p : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
  10651. for (let i = 0; i < output.indent; i++) {
  10652. yield " ";
  10653. }
  10654. output.currentLineWidth += output.indent;
  10655. }
  10656. yield "<!--" + nodeValue + "-->";
  10657. if (nodeValue) {
  10658. output.currentLineWidth += nodeValue.length + 7;
  10659. }
  10660. } else if (node.nodeType === 10 /* DOCUMENT_TYPE_NODE */) {
  10661. yield "<!doctype html>";
  10662. }
  10663. }
  10664. var AMP_REGEX = /&/g;
  10665. var NBSP_REGEX = /\u00a0/g;
  10666. var DOUBLE_QUOTE_REGEX = /"/g;
  10667. var LT_REGEX = /</g;
  10668. var GT_REGEX = />/g;
  10669. var CAN_REMOVE_ATTR_QUOTES = /^[^ \t\n\f\r"'`=<>\/\\-]+$/;
  10670. function getTagName(element) {
  10671. if (element.namespaceURI === "http://www.w3.org/1999/xhtml") {
  10672. return element.nodeName.toLowerCase();
  10673. } else {
  10674. return element.nodeName;
  10675. }
  10676. }
  10677. function escapeString(str, attrMode) {
  10678. str = str.replace(AMP_REGEX, "&amp;").replace(NBSP_REGEX, "&nbsp;");
  10679. if (attrMode) {
  10680. return str.replace(DOUBLE_QUOTE_REGEX, "&quot;");
  10681. }
  10682. return str.replace(LT_REGEX, "&lt;").replace(GT_REGEX, "&gt;");
  10683. }
  10684. function isWithinWhitespaceSensitive(node) {
  10685. let _node = node;
  10686. while (_node == null ? void 0 : _node.nodeName) {
  10687. if (WHITESPACE_SENSITIVE.has(_node.nodeName)) {
  10688. return true;
  10689. }
  10690. _node = _node.parentNode;
  10691. }
  10692. return false;
  10693. }
  10694. var NON_ESCAPABLE_CONTENT = /* @__PURE__ */ new Set([
  10695. "STYLE",
  10696. "SCRIPT",
  10697. "IFRAME",
  10698. "NOSCRIPT",
  10699. "XMP",
  10700. "NOEMBED",
  10701. "NOFRAMES",
  10702. "PLAINTEXT"
  10703. ]);
  10704. var WHITESPACE_SENSITIVE = /* @__PURE__ */ new Set([
  10705. "CODE",
  10706. "OUTPUT",
  10707. "PLAINTEXT",
  10708. "PRE",
  10709. "SCRIPT",
  10710. "TEMPLATE",
  10711. "TEXTAREA"
  10712. ]);
  10713. var EMPTY_ELEMENTS = /* @__PURE__ */ new Set([
  10714. "area",
  10715. "base",
  10716. "basefont",
  10717. "bgsound",
  10718. "br",
  10719. "col",
  10720. "embed",
  10721. "frame",
  10722. "hr",
  10723. "img",
  10724. "input",
  10725. "keygen",
  10726. "link",
  10727. "meta",
  10728. "param",
  10729. "source",
  10730. "trace",
  10731. "track",
  10732. "wbr"
  10733. ]);
  10734. var REMOVE_EMPTY_ATTR = /* @__PURE__ */ new Set(["class", "dir", "id", "lang", "name", "title"]);
  10735. var BOOLEAN_ATTR = /* @__PURE__ */ new Set([
  10736. "allowfullscreen",
  10737. "async",
  10738. "autofocus",
  10739. "autoplay",
  10740. "checked",
  10741. "compact",
  10742. "controls",
  10743. "declare",
  10744. "default",
  10745. "defaultchecked",
  10746. "defaultmuted",
  10747. "defaultselected",
  10748. "defer",
  10749. "disabled",
  10750. "enabled",
  10751. "formnovalidate",
  10752. "hidden",
  10753. "indeterminate",
  10754. "inert",
  10755. "ismap",
  10756. "itemscope",
  10757. "loop",
  10758. "multiple",
  10759. "muted",
  10760. "nohref",
  10761. "nomodule",
  10762. "noresize",
  10763. "noshade",
  10764. "novalidate",
  10765. "nowrap",
  10766. "open",
  10767. "pauseonexit",
  10768. "readonly",
  10769. "required",
  10770. "reversed",
  10771. "scoped",
  10772. "seamless",
  10773. "selected",
  10774. "sortable",
  10775. "truespeed",
  10776. "typemustmatch",
  10777. "visible"
  10778. ]);
  10779. var STRUCTURE_ELEMENTS = /* @__PURE__ */ new Set([
  10780. "html",
  10781. "body",
  10782. "head",
  10783. "iframe",
  10784. "meta",
  10785. "link",
  10786. "base",
  10787. "title",
  10788. "script",
  10789. "style"
  10790. ]);
  10791. // src/mock-doc/node.ts
  10792. var MockNode2 = class {
  10793. constructor(ownerDocument, nodeType, nodeName, nodeValue) {
  10794. this.ownerDocument = ownerDocument;
  10795. this.nodeType = nodeType;
  10796. this.nodeName = nodeName;
  10797. this._nodeValue = nodeValue;
  10798. this.parentNode = null;
  10799. this.childNodes = [];
  10800. }
  10801. appendChild(newNode) {
  10802. if (newNode.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */) {
  10803. const nodes = newNode.childNodes.slice();
  10804. for (const child of nodes) {
  10805. this.appendChild(child);
  10806. }
  10807. } else {
  10808. newNode.remove();
  10809. newNode.parentNode = this;
  10810. this.childNodes.push(newNode);
  10811. connectNode(this.ownerDocument, newNode);
  10812. }
  10813. return newNode;
  10814. }
  10815. append(...items) {
  10816. items.forEach((item) => {
  10817. const isNode = typeof item === "object" && item !== null && "nodeType" in item;
  10818. this.appendChild(isNode ? item : this.ownerDocument.createTextNode(String(item)));
  10819. });
  10820. }
  10821. prepend(...items) {
  10822. const firstChild = this.firstChild;
  10823. items.forEach((item) => {
  10824. const isNode = typeof item === "object" && item !== null && "nodeType" in item;
  10825. if (firstChild) {
  10826. this.insertBefore(isNode ? item : this.ownerDocument.createTextNode(String(item)), firstChild);
  10827. }
  10828. });
  10829. }
  10830. cloneNode(deep) {
  10831. throw new Error(`invalid node type to clone: ${this.nodeType}, deep: ${deep}`);
  10832. }
  10833. compareDocumentPosition(_other) {
  10834. return -1;
  10835. }
  10836. get firstChild() {
  10837. return this.childNodes[0] || null;
  10838. }
  10839. insertBefore(newNode, referenceNode) {
  10840. if (newNode.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */) {
  10841. for (let i = 0, ii = newNode.childNodes.length; i < ii; i++) {
  10842. insertBefore(this, newNode.childNodes[i], referenceNode);
  10843. }
  10844. } else {
  10845. insertBefore(this, newNode, referenceNode);
  10846. }
  10847. return newNode;
  10848. }
  10849. get isConnected() {
  10850. let node = this;
  10851. while (node != null) {
  10852. if (node.nodeType === 9 /* DOCUMENT_NODE */) {
  10853. return true;
  10854. }
  10855. node = node.parentNode;
  10856. if (node != null && node.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */) {
  10857. node = node.host;
  10858. }
  10859. }
  10860. return false;
  10861. }
  10862. isSameNode(node) {
  10863. return this === node;
  10864. }
  10865. get lastChild() {
  10866. return this.childNodes[this.childNodes.length - 1] || null;
  10867. }
  10868. get nextSibling() {
  10869. if (this.parentNode != null) {
  10870. const index = this.parentNode.childNodes.indexOf(this) + 1;
  10871. return this.parentNode.childNodes[index] || null;
  10872. }
  10873. return null;
  10874. }
  10875. get nodeValue() {
  10876. var _a2;
  10877. return (_a2 = this._nodeValue) != null ? _a2 : "";
  10878. }
  10879. set nodeValue(value) {
  10880. this._nodeValue = value;
  10881. }
  10882. get parentElement() {
  10883. return this.parentNode || null;
  10884. }
  10885. set parentElement(value) {
  10886. this.parentNode = value;
  10887. }
  10888. get previousSibling() {
  10889. if (this.parentNode != null) {
  10890. const index = this.parentNode.childNodes.indexOf(this) - 1;
  10891. return this.parentNode.childNodes[index] || null;
  10892. }
  10893. return null;
  10894. }
  10895. contains(otherNode) {
  10896. if (otherNode === this) {
  10897. return true;
  10898. }
  10899. const childNodes = Array.from(this.childNodes);
  10900. if (childNodes.includes(otherNode)) {
  10901. return true;
  10902. }
  10903. return childNodes.some((node) => this.contains.bind(node)(otherNode));
  10904. }
  10905. removeChild(childNode) {
  10906. const index = this.childNodes.indexOf(childNode);
  10907. if (index > -1) {
  10908. this.childNodes.splice(index, 1);
  10909. if (this.nodeType === 1 /* ELEMENT_NODE */) {
  10910. const wasConnected = this.isConnected;
  10911. childNode.parentNode = null;
  10912. if (wasConnected === true) {
  10913. disconnectNode(childNode);
  10914. }
  10915. } else {
  10916. childNode.parentNode = null;
  10917. }
  10918. } else {
  10919. throw new Error(`node not found within childNodes during removeChild`);
  10920. }
  10921. return childNode;
  10922. }
  10923. remove() {
  10924. if (this.parentNode != null) {
  10925. this.parentNode.removeChild(this);
  10926. }
  10927. }
  10928. replaceChild(newChild, oldChild) {
  10929. if (oldChild.parentNode === this) {
  10930. this.insertBefore(newChild, oldChild);
  10931. oldChild.remove();
  10932. return newChild;
  10933. }
  10934. return null;
  10935. }
  10936. get textContent() {
  10937. var _a2;
  10938. return (_a2 = this._nodeValue) != null ? _a2 : "";
  10939. }
  10940. set textContent(value) {
  10941. this._nodeValue = String(value);
  10942. }
  10943. };
  10944. MockNode2.ELEMENT_NODE = 1;
  10945. MockNode2.TEXT_NODE = 3;
  10946. MockNode2.PROCESSING_INSTRUCTION_NODE = 7;
  10947. MockNode2.COMMENT_NODE = 8;
  10948. MockNode2.DOCUMENT_NODE = 9;
  10949. MockNode2.DOCUMENT_TYPE_NODE = 10;
  10950. MockNode2.DOCUMENT_FRAGMENT_NODE = 11;
  10951. var MockNodeList = class {
  10952. constructor(ownerDocument, childNodes, length) {
  10953. this.ownerDocument = ownerDocument;
  10954. this.childNodes = childNodes;
  10955. this.length = length;
  10956. }
  10957. };
  10958. var MockElement = class extends MockNode2 {
  10959. attachInternals() {
  10960. return new Proxy({}, {
  10961. get: function(_target, prop, _receiver) {
  10962. console.error(
  10963. `NOTE: Property ${String(prop)} was accessed on ElementInternals, but this property is not implemented.
  10964. Testing components with ElementInternals is fully supported in e2e tests.`
  10965. );
  10966. }
  10967. });
  10968. }
  10969. constructor(ownerDocument, nodeName, namespaceURI = null) {
  10970. super(ownerDocument, 1 /* ELEMENT_NODE */, typeof nodeName === "string" ? nodeName : null, null);
  10971. this.__namespaceURI = namespaceURI;
  10972. this.__shadowRoot = null;
  10973. this.__attributeMap = null;
  10974. }
  10975. addEventListener(type, handler) {
  10976. addEventListener(this, type, handler);
  10977. }
  10978. attachShadow(_opts) {
  10979. const shadowRoot = this.ownerDocument.createDocumentFragment();
  10980. this.shadowRoot = shadowRoot;
  10981. return shadowRoot;
  10982. }
  10983. blur() {
  10984. dispatchEvent(
  10985. this,
  10986. new MockFocusEvent("blur", { relatedTarget: null, bubbles: true, cancelable: true, composed: true })
  10987. );
  10988. }
  10989. get localName() {
  10990. if (!this.nodeName) {
  10991. throw new Error(`Can't compute elements localName without nodeName`);
  10992. }
  10993. return this.nodeName.toLocaleLowerCase();
  10994. }
  10995. get namespaceURI() {
  10996. return this.__namespaceURI;
  10997. }
  10998. get shadowRoot() {
  10999. return this.__shadowRoot || null;
  11000. }
  11001. /**
  11002. * Set shadow root for element
  11003. * @param shadowRoot - ShadowRoot to set
  11004. */
  11005. set shadowRoot(shadowRoot) {
  11006. if (shadowRoot != null) {
  11007. shadowRoot.host = this;
  11008. this.__shadowRoot = shadowRoot;
  11009. } else {
  11010. delete this.__shadowRoot;
  11011. }
  11012. }
  11013. get attributes() {
  11014. if (this.__attributeMap == null) {
  11015. const attrMap = createAttributeProxy(false);
  11016. this.__attributeMap = attrMap;
  11017. return attrMap;
  11018. }
  11019. return this.__attributeMap;
  11020. }
  11021. set attributes(attrs) {
  11022. this.__attributeMap = attrs;
  11023. }
  11024. get children() {
  11025. return this.childNodes.filter((n) => n.nodeType === 1 /* ELEMENT_NODE */);
  11026. }
  11027. get childElementCount() {
  11028. return this.childNodes.filter((n) => n.nodeType === 1 /* ELEMENT_NODE */).length;
  11029. }
  11030. get className() {
  11031. return this.getAttributeNS(null, "class") || "";
  11032. }
  11033. set className(value) {
  11034. this.setAttributeNS(null, "class", value);
  11035. }
  11036. get classList() {
  11037. return new MockClassList(this);
  11038. }
  11039. click() {
  11040. dispatchEvent(this, new MockEvent("click", { bubbles: true, cancelable: true, composed: true }));
  11041. }
  11042. cloneNode(_deep) {
  11043. return null;
  11044. }
  11045. closest(selector) {
  11046. let elm = this;
  11047. while (elm != null) {
  11048. if (elm.matches(selector)) {
  11049. return elm;
  11050. }
  11051. elm = elm.parentNode;
  11052. }
  11053. return null;
  11054. }
  11055. get dataset() {
  11056. return dataset(this);
  11057. }
  11058. get dir() {
  11059. return this.getAttributeNS(null, "dir") || "";
  11060. }
  11061. set dir(value) {
  11062. this.setAttributeNS(null, "dir", value);
  11063. }
  11064. dispatchEvent(ev) {
  11065. return dispatchEvent(this, ev);
  11066. }
  11067. get firstElementChild() {
  11068. return this.children[0] || null;
  11069. }
  11070. focus(_options) {
  11071. dispatchEvent(
  11072. this,
  11073. new MockFocusEvent("focus", { relatedTarget: null, bubbles: true, cancelable: true, composed: true })
  11074. );
  11075. }
  11076. getAttribute(attrName) {
  11077. if (attrName === "style") {
  11078. if (this.__style != null && this.__style.length > 0) {
  11079. return this.style.cssText;
  11080. }
  11081. return null;
  11082. }
  11083. const attr = this.attributes.getNamedItem(attrName);
  11084. if (attr != null) {
  11085. return attr.value;
  11086. }
  11087. return null;
  11088. }
  11089. getAttributeNS(namespaceURI, attrName) {
  11090. const attr = this.attributes.getNamedItemNS(namespaceURI, attrName);
  11091. if (attr != null) {
  11092. return attr.value;
  11093. }
  11094. return null;
  11095. }
  11096. getAttributeNode(attrName) {
  11097. if (!this.hasAttribute(attrName)) {
  11098. return null;
  11099. }
  11100. return new MockAttr(attrName, this.getAttribute(attrName));
  11101. }
  11102. getBoundingClientRect() {
  11103. return { bottom: 0, height: 0, left: 0, right: 0, top: 0, width: 0, x: 0, y: 0 };
  11104. }
  11105. getRootNode(opts) {
  11106. const isComposed = opts != null && opts.composed === true;
  11107. let node = this;
  11108. while (node.parentNode != null) {
  11109. node = node.parentNode;
  11110. if (isComposed === true && node.parentNode == null && node.host != null) {
  11111. node = node.host;
  11112. }
  11113. }
  11114. return node;
  11115. }
  11116. get draggable() {
  11117. return this.getAttributeNS(null, "draggable") === "true";
  11118. }
  11119. set draggable(value) {
  11120. this.setAttributeNS(null, "draggable", value);
  11121. }
  11122. hasChildNodes() {
  11123. return this.childNodes.length > 0;
  11124. }
  11125. get id() {
  11126. return this.getAttributeNS(null, "id") || "";
  11127. }
  11128. set id(value) {
  11129. this.setAttributeNS(null, "id", value);
  11130. }
  11131. get innerHTML() {
  11132. if (this.childNodes.length === 0) {
  11133. return "";
  11134. }
  11135. return serializeNodeToHtml(this, {
  11136. newLines: false,
  11137. indentSpaces: 0
  11138. });
  11139. }
  11140. set innerHTML(html) {
  11141. var _a2;
  11142. if (NON_ESCAPABLE_CONTENT.has((_a2 = this.nodeName) != null ? _a2 : "") === true) {
  11143. setTextContent(this, html);
  11144. } else {
  11145. for (let i = this.childNodes.length - 1; i >= 0; i--) {
  11146. this.removeChild(this.childNodes[i]);
  11147. }
  11148. if (typeof html === "string") {
  11149. const frag = parseFragmentUtil(this.ownerDocument, html);
  11150. while (frag.childNodes.length > 0) {
  11151. this.appendChild(frag.childNodes[0]);
  11152. }
  11153. }
  11154. }
  11155. }
  11156. get innerText() {
  11157. const text = [];
  11158. getTextContent(this.childNodes, text);
  11159. return text.join("");
  11160. }
  11161. set innerText(value) {
  11162. setTextContent(this, value);
  11163. }
  11164. insertAdjacentElement(position, elm) {
  11165. if (position === "beforebegin" && this.parentNode) {
  11166. insertBefore(this.parentNode, elm, this);
  11167. } else if (position === "afterbegin") {
  11168. this.prepend(elm);
  11169. } else if (position === "beforeend") {
  11170. this.appendChild(elm);
  11171. } else if (position === "afterend" && this.parentNode) {
  11172. insertBefore(this.parentNode, elm, this.nextSibling);
  11173. }
  11174. return elm;
  11175. }
  11176. insertAdjacentHTML(position, html) {
  11177. const frag = parseFragmentUtil(this.ownerDocument, html);
  11178. if (position === "beforebegin") {
  11179. while (frag.childNodes.length > 0) {
  11180. if (this.parentNode) {
  11181. insertBefore(this.parentNode, frag.childNodes[0], this);
  11182. }
  11183. }
  11184. } else if (position === "afterbegin") {
  11185. while (frag.childNodes.length > 0) {
  11186. this.prepend(frag.childNodes[frag.childNodes.length - 1]);
  11187. }
  11188. } else if (position === "beforeend") {
  11189. while (frag.childNodes.length > 0) {
  11190. this.appendChild(frag.childNodes[0]);
  11191. }
  11192. } else if (position === "afterend") {
  11193. while (frag.childNodes.length > 0) {
  11194. if (this.parentNode) {
  11195. insertBefore(this.parentNode, frag.childNodes[frag.childNodes.length - 1], this.nextSibling);
  11196. }
  11197. }
  11198. }
  11199. }
  11200. insertAdjacentText(position, text) {
  11201. const elm = this.ownerDocument.createTextNode(text);
  11202. if (position === "beforebegin" && this.parentNode) {
  11203. insertBefore(this.parentNode, elm, this);
  11204. } else if (position === "afterbegin") {
  11205. this.prepend(elm);
  11206. } else if (position === "beforeend") {
  11207. this.appendChild(elm);
  11208. } else if (position === "afterend" && this.parentNode) {
  11209. insertBefore(this.parentNode, elm, this.nextSibling);
  11210. }
  11211. }
  11212. hasAttribute(attrName) {
  11213. if (attrName === "style") {
  11214. return this.__style != null && this.__style.length > 0;
  11215. }
  11216. return this.getAttribute(attrName) !== null;
  11217. }
  11218. hasAttributeNS(namespaceURI, name) {
  11219. return this.getAttributeNS(namespaceURI, name) !== null;
  11220. }
  11221. get hidden() {
  11222. return this.hasAttributeNS(null, "hidden");
  11223. }
  11224. set hidden(isHidden) {
  11225. if (isHidden === true) {
  11226. this.setAttributeNS(null, "hidden", "");
  11227. } else {
  11228. this.removeAttributeNS(null, "hidden");
  11229. }
  11230. }
  11231. get lang() {
  11232. return this.getAttributeNS(null, "lang") || "";
  11233. }
  11234. set lang(value) {
  11235. this.setAttributeNS(null, "lang", value);
  11236. }
  11237. get lastElementChild() {
  11238. const children = this.children;
  11239. return children[children.length - 1] || null;
  11240. }
  11241. matches(selector) {
  11242. return matches(selector, this);
  11243. }
  11244. get nextElementSibling() {
  11245. const parentElement = this.parentElement;
  11246. if (parentElement != null && (parentElement.nodeType === 1 /* ELEMENT_NODE */ || parentElement.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */ || parentElement.nodeType === 9 /* DOCUMENT_NODE */)) {
  11247. const children = parentElement.children;
  11248. const index = children.indexOf(this) + 1;
  11249. return parentElement.children[index] || null;
  11250. }
  11251. return null;
  11252. }
  11253. get outerHTML() {
  11254. return serializeNodeToHtml(this, {
  11255. newLines: false,
  11256. outerHtml: true,
  11257. indentSpaces: 0
  11258. });
  11259. }
  11260. get previousElementSibling() {
  11261. const parentElement = this.parentElement;
  11262. if (parentElement != null && (parentElement.nodeType === 1 /* ELEMENT_NODE */ || parentElement.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */ || parentElement.nodeType === 9 /* DOCUMENT_NODE */)) {
  11263. const children = parentElement.children;
  11264. const index = children.indexOf(this) - 1;
  11265. return parentElement.children[index] || null;
  11266. }
  11267. return null;
  11268. }
  11269. getElementsByClassName(classNames) {
  11270. const classes = classNames.trim().split(" ").filter((c) => c.length > 0);
  11271. const results = [];
  11272. getElementsByClassName(this, classes, results);
  11273. return results;
  11274. }
  11275. getElementsByTagName(tagName) {
  11276. const results = [];
  11277. getElementsByTagName(this, tagName.toLowerCase(), results);
  11278. return results;
  11279. }
  11280. querySelector(selector) {
  11281. return selectOne(selector, this);
  11282. }
  11283. querySelectorAll(selector) {
  11284. return selectAll(selector, this);
  11285. }
  11286. removeAttribute(attrName) {
  11287. if (attrName === "style") {
  11288. delete this.__style;
  11289. } else {
  11290. const attr = this.attributes.getNamedItem(attrName);
  11291. if (attr != null) {
  11292. this.attributes.removeNamedItemNS(attr);
  11293. if (checkAttributeChanged(this) === true) {
  11294. attributeChanged(this, attrName, attr.value, null);
  11295. }
  11296. }
  11297. }
  11298. }
  11299. removeAttributeNS(namespaceURI, attrName) {
  11300. const attr = this.attributes.getNamedItemNS(namespaceURI, attrName);
  11301. if (attr != null) {
  11302. this.attributes.removeNamedItemNS(attr);
  11303. if (checkAttributeChanged(this) === true) {
  11304. attributeChanged(this, attrName, attr.value, null);
  11305. }
  11306. }
  11307. }
  11308. removeEventListener(type, handler) {
  11309. removeEventListener(this, type, handler);
  11310. }
  11311. setAttribute(attrName, value) {
  11312. if (attrName === "style") {
  11313. this.style = value;
  11314. } else {
  11315. const attributes = this.attributes;
  11316. let attr = attributes.getNamedItem(attrName);
  11317. const checkAttrChanged = checkAttributeChanged(this);
  11318. if (attr != null) {
  11319. if (checkAttrChanged === true) {
  11320. const oldValue = attr.value;
  11321. attr.value = value;
  11322. if (oldValue !== attr.value) {
  11323. attributeChanged(this, attr.name, oldValue, attr.value);
  11324. }
  11325. } else {
  11326. attr.value = value;
  11327. }
  11328. } else {
  11329. if (attributes.caseInsensitive) {
  11330. attrName = attrName.toLowerCase();
  11331. }
  11332. attr = new MockAttr(attrName, value);
  11333. attributes.__items.push(attr);
  11334. if (checkAttrChanged === true) {
  11335. attributeChanged(this, attrName, null, attr.value);
  11336. }
  11337. }
  11338. }
  11339. }
  11340. setAttributeNS(namespaceURI, attrName, value) {
  11341. const attributes = this.attributes;
  11342. let attr = attributes.getNamedItemNS(namespaceURI, attrName);
  11343. const checkAttrChanged = checkAttributeChanged(this);
  11344. if (attr != null) {
  11345. if (checkAttrChanged === true) {
  11346. const oldValue = attr.value;
  11347. attr.value = value;
  11348. if (oldValue !== attr.value) {
  11349. attributeChanged(this, attr.name, oldValue, attr.value);
  11350. }
  11351. } else {
  11352. attr.value = value;
  11353. }
  11354. } else {
  11355. attr = new MockAttr(attrName, value, namespaceURI);
  11356. attributes.__items.push(attr);
  11357. if (checkAttrChanged === true) {
  11358. attributeChanged(this, attrName, null, attr.value);
  11359. }
  11360. }
  11361. }
  11362. get style() {
  11363. if (this.__style == null) {
  11364. this.__style = createCSSStyleDeclaration();
  11365. }
  11366. return this.__style;
  11367. }
  11368. set style(val) {
  11369. if (typeof val === "string") {
  11370. if (this.__style == null) {
  11371. this.__style = createCSSStyleDeclaration();
  11372. }
  11373. this.__style.cssText = val;
  11374. } else {
  11375. this.__style = val;
  11376. }
  11377. }
  11378. get tabIndex() {
  11379. return parseInt(this.getAttributeNS(null, "tabindex") || "-1", 10);
  11380. }
  11381. set tabIndex(value) {
  11382. this.setAttributeNS(null, "tabindex", value);
  11383. }
  11384. get tagName() {
  11385. var _a2;
  11386. return (_a2 = this.nodeName) != null ? _a2 : "";
  11387. }
  11388. set tagName(value) {
  11389. this.nodeName = value;
  11390. }
  11391. get textContent() {
  11392. const text = [];
  11393. getTextContent(this.childNodes, text);
  11394. return text.join("");
  11395. }
  11396. set textContent(value) {
  11397. setTextContent(this, value);
  11398. }
  11399. get title() {
  11400. return this.getAttributeNS(null, "title") || "";
  11401. }
  11402. set title(value) {
  11403. this.setAttributeNS(null, "title", value);
  11404. }
  11405. animate() {
  11406. }
  11407. onanimationstart() {
  11408. }
  11409. onanimationend() {
  11410. }
  11411. onanimationiteration() {
  11412. }
  11413. onabort() {
  11414. }
  11415. onauxclick() {
  11416. }
  11417. onbeforecopy() {
  11418. }
  11419. onbeforecut() {
  11420. }
  11421. onbeforepaste() {
  11422. }
  11423. onblur() {
  11424. }
  11425. oncancel() {
  11426. }
  11427. oncanplay() {
  11428. }
  11429. oncanplaythrough() {
  11430. }
  11431. onchange() {
  11432. }
  11433. onclick() {
  11434. }
  11435. onclose() {
  11436. }
  11437. oncontextmenu() {
  11438. }
  11439. oncopy() {
  11440. }
  11441. oncuechange() {
  11442. }
  11443. oncut() {
  11444. }
  11445. ondblclick() {
  11446. }
  11447. ondrag() {
  11448. }
  11449. ondragend() {
  11450. }
  11451. ondragenter() {
  11452. }
  11453. ondragleave() {
  11454. }
  11455. ondragover() {
  11456. }
  11457. ondragstart() {
  11458. }
  11459. ondrop() {
  11460. }
  11461. ondurationchange() {
  11462. }
  11463. onemptied() {
  11464. }
  11465. onended() {
  11466. }
  11467. onerror() {
  11468. }
  11469. onfocus() {
  11470. }
  11471. onfocusin() {
  11472. }
  11473. onfocusout() {
  11474. }
  11475. onformdata() {
  11476. }
  11477. onfullscreenchange() {
  11478. }
  11479. onfullscreenerror() {
  11480. }
  11481. ongotpointercapture() {
  11482. }
  11483. oninput() {
  11484. }
  11485. oninvalid() {
  11486. }
  11487. onkeydown() {
  11488. }
  11489. onkeypress() {
  11490. }
  11491. onkeyup() {
  11492. }
  11493. onload() {
  11494. }
  11495. onloadeddata() {
  11496. }
  11497. onloadedmetadata() {
  11498. }
  11499. onloadstart() {
  11500. }
  11501. onlostpointercapture() {
  11502. }
  11503. onmousedown() {
  11504. }
  11505. onmouseenter() {
  11506. }
  11507. onmouseleave() {
  11508. }
  11509. onmousemove() {
  11510. }
  11511. onmouseout() {
  11512. }
  11513. onmouseover() {
  11514. }
  11515. onmouseup() {
  11516. }
  11517. onmousewheel() {
  11518. }
  11519. onpaste() {
  11520. }
  11521. onpause() {
  11522. }
  11523. onplay() {
  11524. }
  11525. onplaying() {
  11526. }
  11527. onpointercancel() {
  11528. }
  11529. onpointerdown() {
  11530. }
  11531. onpointerenter() {
  11532. }
  11533. onpointerleave() {
  11534. }
  11535. onpointermove() {
  11536. }
  11537. onpointerout() {
  11538. }
  11539. onpointerover() {
  11540. }
  11541. onpointerup() {
  11542. }
  11543. onprogress() {
  11544. }
  11545. onratechange() {
  11546. }
  11547. onreset() {
  11548. }
  11549. onresize() {
  11550. }
  11551. onscroll() {
  11552. }
  11553. onsearch() {
  11554. }
  11555. onseeked() {
  11556. }
  11557. onseeking() {
  11558. }
  11559. onselect() {
  11560. }
  11561. onselectstart() {
  11562. }
  11563. onstalled() {
  11564. }
  11565. onsubmit() {
  11566. }
  11567. onsuspend() {
  11568. }
  11569. ontimeupdate() {
  11570. }
  11571. ontoggle() {
  11572. }
  11573. onvolumechange() {
  11574. }
  11575. onwaiting() {
  11576. }
  11577. onwebkitfullscreenchange() {
  11578. }
  11579. onwebkitfullscreenerror() {
  11580. }
  11581. onwheel() {
  11582. }
  11583. requestFullscreen() {
  11584. }
  11585. scrollBy() {
  11586. }
  11587. scrollTo() {
  11588. }
  11589. scrollIntoView() {
  11590. }
  11591. toString(opts) {
  11592. return serializeNodeToHtml(this, opts);
  11593. }
  11594. };
  11595. function getElementsByClassName(elm, classNames, foundElms) {
  11596. const children = elm.children;
  11597. for (let i = 0, ii = children.length; i < ii; i++) {
  11598. const childElm = children[i];
  11599. for (let j = 0, jj = classNames.length; j < jj; j++) {
  11600. if (childElm.classList.contains(classNames[j])) {
  11601. foundElms.push(childElm);
  11602. }
  11603. }
  11604. getElementsByClassName(childElm, classNames, foundElms);
  11605. }
  11606. }
  11607. function getElementsByTagName(elm, tagName, foundElms) {
  11608. var _a2;
  11609. const children = elm.children;
  11610. for (let i = 0, ii = children.length; i < ii; i++) {
  11611. const childElm = children[i];
  11612. if (tagName === "*" || ((_a2 = childElm.nodeName) != null ? _a2 : "").toLowerCase() === tagName) {
  11613. foundElms.push(childElm);
  11614. }
  11615. getElementsByTagName(childElm, tagName, foundElms);
  11616. }
  11617. }
  11618. function resetElement(elm) {
  11619. resetEventListeners(elm);
  11620. delete elm.__attributeMap;
  11621. delete elm.__shadowRoot;
  11622. delete elm.__style;
  11623. }
  11624. function insertBefore(parentNode, newNode, referenceNode) {
  11625. if (newNode !== referenceNode) {
  11626. newNode.remove();
  11627. newNode.parentNode = parentNode;
  11628. newNode.ownerDocument = parentNode.ownerDocument;
  11629. if (referenceNode != null) {
  11630. const index = parentNode.childNodes.indexOf(referenceNode);
  11631. if (index > -1) {
  11632. parentNode.childNodes.splice(index, 0, newNode);
  11633. } else {
  11634. throw new Error(`referenceNode not found in parentNode.childNodes`);
  11635. }
  11636. } else {
  11637. parentNode.childNodes.push(newNode);
  11638. }
  11639. connectNode(parentNode.ownerDocument, newNode);
  11640. }
  11641. return newNode;
  11642. }
  11643. var MockHTMLElement = class extends MockElement {
  11644. constructor(ownerDocument, nodeName) {
  11645. super(ownerDocument, typeof nodeName === "string" ? nodeName.toUpperCase() : null);
  11646. this.__namespaceURI = "http://www.w3.org/1999/xhtml";
  11647. }
  11648. get tagName() {
  11649. var _a2;
  11650. return (_a2 = this.nodeName) != null ? _a2 : "";
  11651. }
  11652. set tagName(value) {
  11653. this.nodeName = value;
  11654. }
  11655. /**
  11656. * A node’s parent of type Element is known as its parent element.
  11657. * If the node has a parent of a different type, its parent element
  11658. * is null.
  11659. * @returns MockElement
  11660. */
  11661. get parentElement() {
  11662. if (this.nodeName === "HTML") {
  11663. return null;
  11664. }
  11665. return super.parentElement;
  11666. }
  11667. get attributes() {
  11668. if (this.__attributeMap == null) {
  11669. const attrMap = createAttributeProxy(true);
  11670. this.__attributeMap = attrMap;
  11671. return attrMap;
  11672. }
  11673. return this.__attributeMap;
  11674. }
  11675. set attributes(attrs) {
  11676. this.__attributeMap = attrs;
  11677. }
  11678. };
  11679. var MockTextNode = class _MockTextNode extends MockNode2 {
  11680. constructor(ownerDocument, text) {
  11681. super(ownerDocument, 3 /* TEXT_NODE */, "#text" /* TEXT_NODE */, text);
  11682. }
  11683. cloneNode(_deep) {
  11684. return new _MockTextNode(null, this.nodeValue);
  11685. }
  11686. get textContent() {
  11687. return this.nodeValue;
  11688. }
  11689. set textContent(text) {
  11690. this.nodeValue = text;
  11691. }
  11692. get data() {
  11693. return this.nodeValue;
  11694. }
  11695. set data(text) {
  11696. this.nodeValue = text;
  11697. }
  11698. get wholeText() {
  11699. if (this.parentNode != null) {
  11700. const text = [];
  11701. for (let i = 0, ii = this.parentNode.childNodes.length; i < ii; i++) {
  11702. const childNode = this.parentNode.childNodes[i];
  11703. if (childNode.nodeType === 3 /* TEXT_NODE */) {
  11704. text.push(childNode.nodeValue);
  11705. }
  11706. }
  11707. return text.join("");
  11708. }
  11709. return this.nodeValue;
  11710. }
  11711. };
  11712. function getTextContent(childNodes, text) {
  11713. for (let i = 0, ii = childNodes.length; i < ii; i++) {
  11714. const childNode = childNodes[i];
  11715. if (childNode.nodeType === 3 /* TEXT_NODE */) {
  11716. text.push(childNode.nodeValue);
  11717. } else if (childNode.nodeType === 1 /* ELEMENT_NODE */) {
  11718. getTextContent(childNode.childNodes, text);
  11719. }
  11720. }
  11721. }
  11722. function setTextContent(elm, text) {
  11723. for (let i = elm.childNodes.length - 1; i >= 0; i--) {
  11724. elm.removeChild(elm.childNodes[i]);
  11725. }
  11726. const textNode = new MockTextNode(elm.ownerDocument, text);
  11727. elm.appendChild(textNode);
  11728. }
  11729. // src/mock-doc/comment-node.ts
  11730. var MockComment = class _MockComment extends MockNode2 {
  11731. constructor(ownerDocument, data) {
  11732. super(ownerDocument, 8 /* COMMENT_NODE */, "#comment" /* COMMENT_NODE */, data);
  11733. }
  11734. cloneNode(_deep) {
  11735. return new _MockComment(null, this.nodeValue);
  11736. }
  11737. get textContent() {
  11738. return this.nodeValue;
  11739. }
  11740. set textContent(text) {
  11741. this.nodeValue = text;
  11742. }
  11743. };
  11744. // src/mock-doc/document-fragment.ts
  11745. var MockDocumentFragment = class _MockDocumentFragment extends MockHTMLElement {
  11746. constructor(ownerDocument) {
  11747. super(ownerDocument, null);
  11748. this.nodeName = "#document-fragment" /* DOCUMENT_FRAGMENT_NODE */;
  11749. this.nodeType = 11 /* DOCUMENT_FRAGMENT_NODE */;
  11750. }
  11751. getElementById(id) {
  11752. return getElementById(this, id);
  11753. }
  11754. cloneNode(deep) {
  11755. const cloned = new _MockDocumentFragment(null);
  11756. if (deep) {
  11757. for (let i = 0, ii = this.childNodes.length; i < ii; i++) {
  11758. const childNode = this.childNodes[i];
  11759. if (childNode.nodeType === 1 /* ELEMENT_NODE */ || childNode.nodeType === 3 /* TEXT_NODE */ || childNode.nodeType === 8 /* COMMENT_NODE */) {
  11760. const clonedChildNode = this.childNodes[i].cloneNode(true);
  11761. cloned.appendChild(clonedChildNode);
  11762. }
  11763. }
  11764. }
  11765. return cloned;
  11766. }
  11767. };
  11768. // src/mock-doc/document-type-node.ts
  11769. var MockDocumentTypeNode = class extends MockHTMLElement {
  11770. constructor(ownerDocument) {
  11771. super(ownerDocument, "!DOCTYPE");
  11772. this.nodeType = 10 /* DOCUMENT_TYPE_NODE */;
  11773. this.setAttribute("html", "");
  11774. }
  11775. };
  11776. // src/mock-doc/css-style-sheet.ts
  11777. var MockCSSRule = class {
  11778. constructor(parentStyleSheet) {
  11779. this.parentStyleSheet = parentStyleSheet;
  11780. this.cssText = "";
  11781. this.type = 0;
  11782. }
  11783. };
  11784. var MockCSSStyleSheet = class {
  11785. constructor(ownerNode) {
  11786. this.type = "text/css";
  11787. this.parentStyleSheet = null;
  11788. this.cssRules = [];
  11789. this.ownerNode = ownerNode;
  11790. }
  11791. get rules() {
  11792. return this.cssRules;
  11793. }
  11794. set rules(rules) {
  11795. this.cssRules = rules;
  11796. }
  11797. deleteRule(index) {
  11798. if (index >= 0 && index < this.cssRules.length) {
  11799. this.cssRules.splice(index, 1);
  11800. updateStyleTextNode(this.ownerNode);
  11801. }
  11802. }
  11803. insertRule(rule, index = 0) {
  11804. if (typeof index !== "number") {
  11805. index = 0;
  11806. }
  11807. if (index < 0) {
  11808. index = 0;
  11809. }
  11810. if (index > this.cssRules.length) {
  11811. index = this.cssRules.length;
  11812. }
  11813. const cssRule = new MockCSSRule(this);
  11814. cssRule.cssText = rule;
  11815. this.cssRules.splice(index, 0, cssRule);
  11816. updateStyleTextNode(this.ownerNode);
  11817. return index;
  11818. }
  11819. };
  11820. function getStyleElementText(styleElm) {
  11821. const output = [];
  11822. for (let i = 0; i < styleElm.childNodes.length; i++) {
  11823. output.push(styleElm.childNodes[i].nodeValue);
  11824. }
  11825. return output.join("");
  11826. }
  11827. function setStyleElementText(styleElm, text) {
  11828. const sheet = styleElm.sheet;
  11829. sheet.cssRules.length = 0;
  11830. sheet.insertRule(text);
  11831. updateStyleTextNode(styleElm);
  11832. }
  11833. function updateStyleTextNode(styleElm) {
  11834. const childNodeLen = styleElm.childNodes.length;
  11835. if (childNodeLen > 1) {
  11836. for (let i = childNodeLen - 1; i >= 1; i--) {
  11837. styleElm.removeChild(styleElm.childNodes[i]);
  11838. }
  11839. } else if (childNodeLen < 1) {
  11840. styleElm.appendChild(styleElm.ownerDocument.createTextNode(""));
  11841. }
  11842. const textNode = styleElm.childNodes[0];
  11843. textNode.nodeValue = styleElm.sheet.cssRules.map((r) => r.cssText).join("\n");
  11844. }
  11845. // src/mock-doc/element.ts
  11846. function createElement(ownerDocument, tagName) {
  11847. if (typeof tagName !== "string" || tagName === "" || !/^[a-z0-9-_:]+$/i.test(tagName)) {
  11848. throw new Error(`The tag name provided (${tagName}) is not a valid name.`);
  11849. }
  11850. tagName = tagName.toLowerCase();
  11851. switch (tagName) {
  11852. case "a":
  11853. return new MockAnchorElement(ownerDocument);
  11854. case "base":
  11855. return new MockBaseElement(ownerDocument);
  11856. case "button":
  11857. return new MockButtonElement(ownerDocument);
  11858. case "canvas":
  11859. return new MockCanvasElement(ownerDocument);
  11860. case "form":
  11861. return new MockFormElement(ownerDocument);
  11862. case "img":
  11863. return new MockImageElement(ownerDocument);
  11864. case "input":
  11865. return new MockInputElement(ownerDocument);
  11866. case "link":
  11867. return new MockLinkElement(ownerDocument);
  11868. case "meta":
  11869. return new MockMetaElement(ownerDocument);
  11870. case "script":
  11871. return new MockScriptElement(ownerDocument);
  11872. case "style":
  11873. return new MockStyleElement(ownerDocument);
  11874. case "template":
  11875. return new MockTemplateElement(ownerDocument);
  11876. case "title":
  11877. return new MockTitleElement(ownerDocument);
  11878. case "ul":
  11879. return new MockUListElement(ownerDocument);
  11880. }
  11881. if (ownerDocument != null && tagName.includes("-")) {
  11882. const win = ownerDocument.defaultView;
  11883. if (win != null && win.customElements != null) {
  11884. return createCustomElement(win.customElements, ownerDocument, tagName);
  11885. }
  11886. }
  11887. return new MockHTMLElement(ownerDocument, tagName);
  11888. }
  11889. function createElementNS(ownerDocument, namespaceURI, tagName) {
  11890. if (namespaceURI === "http://www.w3.org/1999/xhtml") {
  11891. return createElement(ownerDocument, tagName);
  11892. } else if (namespaceURI === "http://www.w3.org/2000/svg") {
  11893. switch (tagName.toLowerCase()) {
  11894. case "text":
  11895. case "tspan":
  11896. case "tref":
  11897. case "altglyph":
  11898. case "textpath":
  11899. return new MockSVGTextContentElement(ownerDocument, tagName);
  11900. case "circle":
  11901. case "ellipse":
  11902. case "image":
  11903. case "line":
  11904. case "path":
  11905. case "polygon":
  11906. case "polyline":
  11907. case "rect":
  11908. case "use":
  11909. return new MockSVGGraphicsElement(ownerDocument, tagName);
  11910. case "svg":
  11911. return new MockSVGSVGElement(ownerDocument, tagName);
  11912. default:
  11913. return new MockSVGElement(ownerDocument, tagName);
  11914. }
  11915. } else {
  11916. return new MockElement(ownerDocument, tagName, namespaceURI);
  11917. }
  11918. }
  11919. var MockAnchorElement = class extends MockHTMLElement {
  11920. constructor(ownerDocument) {
  11921. super(ownerDocument, "a");
  11922. }
  11923. get href() {
  11924. return fullUrl(this, "href");
  11925. }
  11926. set href(value) {
  11927. this.setAttribute("href", value);
  11928. }
  11929. get pathname() {
  11930. return new URL(this.href).pathname;
  11931. }
  11932. };
  11933. var MockButtonElement = class extends MockHTMLElement {
  11934. constructor(ownerDocument) {
  11935. super(ownerDocument, "button");
  11936. }
  11937. };
  11938. patchPropAttributes(
  11939. MockButtonElement.prototype,
  11940. {
  11941. type: String
  11942. },
  11943. {
  11944. type: "submit"
  11945. }
  11946. );
  11947. var MockImageElement = class extends MockHTMLElement {
  11948. constructor(ownerDocument) {
  11949. super(ownerDocument, "img");
  11950. }
  11951. get draggable() {
  11952. return this.getAttributeNS(null, "draggable") !== "false";
  11953. }
  11954. set draggable(value) {
  11955. this.setAttributeNS(null, "draggable", value);
  11956. }
  11957. get src() {
  11958. return fullUrl(this, "src");
  11959. }
  11960. set src(value) {
  11961. this.setAttribute("src", value);
  11962. }
  11963. };
  11964. patchPropAttributes(MockImageElement.prototype, {
  11965. height: Number,
  11966. width: Number
  11967. });
  11968. var MockInputElement = class extends MockHTMLElement {
  11969. constructor(ownerDocument) {
  11970. super(ownerDocument, "input");
  11971. }
  11972. get list() {
  11973. const listId = this.getAttribute("list");
  11974. if (listId) {
  11975. return this.ownerDocument.getElementById(listId);
  11976. }
  11977. return null;
  11978. }
  11979. };
  11980. patchPropAttributes(
  11981. MockInputElement.prototype,
  11982. {
  11983. accept: String,
  11984. autocomplete: String,
  11985. autofocus: Boolean,
  11986. capture: String,
  11987. checked: Boolean,
  11988. disabled: Boolean,
  11989. form: String,
  11990. formaction: String,
  11991. formenctype: String,
  11992. formmethod: String,
  11993. formnovalidate: String,
  11994. formtarget: String,
  11995. height: Number,
  11996. inputmode: String,
  11997. max: String,
  11998. maxLength: Number,
  11999. min: String,
  12000. minLength: Number,
  12001. multiple: Boolean,
  12002. name: String,
  12003. pattern: String,
  12004. placeholder: String,
  12005. required: Boolean,
  12006. readOnly: Boolean,
  12007. size: Number,
  12008. spellCheck: Boolean,
  12009. src: String,
  12010. step: String,
  12011. type: String,
  12012. value: String,
  12013. width: Number
  12014. },
  12015. {
  12016. type: "text"
  12017. }
  12018. );
  12019. var MockFormElement = class extends MockHTMLElement {
  12020. constructor(ownerDocument) {
  12021. super(ownerDocument, "form");
  12022. }
  12023. };
  12024. patchPropAttributes(MockFormElement.prototype, {
  12025. name: String
  12026. });
  12027. var MockLinkElement = class extends MockHTMLElement {
  12028. constructor(ownerDocument) {
  12029. super(ownerDocument, "link");
  12030. }
  12031. get href() {
  12032. return fullUrl(this, "href");
  12033. }
  12034. set href(value) {
  12035. this.setAttribute("href", value);
  12036. }
  12037. };
  12038. patchPropAttributes(MockLinkElement.prototype, {
  12039. crossorigin: String,
  12040. media: String,
  12041. rel: String,
  12042. type: String
  12043. });
  12044. var MockMetaElement = class extends MockHTMLElement {
  12045. constructor(ownerDocument) {
  12046. super(ownerDocument, "meta");
  12047. }
  12048. };
  12049. patchPropAttributes(MockMetaElement.prototype, {
  12050. charset: String,
  12051. content: String,
  12052. name: String
  12053. });
  12054. var MockScriptElement = class extends MockHTMLElement {
  12055. constructor(ownerDocument) {
  12056. super(ownerDocument, "script");
  12057. }
  12058. get src() {
  12059. return fullUrl(this, "src");
  12060. }
  12061. set src(value) {
  12062. this.setAttribute("src", value);
  12063. }
  12064. };
  12065. patchPropAttributes(MockScriptElement.prototype, {
  12066. type: String
  12067. });
  12068. var MockDOMMatrix = class _MockDOMMatrix {
  12069. constructor() {
  12070. this.a = 1;
  12071. this.b = 0;
  12072. this.c = 0;
  12073. this.d = 1;
  12074. this.e = 0;
  12075. this.f = 0;
  12076. this.m11 = 1;
  12077. this.m12 = 0;
  12078. this.m13 = 0;
  12079. this.m14 = 0;
  12080. this.m21 = 0;
  12081. this.m22 = 1;
  12082. this.m23 = 0;
  12083. this.m24 = 0;
  12084. this.m31 = 0;
  12085. this.m32 = 0;
  12086. this.m33 = 1;
  12087. this.m34 = 0;
  12088. this.m41 = 0;
  12089. this.m42 = 0;
  12090. this.m43 = 0;
  12091. this.m44 = 1;
  12092. this.is2D = true;
  12093. this.isIdentity = true;
  12094. }
  12095. static fromMatrix() {
  12096. return new _MockDOMMatrix();
  12097. }
  12098. inverse() {
  12099. return new _MockDOMMatrix();
  12100. }
  12101. flipX() {
  12102. return new _MockDOMMatrix();
  12103. }
  12104. flipY() {
  12105. return new _MockDOMMatrix();
  12106. }
  12107. multiply() {
  12108. return new _MockDOMMatrix();
  12109. }
  12110. rotate() {
  12111. return new _MockDOMMatrix();
  12112. }
  12113. rotateAxisAngle() {
  12114. return new _MockDOMMatrix();
  12115. }
  12116. rotateFromVector() {
  12117. return new _MockDOMMatrix();
  12118. }
  12119. scale() {
  12120. return new _MockDOMMatrix();
  12121. }
  12122. scaleNonUniform() {
  12123. return new _MockDOMMatrix();
  12124. }
  12125. skewX() {
  12126. return new _MockDOMMatrix();
  12127. }
  12128. skewY() {
  12129. return new _MockDOMMatrix();
  12130. }
  12131. toJSON() {
  12132. }
  12133. toString() {
  12134. }
  12135. transformPoint() {
  12136. return new MockDOMPoint();
  12137. }
  12138. translate() {
  12139. return new _MockDOMMatrix();
  12140. }
  12141. };
  12142. var MockDOMPoint = class {
  12143. constructor() {
  12144. this.w = 1;
  12145. this.x = 0;
  12146. this.y = 0;
  12147. this.z = 0;
  12148. }
  12149. toJSON() {
  12150. }
  12151. matrixTransform() {
  12152. return new MockDOMMatrix();
  12153. }
  12154. };
  12155. var MockSVGRect = class {
  12156. constructor() {
  12157. this.height = 10;
  12158. this.width = 10;
  12159. this.x = 0;
  12160. this.y = 0;
  12161. }
  12162. };
  12163. var MockStyleElement = class extends MockHTMLElement {
  12164. constructor(ownerDocument) {
  12165. super(ownerDocument, "style");
  12166. this.sheet = new MockCSSStyleSheet(this);
  12167. }
  12168. get innerHTML() {
  12169. return getStyleElementText(this);
  12170. }
  12171. set innerHTML(value) {
  12172. setStyleElementText(this, value);
  12173. }
  12174. get innerText() {
  12175. return getStyleElementText(this);
  12176. }
  12177. set innerText(value) {
  12178. setStyleElementText(this, value);
  12179. }
  12180. get textContent() {
  12181. return getStyleElementText(this);
  12182. }
  12183. set textContent(value) {
  12184. setStyleElementText(this, value);
  12185. }
  12186. };
  12187. var MockSVGElement = class extends MockElement {
  12188. constructor() {
  12189. super(...arguments);
  12190. this.__namespaceURI = "http://www.w3.org/2000/svg";
  12191. }
  12192. // SVGElement properties and methods
  12193. get ownerSVGElement() {
  12194. return null;
  12195. }
  12196. get viewportElement() {
  12197. return null;
  12198. }
  12199. onunload() {
  12200. }
  12201. // SVGGeometryElement properties and methods
  12202. get pathLength() {
  12203. return 0;
  12204. }
  12205. isPointInFill(_pt) {
  12206. return false;
  12207. }
  12208. isPointInStroke(_pt) {
  12209. return false;
  12210. }
  12211. getTotalLength() {
  12212. return 0;
  12213. }
  12214. };
  12215. var MockSVGGraphicsElement = class extends MockSVGElement {
  12216. getBBox(_options) {
  12217. return new MockSVGRect();
  12218. }
  12219. getCTM() {
  12220. return new MockDOMMatrix();
  12221. }
  12222. getScreenCTM() {
  12223. return new MockDOMMatrix();
  12224. }
  12225. };
  12226. var MockSVGSVGElement = class extends MockSVGGraphicsElement {
  12227. createSVGPoint() {
  12228. return new MockDOMPoint();
  12229. }
  12230. };
  12231. var MockSVGTextContentElement = class extends MockSVGGraphicsElement {
  12232. getComputedTextLength() {
  12233. return 0;
  12234. }
  12235. };
  12236. var MockBaseElement = class extends MockHTMLElement {
  12237. constructor(ownerDocument) {
  12238. super(ownerDocument, "base");
  12239. }
  12240. get href() {
  12241. return fullUrl(this, "href");
  12242. }
  12243. set href(value) {
  12244. this.setAttribute("href", value);
  12245. }
  12246. };
  12247. var MockTemplateElement = class _MockTemplateElement extends MockHTMLElement {
  12248. constructor(ownerDocument) {
  12249. super(ownerDocument, "template");
  12250. this.content = new MockDocumentFragment(ownerDocument);
  12251. }
  12252. get innerHTML() {
  12253. return this.content.innerHTML;
  12254. }
  12255. set innerHTML(html) {
  12256. this.content.innerHTML = html;
  12257. }
  12258. cloneNode(deep) {
  12259. const cloned = new _MockTemplateElement(null);
  12260. cloned.attributes = cloneAttributes(this.attributes);
  12261. const styleCssText = this.getAttribute("style");
  12262. if (styleCssText != null && styleCssText.length > 0) {
  12263. cloned.setAttribute("style", styleCssText);
  12264. }
  12265. cloned.content = this.content.cloneNode(deep);
  12266. if (deep) {
  12267. for (let i = 0, ii = this.childNodes.length; i < ii; i++) {
  12268. const clonedChildNode = this.childNodes[i].cloneNode(true);
  12269. cloned.appendChild(clonedChildNode);
  12270. }
  12271. }
  12272. return cloned;
  12273. }
  12274. };
  12275. var MockTitleElement = class extends MockHTMLElement {
  12276. constructor(ownerDocument) {
  12277. super(ownerDocument, "title");
  12278. }
  12279. get text() {
  12280. return this.textContent;
  12281. }
  12282. set text(value) {
  12283. this.textContent = value;
  12284. }
  12285. };
  12286. var MockUListElement = class extends MockHTMLElement {
  12287. constructor(ownerDocument) {
  12288. super(ownerDocument, "ul");
  12289. }
  12290. };
  12291. var CanvasRenderingContext = class {
  12292. constructor(context, contextAttributes) {
  12293. this.context = context;
  12294. this.contextAttributes = contextAttributes;
  12295. }
  12296. fillRect() {
  12297. return;
  12298. }
  12299. clearRect() {
  12300. }
  12301. getImageData(_, __, w, h) {
  12302. return {
  12303. data: new Array(w * h * 4)
  12304. };
  12305. }
  12306. toDataURL() {
  12307. return "data:,";
  12308. }
  12309. putImageData() {
  12310. }
  12311. createImageData() {
  12312. return {};
  12313. }
  12314. setTransform() {
  12315. }
  12316. drawImage() {
  12317. }
  12318. save() {
  12319. }
  12320. fillText() {
  12321. }
  12322. restore() {
  12323. }
  12324. beginPath() {
  12325. }
  12326. moveTo() {
  12327. }
  12328. lineTo() {
  12329. }
  12330. closePath() {
  12331. }
  12332. stroke() {
  12333. }
  12334. translate() {
  12335. }
  12336. scale() {
  12337. }
  12338. rotate() {
  12339. }
  12340. arc() {
  12341. }
  12342. fill() {
  12343. }
  12344. measureText() {
  12345. return { width: 0 };
  12346. }
  12347. transform() {
  12348. }
  12349. rect() {
  12350. }
  12351. clip() {
  12352. }
  12353. };
  12354. var MockCanvasElement = class extends MockHTMLElement {
  12355. constructor(ownerDocument) {
  12356. super(ownerDocument, "canvas");
  12357. }
  12358. getContext(context, contextAttributes) {
  12359. return new CanvasRenderingContext(context, contextAttributes);
  12360. }
  12361. };
  12362. function fullUrl(elm, attrName) {
  12363. const val = elm.getAttribute(attrName) || "";
  12364. if (elm.ownerDocument != null) {
  12365. const win = elm.ownerDocument.defaultView;
  12366. if (win != null) {
  12367. const loc = win.location;
  12368. if (loc != null) {
  12369. try {
  12370. const url = new URL(val, loc.href);
  12371. return url.href;
  12372. } catch (e) {
  12373. }
  12374. }
  12375. }
  12376. }
  12377. return val.replace(/\'|\"/g, "").trim();
  12378. }
  12379. function patchPropAttributes(prototype, attrs, defaults = {}) {
  12380. Object.keys(attrs).forEach((propName) => {
  12381. const attr = attrs[propName];
  12382. const defaultValue = defaults[propName];
  12383. if (attr === Boolean) {
  12384. Object.defineProperty(prototype, propName, {
  12385. get() {
  12386. return this.hasAttribute(propName);
  12387. },
  12388. set(value) {
  12389. if (value) {
  12390. this.setAttribute(propName, "");
  12391. } else {
  12392. this.removeAttribute(propName);
  12393. }
  12394. }
  12395. });
  12396. } else if (attr === Number) {
  12397. Object.defineProperty(prototype, propName, {
  12398. get() {
  12399. const value = this.getAttribute(propName);
  12400. return value ? parseInt(value, 10) : defaultValue === void 0 ? 0 : defaultValue;
  12401. },
  12402. set(value) {
  12403. this.setAttribute(propName, value);
  12404. }
  12405. });
  12406. } else {
  12407. Object.defineProperty(prototype, propName, {
  12408. get() {
  12409. return this.hasAttribute(propName) ? this.getAttribute(propName) : defaultValue || "";
  12410. },
  12411. set(value) {
  12412. this.setAttribute(propName, value);
  12413. }
  12414. });
  12415. }
  12416. });
  12417. }
  12418. MockElement.prototype.cloneNode = function(deep) {
  12419. const cloned = createElement(this.ownerDocument, this.nodeName);
  12420. cloned.attributes = cloneAttributes(this.attributes);
  12421. const styleCssText = this.getAttribute("style");
  12422. if (styleCssText != null && styleCssText.length > 0) {
  12423. cloned.setAttribute("style", styleCssText);
  12424. }
  12425. if (deep) {
  12426. for (let i = 0, ii = this.childNodes.length; i < ii; i++) {
  12427. const clonedChildNode = this.childNodes[i].cloneNode(true);
  12428. cloned.appendChild(clonedChildNode);
  12429. }
  12430. }
  12431. return cloned;
  12432. };
  12433. // src/mock-doc/parse-html.ts
  12434. var sharedDocument;
  12435. function parseHtmlToDocument(html, ownerDocument = null) {
  12436. if (ownerDocument == null) {
  12437. if (sharedDocument == null) {
  12438. sharedDocument = new MockDocument();
  12439. }
  12440. ownerDocument = sharedDocument;
  12441. }
  12442. return parseDocumentUtil(ownerDocument, html);
  12443. }
  12444. // src/mock-doc/console.ts
  12445. var consoleNoop = () => {
  12446. };
  12447. function createConsole() {
  12448. return {
  12449. debug: consoleNoop,
  12450. error: consoleNoop,
  12451. info: consoleNoop,
  12452. log: consoleNoop,
  12453. warn: consoleNoop,
  12454. dir: consoleNoop,
  12455. dirxml: consoleNoop,
  12456. table: consoleNoop,
  12457. trace: consoleNoop,
  12458. group: consoleNoop,
  12459. groupCollapsed: consoleNoop,
  12460. groupEnd: consoleNoop,
  12461. clear: consoleNoop,
  12462. count: consoleNoop,
  12463. countReset: consoleNoop,
  12464. assert: consoleNoop,
  12465. profile: consoleNoop,
  12466. profileEnd: consoleNoop,
  12467. time: consoleNoop,
  12468. timeLog: consoleNoop,
  12469. timeEnd: consoleNoop,
  12470. timeStamp: consoleNoop,
  12471. context: consoleNoop,
  12472. memory: consoleNoop
  12473. };
  12474. }
  12475. // src/mock-doc/headers.ts
  12476. var MockHeaders = class {
  12477. constructor(init) {
  12478. this._values = [];
  12479. if (typeof init === "object") {
  12480. if (typeof init[Symbol.iterator] === "function") {
  12481. const kvs = [];
  12482. for (const kv of init) {
  12483. if (typeof kv[Symbol.iterator] === "function") {
  12484. kvs.push([...kv]);
  12485. }
  12486. }
  12487. for (const kv of kvs) {
  12488. this.append(kv[0], kv[1]);
  12489. }
  12490. } else {
  12491. for (const key in init) {
  12492. this.append(key, init[key]);
  12493. }
  12494. }
  12495. }
  12496. }
  12497. append(key, value) {
  12498. this._values.push([key, value + ""]);
  12499. }
  12500. delete(key) {
  12501. key = key.toLowerCase();
  12502. for (let i = this._values.length - 1; i >= 0; i--) {
  12503. if (this._values[i][0].toLowerCase() === key) {
  12504. this._values.splice(i, 1);
  12505. }
  12506. }
  12507. }
  12508. entries() {
  12509. const entries = [];
  12510. for (const kv of this.keys()) {
  12511. entries.push([kv, this.get(kv)]);
  12512. }
  12513. let index = -1;
  12514. return {
  12515. next() {
  12516. index++;
  12517. return {
  12518. value: entries[index],
  12519. done: !entries[index]
  12520. };
  12521. },
  12522. [Symbol.iterator]() {
  12523. return this;
  12524. }
  12525. };
  12526. }
  12527. forEach(cb) {
  12528. for (const kv of this.entries()) {
  12529. cb(kv[1], kv[0]);
  12530. }
  12531. }
  12532. get(key) {
  12533. const rtn = [];
  12534. key = key.toLowerCase();
  12535. for (const kv of this._values) {
  12536. if (kv[0].toLowerCase() === key) {
  12537. rtn.push(kv[1]);
  12538. }
  12539. }
  12540. return rtn.length > 0 ? rtn.join(", ") : null;
  12541. }
  12542. has(key) {
  12543. key = key.toLowerCase();
  12544. for (const kv of this._values) {
  12545. if (kv[0].toLowerCase() === key) {
  12546. return true;
  12547. }
  12548. }
  12549. return false;
  12550. }
  12551. keys() {
  12552. const keys = [];
  12553. for (const kv of this._values) {
  12554. const key = kv[0].toLowerCase();
  12555. if (!keys.includes(key)) {
  12556. keys.push(key);
  12557. }
  12558. }
  12559. let index = -1;
  12560. return {
  12561. next() {
  12562. index++;
  12563. return {
  12564. value: keys[index],
  12565. done: !keys[index]
  12566. };
  12567. },
  12568. [Symbol.iterator]() {
  12569. return this;
  12570. }
  12571. };
  12572. }
  12573. set(key, value) {
  12574. for (const kv of this._values) {
  12575. if (kv[0].toLowerCase() === key.toLowerCase()) {
  12576. kv[1] = value + "";
  12577. return;
  12578. }
  12579. }
  12580. this.append(key, value);
  12581. }
  12582. values() {
  12583. const values = this._values;
  12584. let index = -1;
  12585. return {
  12586. next() {
  12587. index++;
  12588. const done = !values[index];
  12589. return {
  12590. value: done ? void 0 : values[index][1],
  12591. done
  12592. };
  12593. },
  12594. [Symbol.iterator]() {
  12595. return this;
  12596. }
  12597. };
  12598. }
  12599. [Symbol.iterator]() {
  12600. return this.entries();
  12601. }
  12602. };
  12603. // src/mock-doc/parser.ts
  12604. var MockDOMParser = class {
  12605. parseFromString(htmlToParse, mimeType) {
  12606. if (mimeType !== "text/html") {
  12607. console.error("XML parsing not implemented yet, continuing as html");
  12608. }
  12609. return parseHtmlToDocument(htmlToParse);
  12610. }
  12611. };
  12612. // src/mock-doc/request-response.ts
  12613. var MockRequest = class _MockRequest {
  12614. constructor(input, init = {}) {
  12615. this._method = "GET";
  12616. this._url = "/";
  12617. this.bodyUsed = false;
  12618. this.cache = "default";
  12619. this.credentials = "same-origin";
  12620. this.integrity = "";
  12621. this.keepalive = false;
  12622. this.mode = "cors";
  12623. this.redirect = "follow";
  12624. this.referrer = "about:client";
  12625. this.referrerPolicy = "";
  12626. if (typeof input === "string") {
  12627. this.url = input;
  12628. } else if (input) {
  12629. Object.assign(this, input);
  12630. this.headers = new MockHeaders(input.headers);
  12631. }
  12632. Object.assign(this, init);
  12633. if (init.headers) {
  12634. this.headers = new MockHeaders(init.headers);
  12635. }
  12636. if (!this.headers) {
  12637. this.headers = new MockHeaders();
  12638. }
  12639. }
  12640. get url() {
  12641. if (typeof this._url === "string") {
  12642. return new URL(this._url, location.href).href;
  12643. }
  12644. return new URL("/", location.href).href;
  12645. }
  12646. set url(value) {
  12647. this._url = value;
  12648. }
  12649. get method() {
  12650. if (typeof this._method === "string") {
  12651. return this._method.toUpperCase();
  12652. }
  12653. return "GET";
  12654. }
  12655. set method(value) {
  12656. this._method = value;
  12657. }
  12658. clone() {
  12659. const clone = { ...this };
  12660. clone.headers = new MockHeaders(this.headers);
  12661. return new _MockRequest(clone);
  12662. }
  12663. };
  12664. var MockResponse = class _MockResponse {
  12665. constructor(body, init = {}) {
  12666. this.ok = true;
  12667. this.status = 200;
  12668. this.statusText = "";
  12669. this.type = "default";
  12670. this.url = "";
  12671. this._body = body;
  12672. if (init) {
  12673. Object.assign(this, init);
  12674. }
  12675. this.headers = new MockHeaders(init.headers);
  12676. }
  12677. async json() {
  12678. return JSON.parse(this._body);
  12679. }
  12680. async text() {
  12681. return this._body;
  12682. }
  12683. clone() {
  12684. const initClone = { ...this };
  12685. initClone.headers = new MockHeaders(this.headers);
  12686. return new _MockResponse(this._body, initClone);
  12687. }
  12688. };
  12689. // src/mock-doc/global.ts
  12690. function patchWindow(winToBePatched) {
  12691. const mockWin = new MockWindow(false);
  12692. WINDOW_FUNCTIONS.forEach((fnName) => {
  12693. if (typeof winToBePatched[fnName] !== "function") {
  12694. winToBePatched[fnName] = mockWin[fnName].bind(mockWin);
  12695. }
  12696. });
  12697. WINDOW_PROPS.forEach((propName) => {
  12698. if (winToBePatched === void 0) {
  12699. Object.defineProperty(winToBePatched, propName, {
  12700. get() {
  12701. return mockWin[propName];
  12702. },
  12703. set(val) {
  12704. mockWin[propName] = val;
  12705. },
  12706. configurable: true,
  12707. enumerable: true
  12708. });
  12709. }
  12710. });
  12711. }
  12712. function addGlobalsToWindowPrototype(mockWinPrototype) {
  12713. GLOBAL_CONSTRUCTORS.forEach(([cstrName, Cstr]) => {
  12714. Object.defineProperty(mockWinPrototype, cstrName, {
  12715. get() {
  12716. return this["__" + cstrName] || Cstr;
  12717. },
  12718. set(cstr) {
  12719. this["__" + cstrName] = cstr;
  12720. },
  12721. configurable: true,
  12722. enumerable: true
  12723. });
  12724. });
  12725. }
  12726. var WINDOW_FUNCTIONS = [
  12727. "addEventListener",
  12728. "alert",
  12729. "blur",
  12730. "cancelAnimationFrame",
  12731. "cancelIdleCallback",
  12732. "clearInterval",
  12733. "clearTimeout",
  12734. "close",
  12735. "confirm",
  12736. "dispatchEvent",
  12737. "focus",
  12738. "getComputedStyle",
  12739. "matchMedia",
  12740. "open",
  12741. "prompt",
  12742. "removeEventListener",
  12743. "requestAnimationFrame",
  12744. "requestIdleCallback",
  12745. "URL"
  12746. ];
  12747. var WINDOW_PROPS = [
  12748. "customElements",
  12749. "devicePixelRatio",
  12750. "document",
  12751. "history",
  12752. "innerHeight",
  12753. "innerWidth",
  12754. "localStorage",
  12755. "location",
  12756. "navigator",
  12757. "pageXOffset",
  12758. "pageYOffset",
  12759. "performance",
  12760. "screenLeft",
  12761. "screenTop",
  12762. "screenX",
  12763. "screenY",
  12764. "scrollX",
  12765. "scrollY",
  12766. "sessionStorage",
  12767. "CSS",
  12768. "CustomEvent",
  12769. "Event",
  12770. "Element",
  12771. "HTMLElement",
  12772. "Node",
  12773. "NodeList",
  12774. "FocusEvent",
  12775. "KeyboardEvent",
  12776. "MouseEvent"
  12777. ];
  12778. var GLOBAL_CONSTRUCTORS = [
  12779. ["CustomEvent", MockCustomEvent],
  12780. ["DocumentFragment", MockDocumentFragment],
  12781. ["DOMParser", MockDOMParser],
  12782. ["Event", MockEvent],
  12783. ["FocusEvent", MockFocusEvent],
  12784. ["Headers", MockHeaders],
  12785. ["KeyboardEvent", MockKeyboardEvent],
  12786. ["MouseEvent", MockMouseEvent],
  12787. ["Request", MockRequest],
  12788. ["Response", MockResponse],
  12789. ["ShadowRoot", MockDocumentFragment],
  12790. ["HTMLAnchorElement", MockAnchorElement],
  12791. ["HTMLBaseElement", MockBaseElement],
  12792. ["HTMLButtonElement", MockButtonElement],
  12793. ["HTMLCanvasElement", MockCanvasElement],
  12794. ["HTMLFormElement", MockFormElement],
  12795. ["HTMLImageElement", MockImageElement],
  12796. ["HTMLInputElement", MockInputElement],
  12797. ["HTMLLinkElement", MockLinkElement],
  12798. ["HTMLMetaElement", MockMetaElement],
  12799. ["HTMLScriptElement", MockScriptElement],
  12800. ["HTMLStyleElement", MockStyleElement],
  12801. ["HTMLTemplateElement", MockTemplateElement],
  12802. ["HTMLTitleElement", MockTitleElement],
  12803. ["HTMLUListElement", MockUListElement]
  12804. ];
  12805. // src/mock-doc/history.ts
  12806. var MockHistory = class {
  12807. constructor() {
  12808. this.items = [];
  12809. }
  12810. get length() {
  12811. return this.items.length;
  12812. }
  12813. back() {
  12814. this.go(-1);
  12815. }
  12816. forward() {
  12817. this.go(1);
  12818. }
  12819. go(_value) {
  12820. }
  12821. pushState(_state, _title, _url) {
  12822. }
  12823. replaceState(_state, _title, _url) {
  12824. }
  12825. };
  12826. // src/mock-doc/intersection-observer.ts
  12827. var MockIntersectionObserver = class {
  12828. constructor() {
  12829. }
  12830. disconnect() {
  12831. }
  12832. observe() {
  12833. }
  12834. takeRecords() {
  12835. return [];
  12836. }
  12837. unobserve() {
  12838. }
  12839. };
  12840. // src/mock-doc/location.ts
  12841. var MockLocation = class {
  12842. constructor() {
  12843. this.ancestorOrigins = null;
  12844. this.protocol = "";
  12845. this.host = "";
  12846. this.hostname = "";
  12847. this.port = "";
  12848. this.pathname = "";
  12849. this.search = "";
  12850. this.hash = "";
  12851. this.username = "";
  12852. this.password = "";
  12853. this.origin = "";
  12854. this._href = "";
  12855. }
  12856. get href() {
  12857. return this._href;
  12858. }
  12859. set href(value) {
  12860. const url = new URL(value, "http://mockdoc.stenciljs.com");
  12861. this._href = url.href;
  12862. this.protocol = url.protocol;
  12863. this.host = url.host;
  12864. this.hostname = url.hostname;
  12865. this.port = url.port;
  12866. this.pathname = url.pathname;
  12867. this.search = url.search;
  12868. this.hash = url.hash;
  12869. this.username = url.username;
  12870. this.password = url.password;
  12871. this.origin = url.origin;
  12872. }
  12873. assign(_url) {
  12874. }
  12875. reload(_forcedReload) {
  12876. }
  12877. replace(_url) {
  12878. }
  12879. toString() {
  12880. return this.href;
  12881. }
  12882. };
  12883. // src/mock-doc/navigator.ts
  12884. var MockNavigator = class {
  12885. constructor() {
  12886. this.appCodeName = "MockNavigator";
  12887. this.appName = "MockNavigator";
  12888. this.appVersion = "MockNavigator";
  12889. this.platform = "MockNavigator";
  12890. this.userAgent = "MockNavigator";
  12891. }
  12892. };
  12893. // src/mock-doc/performance.ts
  12894. var MockPerformance = class {
  12895. constructor() {
  12896. this.timeOrigin = Date.now();
  12897. this.eventCounts = /* @__PURE__ */ new Map();
  12898. }
  12899. addEventListener() {
  12900. }
  12901. clearMarks() {
  12902. }
  12903. clearMeasures() {
  12904. }
  12905. clearResourceTimings() {
  12906. }
  12907. dispatchEvent() {
  12908. return true;
  12909. }
  12910. getEntries() {
  12911. return [];
  12912. }
  12913. getEntriesByName() {
  12914. return [];
  12915. }
  12916. getEntriesByType() {
  12917. return [];
  12918. }
  12919. // Stencil's implementation of `mark` is non-compliant with the `Performance` interface. Because Stencil will
  12920. // instantiate an instance of this class and may attempt to assign it to a variable of type `Performance`, the return
  12921. // type must match the `Performance` interface (rather than typing this function as returning `void` and ignoring the
  12922. // associated errors returned by the type checker)
  12923. // @ts-ignore
  12924. mark() {
  12925. }
  12926. // Stencil's implementation of `measure` is non-compliant with the `Performance` interface. Because Stencil will
  12927. // instantiate an instance of this class and may attempt to assign it to a variable of type `Performance`, the return
  12928. // type must match the `Performance` interface (rather than typing this function as returning `void` and ignoring the
  12929. // associated errors returned by the type checker)
  12930. // @ts-ignore
  12931. measure() {
  12932. }
  12933. get navigation() {
  12934. return {};
  12935. }
  12936. now() {
  12937. return Date.now() - this.timeOrigin;
  12938. }
  12939. get onresourcetimingbufferfull() {
  12940. return null;
  12941. }
  12942. removeEventListener() {
  12943. }
  12944. setResourceTimingBufferSize() {
  12945. }
  12946. get timing() {
  12947. return {};
  12948. }
  12949. toJSON() {
  12950. }
  12951. };
  12952. function resetPerformance(perf) {
  12953. if (perf != null) {
  12954. try {
  12955. perf.timeOrigin = Date.now();
  12956. } catch (e) {
  12957. }
  12958. }
  12959. }
  12960. // src/mock-doc/storage.ts
  12961. var MockStorage = class {
  12962. constructor() {
  12963. this.items = /* @__PURE__ */ new Map();
  12964. }
  12965. key(_value) {
  12966. }
  12967. getItem(key) {
  12968. key = String(key);
  12969. if (this.items.has(key)) {
  12970. return this.items.get(key);
  12971. }
  12972. return null;
  12973. }
  12974. setItem(key, value) {
  12975. if (value == null) {
  12976. value = "null";
  12977. }
  12978. this.items.set(String(key), String(value));
  12979. }
  12980. removeItem(key) {
  12981. this.items.delete(String(key));
  12982. }
  12983. clear() {
  12984. this.items.clear();
  12985. }
  12986. };
  12987. // src/mock-doc/window.ts
  12988. var nativeClearInterval = clearInterval;
  12989. var nativeClearTimeout = clearTimeout;
  12990. var nativeSetInterval = setInterval;
  12991. var nativeSetTimeout = setTimeout;
  12992. var nativeURL = URL;
  12993. var nativeWindow = globalThis.window;
  12994. var MockWindow = class {
  12995. constructor(html = null) {
  12996. if (html !== false) {
  12997. this.document = new MockDocument(html, this);
  12998. } else {
  12999. this.document = null;
  13000. }
  13001. this.performance = new MockPerformance();
  13002. this.customElements = new MockCustomElementRegistry(this);
  13003. this.console = createConsole();
  13004. resetWindowDefaults(this);
  13005. resetWindowDimensions(this);
  13006. }
  13007. addEventListener(type, handler) {
  13008. addEventListener(this, type, handler);
  13009. }
  13010. alert(msg) {
  13011. if (this.console) {
  13012. this.console.debug(msg);
  13013. } else {
  13014. console.debug(msg);
  13015. }
  13016. }
  13017. blur() {
  13018. }
  13019. cancelAnimationFrame(id) {
  13020. this.__clearTimeout.call(nativeWindow || this, id);
  13021. }
  13022. cancelIdleCallback(id) {
  13023. this.__clearTimeout.call(nativeWindow || this, id);
  13024. }
  13025. get CharacterData() {
  13026. if (this.__charDataCstr == null) {
  13027. const ownerDocument = this.document;
  13028. this.__charDataCstr = class extends MockNode2 {
  13029. constructor() {
  13030. super(ownerDocument, 0, "test", "");
  13031. throw new Error("Illegal constructor: cannot construct CharacterData");
  13032. }
  13033. };
  13034. }
  13035. return this.__charDataCstr;
  13036. }
  13037. set CharacterData(charDataCstr) {
  13038. this.__charDataCstr = charDataCstr;
  13039. }
  13040. clearInterval(id) {
  13041. this.__clearInterval.call(nativeWindow || this, id);
  13042. }
  13043. clearTimeout(id) {
  13044. this.__clearTimeout.call(nativeWindow || this, id);
  13045. }
  13046. close() {
  13047. resetWindow(this);
  13048. }
  13049. confirm() {
  13050. return false;
  13051. }
  13052. get CSS() {
  13053. return {
  13054. supports: () => true
  13055. };
  13056. }
  13057. get Document() {
  13058. if (this.__docCstr == null) {
  13059. const win = this;
  13060. this.__docCstr = class extends MockDocument {
  13061. constructor() {
  13062. super(false, win);
  13063. throw new Error("Illegal constructor: cannot construct Document");
  13064. }
  13065. };
  13066. }
  13067. return this.__docCstr;
  13068. }
  13069. set Document(docCstr) {
  13070. this.__docCstr = docCstr;
  13071. }
  13072. get DocumentFragment() {
  13073. if (this.__docFragCstr == null) {
  13074. const ownerDocument = this.document;
  13075. this.__docFragCstr = class extends MockDocumentFragment {
  13076. constructor() {
  13077. super(ownerDocument);
  13078. throw new Error("Illegal constructor: cannot construct DocumentFragment");
  13079. }
  13080. };
  13081. }
  13082. return this.__docFragCstr;
  13083. }
  13084. set DocumentFragment(docFragCstr) {
  13085. this.__docFragCstr = docFragCstr;
  13086. }
  13087. get DocumentType() {
  13088. if (this.__docTypeCstr == null) {
  13089. const ownerDocument = this.document;
  13090. this.__docTypeCstr = class extends MockNode2 {
  13091. constructor() {
  13092. super(ownerDocument, 0, "test", "");
  13093. throw new Error("Illegal constructor: cannot construct DocumentType");
  13094. }
  13095. };
  13096. }
  13097. return this.__docTypeCstr;
  13098. }
  13099. set DocumentType(docTypeCstr) {
  13100. this.__docTypeCstr = docTypeCstr;
  13101. }
  13102. get DOMTokenList() {
  13103. if (this.__domTokenListCstr == null) {
  13104. this.__domTokenListCstr = class MockDOMTokenList {
  13105. };
  13106. }
  13107. return this.__domTokenListCstr;
  13108. }
  13109. set DOMTokenList(domTokenListCstr) {
  13110. this.__domTokenListCstr = domTokenListCstr;
  13111. }
  13112. dispatchEvent(ev) {
  13113. return dispatchEvent(this, ev);
  13114. }
  13115. get Element() {
  13116. if (this.__elementCstr == null) {
  13117. const ownerDocument = this.document;
  13118. this.__elementCstr = class extends MockElement {
  13119. constructor() {
  13120. super(ownerDocument, "");
  13121. throw new Error("Illegal constructor: cannot construct Element");
  13122. }
  13123. };
  13124. }
  13125. return this.__elementCstr;
  13126. }
  13127. fetch(input, init) {
  13128. if (typeof fetch === "function") {
  13129. return fetch(input, init);
  13130. }
  13131. throw new Error(`fetch() not implemented`);
  13132. }
  13133. focus() {
  13134. }
  13135. getComputedStyle(_) {
  13136. return {
  13137. cssText: "",
  13138. length: 0,
  13139. parentRule: null,
  13140. getPropertyPriority() {
  13141. return null;
  13142. },
  13143. getPropertyValue() {
  13144. return "";
  13145. },
  13146. item() {
  13147. return null;
  13148. },
  13149. removeProperty() {
  13150. return null;
  13151. },
  13152. setProperty() {
  13153. return null;
  13154. }
  13155. };
  13156. }
  13157. get globalThis() {
  13158. return this;
  13159. }
  13160. get history() {
  13161. if (this.__history == null) {
  13162. this.__history = new MockHistory();
  13163. }
  13164. return this.__history;
  13165. }
  13166. set history(hsty) {
  13167. this.__history = hsty;
  13168. }
  13169. get JSON() {
  13170. return JSON;
  13171. }
  13172. get HTMLElement() {
  13173. if (this.__htmlElementCstr == null) {
  13174. const ownerDocument = this.document;
  13175. this.__htmlElementCstr = class extends MockHTMLElement {
  13176. constructor() {
  13177. super(ownerDocument, "");
  13178. const observedAttributes = this.constructor.observedAttributes;
  13179. if (Array.isArray(observedAttributes) && typeof this.attributeChangedCallback === "function") {
  13180. observedAttributes.forEach((attrName) => {
  13181. const attrValue = this.getAttribute(attrName);
  13182. if (attrValue != null) {
  13183. this.attributeChangedCallback(attrName, null, attrValue);
  13184. }
  13185. });
  13186. }
  13187. }
  13188. };
  13189. }
  13190. return this.__htmlElementCstr;
  13191. }
  13192. set HTMLElement(htmlElementCstr) {
  13193. this.__htmlElementCstr = htmlElementCstr;
  13194. }
  13195. get IntersectionObserver() {
  13196. return MockIntersectionObserver;
  13197. }
  13198. get localStorage() {
  13199. if (this.__localStorage == null) {
  13200. this.__localStorage = new MockStorage();
  13201. }
  13202. return this.__localStorage;
  13203. }
  13204. set localStorage(locStorage) {
  13205. this.__localStorage = locStorage;
  13206. }
  13207. get location() {
  13208. if (this.__location == null) {
  13209. this.__location = new MockLocation();
  13210. }
  13211. return this.__location;
  13212. }
  13213. set location(val) {
  13214. if (typeof val === "string") {
  13215. if (this.__location == null) {
  13216. this.__location = new MockLocation();
  13217. }
  13218. this.__location.href = val;
  13219. } else {
  13220. this.__location = val;
  13221. }
  13222. }
  13223. matchMedia(media) {
  13224. return {
  13225. media,
  13226. matches: false,
  13227. addListener: (_handler) => {
  13228. },
  13229. removeListener: (_handler) => {
  13230. },
  13231. addEventListener: (_type, _handler) => {
  13232. },
  13233. removeEventListener: (_type, _handler) => {
  13234. },
  13235. dispatchEvent: (_ev) => {
  13236. },
  13237. onchange: null
  13238. };
  13239. }
  13240. get Node() {
  13241. if (this.__nodeCstr == null) {
  13242. const ownerDocument = this.document;
  13243. this.__nodeCstr = class extends MockNode2 {
  13244. constructor() {
  13245. super(ownerDocument, 0, "test", "");
  13246. throw new Error("Illegal constructor: cannot construct Node");
  13247. }
  13248. };
  13249. }
  13250. return this.__nodeCstr;
  13251. }
  13252. get NodeList() {
  13253. if (this.__nodeListCstr == null) {
  13254. const ownerDocument = this.document;
  13255. this.__nodeListCstr = class extends MockNodeList {
  13256. constructor() {
  13257. super(ownerDocument, [], 0);
  13258. throw new Error("Illegal constructor: cannot construct NodeList");
  13259. }
  13260. };
  13261. }
  13262. return this.__nodeListCstr;
  13263. }
  13264. get navigator() {
  13265. if (this.__navigator == null) {
  13266. this.__navigator = new MockNavigator();
  13267. }
  13268. return this.__navigator;
  13269. }
  13270. set navigator(nav) {
  13271. this.__navigator = nav;
  13272. }
  13273. get parent() {
  13274. return null;
  13275. }
  13276. prompt() {
  13277. return "";
  13278. }
  13279. open() {
  13280. return null;
  13281. }
  13282. get origin() {
  13283. return this.location.origin;
  13284. }
  13285. removeEventListener(type, handler) {
  13286. removeEventListener(this, type, handler);
  13287. }
  13288. requestAnimationFrame(callback) {
  13289. return this.setTimeout(() => {
  13290. callback(Date.now());
  13291. }, 0);
  13292. }
  13293. requestIdleCallback(callback) {
  13294. return this.setTimeout(() => {
  13295. callback({
  13296. didTimeout: false,
  13297. timeRemaining: () => 0
  13298. });
  13299. }, 0);
  13300. }
  13301. scroll(_x, _y) {
  13302. }
  13303. scrollBy(_x, _y) {
  13304. }
  13305. scrollTo(_x, _y) {
  13306. }
  13307. get self() {
  13308. return this;
  13309. }
  13310. get sessionStorage() {
  13311. if (this.__sessionStorage == null) {
  13312. this.__sessionStorage = new MockStorage();
  13313. }
  13314. return this.__sessionStorage;
  13315. }
  13316. set sessionStorage(locStorage) {
  13317. this.__sessionStorage = locStorage;
  13318. }
  13319. setInterval(callback, ms, ...args) {
  13320. if (this.__timeouts == null) {
  13321. this.__timeouts = /* @__PURE__ */ new Set();
  13322. }
  13323. ms = Math.min(ms, this.__maxTimeout);
  13324. if (this.__allowInterval) {
  13325. const intervalId = this.__setInterval(() => {
  13326. if (this.__timeouts) {
  13327. this.__timeouts.delete(intervalId);
  13328. try {
  13329. callback(...args);
  13330. } catch (e) {
  13331. if (this.console) {
  13332. this.console.error(e);
  13333. } else {
  13334. console.error(e);
  13335. }
  13336. }
  13337. }
  13338. }, ms);
  13339. if (this.__timeouts) {
  13340. this.__timeouts.add(intervalId);
  13341. }
  13342. return intervalId;
  13343. }
  13344. const timeoutId = this.__setTimeout.call(
  13345. nativeWindow || this,
  13346. () => {
  13347. if (this.__timeouts) {
  13348. this.__timeouts.delete(timeoutId);
  13349. try {
  13350. callback(...args);
  13351. } catch (e) {
  13352. if (this.console) {
  13353. this.console.error(e);
  13354. } else {
  13355. console.error(e);
  13356. }
  13357. }
  13358. }
  13359. },
  13360. ms
  13361. );
  13362. if (this.__timeouts) {
  13363. this.__timeouts.add(timeoutId);
  13364. }
  13365. return timeoutId;
  13366. }
  13367. setTimeout(callback, ms, ...args) {
  13368. if (this.__timeouts == null) {
  13369. this.__timeouts = /* @__PURE__ */ new Set();
  13370. }
  13371. ms = Math.min(ms, this.__maxTimeout);
  13372. const timeoutId = this.__setTimeout.call(
  13373. nativeWindow || this,
  13374. () => {
  13375. if (this.__timeouts) {
  13376. this.__timeouts.delete(timeoutId);
  13377. try {
  13378. callback(...args);
  13379. } catch (e) {
  13380. if (this.console) {
  13381. this.console.error(e);
  13382. } else {
  13383. console.error(e);
  13384. }
  13385. }
  13386. }
  13387. },
  13388. ms
  13389. );
  13390. if (this.__timeouts) {
  13391. this.__timeouts.add(timeoutId);
  13392. }
  13393. return timeoutId;
  13394. }
  13395. get top() {
  13396. return this;
  13397. }
  13398. get window() {
  13399. return this;
  13400. }
  13401. onanimationstart() {
  13402. }
  13403. onanimationend() {
  13404. }
  13405. onanimationiteration() {
  13406. }
  13407. onabort() {
  13408. }
  13409. onauxclick() {
  13410. }
  13411. onbeforecopy() {
  13412. }
  13413. onbeforecut() {
  13414. }
  13415. onbeforepaste() {
  13416. }
  13417. onblur() {
  13418. }
  13419. oncancel() {
  13420. }
  13421. oncanplay() {
  13422. }
  13423. oncanplaythrough() {
  13424. }
  13425. onchange() {
  13426. }
  13427. onclick() {
  13428. }
  13429. onclose() {
  13430. }
  13431. oncontextmenu() {
  13432. }
  13433. oncopy() {
  13434. }
  13435. oncuechange() {
  13436. }
  13437. oncut() {
  13438. }
  13439. ondblclick() {
  13440. }
  13441. ondrag() {
  13442. }
  13443. ondragend() {
  13444. }
  13445. ondragenter() {
  13446. }
  13447. ondragleave() {
  13448. }
  13449. ondragover() {
  13450. }
  13451. ondragstart() {
  13452. }
  13453. ondrop() {
  13454. }
  13455. ondurationchange() {
  13456. }
  13457. onemptied() {
  13458. }
  13459. onended() {
  13460. }
  13461. onerror() {
  13462. }
  13463. onfocus() {
  13464. }
  13465. onfocusin() {
  13466. }
  13467. onfocusout() {
  13468. }
  13469. onformdata() {
  13470. }
  13471. onfullscreenchange() {
  13472. }
  13473. onfullscreenerror() {
  13474. }
  13475. ongotpointercapture() {
  13476. }
  13477. oninput() {
  13478. }
  13479. oninvalid() {
  13480. }
  13481. onkeydown() {
  13482. }
  13483. onkeypress() {
  13484. }
  13485. onkeyup() {
  13486. }
  13487. onload() {
  13488. }
  13489. onloadeddata() {
  13490. }
  13491. onloadedmetadata() {
  13492. }
  13493. onloadstart() {
  13494. }
  13495. onlostpointercapture() {
  13496. }
  13497. onmousedown() {
  13498. }
  13499. onmouseenter() {
  13500. }
  13501. onmouseleave() {
  13502. }
  13503. onmousemove() {
  13504. }
  13505. onmouseout() {
  13506. }
  13507. onmouseover() {
  13508. }
  13509. onmouseup() {
  13510. }
  13511. onmousewheel() {
  13512. }
  13513. onpaste() {
  13514. }
  13515. onpause() {
  13516. }
  13517. onplay() {
  13518. }
  13519. onplaying() {
  13520. }
  13521. onpointercancel() {
  13522. }
  13523. onpointerdown() {
  13524. }
  13525. onpointerenter() {
  13526. }
  13527. onpointerleave() {
  13528. }
  13529. onpointermove() {
  13530. }
  13531. onpointerout() {
  13532. }
  13533. onpointerover() {
  13534. }
  13535. onpointerup() {
  13536. }
  13537. onprogress() {
  13538. }
  13539. onratechange() {
  13540. }
  13541. onreset() {
  13542. }
  13543. onresize() {
  13544. }
  13545. onscroll() {
  13546. }
  13547. onsearch() {
  13548. }
  13549. onseeked() {
  13550. }
  13551. onseeking() {
  13552. }
  13553. onselect() {
  13554. }
  13555. onselectstart() {
  13556. }
  13557. onstalled() {
  13558. }
  13559. onsubmit() {
  13560. }
  13561. onsuspend() {
  13562. }
  13563. ontimeupdate() {
  13564. }
  13565. ontoggle() {
  13566. }
  13567. onvolumechange() {
  13568. }
  13569. onwaiting() {
  13570. }
  13571. onwebkitfullscreenchange() {
  13572. }
  13573. onwebkitfullscreenerror() {
  13574. }
  13575. onwheel() {
  13576. }
  13577. };
  13578. addGlobalsToWindowPrototype(MockWindow.prototype);
  13579. function resetWindowDefaults(win) {
  13580. win.__clearInterval = nativeClearInterval;
  13581. win.__clearTimeout = nativeClearTimeout;
  13582. win.__setInterval = nativeSetInterval;
  13583. win.__setTimeout = nativeSetTimeout;
  13584. win.__maxTimeout = 3e4;
  13585. win.__allowInterval = true;
  13586. win.URL = nativeURL;
  13587. }
  13588. function cloneWindow(srcWin, opts = {}) {
  13589. if (srcWin == null) {
  13590. return null;
  13591. }
  13592. const clonedWin = new MockWindow(false);
  13593. if (!opts.customElementProxy) {
  13594. srcWin.customElements = null;
  13595. }
  13596. if (srcWin.document != null) {
  13597. const clonedDoc = new MockDocument(false, clonedWin);
  13598. clonedWin.document = clonedDoc;
  13599. clonedDoc.documentElement = srcWin.document.documentElement.cloneNode(true);
  13600. } else {
  13601. clonedWin.document = new MockDocument(null, clonedWin);
  13602. }
  13603. return clonedWin;
  13604. }
  13605. function constrainTimeouts(win) {
  13606. win.__allowInterval = false;
  13607. win.__maxTimeout = 0;
  13608. }
  13609. function resetWindow(win) {
  13610. if (win != null) {
  13611. if (win.__timeouts) {
  13612. win.__timeouts.forEach((timeoutId) => {
  13613. nativeClearInterval(timeoutId);
  13614. nativeClearTimeout(timeoutId);
  13615. });
  13616. win.__timeouts.clear();
  13617. }
  13618. if (win.customElements && win.customElements.clear) {
  13619. win.customElements.clear();
  13620. }
  13621. resetDocument(win.document);
  13622. resetPerformance(win.performance);
  13623. for (const key in win) {
  13624. if (win.hasOwnProperty(key) && key !== "document" && key !== "performance" && key !== "customElements") {
  13625. delete win[key];
  13626. }
  13627. }
  13628. resetWindowDefaults(win);
  13629. resetWindowDimensions(win);
  13630. resetEventListeners(win);
  13631. if (win.document != null) {
  13632. try {
  13633. win.document.defaultView = win;
  13634. } catch (e) {
  13635. }
  13636. }
  13637. win.fetch = null;
  13638. win.Headers = null;
  13639. win.Request = null;
  13640. win.Response = null;
  13641. win.FetchError = null;
  13642. }
  13643. }
  13644. function resetWindowDimensions(win) {
  13645. try {
  13646. win.devicePixelRatio = 1;
  13647. win.innerHeight = 768;
  13648. win.innerWidth = 1366;
  13649. win.pageXOffset = 0;
  13650. win.pageYOffset = 0;
  13651. win.screenLeft = 0;
  13652. win.screenTop = 0;
  13653. win.screenX = 0;
  13654. win.screenY = 0;
  13655. win.scrollX = 0;
  13656. win.scrollY = 0;
  13657. win.screen = {
  13658. availHeight: win.innerHeight,
  13659. availLeft: 0,
  13660. availTop: 0,
  13661. availWidth: win.innerWidth,
  13662. colorDepth: 24,
  13663. height: win.innerHeight,
  13664. keepAwake: false,
  13665. orientation: {
  13666. angle: 0,
  13667. type: "portrait-primary"
  13668. },
  13669. pixelDepth: 24,
  13670. width: win.innerWidth
  13671. };
  13672. } catch (e) {
  13673. }
  13674. }
  13675. // src/mock-doc/document.ts
  13676. var MockDocument = class _MockDocument extends MockHTMLElement {
  13677. constructor(html = null, win = null) {
  13678. super(null, null);
  13679. this.nodeName = "#document" /* DOCUMENT_NODE */;
  13680. this.nodeType = 9 /* DOCUMENT_NODE */;
  13681. this.defaultView = win;
  13682. this.cookie = "";
  13683. this.referrer = "";
  13684. this.appendChild(this.createDocumentTypeNode());
  13685. if (typeof html === "string") {
  13686. const parsedDoc = parseDocumentUtil(this, html);
  13687. const documentElement = parsedDoc.children.find((elm) => elm.nodeName === "HTML");
  13688. if (documentElement != null) {
  13689. this.appendChild(documentElement);
  13690. setOwnerDocument(documentElement, this);
  13691. }
  13692. } else if (html !== false) {
  13693. const documentElement = new MockHTMLElement(this, "html");
  13694. this.appendChild(documentElement);
  13695. documentElement.appendChild(new MockHTMLElement(this, "head"));
  13696. documentElement.appendChild(new MockHTMLElement(this, "body"));
  13697. }
  13698. }
  13699. get dir() {
  13700. return this.documentElement.dir;
  13701. }
  13702. set dir(value) {
  13703. this.documentElement.dir = value;
  13704. }
  13705. get localName() {
  13706. throw new Error("Unimplemented");
  13707. }
  13708. get location() {
  13709. if (this.defaultView != null) {
  13710. return this.defaultView.location;
  13711. }
  13712. return null;
  13713. }
  13714. set location(val) {
  13715. if (this.defaultView != null) {
  13716. this.defaultView.location = val;
  13717. }
  13718. }
  13719. get baseURI() {
  13720. const baseNode = this.head.childNodes.find((node) => node.nodeName === "BASE");
  13721. if (baseNode) {
  13722. return baseNode.href;
  13723. }
  13724. return this.URL;
  13725. }
  13726. get URL() {
  13727. return this.location.href;
  13728. }
  13729. get styleSheets() {
  13730. return this.querySelectorAll("style");
  13731. }
  13732. get scripts() {
  13733. return this.querySelectorAll("script");
  13734. }
  13735. get forms() {
  13736. return this.querySelectorAll("form");
  13737. }
  13738. get images() {
  13739. return this.querySelectorAll("img");
  13740. }
  13741. get scrollingElement() {
  13742. return this.documentElement;
  13743. }
  13744. get documentElement() {
  13745. for (let i = this.childNodes.length - 1; i >= 0; i--) {
  13746. if (this.childNodes[i].nodeName === "HTML") {
  13747. return this.childNodes[i];
  13748. }
  13749. }
  13750. const documentElement = new MockHTMLElement(this, "html");
  13751. this.appendChild(documentElement);
  13752. return documentElement;
  13753. }
  13754. set documentElement(documentElement) {
  13755. for (let i = this.childNodes.length - 1; i >= 0; i--) {
  13756. if (this.childNodes[i].nodeType !== 10 /* DOCUMENT_TYPE_NODE */) {
  13757. this.childNodes[i].remove();
  13758. }
  13759. }
  13760. if (documentElement != null) {
  13761. this.appendChild(documentElement);
  13762. setOwnerDocument(documentElement, this);
  13763. }
  13764. }
  13765. get head() {
  13766. const documentElement = this.documentElement;
  13767. for (let i = 0; i < documentElement.childNodes.length; i++) {
  13768. if (documentElement.childNodes[i].nodeName === "HEAD") {
  13769. return documentElement.childNodes[i];
  13770. }
  13771. }
  13772. const head = new MockHTMLElement(this, "head");
  13773. documentElement.insertBefore(head, documentElement.firstChild);
  13774. return head;
  13775. }
  13776. set head(head) {
  13777. const documentElement = this.documentElement;
  13778. for (let i = documentElement.childNodes.length - 1; i >= 0; i--) {
  13779. if (documentElement.childNodes[i].nodeName === "HEAD") {
  13780. documentElement.childNodes[i].remove();
  13781. }
  13782. }
  13783. if (head != null) {
  13784. documentElement.insertBefore(head, documentElement.firstChild);
  13785. setOwnerDocument(head, this);
  13786. }
  13787. }
  13788. get body() {
  13789. const documentElement = this.documentElement;
  13790. for (let i = documentElement.childNodes.length - 1; i >= 0; i--) {
  13791. if (documentElement.childNodes[i].nodeName === "BODY") {
  13792. return documentElement.childNodes[i];
  13793. }
  13794. }
  13795. const body = new MockHTMLElement(this, "body");
  13796. documentElement.appendChild(body);
  13797. return body;
  13798. }
  13799. set body(body) {
  13800. const documentElement = this.documentElement;
  13801. for (let i = documentElement.childNodes.length - 1; i >= 0; i--) {
  13802. if (documentElement.childNodes[i].nodeName === "BODY") {
  13803. documentElement.childNodes[i].remove();
  13804. }
  13805. }
  13806. if (body != null) {
  13807. documentElement.appendChild(body);
  13808. setOwnerDocument(body, this);
  13809. }
  13810. }
  13811. appendChild(newNode) {
  13812. newNode.remove();
  13813. newNode.parentNode = this;
  13814. this.childNodes.push(newNode);
  13815. return newNode;
  13816. }
  13817. createComment(data) {
  13818. return new MockComment(this, data);
  13819. }
  13820. createAttribute(attrName) {
  13821. return new MockAttr(attrName.toLowerCase(), "");
  13822. }
  13823. createAttributeNS(namespaceURI, attrName) {
  13824. return new MockAttr(attrName, "", namespaceURI);
  13825. }
  13826. createElement(tagName) {
  13827. if (tagName === "#document" /* DOCUMENT_NODE */) {
  13828. const doc = new _MockDocument(false);
  13829. doc.nodeName = tagName;
  13830. doc.parentNode = null;
  13831. return doc;
  13832. }
  13833. return createElement(this, tagName);
  13834. }
  13835. createElementNS(namespaceURI, tagName) {
  13836. const elmNs = createElementNS(this, namespaceURI, tagName);
  13837. return elmNs;
  13838. }
  13839. createTextNode(text) {
  13840. return new MockTextNode(this, text);
  13841. }
  13842. createDocumentFragment() {
  13843. return new MockDocumentFragment(this);
  13844. }
  13845. createDocumentTypeNode() {
  13846. return new MockDocumentTypeNode(this);
  13847. }
  13848. getElementById(id) {
  13849. return getElementById(this, id);
  13850. }
  13851. getElementsByName(elmName) {
  13852. return getElementsByName(this, elmName.toLowerCase());
  13853. }
  13854. get title() {
  13855. const title = this.head.childNodes.find((elm) => elm.nodeName === "TITLE");
  13856. if (title != null && typeof title.textContent === "string") {
  13857. return title.textContent.trim();
  13858. }
  13859. return "";
  13860. }
  13861. set title(value) {
  13862. const head = this.head;
  13863. let title = head.childNodes.find((elm) => elm.nodeName === "TITLE");
  13864. if (title == null) {
  13865. title = this.createElement("title");
  13866. head.appendChild(title);
  13867. }
  13868. title.textContent = value;
  13869. }
  13870. };
  13871. function resetDocument(doc) {
  13872. if (doc != null) {
  13873. resetEventListeners(doc);
  13874. const documentElement = doc.documentElement;
  13875. if (documentElement != null) {
  13876. resetElement(documentElement);
  13877. for (let i = 0, ii = documentElement.childNodes.length; i < ii; i++) {
  13878. const childNode = documentElement.childNodes[i];
  13879. resetElement(childNode);
  13880. childNode.childNodes.length = 0;
  13881. }
  13882. }
  13883. for (const key in doc) {
  13884. if (doc.hasOwnProperty(key) && !DOC_KEY_KEEPERS.has(key)) {
  13885. delete doc[key];
  13886. }
  13887. }
  13888. try {
  13889. doc.nodeName = "#document" /* DOCUMENT_NODE */;
  13890. } catch (e) {
  13891. }
  13892. try {
  13893. doc.nodeType = 9 /* DOCUMENT_NODE */;
  13894. } catch (e) {
  13895. }
  13896. try {
  13897. doc.cookie = "";
  13898. } catch (e) {
  13899. }
  13900. try {
  13901. doc.referrer = "";
  13902. } catch (e) {
  13903. }
  13904. }
  13905. }
  13906. var DOC_KEY_KEEPERS = /* @__PURE__ */ new Set([
  13907. "nodeName",
  13908. "nodeType",
  13909. "nodeValue",
  13910. "ownerDocument",
  13911. "parentNode",
  13912. "childNodes",
  13913. "_shadowRoot"
  13914. ]);
  13915. function getElementById(elm, id) {
  13916. const children = elm.children;
  13917. for (let i = 0, ii = children.length; i < ii; i++) {
  13918. const childElm = children[i];
  13919. if (childElm.id === id) {
  13920. return childElm;
  13921. }
  13922. const childElmFound = getElementById(childElm, id);
  13923. if (childElmFound != null) {
  13924. return childElmFound;
  13925. }
  13926. }
  13927. return null;
  13928. }
  13929. function getElementsByName(elm, elmName, foundElms = []) {
  13930. const children = elm.children;
  13931. for (let i = 0, ii = children.length; i < ii; i++) {
  13932. const childElm = children[i];
  13933. if (childElm.name && childElm.name.toLowerCase() === elmName) {
  13934. foundElms.push(childElm);
  13935. }
  13936. getElementsByName(childElm, elmName, foundElms);
  13937. }
  13938. return foundElms;
  13939. }
  13940. function setOwnerDocument(elm, ownerDocument) {
  13941. for (let i = 0, ii = elm.childNodes.length; i < ii; i++) {
  13942. elm.childNodes[i].ownerDocument = ownerDocument;
  13943. if (elm.childNodes[i].nodeType === 1 /* ELEMENT_NODE */) {
  13944. setOwnerDocument(elm.childNodes[i], ownerDocument);
  13945. }
  13946. }
  13947. }
  13948. // src/hydrate/runner/create-window.ts
  13949. var templateWindows = /* @__PURE__ */ new Map();
  13950. function createWindowFromHtml(templateHtml, uniqueId) {
  13951. let templateWindow = templateWindows.get(uniqueId);
  13952. if (templateWindow == null) {
  13953. templateWindow = new MockWindow(templateHtml);
  13954. templateWindows.set(uniqueId, templateWindow);
  13955. }
  13956. const win = cloneWindow(templateWindow);
  13957. return win;
  13958. }
  13959. // src/hydrate/runner/render.ts
  13960. import { Readable } from "stream";
  13961. import { hydrateFactory } from "@stencil/core/hydrate-factory";
  13962. // src/utils/helpers.ts
  13963. var isString = (v) => typeof v === "string";
  13964. // src/utils/message-utils.ts
  13965. var catchError = (diagnostics, err2, msg) => {
  13966. const diagnostic = {
  13967. level: "error",
  13968. type: "build",
  13969. header: "Build Error",
  13970. messageText: "build error",
  13971. lines: []
  13972. };
  13973. if (isString(msg)) {
  13974. diagnostic.messageText = msg.length ? msg : "UNKNOWN ERROR";
  13975. } else if (err2 != null) {
  13976. if (err2.stack != null) {
  13977. diagnostic.messageText = err2.stack.toString();
  13978. } else {
  13979. if (err2.message != null) {
  13980. diagnostic.messageText = err2.message.length ? err2.message : "UNKNOWN ERROR";
  13981. } else {
  13982. diagnostic.messageText = err2.toString();
  13983. }
  13984. }
  13985. }
  13986. if (diagnostics != null && !shouldIgnoreError(diagnostic.messageText)) {
  13987. diagnostics.push(diagnostic);
  13988. }
  13989. return diagnostic;
  13990. };
  13991. var hasError = (diagnostics) => {
  13992. if (diagnostics == null || diagnostics.length === 0) {
  13993. return false;
  13994. }
  13995. return diagnostics.some((d) => d.level === "error" && d.type !== "runtime");
  13996. };
  13997. var shouldIgnoreError = (msg) => {
  13998. return msg === TASK_CANCELED_MSG;
  13999. };
  14000. var TASK_CANCELED_MSG = `task canceled`;
  14001. // src/utils/result.ts
  14002. var result_exports = {};
  14003. __export(result_exports, {
  14004. err: () => err,
  14005. map: () => map,
  14006. ok: () => ok,
  14007. unwrap: () => unwrap,
  14008. unwrapErr: () => unwrapErr
  14009. });
  14010. var ok = (value) => ({
  14011. isOk: true,
  14012. isErr: false,
  14013. value
  14014. });
  14015. var err = (value) => ({
  14016. isOk: false,
  14017. isErr: true,
  14018. value
  14019. });
  14020. function map(result, fn) {
  14021. if (result.isOk) {
  14022. const val = fn(result.value);
  14023. if (val instanceof Promise) {
  14024. return val.then((newVal) => ok(newVal));
  14025. } else {
  14026. return ok(val);
  14027. }
  14028. }
  14029. if (result.isErr) {
  14030. const value = result.value;
  14031. return err(value);
  14032. }
  14033. throw "should never get here";
  14034. }
  14035. var unwrap = (result) => {
  14036. if (result.isOk) {
  14037. return result.value;
  14038. } else {
  14039. throw result.value;
  14040. }
  14041. };
  14042. var unwrapErr = (result) => {
  14043. if (result.isErr) {
  14044. return result.value;
  14045. } else {
  14046. throw result.value;
  14047. }
  14048. };
  14049. // src/compiler/html/canonical-link.ts
  14050. var updateCanonicalLink = (doc, href) => {
  14051. var _a2;
  14052. let canonicalLinkElm = doc.head.querySelector('link[rel="canonical"]');
  14053. if (typeof href === "string") {
  14054. if (canonicalLinkElm == null) {
  14055. canonicalLinkElm = doc.createElement("link");
  14056. canonicalLinkElm.setAttribute("rel", "canonical");
  14057. doc.head.appendChild(canonicalLinkElm);
  14058. }
  14059. canonicalLinkElm.setAttribute("href", href);
  14060. } else {
  14061. if (canonicalLinkElm != null) {
  14062. const existingHref = canonicalLinkElm.getAttribute("href");
  14063. if (!existingHref) {
  14064. (_a2 = canonicalLinkElm.parentNode) == null ? void 0 : _a2.removeChild(canonicalLinkElm);
  14065. }
  14066. }
  14067. }
  14068. };
  14069. // src/compiler/html/relocate-meta-charset.ts
  14070. var relocateMetaCharset = (doc) => {
  14071. const head = doc.head;
  14072. let charsetElm = head.querySelector("meta[charset]");
  14073. if (charsetElm == null) {
  14074. charsetElm = doc.createElement("meta");
  14075. charsetElm.setAttribute("charset", "utf-8");
  14076. } else {
  14077. charsetElm.remove();
  14078. }
  14079. head.insertBefore(charsetElm, head.firstChild);
  14080. };
  14081. // src/compiler/style/css-parser/parse-css.ts
  14082. var parseCss = (css, filePath) => {
  14083. let lineno = 1;
  14084. let column = 1;
  14085. const diagnostics = [];
  14086. const updatePosition = (str) => {
  14087. const lines = str.match(/\n/g);
  14088. if (lines) lineno += lines.length;
  14089. const i = str.lastIndexOf("\n");
  14090. column = ~i ? str.length - i : column + str.length;
  14091. };
  14092. const position = () => {
  14093. const start = { line: lineno, column };
  14094. return (node) => {
  14095. node.position = new ParsePosition(start);
  14096. whitespace();
  14097. return node;
  14098. };
  14099. };
  14100. const error = (msg) => {
  14101. const srcLines = css.split("\n");
  14102. const d = {
  14103. level: "error",
  14104. type: "css",
  14105. language: "css",
  14106. header: "CSS Parse",
  14107. messageText: msg,
  14108. absFilePath: filePath,
  14109. lines: [
  14110. {
  14111. lineIndex: lineno - 1,
  14112. lineNumber: lineno,
  14113. errorCharStart: column,
  14114. text: css[lineno - 1]
  14115. }
  14116. ]
  14117. };
  14118. if (lineno > 1) {
  14119. const previousLine = {
  14120. lineIndex: lineno - 1,
  14121. lineNumber: lineno - 1,
  14122. text: css[lineno - 2],
  14123. errorCharStart: -1,
  14124. errorLength: -1
  14125. };
  14126. d.lines.unshift(previousLine);
  14127. }
  14128. if (lineno + 2 < srcLines.length) {
  14129. const nextLine = {
  14130. lineIndex: lineno,
  14131. lineNumber: lineno + 1,
  14132. text: srcLines[lineno],
  14133. errorCharStart: -1,
  14134. errorLength: -1
  14135. };
  14136. d.lines.push(nextLine);
  14137. }
  14138. diagnostics.push(d);
  14139. return null;
  14140. };
  14141. const stylesheet = () => {
  14142. const rulesList = rules();
  14143. return {
  14144. type: 14 /* StyleSheet */,
  14145. stylesheet: {
  14146. source: filePath,
  14147. rules: rulesList
  14148. }
  14149. };
  14150. };
  14151. const open = () => match(/^{\s*/);
  14152. const close = () => match(/^}/);
  14153. const match = (re) => {
  14154. const m = re.exec(css);
  14155. if (!m) return;
  14156. const str = m[0];
  14157. updatePosition(str);
  14158. css = css.slice(str.length);
  14159. return m;
  14160. };
  14161. const rules = () => {
  14162. let node;
  14163. const rules2 = [];
  14164. whitespace();
  14165. comments(rules2);
  14166. while (css.length && css.charAt(0) !== "}" && (node = atrule() || rule())) {
  14167. rules2.push(node);
  14168. comments(rules2);
  14169. }
  14170. return rules2;
  14171. };
  14172. const whitespace = () => match(/^\s*/);
  14173. const comments = (rules2) => {
  14174. let c;
  14175. rules2 = rules2 || [];
  14176. while (c = comment()) {
  14177. rules2.push(c);
  14178. }
  14179. return rules2;
  14180. };
  14181. const comment = () => {
  14182. const pos = position();
  14183. if ("/" !== css.charAt(0) || "*" !== css.charAt(1)) return null;
  14184. let i = 2;
  14185. while ("" !== css.charAt(i) && ("*" !== css.charAt(i) || "/" !== css.charAt(i + 1))) ++i;
  14186. i += 2;
  14187. if ("" === css.charAt(i - 1)) {
  14188. return error("End of comment missing");
  14189. }
  14190. const comment2 = css.slice(2, i - 2);
  14191. column += 2;
  14192. updatePosition(comment2);
  14193. css = css.slice(i);
  14194. column += 2;
  14195. return pos({
  14196. type: 1 /* Comment */,
  14197. comment: comment2
  14198. });
  14199. };
  14200. const selector = () => {
  14201. const m = match(/^([^{]+)/);
  14202. if (!m) return null;
  14203. return trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, "").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function(m2) {
  14204. return m2.replace(/,/g, "\u200C");
  14205. }).split(/\s*(?![^(]*\)),\s*/).map(function(s) {
  14206. return s.replace(/\u200C/g, ",");
  14207. });
  14208. };
  14209. const declaration = () => {
  14210. const pos = position();
  14211. let prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
  14212. if (!prop) return null;
  14213. prop = trim(prop[0]);
  14214. if (!match(/^:\s*/)) return error(`property missing ':'`);
  14215. const val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
  14216. const ret = pos({
  14217. type: 4 /* Declaration */,
  14218. property: prop.replace(commentre, ""),
  14219. value: val ? trim(val[0]).replace(commentre, "") : ""
  14220. });
  14221. match(/^[;\s]*/);
  14222. return ret;
  14223. };
  14224. const declarations = () => {
  14225. const decls = [];
  14226. if (!open()) return error(`missing '{'`);
  14227. comments(decls);
  14228. let decl;
  14229. while (decl = declaration()) {
  14230. decls.push(decl);
  14231. comments(decls);
  14232. }
  14233. if (!close()) return error(`missing '}'`);
  14234. return decls;
  14235. };
  14236. const keyframe = () => {
  14237. let m;
  14238. const values = [];
  14239. const pos = position();
  14240. while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) {
  14241. values.push(m[1]);
  14242. match(/^,\s*/);
  14243. }
  14244. if (!values.length) return null;
  14245. return pos({
  14246. type: 9 /* KeyFrame */,
  14247. values,
  14248. declarations: declarations()
  14249. });
  14250. };
  14251. const atkeyframes = () => {
  14252. const pos = position();
  14253. let m = match(/^@([-\w]+)?keyframes\s*/);
  14254. if (!m) return null;
  14255. const vendor = m[1];
  14256. m = match(/^([-\w]+)\s*/);
  14257. if (!m) return error(`@keyframes missing name`);
  14258. const name = m[1];
  14259. if (!open()) return error(`@keyframes missing '{'`);
  14260. let frame;
  14261. let frames = comments();
  14262. while (frame = keyframe()) {
  14263. frames.push(frame);
  14264. frames = frames.concat(comments());
  14265. }
  14266. if (!close()) return error(`@keyframes missing '}'`);
  14267. return pos({
  14268. type: 8 /* KeyFrames */,
  14269. name,
  14270. vendor,
  14271. keyframes: frames
  14272. });
  14273. };
  14274. const atsupports = () => {
  14275. const pos = position();
  14276. const m = match(/^@supports *([^{]+)/);
  14277. if (!m) return null;
  14278. const supports = trim(m[1]);
  14279. if (!open()) return error(`@supports missing '{'`);
  14280. const style = comments().concat(rules());
  14281. if (!close()) return error(`@supports missing '}'`);
  14282. return pos({
  14283. type: 15 /* Supports */,
  14284. supports,
  14285. rules: style
  14286. });
  14287. };
  14288. const athost = () => {
  14289. const pos = position();
  14290. const m = match(/^@host\s*/);
  14291. if (!m) return null;
  14292. if (!open()) return error(`@host missing '{'`);
  14293. const style = comments().concat(rules());
  14294. if (!close()) return error(`@host missing '}'`);
  14295. return pos({
  14296. type: 6 /* Host */,
  14297. rules: style
  14298. });
  14299. };
  14300. const atmedia = () => {
  14301. const pos = position();
  14302. const m = match(/^@media *([^{]+)/);
  14303. if (!m) return null;
  14304. const media = trim(m[1]);
  14305. if (!open()) return error(`@media missing '{'`);
  14306. const style = comments().concat(rules());
  14307. if (!close()) return error(`@media missing '}'`);
  14308. return pos({
  14309. type: 10 /* Media */,
  14310. media,
  14311. rules: style
  14312. });
  14313. };
  14314. const atcustommedia = () => {
  14315. const pos = position();
  14316. const m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
  14317. if (!m) return null;
  14318. return pos({
  14319. type: 2 /* CustomMedia */,
  14320. name: trim(m[1]),
  14321. media: trim(m[2])
  14322. });
  14323. };
  14324. const atpage = () => {
  14325. const pos = position();
  14326. const m = match(/^@page */);
  14327. if (!m) return null;
  14328. const sel = selector() || [];
  14329. if (!open()) return error(`@page missing '{'`);
  14330. let decls = comments();
  14331. let decl;
  14332. while (decl = declaration()) {
  14333. decls.push(decl);
  14334. decls = decls.concat(comments());
  14335. }
  14336. if (!close()) return error(`@page missing '}'`);
  14337. return pos({
  14338. type: 12 /* Page */,
  14339. selectors: sel,
  14340. declarations: decls
  14341. });
  14342. };
  14343. const atdocument = () => {
  14344. const pos = position();
  14345. const m = match(/^@([-\w]+)?document *([^{]+)/);
  14346. if (!m) return null;
  14347. const vendor = trim(m[1]);
  14348. const doc = trim(m[2]);
  14349. if (!open()) return error(`@document missing '{'`);
  14350. const style = comments().concat(rules());
  14351. if (!close()) return error(`@document missing '}'`);
  14352. return pos({
  14353. type: 3 /* Document */,
  14354. document: doc,
  14355. vendor,
  14356. rules: style
  14357. });
  14358. };
  14359. const atfontface = () => {
  14360. const pos = position();
  14361. const m = match(/^@font-face\s*/);
  14362. if (!m) return null;
  14363. if (!open()) return error(`@font-face missing '{'`);
  14364. let decls = comments();
  14365. let decl;
  14366. while (decl = declaration()) {
  14367. decls.push(decl);
  14368. decls = decls.concat(comments());
  14369. }
  14370. if (!close()) return error(`@font-face missing '}'`);
  14371. return pos({
  14372. type: 5 /* FontFace */,
  14373. declarations: decls
  14374. });
  14375. };
  14376. const compileAtrule = (nodeName, nodeType) => {
  14377. const re = new RegExp("^@" + nodeName + "\\s*([^;]+);");
  14378. return () => {
  14379. const pos = position();
  14380. const m = match(re);
  14381. if (!m) return null;
  14382. const node = {
  14383. type: nodeType
  14384. };
  14385. node[nodeName] = m[1].trim();
  14386. return pos(node);
  14387. };
  14388. };
  14389. const atimport = compileAtrule("import", 7 /* Import */);
  14390. const atcharset = compileAtrule("charset", 0 /* Charset */);
  14391. const atnamespace = compileAtrule("namespace", 11 /* Namespace */);
  14392. const atrule = () => {
  14393. if (css[0] !== "@") return null;
  14394. return atkeyframes() || atmedia() || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface();
  14395. };
  14396. const rule = () => {
  14397. const pos = position();
  14398. const sel = selector();
  14399. if (!sel) return error("selector missing");
  14400. comments();
  14401. return pos({
  14402. type: 13 /* Rule */,
  14403. selectors: sel,
  14404. declarations: declarations()
  14405. });
  14406. };
  14407. class ParsePosition {
  14408. constructor(start) {
  14409. this.start = start;
  14410. this.end = { line: lineno, column };
  14411. this.source = filePath;
  14412. }
  14413. }
  14414. ParsePosition.prototype.content = css;
  14415. return {
  14416. diagnostics,
  14417. ...addParent(stylesheet())
  14418. };
  14419. };
  14420. var trim = (str) => str ? str.trim() : "";
  14421. var addParent = (obj, parent) => {
  14422. const isNode = obj && typeof obj.type === "string";
  14423. const childParent = isNode ? obj : parent;
  14424. for (const k in obj) {
  14425. const value = obj[k];
  14426. if (Array.isArray(value)) {
  14427. value.forEach(function(v) {
  14428. addParent(v, childParent);
  14429. });
  14430. } else if (value && typeof value === "object") {
  14431. addParent(value, childParent);
  14432. }
  14433. }
  14434. if (isNode) {
  14435. Object.defineProperty(obj, "parent", {
  14436. configurable: true,
  14437. writable: true,
  14438. enumerable: false,
  14439. value: parent || null
  14440. });
  14441. }
  14442. return obj;
  14443. };
  14444. var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
  14445. // src/compiler/style/css-parser/get-css-selectors.ts
  14446. var getCssSelectors = (sel) => {
  14447. SELECTORS.all.length = SELECTORS.tags.length = SELECTORS.classNames.length = SELECTORS.ids.length = SELECTORS.attrs.length = 0;
  14448. sel = sel.replace(/\./g, " .").replace(/\#/g, " #").replace(/\[/g, " [").replace(/\>/g, " > ").replace(/\+/g, " + ").replace(/\~/g, " ~ ").replace(/\*/g, " * ").replace(/\:not\((.*?)\)/g, " ");
  14449. const items = sel.split(" ");
  14450. for (let i = 0, l = items.length; i < l; i++) {
  14451. items[i] = items[i].split(":")[0];
  14452. if (items[i].length === 0) continue;
  14453. if (items[i].charAt(0) === ".") {
  14454. SELECTORS.classNames.push(items[i].slice(1));
  14455. } else if (items[i].charAt(0) === "#") {
  14456. SELECTORS.ids.push(items[i].slice(1));
  14457. } else if (items[i].charAt(0) === "[") {
  14458. items[i] = items[i].slice(1).split("=")[0].split("]")[0].trim();
  14459. SELECTORS.attrs.push(items[i].toLowerCase());
  14460. } else if (/[a-z]/g.test(items[i].charAt(0))) {
  14461. SELECTORS.tags.push(items[i].toLowerCase());
  14462. }
  14463. }
  14464. SELECTORS.classNames = SELECTORS.classNames.sort((a, b) => {
  14465. if (a.length < b.length) return -1;
  14466. if (a.length > b.length) return 1;
  14467. return 0;
  14468. });
  14469. return SELECTORS;
  14470. };
  14471. var SELECTORS = {
  14472. all: [],
  14473. tags: [],
  14474. classNames: [],
  14475. ids: [],
  14476. attrs: []
  14477. };
  14478. // src/compiler/style/css-parser/serialize-css.ts
  14479. var serializeCss = (stylesheet, serializeOpts) => {
  14480. const usedSelectors = serializeOpts.usedSelectors || null;
  14481. const opts = {
  14482. usedSelectors: usedSelectors || null,
  14483. hasUsedAttrs: !!usedSelectors && usedSelectors.attrs.size > 0,
  14484. hasUsedClassNames: !!usedSelectors && usedSelectors.classNames.size > 0,
  14485. hasUsedIds: !!usedSelectors && usedSelectors.ids.size > 0,
  14486. hasUsedTags: !!usedSelectors && usedSelectors.tags.size > 0
  14487. };
  14488. const rules = stylesheet.rules;
  14489. if (!rules) {
  14490. return "";
  14491. }
  14492. const rulesLen = rules.length;
  14493. const out = [];
  14494. for (let i = 0; i < rulesLen; i++) {
  14495. out.push(serializeCssVisitNode(opts, rules[i], i, rulesLen));
  14496. }
  14497. return out.join("");
  14498. };
  14499. var serializeCssVisitNode = (opts, node, index, len) => {
  14500. var _a2;
  14501. const nodeType = node.type;
  14502. if (nodeType === 4 /* Declaration */) {
  14503. return serializeCssDeclaration(node, index, len);
  14504. }
  14505. if (nodeType === 13 /* Rule */) {
  14506. return serializeCssRule(opts, node);
  14507. }
  14508. if (nodeType === 1 /* Comment */) {
  14509. if (((_a2 = node.comment) == null ? void 0 : _a2[0]) === "!") {
  14510. return `/*${node.comment}*/`;
  14511. } else {
  14512. return "";
  14513. }
  14514. }
  14515. if (nodeType === 10 /* Media */) {
  14516. return serializeCssMedia(opts, node);
  14517. }
  14518. if (nodeType === 8 /* KeyFrames */) {
  14519. return serializeCssKeyframes(opts, node);
  14520. }
  14521. if (nodeType === 9 /* KeyFrame */) {
  14522. return serializeCssKeyframe(opts, node);
  14523. }
  14524. if (nodeType === 5 /* FontFace */) {
  14525. return serializeCssFontFace(opts, node);
  14526. }
  14527. if (nodeType === 15 /* Supports */) {
  14528. return serializeCssSupports(opts, node);
  14529. }
  14530. if (nodeType === 7 /* Import */) {
  14531. return "@import " + node.import + ";";
  14532. }
  14533. if (nodeType === 0 /* Charset */) {
  14534. return "@charset " + node.charset + ";";
  14535. }
  14536. if (nodeType === 12 /* Page */) {
  14537. return serializeCssPage(opts, node);
  14538. }
  14539. if (nodeType === 6 /* Host */) {
  14540. return "@host{" + serializeCssMapVisit(opts, node.rules) + "}";
  14541. }
  14542. if (nodeType === 2 /* CustomMedia */) {
  14543. return "@custom-media " + node.name + " " + node.media + ";";
  14544. }
  14545. if (nodeType === 3 /* Document */) {
  14546. return serializeCssDocument(opts, node);
  14547. }
  14548. if (nodeType === 11 /* Namespace */) {
  14549. return "@namespace " + node.namespace + ";";
  14550. }
  14551. return "";
  14552. };
  14553. var serializeCssRule = (opts, node) => {
  14554. var _a2, _b;
  14555. const decls = node.declarations;
  14556. const usedSelectors = opts.usedSelectors;
  14557. const selectors = (_b = (_a2 = node.selectors) == null ? void 0 : _a2.slice()) != null ? _b : [];
  14558. if (decls == null || decls.length === 0) {
  14559. return "";
  14560. }
  14561. if (usedSelectors) {
  14562. let i;
  14563. let j;
  14564. let include = true;
  14565. for (i = selectors.length - 1; i >= 0; i--) {
  14566. const sel = getCssSelectors(selectors[i]);
  14567. include = true;
  14568. let jlen = sel.classNames.length;
  14569. if (jlen > 0 && opts.hasUsedClassNames) {
  14570. for (j = 0; j < jlen; j++) {
  14571. if (!usedSelectors.classNames.has(sel.classNames[j])) {
  14572. include = false;
  14573. break;
  14574. }
  14575. }
  14576. }
  14577. if (include && opts.hasUsedTags) {
  14578. jlen = sel.tags.length;
  14579. if (jlen > 0) {
  14580. for (j = 0; j < jlen; j++) {
  14581. if (!usedSelectors.tags.has(sel.tags[j])) {
  14582. include = false;
  14583. break;
  14584. }
  14585. }
  14586. }
  14587. }
  14588. if (include && opts.hasUsedAttrs) {
  14589. jlen = sel.attrs.length;
  14590. if (jlen > 0) {
  14591. for (j = 0; j < jlen; j++) {
  14592. if (!usedSelectors.attrs.has(sel.attrs[j])) {
  14593. include = false;
  14594. break;
  14595. }
  14596. }
  14597. }
  14598. }
  14599. if (include && opts.hasUsedIds) {
  14600. jlen = sel.ids.length;
  14601. if (jlen > 0) {
  14602. for (j = 0; j < jlen; j++) {
  14603. if (!usedSelectors.ids.has(sel.ids[j])) {
  14604. include = false;
  14605. break;
  14606. }
  14607. }
  14608. }
  14609. }
  14610. if (!include) {
  14611. selectors.splice(i, 1);
  14612. }
  14613. }
  14614. }
  14615. if (selectors.length === 0) {
  14616. return "";
  14617. }
  14618. const cleanedSelectors = [];
  14619. let cleanedSelector = "";
  14620. if (node.selectors) {
  14621. for (const selector of node.selectors) {
  14622. cleanedSelector = removeSelectorWhitespace(selector);
  14623. if (!cleanedSelectors.includes(cleanedSelector)) {
  14624. cleanedSelectors.push(cleanedSelector);
  14625. }
  14626. }
  14627. }
  14628. return `${cleanedSelectors}{${serializeCssMapVisit(opts, decls)}}`;
  14629. };
  14630. var serializeCssDeclaration = (node, index, len) => {
  14631. if (node.value === "") {
  14632. return "";
  14633. }
  14634. if (len - 1 === index) {
  14635. return node.property + ":" + node.value;
  14636. }
  14637. return node.property + ":" + node.value + ";";
  14638. };
  14639. var serializeCssMedia = (opts, node) => {
  14640. const mediaCss = serializeCssMapVisit(opts, node.rules);
  14641. if (mediaCss === "") {
  14642. return "";
  14643. }
  14644. return "@media " + removeMediaWhitespace(node.media) + "{" + mediaCss + "}";
  14645. };
  14646. var serializeCssKeyframes = (opts, node) => {
  14647. const keyframesCss = serializeCssMapVisit(opts, node.keyframes);
  14648. if (keyframesCss === "") {
  14649. return "";
  14650. }
  14651. return "@" + (node.vendor || "") + "keyframes " + node.name + "{" + keyframesCss + "}";
  14652. };
  14653. var serializeCssKeyframe = (opts, node) => {
  14654. var _a2, _b;
  14655. return ((_b = (_a2 = node.values) == null ? void 0 : _a2.join(",")) != null ? _b : "") + "{" + serializeCssMapVisit(opts, node.declarations) + "}";
  14656. };
  14657. var serializeCssFontFace = (opts, node) => {
  14658. const fontCss = serializeCssMapVisit(opts, node.declarations);
  14659. if (fontCss === "") {
  14660. return "";
  14661. }
  14662. return "@font-face{" + fontCss + "}";
  14663. };
  14664. var serializeCssSupports = (opts, node) => {
  14665. const supportsCss = serializeCssMapVisit(opts, node.rules);
  14666. if (supportsCss === "") {
  14667. return "";
  14668. }
  14669. return "@supports " + node.supports + "{" + supportsCss + "}";
  14670. };
  14671. var serializeCssPage = (opts, node) => {
  14672. var _a2, _b;
  14673. const sel = (_b = (_a2 = node.selectors) == null ? void 0 : _a2.join(", ")) != null ? _b : "";
  14674. return "@page " + sel + "{" + serializeCssMapVisit(opts, node.declarations) + "}";
  14675. };
  14676. var serializeCssDocument = (opts, node) => {
  14677. const documentCss = serializeCssMapVisit(opts, node.rules);
  14678. const doc = "@" + (node.vendor || "") + "document " + node.document;
  14679. if (documentCss === "") {
  14680. return "";
  14681. }
  14682. return doc + "{" + documentCss + "}";
  14683. };
  14684. var serializeCssMapVisit = (opts, nodes) => {
  14685. let rtn = "";
  14686. if (nodes) {
  14687. for (let i = 0, len = nodes.length; i < len; i++) {
  14688. rtn += serializeCssVisitNode(opts, nodes[i], i, len);
  14689. }
  14690. }
  14691. return rtn;
  14692. };
  14693. var removeSelectorWhitespace = (selector) => {
  14694. let rtn = "";
  14695. let char = "";
  14696. let inAttr = false;
  14697. selector = selector.trim();
  14698. for (let i = 0, l = selector.length; i < l; i++) {
  14699. char = selector[i];
  14700. if (char === "[" && rtn[rtn.length - 1] !== "\\") {
  14701. inAttr = true;
  14702. } else if (char === "]" && rtn[rtn.length - 1] !== "\\") {
  14703. inAttr = false;
  14704. }
  14705. if (!inAttr && CSS_WS_REG.test(char)) {
  14706. if (CSS_NEXT_CHAR_REG.test(selector[i + 1])) {
  14707. continue;
  14708. }
  14709. if (CSS_PREV_CHAR_REG.test(rtn[rtn.length - 1])) {
  14710. continue;
  14711. }
  14712. rtn += " ";
  14713. } else {
  14714. rtn += char;
  14715. }
  14716. }
  14717. return rtn;
  14718. };
  14719. var removeMediaWhitespace = (media) => {
  14720. var _a2;
  14721. let rtn = "";
  14722. let char = "";
  14723. media = (_a2 = media == null ? void 0 : media.trim()) != null ? _a2 : "";
  14724. for (let i = 0, l = media.length; i < l; i++) {
  14725. char = media[i];
  14726. if (CSS_WS_REG.test(char)) {
  14727. if (CSS_WS_REG.test(rtn[rtn.length - 1])) {
  14728. continue;
  14729. }
  14730. rtn += " ";
  14731. } else {
  14732. rtn += char;
  14733. }
  14734. }
  14735. return rtn;
  14736. };
  14737. var CSS_WS_REG = /\s/;
  14738. var CSS_NEXT_CHAR_REG = /[>\(\)\~\,\+\s]/;
  14739. var CSS_PREV_CHAR_REG = /[>\(\~\,\+]/;
  14740. // src/compiler/style/css-parser/used-selectors.ts
  14741. var getUsedSelectors = (elm) => {
  14742. const usedSelectors = {
  14743. attrs: /* @__PURE__ */ new Set(),
  14744. classNames: /* @__PURE__ */ new Set(),
  14745. ids: /* @__PURE__ */ new Set(),
  14746. tags: /* @__PURE__ */ new Set()
  14747. };
  14748. collectUsedSelectors(usedSelectors, elm);
  14749. return usedSelectors;
  14750. };
  14751. var collectUsedSelectors = (usedSelectors, elm) => {
  14752. if (elm != null && elm.nodeType === 1) {
  14753. const children = elm.children;
  14754. const tagName = elm.nodeName.toLowerCase();
  14755. usedSelectors.tags.add(tagName);
  14756. const attributes = elm.attributes;
  14757. for (let i = 0, l = attributes.length; i < l; i++) {
  14758. const attr = attributes.item(i);
  14759. const attrName = attr.name.toLowerCase();
  14760. usedSelectors.attrs.add(attrName);
  14761. if (attrName === "class") {
  14762. const classList = elm.classList;
  14763. for (let i2 = 0, l2 = classList.length; i2 < l2; i2++) {
  14764. usedSelectors.classNames.add(classList.item(i2));
  14765. }
  14766. } else if (attrName === "id") {
  14767. usedSelectors.ids.add(attr.value);
  14768. }
  14769. }
  14770. if (children) {
  14771. for (let i = 0, l = children.length; i < l; i++) {
  14772. collectUsedSelectors(usedSelectors, children[i]);
  14773. }
  14774. }
  14775. }
  14776. };
  14777. // src/compiler/html/remove-unused-styles.ts
  14778. var removeUnusedStyles = (doc, diagnostics) => {
  14779. try {
  14780. const styleElms = doc.head.querySelectorAll(`style[data-styles]`);
  14781. const styleLen = styleElms.length;
  14782. if (styleLen > 0) {
  14783. const usedSelectors = getUsedSelectors(doc.documentElement);
  14784. for (let i = 0; i < styleLen; i++) {
  14785. removeUnusedStyleText(usedSelectors, diagnostics, styleElms[i]);
  14786. }
  14787. }
  14788. } catch (e) {
  14789. catchError(diagnostics, e);
  14790. }
  14791. };
  14792. var removeUnusedStyleText = (usedSelectors, diagnostics, styleElm) => {
  14793. try {
  14794. const parseResults = parseCss(styleElm.innerHTML);
  14795. diagnostics.push(...parseResults.diagnostics);
  14796. if (hasError(diagnostics)) {
  14797. return;
  14798. }
  14799. try {
  14800. styleElm.innerHTML = serializeCss(parseResults.stylesheet, {
  14801. usedSelectors
  14802. });
  14803. } catch (e) {
  14804. diagnostics.push({
  14805. level: "warn",
  14806. type: "css",
  14807. header: "CSS Stringify",
  14808. messageText: e,
  14809. lines: []
  14810. });
  14811. }
  14812. } catch (e) {
  14813. diagnostics.push({
  14814. level: "warn",
  14815. type: "css",
  14816. header: "CSS Parse",
  14817. messageText: e,
  14818. lines: []
  14819. });
  14820. }
  14821. };
  14822. // src/hydrate/runner/inspect-element.ts
  14823. function inspectElement(results, elm, depth) {
  14824. const children = [...Array.from(elm.children), ...Array.from(elm.shadowRoot ? elm.shadowRoot.children : [])];
  14825. for (let i = 0, ii = children.length; i < ii; i++) {
  14826. const childElm = children[i];
  14827. const tagName = childElm.nodeName.toLowerCase();
  14828. if (tagName.includes("-")) {
  14829. const cmp = results.components.find((c) => c.tag === tagName);
  14830. if (cmp != null) {
  14831. cmp.count++;
  14832. if (depth > cmp.depth) {
  14833. cmp.depth = depth;
  14834. }
  14835. }
  14836. } else {
  14837. switch (tagName) {
  14838. case "a":
  14839. const anchor = collectAttributes(childElm);
  14840. anchor.href = childElm.href;
  14841. if (typeof anchor.href === "string") {
  14842. if (!results.anchors.some((a) => a.href === anchor.href)) {
  14843. results.anchors.push(anchor);
  14844. }
  14845. }
  14846. break;
  14847. case "img":
  14848. const img = collectAttributes(childElm);
  14849. img.src = childElm.src;
  14850. if (typeof img.src === "string") {
  14851. if (!results.imgs.some((a) => a.src === img.src)) {
  14852. results.imgs.push(img);
  14853. }
  14854. }
  14855. break;
  14856. case "link":
  14857. const link = collectAttributes(childElm);
  14858. link.href = childElm.href;
  14859. if (typeof link.rel === "string" && link.rel.toLowerCase() === "stylesheet") {
  14860. if (typeof link.href === "string") {
  14861. if (!results.styles.some((s) => s.link === link.href)) {
  14862. delete link.rel;
  14863. delete link.type;
  14864. results.styles.push(link);
  14865. }
  14866. }
  14867. }
  14868. break;
  14869. case "script":
  14870. const script = collectAttributes(childElm);
  14871. if (childElm.hasAttribute("src")) {
  14872. script.src = childElm.src;
  14873. if (typeof script.src === "string") {
  14874. if (!results.scripts.some((s) => s.src === script.src)) {
  14875. results.scripts.push(script);
  14876. }
  14877. }
  14878. } else {
  14879. const staticDataKey = childElm.getAttribute("data-stencil-static");
  14880. if (staticDataKey) {
  14881. results.staticData.push({
  14882. id: staticDataKey,
  14883. type: childElm.getAttribute("type"),
  14884. content: childElm.textContent
  14885. });
  14886. }
  14887. }
  14888. break;
  14889. }
  14890. }
  14891. depth++;
  14892. inspectElement(results, childElm, depth);
  14893. }
  14894. }
  14895. function collectAttributes(node) {
  14896. const parsedElm = {};
  14897. const attrs = node.attributes;
  14898. for (let i = 0, ii = attrs.length; i < ii; i++) {
  14899. const attr = attrs.item(i);
  14900. const attrName = attr.nodeName.toLowerCase();
  14901. if (SKIP_ATTRS.has(attrName)) {
  14902. continue;
  14903. }
  14904. const attrValue = attr.nodeValue;
  14905. if (attrName === "class" && attrValue === "") {
  14906. continue;
  14907. }
  14908. parsedElm[attrName] = attrValue;
  14909. }
  14910. return parsedElm;
  14911. }
  14912. var SKIP_ATTRS = /* @__PURE__ */ new Set(["s-id", "c-id"]);
  14913. // src/hydrate/runner/patch-dom-implementation.ts
  14914. function patchDomImplementation(doc, opts) {
  14915. let win;
  14916. if (doc.defaultView != null) {
  14917. opts.destroyWindow = true;
  14918. patchWindow(doc.defaultView);
  14919. win = doc.defaultView;
  14920. } else {
  14921. opts.destroyWindow = true;
  14922. opts.destroyDocument = false;
  14923. win = new MockWindow(false);
  14924. }
  14925. if (win.document !== doc) {
  14926. win.document = doc;
  14927. }
  14928. if (doc.defaultView !== win) {
  14929. doc.defaultView = win;
  14930. }
  14931. const HTMLElement = doc.documentElement.constructor.prototype;
  14932. if (typeof HTMLElement.getRootNode !== "function") {
  14933. const elm = doc.createElement("unknown-element");
  14934. const HTMLUnknownElement = elm.constructor.prototype;
  14935. HTMLUnknownElement.getRootNode = getRootNode;
  14936. }
  14937. if (typeof doc.createEvent === "function") {
  14938. const CustomEvent = doc.createEvent("CustomEvent").constructor;
  14939. if (win.CustomEvent !== CustomEvent) {
  14940. win.CustomEvent = CustomEvent;
  14941. }
  14942. }
  14943. try {
  14944. win.__stencil_baseURI = doc.baseURI;
  14945. } catch (e) {
  14946. Object.defineProperty(doc, "baseURI", {
  14947. get() {
  14948. const baseElm = doc.querySelector("base[href]");
  14949. if (baseElm) {
  14950. return new URL(baseElm.getAttribute("href"), win.location.href).href;
  14951. }
  14952. return win.location.href;
  14953. }
  14954. });
  14955. }
  14956. return win;
  14957. }
  14958. function getRootNode(opts) {
  14959. const isComposed = opts != null && opts.composed === true;
  14960. let node = this;
  14961. while (node.parentNode != null) {
  14962. node = node.parentNode;
  14963. if (isComposed === true && node.parentNode == null && node.host != null) {
  14964. node = node.host;
  14965. }
  14966. }
  14967. return node;
  14968. }
  14969. // src/hydrate/runner/render-utils.ts
  14970. function normalizeHydrateOptions(inputOpts) {
  14971. const outputOpts = Object.assign(
  14972. {
  14973. serializeToHtml: false,
  14974. destroyWindow: false,
  14975. destroyDocument: false
  14976. },
  14977. inputOpts || {}
  14978. );
  14979. if (typeof outputOpts.clientHydrateAnnotations !== "boolean") {
  14980. outputOpts.clientHydrateAnnotations = true;
  14981. }
  14982. if (typeof outputOpts.constrainTimeouts !== "boolean") {
  14983. outputOpts.constrainTimeouts = true;
  14984. }
  14985. if (typeof outputOpts.maxHydrateCount !== "number") {
  14986. outputOpts.maxHydrateCount = 300;
  14987. }
  14988. if (typeof outputOpts.runtimeLogging !== "boolean") {
  14989. outputOpts.runtimeLogging = false;
  14990. }
  14991. if (typeof outputOpts.timeout !== "number") {
  14992. outputOpts.timeout = 15e3;
  14993. }
  14994. if (Array.isArray(outputOpts.excludeComponents)) {
  14995. outputOpts.excludeComponents = outputOpts.excludeComponents.filter(filterValidTags).map(mapValidTags);
  14996. } else {
  14997. outputOpts.excludeComponents = [];
  14998. }
  14999. if (Array.isArray(outputOpts.staticComponents)) {
  15000. outputOpts.staticComponents = outputOpts.staticComponents.filter(filterValidTags).map(mapValidTags);
  15001. } else {
  15002. outputOpts.staticComponents = [];
  15003. }
  15004. return outputOpts;
  15005. }
  15006. function filterValidTags(tag) {
  15007. return typeof tag === "string" && tag.includes("-");
  15008. }
  15009. function mapValidTags(tag) {
  15010. return tag.trim().toLowerCase();
  15011. }
  15012. function generateHydrateResults(opts) {
  15013. if (typeof opts.url !== "string") {
  15014. opts.url = `https://hydrate.stenciljs.com/`;
  15015. }
  15016. if (typeof opts.buildId !== "string") {
  15017. opts.buildId = createHydrateBuildId();
  15018. }
  15019. const results = {
  15020. buildId: opts.buildId,
  15021. diagnostics: [],
  15022. url: opts.url,
  15023. host: null,
  15024. hostname: null,
  15025. href: null,
  15026. pathname: null,
  15027. port: null,
  15028. search: null,
  15029. hash: null,
  15030. html: null,
  15031. httpStatus: null,
  15032. hydratedCount: 0,
  15033. anchors: [],
  15034. components: [],
  15035. imgs: [],
  15036. scripts: [],
  15037. staticData: [],
  15038. styles: [],
  15039. title: null
  15040. };
  15041. try {
  15042. const url = new URL(opts.url, `https://hydrate.stenciljs.com/`);
  15043. results.url = url.href;
  15044. results.host = url.host;
  15045. results.hostname = url.hostname;
  15046. results.href = url.href;
  15047. results.port = url.port;
  15048. results.pathname = url.pathname;
  15049. results.search = url.search;
  15050. results.hash = url.hash;
  15051. } catch (e) {
  15052. renderCatchError(results, e);
  15053. }
  15054. return results;
  15055. }
  15056. var createHydrateBuildId = () => {
  15057. let chars = "abcdefghijklmnopqrstuvwxyz";
  15058. let buildId = "";
  15059. while (buildId.length < 8) {
  15060. const char = chars[Math.floor(Math.random() * chars.length)];
  15061. buildId += char;
  15062. if (buildId.length === 1) {
  15063. chars += "0123456789";
  15064. }
  15065. }
  15066. return buildId;
  15067. };
  15068. function renderBuildDiagnostic(results, level, header, msg) {
  15069. const diagnostic = {
  15070. level,
  15071. type: "build",
  15072. header,
  15073. messageText: msg,
  15074. relFilePath: void 0,
  15075. absFilePath: void 0,
  15076. lines: []
  15077. };
  15078. if (results.pathname) {
  15079. if (results.pathname !== "/") {
  15080. diagnostic.header += ": " + results.pathname;
  15081. }
  15082. } else if (results.url) {
  15083. diagnostic.header += ": " + results.url;
  15084. }
  15085. results.diagnostics.push(diagnostic);
  15086. return diagnostic;
  15087. }
  15088. function renderBuildError(results, msg) {
  15089. return renderBuildDiagnostic(results, "error", "Hydrate Error", msg || "");
  15090. }
  15091. function renderCatchError(results, err2) {
  15092. const diagnostic = renderBuildError(results);
  15093. if (err2 != null) {
  15094. if (err2.stack != null) {
  15095. diagnostic.messageText = err2.stack.toString();
  15096. } else {
  15097. if (err2.message != null) {
  15098. diagnostic.messageText = err2.message.toString();
  15099. } else {
  15100. diagnostic.messageText = err2.toString();
  15101. }
  15102. }
  15103. }
  15104. return diagnostic;
  15105. }
  15106. // src/hydrate/runner/runtime-log.ts
  15107. function runtimeLogging(win, opts, results) {
  15108. try {
  15109. const pathname = win.location.pathname;
  15110. win.console.error = (...msgs) => {
  15111. const errMsg = msgs.reduce((errMsg2, m) => {
  15112. if (m) {
  15113. if (m.stack != null) {
  15114. return errMsg2 + " " + String(m.stack);
  15115. } else {
  15116. if (m.message != null) {
  15117. return errMsg2 + " " + String(m.message);
  15118. }
  15119. }
  15120. }
  15121. return String(m);
  15122. }, "").trim();
  15123. if (errMsg !== "") {
  15124. renderCatchError(results, errMsg);
  15125. if (opts.runtimeLogging) {
  15126. runtimeLog(pathname, "error", [errMsg]);
  15127. }
  15128. }
  15129. };
  15130. win.console.debug = (...msgs) => {
  15131. renderBuildDiagnostic(results, "debug", "Hydrate Debug", [...msgs].join(", "));
  15132. if (opts.runtimeLogging) {
  15133. runtimeLog(pathname, "debug", msgs);
  15134. }
  15135. };
  15136. if (opts.runtimeLogging) {
  15137. ["log", "warn", "assert", "info", "trace"].forEach((type) => {
  15138. win.console[type] = (...msgs) => {
  15139. runtimeLog(pathname, type, msgs);
  15140. };
  15141. });
  15142. }
  15143. } catch (e) {
  15144. renderCatchError(results, e);
  15145. }
  15146. }
  15147. function runtimeLog(pathname, type, msgs) {
  15148. global.console[type].apply(global.console, [`[ ${pathname} ${type} ] `, ...msgs]);
  15149. }
  15150. // src/hydrate/runner/window-initialize.ts
  15151. function initializeWindow(win, doc, opts, results) {
  15152. if (typeof opts.url === "string") {
  15153. try {
  15154. win.location.href = opts.url;
  15155. } catch (e) {
  15156. }
  15157. }
  15158. if (typeof opts.userAgent === "string") {
  15159. try {
  15160. win.navigator.userAgent = opts.userAgent;
  15161. } catch (e) {
  15162. }
  15163. }
  15164. if (typeof opts.cookie === "string") {
  15165. try {
  15166. doc.cookie = opts.cookie;
  15167. } catch (e) {
  15168. }
  15169. }
  15170. if (typeof opts.referrer === "string") {
  15171. try {
  15172. doc.referrer = opts.referrer;
  15173. } catch (e) {
  15174. }
  15175. }
  15176. if (typeof opts.direction === "string") {
  15177. try {
  15178. doc.documentElement.setAttribute("dir", opts.direction);
  15179. } catch (e) {
  15180. }
  15181. }
  15182. if (typeof opts.language === "string") {
  15183. try {
  15184. doc.documentElement.setAttribute("lang", opts.language);
  15185. } catch (e) {
  15186. }
  15187. }
  15188. if (typeof opts.buildId === "string") {
  15189. try {
  15190. doc.documentElement.setAttribute("data-stencil-build", opts.buildId);
  15191. } catch (e) {
  15192. }
  15193. }
  15194. try {
  15195. win.customElements = null;
  15196. } catch (e) {
  15197. }
  15198. if (opts.constrainTimeouts) {
  15199. constrainTimeouts(win);
  15200. }
  15201. runtimeLogging(win, opts, results);
  15202. return win;
  15203. }
  15204. // src/hydrate/runner/render.ts
  15205. var NOOP = () => {
  15206. };
  15207. function streamToString(html, option) {
  15208. return renderToString(html, option, true);
  15209. }
  15210. function renderToString(html, options, asStream) {
  15211. const opts = normalizeHydrateOptions(options);
  15212. opts.serializeToHtml = true;
  15213. opts.fullDocument = typeof opts.fullDocument === "boolean" ? opts.fullDocument : true;
  15214. opts.serializeShadowRoot = typeof opts.serializeShadowRoot === "boolean" ? opts.serializeShadowRoot : true;
  15215. opts.constrainTimeouts = false;
  15216. return hydrateDocument(html, opts, asStream);
  15217. }
  15218. function hydrateDocument(doc, options, asStream) {
  15219. const opts = normalizeHydrateOptions(options);
  15220. let win = null;
  15221. const results = generateHydrateResults(opts);
  15222. if (hasError(results.diagnostics)) {
  15223. return Promise.resolve(results);
  15224. }
  15225. if (typeof doc === "string") {
  15226. try {
  15227. opts.destroyWindow = true;
  15228. opts.destroyDocument = true;
  15229. win = new MockWindow(doc);
  15230. if (!asStream) {
  15231. return render(win, opts, results).then(() => results);
  15232. }
  15233. return renderStream(win, opts, results);
  15234. } catch (e) {
  15235. if (win && win.close) {
  15236. win.close();
  15237. }
  15238. win = null;
  15239. renderCatchError(results, e);
  15240. return Promise.resolve(results);
  15241. }
  15242. }
  15243. if (isValidDocument(doc)) {
  15244. try {
  15245. opts.destroyDocument = false;
  15246. win = patchDomImplementation(doc, opts);
  15247. if (!asStream) {
  15248. return render(win, opts, results).then(() => results);
  15249. }
  15250. return renderStream(win, opts, results);
  15251. } catch (e) {
  15252. if (win && win.close) {
  15253. win.close();
  15254. }
  15255. win = null;
  15256. renderCatchError(results, e);
  15257. return Promise.resolve(results);
  15258. }
  15259. }
  15260. renderBuildError(results, `Invalid html or document. Must be either a valid "html" string, or DOM "document".`);
  15261. return Promise.resolve(results);
  15262. }
  15263. async function render(win, opts, results) {
  15264. if ("process" in globalThis && typeof process.on === "function" && !process.__stencilErrors) {
  15265. process.__stencilErrors = true;
  15266. process.on("unhandledRejection", (e) => {
  15267. console.log("unhandledRejection", e);
  15268. });
  15269. }
  15270. initializeWindow(win, win.document, opts, results);
  15271. const beforeHydrateFn = typeof opts.beforeHydrate === "function" ? opts.beforeHydrate : NOOP;
  15272. try {
  15273. await Promise.resolve(beforeHydrateFn(win.document));
  15274. return new Promise((resolve) => hydrateFactory(win, opts, results, afterHydrate, resolve));
  15275. } catch (e) {
  15276. renderCatchError(results, e);
  15277. return finalizeHydrate(win, win.document, opts, results);
  15278. }
  15279. }
  15280. function renderStream(win, opts, results) {
  15281. async function* processRender() {
  15282. const renderResult = await render(win, opts, results);
  15283. yield renderResult.html;
  15284. }
  15285. return Readable.from(processRender());
  15286. }
  15287. async function afterHydrate(win, opts, results, resolve) {
  15288. const afterHydrateFn = typeof opts.afterHydrate === "function" ? opts.afterHydrate : NOOP;
  15289. try {
  15290. await Promise.resolve(afterHydrateFn(win.document));
  15291. return resolve(finalizeHydrate(win, win.document, opts, results));
  15292. } catch (e) {
  15293. renderCatchError(results, e);
  15294. return resolve(finalizeHydrate(win, win.document, opts, results));
  15295. }
  15296. }
  15297. function finalizeHydrate(win, doc, opts, results) {
  15298. try {
  15299. inspectElement(results, doc.documentElement, 0);
  15300. if (opts.removeUnusedStyles !== false) {
  15301. try {
  15302. removeUnusedStyles(doc, results.diagnostics);
  15303. } catch (e) {
  15304. renderCatchError(results, e);
  15305. }
  15306. }
  15307. if (typeof opts.title === "string") {
  15308. try {
  15309. doc.title = opts.title;
  15310. } catch (e) {
  15311. renderCatchError(results, e);
  15312. }
  15313. }
  15314. results.title = doc.title;
  15315. if (opts.removeScripts) {
  15316. removeScripts(doc.documentElement);
  15317. }
  15318. try {
  15319. updateCanonicalLink(doc, opts.canonicalUrl);
  15320. } catch (e) {
  15321. renderCatchError(results, e);
  15322. }
  15323. try {
  15324. relocateMetaCharset(doc);
  15325. } catch (e) {
  15326. }
  15327. if (!hasError(results.diagnostics)) {
  15328. results.httpStatus = 200;
  15329. }
  15330. try {
  15331. const metaStatus = doc.head.querySelector('meta[http-equiv="status"]');
  15332. if (metaStatus != null) {
  15333. const metaStatusContent = metaStatus.getAttribute("content");
  15334. if (metaStatusContent && metaStatusContent.length > 0) {
  15335. results.httpStatus = parseInt(metaStatusContent, 10);
  15336. }
  15337. }
  15338. } catch (e) {
  15339. }
  15340. if (opts.clientHydrateAnnotations) {
  15341. doc.documentElement.classList.add("hydrated");
  15342. }
  15343. if (opts.serializeToHtml) {
  15344. results.html = serializeDocumentToString(doc, opts);
  15345. }
  15346. } catch (e) {
  15347. renderCatchError(results, e);
  15348. }
  15349. destroyWindow(win, doc, opts, results);
  15350. return results;
  15351. }
  15352. function destroyWindow(win, doc, opts, results) {
  15353. if (!opts.destroyWindow) {
  15354. return;
  15355. }
  15356. try {
  15357. if (!opts.destroyDocument) {
  15358. win.document = null;
  15359. doc.defaultView = null;
  15360. }
  15361. if (win.close) {
  15362. win.close();
  15363. }
  15364. } catch (e) {
  15365. renderCatchError(results, e);
  15366. }
  15367. }
  15368. function serializeDocumentToString(doc, opts) {
  15369. return serializeNodeToHtml(doc, {
  15370. approximateLineWidth: opts.approximateLineWidth,
  15371. outerHtml: false,
  15372. prettyHtml: opts.prettyHtml,
  15373. removeAttributeQuotes: opts.removeAttributeQuotes,
  15374. removeBooleanAttributeQuotes: opts.removeBooleanAttributeQuotes,
  15375. removeEmptyAttributes: opts.removeEmptyAttributes,
  15376. removeHtmlComments: opts.removeHtmlComments,
  15377. serializeShadowRoot: opts.serializeShadowRoot,
  15378. fullDocument: opts.fullDocument
  15379. });
  15380. }
  15381. function isValidDocument(doc) {
  15382. return doc != null && doc.nodeType === 9 && doc.documentElement != null && doc.documentElement.nodeType === 1 && doc.body != null && doc.body.nodeType === 1;
  15383. }
  15384. function removeScripts(elm) {
  15385. const children = elm.children;
  15386. for (let i = children.length - 1; i >= 0; i--) {
  15387. const child = children[i];
  15388. removeScripts(child);
  15389. if (child.nodeName === "SCRIPT" || child.nodeName === "LINK" && child.getAttribute("rel") === "modulepreload") {
  15390. child.remove();
  15391. }
  15392. }
  15393. }
  15394. export {
  15395. createWindowFromHtml,
  15396. hydrateDocument,
  15397. renderToString,
  15398. serializeDocumentToString,
  15399. streamToString
  15400. };