You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

plist-parse.js 196KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456
  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. (function (Buffer){(function (){
  3. /**
  4. * Module dependencies.
  5. */
  6. const { DOMParser } = require('@xmldom/xmldom');
  7. /**
  8. * Module exports.
  9. */
  10. exports.parse = parse;
  11. var TEXT_NODE = 3;
  12. var CDATA_NODE = 4;
  13. var COMMENT_NODE = 8;
  14. /**
  15. * We ignore raw text (usually whitespace), <!-- xml comments -->,
  16. * and raw CDATA nodes.
  17. *
  18. * @param {Element} node
  19. * @returns {Boolean}
  20. * @api private
  21. */
  22. function shouldIgnoreNode (node) {
  23. return node.nodeType === TEXT_NODE
  24. || node.nodeType === COMMENT_NODE
  25. || node.nodeType === CDATA_NODE;
  26. }
  27. /**
  28. * Check if the node is empty. Some plist file has such node:
  29. * <key />
  30. * this node shoud be ignored.
  31. *
  32. * @see https://github.com/TooTallNate/plist.js/issues/66
  33. * @param {Element} node
  34. * @returns {Boolean}
  35. * @api private
  36. */
  37. function isEmptyNode(node){
  38. if(!node.childNodes || node.childNodes.length === 0) {
  39. return true;
  40. } else {
  41. return false;
  42. }
  43. }
  44. function invariant(test, message) {
  45. if (!test) {
  46. throw new Error(message);
  47. }
  48. }
  49. /**
  50. * Parses a Plist XML string. Returns an Object.
  51. *
  52. * @param {String} xml - the XML String to decode
  53. * @returns {Mixed} the decoded value from the Plist XML
  54. * @api public
  55. */
  56. function parse (xml) {
  57. var doc = new DOMParser().parseFromString(xml);
  58. invariant(
  59. doc.documentElement.nodeName === 'plist',
  60. 'malformed document. First element should be <plist>'
  61. );
  62. var plist = parsePlistXML(doc.documentElement);
  63. // the root <plist> node gets interpreted as an Array,
  64. // so pull out the inner data first
  65. if (plist.length == 1) plist = plist[0];
  66. return plist;
  67. }
  68. /**
  69. * Convert an XML based plist document into a JSON representation.
  70. *
  71. * @param {Object} xml_node - current XML node in the plist
  72. * @returns {Mixed} built up JSON object
  73. * @api private
  74. */
  75. function parsePlistXML (node) {
  76. var i, new_obj, key, val, new_arr, res, counter, type;
  77. if (!node)
  78. return null;
  79. if (node.nodeName === 'plist') {
  80. new_arr = [];
  81. if (isEmptyNode(node)) {
  82. return new_arr;
  83. }
  84. for (i=0; i < node.childNodes.length; i++) {
  85. if (!shouldIgnoreNode(node.childNodes[i])) {
  86. new_arr.push( parsePlistXML(node.childNodes[i]));
  87. }
  88. }
  89. return new_arr;
  90. } else if (node.nodeName === 'dict') {
  91. new_obj = {};
  92. key = null;
  93. counter = 0;
  94. if (isEmptyNode(node)) {
  95. return new_obj;
  96. }
  97. for (i=0; i < node.childNodes.length; i++) {
  98. if (shouldIgnoreNode(node.childNodes[i])) continue;
  99. if (counter % 2 === 0) {
  100. invariant(
  101. node.childNodes[i].nodeName === 'key',
  102. 'Missing key while parsing <dict/>.'
  103. );
  104. key = parsePlistXML(node.childNodes[i]);
  105. } else {
  106. invariant(
  107. node.childNodes[i].nodeName !== 'key',
  108. 'Unexpected key "'
  109. + parsePlistXML(node.childNodes[i])
  110. + '" while parsing <dict/>.'
  111. );
  112. new_obj[key] = parsePlistXML(node.childNodes[i]);
  113. }
  114. counter += 1;
  115. }
  116. if (counter % 2 === 1) {
  117. new_obj[key] = '';
  118. }
  119. return new_obj;
  120. } else if (node.nodeName === 'array') {
  121. new_arr = [];
  122. if (isEmptyNode(node)) {
  123. return new_arr;
  124. }
  125. for (i=0; i < node.childNodes.length; i++) {
  126. if (!shouldIgnoreNode(node.childNodes[i])) {
  127. res = parsePlistXML(node.childNodes[i]);
  128. if (null != res) new_arr.push(res);
  129. }
  130. }
  131. return new_arr;
  132. } else if (node.nodeName === '#text') {
  133. // TODO: what should we do with text types? (CDATA sections)
  134. } else if (node.nodeName === 'key') {
  135. if (isEmptyNode(node)) {
  136. return '';
  137. }
  138. invariant(
  139. node.childNodes[0].nodeValue !== '__proto__',
  140. '__proto__ keys can lead to prototype pollution. More details on CVE-2022-22912'
  141. );
  142. return node.childNodes[0].nodeValue;
  143. } else if (node.nodeName === 'string') {
  144. res = '';
  145. if (isEmptyNode(node)) {
  146. return res;
  147. }
  148. for (i=0; i < node.childNodes.length; i++) {
  149. var type = node.childNodes[i].nodeType;
  150. if (type === TEXT_NODE || type === CDATA_NODE) {
  151. res += node.childNodes[i].nodeValue;
  152. }
  153. }
  154. return res;
  155. } else if (node.nodeName === 'integer') {
  156. invariant(
  157. !isEmptyNode(node),
  158. 'Cannot parse "" as integer.'
  159. );
  160. return parseInt(node.childNodes[0].nodeValue, 10);
  161. } else if (node.nodeName === 'real') {
  162. invariant(
  163. !isEmptyNode(node),
  164. 'Cannot parse "" as real.'
  165. );
  166. res = '';
  167. for (i=0; i < node.childNodes.length; i++) {
  168. if (node.childNodes[i].nodeType === TEXT_NODE) {
  169. res += node.childNodes[i].nodeValue;
  170. }
  171. }
  172. return parseFloat(res);
  173. } else if (node.nodeName === 'data') {
  174. res = '';
  175. if (isEmptyNode(node)) {
  176. return Buffer.from(res, 'base64');
  177. }
  178. for (i=0; i < node.childNodes.length; i++) {
  179. if (node.childNodes[i].nodeType === TEXT_NODE) {
  180. res += node.childNodes[i].nodeValue.replace(/\s+/g, '');
  181. }
  182. }
  183. return Buffer.from(res, 'base64');
  184. } else if (node.nodeName === 'date') {
  185. invariant(
  186. !isEmptyNode(node),
  187. 'Cannot parse "" as Date.'
  188. )
  189. return new Date(node.childNodes[0].nodeValue);
  190. } else if (node.nodeName === 'null') {
  191. return null;
  192. } else if (node.nodeName === 'true') {
  193. return true;
  194. } else if (node.nodeName === 'false') {
  195. return false;
  196. } else {
  197. throw new Error('Invalid PLIST tag ' + node.nodeName);
  198. }
  199. }
  200. }).call(this)}).call(this,require("buffer").Buffer)
  201. },{"@xmldom/xmldom":6,"buffer":9}],2:[function(require,module,exports){
  202. 'use strict'
  203. /**
  204. * Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.
  205. *
  206. * Works with anything that has a `length` property and index access properties, including NodeList.
  207. *
  208. * @template {unknown} T
  209. * @param {Array<T> | ({length:number, [number]: T})} list
  210. * @param {function (item: T, index: number, list:Array<T> | ({length:number, [number]: T})):boolean} predicate
  211. * @param {Partial<Pick<ArrayConstructor['prototype'], 'find'>>?} ac `Array.prototype` by default,
  212. * allows injecting a custom implementation in tests
  213. * @returns {T | undefined}
  214. *
  215. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
  216. * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find
  217. */
  218. function find(list, predicate, ac) {
  219. if (ac === undefined) {
  220. ac = Array.prototype;
  221. }
  222. if (list && typeof ac.find === 'function') {
  223. return ac.find.call(list, predicate);
  224. }
  225. for (var i = 0; i < list.length; i++) {
  226. if (Object.prototype.hasOwnProperty.call(list, i)) {
  227. var item = list[i];
  228. if (predicate.call(undefined, item, i, list)) {
  229. return item;
  230. }
  231. }
  232. }
  233. }
  234. /**
  235. * "Shallow freezes" an object to render it immutable.
  236. * Uses `Object.freeze` if available,
  237. * otherwise the immutability is only in the type.
  238. *
  239. * Is used to create "enum like" objects.
  240. *
  241. * @template T
  242. * @param {T} object the object to freeze
  243. * @param {Pick<ObjectConstructor, 'freeze'> = Object} oc `Object` by default,
  244. * allows to inject custom object constructor for tests
  245. * @returns {Readonly<T>}
  246. *
  247. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
  248. */
  249. function freeze(object, oc) {
  250. if (oc === undefined) {
  251. oc = Object
  252. }
  253. return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object
  254. }
  255. /**
  256. * Since we can not rely on `Object.assign` we provide a simplified version
  257. * that is sufficient for our needs.
  258. *
  259. * @param {Object} target
  260. * @param {Object | null | undefined} source
  261. *
  262. * @returns {Object} target
  263. * @throws TypeError if target is not an object
  264. *
  265. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
  266. * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign
  267. */
  268. function assign(target, source) {
  269. if (target === null || typeof target !== 'object') {
  270. throw new TypeError('target is not an object')
  271. }
  272. for (var key in source) {
  273. if (Object.prototype.hasOwnProperty.call(source, key)) {
  274. target[key] = source[key]
  275. }
  276. }
  277. return target
  278. }
  279. /**
  280. * All mime types that are allowed as input to `DOMParser.parseFromString`
  281. *
  282. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN
  283. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec
  284. * @see DOMParser.prototype.parseFromString
  285. */
  286. var MIME_TYPE = freeze({
  287. /**
  288. * `text/html`, the only mime type that triggers treating an XML document as HTML.
  289. *
  290. * @see DOMParser.SupportedType.isHTML
  291. * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
  292. * @see https://en.wikipedia.org/wiki/HTML Wikipedia
  293. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
  294. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec
  295. */
  296. HTML: 'text/html',
  297. /**
  298. * Helper method to check a mime type if it indicates an HTML document
  299. *
  300. * @param {string} [value]
  301. * @returns {boolean}
  302. *
  303. * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
  304. * @see https://en.wikipedia.org/wiki/HTML Wikipedia
  305. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
  306. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring */
  307. isHTML: function (value) {
  308. return value === MIME_TYPE.HTML
  309. },
  310. /**
  311. * `application/xml`, the standard mime type for XML documents.
  312. *
  313. * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration
  314. * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
  315. * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
  316. */
  317. XML_APPLICATION: 'application/xml',
  318. /**
  319. * `text/html`, an alias for `application/xml`.
  320. *
  321. * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
  322. * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
  323. * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
  324. */
  325. XML_TEXT: 'text/xml',
  326. /**
  327. * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
  328. * but is parsed as an XML document.
  329. *
  330. * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration
  331. * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
  332. * @see https://en.wikipedia.org/wiki/XHTML Wikipedia
  333. */
  334. XML_XHTML_APPLICATION: 'application/xhtml+xml',
  335. /**
  336. * `image/svg+xml`,
  337. *
  338. * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
  339. * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
  340. * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
  341. */
  342. XML_SVG_IMAGE: 'image/svg+xml',
  343. })
  344. /**
  345. * Namespaces that are used in this code base.
  346. *
  347. * @see http://www.w3.org/TR/REC-xml-names
  348. */
  349. var NAMESPACE = freeze({
  350. /**
  351. * The XHTML namespace.
  352. *
  353. * @see http://www.w3.org/1999/xhtml
  354. */
  355. HTML: 'http://www.w3.org/1999/xhtml',
  356. /**
  357. * Checks if `uri` equals `NAMESPACE.HTML`.
  358. *
  359. * @param {string} [uri]
  360. *
  361. * @see NAMESPACE.HTML
  362. */
  363. isHTML: function (uri) {
  364. return uri === NAMESPACE.HTML
  365. },
  366. /**
  367. * The SVG namespace.
  368. *
  369. * @see http://www.w3.org/2000/svg
  370. */
  371. SVG: 'http://www.w3.org/2000/svg',
  372. /**
  373. * The `xml:` namespace.
  374. *
  375. * @see http://www.w3.org/XML/1998/namespace
  376. */
  377. XML: 'http://www.w3.org/XML/1998/namespace',
  378. /**
  379. * The `xmlns:` namespace
  380. *
  381. * @see https://www.w3.org/2000/xmlns/
  382. */
  383. XMLNS: 'http://www.w3.org/2000/xmlns/',
  384. })
  385. exports.assign = assign;
  386. exports.find = find;
  387. exports.freeze = freeze;
  388. exports.MIME_TYPE = MIME_TYPE;
  389. exports.NAMESPACE = NAMESPACE;
  390. },{}],3:[function(require,module,exports){
  391. var conventions = require("./conventions");
  392. var dom = require('./dom')
  393. var entities = require('./entities');
  394. var sax = require('./sax');
  395. var DOMImplementation = dom.DOMImplementation;
  396. var NAMESPACE = conventions.NAMESPACE;
  397. var ParseError = sax.ParseError;
  398. var XMLReader = sax.XMLReader;
  399. /**
  400. * Normalizes line ending according to https://www.w3.org/TR/xml11/#sec-line-ends:
  401. *
  402. * > XML parsed entities are often stored in computer files which,
  403. * > for editing convenience, are organized into lines.
  404. * > These lines are typically separated by some combination
  405. * > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).
  406. * >
  407. * > To simplify the tasks of applications, the XML processor must behave
  408. * > as if it normalized all line breaks in external parsed entities (including the document entity)
  409. * > on input, before parsing, by translating all of the following to a single #xA character:
  410. * >
  411. * > 1. the two-character sequence #xD #xA
  412. * > 2. the two-character sequence #xD #x85
  413. * > 3. the single character #x85
  414. * > 4. the single character #x2028
  415. * > 5. any #xD character that is not immediately followed by #xA or #x85.
  416. *
  417. * @param {string} input
  418. * @returns {string}
  419. */
  420. function normalizeLineEndings(input) {
  421. return input
  422. .replace(/\r[\n\u0085]/g, '\n')
  423. .replace(/[\r\u0085\u2028]/g, '\n')
  424. }
  425. /**
  426. * @typedef Locator
  427. * @property {number} [columnNumber]
  428. * @property {number} [lineNumber]
  429. */
  430. /**
  431. * @typedef DOMParserOptions
  432. * @property {DOMHandler} [domBuilder]
  433. * @property {Function} [errorHandler]
  434. * @property {(string) => string} [normalizeLineEndings] used to replace line endings before parsing
  435. * defaults to `normalizeLineEndings`
  436. * @property {Locator} [locator]
  437. * @property {Record<string, string>} [xmlns]
  438. *
  439. * @see normalizeLineEndings
  440. */
  441. /**
  442. * The DOMParser interface provides the ability to parse XML or HTML source code
  443. * from a string into a DOM `Document`.
  444. *
  445. * _xmldom is different from the spec in that it allows an `options` parameter,
  446. * to override the default behavior._
  447. *
  448. * @param {DOMParserOptions} [options]
  449. * @constructor
  450. *
  451. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
  452. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
  453. */
  454. function DOMParser(options){
  455. this.options = options ||{locator:{}};
  456. }
  457. DOMParser.prototype.parseFromString = function(source,mimeType){
  458. var options = this.options;
  459. var sax = new XMLReader();
  460. var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
  461. var errorHandler = options.errorHandler;
  462. var locator = options.locator;
  463. var defaultNSMap = options.xmlns||{};
  464. var isHTML = /\/x?html?$/.test(mimeType);//mimeType.toLowerCase().indexOf('html') > -1;
  465. var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES;
  466. if(locator){
  467. domBuilder.setDocumentLocator(locator)
  468. }
  469. sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
  470. sax.domBuilder = options.domBuilder || domBuilder;
  471. if(isHTML){
  472. defaultNSMap[''] = NAMESPACE.HTML;
  473. }
  474. defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
  475. var normalize = options.normalizeLineEndings || normalizeLineEndings;
  476. if (source && typeof source === 'string') {
  477. sax.parse(
  478. normalize(source),
  479. defaultNSMap,
  480. entityMap
  481. )
  482. } else {
  483. sax.errorHandler.error('invalid doc source')
  484. }
  485. return domBuilder.doc;
  486. }
  487. function buildErrorHandler(errorImpl,domBuilder,locator){
  488. if(!errorImpl){
  489. if(domBuilder instanceof DOMHandler){
  490. return domBuilder;
  491. }
  492. errorImpl = domBuilder ;
  493. }
  494. var errorHandler = {}
  495. var isCallback = errorImpl instanceof Function;
  496. locator = locator||{}
  497. function build(key){
  498. var fn = errorImpl[key];
  499. if(!fn && isCallback){
  500. fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl;
  501. }
  502. errorHandler[key] = fn && function(msg){
  503. fn('[xmldom '+key+']\t'+msg+_locator(locator));
  504. }||function(){};
  505. }
  506. build('warning');
  507. build('error');
  508. build('fatalError');
  509. return errorHandler;
  510. }
  511. //console.log('#\n\n\n\n\n\n\n####')
  512. /**
  513. * +ContentHandler+ErrorHandler
  514. * +LexicalHandler+EntityResolver2
  515. * -DeclHandler-DTDHandler
  516. *
  517. * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
  518. * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
  519. * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
  520. */
  521. function DOMHandler() {
  522. this.cdata = false;
  523. }
  524. function position(locator,node){
  525. node.lineNumber = locator.lineNumber;
  526. node.columnNumber = locator.columnNumber;
  527. }
  528. /**
  529. * @see org.xml.sax.ContentHandler#startDocument
  530. * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
  531. */
  532. DOMHandler.prototype = {
  533. startDocument : function() {
  534. this.doc = new DOMImplementation().createDocument(null, null, null);
  535. if (this.locator) {
  536. this.doc.documentURI = this.locator.systemId;
  537. }
  538. },
  539. startElement:function(namespaceURI, localName, qName, attrs) {
  540. var doc = this.doc;
  541. var el = doc.createElementNS(namespaceURI, qName||localName);
  542. var len = attrs.length;
  543. appendElement(this, el);
  544. this.currentElement = el;
  545. this.locator && position(this.locator,el)
  546. for (var i = 0 ; i < len; i++) {
  547. var namespaceURI = attrs.getURI(i);
  548. var value = attrs.getValue(i);
  549. var qName = attrs.getQName(i);
  550. var attr = doc.createAttributeNS(namespaceURI, qName);
  551. this.locator &&position(attrs.getLocator(i),attr);
  552. attr.value = attr.nodeValue = value;
  553. el.setAttributeNode(attr)
  554. }
  555. },
  556. endElement:function(namespaceURI, localName, qName) {
  557. var current = this.currentElement
  558. var tagName = current.tagName;
  559. this.currentElement = current.parentNode;
  560. },
  561. startPrefixMapping:function(prefix, uri) {
  562. },
  563. endPrefixMapping:function(prefix) {
  564. },
  565. processingInstruction:function(target, data) {
  566. var ins = this.doc.createProcessingInstruction(target, data);
  567. this.locator && position(this.locator,ins)
  568. appendElement(this, ins);
  569. },
  570. ignorableWhitespace:function(ch, start, length) {
  571. },
  572. characters:function(chars, start, length) {
  573. chars = _toString.apply(this,arguments)
  574. //console.log(chars)
  575. if(chars){
  576. if (this.cdata) {
  577. var charNode = this.doc.createCDATASection(chars);
  578. } else {
  579. var charNode = this.doc.createTextNode(chars);
  580. }
  581. if(this.currentElement){
  582. this.currentElement.appendChild(charNode);
  583. }else if(/^\s*$/.test(chars)){
  584. this.doc.appendChild(charNode);
  585. //process xml
  586. }
  587. this.locator && position(this.locator,charNode)
  588. }
  589. },
  590. skippedEntity:function(name) {
  591. },
  592. endDocument:function() {
  593. this.doc.normalize();
  594. },
  595. setDocumentLocator:function (locator) {
  596. if(this.locator = locator){// && !('lineNumber' in locator)){
  597. locator.lineNumber = 0;
  598. }
  599. },
  600. //LexicalHandler
  601. comment:function(chars, start, length) {
  602. chars = _toString.apply(this,arguments)
  603. var comm = this.doc.createComment(chars);
  604. this.locator && position(this.locator,comm)
  605. appendElement(this, comm);
  606. },
  607. startCDATA:function() {
  608. //used in characters() methods
  609. this.cdata = true;
  610. },
  611. endCDATA:function() {
  612. this.cdata = false;
  613. },
  614. startDTD:function(name, publicId, systemId) {
  615. var impl = this.doc.implementation;
  616. if (impl && impl.createDocumentType) {
  617. var dt = impl.createDocumentType(name, publicId, systemId);
  618. this.locator && position(this.locator,dt)
  619. appendElement(this, dt);
  620. this.doc.doctype = dt;
  621. }
  622. },
  623. /**
  624. * @see org.xml.sax.ErrorHandler
  625. * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
  626. */
  627. warning:function(error) {
  628. console.warn('[xmldom warning]\t'+error,_locator(this.locator));
  629. },
  630. error:function(error) {
  631. console.error('[xmldom error]\t'+error,_locator(this.locator));
  632. },
  633. fatalError:function(error) {
  634. throw new ParseError(error, this.locator);
  635. }
  636. }
  637. function _locator(l){
  638. if(l){
  639. return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
  640. }
  641. }
  642. function _toString(chars,start,length){
  643. if(typeof chars == 'string'){
  644. return chars.substr(start,length)
  645. }else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
  646. if(chars.length >= start+length || start){
  647. return new java.lang.String(chars,start,length)+'';
  648. }
  649. return chars;
  650. }
  651. }
  652. /*
  653. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
  654. * used method of org.xml.sax.ext.LexicalHandler:
  655. * #comment(chars, start, length)
  656. * #startCDATA()
  657. * #endCDATA()
  658. * #startDTD(name, publicId, systemId)
  659. *
  660. *
  661. * IGNORED method of org.xml.sax.ext.LexicalHandler:
  662. * #endDTD()
  663. * #startEntity(name)
  664. * #endEntity(name)
  665. *
  666. *
  667. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
  668. * IGNORED method of org.xml.sax.ext.DeclHandler
  669. * #attributeDecl(eName, aName, type, mode, value)
  670. * #elementDecl(name, model)
  671. * #externalEntityDecl(name, publicId, systemId)
  672. * #internalEntityDecl(name, value)
  673. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
  674. * IGNORED method of org.xml.sax.EntityResolver2
  675. * #resolveEntity(String name,String publicId,String baseURI,String systemId)
  676. * #resolveEntity(publicId, systemId)
  677. * #getExternalSubset(name, baseURI)
  678. * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
  679. * IGNORED method of org.xml.sax.DTDHandler
  680. * #notationDecl(name, publicId, systemId) {};
  681. * #unparsedEntityDecl(name, publicId, systemId, notationName) {};
  682. */
  683. "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
  684. DOMHandler.prototype[key] = function(){return null}
  685. })
  686. /* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
  687. function appendElement (hander,node) {
  688. if (!hander.currentElement) {
  689. hander.doc.appendChild(node);
  690. } else {
  691. hander.currentElement.appendChild(node);
  692. }
  693. }//appendChild and setAttributeNS are preformance key
  694. exports.__DOMHandler = DOMHandler;
  695. exports.normalizeLineEndings = normalizeLineEndings;
  696. exports.DOMParser = DOMParser;
  697. },{"./conventions":2,"./dom":4,"./entities":5,"./sax":7}],4:[function(require,module,exports){
  698. var conventions = require("./conventions");
  699. var find = conventions.find;
  700. var NAMESPACE = conventions.NAMESPACE;
  701. /**
  702. * A prerequisite for `[].filter`, to drop elements that are empty
  703. * @param {string} input
  704. * @returns {boolean}
  705. */
  706. function notEmptyString (input) {
  707. return input !== ''
  708. }
  709. /**
  710. * @see https://infra.spec.whatwg.org/#split-on-ascii-whitespace
  711. * @see https://infra.spec.whatwg.org/#ascii-whitespace
  712. *
  713. * @param {string} input
  714. * @returns {string[]} (can be empty)
  715. */
  716. function splitOnASCIIWhitespace(input) {
  717. // U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE
  718. return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : []
  719. }
  720. /**
  721. * Adds element as a key to current if it is not already present.
  722. *
  723. * @param {Record<string, boolean | undefined>} current
  724. * @param {string} element
  725. * @returns {Record<string, boolean | undefined>}
  726. */
  727. function orderedSetReducer (current, element) {
  728. if (!current.hasOwnProperty(element)) {
  729. current[element] = true;
  730. }
  731. return current;
  732. }
  733. /**
  734. * @see https://infra.spec.whatwg.org/#ordered-set
  735. * @param {string} input
  736. * @returns {string[]}
  737. */
  738. function toOrderedSet(input) {
  739. if (!input) return [];
  740. var list = splitOnASCIIWhitespace(input);
  741. return Object.keys(list.reduce(orderedSetReducer, {}))
  742. }
  743. /**
  744. * Uses `list.indexOf` to implement something like `Array.prototype.includes`,
  745. * which we can not rely on being available.
  746. *
  747. * @param {any[]} list
  748. * @returns {function(any): boolean}
  749. */
  750. function arrayIncludes (list) {
  751. return function(element) {
  752. return list && list.indexOf(element) !== -1;
  753. }
  754. }
  755. function copy(src,dest){
  756. for(var p in src){
  757. if (Object.prototype.hasOwnProperty.call(src, p)) {
  758. dest[p] = src[p];
  759. }
  760. }
  761. }
  762. /**
  763. ^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
  764. ^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
  765. */
  766. function _extends(Class,Super){
  767. var pt = Class.prototype;
  768. if(!(pt instanceof Super)){
  769. function t(){};
  770. t.prototype = Super.prototype;
  771. t = new t();
  772. copy(pt,t);
  773. Class.prototype = pt = t;
  774. }
  775. if(pt.constructor != Class){
  776. if(typeof Class != 'function'){
  777. console.error("unknown Class:"+Class)
  778. }
  779. pt.constructor = Class
  780. }
  781. }
  782. // Node Types
  783. var NodeType = {}
  784. var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
  785. var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
  786. var TEXT_NODE = NodeType.TEXT_NODE = 3;
  787. var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
  788. var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
  789. var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
  790. var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
  791. var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
  792. var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
  793. var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
  794. var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
  795. var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
  796. // ExceptionCode
  797. var ExceptionCode = {}
  798. var ExceptionMessage = {};
  799. var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1);
  800. var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
  801. var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
  802. var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
  803. var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
  804. var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
  805. var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
  806. var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
  807. var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
  808. var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
  809. //level2
  810. var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
  811. var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
  812. var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
  813. var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
  814. var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15);
  815. /**
  816. * DOM Level 2
  817. * Object DOMException
  818. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
  819. * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
  820. */
  821. function DOMException(code, message) {
  822. if(message instanceof Error){
  823. var error = message;
  824. }else{
  825. error = this;
  826. Error.call(this, ExceptionMessage[code]);
  827. this.message = ExceptionMessage[code];
  828. if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
  829. }
  830. error.code = code;
  831. if(message) this.message = this.message + ": " + message;
  832. return error;
  833. };
  834. DOMException.prototype = Error.prototype;
  835. copy(ExceptionCode,DOMException)
  836. /**
  837. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
  838. * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.
  839. * The items in the NodeList are accessible via an integral index, starting from 0.
  840. */
  841. function NodeList() {
  842. };
  843. NodeList.prototype = {
  844. /**
  845. * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
  846. * @standard level1
  847. */
  848. length:0,
  849. /**
  850. * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
  851. * @standard level1
  852. * @param index unsigned long
  853. * Index into the collection.
  854. * @return Node
  855. * The node at the indexth position in the NodeList, or null if that is not a valid index.
  856. */
  857. item: function(index) {
  858. return this[index] || null;
  859. },
  860. toString:function(isHTML,nodeFilter){
  861. for(var buf = [], i = 0;i<this.length;i++){
  862. serializeToString(this[i],buf,isHTML,nodeFilter);
  863. }
  864. return buf.join('');
  865. },
  866. /**
  867. * @private
  868. * @param {function (Node):boolean} predicate
  869. * @returns {Node[]}
  870. */
  871. filter: function (predicate) {
  872. return Array.prototype.filter.call(this, predicate);
  873. },
  874. /**
  875. * @private
  876. * @param {Node} item
  877. * @returns {number}
  878. */
  879. indexOf: function (item) {
  880. return Array.prototype.indexOf.call(this, item);
  881. },
  882. };
  883. function LiveNodeList(node,refresh){
  884. this._node = node;
  885. this._refresh = refresh
  886. _updateLiveList(this);
  887. }
  888. function _updateLiveList(list){
  889. var inc = list._node._inc || list._node.ownerDocument._inc;
  890. if(list._inc != inc){
  891. var ls = list._refresh(list._node);
  892. //console.log(ls.length)
  893. __set__(list,'length',ls.length);
  894. copy(ls,list);
  895. list._inc = inc;
  896. }
  897. }
  898. LiveNodeList.prototype.item = function(i){
  899. _updateLiveList(this);
  900. return this[i];
  901. }
  902. _extends(LiveNodeList,NodeList);
  903. /**
  904. * Objects implementing the NamedNodeMap interface are used
  905. * to represent collections of nodes that can be accessed by name.
  906. * Note that NamedNodeMap does not inherit from NodeList;
  907. * NamedNodeMaps are not maintained in any particular order.
  908. * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index,
  909. * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
  910. * and does not imply that the DOM specifies an order to these Nodes.
  911. * NamedNodeMap objects in the DOM are live.
  912. * used for attributes or DocumentType entities
  913. */
  914. function NamedNodeMap() {
  915. };
  916. function _findNodeIndex(list,node){
  917. var i = list.length;
  918. while(i--){
  919. if(list[i] === node){return i}
  920. }
  921. }
  922. function _addNamedNode(el,list,newAttr,oldAttr){
  923. if(oldAttr){
  924. list[_findNodeIndex(list,oldAttr)] = newAttr;
  925. }else{
  926. list[list.length++] = newAttr;
  927. }
  928. if(el){
  929. newAttr.ownerElement = el;
  930. var doc = el.ownerDocument;
  931. if(doc){
  932. oldAttr && _onRemoveAttribute(doc,el,oldAttr);
  933. _onAddAttribute(doc,el,newAttr);
  934. }
  935. }
  936. }
  937. function _removeNamedNode(el,list,attr){
  938. //console.log('remove attr:'+attr)
  939. var i = _findNodeIndex(list,attr);
  940. if(i>=0){
  941. var lastIndex = list.length-1
  942. while(i<lastIndex){
  943. list[i] = list[++i]
  944. }
  945. list.length = lastIndex;
  946. if(el){
  947. var doc = el.ownerDocument;
  948. if(doc){
  949. _onRemoveAttribute(doc,el,attr);
  950. attr.ownerElement = null;
  951. }
  952. }
  953. }else{
  954. throw new DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
  955. }
  956. }
  957. NamedNodeMap.prototype = {
  958. length:0,
  959. item:NodeList.prototype.item,
  960. getNamedItem: function(key) {
  961. // if(key.indexOf(':')>0 || key == 'xmlns'){
  962. // return null;
  963. // }
  964. //console.log()
  965. var i = this.length;
  966. while(i--){
  967. var attr = this[i];
  968. //console.log(attr.nodeName,key)
  969. if(attr.nodeName == key){
  970. return attr;
  971. }
  972. }
  973. },
  974. setNamedItem: function(attr) {
  975. var el = attr.ownerElement;
  976. if(el && el!=this._ownerElement){
  977. throw new DOMException(INUSE_ATTRIBUTE_ERR);
  978. }
  979. var oldAttr = this.getNamedItem(attr.nodeName);
  980. _addNamedNode(this._ownerElement,this,attr,oldAttr);
  981. return oldAttr;
  982. },
  983. /* returns Node */
  984. setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR
  985. var el = attr.ownerElement, oldAttr;
  986. if(el && el!=this._ownerElement){
  987. throw new DOMException(INUSE_ATTRIBUTE_ERR);
  988. }
  989. oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);
  990. _addNamedNode(this._ownerElement,this,attr,oldAttr);
  991. return oldAttr;
  992. },
  993. /* returns Node */
  994. removeNamedItem: function(key) {
  995. var attr = this.getNamedItem(key);
  996. _removeNamedNode(this._ownerElement,this,attr);
  997. return attr;
  998. },// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
  999. //for level2
  1000. removeNamedItemNS:function(namespaceURI,localName){
  1001. var attr = this.getNamedItemNS(namespaceURI,localName);
  1002. _removeNamedNode(this._ownerElement,this,attr);
  1003. return attr;
  1004. },
  1005. getNamedItemNS: function(namespaceURI, localName) {
  1006. var i = this.length;
  1007. while(i--){
  1008. var node = this[i];
  1009. if(node.localName == localName && node.namespaceURI == namespaceURI){
  1010. return node;
  1011. }
  1012. }
  1013. return null;
  1014. }
  1015. };
  1016. /**
  1017. * The DOMImplementation interface represents an object providing methods
  1018. * which are not dependent on any particular document.
  1019. * Such an object is returned by the `Document.implementation` property.
  1020. *
  1021. * __The individual methods describe the differences compared to the specs.__
  1022. *
  1023. * @constructor
  1024. *
  1025. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN
  1026. * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core (Initial)
  1027. * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core
  1028. * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core
  1029. * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard
  1030. */
  1031. function DOMImplementation() {
  1032. }
  1033. DOMImplementation.prototype = {
  1034. /**
  1035. * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.
  1036. * The different implementations fairly diverged in what kind of features were reported.
  1037. * The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.
  1038. *
  1039. * @deprecated It is deprecated and modern browsers return true in all cases.
  1040. *
  1041. * @param {string} feature
  1042. * @param {string} [version]
  1043. * @returns {boolean} always true
  1044. *
  1045. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
  1046. * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
  1047. * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
  1048. */
  1049. hasFeature: function(feature, version) {
  1050. return true;
  1051. },
  1052. /**
  1053. * Creates an XML Document object of the specified type with its document element.
  1054. *
  1055. * __It behaves slightly different from the description in the living standard__:
  1056. * - There is no interface/class `XMLDocument`, it returns a `Document` instance.
  1057. * - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.
  1058. * - this implementation is not validating names or qualified names
  1059. * (when parsing XML strings, the SAX parser takes care of that)
  1060. *
  1061. * @param {string|null} namespaceURI
  1062. * @param {string} qualifiedName
  1063. * @param {DocumentType=null} doctype
  1064. * @returns {Document}
  1065. *
  1066. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
  1067. * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)
  1068. * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
  1069. *
  1070. * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
  1071. * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
  1072. * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
  1073. */
  1074. createDocument: function(namespaceURI, qualifiedName, doctype){
  1075. var doc = new Document();
  1076. doc.implementation = this;
  1077. doc.childNodes = new NodeList();
  1078. doc.doctype = doctype || null;
  1079. if (doctype){
  1080. doc.appendChild(doctype);
  1081. }
  1082. if (qualifiedName){
  1083. var root = doc.createElementNS(namespaceURI, qualifiedName);
  1084. doc.appendChild(root);
  1085. }
  1086. return doc;
  1087. },
  1088. /**
  1089. * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
  1090. *
  1091. * __This behavior is slightly different from the in the specs__:
  1092. * - this implementation is not validating names or qualified names
  1093. * (when parsing XML strings, the SAX parser takes care of that)
  1094. *
  1095. * @param {string} qualifiedName
  1096. * @param {string} [publicId]
  1097. * @param {string} [systemId]
  1098. * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
  1099. * or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
  1100. *
  1101. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN
  1102. * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core
  1103. * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard
  1104. *
  1105. * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
  1106. * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
  1107. * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
  1108. */
  1109. createDocumentType: function(qualifiedName, publicId, systemId){
  1110. var node = new DocumentType();
  1111. node.name = qualifiedName;
  1112. node.nodeName = qualifiedName;
  1113. node.publicId = publicId || '';
  1114. node.systemId = systemId || '';
  1115. return node;
  1116. }
  1117. };
  1118. /**
  1119. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
  1120. */
  1121. function Node() {
  1122. };
  1123. Node.prototype = {
  1124. firstChild : null,
  1125. lastChild : null,
  1126. previousSibling : null,
  1127. nextSibling : null,
  1128. attributes : null,
  1129. parentNode : null,
  1130. childNodes : null,
  1131. ownerDocument : null,
  1132. nodeValue : null,
  1133. namespaceURI : null,
  1134. prefix : null,
  1135. localName : null,
  1136. // Modified in DOM Level 2:
  1137. insertBefore:function(newChild, refChild){//raises
  1138. return _insertBefore(this,newChild,refChild);
  1139. },
  1140. replaceChild:function(newChild, oldChild){//raises
  1141. _insertBefore(this, newChild,oldChild, assertPreReplacementValidityInDocument);
  1142. if(oldChild){
  1143. this.removeChild(oldChild);
  1144. }
  1145. },
  1146. removeChild:function(oldChild){
  1147. return _removeChild(this,oldChild);
  1148. },
  1149. appendChild:function(newChild){
  1150. return this.insertBefore(newChild,null);
  1151. },
  1152. hasChildNodes:function(){
  1153. return this.firstChild != null;
  1154. },
  1155. cloneNode:function(deep){
  1156. return cloneNode(this.ownerDocument||this,this,deep);
  1157. },
  1158. // Modified in DOM Level 2:
  1159. normalize:function(){
  1160. var child = this.firstChild;
  1161. while(child){
  1162. var next = child.nextSibling;
  1163. if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){
  1164. this.removeChild(next);
  1165. child.appendData(next.data);
  1166. }else{
  1167. child.normalize();
  1168. child = next;
  1169. }
  1170. }
  1171. },
  1172. // Introduced in DOM Level 2:
  1173. isSupported:function(feature, version){
  1174. return this.ownerDocument.implementation.hasFeature(feature,version);
  1175. },
  1176. // Introduced in DOM Level 2:
  1177. hasAttributes:function(){
  1178. return this.attributes.length>0;
  1179. },
  1180. /**
  1181. * Look up the prefix associated to the given namespace URI, starting from this node.
  1182. * **The default namespace declarations are ignored by this method.**
  1183. * See Namespace Prefix Lookup for details on the algorithm used by this method.
  1184. *
  1185. * _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._
  1186. *
  1187. * @param {string | null} namespaceURI
  1188. * @returns {string | null}
  1189. * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix
  1190. * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo
  1191. * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
  1192. * @see https://github.com/xmldom/xmldom/issues/322
  1193. */
  1194. lookupPrefix:function(namespaceURI){
  1195. var el = this;
  1196. while(el){
  1197. var map = el._nsMap;
  1198. //console.dir(map)
  1199. if(map){
  1200. for(var n in map){
  1201. if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
  1202. return n;
  1203. }
  1204. }
  1205. }
  1206. el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
  1207. }
  1208. return null;
  1209. },
  1210. // Introduced in DOM Level 3:
  1211. lookupNamespaceURI:function(prefix){
  1212. var el = this;
  1213. while(el){
  1214. var map = el._nsMap;
  1215. //console.dir(map)
  1216. if(map){
  1217. if(Object.prototype.hasOwnProperty.call(map, prefix)){
  1218. return map[prefix] ;
  1219. }
  1220. }
  1221. el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
  1222. }
  1223. return null;
  1224. },
  1225. // Introduced in DOM Level 3:
  1226. isDefaultNamespace:function(namespaceURI){
  1227. var prefix = this.lookupPrefix(namespaceURI);
  1228. return prefix == null;
  1229. }
  1230. };
  1231. function _xmlEncoder(c){
  1232. return c == '<' && '&lt;' ||
  1233. c == '>' && '&gt;' ||
  1234. c == '&' && '&amp;' ||
  1235. c == '"' && '&quot;' ||
  1236. '&#'+c.charCodeAt()+';'
  1237. }
  1238. copy(NodeType,Node);
  1239. copy(NodeType,Node.prototype);
  1240. /**
  1241. * @param callback return true for continue,false for break
  1242. * @return boolean true: break visit;
  1243. */
  1244. function _visitNode(node,callback){
  1245. if(callback(node)){
  1246. return true;
  1247. }
  1248. if(node = node.firstChild){
  1249. do{
  1250. if(_visitNode(node,callback)){return true}
  1251. }while(node=node.nextSibling)
  1252. }
  1253. }
  1254. function Document(){
  1255. this.ownerDocument = this;
  1256. }
  1257. function _onAddAttribute(doc,el,newAttr){
  1258. doc && doc._inc++;
  1259. var ns = newAttr.namespaceURI ;
  1260. if(ns === NAMESPACE.XMLNS){
  1261. //update namespace
  1262. el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value
  1263. }
  1264. }
  1265. function _onRemoveAttribute(doc,el,newAttr,remove){
  1266. doc && doc._inc++;
  1267. var ns = newAttr.namespaceURI ;
  1268. if(ns === NAMESPACE.XMLNS){
  1269. //update namespace
  1270. delete el._nsMap[newAttr.prefix?newAttr.localName:'']
  1271. }
  1272. }
  1273. /**
  1274. * Updates `el.childNodes`, updating the indexed items and it's `length`.
  1275. * Passing `newChild` means it will be appended.
  1276. * Otherwise it's assumed that an item has been removed,
  1277. * and `el.firstNode` and it's `.nextSibling` are used
  1278. * to walk the current list of child nodes.
  1279. *
  1280. * @param {Document} doc
  1281. * @param {Node} el
  1282. * @param {Node} [newChild]
  1283. * @private
  1284. */
  1285. function _onUpdateChild (doc, el, newChild) {
  1286. if(doc && doc._inc){
  1287. doc._inc++;
  1288. //update childNodes
  1289. var cs = el.childNodes;
  1290. if (newChild) {
  1291. cs[cs.length++] = newChild;
  1292. } else {
  1293. var child = el.firstChild;
  1294. var i = 0;
  1295. while (child) {
  1296. cs[i++] = child;
  1297. child = child.nextSibling;
  1298. }
  1299. cs.length = i;
  1300. delete cs[cs.length];
  1301. }
  1302. }
  1303. }
  1304. /**
  1305. * Removes the connections between `parentNode` and `child`
  1306. * and any existing `child.previousSibling` or `child.nextSibling`.
  1307. *
  1308. * @see https://github.com/xmldom/xmldom/issues/135
  1309. * @see https://github.com/xmldom/xmldom/issues/145
  1310. *
  1311. * @param {Node} parentNode
  1312. * @param {Node} child
  1313. * @returns {Node} the child that was removed.
  1314. * @private
  1315. */
  1316. function _removeChild (parentNode, child) {
  1317. var previous = child.previousSibling;
  1318. var next = child.nextSibling;
  1319. if (previous) {
  1320. previous.nextSibling = next;
  1321. } else {
  1322. parentNode.firstChild = next;
  1323. }
  1324. if (next) {
  1325. next.previousSibling = previous;
  1326. } else {
  1327. parentNode.lastChild = previous;
  1328. }
  1329. child.parentNode = null;
  1330. child.previousSibling = null;
  1331. child.nextSibling = null;
  1332. _onUpdateChild(parentNode.ownerDocument, parentNode);
  1333. return child;
  1334. }
  1335. /**
  1336. * Returns `true` if `node` can be a parent for insertion.
  1337. * @param {Node} node
  1338. * @returns {boolean}
  1339. */
  1340. function hasValidParentNodeType(node) {
  1341. return (
  1342. node &&
  1343. (node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE)
  1344. );
  1345. }
  1346. /**
  1347. * Returns `true` if `node` can be inserted according to it's `nodeType`.
  1348. * @param {Node} node
  1349. * @returns {boolean}
  1350. */
  1351. function hasInsertableNodeType(node) {
  1352. return (
  1353. node &&
  1354. (isElementNode(node) ||
  1355. isTextNode(node) ||
  1356. isDocTypeNode(node) ||
  1357. node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||
  1358. node.nodeType === Node.COMMENT_NODE ||
  1359. node.nodeType === Node.PROCESSING_INSTRUCTION_NODE)
  1360. );
  1361. }
  1362. /**
  1363. * Returns true if `node` is a DOCTYPE node
  1364. * @param {Node} node
  1365. * @returns {boolean}
  1366. */
  1367. function isDocTypeNode(node) {
  1368. return node && node.nodeType === Node.DOCUMENT_TYPE_NODE;
  1369. }
  1370. /**
  1371. * Returns true if the node is an element
  1372. * @param {Node} node
  1373. * @returns {boolean}
  1374. */
  1375. function isElementNode(node) {
  1376. return node && node.nodeType === Node.ELEMENT_NODE;
  1377. }
  1378. /**
  1379. * Returns true if `node` is a text node
  1380. * @param {Node} node
  1381. * @returns {boolean}
  1382. */
  1383. function isTextNode(node) {
  1384. return node && node.nodeType === Node.TEXT_NODE;
  1385. }
  1386. /**
  1387. * Check if en element node can be inserted before `child`, or at the end if child is falsy,
  1388. * according to the presence and position of a doctype node on the same level.
  1389. *
  1390. * @param {Document} doc The document node
  1391. * @param {Node} child the node that would become the nextSibling if the element would be inserted
  1392. * @returns {boolean} `true` if an element can be inserted before child
  1393. * @private
  1394. * https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
  1395. */
  1396. function isElementInsertionPossible(doc, child) {
  1397. var parentChildNodes = doc.childNodes || [];
  1398. if (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {
  1399. return false;
  1400. }
  1401. var docTypeNode = find(parentChildNodes, isDocTypeNode);
  1402. return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
  1403. }
  1404. /**
  1405. * Check if en element node can be inserted before `child`, or at the end if child is falsy,
  1406. * according to the presence and position of a doctype node on the same level.
  1407. *
  1408. * @param {Node} doc The document node
  1409. * @param {Node} child the node that would become the nextSibling if the element would be inserted
  1410. * @returns {boolean} `true` if an element can be inserted before child
  1411. * @private
  1412. * https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
  1413. */
  1414. function isElementReplacementPossible(doc, child) {
  1415. var parentChildNodes = doc.childNodes || [];
  1416. function hasElementChildThatIsNotChild(node) {
  1417. return isElementNode(node) && node !== child;
  1418. }
  1419. if (find(parentChildNodes, hasElementChildThatIsNotChild)) {
  1420. return false;
  1421. }
  1422. var docTypeNode = find(parentChildNodes, isDocTypeNode);
  1423. return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
  1424. }
  1425. /**
  1426. * @private
  1427. * Steps 1-5 of the checks before inserting and before replacing a child are the same.
  1428. *
  1429. * @param {Node} parent the parent node to insert `node` into
  1430. * @param {Node} node the node to insert
  1431. * @param {Node=} child the node that should become the `nextSibling` of `node`
  1432. * @returns {Node}
  1433. * @throws DOMException for several node combinations that would create a DOM that is not well-formed.
  1434. * @throws DOMException if `child` is provided but is not a child of `parent`.
  1435. * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
  1436. * @see https://dom.spec.whatwg.org/#concept-node-replace
  1437. */
  1438. function assertPreInsertionValidity1to5(parent, node, child) {
  1439. // 1. If `parent` is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException.
  1440. if (!hasValidParentNodeType(parent)) {
  1441. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType);
  1442. }
  1443. // 2. If `node` is a host-including inclusive ancestor of `parent`, then throw a "HierarchyRequestError" DOMException.
  1444. // not implemented!
  1445. // 3. If `child` is non-null and its parent is not `parent`, then throw a "NotFoundError" DOMException.
  1446. if (child && child.parentNode !== parent) {
  1447. throw new DOMException(NOT_FOUND_ERR, 'child not in parent');
  1448. }
  1449. if (
  1450. // 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException.
  1451. !hasInsertableNodeType(node) ||
  1452. // 5. If either `node` is a Text node and `parent` is a document,
  1453. // the sax parser currently adds top level text nodes, this will be fixed in 0.9.0
  1454. // || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)
  1455. // or `node` is a doctype and `parent` is not a document, then throw a "HierarchyRequestError" DOMException.
  1456. (isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE)
  1457. ) {
  1458. throw new DOMException(
  1459. HIERARCHY_REQUEST_ERR,
  1460. 'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType
  1461. );
  1462. }
  1463. }
  1464. /**
  1465. * @private
  1466. * Step 6 of the checks before inserting and before replacing a child are different.
  1467. *
  1468. * @param {Document} parent the parent node to insert `node` into
  1469. * @param {Node} node the node to insert
  1470. * @param {Node | undefined} child the node that should become the `nextSibling` of `node`
  1471. * @returns {Node}
  1472. * @throws DOMException for several node combinations that would create a DOM that is not well-formed.
  1473. * @throws DOMException if `child` is provided but is not a child of `parent`.
  1474. * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
  1475. * @see https://dom.spec.whatwg.org/#concept-node-replace
  1476. */
  1477. function assertPreInsertionValidityInDocument(parent, node, child) {
  1478. var parentChildNodes = parent.childNodes || [];
  1479. var nodeChildNodes = node.childNodes || [];
  1480. // DocumentFragment
  1481. if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  1482. var nodeChildElements = nodeChildNodes.filter(isElementNode);
  1483. // If node has more than one element child or has a Text node child.
  1484. if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
  1485. throw new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');
  1486. }
  1487. // Otherwise, if `node` has one element child and either `parent` has an element child,
  1488. // `child` is a doctype, or `child` is non-null and a doctype is following `child`.
  1489. if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {
  1490. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');
  1491. }
  1492. }
  1493. // Element
  1494. if (isElementNode(node)) {
  1495. // `parent` has an element child, `child` is a doctype,
  1496. // or `child` is non-null and a doctype is following `child`.
  1497. if (!isElementInsertionPossible(parent, child)) {
  1498. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');
  1499. }
  1500. }
  1501. // DocumentType
  1502. if (isDocTypeNode(node)) {
  1503. // `parent` has a doctype child,
  1504. if (find(parentChildNodes, isDocTypeNode)) {
  1505. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');
  1506. }
  1507. var parentElementChild = find(parentChildNodes, isElementNode);
  1508. // `child` is non-null and an element is preceding `child`,
  1509. if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
  1510. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');
  1511. }
  1512. // or `child` is null and `parent` has an element child.
  1513. if (!child && parentElementChild) {
  1514. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present');
  1515. }
  1516. }
  1517. }
  1518. /**
  1519. * @private
  1520. * Step 6 of the checks before inserting and before replacing a child are different.
  1521. *
  1522. * @param {Document} parent the parent node to insert `node` into
  1523. * @param {Node} node the node to insert
  1524. * @param {Node | undefined} child the node that should become the `nextSibling` of `node`
  1525. * @returns {Node}
  1526. * @throws DOMException for several node combinations that would create a DOM that is not well-formed.
  1527. * @throws DOMException if `child` is provided but is not a child of `parent`.
  1528. * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
  1529. * @see https://dom.spec.whatwg.org/#concept-node-replace
  1530. */
  1531. function assertPreReplacementValidityInDocument(parent, node, child) {
  1532. var parentChildNodes = parent.childNodes || [];
  1533. var nodeChildNodes = node.childNodes || [];
  1534. // DocumentFragment
  1535. if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  1536. var nodeChildElements = nodeChildNodes.filter(isElementNode);
  1537. // If `node` has more than one element child or has a Text node child.
  1538. if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
  1539. throw new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');
  1540. }
  1541. // Otherwise, if `node` has one element child and either `parent` has an element child that is not `child` or a doctype is following `child`.
  1542. if (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {
  1543. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');
  1544. }
  1545. }
  1546. // Element
  1547. if (isElementNode(node)) {
  1548. // `parent` has an element child that is not `child` or a doctype is following `child`.
  1549. if (!isElementReplacementPossible(parent, child)) {
  1550. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');
  1551. }
  1552. }
  1553. // DocumentType
  1554. if (isDocTypeNode(node)) {
  1555. function hasDoctypeChildThatIsNotChild(node) {
  1556. return isDocTypeNode(node) && node !== child;
  1557. }
  1558. // `parent` has a doctype child that is not `child`,
  1559. if (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) {
  1560. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');
  1561. }
  1562. var parentElementChild = find(parentChildNodes, isElementNode);
  1563. // or an element is preceding `child`.
  1564. if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
  1565. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');
  1566. }
  1567. }
  1568. }
  1569. /**
  1570. * @private
  1571. * @param {Node} parent the parent node to insert `node` into
  1572. * @param {Node} node the node to insert
  1573. * @param {Node=} child the node that should become the `nextSibling` of `node`
  1574. * @returns {Node}
  1575. * @throws DOMException for several node combinations that would create a DOM that is not well-formed.
  1576. * @throws DOMException if `child` is provided but is not a child of `parent`.
  1577. * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
  1578. */
  1579. function _insertBefore(parent, node, child, _inDocumentAssertion) {
  1580. // To ensure pre-insertion validity of a node into a parent before a child, run these steps:
  1581. assertPreInsertionValidity1to5(parent, node, child);
  1582. // If parent is a document, and any of the statements below, switched on the interface node implements,
  1583. // are true, then throw a "HierarchyRequestError" DOMException.
  1584. if (parent.nodeType === Node.DOCUMENT_NODE) {
  1585. (_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);
  1586. }
  1587. var cp = node.parentNode;
  1588. if(cp){
  1589. cp.removeChild(node);//remove and update
  1590. }
  1591. if(node.nodeType === DOCUMENT_FRAGMENT_NODE){
  1592. var newFirst = node.firstChild;
  1593. if (newFirst == null) {
  1594. return node;
  1595. }
  1596. var newLast = node.lastChild;
  1597. }else{
  1598. newFirst = newLast = node;
  1599. }
  1600. var pre = child ? child.previousSibling : parent.lastChild;
  1601. newFirst.previousSibling = pre;
  1602. newLast.nextSibling = child;
  1603. if(pre){
  1604. pre.nextSibling = newFirst;
  1605. }else{
  1606. parent.firstChild = newFirst;
  1607. }
  1608. if(child == null){
  1609. parent.lastChild = newLast;
  1610. }else{
  1611. child.previousSibling = newLast;
  1612. }
  1613. do{
  1614. newFirst.parentNode = parent;
  1615. }while(newFirst !== newLast && (newFirst= newFirst.nextSibling))
  1616. _onUpdateChild(parent.ownerDocument||parent, parent);
  1617. //console.log(parent.lastChild.nextSibling == null)
  1618. if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
  1619. node.firstChild = node.lastChild = null;
  1620. }
  1621. return node;
  1622. }
  1623. /**
  1624. * Appends `newChild` to `parentNode`.
  1625. * If `newChild` is already connected to a `parentNode` it is first removed from it.
  1626. *
  1627. * @see https://github.com/xmldom/xmldom/issues/135
  1628. * @see https://github.com/xmldom/xmldom/issues/145
  1629. * @param {Node} parentNode
  1630. * @param {Node} newChild
  1631. * @returns {Node}
  1632. * @private
  1633. */
  1634. function _appendSingleChild (parentNode, newChild) {
  1635. if (newChild.parentNode) {
  1636. newChild.parentNode.removeChild(newChild);
  1637. }
  1638. newChild.parentNode = parentNode;
  1639. newChild.previousSibling = parentNode.lastChild;
  1640. newChild.nextSibling = null;
  1641. if (newChild.previousSibling) {
  1642. newChild.previousSibling.nextSibling = newChild;
  1643. } else {
  1644. parentNode.firstChild = newChild;
  1645. }
  1646. parentNode.lastChild = newChild;
  1647. _onUpdateChild(parentNode.ownerDocument, parentNode, newChild);
  1648. return newChild;
  1649. }
  1650. Document.prototype = {
  1651. //implementation : null,
  1652. nodeName : '#document',
  1653. nodeType : DOCUMENT_NODE,
  1654. /**
  1655. * The DocumentType node of the document.
  1656. *
  1657. * @readonly
  1658. * @type DocumentType
  1659. */
  1660. doctype : null,
  1661. documentElement : null,
  1662. _inc : 1,
  1663. insertBefore : function(newChild, refChild){//raises
  1664. if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
  1665. var child = newChild.firstChild;
  1666. while(child){
  1667. var next = child.nextSibling;
  1668. this.insertBefore(child,refChild);
  1669. child = next;
  1670. }
  1671. return newChild;
  1672. }
  1673. _insertBefore(this, newChild, refChild);
  1674. newChild.ownerDocument = this;
  1675. if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {
  1676. this.documentElement = newChild;
  1677. }
  1678. return newChild;
  1679. },
  1680. removeChild : function(oldChild){
  1681. if(this.documentElement == oldChild){
  1682. this.documentElement = null;
  1683. }
  1684. return _removeChild(this,oldChild);
  1685. },
  1686. replaceChild: function (newChild, oldChild) {
  1687. //raises
  1688. _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
  1689. newChild.ownerDocument = this;
  1690. if (oldChild) {
  1691. this.removeChild(oldChild);
  1692. }
  1693. if (isElementNode(newChild)) {
  1694. this.documentElement = newChild;
  1695. }
  1696. },
  1697. // Introduced in DOM Level 2:
  1698. importNode : function(importedNode,deep){
  1699. return importNode(this,importedNode,deep);
  1700. },
  1701. // Introduced in DOM Level 2:
  1702. getElementById : function(id){
  1703. var rtv = null;
  1704. _visitNode(this.documentElement,function(node){
  1705. if(node.nodeType == ELEMENT_NODE){
  1706. if(node.getAttribute('id') == id){
  1707. rtv = node;
  1708. return true;
  1709. }
  1710. }
  1711. })
  1712. return rtv;
  1713. },
  1714. /**
  1715. * The `getElementsByClassName` method of `Document` interface returns an array-like object
  1716. * of all child elements which have **all** of the given class name(s).
  1717. *
  1718. * Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.
  1719. *
  1720. *
  1721. * Warning: This is a live LiveNodeList.
  1722. * Changes in the DOM will reflect in the array as the changes occur.
  1723. * If an element selected by this array no longer qualifies for the selector,
  1724. * it will automatically be removed. Be aware of this for iteration purposes.
  1725. *
  1726. * @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace
  1727. *
  1728. * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
  1729. * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
  1730. */
  1731. getElementsByClassName: function(classNames) {
  1732. var classNamesSet = toOrderedSet(classNames)
  1733. return new LiveNodeList(this, function(base) {
  1734. var ls = [];
  1735. if (classNamesSet.length > 0) {
  1736. _visitNode(base.documentElement, function(node) {
  1737. if(node !== base && node.nodeType === ELEMENT_NODE) {
  1738. var nodeClassNames = node.getAttribute('class')
  1739. // can be null if the attribute does not exist
  1740. if (nodeClassNames) {
  1741. // before splitting and iterating just compare them for the most common case
  1742. var matches = classNames === nodeClassNames;
  1743. if (!matches) {
  1744. var nodeClassNamesSet = toOrderedSet(nodeClassNames)
  1745. matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet))
  1746. }
  1747. if(matches) {
  1748. ls.push(node);
  1749. }
  1750. }
  1751. }
  1752. });
  1753. }
  1754. return ls;
  1755. });
  1756. },
  1757. //document factory method:
  1758. createElement : function(tagName){
  1759. var node = new Element();
  1760. node.ownerDocument = this;
  1761. node.nodeName = tagName;
  1762. node.tagName = tagName;
  1763. node.localName = tagName;
  1764. node.childNodes = new NodeList();
  1765. var attrs = node.attributes = new NamedNodeMap();
  1766. attrs._ownerElement = node;
  1767. return node;
  1768. },
  1769. createDocumentFragment : function(){
  1770. var node = new DocumentFragment();
  1771. node.ownerDocument = this;
  1772. node.childNodes = new NodeList();
  1773. return node;
  1774. },
  1775. createTextNode : function(data){
  1776. var node = new Text();
  1777. node.ownerDocument = this;
  1778. node.appendData(data)
  1779. return node;
  1780. },
  1781. createComment : function(data){
  1782. var node = new Comment();
  1783. node.ownerDocument = this;
  1784. node.appendData(data)
  1785. return node;
  1786. },
  1787. createCDATASection : function(data){
  1788. var node = new CDATASection();
  1789. node.ownerDocument = this;
  1790. node.appendData(data)
  1791. return node;
  1792. },
  1793. createProcessingInstruction : function(target,data){
  1794. var node = new ProcessingInstruction();
  1795. node.ownerDocument = this;
  1796. node.tagName = node.target = target;
  1797. node.nodeValue= node.data = data;
  1798. return node;
  1799. },
  1800. createAttribute : function(name){
  1801. var node = new Attr();
  1802. node.ownerDocument = this;
  1803. node.name = name;
  1804. node.nodeName = name;
  1805. node.localName = name;
  1806. node.specified = true;
  1807. return node;
  1808. },
  1809. createEntityReference : function(name){
  1810. var node = new EntityReference();
  1811. node.ownerDocument = this;
  1812. node.nodeName = name;
  1813. return node;
  1814. },
  1815. // Introduced in DOM Level 2:
  1816. createElementNS : function(namespaceURI,qualifiedName){
  1817. var node = new Element();
  1818. var pl = qualifiedName.split(':');
  1819. var attrs = node.attributes = new NamedNodeMap();
  1820. node.childNodes = new NodeList();
  1821. node.ownerDocument = this;
  1822. node.nodeName = qualifiedName;
  1823. node.tagName = qualifiedName;
  1824. node.namespaceURI = namespaceURI;
  1825. if(pl.length == 2){
  1826. node.prefix = pl[0];
  1827. node.localName = pl[1];
  1828. }else{
  1829. //el.prefix = null;
  1830. node.localName = qualifiedName;
  1831. }
  1832. attrs._ownerElement = node;
  1833. return node;
  1834. },
  1835. // Introduced in DOM Level 2:
  1836. createAttributeNS : function(namespaceURI,qualifiedName){
  1837. var node = new Attr();
  1838. var pl = qualifiedName.split(':');
  1839. node.ownerDocument = this;
  1840. node.nodeName = qualifiedName;
  1841. node.name = qualifiedName;
  1842. node.namespaceURI = namespaceURI;
  1843. node.specified = true;
  1844. if(pl.length == 2){
  1845. node.prefix = pl[0];
  1846. node.localName = pl[1];
  1847. }else{
  1848. //el.prefix = null;
  1849. node.localName = qualifiedName;
  1850. }
  1851. return node;
  1852. }
  1853. };
  1854. _extends(Document,Node);
  1855. function Element() {
  1856. this._nsMap = {};
  1857. };
  1858. Element.prototype = {
  1859. nodeType : ELEMENT_NODE,
  1860. hasAttribute : function(name){
  1861. return this.getAttributeNode(name)!=null;
  1862. },
  1863. getAttribute : function(name){
  1864. var attr = this.getAttributeNode(name);
  1865. return attr && attr.value || '';
  1866. },
  1867. getAttributeNode : function(name){
  1868. return this.attributes.getNamedItem(name);
  1869. },
  1870. setAttribute : function(name, value){
  1871. var attr = this.ownerDocument.createAttribute(name);
  1872. attr.value = attr.nodeValue = "" + value;
  1873. this.setAttributeNode(attr)
  1874. },
  1875. removeAttribute : function(name){
  1876. var attr = this.getAttributeNode(name)
  1877. attr && this.removeAttributeNode(attr);
  1878. },
  1879. //four real opeartion method
  1880. appendChild:function(newChild){
  1881. if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
  1882. return this.insertBefore(newChild,null);
  1883. }else{
  1884. return _appendSingleChild(this,newChild);
  1885. }
  1886. },
  1887. setAttributeNode : function(newAttr){
  1888. return this.attributes.setNamedItem(newAttr);
  1889. },
  1890. setAttributeNodeNS : function(newAttr){
  1891. return this.attributes.setNamedItemNS(newAttr);
  1892. },
  1893. removeAttributeNode : function(oldAttr){
  1894. //console.log(this == oldAttr.ownerElement)
  1895. return this.attributes.removeNamedItem(oldAttr.nodeName);
  1896. },
  1897. //get real attribute name,and remove it by removeAttributeNode
  1898. removeAttributeNS : function(namespaceURI, localName){
  1899. var old = this.getAttributeNodeNS(namespaceURI, localName);
  1900. old && this.removeAttributeNode(old);
  1901. },
  1902. hasAttributeNS : function(namespaceURI, localName){
  1903. return this.getAttributeNodeNS(namespaceURI, localName)!=null;
  1904. },
  1905. getAttributeNS : function(namespaceURI, localName){
  1906. var attr = this.getAttributeNodeNS(namespaceURI, localName);
  1907. return attr && attr.value || '';
  1908. },
  1909. setAttributeNS : function(namespaceURI, qualifiedName, value){
  1910. var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
  1911. attr.value = attr.nodeValue = "" + value;
  1912. this.setAttributeNode(attr)
  1913. },
  1914. getAttributeNodeNS : function(namespaceURI, localName){
  1915. return this.attributes.getNamedItemNS(namespaceURI, localName);
  1916. },
  1917. getElementsByTagName : function(tagName){
  1918. return new LiveNodeList(this,function(base){
  1919. var ls = [];
  1920. _visitNode(base,function(node){
  1921. if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){
  1922. ls.push(node);
  1923. }
  1924. });
  1925. return ls;
  1926. });
  1927. },
  1928. getElementsByTagNameNS : function(namespaceURI, localName){
  1929. return new LiveNodeList(this,function(base){
  1930. var ls = [];
  1931. _visitNode(base,function(node){
  1932. if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){
  1933. ls.push(node);
  1934. }
  1935. });
  1936. return ls;
  1937. });
  1938. }
  1939. };
  1940. Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
  1941. Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
  1942. _extends(Element,Node);
  1943. function Attr() {
  1944. };
  1945. Attr.prototype.nodeType = ATTRIBUTE_NODE;
  1946. _extends(Attr,Node);
  1947. function CharacterData() {
  1948. };
  1949. CharacterData.prototype = {
  1950. data : '',
  1951. substringData : function(offset, count) {
  1952. return this.data.substring(offset, offset+count);
  1953. },
  1954. appendData: function(text) {
  1955. text = this.data+text;
  1956. this.nodeValue = this.data = text;
  1957. this.length = text.length;
  1958. },
  1959. insertData: function(offset,text) {
  1960. this.replaceData(offset,0,text);
  1961. },
  1962. appendChild:function(newChild){
  1963. throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
  1964. },
  1965. deleteData: function(offset, count) {
  1966. this.replaceData(offset,count,"");
  1967. },
  1968. replaceData: function(offset, count, text) {
  1969. var start = this.data.substring(0,offset);
  1970. var end = this.data.substring(offset+count);
  1971. text = start + text + end;
  1972. this.nodeValue = this.data = text;
  1973. this.length = text.length;
  1974. }
  1975. }
  1976. _extends(CharacterData,Node);
  1977. function Text() {
  1978. };
  1979. Text.prototype = {
  1980. nodeName : "#text",
  1981. nodeType : TEXT_NODE,
  1982. splitText : function(offset) {
  1983. var text = this.data;
  1984. var newText = text.substring(offset);
  1985. text = text.substring(0, offset);
  1986. this.data = this.nodeValue = text;
  1987. this.length = text.length;
  1988. var newNode = this.ownerDocument.createTextNode(newText);
  1989. if(this.parentNode){
  1990. this.parentNode.insertBefore(newNode, this.nextSibling);
  1991. }
  1992. return newNode;
  1993. }
  1994. }
  1995. _extends(Text,CharacterData);
  1996. function Comment() {
  1997. };
  1998. Comment.prototype = {
  1999. nodeName : "#comment",
  2000. nodeType : COMMENT_NODE
  2001. }
  2002. _extends(Comment,CharacterData);
  2003. function CDATASection() {
  2004. };
  2005. CDATASection.prototype = {
  2006. nodeName : "#cdata-section",
  2007. nodeType : CDATA_SECTION_NODE
  2008. }
  2009. _extends(CDATASection,CharacterData);
  2010. function DocumentType() {
  2011. };
  2012. DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
  2013. _extends(DocumentType,Node);
  2014. function Notation() {
  2015. };
  2016. Notation.prototype.nodeType = NOTATION_NODE;
  2017. _extends(Notation,Node);
  2018. function Entity() {
  2019. };
  2020. Entity.prototype.nodeType = ENTITY_NODE;
  2021. _extends(Entity,Node);
  2022. function EntityReference() {
  2023. };
  2024. EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
  2025. _extends(EntityReference,Node);
  2026. function DocumentFragment() {
  2027. };
  2028. DocumentFragment.prototype.nodeName = "#document-fragment";
  2029. DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
  2030. _extends(DocumentFragment,Node);
  2031. function ProcessingInstruction() {
  2032. }
  2033. ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
  2034. _extends(ProcessingInstruction,Node);
  2035. function XMLSerializer(){}
  2036. XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
  2037. return nodeSerializeToString.call(node,isHtml,nodeFilter);
  2038. }
  2039. Node.prototype.toString = nodeSerializeToString;
  2040. function nodeSerializeToString(isHtml,nodeFilter){
  2041. var buf = [];
  2042. var refNode = this.nodeType == 9 && this.documentElement || this;
  2043. var prefix = refNode.prefix;
  2044. var uri = refNode.namespaceURI;
  2045. if(uri && prefix == null){
  2046. //console.log(prefix)
  2047. var prefix = refNode.lookupPrefix(uri);
  2048. if(prefix == null){
  2049. //isHTML = true;
  2050. var visibleNamespaces=[
  2051. {namespace:uri,prefix:null}
  2052. //{namespace:uri,prefix:''}
  2053. ]
  2054. }
  2055. }
  2056. serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
  2057. //console.log('###',this.nodeType,uri,prefix,buf.join(''))
  2058. return buf.join('');
  2059. }
  2060. function needNamespaceDefine(node, isHTML, visibleNamespaces) {
  2061. var prefix = node.prefix || '';
  2062. var uri = node.namespaceURI;
  2063. // According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,
  2064. // and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :
  2065. // > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.
  2066. // in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)
  2067. // and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :
  2068. // > [...] Furthermore, the attribute value [...] must not be an empty string.
  2069. // so serializing empty namespace value like xmlns:ds="" would produce an invalid XML document.
  2070. if (!uri) {
  2071. return false;
  2072. }
  2073. if (prefix === "xml" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) {
  2074. return false;
  2075. }
  2076. var i = visibleNamespaces.length
  2077. while (i--) {
  2078. var ns = visibleNamespaces[i];
  2079. // get namespace prefix
  2080. if (ns.prefix === prefix) {
  2081. return ns.namespace !== uri;
  2082. }
  2083. }
  2084. return true;
  2085. }
  2086. /**
  2087. * Well-formed constraint: No < in Attribute Values
  2088. * > The replacement text of any entity referred to directly or indirectly
  2089. * > in an attribute value must not contain a <.
  2090. * @see https://www.w3.org/TR/xml11/#CleanAttrVals
  2091. * @see https://www.w3.org/TR/xml11/#NT-AttValue
  2092. *
  2093. * Literal whitespace other than space that appear in attribute values
  2094. * are serialized as their entity references, so they will be preserved.
  2095. * (In contrast to whitespace literals in the input which are normalized to spaces)
  2096. * @see https://www.w3.org/TR/xml11/#AVNormalize
  2097. * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes
  2098. */
  2099. function addSerializedAttribute(buf, qualifiedName, value) {
  2100. buf.push(' ', qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"')
  2101. }
  2102. function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
  2103. if (!visibleNamespaces) {
  2104. visibleNamespaces = [];
  2105. }
  2106. if(nodeFilter){
  2107. node = nodeFilter(node);
  2108. if(node){
  2109. if(typeof node == 'string'){
  2110. buf.push(node);
  2111. return;
  2112. }
  2113. }else{
  2114. return;
  2115. }
  2116. //buf.sort.apply(attrs, attributeSorter);
  2117. }
  2118. switch(node.nodeType){
  2119. case ELEMENT_NODE:
  2120. var attrs = node.attributes;
  2121. var len = attrs.length;
  2122. var child = node.firstChild;
  2123. var nodeName = node.tagName;
  2124. isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML
  2125. var prefixedNodeName = nodeName
  2126. if (!isHTML && !node.prefix && node.namespaceURI) {
  2127. var defaultNS
  2128. // lookup current default ns from `xmlns` attribute
  2129. for (var ai = 0; ai < attrs.length; ai++) {
  2130. if (attrs.item(ai).name === 'xmlns') {
  2131. defaultNS = attrs.item(ai).value
  2132. break
  2133. }
  2134. }
  2135. if (!defaultNS) {
  2136. // lookup current default ns in visibleNamespaces
  2137. for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
  2138. var namespace = visibleNamespaces[nsi]
  2139. if (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {
  2140. defaultNS = namespace.namespace
  2141. break
  2142. }
  2143. }
  2144. }
  2145. if (defaultNS !== node.namespaceURI) {
  2146. for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
  2147. var namespace = visibleNamespaces[nsi]
  2148. if (namespace.namespace === node.namespaceURI) {
  2149. if (namespace.prefix) {
  2150. prefixedNodeName = namespace.prefix + ':' + nodeName
  2151. }
  2152. break
  2153. }
  2154. }
  2155. }
  2156. }
  2157. buf.push('<', prefixedNodeName);
  2158. for(var i=0;i<len;i++){
  2159. // add namespaces for attributes
  2160. var attr = attrs.item(i);
  2161. if (attr.prefix == 'xmlns') {
  2162. visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
  2163. }else if(attr.nodeName == 'xmlns'){
  2164. visibleNamespaces.push({ prefix: '', namespace: attr.value });
  2165. }
  2166. }
  2167. for(var i=0;i<len;i++){
  2168. var attr = attrs.item(i);
  2169. if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
  2170. var prefix = attr.prefix||'';
  2171. var uri = attr.namespaceURI;
  2172. addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
  2173. visibleNamespaces.push({ prefix: prefix, namespace:uri });
  2174. }
  2175. serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
  2176. }
  2177. // add namespace for current node
  2178. if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
  2179. var prefix = node.prefix||'';
  2180. var uri = node.namespaceURI;
  2181. addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
  2182. visibleNamespaces.push({ prefix: prefix, namespace:uri });
  2183. }
  2184. if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
  2185. buf.push('>');
  2186. //if is cdata child node
  2187. if(isHTML && /^script$/i.test(nodeName)){
  2188. while(child){
  2189. if(child.data){
  2190. buf.push(child.data);
  2191. }else{
  2192. serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
  2193. }
  2194. child = child.nextSibling;
  2195. }
  2196. }else
  2197. {
  2198. while(child){
  2199. serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
  2200. child = child.nextSibling;
  2201. }
  2202. }
  2203. buf.push('</',prefixedNodeName,'>');
  2204. }else{
  2205. buf.push('/>');
  2206. }
  2207. // remove added visible namespaces
  2208. //visibleNamespaces.length = startVisibleNamespaces;
  2209. return;
  2210. case DOCUMENT_NODE:
  2211. case DOCUMENT_FRAGMENT_NODE:
  2212. var child = node.firstChild;
  2213. while(child){
  2214. serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
  2215. child = child.nextSibling;
  2216. }
  2217. return;
  2218. case ATTRIBUTE_NODE:
  2219. return addSerializedAttribute(buf, node.name, node.value);
  2220. case TEXT_NODE:
  2221. /**
  2222. * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
  2223. * except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
  2224. * If they are needed elsewhere, they must be escaped using either numeric character references or the strings
  2225. * `&amp;` and `&lt;` respectively.
  2226. * The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility,
  2227. * be escaped using either `&gt;` or a character reference when it appears in the string `]]>` in content,
  2228. * when that string is not marking the end of a CDATA section.
  2229. *
  2230. * In the content of elements, character data is any string of characters
  2231. * which does not contain the start-delimiter of any markup
  2232. * and does not include the CDATA-section-close delimiter, `]]>`.
  2233. *
  2234. * @see https://www.w3.org/TR/xml/#NT-CharData
  2235. * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
  2236. */
  2237. return buf.push(node.data
  2238. .replace(/[<&>]/g,_xmlEncoder)
  2239. );
  2240. case CDATA_SECTION_NODE:
  2241. return buf.push( '<![CDATA[',node.data,']]>');
  2242. case COMMENT_NODE:
  2243. return buf.push( "<!--",node.data,"-->");
  2244. case DOCUMENT_TYPE_NODE:
  2245. var pubid = node.publicId;
  2246. var sysid = node.systemId;
  2247. buf.push('<!DOCTYPE ',node.name);
  2248. if(pubid){
  2249. buf.push(' PUBLIC ', pubid);
  2250. if (sysid && sysid!='.') {
  2251. buf.push(' ', sysid);
  2252. }
  2253. buf.push('>');
  2254. }else if(sysid && sysid!='.'){
  2255. buf.push(' SYSTEM ', sysid, '>');
  2256. }else{
  2257. var sub = node.internalSubset;
  2258. if(sub){
  2259. buf.push(" [",sub,"]");
  2260. }
  2261. buf.push(">");
  2262. }
  2263. return;
  2264. case PROCESSING_INSTRUCTION_NODE:
  2265. return buf.push( "<?",node.target," ",node.data,"?>");
  2266. case ENTITY_REFERENCE_NODE:
  2267. return buf.push( '&',node.nodeName,';');
  2268. //case ENTITY_NODE:
  2269. //case NOTATION_NODE:
  2270. default:
  2271. buf.push('??',node.nodeName);
  2272. }
  2273. }
  2274. function importNode(doc,node,deep){
  2275. var node2;
  2276. switch (node.nodeType) {
  2277. case ELEMENT_NODE:
  2278. node2 = node.cloneNode(false);
  2279. node2.ownerDocument = doc;
  2280. //var attrs = node2.attributes;
  2281. //var len = attrs.length;
  2282. //for(var i=0;i<len;i++){
  2283. //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
  2284. //}
  2285. case DOCUMENT_FRAGMENT_NODE:
  2286. break;
  2287. case ATTRIBUTE_NODE:
  2288. deep = true;
  2289. break;
  2290. //case ENTITY_REFERENCE_NODE:
  2291. //case PROCESSING_INSTRUCTION_NODE:
  2292. ////case TEXT_NODE:
  2293. //case CDATA_SECTION_NODE:
  2294. //case COMMENT_NODE:
  2295. // deep = false;
  2296. // break;
  2297. //case DOCUMENT_NODE:
  2298. //case DOCUMENT_TYPE_NODE:
  2299. //cannot be imported.
  2300. //case ENTITY_NODE:
  2301. //case NOTATION_NODE:
  2302. //can not hit in level3
  2303. //default:throw e;
  2304. }
  2305. if(!node2){
  2306. node2 = node.cloneNode(false);//false
  2307. }
  2308. node2.ownerDocument = doc;
  2309. node2.parentNode = null;
  2310. if(deep){
  2311. var child = node.firstChild;
  2312. while(child){
  2313. node2.appendChild(importNode(doc,child,deep));
  2314. child = child.nextSibling;
  2315. }
  2316. }
  2317. return node2;
  2318. }
  2319. //
  2320. //var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
  2321. // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
  2322. function cloneNode(doc,node,deep){
  2323. var node2 = new node.constructor();
  2324. for (var n in node) {
  2325. if (Object.prototype.hasOwnProperty.call(node, n)) {
  2326. var v = node[n];
  2327. if (typeof v != "object") {
  2328. if (v != node2[n]) {
  2329. node2[n] = v;
  2330. }
  2331. }
  2332. }
  2333. }
  2334. if(node.childNodes){
  2335. node2.childNodes = new NodeList();
  2336. }
  2337. node2.ownerDocument = doc;
  2338. switch (node2.nodeType) {
  2339. case ELEMENT_NODE:
  2340. var attrs = node.attributes;
  2341. var attrs2 = node2.attributes = new NamedNodeMap();
  2342. var len = attrs.length
  2343. attrs2._ownerElement = node2;
  2344. for(var i=0;i<len;i++){
  2345. node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
  2346. }
  2347. break;;
  2348. case ATTRIBUTE_NODE:
  2349. deep = true;
  2350. }
  2351. if(deep){
  2352. var child = node.firstChild;
  2353. while(child){
  2354. node2.appendChild(cloneNode(doc,child,deep));
  2355. child = child.nextSibling;
  2356. }
  2357. }
  2358. return node2;
  2359. }
  2360. function __set__(object,key,value){
  2361. object[key] = value
  2362. }
  2363. //do dynamic
  2364. try{
  2365. if(Object.defineProperty){
  2366. Object.defineProperty(LiveNodeList.prototype,'length',{
  2367. get:function(){
  2368. _updateLiveList(this);
  2369. return this.$$length;
  2370. }
  2371. });
  2372. Object.defineProperty(Node.prototype,'textContent',{
  2373. get:function(){
  2374. return getTextContent(this);
  2375. },
  2376. set:function(data){
  2377. switch(this.nodeType){
  2378. case ELEMENT_NODE:
  2379. case DOCUMENT_FRAGMENT_NODE:
  2380. while(this.firstChild){
  2381. this.removeChild(this.firstChild);
  2382. }
  2383. if(data || String(data)){
  2384. this.appendChild(this.ownerDocument.createTextNode(data));
  2385. }
  2386. break;
  2387. default:
  2388. this.data = data;
  2389. this.value = data;
  2390. this.nodeValue = data;
  2391. }
  2392. }
  2393. })
  2394. function getTextContent(node){
  2395. switch(node.nodeType){
  2396. case ELEMENT_NODE:
  2397. case DOCUMENT_FRAGMENT_NODE:
  2398. var buf = [];
  2399. node = node.firstChild;
  2400. while(node){
  2401. if(node.nodeType!==7 && node.nodeType !==8){
  2402. buf.push(getTextContent(node));
  2403. }
  2404. node = node.nextSibling;
  2405. }
  2406. return buf.join('');
  2407. default:
  2408. return node.nodeValue;
  2409. }
  2410. }
  2411. __set__ = function(object,key,value){
  2412. //console.log(value)
  2413. object['$$'+key] = value
  2414. }
  2415. }
  2416. }catch(e){//ie8
  2417. }
  2418. //if(typeof require == 'function'){
  2419. exports.DocumentType = DocumentType;
  2420. exports.DOMException = DOMException;
  2421. exports.DOMImplementation = DOMImplementation;
  2422. exports.Element = Element;
  2423. exports.Node = Node;
  2424. exports.NodeList = NodeList;
  2425. exports.XMLSerializer = XMLSerializer;
  2426. //}
  2427. },{"./conventions":2}],5:[function(require,module,exports){
  2428. 'use strict';
  2429. var freeze = require('./conventions').freeze;
  2430. /**
  2431. * The entities that are predefined in every XML document.
  2432. *
  2433. * @see https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-predefined-ent W3C XML 1.1
  2434. * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0
  2435. * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML Wikipedia
  2436. */
  2437. exports.XML_ENTITIES = freeze({
  2438. amp: '&',
  2439. apos: "'",
  2440. gt: '>',
  2441. lt: '<',
  2442. quot: '"',
  2443. });
  2444. /**
  2445. * A map of all entities that are detected in an HTML document.
  2446. * They contain all entries from `XML_ENTITIES`.
  2447. *
  2448. * @see XML_ENTITIES
  2449. * @see DOMParser.parseFromString
  2450. * @see DOMImplementation.prototype.createHTMLDocument
  2451. * @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5) Spec
  2452. * @see https://html.spec.whatwg.org/entities.json JSON
  2453. * @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names
  2454. * @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML
  2455. * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML)
  2456. * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML)
  2457. */
  2458. exports.HTML_ENTITIES = freeze({
  2459. Aacute: '\u00C1',
  2460. aacute: '\u00E1',
  2461. Abreve: '\u0102',
  2462. abreve: '\u0103',
  2463. ac: '\u223E',
  2464. acd: '\u223F',
  2465. acE: '\u223E\u0333',
  2466. Acirc: '\u00C2',
  2467. acirc: '\u00E2',
  2468. acute: '\u00B4',
  2469. Acy: '\u0410',
  2470. acy: '\u0430',
  2471. AElig: '\u00C6',
  2472. aelig: '\u00E6',
  2473. af: '\u2061',
  2474. Afr: '\uD835\uDD04',
  2475. afr: '\uD835\uDD1E',
  2476. Agrave: '\u00C0',
  2477. agrave: '\u00E0',
  2478. alefsym: '\u2135',
  2479. aleph: '\u2135',
  2480. Alpha: '\u0391',
  2481. alpha: '\u03B1',
  2482. Amacr: '\u0100',
  2483. amacr: '\u0101',
  2484. amalg: '\u2A3F',
  2485. AMP: '\u0026',
  2486. amp: '\u0026',
  2487. And: '\u2A53',
  2488. and: '\u2227',
  2489. andand: '\u2A55',
  2490. andd: '\u2A5C',
  2491. andslope: '\u2A58',
  2492. andv: '\u2A5A',
  2493. ang: '\u2220',
  2494. ange: '\u29A4',
  2495. angle: '\u2220',
  2496. angmsd: '\u2221',
  2497. angmsdaa: '\u29A8',
  2498. angmsdab: '\u29A9',
  2499. angmsdac: '\u29AA',
  2500. angmsdad: '\u29AB',
  2501. angmsdae: '\u29AC',
  2502. angmsdaf: '\u29AD',
  2503. angmsdag: '\u29AE',
  2504. angmsdah: '\u29AF',
  2505. angrt: '\u221F',
  2506. angrtvb: '\u22BE',
  2507. angrtvbd: '\u299D',
  2508. angsph: '\u2222',
  2509. angst: '\u00C5',
  2510. angzarr: '\u237C',
  2511. Aogon: '\u0104',
  2512. aogon: '\u0105',
  2513. Aopf: '\uD835\uDD38',
  2514. aopf: '\uD835\uDD52',
  2515. ap: '\u2248',
  2516. apacir: '\u2A6F',
  2517. apE: '\u2A70',
  2518. ape: '\u224A',
  2519. apid: '\u224B',
  2520. apos: '\u0027',
  2521. ApplyFunction: '\u2061',
  2522. approx: '\u2248',
  2523. approxeq: '\u224A',
  2524. Aring: '\u00C5',
  2525. aring: '\u00E5',
  2526. Ascr: '\uD835\uDC9C',
  2527. ascr: '\uD835\uDCB6',
  2528. Assign: '\u2254',
  2529. ast: '\u002A',
  2530. asymp: '\u2248',
  2531. asympeq: '\u224D',
  2532. Atilde: '\u00C3',
  2533. atilde: '\u00E3',
  2534. Auml: '\u00C4',
  2535. auml: '\u00E4',
  2536. awconint: '\u2233',
  2537. awint: '\u2A11',
  2538. backcong: '\u224C',
  2539. backepsilon: '\u03F6',
  2540. backprime: '\u2035',
  2541. backsim: '\u223D',
  2542. backsimeq: '\u22CD',
  2543. Backslash: '\u2216',
  2544. Barv: '\u2AE7',
  2545. barvee: '\u22BD',
  2546. Barwed: '\u2306',
  2547. barwed: '\u2305',
  2548. barwedge: '\u2305',
  2549. bbrk: '\u23B5',
  2550. bbrktbrk: '\u23B6',
  2551. bcong: '\u224C',
  2552. Bcy: '\u0411',
  2553. bcy: '\u0431',
  2554. bdquo: '\u201E',
  2555. becaus: '\u2235',
  2556. Because: '\u2235',
  2557. because: '\u2235',
  2558. bemptyv: '\u29B0',
  2559. bepsi: '\u03F6',
  2560. bernou: '\u212C',
  2561. Bernoullis: '\u212C',
  2562. Beta: '\u0392',
  2563. beta: '\u03B2',
  2564. beth: '\u2136',
  2565. between: '\u226C',
  2566. Bfr: '\uD835\uDD05',
  2567. bfr: '\uD835\uDD1F',
  2568. bigcap: '\u22C2',
  2569. bigcirc: '\u25EF',
  2570. bigcup: '\u22C3',
  2571. bigodot: '\u2A00',
  2572. bigoplus: '\u2A01',
  2573. bigotimes: '\u2A02',
  2574. bigsqcup: '\u2A06',
  2575. bigstar: '\u2605',
  2576. bigtriangledown: '\u25BD',
  2577. bigtriangleup: '\u25B3',
  2578. biguplus: '\u2A04',
  2579. bigvee: '\u22C1',
  2580. bigwedge: '\u22C0',
  2581. bkarow: '\u290D',
  2582. blacklozenge: '\u29EB',
  2583. blacksquare: '\u25AA',
  2584. blacktriangle: '\u25B4',
  2585. blacktriangledown: '\u25BE',
  2586. blacktriangleleft: '\u25C2',
  2587. blacktriangleright: '\u25B8',
  2588. blank: '\u2423',
  2589. blk12: '\u2592',
  2590. blk14: '\u2591',
  2591. blk34: '\u2593',
  2592. block: '\u2588',
  2593. bne: '\u003D\u20E5',
  2594. bnequiv: '\u2261\u20E5',
  2595. bNot: '\u2AED',
  2596. bnot: '\u2310',
  2597. Bopf: '\uD835\uDD39',
  2598. bopf: '\uD835\uDD53',
  2599. bot: '\u22A5',
  2600. bottom: '\u22A5',
  2601. bowtie: '\u22C8',
  2602. boxbox: '\u29C9',
  2603. boxDL: '\u2557',
  2604. boxDl: '\u2556',
  2605. boxdL: '\u2555',
  2606. boxdl: '\u2510',
  2607. boxDR: '\u2554',
  2608. boxDr: '\u2553',
  2609. boxdR: '\u2552',
  2610. boxdr: '\u250C',
  2611. boxH: '\u2550',
  2612. boxh: '\u2500',
  2613. boxHD: '\u2566',
  2614. boxHd: '\u2564',
  2615. boxhD: '\u2565',
  2616. boxhd: '\u252C',
  2617. boxHU: '\u2569',
  2618. boxHu: '\u2567',
  2619. boxhU: '\u2568',
  2620. boxhu: '\u2534',
  2621. boxminus: '\u229F',
  2622. boxplus: '\u229E',
  2623. boxtimes: '\u22A0',
  2624. boxUL: '\u255D',
  2625. boxUl: '\u255C',
  2626. boxuL: '\u255B',
  2627. boxul: '\u2518',
  2628. boxUR: '\u255A',
  2629. boxUr: '\u2559',
  2630. boxuR: '\u2558',
  2631. boxur: '\u2514',
  2632. boxV: '\u2551',
  2633. boxv: '\u2502',
  2634. boxVH: '\u256C',
  2635. boxVh: '\u256B',
  2636. boxvH: '\u256A',
  2637. boxvh: '\u253C',
  2638. boxVL: '\u2563',
  2639. boxVl: '\u2562',
  2640. boxvL: '\u2561',
  2641. boxvl: '\u2524',
  2642. boxVR: '\u2560',
  2643. boxVr: '\u255F',
  2644. boxvR: '\u255E',
  2645. boxvr: '\u251C',
  2646. bprime: '\u2035',
  2647. Breve: '\u02D8',
  2648. breve: '\u02D8',
  2649. brvbar: '\u00A6',
  2650. Bscr: '\u212C',
  2651. bscr: '\uD835\uDCB7',
  2652. bsemi: '\u204F',
  2653. bsim: '\u223D',
  2654. bsime: '\u22CD',
  2655. bsol: '\u005C',
  2656. bsolb: '\u29C5',
  2657. bsolhsub: '\u27C8',
  2658. bull: '\u2022',
  2659. bullet: '\u2022',
  2660. bump: '\u224E',
  2661. bumpE: '\u2AAE',
  2662. bumpe: '\u224F',
  2663. Bumpeq: '\u224E',
  2664. bumpeq: '\u224F',
  2665. Cacute: '\u0106',
  2666. cacute: '\u0107',
  2667. Cap: '\u22D2',
  2668. cap: '\u2229',
  2669. capand: '\u2A44',
  2670. capbrcup: '\u2A49',
  2671. capcap: '\u2A4B',
  2672. capcup: '\u2A47',
  2673. capdot: '\u2A40',
  2674. CapitalDifferentialD: '\u2145',
  2675. caps: '\u2229\uFE00',
  2676. caret: '\u2041',
  2677. caron: '\u02C7',
  2678. Cayleys: '\u212D',
  2679. ccaps: '\u2A4D',
  2680. Ccaron: '\u010C',
  2681. ccaron: '\u010D',
  2682. Ccedil: '\u00C7',
  2683. ccedil: '\u00E7',
  2684. Ccirc: '\u0108',
  2685. ccirc: '\u0109',
  2686. Cconint: '\u2230',
  2687. ccups: '\u2A4C',
  2688. ccupssm: '\u2A50',
  2689. Cdot: '\u010A',
  2690. cdot: '\u010B',
  2691. cedil: '\u00B8',
  2692. Cedilla: '\u00B8',
  2693. cemptyv: '\u29B2',
  2694. cent: '\u00A2',
  2695. CenterDot: '\u00B7',
  2696. centerdot: '\u00B7',
  2697. Cfr: '\u212D',
  2698. cfr: '\uD835\uDD20',
  2699. CHcy: '\u0427',
  2700. chcy: '\u0447',
  2701. check: '\u2713',
  2702. checkmark: '\u2713',
  2703. Chi: '\u03A7',
  2704. chi: '\u03C7',
  2705. cir: '\u25CB',
  2706. circ: '\u02C6',
  2707. circeq: '\u2257',
  2708. circlearrowleft: '\u21BA',
  2709. circlearrowright: '\u21BB',
  2710. circledast: '\u229B',
  2711. circledcirc: '\u229A',
  2712. circleddash: '\u229D',
  2713. CircleDot: '\u2299',
  2714. circledR: '\u00AE',
  2715. circledS: '\u24C8',
  2716. CircleMinus: '\u2296',
  2717. CirclePlus: '\u2295',
  2718. CircleTimes: '\u2297',
  2719. cirE: '\u29C3',
  2720. cire: '\u2257',
  2721. cirfnint: '\u2A10',
  2722. cirmid: '\u2AEF',
  2723. cirscir: '\u29C2',
  2724. ClockwiseContourIntegral: '\u2232',
  2725. CloseCurlyDoubleQuote: '\u201D',
  2726. CloseCurlyQuote: '\u2019',
  2727. clubs: '\u2663',
  2728. clubsuit: '\u2663',
  2729. Colon: '\u2237',
  2730. colon: '\u003A',
  2731. Colone: '\u2A74',
  2732. colone: '\u2254',
  2733. coloneq: '\u2254',
  2734. comma: '\u002C',
  2735. commat: '\u0040',
  2736. comp: '\u2201',
  2737. compfn: '\u2218',
  2738. complement: '\u2201',
  2739. complexes: '\u2102',
  2740. cong: '\u2245',
  2741. congdot: '\u2A6D',
  2742. Congruent: '\u2261',
  2743. Conint: '\u222F',
  2744. conint: '\u222E',
  2745. ContourIntegral: '\u222E',
  2746. Copf: '\u2102',
  2747. copf: '\uD835\uDD54',
  2748. coprod: '\u2210',
  2749. Coproduct: '\u2210',
  2750. COPY: '\u00A9',
  2751. copy: '\u00A9',
  2752. copysr: '\u2117',
  2753. CounterClockwiseContourIntegral: '\u2233',
  2754. crarr: '\u21B5',
  2755. Cross: '\u2A2F',
  2756. cross: '\u2717',
  2757. Cscr: '\uD835\uDC9E',
  2758. cscr: '\uD835\uDCB8',
  2759. csub: '\u2ACF',
  2760. csube: '\u2AD1',
  2761. csup: '\u2AD0',
  2762. csupe: '\u2AD2',
  2763. ctdot: '\u22EF',
  2764. cudarrl: '\u2938',
  2765. cudarrr: '\u2935',
  2766. cuepr: '\u22DE',
  2767. cuesc: '\u22DF',
  2768. cularr: '\u21B6',
  2769. cularrp: '\u293D',
  2770. Cup: '\u22D3',
  2771. cup: '\u222A',
  2772. cupbrcap: '\u2A48',
  2773. CupCap: '\u224D',
  2774. cupcap: '\u2A46',
  2775. cupcup: '\u2A4A',
  2776. cupdot: '\u228D',
  2777. cupor: '\u2A45',
  2778. cups: '\u222A\uFE00',
  2779. curarr: '\u21B7',
  2780. curarrm: '\u293C',
  2781. curlyeqprec: '\u22DE',
  2782. curlyeqsucc: '\u22DF',
  2783. curlyvee: '\u22CE',
  2784. curlywedge: '\u22CF',
  2785. curren: '\u00A4',
  2786. curvearrowleft: '\u21B6',
  2787. curvearrowright: '\u21B7',
  2788. cuvee: '\u22CE',
  2789. cuwed: '\u22CF',
  2790. cwconint: '\u2232',
  2791. cwint: '\u2231',
  2792. cylcty: '\u232D',
  2793. Dagger: '\u2021',
  2794. dagger: '\u2020',
  2795. daleth: '\u2138',
  2796. Darr: '\u21A1',
  2797. dArr: '\u21D3',
  2798. darr: '\u2193',
  2799. dash: '\u2010',
  2800. Dashv: '\u2AE4',
  2801. dashv: '\u22A3',
  2802. dbkarow: '\u290F',
  2803. dblac: '\u02DD',
  2804. Dcaron: '\u010E',
  2805. dcaron: '\u010F',
  2806. Dcy: '\u0414',
  2807. dcy: '\u0434',
  2808. DD: '\u2145',
  2809. dd: '\u2146',
  2810. ddagger: '\u2021',
  2811. ddarr: '\u21CA',
  2812. DDotrahd: '\u2911',
  2813. ddotseq: '\u2A77',
  2814. deg: '\u00B0',
  2815. Del: '\u2207',
  2816. Delta: '\u0394',
  2817. delta: '\u03B4',
  2818. demptyv: '\u29B1',
  2819. dfisht: '\u297F',
  2820. Dfr: '\uD835\uDD07',
  2821. dfr: '\uD835\uDD21',
  2822. dHar: '\u2965',
  2823. dharl: '\u21C3',
  2824. dharr: '\u21C2',
  2825. DiacriticalAcute: '\u00B4',
  2826. DiacriticalDot: '\u02D9',
  2827. DiacriticalDoubleAcute: '\u02DD',
  2828. DiacriticalGrave: '\u0060',
  2829. DiacriticalTilde: '\u02DC',
  2830. diam: '\u22C4',
  2831. Diamond: '\u22C4',
  2832. diamond: '\u22C4',
  2833. diamondsuit: '\u2666',
  2834. diams: '\u2666',
  2835. die: '\u00A8',
  2836. DifferentialD: '\u2146',
  2837. digamma: '\u03DD',
  2838. disin: '\u22F2',
  2839. div: '\u00F7',
  2840. divide: '\u00F7',
  2841. divideontimes: '\u22C7',
  2842. divonx: '\u22C7',
  2843. DJcy: '\u0402',
  2844. djcy: '\u0452',
  2845. dlcorn: '\u231E',
  2846. dlcrop: '\u230D',
  2847. dollar: '\u0024',
  2848. Dopf: '\uD835\uDD3B',
  2849. dopf: '\uD835\uDD55',
  2850. Dot: '\u00A8',
  2851. dot: '\u02D9',
  2852. DotDot: '\u20DC',
  2853. doteq: '\u2250',
  2854. doteqdot: '\u2251',
  2855. DotEqual: '\u2250',
  2856. dotminus: '\u2238',
  2857. dotplus: '\u2214',
  2858. dotsquare: '\u22A1',
  2859. doublebarwedge: '\u2306',
  2860. DoubleContourIntegral: '\u222F',
  2861. DoubleDot: '\u00A8',
  2862. DoubleDownArrow: '\u21D3',
  2863. DoubleLeftArrow: '\u21D0',
  2864. DoubleLeftRightArrow: '\u21D4',
  2865. DoubleLeftTee: '\u2AE4',
  2866. DoubleLongLeftArrow: '\u27F8',
  2867. DoubleLongLeftRightArrow: '\u27FA',
  2868. DoubleLongRightArrow: '\u27F9',
  2869. DoubleRightArrow: '\u21D2',
  2870. DoubleRightTee: '\u22A8',
  2871. DoubleUpArrow: '\u21D1',
  2872. DoubleUpDownArrow: '\u21D5',
  2873. DoubleVerticalBar: '\u2225',
  2874. DownArrow: '\u2193',
  2875. Downarrow: '\u21D3',
  2876. downarrow: '\u2193',
  2877. DownArrowBar: '\u2913',
  2878. DownArrowUpArrow: '\u21F5',
  2879. DownBreve: '\u0311',
  2880. downdownarrows: '\u21CA',
  2881. downharpoonleft: '\u21C3',
  2882. downharpoonright: '\u21C2',
  2883. DownLeftRightVector: '\u2950',
  2884. DownLeftTeeVector: '\u295E',
  2885. DownLeftVector: '\u21BD',
  2886. DownLeftVectorBar: '\u2956',
  2887. DownRightTeeVector: '\u295F',
  2888. DownRightVector: '\u21C1',
  2889. DownRightVectorBar: '\u2957',
  2890. DownTee: '\u22A4',
  2891. DownTeeArrow: '\u21A7',
  2892. drbkarow: '\u2910',
  2893. drcorn: '\u231F',
  2894. drcrop: '\u230C',
  2895. Dscr: '\uD835\uDC9F',
  2896. dscr: '\uD835\uDCB9',
  2897. DScy: '\u0405',
  2898. dscy: '\u0455',
  2899. dsol: '\u29F6',
  2900. Dstrok: '\u0110',
  2901. dstrok: '\u0111',
  2902. dtdot: '\u22F1',
  2903. dtri: '\u25BF',
  2904. dtrif: '\u25BE',
  2905. duarr: '\u21F5',
  2906. duhar: '\u296F',
  2907. dwangle: '\u29A6',
  2908. DZcy: '\u040F',
  2909. dzcy: '\u045F',
  2910. dzigrarr: '\u27FF',
  2911. Eacute: '\u00C9',
  2912. eacute: '\u00E9',
  2913. easter: '\u2A6E',
  2914. Ecaron: '\u011A',
  2915. ecaron: '\u011B',
  2916. ecir: '\u2256',
  2917. Ecirc: '\u00CA',
  2918. ecirc: '\u00EA',
  2919. ecolon: '\u2255',
  2920. Ecy: '\u042D',
  2921. ecy: '\u044D',
  2922. eDDot: '\u2A77',
  2923. Edot: '\u0116',
  2924. eDot: '\u2251',
  2925. edot: '\u0117',
  2926. ee: '\u2147',
  2927. efDot: '\u2252',
  2928. Efr: '\uD835\uDD08',
  2929. efr: '\uD835\uDD22',
  2930. eg: '\u2A9A',
  2931. Egrave: '\u00C8',
  2932. egrave: '\u00E8',
  2933. egs: '\u2A96',
  2934. egsdot: '\u2A98',
  2935. el: '\u2A99',
  2936. Element: '\u2208',
  2937. elinters: '\u23E7',
  2938. ell: '\u2113',
  2939. els: '\u2A95',
  2940. elsdot: '\u2A97',
  2941. Emacr: '\u0112',
  2942. emacr: '\u0113',
  2943. empty: '\u2205',
  2944. emptyset: '\u2205',
  2945. EmptySmallSquare: '\u25FB',
  2946. emptyv: '\u2205',
  2947. EmptyVerySmallSquare: '\u25AB',
  2948. emsp: '\u2003',
  2949. emsp13: '\u2004',
  2950. emsp14: '\u2005',
  2951. ENG: '\u014A',
  2952. eng: '\u014B',
  2953. ensp: '\u2002',
  2954. Eogon: '\u0118',
  2955. eogon: '\u0119',
  2956. Eopf: '\uD835\uDD3C',
  2957. eopf: '\uD835\uDD56',
  2958. epar: '\u22D5',
  2959. eparsl: '\u29E3',
  2960. eplus: '\u2A71',
  2961. epsi: '\u03B5',
  2962. Epsilon: '\u0395',
  2963. epsilon: '\u03B5',
  2964. epsiv: '\u03F5',
  2965. eqcirc: '\u2256',
  2966. eqcolon: '\u2255',
  2967. eqsim: '\u2242',
  2968. eqslantgtr: '\u2A96',
  2969. eqslantless: '\u2A95',
  2970. Equal: '\u2A75',
  2971. equals: '\u003D',
  2972. EqualTilde: '\u2242',
  2973. equest: '\u225F',
  2974. Equilibrium: '\u21CC',
  2975. equiv: '\u2261',
  2976. equivDD: '\u2A78',
  2977. eqvparsl: '\u29E5',
  2978. erarr: '\u2971',
  2979. erDot: '\u2253',
  2980. Escr: '\u2130',
  2981. escr: '\u212F',
  2982. esdot: '\u2250',
  2983. Esim: '\u2A73',
  2984. esim: '\u2242',
  2985. Eta: '\u0397',
  2986. eta: '\u03B7',
  2987. ETH: '\u00D0',
  2988. eth: '\u00F0',
  2989. Euml: '\u00CB',
  2990. euml: '\u00EB',
  2991. euro: '\u20AC',
  2992. excl: '\u0021',
  2993. exist: '\u2203',
  2994. Exists: '\u2203',
  2995. expectation: '\u2130',
  2996. ExponentialE: '\u2147',
  2997. exponentiale: '\u2147',
  2998. fallingdotseq: '\u2252',
  2999. Fcy: '\u0424',
  3000. fcy: '\u0444',
  3001. female: '\u2640',
  3002. ffilig: '\uFB03',
  3003. fflig: '\uFB00',
  3004. ffllig: '\uFB04',
  3005. Ffr: '\uD835\uDD09',
  3006. ffr: '\uD835\uDD23',
  3007. filig: '\uFB01',
  3008. FilledSmallSquare: '\u25FC',
  3009. FilledVerySmallSquare: '\u25AA',
  3010. fjlig: '\u0066\u006A',
  3011. flat: '\u266D',
  3012. fllig: '\uFB02',
  3013. fltns: '\u25B1',
  3014. fnof: '\u0192',
  3015. Fopf: '\uD835\uDD3D',
  3016. fopf: '\uD835\uDD57',
  3017. ForAll: '\u2200',
  3018. forall: '\u2200',
  3019. fork: '\u22D4',
  3020. forkv: '\u2AD9',
  3021. Fouriertrf: '\u2131',
  3022. fpartint: '\u2A0D',
  3023. frac12: '\u00BD',
  3024. frac13: '\u2153',
  3025. frac14: '\u00BC',
  3026. frac15: '\u2155',
  3027. frac16: '\u2159',
  3028. frac18: '\u215B',
  3029. frac23: '\u2154',
  3030. frac25: '\u2156',
  3031. frac34: '\u00BE',
  3032. frac35: '\u2157',
  3033. frac38: '\u215C',
  3034. frac45: '\u2158',
  3035. frac56: '\u215A',
  3036. frac58: '\u215D',
  3037. frac78: '\u215E',
  3038. frasl: '\u2044',
  3039. frown: '\u2322',
  3040. Fscr: '\u2131',
  3041. fscr: '\uD835\uDCBB',
  3042. gacute: '\u01F5',
  3043. Gamma: '\u0393',
  3044. gamma: '\u03B3',
  3045. Gammad: '\u03DC',
  3046. gammad: '\u03DD',
  3047. gap: '\u2A86',
  3048. Gbreve: '\u011E',
  3049. gbreve: '\u011F',
  3050. Gcedil: '\u0122',
  3051. Gcirc: '\u011C',
  3052. gcirc: '\u011D',
  3053. Gcy: '\u0413',
  3054. gcy: '\u0433',
  3055. Gdot: '\u0120',
  3056. gdot: '\u0121',
  3057. gE: '\u2267',
  3058. ge: '\u2265',
  3059. gEl: '\u2A8C',
  3060. gel: '\u22DB',
  3061. geq: '\u2265',
  3062. geqq: '\u2267',
  3063. geqslant: '\u2A7E',
  3064. ges: '\u2A7E',
  3065. gescc: '\u2AA9',
  3066. gesdot: '\u2A80',
  3067. gesdoto: '\u2A82',
  3068. gesdotol: '\u2A84',
  3069. gesl: '\u22DB\uFE00',
  3070. gesles: '\u2A94',
  3071. Gfr: '\uD835\uDD0A',
  3072. gfr: '\uD835\uDD24',
  3073. Gg: '\u22D9',
  3074. gg: '\u226B',
  3075. ggg: '\u22D9',
  3076. gimel: '\u2137',
  3077. GJcy: '\u0403',
  3078. gjcy: '\u0453',
  3079. gl: '\u2277',
  3080. gla: '\u2AA5',
  3081. glE: '\u2A92',
  3082. glj: '\u2AA4',
  3083. gnap: '\u2A8A',
  3084. gnapprox: '\u2A8A',
  3085. gnE: '\u2269',
  3086. gne: '\u2A88',
  3087. gneq: '\u2A88',
  3088. gneqq: '\u2269',
  3089. gnsim: '\u22E7',
  3090. Gopf: '\uD835\uDD3E',
  3091. gopf: '\uD835\uDD58',
  3092. grave: '\u0060',
  3093. GreaterEqual: '\u2265',
  3094. GreaterEqualLess: '\u22DB',
  3095. GreaterFullEqual: '\u2267',
  3096. GreaterGreater: '\u2AA2',
  3097. GreaterLess: '\u2277',
  3098. GreaterSlantEqual: '\u2A7E',
  3099. GreaterTilde: '\u2273',
  3100. Gscr: '\uD835\uDCA2',
  3101. gscr: '\u210A',
  3102. gsim: '\u2273',
  3103. gsime: '\u2A8E',
  3104. gsiml: '\u2A90',
  3105. Gt: '\u226B',
  3106. GT: '\u003E',
  3107. gt: '\u003E',
  3108. gtcc: '\u2AA7',
  3109. gtcir: '\u2A7A',
  3110. gtdot: '\u22D7',
  3111. gtlPar: '\u2995',
  3112. gtquest: '\u2A7C',
  3113. gtrapprox: '\u2A86',
  3114. gtrarr: '\u2978',
  3115. gtrdot: '\u22D7',
  3116. gtreqless: '\u22DB',
  3117. gtreqqless: '\u2A8C',
  3118. gtrless: '\u2277',
  3119. gtrsim: '\u2273',
  3120. gvertneqq: '\u2269\uFE00',
  3121. gvnE: '\u2269\uFE00',
  3122. Hacek: '\u02C7',
  3123. hairsp: '\u200A',
  3124. half: '\u00BD',
  3125. hamilt: '\u210B',
  3126. HARDcy: '\u042A',
  3127. hardcy: '\u044A',
  3128. hArr: '\u21D4',
  3129. harr: '\u2194',
  3130. harrcir: '\u2948',
  3131. harrw: '\u21AD',
  3132. Hat: '\u005E',
  3133. hbar: '\u210F',
  3134. Hcirc: '\u0124',
  3135. hcirc: '\u0125',
  3136. hearts: '\u2665',
  3137. heartsuit: '\u2665',
  3138. hellip: '\u2026',
  3139. hercon: '\u22B9',
  3140. Hfr: '\u210C',
  3141. hfr: '\uD835\uDD25',
  3142. HilbertSpace: '\u210B',
  3143. hksearow: '\u2925',
  3144. hkswarow: '\u2926',
  3145. hoarr: '\u21FF',
  3146. homtht: '\u223B',
  3147. hookleftarrow: '\u21A9',
  3148. hookrightarrow: '\u21AA',
  3149. Hopf: '\u210D',
  3150. hopf: '\uD835\uDD59',
  3151. horbar: '\u2015',
  3152. HorizontalLine: '\u2500',
  3153. Hscr: '\u210B',
  3154. hscr: '\uD835\uDCBD',
  3155. hslash: '\u210F',
  3156. Hstrok: '\u0126',
  3157. hstrok: '\u0127',
  3158. HumpDownHump: '\u224E',
  3159. HumpEqual: '\u224F',
  3160. hybull: '\u2043',
  3161. hyphen: '\u2010',
  3162. Iacute: '\u00CD',
  3163. iacute: '\u00ED',
  3164. ic: '\u2063',
  3165. Icirc: '\u00CE',
  3166. icirc: '\u00EE',
  3167. Icy: '\u0418',
  3168. icy: '\u0438',
  3169. Idot: '\u0130',
  3170. IEcy: '\u0415',
  3171. iecy: '\u0435',
  3172. iexcl: '\u00A1',
  3173. iff: '\u21D4',
  3174. Ifr: '\u2111',
  3175. ifr: '\uD835\uDD26',
  3176. Igrave: '\u00CC',
  3177. igrave: '\u00EC',
  3178. ii: '\u2148',
  3179. iiiint: '\u2A0C',
  3180. iiint: '\u222D',
  3181. iinfin: '\u29DC',
  3182. iiota: '\u2129',
  3183. IJlig: '\u0132',
  3184. ijlig: '\u0133',
  3185. Im: '\u2111',
  3186. Imacr: '\u012A',
  3187. imacr: '\u012B',
  3188. image: '\u2111',
  3189. ImaginaryI: '\u2148',
  3190. imagline: '\u2110',
  3191. imagpart: '\u2111',
  3192. imath: '\u0131',
  3193. imof: '\u22B7',
  3194. imped: '\u01B5',
  3195. Implies: '\u21D2',
  3196. in: '\u2208',
  3197. incare: '\u2105',
  3198. infin: '\u221E',
  3199. infintie: '\u29DD',
  3200. inodot: '\u0131',
  3201. Int: '\u222C',
  3202. int: '\u222B',
  3203. intcal: '\u22BA',
  3204. integers: '\u2124',
  3205. Integral: '\u222B',
  3206. intercal: '\u22BA',
  3207. Intersection: '\u22C2',
  3208. intlarhk: '\u2A17',
  3209. intprod: '\u2A3C',
  3210. InvisibleComma: '\u2063',
  3211. InvisibleTimes: '\u2062',
  3212. IOcy: '\u0401',
  3213. iocy: '\u0451',
  3214. Iogon: '\u012E',
  3215. iogon: '\u012F',
  3216. Iopf: '\uD835\uDD40',
  3217. iopf: '\uD835\uDD5A',
  3218. Iota: '\u0399',
  3219. iota: '\u03B9',
  3220. iprod: '\u2A3C',
  3221. iquest: '\u00BF',
  3222. Iscr: '\u2110',
  3223. iscr: '\uD835\uDCBE',
  3224. isin: '\u2208',
  3225. isindot: '\u22F5',
  3226. isinE: '\u22F9',
  3227. isins: '\u22F4',
  3228. isinsv: '\u22F3',
  3229. isinv: '\u2208',
  3230. it: '\u2062',
  3231. Itilde: '\u0128',
  3232. itilde: '\u0129',
  3233. Iukcy: '\u0406',
  3234. iukcy: '\u0456',
  3235. Iuml: '\u00CF',
  3236. iuml: '\u00EF',
  3237. Jcirc: '\u0134',
  3238. jcirc: '\u0135',
  3239. Jcy: '\u0419',
  3240. jcy: '\u0439',
  3241. Jfr: '\uD835\uDD0D',
  3242. jfr: '\uD835\uDD27',
  3243. jmath: '\u0237',
  3244. Jopf: '\uD835\uDD41',
  3245. jopf: '\uD835\uDD5B',
  3246. Jscr: '\uD835\uDCA5',
  3247. jscr: '\uD835\uDCBF',
  3248. Jsercy: '\u0408',
  3249. jsercy: '\u0458',
  3250. Jukcy: '\u0404',
  3251. jukcy: '\u0454',
  3252. Kappa: '\u039A',
  3253. kappa: '\u03BA',
  3254. kappav: '\u03F0',
  3255. Kcedil: '\u0136',
  3256. kcedil: '\u0137',
  3257. Kcy: '\u041A',
  3258. kcy: '\u043A',
  3259. Kfr: '\uD835\uDD0E',
  3260. kfr: '\uD835\uDD28',
  3261. kgreen: '\u0138',
  3262. KHcy: '\u0425',
  3263. khcy: '\u0445',
  3264. KJcy: '\u040C',
  3265. kjcy: '\u045C',
  3266. Kopf: '\uD835\uDD42',
  3267. kopf: '\uD835\uDD5C',
  3268. Kscr: '\uD835\uDCA6',
  3269. kscr: '\uD835\uDCC0',
  3270. lAarr: '\u21DA',
  3271. Lacute: '\u0139',
  3272. lacute: '\u013A',
  3273. laemptyv: '\u29B4',
  3274. lagran: '\u2112',
  3275. Lambda: '\u039B',
  3276. lambda: '\u03BB',
  3277. Lang: '\u27EA',
  3278. lang: '\u27E8',
  3279. langd: '\u2991',
  3280. langle: '\u27E8',
  3281. lap: '\u2A85',
  3282. Laplacetrf: '\u2112',
  3283. laquo: '\u00AB',
  3284. Larr: '\u219E',
  3285. lArr: '\u21D0',
  3286. larr: '\u2190',
  3287. larrb: '\u21E4',
  3288. larrbfs: '\u291F',
  3289. larrfs: '\u291D',
  3290. larrhk: '\u21A9',
  3291. larrlp: '\u21AB',
  3292. larrpl: '\u2939',
  3293. larrsim: '\u2973',
  3294. larrtl: '\u21A2',
  3295. lat: '\u2AAB',
  3296. lAtail: '\u291B',
  3297. latail: '\u2919',
  3298. late: '\u2AAD',
  3299. lates: '\u2AAD\uFE00',
  3300. lBarr: '\u290E',
  3301. lbarr: '\u290C',
  3302. lbbrk: '\u2772',
  3303. lbrace: '\u007B',
  3304. lbrack: '\u005B',
  3305. lbrke: '\u298B',
  3306. lbrksld: '\u298F',
  3307. lbrkslu: '\u298D',
  3308. Lcaron: '\u013D',
  3309. lcaron: '\u013E',
  3310. Lcedil: '\u013B',
  3311. lcedil: '\u013C',
  3312. lceil: '\u2308',
  3313. lcub: '\u007B',
  3314. Lcy: '\u041B',
  3315. lcy: '\u043B',
  3316. ldca: '\u2936',
  3317. ldquo: '\u201C',
  3318. ldquor: '\u201E',
  3319. ldrdhar: '\u2967',
  3320. ldrushar: '\u294B',
  3321. ldsh: '\u21B2',
  3322. lE: '\u2266',
  3323. le: '\u2264',
  3324. LeftAngleBracket: '\u27E8',
  3325. LeftArrow: '\u2190',
  3326. Leftarrow: '\u21D0',
  3327. leftarrow: '\u2190',
  3328. LeftArrowBar: '\u21E4',
  3329. LeftArrowRightArrow: '\u21C6',
  3330. leftarrowtail: '\u21A2',
  3331. LeftCeiling: '\u2308',
  3332. LeftDoubleBracket: '\u27E6',
  3333. LeftDownTeeVector: '\u2961',
  3334. LeftDownVector: '\u21C3',
  3335. LeftDownVectorBar: '\u2959',
  3336. LeftFloor: '\u230A',
  3337. leftharpoondown: '\u21BD',
  3338. leftharpoonup: '\u21BC',
  3339. leftleftarrows: '\u21C7',
  3340. LeftRightArrow: '\u2194',
  3341. Leftrightarrow: '\u21D4',
  3342. leftrightarrow: '\u2194',
  3343. leftrightarrows: '\u21C6',
  3344. leftrightharpoons: '\u21CB',
  3345. leftrightsquigarrow: '\u21AD',
  3346. LeftRightVector: '\u294E',
  3347. LeftTee: '\u22A3',
  3348. LeftTeeArrow: '\u21A4',
  3349. LeftTeeVector: '\u295A',
  3350. leftthreetimes: '\u22CB',
  3351. LeftTriangle: '\u22B2',
  3352. LeftTriangleBar: '\u29CF',
  3353. LeftTriangleEqual: '\u22B4',
  3354. LeftUpDownVector: '\u2951',
  3355. LeftUpTeeVector: '\u2960',
  3356. LeftUpVector: '\u21BF',
  3357. LeftUpVectorBar: '\u2958',
  3358. LeftVector: '\u21BC',
  3359. LeftVectorBar: '\u2952',
  3360. lEg: '\u2A8B',
  3361. leg: '\u22DA',
  3362. leq: '\u2264',
  3363. leqq: '\u2266',
  3364. leqslant: '\u2A7D',
  3365. les: '\u2A7D',
  3366. lescc: '\u2AA8',
  3367. lesdot: '\u2A7F',
  3368. lesdoto: '\u2A81',
  3369. lesdotor: '\u2A83',
  3370. lesg: '\u22DA\uFE00',
  3371. lesges: '\u2A93',
  3372. lessapprox: '\u2A85',
  3373. lessdot: '\u22D6',
  3374. lesseqgtr: '\u22DA',
  3375. lesseqqgtr: '\u2A8B',
  3376. LessEqualGreater: '\u22DA',
  3377. LessFullEqual: '\u2266',
  3378. LessGreater: '\u2276',
  3379. lessgtr: '\u2276',
  3380. LessLess: '\u2AA1',
  3381. lesssim: '\u2272',
  3382. LessSlantEqual: '\u2A7D',
  3383. LessTilde: '\u2272',
  3384. lfisht: '\u297C',
  3385. lfloor: '\u230A',
  3386. Lfr: '\uD835\uDD0F',
  3387. lfr: '\uD835\uDD29',
  3388. lg: '\u2276',
  3389. lgE: '\u2A91',
  3390. lHar: '\u2962',
  3391. lhard: '\u21BD',
  3392. lharu: '\u21BC',
  3393. lharul: '\u296A',
  3394. lhblk: '\u2584',
  3395. LJcy: '\u0409',
  3396. ljcy: '\u0459',
  3397. Ll: '\u22D8',
  3398. ll: '\u226A',
  3399. llarr: '\u21C7',
  3400. llcorner: '\u231E',
  3401. Lleftarrow: '\u21DA',
  3402. llhard: '\u296B',
  3403. lltri: '\u25FA',
  3404. Lmidot: '\u013F',
  3405. lmidot: '\u0140',
  3406. lmoust: '\u23B0',
  3407. lmoustache: '\u23B0',
  3408. lnap: '\u2A89',
  3409. lnapprox: '\u2A89',
  3410. lnE: '\u2268',
  3411. lne: '\u2A87',
  3412. lneq: '\u2A87',
  3413. lneqq: '\u2268',
  3414. lnsim: '\u22E6',
  3415. loang: '\u27EC',
  3416. loarr: '\u21FD',
  3417. lobrk: '\u27E6',
  3418. LongLeftArrow: '\u27F5',
  3419. Longleftarrow: '\u27F8',
  3420. longleftarrow: '\u27F5',
  3421. LongLeftRightArrow: '\u27F7',
  3422. Longleftrightarrow: '\u27FA',
  3423. longleftrightarrow: '\u27F7',
  3424. longmapsto: '\u27FC',
  3425. LongRightArrow: '\u27F6',
  3426. Longrightarrow: '\u27F9',
  3427. longrightarrow: '\u27F6',
  3428. looparrowleft: '\u21AB',
  3429. looparrowright: '\u21AC',
  3430. lopar: '\u2985',
  3431. Lopf: '\uD835\uDD43',
  3432. lopf: '\uD835\uDD5D',
  3433. loplus: '\u2A2D',
  3434. lotimes: '\u2A34',
  3435. lowast: '\u2217',
  3436. lowbar: '\u005F',
  3437. LowerLeftArrow: '\u2199',
  3438. LowerRightArrow: '\u2198',
  3439. loz: '\u25CA',
  3440. lozenge: '\u25CA',
  3441. lozf: '\u29EB',
  3442. lpar: '\u0028',
  3443. lparlt: '\u2993',
  3444. lrarr: '\u21C6',
  3445. lrcorner: '\u231F',
  3446. lrhar: '\u21CB',
  3447. lrhard: '\u296D',
  3448. lrm: '\u200E',
  3449. lrtri: '\u22BF',
  3450. lsaquo: '\u2039',
  3451. Lscr: '\u2112',
  3452. lscr: '\uD835\uDCC1',
  3453. Lsh: '\u21B0',
  3454. lsh: '\u21B0',
  3455. lsim: '\u2272',
  3456. lsime: '\u2A8D',
  3457. lsimg: '\u2A8F',
  3458. lsqb: '\u005B',
  3459. lsquo: '\u2018',
  3460. lsquor: '\u201A',
  3461. Lstrok: '\u0141',
  3462. lstrok: '\u0142',
  3463. Lt: '\u226A',
  3464. LT: '\u003C',
  3465. lt: '\u003C',
  3466. ltcc: '\u2AA6',
  3467. ltcir: '\u2A79',
  3468. ltdot: '\u22D6',
  3469. lthree: '\u22CB',
  3470. ltimes: '\u22C9',
  3471. ltlarr: '\u2976',
  3472. ltquest: '\u2A7B',
  3473. ltri: '\u25C3',
  3474. ltrie: '\u22B4',
  3475. ltrif: '\u25C2',
  3476. ltrPar: '\u2996',
  3477. lurdshar: '\u294A',
  3478. luruhar: '\u2966',
  3479. lvertneqq: '\u2268\uFE00',
  3480. lvnE: '\u2268\uFE00',
  3481. macr: '\u00AF',
  3482. male: '\u2642',
  3483. malt: '\u2720',
  3484. maltese: '\u2720',
  3485. Map: '\u2905',
  3486. map: '\u21A6',
  3487. mapsto: '\u21A6',
  3488. mapstodown: '\u21A7',
  3489. mapstoleft: '\u21A4',
  3490. mapstoup: '\u21A5',
  3491. marker: '\u25AE',
  3492. mcomma: '\u2A29',
  3493. Mcy: '\u041C',
  3494. mcy: '\u043C',
  3495. mdash: '\u2014',
  3496. mDDot: '\u223A',
  3497. measuredangle: '\u2221',
  3498. MediumSpace: '\u205F',
  3499. Mellintrf: '\u2133',
  3500. Mfr: '\uD835\uDD10',
  3501. mfr: '\uD835\uDD2A',
  3502. mho: '\u2127',
  3503. micro: '\u00B5',
  3504. mid: '\u2223',
  3505. midast: '\u002A',
  3506. midcir: '\u2AF0',
  3507. middot: '\u00B7',
  3508. minus: '\u2212',
  3509. minusb: '\u229F',
  3510. minusd: '\u2238',
  3511. minusdu: '\u2A2A',
  3512. MinusPlus: '\u2213',
  3513. mlcp: '\u2ADB',
  3514. mldr: '\u2026',
  3515. mnplus: '\u2213',
  3516. models: '\u22A7',
  3517. Mopf: '\uD835\uDD44',
  3518. mopf: '\uD835\uDD5E',
  3519. mp: '\u2213',
  3520. Mscr: '\u2133',
  3521. mscr: '\uD835\uDCC2',
  3522. mstpos: '\u223E',
  3523. Mu: '\u039C',
  3524. mu: '\u03BC',
  3525. multimap: '\u22B8',
  3526. mumap: '\u22B8',
  3527. nabla: '\u2207',
  3528. Nacute: '\u0143',
  3529. nacute: '\u0144',
  3530. nang: '\u2220\u20D2',
  3531. nap: '\u2249',
  3532. napE: '\u2A70\u0338',
  3533. napid: '\u224B\u0338',
  3534. napos: '\u0149',
  3535. napprox: '\u2249',
  3536. natur: '\u266E',
  3537. natural: '\u266E',
  3538. naturals: '\u2115',
  3539. nbsp: '\u00A0',
  3540. nbump: '\u224E\u0338',
  3541. nbumpe: '\u224F\u0338',
  3542. ncap: '\u2A43',
  3543. Ncaron: '\u0147',
  3544. ncaron: '\u0148',
  3545. Ncedil: '\u0145',
  3546. ncedil: '\u0146',
  3547. ncong: '\u2247',
  3548. ncongdot: '\u2A6D\u0338',
  3549. ncup: '\u2A42',
  3550. Ncy: '\u041D',
  3551. ncy: '\u043D',
  3552. ndash: '\u2013',
  3553. ne: '\u2260',
  3554. nearhk: '\u2924',
  3555. neArr: '\u21D7',
  3556. nearr: '\u2197',
  3557. nearrow: '\u2197',
  3558. nedot: '\u2250\u0338',
  3559. NegativeMediumSpace: '\u200B',
  3560. NegativeThickSpace: '\u200B',
  3561. NegativeThinSpace: '\u200B',
  3562. NegativeVeryThinSpace: '\u200B',
  3563. nequiv: '\u2262',
  3564. nesear: '\u2928',
  3565. nesim: '\u2242\u0338',
  3566. NestedGreaterGreater: '\u226B',
  3567. NestedLessLess: '\u226A',
  3568. NewLine: '\u000A',
  3569. nexist: '\u2204',
  3570. nexists: '\u2204',
  3571. Nfr: '\uD835\uDD11',
  3572. nfr: '\uD835\uDD2B',
  3573. ngE: '\u2267\u0338',
  3574. nge: '\u2271',
  3575. ngeq: '\u2271',
  3576. ngeqq: '\u2267\u0338',
  3577. ngeqslant: '\u2A7E\u0338',
  3578. nges: '\u2A7E\u0338',
  3579. nGg: '\u22D9\u0338',
  3580. ngsim: '\u2275',
  3581. nGt: '\u226B\u20D2',
  3582. ngt: '\u226F',
  3583. ngtr: '\u226F',
  3584. nGtv: '\u226B\u0338',
  3585. nhArr: '\u21CE',
  3586. nharr: '\u21AE',
  3587. nhpar: '\u2AF2',
  3588. ni: '\u220B',
  3589. nis: '\u22FC',
  3590. nisd: '\u22FA',
  3591. niv: '\u220B',
  3592. NJcy: '\u040A',
  3593. njcy: '\u045A',
  3594. nlArr: '\u21CD',
  3595. nlarr: '\u219A',
  3596. nldr: '\u2025',
  3597. nlE: '\u2266\u0338',
  3598. nle: '\u2270',
  3599. nLeftarrow: '\u21CD',
  3600. nleftarrow: '\u219A',
  3601. nLeftrightarrow: '\u21CE',
  3602. nleftrightarrow: '\u21AE',
  3603. nleq: '\u2270',
  3604. nleqq: '\u2266\u0338',
  3605. nleqslant: '\u2A7D\u0338',
  3606. nles: '\u2A7D\u0338',
  3607. nless: '\u226E',
  3608. nLl: '\u22D8\u0338',
  3609. nlsim: '\u2274',
  3610. nLt: '\u226A\u20D2',
  3611. nlt: '\u226E',
  3612. nltri: '\u22EA',
  3613. nltrie: '\u22EC',
  3614. nLtv: '\u226A\u0338',
  3615. nmid: '\u2224',
  3616. NoBreak: '\u2060',
  3617. NonBreakingSpace: '\u00A0',
  3618. Nopf: '\u2115',
  3619. nopf: '\uD835\uDD5F',
  3620. Not: '\u2AEC',
  3621. not: '\u00AC',
  3622. NotCongruent: '\u2262',
  3623. NotCupCap: '\u226D',
  3624. NotDoubleVerticalBar: '\u2226',
  3625. NotElement: '\u2209',
  3626. NotEqual: '\u2260',
  3627. NotEqualTilde: '\u2242\u0338',
  3628. NotExists: '\u2204',
  3629. NotGreater: '\u226F',
  3630. NotGreaterEqual: '\u2271',
  3631. NotGreaterFullEqual: '\u2267\u0338',
  3632. NotGreaterGreater: '\u226B\u0338',
  3633. NotGreaterLess: '\u2279',
  3634. NotGreaterSlantEqual: '\u2A7E\u0338',
  3635. NotGreaterTilde: '\u2275',
  3636. NotHumpDownHump: '\u224E\u0338',
  3637. NotHumpEqual: '\u224F\u0338',
  3638. notin: '\u2209',
  3639. notindot: '\u22F5\u0338',
  3640. notinE: '\u22F9\u0338',
  3641. notinva: '\u2209',
  3642. notinvb: '\u22F7',
  3643. notinvc: '\u22F6',
  3644. NotLeftTriangle: '\u22EA',
  3645. NotLeftTriangleBar: '\u29CF\u0338',
  3646. NotLeftTriangleEqual: '\u22EC',
  3647. NotLess: '\u226E',
  3648. NotLessEqual: '\u2270',
  3649. NotLessGreater: '\u2278',
  3650. NotLessLess: '\u226A\u0338',
  3651. NotLessSlantEqual: '\u2A7D\u0338',
  3652. NotLessTilde: '\u2274',
  3653. NotNestedGreaterGreater: '\u2AA2\u0338',
  3654. NotNestedLessLess: '\u2AA1\u0338',
  3655. notni: '\u220C',
  3656. notniva: '\u220C',
  3657. notnivb: '\u22FE',
  3658. notnivc: '\u22FD',
  3659. NotPrecedes: '\u2280',
  3660. NotPrecedesEqual: '\u2AAF\u0338',
  3661. NotPrecedesSlantEqual: '\u22E0',
  3662. NotReverseElement: '\u220C',
  3663. NotRightTriangle: '\u22EB',
  3664. NotRightTriangleBar: '\u29D0\u0338',
  3665. NotRightTriangleEqual: '\u22ED',
  3666. NotSquareSubset: '\u228F\u0338',
  3667. NotSquareSubsetEqual: '\u22E2',
  3668. NotSquareSuperset: '\u2290\u0338',
  3669. NotSquareSupersetEqual: '\u22E3',
  3670. NotSubset: '\u2282\u20D2',
  3671. NotSubsetEqual: '\u2288',
  3672. NotSucceeds: '\u2281',
  3673. NotSucceedsEqual: '\u2AB0\u0338',
  3674. NotSucceedsSlantEqual: '\u22E1',
  3675. NotSucceedsTilde: '\u227F\u0338',
  3676. NotSuperset: '\u2283\u20D2',
  3677. NotSupersetEqual: '\u2289',
  3678. NotTilde: '\u2241',
  3679. NotTildeEqual: '\u2244',
  3680. NotTildeFullEqual: '\u2247',
  3681. NotTildeTilde: '\u2249',
  3682. NotVerticalBar: '\u2224',
  3683. npar: '\u2226',
  3684. nparallel: '\u2226',
  3685. nparsl: '\u2AFD\u20E5',
  3686. npart: '\u2202\u0338',
  3687. npolint: '\u2A14',
  3688. npr: '\u2280',
  3689. nprcue: '\u22E0',
  3690. npre: '\u2AAF\u0338',
  3691. nprec: '\u2280',
  3692. npreceq: '\u2AAF\u0338',
  3693. nrArr: '\u21CF',
  3694. nrarr: '\u219B',
  3695. nrarrc: '\u2933\u0338',
  3696. nrarrw: '\u219D\u0338',
  3697. nRightarrow: '\u21CF',
  3698. nrightarrow: '\u219B',
  3699. nrtri: '\u22EB',
  3700. nrtrie: '\u22ED',
  3701. nsc: '\u2281',
  3702. nsccue: '\u22E1',
  3703. nsce: '\u2AB0\u0338',
  3704. Nscr: '\uD835\uDCA9',
  3705. nscr: '\uD835\uDCC3',
  3706. nshortmid: '\u2224',
  3707. nshortparallel: '\u2226',
  3708. nsim: '\u2241',
  3709. nsime: '\u2244',
  3710. nsimeq: '\u2244',
  3711. nsmid: '\u2224',
  3712. nspar: '\u2226',
  3713. nsqsube: '\u22E2',
  3714. nsqsupe: '\u22E3',
  3715. nsub: '\u2284',
  3716. nsubE: '\u2AC5\u0338',
  3717. nsube: '\u2288',
  3718. nsubset: '\u2282\u20D2',
  3719. nsubseteq: '\u2288',
  3720. nsubseteqq: '\u2AC5\u0338',
  3721. nsucc: '\u2281',
  3722. nsucceq: '\u2AB0\u0338',
  3723. nsup: '\u2285',
  3724. nsupE: '\u2AC6\u0338',
  3725. nsupe: '\u2289',
  3726. nsupset: '\u2283\u20D2',
  3727. nsupseteq: '\u2289',
  3728. nsupseteqq: '\u2AC6\u0338',
  3729. ntgl: '\u2279',
  3730. Ntilde: '\u00D1',
  3731. ntilde: '\u00F1',
  3732. ntlg: '\u2278',
  3733. ntriangleleft: '\u22EA',
  3734. ntrianglelefteq: '\u22EC',
  3735. ntriangleright: '\u22EB',
  3736. ntrianglerighteq: '\u22ED',
  3737. Nu: '\u039D',
  3738. nu: '\u03BD',
  3739. num: '\u0023',
  3740. numero: '\u2116',
  3741. numsp: '\u2007',
  3742. nvap: '\u224D\u20D2',
  3743. nVDash: '\u22AF',
  3744. nVdash: '\u22AE',
  3745. nvDash: '\u22AD',
  3746. nvdash: '\u22AC',
  3747. nvge: '\u2265\u20D2',
  3748. nvgt: '\u003E\u20D2',
  3749. nvHarr: '\u2904',
  3750. nvinfin: '\u29DE',
  3751. nvlArr: '\u2902',
  3752. nvle: '\u2264\u20D2',
  3753. nvlt: '\u003C\u20D2',
  3754. nvltrie: '\u22B4\u20D2',
  3755. nvrArr: '\u2903',
  3756. nvrtrie: '\u22B5\u20D2',
  3757. nvsim: '\u223C\u20D2',
  3758. nwarhk: '\u2923',
  3759. nwArr: '\u21D6',
  3760. nwarr: '\u2196',
  3761. nwarrow: '\u2196',
  3762. nwnear: '\u2927',
  3763. Oacute: '\u00D3',
  3764. oacute: '\u00F3',
  3765. oast: '\u229B',
  3766. ocir: '\u229A',
  3767. Ocirc: '\u00D4',
  3768. ocirc: '\u00F4',
  3769. Ocy: '\u041E',
  3770. ocy: '\u043E',
  3771. odash: '\u229D',
  3772. Odblac: '\u0150',
  3773. odblac: '\u0151',
  3774. odiv: '\u2A38',
  3775. odot: '\u2299',
  3776. odsold: '\u29BC',
  3777. OElig: '\u0152',
  3778. oelig: '\u0153',
  3779. ofcir: '\u29BF',
  3780. Ofr: '\uD835\uDD12',
  3781. ofr: '\uD835\uDD2C',
  3782. ogon: '\u02DB',
  3783. Ograve: '\u00D2',
  3784. ograve: '\u00F2',
  3785. ogt: '\u29C1',
  3786. ohbar: '\u29B5',
  3787. ohm: '\u03A9',
  3788. oint: '\u222E',
  3789. olarr: '\u21BA',
  3790. olcir: '\u29BE',
  3791. olcross: '\u29BB',
  3792. oline: '\u203E',
  3793. olt: '\u29C0',
  3794. Omacr: '\u014C',
  3795. omacr: '\u014D',
  3796. Omega: '\u03A9',
  3797. omega: '\u03C9',
  3798. Omicron: '\u039F',
  3799. omicron: '\u03BF',
  3800. omid: '\u29B6',
  3801. ominus: '\u2296',
  3802. Oopf: '\uD835\uDD46',
  3803. oopf: '\uD835\uDD60',
  3804. opar: '\u29B7',
  3805. OpenCurlyDoubleQuote: '\u201C',
  3806. OpenCurlyQuote: '\u2018',
  3807. operp: '\u29B9',
  3808. oplus: '\u2295',
  3809. Or: '\u2A54',
  3810. or: '\u2228',
  3811. orarr: '\u21BB',
  3812. ord: '\u2A5D',
  3813. order: '\u2134',
  3814. orderof: '\u2134',
  3815. ordf: '\u00AA',
  3816. ordm: '\u00BA',
  3817. origof: '\u22B6',
  3818. oror: '\u2A56',
  3819. orslope: '\u2A57',
  3820. orv: '\u2A5B',
  3821. oS: '\u24C8',
  3822. Oscr: '\uD835\uDCAA',
  3823. oscr: '\u2134',
  3824. Oslash: '\u00D8',
  3825. oslash: '\u00F8',
  3826. osol: '\u2298',
  3827. Otilde: '\u00D5',
  3828. otilde: '\u00F5',
  3829. Otimes: '\u2A37',
  3830. otimes: '\u2297',
  3831. otimesas: '\u2A36',
  3832. Ouml: '\u00D6',
  3833. ouml: '\u00F6',
  3834. ovbar: '\u233D',
  3835. OverBar: '\u203E',
  3836. OverBrace: '\u23DE',
  3837. OverBracket: '\u23B4',
  3838. OverParenthesis: '\u23DC',
  3839. par: '\u2225',
  3840. para: '\u00B6',
  3841. parallel: '\u2225',
  3842. parsim: '\u2AF3',
  3843. parsl: '\u2AFD',
  3844. part: '\u2202',
  3845. PartialD: '\u2202',
  3846. Pcy: '\u041F',
  3847. pcy: '\u043F',
  3848. percnt: '\u0025',
  3849. period: '\u002E',
  3850. permil: '\u2030',
  3851. perp: '\u22A5',
  3852. pertenk: '\u2031',
  3853. Pfr: '\uD835\uDD13',
  3854. pfr: '\uD835\uDD2D',
  3855. Phi: '\u03A6',
  3856. phi: '\u03C6',
  3857. phiv: '\u03D5',
  3858. phmmat: '\u2133',
  3859. phone: '\u260E',
  3860. Pi: '\u03A0',
  3861. pi: '\u03C0',
  3862. pitchfork: '\u22D4',
  3863. piv: '\u03D6',
  3864. planck: '\u210F',
  3865. planckh: '\u210E',
  3866. plankv: '\u210F',
  3867. plus: '\u002B',
  3868. plusacir: '\u2A23',
  3869. plusb: '\u229E',
  3870. pluscir: '\u2A22',
  3871. plusdo: '\u2214',
  3872. plusdu: '\u2A25',
  3873. pluse: '\u2A72',
  3874. PlusMinus: '\u00B1',
  3875. plusmn: '\u00B1',
  3876. plussim: '\u2A26',
  3877. plustwo: '\u2A27',
  3878. pm: '\u00B1',
  3879. Poincareplane: '\u210C',
  3880. pointint: '\u2A15',
  3881. Popf: '\u2119',
  3882. popf: '\uD835\uDD61',
  3883. pound: '\u00A3',
  3884. Pr: '\u2ABB',
  3885. pr: '\u227A',
  3886. prap: '\u2AB7',
  3887. prcue: '\u227C',
  3888. prE: '\u2AB3',
  3889. pre: '\u2AAF',
  3890. prec: '\u227A',
  3891. precapprox: '\u2AB7',
  3892. preccurlyeq: '\u227C',
  3893. Precedes: '\u227A',
  3894. PrecedesEqual: '\u2AAF',
  3895. PrecedesSlantEqual: '\u227C',
  3896. PrecedesTilde: '\u227E',
  3897. preceq: '\u2AAF',
  3898. precnapprox: '\u2AB9',
  3899. precneqq: '\u2AB5',
  3900. precnsim: '\u22E8',
  3901. precsim: '\u227E',
  3902. Prime: '\u2033',
  3903. prime: '\u2032',
  3904. primes: '\u2119',
  3905. prnap: '\u2AB9',
  3906. prnE: '\u2AB5',
  3907. prnsim: '\u22E8',
  3908. prod: '\u220F',
  3909. Product: '\u220F',
  3910. profalar: '\u232E',
  3911. profline: '\u2312',
  3912. profsurf: '\u2313',
  3913. prop: '\u221D',
  3914. Proportion: '\u2237',
  3915. Proportional: '\u221D',
  3916. propto: '\u221D',
  3917. prsim: '\u227E',
  3918. prurel: '\u22B0',
  3919. Pscr: '\uD835\uDCAB',
  3920. pscr: '\uD835\uDCC5',
  3921. Psi: '\u03A8',
  3922. psi: '\u03C8',
  3923. puncsp: '\u2008',
  3924. Qfr: '\uD835\uDD14',
  3925. qfr: '\uD835\uDD2E',
  3926. qint: '\u2A0C',
  3927. Qopf: '\u211A',
  3928. qopf: '\uD835\uDD62',
  3929. qprime: '\u2057',
  3930. Qscr: '\uD835\uDCAC',
  3931. qscr: '\uD835\uDCC6',
  3932. quaternions: '\u210D',
  3933. quatint: '\u2A16',
  3934. quest: '\u003F',
  3935. questeq: '\u225F',
  3936. QUOT: '\u0022',
  3937. quot: '\u0022',
  3938. rAarr: '\u21DB',
  3939. race: '\u223D\u0331',
  3940. Racute: '\u0154',
  3941. racute: '\u0155',
  3942. radic: '\u221A',
  3943. raemptyv: '\u29B3',
  3944. Rang: '\u27EB',
  3945. rang: '\u27E9',
  3946. rangd: '\u2992',
  3947. range: '\u29A5',
  3948. rangle: '\u27E9',
  3949. raquo: '\u00BB',
  3950. Rarr: '\u21A0',
  3951. rArr: '\u21D2',
  3952. rarr: '\u2192',
  3953. rarrap: '\u2975',
  3954. rarrb: '\u21E5',
  3955. rarrbfs: '\u2920',
  3956. rarrc: '\u2933',
  3957. rarrfs: '\u291E',
  3958. rarrhk: '\u21AA',
  3959. rarrlp: '\u21AC',
  3960. rarrpl: '\u2945',
  3961. rarrsim: '\u2974',
  3962. Rarrtl: '\u2916',
  3963. rarrtl: '\u21A3',
  3964. rarrw: '\u219D',
  3965. rAtail: '\u291C',
  3966. ratail: '\u291A',
  3967. ratio: '\u2236',
  3968. rationals: '\u211A',
  3969. RBarr: '\u2910',
  3970. rBarr: '\u290F',
  3971. rbarr: '\u290D',
  3972. rbbrk: '\u2773',
  3973. rbrace: '\u007D',
  3974. rbrack: '\u005D',
  3975. rbrke: '\u298C',
  3976. rbrksld: '\u298E',
  3977. rbrkslu: '\u2990',
  3978. Rcaron: '\u0158',
  3979. rcaron: '\u0159',
  3980. Rcedil: '\u0156',
  3981. rcedil: '\u0157',
  3982. rceil: '\u2309',
  3983. rcub: '\u007D',
  3984. Rcy: '\u0420',
  3985. rcy: '\u0440',
  3986. rdca: '\u2937',
  3987. rdldhar: '\u2969',
  3988. rdquo: '\u201D',
  3989. rdquor: '\u201D',
  3990. rdsh: '\u21B3',
  3991. Re: '\u211C',
  3992. real: '\u211C',
  3993. realine: '\u211B',
  3994. realpart: '\u211C',
  3995. reals: '\u211D',
  3996. rect: '\u25AD',
  3997. REG: '\u00AE',
  3998. reg: '\u00AE',
  3999. ReverseElement: '\u220B',
  4000. ReverseEquilibrium: '\u21CB',
  4001. ReverseUpEquilibrium: '\u296F',
  4002. rfisht: '\u297D',
  4003. rfloor: '\u230B',
  4004. Rfr: '\u211C',
  4005. rfr: '\uD835\uDD2F',
  4006. rHar: '\u2964',
  4007. rhard: '\u21C1',
  4008. rharu: '\u21C0',
  4009. rharul: '\u296C',
  4010. Rho: '\u03A1',
  4011. rho: '\u03C1',
  4012. rhov: '\u03F1',
  4013. RightAngleBracket: '\u27E9',
  4014. RightArrow: '\u2192',
  4015. Rightarrow: '\u21D2',
  4016. rightarrow: '\u2192',
  4017. RightArrowBar: '\u21E5',
  4018. RightArrowLeftArrow: '\u21C4',
  4019. rightarrowtail: '\u21A3',
  4020. RightCeiling: '\u2309',
  4021. RightDoubleBracket: '\u27E7',
  4022. RightDownTeeVector: '\u295D',
  4023. RightDownVector: '\u21C2',
  4024. RightDownVectorBar: '\u2955',
  4025. RightFloor: '\u230B',
  4026. rightharpoondown: '\u21C1',
  4027. rightharpoonup: '\u21C0',
  4028. rightleftarrows: '\u21C4',
  4029. rightleftharpoons: '\u21CC',
  4030. rightrightarrows: '\u21C9',
  4031. rightsquigarrow: '\u219D',
  4032. RightTee: '\u22A2',
  4033. RightTeeArrow: '\u21A6',
  4034. RightTeeVector: '\u295B',
  4035. rightthreetimes: '\u22CC',
  4036. RightTriangle: '\u22B3',
  4037. RightTriangleBar: '\u29D0',
  4038. RightTriangleEqual: '\u22B5',
  4039. RightUpDownVector: '\u294F',
  4040. RightUpTeeVector: '\u295C',
  4041. RightUpVector: '\u21BE',
  4042. RightUpVectorBar: '\u2954',
  4043. RightVector: '\u21C0',
  4044. RightVectorBar: '\u2953',
  4045. ring: '\u02DA',
  4046. risingdotseq: '\u2253',
  4047. rlarr: '\u21C4',
  4048. rlhar: '\u21CC',
  4049. rlm: '\u200F',
  4050. rmoust: '\u23B1',
  4051. rmoustache: '\u23B1',
  4052. rnmid: '\u2AEE',
  4053. roang: '\u27ED',
  4054. roarr: '\u21FE',
  4055. robrk: '\u27E7',
  4056. ropar: '\u2986',
  4057. Ropf: '\u211D',
  4058. ropf: '\uD835\uDD63',
  4059. roplus: '\u2A2E',
  4060. rotimes: '\u2A35',
  4061. RoundImplies: '\u2970',
  4062. rpar: '\u0029',
  4063. rpargt: '\u2994',
  4064. rppolint: '\u2A12',
  4065. rrarr: '\u21C9',
  4066. Rrightarrow: '\u21DB',
  4067. rsaquo: '\u203A',
  4068. Rscr: '\u211B',
  4069. rscr: '\uD835\uDCC7',
  4070. Rsh: '\u21B1',
  4071. rsh: '\u21B1',
  4072. rsqb: '\u005D',
  4073. rsquo: '\u2019',
  4074. rsquor: '\u2019',
  4075. rthree: '\u22CC',
  4076. rtimes: '\u22CA',
  4077. rtri: '\u25B9',
  4078. rtrie: '\u22B5',
  4079. rtrif: '\u25B8',
  4080. rtriltri: '\u29CE',
  4081. RuleDelayed: '\u29F4',
  4082. ruluhar: '\u2968',
  4083. rx: '\u211E',
  4084. Sacute: '\u015A',
  4085. sacute: '\u015B',
  4086. sbquo: '\u201A',
  4087. Sc: '\u2ABC',
  4088. sc: '\u227B',
  4089. scap: '\u2AB8',
  4090. Scaron: '\u0160',
  4091. scaron: '\u0161',
  4092. sccue: '\u227D',
  4093. scE: '\u2AB4',
  4094. sce: '\u2AB0',
  4095. Scedil: '\u015E',
  4096. scedil: '\u015F',
  4097. Scirc: '\u015C',
  4098. scirc: '\u015D',
  4099. scnap: '\u2ABA',
  4100. scnE: '\u2AB6',
  4101. scnsim: '\u22E9',
  4102. scpolint: '\u2A13',
  4103. scsim: '\u227F',
  4104. Scy: '\u0421',
  4105. scy: '\u0441',
  4106. sdot: '\u22C5',
  4107. sdotb: '\u22A1',
  4108. sdote: '\u2A66',
  4109. searhk: '\u2925',
  4110. seArr: '\u21D8',
  4111. searr: '\u2198',
  4112. searrow: '\u2198',
  4113. sect: '\u00A7',
  4114. semi: '\u003B',
  4115. seswar: '\u2929',
  4116. setminus: '\u2216',
  4117. setmn: '\u2216',
  4118. sext: '\u2736',
  4119. Sfr: '\uD835\uDD16',
  4120. sfr: '\uD835\uDD30',
  4121. sfrown: '\u2322',
  4122. sharp: '\u266F',
  4123. SHCHcy: '\u0429',
  4124. shchcy: '\u0449',
  4125. SHcy: '\u0428',
  4126. shcy: '\u0448',
  4127. ShortDownArrow: '\u2193',
  4128. ShortLeftArrow: '\u2190',
  4129. shortmid: '\u2223',
  4130. shortparallel: '\u2225',
  4131. ShortRightArrow: '\u2192',
  4132. ShortUpArrow: '\u2191',
  4133. shy: '\u00AD',
  4134. Sigma: '\u03A3',
  4135. sigma: '\u03C3',
  4136. sigmaf: '\u03C2',
  4137. sigmav: '\u03C2',
  4138. sim: '\u223C',
  4139. simdot: '\u2A6A',
  4140. sime: '\u2243',
  4141. simeq: '\u2243',
  4142. simg: '\u2A9E',
  4143. simgE: '\u2AA0',
  4144. siml: '\u2A9D',
  4145. simlE: '\u2A9F',
  4146. simne: '\u2246',
  4147. simplus: '\u2A24',
  4148. simrarr: '\u2972',
  4149. slarr: '\u2190',
  4150. SmallCircle: '\u2218',
  4151. smallsetminus: '\u2216',
  4152. smashp: '\u2A33',
  4153. smeparsl: '\u29E4',
  4154. smid: '\u2223',
  4155. smile: '\u2323',
  4156. smt: '\u2AAA',
  4157. smte: '\u2AAC',
  4158. smtes: '\u2AAC\uFE00',
  4159. SOFTcy: '\u042C',
  4160. softcy: '\u044C',
  4161. sol: '\u002F',
  4162. solb: '\u29C4',
  4163. solbar: '\u233F',
  4164. Sopf: '\uD835\uDD4A',
  4165. sopf: '\uD835\uDD64',
  4166. spades: '\u2660',
  4167. spadesuit: '\u2660',
  4168. spar: '\u2225',
  4169. sqcap: '\u2293',
  4170. sqcaps: '\u2293\uFE00',
  4171. sqcup: '\u2294',
  4172. sqcups: '\u2294\uFE00',
  4173. Sqrt: '\u221A',
  4174. sqsub: '\u228F',
  4175. sqsube: '\u2291',
  4176. sqsubset: '\u228F',
  4177. sqsubseteq: '\u2291',
  4178. sqsup: '\u2290',
  4179. sqsupe: '\u2292',
  4180. sqsupset: '\u2290',
  4181. sqsupseteq: '\u2292',
  4182. squ: '\u25A1',
  4183. Square: '\u25A1',
  4184. square: '\u25A1',
  4185. SquareIntersection: '\u2293',
  4186. SquareSubset: '\u228F',
  4187. SquareSubsetEqual: '\u2291',
  4188. SquareSuperset: '\u2290',
  4189. SquareSupersetEqual: '\u2292',
  4190. SquareUnion: '\u2294',
  4191. squarf: '\u25AA',
  4192. squf: '\u25AA',
  4193. srarr: '\u2192',
  4194. Sscr: '\uD835\uDCAE',
  4195. sscr: '\uD835\uDCC8',
  4196. ssetmn: '\u2216',
  4197. ssmile: '\u2323',
  4198. sstarf: '\u22C6',
  4199. Star: '\u22C6',
  4200. star: '\u2606',
  4201. starf: '\u2605',
  4202. straightepsilon: '\u03F5',
  4203. straightphi: '\u03D5',
  4204. strns: '\u00AF',
  4205. Sub: '\u22D0',
  4206. sub: '\u2282',
  4207. subdot: '\u2ABD',
  4208. subE: '\u2AC5',
  4209. sube: '\u2286',
  4210. subedot: '\u2AC3',
  4211. submult: '\u2AC1',
  4212. subnE: '\u2ACB',
  4213. subne: '\u228A',
  4214. subplus: '\u2ABF',
  4215. subrarr: '\u2979',
  4216. Subset: '\u22D0',
  4217. subset: '\u2282',
  4218. subseteq: '\u2286',
  4219. subseteqq: '\u2AC5',
  4220. SubsetEqual: '\u2286',
  4221. subsetneq: '\u228A',
  4222. subsetneqq: '\u2ACB',
  4223. subsim: '\u2AC7',
  4224. subsub: '\u2AD5',
  4225. subsup: '\u2AD3',
  4226. succ: '\u227B',
  4227. succapprox: '\u2AB8',
  4228. succcurlyeq: '\u227D',
  4229. Succeeds: '\u227B',
  4230. SucceedsEqual: '\u2AB0',
  4231. SucceedsSlantEqual: '\u227D',
  4232. SucceedsTilde: '\u227F',
  4233. succeq: '\u2AB0',
  4234. succnapprox: '\u2ABA',
  4235. succneqq: '\u2AB6',
  4236. succnsim: '\u22E9',
  4237. succsim: '\u227F',
  4238. SuchThat: '\u220B',
  4239. Sum: '\u2211',
  4240. sum: '\u2211',
  4241. sung: '\u266A',
  4242. Sup: '\u22D1',
  4243. sup: '\u2283',
  4244. sup1: '\u00B9',
  4245. sup2: '\u00B2',
  4246. sup3: '\u00B3',
  4247. supdot: '\u2ABE',
  4248. supdsub: '\u2AD8',
  4249. supE: '\u2AC6',
  4250. supe: '\u2287',
  4251. supedot: '\u2AC4',
  4252. Superset: '\u2283',
  4253. SupersetEqual: '\u2287',
  4254. suphsol: '\u27C9',
  4255. suphsub: '\u2AD7',
  4256. suplarr: '\u297B',
  4257. supmult: '\u2AC2',
  4258. supnE: '\u2ACC',
  4259. supne: '\u228B',
  4260. supplus: '\u2AC0',
  4261. Supset: '\u22D1',
  4262. supset: '\u2283',
  4263. supseteq: '\u2287',
  4264. supseteqq: '\u2AC6',
  4265. supsetneq: '\u228B',
  4266. supsetneqq: '\u2ACC',
  4267. supsim: '\u2AC8',
  4268. supsub: '\u2AD4',
  4269. supsup: '\u2AD6',
  4270. swarhk: '\u2926',
  4271. swArr: '\u21D9',
  4272. swarr: '\u2199',
  4273. swarrow: '\u2199',
  4274. swnwar: '\u292A',
  4275. szlig: '\u00DF',
  4276. Tab: '\u0009',
  4277. target: '\u2316',
  4278. Tau: '\u03A4',
  4279. tau: '\u03C4',
  4280. tbrk: '\u23B4',
  4281. Tcaron: '\u0164',
  4282. tcaron: '\u0165',
  4283. Tcedil: '\u0162',
  4284. tcedil: '\u0163',
  4285. Tcy: '\u0422',
  4286. tcy: '\u0442',
  4287. tdot: '\u20DB',
  4288. telrec: '\u2315',
  4289. Tfr: '\uD835\uDD17',
  4290. tfr: '\uD835\uDD31',
  4291. there4: '\u2234',
  4292. Therefore: '\u2234',
  4293. therefore: '\u2234',
  4294. Theta: '\u0398',
  4295. theta: '\u03B8',
  4296. thetasym: '\u03D1',
  4297. thetav: '\u03D1',
  4298. thickapprox: '\u2248',
  4299. thicksim: '\u223C',
  4300. ThickSpace: '\u205F\u200A',
  4301. thinsp: '\u2009',
  4302. ThinSpace: '\u2009',
  4303. thkap: '\u2248',
  4304. thksim: '\u223C',
  4305. THORN: '\u00DE',
  4306. thorn: '\u00FE',
  4307. Tilde: '\u223C',
  4308. tilde: '\u02DC',
  4309. TildeEqual: '\u2243',
  4310. TildeFullEqual: '\u2245',
  4311. TildeTilde: '\u2248',
  4312. times: '\u00D7',
  4313. timesb: '\u22A0',
  4314. timesbar: '\u2A31',
  4315. timesd: '\u2A30',
  4316. tint: '\u222D',
  4317. toea: '\u2928',
  4318. top: '\u22A4',
  4319. topbot: '\u2336',
  4320. topcir: '\u2AF1',
  4321. Topf: '\uD835\uDD4B',
  4322. topf: '\uD835\uDD65',
  4323. topfork: '\u2ADA',
  4324. tosa: '\u2929',
  4325. tprime: '\u2034',
  4326. TRADE: '\u2122',
  4327. trade: '\u2122',
  4328. triangle: '\u25B5',
  4329. triangledown: '\u25BF',
  4330. triangleleft: '\u25C3',
  4331. trianglelefteq: '\u22B4',
  4332. triangleq: '\u225C',
  4333. triangleright: '\u25B9',
  4334. trianglerighteq: '\u22B5',
  4335. tridot: '\u25EC',
  4336. trie: '\u225C',
  4337. triminus: '\u2A3A',
  4338. TripleDot: '\u20DB',
  4339. triplus: '\u2A39',
  4340. trisb: '\u29CD',
  4341. tritime: '\u2A3B',
  4342. trpezium: '\u23E2',
  4343. Tscr: '\uD835\uDCAF',
  4344. tscr: '\uD835\uDCC9',
  4345. TScy: '\u0426',
  4346. tscy: '\u0446',
  4347. TSHcy: '\u040B',
  4348. tshcy: '\u045B',
  4349. Tstrok: '\u0166',
  4350. tstrok: '\u0167',
  4351. twixt: '\u226C',
  4352. twoheadleftarrow: '\u219E',
  4353. twoheadrightarrow: '\u21A0',
  4354. Uacute: '\u00DA',
  4355. uacute: '\u00FA',
  4356. Uarr: '\u219F',
  4357. uArr: '\u21D1',
  4358. uarr: '\u2191',
  4359. Uarrocir: '\u2949',
  4360. Ubrcy: '\u040E',
  4361. ubrcy: '\u045E',
  4362. Ubreve: '\u016C',
  4363. ubreve: '\u016D',
  4364. Ucirc: '\u00DB',
  4365. ucirc: '\u00FB',
  4366. Ucy: '\u0423',
  4367. ucy: '\u0443',
  4368. udarr: '\u21C5',
  4369. Udblac: '\u0170',
  4370. udblac: '\u0171',
  4371. udhar: '\u296E',
  4372. ufisht: '\u297E',
  4373. Ufr: '\uD835\uDD18',
  4374. ufr: '\uD835\uDD32',
  4375. Ugrave: '\u00D9',
  4376. ugrave: '\u00F9',
  4377. uHar: '\u2963',
  4378. uharl: '\u21BF',
  4379. uharr: '\u21BE',
  4380. uhblk: '\u2580',
  4381. ulcorn: '\u231C',
  4382. ulcorner: '\u231C',
  4383. ulcrop: '\u230F',
  4384. ultri: '\u25F8',
  4385. Umacr: '\u016A',
  4386. umacr: '\u016B',
  4387. uml: '\u00A8',
  4388. UnderBar: '\u005F',
  4389. UnderBrace: '\u23DF',
  4390. UnderBracket: '\u23B5',
  4391. UnderParenthesis: '\u23DD',
  4392. Union: '\u22C3',
  4393. UnionPlus: '\u228E',
  4394. Uogon: '\u0172',
  4395. uogon: '\u0173',
  4396. Uopf: '\uD835\uDD4C',
  4397. uopf: '\uD835\uDD66',
  4398. UpArrow: '\u2191',
  4399. Uparrow: '\u21D1',
  4400. uparrow: '\u2191',
  4401. UpArrowBar: '\u2912',
  4402. UpArrowDownArrow: '\u21C5',
  4403. UpDownArrow: '\u2195',
  4404. Updownarrow: '\u21D5',
  4405. updownarrow: '\u2195',
  4406. UpEquilibrium: '\u296E',
  4407. upharpoonleft: '\u21BF',
  4408. upharpoonright: '\u21BE',
  4409. uplus: '\u228E',
  4410. UpperLeftArrow: '\u2196',
  4411. UpperRightArrow: '\u2197',
  4412. Upsi: '\u03D2',
  4413. upsi: '\u03C5',
  4414. upsih: '\u03D2',
  4415. Upsilon: '\u03A5',
  4416. upsilon: '\u03C5',
  4417. UpTee: '\u22A5',
  4418. UpTeeArrow: '\u21A5',
  4419. upuparrows: '\u21C8',
  4420. urcorn: '\u231D',
  4421. urcorner: '\u231D',
  4422. urcrop: '\u230E',
  4423. Uring: '\u016E',
  4424. uring: '\u016F',
  4425. urtri: '\u25F9',
  4426. Uscr: '\uD835\uDCB0',
  4427. uscr: '\uD835\uDCCA',
  4428. utdot: '\u22F0',
  4429. Utilde: '\u0168',
  4430. utilde: '\u0169',
  4431. utri: '\u25B5',
  4432. utrif: '\u25B4',
  4433. uuarr: '\u21C8',
  4434. Uuml: '\u00DC',
  4435. uuml: '\u00FC',
  4436. uwangle: '\u29A7',
  4437. vangrt: '\u299C',
  4438. varepsilon: '\u03F5',
  4439. varkappa: '\u03F0',
  4440. varnothing: '\u2205',
  4441. varphi: '\u03D5',
  4442. varpi: '\u03D6',
  4443. varpropto: '\u221D',
  4444. vArr: '\u21D5',
  4445. varr: '\u2195',
  4446. varrho: '\u03F1',
  4447. varsigma: '\u03C2',
  4448. varsubsetneq: '\u228A\uFE00',
  4449. varsubsetneqq: '\u2ACB\uFE00',
  4450. varsupsetneq: '\u228B\uFE00',
  4451. varsupsetneqq: '\u2ACC\uFE00',
  4452. vartheta: '\u03D1',
  4453. vartriangleleft: '\u22B2',
  4454. vartriangleright: '\u22B3',
  4455. Vbar: '\u2AEB',
  4456. vBar: '\u2AE8',
  4457. vBarv: '\u2AE9',
  4458. Vcy: '\u0412',
  4459. vcy: '\u0432',
  4460. VDash: '\u22AB',
  4461. Vdash: '\u22A9',
  4462. vDash: '\u22A8',
  4463. vdash: '\u22A2',
  4464. Vdashl: '\u2AE6',
  4465. Vee: '\u22C1',
  4466. vee: '\u2228',
  4467. veebar: '\u22BB',
  4468. veeeq: '\u225A',
  4469. vellip: '\u22EE',
  4470. Verbar: '\u2016',
  4471. verbar: '\u007C',
  4472. Vert: '\u2016',
  4473. vert: '\u007C',
  4474. VerticalBar: '\u2223',
  4475. VerticalLine: '\u007C',
  4476. VerticalSeparator: '\u2758',
  4477. VerticalTilde: '\u2240',
  4478. VeryThinSpace: '\u200A',
  4479. Vfr: '\uD835\uDD19',
  4480. vfr: '\uD835\uDD33',
  4481. vltri: '\u22B2',
  4482. vnsub: '\u2282\u20D2',
  4483. vnsup: '\u2283\u20D2',
  4484. Vopf: '\uD835\uDD4D',
  4485. vopf: '\uD835\uDD67',
  4486. vprop: '\u221D',
  4487. vrtri: '\u22B3',
  4488. Vscr: '\uD835\uDCB1',
  4489. vscr: '\uD835\uDCCB',
  4490. vsubnE: '\u2ACB\uFE00',
  4491. vsubne: '\u228A\uFE00',
  4492. vsupnE: '\u2ACC\uFE00',
  4493. vsupne: '\u228B\uFE00',
  4494. Vvdash: '\u22AA',
  4495. vzigzag: '\u299A',
  4496. Wcirc: '\u0174',
  4497. wcirc: '\u0175',
  4498. wedbar: '\u2A5F',
  4499. Wedge: '\u22C0',
  4500. wedge: '\u2227',
  4501. wedgeq: '\u2259',
  4502. weierp: '\u2118',
  4503. Wfr: '\uD835\uDD1A',
  4504. wfr: '\uD835\uDD34',
  4505. Wopf: '\uD835\uDD4E',
  4506. wopf: '\uD835\uDD68',
  4507. wp: '\u2118',
  4508. wr: '\u2240',
  4509. wreath: '\u2240',
  4510. Wscr: '\uD835\uDCB2',
  4511. wscr: '\uD835\uDCCC',
  4512. xcap: '\u22C2',
  4513. xcirc: '\u25EF',
  4514. xcup: '\u22C3',
  4515. xdtri: '\u25BD',
  4516. Xfr: '\uD835\uDD1B',
  4517. xfr: '\uD835\uDD35',
  4518. xhArr: '\u27FA',
  4519. xharr: '\u27F7',
  4520. Xi: '\u039E',
  4521. xi: '\u03BE',
  4522. xlArr: '\u27F8',
  4523. xlarr: '\u27F5',
  4524. xmap: '\u27FC',
  4525. xnis: '\u22FB',
  4526. xodot: '\u2A00',
  4527. Xopf: '\uD835\uDD4F',
  4528. xopf: '\uD835\uDD69',
  4529. xoplus: '\u2A01',
  4530. xotime: '\u2A02',
  4531. xrArr: '\u27F9',
  4532. xrarr: '\u27F6',
  4533. Xscr: '\uD835\uDCB3',
  4534. xscr: '\uD835\uDCCD',
  4535. xsqcup: '\u2A06',
  4536. xuplus: '\u2A04',
  4537. xutri: '\u25B3',
  4538. xvee: '\u22C1',
  4539. xwedge: '\u22C0',
  4540. Yacute: '\u00DD',
  4541. yacute: '\u00FD',
  4542. YAcy: '\u042F',
  4543. yacy: '\u044F',
  4544. Ycirc: '\u0176',
  4545. ycirc: '\u0177',
  4546. Ycy: '\u042B',
  4547. ycy: '\u044B',
  4548. yen: '\u00A5',
  4549. Yfr: '\uD835\uDD1C',
  4550. yfr: '\uD835\uDD36',
  4551. YIcy: '\u0407',
  4552. yicy: '\u0457',
  4553. Yopf: '\uD835\uDD50',
  4554. yopf: '\uD835\uDD6A',
  4555. Yscr: '\uD835\uDCB4',
  4556. yscr: '\uD835\uDCCE',
  4557. YUcy: '\u042E',
  4558. yucy: '\u044E',
  4559. Yuml: '\u0178',
  4560. yuml: '\u00FF',
  4561. Zacute: '\u0179',
  4562. zacute: '\u017A',
  4563. Zcaron: '\u017D',
  4564. zcaron: '\u017E',
  4565. Zcy: '\u0417',
  4566. zcy: '\u0437',
  4567. Zdot: '\u017B',
  4568. zdot: '\u017C',
  4569. zeetrf: '\u2128',
  4570. ZeroWidthSpace: '\u200B',
  4571. Zeta: '\u0396',
  4572. zeta: '\u03B6',
  4573. Zfr: '\u2128',
  4574. zfr: '\uD835\uDD37',
  4575. ZHcy: '\u0416',
  4576. zhcy: '\u0436',
  4577. zigrarr: '\u21DD',
  4578. Zopf: '\u2124',
  4579. zopf: '\uD835\uDD6B',
  4580. Zscr: '\uD835\uDCB5',
  4581. zscr: '\uD835\uDCCF',
  4582. zwj: '\u200D',
  4583. zwnj: '\u200C',
  4584. });
  4585. /**
  4586. * @deprecated use `HTML_ENTITIES` instead
  4587. * @see HTML_ENTITIES
  4588. */
  4589. exports.entityMap = exports.HTML_ENTITIES;
  4590. },{"./conventions":2}],6:[function(require,module,exports){
  4591. var dom = require('./dom')
  4592. exports.DOMImplementation = dom.DOMImplementation
  4593. exports.XMLSerializer = dom.XMLSerializer
  4594. exports.DOMParser = require('./dom-parser').DOMParser
  4595. },{"./dom":4,"./dom-parser":3}],7:[function(require,module,exports){
  4596. var NAMESPACE = require("./conventions").NAMESPACE;
  4597. //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
  4598. //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
  4599. //[5] Name ::= NameStartChar (NameChar)*
  4600. var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF
  4601. var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
  4602. var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
  4603. //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
  4604. //var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
  4605. //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
  4606. //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
  4607. var S_TAG = 0;//tag name offerring
  4608. var S_ATTR = 1;//attr name offerring
  4609. var S_ATTR_SPACE=2;//attr name end and space offer
  4610. var S_EQ = 3;//=space?
  4611. var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)
  4612. var S_ATTR_END = 5;//attr value end and no space(quot end)
  4613. var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)
  4614. var S_TAG_CLOSE = 7;//closed el<el />
  4615. /**
  4616. * Creates an error that will not be caught by XMLReader aka the SAX parser.
  4617. *
  4618. * @param {string} message
  4619. * @param {any?} locator Optional, can provide details about the location in the source
  4620. * @constructor
  4621. */
  4622. function ParseError(message, locator) {
  4623. this.message = message
  4624. this.locator = locator
  4625. if(Error.captureStackTrace) Error.captureStackTrace(this, ParseError);
  4626. }
  4627. ParseError.prototype = new Error();
  4628. ParseError.prototype.name = ParseError.name
  4629. function XMLReader(){
  4630. }
  4631. XMLReader.prototype = {
  4632. parse:function(source,defaultNSMap,entityMap){
  4633. var domBuilder = this.domBuilder;
  4634. domBuilder.startDocument();
  4635. _copy(defaultNSMap ,defaultNSMap = {})
  4636. parse(source,defaultNSMap,entityMap,
  4637. domBuilder,this.errorHandler);
  4638. domBuilder.endDocument();
  4639. }
  4640. }
  4641. function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
  4642. function fixedFromCharCode(code) {
  4643. // String.prototype.fromCharCode does not supports
  4644. // > 2 bytes unicode chars directly
  4645. if (code > 0xffff) {
  4646. code -= 0x10000;
  4647. var surrogate1 = 0xd800 + (code >> 10)
  4648. , surrogate2 = 0xdc00 + (code & 0x3ff);
  4649. return String.fromCharCode(surrogate1, surrogate2);
  4650. } else {
  4651. return String.fromCharCode(code);
  4652. }
  4653. }
  4654. function entityReplacer(a){
  4655. var k = a.slice(1,-1);
  4656. if (Object.hasOwnProperty.call(entityMap, k)) {
  4657. return entityMap[k];
  4658. }else if(k.charAt(0) === '#'){
  4659. return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
  4660. }else{
  4661. errorHandler.error('entity not found:'+a);
  4662. return a;
  4663. }
  4664. }
  4665. function appendText(end){//has some bugs
  4666. if(end>start){
  4667. var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);
  4668. locator&&position(start);
  4669. domBuilder.characters(xt,0,end-start);
  4670. start = end
  4671. }
  4672. }
  4673. function position(p,m){
  4674. while(p>=lineEnd && (m = linePattern.exec(source))){
  4675. lineStart = m.index;
  4676. lineEnd = lineStart + m[0].length;
  4677. locator.lineNumber++;
  4678. //console.log('line++:',locator,startPos,endPos)
  4679. }
  4680. locator.columnNumber = p-lineStart+1;
  4681. }
  4682. var lineStart = 0;
  4683. var lineEnd = 0;
  4684. var linePattern = /.*(?:\r\n?|\n)|.*$/g
  4685. var locator = domBuilder.locator;
  4686. var parseStack = [{currentNSMap:defaultNSMapCopy}]
  4687. var closeMap = {};
  4688. var start = 0;
  4689. while(true){
  4690. try{
  4691. var tagStart = source.indexOf('<',start);
  4692. if(tagStart<0){
  4693. if(!source.substr(start).match(/^\s*$/)){
  4694. var doc = domBuilder.doc;
  4695. var text = doc.createTextNode(source.substr(start));
  4696. doc.appendChild(text);
  4697. domBuilder.currentElement = text;
  4698. }
  4699. return;
  4700. }
  4701. if(tagStart>start){
  4702. appendText(tagStart);
  4703. }
  4704. switch(source.charAt(tagStart+1)){
  4705. case '/':
  4706. var end = source.indexOf('>',tagStart+3);
  4707. var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, '');
  4708. var config = parseStack.pop();
  4709. if(end<0){
  4710. tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
  4711. errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
  4712. end = tagStart+1+tagName.length;
  4713. }else if(tagName.match(/\s</)){
  4714. tagName = tagName.replace(/[\s<].*/,'');
  4715. errorHandler.error("end tag name: "+tagName+' maybe not complete');
  4716. end = tagStart+1+tagName.length;
  4717. }
  4718. var localNSMap = config.localNSMap;
  4719. var endMatch = config.tagName == tagName;
  4720. var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
  4721. if(endIgnoreCaseMach){
  4722. domBuilder.endElement(config.uri,config.localName,tagName);
  4723. if(localNSMap){
  4724. for (var prefix in localNSMap) {
  4725. if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
  4726. domBuilder.endPrefixMapping(prefix);
  4727. }
  4728. }
  4729. }
  4730. if(!endMatch){
  4731. errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName ); // No known test case
  4732. }
  4733. }else{
  4734. parseStack.push(config)
  4735. }
  4736. end++;
  4737. break;
  4738. // end elment
  4739. case '?':// <?...?>
  4740. locator&&position(tagStart);
  4741. end = parseInstruction(source,tagStart,domBuilder);
  4742. break;
  4743. case '!':// <!doctype,<![CDATA,<!--
  4744. locator&&position(tagStart);
  4745. end = parseDCC(source,tagStart,domBuilder,errorHandler);
  4746. break;
  4747. default:
  4748. locator&&position(tagStart);
  4749. var el = new ElementAttributes();
  4750. var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
  4751. //elStartEnd
  4752. var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
  4753. var len = el.length;
  4754. if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
  4755. el.closed = true;
  4756. if(!entityMap.nbsp){
  4757. errorHandler.warning('unclosed xml attribute');
  4758. }
  4759. }
  4760. if(locator && len){
  4761. var locator2 = copyLocator(locator,{});
  4762. //try{//attribute position fixed
  4763. for(var i = 0;i<len;i++){
  4764. var a = el[i];
  4765. position(a.offset);
  4766. a.locator = copyLocator(locator,{});
  4767. }
  4768. domBuilder.locator = locator2
  4769. if(appendElement(el,domBuilder,currentNSMap)){
  4770. parseStack.push(el)
  4771. }
  4772. domBuilder.locator = locator;
  4773. }else{
  4774. if(appendElement(el,domBuilder,currentNSMap)){
  4775. parseStack.push(el)
  4776. }
  4777. }
  4778. if (NAMESPACE.isHTML(el.uri) && !el.closed) {
  4779. end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
  4780. } else {
  4781. end++;
  4782. }
  4783. }
  4784. }catch(e){
  4785. if (e instanceof ParseError) {
  4786. throw e;
  4787. }
  4788. errorHandler.error('element parse error: '+e)
  4789. end = -1;
  4790. }
  4791. if(end>start){
  4792. start = end;
  4793. }else{
  4794. //TODO: 这里有可能sax回退,有位置错误风险
  4795. appendText(Math.max(tagStart,start)+1);
  4796. }
  4797. }
  4798. }
  4799. function copyLocator(f,t){
  4800. t.lineNumber = f.lineNumber;
  4801. t.columnNumber = f.columnNumber;
  4802. return t;
  4803. }
  4804. /**
  4805. * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
  4806. * @return end of the elementStartPart(end of elementEndPart for selfClosed el)
  4807. */
  4808. function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){
  4809. /**
  4810. * @param {string} qname
  4811. * @param {string} value
  4812. * @param {number} startIndex
  4813. */
  4814. function addAttribute(qname, value, startIndex) {
  4815. if (el.attributeNames.hasOwnProperty(qname)) {
  4816. errorHandler.fatalError('Attribute ' + qname + ' redefined')
  4817. }
  4818. el.addValue(
  4819. qname,
  4820. // @see https://www.w3.org/TR/xml/#AVNormalize
  4821. // since the xmldom sax parser does not "interpret" DTD the following is not implemented:
  4822. // - recursive replacement of (DTD) entity references
  4823. // - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA
  4824. value.replace(/[\t\n\r]/g, ' ').replace(/&#?\w+;/g, entityReplacer),
  4825. startIndex
  4826. )
  4827. }
  4828. var attrName;
  4829. var value;
  4830. var p = ++start;
  4831. var s = S_TAG;//status
  4832. while(true){
  4833. var c = source.charAt(p);
  4834. switch(c){
  4835. case '=':
  4836. if(s === S_ATTR){//attrName
  4837. attrName = source.slice(start,p);
  4838. s = S_EQ;
  4839. }else if(s === S_ATTR_SPACE){
  4840. s = S_EQ;
  4841. }else{
  4842. //fatalError: equal must after attrName or space after attrName
  4843. throw new Error('attribute equal must after attrName'); // No known test case
  4844. }
  4845. break;
  4846. case '\'':
  4847. case '"':
  4848. if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE
  4849. ){//equal
  4850. if(s === S_ATTR){
  4851. errorHandler.warning('attribute value must after "="')
  4852. attrName = source.slice(start,p)
  4853. }
  4854. start = p+1;
  4855. p = source.indexOf(c,start)
  4856. if(p>0){
  4857. value = source.slice(start, p);
  4858. addAttribute(attrName, value, start-1);
  4859. s = S_ATTR_END;
  4860. }else{
  4861. //fatalError: no end quot match
  4862. throw new Error('attribute value no end \''+c+'\' match');
  4863. }
  4864. }else if(s == S_ATTR_NOQUOT_VALUE){
  4865. value = source.slice(start, p);
  4866. addAttribute(attrName, value, start);
  4867. errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
  4868. start = p+1;
  4869. s = S_ATTR_END
  4870. }else{
  4871. //fatalError: no equal before
  4872. throw new Error('attribute value must after "="'); // No known test case
  4873. }
  4874. break;
  4875. case '/':
  4876. switch(s){
  4877. case S_TAG:
  4878. el.setTagName(source.slice(start,p));
  4879. case S_ATTR_END:
  4880. case S_TAG_SPACE:
  4881. case S_TAG_CLOSE:
  4882. s =S_TAG_CLOSE;
  4883. el.closed = true;
  4884. case S_ATTR_NOQUOT_VALUE:
  4885. case S_ATTR:
  4886. break;
  4887. case S_ATTR_SPACE:
  4888. el.closed = true;
  4889. break;
  4890. //case S_EQ:
  4891. default:
  4892. throw new Error("attribute invalid close char('/')") // No known test case
  4893. }
  4894. break;
  4895. case ''://end document
  4896. errorHandler.error('unexpected end of input');
  4897. if(s == S_TAG){
  4898. el.setTagName(source.slice(start,p));
  4899. }
  4900. return p;
  4901. case '>':
  4902. switch(s){
  4903. case S_TAG:
  4904. el.setTagName(source.slice(start,p));
  4905. case S_ATTR_END:
  4906. case S_TAG_SPACE:
  4907. case S_TAG_CLOSE:
  4908. break;//normal
  4909. case S_ATTR_NOQUOT_VALUE://Compatible state
  4910. case S_ATTR:
  4911. value = source.slice(start,p);
  4912. if(value.slice(-1) === '/'){
  4913. el.closed = true;
  4914. value = value.slice(0,-1)
  4915. }
  4916. case S_ATTR_SPACE:
  4917. if(s === S_ATTR_SPACE){
  4918. value = attrName;
  4919. }
  4920. if(s == S_ATTR_NOQUOT_VALUE){
  4921. errorHandler.warning('attribute "'+value+'" missed quot(")!');
  4922. addAttribute(attrName, value, start)
  4923. }else{
  4924. if(!NAMESPACE.isHTML(currentNSMap['']) || !value.match(/^(?:disabled|checked|selected)$/i)){
  4925. errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
  4926. }
  4927. addAttribute(value, value, start)
  4928. }
  4929. break;
  4930. case S_EQ:
  4931. throw new Error('attribute value missed!!');
  4932. }
  4933. // console.log(tagName,tagNamePattern,tagNamePattern.test(tagName))
  4934. return p;
  4935. /*xml space '\x20' | #x9 | #xD | #xA; */
  4936. case '\u0080':
  4937. c = ' ';
  4938. default:
  4939. if(c<= ' '){//space
  4940. switch(s){
  4941. case S_TAG:
  4942. el.setTagName(source.slice(start,p));//tagName
  4943. s = S_TAG_SPACE;
  4944. break;
  4945. case S_ATTR:
  4946. attrName = source.slice(start,p)
  4947. s = S_ATTR_SPACE;
  4948. break;
  4949. case S_ATTR_NOQUOT_VALUE:
  4950. var value = source.slice(start, p);
  4951. errorHandler.warning('attribute "'+value+'" missed quot(")!!');
  4952. addAttribute(attrName, value, start)
  4953. case S_ATTR_END:
  4954. s = S_TAG_SPACE;
  4955. break;
  4956. //case S_TAG_SPACE:
  4957. //case S_EQ:
  4958. //case S_ATTR_SPACE:
  4959. // void();break;
  4960. //case S_TAG_CLOSE:
  4961. //ignore warning
  4962. }
  4963. }else{//not space
  4964. //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
  4965. //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
  4966. switch(s){
  4967. //case S_TAG:void();break;
  4968. //case S_ATTR:void();break;
  4969. //case S_ATTR_NOQUOT_VALUE:void();break;
  4970. case S_ATTR_SPACE:
  4971. var tagName = el.tagName;
  4972. if (!NAMESPACE.isHTML(currentNSMap['']) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
  4973. errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!')
  4974. }
  4975. addAttribute(attrName, attrName, start);
  4976. start = p;
  4977. s = S_ATTR;
  4978. break;
  4979. case S_ATTR_END:
  4980. errorHandler.warning('attribute space is required"'+attrName+'"!!')
  4981. case S_TAG_SPACE:
  4982. s = S_ATTR;
  4983. start = p;
  4984. break;
  4985. case S_EQ:
  4986. s = S_ATTR_NOQUOT_VALUE;
  4987. start = p;
  4988. break;
  4989. case S_TAG_CLOSE:
  4990. throw new Error("elements closed character '/' and '>' must be connected to");
  4991. }
  4992. }
  4993. }//end outer switch
  4994. //console.log('p++',p)
  4995. p++;
  4996. }
  4997. }
  4998. /**
  4999. * @return true if has new namespace define
  5000. */
  5001. function appendElement(el,domBuilder,currentNSMap){
  5002. var tagName = el.tagName;
  5003. var localNSMap = null;
  5004. //var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
  5005. var i = el.length;
  5006. while(i--){
  5007. var a = el[i];
  5008. var qName = a.qName;
  5009. var value = a.value;
  5010. var nsp = qName.indexOf(':');
  5011. if(nsp>0){
  5012. var prefix = a.prefix = qName.slice(0,nsp);
  5013. var localName = qName.slice(nsp+1);
  5014. var nsPrefix = prefix === 'xmlns' && localName
  5015. }else{
  5016. localName = qName;
  5017. prefix = null
  5018. nsPrefix = qName === 'xmlns' && ''
  5019. }
  5020. //can not set prefix,because prefix !== ''
  5021. a.localName = localName ;
  5022. //prefix == null for no ns prefix attribute
  5023. if(nsPrefix !== false){//hack!!
  5024. if(localNSMap == null){
  5025. localNSMap = {}
  5026. //console.log(currentNSMap,0)
  5027. _copy(currentNSMap,currentNSMap={})
  5028. //console.log(currentNSMap,1)
  5029. }
  5030. currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
  5031. a.uri = NAMESPACE.XMLNS
  5032. domBuilder.startPrefixMapping(nsPrefix, value)
  5033. }
  5034. }
  5035. var i = el.length;
  5036. while(i--){
  5037. a = el[i];
  5038. var prefix = a.prefix;
  5039. if(prefix){//no prefix attribute has no namespace
  5040. if(prefix === 'xml'){
  5041. a.uri = NAMESPACE.XML;
  5042. }if(prefix !== 'xmlns'){
  5043. a.uri = currentNSMap[prefix || '']
  5044. //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
  5045. }
  5046. }
  5047. }
  5048. var nsp = tagName.indexOf(':');
  5049. if(nsp>0){
  5050. prefix = el.prefix = tagName.slice(0,nsp);
  5051. localName = el.localName = tagName.slice(nsp+1);
  5052. }else{
  5053. prefix = null;//important!!
  5054. localName = el.localName = tagName;
  5055. }
  5056. //no prefix element has default namespace
  5057. var ns = el.uri = currentNSMap[prefix || ''];
  5058. domBuilder.startElement(ns,localName,tagName,el);
  5059. //endPrefixMapping and startPrefixMapping have not any help for dom builder
  5060. //localNSMap = null
  5061. if(el.closed){
  5062. domBuilder.endElement(ns,localName,tagName);
  5063. if(localNSMap){
  5064. for (prefix in localNSMap) {
  5065. if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
  5066. domBuilder.endPrefixMapping(prefix);
  5067. }
  5068. }
  5069. }
  5070. }else{
  5071. el.currentNSMap = currentNSMap;
  5072. el.localNSMap = localNSMap;
  5073. //parseStack.push(el);
  5074. return true;
  5075. }
  5076. }
  5077. function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
  5078. if(/^(?:script|textarea)$/i.test(tagName)){
  5079. var elEndStart = source.indexOf('</'+tagName+'>',elStartEnd);
  5080. var text = source.substring(elStartEnd+1,elEndStart);
  5081. if(/[&<]/.test(text)){
  5082. if(/^script$/i.test(tagName)){
  5083. //if(!/\]\]>/.test(text)){
  5084. //lexHandler.startCDATA();
  5085. domBuilder.characters(text,0,text.length);
  5086. //lexHandler.endCDATA();
  5087. return elEndStart;
  5088. //}
  5089. }//}else{//text area
  5090. text = text.replace(/&#?\w+;/g,entityReplacer);
  5091. domBuilder.characters(text,0,text.length);
  5092. return elEndStart;
  5093. //}
  5094. }
  5095. }
  5096. return elStartEnd+1;
  5097. }
  5098. function fixSelfClosed(source,elStartEnd,tagName,closeMap){
  5099. //if(tagName in closeMap){
  5100. var pos = closeMap[tagName];
  5101. if(pos == null){
  5102. //console.log(tagName)
  5103. pos = source.lastIndexOf('</'+tagName+'>')
  5104. if(pos<elStartEnd){//忘记闭合
  5105. pos = source.lastIndexOf('</'+tagName)
  5106. }
  5107. closeMap[tagName] =pos
  5108. }
  5109. return pos<elStartEnd;
  5110. //}
  5111. }
  5112. function _copy (source, target) {
  5113. for (var n in source) {
  5114. if (Object.prototype.hasOwnProperty.call(source, n)) {
  5115. target[n] = source[n];
  5116. }
  5117. }
  5118. }
  5119. function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
  5120. var next= source.charAt(start+2)
  5121. switch(next){
  5122. case '-':
  5123. if(source.charAt(start + 3) === '-'){
  5124. var end = source.indexOf('-->',start+4);
  5125. //append comment source.substring(4,end)//<!--
  5126. if(end>start){
  5127. domBuilder.comment(source,start+4,end-start-4);
  5128. return end+3;
  5129. }else{
  5130. errorHandler.error("Unclosed comment");
  5131. return -1;
  5132. }
  5133. }else{
  5134. //error
  5135. return -1;
  5136. }
  5137. default:
  5138. if(source.substr(start+3,6) == 'CDATA['){
  5139. var end = source.indexOf(']]>',start+9);
  5140. domBuilder.startCDATA();
  5141. domBuilder.characters(source,start+9,end-start-9);
  5142. domBuilder.endCDATA()
  5143. return end+3;
  5144. }
  5145. //<!DOCTYPE
  5146. //startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
  5147. var matchs = split(source,start);
  5148. var len = matchs.length;
  5149. if(len>1 && /!doctype/i.test(matchs[0][0])){
  5150. var name = matchs[1][0];
  5151. var pubid = false;
  5152. var sysid = false;
  5153. if(len>3){
  5154. if(/^public$/i.test(matchs[2][0])){
  5155. pubid = matchs[3][0];
  5156. sysid = len>4 && matchs[4][0];
  5157. }else if(/^system$/i.test(matchs[2][0])){
  5158. sysid = matchs[3][0];
  5159. }
  5160. }
  5161. var lastMatch = matchs[len-1]
  5162. domBuilder.startDTD(name, pubid, sysid);
  5163. domBuilder.endDTD();
  5164. return lastMatch.index+lastMatch[0].length
  5165. }
  5166. }
  5167. return -1;
  5168. }
  5169. function parseInstruction(source,start,domBuilder){
  5170. var end = source.indexOf('?>',start);
  5171. if(end){
  5172. var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
  5173. if(match){
  5174. var len = match[0].length;
  5175. domBuilder.processingInstruction(match[1], match[2]) ;
  5176. return end+2;
  5177. }else{//error
  5178. return -1;
  5179. }
  5180. }
  5181. return -1;
  5182. }
  5183. function ElementAttributes(){
  5184. this.attributeNames = {}
  5185. }
  5186. ElementAttributes.prototype = {
  5187. setTagName:function(tagName){
  5188. if(!tagNamePattern.test(tagName)){
  5189. throw new Error('invalid tagName:'+tagName)
  5190. }
  5191. this.tagName = tagName
  5192. },
  5193. addValue:function(qName, value, offset) {
  5194. if(!tagNamePattern.test(qName)){
  5195. throw new Error('invalid attribute:'+qName)
  5196. }
  5197. this.attributeNames[qName] = this.length;
  5198. this[this.length++] = {qName:qName,value:value,offset:offset}
  5199. },
  5200. length:0,
  5201. getLocalName:function(i){return this[i].localName},
  5202. getLocator:function(i){return this[i].locator},
  5203. getQName:function(i){return this[i].qName},
  5204. getURI:function(i){return this[i].uri},
  5205. getValue:function(i){return this[i].value}
  5206. // ,getIndex:function(uri, localName)){
  5207. // if(localName){
  5208. //
  5209. // }else{
  5210. // var qName = uri
  5211. // }
  5212. // },
  5213. // getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
  5214. // getType:function(uri,localName){}
  5215. // getType:function(i){},
  5216. }
  5217. function split(source,start){
  5218. var match;
  5219. var buf = [];
  5220. var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
  5221. reg.lastIndex = start;
  5222. reg.exec(source);//skip <
  5223. while(match = reg.exec(source)){
  5224. buf.push(match);
  5225. if(match[1])return buf;
  5226. }
  5227. }
  5228. exports.XMLReader = XMLReader;
  5229. exports.ParseError = ParseError;
  5230. },{"./conventions":2}],8:[function(require,module,exports){
  5231. 'use strict'
  5232. exports.byteLength = byteLength
  5233. exports.toByteArray = toByteArray
  5234. exports.fromByteArray = fromByteArray
  5235. var lookup = []
  5236. var revLookup = []
  5237. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  5238. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  5239. for (var i = 0, len = code.length; i < len; ++i) {
  5240. lookup[i] = code[i]
  5241. revLookup[code.charCodeAt(i)] = i
  5242. }
  5243. // Support decoding URL-safe base64 strings, as Node.js does.
  5244. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  5245. revLookup['-'.charCodeAt(0)] = 62
  5246. revLookup['_'.charCodeAt(0)] = 63
  5247. function getLens (b64) {
  5248. var len = b64.length
  5249. if (len % 4 > 0) {
  5250. throw new Error('Invalid string. Length must be a multiple of 4')
  5251. }
  5252. // Trim off extra bytes after placeholder bytes are found
  5253. // See: https://github.com/beatgammit/base64-js/issues/42
  5254. var validLen = b64.indexOf('=')
  5255. if (validLen === -1) validLen = len
  5256. var placeHoldersLen = validLen === len
  5257. ? 0
  5258. : 4 - (validLen % 4)
  5259. return [validLen, placeHoldersLen]
  5260. }
  5261. // base64 is 4/3 + up to two characters of the original data
  5262. function byteLength (b64) {
  5263. var lens = getLens(b64)
  5264. var validLen = lens[0]
  5265. var placeHoldersLen = lens[1]
  5266. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  5267. }
  5268. function _byteLength (b64, validLen, placeHoldersLen) {
  5269. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  5270. }
  5271. function toByteArray (b64) {
  5272. var tmp
  5273. var lens = getLens(b64)
  5274. var validLen = lens[0]
  5275. var placeHoldersLen = lens[1]
  5276. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  5277. var curByte = 0
  5278. // if there are placeholders, only get up to the last complete 4 chars
  5279. var len = placeHoldersLen > 0
  5280. ? validLen - 4
  5281. : validLen
  5282. var i
  5283. for (i = 0; i < len; i += 4) {
  5284. tmp =
  5285. (revLookup[b64.charCodeAt(i)] << 18) |
  5286. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  5287. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  5288. revLookup[b64.charCodeAt(i + 3)]
  5289. arr[curByte++] = (tmp >> 16) & 0xFF
  5290. arr[curByte++] = (tmp >> 8) & 0xFF
  5291. arr[curByte++] = tmp & 0xFF
  5292. }
  5293. if (placeHoldersLen === 2) {
  5294. tmp =
  5295. (revLookup[b64.charCodeAt(i)] << 2) |
  5296. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  5297. arr[curByte++] = tmp & 0xFF
  5298. }
  5299. if (placeHoldersLen === 1) {
  5300. tmp =
  5301. (revLookup[b64.charCodeAt(i)] << 10) |
  5302. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  5303. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  5304. arr[curByte++] = (tmp >> 8) & 0xFF
  5305. arr[curByte++] = tmp & 0xFF
  5306. }
  5307. return arr
  5308. }
  5309. function tripletToBase64 (num) {
  5310. return lookup[num >> 18 & 0x3F] +
  5311. lookup[num >> 12 & 0x3F] +
  5312. lookup[num >> 6 & 0x3F] +
  5313. lookup[num & 0x3F]
  5314. }
  5315. function encodeChunk (uint8, start, end) {
  5316. var tmp
  5317. var output = []
  5318. for (var i = start; i < end; i += 3) {
  5319. tmp =
  5320. ((uint8[i] << 16) & 0xFF0000) +
  5321. ((uint8[i + 1] << 8) & 0xFF00) +
  5322. (uint8[i + 2] & 0xFF)
  5323. output.push(tripletToBase64(tmp))
  5324. }
  5325. return output.join('')
  5326. }
  5327. function fromByteArray (uint8) {
  5328. var tmp
  5329. var len = uint8.length
  5330. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  5331. var parts = []
  5332. var maxChunkLength = 16383 // must be multiple of 3
  5333. // go through the array every three bytes, we'll deal with trailing stuff later
  5334. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  5335. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  5336. }
  5337. // pad the end with zeros, but make sure to not forget the extra bytes
  5338. if (extraBytes === 1) {
  5339. tmp = uint8[len - 1]
  5340. parts.push(
  5341. lookup[tmp >> 2] +
  5342. lookup[(tmp << 4) & 0x3F] +
  5343. '=='
  5344. )
  5345. } else if (extraBytes === 2) {
  5346. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  5347. parts.push(
  5348. lookup[tmp >> 10] +
  5349. lookup[(tmp >> 4) & 0x3F] +
  5350. lookup[(tmp << 2) & 0x3F] +
  5351. '='
  5352. )
  5353. }
  5354. return parts.join('')
  5355. }
  5356. },{}],9:[function(require,module,exports){
  5357. (function (Buffer){(function (){
  5358. /*!
  5359. * The buffer module from node.js, for the browser.
  5360. *
  5361. * @author Feross Aboukhadijeh <https://feross.org>
  5362. * @license MIT
  5363. */
  5364. /* eslint-disable no-proto */
  5365. 'use strict'
  5366. var base64 = require('base64-js')
  5367. var ieee754 = require('ieee754')
  5368. exports.Buffer = Buffer
  5369. exports.SlowBuffer = SlowBuffer
  5370. exports.INSPECT_MAX_BYTES = 50
  5371. var K_MAX_LENGTH = 0x7fffffff
  5372. exports.kMaxLength = K_MAX_LENGTH
  5373. /**
  5374. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5375. * === true Use Uint8Array implementation (fastest)
  5376. * === false Print warning and recommend using `buffer` v4.x which has an Object
  5377. * implementation (most compatible, even IE6)
  5378. *
  5379. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5380. * Opera 11.6+, iOS 4.2+.
  5381. *
  5382. * We report that the browser does not support typed arrays if the are not subclassable
  5383. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  5384. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  5385. * for __proto__ and has a buggy typed array implementation.
  5386. */
  5387. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  5388. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  5389. typeof console.error === 'function') {
  5390. console.error(
  5391. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  5392. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  5393. )
  5394. }
  5395. function typedArraySupport () {
  5396. // Can typed array instances can be augmented?
  5397. try {
  5398. var arr = new Uint8Array(1)
  5399. arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
  5400. return arr.foo() === 42
  5401. } catch (e) {
  5402. return false
  5403. }
  5404. }
  5405. Object.defineProperty(Buffer.prototype, 'parent', {
  5406. enumerable: true,
  5407. get: function () {
  5408. if (!Buffer.isBuffer(this)) return undefined
  5409. return this.buffer
  5410. }
  5411. })
  5412. Object.defineProperty(Buffer.prototype, 'offset', {
  5413. enumerable: true,
  5414. get: function () {
  5415. if (!Buffer.isBuffer(this)) return undefined
  5416. return this.byteOffset
  5417. }
  5418. })
  5419. function createBuffer (length) {
  5420. if (length > K_MAX_LENGTH) {
  5421. throw new RangeError('The value "' + length + '" is invalid for option "size"')
  5422. }
  5423. // Return an augmented `Uint8Array` instance
  5424. var buf = new Uint8Array(length)
  5425. buf.__proto__ = Buffer.prototype
  5426. return buf
  5427. }
  5428. /**
  5429. * The Buffer constructor returns instances of `Uint8Array` that have their
  5430. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5431. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5432. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5433. * returns a single octet.
  5434. *
  5435. * The `Uint8Array` prototype remains unmodified.
  5436. */
  5437. function Buffer (arg, encodingOrOffset, length) {
  5438. // Common case.
  5439. if (typeof arg === 'number') {
  5440. if (typeof encodingOrOffset === 'string') {
  5441. throw new TypeError(
  5442. 'The "string" argument must be of type string. Received type number'
  5443. )
  5444. }
  5445. return allocUnsafe(arg)
  5446. }
  5447. return from(arg, encodingOrOffset, length)
  5448. }
  5449. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5450. if (typeof Symbol !== 'undefined' && Symbol.species != null &&
  5451. Buffer[Symbol.species] === Buffer) {
  5452. Object.defineProperty(Buffer, Symbol.species, {
  5453. value: null,
  5454. configurable: true,
  5455. enumerable: false,
  5456. writable: false
  5457. })
  5458. }
  5459. Buffer.poolSize = 8192 // not used by this implementation
  5460. function from (value, encodingOrOffset, length) {
  5461. if (typeof value === 'string') {
  5462. return fromString(value, encodingOrOffset)
  5463. }
  5464. if (ArrayBuffer.isView(value)) {
  5465. return fromArrayLike(value)
  5466. }
  5467. if (value == null) {
  5468. throw TypeError(
  5469. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  5470. 'or Array-like Object. Received type ' + (typeof value)
  5471. )
  5472. }
  5473. if (isInstance(value, ArrayBuffer) ||
  5474. (value && isInstance(value.buffer, ArrayBuffer))) {
  5475. return fromArrayBuffer(value, encodingOrOffset, length)
  5476. }
  5477. if (typeof value === 'number') {
  5478. throw new TypeError(
  5479. 'The "value" argument must not be of type number. Received type number'
  5480. )
  5481. }
  5482. var valueOf = value.valueOf && value.valueOf()
  5483. if (valueOf != null && valueOf !== value) {
  5484. return Buffer.from(valueOf, encodingOrOffset, length)
  5485. }
  5486. var b = fromObject(value)
  5487. if (b) return b
  5488. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
  5489. typeof value[Symbol.toPrimitive] === 'function') {
  5490. return Buffer.from(
  5491. value[Symbol.toPrimitive]('string'), encodingOrOffset, length
  5492. )
  5493. }
  5494. throw new TypeError(
  5495. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  5496. 'or Array-like Object. Received type ' + (typeof value)
  5497. )
  5498. }
  5499. /**
  5500. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5501. * if value is a number.
  5502. * Buffer.from(str[, encoding])
  5503. * Buffer.from(array)
  5504. * Buffer.from(buffer)
  5505. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5506. **/
  5507. Buffer.from = function (value, encodingOrOffset, length) {
  5508. return from(value, encodingOrOffset, length)
  5509. }
  5510. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  5511. // https://github.com/feross/buffer/pull/148
  5512. Buffer.prototype.__proto__ = Uint8Array.prototype
  5513. Buffer.__proto__ = Uint8Array
  5514. function assertSize (size) {
  5515. if (typeof size !== 'number') {
  5516. throw new TypeError('"size" argument must be of type number')
  5517. } else if (size < 0) {
  5518. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  5519. }
  5520. }
  5521. function alloc (size, fill, encoding) {
  5522. assertSize(size)
  5523. if (size <= 0) {
  5524. return createBuffer(size)
  5525. }
  5526. if (fill !== undefined) {
  5527. // Only pay attention to encoding if it's a string. This
  5528. // prevents accidentally sending in a number that would
  5529. // be interpretted as a start offset.
  5530. return typeof encoding === 'string'
  5531. ? createBuffer(size).fill(fill, encoding)
  5532. : createBuffer(size).fill(fill)
  5533. }
  5534. return createBuffer(size)
  5535. }
  5536. /**
  5537. * Creates a new filled Buffer instance.
  5538. * alloc(size[, fill[, encoding]])
  5539. **/
  5540. Buffer.alloc = function (size, fill, encoding) {
  5541. return alloc(size, fill, encoding)
  5542. }
  5543. function allocUnsafe (size) {
  5544. assertSize(size)
  5545. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  5546. }
  5547. /**
  5548. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5549. * */
  5550. Buffer.allocUnsafe = function (size) {
  5551. return allocUnsafe(size)
  5552. }
  5553. /**
  5554. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5555. */
  5556. Buffer.allocUnsafeSlow = function (size) {
  5557. return allocUnsafe(size)
  5558. }
  5559. function fromString (string, encoding) {
  5560. if (typeof encoding !== 'string' || encoding === '') {
  5561. encoding = 'utf8'
  5562. }
  5563. if (!Buffer.isEncoding(encoding)) {
  5564. throw new TypeError('Unknown encoding: ' + encoding)
  5565. }
  5566. var length = byteLength(string, encoding) | 0
  5567. var buf = createBuffer(length)
  5568. var actual = buf.write(string, encoding)
  5569. if (actual !== length) {
  5570. // Writing a hex string, for example, that contains invalid characters will
  5571. // cause everything after the first invalid character to be ignored. (e.g.
  5572. // 'abxxcd' will be treated as 'ab')
  5573. buf = buf.slice(0, actual)
  5574. }
  5575. return buf
  5576. }
  5577. function fromArrayLike (array) {
  5578. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5579. var buf = createBuffer(length)
  5580. for (var i = 0; i < length; i += 1) {
  5581. buf[i] = array[i] & 255
  5582. }
  5583. return buf
  5584. }
  5585. function fromArrayBuffer (array, byteOffset, length) {
  5586. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5587. throw new RangeError('"offset" is outside of buffer bounds')
  5588. }
  5589. if (array.byteLength < byteOffset + (length || 0)) {
  5590. throw new RangeError('"length" is outside of buffer bounds')
  5591. }
  5592. var buf
  5593. if (byteOffset === undefined && length === undefined) {
  5594. buf = new Uint8Array(array)
  5595. } else if (length === undefined) {
  5596. buf = new Uint8Array(array, byteOffset)
  5597. } else {
  5598. buf = new Uint8Array(array, byteOffset, length)
  5599. }
  5600. // Return an augmented `Uint8Array` instance
  5601. buf.__proto__ = Buffer.prototype
  5602. return buf
  5603. }
  5604. function fromObject (obj) {
  5605. if (Buffer.isBuffer(obj)) {
  5606. var len = checked(obj.length) | 0
  5607. var buf = createBuffer(len)
  5608. if (buf.length === 0) {
  5609. return buf
  5610. }
  5611. obj.copy(buf, 0, 0, len)
  5612. return buf
  5613. }
  5614. if (obj.length !== undefined) {
  5615. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  5616. return createBuffer(0)
  5617. }
  5618. return fromArrayLike(obj)
  5619. }
  5620. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  5621. return fromArrayLike(obj.data)
  5622. }
  5623. }
  5624. function checked (length) {
  5625. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  5626. // length is NaN (which is otherwise coerced to zero.)
  5627. if (length >= K_MAX_LENGTH) {
  5628. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5629. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  5630. }
  5631. return length | 0
  5632. }
  5633. function SlowBuffer (length) {
  5634. if (+length != length) { // eslint-disable-line eqeqeq
  5635. length = 0
  5636. }
  5637. return Buffer.alloc(+length)
  5638. }
  5639. Buffer.isBuffer = function isBuffer (b) {
  5640. return b != null && b._isBuffer === true &&
  5641. b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
  5642. }
  5643. Buffer.compare = function compare (a, b) {
  5644. if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
  5645. if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
  5646. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5647. throw new TypeError(
  5648. 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
  5649. )
  5650. }
  5651. if (a === b) return 0
  5652. var x = a.length
  5653. var y = b.length
  5654. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5655. if (a[i] !== b[i]) {
  5656. x = a[i]
  5657. y = b[i]
  5658. break
  5659. }
  5660. }
  5661. if (x < y) return -1
  5662. if (y < x) return 1
  5663. return 0
  5664. }
  5665. Buffer.isEncoding = function isEncoding (encoding) {
  5666. switch (String(encoding).toLowerCase()) {
  5667. case 'hex':
  5668. case 'utf8':
  5669. case 'utf-8':
  5670. case 'ascii':
  5671. case 'latin1':
  5672. case 'binary':
  5673. case 'base64':
  5674. case 'ucs2':
  5675. case 'ucs-2':
  5676. case 'utf16le':
  5677. case 'utf-16le':
  5678. return true
  5679. default:
  5680. return false
  5681. }
  5682. }
  5683. Buffer.concat = function concat (list, length) {
  5684. if (!Array.isArray(list)) {
  5685. throw new TypeError('"list" argument must be an Array of Buffers')
  5686. }
  5687. if (list.length === 0) {
  5688. return Buffer.alloc(0)
  5689. }
  5690. var i
  5691. if (length === undefined) {
  5692. length = 0
  5693. for (i = 0; i < list.length; ++i) {
  5694. length += list[i].length
  5695. }
  5696. }
  5697. var buffer = Buffer.allocUnsafe(length)
  5698. var pos = 0
  5699. for (i = 0; i < list.length; ++i) {
  5700. var buf = list[i]
  5701. if (isInstance(buf, Uint8Array)) {
  5702. buf = Buffer.from(buf)
  5703. }
  5704. if (!Buffer.isBuffer(buf)) {
  5705. throw new TypeError('"list" argument must be an Array of Buffers')
  5706. }
  5707. buf.copy(buffer, pos)
  5708. pos += buf.length
  5709. }
  5710. return buffer
  5711. }
  5712. function byteLength (string, encoding) {
  5713. if (Buffer.isBuffer(string)) {
  5714. return string.length
  5715. }
  5716. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  5717. return string.byteLength
  5718. }
  5719. if (typeof string !== 'string') {
  5720. throw new TypeError(
  5721. 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
  5722. 'Received type ' + typeof string
  5723. )
  5724. }
  5725. var len = string.length
  5726. var mustMatch = (arguments.length > 2 && arguments[2] === true)
  5727. if (!mustMatch && len === 0) return 0
  5728. // Use a for loop to avoid recursion
  5729. var loweredCase = false
  5730. for (;;) {
  5731. switch (encoding) {
  5732. case 'ascii':
  5733. case 'latin1':
  5734. case 'binary':
  5735. return len
  5736. case 'utf8':
  5737. case 'utf-8':
  5738. return utf8ToBytes(string).length
  5739. case 'ucs2':
  5740. case 'ucs-2':
  5741. case 'utf16le':
  5742. case 'utf-16le':
  5743. return len * 2
  5744. case 'hex':
  5745. return len >>> 1
  5746. case 'base64':
  5747. return base64ToBytes(string).length
  5748. default:
  5749. if (loweredCase) {
  5750. return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
  5751. }
  5752. encoding = ('' + encoding).toLowerCase()
  5753. loweredCase = true
  5754. }
  5755. }
  5756. }
  5757. Buffer.byteLength = byteLength
  5758. function slowToString (encoding, start, end) {
  5759. var loweredCase = false
  5760. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  5761. // property of a typed array.
  5762. // This behaves neither like String nor Uint8Array in that we set start/end
  5763. // to their upper/lower bounds if the value passed is out of range.
  5764. // undefined is handled specially as per ECMA-262 6th Edition,
  5765. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  5766. if (start === undefined || start < 0) {
  5767. start = 0
  5768. }
  5769. // Return early if start > this.length. Done here to prevent potential uint32
  5770. // coercion fail below.
  5771. if (start > this.length) {
  5772. return ''
  5773. }
  5774. if (end === undefined || end > this.length) {
  5775. end = this.length
  5776. }
  5777. if (end <= 0) {
  5778. return ''
  5779. }
  5780. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  5781. end >>>= 0
  5782. start >>>= 0
  5783. if (end <= start) {
  5784. return ''
  5785. }
  5786. if (!encoding) encoding = 'utf8'
  5787. while (true) {
  5788. switch (encoding) {
  5789. case 'hex':
  5790. return hexSlice(this, start, end)
  5791. case 'utf8':
  5792. case 'utf-8':
  5793. return utf8Slice(this, start, end)
  5794. case 'ascii':
  5795. return asciiSlice(this, start, end)
  5796. case 'latin1':
  5797. case 'binary':
  5798. return latin1Slice(this, start, end)
  5799. case 'base64':
  5800. return base64Slice(this, start, end)
  5801. case 'ucs2':
  5802. case 'ucs-2':
  5803. case 'utf16le':
  5804. case 'utf-16le':
  5805. return utf16leSlice(this, start, end)
  5806. default:
  5807. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  5808. encoding = (encoding + '').toLowerCase()
  5809. loweredCase = true
  5810. }
  5811. }
  5812. }
  5813. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  5814. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  5815. // reliably in a browserify context because there could be multiple different
  5816. // copies of the 'buffer' package in use. This method works even for Buffer
  5817. // instances that were created from another copy of the `buffer` package.
  5818. // See: https://github.com/feross/buffer/issues/154
  5819. Buffer.prototype._isBuffer = true
  5820. function swap (b, n, m) {
  5821. var i = b[n]
  5822. b[n] = b[m]
  5823. b[m] = i
  5824. }
  5825. Buffer.prototype.swap16 = function swap16 () {
  5826. var len = this.length
  5827. if (len % 2 !== 0) {
  5828. throw new RangeError('Buffer size must be a multiple of 16-bits')
  5829. }
  5830. for (var i = 0; i < len; i += 2) {
  5831. swap(this, i, i + 1)
  5832. }
  5833. return this
  5834. }
  5835. Buffer.prototype.swap32 = function swap32 () {
  5836. var len = this.length
  5837. if (len % 4 !== 0) {
  5838. throw new RangeError('Buffer size must be a multiple of 32-bits')
  5839. }
  5840. for (var i = 0; i < len; i += 4) {
  5841. swap(this, i, i + 3)
  5842. swap(this, i + 1, i + 2)
  5843. }
  5844. return this
  5845. }
  5846. Buffer.prototype.swap64 = function swap64 () {
  5847. var len = this.length
  5848. if (len % 8 !== 0) {
  5849. throw new RangeError('Buffer size must be a multiple of 64-bits')
  5850. }
  5851. for (var i = 0; i < len; i += 8) {
  5852. swap(this, i, i + 7)
  5853. swap(this, i + 1, i + 6)
  5854. swap(this, i + 2, i + 5)
  5855. swap(this, i + 3, i + 4)
  5856. }
  5857. return this
  5858. }
  5859. Buffer.prototype.toString = function toString () {
  5860. var length = this.length
  5861. if (length === 0) return ''
  5862. if (arguments.length === 0) return utf8Slice(this, 0, length)
  5863. return slowToString.apply(this, arguments)
  5864. }
  5865. Buffer.prototype.toLocaleString = Buffer.prototype.toString
  5866. Buffer.prototype.equals = function equals (b) {
  5867. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  5868. if (this === b) return true
  5869. return Buffer.compare(this, b) === 0
  5870. }
  5871. Buffer.prototype.inspect = function inspect () {
  5872. var str = ''
  5873. var max = exports.INSPECT_MAX_BYTES
  5874. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
  5875. if (this.length > max) str += ' ... '
  5876. return '<Buffer ' + str + '>'
  5877. }
  5878. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  5879. if (isInstance(target, Uint8Array)) {
  5880. target = Buffer.from(target, target.offset, target.byteLength)
  5881. }
  5882. if (!Buffer.isBuffer(target)) {
  5883. throw new TypeError(
  5884. 'The "target" argument must be one of type Buffer or Uint8Array. ' +
  5885. 'Received type ' + (typeof target)
  5886. )
  5887. }
  5888. if (start === undefined) {
  5889. start = 0
  5890. }
  5891. if (end === undefined) {
  5892. end = target ? target.length : 0
  5893. }
  5894. if (thisStart === undefined) {
  5895. thisStart = 0
  5896. }
  5897. if (thisEnd === undefined) {
  5898. thisEnd = this.length
  5899. }
  5900. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  5901. throw new RangeError('out of range index')
  5902. }
  5903. if (thisStart >= thisEnd && start >= end) {
  5904. return 0
  5905. }
  5906. if (thisStart >= thisEnd) {
  5907. return -1
  5908. }
  5909. if (start >= end) {
  5910. return 1
  5911. }
  5912. start >>>= 0
  5913. end >>>= 0
  5914. thisStart >>>= 0
  5915. thisEnd >>>= 0
  5916. if (this === target) return 0
  5917. var x = thisEnd - thisStart
  5918. var y = end - start
  5919. var len = Math.min(x, y)
  5920. var thisCopy = this.slice(thisStart, thisEnd)
  5921. var targetCopy = target.slice(start, end)
  5922. for (var i = 0; i < len; ++i) {
  5923. if (thisCopy[i] !== targetCopy[i]) {
  5924. x = thisCopy[i]
  5925. y = targetCopy[i]
  5926. break
  5927. }
  5928. }
  5929. if (x < y) return -1
  5930. if (y < x) return 1
  5931. return 0
  5932. }
  5933. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  5934. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  5935. //
  5936. // Arguments:
  5937. // - buffer - a Buffer to search
  5938. // - val - a string, Buffer, or number
  5939. // - byteOffset - an index into `buffer`; will be clamped to an int32
  5940. // - encoding - an optional encoding, relevant is val is a string
  5941. // - dir - true for indexOf, false for lastIndexOf
  5942. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  5943. // Empty buffer means no match
  5944. if (buffer.length === 0) return -1
  5945. // Normalize byteOffset
  5946. if (typeof byteOffset === 'string') {
  5947. encoding = byteOffset
  5948. byteOffset = 0
  5949. } else if (byteOffset > 0x7fffffff) {
  5950. byteOffset = 0x7fffffff
  5951. } else if (byteOffset < -0x80000000) {
  5952. byteOffset = -0x80000000
  5953. }
  5954. byteOffset = +byteOffset // Coerce to Number.
  5955. if (numberIsNaN(byteOffset)) {
  5956. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  5957. byteOffset = dir ? 0 : (buffer.length - 1)
  5958. }
  5959. // Normalize byteOffset: negative offsets start from the end of the buffer
  5960. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  5961. if (byteOffset >= buffer.length) {
  5962. if (dir) return -1
  5963. else byteOffset = buffer.length - 1
  5964. } else if (byteOffset < 0) {
  5965. if (dir) byteOffset = 0
  5966. else return -1
  5967. }
  5968. // Normalize val
  5969. if (typeof val === 'string') {
  5970. val = Buffer.from(val, encoding)
  5971. }
  5972. // Finally, search either indexOf (if dir is true) or lastIndexOf
  5973. if (Buffer.isBuffer(val)) {
  5974. // Special case: looking for empty string/buffer always fails
  5975. if (val.length === 0) {
  5976. return -1
  5977. }
  5978. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  5979. } else if (typeof val === 'number') {
  5980. val = val & 0xFF // Search for a byte value [0-255]
  5981. if (typeof Uint8Array.prototype.indexOf === 'function') {
  5982. if (dir) {
  5983. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  5984. } else {
  5985. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  5986. }
  5987. }
  5988. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  5989. }
  5990. throw new TypeError('val must be string, number or Buffer')
  5991. }
  5992. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  5993. var indexSize = 1
  5994. var arrLength = arr.length
  5995. var valLength = val.length
  5996. if (encoding !== undefined) {
  5997. encoding = String(encoding).toLowerCase()
  5998. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  5999. encoding === 'utf16le' || encoding === 'utf-16le') {
  6000. if (arr.length < 2 || val.length < 2) {
  6001. return -1
  6002. }
  6003. indexSize = 2
  6004. arrLength /= 2
  6005. valLength /= 2
  6006. byteOffset /= 2
  6007. }
  6008. }
  6009. function read (buf, i) {
  6010. if (indexSize === 1) {
  6011. return buf[i]
  6012. } else {
  6013. return buf.readUInt16BE(i * indexSize)
  6014. }
  6015. }
  6016. var i
  6017. if (dir) {
  6018. var foundIndex = -1
  6019. for (i = byteOffset; i < arrLength; i++) {
  6020. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6021. if (foundIndex === -1) foundIndex = i
  6022. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6023. } else {
  6024. if (foundIndex !== -1) i -= i - foundIndex
  6025. foundIndex = -1
  6026. }
  6027. }
  6028. } else {
  6029. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6030. for (i = byteOffset; i >= 0; i--) {
  6031. var found = true
  6032. for (var j = 0; j < valLength; j++) {
  6033. if (read(arr, i + j) !== read(val, j)) {
  6034. found = false
  6035. break
  6036. }
  6037. }
  6038. if (found) return i
  6039. }
  6040. }
  6041. return -1
  6042. }
  6043. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6044. return this.indexOf(val, byteOffset, encoding) !== -1
  6045. }
  6046. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6047. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6048. }
  6049. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6050. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6051. }
  6052. function hexWrite (buf, string, offset, length) {
  6053. offset = Number(offset) || 0
  6054. var remaining = buf.length - offset
  6055. if (!length) {
  6056. length = remaining
  6057. } else {
  6058. length = Number(length)
  6059. if (length > remaining) {
  6060. length = remaining
  6061. }
  6062. }
  6063. var strLen = string.length
  6064. if (length > strLen / 2) {
  6065. length = strLen / 2
  6066. }
  6067. for (var i = 0; i < length; ++i) {
  6068. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6069. if (numberIsNaN(parsed)) return i
  6070. buf[offset + i] = parsed
  6071. }
  6072. return i
  6073. }
  6074. function utf8Write (buf, string, offset, length) {
  6075. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6076. }
  6077. function asciiWrite (buf, string, offset, length) {
  6078. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6079. }
  6080. function latin1Write (buf, string, offset, length) {
  6081. return asciiWrite(buf, string, offset, length)
  6082. }
  6083. function base64Write (buf, string, offset, length) {
  6084. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6085. }
  6086. function ucs2Write (buf, string, offset, length) {
  6087. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6088. }
  6089. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6090. // Buffer#write(string)
  6091. if (offset === undefined) {
  6092. encoding = 'utf8'
  6093. length = this.length
  6094. offset = 0
  6095. // Buffer#write(string, encoding)
  6096. } else if (length === undefined && typeof offset === 'string') {
  6097. encoding = offset
  6098. length = this.length
  6099. offset = 0
  6100. // Buffer#write(string, offset[, length][, encoding])
  6101. } else if (isFinite(offset)) {
  6102. offset = offset >>> 0
  6103. if (isFinite(length)) {
  6104. length = length >>> 0
  6105. if (encoding === undefined) encoding = 'utf8'
  6106. } else {
  6107. encoding = length
  6108. length = undefined
  6109. }
  6110. } else {
  6111. throw new Error(
  6112. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6113. )
  6114. }
  6115. var remaining = this.length - offset
  6116. if (length === undefined || length > remaining) length = remaining
  6117. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6118. throw new RangeError('Attempt to write outside buffer bounds')
  6119. }
  6120. if (!encoding) encoding = 'utf8'
  6121. var loweredCase = false
  6122. for (;;) {
  6123. switch (encoding) {
  6124. case 'hex':
  6125. return hexWrite(this, string, offset, length)
  6126. case 'utf8':
  6127. case 'utf-8':
  6128. return utf8Write(this, string, offset, length)
  6129. case 'ascii':
  6130. return asciiWrite(this, string, offset, length)
  6131. case 'latin1':
  6132. case 'binary':
  6133. return latin1Write(this, string, offset, length)
  6134. case 'base64':
  6135. // Warning: maxLength not taken into account in base64Write
  6136. return base64Write(this, string, offset, length)
  6137. case 'ucs2':
  6138. case 'ucs-2':
  6139. case 'utf16le':
  6140. case 'utf-16le':
  6141. return ucs2Write(this, string, offset, length)
  6142. default:
  6143. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6144. encoding = ('' + encoding).toLowerCase()
  6145. loweredCase = true
  6146. }
  6147. }
  6148. }
  6149. Buffer.prototype.toJSON = function toJSON () {
  6150. return {
  6151. type: 'Buffer',
  6152. data: Array.prototype.slice.call(this._arr || this, 0)
  6153. }
  6154. }
  6155. function base64Slice (buf, start, end) {
  6156. if (start === 0 && end === buf.length) {
  6157. return base64.fromByteArray(buf)
  6158. } else {
  6159. return base64.fromByteArray(buf.slice(start, end))
  6160. }
  6161. }
  6162. function utf8Slice (buf, start, end) {
  6163. end = Math.min(buf.length, end)
  6164. var res = []
  6165. var i = start
  6166. while (i < end) {
  6167. var firstByte = buf[i]
  6168. var codePoint = null
  6169. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6170. : (firstByte > 0xDF) ? 3
  6171. : (firstByte > 0xBF) ? 2
  6172. : 1
  6173. if (i + bytesPerSequence <= end) {
  6174. var secondByte, thirdByte, fourthByte, tempCodePoint
  6175. switch (bytesPerSequence) {
  6176. case 1:
  6177. if (firstByte < 0x80) {
  6178. codePoint = firstByte
  6179. }
  6180. break
  6181. case 2:
  6182. secondByte = buf[i + 1]
  6183. if ((secondByte & 0xC0) === 0x80) {
  6184. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6185. if (tempCodePoint > 0x7F) {
  6186. codePoint = tempCodePoint
  6187. }
  6188. }
  6189. break
  6190. case 3:
  6191. secondByte = buf[i + 1]
  6192. thirdByte = buf[i + 2]
  6193. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6194. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6195. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6196. codePoint = tempCodePoint
  6197. }
  6198. }
  6199. break
  6200. case 4:
  6201. secondByte = buf[i + 1]
  6202. thirdByte = buf[i + 2]
  6203. fourthByte = buf[i + 3]
  6204. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6205. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6206. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6207. codePoint = tempCodePoint
  6208. }
  6209. }
  6210. }
  6211. }
  6212. if (codePoint === null) {
  6213. // we did not generate a valid codePoint so insert a
  6214. // replacement char (U+FFFD) and advance only 1 byte
  6215. codePoint = 0xFFFD
  6216. bytesPerSequence = 1
  6217. } else if (codePoint > 0xFFFF) {
  6218. // encode to utf16 (surrogate pair dance)
  6219. codePoint -= 0x10000
  6220. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6221. codePoint = 0xDC00 | codePoint & 0x3FF
  6222. }
  6223. res.push(codePoint)
  6224. i += bytesPerSequence
  6225. }
  6226. return decodeCodePointsArray(res)
  6227. }
  6228. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6229. // the lowest limit is Chrome, with 0x10000 args.
  6230. // We go 1 magnitude less, for safety
  6231. var MAX_ARGUMENTS_LENGTH = 0x1000
  6232. function decodeCodePointsArray (codePoints) {
  6233. var len = codePoints.length
  6234. if (len <= MAX_ARGUMENTS_LENGTH) {
  6235. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6236. }
  6237. // Decode in chunks to avoid "call stack size exceeded".
  6238. var res = ''
  6239. var i = 0
  6240. while (i < len) {
  6241. res += String.fromCharCode.apply(
  6242. String,
  6243. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6244. )
  6245. }
  6246. return res
  6247. }
  6248. function asciiSlice (buf, start, end) {
  6249. var ret = ''
  6250. end = Math.min(buf.length, end)
  6251. for (var i = start; i < end; ++i) {
  6252. ret += String.fromCharCode(buf[i] & 0x7F)
  6253. }
  6254. return ret
  6255. }
  6256. function latin1Slice (buf, start, end) {
  6257. var ret = ''
  6258. end = Math.min(buf.length, end)
  6259. for (var i = start; i < end; ++i) {
  6260. ret += String.fromCharCode(buf[i])
  6261. }
  6262. return ret
  6263. }
  6264. function hexSlice (buf, start, end) {
  6265. var len = buf.length
  6266. if (!start || start < 0) start = 0
  6267. if (!end || end < 0 || end > len) end = len
  6268. var out = ''
  6269. for (var i = start; i < end; ++i) {
  6270. out += toHex(buf[i])
  6271. }
  6272. return out
  6273. }
  6274. function utf16leSlice (buf, start, end) {
  6275. var bytes = buf.slice(start, end)
  6276. var res = ''
  6277. for (var i = 0; i < bytes.length; i += 2) {
  6278. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  6279. }
  6280. return res
  6281. }
  6282. Buffer.prototype.slice = function slice (start, end) {
  6283. var len = this.length
  6284. start = ~~start
  6285. end = end === undefined ? len : ~~end
  6286. if (start < 0) {
  6287. start += len
  6288. if (start < 0) start = 0
  6289. } else if (start > len) {
  6290. start = len
  6291. }
  6292. if (end < 0) {
  6293. end += len
  6294. if (end < 0) end = 0
  6295. } else if (end > len) {
  6296. end = len
  6297. }
  6298. if (end < start) end = start
  6299. var newBuf = this.subarray(start, end)
  6300. // Return an augmented `Uint8Array` instance
  6301. newBuf.__proto__ = Buffer.prototype
  6302. return newBuf
  6303. }
  6304. /*
  6305. * Need to make sure that buffer isn't trying to write out of bounds.
  6306. */
  6307. function checkOffset (offset, ext, length) {
  6308. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6309. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6310. }
  6311. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6312. offset = offset >>> 0
  6313. byteLength = byteLength >>> 0
  6314. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6315. var val = this[offset]
  6316. var mul = 1
  6317. var i = 0
  6318. while (++i < byteLength && (mul *= 0x100)) {
  6319. val += this[offset + i] * mul
  6320. }
  6321. return val
  6322. }
  6323. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6324. offset = offset >>> 0
  6325. byteLength = byteLength >>> 0
  6326. if (!noAssert) {
  6327. checkOffset(offset, byteLength, this.length)
  6328. }
  6329. var val = this[offset + --byteLength]
  6330. var mul = 1
  6331. while (byteLength > 0 && (mul *= 0x100)) {
  6332. val += this[offset + --byteLength] * mul
  6333. }
  6334. return val
  6335. }
  6336. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6337. offset = offset >>> 0
  6338. if (!noAssert) checkOffset(offset, 1, this.length)
  6339. return this[offset]
  6340. }
  6341. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6342. offset = offset >>> 0
  6343. if (!noAssert) checkOffset(offset, 2, this.length)
  6344. return this[offset] | (this[offset + 1] << 8)
  6345. }
  6346. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6347. offset = offset >>> 0
  6348. if (!noAssert) checkOffset(offset, 2, this.length)
  6349. return (this[offset] << 8) | this[offset + 1]
  6350. }
  6351. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6352. offset = offset >>> 0
  6353. if (!noAssert) checkOffset(offset, 4, this.length)
  6354. return ((this[offset]) |
  6355. (this[offset + 1] << 8) |
  6356. (this[offset + 2] << 16)) +
  6357. (this[offset + 3] * 0x1000000)
  6358. }
  6359. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6360. offset = offset >>> 0
  6361. if (!noAssert) checkOffset(offset, 4, this.length)
  6362. return (this[offset] * 0x1000000) +
  6363. ((this[offset + 1] << 16) |
  6364. (this[offset + 2] << 8) |
  6365. this[offset + 3])
  6366. }
  6367. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6368. offset = offset >>> 0
  6369. byteLength = byteLength >>> 0
  6370. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6371. var val = this[offset]
  6372. var mul = 1
  6373. var i = 0
  6374. while (++i < byteLength && (mul *= 0x100)) {
  6375. val += this[offset + i] * mul
  6376. }
  6377. mul *= 0x80
  6378. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6379. return val
  6380. }
  6381. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6382. offset = offset >>> 0
  6383. byteLength = byteLength >>> 0
  6384. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6385. var i = byteLength
  6386. var mul = 1
  6387. var val = this[offset + --i]
  6388. while (i > 0 && (mul *= 0x100)) {
  6389. val += this[offset + --i] * mul
  6390. }
  6391. mul *= 0x80
  6392. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6393. return val
  6394. }
  6395. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6396. offset = offset >>> 0
  6397. if (!noAssert) checkOffset(offset, 1, this.length)
  6398. if (!(this[offset] & 0x80)) return (this[offset])
  6399. return ((0xff - this[offset] + 1) * -1)
  6400. }
  6401. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6402. offset = offset >>> 0
  6403. if (!noAssert) checkOffset(offset, 2, this.length)
  6404. var val = this[offset] | (this[offset + 1] << 8)
  6405. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6406. }
  6407. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6408. offset = offset >>> 0
  6409. if (!noAssert) checkOffset(offset, 2, this.length)
  6410. var val = this[offset + 1] | (this[offset] << 8)
  6411. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6412. }
  6413. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6414. offset = offset >>> 0
  6415. if (!noAssert) checkOffset(offset, 4, this.length)
  6416. return (this[offset]) |
  6417. (this[offset + 1] << 8) |
  6418. (this[offset + 2] << 16) |
  6419. (this[offset + 3] << 24)
  6420. }
  6421. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6422. offset = offset >>> 0
  6423. if (!noAssert) checkOffset(offset, 4, this.length)
  6424. return (this[offset] << 24) |
  6425. (this[offset + 1] << 16) |
  6426. (this[offset + 2] << 8) |
  6427. (this[offset + 3])
  6428. }
  6429. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6430. offset = offset >>> 0
  6431. if (!noAssert) checkOffset(offset, 4, this.length)
  6432. return ieee754.read(this, offset, true, 23, 4)
  6433. }
  6434. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6435. offset = offset >>> 0
  6436. if (!noAssert) checkOffset(offset, 4, this.length)
  6437. return ieee754.read(this, offset, false, 23, 4)
  6438. }
  6439. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6440. offset = offset >>> 0
  6441. if (!noAssert) checkOffset(offset, 8, this.length)
  6442. return ieee754.read(this, offset, true, 52, 8)
  6443. }
  6444. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6445. offset = offset >>> 0
  6446. if (!noAssert) checkOffset(offset, 8, this.length)
  6447. return ieee754.read(this, offset, false, 52, 8)
  6448. }
  6449. function checkInt (buf, value, offset, ext, max, min) {
  6450. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6451. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6452. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6453. }
  6454. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6455. value = +value
  6456. offset = offset >>> 0
  6457. byteLength = byteLength >>> 0
  6458. if (!noAssert) {
  6459. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6460. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6461. }
  6462. var mul = 1
  6463. var i = 0
  6464. this[offset] = value & 0xFF
  6465. while (++i < byteLength && (mul *= 0x100)) {
  6466. this[offset + i] = (value / mul) & 0xFF
  6467. }
  6468. return offset + byteLength
  6469. }
  6470. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6471. value = +value
  6472. offset = offset >>> 0
  6473. byteLength = byteLength >>> 0
  6474. if (!noAssert) {
  6475. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6476. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6477. }
  6478. var i = byteLength - 1
  6479. var mul = 1
  6480. this[offset + i] = value & 0xFF
  6481. while (--i >= 0 && (mul *= 0x100)) {
  6482. this[offset + i] = (value / mul) & 0xFF
  6483. }
  6484. return offset + byteLength
  6485. }
  6486. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6487. value = +value
  6488. offset = offset >>> 0
  6489. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6490. this[offset] = (value & 0xff)
  6491. return offset + 1
  6492. }
  6493. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6494. value = +value
  6495. offset = offset >>> 0
  6496. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6497. this[offset] = (value & 0xff)
  6498. this[offset + 1] = (value >>> 8)
  6499. return offset + 2
  6500. }
  6501. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6502. value = +value
  6503. offset = offset >>> 0
  6504. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6505. this[offset] = (value >>> 8)
  6506. this[offset + 1] = (value & 0xff)
  6507. return offset + 2
  6508. }
  6509. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6510. value = +value
  6511. offset = offset >>> 0
  6512. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6513. this[offset + 3] = (value >>> 24)
  6514. this[offset + 2] = (value >>> 16)
  6515. this[offset + 1] = (value >>> 8)
  6516. this[offset] = (value & 0xff)
  6517. return offset + 4
  6518. }
  6519. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6520. value = +value
  6521. offset = offset >>> 0
  6522. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6523. this[offset] = (value >>> 24)
  6524. this[offset + 1] = (value >>> 16)
  6525. this[offset + 2] = (value >>> 8)
  6526. this[offset + 3] = (value & 0xff)
  6527. return offset + 4
  6528. }
  6529. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6530. value = +value
  6531. offset = offset >>> 0
  6532. if (!noAssert) {
  6533. var limit = Math.pow(2, (8 * byteLength) - 1)
  6534. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6535. }
  6536. var i = 0
  6537. var mul = 1
  6538. var sub = 0
  6539. this[offset] = value & 0xFF
  6540. while (++i < byteLength && (mul *= 0x100)) {
  6541. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6542. sub = 1
  6543. }
  6544. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6545. }
  6546. return offset + byteLength
  6547. }
  6548. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6549. value = +value
  6550. offset = offset >>> 0
  6551. if (!noAssert) {
  6552. var limit = Math.pow(2, (8 * byteLength) - 1)
  6553. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6554. }
  6555. var i = byteLength - 1
  6556. var mul = 1
  6557. var sub = 0
  6558. this[offset + i] = value & 0xFF
  6559. while (--i >= 0 && (mul *= 0x100)) {
  6560. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6561. sub = 1
  6562. }
  6563. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6564. }
  6565. return offset + byteLength
  6566. }
  6567. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6568. value = +value
  6569. offset = offset >>> 0
  6570. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6571. if (value < 0) value = 0xff + value + 1
  6572. this[offset] = (value & 0xff)
  6573. return offset + 1
  6574. }
  6575. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6576. value = +value
  6577. offset = offset >>> 0
  6578. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6579. this[offset] = (value & 0xff)
  6580. this[offset + 1] = (value >>> 8)
  6581. return offset + 2
  6582. }
  6583. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6584. value = +value
  6585. offset = offset >>> 0
  6586. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6587. this[offset] = (value >>> 8)
  6588. this[offset + 1] = (value & 0xff)
  6589. return offset + 2
  6590. }
  6591. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6592. value = +value
  6593. offset = offset >>> 0
  6594. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6595. this[offset] = (value & 0xff)
  6596. this[offset + 1] = (value >>> 8)
  6597. this[offset + 2] = (value >>> 16)
  6598. this[offset + 3] = (value >>> 24)
  6599. return offset + 4
  6600. }
  6601. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6602. value = +value
  6603. offset = offset >>> 0
  6604. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6605. if (value < 0) value = 0xffffffff + value + 1
  6606. this[offset] = (value >>> 24)
  6607. this[offset + 1] = (value >>> 16)
  6608. this[offset + 2] = (value >>> 8)
  6609. this[offset + 3] = (value & 0xff)
  6610. return offset + 4
  6611. }
  6612. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6613. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6614. if (offset < 0) throw new RangeError('Index out of range')
  6615. }
  6616. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6617. value = +value
  6618. offset = offset >>> 0
  6619. if (!noAssert) {
  6620. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6621. }
  6622. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6623. return offset + 4
  6624. }
  6625. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6626. return writeFloat(this, value, offset, true, noAssert)
  6627. }
  6628. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6629. return writeFloat(this, value, offset, false, noAssert)
  6630. }
  6631. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6632. value = +value
  6633. offset = offset >>> 0
  6634. if (!noAssert) {
  6635. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6636. }
  6637. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6638. return offset + 8
  6639. }
  6640. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6641. return writeDouble(this, value, offset, true, noAssert)
  6642. }
  6643. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6644. return writeDouble(this, value, offset, false, noAssert)
  6645. }
  6646. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6647. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6648. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
  6649. if (!start) start = 0
  6650. if (!end && end !== 0) end = this.length
  6651. if (targetStart >= target.length) targetStart = target.length
  6652. if (!targetStart) targetStart = 0
  6653. if (end > 0 && end < start) end = start
  6654. // Copy 0 bytes; we're done
  6655. if (end === start) return 0
  6656. if (target.length === 0 || this.length === 0) return 0
  6657. // Fatal error conditions
  6658. if (targetStart < 0) {
  6659. throw new RangeError('targetStart out of bounds')
  6660. }
  6661. if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
  6662. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6663. // Are we oob?
  6664. if (end > this.length) end = this.length
  6665. if (target.length - targetStart < end - start) {
  6666. end = target.length - targetStart + start
  6667. }
  6668. var len = end - start
  6669. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  6670. // Use built-in when available, missing from IE11
  6671. this.copyWithin(targetStart, start, end)
  6672. } else if (this === target && start < targetStart && targetStart < end) {
  6673. // descending copy from end
  6674. for (var i = len - 1; i >= 0; --i) {
  6675. target[i + targetStart] = this[i + start]
  6676. }
  6677. } else {
  6678. Uint8Array.prototype.set.call(
  6679. target,
  6680. this.subarray(start, end),
  6681. targetStart
  6682. )
  6683. }
  6684. return len
  6685. }
  6686. // Usage:
  6687. // buffer.fill(number[, offset[, end]])
  6688. // buffer.fill(buffer[, offset[, end]])
  6689. // buffer.fill(string[, offset[, end]][, encoding])
  6690. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6691. // Handle string cases:
  6692. if (typeof val === 'string') {
  6693. if (typeof start === 'string') {
  6694. encoding = start
  6695. start = 0
  6696. end = this.length
  6697. } else if (typeof end === 'string') {
  6698. encoding = end
  6699. end = this.length
  6700. }
  6701. if (encoding !== undefined && typeof encoding !== 'string') {
  6702. throw new TypeError('encoding must be a string')
  6703. }
  6704. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  6705. throw new TypeError('Unknown encoding: ' + encoding)
  6706. }
  6707. if (val.length === 1) {
  6708. var code = val.charCodeAt(0)
  6709. if ((encoding === 'utf8' && code < 128) ||
  6710. encoding === 'latin1') {
  6711. // Fast path: If `val` fits into a single byte, use that numeric value.
  6712. val = code
  6713. }
  6714. }
  6715. } else if (typeof val === 'number') {
  6716. val = val & 255
  6717. }
  6718. // Invalid ranges are not set to a default, so can range check early.
  6719. if (start < 0 || this.length < start || this.length < end) {
  6720. throw new RangeError('Out of range index')
  6721. }
  6722. if (end <= start) {
  6723. return this
  6724. }
  6725. start = start >>> 0
  6726. end = end === undefined ? this.length : end >>> 0
  6727. if (!val) val = 0
  6728. var i
  6729. if (typeof val === 'number') {
  6730. for (i = start; i < end; ++i) {
  6731. this[i] = val
  6732. }
  6733. } else {
  6734. var bytes = Buffer.isBuffer(val)
  6735. ? val
  6736. : Buffer.from(val, encoding)
  6737. var len = bytes.length
  6738. if (len === 0) {
  6739. throw new TypeError('The value "' + val +
  6740. '" is invalid for argument "value"')
  6741. }
  6742. for (i = 0; i < end - start; ++i) {
  6743. this[i + start] = bytes[i % len]
  6744. }
  6745. }
  6746. return this
  6747. }
  6748. // HELPER FUNCTIONS
  6749. // ================
  6750. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  6751. function base64clean (str) {
  6752. // Node takes equal signs as end of the Base64 encoding
  6753. str = str.split('=')[0]
  6754. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  6755. str = str.trim().replace(INVALID_BASE64_RE, '')
  6756. // Node converts strings with length < 2 to ''
  6757. if (str.length < 2) return ''
  6758. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  6759. while (str.length % 4 !== 0) {
  6760. str = str + '='
  6761. }
  6762. return str
  6763. }
  6764. function toHex (n) {
  6765. if (n < 16) return '0' + n.toString(16)
  6766. return n.toString(16)
  6767. }
  6768. function utf8ToBytes (string, units) {
  6769. units = units || Infinity
  6770. var codePoint
  6771. var length = string.length
  6772. var leadSurrogate = null
  6773. var bytes = []
  6774. for (var i = 0; i < length; ++i) {
  6775. codePoint = string.charCodeAt(i)
  6776. // is surrogate component
  6777. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  6778. // last char was a lead
  6779. if (!leadSurrogate) {
  6780. // no lead yet
  6781. if (codePoint > 0xDBFF) {
  6782. // unexpected trail
  6783. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6784. continue
  6785. } else if (i + 1 === length) {
  6786. // unpaired lead
  6787. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6788. continue
  6789. }
  6790. // valid lead
  6791. leadSurrogate = codePoint
  6792. continue
  6793. }
  6794. // 2 leads in a row
  6795. if (codePoint < 0xDC00) {
  6796. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6797. leadSurrogate = codePoint
  6798. continue
  6799. }
  6800. // valid surrogate pair
  6801. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  6802. } else if (leadSurrogate) {
  6803. // valid bmp char, but last char was a lead
  6804. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6805. }
  6806. leadSurrogate = null
  6807. // encode utf8
  6808. if (codePoint < 0x80) {
  6809. if ((units -= 1) < 0) break
  6810. bytes.push(codePoint)
  6811. } else if (codePoint < 0x800) {
  6812. if ((units -= 2) < 0) break
  6813. bytes.push(
  6814. codePoint >> 0x6 | 0xC0,
  6815. codePoint & 0x3F | 0x80
  6816. )
  6817. } else if (codePoint < 0x10000) {
  6818. if ((units -= 3) < 0) break
  6819. bytes.push(
  6820. codePoint >> 0xC | 0xE0,
  6821. codePoint >> 0x6 & 0x3F | 0x80,
  6822. codePoint & 0x3F | 0x80
  6823. )
  6824. } else if (codePoint < 0x110000) {
  6825. if ((units -= 4) < 0) break
  6826. bytes.push(
  6827. codePoint >> 0x12 | 0xF0,
  6828. codePoint >> 0xC & 0x3F | 0x80,
  6829. codePoint >> 0x6 & 0x3F | 0x80,
  6830. codePoint & 0x3F | 0x80
  6831. )
  6832. } else {
  6833. throw new Error('Invalid code point')
  6834. }
  6835. }
  6836. return bytes
  6837. }
  6838. function asciiToBytes (str) {
  6839. var byteArray = []
  6840. for (var i = 0; i < str.length; ++i) {
  6841. // Node's code seems to be doing this and not & 0x7F..
  6842. byteArray.push(str.charCodeAt(i) & 0xFF)
  6843. }
  6844. return byteArray
  6845. }
  6846. function utf16leToBytes (str, units) {
  6847. var c, hi, lo
  6848. var byteArray = []
  6849. for (var i = 0; i < str.length; ++i) {
  6850. if ((units -= 2) < 0) break
  6851. c = str.charCodeAt(i)
  6852. hi = c >> 8
  6853. lo = c % 256
  6854. byteArray.push(lo)
  6855. byteArray.push(hi)
  6856. }
  6857. return byteArray
  6858. }
  6859. function base64ToBytes (str) {
  6860. return base64.toByteArray(base64clean(str))
  6861. }
  6862. function blitBuffer (src, dst, offset, length) {
  6863. for (var i = 0; i < length; ++i) {
  6864. if ((i + offset >= dst.length) || (i >= src.length)) break
  6865. dst[i + offset] = src[i]
  6866. }
  6867. return i
  6868. }
  6869. // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  6870. // the `instanceof` check but they should be treated as of that type.
  6871. // See: https://github.com/feross/buffer/issues/166
  6872. function isInstance (obj, type) {
  6873. return obj instanceof type ||
  6874. (obj != null && obj.constructor != null && obj.constructor.name != null &&
  6875. obj.constructor.name === type.name)
  6876. }
  6877. function numberIsNaN (obj) {
  6878. // For IE11 support
  6879. return obj !== obj // eslint-disable-line no-self-compare
  6880. }
  6881. }).call(this)}).call(this,require("buffer").Buffer)
  6882. },{"base64-js":8,"buffer":9,"ieee754":10}],10:[function(require,module,exports){
  6883. /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
  6884. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  6885. var e, m
  6886. var eLen = (nBytes * 8) - mLen - 1
  6887. var eMax = (1 << eLen) - 1
  6888. var eBias = eMax >> 1
  6889. var nBits = -7
  6890. var i = isLE ? (nBytes - 1) : 0
  6891. var d = isLE ? -1 : 1
  6892. var s = buffer[offset + i]
  6893. i += d
  6894. e = s & ((1 << (-nBits)) - 1)
  6895. s >>= (-nBits)
  6896. nBits += eLen
  6897. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  6898. m = e & ((1 << (-nBits)) - 1)
  6899. e >>= (-nBits)
  6900. nBits += mLen
  6901. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  6902. if (e === 0) {
  6903. e = 1 - eBias
  6904. } else if (e === eMax) {
  6905. return m ? NaN : ((s ? -1 : 1) * Infinity)
  6906. } else {
  6907. m = m + Math.pow(2, mLen)
  6908. e = e - eBias
  6909. }
  6910. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  6911. }
  6912. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  6913. var e, m, c
  6914. var eLen = (nBytes * 8) - mLen - 1
  6915. var eMax = (1 << eLen) - 1
  6916. var eBias = eMax >> 1
  6917. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  6918. var i = isLE ? 0 : (nBytes - 1)
  6919. var d = isLE ? 1 : -1
  6920. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  6921. value = Math.abs(value)
  6922. if (isNaN(value) || value === Infinity) {
  6923. m = isNaN(value) ? 1 : 0
  6924. e = eMax
  6925. } else {
  6926. e = Math.floor(Math.log(value) / Math.LN2)
  6927. if (value * (c = Math.pow(2, -e)) < 1) {
  6928. e--
  6929. c *= 2
  6930. }
  6931. if (e + eBias >= 1) {
  6932. value += rt / c
  6933. } else {
  6934. value += rt * Math.pow(2, 1 - eBias)
  6935. }
  6936. if (value * c >= 2) {
  6937. e++
  6938. c /= 2
  6939. }
  6940. if (e + eBias >= eMax) {
  6941. m = 0
  6942. e = eMax
  6943. } else if (e + eBias >= 1) {
  6944. m = ((value * c) - 1) * Math.pow(2, mLen)
  6945. e = e + eBias
  6946. } else {
  6947. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  6948. e = 0
  6949. }
  6950. }
  6951. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  6952. e = (e << mLen) | m
  6953. eLen += mLen
  6954. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  6955. buffer[offset + i - d] |= s * 128
  6956. }
  6957. },{}]},{},[1])(1)
  6958. });