2
0

pdf.worker.js 1.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function webpackUniversalModuleDefinition(root, factory) {
  16. if(typeof exports === 'object' && typeof module === 'object')
  17. module.exports = factory();
  18. else if(typeof define === 'function' && define.amd)
  19. define("pdfjs-dist/build/pdf.worker", [], factory);
  20. else if(typeof exports === 'object')
  21. exports["pdfjs-dist/build/pdf.worker"] = factory();
  22. else
  23. root["pdfjs-dist/build/pdf.worker"] = root.pdfjsDistBuildPdfWorker = factory();
  24. })(this, function() {
  25. return /******/ (function(modules) { // webpackBootstrap
  26. /******/ // The module cache
  27. /******/ var installedModules = {};
  28. /******/ // The require function
  29. /******/ function __w_pdfjs_require__(moduleId) {
  30. /******/ // Check if module is in cache
  31. /******/ if(installedModules[moduleId])
  32. /******/ return installedModules[moduleId].exports;
  33. /******/ // Create a new module (and put it into the cache)
  34. /******/ var module = installedModules[moduleId] = {
  35. /******/ i: moduleId,
  36. /******/ l: false,
  37. /******/ exports: {}
  38. /******/ };
  39. /******/ // Execute the module function
  40. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  41. /******/ // Flag the module as loaded
  42. /******/ module.l = true;
  43. /******/ // Return the exports of the module
  44. /******/ return module.exports;
  45. /******/ }
  46. /******/ // expose the modules object (__webpack_modules__)
  47. /******/ __w_pdfjs_require__.m = modules;
  48. /******/ // expose the module cache
  49. /******/ __w_pdfjs_require__.c = installedModules;
  50. /******/ // identity function for calling harmony imports with the correct context
  51. /******/ __w_pdfjs_require__.i = function(value) { return value; };
  52. /******/ // define getter function for harmony exports
  53. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  54. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  55. /******/ Object.defineProperty(exports, name, {
  56. /******/ configurable: false,
  57. /******/ enumerable: true,
  58. /******/ get: getter
  59. /******/ });
  60. /******/ }
  61. /******/ };
  62. /******/ // getDefaultExport function for compatibility with non-harmony modules
  63. /******/ __w_pdfjs_require__.n = function(module) {
  64. /******/ var getter = module && module.__esModule ?
  65. /******/ function getDefault() { return module['default']; } :
  66. /******/ function getModuleExports() { return module; };
  67. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  68. /******/ return getter;
  69. /******/ };
  70. /******/ // Object.prototype.hasOwnProperty.call
  71. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  72. /******/ // __webpack_public_path__
  73. /******/ __w_pdfjs_require__.p = "";
  74. /******/ // Load entry module and return exports
  75. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 37);
  76. /******/ })
  77. /************************************************************************/
  78. /******/ ([
  79. /* 0 */
  80. /***/ (function(module, exports, __w_pdfjs_require__) {
  81. "use strict";
  82. /* WEBPACK VAR INJECTION */(function(global) {
  83. var compatibility = __w_pdfjs_require__(36);
  84. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  85. var FONT_IDENTITY_MATRIX = [
  86. 0.001,
  87. 0,
  88. 0,
  89. 0.001,
  90. 0,
  91. 0
  92. ];
  93. var TextRenderingMode = {
  94. FILL: 0,
  95. STROKE: 1,
  96. FILL_STROKE: 2,
  97. INVISIBLE: 3,
  98. FILL_ADD_TO_PATH: 4,
  99. STROKE_ADD_TO_PATH: 5,
  100. FILL_STROKE_ADD_TO_PATH: 6,
  101. ADD_TO_PATH: 7,
  102. FILL_STROKE_MASK: 3,
  103. ADD_TO_PATH_FLAG: 4
  104. };
  105. var ImageKind = {
  106. GRAYSCALE_1BPP: 1,
  107. RGB_24BPP: 2,
  108. RGBA_32BPP: 3
  109. };
  110. var AnnotationType = {
  111. TEXT: 1,
  112. LINK: 2,
  113. FREETEXT: 3,
  114. LINE: 4,
  115. SQUARE: 5,
  116. CIRCLE: 6,
  117. POLYGON: 7,
  118. POLYLINE: 8,
  119. HIGHLIGHT: 9,
  120. UNDERLINE: 10,
  121. SQUIGGLY: 11,
  122. STRIKEOUT: 12,
  123. STAMP: 13,
  124. CARET: 14,
  125. INK: 15,
  126. POPUP: 16,
  127. FILEATTACHMENT: 17,
  128. SOUND: 18,
  129. MOVIE: 19,
  130. WIDGET: 20,
  131. SCREEN: 21,
  132. PRINTERMARK: 22,
  133. TRAPNET: 23,
  134. WATERMARK: 24,
  135. THREED: 25,
  136. REDACT: 26
  137. };
  138. var AnnotationFlag = {
  139. INVISIBLE: 0x01,
  140. HIDDEN: 0x02,
  141. PRINT: 0x04,
  142. NOZOOM: 0x08,
  143. NOROTATE: 0x10,
  144. NOVIEW: 0x20,
  145. READONLY: 0x40,
  146. LOCKED: 0x80,
  147. TOGGLENOVIEW: 0x100,
  148. LOCKEDCONTENTS: 0x200
  149. };
  150. var AnnotationFieldFlag = {
  151. READONLY: 0x0000001,
  152. REQUIRED: 0x0000002,
  153. NOEXPORT: 0x0000004,
  154. MULTILINE: 0x0001000,
  155. PASSWORD: 0x0002000,
  156. NOTOGGLETOOFF: 0x0004000,
  157. RADIO: 0x0008000,
  158. PUSHBUTTON: 0x0010000,
  159. COMBO: 0x0020000,
  160. EDIT: 0x0040000,
  161. SORT: 0x0080000,
  162. FILESELECT: 0x0100000,
  163. MULTISELECT: 0x0200000,
  164. DONOTSPELLCHECK: 0x0400000,
  165. DONOTSCROLL: 0x0800000,
  166. COMB: 0x1000000,
  167. RICHTEXT: 0x2000000,
  168. RADIOSINUNISON: 0x2000000,
  169. COMMITONSELCHANGE: 0x4000000
  170. };
  171. var AnnotationBorderStyleType = {
  172. SOLID: 1,
  173. DASHED: 2,
  174. BEVELED: 3,
  175. INSET: 4,
  176. UNDERLINE: 5
  177. };
  178. var StreamType = {
  179. UNKNOWN: 0,
  180. FLATE: 1,
  181. LZW: 2,
  182. DCT: 3,
  183. JPX: 4,
  184. JBIG: 5,
  185. A85: 6,
  186. AHX: 7,
  187. CCF: 8,
  188. RL: 9
  189. };
  190. var FontType = {
  191. UNKNOWN: 0,
  192. TYPE1: 1,
  193. TYPE1C: 2,
  194. CIDFONTTYPE0: 3,
  195. CIDFONTTYPE0C: 4,
  196. TRUETYPE: 5,
  197. CIDFONTTYPE2: 6,
  198. TYPE3: 7,
  199. OPENTYPE: 8,
  200. TYPE0: 9,
  201. MMTYPE1: 10
  202. };
  203. var VERBOSITY_LEVELS = {
  204. errors: 0,
  205. warnings: 1,
  206. infos: 5
  207. };
  208. var CMapCompressionType = {
  209. NONE: 0,
  210. BINARY: 1,
  211. STREAM: 2
  212. };
  213. var OPS = {
  214. dependency: 1,
  215. setLineWidth: 2,
  216. setLineCap: 3,
  217. setLineJoin: 4,
  218. setMiterLimit: 5,
  219. setDash: 6,
  220. setRenderingIntent: 7,
  221. setFlatness: 8,
  222. setGState: 9,
  223. save: 10,
  224. restore: 11,
  225. transform: 12,
  226. moveTo: 13,
  227. lineTo: 14,
  228. curveTo: 15,
  229. curveTo2: 16,
  230. curveTo3: 17,
  231. closePath: 18,
  232. rectangle: 19,
  233. stroke: 20,
  234. closeStroke: 21,
  235. fill: 22,
  236. eoFill: 23,
  237. fillStroke: 24,
  238. eoFillStroke: 25,
  239. closeFillStroke: 26,
  240. closeEOFillStroke: 27,
  241. endPath: 28,
  242. clip: 29,
  243. eoClip: 30,
  244. beginText: 31,
  245. endText: 32,
  246. setCharSpacing: 33,
  247. setWordSpacing: 34,
  248. setHScale: 35,
  249. setLeading: 36,
  250. setFont: 37,
  251. setTextRenderingMode: 38,
  252. setTextRise: 39,
  253. moveText: 40,
  254. setLeadingMoveText: 41,
  255. setTextMatrix: 42,
  256. nextLine: 43,
  257. showText: 44,
  258. showSpacedText: 45,
  259. nextLineShowText: 46,
  260. nextLineSetSpacingShowText: 47,
  261. setCharWidth: 48,
  262. setCharWidthAndBounds: 49,
  263. setStrokeColorSpace: 50,
  264. setFillColorSpace: 51,
  265. setStrokeColor: 52,
  266. setStrokeColorN: 53,
  267. setFillColor: 54,
  268. setFillColorN: 55,
  269. setStrokeGray: 56,
  270. setFillGray: 57,
  271. setStrokeRGBColor: 58,
  272. setFillRGBColor: 59,
  273. setStrokeCMYKColor: 60,
  274. setFillCMYKColor: 61,
  275. shadingFill: 62,
  276. beginInlineImage: 63,
  277. beginImageData: 64,
  278. endInlineImage: 65,
  279. paintXObject: 66,
  280. markPoint: 67,
  281. markPointProps: 68,
  282. beginMarkedContent: 69,
  283. beginMarkedContentProps: 70,
  284. endMarkedContent: 71,
  285. beginCompat: 72,
  286. endCompat: 73,
  287. paintFormXObjectBegin: 74,
  288. paintFormXObjectEnd: 75,
  289. beginGroup: 76,
  290. endGroup: 77,
  291. beginAnnotations: 78,
  292. endAnnotations: 79,
  293. beginAnnotation: 80,
  294. endAnnotation: 81,
  295. paintJpegXObject: 82,
  296. paintImageMaskXObject: 83,
  297. paintImageMaskXObjectGroup: 84,
  298. paintImageXObject: 85,
  299. paintInlineImageXObject: 86,
  300. paintInlineImageXObjectGroup: 87,
  301. paintImageXObjectRepeat: 88,
  302. paintImageMaskXObjectRepeat: 89,
  303. paintSolidColorImageMask: 90,
  304. constructPath: 91
  305. };
  306. var verbosity = VERBOSITY_LEVELS.warnings;
  307. function setVerbosityLevel(level) {
  308. verbosity = level;
  309. }
  310. function getVerbosityLevel() {
  311. return verbosity;
  312. }
  313. function info(msg) {
  314. if (verbosity >= VERBOSITY_LEVELS.infos) {
  315. console.log('Info: ' + msg);
  316. }
  317. }
  318. function warn(msg) {
  319. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  320. console.log('Warning: ' + msg);
  321. }
  322. }
  323. function deprecated(details) {
  324. console.log('Deprecated API usage: ' + details);
  325. }
  326. function error(msg) {
  327. if (verbosity >= VERBOSITY_LEVELS.errors) {
  328. console.log('Error: ' + msg);
  329. console.log(backtrace());
  330. }
  331. throw new Error(msg);
  332. }
  333. function backtrace() {
  334. try {
  335. throw new Error();
  336. } catch (e) {
  337. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  338. }
  339. }
  340. function assert(cond, msg) {
  341. if (!cond) {
  342. error(msg);
  343. }
  344. }
  345. var UNSUPPORTED_FEATURES = {
  346. unknown: 'unknown',
  347. forms: 'forms',
  348. javaScript: 'javaScript',
  349. smask: 'smask',
  350. shadingPattern: 'shadingPattern',
  351. font: 'font'
  352. };
  353. function isSameOrigin(baseUrl, otherUrl) {
  354. try {
  355. var base = new URL(baseUrl);
  356. if (!base.origin || base.origin === 'null') {
  357. return false;
  358. }
  359. } catch (e) {
  360. return false;
  361. }
  362. var other = new URL(otherUrl, base);
  363. return base.origin === other.origin;
  364. }
  365. function isValidProtocol(url) {
  366. if (!url) {
  367. return false;
  368. }
  369. switch (url.protocol) {
  370. case 'http:':
  371. case 'https:':
  372. case 'ftp:':
  373. case 'mailto:':
  374. case 'tel:':
  375. return true;
  376. default:
  377. return false;
  378. }
  379. }
  380. function createValidAbsoluteUrl(url, baseUrl) {
  381. if (!url) {
  382. return null;
  383. }
  384. try {
  385. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  386. if (isValidProtocol(absoluteUrl)) {
  387. return absoluteUrl;
  388. }
  389. } catch (ex) {
  390. }
  391. return null;
  392. }
  393. function shadow(obj, prop, value) {
  394. Object.defineProperty(obj, prop, {
  395. value: value,
  396. enumerable: true,
  397. configurable: true,
  398. writable: false
  399. });
  400. return value;
  401. }
  402. function getLookupTableFactory(initializer) {
  403. var lookup;
  404. return function () {
  405. if (initializer) {
  406. lookup = Object.create(null);
  407. initializer(lookup);
  408. initializer = null;
  409. }
  410. return lookup;
  411. };
  412. }
  413. var PasswordResponses = {
  414. NEED_PASSWORD: 1,
  415. INCORRECT_PASSWORD: 2
  416. };
  417. var PasswordException = function PasswordExceptionClosure() {
  418. function PasswordException(msg, code) {
  419. this.name = 'PasswordException';
  420. this.message = msg;
  421. this.code = code;
  422. }
  423. PasswordException.prototype = new Error();
  424. PasswordException.constructor = PasswordException;
  425. return PasswordException;
  426. }();
  427. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  428. function UnknownErrorException(msg, details) {
  429. this.name = 'UnknownErrorException';
  430. this.message = msg;
  431. this.details = details;
  432. }
  433. UnknownErrorException.prototype = new Error();
  434. UnknownErrorException.constructor = UnknownErrorException;
  435. return UnknownErrorException;
  436. }();
  437. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  438. function InvalidPDFException(msg) {
  439. this.name = 'InvalidPDFException';
  440. this.message = msg;
  441. }
  442. InvalidPDFException.prototype = new Error();
  443. InvalidPDFException.constructor = InvalidPDFException;
  444. return InvalidPDFException;
  445. }();
  446. var MissingPDFException = function MissingPDFExceptionClosure() {
  447. function MissingPDFException(msg) {
  448. this.name = 'MissingPDFException';
  449. this.message = msg;
  450. }
  451. MissingPDFException.prototype = new Error();
  452. MissingPDFException.constructor = MissingPDFException;
  453. return MissingPDFException;
  454. }();
  455. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  456. function UnexpectedResponseException(msg, status) {
  457. this.name = 'UnexpectedResponseException';
  458. this.message = msg;
  459. this.status = status;
  460. }
  461. UnexpectedResponseException.prototype = new Error();
  462. UnexpectedResponseException.constructor = UnexpectedResponseException;
  463. return UnexpectedResponseException;
  464. }();
  465. var NotImplementedException = function NotImplementedExceptionClosure() {
  466. function NotImplementedException(msg) {
  467. this.message = msg;
  468. }
  469. NotImplementedException.prototype = new Error();
  470. NotImplementedException.prototype.name = 'NotImplementedException';
  471. NotImplementedException.constructor = NotImplementedException;
  472. return NotImplementedException;
  473. }();
  474. var MissingDataException = function MissingDataExceptionClosure() {
  475. function MissingDataException(begin, end) {
  476. this.begin = begin;
  477. this.end = end;
  478. this.message = 'Missing data [' + begin + ', ' + end + ')';
  479. }
  480. MissingDataException.prototype = new Error();
  481. MissingDataException.prototype.name = 'MissingDataException';
  482. MissingDataException.constructor = MissingDataException;
  483. return MissingDataException;
  484. }();
  485. var XRefParseException = function XRefParseExceptionClosure() {
  486. function XRefParseException(msg) {
  487. this.message = msg;
  488. }
  489. XRefParseException.prototype = new Error();
  490. XRefParseException.prototype.name = 'XRefParseException';
  491. XRefParseException.constructor = XRefParseException;
  492. return XRefParseException;
  493. }();
  494. var NullCharactersRegExp = /\x00/g;
  495. function removeNullCharacters(str) {
  496. if (typeof str !== 'string') {
  497. warn('The argument for removeNullCharacters must be a string.');
  498. return str;
  499. }
  500. return str.replace(NullCharactersRegExp, '');
  501. }
  502. function bytesToString(bytes) {
  503. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  504. var length = bytes.length;
  505. var MAX_ARGUMENT_COUNT = 8192;
  506. if (length < MAX_ARGUMENT_COUNT) {
  507. return String.fromCharCode.apply(null, bytes);
  508. }
  509. var strBuf = [];
  510. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  511. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  512. var chunk = bytes.subarray(i, chunkEnd);
  513. strBuf.push(String.fromCharCode.apply(null, chunk));
  514. }
  515. return strBuf.join('');
  516. }
  517. function stringToBytes(str) {
  518. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  519. var length = str.length;
  520. var bytes = new Uint8Array(length);
  521. for (var i = 0; i < length; ++i) {
  522. bytes[i] = str.charCodeAt(i) & 0xFF;
  523. }
  524. return bytes;
  525. }
  526. function arrayByteLength(arr) {
  527. if (arr.length !== undefined) {
  528. return arr.length;
  529. }
  530. assert(arr.byteLength !== undefined);
  531. return arr.byteLength;
  532. }
  533. function arraysToBytes(arr) {
  534. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  535. return arr[0];
  536. }
  537. var resultLength = 0;
  538. var i, ii = arr.length;
  539. var item, itemLength;
  540. for (i = 0; i < ii; i++) {
  541. item = arr[i];
  542. itemLength = arrayByteLength(item);
  543. resultLength += itemLength;
  544. }
  545. var pos = 0;
  546. var data = new Uint8Array(resultLength);
  547. for (i = 0; i < ii; i++) {
  548. item = arr[i];
  549. if (!(item instanceof Uint8Array)) {
  550. if (typeof item === 'string') {
  551. item = stringToBytes(item);
  552. } else {
  553. item = new Uint8Array(item);
  554. }
  555. }
  556. itemLength = item.byteLength;
  557. data.set(item, pos);
  558. pos += itemLength;
  559. }
  560. return data;
  561. }
  562. function string32(value) {
  563. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  564. }
  565. function log2(x) {
  566. var n = 1, i = 0;
  567. while (x > n) {
  568. n <<= 1;
  569. i++;
  570. }
  571. return i;
  572. }
  573. function readInt8(data, start) {
  574. return data[start] << 24 >> 24;
  575. }
  576. function readUint16(data, offset) {
  577. return data[offset] << 8 | data[offset + 1];
  578. }
  579. function readUint32(data, offset) {
  580. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  581. }
  582. function isLittleEndian() {
  583. var buffer8 = new Uint8Array(2);
  584. buffer8[0] = 1;
  585. var buffer16 = new Uint16Array(buffer8.buffer);
  586. return buffer16[0] === 1;
  587. }
  588. function isEvalSupported() {
  589. try {
  590. new Function('');
  591. return true;
  592. } catch (e) {
  593. return false;
  594. }
  595. }
  596. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  597. function Uint32ArrayView(buffer, length) {
  598. this.buffer = buffer;
  599. this.byteLength = buffer.length;
  600. this.length = length === undefined ? this.byteLength >> 2 : length;
  601. ensureUint32ArrayViewProps(this.length);
  602. }
  603. Uint32ArrayView.prototype = Object.create(null);
  604. var uint32ArrayViewSetters = 0;
  605. function createUint32ArrayProp(index) {
  606. return {
  607. get: function () {
  608. var buffer = this.buffer, offset = index << 2;
  609. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  610. },
  611. set: function (value) {
  612. var buffer = this.buffer, offset = index << 2;
  613. buffer[offset] = value & 255;
  614. buffer[offset + 1] = value >> 8 & 255;
  615. buffer[offset + 2] = value >> 16 & 255;
  616. buffer[offset + 3] = value >>> 24 & 255;
  617. }
  618. };
  619. }
  620. function ensureUint32ArrayViewProps(length) {
  621. while (uint32ArrayViewSetters < length) {
  622. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  623. uint32ArrayViewSetters++;
  624. }
  625. }
  626. return Uint32ArrayView;
  627. }();
  628. exports.Uint32ArrayView = Uint32ArrayView;
  629. var IDENTITY_MATRIX = [
  630. 1,
  631. 0,
  632. 0,
  633. 1,
  634. 0,
  635. 0
  636. ];
  637. var Util = function UtilClosure() {
  638. function Util() {
  639. }
  640. var rgbBuf = [
  641. 'rgb(',
  642. 0,
  643. ',',
  644. 0,
  645. ',',
  646. 0,
  647. ')'
  648. ];
  649. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  650. rgbBuf[1] = r;
  651. rgbBuf[3] = g;
  652. rgbBuf[5] = b;
  653. return rgbBuf.join('');
  654. };
  655. Util.transform = function Util_transform(m1, m2) {
  656. return [
  657. m1[0] * m2[0] + m1[2] * m2[1],
  658. m1[1] * m2[0] + m1[3] * m2[1],
  659. m1[0] * m2[2] + m1[2] * m2[3],
  660. m1[1] * m2[2] + m1[3] * m2[3],
  661. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  662. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  663. ];
  664. };
  665. Util.applyTransform = function Util_applyTransform(p, m) {
  666. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  667. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  668. return [
  669. xt,
  670. yt
  671. ];
  672. };
  673. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  674. var d = m[0] * m[3] - m[1] * m[2];
  675. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  676. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  677. return [
  678. xt,
  679. yt
  680. ];
  681. };
  682. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  683. var p1 = Util.applyTransform(r, m);
  684. var p2 = Util.applyTransform(r.slice(2, 4), m);
  685. var p3 = Util.applyTransform([
  686. r[0],
  687. r[3]
  688. ], m);
  689. var p4 = Util.applyTransform([
  690. r[2],
  691. r[1]
  692. ], m);
  693. return [
  694. Math.min(p1[0], p2[0], p3[0], p4[0]),
  695. Math.min(p1[1], p2[1], p3[1], p4[1]),
  696. Math.max(p1[0], p2[0], p3[0], p4[0]),
  697. Math.max(p1[1], p2[1], p3[1], p4[1])
  698. ];
  699. };
  700. Util.inverseTransform = function Util_inverseTransform(m) {
  701. var d = m[0] * m[3] - m[1] * m[2];
  702. return [
  703. m[3] / d,
  704. -m[1] / d,
  705. -m[2] / d,
  706. m[0] / d,
  707. (m[2] * m[5] - m[4] * m[3]) / d,
  708. (m[4] * m[1] - m[5] * m[0]) / d
  709. ];
  710. };
  711. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  712. return [
  713. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  714. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  715. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  716. ];
  717. };
  718. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  719. var transpose = [
  720. m[0],
  721. m[2],
  722. m[1],
  723. m[3]
  724. ];
  725. var a = m[0] * transpose[0] + m[1] * transpose[2];
  726. var b = m[0] * transpose[1] + m[1] * transpose[3];
  727. var c = m[2] * transpose[0] + m[3] * transpose[2];
  728. var d = m[2] * transpose[1] + m[3] * transpose[3];
  729. var first = (a + d) / 2;
  730. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  731. var sx = first + second || 1;
  732. var sy = first - second || 1;
  733. return [
  734. Math.sqrt(sx),
  735. Math.sqrt(sy)
  736. ];
  737. };
  738. Util.normalizeRect = function Util_normalizeRect(rect) {
  739. var r = rect.slice(0);
  740. if (rect[0] > rect[2]) {
  741. r[0] = rect[2];
  742. r[2] = rect[0];
  743. }
  744. if (rect[1] > rect[3]) {
  745. r[1] = rect[3];
  746. r[3] = rect[1];
  747. }
  748. return r;
  749. };
  750. Util.intersect = function Util_intersect(rect1, rect2) {
  751. function compare(a, b) {
  752. return a - b;
  753. }
  754. var orderedX = [
  755. rect1[0],
  756. rect1[2],
  757. rect2[0],
  758. rect2[2]
  759. ].sort(compare), orderedY = [
  760. rect1[1],
  761. rect1[3],
  762. rect2[1],
  763. rect2[3]
  764. ].sort(compare), result = [];
  765. rect1 = Util.normalizeRect(rect1);
  766. rect2 = Util.normalizeRect(rect2);
  767. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  768. result[0] = orderedX[1];
  769. result[2] = orderedX[2];
  770. } else {
  771. return false;
  772. }
  773. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  774. result[1] = orderedY[1];
  775. result[3] = orderedY[2];
  776. } else {
  777. return false;
  778. }
  779. return result;
  780. };
  781. Util.sign = function Util_sign(num) {
  782. return num < 0 ? -1 : 1;
  783. };
  784. var ROMAN_NUMBER_MAP = [
  785. '',
  786. 'C',
  787. 'CC',
  788. 'CCC',
  789. 'CD',
  790. 'D',
  791. 'DC',
  792. 'DCC',
  793. 'DCCC',
  794. 'CM',
  795. '',
  796. 'X',
  797. 'XX',
  798. 'XXX',
  799. 'XL',
  800. 'L',
  801. 'LX',
  802. 'LXX',
  803. 'LXXX',
  804. 'XC',
  805. '',
  806. 'I',
  807. 'II',
  808. 'III',
  809. 'IV',
  810. 'V',
  811. 'VI',
  812. 'VII',
  813. 'VIII',
  814. 'IX'
  815. ];
  816. Util.toRoman = function Util_toRoman(number, lowerCase) {
  817. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  818. var pos, romanBuf = [];
  819. while (number >= 1000) {
  820. number -= 1000;
  821. romanBuf.push('M');
  822. }
  823. pos = number / 100 | 0;
  824. number %= 100;
  825. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  826. pos = number / 10 | 0;
  827. number %= 10;
  828. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  829. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  830. var romanStr = romanBuf.join('');
  831. return lowerCase ? romanStr.toLowerCase() : romanStr;
  832. };
  833. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  834. Array.prototype.push.apply(arr1, arr2);
  835. };
  836. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  837. Array.prototype.unshift.apply(arr1, arr2);
  838. };
  839. Util.extendObj = function extendObj(obj1, obj2) {
  840. for (var key in obj2) {
  841. obj1[key] = obj2[key];
  842. }
  843. };
  844. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  845. while (dict && !dict.has(name)) {
  846. dict = dict.get('Parent');
  847. }
  848. if (!dict) {
  849. return null;
  850. }
  851. return getArray ? dict.getArray(name) : dict.get(name);
  852. };
  853. Util.inherit = function Util_inherit(sub, base, prototype) {
  854. sub.prototype = Object.create(base.prototype);
  855. sub.prototype.constructor = sub;
  856. for (var prop in prototype) {
  857. sub.prototype[prop] = prototype[prop];
  858. }
  859. };
  860. Util.loadScript = function Util_loadScript(src, callback) {
  861. var script = document.createElement('script');
  862. var loaded = false;
  863. script.setAttribute('src', src);
  864. if (callback) {
  865. script.onload = function () {
  866. if (!loaded) {
  867. callback();
  868. }
  869. loaded = true;
  870. };
  871. }
  872. document.getElementsByTagName('head')[0].appendChild(script);
  873. };
  874. return Util;
  875. }();
  876. var PageViewport = function PageViewportClosure() {
  877. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  878. this.viewBox = viewBox;
  879. this.scale = scale;
  880. this.rotation = rotation;
  881. this.offsetX = offsetX;
  882. this.offsetY = offsetY;
  883. var centerX = (viewBox[2] + viewBox[0]) / 2;
  884. var centerY = (viewBox[3] + viewBox[1]) / 2;
  885. var rotateA, rotateB, rotateC, rotateD;
  886. rotation = rotation % 360;
  887. rotation = rotation < 0 ? rotation + 360 : rotation;
  888. switch (rotation) {
  889. case 180:
  890. rotateA = -1;
  891. rotateB = 0;
  892. rotateC = 0;
  893. rotateD = 1;
  894. break;
  895. case 90:
  896. rotateA = 0;
  897. rotateB = 1;
  898. rotateC = 1;
  899. rotateD = 0;
  900. break;
  901. case 270:
  902. rotateA = 0;
  903. rotateB = -1;
  904. rotateC = -1;
  905. rotateD = 0;
  906. break;
  907. default:
  908. rotateA = 1;
  909. rotateB = 0;
  910. rotateC = 0;
  911. rotateD = -1;
  912. break;
  913. }
  914. if (dontFlip) {
  915. rotateC = -rotateC;
  916. rotateD = -rotateD;
  917. }
  918. var offsetCanvasX, offsetCanvasY;
  919. var width, height;
  920. if (rotateA === 0) {
  921. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  922. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  923. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  924. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  925. } else {
  926. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  927. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  928. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  929. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  930. }
  931. this.transform = [
  932. rotateA * scale,
  933. rotateB * scale,
  934. rotateC * scale,
  935. rotateD * scale,
  936. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  937. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  938. ];
  939. this.width = width;
  940. this.height = height;
  941. this.fontScale = scale;
  942. }
  943. PageViewport.prototype = {
  944. clone: function PageViewPort_clone(args) {
  945. args = args || {};
  946. var scale = 'scale' in args ? args.scale : this.scale;
  947. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  948. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  949. },
  950. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  951. return Util.applyTransform([
  952. x,
  953. y
  954. ], this.transform);
  955. },
  956. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  957. var tl = Util.applyTransform([
  958. rect[0],
  959. rect[1]
  960. ], this.transform);
  961. var br = Util.applyTransform([
  962. rect[2],
  963. rect[3]
  964. ], this.transform);
  965. return [
  966. tl[0],
  967. tl[1],
  968. br[0],
  969. br[1]
  970. ];
  971. },
  972. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  973. return Util.applyInverseTransform([
  974. x,
  975. y
  976. ], this.transform);
  977. }
  978. };
  979. return PageViewport;
  980. }();
  981. var PDFStringTranslateTable = [
  982. 0,
  983. 0,
  984. 0,
  985. 0,
  986. 0,
  987. 0,
  988. 0,
  989. 0,
  990. 0,
  991. 0,
  992. 0,
  993. 0,
  994. 0,
  995. 0,
  996. 0,
  997. 0,
  998. 0,
  999. 0,
  1000. 0,
  1001. 0,
  1002. 0,
  1003. 0,
  1004. 0,
  1005. 0,
  1006. 0x2D8,
  1007. 0x2C7,
  1008. 0x2C6,
  1009. 0x2D9,
  1010. 0x2DD,
  1011. 0x2DB,
  1012. 0x2DA,
  1013. 0x2DC,
  1014. 0,
  1015. 0,
  1016. 0,
  1017. 0,
  1018. 0,
  1019. 0,
  1020. 0,
  1021. 0,
  1022. 0,
  1023. 0,
  1024. 0,
  1025. 0,
  1026. 0,
  1027. 0,
  1028. 0,
  1029. 0,
  1030. 0,
  1031. 0,
  1032. 0,
  1033. 0,
  1034. 0,
  1035. 0,
  1036. 0,
  1037. 0,
  1038. 0,
  1039. 0,
  1040. 0,
  1041. 0,
  1042. 0,
  1043. 0,
  1044. 0,
  1045. 0,
  1046. 0,
  1047. 0,
  1048. 0,
  1049. 0,
  1050. 0,
  1051. 0,
  1052. 0,
  1053. 0,
  1054. 0,
  1055. 0,
  1056. 0,
  1057. 0,
  1058. 0,
  1059. 0,
  1060. 0,
  1061. 0,
  1062. 0,
  1063. 0,
  1064. 0,
  1065. 0,
  1066. 0,
  1067. 0,
  1068. 0,
  1069. 0,
  1070. 0,
  1071. 0,
  1072. 0,
  1073. 0,
  1074. 0,
  1075. 0,
  1076. 0,
  1077. 0,
  1078. 0,
  1079. 0,
  1080. 0,
  1081. 0,
  1082. 0,
  1083. 0,
  1084. 0,
  1085. 0,
  1086. 0,
  1087. 0,
  1088. 0,
  1089. 0,
  1090. 0,
  1091. 0,
  1092. 0,
  1093. 0,
  1094. 0,
  1095. 0,
  1096. 0,
  1097. 0,
  1098. 0,
  1099. 0,
  1100. 0,
  1101. 0,
  1102. 0,
  1103. 0,
  1104. 0,
  1105. 0,
  1106. 0,
  1107. 0,
  1108. 0,
  1109. 0,
  1110. 0x2022,
  1111. 0x2020,
  1112. 0x2021,
  1113. 0x2026,
  1114. 0x2014,
  1115. 0x2013,
  1116. 0x192,
  1117. 0x2044,
  1118. 0x2039,
  1119. 0x203A,
  1120. 0x2212,
  1121. 0x2030,
  1122. 0x201E,
  1123. 0x201C,
  1124. 0x201D,
  1125. 0x2018,
  1126. 0x2019,
  1127. 0x201A,
  1128. 0x2122,
  1129. 0xFB01,
  1130. 0xFB02,
  1131. 0x141,
  1132. 0x152,
  1133. 0x160,
  1134. 0x178,
  1135. 0x17D,
  1136. 0x131,
  1137. 0x142,
  1138. 0x153,
  1139. 0x161,
  1140. 0x17E,
  1141. 0,
  1142. 0x20AC
  1143. ];
  1144. function stringToPDFString(str) {
  1145. var i, n = str.length, strBuf = [];
  1146. if (str[0] === '\xFE' && str[1] === '\xFF') {
  1147. for (i = 2; i < n; i += 2) {
  1148. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  1149. }
  1150. } else {
  1151. for (i = 0; i < n; ++i) {
  1152. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  1153. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  1154. }
  1155. }
  1156. return strBuf.join('');
  1157. }
  1158. function stringToUTF8String(str) {
  1159. return decodeURIComponent(escape(str));
  1160. }
  1161. function utf8StringToString(str) {
  1162. return unescape(encodeURIComponent(str));
  1163. }
  1164. function isEmptyObj(obj) {
  1165. for (var key in obj) {
  1166. return false;
  1167. }
  1168. return true;
  1169. }
  1170. function isBool(v) {
  1171. return typeof v === 'boolean';
  1172. }
  1173. function isInt(v) {
  1174. return typeof v === 'number' && (v | 0) === v;
  1175. }
  1176. function isNum(v) {
  1177. return typeof v === 'number';
  1178. }
  1179. function isString(v) {
  1180. return typeof v === 'string';
  1181. }
  1182. function isArray(v) {
  1183. return v instanceof Array;
  1184. }
  1185. function isArrayBuffer(v) {
  1186. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  1187. }
  1188. function isSpace(ch) {
  1189. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  1190. }
  1191. function isNodeJS() {
  1192. if (typeof __pdfjsdev_webpack__ === 'undefined') {
  1193. return typeof process === 'object' && process + '' === '[object process]';
  1194. }
  1195. return false;
  1196. }
  1197. function createPromiseCapability() {
  1198. var capability = {};
  1199. capability.promise = new Promise(function (resolve, reject) {
  1200. capability.resolve = resolve;
  1201. capability.reject = reject;
  1202. });
  1203. return capability;
  1204. }
  1205. var StatTimer = function StatTimerClosure() {
  1206. function rpad(str, pad, length) {
  1207. while (str.length < length) {
  1208. str += pad;
  1209. }
  1210. return str;
  1211. }
  1212. function StatTimer() {
  1213. this.started = Object.create(null);
  1214. this.times = [];
  1215. this.enabled = true;
  1216. }
  1217. StatTimer.prototype = {
  1218. time: function StatTimer_time(name) {
  1219. if (!this.enabled) {
  1220. return;
  1221. }
  1222. if (name in this.started) {
  1223. warn('Timer is already running for ' + name);
  1224. }
  1225. this.started[name] = Date.now();
  1226. },
  1227. timeEnd: function StatTimer_timeEnd(name) {
  1228. if (!this.enabled) {
  1229. return;
  1230. }
  1231. if (!(name in this.started)) {
  1232. warn('Timer has not been started for ' + name);
  1233. }
  1234. this.times.push({
  1235. 'name': name,
  1236. 'start': this.started[name],
  1237. 'end': Date.now()
  1238. });
  1239. delete this.started[name];
  1240. },
  1241. toString: function StatTimer_toString() {
  1242. var i, ii;
  1243. var times = this.times;
  1244. var out = '';
  1245. var longest = 0;
  1246. for (i = 0, ii = times.length; i < ii; ++i) {
  1247. var name = times[i]['name'];
  1248. if (name.length > longest) {
  1249. longest = name.length;
  1250. }
  1251. }
  1252. for (i = 0, ii = times.length; i < ii; ++i) {
  1253. var span = times[i];
  1254. var duration = span.end - span.start;
  1255. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  1256. }
  1257. return out;
  1258. }
  1259. };
  1260. return StatTimer;
  1261. }();
  1262. var createBlob = function createBlob(data, contentType) {
  1263. if (typeof Blob !== 'undefined') {
  1264. return new Blob([data], { type: contentType });
  1265. }
  1266. warn('The "Blob" constructor is not supported.');
  1267. };
  1268. var createObjectURL = function createObjectURLClosure() {
  1269. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1270. return function createObjectURL(data, contentType, forceDataSchema) {
  1271. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  1272. var blob = createBlob(data, contentType);
  1273. return URL.createObjectURL(blob);
  1274. }
  1275. var buffer = 'data:' + contentType + ';base64,';
  1276. for (var i = 0, ii = data.length; i < ii; i += 3) {
  1277. var b1 = data[i] & 0xFF;
  1278. var b2 = data[i + 1] & 0xFF;
  1279. var b3 = data[i + 2] & 0xFF;
  1280. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  1281. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  1282. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  1283. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1284. }
  1285. return buffer;
  1286. };
  1287. }();
  1288. function MessageHandler(sourceName, targetName, comObj) {
  1289. this.sourceName = sourceName;
  1290. this.targetName = targetName;
  1291. this.comObj = comObj;
  1292. this.callbackIndex = 1;
  1293. this.postMessageTransfers = true;
  1294. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1295. var ah = this.actionHandler = Object.create(null);
  1296. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  1297. var data = event.data;
  1298. if (data.targetName !== this.sourceName) {
  1299. return;
  1300. }
  1301. if (data.isReply) {
  1302. var callbackId = data.callbackId;
  1303. if (data.callbackId in callbacksCapabilities) {
  1304. var callback = callbacksCapabilities[callbackId];
  1305. delete callbacksCapabilities[callbackId];
  1306. if ('error' in data) {
  1307. callback.reject(data.error);
  1308. } else {
  1309. callback.resolve(data.data);
  1310. }
  1311. } else {
  1312. error('Cannot resolve callback ' + callbackId);
  1313. }
  1314. } else if (data.action in ah) {
  1315. var action = ah[data.action];
  1316. if (data.callbackId) {
  1317. var sourceName = this.sourceName;
  1318. var targetName = data.sourceName;
  1319. Promise.resolve().then(function () {
  1320. return action[0].call(action[1], data.data);
  1321. }).then(function (result) {
  1322. comObj.postMessage({
  1323. sourceName: sourceName,
  1324. targetName: targetName,
  1325. isReply: true,
  1326. callbackId: data.callbackId,
  1327. data: result
  1328. });
  1329. }, function (reason) {
  1330. if (reason instanceof Error) {
  1331. reason = reason + '';
  1332. }
  1333. comObj.postMessage({
  1334. sourceName: sourceName,
  1335. targetName: targetName,
  1336. isReply: true,
  1337. callbackId: data.callbackId,
  1338. error: reason
  1339. });
  1340. });
  1341. } else {
  1342. action[0].call(action[1], data.data);
  1343. }
  1344. } else {
  1345. error('Unknown action from worker: ' + data.action);
  1346. }
  1347. }.bind(this);
  1348. comObj.addEventListener('message', this._onComObjOnMessage);
  1349. }
  1350. MessageHandler.prototype = {
  1351. on: function messageHandlerOn(actionName, handler, scope) {
  1352. var ah = this.actionHandler;
  1353. if (ah[actionName]) {
  1354. error('There is already an actionName called "' + actionName + '"');
  1355. }
  1356. ah[actionName] = [
  1357. handler,
  1358. scope
  1359. ];
  1360. },
  1361. send: function messageHandlerSend(actionName, data, transfers) {
  1362. var message = {
  1363. sourceName: this.sourceName,
  1364. targetName: this.targetName,
  1365. action: actionName,
  1366. data: data
  1367. };
  1368. this.postMessage(message, transfers);
  1369. },
  1370. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  1371. var callbackId = this.callbackIndex++;
  1372. var message = {
  1373. sourceName: this.sourceName,
  1374. targetName: this.targetName,
  1375. action: actionName,
  1376. data: data,
  1377. callbackId: callbackId
  1378. };
  1379. var capability = createPromiseCapability();
  1380. this.callbacksCapabilities[callbackId] = capability;
  1381. try {
  1382. this.postMessage(message, transfers);
  1383. } catch (e) {
  1384. capability.reject(e);
  1385. }
  1386. return capability.promise;
  1387. },
  1388. postMessage: function (message, transfers) {
  1389. if (transfers && this.postMessageTransfers) {
  1390. this.comObj.postMessage(message, transfers);
  1391. } else {
  1392. this.comObj.postMessage(message);
  1393. }
  1394. },
  1395. destroy: function () {
  1396. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1397. }
  1398. };
  1399. function loadJpegStream(id, imageUrl, objs) {
  1400. var img = new Image();
  1401. img.onload = function loadJpegStream_onloadClosure() {
  1402. objs.resolve(id, img);
  1403. };
  1404. img.onerror = function loadJpegStream_onerrorClosure() {
  1405. objs.resolve(id, null);
  1406. warn('Error during JPEG image loading');
  1407. };
  1408. img.src = imageUrl;
  1409. }
  1410. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  1411. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  1412. exports.OPS = OPS;
  1413. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  1414. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  1415. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  1416. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  1417. exports.AnnotationFlag = AnnotationFlag;
  1418. exports.AnnotationType = AnnotationType;
  1419. exports.FontType = FontType;
  1420. exports.ImageKind = ImageKind;
  1421. exports.CMapCompressionType = CMapCompressionType;
  1422. exports.InvalidPDFException = InvalidPDFException;
  1423. exports.MessageHandler = MessageHandler;
  1424. exports.MissingDataException = MissingDataException;
  1425. exports.MissingPDFException = MissingPDFException;
  1426. exports.NotImplementedException = NotImplementedException;
  1427. exports.PageViewport = PageViewport;
  1428. exports.PasswordException = PasswordException;
  1429. exports.PasswordResponses = PasswordResponses;
  1430. exports.StatTimer = StatTimer;
  1431. exports.StreamType = StreamType;
  1432. exports.TextRenderingMode = TextRenderingMode;
  1433. exports.UnexpectedResponseException = UnexpectedResponseException;
  1434. exports.UnknownErrorException = UnknownErrorException;
  1435. exports.Util = Util;
  1436. exports.XRefParseException = XRefParseException;
  1437. exports.arrayByteLength = arrayByteLength;
  1438. exports.arraysToBytes = arraysToBytes;
  1439. exports.assert = assert;
  1440. exports.bytesToString = bytesToString;
  1441. exports.createBlob = createBlob;
  1442. exports.createPromiseCapability = createPromiseCapability;
  1443. exports.createObjectURL = createObjectURL;
  1444. exports.deprecated = deprecated;
  1445. exports.error = error;
  1446. exports.getLookupTableFactory = getLookupTableFactory;
  1447. exports.getVerbosityLevel = getVerbosityLevel;
  1448. exports.globalScope = globalScope;
  1449. exports.info = info;
  1450. exports.isArray = isArray;
  1451. exports.isArrayBuffer = isArrayBuffer;
  1452. exports.isBool = isBool;
  1453. exports.isEmptyObj = isEmptyObj;
  1454. exports.isInt = isInt;
  1455. exports.isNum = isNum;
  1456. exports.isString = isString;
  1457. exports.isSpace = isSpace;
  1458. exports.isNodeJS = isNodeJS;
  1459. exports.isSameOrigin = isSameOrigin;
  1460. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  1461. exports.isLittleEndian = isLittleEndian;
  1462. exports.isEvalSupported = isEvalSupported;
  1463. exports.loadJpegStream = loadJpegStream;
  1464. exports.log2 = log2;
  1465. exports.readInt8 = readInt8;
  1466. exports.readUint16 = readUint16;
  1467. exports.readUint32 = readUint32;
  1468. exports.removeNullCharacters = removeNullCharacters;
  1469. exports.setVerbosityLevel = setVerbosityLevel;
  1470. exports.shadow = shadow;
  1471. exports.string32 = string32;
  1472. exports.stringToBytes = stringToBytes;
  1473. exports.stringToPDFString = stringToPDFString;
  1474. exports.stringToUTF8String = stringToUTF8String;
  1475. exports.utf8StringToString = utf8StringToString;
  1476. exports.warn = warn;
  1477. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(9)))
  1478. /***/ }),
  1479. /* 1 */
  1480. /***/ (function(module, exports, __w_pdfjs_require__) {
  1481. "use strict";
  1482. var sharedUtil = __w_pdfjs_require__(0);
  1483. var isArray = sharedUtil.isArray;
  1484. var EOF = {};
  1485. var Name = function NameClosure() {
  1486. function Name(name) {
  1487. this.name = name;
  1488. }
  1489. Name.prototype = {};
  1490. var nameCache = Object.create(null);
  1491. Name.get = function Name_get(name) {
  1492. var nameValue = nameCache[name];
  1493. return nameValue ? nameValue : nameCache[name] = new Name(name);
  1494. };
  1495. return Name;
  1496. }();
  1497. var Cmd = function CmdClosure() {
  1498. function Cmd(cmd) {
  1499. this.cmd = cmd;
  1500. }
  1501. Cmd.prototype = {};
  1502. var cmdCache = Object.create(null);
  1503. Cmd.get = function Cmd_get(cmd) {
  1504. var cmdValue = cmdCache[cmd];
  1505. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  1506. };
  1507. return Cmd;
  1508. }();
  1509. var Dict = function DictClosure() {
  1510. var nonSerializable = function nonSerializableClosure() {
  1511. return nonSerializable;
  1512. };
  1513. function Dict(xref) {
  1514. this.map = Object.create(null);
  1515. this.xref = xref;
  1516. this.objId = null;
  1517. this.suppressEncryption = false;
  1518. this.__nonSerializable__ = nonSerializable;
  1519. }
  1520. Dict.prototype = {
  1521. assignXref: function Dict_assignXref(newXref) {
  1522. this.xref = newXref;
  1523. },
  1524. get: function Dict_get(key1, key2, key3) {
  1525. var value;
  1526. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1527. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  1528. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1529. }
  1530. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  1531. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1532. }
  1533. value = this.map[key3] || null;
  1534. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1535. },
  1536. getAsync: function Dict_getAsync(key1, key2, key3) {
  1537. var value;
  1538. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1539. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  1540. if (xref) {
  1541. return xref.fetchIfRefAsync(value, suppressEncryption);
  1542. }
  1543. return Promise.resolve(value);
  1544. }
  1545. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  1546. if (xref) {
  1547. return xref.fetchIfRefAsync(value, suppressEncryption);
  1548. }
  1549. return Promise.resolve(value);
  1550. }
  1551. value = this.map[key3] || null;
  1552. if (xref) {
  1553. return xref.fetchIfRefAsync(value, suppressEncryption);
  1554. }
  1555. return Promise.resolve(value);
  1556. },
  1557. getArray: function Dict_getArray(key1, key2, key3) {
  1558. var value = this.get(key1, key2, key3);
  1559. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1560. if (!isArray(value) || !xref) {
  1561. return value;
  1562. }
  1563. value = value.slice();
  1564. for (var i = 0, ii = value.length; i < ii; i++) {
  1565. if (!isRef(value[i])) {
  1566. continue;
  1567. }
  1568. value[i] = xref.fetch(value[i], suppressEncryption);
  1569. }
  1570. return value;
  1571. },
  1572. getRaw: function Dict_getRaw(key) {
  1573. return this.map[key];
  1574. },
  1575. getKeys: function Dict_getKeys() {
  1576. return Object.keys(this.map);
  1577. },
  1578. set: function Dict_set(key, value) {
  1579. this.map[key] = value;
  1580. },
  1581. has: function Dict_has(key) {
  1582. return key in this.map;
  1583. },
  1584. forEach: function Dict_forEach(callback) {
  1585. for (var key in this.map) {
  1586. callback(key, this.get(key));
  1587. }
  1588. }
  1589. };
  1590. Dict.empty = new Dict(null);
  1591. Dict.merge = function Dict_merge(xref, dictArray) {
  1592. var mergedDict = new Dict(xref);
  1593. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  1594. var dict = dictArray[i];
  1595. if (!isDict(dict)) {
  1596. continue;
  1597. }
  1598. for (var keyName in dict.map) {
  1599. if (mergedDict.map[keyName]) {
  1600. continue;
  1601. }
  1602. mergedDict.map[keyName] = dict.map[keyName];
  1603. }
  1604. }
  1605. return mergedDict;
  1606. };
  1607. return Dict;
  1608. }();
  1609. var Ref = function RefClosure() {
  1610. function Ref(num, gen) {
  1611. this.num = num;
  1612. this.gen = gen;
  1613. }
  1614. Ref.prototype = {
  1615. toString: function Ref_toString() {
  1616. var str = this.num + 'R';
  1617. if (this.gen !== 0) {
  1618. str += this.gen;
  1619. }
  1620. return str;
  1621. }
  1622. };
  1623. return Ref;
  1624. }();
  1625. var RefSet = function RefSetClosure() {
  1626. function RefSet() {
  1627. this.dict = Object.create(null);
  1628. }
  1629. RefSet.prototype = {
  1630. has: function RefSet_has(ref) {
  1631. return ref.toString() in this.dict;
  1632. },
  1633. put: function RefSet_put(ref) {
  1634. this.dict[ref.toString()] = true;
  1635. },
  1636. remove: function RefSet_remove(ref) {
  1637. delete this.dict[ref.toString()];
  1638. }
  1639. };
  1640. return RefSet;
  1641. }();
  1642. var RefSetCache = function RefSetCacheClosure() {
  1643. function RefSetCache() {
  1644. this.dict = Object.create(null);
  1645. }
  1646. RefSetCache.prototype = {
  1647. get: function RefSetCache_get(ref) {
  1648. return this.dict[ref.toString()];
  1649. },
  1650. has: function RefSetCache_has(ref) {
  1651. return ref.toString() in this.dict;
  1652. },
  1653. put: function RefSetCache_put(ref, obj) {
  1654. this.dict[ref.toString()] = obj;
  1655. },
  1656. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  1657. this.dict[ref.toString()] = this.get(aliasRef);
  1658. },
  1659. forEach: function RefSetCache_forEach(fn, thisArg) {
  1660. for (var i in this.dict) {
  1661. fn.call(thisArg, this.dict[i]);
  1662. }
  1663. },
  1664. clear: function RefSetCache_clear() {
  1665. this.dict = Object.create(null);
  1666. }
  1667. };
  1668. return RefSetCache;
  1669. }();
  1670. function isEOF(v) {
  1671. return v === EOF;
  1672. }
  1673. function isName(v, name) {
  1674. return v instanceof Name && (name === undefined || v.name === name);
  1675. }
  1676. function isCmd(v, cmd) {
  1677. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  1678. }
  1679. function isDict(v, type) {
  1680. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  1681. }
  1682. function isRef(v) {
  1683. return v instanceof Ref;
  1684. }
  1685. function isRefsEqual(v1, v2) {
  1686. return v1.num === v2.num && v1.gen === v2.gen;
  1687. }
  1688. function isStream(v) {
  1689. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  1690. }
  1691. exports.EOF = EOF;
  1692. exports.Cmd = Cmd;
  1693. exports.Dict = Dict;
  1694. exports.Name = Name;
  1695. exports.Ref = Ref;
  1696. exports.RefSet = RefSet;
  1697. exports.RefSetCache = RefSetCache;
  1698. exports.isEOF = isEOF;
  1699. exports.isCmd = isCmd;
  1700. exports.isDict = isDict;
  1701. exports.isName = isName;
  1702. exports.isRef = isRef;
  1703. exports.isRefsEqual = isRefsEqual;
  1704. exports.isStream = isStream;
  1705. /***/ }),
  1706. /* 2 */
  1707. /***/ (function(module, exports, __w_pdfjs_require__) {
  1708. "use strict";
  1709. var sharedUtil = __w_pdfjs_require__(0);
  1710. var corePrimitives = __w_pdfjs_require__(1);
  1711. var coreJbig2 = __w_pdfjs_require__(28);
  1712. var coreJpg = __w_pdfjs_require__(29);
  1713. var coreJpx = __w_pdfjs_require__(15);
  1714. var Util = sharedUtil.Util;
  1715. var error = sharedUtil.error;
  1716. var info = sharedUtil.info;
  1717. var isInt = sharedUtil.isInt;
  1718. var isArray = sharedUtil.isArray;
  1719. var createObjectURL = sharedUtil.createObjectURL;
  1720. var shadow = sharedUtil.shadow;
  1721. var isSpace = sharedUtil.isSpace;
  1722. var Dict = corePrimitives.Dict;
  1723. var isDict = corePrimitives.isDict;
  1724. var isStream = corePrimitives.isStream;
  1725. var Jbig2Image = coreJbig2.Jbig2Image;
  1726. var JpegImage = coreJpg.JpegImage;
  1727. var JpxImage = coreJpx.JpxImage;
  1728. var Stream = function StreamClosure() {
  1729. function Stream(arrayBuffer, start, length, dict) {
  1730. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  1731. this.start = start || 0;
  1732. this.pos = this.start;
  1733. this.end = start + length || this.bytes.length;
  1734. this.dict = dict;
  1735. }
  1736. Stream.prototype = {
  1737. get length() {
  1738. return this.end - this.start;
  1739. },
  1740. get isEmpty() {
  1741. return this.length === 0;
  1742. },
  1743. getByte: function Stream_getByte() {
  1744. if (this.pos >= this.end) {
  1745. return -1;
  1746. }
  1747. return this.bytes[this.pos++];
  1748. },
  1749. getUint16: function Stream_getUint16() {
  1750. var b0 = this.getByte();
  1751. var b1 = this.getByte();
  1752. if (b0 === -1 || b1 === -1) {
  1753. return -1;
  1754. }
  1755. return (b0 << 8) + b1;
  1756. },
  1757. getInt32: function Stream_getInt32() {
  1758. var b0 = this.getByte();
  1759. var b1 = this.getByte();
  1760. var b2 = this.getByte();
  1761. var b3 = this.getByte();
  1762. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1763. },
  1764. getBytes: function Stream_getBytes(length) {
  1765. var bytes = this.bytes;
  1766. var pos = this.pos;
  1767. var strEnd = this.end;
  1768. if (!length) {
  1769. return bytes.subarray(pos, strEnd);
  1770. }
  1771. var end = pos + length;
  1772. if (end > strEnd) {
  1773. end = strEnd;
  1774. }
  1775. this.pos = end;
  1776. return bytes.subarray(pos, end);
  1777. },
  1778. peekByte: function Stream_peekByte() {
  1779. var peekedByte = this.getByte();
  1780. this.pos--;
  1781. return peekedByte;
  1782. },
  1783. peekBytes: function Stream_peekBytes(length) {
  1784. var bytes = this.getBytes(length);
  1785. this.pos -= bytes.length;
  1786. return bytes;
  1787. },
  1788. skip: function Stream_skip(n) {
  1789. if (!n) {
  1790. n = 1;
  1791. }
  1792. this.pos += n;
  1793. },
  1794. reset: function Stream_reset() {
  1795. this.pos = this.start;
  1796. },
  1797. moveStart: function Stream_moveStart() {
  1798. this.start = this.pos;
  1799. },
  1800. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  1801. return new Stream(this.bytes.buffer, start, length, dict);
  1802. }
  1803. };
  1804. return Stream;
  1805. }();
  1806. var StringStream = function StringStreamClosure() {
  1807. function StringStream(str) {
  1808. var length = str.length;
  1809. var bytes = new Uint8Array(length);
  1810. for (var n = 0; n < length; ++n) {
  1811. bytes[n] = str.charCodeAt(n);
  1812. }
  1813. Stream.call(this, bytes);
  1814. }
  1815. StringStream.prototype = Stream.prototype;
  1816. return StringStream;
  1817. }();
  1818. var DecodeStream = function DecodeStreamClosure() {
  1819. var emptyBuffer = new Uint8Array(0);
  1820. function DecodeStream(maybeMinBufferLength) {
  1821. this.pos = 0;
  1822. this.bufferLength = 0;
  1823. this.eof = false;
  1824. this.buffer = emptyBuffer;
  1825. this.minBufferLength = 512;
  1826. if (maybeMinBufferLength) {
  1827. while (this.minBufferLength < maybeMinBufferLength) {
  1828. this.minBufferLength *= 2;
  1829. }
  1830. }
  1831. }
  1832. DecodeStream.prototype = {
  1833. get isEmpty() {
  1834. while (!this.eof && this.bufferLength === 0) {
  1835. this.readBlock();
  1836. }
  1837. return this.bufferLength === 0;
  1838. },
  1839. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  1840. var buffer = this.buffer;
  1841. if (requested <= buffer.byteLength) {
  1842. return buffer;
  1843. }
  1844. var size = this.minBufferLength;
  1845. while (size < requested) {
  1846. size *= 2;
  1847. }
  1848. var buffer2 = new Uint8Array(size);
  1849. buffer2.set(buffer);
  1850. return this.buffer = buffer2;
  1851. },
  1852. getByte: function DecodeStream_getByte() {
  1853. var pos = this.pos;
  1854. while (this.bufferLength <= pos) {
  1855. if (this.eof) {
  1856. return -1;
  1857. }
  1858. this.readBlock();
  1859. }
  1860. return this.buffer[this.pos++];
  1861. },
  1862. getUint16: function DecodeStream_getUint16() {
  1863. var b0 = this.getByte();
  1864. var b1 = this.getByte();
  1865. if (b0 === -1 || b1 === -1) {
  1866. return -1;
  1867. }
  1868. return (b0 << 8) + b1;
  1869. },
  1870. getInt32: function DecodeStream_getInt32() {
  1871. var b0 = this.getByte();
  1872. var b1 = this.getByte();
  1873. var b2 = this.getByte();
  1874. var b3 = this.getByte();
  1875. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1876. },
  1877. getBytes: function DecodeStream_getBytes(length) {
  1878. var end, pos = this.pos;
  1879. if (length) {
  1880. this.ensureBuffer(pos + length);
  1881. end = pos + length;
  1882. while (!this.eof && this.bufferLength < end) {
  1883. this.readBlock();
  1884. }
  1885. var bufEnd = this.bufferLength;
  1886. if (end > bufEnd) {
  1887. end = bufEnd;
  1888. }
  1889. } else {
  1890. while (!this.eof) {
  1891. this.readBlock();
  1892. }
  1893. end = this.bufferLength;
  1894. }
  1895. this.pos = end;
  1896. return this.buffer.subarray(pos, end);
  1897. },
  1898. peekByte: function DecodeStream_peekByte() {
  1899. var peekedByte = this.getByte();
  1900. this.pos--;
  1901. return peekedByte;
  1902. },
  1903. peekBytes: function DecodeStream_peekBytes(length) {
  1904. var bytes = this.getBytes(length);
  1905. this.pos -= bytes.length;
  1906. return bytes;
  1907. },
  1908. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  1909. var end = start + length;
  1910. while (this.bufferLength <= end && !this.eof) {
  1911. this.readBlock();
  1912. }
  1913. return new Stream(this.buffer, start, length, dict);
  1914. },
  1915. skip: function DecodeStream_skip(n) {
  1916. if (!n) {
  1917. n = 1;
  1918. }
  1919. this.pos += n;
  1920. },
  1921. reset: function DecodeStream_reset() {
  1922. this.pos = 0;
  1923. },
  1924. getBaseStreams: function DecodeStream_getBaseStreams() {
  1925. if (this.str && this.str.getBaseStreams) {
  1926. return this.str.getBaseStreams();
  1927. }
  1928. return [];
  1929. }
  1930. };
  1931. return DecodeStream;
  1932. }();
  1933. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  1934. function StreamsSequenceStream(streams) {
  1935. this.streams = streams;
  1936. DecodeStream.call(this, null);
  1937. }
  1938. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  1939. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  1940. var streams = this.streams;
  1941. if (streams.length === 0) {
  1942. this.eof = true;
  1943. return;
  1944. }
  1945. var stream = streams.shift();
  1946. var chunk = stream.getBytes();
  1947. var bufferLength = this.bufferLength;
  1948. var newLength = bufferLength + chunk.length;
  1949. var buffer = this.ensureBuffer(newLength);
  1950. buffer.set(chunk, bufferLength);
  1951. this.bufferLength = newLength;
  1952. };
  1953. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  1954. var baseStreams = [];
  1955. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  1956. var stream = this.streams[i];
  1957. if (stream.getBaseStreams) {
  1958. Util.appendToArray(baseStreams, stream.getBaseStreams());
  1959. }
  1960. }
  1961. return baseStreams;
  1962. };
  1963. return StreamsSequenceStream;
  1964. }();
  1965. var FlateStream = function FlateStreamClosure() {
  1966. var codeLenCodeMap = new Int32Array([
  1967. 16,
  1968. 17,
  1969. 18,
  1970. 0,
  1971. 8,
  1972. 7,
  1973. 9,
  1974. 6,
  1975. 10,
  1976. 5,
  1977. 11,
  1978. 4,
  1979. 12,
  1980. 3,
  1981. 13,
  1982. 2,
  1983. 14,
  1984. 1,
  1985. 15
  1986. ]);
  1987. var lengthDecode = new Int32Array([
  1988. 0x00003,
  1989. 0x00004,
  1990. 0x00005,
  1991. 0x00006,
  1992. 0x00007,
  1993. 0x00008,
  1994. 0x00009,
  1995. 0x0000a,
  1996. 0x1000b,
  1997. 0x1000d,
  1998. 0x1000f,
  1999. 0x10011,
  2000. 0x20013,
  2001. 0x20017,
  2002. 0x2001b,
  2003. 0x2001f,
  2004. 0x30023,
  2005. 0x3002b,
  2006. 0x30033,
  2007. 0x3003b,
  2008. 0x40043,
  2009. 0x40053,
  2010. 0x40063,
  2011. 0x40073,
  2012. 0x50083,
  2013. 0x500a3,
  2014. 0x500c3,
  2015. 0x500e3,
  2016. 0x00102,
  2017. 0x00102,
  2018. 0x00102
  2019. ]);
  2020. var distDecode = new Int32Array([
  2021. 0x00001,
  2022. 0x00002,
  2023. 0x00003,
  2024. 0x00004,
  2025. 0x10005,
  2026. 0x10007,
  2027. 0x20009,
  2028. 0x2000d,
  2029. 0x30011,
  2030. 0x30019,
  2031. 0x40021,
  2032. 0x40031,
  2033. 0x50041,
  2034. 0x50061,
  2035. 0x60081,
  2036. 0x600c1,
  2037. 0x70101,
  2038. 0x70181,
  2039. 0x80201,
  2040. 0x80301,
  2041. 0x90401,
  2042. 0x90601,
  2043. 0xa0801,
  2044. 0xa0c01,
  2045. 0xb1001,
  2046. 0xb1801,
  2047. 0xc2001,
  2048. 0xc3001,
  2049. 0xd4001,
  2050. 0xd6001
  2051. ]);
  2052. var fixedLitCodeTab = [
  2053. new Int32Array([
  2054. 0x70100,
  2055. 0x80050,
  2056. 0x80010,
  2057. 0x80118,
  2058. 0x70110,
  2059. 0x80070,
  2060. 0x80030,
  2061. 0x900c0,
  2062. 0x70108,
  2063. 0x80060,
  2064. 0x80020,
  2065. 0x900a0,
  2066. 0x80000,
  2067. 0x80080,
  2068. 0x80040,
  2069. 0x900e0,
  2070. 0x70104,
  2071. 0x80058,
  2072. 0x80018,
  2073. 0x90090,
  2074. 0x70114,
  2075. 0x80078,
  2076. 0x80038,
  2077. 0x900d0,
  2078. 0x7010c,
  2079. 0x80068,
  2080. 0x80028,
  2081. 0x900b0,
  2082. 0x80008,
  2083. 0x80088,
  2084. 0x80048,
  2085. 0x900f0,
  2086. 0x70102,
  2087. 0x80054,
  2088. 0x80014,
  2089. 0x8011c,
  2090. 0x70112,
  2091. 0x80074,
  2092. 0x80034,
  2093. 0x900c8,
  2094. 0x7010a,
  2095. 0x80064,
  2096. 0x80024,
  2097. 0x900a8,
  2098. 0x80004,
  2099. 0x80084,
  2100. 0x80044,
  2101. 0x900e8,
  2102. 0x70106,
  2103. 0x8005c,
  2104. 0x8001c,
  2105. 0x90098,
  2106. 0x70116,
  2107. 0x8007c,
  2108. 0x8003c,
  2109. 0x900d8,
  2110. 0x7010e,
  2111. 0x8006c,
  2112. 0x8002c,
  2113. 0x900b8,
  2114. 0x8000c,
  2115. 0x8008c,
  2116. 0x8004c,
  2117. 0x900f8,
  2118. 0x70101,
  2119. 0x80052,
  2120. 0x80012,
  2121. 0x8011a,
  2122. 0x70111,
  2123. 0x80072,
  2124. 0x80032,
  2125. 0x900c4,
  2126. 0x70109,
  2127. 0x80062,
  2128. 0x80022,
  2129. 0x900a4,
  2130. 0x80002,
  2131. 0x80082,
  2132. 0x80042,
  2133. 0x900e4,
  2134. 0x70105,
  2135. 0x8005a,
  2136. 0x8001a,
  2137. 0x90094,
  2138. 0x70115,
  2139. 0x8007a,
  2140. 0x8003a,
  2141. 0x900d4,
  2142. 0x7010d,
  2143. 0x8006a,
  2144. 0x8002a,
  2145. 0x900b4,
  2146. 0x8000a,
  2147. 0x8008a,
  2148. 0x8004a,
  2149. 0x900f4,
  2150. 0x70103,
  2151. 0x80056,
  2152. 0x80016,
  2153. 0x8011e,
  2154. 0x70113,
  2155. 0x80076,
  2156. 0x80036,
  2157. 0x900cc,
  2158. 0x7010b,
  2159. 0x80066,
  2160. 0x80026,
  2161. 0x900ac,
  2162. 0x80006,
  2163. 0x80086,
  2164. 0x80046,
  2165. 0x900ec,
  2166. 0x70107,
  2167. 0x8005e,
  2168. 0x8001e,
  2169. 0x9009c,
  2170. 0x70117,
  2171. 0x8007e,
  2172. 0x8003e,
  2173. 0x900dc,
  2174. 0x7010f,
  2175. 0x8006e,
  2176. 0x8002e,
  2177. 0x900bc,
  2178. 0x8000e,
  2179. 0x8008e,
  2180. 0x8004e,
  2181. 0x900fc,
  2182. 0x70100,
  2183. 0x80051,
  2184. 0x80011,
  2185. 0x80119,
  2186. 0x70110,
  2187. 0x80071,
  2188. 0x80031,
  2189. 0x900c2,
  2190. 0x70108,
  2191. 0x80061,
  2192. 0x80021,
  2193. 0x900a2,
  2194. 0x80001,
  2195. 0x80081,
  2196. 0x80041,
  2197. 0x900e2,
  2198. 0x70104,
  2199. 0x80059,
  2200. 0x80019,
  2201. 0x90092,
  2202. 0x70114,
  2203. 0x80079,
  2204. 0x80039,
  2205. 0x900d2,
  2206. 0x7010c,
  2207. 0x80069,
  2208. 0x80029,
  2209. 0x900b2,
  2210. 0x80009,
  2211. 0x80089,
  2212. 0x80049,
  2213. 0x900f2,
  2214. 0x70102,
  2215. 0x80055,
  2216. 0x80015,
  2217. 0x8011d,
  2218. 0x70112,
  2219. 0x80075,
  2220. 0x80035,
  2221. 0x900ca,
  2222. 0x7010a,
  2223. 0x80065,
  2224. 0x80025,
  2225. 0x900aa,
  2226. 0x80005,
  2227. 0x80085,
  2228. 0x80045,
  2229. 0x900ea,
  2230. 0x70106,
  2231. 0x8005d,
  2232. 0x8001d,
  2233. 0x9009a,
  2234. 0x70116,
  2235. 0x8007d,
  2236. 0x8003d,
  2237. 0x900da,
  2238. 0x7010e,
  2239. 0x8006d,
  2240. 0x8002d,
  2241. 0x900ba,
  2242. 0x8000d,
  2243. 0x8008d,
  2244. 0x8004d,
  2245. 0x900fa,
  2246. 0x70101,
  2247. 0x80053,
  2248. 0x80013,
  2249. 0x8011b,
  2250. 0x70111,
  2251. 0x80073,
  2252. 0x80033,
  2253. 0x900c6,
  2254. 0x70109,
  2255. 0x80063,
  2256. 0x80023,
  2257. 0x900a6,
  2258. 0x80003,
  2259. 0x80083,
  2260. 0x80043,
  2261. 0x900e6,
  2262. 0x70105,
  2263. 0x8005b,
  2264. 0x8001b,
  2265. 0x90096,
  2266. 0x70115,
  2267. 0x8007b,
  2268. 0x8003b,
  2269. 0x900d6,
  2270. 0x7010d,
  2271. 0x8006b,
  2272. 0x8002b,
  2273. 0x900b6,
  2274. 0x8000b,
  2275. 0x8008b,
  2276. 0x8004b,
  2277. 0x900f6,
  2278. 0x70103,
  2279. 0x80057,
  2280. 0x80017,
  2281. 0x8011f,
  2282. 0x70113,
  2283. 0x80077,
  2284. 0x80037,
  2285. 0x900ce,
  2286. 0x7010b,
  2287. 0x80067,
  2288. 0x80027,
  2289. 0x900ae,
  2290. 0x80007,
  2291. 0x80087,
  2292. 0x80047,
  2293. 0x900ee,
  2294. 0x70107,
  2295. 0x8005f,
  2296. 0x8001f,
  2297. 0x9009e,
  2298. 0x70117,
  2299. 0x8007f,
  2300. 0x8003f,
  2301. 0x900de,
  2302. 0x7010f,
  2303. 0x8006f,
  2304. 0x8002f,
  2305. 0x900be,
  2306. 0x8000f,
  2307. 0x8008f,
  2308. 0x8004f,
  2309. 0x900fe,
  2310. 0x70100,
  2311. 0x80050,
  2312. 0x80010,
  2313. 0x80118,
  2314. 0x70110,
  2315. 0x80070,
  2316. 0x80030,
  2317. 0x900c1,
  2318. 0x70108,
  2319. 0x80060,
  2320. 0x80020,
  2321. 0x900a1,
  2322. 0x80000,
  2323. 0x80080,
  2324. 0x80040,
  2325. 0x900e1,
  2326. 0x70104,
  2327. 0x80058,
  2328. 0x80018,
  2329. 0x90091,
  2330. 0x70114,
  2331. 0x80078,
  2332. 0x80038,
  2333. 0x900d1,
  2334. 0x7010c,
  2335. 0x80068,
  2336. 0x80028,
  2337. 0x900b1,
  2338. 0x80008,
  2339. 0x80088,
  2340. 0x80048,
  2341. 0x900f1,
  2342. 0x70102,
  2343. 0x80054,
  2344. 0x80014,
  2345. 0x8011c,
  2346. 0x70112,
  2347. 0x80074,
  2348. 0x80034,
  2349. 0x900c9,
  2350. 0x7010a,
  2351. 0x80064,
  2352. 0x80024,
  2353. 0x900a9,
  2354. 0x80004,
  2355. 0x80084,
  2356. 0x80044,
  2357. 0x900e9,
  2358. 0x70106,
  2359. 0x8005c,
  2360. 0x8001c,
  2361. 0x90099,
  2362. 0x70116,
  2363. 0x8007c,
  2364. 0x8003c,
  2365. 0x900d9,
  2366. 0x7010e,
  2367. 0x8006c,
  2368. 0x8002c,
  2369. 0x900b9,
  2370. 0x8000c,
  2371. 0x8008c,
  2372. 0x8004c,
  2373. 0x900f9,
  2374. 0x70101,
  2375. 0x80052,
  2376. 0x80012,
  2377. 0x8011a,
  2378. 0x70111,
  2379. 0x80072,
  2380. 0x80032,
  2381. 0x900c5,
  2382. 0x70109,
  2383. 0x80062,
  2384. 0x80022,
  2385. 0x900a5,
  2386. 0x80002,
  2387. 0x80082,
  2388. 0x80042,
  2389. 0x900e5,
  2390. 0x70105,
  2391. 0x8005a,
  2392. 0x8001a,
  2393. 0x90095,
  2394. 0x70115,
  2395. 0x8007a,
  2396. 0x8003a,
  2397. 0x900d5,
  2398. 0x7010d,
  2399. 0x8006a,
  2400. 0x8002a,
  2401. 0x900b5,
  2402. 0x8000a,
  2403. 0x8008a,
  2404. 0x8004a,
  2405. 0x900f5,
  2406. 0x70103,
  2407. 0x80056,
  2408. 0x80016,
  2409. 0x8011e,
  2410. 0x70113,
  2411. 0x80076,
  2412. 0x80036,
  2413. 0x900cd,
  2414. 0x7010b,
  2415. 0x80066,
  2416. 0x80026,
  2417. 0x900ad,
  2418. 0x80006,
  2419. 0x80086,
  2420. 0x80046,
  2421. 0x900ed,
  2422. 0x70107,
  2423. 0x8005e,
  2424. 0x8001e,
  2425. 0x9009d,
  2426. 0x70117,
  2427. 0x8007e,
  2428. 0x8003e,
  2429. 0x900dd,
  2430. 0x7010f,
  2431. 0x8006e,
  2432. 0x8002e,
  2433. 0x900bd,
  2434. 0x8000e,
  2435. 0x8008e,
  2436. 0x8004e,
  2437. 0x900fd,
  2438. 0x70100,
  2439. 0x80051,
  2440. 0x80011,
  2441. 0x80119,
  2442. 0x70110,
  2443. 0x80071,
  2444. 0x80031,
  2445. 0x900c3,
  2446. 0x70108,
  2447. 0x80061,
  2448. 0x80021,
  2449. 0x900a3,
  2450. 0x80001,
  2451. 0x80081,
  2452. 0x80041,
  2453. 0x900e3,
  2454. 0x70104,
  2455. 0x80059,
  2456. 0x80019,
  2457. 0x90093,
  2458. 0x70114,
  2459. 0x80079,
  2460. 0x80039,
  2461. 0x900d3,
  2462. 0x7010c,
  2463. 0x80069,
  2464. 0x80029,
  2465. 0x900b3,
  2466. 0x80009,
  2467. 0x80089,
  2468. 0x80049,
  2469. 0x900f3,
  2470. 0x70102,
  2471. 0x80055,
  2472. 0x80015,
  2473. 0x8011d,
  2474. 0x70112,
  2475. 0x80075,
  2476. 0x80035,
  2477. 0x900cb,
  2478. 0x7010a,
  2479. 0x80065,
  2480. 0x80025,
  2481. 0x900ab,
  2482. 0x80005,
  2483. 0x80085,
  2484. 0x80045,
  2485. 0x900eb,
  2486. 0x70106,
  2487. 0x8005d,
  2488. 0x8001d,
  2489. 0x9009b,
  2490. 0x70116,
  2491. 0x8007d,
  2492. 0x8003d,
  2493. 0x900db,
  2494. 0x7010e,
  2495. 0x8006d,
  2496. 0x8002d,
  2497. 0x900bb,
  2498. 0x8000d,
  2499. 0x8008d,
  2500. 0x8004d,
  2501. 0x900fb,
  2502. 0x70101,
  2503. 0x80053,
  2504. 0x80013,
  2505. 0x8011b,
  2506. 0x70111,
  2507. 0x80073,
  2508. 0x80033,
  2509. 0x900c7,
  2510. 0x70109,
  2511. 0x80063,
  2512. 0x80023,
  2513. 0x900a7,
  2514. 0x80003,
  2515. 0x80083,
  2516. 0x80043,
  2517. 0x900e7,
  2518. 0x70105,
  2519. 0x8005b,
  2520. 0x8001b,
  2521. 0x90097,
  2522. 0x70115,
  2523. 0x8007b,
  2524. 0x8003b,
  2525. 0x900d7,
  2526. 0x7010d,
  2527. 0x8006b,
  2528. 0x8002b,
  2529. 0x900b7,
  2530. 0x8000b,
  2531. 0x8008b,
  2532. 0x8004b,
  2533. 0x900f7,
  2534. 0x70103,
  2535. 0x80057,
  2536. 0x80017,
  2537. 0x8011f,
  2538. 0x70113,
  2539. 0x80077,
  2540. 0x80037,
  2541. 0x900cf,
  2542. 0x7010b,
  2543. 0x80067,
  2544. 0x80027,
  2545. 0x900af,
  2546. 0x80007,
  2547. 0x80087,
  2548. 0x80047,
  2549. 0x900ef,
  2550. 0x70107,
  2551. 0x8005f,
  2552. 0x8001f,
  2553. 0x9009f,
  2554. 0x70117,
  2555. 0x8007f,
  2556. 0x8003f,
  2557. 0x900df,
  2558. 0x7010f,
  2559. 0x8006f,
  2560. 0x8002f,
  2561. 0x900bf,
  2562. 0x8000f,
  2563. 0x8008f,
  2564. 0x8004f,
  2565. 0x900ff
  2566. ]),
  2567. 9
  2568. ];
  2569. var fixedDistCodeTab = [
  2570. new Int32Array([
  2571. 0x50000,
  2572. 0x50010,
  2573. 0x50008,
  2574. 0x50018,
  2575. 0x50004,
  2576. 0x50014,
  2577. 0x5000c,
  2578. 0x5001c,
  2579. 0x50002,
  2580. 0x50012,
  2581. 0x5000a,
  2582. 0x5001a,
  2583. 0x50006,
  2584. 0x50016,
  2585. 0x5000e,
  2586. 0x00000,
  2587. 0x50001,
  2588. 0x50011,
  2589. 0x50009,
  2590. 0x50019,
  2591. 0x50005,
  2592. 0x50015,
  2593. 0x5000d,
  2594. 0x5001d,
  2595. 0x50003,
  2596. 0x50013,
  2597. 0x5000b,
  2598. 0x5001b,
  2599. 0x50007,
  2600. 0x50017,
  2601. 0x5000f,
  2602. 0x00000
  2603. ]),
  2604. 5
  2605. ];
  2606. function FlateStream(str, maybeLength) {
  2607. this.str = str;
  2608. this.dict = str.dict;
  2609. var cmf = str.getByte();
  2610. var flg = str.getByte();
  2611. if (cmf === -1 || flg === -1) {
  2612. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  2613. }
  2614. if ((cmf & 0x0f) !== 0x08) {
  2615. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  2616. }
  2617. if (((cmf << 8) + flg) % 31 !== 0) {
  2618. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  2619. }
  2620. if (flg & 0x20) {
  2621. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  2622. }
  2623. this.codeSize = 0;
  2624. this.codeBuf = 0;
  2625. DecodeStream.call(this, maybeLength);
  2626. }
  2627. FlateStream.prototype = Object.create(DecodeStream.prototype);
  2628. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  2629. var str = this.str;
  2630. var codeSize = this.codeSize;
  2631. var codeBuf = this.codeBuf;
  2632. var b;
  2633. while (codeSize < bits) {
  2634. if ((b = str.getByte()) === -1) {
  2635. error('Bad encoding in flate stream');
  2636. }
  2637. codeBuf |= b << codeSize;
  2638. codeSize += 8;
  2639. }
  2640. b = codeBuf & (1 << bits) - 1;
  2641. this.codeBuf = codeBuf >> bits;
  2642. this.codeSize = codeSize -= bits;
  2643. return b;
  2644. };
  2645. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  2646. var str = this.str;
  2647. var codes = table[0];
  2648. var maxLen = table[1];
  2649. var codeSize = this.codeSize;
  2650. var codeBuf = this.codeBuf;
  2651. var b;
  2652. while (codeSize < maxLen) {
  2653. if ((b = str.getByte()) === -1) {
  2654. break;
  2655. }
  2656. codeBuf |= b << codeSize;
  2657. codeSize += 8;
  2658. }
  2659. var code = codes[codeBuf & (1 << maxLen) - 1];
  2660. var codeLen = code >> 16;
  2661. var codeVal = code & 0xffff;
  2662. if (codeLen < 1 || codeSize < codeLen) {
  2663. error('Bad encoding in flate stream');
  2664. }
  2665. this.codeBuf = codeBuf >> codeLen;
  2666. this.codeSize = codeSize - codeLen;
  2667. return codeVal;
  2668. };
  2669. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  2670. var n = lengths.length;
  2671. var maxLen = 0;
  2672. var i;
  2673. for (i = 0; i < n; ++i) {
  2674. if (lengths[i] > maxLen) {
  2675. maxLen = lengths[i];
  2676. }
  2677. }
  2678. var size = 1 << maxLen;
  2679. var codes = new Int32Array(size);
  2680. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  2681. for (var val = 0; val < n; ++val) {
  2682. if (lengths[val] === len) {
  2683. var code2 = 0;
  2684. var t = code;
  2685. for (i = 0; i < len; ++i) {
  2686. code2 = code2 << 1 | t & 1;
  2687. t >>= 1;
  2688. }
  2689. for (i = code2; i < size; i += skip) {
  2690. codes[i] = len << 16 | val;
  2691. }
  2692. ++code;
  2693. }
  2694. }
  2695. }
  2696. return [
  2697. codes,
  2698. maxLen
  2699. ];
  2700. };
  2701. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  2702. var buffer, len;
  2703. var str = this.str;
  2704. var hdr = this.getBits(3);
  2705. if (hdr & 1) {
  2706. this.eof = true;
  2707. }
  2708. hdr >>= 1;
  2709. if (hdr === 0) {
  2710. var b;
  2711. if ((b = str.getByte()) === -1) {
  2712. error('Bad block header in flate stream');
  2713. }
  2714. var blockLen = b;
  2715. if ((b = str.getByte()) === -1) {
  2716. error('Bad block header in flate stream');
  2717. }
  2718. blockLen |= b << 8;
  2719. if ((b = str.getByte()) === -1) {
  2720. error('Bad block header in flate stream');
  2721. }
  2722. var check = b;
  2723. if ((b = str.getByte()) === -1) {
  2724. error('Bad block header in flate stream');
  2725. }
  2726. check |= b << 8;
  2727. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  2728. error('Bad uncompressed block length in flate stream');
  2729. }
  2730. this.codeBuf = 0;
  2731. this.codeSize = 0;
  2732. var bufferLength = this.bufferLength;
  2733. buffer = this.ensureBuffer(bufferLength + blockLen);
  2734. var end = bufferLength + blockLen;
  2735. this.bufferLength = end;
  2736. if (blockLen === 0) {
  2737. if (str.peekByte() === -1) {
  2738. this.eof = true;
  2739. }
  2740. } else {
  2741. for (var n = bufferLength; n < end; ++n) {
  2742. if ((b = str.getByte()) === -1) {
  2743. this.eof = true;
  2744. break;
  2745. }
  2746. buffer[n] = b;
  2747. }
  2748. }
  2749. return;
  2750. }
  2751. var litCodeTable;
  2752. var distCodeTable;
  2753. if (hdr === 1) {
  2754. litCodeTable = fixedLitCodeTab;
  2755. distCodeTable = fixedDistCodeTab;
  2756. } else if (hdr === 2) {
  2757. var numLitCodes = this.getBits(5) + 257;
  2758. var numDistCodes = this.getBits(5) + 1;
  2759. var numCodeLenCodes = this.getBits(4) + 4;
  2760. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  2761. var i;
  2762. for (i = 0; i < numCodeLenCodes; ++i) {
  2763. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  2764. }
  2765. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  2766. len = 0;
  2767. i = 0;
  2768. var codes = numLitCodes + numDistCodes;
  2769. var codeLengths = new Uint8Array(codes);
  2770. var bitsLength, bitsOffset, what;
  2771. while (i < codes) {
  2772. var code = this.getCode(codeLenCodeTab);
  2773. if (code === 16) {
  2774. bitsLength = 2;
  2775. bitsOffset = 3;
  2776. what = len;
  2777. } else if (code === 17) {
  2778. bitsLength = 3;
  2779. bitsOffset = 3;
  2780. what = len = 0;
  2781. } else if (code === 18) {
  2782. bitsLength = 7;
  2783. bitsOffset = 11;
  2784. what = len = 0;
  2785. } else {
  2786. codeLengths[i++] = len = code;
  2787. continue;
  2788. }
  2789. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  2790. while (repeatLength-- > 0) {
  2791. codeLengths[i++] = what;
  2792. }
  2793. }
  2794. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  2795. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  2796. } else {
  2797. error('Unknown block type in flate stream');
  2798. }
  2799. buffer = this.buffer;
  2800. var limit = buffer ? buffer.length : 0;
  2801. var pos = this.bufferLength;
  2802. while (true) {
  2803. var code1 = this.getCode(litCodeTable);
  2804. if (code1 < 256) {
  2805. if (pos + 1 >= limit) {
  2806. buffer = this.ensureBuffer(pos + 1);
  2807. limit = buffer.length;
  2808. }
  2809. buffer[pos++] = code1;
  2810. continue;
  2811. }
  2812. if (code1 === 256) {
  2813. this.bufferLength = pos;
  2814. return;
  2815. }
  2816. code1 -= 257;
  2817. code1 = lengthDecode[code1];
  2818. var code2 = code1 >> 16;
  2819. if (code2 > 0) {
  2820. code2 = this.getBits(code2);
  2821. }
  2822. len = (code1 & 0xffff) + code2;
  2823. code1 = this.getCode(distCodeTable);
  2824. code1 = distDecode[code1];
  2825. code2 = code1 >> 16;
  2826. if (code2 > 0) {
  2827. code2 = this.getBits(code2);
  2828. }
  2829. var dist = (code1 & 0xffff) + code2;
  2830. if (pos + len >= limit) {
  2831. buffer = this.ensureBuffer(pos + len);
  2832. limit = buffer.length;
  2833. }
  2834. for (var k = 0; k < len; ++k, ++pos) {
  2835. buffer[pos] = buffer[pos - dist];
  2836. }
  2837. }
  2838. };
  2839. return FlateStream;
  2840. }();
  2841. var PredictorStream = function PredictorStreamClosure() {
  2842. function PredictorStream(str, maybeLength, params) {
  2843. if (!isDict(params)) {
  2844. return str;
  2845. }
  2846. var predictor = this.predictor = params.get('Predictor') || 1;
  2847. if (predictor <= 1) {
  2848. return str;
  2849. }
  2850. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  2851. error('Unsupported predictor: ' + predictor);
  2852. }
  2853. if (predictor === 2) {
  2854. this.readBlock = this.readBlockTiff;
  2855. } else {
  2856. this.readBlock = this.readBlockPng;
  2857. }
  2858. this.str = str;
  2859. this.dict = str.dict;
  2860. var colors = this.colors = params.get('Colors') || 1;
  2861. var bits = this.bits = params.get('BitsPerComponent') || 8;
  2862. var columns = this.columns = params.get('Columns') || 1;
  2863. this.pixBytes = colors * bits + 7 >> 3;
  2864. this.rowBytes = columns * colors * bits + 7 >> 3;
  2865. DecodeStream.call(this, maybeLength);
  2866. return this;
  2867. }
  2868. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  2869. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  2870. var rowBytes = this.rowBytes;
  2871. var bufferLength = this.bufferLength;
  2872. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2873. var bits = this.bits;
  2874. var colors = this.colors;
  2875. var rawBytes = this.str.getBytes(rowBytes);
  2876. this.eof = !rawBytes.length;
  2877. if (this.eof) {
  2878. return;
  2879. }
  2880. var inbuf = 0, outbuf = 0;
  2881. var inbits = 0, outbits = 0;
  2882. var pos = bufferLength;
  2883. var i;
  2884. if (bits === 1 && colors === 1) {
  2885. for (i = 0; i < rowBytes; ++i) {
  2886. var c = rawBytes[i] ^ inbuf;
  2887. c ^= c >> 1;
  2888. c ^= c >> 2;
  2889. c ^= c >> 4;
  2890. inbuf = (c & 1) << 7;
  2891. buffer[pos++] = c;
  2892. }
  2893. } else if (bits === 8) {
  2894. for (i = 0; i < colors; ++i) {
  2895. buffer[pos++] = rawBytes[i];
  2896. }
  2897. for (; i < rowBytes; ++i) {
  2898. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  2899. pos++;
  2900. }
  2901. } else {
  2902. var compArray = new Uint8Array(colors + 1);
  2903. var bitMask = (1 << bits) - 1;
  2904. var j = 0, k = bufferLength;
  2905. var columns = this.columns;
  2906. for (i = 0; i < columns; ++i) {
  2907. for (var kk = 0; kk < colors; ++kk) {
  2908. if (inbits < bits) {
  2909. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  2910. inbits += 8;
  2911. }
  2912. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  2913. inbits -= bits;
  2914. outbuf = outbuf << bits | compArray[kk];
  2915. outbits += bits;
  2916. if (outbits >= 8) {
  2917. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  2918. outbits -= 8;
  2919. }
  2920. }
  2921. }
  2922. if (outbits > 0) {
  2923. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  2924. }
  2925. }
  2926. this.bufferLength += rowBytes;
  2927. };
  2928. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  2929. var rowBytes = this.rowBytes;
  2930. var pixBytes = this.pixBytes;
  2931. var predictor = this.str.getByte();
  2932. var rawBytes = this.str.getBytes(rowBytes);
  2933. this.eof = !rawBytes.length;
  2934. if (this.eof) {
  2935. return;
  2936. }
  2937. var bufferLength = this.bufferLength;
  2938. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2939. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  2940. if (prevRow.length === 0) {
  2941. prevRow = new Uint8Array(rowBytes);
  2942. }
  2943. var i, j = bufferLength, up, c;
  2944. switch (predictor) {
  2945. case 0:
  2946. for (i = 0; i < rowBytes; ++i) {
  2947. buffer[j++] = rawBytes[i];
  2948. }
  2949. break;
  2950. case 1:
  2951. for (i = 0; i < pixBytes; ++i) {
  2952. buffer[j++] = rawBytes[i];
  2953. }
  2954. for (; i < rowBytes; ++i) {
  2955. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  2956. j++;
  2957. }
  2958. break;
  2959. case 2:
  2960. for (i = 0; i < rowBytes; ++i) {
  2961. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  2962. }
  2963. break;
  2964. case 3:
  2965. for (i = 0; i < pixBytes; ++i) {
  2966. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  2967. }
  2968. for (; i < rowBytes; ++i) {
  2969. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  2970. j++;
  2971. }
  2972. break;
  2973. case 4:
  2974. for (i = 0; i < pixBytes; ++i) {
  2975. up = prevRow[i];
  2976. c = rawBytes[i];
  2977. buffer[j++] = up + c;
  2978. }
  2979. for (; i < rowBytes; ++i) {
  2980. up = prevRow[i];
  2981. var upLeft = prevRow[i - pixBytes];
  2982. var left = buffer[j - pixBytes];
  2983. var p = left + up - upLeft;
  2984. var pa = p - left;
  2985. if (pa < 0) {
  2986. pa = -pa;
  2987. }
  2988. var pb = p - up;
  2989. if (pb < 0) {
  2990. pb = -pb;
  2991. }
  2992. var pc = p - upLeft;
  2993. if (pc < 0) {
  2994. pc = -pc;
  2995. }
  2996. c = rawBytes[i];
  2997. if (pa <= pb && pa <= pc) {
  2998. buffer[j++] = left + c;
  2999. } else if (pb <= pc) {
  3000. buffer[j++] = up + c;
  3001. } else {
  3002. buffer[j++] = upLeft + c;
  3003. }
  3004. }
  3005. break;
  3006. default:
  3007. error('Unsupported predictor: ' + predictor);
  3008. }
  3009. this.bufferLength += rowBytes;
  3010. };
  3011. return PredictorStream;
  3012. }();
  3013. var JpegStream = function JpegStreamClosure() {
  3014. function JpegStream(stream, maybeLength, dict, params) {
  3015. var ch;
  3016. while ((ch = stream.getByte()) !== -1) {
  3017. if (ch === 0xFF) {
  3018. stream.skip(-1);
  3019. break;
  3020. }
  3021. }
  3022. this.stream = stream;
  3023. this.maybeLength = maybeLength;
  3024. this.dict = dict;
  3025. this.params = params;
  3026. DecodeStream.call(this, maybeLength);
  3027. }
  3028. JpegStream.prototype = Object.create(DecodeStream.prototype);
  3029. Object.defineProperty(JpegStream.prototype, 'bytes', {
  3030. get: function JpegStream_bytes() {
  3031. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3032. },
  3033. configurable: true
  3034. });
  3035. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  3036. if (this.bufferLength) {
  3037. return;
  3038. }
  3039. var jpegImage = new JpegImage();
  3040. var decodeArr = this.dict.getArray('Decode', 'D');
  3041. if (this.forceRGB && isArray(decodeArr)) {
  3042. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  3043. var decodeArrLength = decodeArr.length;
  3044. var transform = new Int32Array(decodeArrLength);
  3045. var transformNeeded = false;
  3046. var maxValue = (1 << bitsPerComponent) - 1;
  3047. for (var i = 0; i < decodeArrLength; i += 2) {
  3048. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  3049. transform[i + 1] = decodeArr[i] * maxValue | 0;
  3050. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  3051. transformNeeded = true;
  3052. }
  3053. }
  3054. if (transformNeeded) {
  3055. jpegImage.decodeTransform = transform;
  3056. }
  3057. }
  3058. if (isDict(this.params)) {
  3059. var colorTransform = this.params.get('ColorTransform');
  3060. if (isInt(colorTransform)) {
  3061. jpegImage.colorTransform = colorTransform;
  3062. }
  3063. }
  3064. jpegImage.parse(this.bytes);
  3065. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  3066. this.buffer = data;
  3067. this.bufferLength = data.length;
  3068. this.eof = true;
  3069. };
  3070. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  3071. this.ensureBuffer();
  3072. return this.buffer;
  3073. };
  3074. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  3075. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  3076. };
  3077. return JpegStream;
  3078. }();
  3079. var JpxStream = function JpxStreamClosure() {
  3080. function JpxStream(stream, maybeLength, dict, params) {
  3081. this.stream = stream;
  3082. this.maybeLength = maybeLength;
  3083. this.dict = dict;
  3084. this.params = params;
  3085. DecodeStream.call(this, maybeLength);
  3086. }
  3087. JpxStream.prototype = Object.create(DecodeStream.prototype);
  3088. Object.defineProperty(JpxStream.prototype, 'bytes', {
  3089. get: function JpxStream_bytes() {
  3090. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3091. },
  3092. configurable: true
  3093. });
  3094. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  3095. if (this.bufferLength) {
  3096. return;
  3097. }
  3098. var jpxImage = new JpxImage();
  3099. jpxImage.parse(this.bytes);
  3100. var width = jpxImage.width;
  3101. var height = jpxImage.height;
  3102. var componentsCount = jpxImage.componentsCount;
  3103. var tileCount = jpxImage.tiles.length;
  3104. if (tileCount === 1) {
  3105. this.buffer = jpxImage.tiles[0].items;
  3106. } else {
  3107. var data = new Uint8Array(width * height * componentsCount);
  3108. for (var k = 0; k < tileCount; k++) {
  3109. var tileComponents = jpxImage.tiles[k];
  3110. var tileWidth = tileComponents.width;
  3111. var tileHeight = tileComponents.height;
  3112. var tileLeft = tileComponents.left;
  3113. var tileTop = tileComponents.top;
  3114. var src = tileComponents.items;
  3115. var srcPosition = 0;
  3116. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  3117. var imgRowSize = width * componentsCount;
  3118. var tileRowSize = tileWidth * componentsCount;
  3119. for (var j = 0; j < tileHeight; j++) {
  3120. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  3121. data.set(rowBytes, dataPosition);
  3122. srcPosition += tileRowSize;
  3123. dataPosition += imgRowSize;
  3124. }
  3125. }
  3126. this.buffer = data;
  3127. }
  3128. this.bufferLength = this.buffer.length;
  3129. this.eof = true;
  3130. };
  3131. return JpxStream;
  3132. }();
  3133. var Jbig2Stream = function Jbig2StreamClosure() {
  3134. function Jbig2Stream(stream, maybeLength, dict, params) {
  3135. this.stream = stream;
  3136. this.maybeLength = maybeLength;
  3137. this.dict = dict;
  3138. this.params = params;
  3139. DecodeStream.call(this, maybeLength);
  3140. }
  3141. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  3142. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  3143. get: function Jbig2Stream_bytes() {
  3144. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3145. },
  3146. configurable: true
  3147. });
  3148. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  3149. if (this.bufferLength) {
  3150. return;
  3151. }
  3152. var jbig2Image = new Jbig2Image();
  3153. var chunks = [];
  3154. if (isDict(this.params)) {
  3155. var globalsStream = this.params.get('JBIG2Globals');
  3156. if (isStream(globalsStream)) {
  3157. var globals = globalsStream.getBytes();
  3158. chunks.push({
  3159. data: globals,
  3160. start: 0,
  3161. end: globals.length
  3162. });
  3163. }
  3164. }
  3165. chunks.push({
  3166. data: this.bytes,
  3167. start: 0,
  3168. end: this.bytes.length
  3169. });
  3170. var data = jbig2Image.parseChunks(chunks);
  3171. var dataLength = data.length;
  3172. for (var i = 0; i < dataLength; i++) {
  3173. data[i] ^= 0xFF;
  3174. }
  3175. this.buffer = data;
  3176. this.bufferLength = dataLength;
  3177. this.eof = true;
  3178. };
  3179. return Jbig2Stream;
  3180. }();
  3181. var DecryptStream = function DecryptStreamClosure() {
  3182. function DecryptStream(str, maybeLength, decrypt) {
  3183. this.str = str;
  3184. this.dict = str.dict;
  3185. this.decrypt = decrypt;
  3186. this.nextChunk = null;
  3187. this.initialized = false;
  3188. DecodeStream.call(this, maybeLength);
  3189. }
  3190. var chunkSize = 512;
  3191. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  3192. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  3193. var chunk;
  3194. if (this.initialized) {
  3195. chunk = this.nextChunk;
  3196. } else {
  3197. chunk = this.str.getBytes(chunkSize);
  3198. this.initialized = true;
  3199. }
  3200. if (!chunk || chunk.length === 0) {
  3201. this.eof = true;
  3202. return;
  3203. }
  3204. this.nextChunk = this.str.getBytes(chunkSize);
  3205. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  3206. var decrypt = this.decrypt;
  3207. chunk = decrypt(chunk, !hasMoreData);
  3208. var bufferLength = this.bufferLength;
  3209. var i, n = chunk.length;
  3210. var buffer = this.ensureBuffer(bufferLength + n);
  3211. for (i = 0; i < n; i++) {
  3212. buffer[bufferLength++] = chunk[i];
  3213. }
  3214. this.bufferLength = bufferLength;
  3215. };
  3216. return DecryptStream;
  3217. }();
  3218. var Ascii85Stream = function Ascii85StreamClosure() {
  3219. function Ascii85Stream(str, maybeLength) {
  3220. this.str = str;
  3221. this.dict = str.dict;
  3222. this.input = new Uint8Array(5);
  3223. if (maybeLength) {
  3224. maybeLength = 0.8 * maybeLength;
  3225. }
  3226. DecodeStream.call(this, maybeLength);
  3227. }
  3228. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  3229. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  3230. var TILDA_CHAR = 0x7E;
  3231. var Z_LOWER_CHAR = 0x7A;
  3232. var EOF = -1;
  3233. var str = this.str;
  3234. var c = str.getByte();
  3235. while (isSpace(c)) {
  3236. c = str.getByte();
  3237. }
  3238. if (c === EOF || c === TILDA_CHAR) {
  3239. this.eof = true;
  3240. return;
  3241. }
  3242. var bufferLength = this.bufferLength, buffer;
  3243. var i;
  3244. if (c === Z_LOWER_CHAR) {
  3245. buffer = this.ensureBuffer(bufferLength + 4);
  3246. for (i = 0; i < 4; ++i) {
  3247. buffer[bufferLength + i] = 0;
  3248. }
  3249. this.bufferLength += 4;
  3250. } else {
  3251. var input = this.input;
  3252. input[0] = c;
  3253. for (i = 1; i < 5; ++i) {
  3254. c = str.getByte();
  3255. while (isSpace(c)) {
  3256. c = str.getByte();
  3257. }
  3258. input[i] = c;
  3259. if (c === EOF || c === TILDA_CHAR) {
  3260. break;
  3261. }
  3262. }
  3263. buffer = this.ensureBuffer(bufferLength + i - 1);
  3264. this.bufferLength += i - 1;
  3265. if (i < 5) {
  3266. for (; i < 5; ++i) {
  3267. input[i] = 0x21 + 84;
  3268. }
  3269. this.eof = true;
  3270. }
  3271. var t = 0;
  3272. for (i = 0; i < 5; ++i) {
  3273. t = t * 85 + (input[i] - 0x21);
  3274. }
  3275. for (i = 3; i >= 0; --i) {
  3276. buffer[bufferLength + i] = t & 0xFF;
  3277. t >>= 8;
  3278. }
  3279. }
  3280. };
  3281. return Ascii85Stream;
  3282. }();
  3283. var AsciiHexStream = function AsciiHexStreamClosure() {
  3284. function AsciiHexStream(str, maybeLength) {
  3285. this.str = str;
  3286. this.dict = str.dict;
  3287. this.firstDigit = -1;
  3288. if (maybeLength) {
  3289. maybeLength = 0.5 * maybeLength;
  3290. }
  3291. DecodeStream.call(this, maybeLength);
  3292. }
  3293. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  3294. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  3295. var UPSTREAM_BLOCK_SIZE = 8000;
  3296. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  3297. if (!bytes.length) {
  3298. this.eof = true;
  3299. return;
  3300. }
  3301. var maxDecodeLength = bytes.length + 1 >> 1;
  3302. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  3303. var bufferLength = this.bufferLength;
  3304. var firstDigit = this.firstDigit;
  3305. for (var i = 0, ii = bytes.length; i < ii; i++) {
  3306. var ch = bytes[i], digit;
  3307. if (ch >= 0x30 && ch <= 0x39) {
  3308. digit = ch & 0x0F;
  3309. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  3310. digit = (ch & 0x0F) + 9;
  3311. } else if (ch === 0x3E) {
  3312. this.eof = true;
  3313. break;
  3314. } else {
  3315. continue;
  3316. }
  3317. if (firstDigit < 0) {
  3318. firstDigit = digit;
  3319. } else {
  3320. buffer[bufferLength++] = firstDigit << 4 | digit;
  3321. firstDigit = -1;
  3322. }
  3323. }
  3324. if (firstDigit >= 0 && this.eof) {
  3325. buffer[bufferLength++] = firstDigit << 4;
  3326. firstDigit = -1;
  3327. }
  3328. this.firstDigit = firstDigit;
  3329. this.bufferLength = bufferLength;
  3330. };
  3331. return AsciiHexStream;
  3332. }();
  3333. var RunLengthStream = function RunLengthStreamClosure() {
  3334. function RunLengthStream(str, maybeLength) {
  3335. this.str = str;
  3336. this.dict = str.dict;
  3337. DecodeStream.call(this, maybeLength);
  3338. }
  3339. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  3340. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  3341. var repeatHeader = this.str.getBytes(2);
  3342. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  3343. this.eof = true;
  3344. return;
  3345. }
  3346. var buffer;
  3347. var bufferLength = this.bufferLength;
  3348. var n = repeatHeader[0];
  3349. if (n < 128) {
  3350. buffer = this.ensureBuffer(bufferLength + n + 1);
  3351. buffer[bufferLength++] = repeatHeader[1];
  3352. if (n > 0) {
  3353. var source = this.str.getBytes(n);
  3354. buffer.set(source, bufferLength);
  3355. bufferLength += n;
  3356. }
  3357. } else {
  3358. n = 257 - n;
  3359. var b = repeatHeader[1];
  3360. buffer = this.ensureBuffer(bufferLength + n + 1);
  3361. for (var i = 0; i < n; i++) {
  3362. buffer[bufferLength++] = b;
  3363. }
  3364. }
  3365. this.bufferLength = bufferLength;
  3366. };
  3367. return RunLengthStream;
  3368. }();
  3369. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  3370. var ccittEOL = -2;
  3371. var ccittEOF = -1;
  3372. var twoDimPass = 0;
  3373. var twoDimHoriz = 1;
  3374. var twoDimVert0 = 2;
  3375. var twoDimVertR1 = 3;
  3376. var twoDimVertL1 = 4;
  3377. var twoDimVertR2 = 5;
  3378. var twoDimVertL2 = 6;
  3379. var twoDimVertR3 = 7;
  3380. var twoDimVertL3 = 8;
  3381. var twoDimTable = [
  3382. [
  3383. -1,
  3384. -1
  3385. ],
  3386. [
  3387. -1,
  3388. -1
  3389. ],
  3390. [
  3391. 7,
  3392. twoDimVertL3
  3393. ],
  3394. [
  3395. 7,
  3396. twoDimVertR3
  3397. ],
  3398. [
  3399. 6,
  3400. twoDimVertL2
  3401. ],
  3402. [
  3403. 6,
  3404. twoDimVertL2
  3405. ],
  3406. [
  3407. 6,
  3408. twoDimVertR2
  3409. ],
  3410. [
  3411. 6,
  3412. twoDimVertR2
  3413. ],
  3414. [
  3415. 4,
  3416. twoDimPass
  3417. ],
  3418. [
  3419. 4,
  3420. twoDimPass
  3421. ],
  3422. [
  3423. 4,
  3424. twoDimPass
  3425. ],
  3426. [
  3427. 4,
  3428. twoDimPass
  3429. ],
  3430. [
  3431. 4,
  3432. twoDimPass
  3433. ],
  3434. [
  3435. 4,
  3436. twoDimPass
  3437. ],
  3438. [
  3439. 4,
  3440. twoDimPass
  3441. ],
  3442. [
  3443. 4,
  3444. twoDimPass
  3445. ],
  3446. [
  3447. 3,
  3448. twoDimHoriz
  3449. ],
  3450. [
  3451. 3,
  3452. twoDimHoriz
  3453. ],
  3454. [
  3455. 3,
  3456. twoDimHoriz
  3457. ],
  3458. [
  3459. 3,
  3460. twoDimHoriz
  3461. ],
  3462. [
  3463. 3,
  3464. twoDimHoriz
  3465. ],
  3466. [
  3467. 3,
  3468. twoDimHoriz
  3469. ],
  3470. [
  3471. 3,
  3472. twoDimHoriz
  3473. ],
  3474. [
  3475. 3,
  3476. twoDimHoriz
  3477. ],
  3478. [
  3479. 3,
  3480. twoDimHoriz
  3481. ],
  3482. [
  3483. 3,
  3484. twoDimHoriz
  3485. ],
  3486. [
  3487. 3,
  3488. twoDimHoriz
  3489. ],
  3490. [
  3491. 3,
  3492. twoDimHoriz
  3493. ],
  3494. [
  3495. 3,
  3496. twoDimHoriz
  3497. ],
  3498. [
  3499. 3,
  3500. twoDimHoriz
  3501. ],
  3502. [
  3503. 3,
  3504. twoDimHoriz
  3505. ],
  3506. [
  3507. 3,
  3508. twoDimHoriz
  3509. ],
  3510. [
  3511. 3,
  3512. twoDimVertL1
  3513. ],
  3514. [
  3515. 3,
  3516. twoDimVertL1
  3517. ],
  3518. [
  3519. 3,
  3520. twoDimVertL1
  3521. ],
  3522. [
  3523. 3,
  3524. twoDimVertL1
  3525. ],
  3526. [
  3527. 3,
  3528. twoDimVertL1
  3529. ],
  3530. [
  3531. 3,
  3532. twoDimVertL1
  3533. ],
  3534. [
  3535. 3,
  3536. twoDimVertL1
  3537. ],
  3538. [
  3539. 3,
  3540. twoDimVertL1
  3541. ],
  3542. [
  3543. 3,
  3544. twoDimVertL1
  3545. ],
  3546. [
  3547. 3,
  3548. twoDimVertL1
  3549. ],
  3550. [
  3551. 3,
  3552. twoDimVertL1
  3553. ],
  3554. [
  3555. 3,
  3556. twoDimVertL1
  3557. ],
  3558. [
  3559. 3,
  3560. twoDimVertL1
  3561. ],
  3562. [
  3563. 3,
  3564. twoDimVertL1
  3565. ],
  3566. [
  3567. 3,
  3568. twoDimVertL1
  3569. ],
  3570. [
  3571. 3,
  3572. twoDimVertL1
  3573. ],
  3574. [
  3575. 3,
  3576. twoDimVertR1
  3577. ],
  3578. [
  3579. 3,
  3580. twoDimVertR1
  3581. ],
  3582. [
  3583. 3,
  3584. twoDimVertR1
  3585. ],
  3586. [
  3587. 3,
  3588. twoDimVertR1
  3589. ],
  3590. [
  3591. 3,
  3592. twoDimVertR1
  3593. ],
  3594. [
  3595. 3,
  3596. twoDimVertR1
  3597. ],
  3598. [
  3599. 3,
  3600. twoDimVertR1
  3601. ],
  3602. [
  3603. 3,
  3604. twoDimVertR1
  3605. ],
  3606. [
  3607. 3,
  3608. twoDimVertR1
  3609. ],
  3610. [
  3611. 3,
  3612. twoDimVertR1
  3613. ],
  3614. [
  3615. 3,
  3616. twoDimVertR1
  3617. ],
  3618. [
  3619. 3,
  3620. twoDimVertR1
  3621. ],
  3622. [
  3623. 3,
  3624. twoDimVertR1
  3625. ],
  3626. [
  3627. 3,
  3628. twoDimVertR1
  3629. ],
  3630. [
  3631. 3,
  3632. twoDimVertR1
  3633. ],
  3634. [
  3635. 3,
  3636. twoDimVertR1
  3637. ],
  3638. [
  3639. 1,
  3640. twoDimVert0
  3641. ],
  3642. [
  3643. 1,
  3644. twoDimVert0
  3645. ],
  3646. [
  3647. 1,
  3648. twoDimVert0
  3649. ],
  3650. [
  3651. 1,
  3652. twoDimVert0
  3653. ],
  3654. [
  3655. 1,
  3656. twoDimVert0
  3657. ],
  3658. [
  3659. 1,
  3660. twoDimVert0
  3661. ],
  3662. [
  3663. 1,
  3664. twoDimVert0
  3665. ],
  3666. [
  3667. 1,
  3668. twoDimVert0
  3669. ],
  3670. [
  3671. 1,
  3672. twoDimVert0
  3673. ],
  3674. [
  3675. 1,
  3676. twoDimVert0
  3677. ],
  3678. [
  3679. 1,
  3680. twoDimVert0
  3681. ],
  3682. [
  3683. 1,
  3684. twoDimVert0
  3685. ],
  3686. [
  3687. 1,
  3688. twoDimVert0
  3689. ],
  3690. [
  3691. 1,
  3692. twoDimVert0
  3693. ],
  3694. [
  3695. 1,
  3696. twoDimVert0
  3697. ],
  3698. [
  3699. 1,
  3700. twoDimVert0
  3701. ],
  3702. [
  3703. 1,
  3704. twoDimVert0
  3705. ],
  3706. [
  3707. 1,
  3708. twoDimVert0
  3709. ],
  3710. [
  3711. 1,
  3712. twoDimVert0
  3713. ],
  3714. [
  3715. 1,
  3716. twoDimVert0
  3717. ],
  3718. [
  3719. 1,
  3720. twoDimVert0
  3721. ],
  3722. [
  3723. 1,
  3724. twoDimVert0
  3725. ],
  3726. [
  3727. 1,
  3728. twoDimVert0
  3729. ],
  3730. [
  3731. 1,
  3732. twoDimVert0
  3733. ],
  3734. [
  3735. 1,
  3736. twoDimVert0
  3737. ],
  3738. [
  3739. 1,
  3740. twoDimVert0
  3741. ],
  3742. [
  3743. 1,
  3744. twoDimVert0
  3745. ],
  3746. [
  3747. 1,
  3748. twoDimVert0
  3749. ],
  3750. [
  3751. 1,
  3752. twoDimVert0
  3753. ],
  3754. [
  3755. 1,
  3756. twoDimVert0
  3757. ],
  3758. [
  3759. 1,
  3760. twoDimVert0
  3761. ],
  3762. [
  3763. 1,
  3764. twoDimVert0
  3765. ],
  3766. [
  3767. 1,
  3768. twoDimVert0
  3769. ],
  3770. [
  3771. 1,
  3772. twoDimVert0
  3773. ],
  3774. [
  3775. 1,
  3776. twoDimVert0
  3777. ],
  3778. [
  3779. 1,
  3780. twoDimVert0
  3781. ],
  3782. [
  3783. 1,
  3784. twoDimVert0
  3785. ],
  3786. [
  3787. 1,
  3788. twoDimVert0
  3789. ],
  3790. [
  3791. 1,
  3792. twoDimVert0
  3793. ],
  3794. [
  3795. 1,
  3796. twoDimVert0
  3797. ],
  3798. [
  3799. 1,
  3800. twoDimVert0
  3801. ],
  3802. [
  3803. 1,
  3804. twoDimVert0
  3805. ],
  3806. [
  3807. 1,
  3808. twoDimVert0
  3809. ],
  3810. [
  3811. 1,
  3812. twoDimVert0
  3813. ],
  3814. [
  3815. 1,
  3816. twoDimVert0
  3817. ],
  3818. [
  3819. 1,
  3820. twoDimVert0
  3821. ],
  3822. [
  3823. 1,
  3824. twoDimVert0
  3825. ],
  3826. [
  3827. 1,
  3828. twoDimVert0
  3829. ],
  3830. [
  3831. 1,
  3832. twoDimVert0
  3833. ],
  3834. [
  3835. 1,
  3836. twoDimVert0
  3837. ],
  3838. [
  3839. 1,
  3840. twoDimVert0
  3841. ],
  3842. [
  3843. 1,
  3844. twoDimVert0
  3845. ],
  3846. [
  3847. 1,
  3848. twoDimVert0
  3849. ],
  3850. [
  3851. 1,
  3852. twoDimVert0
  3853. ],
  3854. [
  3855. 1,
  3856. twoDimVert0
  3857. ],
  3858. [
  3859. 1,
  3860. twoDimVert0
  3861. ],
  3862. [
  3863. 1,
  3864. twoDimVert0
  3865. ],
  3866. [
  3867. 1,
  3868. twoDimVert0
  3869. ],
  3870. [
  3871. 1,
  3872. twoDimVert0
  3873. ],
  3874. [
  3875. 1,
  3876. twoDimVert0
  3877. ],
  3878. [
  3879. 1,
  3880. twoDimVert0
  3881. ],
  3882. [
  3883. 1,
  3884. twoDimVert0
  3885. ],
  3886. [
  3887. 1,
  3888. twoDimVert0
  3889. ],
  3890. [
  3891. 1,
  3892. twoDimVert0
  3893. ]
  3894. ];
  3895. var whiteTable1 = [
  3896. [
  3897. -1,
  3898. -1
  3899. ],
  3900. [
  3901. 12,
  3902. ccittEOL
  3903. ],
  3904. [
  3905. -1,
  3906. -1
  3907. ],
  3908. [
  3909. -1,
  3910. -1
  3911. ],
  3912. [
  3913. -1,
  3914. -1
  3915. ],
  3916. [
  3917. -1,
  3918. -1
  3919. ],
  3920. [
  3921. -1,
  3922. -1
  3923. ],
  3924. [
  3925. -1,
  3926. -1
  3927. ],
  3928. [
  3929. -1,
  3930. -1
  3931. ],
  3932. [
  3933. -1,
  3934. -1
  3935. ],
  3936. [
  3937. -1,
  3938. -1
  3939. ],
  3940. [
  3941. -1,
  3942. -1
  3943. ],
  3944. [
  3945. -1,
  3946. -1
  3947. ],
  3948. [
  3949. -1,
  3950. -1
  3951. ],
  3952. [
  3953. -1,
  3954. -1
  3955. ],
  3956. [
  3957. -1,
  3958. -1
  3959. ],
  3960. [
  3961. 11,
  3962. 1792
  3963. ],
  3964. [
  3965. 11,
  3966. 1792
  3967. ],
  3968. [
  3969. 12,
  3970. 1984
  3971. ],
  3972. [
  3973. 12,
  3974. 2048
  3975. ],
  3976. [
  3977. 12,
  3978. 2112
  3979. ],
  3980. [
  3981. 12,
  3982. 2176
  3983. ],
  3984. [
  3985. 12,
  3986. 2240
  3987. ],
  3988. [
  3989. 12,
  3990. 2304
  3991. ],
  3992. [
  3993. 11,
  3994. 1856
  3995. ],
  3996. [
  3997. 11,
  3998. 1856
  3999. ],
  4000. [
  4001. 11,
  4002. 1920
  4003. ],
  4004. [
  4005. 11,
  4006. 1920
  4007. ],
  4008. [
  4009. 12,
  4010. 2368
  4011. ],
  4012. [
  4013. 12,
  4014. 2432
  4015. ],
  4016. [
  4017. 12,
  4018. 2496
  4019. ],
  4020. [
  4021. 12,
  4022. 2560
  4023. ]
  4024. ];
  4025. var whiteTable2 = [
  4026. [
  4027. -1,
  4028. -1
  4029. ],
  4030. [
  4031. -1,
  4032. -1
  4033. ],
  4034. [
  4035. -1,
  4036. -1
  4037. ],
  4038. [
  4039. -1,
  4040. -1
  4041. ],
  4042. [
  4043. 8,
  4044. 29
  4045. ],
  4046. [
  4047. 8,
  4048. 29
  4049. ],
  4050. [
  4051. 8,
  4052. 30
  4053. ],
  4054. [
  4055. 8,
  4056. 30
  4057. ],
  4058. [
  4059. 8,
  4060. 45
  4061. ],
  4062. [
  4063. 8,
  4064. 45
  4065. ],
  4066. [
  4067. 8,
  4068. 46
  4069. ],
  4070. [
  4071. 8,
  4072. 46
  4073. ],
  4074. [
  4075. 7,
  4076. 22
  4077. ],
  4078. [
  4079. 7,
  4080. 22
  4081. ],
  4082. [
  4083. 7,
  4084. 22
  4085. ],
  4086. [
  4087. 7,
  4088. 22
  4089. ],
  4090. [
  4091. 7,
  4092. 23
  4093. ],
  4094. [
  4095. 7,
  4096. 23
  4097. ],
  4098. [
  4099. 7,
  4100. 23
  4101. ],
  4102. [
  4103. 7,
  4104. 23
  4105. ],
  4106. [
  4107. 8,
  4108. 47
  4109. ],
  4110. [
  4111. 8,
  4112. 47
  4113. ],
  4114. [
  4115. 8,
  4116. 48
  4117. ],
  4118. [
  4119. 8,
  4120. 48
  4121. ],
  4122. [
  4123. 6,
  4124. 13
  4125. ],
  4126. [
  4127. 6,
  4128. 13
  4129. ],
  4130. [
  4131. 6,
  4132. 13
  4133. ],
  4134. [
  4135. 6,
  4136. 13
  4137. ],
  4138. [
  4139. 6,
  4140. 13
  4141. ],
  4142. [
  4143. 6,
  4144. 13
  4145. ],
  4146. [
  4147. 6,
  4148. 13
  4149. ],
  4150. [
  4151. 6,
  4152. 13
  4153. ],
  4154. [
  4155. 7,
  4156. 20
  4157. ],
  4158. [
  4159. 7,
  4160. 20
  4161. ],
  4162. [
  4163. 7,
  4164. 20
  4165. ],
  4166. [
  4167. 7,
  4168. 20
  4169. ],
  4170. [
  4171. 8,
  4172. 33
  4173. ],
  4174. [
  4175. 8,
  4176. 33
  4177. ],
  4178. [
  4179. 8,
  4180. 34
  4181. ],
  4182. [
  4183. 8,
  4184. 34
  4185. ],
  4186. [
  4187. 8,
  4188. 35
  4189. ],
  4190. [
  4191. 8,
  4192. 35
  4193. ],
  4194. [
  4195. 8,
  4196. 36
  4197. ],
  4198. [
  4199. 8,
  4200. 36
  4201. ],
  4202. [
  4203. 8,
  4204. 37
  4205. ],
  4206. [
  4207. 8,
  4208. 37
  4209. ],
  4210. [
  4211. 8,
  4212. 38
  4213. ],
  4214. [
  4215. 8,
  4216. 38
  4217. ],
  4218. [
  4219. 7,
  4220. 19
  4221. ],
  4222. [
  4223. 7,
  4224. 19
  4225. ],
  4226. [
  4227. 7,
  4228. 19
  4229. ],
  4230. [
  4231. 7,
  4232. 19
  4233. ],
  4234. [
  4235. 8,
  4236. 31
  4237. ],
  4238. [
  4239. 8,
  4240. 31
  4241. ],
  4242. [
  4243. 8,
  4244. 32
  4245. ],
  4246. [
  4247. 8,
  4248. 32
  4249. ],
  4250. [
  4251. 6,
  4252. 1
  4253. ],
  4254. [
  4255. 6,
  4256. 1
  4257. ],
  4258. [
  4259. 6,
  4260. 1
  4261. ],
  4262. [
  4263. 6,
  4264. 1
  4265. ],
  4266. [
  4267. 6,
  4268. 1
  4269. ],
  4270. [
  4271. 6,
  4272. 1
  4273. ],
  4274. [
  4275. 6,
  4276. 1
  4277. ],
  4278. [
  4279. 6,
  4280. 1
  4281. ],
  4282. [
  4283. 6,
  4284. 12
  4285. ],
  4286. [
  4287. 6,
  4288. 12
  4289. ],
  4290. [
  4291. 6,
  4292. 12
  4293. ],
  4294. [
  4295. 6,
  4296. 12
  4297. ],
  4298. [
  4299. 6,
  4300. 12
  4301. ],
  4302. [
  4303. 6,
  4304. 12
  4305. ],
  4306. [
  4307. 6,
  4308. 12
  4309. ],
  4310. [
  4311. 6,
  4312. 12
  4313. ],
  4314. [
  4315. 8,
  4316. 53
  4317. ],
  4318. [
  4319. 8,
  4320. 53
  4321. ],
  4322. [
  4323. 8,
  4324. 54
  4325. ],
  4326. [
  4327. 8,
  4328. 54
  4329. ],
  4330. [
  4331. 7,
  4332. 26
  4333. ],
  4334. [
  4335. 7,
  4336. 26
  4337. ],
  4338. [
  4339. 7,
  4340. 26
  4341. ],
  4342. [
  4343. 7,
  4344. 26
  4345. ],
  4346. [
  4347. 8,
  4348. 39
  4349. ],
  4350. [
  4351. 8,
  4352. 39
  4353. ],
  4354. [
  4355. 8,
  4356. 40
  4357. ],
  4358. [
  4359. 8,
  4360. 40
  4361. ],
  4362. [
  4363. 8,
  4364. 41
  4365. ],
  4366. [
  4367. 8,
  4368. 41
  4369. ],
  4370. [
  4371. 8,
  4372. 42
  4373. ],
  4374. [
  4375. 8,
  4376. 42
  4377. ],
  4378. [
  4379. 8,
  4380. 43
  4381. ],
  4382. [
  4383. 8,
  4384. 43
  4385. ],
  4386. [
  4387. 8,
  4388. 44
  4389. ],
  4390. [
  4391. 8,
  4392. 44
  4393. ],
  4394. [
  4395. 7,
  4396. 21
  4397. ],
  4398. [
  4399. 7,
  4400. 21
  4401. ],
  4402. [
  4403. 7,
  4404. 21
  4405. ],
  4406. [
  4407. 7,
  4408. 21
  4409. ],
  4410. [
  4411. 7,
  4412. 28
  4413. ],
  4414. [
  4415. 7,
  4416. 28
  4417. ],
  4418. [
  4419. 7,
  4420. 28
  4421. ],
  4422. [
  4423. 7,
  4424. 28
  4425. ],
  4426. [
  4427. 8,
  4428. 61
  4429. ],
  4430. [
  4431. 8,
  4432. 61
  4433. ],
  4434. [
  4435. 8,
  4436. 62
  4437. ],
  4438. [
  4439. 8,
  4440. 62
  4441. ],
  4442. [
  4443. 8,
  4444. 63
  4445. ],
  4446. [
  4447. 8,
  4448. 63
  4449. ],
  4450. [
  4451. 8,
  4452. 0
  4453. ],
  4454. [
  4455. 8,
  4456. 0
  4457. ],
  4458. [
  4459. 8,
  4460. 320
  4461. ],
  4462. [
  4463. 8,
  4464. 320
  4465. ],
  4466. [
  4467. 8,
  4468. 384
  4469. ],
  4470. [
  4471. 8,
  4472. 384
  4473. ],
  4474. [
  4475. 5,
  4476. 10
  4477. ],
  4478. [
  4479. 5,
  4480. 10
  4481. ],
  4482. [
  4483. 5,
  4484. 10
  4485. ],
  4486. [
  4487. 5,
  4488. 10
  4489. ],
  4490. [
  4491. 5,
  4492. 10
  4493. ],
  4494. [
  4495. 5,
  4496. 10
  4497. ],
  4498. [
  4499. 5,
  4500. 10
  4501. ],
  4502. [
  4503. 5,
  4504. 10
  4505. ],
  4506. [
  4507. 5,
  4508. 10
  4509. ],
  4510. [
  4511. 5,
  4512. 10
  4513. ],
  4514. [
  4515. 5,
  4516. 10
  4517. ],
  4518. [
  4519. 5,
  4520. 10
  4521. ],
  4522. [
  4523. 5,
  4524. 10
  4525. ],
  4526. [
  4527. 5,
  4528. 10
  4529. ],
  4530. [
  4531. 5,
  4532. 10
  4533. ],
  4534. [
  4535. 5,
  4536. 10
  4537. ],
  4538. [
  4539. 5,
  4540. 11
  4541. ],
  4542. [
  4543. 5,
  4544. 11
  4545. ],
  4546. [
  4547. 5,
  4548. 11
  4549. ],
  4550. [
  4551. 5,
  4552. 11
  4553. ],
  4554. [
  4555. 5,
  4556. 11
  4557. ],
  4558. [
  4559. 5,
  4560. 11
  4561. ],
  4562. [
  4563. 5,
  4564. 11
  4565. ],
  4566. [
  4567. 5,
  4568. 11
  4569. ],
  4570. [
  4571. 5,
  4572. 11
  4573. ],
  4574. [
  4575. 5,
  4576. 11
  4577. ],
  4578. [
  4579. 5,
  4580. 11
  4581. ],
  4582. [
  4583. 5,
  4584. 11
  4585. ],
  4586. [
  4587. 5,
  4588. 11
  4589. ],
  4590. [
  4591. 5,
  4592. 11
  4593. ],
  4594. [
  4595. 5,
  4596. 11
  4597. ],
  4598. [
  4599. 5,
  4600. 11
  4601. ],
  4602. [
  4603. 7,
  4604. 27
  4605. ],
  4606. [
  4607. 7,
  4608. 27
  4609. ],
  4610. [
  4611. 7,
  4612. 27
  4613. ],
  4614. [
  4615. 7,
  4616. 27
  4617. ],
  4618. [
  4619. 8,
  4620. 59
  4621. ],
  4622. [
  4623. 8,
  4624. 59
  4625. ],
  4626. [
  4627. 8,
  4628. 60
  4629. ],
  4630. [
  4631. 8,
  4632. 60
  4633. ],
  4634. [
  4635. 9,
  4636. 1472
  4637. ],
  4638. [
  4639. 9,
  4640. 1536
  4641. ],
  4642. [
  4643. 9,
  4644. 1600
  4645. ],
  4646. [
  4647. 9,
  4648. 1728
  4649. ],
  4650. [
  4651. 7,
  4652. 18
  4653. ],
  4654. [
  4655. 7,
  4656. 18
  4657. ],
  4658. [
  4659. 7,
  4660. 18
  4661. ],
  4662. [
  4663. 7,
  4664. 18
  4665. ],
  4666. [
  4667. 7,
  4668. 24
  4669. ],
  4670. [
  4671. 7,
  4672. 24
  4673. ],
  4674. [
  4675. 7,
  4676. 24
  4677. ],
  4678. [
  4679. 7,
  4680. 24
  4681. ],
  4682. [
  4683. 8,
  4684. 49
  4685. ],
  4686. [
  4687. 8,
  4688. 49
  4689. ],
  4690. [
  4691. 8,
  4692. 50
  4693. ],
  4694. [
  4695. 8,
  4696. 50
  4697. ],
  4698. [
  4699. 8,
  4700. 51
  4701. ],
  4702. [
  4703. 8,
  4704. 51
  4705. ],
  4706. [
  4707. 8,
  4708. 52
  4709. ],
  4710. [
  4711. 8,
  4712. 52
  4713. ],
  4714. [
  4715. 7,
  4716. 25
  4717. ],
  4718. [
  4719. 7,
  4720. 25
  4721. ],
  4722. [
  4723. 7,
  4724. 25
  4725. ],
  4726. [
  4727. 7,
  4728. 25
  4729. ],
  4730. [
  4731. 8,
  4732. 55
  4733. ],
  4734. [
  4735. 8,
  4736. 55
  4737. ],
  4738. [
  4739. 8,
  4740. 56
  4741. ],
  4742. [
  4743. 8,
  4744. 56
  4745. ],
  4746. [
  4747. 8,
  4748. 57
  4749. ],
  4750. [
  4751. 8,
  4752. 57
  4753. ],
  4754. [
  4755. 8,
  4756. 58
  4757. ],
  4758. [
  4759. 8,
  4760. 58
  4761. ],
  4762. [
  4763. 6,
  4764. 192
  4765. ],
  4766. [
  4767. 6,
  4768. 192
  4769. ],
  4770. [
  4771. 6,
  4772. 192
  4773. ],
  4774. [
  4775. 6,
  4776. 192
  4777. ],
  4778. [
  4779. 6,
  4780. 192
  4781. ],
  4782. [
  4783. 6,
  4784. 192
  4785. ],
  4786. [
  4787. 6,
  4788. 192
  4789. ],
  4790. [
  4791. 6,
  4792. 192
  4793. ],
  4794. [
  4795. 6,
  4796. 1664
  4797. ],
  4798. [
  4799. 6,
  4800. 1664
  4801. ],
  4802. [
  4803. 6,
  4804. 1664
  4805. ],
  4806. [
  4807. 6,
  4808. 1664
  4809. ],
  4810. [
  4811. 6,
  4812. 1664
  4813. ],
  4814. [
  4815. 6,
  4816. 1664
  4817. ],
  4818. [
  4819. 6,
  4820. 1664
  4821. ],
  4822. [
  4823. 6,
  4824. 1664
  4825. ],
  4826. [
  4827. 8,
  4828. 448
  4829. ],
  4830. [
  4831. 8,
  4832. 448
  4833. ],
  4834. [
  4835. 8,
  4836. 512
  4837. ],
  4838. [
  4839. 8,
  4840. 512
  4841. ],
  4842. [
  4843. 9,
  4844. 704
  4845. ],
  4846. [
  4847. 9,
  4848. 768
  4849. ],
  4850. [
  4851. 8,
  4852. 640
  4853. ],
  4854. [
  4855. 8,
  4856. 640
  4857. ],
  4858. [
  4859. 8,
  4860. 576
  4861. ],
  4862. [
  4863. 8,
  4864. 576
  4865. ],
  4866. [
  4867. 9,
  4868. 832
  4869. ],
  4870. [
  4871. 9,
  4872. 896
  4873. ],
  4874. [
  4875. 9,
  4876. 960
  4877. ],
  4878. [
  4879. 9,
  4880. 1024
  4881. ],
  4882. [
  4883. 9,
  4884. 1088
  4885. ],
  4886. [
  4887. 9,
  4888. 1152
  4889. ],
  4890. [
  4891. 9,
  4892. 1216
  4893. ],
  4894. [
  4895. 9,
  4896. 1280
  4897. ],
  4898. [
  4899. 9,
  4900. 1344
  4901. ],
  4902. [
  4903. 9,
  4904. 1408
  4905. ],
  4906. [
  4907. 7,
  4908. 256
  4909. ],
  4910. [
  4911. 7,
  4912. 256
  4913. ],
  4914. [
  4915. 7,
  4916. 256
  4917. ],
  4918. [
  4919. 7,
  4920. 256
  4921. ],
  4922. [
  4923. 4,
  4924. 2
  4925. ],
  4926. [
  4927. 4,
  4928. 2
  4929. ],
  4930. [
  4931. 4,
  4932. 2
  4933. ],
  4934. [
  4935. 4,
  4936. 2
  4937. ],
  4938. [
  4939. 4,
  4940. 2
  4941. ],
  4942. [
  4943. 4,
  4944. 2
  4945. ],
  4946. [
  4947. 4,
  4948. 2
  4949. ],
  4950. [
  4951. 4,
  4952. 2
  4953. ],
  4954. [
  4955. 4,
  4956. 2
  4957. ],
  4958. [
  4959. 4,
  4960. 2
  4961. ],
  4962. [
  4963. 4,
  4964. 2
  4965. ],
  4966. [
  4967. 4,
  4968. 2
  4969. ],
  4970. [
  4971. 4,
  4972. 2
  4973. ],
  4974. [
  4975. 4,
  4976. 2
  4977. ],
  4978. [
  4979. 4,
  4980. 2
  4981. ],
  4982. [
  4983. 4,
  4984. 2
  4985. ],
  4986. [
  4987. 4,
  4988. 2
  4989. ],
  4990. [
  4991. 4,
  4992. 2
  4993. ],
  4994. [
  4995. 4,
  4996. 2
  4997. ],
  4998. [
  4999. 4,
  5000. 2
  5001. ],
  5002. [
  5003. 4,
  5004. 2
  5005. ],
  5006. [
  5007. 4,
  5008. 2
  5009. ],
  5010. [
  5011. 4,
  5012. 2
  5013. ],
  5014. [
  5015. 4,
  5016. 2
  5017. ],
  5018. [
  5019. 4,
  5020. 2
  5021. ],
  5022. [
  5023. 4,
  5024. 2
  5025. ],
  5026. [
  5027. 4,
  5028. 2
  5029. ],
  5030. [
  5031. 4,
  5032. 2
  5033. ],
  5034. [
  5035. 4,
  5036. 2
  5037. ],
  5038. [
  5039. 4,
  5040. 2
  5041. ],
  5042. [
  5043. 4,
  5044. 2
  5045. ],
  5046. [
  5047. 4,
  5048. 2
  5049. ],
  5050. [
  5051. 4,
  5052. 3
  5053. ],
  5054. [
  5055. 4,
  5056. 3
  5057. ],
  5058. [
  5059. 4,
  5060. 3
  5061. ],
  5062. [
  5063. 4,
  5064. 3
  5065. ],
  5066. [
  5067. 4,
  5068. 3
  5069. ],
  5070. [
  5071. 4,
  5072. 3
  5073. ],
  5074. [
  5075. 4,
  5076. 3
  5077. ],
  5078. [
  5079. 4,
  5080. 3
  5081. ],
  5082. [
  5083. 4,
  5084. 3
  5085. ],
  5086. [
  5087. 4,
  5088. 3
  5089. ],
  5090. [
  5091. 4,
  5092. 3
  5093. ],
  5094. [
  5095. 4,
  5096. 3
  5097. ],
  5098. [
  5099. 4,
  5100. 3
  5101. ],
  5102. [
  5103. 4,
  5104. 3
  5105. ],
  5106. [
  5107. 4,
  5108. 3
  5109. ],
  5110. [
  5111. 4,
  5112. 3
  5113. ],
  5114. [
  5115. 4,
  5116. 3
  5117. ],
  5118. [
  5119. 4,
  5120. 3
  5121. ],
  5122. [
  5123. 4,
  5124. 3
  5125. ],
  5126. [
  5127. 4,
  5128. 3
  5129. ],
  5130. [
  5131. 4,
  5132. 3
  5133. ],
  5134. [
  5135. 4,
  5136. 3
  5137. ],
  5138. [
  5139. 4,
  5140. 3
  5141. ],
  5142. [
  5143. 4,
  5144. 3
  5145. ],
  5146. [
  5147. 4,
  5148. 3
  5149. ],
  5150. [
  5151. 4,
  5152. 3
  5153. ],
  5154. [
  5155. 4,
  5156. 3
  5157. ],
  5158. [
  5159. 4,
  5160. 3
  5161. ],
  5162. [
  5163. 4,
  5164. 3
  5165. ],
  5166. [
  5167. 4,
  5168. 3
  5169. ],
  5170. [
  5171. 4,
  5172. 3
  5173. ],
  5174. [
  5175. 4,
  5176. 3
  5177. ],
  5178. [
  5179. 5,
  5180. 128
  5181. ],
  5182. [
  5183. 5,
  5184. 128
  5185. ],
  5186. [
  5187. 5,
  5188. 128
  5189. ],
  5190. [
  5191. 5,
  5192. 128
  5193. ],
  5194. [
  5195. 5,
  5196. 128
  5197. ],
  5198. [
  5199. 5,
  5200. 128
  5201. ],
  5202. [
  5203. 5,
  5204. 128
  5205. ],
  5206. [
  5207. 5,
  5208. 128
  5209. ],
  5210. [
  5211. 5,
  5212. 128
  5213. ],
  5214. [
  5215. 5,
  5216. 128
  5217. ],
  5218. [
  5219. 5,
  5220. 128
  5221. ],
  5222. [
  5223. 5,
  5224. 128
  5225. ],
  5226. [
  5227. 5,
  5228. 128
  5229. ],
  5230. [
  5231. 5,
  5232. 128
  5233. ],
  5234. [
  5235. 5,
  5236. 128
  5237. ],
  5238. [
  5239. 5,
  5240. 128
  5241. ],
  5242. [
  5243. 5,
  5244. 8
  5245. ],
  5246. [
  5247. 5,
  5248. 8
  5249. ],
  5250. [
  5251. 5,
  5252. 8
  5253. ],
  5254. [
  5255. 5,
  5256. 8
  5257. ],
  5258. [
  5259. 5,
  5260. 8
  5261. ],
  5262. [
  5263. 5,
  5264. 8
  5265. ],
  5266. [
  5267. 5,
  5268. 8
  5269. ],
  5270. [
  5271. 5,
  5272. 8
  5273. ],
  5274. [
  5275. 5,
  5276. 8
  5277. ],
  5278. [
  5279. 5,
  5280. 8
  5281. ],
  5282. [
  5283. 5,
  5284. 8
  5285. ],
  5286. [
  5287. 5,
  5288. 8
  5289. ],
  5290. [
  5291. 5,
  5292. 8
  5293. ],
  5294. [
  5295. 5,
  5296. 8
  5297. ],
  5298. [
  5299. 5,
  5300. 8
  5301. ],
  5302. [
  5303. 5,
  5304. 8
  5305. ],
  5306. [
  5307. 5,
  5308. 9
  5309. ],
  5310. [
  5311. 5,
  5312. 9
  5313. ],
  5314. [
  5315. 5,
  5316. 9
  5317. ],
  5318. [
  5319. 5,
  5320. 9
  5321. ],
  5322. [
  5323. 5,
  5324. 9
  5325. ],
  5326. [
  5327. 5,
  5328. 9
  5329. ],
  5330. [
  5331. 5,
  5332. 9
  5333. ],
  5334. [
  5335. 5,
  5336. 9
  5337. ],
  5338. [
  5339. 5,
  5340. 9
  5341. ],
  5342. [
  5343. 5,
  5344. 9
  5345. ],
  5346. [
  5347. 5,
  5348. 9
  5349. ],
  5350. [
  5351. 5,
  5352. 9
  5353. ],
  5354. [
  5355. 5,
  5356. 9
  5357. ],
  5358. [
  5359. 5,
  5360. 9
  5361. ],
  5362. [
  5363. 5,
  5364. 9
  5365. ],
  5366. [
  5367. 5,
  5368. 9
  5369. ],
  5370. [
  5371. 6,
  5372. 16
  5373. ],
  5374. [
  5375. 6,
  5376. 16
  5377. ],
  5378. [
  5379. 6,
  5380. 16
  5381. ],
  5382. [
  5383. 6,
  5384. 16
  5385. ],
  5386. [
  5387. 6,
  5388. 16
  5389. ],
  5390. [
  5391. 6,
  5392. 16
  5393. ],
  5394. [
  5395. 6,
  5396. 16
  5397. ],
  5398. [
  5399. 6,
  5400. 16
  5401. ],
  5402. [
  5403. 6,
  5404. 17
  5405. ],
  5406. [
  5407. 6,
  5408. 17
  5409. ],
  5410. [
  5411. 6,
  5412. 17
  5413. ],
  5414. [
  5415. 6,
  5416. 17
  5417. ],
  5418. [
  5419. 6,
  5420. 17
  5421. ],
  5422. [
  5423. 6,
  5424. 17
  5425. ],
  5426. [
  5427. 6,
  5428. 17
  5429. ],
  5430. [
  5431. 6,
  5432. 17
  5433. ],
  5434. [
  5435. 4,
  5436. 4
  5437. ],
  5438. [
  5439. 4,
  5440. 4
  5441. ],
  5442. [
  5443. 4,
  5444. 4
  5445. ],
  5446. [
  5447. 4,
  5448. 4
  5449. ],
  5450. [
  5451. 4,
  5452. 4
  5453. ],
  5454. [
  5455. 4,
  5456. 4
  5457. ],
  5458. [
  5459. 4,
  5460. 4
  5461. ],
  5462. [
  5463. 4,
  5464. 4
  5465. ],
  5466. [
  5467. 4,
  5468. 4
  5469. ],
  5470. [
  5471. 4,
  5472. 4
  5473. ],
  5474. [
  5475. 4,
  5476. 4
  5477. ],
  5478. [
  5479. 4,
  5480. 4
  5481. ],
  5482. [
  5483. 4,
  5484. 4
  5485. ],
  5486. [
  5487. 4,
  5488. 4
  5489. ],
  5490. [
  5491. 4,
  5492. 4
  5493. ],
  5494. [
  5495. 4,
  5496. 4
  5497. ],
  5498. [
  5499. 4,
  5500. 4
  5501. ],
  5502. [
  5503. 4,
  5504. 4
  5505. ],
  5506. [
  5507. 4,
  5508. 4
  5509. ],
  5510. [
  5511. 4,
  5512. 4
  5513. ],
  5514. [
  5515. 4,
  5516. 4
  5517. ],
  5518. [
  5519. 4,
  5520. 4
  5521. ],
  5522. [
  5523. 4,
  5524. 4
  5525. ],
  5526. [
  5527. 4,
  5528. 4
  5529. ],
  5530. [
  5531. 4,
  5532. 4
  5533. ],
  5534. [
  5535. 4,
  5536. 4
  5537. ],
  5538. [
  5539. 4,
  5540. 4
  5541. ],
  5542. [
  5543. 4,
  5544. 4
  5545. ],
  5546. [
  5547. 4,
  5548. 4
  5549. ],
  5550. [
  5551. 4,
  5552. 4
  5553. ],
  5554. [
  5555. 4,
  5556. 4
  5557. ],
  5558. [
  5559. 4,
  5560. 4
  5561. ],
  5562. [
  5563. 4,
  5564. 5
  5565. ],
  5566. [
  5567. 4,
  5568. 5
  5569. ],
  5570. [
  5571. 4,
  5572. 5
  5573. ],
  5574. [
  5575. 4,
  5576. 5
  5577. ],
  5578. [
  5579. 4,
  5580. 5
  5581. ],
  5582. [
  5583. 4,
  5584. 5
  5585. ],
  5586. [
  5587. 4,
  5588. 5
  5589. ],
  5590. [
  5591. 4,
  5592. 5
  5593. ],
  5594. [
  5595. 4,
  5596. 5
  5597. ],
  5598. [
  5599. 4,
  5600. 5
  5601. ],
  5602. [
  5603. 4,
  5604. 5
  5605. ],
  5606. [
  5607. 4,
  5608. 5
  5609. ],
  5610. [
  5611. 4,
  5612. 5
  5613. ],
  5614. [
  5615. 4,
  5616. 5
  5617. ],
  5618. [
  5619. 4,
  5620. 5
  5621. ],
  5622. [
  5623. 4,
  5624. 5
  5625. ],
  5626. [
  5627. 4,
  5628. 5
  5629. ],
  5630. [
  5631. 4,
  5632. 5
  5633. ],
  5634. [
  5635. 4,
  5636. 5
  5637. ],
  5638. [
  5639. 4,
  5640. 5
  5641. ],
  5642. [
  5643. 4,
  5644. 5
  5645. ],
  5646. [
  5647. 4,
  5648. 5
  5649. ],
  5650. [
  5651. 4,
  5652. 5
  5653. ],
  5654. [
  5655. 4,
  5656. 5
  5657. ],
  5658. [
  5659. 4,
  5660. 5
  5661. ],
  5662. [
  5663. 4,
  5664. 5
  5665. ],
  5666. [
  5667. 4,
  5668. 5
  5669. ],
  5670. [
  5671. 4,
  5672. 5
  5673. ],
  5674. [
  5675. 4,
  5676. 5
  5677. ],
  5678. [
  5679. 4,
  5680. 5
  5681. ],
  5682. [
  5683. 4,
  5684. 5
  5685. ],
  5686. [
  5687. 4,
  5688. 5
  5689. ],
  5690. [
  5691. 6,
  5692. 14
  5693. ],
  5694. [
  5695. 6,
  5696. 14
  5697. ],
  5698. [
  5699. 6,
  5700. 14
  5701. ],
  5702. [
  5703. 6,
  5704. 14
  5705. ],
  5706. [
  5707. 6,
  5708. 14
  5709. ],
  5710. [
  5711. 6,
  5712. 14
  5713. ],
  5714. [
  5715. 6,
  5716. 14
  5717. ],
  5718. [
  5719. 6,
  5720. 14
  5721. ],
  5722. [
  5723. 6,
  5724. 15
  5725. ],
  5726. [
  5727. 6,
  5728. 15
  5729. ],
  5730. [
  5731. 6,
  5732. 15
  5733. ],
  5734. [
  5735. 6,
  5736. 15
  5737. ],
  5738. [
  5739. 6,
  5740. 15
  5741. ],
  5742. [
  5743. 6,
  5744. 15
  5745. ],
  5746. [
  5747. 6,
  5748. 15
  5749. ],
  5750. [
  5751. 6,
  5752. 15
  5753. ],
  5754. [
  5755. 5,
  5756. 64
  5757. ],
  5758. [
  5759. 5,
  5760. 64
  5761. ],
  5762. [
  5763. 5,
  5764. 64
  5765. ],
  5766. [
  5767. 5,
  5768. 64
  5769. ],
  5770. [
  5771. 5,
  5772. 64
  5773. ],
  5774. [
  5775. 5,
  5776. 64
  5777. ],
  5778. [
  5779. 5,
  5780. 64
  5781. ],
  5782. [
  5783. 5,
  5784. 64
  5785. ],
  5786. [
  5787. 5,
  5788. 64
  5789. ],
  5790. [
  5791. 5,
  5792. 64
  5793. ],
  5794. [
  5795. 5,
  5796. 64
  5797. ],
  5798. [
  5799. 5,
  5800. 64
  5801. ],
  5802. [
  5803. 5,
  5804. 64
  5805. ],
  5806. [
  5807. 5,
  5808. 64
  5809. ],
  5810. [
  5811. 5,
  5812. 64
  5813. ],
  5814. [
  5815. 5,
  5816. 64
  5817. ],
  5818. [
  5819. 4,
  5820. 6
  5821. ],
  5822. [
  5823. 4,
  5824. 6
  5825. ],
  5826. [
  5827. 4,
  5828. 6
  5829. ],
  5830. [
  5831. 4,
  5832. 6
  5833. ],
  5834. [
  5835. 4,
  5836. 6
  5837. ],
  5838. [
  5839. 4,
  5840. 6
  5841. ],
  5842. [
  5843. 4,
  5844. 6
  5845. ],
  5846. [
  5847. 4,
  5848. 6
  5849. ],
  5850. [
  5851. 4,
  5852. 6
  5853. ],
  5854. [
  5855. 4,
  5856. 6
  5857. ],
  5858. [
  5859. 4,
  5860. 6
  5861. ],
  5862. [
  5863. 4,
  5864. 6
  5865. ],
  5866. [
  5867. 4,
  5868. 6
  5869. ],
  5870. [
  5871. 4,
  5872. 6
  5873. ],
  5874. [
  5875. 4,
  5876. 6
  5877. ],
  5878. [
  5879. 4,
  5880. 6
  5881. ],
  5882. [
  5883. 4,
  5884. 6
  5885. ],
  5886. [
  5887. 4,
  5888. 6
  5889. ],
  5890. [
  5891. 4,
  5892. 6
  5893. ],
  5894. [
  5895. 4,
  5896. 6
  5897. ],
  5898. [
  5899. 4,
  5900. 6
  5901. ],
  5902. [
  5903. 4,
  5904. 6
  5905. ],
  5906. [
  5907. 4,
  5908. 6
  5909. ],
  5910. [
  5911. 4,
  5912. 6
  5913. ],
  5914. [
  5915. 4,
  5916. 6
  5917. ],
  5918. [
  5919. 4,
  5920. 6
  5921. ],
  5922. [
  5923. 4,
  5924. 6
  5925. ],
  5926. [
  5927. 4,
  5928. 6
  5929. ],
  5930. [
  5931. 4,
  5932. 6
  5933. ],
  5934. [
  5935. 4,
  5936. 6
  5937. ],
  5938. [
  5939. 4,
  5940. 6
  5941. ],
  5942. [
  5943. 4,
  5944. 6
  5945. ],
  5946. [
  5947. 4,
  5948. 7
  5949. ],
  5950. [
  5951. 4,
  5952. 7
  5953. ],
  5954. [
  5955. 4,
  5956. 7
  5957. ],
  5958. [
  5959. 4,
  5960. 7
  5961. ],
  5962. [
  5963. 4,
  5964. 7
  5965. ],
  5966. [
  5967. 4,
  5968. 7
  5969. ],
  5970. [
  5971. 4,
  5972. 7
  5973. ],
  5974. [
  5975. 4,
  5976. 7
  5977. ],
  5978. [
  5979. 4,
  5980. 7
  5981. ],
  5982. [
  5983. 4,
  5984. 7
  5985. ],
  5986. [
  5987. 4,
  5988. 7
  5989. ],
  5990. [
  5991. 4,
  5992. 7
  5993. ],
  5994. [
  5995. 4,
  5996. 7
  5997. ],
  5998. [
  5999. 4,
  6000. 7
  6001. ],
  6002. [
  6003. 4,
  6004. 7
  6005. ],
  6006. [
  6007. 4,
  6008. 7
  6009. ],
  6010. [
  6011. 4,
  6012. 7
  6013. ],
  6014. [
  6015. 4,
  6016. 7
  6017. ],
  6018. [
  6019. 4,
  6020. 7
  6021. ],
  6022. [
  6023. 4,
  6024. 7
  6025. ],
  6026. [
  6027. 4,
  6028. 7
  6029. ],
  6030. [
  6031. 4,
  6032. 7
  6033. ],
  6034. [
  6035. 4,
  6036. 7
  6037. ],
  6038. [
  6039. 4,
  6040. 7
  6041. ],
  6042. [
  6043. 4,
  6044. 7
  6045. ],
  6046. [
  6047. 4,
  6048. 7
  6049. ],
  6050. [
  6051. 4,
  6052. 7
  6053. ],
  6054. [
  6055. 4,
  6056. 7
  6057. ],
  6058. [
  6059. 4,
  6060. 7
  6061. ],
  6062. [
  6063. 4,
  6064. 7
  6065. ],
  6066. [
  6067. 4,
  6068. 7
  6069. ],
  6070. [
  6071. 4,
  6072. 7
  6073. ]
  6074. ];
  6075. var blackTable1 = [
  6076. [
  6077. -1,
  6078. -1
  6079. ],
  6080. [
  6081. -1,
  6082. -1
  6083. ],
  6084. [
  6085. 12,
  6086. ccittEOL
  6087. ],
  6088. [
  6089. 12,
  6090. ccittEOL
  6091. ],
  6092. [
  6093. -1,
  6094. -1
  6095. ],
  6096. [
  6097. -1,
  6098. -1
  6099. ],
  6100. [
  6101. -1,
  6102. -1
  6103. ],
  6104. [
  6105. -1,
  6106. -1
  6107. ],
  6108. [
  6109. -1,
  6110. -1
  6111. ],
  6112. [
  6113. -1,
  6114. -1
  6115. ],
  6116. [
  6117. -1,
  6118. -1
  6119. ],
  6120. [
  6121. -1,
  6122. -1
  6123. ],
  6124. [
  6125. -1,
  6126. -1
  6127. ],
  6128. [
  6129. -1,
  6130. -1
  6131. ],
  6132. [
  6133. -1,
  6134. -1
  6135. ],
  6136. [
  6137. -1,
  6138. -1
  6139. ],
  6140. [
  6141. -1,
  6142. -1
  6143. ],
  6144. [
  6145. -1,
  6146. -1
  6147. ],
  6148. [
  6149. -1,
  6150. -1
  6151. ],
  6152. [
  6153. -1,
  6154. -1
  6155. ],
  6156. [
  6157. -1,
  6158. -1
  6159. ],
  6160. [
  6161. -1,
  6162. -1
  6163. ],
  6164. [
  6165. -1,
  6166. -1
  6167. ],
  6168. [
  6169. -1,
  6170. -1
  6171. ],
  6172. [
  6173. -1,
  6174. -1
  6175. ],
  6176. [
  6177. -1,
  6178. -1
  6179. ],
  6180. [
  6181. -1,
  6182. -1
  6183. ],
  6184. [
  6185. -1,
  6186. -1
  6187. ],
  6188. [
  6189. -1,
  6190. -1
  6191. ],
  6192. [
  6193. -1,
  6194. -1
  6195. ],
  6196. [
  6197. -1,
  6198. -1
  6199. ],
  6200. [
  6201. -1,
  6202. -1
  6203. ],
  6204. [
  6205. 11,
  6206. 1792
  6207. ],
  6208. [
  6209. 11,
  6210. 1792
  6211. ],
  6212. [
  6213. 11,
  6214. 1792
  6215. ],
  6216. [
  6217. 11,
  6218. 1792
  6219. ],
  6220. [
  6221. 12,
  6222. 1984
  6223. ],
  6224. [
  6225. 12,
  6226. 1984
  6227. ],
  6228. [
  6229. 12,
  6230. 2048
  6231. ],
  6232. [
  6233. 12,
  6234. 2048
  6235. ],
  6236. [
  6237. 12,
  6238. 2112
  6239. ],
  6240. [
  6241. 12,
  6242. 2112
  6243. ],
  6244. [
  6245. 12,
  6246. 2176
  6247. ],
  6248. [
  6249. 12,
  6250. 2176
  6251. ],
  6252. [
  6253. 12,
  6254. 2240
  6255. ],
  6256. [
  6257. 12,
  6258. 2240
  6259. ],
  6260. [
  6261. 12,
  6262. 2304
  6263. ],
  6264. [
  6265. 12,
  6266. 2304
  6267. ],
  6268. [
  6269. 11,
  6270. 1856
  6271. ],
  6272. [
  6273. 11,
  6274. 1856
  6275. ],
  6276. [
  6277. 11,
  6278. 1856
  6279. ],
  6280. [
  6281. 11,
  6282. 1856
  6283. ],
  6284. [
  6285. 11,
  6286. 1920
  6287. ],
  6288. [
  6289. 11,
  6290. 1920
  6291. ],
  6292. [
  6293. 11,
  6294. 1920
  6295. ],
  6296. [
  6297. 11,
  6298. 1920
  6299. ],
  6300. [
  6301. 12,
  6302. 2368
  6303. ],
  6304. [
  6305. 12,
  6306. 2368
  6307. ],
  6308. [
  6309. 12,
  6310. 2432
  6311. ],
  6312. [
  6313. 12,
  6314. 2432
  6315. ],
  6316. [
  6317. 12,
  6318. 2496
  6319. ],
  6320. [
  6321. 12,
  6322. 2496
  6323. ],
  6324. [
  6325. 12,
  6326. 2560
  6327. ],
  6328. [
  6329. 12,
  6330. 2560
  6331. ],
  6332. [
  6333. 10,
  6334. 18
  6335. ],
  6336. [
  6337. 10,
  6338. 18
  6339. ],
  6340. [
  6341. 10,
  6342. 18
  6343. ],
  6344. [
  6345. 10,
  6346. 18
  6347. ],
  6348. [
  6349. 10,
  6350. 18
  6351. ],
  6352. [
  6353. 10,
  6354. 18
  6355. ],
  6356. [
  6357. 10,
  6358. 18
  6359. ],
  6360. [
  6361. 10,
  6362. 18
  6363. ],
  6364. [
  6365. 12,
  6366. 52
  6367. ],
  6368. [
  6369. 12,
  6370. 52
  6371. ],
  6372. [
  6373. 13,
  6374. 640
  6375. ],
  6376. [
  6377. 13,
  6378. 704
  6379. ],
  6380. [
  6381. 13,
  6382. 768
  6383. ],
  6384. [
  6385. 13,
  6386. 832
  6387. ],
  6388. [
  6389. 12,
  6390. 55
  6391. ],
  6392. [
  6393. 12,
  6394. 55
  6395. ],
  6396. [
  6397. 12,
  6398. 56
  6399. ],
  6400. [
  6401. 12,
  6402. 56
  6403. ],
  6404. [
  6405. 13,
  6406. 1280
  6407. ],
  6408. [
  6409. 13,
  6410. 1344
  6411. ],
  6412. [
  6413. 13,
  6414. 1408
  6415. ],
  6416. [
  6417. 13,
  6418. 1472
  6419. ],
  6420. [
  6421. 12,
  6422. 59
  6423. ],
  6424. [
  6425. 12,
  6426. 59
  6427. ],
  6428. [
  6429. 12,
  6430. 60
  6431. ],
  6432. [
  6433. 12,
  6434. 60
  6435. ],
  6436. [
  6437. 13,
  6438. 1536
  6439. ],
  6440. [
  6441. 13,
  6442. 1600
  6443. ],
  6444. [
  6445. 11,
  6446. 24
  6447. ],
  6448. [
  6449. 11,
  6450. 24
  6451. ],
  6452. [
  6453. 11,
  6454. 24
  6455. ],
  6456. [
  6457. 11,
  6458. 24
  6459. ],
  6460. [
  6461. 11,
  6462. 25
  6463. ],
  6464. [
  6465. 11,
  6466. 25
  6467. ],
  6468. [
  6469. 11,
  6470. 25
  6471. ],
  6472. [
  6473. 11,
  6474. 25
  6475. ],
  6476. [
  6477. 13,
  6478. 1664
  6479. ],
  6480. [
  6481. 13,
  6482. 1728
  6483. ],
  6484. [
  6485. 12,
  6486. 320
  6487. ],
  6488. [
  6489. 12,
  6490. 320
  6491. ],
  6492. [
  6493. 12,
  6494. 384
  6495. ],
  6496. [
  6497. 12,
  6498. 384
  6499. ],
  6500. [
  6501. 12,
  6502. 448
  6503. ],
  6504. [
  6505. 12,
  6506. 448
  6507. ],
  6508. [
  6509. 13,
  6510. 512
  6511. ],
  6512. [
  6513. 13,
  6514. 576
  6515. ],
  6516. [
  6517. 12,
  6518. 53
  6519. ],
  6520. [
  6521. 12,
  6522. 53
  6523. ],
  6524. [
  6525. 12,
  6526. 54
  6527. ],
  6528. [
  6529. 12,
  6530. 54
  6531. ],
  6532. [
  6533. 13,
  6534. 896
  6535. ],
  6536. [
  6537. 13,
  6538. 960
  6539. ],
  6540. [
  6541. 13,
  6542. 1024
  6543. ],
  6544. [
  6545. 13,
  6546. 1088
  6547. ],
  6548. [
  6549. 13,
  6550. 1152
  6551. ],
  6552. [
  6553. 13,
  6554. 1216
  6555. ],
  6556. [
  6557. 10,
  6558. 64
  6559. ],
  6560. [
  6561. 10,
  6562. 64
  6563. ],
  6564. [
  6565. 10,
  6566. 64
  6567. ],
  6568. [
  6569. 10,
  6570. 64
  6571. ],
  6572. [
  6573. 10,
  6574. 64
  6575. ],
  6576. [
  6577. 10,
  6578. 64
  6579. ],
  6580. [
  6581. 10,
  6582. 64
  6583. ],
  6584. [
  6585. 10,
  6586. 64
  6587. ]
  6588. ];
  6589. var blackTable2 = [
  6590. [
  6591. 8,
  6592. 13
  6593. ],
  6594. [
  6595. 8,
  6596. 13
  6597. ],
  6598. [
  6599. 8,
  6600. 13
  6601. ],
  6602. [
  6603. 8,
  6604. 13
  6605. ],
  6606. [
  6607. 8,
  6608. 13
  6609. ],
  6610. [
  6611. 8,
  6612. 13
  6613. ],
  6614. [
  6615. 8,
  6616. 13
  6617. ],
  6618. [
  6619. 8,
  6620. 13
  6621. ],
  6622. [
  6623. 8,
  6624. 13
  6625. ],
  6626. [
  6627. 8,
  6628. 13
  6629. ],
  6630. [
  6631. 8,
  6632. 13
  6633. ],
  6634. [
  6635. 8,
  6636. 13
  6637. ],
  6638. [
  6639. 8,
  6640. 13
  6641. ],
  6642. [
  6643. 8,
  6644. 13
  6645. ],
  6646. [
  6647. 8,
  6648. 13
  6649. ],
  6650. [
  6651. 8,
  6652. 13
  6653. ],
  6654. [
  6655. 11,
  6656. 23
  6657. ],
  6658. [
  6659. 11,
  6660. 23
  6661. ],
  6662. [
  6663. 12,
  6664. 50
  6665. ],
  6666. [
  6667. 12,
  6668. 51
  6669. ],
  6670. [
  6671. 12,
  6672. 44
  6673. ],
  6674. [
  6675. 12,
  6676. 45
  6677. ],
  6678. [
  6679. 12,
  6680. 46
  6681. ],
  6682. [
  6683. 12,
  6684. 47
  6685. ],
  6686. [
  6687. 12,
  6688. 57
  6689. ],
  6690. [
  6691. 12,
  6692. 58
  6693. ],
  6694. [
  6695. 12,
  6696. 61
  6697. ],
  6698. [
  6699. 12,
  6700. 256
  6701. ],
  6702. [
  6703. 10,
  6704. 16
  6705. ],
  6706. [
  6707. 10,
  6708. 16
  6709. ],
  6710. [
  6711. 10,
  6712. 16
  6713. ],
  6714. [
  6715. 10,
  6716. 16
  6717. ],
  6718. [
  6719. 10,
  6720. 17
  6721. ],
  6722. [
  6723. 10,
  6724. 17
  6725. ],
  6726. [
  6727. 10,
  6728. 17
  6729. ],
  6730. [
  6731. 10,
  6732. 17
  6733. ],
  6734. [
  6735. 12,
  6736. 48
  6737. ],
  6738. [
  6739. 12,
  6740. 49
  6741. ],
  6742. [
  6743. 12,
  6744. 62
  6745. ],
  6746. [
  6747. 12,
  6748. 63
  6749. ],
  6750. [
  6751. 12,
  6752. 30
  6753. ],
  6754. [
  6755. 12,
  6756. 31
  6757. ],
  6758. [
  6759. 12,
  6760. 32
  6761. ],
  6762. [
  6763. 12,
  6764. 33
  6765. ],
  6766. [
  6767. 12,
  6768. 40
  6769. ],
  6770. [
  6771. 12,
  6772. 41
  6773. ],
  6774. [
  6775. 11,
  6776. 22
  6777. ],
  6778. [
  6779. 11,
  6780. 22
  6781. ],
  6782. [
  6783. 8,
  6784. 14
  6785. ],
  6786. [
  6787. 8,
  6788. 14
  6789. ],
  6790. [
  6791. 8,
  6792. 14
  6793. ],
  6794. [
  6795. 8,
  6796. 14
  6797. ],
  6798. [
  6799. 8,
  6800. 14
  6801. ],
  6802. [
  6803. 8,
  6804. 14
  6805. ],
  6806. [
  6807. 8,
  6808. 14
  6809. ],
  6810. [
  6811. 8,
  6812. 14
  6813. ],
  6814. [
  6815. 8,
  6816. 14
  6817. ],
  6818. [
  6819. 8,
  6820. 14
  6821. ],
  6822. [
  6823. 8,
  6824. 14
  6825. ],
  6826. [
  6827. 8,
  6828. 14
  6829. ],
  6830. [
  6831. 8,
  6832. 14
  6833. ],
  6834. [
  6835. 8,
  6836. 14
  6837. ],
  6838. [
  6839. 8,
  6840. 14
  6841. ],
  6842. [
  6843. 8,
  6844. 14
  6845. ],
  6846. [
  6847. 7,
  6848. 10
  6849. ],
  6850. [
  6851. 7,
  6852. 10
  6853. ],
  6854. [
  6855. 7,
  6856. 10
  6857. ],
  6858. [
  6859. 7,
  6860. 10
  6861. ],
  6862. [
  6863. 7,
  6864. 10
  6865. ],
  6866. [
  6867. 7,
  6868. 10
  6869. ],
  6870. [
  6871. 7,
  6872. 10
  6873. ],
  6874. [
  6875. 7,
  6876. 10
  6877. ],
  6878. [
  6879. 7,
  6880. 10
  6881. ],
  6882. [
  6883. 7,
  6884. 10
  6885. ],
  6886. [
  6887. 7,
  6888. 10
  6889. ],
  6890. [
  6891. 7,
  6892. 10
  6893. ],
  6894. [
  6895. 7,
  6896. 10
  6897. ],
  6898. [
  6899. 7,
  6900. 10
  6901. ],
  6902. [
  6903. 7,
  6904. 10
  6905. ],
  6906. [
  6907. 7,
  6908. 10
  6909. ],
  6910. [
  6911. 7,
  6912. 10
  6913. ],
  6914. [
  6915. 7,
  6916. 10
  6917. ],
  6918. [
  6919. 7,
  6920. 10
  6921. ],
  6922. [
  6923. 7,
  6924. 10
  6925. ],
  6926. [
  6927. 7,
  6928. 10
  6929. ],
  6930. [
  6931. 7,
  6932. 10
  6933. ],
  6934. [
  6935. 7,
  6936. 10
  6937. ],
  6938. [
  6939. 7,
  6940. 10
  6941. ],
  6942. [
  6943. 7,
  6944. 10
  6945. ],
  6946. [
  6947. 7,
  6948. 10
  6949. ],
  6950. [
  6951. 7,
  6952. 10
  6953. ],
  6954. [
  6955. 7,
  6956. 10
  6957. ],
  6958. [
  6959. 7,
  6960. 10
  6961. ],
  6962. [
  6963. 7,
  6964. 10
  6965. ],
  6966. [
  6967. 7,
  6968. 10
  6969. ],
  6970. [
  6971. 7,
  6972. 10
  6973. ],
  6974. [
  6975. 7,
  6976. 11
  6977. ],
  6978. [
  6979. 7,
  6980. 11
  6981. ],
  6982. [
  6983. 7,
  6984. 11
  6985. ],
  6986. [
  6987. 7,
  6988. 11
  6989. ],
  6990. [
  6991. 7,
  6992. 11
  6993. ],
  6994. [
  6995. 7,
  6996. 11
  6997. ],
  6998. [
  6999. 7,
  7000. 11
  7001. ],
  7002. [
  7003. 7,
  7004. 11
  7005. ],
  7006. [
  7007. 7,
  7008. 11
  7009. ],
  7010. [
  7011. 7,
  7012. 11
  7013. ],
  7014. [
  7015. 7,
  7016. 11
  7017. ],
  7018. [
  7019. 7,
  7020. 11
  7021. ],
  7022. [
  7023. 7,
  7024. 11
  7025. ],
  7026. [
  7027. 7,
  7028. 11
  7029. ],
  7030. [
  7031. 7,
  7032. 11
  7033. ],
  7034. [
  7035. 7,
  7036. 11
  7037. ],
  7038. [
  7039. 7,
  7040. 11
  7041. ],
  7042. [
  7043. 7,
  7044. 11
  7045. ],
  7046. [
  7047. 7,
  7048. 11
  7049. ],
  7050. [
  7051. 7,
  7052. 11
  7053. ],
  7054. [
  7055. 7,
  7056. 11
  7057. ],
  7058. [
  7059. 7,
  7060. 11
  7061. ],
  7062. [
  7063. 7,
  7064. 11
  7065. ],
  7066. [
  7067. 7,
  7068. 11
  7069. ],
  7070. [
  7071. 7,
  7072. 11
  7073. ],
  7074. [
  7075. 7,
  7076. 11
  7077. ],
  7078. [
  7079. 7,
  7080. 11
  7081. ],
  7082. [
  7083. 7,
  7084. 11
  7085. ],
  7086. [
  7087. 7,
  7088. 11
  7089. ],
  7090. [
  7091. 7,
  7092. 11
  7093. ],
  7094. [
  7095. 7,
  7096. 11
  7097. ],
  7098. [
  7099. 7,
  7100. 11
  7101. ],
  7102. [
  7103. 9,
  7104. 15
  7105. ],
  7106. [
  7107. 9,
  7108. 15
  7109. ],
  7110. [
  7111. 9,
  7112. 15
  7113. ],
  7114. [
  7115. 9,
  7116. 15
  7117. ],
  7118. [
  7119. 9,
  7120. 15
  7121. ],
  7122. [
  7123. 9,
  7124. 15
  7125. ],
  7126. [
  7127. 9,
  7128. 15
  7129. ],
  7130. [
  7131. 9,
  7132. 15
  7133. ],
  7134. [
  7135. 12,
  7136. 128
  7137. ],
  7138. [
  7139. 12,
  7140. 192
  7141. ],
  7142. [
  7143. 12,
  7144. 26
  7145. ],
  7146. [
  7147. 12,
  7148. 27
  7149. ],
  7150. [
  7151. 12,
  7152. 28
  7153. ],
  7154. [
  7155. 12,
  7156. 29
  7157. ],
  7158. [
  7159. 11,
  7160. 19
  7161. ],
  7162. [
  7163. 11,
  7164. 19
  7165. ],
  7166. [
  7167. 11,
  7168. 20
  7169. ],
  7170. [
  7171. 11,
  7172. 20
  7173. ],
  7174. [
  7175. 12,
  7176. 34
  7177. ],
  7178. [
  7179. 12,
  7180. 35
  7181. ],
  7182. [
  7183. 12,
  7184. 36
  7185. ],
  7186. [
  7187. 12,
  7188. 37
  7189. ],
  7190. [
  7191. 12,
  7192. 38
  7193. ],
  7194. [
  7195. 12,
  7196. 39
  7197. ],
  7198. [
  7199. 11,
  7200. 21
  7201. ],
  7202. [
  7203. 11,
  7204. 21
  7205. ],
  7206. [
  7207. 12,
  7208. 42
  7209. ],
  7210. [
  7211. 12,
  7212. 43
  7213. ],
  7214. [
  7215. 10,
  7216. 0
  7217. ],
  7218. [
  7219. 10,
  7220. 0
  7221. ],
  7222. [
  7223. 10,
  7224. 0
  7225. ],
  7226. [
  7227. 10,
  7228. 0
  7229. ],
  7230. [
  7231. 7,
  7232. 12
  7233. ],
  7234. [
  7235. 7,
  7236. 12
  7237. ],
  7238. [
  7239. 7,
  7240. 12
  7241. ],
  7242. [
  7243. 7,
  7244. 12
  7245. ],
  7246. [
  7247. 7,
  7248. 12
  7249. ],
  7250. [
  7251. 7,
  7252. 12
  7253. ],
  7254. [
  7255. 7,
  7256. 12
  7257. ],
  7258. [
  7259. 7,
  7260. 12
  7261. ],
  7262. [
  7263. 7,
  7264. 12
  7265. ],
  7266. [
  7267. 7,
  7268. 12
  7269. ],
  7270. [
  7271. 7,
  7272. 12
  7273. ],
  7274. [
  7275. 7,
  7276. 12
  7277. ],
  7278. [
  7279. 7,
  7280. 12
  7281. ],
  7282. [
  7283. 7,
  7284. 12
  7285. ],
  7286. [
  7287. 7,
  7288. 12
  7289. ],
  7290. [
  7291. 7,
  7292. 12
  7293. ],
  7294. [
  7295. 7,
  7296. 12
  7297. ],
  7298. [
  7299. 7,
  7300. 12
  7301. ],
  7302. [
  7303. 7,
  7304. 12
  7305. ],
  7306. [
  7307. 7,
  7308. 12
  7309. ],
  7310. [
  7311. 7,
  7312. 12
  7313. ],
  7314. [
  7315. 7,
  7316. 12
  7317. ],
  7318. [
  7319. 7,
  7320. 12
  7321. ],
  7322. [
  7323. 7,
  7324. 12
  7325. ],
  7326. [
  7327. 7,
  7328. 12
  7329. ],
  7330. [
  7331. 7,
  7332. 12
  7333. ],
  7334. [
  7335. 7,
  7336. 12
  7337. ],
  7338. [
  7339. 7,
  7340. 12
  7341. ],
  7342. [
  7343. 7,
  7344. 12
  7345. ],
  7346. [
  7347. 7,
  7348. 12
  7349. ],
  7350. [
  7351. 7,
  7352. 12
  7353. ],
  7354. [
  7355. 7,
  7356. 12
  7357. ]
  7358. ];
  7359. var blackTable3 = [
  7360. [
  7361. -1,
  7362. -1
  7363. ],
  7364. [
  7365. -1,
  7366. -1
  7367. ],
  7368. [
  7369. -1,
  7370. -1
  7371. ],
  7372. [
  7373. -1,
  7374. -1
  7375. ],
  7376. [
  7377. 6,
  7378. 9
  7379. ],
  7380. [
  7381. 6,
  7382. 8
  7383. ],
  7384. [
  7385. 5,
  7386. 7
  7387. ],
  7388. [
  7389. 5,
  7390. 7
  7391. ],
  7392. [
  7393. 4,
  7394. 6
  7395. ],
  7396. [
  7397. 4,
  7398. 6
  7399. ],
  7400. [
  7401. 4,
  7402. 6
  7403. ],
  7404. [
  7405. 4,
  7406. 6
  7407. ],
  7408. [
  7409. 4,
  7410. 5
  7411. ],
  7412. [
  7413. 4,
  7414. 5
  7415. ],
  7416. [
  7417. 4,
  7418. 5
  7419. ],
  7420. [
  7421. 4,
  7422. 5
  7423. ],
  7424. [
  7425. 3,
  7426. 1
  7427. ],
  7428. [
  7429. 3,
  7430. 1
  7431. ],
  7432. [
  7433. 3,
  7434. 1
  7435. ],
  7436. [
  7437. 3,
  7438. 1
  7439. ],
  7440. [
  7441. 3,
  7442. 1
  7443. ],
  7444. [
  7445. 3,
  7446. 1
  7447. ],
  7448. [
  7449. 3,
  7450. 1
  7451. ],
  7452. [
  7453. 3,
  7454. 1
  7455. ],
  7456. [
  7457. 3,
  7458. 4
  7459. ],
  7460. [
  7461. 3,
  7462. 4
  7463. ],
  7464. [
  7465. 3,
  7466. 4
  7467. ],
  7468. [
  7469. 3,
  7470. 4
  7471. ],
  7472. [
  7473. 3,
  7474. 4
  7475. ],
  7476. [
  7477. 3,
  7478. 4
  7479. ],
  7480. [
  7481. 3,
  7482. 4
  7483. ],
  7484. [
  7485. 3,
  7486. 4
  7487. ],
  7488. [
  7489. 2,
  7490. 3
  7491. ],
  7492. [
  7493. 2,
  7494. 3
  7495. ],
  7496. [
  7497. 2,
  7498. 3
  7499. ],
  7500. [
  7501. 2,
  7502. 3
  7503. ],
  7504. [
  7505. 2,
  7506. 3
  7507. ],
  7508. [
  7509. 2,
  7510. 3
  7511. ],
  7512. [
  7513. 2,
  7514. 3
  7515. ],
  7516. [
  7517. 2,
  7518. 3
  7519. ],
  7520. [
  7521. 2,
  7522. 3
  7523. ],
  7524. [
  7525. 2,
  7526. 3
  7527. ],
  7528. [
  7529. 2,
  7530. 3
  7531. ],
  7532. [
  7533. 2,
  7534. 3
  7535. ],
  7536. [
  7537. 2,
  7538. 3
  7539. ],
  7540. [
  7541. 2,
  7542. 3
  7543. ],
  7544. [
  7545. 2,
  7546. 3
  7547. ],
  7548. [
  7549. 2,
  7550. 3
  7551. ],
  7552. [
  7553. 2,
  7554. 2
  7555. ],
  7556. [
  7557. 2,
  7558. 2
  7559. ],
  7560. [
  7561. 2,
  7562. 2
  7563. ],
  7564. [
  7565. 2,
  7566. 2
  7567. ],
  7568. [
  7569. 2,
  7570. 2
  7571. ],
  7572. [
  7573. 2,
  7574. 2
  7575. ],
  7576. [
  7577. 2,
  7578. 2
  7579. ],
  7580. [
  7581. 2,
  7582. 2
  7583. ],
  7584. [
  7585. 2,
  7586. 2
  7587. ],
  7588. [
  7589. 2,
  7590. 2
  7591. ],
  7592. [
  7593. 2,
  7594. 2
  7595. ],
  7596. [
  7597. 2,
  7598. 2
  7599. ],
  7600. [
  7601. 2,
  7602. 2
  7603. ],
  7604. [
  7605. 2,
  7606. 2
  7607. ],
  7608. [
  7609. 2,
  7610. 2
  7611. ],
  7612. [
  7613. 2,
  7614. 2
  7615. ]
  7616. ];
  7617. function CCITTFaxStream(str, maybeLength, params) {
  7618. this.str = str;
  7619. this.dict = str.dict;
  7620. params = params || Dict.empty;
  7621. this.encoding = params.get('K') || 0;
  7622. this.eoline = params.get('EndOfLine') || false;
  7623. this.byteAlign = params.get('EncodedByteAlign') || false;
  7624. this.columns = params.get('Columns') || 1728;
  7625. this.rows = params.get('Rows') || 0;
  7626. var eoblock = params.get('EndOfBlock');
  7627. if (eoblock === null || eoblock === undefined) {
  7628. eoblock = true;
  7629. }
  7630. this.eoblock = eoblock;
  7631. this.black = params.get('BlackIs1') || false;
  7632. this.codingLine = new Uint32Array(this.columns + 1);
  7633. this.refLine = new Uint32Array(this.columns + 2);
  7634. this.codingLine[0] = this.columns;
  7635. this.codingPos = 0;
  7636. this.row = 0;
  7637. this.nextLine2D = this.encoding < 0;
  7638. this.inputBits = 0;
  7639. this.inputBuf = 0;
  7640. this.outputBits = 0;
  7641. var code1;
  7642. while ((code1 = this.lookBits(12)) === 0) {
  7643. this.eatBits(1);
  7644. }
  7645. if (code1 === 1) {
  7646. this.eatBits(12);
  7647. }
  7648. if (this.encoding > 0) {
  7649. this.nextLine2D = !this.lookBits(1);
  7650. this.eatBits(1);
  7651. }
  7652. DecodeStream.call(this, maybeLength);
  7653. }
  7654. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  7655. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  7656. while (!this.eof) {
  7657. var c = this.lookChar();
  7658. this.ensureBuffer(this.bufferLength + 1);
  7659. this.buffer[this.bufferLength++] = c;
  7660. }
  7661. };
  7662. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  7663. var codingLine = this.codingLine;
  7664. var codingPos = this.codingPos;
  7665. if (a1 > codingLine[codingPos]) {
  7666. if (a1 > this.columns) {
  7667. info('row is wrong length');
  7668. this.err = true;
  7669. a1 = this.columns;
  7670. }
  7671. if (codingPos & 1 ^ blackPixels) {
  7672. ++codingPos;
  7673. }
  7674. codingLine[codingPos] = a1;
  7675. }
  7676. this.codingPos = codingPos;
  7677. };
  7678. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  7679. var codingLine = this.codingLine;
  7680. var codingPos = this.codingPos;
  7681. if (a1 > codingLine[codingPos]) {
  7682. if (a1 > this.columns) {
  7683. info('row is wrong length');
  7684. this.err = true;
  7685. a1 = this.columns;
  7686. }
  7687. if (codingPos & 1 ^ blackPixels) {
  7688. ++codingPos;
  7689. }
  7690. codingLine[codingPos] = a1;
  7691. } else if (a1 < codingLine[codingPos]) {
  7692. if (a1 < 0) {
  7693. info('invalid code');
  7694. this.err = true;
  7695. a1 = 0;
  7696. }
  7697. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  7698. --codingPos;
  7699. }
  7700. codingLine[codingPos] = a1;
  7701. }
  7702. this.codingPos = codingPos;
  7703. };
  7704. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  7705. var refLine = this.refLine;
  7706. var codingLine = this.codingLine;
  7707. var columns = this.columns;
  7708. var refPos, blackPixels, bits, i;
  7709. if (this.outputBits === 0) {
  7710. if (this.eof) {
  7711. return null;
  7712. }
  7713. this.err = false;
  7714. var code1, code2, code3;
  7715. if (this.nextLine2D) {
  7716. for (i = 0; codingLine[i] < columns; ++i) {
  7717. refLine[i] = codingLine[i];
  7718. }
  7719. refLine[i++] = columns;
  7720. refLine[i] = columns;
  7721. codingLine[0] = 0;
  7722. this.codingPos = 0;
  7723. refPos = 0;
  7724. blackPixels = 0;
  7725. while (codingLine[this.codingPos] < columns) {
  7726. code1 = this.getTwoDimCode();
  7727. switch (code1) {
  7728. case twoDimPass:
  7729. this.addPixels(refLine[refPos + 1], blackPixels);
  7730. if (refLine[refPos + 1] < columns) {
  7731. refPos += 2;
  7732. }
  7733. break;
  7734. case twoDimHoriz:
  7735. code1 = code2 = 0;
  7736. if (blackPixels) {
  7737. do {
  7738. code1 += code3 = this.getBlackCode();
  7739. } while (code3 >= 64);
  7740. do {
  7741. code2 += code3 = this.getWhiteCode();
  7742. } while (code3 >= 64);
  7743. } else {
  7744. do {
  7745. code1 += code3 = this.getWhiteCode();
  7746. } while (code3 >= 64);
  7747. do {
  7748. code2 += code3 = this.getBlackCode();
  7749. } while (code3 >= 64);
  7750. }
  7751. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7752. if (codingLine[this.codingPos] < columns) {
  7753. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  7754. }
  7755. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7756. refPos += 2;
  7757. }
  7758. break;
  7759. case twoDimVertR3:
  7760. this.addPixels(refLine[refPos] + 3, blackPixels);
  7761. blackPixels ^= 1;
  7762. if (codingLine[this.codingPos] < columns) {
  7763. ++refPos;
  7764. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7765. refPos += 2;
  7766. }
  7767. }
  7768. break;
  7769. case twoDimVertR2:
  7770. this.addPixels(refLine[refPos] + 2, blackPixels);
  7771. blackPixels ^= 1;
  7772. if (codingLine[this.codingPos] < columns) {
  7773. ++refPos;
  7774. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7775. refPos += 2;
  7776. }
  7777. }
  7778. break;
  7779. case twoDimVertR1:
  7780. this.addPixels(refLine[refPos] + 1, blackPixels);
  7781. blackPixels ^= 1;
  7782. if (codingLine[this.codingPos] < columns) {
  7783. ++refPos;
  7784. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7785. refPos += 2;
  7786. }
  7787. }
  7788. break;
  7789. case twoDimVert0:
  7790. this.addPixels(refLine[refPos], blackPixels);
  7791. blackPixels ^= 1;
  7792. if (codingLine[this.codingPos] < columns) {
  7793. ++refPos;
  7794. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7795. refPos += 2;
  7796. }
  7797. }
  7798. break;
  7799. case twoDimVertL3:
  7800. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  7801. blackPixels ^= 1;
  7802. if (codingLine[this.codingPos] < columns) {
  7803. if (refPos > 0) {
  7804. --refPos;
  7805. } else {
  7806. ++refPos;
  7807. }
  7808. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7809. refPos += 2;
  7810. }
  7811. }
  7812. break;
  7813. case twoDimVertL2:
  7814. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  7815. blackPixels ^= 1;
  7816. if (codingLine[this.codingPos] < columns) {
  7817. if (refPos > 0) {
  7818. --refPos;
  7819. } else {
  7820. ++refPos;
  7821. }
  7822. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7823. refPos += 2;
  7824. }
  7825. }
  7826. break;
  7827. case twoDimVertL1:
  7828. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  7829. blackPixels ^= 1;
  7830. if (codingLine[this.codingPos] < columns) {
  7831. if (refPos > 0) {
  7832. --refPos;
  7833. } else {
  7834. ++refPos;
  7835. }
  7836. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7837. refPos += 2;
  7838. }
  7839. }
  7840. break;
  7841. case ccittEOF:
  7842. this.addPixels(columns, 0);
  7843. this.eof = true;
  7844. break;
  7845. default:
  7846. info('bad 2d code');
  7847. this.addPixels(columns, 0);
  7848. this.err = true;
  7849. }
  7850. }
  7851. } else {
  7852. codingLine[0] = 0;
  7853. this.codingPos = 0;
  7854. blackPixels = 0;
  7855. while (codingLine[this.codingPos] < columns) {
  7856. code1 = 0;
  7857. if (blackPixels) {
  7858. do {
  7859. code1 += code3 = this.getBlackCode();
  7860. } while (code3 >= 64);
  7861. } else {
  7862. do {
  7863. code1 += code3 = this.getWhiteCode();
  7864. } while (code3 >= 64);
  7865. }
  7866. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7867. blackPixels ^= 1;
  7868. }
  7869. }
  7870. var gotEOL = false;
  7871. if (this.byteAlign) {
  7872. this.inputBits &= ~7;
  7873. }
  7874. if (!this.eoblock && this.row === this.rows - 1) {
  7875. this.eof = true;
  7876. } else {
  7877. code1 = this.lookBits(12);
  7878. if (this.eoline) {
  7879. while (code1 !== ccittEOF && code1 !== 1) {
  7880. this.eatBits(1);
  7881. code1 = this.lookBits(12);
  7882. }
  7883. } else {
  7884. while (code1 === 0) {
  7885. this.eatBits(1);
  7886. code1 = this.lookBits(12);
  7887. }
  7888. }
  7889. if (code1 === 1) {
  7890. this.eatBits(12);
  7891. gotEOL = true;
  7892. } else if (code1 === ccittEOF) {
  7893. this.eof = true;
  7894. }
  7895. }
  7896. if (!this.eof && this.encoding > 0) {
  7897. this.nextLine2D = !this.lookBits(1);
  7898. this.eatBits(1);
  7899. }
  7900. if (this.eoblock && gotEOL && this.byteAlign) {
  7901. code1 = this.lookBits(12);
  7902. if (code1 === 1) {
  7903. this.eatBits(12);
  7904. if (this.encoding > 0) {
  7905. this.lookBits(1);
  7906. this.eatBits(1);
  7907. }
  7908. if (this.encoding >= 0) {
  7909. for (i = 0; i < 4; ++i) {
  7910. code1 = this.lookBits(12);
  7911. if (code1 !== 1) {
  7912. info('bad rtc code: ' + code1);
  7913. }
  7914. this.eatBits(12);
  7915. if (this.encoding > 0) {
  7916. this.lookBits(1);
  7917. this.eatBits(1);
  7918. }
  7919. }
  7920. }
  7921. this.eof = true;
  7922. }
  7923. } else if (this.err && this.eoline) {
  7924. while (true) {
  7925. code1 = this.lookBits(13);
  7926. if (code1 === ccittEOF) {
  7927. this.eof = true;
  7928. return null;
  7929. }
  7930. if (code1 >> 1 === 1) {
  7931. break;
  7932. }
  7933. this.eatBits(1);
  7934. }
  7935. this.eatBits(12);
  7936. if (this.encoding > 0) {
  7937. this.eatBits(1);
  7938. this.nextLine2D = !(code1 & 1);
  7939. }
  7940. }
  7941. if (codingLine[0] > 0) {
  7942. this.outputBits = codingLine[this.codingPos = 0];
  7943. } else {
  7944. this.outputBits = codingLine[this.codingPos = 1];
  7945. }
  7946. this.row++;
  7947. }
  7948. var c;
  7949. if (this.outputBits >= 8) {
  7950. c = this.codingPos & 1 ? 0 : 0xFF;
  7951. this.outputBits -= 8;
  7952. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  7953. this.codingPos++;
  7954. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7955. }
  7956. } else {
  7957. bits = 8;
  7958. c = 0;
  7959. do {
  7960. if (this.outputBits > bits) {
  7961. c <<= bits;
  7962. if (!(this.codingPos & 1)) {
  7963. c |= 0xFF >> 8 - bits;
  7964. }
  7965. this.outputBits -= bits;
  7966. bits = 0;
  7967. } else {
  7968. c <<= this.outputBits;
  7969. if (!(this.codingPos & 1)) {
  7970. c |= 0xFF >> 8 - this.outputBits;
  7971. }
  7972. bits -= this.outputBits;
  7973. this.outputBits = 0;
  7974. if (codingLine[this.codingPos] < columns) {
  7975. this.codingPos++;
  7976. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7977. } else if (bits > 0) {
  7978. c <<= bits;
  7979. bits = 0;
  7980. }
  7981. }
  7982. } while (bits);
  7983. }
  7984. if (this.black) {
  7985. c ^= 0xFF;
  7986. }
  7987. return c;
  7988. };
  7989. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  7990. var limitValue = limit || 0;
  7991. for (var i = start; i <= end; ++i) {
  7992. var code = this.lookBits(i);
  7993. if (code === ccittEOF) {
  7994. return [
  7995. true,
  7996. 1,
  7997. false
  7998. ];
  7999. }
  8000. if (i < end) {
  8001. code <<= end - i;
  8002. }
  8003. if (!limitValue || code >= limitValue) {
  8004. var p = table[code - limitValue];
  8005. if (p[0] === i) {
  8006. this.eatBits(i);
  8007. return [
  8008. true,
  8009. p[1],
  8010. true
  8011. ];
  8012. }
  8013. }
  8014. }
  8015. return [
  8016. false,
  8017. 0,
  8018. false
  8019. ];
  8020. };
  8021. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  8022. var code = 0;
  8023. var p;
  8024. if (this.eoblock) {
  8025. code = this.lookBits(7);
  8026. p = twoDimTable[code];
  8027. if (p && p[0] > 0) {
  8028. this.eatBits(p[0]);
  8029. return p[1];
  8030. }
  8031. } else {
  8032. var result = this.findTableCode(1, 7, twoDimTable);
  8033. if (result[0] && result[2]) {
  8034. return result[1];
  8035. }
  8036. }
  8037. info('Bad two dim code');
  8038. return ccittEOF;
  8039. };
  8040. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  8041. var code = 0;
  8042. var p;
  8043. if (this.eoblock) {
  8044. code = this.lookBits(12);
  8045. if (code === ccittEOF) {
  8046. return 1;
  8047. }
  8048. if (code >> 5 === 0) {
  8049. p = whiteTable1[code];
  8050. } else {
  8051. p = whiteTable2[code >> 3];
  8052. }
  8053. if (p[0] > 0) {
  8054. this.eatBits(p[0]);
  8055. return p[1];
  8056. }
  8057. } else {
  8058. var result = this.findTableCode(1, 9, whiteTable2);
  8059. if (result[0]) {
  8060. return result[1];
  8061. }
  8062. result = this.findTableCode(11, 12, whiteTable1);
  8063. if (result[0]) {
  8064. return result[1];
  8065. }
  8066. }
  8067. info('bad white code');
  8068. this.eatBits(1);
  8069. return 1;
  8070. };
  8071. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  8072. var code, p;
  8073. if (this.eoblock) {
  8074. code = this.lookBits(13);
  8075. if (code === ccittEOF) {
  8076. return 1;
  8077. }
  8078. if (code >> 7 === 0) {
  8079. p = blackTable1[code];
  8080. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  8081. p = blackTable2[(code >> 1) - 64];
  8082. } else {
  8083. p = blackTable3[code >> 7];
  8084. }
  8085. if (p[0] > 0) {
  8086. this.eatBits(p[0]);
  8087. return p[1];
  8088. }
  8089. } else {
  8090. var result = this.findTableCode(2, 6, blackTable3);
  8091. if (result[0]) {
  8092. return result[1];
  8093. }
  8094. result = this.findTableCode(7, 12, blackTable2, 64);
  8095. if (result[0]) {
  8096. return result[1];
  8097. }
  8098. result = this.findTableCode(10, 13, blackTable1);
  8099. if (result[0]) {
  8100. return result[1];
  8101. }
  8102. }
  8103. info('bad black code');
  8104. this.eatBits(1);
  8105. return 1;
  8106. };
  8107. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  8108. var c;
  8109. while (this.inputBits < n) {
  8110. if ((c = this.str.getByte()) === -1) {
  8111. if (this.inputBits === 0) {
  8112. return ccittEOF;
  8113. }
  8114. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  8115. }
  8116. this.inputBuf = this.inputBuf << 8 | c;
  8117. this.inputBits += 8;
  8118. }
  8119. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  8120. };
  8121. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  8122. if ((this.inputBits -= n) < 0) {
  8123. this.inputBits = 0;
  8124. }
  8125. };
  8126. return CCITTFaxStream;
  8127. }();
  8128. var LZWStream = function LZWStreamClosure() {
  8129. function LZWStream(str, maybeLength, earlyChange) {
  8130. this.str = str;
  8131. this.dict = str.dict;
  8132. this.cachedData = 0;
  8133. this.bitsCached = 0;
  8134. var maxLzwDictionarySize = 4096;
  8135. var lzwState = {
  8136. earlyChange: earlyChange,
  8137. codeLength: 9,
  8138. nextCode: 258,
  8139. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  8140. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  8141. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  8142. currentSequence: new Uint8Array(maxLzwDictionarySize),
  8143. currentSequenceLength: 0
  8144. };
  8145. for (var i = 0; i < 256; ++i) {
  8146. lzwState.dictionaryValues[i] = i;
  8147. lzwState.dictionaryLengths[i] = 1;
  8148. }
  8149. this.lzwState = lzwState;
  8150. DecodeStream.call(this, maybeLength);
  8151. }
  8152. LZWStream.prototype = Object.create(DecodeStream.prototype);
  8153. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  8154. var bitsCached = this.bitsCached;
  8155. var cachedData = this.cachedData;
  8156. while (bitsCached < n) {
  8157. var c = this.str.getByte();
  8158. if (c === -1) {
  8159. this.eof = true;
  8160. return null;
  8161. }
  8162. cachedData = cachedData << 8 | c;
  8163. bitsCached += 8;
  8164. }
  8165. this.bitsCached = bitsCached -= n;
  8166. this.cachedData = cachedData;
  8167. this.lastCode = null;
  8168. return cachedData >>> bitsCached & (1 << n) - 1;
  8169. };
  8170. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  8171. var blockSize = 512;
  8172. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  8173. var i, j, q;
  8174. var lzwState = this.lzwState;
  8175. if (!lzwState) {
  8176. return;
  8177. }
  8178. var earlyChange = lzwState.earlyChange;
  8179. var nextCode = lzwState.nextCode;
  8180. var dictionaryValues = lzwState.dictionaryValues;
  8181. var dictionaryLengths = lzwState.dictionaryLengths;
  8182. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  8183. var codeLength = lzwState.codeLength;
  8184. var prevCode = lzwState.prevCode;
  8185. var currentSequence = lzwState.currentSequence;
  8186. var currentSequenceLength = lzwState.currentSequenceLength;
  8187. var decodedLength = 0;
  8188. var currentBufferLength = this.bufferLength;
  8189. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  8190. for (i = 0; i < blockSize; i++) {
  8191. var code = this.readBits(codeLength);
  8192. var hasPrev = currentSequenceLength > 0;
  8193. if (code < 256) {
  8194. currentSequence[0] = code;
  8195. currentSequenceLength = 1;
  8196. } else if (code >= 258) {
  8197. if (code < nextCode) {
  8198. currentSequenceLength = dictionaryLengths[code];
  8199. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  8200. currentSequence[j] = dictionaryValues[q];
  8201. q = dictionaryPrevCodes[q];
  8202. }
  8203. } else {
  8204. currentSequence[currentSequenceLength++] = currentSequence[0];
  8205. }
  8206. } else if (code === 256) {
  8207. codeLength = 9;
  8208. nextCode = 258;
  8209. currentSequenceLength = 0;
  8210. continue;
  8211. } else {
  8212. this.eof = true;
  8213. delete this.lzwState;
  8214. break;
  8215. }
  8216. if (hasPrev) {
  8217. dictionaryPrevCodes[nextCode] = prevCode;
  8218. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  8219. dictionaryValues[nextCode] = currentSequence[0];
  8220. nextCode++;
  8221. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  8222. }
  8223. prevCode = code;
  8224. decodedLength += currentSequenceLength;
  8225. if (estimatedDecodedSize < decodedLength) {
  8226. do {
  8227. estimatedDecodedSize += decodedSizeDelta;
  8228. } while (estimatedDecodedSize < decodedLength);
  8229. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  8230. }
  8231. for (j = 0; j < currentSequenceLength; j++) {
  8232. buffer[currentBufferLength++] = currentSequence[j];
  8233. }
  8234. }
  8235. lzwState.nextCode = nextCode;
  8236. lzwState.codeLength = codeLength;
  8237. lzwState.prevCode = prevCode;
  8238. lzwState.currentSequenceLength = currentSequenceLength;
  8239. this.bufferLength = currentBufferLength;
  8240. };
  8241. return LZWStream;
  8242. }();
  8243. var NullStream = function NullStreamClosure() {
  8244. function NullStream() {
  8245. Stream.call(this, new Uint8Array(0));
  8246. }
  8247. NullStream.prototype = Stream.prototype;
  8248. return NullStream;
  8249. }();
  8250. exports.Ascii85Stream = Ascii85Stream;
  8251. exports.AsciiHexStream = AsciiHexStream;
  8252. exports.CCITTFaxStream = CCITTFaxStream;
  8253. exports.DecryptStream = DecryptStream;
  8254. exports.DecodeStream = DecodeStream;
  8255. exports.FlateStream = FlateStream;
  8256. exports.Jbig2Stream = Jbig2Stream;
  8257. exports.JpegStream = JpegStream;
  8258. exports.JpxStream = JpxStream;
  8259. exports.NullStream = NullStream;
  8260. exports.PredictorStream = PredictorStream;
  8261. exports.RunLengthStream = RunLengthStream;
  8262. exports.Stream = Stream;
  8263. exports.StreamsSequenceStream = StreamsSequenceStream;
  8264. exports.StringStream = StringStream;
  8265. exports.LZWStream = LZWStream;
  8266. /***/ }),
  8267. /* 3 */
  8268. /***/ (function(module, exports, __w_pdfjs_require__) {
  8269. "use strict";
  8270. var sharedUtil = __w_pdfjs_require__(0);
  8271. var corePrimitives = __w_pdfjs_require__(1);
  8272. var coreFunction = __w_pdfjs_require__(6);
  8273. var error = sharedUtil.error;
  8274. var info = sharedUtil.info;
  8275. var isArray = sharedUtil.isArray;
  8276. var isString = sharedUtil.isString;
  8277. var shadow = sharedUtil.shadow;
  8278. var warn = sharedUtil.warn;
  8279. var isDict = corePrimitives.isDict;
  8280. var isName = corePrimitives.isName;
  8281. var isStream = corePrimitives.isStream;
  8282. var PDFFunction = coreFunction.PDFFunction;
  8283. var ColorSpace = function ColorSpaceClosure() {
  8284. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  8285. var COMPONENTS = 3;
  8286. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  8287. var xRatio = w1 / w2;
  8288. var yRatio = h1 / h2;
  8289. var i, j, py, newIndex = 0, oldIndex;
  8290. var xScaled = new Uint16Array(w2);
  8291. var w1Scanline = w1 * COMPONENTS;
  8292. for (i = 0; i < w2; i++) {
  8293. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  8294. }
  8295. for (i = 0; i < h2; i++) {
  8296. py = Math.floor(i * yRatio) * w1Scanline;
  8297. for (j = 0; j < w2; j++) {
  8298. oldIndex = py + xScaled[j];
  8299. dest[newIndex++] = src[oldIndex++];
  8300. dest[newIndex++] = src[oldIndex++];
  8301. dest[newIndex++] = src[oldIndex++];
  8302. newIndex += alpha01;
  8303. }
  8304. }
  8305. }
  8306. function ColorSpace() {
  8307. error('should not call ColorSpace constructor');
  8308. }
  8309. ColorSpace.prototype = {
  8310. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  8311. var rgb = new Uint8Array(3);
  8312. this.getRgbItem(src, srcOffset, rgb, 0);
  8313. return rgb;
  8314. },
  8315. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  8316. error('Should not call ColorSpace.getRgbItem');
  8317. },
  8318. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8319. error('Should not call ColorSpace.getRgbBuffer');
  8320. },
  8321. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  8322. error('Should not call ColorSpace.getOutputLength');
  8323. },
  8324. isPassthrough: function ColorSpace_isPassthrough(bits) {
  8325. return false;
  8326. },
  8327. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  8328. var count = originalWidth * originalHeight;
  8329. var rgbBuf = null;
  8330. var numComponentColors = 1 << bpc;
  8331. var needsResizing = originalHeight !== height || originalWidth !== width;
  8332. var i, ii;
  8333. if (this.isPassthrough(bpc)) {
  8334. rgbBuf = comps;
  8335. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  8336. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  8337. var key;
  8338. for (i = 0; i < numComponentColors; i++) {
  8339. allColors[i] = i;
  8340. }
  8341. var colorMap = new Uint8Array(numComponentColors * 3);
  8342. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  8343. var destPos, rgbPos;
  8344. if (!needsResizing) {
  8345. destPos = 0;
  8346. for (i = 0; i < count; ++i) {
  8347. key = comps[i] * 3;
  8348. dest[destPos++] = colorMap[key];
  8349. dest[destPos++] = colorMap[key + 1];
  8350. dest[destPos++] = colorMap[key + 2];
  8351. destPos += alpha01;
  8352. }
  8353. } else {
  8354. rgbBuf = new Uint8Array(count * 3);
  8355. rgbPos = 0;
  8356. for (i = 0; i < count; ++i) {
  8357. key = comps[i] * 3;
  8358. rgbBuf[rgbPos++] = colorMap[key];
  8359. rgbBuf[rgbPos++] = colorMap[key + 1];
  8360. rgbBuf[rgbPos++] = colorMap[key + 2];
  8361. }
  8362. }
  8363. } else {
  8364. if (!needsResizing) {
  8365. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  8366. } else {
  8367. rgbBuf = new Uint8Array(count * 3);
  8368. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  8369. }
  8370. }
  8371. if (rgbBuf) {
  8372. if (needsResizing) {
  8373. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  8374. } else {
  8375. rgbPos = 0;
  8376. destPos = 0;
  8377. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  8378. dest[destPos++] = rgbBuf[rgbPos++];
  8379. dest[destPos++] = rgbBuf[rgbPos++];
  8380. dest[destPos++] = rgbBuf[rgbPos++];
  8381. destPos += alpha01;
  8382. }
  8383. }
  8384. }
  8385. },
  8386. usesZeroToOneRange: true
  8387. };
  8388. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  8389. var IR = ColorSpace.parseToIR(cs, xref, res);
  8390. if (IR instanceof AlternateCS) {
  8391. return IR;
  8392. }
  8393. return ColorSpace.fromIR(IR);
  8394. };
  8395. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  8396. var name = isArray(IR) ? IR[0] : IR;
  8397. var whitePoint, blackPoint, gamma;
  8398. switch (name) {
  8399. case 'DeviceGrayCS':
  8400. return this.singletons.gray;
  8401. case 'DeviceRgbCS':
  8402. return this.singletons.rgb;
  8403. case 'DeviceCmykCS':
  8404. return this.singletons.cmyk;
  8405. case 'CalGrayCS':
  8406. whitePoint = IR[1];
  8407. blackPoint = IR[2];
  8408. gamma = IR[3];
  8409. return new CalGrayCS(whitePoint, blackPoint, gamma);
  8410. case 'CalRGBCS':
  8411. whitePoint = IR[1];
  8412. blackPoint = IR[2];
  8413. gamma = IR[3];
  8414. var matrix = IR[4];
  8415. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  8416. case 'PatternCS':
  8417. var basePatternCS = IR[1];
  8418. if (basePatternCS) {
  8419. basePatternCS = ColorSpace.fromIR(basePatternCS);
  8420. }
  8421. return new PatternCS(basePatternCS);
  8422. case 'IndexedCS':
  8423. var baseIndexedCS = IR[1];
  8424. var hiVal = IR[2];
  8425. var lookup = IR[3];
  8426. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  8427. case 'AlternateCS':
  8428. var numComps = IR[1];
  8429. var alt = IR[2];
  8430. var tintFnIR = IR[3];
  8431. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  8432. case 'LabCS':
  8433. whitePoint = IR[1];
  8434. blackPoint = IR[2];
  8435. var range = IR[3];
  8436. return new LabCS(whitePoint, blackPoint, range);
  8437. default:
  8438. error('Unknown name ' + name);
  8439. }
  8440. return null;
  8441. };
  8442. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  8443. if (isName(cs)) {
  8444. var colorSpaces = res.get('ColorSpace');
  8445. if (isDict(colorSpaces)) {
  8446. var refcs = colorSpaces.get(cs.name);
  8447. if (refcs) {
  8448. cs = refcs;
  8449. }
  8450. }
  8451. }
  8452. cs = xref.fetchIfRef(cs);
  8453. if (isName(cs)) {
  8454. switch (cs.name) {
  8455. case 'DeviceGray':
  8456. case 'G':
  8457. return 'DeviceGrayCS';
  8458. case 'DeviceRGB':
  8459. case 'RGB':
  8460. return 'DeviceRgbCS';
  8461. case 'DeviceCMYK':
  8462. case 'CMYK':
  8463. return 'DeviceCmykCS';
  8464. case 'Pattern':
  8465. return [
  8466. 'PatternCS',
  8467. null
  8468. ];
  8469. default:
  8470. error('unrecognized colorspace ' + cs.name);
  8471. }
  8472. } else if (isArray(cs)) {
  8473. var mode = xref.fetchIfRef(cs[0]).name;
  8474. var numComps, params, alt, whitePoint, blackPoint, gamma;
  8475. switch (mode) {
  8476. case 'DeviceGray':
  8477. case 'G':
  8478. return 'DeviceGrayCS';
  8479. case 'DeviceRGB':
  8480. case 'RGB':
  8481. return 'DeviceRgbCS';
  8482. case 'DeviceCMYK':
  8483. case 'CMYK':
  8484. return 'DeviceCmykCS';
  8485. case 'CalGray':
  8486. params = xref.fetchIfRef(cs[1]);
  8487. whitePoint = params.getArray('WhitePoint');
  8488. blackPoint = params.getArray('BlackPoint');
  8489. gamma = params.get('Gamma');
  8490. return [
  8491. 'CalGrayCS',
  8492. whitePoint,
  8493. blackPoint,
  8494. gamma
  8495. ];
  8496. case 'CalRGB':
  8497. params = xref.fetchIfRef(cs[1]);
  8498. whitePoint = params.getArray('WhitePoint');
  8499. blackPoint = params.getArray('BlackPoint');
  8500. gamma = params.getArray('Gamma');
  8501. var matrix = params.getArray('Matrix');
  8502. return [
  8503. 'CalRGBCS',
  8504. whitePoint,
  8505. blackPoint,
  8506. gamma,
  8507. matrix
  8508. ];
  8509. case 'ICCBased':
  8510. var stream = xref.fetchIfRef(cs[1]);
  8511. var dict = stream.dict;
  8512. numComps = dict.get('N');
  8513. alt = dict.get('Alternate');
  8514. if (alt) {
  8515. var altIR = ColorSpace.parseToIR(alt, xref, res);
  8516. var altCS = ColorSpace.fromIR(altIR);
  8517. if (altCS.numComps === numComps) {
  8518. return altIR;
  8519. }
  8520. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  8521. }
  8522. if (numComps === 1) {
  8523. return 'DeviceGrayCS';
  8524. } else if (numComps === 3) {
  8525. return 'DeviceRgbCS';
  8526. } else if (numComps === 4) {
  8527. return 'DeviceCmykCS';
  8528. }
  8529. break;
  8530. case 'Pattern':
  8531. var basePatternCS = cs[1] || null;
  8532. if (basePatternCS) {
  8533. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  8534. }
  8535. return [
  8536. 'PatternCS',
  8537. basePatternCS
  8538. ];
  8539. case 'Indexed':
  8540. case 'I':
  8541. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  8542. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  8543. var lookup = xref.fetchIfRef(cs[3]);
  8544. if (isStream(lookup)) {
  8545. lookup = lookup.getBytes();
  8546. }
  8547. return [
  8548. 'IndexedCS',
  8549. baseIndexedCS,
  8550. hiVal,
  8551. lookup
  8552. ];
  8553. case 'Separation':
  8554. case 'DeviceN':
  8555. var name = xref.fetchIfRef(cs[1]);
  8556. numComps = isArray(name) ? name.length : 1;
  8557. alt = ColorSpace.parseToIR(cs[2], xref, res);
  8558. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  8559. return [
  8560. 'AlternateCS',
  8561. numComps,
  8562. alt,
  8563. tintFnIR
  8564. ];
  8565. case 'Lab':
  8566. params = xref.fetchIfRef(cs[1]);
  8567. whitePoint = params.getArray('WhitePoint');
  8568. blackPoint = params.getArray('BlackPoint');
  8569. var range = params.getArray('Range');
  8570. return [
  8571. 'LabCS',
  8572. whitePoint,
  8573. blackPoint,
  8574. range
  8575. ];
  8576. default:
  8577. error('unimplemented color space object "' + mode + '"');
  8578. }
  8579. } else {
  8580. error('unrecognized color space object: "' + cs + '"');
  8581. }
  8582. return null;
  8583. };
  8584. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  8585. if (!isArray(decode)) {
  8586. return true;
  8587. }
  8588. if (n * 2 !== decode.length) {
  8589. warn('The decode map is not the correct length');
  8590. return true;
  8591. }
  8592. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  8593. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  8594. return false;
  8595. }
  8596. }
  8597. return true;
  8598. };
  8599. ColorSpace.singletons = {
  8600. get gray() {
  8601. return shadow(this, 'gray', new DeviceGrayCS());
  8602. },
  8603. get rgb() {
  8604. return shadow(this, 'rgb', new DeviceRgbCS());
  8605. },
  8606. get cmyk() {
  8607. return shadow(this, 'cmyk', new DeviceCmykCS());
  8608. }
  8609. };
  8610. return ColorSpace;
  8611. }();
  8612. var AlternateCS = function AlternateCSClosure() {
  8613. function AlternateCS(numComps, base, tintFn) {
  8614. this.name = 'Alternate';
  8615. this.numComps = numComps;
  8616. this.defaultColor = new Float32Array(numComps);
  8617. for (var i = 0; i < numComps; ++i) {
  8618. this.defaultColor[i] = 1;
  8619. }
  8620. this.base = base;
  8621. this.tintFn = tintFn;
  8622. this.tmpBuf = new Float32Array(base.numComps);
  8623. }
  8624. AlternateCS.prototype = {
  8625. getRgb: ColorSpace.prototype.getRgb,
  8626. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8627. var tmpBuf = this.tmpBuf;
  8628. this.tintFn(src, srcOffset, tmpBuf, 0);
  8629. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  8630. },
  8631. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8632. var tintFn = this.tintFn;
  8633. var base = this.base;
  8634. var scale = 1 / ((1 << bits) - 1);
  8635. var baseNumComps = base.numComps;
  8636. var usesZeroToOneRange = base.usesZeroToOneRange;
  8637. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  8638. var pos = isPassthrough ? destOffset : 0;
  8639. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  8640. var numComps = this.numComps;
  8641. var scaled = new Float32Array(numComps);
  8642. var tinted = new Float32Array(baseNumComps);
  8643. var i, j;
  8644. for (i = 0; i < count; i++) {
  8645. for (j = 0; j < numComps; j++) {
  8646. scaled[j] = src[srcOffset++] * scale;
  8647. }
  8648. tintFn(scaled, 0, tinted, 0);
  8649. if (usesZeroToOneRange) {
  8650. for (j = 0; j < baseNumComps; j++) {
  8651. baseBuf[pos++] = tinted[j] * 255;
  8652. }
  8653. } else {
  8654. base.getRgbItem(tinted, 0, baseBuf, pos);
  8655. pos += baseNumComps;
  8656. }
  8657. }
  8658. if (!isPassthrough) {
  8659. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  8660. }
  8661. },
  8662. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  8663. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  8664. },
  8665. isPassthrough: ColorSpace.prototype.isPassthrough,
  8666. fillRgb: ColorSpace.prototype.fillRgb,
  8667. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  8668. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  8669. },
  8670. usesZeroToOneRange: true
  8671. };
  8672. return AlternateCS;
  8673. }();
  8674. var PatternCS = function PatternCSClosure() {
  8675. function PatternCS(baseCS) {
  8676. this.name = 'Pattern';
  8677. this.base = baseCS;
  8678. }
  8679. PatternCS.prototype = {};
  8680. return PatternCS;
  8681. }();
  8682. var IndexedCS = function IndexedCSClosure() {
  8683. function IndexedCS(base, highVal, lookup) {
  8684. this.name = 'Indexed';
  8685. this.numComps = 1;
  8686. this.defaultColor = new Uint8Array(this.numComps);
  8687. this.base = base;
  8688. this.highVal = highVal;
  8689. var baseNumComps = base.numComps;
  8690. var length = baseNumComps * highVal;
  8691. if (isStream(lookup)) {
  8692. this.lookup = new Uint8Array(length);
  8693. var bytes = lookup.getBytes(length);
  8694. this.lookup.set(bytes);
  8695. } else if (isString(lookup)) {
  8696. this.lookup = new Uint8Array(length);
  8697. for (var i = 0; i < length; ++i) {
  8698. this.lookup[i] = lookup.charCodeAt(i);
  8699. }
  8700. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  8701. this.lookup = lookup;
  8702. } else {
  8703. error('Unrecognized lookup table: ' + lookup);
  8704. }
  8705. }
  8706. IndexedCS.prototype = {
  8707. getRgb: ColorSpace.prototype.getRgb,
  8708. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8709. var numComps = this.base.numComps;
  8710. var start = src[srcOffset] * numComps;
  8711. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  8712. },
  8713. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8714. var base = this.base;
  8715. var numComps = base.numComps;
  8716. var outputDelta = base.getOutputLength(numComps, alpha01);
  8717. var lookup = this.lookup;
  8718. for (var i = 0; i < count; ++i) {
  8719. var lookupPos = src[srcOffset++] * numComps;
  8720. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  8721. destOffset += outputDelta;
  8722. }
  8723. },
  8724. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  8725. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  8726. },
  8727. isPassthrough: ColorSpace.prototype.isPassthrough,
  8728. fillRgb: ColorSpace.prototype.fillRgb,
  8729. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  8730. return true;
  8731. },
  8732. usesZeroToOneRange: true
  8733. };
  8734. return IndexedCS;
  8735. }();
  8736. var DeviceGrayCS = function DeviceGrayCSClosure() {
  8737. function DeviceGrayCS() {
  8738. this.name = 'DeviceGray';
  8739. this.numComps = 1;
  8740. this.defaultColor = new Float32Array(this.numComps);
  8741. }
  8742. DeviceGrayCS.prototype = {
  8743. getRgb: ColorSpace.prototype.getRgb,
  8744. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8745. var c = src[srcOffset] * 255 | 0;
  8746. c = c < 0 ? 0 : c > 255 ? 255 : c;
  8747. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  8748. },
  8749. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8750. var scale = 255 / ((1 << bits) - 1);
  8751. var j = srcOffset, q = destOffset;
  8752. for (var i = 0; i < count; ++i) {
  8753. var c = scale * src[j++] | 0;
  8754. dest[q++] = c;
  8755. dest[q++] = c;
  8756. dest[q++] = c;
  8757. q += alpha01;
  8758. }
  8759. },
  8760. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  8761. return inputLength * (3 + alpha01);
  8762. },
  8763. isPassthrough: ColorSpace.prototype.isPassthrough,
  8764. fillRgb: ColorSpace.prototype.fillRgb,
  8765. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  8766. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  8767. },
  8768. usesZeroToOneRange: true
  8769. };
  8770. return DeviceGrayCS;
  8771. }();
  8772. var DeviceRgbCS = function DeviceRgbCSClosure() {
  8773. function DeviceRgbCS() {
  8774. this.name = 'DeviceRGB';
  8775. this.numComps = 3;
  8776. this.defaultColor = new Float32Array(this.numComps);
  8777. }
  8778. DeviceRgbCS.prototype = {
  8779. getRgb: ColorSpace.prototype.getRgb,
  8780. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8781. var r = src[srcOffset] * 255 | 0;
  8782. var g = src[srcOffset + 1] * 255 | 0;
  8783. var b = src[srcOffset + 2] * 255 | 0;
  8784. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  8785. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  8786. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  8787. },
  8788. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8789. if (bits === 8 && alpha01 === 0) {
  8790. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  8791. return;
  8792. }
  8793. var scale = 255 / ((1 << bits) - 1);
  8794. var j = srcOffset, q = destOffset;
  8795. for (var i = 0; i < count; ++i) {
  8796. dest[q++] = scale * src[j++] | 0;
  8797. dest[q++] = scale * src[j++] | 0;
  8798. dest[q++] = scale * src[j++] | 0;
  8799. q += alpha01;
  8800. }
  8801. },
  8802. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  8803. return inputLength * (3 + alpha01) / 3 | 0;
  8804. },
  8805. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  8806. return bits === 8;
  8807. },
  8808. fillRgb: ColorSpace.prototype.fillRgb,
  8809. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  8810. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  8811. },
  8812. usesZeroToOneRange: true
  8813. };
  8814. return DeviceRgbCS;
  8815. }();
  8816. var DeviceCmykCS = function DeviceCmykCSClosure() {
  8817. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  8818. var c = src[srcOffset + 0] * srcScale;
  8819. var m = src[srcOffset + 1] * srcScale;
  8820. var y = src[srcOffset + 2] * srcScale;
  8821. var k = src[srcOffset + 3] * srcScale;
  8822. var r = c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k + -285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y + -17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) + k * (-21.86122147463605 * k - 189.48180835922747) + 255 | 0;
  8823. var g = c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k + -79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) + k * (-20.737325471181034 * k - 187.80453709719578) + 255 | 0;
  8824. var b = c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367) + 255 | 0;
  8825. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  8826. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  8827. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  8828. }
  8829. function DeviceCmykCS() {
  8830. this.name = 'DeviceCMYK';
  8831. this.numComps = 4;
  8832. this.defaultColor = new Float32Array(this.numComps);
  8833. this.defaultColor[3] = 1;
  8834. }
  8835. DeviceCmykCS.prototype = {
  8836. getRgb: ColorSpace.prototype.getRgb,
  8837. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8838. convertToRgb(src, srcOffset, 1, dest, destOffset);
  8839. },
  8840. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8841. var scale = 1 / ((1 << bits) - 1);
  8842. for (var i = 0; i < count; i++) {
  8843. convertToRgb(src, srcOffset, scale, dest, destOffset);
  8844. srcOffset += 4;
  8845. destOffset += 3 + alpha01;
  8846. }
  8847. },
  8848. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  8849. return inputLength / 4 * (3 + alpha01) | 0;
  8850. },
  8851. isPassthrough: ColorSpace.prototype.isPassthrough,
  8852. fillRgb: ColorSpace.prototype.fillRgb,
  8853. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  8854. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  8855. },
  8856. usesZeroToOneRange: true
  8857. };
  8858. return DeviceCmykCS;
  8859. }();
  8860. var CalGrayCS = function CalGrayCSClosure() {
  8861. function CalGrayCS(whitePoint, blackPoint, gamma) {
  8862. this.name = 'CalGray';
  8863. this.numComps = 1;
  8864. this.defaultColor = new Float32Array(this.numComps);
  8865. if (!whitePoint) {
  8866. error('WhitePoint missing - required for color space CalGray');
  8867. }
  8868. blackPoint = blackPoint || [
  8869. 0,
  8870. 0,
  8871. 0
  8872. ];
  8873. gamma = gamma || 1;
  8874. this.XW = whitePoint[0];
  8875. this.YW = whitePoint[1];
  8876. this.ZW = whitePoint[2];
  8877. this.XB = blackPoint[0];
  8878. this.YB = blackPoint[1];
  8879. this.ZB = blackPoint[2];
  8880. this.G = gamma;
  8881. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  8882. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  8883. }
  8884. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  8885. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  8886. this.XB = this.YB = this.ZB = 0;
  8887. }
  8888. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  8889. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  8890. }
  8891. if (this.G < 1) {
  8892. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  8893. this.G = 1;
  8894. }
  8895. }
  8896. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  8897. var A = src[srcOffset] * scale;
  8898. var AG = Math.pow(A, cs.G);
  8899. var L = cs.YW * AG;
  8900. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  8901. dest[destOffset] = val;
  8902. dest[destOffset + 1] = val;
  8903. dest[destOffset + 2] = val;
  8904. }
  8905. CalGrayCS.prototype = {
  8906. getRgb: ColorSpace.prototype.getRgb,
  8907. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8908. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  8909. },
  8910. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8911. var scale = 1 / ((1 << bits) - 1);
  8912. for (var i = 0; i < count; ++i) {
  8913. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  8914. srcOffset += 1;
  8915. destOffset += 3 + alpha01;
  8916. }
  8917. },
  8918. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  8919. return inputLength * (3 + alpha01);
  8920. },
  8921. isPassthrough: ColorSpace.prototype.isPassthrough,
  8922. fillRgb: ColorSpace.prototype.fillRgb,
  8923. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  8924. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  8925. },
  8926. usesZeroToOneRange: true
  8927. };
  8928. return CalGrayCS;
  8929. }();
  8930. var CalRGBCS = function CalRGBCSClosure() {
  8931. var BRADFORD_SCALE_MATRIX = new Float32Array([
  8932. 0.8951,
  8933. 0.2664,
  8934. -0.1614,
  8935. -0.7502,
  8936. 1.7135,
  8937. 0.0367,
  8938. 0.0389,
  8939. -0.0685,
  8940. 1.0296
  8941. ]);
  8942. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  8943. 0.9869929,
  8944. -0.1470543,
  8945. 0.1599627,
  8946. 0.4323053,
  8947. 0.5183603,
  8948. 0.0492912,
  8949. -0.0085287,
  8950. 0.0400428,
  8951. 0.9684867
  8952. ]);
  8953. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  8954. 3.2404542,
  8955. -1.5371385,
  8956. -0.4985314,
  8957. -0.9692660,
  8958. 1.8760108,
  8959. 0.0415560,
  8960. 0.0556434,
  8961. -0.2040259,
  8962. 1.0572252
  8963. ]);
  8964. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  8965. 1,
  8966. 1,
  8967. 1
  8968. ]);
  8969. var tempNormalizeMatrix = new Float32Array(3);
  8970. var tempConvertMatrix1 = new Float32Array(3);
  8971. var tempConvertMatrix2 = new Float32Array(3);
  8972. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  8973. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  8974. this.name = 'CalRGB';
  8975. this.numComps = 3;
  8976. this.defaultColor = new Float32Array(this.numComps);
  8977. if (!whitePoint) {
  8978. error('WhitePoint missing - required for color space CalRGB');
  8979. }
  8980. blackPoint = blackPoint || new Float32Array(3);
  8981. gamma = gamma || new Float32Array([
  8982. 1,
  8983. 1,
  8984. 1
  8985. ]);
  8986. matrix = matrix || new Float32Array([
  8987. 1,
  8988. 0,
  8989. 0,
  8990. 0,
  8991. 1,
  8992. 0,
  8993. 0,
  8994. 0,
  8995. 1
  8996. ]);
  8997. var XW = whitePoint[0];
  8998. var YW = whitePoint[1];
  8999. var ZW = whitePoint[2];
  9000. this.whitePoint = whitePoint;
  9001. var XB = blackPoint[0];
  9002. var YB = blackPoint[1];
  9003. var ZB = blackPoint[2];
  9004. this.blackPoint = blackPoint;
  9005. this.GR = gamma[0];
  9006. this.GG = gamma[1];
  9007. this.GB = gamma[2];
  9008. this.MXA = matrix[0];
  9009. this.MYA = matrix[1];
  9010. this.MZA = matrix[2];
  9011. this.MXB = matrix[3];
  9012. this.MYB = matrix[4];
  9013. this.MZB = matrix[5];
  9014. this.MXC = matrix[6];
  9015. this.MYC = matrix[7];
  9016. this.MZC = matrix[8];
  9017. if (XW < 0 || ZW < 0 || YW !== 1) {
  9018. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9019. }
  9020. if (XB < 0 || YB < 0 || ZB < 0) {
  9021. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  9022. this.blackPoint = new Float32Array(3);
  9023. }
  9024. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  9025. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  9026. this.GR = this.GG = this.GB = 1;
  9027. }
  9028. if (this.MXA < 0 || this.MYA < 0 || this.MZA < 0 || this.MXB < 0 || this.MYB < 0 || this.MZB < 0 || this.MXC < 0 || this.MYC < 0 || this.MZC < 0) {
  9029. info('Invalid Matrix for ' + this.name + ' [' + this.MXA + ', ' + this.MYA + ', ' + this.MZA + this.MXB + ', ' + this.MYB + ', ' + this.MZB + this.MXC + ', ' + this.MYC + ', ' + this.MZC + '], falling back to default');
  9030. this.MXA = this.MYB = this.MZC = 1;
  9031. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  9032. }
  9033. }
  9034. function matrixProduct(a, b, result) {
  9035. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  9036. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  9037. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  9038. }
  9039. function convertToFlat(sourceWhitePoint, LMS, result) {
  9040. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  9041. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  9042. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  9043. }
  9044. function convertToD65(sourceWhitePoint, LMS, result) {
  9045. var D65X = 0.95047;
  9046. var D65Y = 1;
  9047. var D65Z = 1.08883;
  9048. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  9049. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  9050. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  9051. }
  9052. function sRGBTransferFunction(color) {
  9053. if (color <= 0.0031308) {
  9054. return adjustToRange(0, 1, 12.92 * color);
  9055. }
  9056. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  9057. }
  9058. function adjustToRange(min, max, value) {
  9059. return Math.max(min, Math.min(max, value));
  9060. }
  9061. function decodeL(L) {
  9062. if (L < 0) {
  9063. return -decodeL(-L);
  9064. }
  9065. if (L > 8.0) {
  9066. return Math.pow((L + 16) / 116, 3);
  9067. }
  9068. return L * DECODE_L_CONSTANT;
  9069. }
  9070. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  9071. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  9072. result[0] = XYZ_Flat[0];
  9073. result[1] = XYZ_Flat[1];
  9074. result[2] = XYZ_Flat[2];
  9075. return;
  9076. }
  9077. var zeroDecodeL = decodeL(0);
  9078. var X_DST = zeroDecodeL;
  9079. var X_SRC = decodeL(sourceBlackPoint[0]);
  9080. var Y_DST = zeroDecodeL;
  9081. var Y_SRC = decodeL(sourceBlackPoint[1]);
  9082. var Z_DST = zeroDecodeL;
  9083. var Z_SRC = decodeL(sourceBlackPoint[2]);
  9084. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  9085. var X_Offset = 1 - X_Scale;
  9086. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  9087. var Y_Offset = 1 - Y_Scale;
  9088. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  9089. var Z_Offset = 1 - Z_Scale;
  9090. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  9091. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  9092. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  9093. }
  9094. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  9095. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  9096. result[0] = XYZ_In[0];
  9097. result[1] = XYZ_In[1];
  9098. result[2] = XYZ_In[2];
  9099. return;
  9100. }
  9101. var LMS = result;
  9102. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  9103. var LMS_Flat = tempNormalizeMatrix;
  9104. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  9105. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  9106. }
  9107. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  9108. var LMS = result;
  9109. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  9110. var LMS_D65 = tempNormalizeMatrix;
  9111. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  9112. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  9113. }
  9114. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9115. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  9116. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  9117. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  9118. var AGR = Math.pow(A, cs.GR);
  9119. var BGG = Math.pow(B, cs.GG);
  9120. var CGB = Math.pow(C, cs.GB);
  9121. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  9122. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  9123. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  9124. var XYZ = tempConvertMatrix1;
  9125. XYZ[0] = X;
  9126. XYZ[1] = Y;
  9127. XYZ[2] = Z;
  9128. var XYZ_Flat = tempConvertMatrix2;
  9129. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  9130. var XYZ_Black = tempConvertMatrix1;
  9131. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  9132. var XYZ_D65 = tempConvertMatrix2;
  9133. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  9134. var SRGB = tempConvertMatrix1;
  9135. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  9136. var sR = sRGBTransferFunction(SRGB[0]);
  9137. var sG = sRGBTransferFunction(SRGB[1]);
  9138. var sB = sRGBTransferFunction(SRGB[2]);
  9139. dest[destOffset] = Math.round(sR * 255);
  9140. dest[destOffset + 1] = Math.round(sG * 255);
  9141. dest[destOffset + 2] = Math.round(sB * 255);
  9142. }
  9143. CalRGBCS.prototype = {
  9144. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  9145. var rgb = new Uint8Array(3);
  9146. this.getRgbItem(src, srcOffset, rgb, 0);
  9147. return rgb;
  9148. },
  9149. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9150. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9151. },
  9152. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9153. var scale = 1 / ((1 << bits) - 1);
  9154. for (var i = 0; i < count; ++i) {
  9155. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9156. srcOffset += 3;
  9157. destOffset += 3 + alpha01;
  9158. }
  9159. },
  9160. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  9161. return inputLength * (3 + alpha01) / 3 | 0;
  9162. },
  9163. isPassthrough: ColorSpace.prototype.isPassthrough,
  9164. fillRgb: ColorSpace.prototype.fillRgb,
  9165. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  9166. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9167. },
  9168. usesZeroToOneRange: true
  9169. };
  9170. return CalRGBCS;
  9171. }();
  9172. var LabCS = function LabCSClosure() {
  9173. function LabCS(whitePoint, blackPoint, range) {
  9174. this.name = 'Lab';
  9175. this.numComps = 3;
  9176. this.defaultColor = new Float32Array(this.numComps);
  9177. if (!whitePoint) {
  9178. error('WhitePoint missing - required for color space Lab');
  9179. }
  9180. blackPoint = blackPoint || [
  9181. 0,
  9182. 0,
  9183. 0
  9184. ];
  9185. range = range || [
  9186. -100,
  9187. 100,
  9188. -100,
  9189. 100
  9190. ];
  9191. this.XW = whitePoint[0];
  9192. this.YW = whitePoint[1];
  9193. this.ZW = whitePoint[2];
  9194. this.amin = range[0];
  9195. this.amax = range[1];
  9196. this.bmin = range[2];
  9197. this.bmax = range[3];
  9198. this.XB = blackPoint[0];
  9199. this.YB = blackPoint[1];
  9200. this.ZB = blackPoint[2];
  9201. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9202. error('Invalid WhitePoint components, no fallback available');
  9203. }
  9204. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9205. info('Invalid BlackPoint, falling back to default');
  9206. this.XB = this.YB = this.ZB = 0;
  9207. }
  9208. if (this.amin > this.amax || this.bmin > this.bmax) {
  9209. info('Invalid Range, falling back to defaults');
  9210. this.amin = -100;
  9211. this.amax = 100;
  9212. this.bmin = -100;
  9213. this.bmax = 100;
  9214. }
  9215. }
  9216. function fn_g(x) {
  9217. var result;
  9218. if (x >= 6 / 29) {
  9219. result = x * x * x;
  9220. } else {
  9221. result = 108 / 841 * (x - 4 / 29);
  9222. }
  9223. return result;
  9224. }
  9225. function decode(value, high1, low2, high2) {
  9226. return low2 + value * (high2 - low2) / high1;
  9227. }
  9228. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  9229. var Ls = src[srcOffset];
  9230. var as = src[srcOffset + 1];
  9231. var bs = src[srcOffset + 2];
  9232. if (maxVal !== false) {
  9233. Ls = decode(Ls, maxVal, 0, 100);
  9234. as = decode(as, maxVal, cs.amin, cs.amax);
  9235. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  9236. }
  9237. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  9238. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  9239. var M = (Ls + 16) / 116;
  9240. var L = M + as / 500;
  9241. var N = M - bs / 200;
  9242. var X = cs.XW * fn_g(L);
  9243. var Y = cs.YW * fn_g(M);
  9244. var Z = cs.ZW * fn_g(N);
  9245. var r, g, b;
  9246. if (cs.ZW < 1) {
  9247. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  9248. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  9249. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  9250. } else {
  9251. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  9252. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  9253. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  9254. }
  9255. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  9256. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  9257. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  9258. }
  9259. LabCS.prototype = {
  9260. getRgb: ColorSpace.prototype.getRgb,
  9261. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9262. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  9263. },
  9264. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9265. var maxVal = (1 << bits) - 1;
  9266. for (var i = 0; i < count; i++) {
  9267. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  9268. srcOffset += 3;
  9269. destOffset += 3 + alpha01;
  9270. }
  9271. },
  9272. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  9273. return inputLength * (3 + alpha01) / 3 | 0;
  9274. },
  9275. isPassthrough: ColorSpace.prototype.isPassthrough,
  9276. fillRgb: ColorSpace.prototype.fillRgb,
  9277. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  9278. return true;
  9279. },
  9280. usesZeroToOneRange: false
  9281. };
  9282. return LabCS;
  9283. }();
  9284. exports.ColorSpace = ColorSpace;
  9285. /***/ }),
  9286. /* 4 */
  9287. /***/ (function(module, exports, __w_pdfjs_require__) {
  9288. "use strict";
  9289. var ExpertEncoding = [
  9290. '',
  9291. '',
  9292. '',
  9293. '',
  9294. '',
  9295. '',
  9296. '',
  9297. '',
  9298. '',
  9299. '',
  9300. '',
  9301. '',
  9302. '',
  9303. '',
  9304. '',
  9305. '',
  9306. '',
  9307. '',
  9308. '',
  9309. '',
  9310. '',
  9311. '',
  9312. '',
  9313. '',
  9314. '',
  9315. '',
  9316. '',
  9317. '',
  9318. '',
  9319. '',
  9320. '',
  9321. '',
  9322. 'space',
  9323. 'exclamsmall',
  9324. 'Hungarumlautsmall',
  9325. '',
  9326. 'dollaroldstyle',
  9327. 'dollarsuperior',
  9328. 'ampersandsmall',
  9329. 'Acutesmall',
  9330. 'parenleftsuperior',
  9331. 'parenrightsuperior',
  9332. 'twodotenleader',
  9333. 'onedotenleader',
  9334. 'comma',
  9335. 'hyphen',
  9336. 'period',
  9337. 'fraction',
  9338. 'zerooldstyle',
  9339. 'oneoldstyle',
  9340. 'twooldstyle',
  9341. 'threeoldstyle',
  9342. 'fouroldstyle',
  9343. 'fiveoldstyle',
  9344. 'sixoldstyle',
  9345. 'sevenoldstyle',
  9346. 'eightoldstyle',
  9347. 'nineoldstyle',
  9348. 'colon',
  9349. 'semicolon',
  9350. 'commasuperior',
  9351. 'threequartersemdash',
  9352. 'periodsuperior',
  9353. 'questionsmall',
  9354. '',
  9355. 'asuperior',
  9356. 'bsuperior',
  9357. 'centsuperior',
  9358. 'dsuperior',
  9359. 'esuperior',
  9360. '',
  9361. '',
  9362. 'isuperior',
  9363. '',
  9364. '',
  9365. 'lsuperior',
  9366. 'msuperior',
  9367. 'nsuperior',
  9368. 'osuperior',
  9369. '',
  9370. '',
  9371. 'rsuperior',
  9372. 'ssuperior',
  9373. 'tsuperior',
  9374. '',
  9375. 'ff',
  9376. 'fi',
  9377. 'fl',
  9378. 'ffi',
  9379. 'ffl',
  9380. 'parenleftinferior',
  9381. '',
  9382. 'parenrightinferior',
  9383. 'Circumflexsmall',
  9384. 'hyphensuperior',
  9385. 'Gravesmall',
  9386. 'Asmall',
  9387. 'Bsmall',
  9388. 'Csmall',
  9389. 'Dsmall',
  9390. 'Esmall',
  9391. 'Fsmall',
  9392. 'Gsmall',
  9393. 'Hsmall',
  9394. 'Ismall',
  9395. 'Jsmall',
  9396. 'Ksmall',
  9397. 'Lsmall',
  9398. 'Msmall',
  9399. 'Nsmall',
  9400. 'Osmall',
  9401. 'Psmall',
  9402. 'Qsmall',
  9403. 'Rsmall',
  9404. 'Ssmall',
  9405. 'Tsmall',
  9406. 'Usmall',
  9407. 'Vsmall',
  9408. 'Wsmall',
  9409. 'Xsmall',
  9410. 'Ysmall',
  9411. 'Zsmall',
  9412. 'colonmonetary',
  9413. 'onefitted',
  9414. 'rupiah',
  9415. 'Tildesmall',
  9416. '',
  9417. '',
  9418. '',
  9419. '',
  9420. '',
  9421. '',
  9422. '',
  9423. '',
  9424. '',
  9425. '',
  9426. '',
  9427. '',
  9428. '',
  9429. '',
  9430. '',
  9431. '',
  9432. '',
  9433. '',
  9434. '',
  9435. '',
  9436. '',
  9437. '',
  9438. '',
  9439. '',
  9440. '',
  9441. '',
  9442. '',
  9443. '',
  9444. '',
  9445. '',
  9446. '',
  9447. '',
  9448. '',
  9449. '',
  9450. 'exclamdownsmall',
  9451. 'centoldstyle',
  9452. 'Lslashsmall',
  9453. '',
  9454. '',
  9455. 'Scaronsmall',
  9456. 'Zcaronsmall',
  9457. 'Dieresissmall',
  9458. 'Brevesmall',
  9459. 'Caronsmall',
  9460. '',
  9461. 'Dotaccentsmall',
  9462. '',
  9463. '',
  9464. 'Macronsmall',
  9465. '',
  9466. '',
  9467. 'figuredash',
  9468. 'hypheninferior',
  9469. '',
  9470. '',
  9471. 'Ogoneksmall',
  9472. 'Ringsmall',
  9473. 'Cedillasmall',
  9474. '',
  9475. '',
  9476. '',
  9477. 'onequarter',
  9478. 'onehalf',
  9479. 'threequarters',
  9480. 'questiondownsmall',
  9481. 'oneeighth',
  9482. 'threeeighths',
  9483. 'fiveeighths',
  9484. 'seveneighths',
  9485. 'onethird',
  9486. 'twothirds',
  9487. '',
  9488. '',
  9489. 'zerosuperior',
  9490. 'onesuperior',
  9491. 'twosuperior',
  9492. 'threesuperior',
  9493. 'foursuperior',
  9494. 'fivesuperior',
  9495. 'sixsuperior',
  9496. 'sevensuperior',
  9497. 'eightsuperior',
  9498. 'ninesuperior',
  9499. 'zeroinferior',
  9500. 'oneinferior',
  9501. 'twoinferior',
  9502. 'threeinferior',
  9503. 'fourinferior',
  9504. 'fiveinferior',
  9505. 'sixinferior',
  9506. 'seveninferior',
  9507. 'eightinferior',
  9508. 'nineinferior',
  9509. 'centinferior',
  9510. 'dollarinferior',
  9511. 'periodinferior',
  9512. 'commainferior',
  9513. 'Agravesmall',
  9514. 'Aacutesmall',
  9515. 'Acircumflexsmall',
  9516. 'Atildesmall',
  9517. 'Adieresissmall',
  9518. 'Aringsmall',
  9519. 'AEsmall',
  9520. 'Ccedillasmall',
  9521. 'Egravesmall',
  9522. 'Eacutesmall',
  9523. 'Ecircumflexsmall',
  9524. 'Edieresissmall',
  9525. 'Igravesmall',
  9526. 'Iacutesmall',
  9527. 'Icircumflexsmall',
  9528. 'Idieresissmall',
  9529. 'Ethsmall',
  9530. 'Ntildesmall',
  9531. 'Ogravesmall',
  9532. 'Oacutesmall',
  9533. 'Ocircumflexsmall',
  9534. 'Otildesmall',
  9535. 'Odieresissmall',
  9536. 'OEsmall',
  9537. 'Oslashsmall',
  9538. 'Ugravesmall',
  9539. 'Uacutesmall',
  9540. 'Ucircumflexsmall',
  9541. 'Udieresissmall',
  9542. 'Yacutesmall',
  9543. 'Thornsmall',
  9544. 'Ydieresissmall'
  9545. ];
  9546. var MacExpertEncoding = [
  9547. '',
  9548. '',
  9549. '',
  9550. '',
  9551. '',
  9552. '',
  9553. '',
  9554. '',
  9555. '',
  9556. '',
  9557. '',
  9558. '',
  9559. '',
  9560. '',
  9561. '',
  9562. '',
  9563. '',
  9564. '',
  9565. '',
  9566. '',
  9567. '',
  9568. '',
  9569. '',
  9570. '',
  9571. '',
  9572. '',
  9573. '',
  9574. '',
  9575. '',
  9576. '',
  9577. '',
  9578. '',
  9579. 'space',
  9580. 'exclamsmall',
  9581. 'Hungarumlautsmall',
  9582. 'centoldstyle',
  9583. 'dollaroldstyle',
  9584. 'dollarsuperior',
  9585. 'ampersandsmall',
  9586. 'Acutesmall',
  9587. 'parenleftsuperior',
  9588. 'parenrightsuperior',
  9589. 'twodotenleader',
  9590. 'onedotenleader',
  9591. 'comma',
  9592. 'hyphen',
  9593. 'period',
  9594. 'fraction',
  9595. 'zerooldstyle',
  9596. 'oneoldstyle',
  9597. 'twooldstyle',
  9598. 'threeoldstyle',
  9599. 'fouroldstyle',
  9600. 'fiveoldstyle',
  9601. 'sixoldstyle',
  9602. 'sevenoldstyle',
  9603. 'eightoldstyle',
  9604. 'nineoldstyle',
  9605. 'colon',
  9606. 'semicolon',
  9607. '',
  9608. 'threequartersemdash',
  9609. '',
  9610. 'questionsmall',
  9611. '',
  9612. '',
  9613. '',
  9614. '',
  9615. 'Ethsmall',
  9616. '',
  9617. '',
  9618. 'onequarter',
  9619. 'onehalf',
  9620. 'threequarters',
  9621. 'oneeighth',
  9622. 'threeeighths',
  9623. 'fiveeighths',
  9624. 'seveneighths',
  9625. 'onethird',
  9626. 'twothirds',
  9627. '',
  9628. '',
  9629. '',
  9630. '',
  9631. '',
  9632. '',
  9633. 'ff',
  9634. 'fi',
  9635. 'fl',
  9636. 'ffi',
  9637. 'ffl',
  9638. 'parenleftinferior',
  9639. '',
  9640. 'parenrightinferior',
  9641. 'Circumflexsmall',
  9642. 'hypheninferior',
  9643. 'Gravesmall',
  9644. 'Asmall',
  9645. 'Bsmall',
  9646. 'Csmall',
  9647. 'Dsmall',
  9648. 'Esmall',
  9649. 'Fsmall',
  9650. 'Gsmall',
  9651. 'Hsmall',
  9652. 'Ismall',
  9653. 'Jsmall',
  9654. 'Ksmall',
  9655. 'Lsmall',
  9656. 'Msmall',
  9657. 'Nsmall',
  9658. 'Osmall',
  9659. 'Psmall',
  9660. 'Qsmall',
  9661. 'Rsmall',
  9662. 'Ssmall',
  9663. 'Tsmall',
  9664. 'Usmall',
  9665. 'Vsmall',
  9666. 'Wsmall',
  9667. 'Xsmall',
  9668. 'Ysmall',
  9669. 'Zsmall',
  9670. 'colonmonetary',
  9671. 'onefitted',
  9672. 'rupiah',
  9673. 'Tildesmall',
  9674. '',
  9675. '',
  9676. 'asuperior',
  9677. 'centsuperior',
  9678. '',
  9679. '',
  9680. '',
  9681. '',
  9682. 'Aacutesmall',
  9683. 'Agravesmall',
  9684. 'Acircumflexsmall',
  9685. 'Adieresissmall',
  9686. 'Atildesmall',
  9687. 'Aringsmall',
  9688. 'Ccedillasmall',
  9689. 'Eacutesmall',
  9690. 'Egravesmall',
  9691. 'Ecircumflexsmall',
  9692. 'Edieresissmall',
  9693. 'Iacutesmall',
  9694. 'Igravesmall',
  9695. 'Icircumflexsmall',
  9696. 'Idieresissmall',
  9697. 'Ntildesmall',
  9698. 'Oacutesmall',
  9699. 'Ogravesmall',
  9700. 'Ocircumflexsmall',
  9701. 'Odieresissmall',
  9702. 'Otildesmall',
  9703. 'Uacutesmall',
  9704. 'Ugravesmall',
  9705. 'Ucircumflexsmall',
  9706. 'Udieresissmall',
  9707. '',
  9708. 'eightsuperior',
  9709. 'fourinferior',
  9710. 'threeinferior',
  9711. 'sixinferior',
  9712. 'eightinferior',
  9713. 'seveninferior',
  9714. 'Scaronsmall',
  9715. '',
  9716. 'centinferior',
  9717. 'twoinferior',
  9718. '',
  9719. 'Dieresissmall',
  9720. '',
  9721. 'Caronsmall',
  9722. 'osuperior',
  9723. 'fiveinferior',
  9724. '',
  9725. 'commainferior',
  9726. 'periodinferior',
  9727. 'Yacutesmall',
  9728. '',
  9729. 'dollarinferior',
  9730. '',
  9731. 'Thornsmall',
  9732. '',
  9733. 'nineinferior',
  9734. 'zeroinferior',
  9735. 'Zcaronsmall',
  9736. 'AEsmall',
  9737. 'Oslashsmall',
  9738. 'questiondownsmall',
  9739. 'oneinferior',
  9740. 'Lslashsmall',
  9741. '',
  9742. '',
  9743. '',
  9744. '',
  9745. '',
  9746. '',
  9747. 'Cedillasmall',
  9748. '',
  9749. '',
  9750. '',
  9751. '',
  9752. '',
  9753. 'OEsmall',
  9754. 'figuredash',
  9755. 'hyphensuperior',
  9756. '',
  9757. '',
  9758. '',
  9759. '',
  9760. 'exclamdownsmall',
  9761. '',
  9762. 'Ydieresissmall',
  9763. '',
  9764. 'onesuperior',
  9765. 'twosuperior',
  9766. 'threesuperior',
  9767. 'foursuperior',
  9768. 'fivesuperior',
  9769. 'sixsuperior',
  9770. 'sevensuperior',
  9771. 'ninesuperior',
  9772. 'zerosuperior',
  9773. '',
  9774. 'esuperior',
  9775. 'rsuperior',
  9776. 'tsuperior',
  9777. '',
  9778. '',
  9779. 'isuperior',
  9780. 'ssuperior',
  9781. 'dsuperior',
  9782. '',
  9783. '',
  9784. '',
  9785. '',
  9786. '',
  9787. 'lsuperior',
  9788. 'Ogoneksmall',
  9789. 'Brevesmall',
  9790. 'Macronsmall',
  9791. 'bsuperior',
  9792. 'nsuperior',
  9793. 'msuperior',
  9794. 'commasuperior',
  9795. 'periodsuperior',
  9796. 'Dotaccentsmall',
  9797. 'Ringsmall'
  9798. ];
  9799. var MacRomanEncoding = [
  9800. '',
  9801. '',
  9802. '',
  9803. '',
  9804. '',
  9805. '',
  9806. '',
  9807. '',
  9808. '',
  9809. '',
  9810. '',
  9811. '',
  9812. '',
  9813. '',
  9814. '',
  9815. '',
  9816. '',
  9817. '',
  9818. '',
  9819. '',
  9820. '',
  9821. '',
  9822. '',
  9823. '',
  9824. '',
  9825. '',
  9826. '',
  9827. '',
  9828. '',
  9829. '',
  9830. '',
  9831. '',
  9832. 'space',
  9833. 'exclam',
  9834. 'quotedbl',
  9835. 'numbersign',
  9836. 'dollar',
  9837. 'percent',
  9838. 'ampersand',
  9839. 'quotesingle',
  9840. 'parenleft',
  9841. 'parenright',
  9842. 'asterisk',
  9843. 'plus',
  9844. 'comma',
  9845. 'hyphen',
  9846. 'period',
  9847. 'slash',
  9848. 'zero',
  9849. 'one',
  9850. 'two',
  9851. 'three',
  9852. 'four',
  9853. 'five',
  9854. 'six',
  9855. 'seven',
  9856. 'eight',
  9857. 'nine',
  9858. 'colon',
  9859. 'semicolon',
  9860. 'less',
  9861. 'equal',
  9862. 'greater',
  9863. 'question',
  9864. 'at',
  9865. 'A',
  9866. 'B',
  9867. 'C',
  9868. 'D',
  9869. 'E',
  9870. 'F',
  9871. 'G',
  9872. 'H',
  9873. 'I',
  9874. 'J',
  9875. 'K',
  9876. 'L',
  9877. 'M',
  9878. 'N',
  9879. 'O',
  9880. 'P',
  9881. 'Q',
  9882. 'R',
  9883. 'S',
  9884. 'T',
  9885. 'U',
  9886. 'V',
  9887. 'W',
  9888. 'X',
  9889. 'Y',
  9890. 'Z',
  9891. 'bracketleft',
  9892. 'backslash',
  9893. 'bracketright',
  9894. 'asciicircum',
  9895. 'underscore',
  9896. 'grave',
  9897. 'a',
  9898. 'b',
  9899. 'c',
  9900. 'd',
  9901. 'e',
  9902. 'f',
  9903. 'g',
  9904. 'h',
  9905. 'i',
  9906. 'j',
  9907. 'k',
  9908. 'l',
  9909. 'm',
  9910. 'n',
  9911. 'o',
  9912. 'p',
  9913. 'q',
  9914. 'r',
  9915. 's',
  9916. 't',
  9917. 'u',
  9918. 'v',
  9919. 'w',
  9920. 'x',
  9921. 'y',
  9922. 'z',
  9923. 'braceleft',
  9924. 'bar',
  9925. 'braceright',
  9926. 'asciitilde',
  9927. '',
  9928. 'Adieresis',
  9929. 'Aring',
  9930. 'Ccedilla',
  9931. 'Eacute',
  9932. 'Ntilde',
  9933. 'Odieresis',
  9934. 'Udieresis',
  9935. 'aacute',
  9936. 'agrave',
  9937. 'acircumflex',
  9938. 'adieresis',
  9939. 'atilde',
  9940. 'aring',
  9941. 'ccedilla',
  9942. 'eacute',
  9943. 'egrave',
  9944. 'ecircumflex',
  9945. 'edieresis',
  9946. 'iacute',
  9947. 'igrave',
  9948. 'icircumflex',
  9949. 'idieresis',
  9950. 'ntilde',
  9951. 'oacute',
  9952. 'ograve',
  9953. 'ocircumflex',
  9954. 'odieresis',
  9955. 'otilde',
  9956. 'uacute',
  9957. 'ugrave',
  9958. 'ucircumflex',
  9959. 'udieresis',
  9960. 'dagger',
  9961. 'degree',
  9962. 'cent',
  9963. 'sterling',
  9964. 'section',
  9965. 'bullet',
  9966. 'paragraph',
  9967. 'germandbls',
  9968. 'registered',
  9969. 'copyright',
  9970. 'trademark',
  9971. 'acute',
  9972. 'dieresis',
  9973. 'notequal',
  9974. 'AE',
  9975. 'Oslash',
  9976. 'infinity',
  9977. 'plusminus',
  9978. 'lessequal',
  9979. 'greaterequal',
  9980. 'yen',
  9981. 'mu',
  9982. 'partialdiff',
  9983. 'summation',
  9984. 'product',
  9985. 'pi',
  9986. 'integral',
  9987. 'ordfeminine',
  9988. 'ordmasculine',
  9989. 'Omega',
  9990. 'ae',
  9991. 'oslash',
  9992. 'questiondown',
  9993. 'exclamdown',
  9994. 'logicalnot',
  9995. 'radical',
  9996. 'florin',
  9997. 'approxequal',
  9998. 'Delta',
  9999. 'guillemotleft',
  10000. 'guillemotright',
  10001. 'ellipsis',
  10002. 'space',
  10003. 'Agrave',
  10004. 'Atilde',
  10005. 'Otilde',
  10006. 'OE',
  10007. 'oe',
  10008. 'endash',
  10009. 'emdash',
  10010. 'quotedblleft',
  10011. 'quotedblright',
  10012. 'quoteleft',
  10013. 'quoteright',
  10014. 'divide',
  10015. 'lozenge',
  10016. 'ydieresis',
  10017. 'Ydieresis',
  10018. 'fraction',
  10019. 'currency',
  10020. 'guilsinglleft',
  10021. 'guilsinglright',
  10022. 'fi',
  10023. 'fl',
  10024. 'daggerdbl',
  10025. 'periodcentered',
  10026. 'quotesinglbase',
  10027. 'quotedblbase',
  10028. 'perthousand',
  10029. 'Acircumflex',
  10030. 'Ecircumflex',
  10031. 'Aacute',
  10032. 'Edieresis',
  10033. 'Egrave',
  10034. 'Iacute',
  10035. 'Icircumflex',
  10036. 'Idieresis',
  10037. 'Igrave',
  10038. 'Oacute',
  10039. 'Ocircumflex',
  10040. 'apple',
  10041. 'Ograve',
  10042. 'Uacute',
  10043. 'Ucircumflex',
  10044. 'Ugrave',
  10045. 'dotlessi',
  10046. 'circumflex',
  10047. 'tilde',
  10048. 'macron',
  10049. 'breve',
  10050. 'dotaccent',
  10051. 'ring',
  10052. 'cedilla',
  10053. 'hungarumlaut',
  10054. 'ogonek',
  10055. 'caron'
  10056. ];
  10057. var StandardEncoding = [
  10058. '',
  10059. '',
  10060. '',
  10061. '',
  10062. '',
  10063. '',
  10064. '',
  10065. '',
  10066. '',
  10067. '',
  10068. '',
  10069. '',
  10070. '',
  10071. '',
  10072. '',
  10073. '',
  10074. '',
  10075. '',
  10076. '',
  10077. '',
  10078. '',
  10079. '',
  10080. '',
  10081. '',
  10082. '',
  10083. '',
  10084. '',
  10085. '',
  10086. '',
  10087. '',
  10088. '',
  10089. '',
  10090. 'space',
  10091. 'exclam',
  10092. 'quotedbl',
  10093. 'numbersign',
  10094. 'dollar',
  10095. 'percent',
  10096. 'ampersand',
  10097. 'quoteright',
  10098. 'parenleft',
  10099. 'parenright',
  10100. 'asterisk',
  10101. 'plus',
  10102. 'comma',
  10103. 'hyphen',
  10104. 'period',
  10105. 'slash',
  10106. 'zero',
  10107. 'one',
  10108. 'two',
  10109. 'three',
  10110. 'four',
  10111. 'five',
  10112. 'six',
  10113. 'seven',
  10114. 'eight',
  10115. 'nine',
  10116. 'colon',
  10117. 'semicolon',
  10118. 'less',
  10119. 'equal',
  10120. 'greater',
  10121. 'question',
  10122. 'at',
  10123. 'A',
  10124. 'B',
  10125. 'C',
  10126. 'D',
  10127. 'E',
  10128. 'F',
  10129. 'G',
  10130. 'H',
  10131. 'I',
  10132. 'J',
  10133. 'K',
  10134. 'L',
  10135. 'M',
  10136. 'N',
  10137. 'O',
  10138. 'P',
  10139. 'Q',
  10140. 'R',
  10141. 'S',
  10142. 'T',
  10143. 'U',
  10144. 'V',
  10145. 'W',
  10146. 'X',
  10147. 'Y',
  10148. 'Z',
  10149. 'bracketleft',
  10150. 'backslash',
  10151. 'bracketright',
  10152. 'asciicircum',
  10153. 'underscore',
  10154. 'quoteleft',
  10155. 'a',
  10156. 'b',
  10157. 'c',
  10158. 'd',
  10159. 'e',
  10160. 'f',
  10161. 'g',
  10162. 'h',
  10163. 'i',
  10164. 'j',
  10165. 'k',
  10166. 'l',
  10167. 'm',
  10168. 'n',
  10169. 'o',
  10170. 'p',
  10171. 'q',
  10172. 'r',
  10173. 's',
  10174. 't',
  10175. 'u',
  10176. 'v',
  10177. 'w',
  10178. 'x',
  10179. 'y',
  10180. 'z',
  10181. 'braceleft',
  10182. 'bar',
  10183. 'braceright',
  10184. 'asciitilde',
  10185. '',
  10186. '',
  10187. '',
  10188. '',
  10189. '',
  10190. '',
  10191. '',
  10192. '',
  10193. '',
  10194. '',
  10195. '',
  10196. '',
  10197. '',
  10198. '',
  10199. '',
  10200. '',
  10201. '',
  10202. '',
  10203. '',
  10204. '',
  10205. '',
  10206. '',
  10207. '',
  10208. '',
  10209. '',
  10210. '',
  10211. '',
  10212. '',
  10213. '',
  10214. '',
  10215. '',
  10216. '',
  10217. '',
  10218. '',
  10219. 'exclamdown',
  10220. 'cent',
  10221. 'sterling',
  10222. 'fraction',
  10223. 'yen',
  10224. 'florin',
  10225. 'section',
  10226. 'currency',
  10227. 'quotesingle',
  10228. 'quotedblleft',
  10229. 'guillemotleft',
  10230. 'guilsinglleft',
  10231. 'guilsinglright',
  10232. 'fi',
  10233. 'fl',
  10234. '',
  10235. 'endash',
  10236. 'dagger',
  10237. 'daggerdbl',
  10238. 'periodcentered',
  10239. '',
  10240. 'paragraph',
  10241. 'bullet',
  10242. 'quotesinglbase',
  10243. 'quotedblbase',
  10244. 'quotedblright',
  10245. 'guillemotright',
  10246. 'ellipsis',
  10247. 'perthousand',
  10248. '',
  10249. 'questiondown',
  10250. '',
  10251. 'grave',
  10252. 'acute',
  10253. 'circumflex',
  10254. 'tilde',
  10255. 'macron',
  10256. 'breve',
  10257. 'dotaccent',
  10258. 'dieresis',
  10259. '',
  10260. 'ring',
  10261. 'cedilla',
  10262. '',
  10263. 'hungarumlaut',
  10264. 'ogonek',
  10265. 'caron',
  10266. 'emdash',
  10267. '',
  10268. '',
  10269. '',
  10270. '',
  10271. '',
  10272. '',
  10273. '',
  10274. '',
  10275. '',
  10276. '',
  10277. '',
  10278. '',
  10279. '',
  10280. '',
  10281. '',
  10282. '',
  10283. 'AE',
  10284. '',
  10285. 'ordfeminine',
  10286. '',
  10287. '',
  10288. '',
  10289. '',
  10290. 'Lslash',
  10291. 'Oslash',
  10292. 'OE',
  10293. 'ordmasculine',
  10294. '',
  10295. '',
  10296. '',
  10297. '',
  10298. '',
  10299. 'ae',
  10300. '',
  10301. '',
  10302. '',
  10303. 'dotlessi',
  10304. '',
  10305. '',
  10306. 'lslash',
  10307. 'oslash',
  10308. 'oe',
  10309. 'germandbls'
  10310. ];
  10311. var WinAnsiEncoding = [
  10312. '',
  10313. '',
  10314. '',
  10315. '',
  10316. '',
  10317. '',
  10318. '',
  10319. '',
  10320. '',
  10321. '',
  10322. '',
  10323. '',
  10324. '',
  10325. '',
  10326. '',
  10327. '',
  10328. '',
  10329. '',
  10330. '',
  10331. '',
  10332. '',
  10333. '',
  10334. '',
  10335. '',
  10336. '',
  10337. '',
  10338. '',
  10339. '',
  10340. '',
  10341. '',
  10342. '',
  10343. '',
  10344. 'space',
  10345. 'exclam',
  10346. 'quotedbl',
  10347. 'numbersign',
  10348. 'dollar',
  10349. 'percent',
  10350. 'ampersand',
  10351. 'quotesingle',
  10352. 'parenleft',
  10353. 'parenright',
  10354. 'asterisk',
  10355. 'plus',
  10356. 'comma',
  10357. 'hyphen',
  10358. 'period',
  10359. 'slash',
  10360. 'zero',
  10361. 'one',
  10362. 'two',
  10363. 'three',
  10364. 'four',
  10365. 'five',
  10366. 'six',
  10367. 'seven',
  10368. 'eight',
  10369. 'nine',
  10370. 'colon',
  10371. 'semicolon',
  10372. 'less',
  10373. 'equal',
  10374. 'greater',
  10375. 'question',
  10376. 'at',
  10377. 'A',
  10378. 'B',
  10379. 'C',
  10380. 'D',
  10381. 'E',
  10382. 'F',
  10383. 'G',
  10384. 'H',
  10385. 'I',
  10386. 'J',
  10387. 'K',
  10388. 'L',
  10389. 'M',
  10390. 'N',
  10391. 'O',
  10392. 'P',
  10393. 'Q',
  10394. 'R',
  10395. 'S',
  10396. 'T',
  10397. 'U',
  10398. 'V',
  10399. 'W',
  10400. 'X',
  10401. 'Y',
  10402. 'Z',
  10403. 'bracketleft',
  10404. 'backslash',
  10405. 'bracketright',
  10406. 'asciicircum',
  10407. 'underscore',
  10408. 'grave',
  10409. 'a',
  10410. 'b',
  10411. 'c',
  10412. 'd',
  10413. 'e',
  10414. 'f',
  10415. 'g',
  10416. 'h',
  10417. 'i',
  10418. 'j',
  10419. 'k',
  10420. 'l',
  10421. 'm',
  10422. 'n',
  10423. 'o',
  10424. 'p',
  10425. 'q',
  10426. 'r',
  10427. 's',
  10428. 't',
  10429. 'u',
  10430. 'v',
  10431. 'w',
  10432. 'x',
  10433. 'y',
  10434. 'z',
  10435. 'braceleft',
  10436. 'bar',
  10437. 'braceright',
  10438. 'asciitilde',
  10439. 'bullet',
  10440. 'Euro',
  10441. 'bullet',
  10442. 'quotesinglbase',
  10443. 'florin',
  10444. 'quotedblbase',
  10445. 'ellipsis',
  10446. 'dagger',
  10447. 'daggerdbl',
  10448. 'circumflex',
  10449. 'perthousand',
  10450. 'Scaron',
  10451. 'guilsinglleft',
  10452. 'OE',
  10453. 'bullet',
  10454. 'Zcaron',
  10455. 'bullet',
  10456. 'bullet',
  10457. 'quoteleft',
  10458. 'quoteright',
  10459. 'quotedblleft',
  10460. 'quotedblright',
  10461. 'bullet',
  10462. 'endash',
  10463. 'emdash',
  10464. 'tilde',
  10465. 'trademark',
  10466. 'scaron',
  10467. 'guilsinglright',
  10468. 'oe',
  10469. 'bullet',
  10470. 'zcaron',
  10471. 'Ydieresis',
  10472. 'space',
  10473. 'exclamdown',
  10474. 'cent',
  10475. 'sterling',
  10476. 'currency',
  10477. 'yen',
  10478. 'brokenbar',
  10479. 'section',
  10480. 'dieresis',
  10481. 'copyright',
  10482. 'ordfeminine',
  10483. 'guillemotleft',
  10484. 'logicalnot',
  10485. 'hyphen',
  10486. 'registered',
  10487. 'macron',
  10488. 'degree',
  10489. 'plusminus',
  10490. 'twosuperior',
  10491. 'threesuperior',
  10492. 'acute',
  10493. 'mu',
  10494. 'paragraph',
  10495. 'periodcentered',
  10496. 'cedilla',
  10497. 'onesuperior',
  10498. 'ordmasculine',
  10499. 'guillemotright',
  10500. 'onequarter',
  10501. 'onehalf',
  10502. 'threequarters',
  10503. 'questiondown',
  10504. 'Agrave',
  10505. 'Aacute',
  10506. 'Acircumflex',
  10507. 'Atilde',
  10508. 'Adieresis',
  10509. 'Aring',
  10510. 'AE',
  10511. 'Ccedilla',
  10512. 'Egrave',
  10513. 'Eacute',
  10514. 'Ecircumflex',
  10515. 'Edieresis',
  10516. 'Igrave',
  10517. 'Iacute',
  10518. 'Icircumflex',
  10519. 'Idieresis',
  10520. 'Eth',
  10521. 'Ntilde',
  10522. 'Ograve',
  10523. 'Oacute',
  10524. 'Ocircumflex',
  10525. 'Otilde',
  10526. 'Odieresis',
  10527. 'multiply',
  10528. 'Oslash',
  10529. 'Ugrave',
  10530. 'Uacute',
  10531. 'Ucircumflex',
  10532. 'Udieresis',
  10533. 'Yacute',
  10534. 'Thorn',
  10535. 'germandbls',
  10536. 'agrave',
  10537. 'aacute',
  10538. 'acircumflex',
  10539. 'atilde',
  10540. 'adieresis',
  10541. 'aring',
  10542. 'ae',
  10543. 'ccedilla',
  10544. 'egrave',
  10545. 'eacute',
  10546. 'ecircumflex',
  10547. 'edieresis',
  10548. 'igrave',
  10549. 'iacute',
  10550. 'icircumflex',
  10551. 'idieresis',
  10552. 'eth',
  10553. 'ntilde',
  10554. 'ograve',
  10555. 'oacute',
  10556. 'ocircumflex',
  10557. 'otilde',
  10558. 'odieresis',
  10559. 'divide',
  10560. 'oslash',
  10561. 'ugrave',
  10562. 'uacute',
  10563. 'ucircumflex',
  10564. 'udieresis',
  10565. 'yacute',
  10566. 'thorn',
  10567. 'ydieresis'
  10568. ];
  10569. var SymbolSetEncoding = [
  10570. '',
  10571. '',
  10572. '',
  10573. '',
  10574. '',
  10575. '',
  10576. '',
  10577. '',
  10578. '',
  10579. '',
  10580. '',
  10581. '',
  10582. '',
  10583. '',
  10584. '',
  10585. '',
  10586. '',
  10587. '',
  10588. '',
  10589. '',
  10590. '',
  10591. '',
  10592. '',
  10593. '',
  10594. '',
  10595. '',
  10596. '',
  10597. '',
  10598. '',
  10599. '',
  10600. '',
  10601. '',
  10602. 'space',
  10603. 'exclam',
  10604. 'universal',
  10605. 'numbersign',
  10606. 'existential',
  10607. 'percent',
  10608. 'ampersand',
  10609. 'suchthat',
  10610. 'parenleft',
  10611. 'parenright',
  10612. 'asteriskmath',
  10613. 'plus',
  10614. 'comma',
  10615. 'minus',
  10616. 'period',
  10617. 'slash',
  10618. 'zero',
  10619. 'one',
  10620. 'two',
  10621. 'three',
  10622. 'four',
  10623. 'five',
  10624. 'six',
  10625. 'seven',
  10626. 'eight',
  10627. 'nine',
  10628. 'colon',
  10629. 'semicolon',
  10630. 'less',
  10631. 'equal',
  10632. 'greater',
  10633. 'question',
  10634. 'congruent',
  10635. 'Alpha',
  10636. 'Beta',
  10637. 'Chi',
  10638. 'Delta',
  10639. 'Epsilon',
  10640. 'Phi',
  10641. 'Gamma',
  10642. 'Eta',
  10643. 'Iota',
  10644. 'theta1',
  10645. 'Kappa',
  10646. 'Lambda',
  10647. 'Mu',
  10648. 'Nu',
  10649. 'Omicron',
  10650. 'Pi',
  10651. 'Theta',
  10652. 'Rho',
  10653. 'Sigma',
  10654. 'Tau',
  10655. 'Upsilon',
  10656. 'sigma1',
  10657. 'Omega',
  10658. 'Xi',
  10659. 'Psi',
  10660. 'Zeta',
  10661. 'bracketleft',
  10662. 'therefore',
  10663. 'bracketright',
  10664. 'perpendicular',
  10665. 'underscore',
  10666. 'radicalex',
  10667. 'alpha',
  10668. 'beta',
  10669. 'chi',
  10670. 'delta',
  10671. 'epsilon',
  10672. 'phi',
  10673. 'gamma',
  10674. 'eta',
  10675. 'iota',
  10676. 'phi1',
  10677. 'kappa',
  10678. 'lambda',
  10679. 'mu',
  10680. 'nu',
  10681. 'omicron',
  10682. 'pi',
  10683. 'theta',
  10684. 'rho',
  10685. 'sigma',
  10686. 'tau',
  10687. 'upsilon',
  10688. 'omega1',
  10689. 'omega',
  10690. 'xi',
  10691. 'psi',
  10692. 'zeta',
  10693. 'braceleft',
  10694. 'bar',
  10695. 'braceright',
  10696. 'similar',
  10697. '',
  10698. '',
  10699. '',
  10700. '',
  10701. '',
  10702. '',
  10703. '',
  10704. '',
  10705. '',
  10706. '',
  10707. '',
  10708. '',
  10709. '',
  10710. '',
  10711. '',
  10712. '',
  10713. '',
  10714. '',
  10715. '',
  10716. '',
  10717. '',
  10718. '',
  10719. '',
  10720. '',
  10721. '',
  10722. '',
  10723. '',
  10724. '',
  10725. '',
  10726. '',
  10727. '',
  10728. '',
  10729. '',
  10730. 'Euro',
  10731. 'Upsilon1',
  10732. 'minute',
  10733. 'lessequal',
  10734. 'fraction',
  10735. 'infinity',
  10736. 'florin',
  10737. 'club',
  10738. 'diamond',
  10739. 'heart',
  10740. 'spade',
  10741. 'arrowboth',
  10742. 'arrowleft',
  10743. 'arrowup',
  10744. 'arrowright',
  10745. 'arrowdown',
  10746. 'degree',
  10747. 'plusminus',
  10748. 'second',
  10749. 'greaterequal',
  10750. 'multiply',
  10751. 'proportional',
  10752. 'partialdiff',
  10753. 'bullet',
  10754. 'divide',
  10755. 'notequal',
  10756. 'equivalence',
  10757. 'approxequal',
  10758. 'ellipsis',
  10759. 'arrowvertex',
  10760. 'arrowhorizex',
  10761. 'carriagereturn',
  10762. 'aleph',
  10763. 'Ifraktur',
  10764. 'Rfraktur',
  10765. 'weierstrass',
  10766. 'circlemultiply',
  10767. 'circleplus',
  10768. 'emptyset',
  10769. 'intersection',
  10770. 'union',
  10771. 'propersuperset',
  10772. 'reflexsuperset',
  10773. 'notsubset',
  10774. 'propersubset',
  10775. 'reflexsubset',
  10776. 'element',
  10777. 'notelement',
  10778. 'angle',
  10779. 'gradient',
  10780. 'registerserif',
  10781. 'copyrightserif',
  10782. 'trademarkserif',
  10783. 'product',
  10784. 'radical',
  10785. 'dotmath',
  10786. 'logicalnot',
  10787. 'logicaland',
  10788. 'logicalor',
  10789. 'arrowdblboth',
  10790. 'arrowdblleft',
  10791. 'arrowdblup',
  10792. 'arrowdblright',
  10793. 'arrowdbldown',
  10794. 'lozenge',
  10795. 'angleleft',
  10796. 'registersans',
  10797. 'copyrightsans',
  10798. 'trademarksans',
  10799. 'summation',
  10800. 'parenlefttp',
  10801. 'parenleftex',
  10802. 'parenleftbt',
  10803. 'bracketlefttp',
  10804. 'bracketleftex',
  10805. 'bracketleftbt',
  10806. 'bracelefttp',
  10807. 'braceleftmid',
  10808. 'braceleftbt',
  10809. 'braceex',
  10810. '',
  10811. 'angleright',
  10812. 'integral',
  10813. 'integraltp',
  10814. 'integralex',
  10815. 'integralbt',
  10816. 'parenrighttp',
  10817. 'parenrightex',
  10818. 'parenrightbt',
  10819. 'bracketrighttp',
  10820. 'bracketrightex',
  10821. 'bracketrightbt',
  10822. 'bracerighttp',
  10823. 'bracerightmid',
  10824. 'bracerightbt'
  10825. ];
  10826. var ZapfDingbatsEncoding = [
  10827. '',
  10828. '',
  10829. '',
  10830. '',
  10831. '',
  10832. '',
  10833. '',
  10834. '',
  10835. '',
  10836. '',
  10837. '',
  10838. '',
  10839. '',
  10840. '',
  10841. '',
  10842. '',
  10843. '',
  10844. '',
  10845. '',
  10846. '',
  10847. '',
  10848. '',
  10849. '',
  10850. '',
  10851. '',
  10852. '',
  10853. '',
  10854. '',
  10855. '',
  10856. '',
  10857. '',
  10858. '',
  10859. 'space',
  10860. 'a1',
  10861. 'a2',
  10862. 'a202',
  10863. 'a3',
  10864. 'a4',
  10865. 'a5',
  10866. 'a119',
  10867. 'a118',
  10868. 'a117',
  10869. 'a11',
  10870. 'a12',
  10871. 'a13',
  10872. 'a14',
  10873. 'a15',
  10874. 'a16',
  10875. 'a105',
  10876. 'a17',
  10877. 'a18',
  10878. 'a19',
  10879. 'a20',
  10880. 'a21',
  10881. 'a22',
  10882. 'a23',
  10883. 'a24',
  10884. 'a25',
  10885. 'a26',
  10886. 'a27',
  10887. 'a28',
  10888. 'a6',
  10889. 'a7',
  10890. 'a8',
  10891. 'a9',
  10892. 'a10',
  10893. 'a29',
  10894. 'a30',
  10895. 'a31',
  10896. 'a32',
  10897. 'a33',
  10898. 'a34',
  10899. 'a35',
  10900. 'a36',
  10901. 'a37',
  10902. 'a38',
  10903. 'a39',
  10904. 'a40',
  10905. 'a41',
  10906. 'a42',
  10907. 'a43',
  10908. 'a44',
  10909. 'a45',
  10910. 'a46',
  10911. 'a47',
  10912. 'a48',
  10913. 'a49',
  10914. 'a50',
  10915. 'a51',
  10916. 'a52',
  10917. 'a53',
  10918. 'a54',
  10919. 'a55',
  10920. 'a56',
  10921. 'a57',
  10922. 'a58',
  10923. 'a59',
  10924. 'a60',
  10925. 'a61',
  10926. 'a62',
  10927. 'a63',
  10928. 'a64',
  10929. 'a65',
  10930. 'a66',
  10931. 'a67',
  10932. 'a68',
  10933. 'a69',
  10934. 'a70',
  10935. 'a71',
  10936. 'a72',
  10937. 'a73',
  10938. 'a74',
  10939. 'a203',
  10940. 'a75',
  10941. 'a204',
  10942. 'a76',
  10943. 'a77',
  10944. 'a78',
  10945. 'a79',
  10946. 'a81',
  10947. 'a82',
  10948. 'a83',
  10949. 'a84',
  10950. 'a97',
  10951. 'a98',
  10952. 'a99',
  10953. 'a100',
  10954. '',
  10955. 'a89',
  10956. 'a90',
  10957. 'a93',
  10958. 'a94',
  10959. 'a91',
  10960. 'a92',
  10961. 'a205',
  10962. 'a85',
  10963. 'a206',
  10964. 'a86',
  10965. 'a87',
  10966. 'a88',
  10967. 'a95',
  10968. 'a96',
  10969. '',
  10970. '',
  10971. '',
  10972. '',
  10973. '',
  10974. '',
  10975. '',
  10976. '',
  10977. '',
  10978. '',
  10979. '',
  10980. '',
  10981. '',
  10982. '',
  10983. '',
  10984. '',
  10985. '',
  10986. '',
  10987. '',
  10988. 'a101',
  10989. 'a102',
  10990. 'a103',
  10991. 'a104',
  10992. 'a106',
  10993. 'a107',
  10994. 'a108',
  10995. 'a112',
  10996. 'a111',
  10997. 'a110',
  10998. 'a109',
  10999. 'a120',
  11000. 'a121',
  11001. 'a122',
  11002. 'a123',
  11003. 'a124',
  11004. 'a125',
  11005. 'a126',
  11006. 'a127',
  11007. 'a128',
  11008. 'a129',
  11009. 'a130',
  11010. 'a131',
  11011. 'a132',
  11012. 'a133',
  11013. 'a134',
  11014. 'a135',
  11015. 'a136',
  11016. 'a137',
  11017. 'a138',
  11018. 'a139',
  11019. 'a140',
  11020. 'a141',
  11021. 'a142',
  11022. 'a143',
  11023. 'a144',
  11024. 'a145',
  11025. 'a146',
  11026. 'a147',
  11027. 'a148',
  11028. 'a149',
  11029. 'a150',
  11030. 'a151',
  11031. 'a152',
  11032. 'a153',
  11033. 'a154',
  11034. 'a155',
  11035. 'a156',
  11036. 'a157',
  11037. 'a158',
  11038. 'a159',
  11039. 'a160',
  11040. 'a161',
  11041. 'a163',
  11042. 'a164',
  11043. 'a196',
  11044. 'a165',
  11045. 'a192',
  11046. 'a166',
  11047. 'a167',
  11048. 'a168',
  11049. 'a169',
  11050. 'a170',
  11051. 'a171',
  11052. 'a172',
  11053. 'a173',
  11054. 'a162',
  11055. 'a174',
  11056. 'a175',
  11057. 'a176',
  11058. 'a177',
  11059. 'a178',
  11060. 'a179',
  11061. 'a193',
  11062. 'a180',
  11063. 'a199',
  11064. 'a181',
  11065. 'a200',
  11066. 'a182',
  11067. '',
  11068. 'a201',
  11069. 'a183',
  11070. 'a184',
  11071. 'a197',
  11072. 'a185',
  11073. 'a194',
  11074. 'a198',
  11075. 'a186',
  11076. 'a195',
  11077. 'a187',
  11078. 'a188',
  11079. 'a189',
  11080. 'a190',
  11081. 'a191'
  11082. ];
  11083. function getEncoding(encodingName) {
  11084. switch (encodingName) {
  11085. case 'WinAnsiEncoding':
  11086. return WinAnsiEncoding;
  11087. case 'StandardEncoding':
  11088. return StandardEncoding;
  11089. case 'MacRomanEncoding':
  11090. return MacRomanEncoding;
  11091. case 'SymbolSetEncoding':
  11092. return SymbolSetEncoding;
  11093. case 'ZapfDingbatsEncoding':
  11094. return ZapfDingbatsEncoding;
  11095. case 'ExpertEncoding':
  11096. return ExpertEncoding;
  11097. case 'MacExpertEncoding':
  11098. return MacExpertEncoding;
  11099. default:
  11100. return null;
  11101. }
  11102. }
  11103. exports.WinAnsiEncoding = WinAnsiEncoding;
  11104. exports.StandardEncoding = StandardEncoding;
  11105. exports.MacRomanEncoding = MacRomanEncoding;
  11106. exports.SymbolSetEncoding = SymbolSetEncoding;
  11107. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  11108. exports.ExpertEncoding = ExpertEncoding;
  11109. exports.getEncoding = getEncoding;
  11110. /***/ }),
  11111. /* 5 */
  11112. /***/ (function(module, exports, __w_pdfjs_require__) {
  11113. "use strict";
  11114. var sharedUtil = __w_pdfjs_require__(0);
  11115. var corePrimitives = __w_pdfjs_require__(1);
  11116. var coreStream = __w_pdfjs_require__(2);
  11117. var MissingDataException = sharedUtil.MissingDataException;
  11118. var StreamType = sharedUtil.StreamType;
  11119. var assert = sharedUtil.assert;
  11120. var error = sharedUtil.error;
  11121. var info = sharedUtil.info;
  11122. var isArray = sharedUtil.isArray;
  11123. var isInt = sharedUtil.isInt;
  11124. var isNum = sharedUtil.isNum;
  11125. var isString = sharedUtil.isString;
  11126. var warn = sharedUtil.warn;
  11127. var EOF = corePrimitives.EOF;
  11128. var Cmd = corePrimitives.Cmd;
  11129. var Dict = corePrimitives.Dict;
  11130. var Name = corePrimitives.Name;
  11131. var Ref = corePrimitives.Ref;
  11132. var isEOF = corePrimitives.isEOF;
  11133. var isCmd = corePrimitives.isCmd;
  11134. var isDict = corePrimitives.isDict;
  11135. var isName = corePrimitives.isName;
  11136. var Ascii85Stream = coreStream.Ascii85Stream;
  11137. var AsciiHexStream = coreStream.AsciiHexStream;
  11138. var CCITTFaxStream = coreStream.CCITTFaxStream;
  11139. var FlateStream = coreStream.FlateStream;
  11140. var Jbig2Stream = coreStream.Jbig2Stream;
  11141. var JpegStream = coreStream.JpegStream;
  11142. var JpxStream = coreStream.JpxStream;
  11143. var LZWStream = coreStream.LZWStream;
  11144. var NullStream = coreStream.NullStream;
  11145. var PredictorStream = coreStream.PredictorStream;
  11146. var RunLengthStream = coreStream.RunLengthStream;
  11147. var MAX_LENGTH_TO_CACHE = 1000;
  11148. var Parser = function ParserClosure() {
  11149. function Parser(lexer, allowStreams, xref, recoveryMode) {
  11150. this.lexer = lexer;
  11151. this.allowStreams = allowStreams;
  11152. this.xref = xref;
  11153. this.recoveryMode = recoveryMode || false;
  11154. this.imageCache = Object.create(null);
  11155. this.refill();
  11156. }
  11157. Parser.prototype = {
  11158. refill: function Parser_refill() {
  11159. this.buf1 = this.lexer.getObj();
  11160. this.buf2 = this.lexer.getObj();
  11161. },
  11162. shift: function Parser_shift() {
  11163. if (isCmd(this.buf2, 'ID')) {
  11164. this.buf1 = this.buf2;
  11165. this.buf2 = null;
  11166. } else {
  11167. this.buf1 = this.buf2;
  11168. this.buf2 = this.lexer.getObj();
  11169. }
  11170. },
  11171. tryShift: function Parser_tryShift() {
  11172. try {
  11173. this.shift();
  11174. return true;
  11175. } catch (e) {
  11176. if (e instanceof MissingDataException) {
  11177. throw e;
  11178. }
  11179. return false;
  11180. }
  11181. },
  11182. getObj: function Parser_getObj(cipherTransform) {
  11183. var buf1 = this.buf1;
  11184. this.shift();
  11185. if (buf1 instanceof Cmd) {
  11186. switch (buf1.cmd) {
  11187. case 'BI':
  11188. return this.makeInlineImage(cipherTransform);
  11189. case '[':
  11190. var array = [];
  11191. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  11192. array.push(this.getObj(cipherTransform));
  11193. }
  11194. if (isEOF(this.buf1)) {
  11195. if (!this.recoveryMode) {
  11196. error('End of file inside array');
  11197. }
  11198. return array;
  11199. }
  11200. this.shift();
  11201. return array;
  11202. case '<<':
  11203. var dict = new Dict(this.xref);
  11204. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  11205. if (!isName(this.buf1)) {
  11206. info('Malformed dictionary: key must be a name object');
  11207. this.shift();
  11208. continue;
  11209. }
  11210. var key = this.buf1.name;
  11211. this.shift();
  11212. if (isEOF(this.buf1)) {
  11213. break;
  11214. }
  11215. dict.set(key, this.getObj(cipherTransform));
  11216. }
  11217. if (isEOF(this.buf1)) {
  11218. if (!this.recoveryMode) {
  11219. error('End of file inside dictionary');
  11220. }
  11221. return dict;
  11222. }
  11223. if (isCmd(this.buf2, 'stream')) {
  11224. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  11225. }
  11226. this.shift();
  11227. return dict;
  11228. default:
  11229. return buf1;
  11230. }
  11231. }
  11232. if (isInt(buf1)) {
  11233. var num = buf1;
  11234. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  11235. var ref = new Ref(num, this.buf1);
  11236. this.shift();
  11237. this.shift();
  11238. return ref;
  11239. }
  11240. return num;
  11241. }
  11242. if (isString(buf1)) {
  11243. var str = buf1;
  11244. if (cipherTransform) {
  11245. str = cipherTransform.decryptString(str);
  11246. }
  11247. return str;
  11248. }
  11249. return buf1;
  11250. },
  11251. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  11252. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  11253. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  11254. while ((ch = stream.getByte()) !== -1) {
  11255. if (state === 0) {
  11256. state = ch === E ? 1 : 0;
  11257. } else if (state === 1) {
  11258. state = ch === I ? 2 : 0;
  11259. } else {
  11260. assert(state === 2);
  11261. if (ch === SPACE || ch === LF || ch === CR) {
  11262. n = 5;
  11263. followingBytes = stream.peekBytes(n);
  11264. for (i = 0; i < n; i++) {
  11265. ch = followingBytes[i];
  11266. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  11267. state = 0;
  11268. break;
  11269. }
  11270. }
  11271. if (state === 2) {
  11272. break;
  11273. }
  11274. } else {
  11275. state = 0;
  11276. }
  11277. }
  11278. }
  11279. return stream.pos - 4 - startPos;
  11280. },
  11281. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  11282. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  11283. while ((b = stream.getByte()) !== -1) {
  11284. if (b !== 0xFF) {
  11285. continue;
  11286. }
  11287. switch (stream.getByte()) {
  11288. case 0x00:
  11289. break;
  11290. case 0xFF:
  11291. stream.skip(-1);
  11292. break;
  11293. case 0xD9:
  11294. foundEOI = true;
  11295. break;
  11296. case 0xC0:
  11297. case 0xC1:
  11298. case 0xC2:
  11299. case 0xC3:
  11300. case 0xC5:
  11301. case 0xC6:
  11302. case 0xC7:
  11303. case 0xC9:
  11304. case 0xCA:
  11305. case 0xCB:
  11306. case 0xCD:
  11307. case 0xCE:
  11308. case 0xCF:
  11309. case 0xC4:
  11310. case 0xCC:
  11311. case 0xDA:
  11312. case 0xDB:
  11313. case 0xDC:
  11314. case 0xDD:
  11315. case 0xDE:
  11316. case 0xDF:
  11317. case 0xE0:
  11318. case 0xE1:
  11319. case 0xE2:
  11320. case 0xE3:
  11321. case 0xE4:
  11322. case 0xE5:
  11323. case 0xE6:
  11324. case 0xE7:
  11325. case 0xE8:
  11326. case 0xE9:
  11327. case 0xEA:
  11328. case 0xEB:
  11329. case 0xEC:
  11330. case 0xED:
  11331. case 0xEE:
  11332. case 0xEF:
  11333. case 0xFE:
  11334. markerLength = stream.getUint16();
  11335. if (markerLength > 2) {
  11336. stream.skip(markerLength - 2);
  11337. } else {
  11338. stream.skip(-2);
  11339. }
  11340. break;
  11341. }
  11342. if (foundEOI) {
  11343. break;
  11344. }
  11345. }
  11346. length = stream.pos - startPos;
  11347. if (b === -1) {
  11348. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  11349. stream.skip(-length);
  11350. return this.findDefaultInlineStreamEnd(stream);
  11351. }
  11352. this.inlineStreamSkipEI(stream);
  11353. return length;
  11354. },
  11355. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  11356. var TILDE = 0x7E, GT = 0x3E;
  11357. var startPos = stream.pos, ch, length;
  11358. while ((ch = stream.getByte()) !== -1) {
  11359. if (ch === TILDE && stream.peekByte() === GT) {
  11360. stream.skip();
  11361. break;
  11362. }
  11363. }
  11364. length = stream.pos - startPos;
  11365. if (ch === -1) {
  11366. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  11367. stream.skip(-length);
  11368. return this.findDefaultInlineStreamEnd(stream);
  11369. }
  11370. this.inlineStreamSkipEI(stream);
  11371. return length;
  11372. },
  11373. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  11374. var GT = 0x3E;
  11375. var startPos = stream.pos, ch, length;
  11376. while ((ch = stream.getByte()) !== -1) {
  11377. if (ch === GT) {
  11378. break;
  11379. }
  11380. }
  11381. length = stream.pos - startPos;
  11382. if (ch === -1) {
  11383. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  11384. stream.skip(-length);
  11385. return this.findDefaultInlineStreamEnd(stream);
  11386. }
  11387. this.inlineStreamSkipEI(stream);
  11388. return length;
  11389. },
  11390. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  11391. var E = 0x45, I = 0x49;
  11392. var state = 0, ch;
  11393. while ((ch = stream.getByte()) !== -1) {
  11394. if (state === 0) {
  11395. state = ch === E ? 1 : 0;
  11396. } else if (state === 1) {
  11397. state = ch === I ? 2 : 0;
  11398. } else if (state === 2) {
  11399. break;
  11400. }
  11401. }
  11402. },
  11403. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  11404. var lexer = this.lexer;
  11405. var stream = lexer.stream;
  11406. var dict = new Dict(this.xref);
  11407. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  11408. if (!isName(this.buf1)) {
  11409. error('Dictionary key must be a name object');
  11410. }
  11411. var key = this.buf1.name;
  11412. this.shift();
  11413. if (isEOF(this.buf1)) {
  11414. break;
  11415. }
  11416. dict.set(key, this.getObj(cipherTransform));
  11417. }
  11418. var filter = dict.get('Filter', 'F'), filterName;
  11419. if (isName(filter)) {
  11420. filterName = filter.name;
  11421. } else if (isArray(filter)) {
  11422. var filterZero = this.xref.fetchIfRef(filter[0]);
  11423. if (isName(filterZero)) {
  11424. filterName = filterZero.name;
  11425. }
  11426. }
  11427. var startPos = stream.pos, length, i, ii;
  11428. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  11429. length = this.findDCTDecodeInlineStreamEnd(stream);
  11430. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  11431. length = this.findASCII85DecodeInlineStreamEnd(stream);
  11432. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  11433. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  11434. } else {
  11435. length = this.findDefaultInlineStreamEnd(stream);
  11436. }
  11437. var imageStream = stream.makeSubStream(startPos, length, dict);
  11438. var adler32;
  11439. if (length < MAX_LENGTH_TO_CACHE) {
  11440. var imageBytes = imageStream.getBytes();
  11441. imageStream.reset();
  11442. var a = 1;
  11443. var b = 0;
  11444. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  11445. a += imageBytes[i] & 0xff;
  11446. b += a;
  11447. }
  11448. adler32 = b % 65521 << 16 | a % 65521;
  11449. if (this.imageCache.adler32 === adler32) {
  11450. this.buf2 = Cmd.get('EI');
  11451. this.shift();
  11452. this.imageCache[adler32].reset();
  11453. return this.imageCache[adler32];
  11454. }
  11455. }
  11456. if (cipherTransform) {
  11457. imageStream = cipherTransform.createStream(imageStream, length);
  11458. }
  11459. imageStream = this.filter(imageStream, dict, length);
  11460. imageStream.dict = dict;
  11461. if (adler32 !== undefined) {
  11462. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  11463. this.imageCache[adler32] = imageStream;
  11464. }
  11465. this.buf2 = Cmd.get('EI');
  11466. this.shift();
  11467. return imageStream;
  11468. },
  11469. makeStream: function Parser_makeStream(dict, cipherTransform) {
  11470. var lexer = this.lexer;
  11471. var stream = lexer.stream;
  11472. lexer.skipToNextLine();
  11473. var pos = stream.pos - 1;
  11474. var length = dict.get('Length');
  11475. if (!isInt(length)) {
  11476. info('Bad ' + length + ' attribute in stream');
  11477. length = 0;
  11478. }
  11479. stream.pos = pos + length;
  11480. lexer.nextChar();
  11481. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  11482. this.shift();
  11483. } else {
  11484. stream.pos = pos;
  11485. var SCAN_BLOCK_SIZE = 2048;
  11486. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  11487. var ENDSTREAM_SIGNATURE = [
  11488. 0x65,
  11489. 0x6E,
  11490. 0x64,
  11491. 0x73,
  11492. 0x74,
  11493. 0x72,
  11494. 0x65,
  11495. 0x61,
  11496. 0x6D
  11497. ];
  11498. var skipped = 0, found = false, i, j;
  11499. while (stream.pos < stream.end) {
  11500. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  11501. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  11502. if (scanLength <= 0) {
  11503. break;
  11504. }
  11505. found = false;
  11506. i = 0;
  11507. while (i < scanLength) {
  11508. j = 0;
  11509. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  11510. j++;
  11511. }
  11512. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  11513. found = true;
  11514. break;
  11515. }
  11516. i++;
  11517. }
  11518. if (found) {
  11519. skipped += i;
  11520. stream.pos += i;
  11521. break;
  11522. }
  11523. skipped += scanLength;
  11524. stream.pos += scanLength;
  11525. }
  11526. if (!found) {
  11527. error('Missing endstream');
  11528. }
  11529. length = skipped;
  11530. lexer.nextChar();
  11531. this.shift();
  11532. this.shift();
  11533. }
  11534. this.shift();
  11535. stream = stream.makeSubStream(pos, length, dict);
  11536. if (cipherTransform) {
  11537. stream = cipherTransform.createStream(stream, length);
  11538. }
  11539. stream = this.filter(stream, dict, length);
  11540. stream.dict = dict;
  11541. return stream;
  11542. },
  11543. filter: function Parser_filter(stream, dict, length) {
  11544. var filter = dict.get('Filter', 'F');
  11545. var params = dict.get('DecodeParms', 'DP');
  11546. if (isName(filter)) {
  11547. if (isArray(params)) {
  11548. params = this.xref.fetchIfRef(params[0]);
  11549. }
  11550. return this.makeFilter(stream, filter.name, length, params);
  11551. }
  11552. var maybeLength = length;
  11553. if (isArray(filter)) {
  11554. var filterArray = filter;
  11555. var paramsArray = params;
  11556. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  11557. filter = this.xref.fetchIfRef(filterArray[i]);
  11558. if (!isName(filter)) {
  11559. error('Bad filter name: ' + filter);
  11560. }
  11561. params = null;
  11562. if (isArray(paramsArray) && i in paramsArray) {
  11563. params = this.xref.fetchIfRef(paramsArray[i]);
  11564. }
  11565. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  11566. maybeLength = null;
  11567. }
  11568. }
  11569. return stream;
  11570. },
  11571. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  11572. if (maybeLength === 0) {
  11573. warn('Empty "' + name + '" stream.');
  11574. return new NullStream(stream);
  11575. }
  11576. try {
  11577. var xrefStreamStats = this.xref.stats.streamTypes;
  11578. if (name === 'FlateDecode' || name === 'Fl') {
  11579. xrefStreamStats[StreamType.FLATE] = true;
  11580. if (params) {
  11581. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  11582. }
  11583. return new FlateStream(stream, maybeLength);
  11584. }
  11585. if (name === 'LZWDecode' || name === 'LZW') {
  11586. xrefStreamStats[StreamType.LZW] = true;
  11587. var earlyChange = 1;
  11588. if (params) {
  11589. if (params.has('EarlyChange')) {
  11590. earlyChange = params.get('EarlyChange');
  11591. }
  11592. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  11593. }
  11594. return new LZWStream(stream, maybeLength, earlyChange);
  11595. }
  11596. if (name === 'DCTDecode' || name === 'DCT') {
  11597. xrefStreamStats[StreamType.DCT] = true;
  11598. return new JpegStream(stream, maybeLength, stream.dict, params);
  11599. }
  11600. if (name === 'JPXDecode' || name === 'JPX') {
  11601. xrefStreamStats[StreamType.JPX] = true;
  11602. return new JpxStream(stream, maybeLength, stream.dict, params);
  11603. }
  11604. if (name === 'ASCII85Decode' || name === 'A85') {
  11605. xrefStreamStats[StreamType.A85] = true;
  11606. return new Ascii85Stream(stream, maybeLength);
  11607. }
  11608. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  11609. xrefStreamStats[StreamType.AHX] = true;
  11610. return new AsciiHexStream(stream, maybeLength);
  11611. }
  11612. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  11613. xrefStreamStats[StreamType.CCF] = true;
  11614. return new CCITTFaxStream(stream, maybeLength, params);
  11615. }
  11616. if (name === 'RunLengthDecode' || name === 'RL') {
  11617. xrefStreamStats[StreamType.RL] = true;
  11618. return new RunLengthStream(stream, maybeLength);
  11619. }
  11620. if (name === 'JBIG2Decode') {
  11621. xrefStreamStats[StreamType.JBIG] = true;
  11622. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  11623. }
  11624. warn('filter "' + name + '" not supported yet');
  11625. return stream;
  11626. } catch (ex) {
  11627. if (ex instanceof MissingDataException) {
  11628. throw ex;
  11629. }
  11630. warn('Invalid stream: \"' + ex + '\"');
  11631. return new NullStream(stream);
  11632. }
  11633. }
  11634. };
  11635. return Parser;
  11636. }();
  11637. var Lexer = function LexerClosure() {
  11638. function Lexer(stream, knownCommands) {
  11639. this.stream = stream;
  11640. this.nextChar();
  11641. this.strBuf = [];
  11642. this.knownCommands = knownCommands;
  11643. }
  11644. var specialChars = [
  11645. 1,
  11646. 0,
  11647. 0,
  11648. 0,
  11649. 0,
  11650. 0,
  11651. 0,
  11652. 0,
  11653. 0,
  11654. 1,
  11655. 1,
  11656. 0,
  11657. 1,
  11658. 1,
  11659. 0,
  11660. 0,
  11661. 0,
  11662. 0,
  11663. 0,
  11664. 0,
  11665. 0,
  11666. 0,
  11667. 0,
  11668. 0,
  11669. 0,
  11670. 0,
  11671. 0,
  11672. 0,
  11673. 0,
  11674. 0,
  11675. 0,
  11676. 0,
  11677. 1,
  11678. 0,
  11679. 0,
  11680. 0,
  11681. 0,
  11682. 2,
  11683. 0,
  11684. 0,
  11685. 2,
  11686. 2,
  11687. 0,
  11688. 0,
  11689. 0,
  11690. 0,
  11691. 0,
  11692. 2,
  11693. 0,
  11694. 0,
  11695. 0,
  11696. 0,
  11697. 0,
  11698. 0,
  11699. 0,
  11700. 0,
  11701. 0,
  11702. 0,
  11703. 0,
  11704. 0,
  11705. 2,
  11706. 0,
  11707. 2,
  11708. 0,
  11709. 0,
  11710. 0,
  11711. 0,
  11712. 0,
  11713. 0,
  11714. 0,
  11715. 0,
  11716. 0,
  11717. 0,
  11718. 0,
  11719. 0,
  11720. 0,
  11721. 0,
  11722. 0,
  11723. 0,
  11724. 0,
  11725. 0,
  11726. 0,
  11727. 0,
  11728. 0,
  11729. 0,
  11730. 0,
  11731. 0,
  11732. 0,
  11733. 0,
  11734. 0,
  11735. 0,
  11736. 2,
  11737. 0,
  11738. 2,
  11739. 0,
  11740. 0,
  11741. 0,
  11742. 0,
  11743. 0,
  11744. 0,
  11745. 0,
  11746. 0,
  11747. 0,
  11748. 0,
  11749. 0,
  11750. 0,
  11751. 0,
  11752. 0,
  11753. 0,
  11754. 0,
  11755. 0,
  11756. 0,
  11757. 0,
  11758. 0,
  11759. 0,
  11760. 0,
  11761. 0,
  11762. 0,
  11763. 0,
  11764. 0,
  11765. 0,
  11766. 0,
  11767. 0,
  11768. 2,
  11769. 0,
  11770. 2,
  11771. 0,
  11772. 0,
  11773. 0,
  11774. 0,
  11775. 0,
  11776. 0,
  11777. 0,
  11778. 0,
  11779. 0,
  11780. 0,
  11781. 0,
  11782. 0,
  11783. 0,
  11784. 0,
  11785. 0,
  11786. 0,
  11787. 0,
  11788. 0,
  11789. 0,
  11790. 0,
  11791. 0,
  11792. 0,
  11793. 0,
  11794. 0,
  11795. 0,
  11796. 0,
  11797. 0,
  11798. 0,
  11799. 0,
  11800. 0,
  11801. 0,
  11802. 0,
  11803. 0,
  11804. 0,
  11805. 0,
  11806. 0,
  11807. 0,
  11808. 0,
  11809. 0,
  11810. 0,
  11811. 0,
  11812. 0,
  11813. 0,
  11814. 0,
  11815. 0,
  11816. 0,
  11817. 0,
  11818. 0,
  11819. 0,
  11820. 0,
  11821. 0,
  11822. 0,
  11823. 0,
  11824. 0,
  11825. 0,
  11826. 0,
  11827. 0,
  11828. 0,
  11829. 0,
  11830. 0,
  11831. 0,
  11832. 0,
  11833. 0,
  11834. 0,
  11835. 0,
  11836. 0,
  11837. 0,
  11838. 0,
  11839. 0,
  11840. 0,
  11841. 0,
  11842. 0,
  11843. 0,
  11844. 0,
  11845. 0,
  11846. 0,
  11847. 0,
  11848. 0,
  11849. 0,
  11850. 0,
  11851. 0,
  11852. 0,
  11853. 0,
  11854. 0,
  11855. 0,
  11856. 0,
  11857. 0,
  11858. 0,
  11859. 0,
  11860. 0,
  11861. 0,
  11862. 0,
  11863. 0,
  11864. 0,
  11865. 0,
  11866. 0,
  11867. 0,
  11868. 0,
  11869. 0,
  11870. 0,
  11871. 0,
  11872. 0,
  11873. 0,
  11874. 0,
  11875. 0,
  11876. 0,
  11877. 0,
  11878. 0,
  11879. 0,
  11880. 0,
  11881. 0,
  11882. 0,
  11883. 0,
  11884. 0,
  11885. 0,
  11886. 0,
  11887. 0,
  11888. 0,
  11889. 0,
  11890. 0,
  11891. 0,
  11892. 0,
  11893. 0,
  11894. 0,
  11895. 0,
  11896. 0,
  11897. 0,
  11898. 0,
  11899. 0,
  11900. 0
  11901. ];
  11902. function toHexDigit(ch) {
  11903. if (ch >= 0x30 && ch <= 0x39) {
  11904. return ch & 0x0F;
  11905. }
  11906. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  11907. return (ch & 0x0F) + 9;
  11908. }
  11909. return -1;
  11910. }
  11911. Lexer.prototype = {
  11912. nextChar: function Lexer_nextChar() {
  11913. return this.currentChar = this.stream.getByte();
  11914. },
  11915. peekChar: function Lexer_peekChar() {
  11916. return this.stream.peekByte();
  11917. },
  11918. getNumber: function Lexer_getNumber() {
  11919. var ch = this.currentChar;
  11920. var eNotation = false;
  11921. var divideBy = 0;
  11922. var sign = 1;
  11923. if (ch === 0x2D) {
  11924. sign = -1;
  11925. ch = this.nextChar();
  11926. if (ch === 0x2D) {
  11927. ch = this.nextChar();
  11928. }
  11929. } else if (ch === 0x2B) {
  11930. ch = this.nextChar();
  11931. }
  11932. if (ch === 0x2E) {
  11933. divideBy = 10;
  11934. ch = this.nextChar();
  11935. }
  11936. if (ch < 0x30 || ch > 0x39) {
  11937. error('Invalid number: ' + String.fromCharCode(ch));
  11938. return 0;
  11939. }
  11940. var baseValue = ch - 0x30;
  11941. var powerValue = 0;
  11942. var powerValueSign = 1;
  11943. while ((ch = this.nextChar()) >= 0) {
  11944. if (0x30 <= ch && ch <= 0x39) {
  11945. var currentDigit = ch - 0x30;
  11946. if (eNotation) {
  11947. powerValue = powerValue * 10 + currentDigit;
  11948. } else {
  11949. if (divideBy !== 0) {
  11950. divideBy *= 10;
  11951. }
  11952. baseValue = baseValue * 10 + currentDigit;
  11953. }
  11954. } else if (ch === 0x2E) {
  11955. if (divideBy === 0) {
  11956. divideBy = 1;
  11957. } else {
  11958. break;
  11959. }
  11960. } else if (ch === 0x2D) {
  11961. warn('Badly formatted number');
  11962. } else if (ch === 0x45 || ch === 0x65) {
  11963. ch = this.peekChar();
  11964. if (ch === 0x2B || ch === 0x2D) {
  11965. powerValueSign = ch === 0x2D ? -1 : 1;
  11966. this.nextChar();
  11967. } else if (ch < 0x30 || ch > 0x39) {
  11968. break;
  11969. }
  11970. eNotation = true;
  11971. } else {
  11972. break;
  11973. }
  11974. }
  11975. if (divideBy !== 0) {
  11976. baseValue /= divideBy;
  11977. }
  11978. if (eNotation) {
  11979. baseValue *= Math.pow(10, powerValueSign * powerValue);
  11980. }
  11981. return sign * baseValue;
  11982. },
  11983. getString: function Lexer_getString() {
  11984. var numParen = 1;
  11985. var done = false;
  11986. var strBuf = this.strBuf;
  11987. strBuf.length = 0;
  11988. var ch = this.nextChar();
  11989. while (true) {
  11990. var charBuffered = false;
  11991. switch (ch | 0) {
  11992. case -1:
  11993. warn('Unterminated string');
  11994. done = true;
  11995. break;
  11996. case 0x28:
  11997. ++numParen;
  11998. strBuf.push('(');
  11999. break;
  12000. case 0x29:
  12001. if (--numParen === 0) {
  12002. this.nextChar();
  12003. done = true;
  12004. } else {
  12005. strBuf.push(')');
  12006. }
  12007. break;
  12008. case 0x5C:
  12009. ch = this.nextChar();
  12010. switch (ch) {
  12011. case -1:
  12012. warn('Unterminated string');
  12013. done = true;
  12014. break;
  12015. case 0x6E:
  12016. strBuf.push('\n');
  12017. break;
  12018. case 0x72:
  12019. strBuf.push('\r');
  12020. break;
  12021. case 0x74:
  12022. strBuf.push('\t');
  12023. break;
  12024. case 0x62:
  12025. strBuf.push('\b');
  12026. break;
  12027. case 0x66:
  12028. strBuf.push('\f');
  12029. break;
  12030. case 0x5C:
  12031. case 0x28:
  12032. case 0x29:
  12033. strBuf.push(String.fromCharCode(ch));
  12034. break;
  12035. case 0x30:
  12036. case 0x31:
  12037. case 0x32:
  12038. case 0x33:
  12039. case 0x34:
  12040. case 0x35:
  12041. case 0x36:
  12042. case 0x37:
  12043. var x = ch & 0x0F;
  12044. ch = this.nextChar();
  12045. charBuffered = true;
  12046. if (ch >= 0x30 && ch <= 0x37) {
  12047. x = (x << 3) + (ch & 0x0F);
  12048. ch = this.nextChar();
  12049. if (ch >= 0x30 && ch <= 0x37) {
  12050. charBuffered = false;
  12051. x = (x << 3) + (ch & 0x0F);
  12052. }
  12053. }
  12054. strBuf.push(String.fromCharCode(x));
  12055. break;
  12056. case 0x0D:
  12057. if (this.peekChar() === 0x0A) {
  12058. this.nextChar();
  12059. }
  12060. break;
  12061. case 0x0A:
  12062. break;
  12063. default:
  12064. strBuf.push(String.fromCharCode(ch));
  12065. break;
  12066. }
  12067. break;
  12068. default:
  12069. strBuf.push(String.fromCharCode(ch));
  12070. break;
  12071. }
  12072. if (done) {
  12073. break;
  12074. }
  12075. if (!charBuffered) {
  12076. ch = this.nextChar();
  12077. }
  12078. }
  12079. return strBuf.join('');
  12080. },
  12081. getName: function Lexer_getName() {
  12082. var ch, previousCh;
  12083. var strBuf = this.strBuf;
  12084. strBuf.length = 0;
  12085. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  12086. if (ch === 0x23) {
  12087. ch = this.nextChar();
  12088. if (specialChars[ch]) {
  12089. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  12090. strBuf.push('#');
  12091. break;
  12092. }
  12093. var x = toHexDigit(ch);
  12094. if (x !== -1) {
  12095. previousCh = ch;
  12096. ch = this.nextChar();
  12097. var x2 = toHexDigit(ch);
  12098. if (x2 === -1) {
  12099. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  12100. strBuf.push('#', String.fromCharCode(previousCh));
  12101. if (specialChars[ch]) {
  12102. break;
  12103. }
  12104. strBuf.push(String.fromCharCode(ch));
  12105. continue;
  12106. }
  12107. strBuf.push(String.fromCharCode(x << 4 | x2));
  12108. } else {
  12109. strBuf.push('#', String.fromCharCode(ch));
  12110. }
  12111. } else {
  12112. strBuf.push(String.fromCharCode(ch));
  12113. }
  12114. }
  12115. if (strBuf.length > 127) {
  12116. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  12117. }
  12118. return Name.get(strBuf.join(''));
  12119. },
  12120. getHexString: function Lexer_getHexString() {
  12121. var strBuf = this.strBuf;
  12122. strBuf.length = 0;
  12123. var ch = this.currentChar;
  12124. var isFirstHex = true;
  12125. var firstDigit;
  12126. var secondDigit;
  12127. while (true) {
  12128. if (ch < 0) {
  12129. warn('Unterminated hex string');
  12130. break;
  12131. } else if (ch === 0x3E) {
  12132. this.nextChar();
  12133. break;
  12134. } else if (specialChars[ch] === 1) {
  12135. ch = this.nextChar();
  12136. continue;
  12137. } else {
  12138. if (isFirstHex) {
  12139. firstDigit = toHexDigit(ch);
  12140. if (firstDigit === -1) {
  12141. warn('Ignoring invalid character "' + ch + '" in hex string');
  12142. ch = this.nextChar();
  12143. continue;
  12144. }
  12145. } else {
  12146. secondDigit = toHexDigit(ch);
  12147. if (secondDigit === -1) {
  12148. warn('Ignoring invalid character "' + ch + '" in hex string');
  12149. ch = this.nextChar();
  12150. continue;
  12151. }
  12152. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  12153. }
  12154. isFirstHex = !isFirstHex;
  12155. ch = this.nextChar();
  12156. }
  12157. }
  12158. return strBuf.join('');
  12159. },
  12160. getObj: function Lexer_getObj() {
  12161. var comment = false;
  12162. var ch = this.currentChar;
  12163. while (true) {
  12164. if (ch < 0) {
  12165. return EOF;
  12166. }
  12167. if (comment) {
  12168. if (ch === 0x0A || ch === 0x0D) {
  12169. comment = false;
  12170. }
  12171. } else if (ch === 0x25) {
  12172. comment = true;
  12173. } else if (specialChars[ch] !== 1) {
  12174. break;
  12175. }
  12176. ch = this.nextChar();
  12177. }
  12178. switch (ch | 0) {
  12179. case 0x30:
  12180. case 0x31:
  12181. case 0x32:
  12182. case 0x33:
  12183. case 0x34:
  12184. case 0x35:
  12185. case 0x36:
  12186. case 0x37:
  12187. case 0x38:
  12188. case 0x39:
  12189. case 0x2B:
  12190. case 0x2D:
  12191. case 0x2E:
  12192. return this.getNumber();
  12193. case 0x28:
  12194. return this.getString();
  12195. case 0x2F:
  12196. return this.getName();
  12197. case 0x5B:
  12198. this.nextChar();
  12199. return Cmd.get('[');
  12200. case 0x5D:
  12201. this.nextChar();
  12202. return Cmd.get(']');
  12203. case 0x3C:
  12204. ch = this.nextChar();
  12205. if (ch === 0x3C) {
  12206. this.nextChar();
  12207. return Cmd.get('<<');
  12208. }
  12209. return this.getHexString();
  12210. case 0x3E:
  12211. ch = this.nextChar();
  12212. if (ch === 0x3E) {
  12213. this.nextChar();
  12214. return Cmd.get('>>');
  12215. }
  12216. return Cmd.get('>');
  12217. case 0x7B:
  12218. this.nextChar();
  12219. return Cmd.get('{');
  12220. case 0x7D:
  12221. this.nextChar();
  12222. return Cmd.get('}');
  12223. case 0x29:
  12224. this.nextChar();
  12225. error('Illegal character: ' + ch);
  12226. break;
  12227. }
  12228. var str = String.fromCharCode(ch);
  12229. var knownCommands = this.knownCommands;
  12230. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  12231. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  12232. var possibleCommand = str + String.fromCharCode(ch);
  12233. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  12234. break;
  12235. }
  12236. if (str.length === 128) {
  12237. error('Command token too long: ' + str.length);
  12238. }
  12239. str = possibleCommand;
  12240. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  12241. }
  12242. if (str === 'true') {
  12243. return true;
  12244. }
  12245. if (str === 'false') {
  12246. return false;
  12247. }
  12248. if (str === 'null') {
  12249. return null;
  12250. }
  12251. return Cmd.get(str);
  12252. },
  12253. skipToNextLine: function Lexer_skipToNextLine() {
  12254. var ch = this.currentChar;
  12255. while (ch >= 0) {
  12256. if (ch === 0x0D) {
  12257. ch = this.nextChar();
  12258. if (ch === 0x0A) {
  12259. this.nextChar();
  12260. }
  12261. break;
  12262. } else if (ch === 0x0A) {
  12263. this.nextChar();
  12264. break;
  12265. }
  12266. ch = this.nextChar();
  12267. }
  12268. }
  12269. };
  12270. return Lexer;
  12271. }();
  12272. var Linearization = {
  12273. create: function LinearizationCreate(stream) {
  12274. function getInt(name, allowZeroValue) {
  12275. var obj = linDict.get(name);
  12276. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  12277. return obj;
  12278. }
  12279. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  12280. }
  12281. function getHints() {
  12282. var hints = linDict.get('H'), hintsLength, item;
  12283. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  12284. for (var index = 0; index < hintsLength; index++) {
  12285. if (!(isInt(item = hints[index]) && item > 0)) {
  12286. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  12287. }
  12288. }
  12289. return hints;
  12290. }
  12291. throw new Error('Hint array in the linearization dictionary is invalid.');
  12292. }
  12293. var parser = new Parser(new Lexer(stream), false, null);
  12294. var obj1 = parser.getObj();
  12295. var obj2 = parser.getObj();
  12296. var obj3 = parser.getObj();
  12297. var linDict = parser.getObj();
  12298. var obj, length;
  12299. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  12300. return null;
  12301. } else if ((length = getInt('L')) !== stream.length) {
  12302. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  12303. }
  12304. return {
  12305. length: length,
  12306. hints: getHints(),
  12307. objectNumberFirst: getInt('O'),
  12308. endFirst: getInt('E'),
  12309. numPages: getInt('N'),
  12310. mainXRefEntriesOffset: getInt('T'),
  12311. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  12312. };
  12313. }
  12314. };
  12315. exports.Lexer = Lexer;
  12316. exports.Linearization = Linearization;
  12317. exports.Parser = Parser;
  12318. /***/ }),
  12319. /* 6 */
  12320. /***/ (function(module, exports, __w_pdfjs_require__) {
  12321. "use strict";
  12322. var sharedUtil = __w_pdfjs_require__(0);
  12323. var corePrimitives = __w_pdfjs_require__(1);
  12324. var corePsParser = __w_pdfjs_require__(34);
  12325. var error = sharedUtil.error;
  12326. var info = sharedUtil.info;
  12327. var isArray = sharedUtil.isArray;
  12328. var isBool = sharedUtil.isBool;
  12329. var isDict = corePrimitives.isDict;
  12330. var isStream = corePrimitives.isStream;
  12331. var PostScriptLexer = corePsParser.PostScriptLexer;
  12332. var PostScriptParser = corePsParser.PostScriptParser;
  12333. var PDFFunction = function PDFFunctionClosure() {
  12334. var CONSTRUCT_SAMPLED = 0;
  12335. var CONSTRUCT_INTERPOLATED = 2;
  12336. var CONSTRUCT_STICHED = 3;
  12337. var CONSTRUCT_POSTSCRIPT = 4;
  12338. return {
  12339. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  12340. var i, ii;
  12341. var length = 1;
  12342. for (i = 0, ii = size.length; i < ii; i++) {
  12343. length *= size[i];
  12344. }
  12345. length *= outputSize;
  12346. var array = new Array(length);
  12347. var codeSize = 0;
  12348. var codeBuf = 0;
  12349. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  12350. var strBytes = str.getBytes((length * bps + 7) / 8);
  12351. var strIdx = 0;
  12352. for (i = 0; i < length; i++) {
  12353. while (codeSize < bps) {
  12354. codeBuf <<= 8;
  12355. codeBuf |= strBytes[strIdx++];
  12356. codeSize += 8;
  12357. }
  12358. codeSize -= bps;
  12359. array[i] = (codeBuf >> codeSize) * sampleMul;
  12360. codeBuf &= (1 << codeSize) - 1;
  12361. }
  12362. return array;
  12363. },
  12364. getIR: function PDFFunction_getIR(xref, fn) {
  12365. var dict = fn.dict;
  12366. if (!dict) {
  12367. dict = fn;
  12368. }
  12369. var types = [
  12370. this.constructSampled,
  12371. null,
  12372. this.constructInterpolated,
  12373. this.constructStiched,
  12374. this.constructPostScript
  12375. ];
  12376. var typeNum = dict.get('FunctionType');
  12377. var typeFn = types[typeNum];
  12378. if (!typeFn) {
  12379. error('Unknown type of function');
  12380. }
  12381. return typeFn.call(this, fn, dict, xref);
  12382. },
  12383. fromIR: function PDFFunction_fromIR(IR) {
  12384. var type = IR[0];
  12385. switch (type) {
  12386. case CONSTRUCT_SAMPLED:
  12387. return this.constructSampledFromIR(IR);
  12388. case CONSTRUCT_INTERPOLATED:
  12389. return this.constructInterpolatedFromIR(IR);
  12390. case CONSTRUCT_STICHED:
  12391. return this.constructStichedFromIR(IR);
  12392. default:
  12393. return this.constructPostScriptFromIR(IR);
  12394. }
  12395. },
  12396. parse: function PDFFunction_parse(xref, fn) {
  12397. var IR = this.getIR(xref, fn);
  12398. return this.fromIR(IR);
  12399. },
  12400. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  12401. if (!isArray(fnObj)) {
  12402. return this.parse(xref, fnObj);
  12403. }
  12404. var fnArray = [];
  12405. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  12406. var obj = xref.fetchIfRef(fnObj[j]);
  12407. fnArray.push(PDFFunction.parse(xref, obj));
  12408. }
  12409. return function (src, srcOffset, dest, destOffset) {
  12410. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  12411. fnArray[i](src, srcOffset, dest, destOffset + i);
  12412. }
  12413. };
  12414. },
  12415. constructSampled: function PDFFunction_constructSampled(str, dict) {
  12416. function toMultiArray(arr) {
  12417. var inputLength = arr.length;
  12418. var out = [];
  12419. var index = 0;
  12420. for (var i = 0; i < inputLength; i += 2) {
  12421. out[index] = [
  12422. arr[i],
  12423. arr[i + 1]
  12424. ];
  12425. ++index;
  12426. }
  12427. return out;
  12428. }
  12429. var domain = dict.getArray('Domain');
  12430. var range = dict.getArray('Range');
  12431. if (!domain || !range) {
  12432. error('No domain or range');
  12433. }
  12434. var inputSize = domain.length / 2;
  12435. var outputSize = range.length / 2;
  12436. domain = toMultiArray(domain);
  12437. range = toMultiArray(range);
  12438. var size = dict.get('Size');
  12439. var bps = dict.get('BitsPerSample');
  12440. var order = dict.get('Order') || 1;
  12441. if (order !== 1) {
  12442. info('No support for cubic spline interpolation: ' + order);
  12443. }
  12444. var encode = dict.getArray('Encode');
  12445. if (!encode) {
  12446. encode = [];
  12447. for (var i = 0; i < inputSize; ++i) {
  12448. encode.push(0);
  12449. encode.push(size[i] - 1);
  12450. }
  12451. }
  12452. encode = toMultiArray(encode);
  12453. var decode = dict.getArray('Decode');
  12454. if (!decode) {
  12455. decode = range;
  12456. } else {
  12457. decode = toMultiArray(decode);
  12458. }
  12459. var samples = this.getSampleArray(size, outputSize, bps, str);
  12460. return [
  12461. CONSTRUCT_SAMPLED,
  12462. inputSize,
  12463. domain,
  12464. encode,
  12465. decode,
  12466. samples,
  12467. size,
  12468. outputSize,
  12469. Math.pow(2, bps) - 1,
  12470. range
  12471. ];
  12472. },
  12473. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  12474. function interpolate(x, xmin, xmax, ymin, ymax) {
  12475. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  12476. }
  12477. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  12478. var m = IR[1];
  12479. var domain = IR[2];
  12480. var encode = IR[3];
  12481. var decode = IR[4];
  12482. var samples = IR[5];
  12483. var size = IR[6];
  12484. var n = IR[7];
  12485. var range = IR[9];
  12486. var cubeVertices = 1 << m;
  12487. var cubeN = new Float64Array(cubeVertices);
  12488. var cubeVertex = new Uint32Array(cubeVertices);
  12489. var i, j;
  12490. for (j = 0; j < cubeVertices; j++) {
  12491. cubeN[j] = 1;
  12492. }
  12493. var k = n, pos = 1;
  12494. for (i = 0; i < m; ++i) {
  12495. var domain_2i = domain[i][0];
  12496. var domain_2i_1 = domain[i][1];
  12497. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  12498. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  12499. var size_i = size[i];
  12500. e = Math.min(Math.max(e, 0), size_i - 1);
  12501. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  12502. var n0 = e0 + 1 - e;
  12503. var n1 = e - e0;
  12504. var offset0 = e0 * k;
  12505. var offset1 = offset0 + k;
  12506. for (j = 0; j < cubeVertices; j++) {
  12507. if (j & pos) {
  12508. cubeN[j] *= n1;
  12509. cubeVertex[j] += offset1;
  12510. } else {
  12511. cubeN[j] *= n0;
  12512. cubeVertex[j] += offset0;
  12513. }
  12514. }
  12515. k *= size_i;
  12516. pos <<= 1;
  12517. }
  12518. for (j = 0; j < n; ++j) {
  12519. var rj = 0;
  12520. for (i = 0; i < cubeVertices; i++) {
  12521. rj += samples[cubeVertex[i] + j] * cubeN[i];
  12522. }
  12523. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  12524. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  12525. }
  12526. };
  12527. },
  12528. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  12529. var c0 = dict.getArray('C0') || [0];
  12530. var c1 = dict.getArray('C1') || [1];
  12531. var n = dict.get('N');
  12532. if (!isArray(c0) || !isArray(c1)) {
  12533. error('Illegal dictionary for interpolated function');
  12534. }
  12535. var length = c0.length;
  12536. var diff = [];
  12537. for (var i = 0; i < length; ++i) {
  12538. diff.push(c1[i] - c0[i]);
  12539. }
  12540. return [
  12541. CONSTRUCT_INTERPOLATED,
  12542. c0,
  12543. diff,
  12544. n
  12545. ];
  12546. },
  12547. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  12548. var c0 = IR[1];
  12549. var diff = IR[2];
  12550. var n = IR[3];
  12551. var length = diff.length;
  12552. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  12553. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  12554. for (var j = 0; j < length; ++j) {
  12555. dest[destOffset + j] = c0[j] + x * diff[j];
  12556. }
  12557. };
  12558. },
  12559. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  12560. var domain = dict.getArray('Domain');
  12561. if (!domain) {
  12562. error('No domain');
  12563. }
  12564. var inputSize = domain.length / 2;
  12565. if (inputSize !== 1) {
  12566. error('Bad domain for stiched function');
  12567. }
  12568. var fnRefs = dict.get('Functions');
  12569. var fns = [];
  12570. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  12571. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  12572. }
  12573. var bounds = dict.getArray('Bounds');
  12574. var encode = dict.getArray('Encode');
  12575. return [
  12576. CONSTRUCT_STICHED,
  12577. domain,
  12578. bounds,
  12579. encode,
  12580. fns
  12581. ];
  12582. },
  12583. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  12584. var domain = IR[1];
  12585. var bounds = IR[2];
  12586. var encode = IR[3];
  12587. var fnsIR = IR[4];
  12588. var fns = [];
  12589. var tmpBuf = new Float32Array(1);
  12590. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  12591. fns.push(PDFFunction.fromIR(fnsIR[i]));
  12592. }
  12593. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  12594. var clip = function constructStichedFromIRClip(v, min, max) {
  12595. if (v > max) {
  12596. v = max;
  12597. } else if (v < min) {
  12598. v = min;
  12599. }
  12600. return v;
  12601. };
  12602. var v = clip(src[srcOffset], domain[0], domain[1]);
  12603. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  12604. if (v < bounds[i]) {
  12605. break;
  12606. }
  12607. }
  12608. var dmin = domain[0];
  12609. if (i > 0) {
  12610. dmin = bounds[i - 1];
  12611. }
  12612. var dmax = domain[1];
  12613. if (i < bounds.length) {
  12614. dmax = bounds[i];
  12615. }
  12616. var rmin = encode[2 * i];
  12617. var rmax = encode[2 * i + 1];
  12618. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  12619. fns[i](tmpBuf, 0, dest, destOffset);
  12620. };
  12621. },
  12622. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  12623. var domain = dict.getArray('Domain');
  12624. var range = dict.getArray('Range');
  12625. if (!domain) {
  12626. error('No domain.');
  12627. }
  12628. if (!range) {
  12629. error('No range.');
  12630. }
  12631. var lexer = new PostScriptLexer(fn);
  12632. var parser = new PostScriptParser(lexer);
  12633. var code = parser.parse();
  12634. return [
  12635. CONSTRUCT_POSTSCRIPT,
  12636. domain,
  12637. range,
  12638. code
  12639. ];
  12640. },
  12641. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  12642. var domain = IR[1];
  12643. var range = IR[2];
  12644. var code = IR[3];
  12645. var compiled = new PostScriptCompiler().compile(code, domain, range);
  12646. if (compiled) {
  12647. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  12648. }
  12649. info('Unable to compile PS function');
  12650. var numOutputs = range.length >> 1;
  12651. var numInputs = domain.length >> 1;
  12652. var evaluator = new PostScriptEvaluator(code);
  12653. var cache = Object.create(null);
  12654. var MAX_CACHE_SIZE = 2048 * 4;
  12655. var cache_available = MAX_CACHE_SIZE;
  12656. var tmpBuf = new Float32Array(numInputs);
  12657. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  12658. var i, value;
  12659. var key = '';
  12660. var input = tmpBuf;
  12661. for (i = 0; i < numInputs; i++) {
  12662. value = src[srcOffset + i];
  12663. input[i] = value;
  12664. key += value + '_';
  12665. }
  12666. var cachedValue = cache[key];
  12667. if (cachedValue !== undefined) {
  12668. dest.set(cachedValue, destOffset);
  12669. return;
  12670. }
  12671. var output = new Float32Array(numOutputs);
  12672. var stack = evaluator.execute(input);
  12673. var stackIndex = stack.length - numOutputs;
  12674. for (i = 0; i < numOutputs; i++) {
  12675. value = stack[stackIndex + i];
  12676. var bound = range[i * 2];
  12677. if (value < bound) {
  12678. value = bound;
  12679. } else {
  12680. bound = range[i * 2 + 1];
  12681. if (value > bound) {
  12682. value = bound;
  12683. }
  12684. }
  12685. output[i] = value;
  12686. }
  12687. if (cache_available > 0) {
  12688. cache_available--;
  12689. cache[key] = output;
  12690. }
  12691. dest.set(output, destOffset);
  12692. };
  12693. }
  12694. };
  12695. }();
  12696. function isPDFFunction(v) {
  12697. var fnDict;
  12698. if (typeof v !== 'object') {
  12699. return false;
  12700. } else if (isDict(v)) {
  12701. fnDict = v;
  12702. } else if (isStream(v)) {
  12703. fnDict = v.dict;
  12704. } else {
  12705. return false;
  12706. }
  12707. return fnDict.has('FunctionType');
  12708. }
  12709. var PostScriptStack = function PostScriptStackClosure() {
  12710. var MAX_STACK_SIZE = 100;
  12711. function PostScriptStack(initialStack) {
  12712. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  12713. }
  12714. PostScriptStack.prototype = {
  12715. push: function PostScriptStack_push(value) {
  12716. if (this.stack.length >= MAX_STACK_SIZE) {
  12717. error('PostScript function stack overflow.');
  12718. }
  12719. this.stack.push(value);
  12720. },
  12721. pop: function PostScriptStack_pop() {
  12722. if (this.stack.length <= 0) {
  12723. error('PostScript function stack underflow.');
  12724. }
  12725. return this.stack.pop();
  12726. },
  12727. copy: function PostScriptStack_copy(n) {
  12728. if (this.stack.length + n >= MAX_STACK_SIZE) {
  12729. error('PostScript function stack overflow.');
  12730. }
  12731. var stack = this.stack;
  12732. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  12733. stack.push(stack[i]);
  12734. }
  12735. },
  12736. index: function PostScriptStack_index(n) {
  12737. this.push(this.stack[this.stack.length - n - 1]);
  12738. },
  12739. roll: function PostScriptStack_roll(n, p) {
  12740. var stack = this.stack;
  12741. var l = stack.length - n;
  12742. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  12743. for (i = l, j = r; i < j; i++, j--) {
  12744. t = stack[i];
  12745. stack[i] = stack[j];
  12746. stack[j] = t;
  12747. }
  12748. for (i = l, j = c - 1; i < j; i++, j--) {
  12749. t = stack[i];
  12750. stack[i] = stack[j];
  12751. stack[j] = t;
  12752. }
  12753. for (i = c, j = r; i < j; i++, j--) {
  12754. t = stack[i];
  12755. stack[i] = stack[j];
  12756. stack[j] = t;
  12757. }
  12758. }
  12759. };
  12760. return PostScriptStack;
  12761. }();
  12762. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  12763. function PostScriptEvaluator(operators) {
  12764. this.operators = operators;
  12765. }
  12766. PostScriptEvaluator.prototype = {
  12767. execute: function PostScriptEvaluator_execute(initialStack) {
  12768. var stack = new PostScriptStack(initialStack);
  12769. var counter = 0;
  12770. var operators = this.operators;
  12771. var length = operators.length;
  12772. var operator, a, b;
  12773. while (counter < length) {
  12774. operator = operators[counter++];
  12775. if (typeof operator === 'number') {
  12776. stack.push(operator);
  12777. continue;
  12778. }
  12779. switch (operator) {
  12780. case 'jz':
  12781. b = stack.pop();
  12782. a = stack.pop();
  12783. if (!a) {
  12784. counter = b;
  12785. }
  12786. break;
  12787. case 'j':
  12788. a = stack.pop();
  12789. counter = a;
  12790. break;
  12791. case 'abs':
  12792. a = stack.pop();
  12793. stack.push(Math.abs(a));
  12794. break;
  12795. case 'add':
  12796. b = stack.pop();
  12797. a = stack.pop();
  12798. stack.push(a + b);
  12799. break;
  12800. case 'and':
  12801. b = stack.pop();
  12802. a = stack.pop();
  12803. if (isBool(a) && isBool(b)) {
  12804. stack.push(a && b);
  12805. } else {
  12806. stack.push(a & b);
  12807. }
  12808. break;
  12809. case 'atan':
  12810. a = stack.pop();
  12811. stack.push(Math.atan(a));
  12812. break;
  12813. case 'bitshift':
  12814. b = stack.pop();
  12815. a = stack.pop();
  12816. if (a > 0) {
  12817. stack.push(a << b);
  12818. } else {
  12819. stack.push(a >> b);
  12820. }
  12821. break;
  12822. case 'ceiling':
  12823. a = stack.pop();
  12824. stack.push(Math.ceil(a));
  12825. break;
  12826. case 'copy':
  12827. a = stack.pop();
  12828. stack.copy(a);
  12829. break;
  12830. case 'cos':
  12831. a = stack.pop();
  12832. stack.push(Math.cos(a));
  12833. break;
  12834. case 'cvi':
  12835. a = stack.pop() | 0;
  12836. stack.push(a);
  12837. break;
  12838. case 'cvr':
  12839. break;
  12840. case 'div':
  12841. b = stack.pop();
  12842. a = stack.pop();
  12843. stack.push(a / b);
  12844. break;
  12845. case 'dup':
  12846. stack.copy(1);
  12847. break;
  12848. case 'eq':
  12849. b = stack.pop();
  12850. a = stack.pop();
  12851. stack.push(a === b);
  12852. break;
  12853. case 'exch':
  12854. stack.roll(2, 1);
  12855. break;
  12856. case 'exp':
  12857. b = stack.pop();
  12858. a = stack.pop();
  12859. stack.push(Math.pow(a, b));
  12860. break;
  12861. case 'false':
  12862. stack.push(false);
  12863. break;
  12864. case 'floor':
  12865. a = stack.pop();
  12866. stack.push(Math.floor(a));
  12867. break;
  12868. case 'ge':
  12869. b = stack.pop();
  12870. a = stack.pop();
  12871. stack.push(a >= b);
  12872. break;
  12873. case 'gt':
  12874. b = stack.pop();
  12875. a = stack.pop();
  12876. stack.push(a > b);
  12877. break;
  12878. case 'idiv':
  12879. b = stack.pop();
  12880. a = stack.pop();
  12881. stack.push(a / b | 0);
  12882. break;
  12883. case 'index':
  12884. a = stack.pop();
  12885. stack.index(a);
  12886. break;
  12887. case 'le':
  12888. b = stack.pop();
  12889. a = stack.pop();
  12890. stack.push(a <= b);
  12891. break;
  12892. case 'ln':
  12893. a = stack.pop();
  12894. stack.push(Math.log(a));
  12895. break;
  12896. case 'log':
  12897. a = stack.pop();
  12898. stack.push(Math.log(a) / Math.LN10);
  12899. break;
  12900. case 'lt':
  12901. b = stack.pop();
  12902. a = stack.pop();
  12903. stack.push(a < b);
  12904. break;
  12905. case 'mod':
  12906. b = stack.pop();
  12907. a = stack.pop();
  12908. stack.push(a % b);
  12909. break;
  12910. case 'mul':
  12911. b = stack.pop();
  12912. a = stack.pop();
  12913. stack.push(a * b);
  12914. break;
  12915. case 'ne':
  12916. b = stack.pop();
  12917. a = stack.pop();
  12918. stack.push(a !== b);
  12919. break;
  12920. case 'neg':
  12921. a = stack.pop();
  12922. stack.push(-a);
  12923. break;
  12924. case 'not':
  12925. a = stack.pop();
  12926. if (isBool(a)) {
  12927. stack.push(!a);
  12928. } else {
  12929. stack.push(~a);
  12930. }
  12931. break;
  12932. case 'or':
  12933. b = stack.pop();
  12934. a = stack.pop();
  12935. if (isBool(a) && isBool(b)) {
  12936. stack.push(a || b);
  12937. } else {
  12938. stack.push(a | b);
  12939. }
  12940. break;
  12941. case 'pop':
  12942. stack.pop();
  12943. break;
  12944. case 'roll':
  12945. b = stack.pop();
  12946. a = stack.pop();
  12947. stack.roll(a, b);
  12948. break;
  12949. case 'round':
  12950. a = stack.pop();
  12951. stack.push(Math.round(a));
  12952. break;
  12953. case 'sin':
  12954. a = stack.pop();
  12955. stack.push(Math.sin(a));
  12956. break;
  12957. case 'sqrt':
  12958. a = stack.pop();
  12959. stack.push(Math.sqrt(a));
  12960. break;
  12961. case 'sub':
  12962. b = stack.pop();
  12963. a = stack.pop();
  12964. stack.push(a - b);
  12965. break;
  12966. case 'true':
  12967. stack.push(true);
  12968. break;
  12969. case 'truncate':
  12970. a = stack.pop();
  12971. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  12972. stack.push(a);
  12973. break;
  12974. case 'xor':
  12975. b = stack.pop();
  12976. a = stack.pop();
  12977. if (isBool(a) && isBool(b)) {
  12978. stack.push(a !== b);
  12979. } else {
  12980. stack.push(a ^ b);
  12981. }
  12982. break;
  12983. default:
  12984. error('Unknown operator ' + operator);
  12985. break;
  12986. }
  12987. }
  12988. return stack.stack;
  12989. }
  12990. };
  12991. return PostScriptEvaluator;
  12992. }();
  12993. var PostScriptCompiler = function PostScriptCompilerClosure() {
  12994. function AstNode(type) {
  12995. this.type = type;
  12996. }
  12997. AstNode.prototype.visit = function (visitor) {
  12998. throw new Error('abstract method');
  12999. };
  13000. function AstArgument(index, min, max) {
  13001. AstNode.call(this, 'args');
  13002. this.index = index;
  13003. this.min = min;
  13004. this.max = max;
  13005. }
  13006. AstArgument.prototype = Object.create(AstNode.prototype);
  13007. AstArgument.prototype.visit = function (visitor) {
  13008. visitor.visitArgument(this);
  13009. };
  13010. function AstLiteral(number) {
  13011. AstNode.call(this, 'literal');
  13012. this.number = number;
  13013. this.min = number;
  13014. this.max = number;
  13015. }
  13016. AstLiteral.prototype = Object.create(AstNode.prototype);
  13017. AstLiteral.prototype.visit = function (visitor) {
  13018. visitor.visitLiteral(this);
  13019. };
  13020. function AstBinaryOperation(op, arg1, arg2, min, max) {
  13021. AstNode.call(this, 'binary');
  13022. this.op = op;
  13023. this.arg1 = arg1;
  13024. this.arg2 = arg2;
  13025. this.min = min;
  13026. this.max = max;
  13027. }
  13028. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  13029. AstBinaryOperation.prototype.visit = function (visitor) {
  13030. visitor.visitBinaryOperation(this);
  13031. };
  13032. function AstMin(arg, max) {
  13033. AstNode.call(this, 'max');
  13034. this.arg = arg;
  13035. this.min = arg.min;
  13036. this.max = max;
  13037. }
  13038. AstMin.prototype = Object.create(AstNode.prototype);
  13039. AstMin.prototype.visit = function (visitor) {
  13040. visitor.visitMin(this);
  13041. };
  13042. function AstVariable(index, min, max) {
  13043. AstNode.call(this, 'var');
  13044. this.index = index;
  13045. this.min = min;
  13046. this.max = max;
  13047. }
  13048. AstVariable.prototype = Object.create(AstNode.prototype);
  13049. AstVariable.prototype.visit = function (visitor) {
  13050. visitor.visitVariable(this);
  13051. };
  13052. function AstVariableDefinition(variable, arg) {
  13053. AstNode.call(this, 'definition');
  13054. this.variable = variable;
  13055. this.arg = arg;
  13056. }
  13057. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  13058. AstVariableDefinition.prototype.visit = function (visitor) {
  13059. visitor.visitVariableDefinition(this);
  13060. };
  13061. function ExpressionBuilderVisitor() {
  13062. this.parts = [];
  13063. }
  13064. ExpressionBuilderVisitor.prototype = {
  13065. visitArgument: function (arg) {
  13066. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  13067. },
  13068. visitVariable: function (variable) {
  13069. this.parts.push('v', variable.index);
  13070. },
  13071. visitLiteral: function (literal) {
  13072. this.parts.push(literal.number);
  13073. },
  13074. visitBinaryOperation: function (operation) {
  13075. this.parts.push('(');
  13076. operation.arg1.visit(this);
  13077. this.parts.push(' ', operation.op, ' ');
  13078. operation.arg2.visit(this);
  13079. this.parts.push(')');
  13080. },
  13081. visitVariableDefinition: function (definition) {
  13082. this.parts.push('var ');
  13083. definition.variable.visit(this);
  13084. this.parts.push(' = ');
  13085. definition.arg.visit(this);
  13086. this.parts.push(';');
  13087. },
  13088. visitMin: function (max) {
  13089. this.parts.push('Math.min(');
  13090. max.arg.visit(this);
  13091. this.parts.push(', ', max.max, ')');
  13092. },
  13093. toString: function () {
  13094. return this.parts.join('');
  13095. }
  13096. };
  13097. function buildAddOperation(num1, num2) {
  13098. if (num2.type === 'literal' && num2.number === 0) {
  13099. return num1;
  13100. }
  13101. if (num1.type === 'literal' && num1.number === 0) {
  13102. return num2;
  13103. }
  13104. if (num2.type === 'literal' && num1.type === 'literal') {
  13105. return new AstLiteral(num1.number + num2.number);
  13106. }
  13107. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  13108. }
  13109. function buildMulOperation(num1, num2) {
  13110. if (num2.type === 'literal') {
  13111. if (num2.number === 0) {
  13112. return new AstLiteral(0);
  13113. } else if (num2.number === 1) {
  13114. return num1;
  13115. } else if (num1.type === 'literal') {
  13116. return new AstLiteral(num1.number * num2.number);
  13117. }
  13118. }
  13119. if (num1.type === 'literal') {
  13120. if (num1.number === 0) {
  13121. return new AstLiteral(0);
  13122. } else if (num1.number === 1) {
  13123. return num2;
  13124. }
  13125. }
  13126. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  13127. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  13128. return new AstBinaryOperation('*', num1, num2, min, max);
  13129. }
  13130. function buildSubOperation(num1, num2) {
  13131. if (num2.type === 'literal') {
  13132. if (num2.number === 0) {
  13133. return num1;
  13134. } else if (num1.type === 'literal') {
  13135. return new AstLiteral(num1.number - num2.number);
  13136. }
  13137. }
  13138. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  13139. return num2.arg2;
  13140. }
  13141. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  13142. }
  13143. function buildMinOperation(num1, max) {
  13144. if (num1.min >= max) {
  13145. return new AstLiteral(max);
  13146. } else if (num1.max <= max) {
  13147. return num1;
  13148. }
  13149. return new AstMin(num1, max);
  13150. }
  13151. function PostScriptCompiler() {
  13152. }
  13153. PostScriptCompiler.prototype = {
  13154. compile: function PostScriptCompiler_compile(code, domain, range) {
  13155. var stack = [];
  13156. var i, ii;
  13157. var instructions = [];
  13158. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  13159. var lastRegister = 0;
  13160. var n, j;
  13161. var num1, num2, ast1, ast2, tmpVar, item;
  13162. for (i = 0; i < inputSize; i++) {
  13163. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  13164. }
  13165. for (i = 0, ii = code.length; i < ii; i++) {
  13166. item = code[i];
  13167. if (typeof item === 'number') {
  13168. stack.push(new AstLiteral(item));
  13169. continue;
  13170. }
  13171. switch (item) {
  13172. case 'add':
  13173. if (stack.length < 2) {
  13174. return null;
  13175. }
  13176. num2 = stack.pop();
  13177. num1 = stack.pop();
  13178. stack.push(buildAddOperation(num1, num2));
  13179. break;
  13180. case 'cvr':
  13181. if (stack.length < 1) {
  13182. return null;
  13183. }
  13184. break;
  13185. case 'mul':
  13186. if (stack.length < 2) {
  13187. return null;
  13188. }
  13189. num2 = stack.pop();
  13190. num1 = stack.pop();
  13191. stack.push(buildMulOperation(num1, num2));
  13192. break;
  13193. case 'sub':
  13194. if (stack.length < 2) {
  13195. return null;
  13196. }
  13197. num2 = stack.pop();
  13198. num1 = stack.pop();
  13199. stack.push(buildSubOperation(num1, num2));
  13200. break;
  13201. case 'exch':
  13202. if (stack.length < 2) {
  13203. return null;
  13204. }
  13205. ast1 = stack.pop();
  13206. ast2 = stack.pop();
  13207. stack.push(ast1, ast2);
  13208. break;
  13209. case 'pop':
  13210. if (stack.length < 1) {
  13211. return null;
  13212. }
  13213. stack.pop();
  13214. break;
  13215. case 'index':
  13216. if (stack.length < 1) {
  13217. return null;
  13218. }
  13219. num1 = stack.pop();
  13220. if (num1.type !== 'literal') {
  13221. return null;
  13222. }
  13223. n = num1.number;
  13224. if (n < 0 || (n | 0) !== n || stack.length < n) {
  13225. return null;
  13226. }
  13227. ast1 = stack[stack.length - n - 1];
  13228. if (ast1.type === 'literal' || ast1.type === 'var') {
  13229. stack.push(ast1);
  13230. break;
  13231. }
  13232. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  13233. stack[stack.length - n - 1] = tmpVar;
  13234. stack.push(tmpVar);
  13235. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  13236. break;
  13237. case 'dup':
  13238. if (stack.length < 1) {
  13239. return null;
  13240. }
  13241. if (typeof code[i + 1] === 'number' && code[i + 2] === 'gt' && code[i + 3] === i + 7 && code[i + 4] === 'jz' && code[i + 5] === 'pop' && code[i + 6] === code[i + 1]) {
  13242. num1 = stack.pop();
  13243. stack.push(buildMinOperation(num1, code[i + 1]));
  13244. i += 6;
  13245. break;
  13246. }
  13247. ast1 = stack[stack.length - 1];
  13248. if (ast1.type === 'literal' || ast1.type === 'var') {
  13249. stack.push(ast1);
  13250. break;
  13251. }
  13252. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  13253. stack[stack.length - 1] = tmpVar;
  13254. stack.push(tmpVar);
  13255. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  13256. break;
  13257. case 'roll':
  13258. if (stack.length < 2) {
  13259. return null;
  13260. }
  13261. num2 = stack.pop();
  13262. num1 = stack.pop();
  13263. if (num2.type !== 'literal' || num1.type !== 'literal') {
  13264. return null;
  13265. }
  13266. j = num2.number;
  13267. n = num1.number;
  13268. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  13269. return null;
  13270. }
  13271. j = (j % n + n) % n;
  13272. if (j === 0) {
  13273. break;
  13274. }
  13275. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  13276. break;
  13277. default:
  13278. return null;
  13279. }
  13280. }
  13281. if (stack.length !== outputSize) {
  13282. return null;
  13283. }
  13284. var result = [];
  13285. instructions.forEach(function (instruction) {
  13286. var statementBuilder = new ExpressionBuilderVisitor();
  13287. instruction.visit(statementBuilder);
  13288. result.push(statementBuilder.toString());
  13289. });
  13290. stack.forEach(function (expr, i) {
  13291. var statementBuilder = new ExpressionBuilderVisitor();
  13292. expr.visit(statementBuilder);
  13293. var min = range[i * 2], max = range[i * 2 + 1];
  13294. var out = [statementBuilder.toString()];
  13295. if (min > expr.min) {
  13296. out.unshift('Math.max(', min, ', ');
  13297. out.push(')');
  13298. }
  13299. if (max < expr.max) {
  13300. out.unshift('Math.min(', max, ', ');
  13301. out.push(')');
  13302. }
  13303. out.unshift('dest[destOffset + ', i, '] = ');
  13304. out.push(';');
  13305. result.push(out.join(''));
  13306. });
  13307. return result.join('\n');
  13308. }
  13309. };
  13310. return PostScriptCompiler;
  13311. }();
  13312. exports.isPDFFunction = isPDFFunction;
  13313. exports.PDFFunction = PDFFunction;
  13314. exports.PostScriptEvaluator = PostScriptEvaluator;
  13315. exports.PostScriptCompiler = PostScriptCompiler;
  13316. /***/ }),
  13317. /* 7 */
  13318. /***/ (function(module, exports, __w_pdfjs_require__) {
  13319. "use strict";
  13320. var sharedUtil = __w_pdfjs_require__(0);
  13321. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  13322. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  13323. t['A'] = 0x0041;
  13324. t['AE'] = 0x00C6;
  13325. t['AEacute'] = 0x01FC;
  13326. t['AEmacron'] = 0x01E2;
  13327. t['AEsmall'] = 0xF7E6;
  13328. t['Aacute'] = 0x00C1;
  13329. t['Aacutesmall'] = 0xF7E1;
  13330. t['Abreve'] = 0x0102;
  13331. t['Abreveacute'] = 0x1EAE;
  13332. t['Abrevecyrillic'] = 0x04D0;
  13333. t['Abrevedotbelow'] = 0x1EB6;
  13334. t['Abrevegrave'] = 0x1EB0;
  13335. t['Abrevehookabove'] = 0x1EB2;
  13336. t['Abrevetilde'] = 0x1EB4;
  13337. t['Acaron'] = 0x01CD;
  13338. t['Acircle'] = 0x24B6;
  13339. t['Acircumflex'] = 0x00C2;
  13340. t['Acircumflexacute'] = 0x1EA4;
  13341. t['Acircumflexdotbelow'] = 0x1EAC;
  13342. t['Acircumflexgrave'] = 0x1EA6;
  13343. t['Acircumflexhookabove'] = 0x1EA8;
  13344. t['Acircumflexsmall'] = 0xF7E2;
  13345. t['Acircumflextilde'] = 0x1EAA;
  13346. t['Acute'] = 0xF6C9;
  13347. t['Acutesmall'] = 0xF7B4;
  13348. t['Acyrillic'] = 0x0410;
  13349. t['Adblgrave'] = 0x0200;
  13350. t['Adieresis'] = 0x00C4;
  13351. t['Adieresiscyrillic'] = 0x04D2;
  13352. t['Adieresismacron'] = 0x01DE;
  13353. t['Adieresissmall'] = 0xF7E4;
  13354. t['Adotbelow'] = 0x1EA0;
  13355. t['Adotmacron'] = 0x01E0;
  13356. t['Agrave'] = 0x00C0;
  13357. t['Agravesmall'] = 0xF7E0;
  13358. t['Ahookabove'] = 0x1EA2;
  13359. t['Aiecyrillic'] = 0x04D4;
  13360. t['Ainvertedbreve'] = 0x0202;
  13361. t['Alpha'] = 0x0391;
  13362. t['Alphatonos'] = 0x0386;
  13363. t['Amacron'] = 0x0100;
  13364. t['Amonospace'] = 0xFF21;
  13365. t['Aogonek'] = 0x0104;
  13366. t['Aring'] = 0x00C5;
  13367. t['Aringacute'] = 0x01FA;
  13368. t['Aringbelow'] = 0x1E00;
  13369. t['Aringsmall'] = 0xF7E5;
  13370. t['Asmall'] = 0xF761;
  13371. t['Atilde'] = 0x00C3;
  13372. t['Atildesmall'] = 0xF7E3;
  13373. t['Aybarmenian'] = 0x0531;
  13374. t['B'] = 0x0042;
  13375. t['Bcircle'] = 0x24B7;
  13376. t['Bdotaccent'] = 0x1E02;
  13377. t['Bdotbelow'] = 0x1E04;
  13378. t['Becyrillic'] = 0x0411;
  13379. t['Benarmenian'] = 0x0532;
  13380. t['Beta'] = 0x0392;
  13381. t['Bhook'] = 0x0181;
  13382. t['Blinebelow'] = 0x1E06;
  13383. t['Bmonospace'] = 0xFF22;
  13384. t['Brevesmall'] = 0xF6F4;
  13385. t['Bsmall'] = 0xF762;
  13386. t['Btopbar'] = 0x0182;
  13387. t['C'] = 0x0043;
  13388. t['Caarmenian'] = 0x053E;
  13389. t['Cacute'] = 0x0106;
  13390. t['Caron'] = 0xF6CA;
  13391. t['Caronsmall'] = 0xF6F5;
  13392. t['Ccaron'] = 0x010C;
  13393. t['Ccedilla'] = 0x00C7;
  13394. t['Ccedillaacute'] = 0x1E08;
  13395. t['Ccedillasmall'] = 0xF7E7;
  13396. t['Ccircle'] = 0x24B8;
  13397. t['Ccircumflex'] = 0x0108;
  13398. t['Cdot'] = 0x010A;
  13399. t['Cdotaccent'] = 0x010A;
  13400. t['Cedillasmall'] = 0xF7B8;
  13401. t['Chaarmenian'] = 0x0549;
  13402. t['Cheabkhasiancyrillic'] = 0x04BC;
  13403. t['Checyrillic'] = 0x0427;
  13404. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  13405. t['Chedescendercyrillic'] = 0x04B6;
  13406. t['Chedieresiscyrillic'] = 0x04F4;
  13407. t['Cheharmenian'] = 0x0543;
  13408. t['Chekhakassiancyrillic'] = 0x04CB;
  13409. t['Cheverticalstrokecyrillic'] = 0x04B8;
  13410. t['Chi'] = 0x03A7;
  13411. t['Chook'] = 0x0187;
  13412. t['Circumflexsmall'] = 0xF6F6;
  13413. t['Cmonospace'] = 0xFF23;
  13414. t['Coarmenian'] = 0x0551;
  13415. t['Csmall'] = 0xF763;
  13416. t['D'] = 0x0044;
  13417. t['DZ'] = 0x01F1;
  13418. t['DZcaron'] = 0x01C4;
  13419. t['Daarmenian'] = 0x0534;
  13420. t['Dafrican'] = 0x0189;
  13421. t['Dcaron'] = 0x010E;
  13422. t['Dcedilla'] = 0x1E10;
  13423. t['Dcircle'] = 0x24B9;
  13424. t['Dcircumflexbelow'] = 0x1E12;
  13425. t['Dcroat'] = 0x0110;
  13426. t['Ddotaccent'] = 0x1E0A;
  13427. t['Ddotbelow'] = 0x1E0C;
  13428. t['Decyrillic'] = 0x0414;
  13429. t['Deicoptic'] = 0x03EE;
  13430. t['Delta'] = 0x2206;
  13431. t['Deltagreek'] = 0x0394;
  13432. t['Dhook'] = 0x018A;
  13433. t['Dieresis'] = 0xF6CB;
  13434. t['DieresisAcute'] = 0xF6CC;
  13435. t['DieresisGrave'] = 0xF6CD;
  13436. t['Dieresissmall'] = 0xF7A8;
  13437. t['Digammagreek'] = 0x03DC;
  13438. t['Djecyrillic'] = 0x0402;
  13439. t['Dlinebelow'] = 0x1E0E;
  13440. t['Dmonospace'] = 0xFF24;
  13441. t['Dotaccentsmall'] = 0xF6F7;
  13442. t['Dslash'] = 0x0110;
  13443. t['Dsmall'] = 0xF764;
  13444. t['Dtopbar'] = 0x018B;
  13445. t['Dz'] = 0x01F2;
  13446. t['Dzcaron'] = 0x01C5;
  13447. t['Dzeabkhasiancyrillic'] = 0x04E0;
  13448. t['Dzecyrillic'] = 0x0405;
  13449. t['Dzhecyrillic'] = 0x040F;
  13450. t['E'] = 0x0045;
  13451. t['Eacute'] = 0x00C9;
  13452. t['Eacutesmall'] = 0xF7E9;
  13453. t['Ebreve'] = 0x0114;
  13454. t['Ecaron'] = 0x011A;
  13455. t['Ecedillabreve'] = 0x1E1C;
  13456. t['Echarmenian'] = 0x0535;
  13457. t['Ecircle'] = 0x24BA;
  13458. t['Ecircumflex'] = 0x00CA;
  13459. t['Ecircumflexacute'] = 0x1EBE;
  13460. t['Ecircumflexbelow'] = 0x1E18;
  13461. t['Ecircumflexdotbelow'] = 0x1EC6;
  13462. t['Ecircumflexgrave'] = 0x1EC0;
  13463. t['Ecircumflexhookabove'] = 0x1EC2;
  13464. t['Ecircumflexsmall'] = 0xF7EA;
  13465. t['Ecircumflextilde'] = 0x1EC4;
  13466. t['Ecyrillic'] = 0x0404;
  13467. t['Edblgrave'] = 0x0204;
  13468. t['Edieresis'] = 0x00CB;
  13469. t['Edieresissmall'] = 0xF7EB;
  13470. t['Edot'] = 0x0116;
  13471. t['Edotaccent'] = 0x0116;
  13472. t['Edotbelow'] = 0x1EB8;
  13473. t['Efcyrillic'] = 0x0424;
  13474. t['Egrave'] = 0x00C8;
  13475. t['Egravesmall'] = 0xF7E8;
  13476. t['Eharmenian'] = 0x0537;
  13477. t['Ehookabove'] = 0x1EBA;
  13478. t['Eightroman'] = 0x2167;
  13479. t['Einvertedbreve'] = 0x0206;
  13480. t['Eiotifiedcyrillic'] = 0x0464;
  13481. t['Elcyrillic'] = 0x041B;
  13482. t['Elevenroman'] = 0x216A;
  13483. t['Emacron'] = 0x0112;
  13484. t['Emacronacute'] = 0x1E16;
  13485. t['Emacrongrave'] = 0x1E14;
  13486. t['Emcyrillic'] = 0x041C;
  13487. t['Emonospace'] = 0xFF25;
  13488. t['Encyrillic'] = 0x041D;
  13489. t['Endescendercyrillic'] = 0x04A2;
  13490. t['Eng'] = 0x014A;
  13491. t['Enghecyrillic'] = 0x04A4;
  13492. t['Enhookcyrillic'] = 0x04C7;
  13493. t['Eogonek'] = 0x0118;
  13494. t['Eopen'] = 0x0190;
  13495. t['Epsilon'] = 0x0395;
  13496. t['Epsilontonos'] = 0x0388;
  13497. t['Ercyrillic'] = 0x0420;
  13498. t['Ereversed'] = 0x018E;
  13499. t['Ereversedcyrillic'] = 0x042D;
  13500. t['Escyrillic'] = 0x0421;
  13501. t['Esdescendercyrillic'] = 0x04AA;
  13502. t['Esh'] = 0x01A9;
  13503. t['Esmall'] = 0xF765;
  13504. t['Eta'] = 0x0397;
  13505. t['Etarmenian'] = 0x0538;
  13506. t['Etatonos'] = 0x0389;
  13507. t['Eth'] = 0x00D0;
  13508. t['Ethsmall'] = 0xF7F0;
  13509. t['Etilde'] = 0x1EBC;
  13510. t['Etildebelow'] = 0x1E1A;
  13511. t['Euro'] = 0x20AC;
  13512. t['Ezh'] = 0x01B7;
  13513. t['Ezhcaron'] = 0x01EE;
  13514. t['Ezhreversed'] = 0x01B8;
  13515. t['F'] = 0x0046;
  13516. t['Fcircle'] = 0x24BB;
  13517. t['Fdotaccent'] = 0x1E1E;
  13518. t['Feharmenian'] = 0x0556;
  13519. t['Feicoptic'] = 0x03E4;
  13520. t['Fhook'] = 0x0191;
  13521. t['Fitacyrillic'] = 0x0472;
  13522. t['Fiveroman'] = 0x2164;
  13523. t['Fmonospace'] = 0xFF26;
  13524. t['Fourroman'] = 0x2163;
  13525. t['Fsmall'] = 0xF766;
  13526. t['G'] = 0x0047;
  13527. t['GBsquare'] = 0x3387;
  13528. t['Gacute'] = 0x01F4;
  13529. t['Gamma'] = 0x0393;
  13530. t['Gammaafrican'] = 0x0194;
  13531. t['Gangiacoptic'] = 0x03EA;
  13532. t['Gbreve'] = 0x011E;
  13533. t['Gcaron'] = 0x01E6;
  13534. t['Gcedilla'] = 0x0122;
  13535. t['Gcircle'] = 0x24BC;
  13536. t['Gcircumflex'] = 0x011C;
  13537. t['Gcommaaccent'] = 0x0122;
  13538. t['Gdot'] = 0x0120;
  13539. t['Gdotaccent'] = 0x0120;
  13540. t['Gecyrillic'] = 0x0413;
  13541. t['Ghadarmenian'] = 0x0542;
  13542. t['Ghemiddlehookcyrillic'] = 0x0494;
  13543. t['Ghestrokecyrillic'] = 0x0492;
  13544. t['Gheupturncyrillic'] = 0x0490;
  13545. t['Ghook'] = 0x0193;
  13546. t['Gimarmenian'] = 0x0533;
  13547. t['Gjecyrillic'] = 0x0403;
  13548. t['Gmacron'] = 0x1E20;
  13549. t['Gmonospace'] = 0xFF27;
  13550. t['Grave'] = 0xF6CE;
  13551. t['Gravesmall'] = 0xF760;
  13552. t['Gsmall'] = 0xF767;
  13553. t['Gsmallhook'] = 0x029B;
  13554. t['Gstroke'] = 0x01E4;
  13555. t['H'] = 0x0048;
  13556. t['H18533'] = 0x25CF;
  13557. t['H18543'] = 0x25AA;
  13558. t['H18551'] = 0x25AB;
  13559. t['H22073'] = 0x25A1;
  13560. t['HPsquare'] = 0x33CB;
  13561. t['Haabkhasiancyrillic'] = 0x04A8;
  13562. t['Hadescendercyrillic'] = 0x04B2;
  13563. t['Hardsigncyrillic'] = 0x042A;
  13564. t['Hbar'] = 0x0126;
  13565. t['Hbrevebelow'] = 0x1E2A;
  13566. t['Hcedilla'] = 0x1E28;
  13567. t['Hcircle'] = 0x24BD;
  13568. t['Hcircumflex'] = 0x0124;
  13569. t['Hdieresis'] = 0x1E26;
  13570. t['Hdotaccent'] = 0x1E22;
  13571. t['Hdotbelow'] = 0x1E24;
  13572. t['Hmonospace'] = 0xFF28;
  13573. t['Hoarmenian'] = 0x0540;
  13574. t['Horicoptic'] = 0x03E8;
  13575. t['Hsmall'] = 0xF768;
  13576. t['Hungarumlaut'] = 0xF6CF;
  13577. t['Hungarumlautsmall'] = 0xF6F8;
  13578. t['Hzsquare'] = 0x3390;
  13579. t['I'] = 0x0049;
  13580. t['IAcyrillic'] = 0x042F;
  13581. t['IJ'] = 0x0132;
  13582. t['IUcyrillic'] = 0x042E;
  13583. t['Iacute'] = 0x00CD;
  13584. t['Iacutesmall'] = 0xF7ED;
  13585. t['Ibreve'] = 0x012C;
  13586. t['Icaron'] = 0x01CF;
  13587. t['Icircle'] = 0x24BE;
  13588. t['Icircumflex'] = 0x00CE;
  13589. t['Icircumflexsmall'] = 0xF7EE;
  13590. t['Icyrillic'] = 0x0406;
  13591. t['Idblgrave'] = 0x0208;
  13592. t['Idieresis'] = 0x00CF;
  13593. t['Idieresisacute'] = 0x1E2E;
  13594. t['Idieresiscyrillic'] = 0x04E4;
  13595. t['Idieresissmall'] = 0xF7EF;
  13596. t['Idot'] = 0x0130;
  13597. t['Idotaccent'] = 0x0130;
  13598. t['Idotbelow'] = 0x1ECA;
  13599. t['Iebrevecyrillic'] = 0x04D6;
  13600. t['Iecyrillic'] = 0x0415;
  13601. t['Ifraktur'] = 0x2111;
  13602. t['Igrave'] = 0x00CC;
  13603. t['Igravesmall'] = 0xF7EC;
  13604. t['Ihookabove'] = 0x1EC8;
  13605. t['Iicyrillic'] = 0x0418;
  13606. t['Iinvertedbreve'] = 0x020A;
  13607. t['Iishortcyrillic'] = 0x0419;
  13608. t['Imacron'] = 0x012A;
  13609. t['Imacroncyrillic'] = 0x04E2;
  13610. t['Imonospace'] = 0xFF29;
  13611. t['Iniarmenian'] = 0x053B;
  13612. t['Iocyrillic'] = 0x0401;
  13613. t['Iogonek'] = 0x012E;
  13614. t['Iota'] = 0x0399;
  13615. t['Iotaafrican'] = 0x0196;
  13616. t['Iotadieresis'] = 0x03AA;
  13617. t['Iotatonos'] = 0x038A;
  13618. t['Ismall'] = 0xF769;
  13619. t['Istroke'] = 0x0197;
  13620. t['Itilde'] = 0x0128;
  13621. t['Itildebelow'] = 0x1E2C;
  13622. t['Izhitsacyrillic'] = 0x0474;
  13623. t['Izhitsadblgravecyrillic'] = 0x0476;
  13624. t['J'] = 0x004A;
  13625. t['Jaarmenian'] = 0x0541;
  13626. t['Jcircle'] = 0x24BF;
  13627. t['Jcircumflex'] = 0x0134;
  13628. t['Jecyrillic'] = 0x0408;
  13629. t['Jheharmenian'] = 0x054B;
  13630. t['Jmonospace'] = 0xFF2A;
  13631. t['Jsmall'] = 0xF76A;
  13632. t['K'] = 0x004B;
  13633. t['KBsquare'] = 0x3385;
  13634. t['KKsquare'] = 0x33CD;
  13635. t['Kabashkircyrillic'] = 0x04A0;
  13636. t['Kacute'] = 0x1E30;
  13637. t['Kacyrillic'] = 0x041A;
  13638. t['Kadescendercyrillic'] = 0x049A;
  13639. t['Kahookcyrillic'] = 0x04C3;
  13640. t['Kappa'] = 0x039A;
  13641. t['Kastrokecyrillic'] = 0x049E;
  13642. t['Kaverticalstrokecyrillic'] = 0x049C;
  13643. t['Kcaron'] = 0x01E8;
  13644. t['Kcedilla'] = 0x0136;
  13645. t['Kcircle'] = 0x24C0;
  13646. t['Kcommaaccent'] = 0x0136;
  13647. t['Kdotbelow'] = 0x1E32;
  13648. t['Keharmenian'] = 0x0554;
  13649. t['Kenarmenian'] = 0x053F;
  13650. t['Khacyrillic'] = 0x0425;
  13651. t['Kheicoptic'] = 0x03E6;
  13652. t['Khook'] = 0x0198;
  13653. t['Kjecyrillic'] = 0x040C;
  13654. t['Klinebelow'] = 0x1E34;
  13655. t['Kmonospace'] = 0xFF2B;
  13656. t['Koppacyrillic'] = 0x0480;
  13657. t['Koppagreek'] = 0x03DE;
  13658. t['Ksicyrillic'] = 0x046E;
  13659. t['Ksmall'] = 0xF76B;
  13660. t['L'] = 0x004C;
  13661. t['LJ'] = 0x01C7;
  13662. t['LL'] = 0xF6BF;
  13663. t['Lacute'] = 0x0139;
  13664. t['Lambda'] = 0x039B;
  13665. t['Lcaron'] = 0x013D;
  13666. t['Lcedilla'] = 0x013B;
  13667. t['Lcircle'] = 0x24C1;
  13668. t['Lcircumflexbelow'] = 0x1E3C;
  13669. t['Lcommaaccent'] = 0x013B;
  13670. t['Ldot'] = 0x013F;
  13671. t['Ldotaccent'] = 0x013F;
  13672. t['Ldotbelow'] = 0x1E36;
  13673. t['Ldotbelowmacron'] = 0x1E38;
  13674. t['Liwnarmenian'] = 0x053C;
  13675. t['Lj'] = 0x01C8;
  13676. t['Ljecyrillic'] = 0x0409;
  13677. t['Llinebelow'] = 0x1E3A;
  13678. t['Lmonospace'] = 0xFF2C;
  13679. t['Lslash'] = 0x0141;
  13680. t['Lslashsmall'] = 0xF6F9;
  13681. t['Lsmall'] = 0xF76C;
  13682. t['M'] = 0x004D;
  13683. t['MBsquare'] = 0x3386;
  13684. t['Macron'] = 0xF6D0;
  13685. t['Macronsmall'] = 0xF7AF;
  13686. t['Macute'] = 0x1E3E;
  13687. t['Mcircle'] = 0x24C2;
  13688. t['Mdotaccent'] = 0x1E40;
  13689. t['Mdotbelow'] = 0x1E42;
  13690. t['Menarmenian'] = 0x0544;
  13691. t['Mmonospace'] = 0xFF2D;
  13692. t['Msmall'] = 0xF76D;
  13693. t['Mturned'] = 0x019C;
  13694. t['Mu'] = 0x039C;
  13695. t['N'] = 0x004E;
  13696. t['NJ'] = 0x01CA;
  13697. t['Nacute'] = 0x0143;
  13698. t['Ncaron'] = 0x0147;
  13699. t['Ncedilla'] = 0x0145;
  13700. t['Ncircle'] = 0x24C3;
  13701. t['Ncircumflexbelow'] = 0x1E4A;
  13702. t['Ncommaaccent'] = 0x0145;
  13703. t['Ndotaccent'] = 0x1E44;
  13704. t['Ndotbelow'] = 0x1E46;
  13705. t['Nhookleft'] = 0x019D;
  13706. t['Nineroman'] = 0x2168;
  13707. t['Nj'] = 0x01CB;
  13708. t['Njecyrillic'] = 0x040A;
  13709. t['Nlinebelow'] = 0x1E48;
  13710. t['Nmonospace'] = 0xFF2E;
  13711. t['Nowarmenian'] = 0x0546;
  13712. t['Nsmall'] = 0xF76E;
  13713. t['Ntilde'] = 0x00D1;
  13714. t['Ntildesmall'] = 0xF7F1;
  13715. t['Nu'] = 0x039D;
  13716. t['O'] = 0x004F;
  13717. t['OE'] = 0x0152;
  13718. t['OEsmall'] = 0xF6FA;
  13719. t['Oacute'] = 0x00D3;
  13720. t['Oacutesmall'] = 0xF7F3;
  13721. t['Obarredcyrillic'] = 0x04E8;
  13722. t['Obarreddieresiscyrillic'] = 0x04EA;
  13723. t['Obreve'] = 0x014E;
  13724. t['Ocaron'] = 0x01D1;
  13725. t['Ocenteredtilde'] = 0x019F;
  13726. t['Ocircle'] = 0x24C4;
  13727. t['Ocircumflex'] = 0x00D4;
  13728. t['Ocircumflexacute'] = 0x1ED0;
  13729. t['Ocircumflexdotbelow'] = 0x1ED8;
  13730. t['Ocircumflexgrave'] = 0x1ED2;
  13731. t['Ocircumflexhookabove'] = 0x1ED4;
  13732. t['Ocircumflexsmall'] = 0xF7F4;
  13733. t['Ocircumflextilde'] = 0x1ED6;
  13734. t['Ocyrillic'] = 0x041E;
  13735. t['Odblacute'] = 0x0150;
  13736. t['Odblgrave'] = 0x020C;
  13737. t['Odieresis'] = 0x00D6;
  13738. t['Odieresiscyrillic'] = 0x04E6;
  13739. t['Odieresissmall'] = 0xF7F6;
  13740. t['Odotbelow'] = 0x1ECC;
  13741. t['Ogoneksmall'] = 0xF6FB;
  13742. t['Ograve'] = 0x00D2;
  13743. t['Ogravesmall'] = 0xF7F2;
  13744. t['Oharmenian'] = 0x0555;
  13745. t['Ohm'] = 0x2126;
  13746. t['Ohookabove'] = 0x1ECE;
  13747. t['Ohorn'] = 0x01A0;
  13748. t['Ohornacute'] = 0x1EDA;
  13749. t['Ohorndotbelow'] = 0x1EE2;
  13750. t['Ohorngrave'] = 0x1EDC;
  13751. t['Ohornhookabove'] = 0x1EDE;
  13752. t['Ohorntilde'] = 0x1EE0;
  13753. t['Ohungarumlaut'] = 0x0150;
  13754. t['Oi'] = 0x01A2;
  13755. t['Oinvertedbreve'] = 0x020E;
  13756. t['Omacron'] = 0x014C;
  13757. t['Omacronacute'] = 0x1E52;
  13758. t['Omacrongrave'] = 0x1E50;
  13759. t['Omega'] = 0x2126;
  13760. t['Omegacyrillic'] = 0x0460;
  13761. t['Omegagreek'] = 0x03A9;
  13762. t['Omegaroundcyrillic'] = 0x047A;
  13763. t['Omegatitlocyrillic'] = 0x047C;
  13764. t['Omegatonos'] = 0x038F;
  13765. t['Omicron'] = 0x039F;
  13766. t['Omicrontonos'] = 0x038C;
  13767. t['Omonospace'] = 0xFF2F;
  13768. t['Oneroman'] = 0x2160;
  13769. t['Oogonek'] = 0x01EA;
  13770. t['Oogonekmacron'] = 0x01EC;
  13771. t['Oopen'] = 0x0186;
  13772. t['Oslash'] = 0x00D8;
  13773. t['Oslashacute'] = 0x01FE;
  13774. t['Oslashsmall'] = 0xF7F8;
  13775. t['Osmall'] = 0xF76F;
  13776. t['Ostrokeacute'] = 0x01FE;
  13777. t['Otcyrillic'] = 0x047E;
  13778. t['Otilde'] = 0x00D5;
  13779. t['Otildeacute'] = 0x1E4C;
  13780. t['Otildedieresis'] = 0x1E4E;
  13781. t['Otildesmall'] = 0xF7F5;
  13782. t['P'] = 0x0050;
  13783. t['Pacute'] = 0x1E54;
  13784. t['Pcircle'] = 0x24C5;
  13785. t['Pdotaccent'] = 0x1E56;
  13786. t['Pecyrillic'] = 0x041F;
  13787. t['Peharmenian'] = 0x054A;
  13788. t['Pemiddlehookcyrillic'] = 0x04A6;
  13789. t['Phi'] = 0x03A6;
  13790. t['Phook'] = 0x01A4;
  13791. t['Pi'] = 0x03A0;
  13792. t['Piwrarmenian'] = 0x0553;
  13793. t['Pmonospace'] = 0xFF30;
  13794. t['Psi'] = 0x03A8;
  13795. t['Psicyrillic'] = 0x0470;
  13796. t['Psmall'] = 0xF770;
  13797. t['Q'] = 0x0051;
  13798. t['Qcircle'] = 0x24C6;
  13799. t['Qmonospace'] = 0xFF31;
  13800. t['Qsmall'] = 0xF771;
  13801. t['R'] = 0x0052;
  13802. t['Raarmenian'] = 0x054C;
  13803. t['Racute'] = 0x0154;
  13804. t['Rcaron'] = 0x0158;
  13805. t['Rcedilla'] = 0x0156;
  13806. t['Rcircle'] = 0x24C7;
  13807. t['Rcommaaccent'] = 0x0156;
  13808. t['Rdblgrave'] = 0x0210;
  13809. t['Rdotaccent'] = 0x1E58;
  13810. t['Rdotbelow'] = 0x1E5A;
  13811. t['Rdotbelowmacron'] = 0x1E5C;
  13812. t['Reharmenian'] = 0x0550;
  13813. t['Rfraktur'] = 0x211C;
  13814. t['Rho'] = 0x03A1;
  13815. t['Ringsmall'] = 0xF6FC;
  13816. t['Rinvertedbreve'] = 0x0212;
  13817. t['Rlinebelow'] = 0x1E5E;
  13818. t['Rmonospace'] = 0xFF32;
  13819. t['Rsmall'] = 0xF772;
  13820. t['Rsmallinverted'] = 0x0281;
  13821. t['Rsmallinvertedsuperior'] = 0x02B6;
  13822. t['S'] = 0x0053;
  13823. t['SF010000'] = 0x250C;
  13824. t['SF020000'] = 0x2514;
  13825. t['SF030000'] = 0x2510;
  13826. t['SF040000'] = 0x2518;
  13827. t['SF050000'] = 0x253C;
  13828. t['SF060000'] = 0x252C;
  13829. t['SF070000'] = 0x2534;
  13830. t['SF080000'] = 0x251C;
  13831. t['SF090000'] = 0x2524;
  13832. t['SF100000'] = 0x2500;
  13833. t['SF110000'] = 0x2502;
  13834. t['SF190000'] = 0x2561;
  13835. t['SF200000'] = 0x2562;
  13836. t['SF210000'] = 0x2556;
  13837. t['SF220000'] = 0x2555;
  13838. t['SF230000'] = 0x2563;
  13839. t['SF240000'] = 0x2551;
  13840. t['SF250000'] = 0x2557;
  13841. t['SF260000'] = 0x255D;
  13842. t['SF270000'] = 0x255C;
  13843. t['SF280000'] = 0x255B;
  13844. t['SF360000'] = 0x255E;
  13845. t['SF370000'] = 0x255F;
  13846. t['SF380000'] = 0x255A;
  13847. t['SF390000'] = 0x2554;
  13848. t['SF400000'] = 0x2569;
  13849. t['SF410000'] = 0x2566;
  13850. t['SF420000'] = 0x2560;
  13851. t['SF430000'] = 0x2550;
  13852. t['SF440000'] = 0x256C;
  13853. t['SF450000'] = 0x2567;
  13854. t['SF460000'] = 0x2568;
  13855. t['SF470000'] = 0x2564;
  13856. t['SF480000'] = 0x2565;
  13857. t['SF490000'] = 0x2559;
  13858. t['SF500000'] = 0x2558;
  13859. t['SF510000'] = 0x2552;
  13860. t['SF520000'] = 0x2553;
  13861. t['SF530000'] = 0x256B;
  13862. t['SF540000'] = 0x256A;
  13863. t['Sacute'] = 0x015A;
  13864. t['Sacutedotaccent'] = 0x1E64;
  13865. t['Sampigreek'] = 0x03E0;
  13866. t['Scaron'] = 0x0160;
  13867. t['Scarondotaccent'] = 0x1E66;
  13868. t['Scaronsmall'] = 0xF6FD;
  13869. t['Scedilla'] = 0x015E;
  13870. t['Schwa'] = 0x018F;
  13871. t['Schwacyrillic'] = 0x04D8;
  13872. t['Schwadieresiscyrillic'] = 0x04DA;
  13873. t['Scircle'] = 0x24C8;
  13874. t['Scircumflex'] = 0x015C;
  13875. t['Scommaaccent'] = 0x0218;
  13876. t['Sdotaccent'] = 0x1E60;
  13877. t['Sdotbelow'] = 0x1E62;
  13878. t['Sdotbelowdotaccent'] = 0x1E68;
  13879. t['Seharmenian'] = 0x054D;
  13880. t['Sevenroman'] = 0x2166;
  13881. t['Shaarmenian'] = 0x0547;
  13882. t['Shacyrillic'] = 0x0428;
  13883. t['Shchacyrillic'] = 0x0429;
  13884. t['Sheicoptic'] = 0x03E2;
  13885. t['Shhacyrillic'] = 0x04BA;
  13886. t['Shimacoptic'] = 0x03EC;
  13887. t['Sigma'] = 0x03A3;
  13888. t['Sixroman'] = 0x2165;
  13889. t['Smonospace'] = 0xFF33;
  13890. t['Softsigncyrillic'] = 0x042C;
  13891. t['Ssmall'] = 0xF773;
  13892. t['Stigmagreek'] = 0x03DA;
  13893. t['T'] = 0x0054;
  13894. t['Tau'] = 0x03A4;
  13895. t['Tbar'] = 0x0166;
  13896. t['Tcaron'] = 0x0164;
  13897. t['Tcedilla'] = 0x0162;
  13898. t['Tcircle'] = 0x24C9;
  13899. t['Tcircumflexbelow'] = 0x1E70;
  13900. t['Tcommaaccent'] = 0x0162;
  13901. t['Tdotaccent'] = 0x1E6A;
  13902. t['Tdotbelow'] = 0x1E6C;
  13903. t['Tecyrillic'] = 0x0422;
  13904. t['Tedescendercyrillic'] = 0x04AC;
  13905. t['Tenroman'] = 0x2169;
  13906. t['Tetsecyrillic'] = 0x04B4;
  13907. t['Theta'] = 0x0398;
  13908. t['Thook'] = 0x01AC;
  13909. t['Thorn'] = 0x00DE;
  13910. t['Thornsmall'] = 0xF7FE;
  13911. t['Threeroman'] = 0x2162;
  13912. t['Tildesmall'] = 0xF6FE;
  13913. t['Tiwnarmenian'] = 0x054F;
  13914. t['Tlinebelow'] = 0x1E6E;
  13915. t['Tmonospace'] = 0xFF34;
  13916. t['Toarmenian'] = 0x0539;
  13917. t['Tonefive'] = 0x01BC;
  13918. t['Tonesix'] = 0x0184;
  13919. t['Tonetwo'] = 0x01A7;
  13920. t['Tretroflexhook'] = 0x01AE;
  13921. t['Tsecyrillic'] = 0x0426;
  13922. t['Tshecyrillic'] = 0x040B;
  13923. t['Tsmall'] = 0xF774;
  13924. t['Twelveroman'] = 0x216B;
  13925. t['Tworoman'] = 0x2161;
  13926. t['U'] = 0x0055;
  13927. t['Uacute'] = 0x00DA;
  13928. t['Uacutesmall'] = 0xF7FA;
  13929. t['Ubreve'] = 0x016C;
  13930. t['Ucaron'] = 0x01D3;
  13931. t['Ucircle'] = 0x24CA;
  13932. t['Ucircumflex'] = 0x00DB;
  13933. t['Ucircumflexbelow'] = 0x1E76;
  13934. t['Ucircumflexsmall'] = 0xF7FB;
  13935. t['Ucyrillic'] = 0x0423;
  13936. t['Udblacute'] = 0x0170;
  13937. t['Udblgrave'] = 0x0214;
  13938. t['Udieresis'] = 0x00DC;
  13939. t['Udieresisacute'] = 0x01D7;
  13940. t['Udieresisbelow'] = 0x1E72;
  13941. t['Udieresiscaron'] = 0x01D9;
  13942. t['Udieresiscyrillic'] = 0x04F0;
  13943. t['Udieresisgrave'] = 0x01DB;
  13944. t['Udieresismacron'] = 0x01D5;
  13945. t['Udieresissmall'] = 0xF7FC;
  13946. t['Udotbelow'] = 0x1EE4;
  13947. t['Ugrave'] = 0x00D9;
  13948. t['Ugravesmall'] = 0xF7F9;
  13949. t['Uhookabove'] = 0x1EE6;
  13950. t['Uhorn'] = 0x01AF;
  13951. t['Uhornacute'] = 0x1EE8;
  13952. t['Uhorndotbelow'] = 0x1EF0;
  13953. t['Uhorngrave'] = 0x1EEA;
  13954. t['Uhornhookabove'] = 0x1EEC;
  13955. t['Uhorntilde'] = 0x1EEE;
  13956. t['Uhungarumlaut'] = 0x0170;
  13957. t['Uhungarumlautcyrillic'] = 0x04F2;
  13958. t['Uinvertedbreve'] = 0x0216;
  13959. t['Ukcyrillic'] = 0x0478;
  13960. t['Umacron'] = 0x016A;
  13961. t['Umacroncyrillic'] = 0x04EE;
  13962. t['Umacrondieresis'] = 0x1E7A;
  13963. t['Umonospace'] = 0xFF35;
  13964. t['Uogonek'] = 0x0172;
  13965. t['Upsilon'] = 0x03A5;
  13966. t['Upsilon1'] = 0x03D2;
  13967. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  13968. t['Upsilonafrican'] = 0x01B1;
  13969. t['Upsilondieresis'] = 0x03AB;
  13970. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  13971. t['Upsilonhooksymbol'] = 0x03D2;
  13972. t['Upsilontonos'] = 0x038E;
  13973. t['Uring'] = 0x016E;
  13974. t['Ushortcyrillic'] = 0x040E;
  13975. t['Usmall'] = 0xF775;
  13976. t['Ustraightcyrillic'] = 0x04AE;
  13977. t['Ustraightstrokecyrillic'] = 0x04B0;
  13978. t['Utilde'] = 0x0168;
  13979. t['Utildeacute'] = 0x1E78;
  13980. t['Utildebelow'] = 0x1E74;
  13981. t['V'] = 0x0056;
  13982. t['Vcircle'] = 0x24CB;
  13983. t['Vdotbelow'] = 0x1E7E;
  13984. t['Vecyrillic'] = 0x0412;
  13985. t['Vewarmenian'] = 0x054E;
  13986. t['Vhook'] = 0x01B2;
  13987. t['Vmonospace'] = 0xFF36;
  13988. t['Voarmenian'] = 0x0548;
  13989. t['Vsmall'] = 0xF776;
  13990. t['Vtilde'] = 0x1E7C;
  13991. t['W'] = 0x0057;
  13992. t['Wacute'] = 0x1E82;
  13993. t['Wcircle'] = 0x24CC;
  13994. t['Wcircumflex'] = 0x0174;
  13995. t['Wdieresis'] = 0x1E84;
  13996. t['Wdotaccent'] = 0x1E86;
  13997. t['Wdotbelow'] = 0x1E88;
  13998. t['Wgrave'] = 0x1E80;
  13999. t['Wmonospace'] = 0xFF37;
  14000. t['Wsmall'] = 0xF777;
  14001. t['X'] = 0x0058;
  14002. t['Xcircle'] = 0x24CD;
  14003. t['Xdieresis'] = 0x1E8C;
  14004. t['Xdotaccent'] = 0x1E8A;
  14005. t['Xeharmenian'] = 0x053D;
  14006. t['Xi'] = 0x039E;
  14007. t['Xmonospace'] = 0xFF38;
  14008. t['Xsmall'] = 0xF778;
  14009. t['Y'] = 0x0059;
  14010. t['Yacute'] = 0x00DD;
  14011. t['Yacutesmall'] = 0xF7FD;
  14012. t['Yatcyrillic'] = 0x0462;
  14013. t['Ycircle'] = 0x24CE;
  14014. t['Ycircumflex'] = 0x0176;
  14015. t['Ydieresis'] = 0x0178;
  14016. t['Ydieresissmall'] = 0xF7FF;
  14017. t['Ydotaccent'] = 0x1E8E;
  14018. t['Ydotbelow'] = 0x1EF4;
  14019. t['Yericyrillic'] = 0x042B;
  14020. t['Yerudieresiscyrillic'] = 0x04F8;
  14021. t['Ygrave'] = 0x1EF2;
  14022. t['Yhook'] = 0x01B3;
  14023. t['Yhookabove'] = 0x1EF6;
  14024. t['Yiarmenian'] = 0x0545;
  14025. t['Yicyrillic'] = 0x0407;
  14026. t['Yiwnarmenian'] = 0x0552;
  14027. t['Ymonospace'] = 0xFF39;
  14028. t['Ysmall'] = 0xF779;
  14029. t['Ytilde'] = 0x1EF8;
  14030. t['Yusbigcyrillic'] = 0x046A;
  14031. t['Yusbigiotifiedcyrillic'] = 0x046C;
  14032. t['Yuslittlecyrillic'] = 0x0466;
  14033. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  14034. t['Z'] = 0x005A;
  14035. t['Zaarmenian'] = 0x0536;
  14036. t['Zacute'] = 0x0179;
  14037. t['Zcaron'] = 0x017D;
  14038. t['Zcaronsmall'] = 0xF6FF;
  14039. t['Zcircle'] = 0x24CF;
  14040. t['Zcircumflex'] = 0x1E90;
  14041. t['Zdot'] = 0x017B;
  14042. t['Zdotaccent'] = 0x017B;
  14043. t['Zdotbelow'] = 0x1E92;
  14044. t['Zecyrillic'] = 0x0417;
  14045. t['Zedescendercyrillic'] = 0x0498;
  14046. t['Zedieresiscyrillic'] = 0x04DE;
  14047. t['Zeta'] = 0x0396;
  14048. t['Zhearmenian'] = 0x053A;
  14049. t['Zhebrevecyrillic'] = 0x04C1;
  14050. t['Zhecyrillic'] = 0x0416;
  14051. t['Zhedescendercyrillic'] = 0x0496;
  14052. t['Zhedieresiscyrillic'] = 0x04DC;
  14053. t['Zlinebelow'] = 0x1E94;
  14054. t['Zmonospace'] = 0xFF3A;
  14055. t['Zsmall'] = 0xF77A;
  14056. t['Zstroke'] = 0x01B5;
  14057. t['a'] = 0x0061;
  14058. t['aabengali'] = 0x0986;
  14059. t['aacute'] = 0x00E1;
  14060. t['aadeva'] = 0x0906;
  14061. t['aagujarati'] = 0x0A86;
  14062. t['aagurmukhi'] = 0x0A06;
  14063. t['aamatragurmukhi'] = 0x0A3E;
  14064. t['aarusquare'] = 0x3303;
  14065. t['aavowelsignbengali'] = 0x09BE;
  14066. t['aavowelsigndeva'] = 0x093E;
  14067. t['aavowelsigngujarati'] = 0x0ABE;
  14068. t['abbreviationmarkarmenian'] = 0x055F;
  14069. t['abbreviationsigndeva'] = 0x0970;
  14070. t['abengali'] = 0x0985;
  14071. t['abopomofo'] = 0x311A;
  14072. t['abreve'] = 0x0103;
  14073. t['abreveacute'] = 0x1EAF;
  14074. t['abrevecyrillic'] = 0x04D1;
  14075. t['abrevedotbelow'] = 0x1EB7;
  14076. t['abrevegrave'] = 0x1EB1;
  14077. t['abrevehookabove'] = 0x1EB3;
  14078. t['abrevetilde'] = 0x1EB5;
  14079. t['acaron'] = 0x01CE;
  14080. t['acircle'] = 0x24D0;
  14081. t['acircumflex'] = 0x00E2;
  14082. t['acircumflexacute'] = 0x1EA5;
  14083. t['acircumflexdotbelow'] = 0x1EAD;
  14084. t['acircumflexgrave'] = 0x1EA7;
  14085. t['acircumflexhookabove'] = 0x1EA9;
  14086. t['acircumflextilde'] = 0x1EAB;
  14087. t['acute'] = 0x00B4;
  14088. t['acutebelowcmb'] = 0x0317;
  14089. t['acutecmb'] = 0x0301;
  14090. t['acutecomb'] = 0x0301;
  14091. t['acutedeva'] = 0x0954;
  14092. t['acutelowmod'] = 0x02CF;
  14093. t['acutetonecmb'] = 0x0341;
  14094. t['acyrillic'] = 0x0430;
  14095. t['adblgrave'] = 0x0201;
  14096. t['addakgurmukhi'] = 0x0A71;
  14097. t['adeva'] = 0x0905;
  14098. t['adieresis'] = 0x00E4;
  14099. t['adieresiscyrillic'] = 0x04D3;
  14100. t['adieresismacron'] = 0x01DF;
  14101. t['adotbelow'] = 0x1EA1;
  14102. t['adotmacron'] = 0x01E1;
  14103. t['ae'] = 0x00E6;
  14104. t['aeacute'] = 0x01FD;
  14105. t['aekorean'] = 0x3150;
  14106. t['aemacron'] = 0x01E3;
  14107. t['afii00208'] = 0x2015;
  14108. t['afii08941'] = 0x20A4;
  14109. t['afii10017'] = 0x0410;
  14110. t['afii10018'] = 0x0411;
  14111. t['afii10019'] = 0x0412;
  14112. t['afii10020'] = 0x0413;
  14113. t['afii10021'] = 0x0414;
  14114. t['afii10022'] = 0x0415;
  14115. t['afii10023'] = 0x0401;
  14116. t['afii10024'] = 0x0416;
  14117. t['afii10025'] = 0x0417;
  14118. t['afii10026'] = 0x0418;
  14119. t['afii10027'] = 0x0419;
  14120. t['afii10028'] = 0x041A;
  14121. t['afii10029'] = 0x041B;
  14122. t['afii10030'] = 0x041C;
  14123. t['afii10031'] = 0x041D;
  14124. t['afii10032'] = 0x041E;
  14125. t['afii10033'] = 0x041F;
  14126. t['afii10034'] = 0x0420;
  14127. t['afii10035'] = 0x0421;
  14128. t['afii10036'] = 0x0422;
  14129. t['afii10037'] = 0x0423;
  14130. t['afii10038'] = 0x0424;
  14131. t['afii10039'] = 0x0425;
  14132. t['afii10040'] = 0x0426;
  14133. t['afii10041'] = 0x0427;
  14134. t['afii10042'] = 0x0428;
  14135. t['afii10043'] = 0x0429;
  14136. t['afii10044'] = 0x042A;
  14137. t['afii10045'] = 0x042B;
  14138. t['afii10046'] = 0x042C;
  14139. t['afii10047'] = 0x042D;
  14140. t['afii10048'] = 0x042E;
  14141. t['afii10049'] = 0x042F;
  14142. t['afii10050'] = 0x0490;
  14143. t['afii10051'] = 0x0402;
  14144. t['afii10052'] = 0x0403;
  14145. t['afii10053'] = 0x0404;
  14146. t['afii10054'] = 0x0405;
  14147. t['afii10055'] = 0x0406;
  14148. t['afii10056'] = 0x0407;
  14149. t['afii10057'] = 0x0408;
  14150. t['afii10058'] = 0x0409;
  14151. t['afii10059'] = 0x040A;
  14152. t['afii10060'] = 0x040B;
  14153. t['afii10061'] = 0x040C;
  14154. t['afii10062'] = 0x040E;
  14155. t['afii10063'] = 0xF6C4;
  14156. t['afii10064'] = 0xF6C5;
  14157. t['afii10065'] = 0x0430;
  14158. t['afii10066'] = 0x0431;
  14159. t['afii10067'] = 0x0432;
  14160. t['afii10068'] = 0x0433;
  14161. t['afii10069'] = 0x0434;
  14162. t['afii10070'] = 0x0435;
  14163. t['afii10071'] = 0x0451;
  14164. t['afii10072'] = 0x0436;
  14165. t['afii10073'] = 0x0437;
  14166. t['afii10074'] = 0x0438;
  14167. t['afii10075'] = 0x0439;
  14168. t['afii10076'] = 0x043A;
  14169. t['afii10077'] = 0x043B;
  14170. t['afii10078'] = 0x043C;
  14171. t['afii10079'] = 0x043D;
  14172. t['afii10080'] = 0x043E;
  14173. t['afii10081'] = 0x043F;
  14174. t['afii10082'] = 0x0440;
  14175. t['afii10083'] = 0x0441;
  14176. t['afii10084'] = 0x0442;
  14177. t['afii10085'] = 0x0443;
  14178. t['afii10086'] = 0x0444;
  14179. t['afii10087'] = 0x0445;
  14180. t['afii10088'] = 0x0446;
  14181. t['afii10089'] = 0x0447;
  14182. t['afii10090'] = 0x0448;
  14183. t['afii10091'] = 0x0449;
  14184. t['afii10092'] = 0x044A;
  14185. t['afii10093'] = 0x044B;
  14186. t['afii10094'] = 0x044C;
  14187. t['afii10095'] = 0x044D;
  14188. t['afii10096'] = 0x044E;
  14189. t['afii10097'] = 0x044F;
  14190. t['afii10098'] = 0x0491;
  14191. t['afii10099'] = 0x0452;
  14192. t['afii10100'] = 0x0453;
  14193. t['afii10101'] = 0x0454;
  14194. t['afii10102'] = 0x0455;
  14195. t['afii10103'] = 0x0456;
  14196. t['afii10104'] = 0x0457;
  14197. t['afii10105'] = 0x0458;
  14198. t['afii10106'] = 0x0459;
  14199. t['afii10107'] = 0x045A;
  14200. t['afii10108'] = 0x045B;
  14201. t['afii10109'] = 0x045C;
  14202. t['afii10110'] = 0x045E;
  14203. t['afii10145'] = 0x040F;
  14204. t['afii10146'] = 0x0462;
  14205. t['afii10147'] = 0x0472;
  14206. t['afii10148'] = 0x0474;
  14207. t['afii10192'] = 0xF6C6;
  14208. t['afii10193'] = 0x045F;
  14209. t['afii10194'] = 0x0463;
  14210. t['afii10195'] = 0x0473;
  14211. t['afii10196'] = 0x0475;
  14212. t['afii10831'] = 0xF6C7;
  14213. t['afii10832'] = 0xF6C8;
  14214. t['afii10846'] = 0x04D9;
  14215. t['afii299'] = 0x200E;
  14216. t['afii300'] = 0x200F;
  14217. t['afii301'] = 0x200D;
  14218. t['afii57381'] = 0x066A;
  14219. t['afii57388'] = 0x060C;
  14220. t['afii57392'] = 0x0660;
  14221. t['afii57393'] = 0x0661;
  14222. t['afii57394'] = 0x0662;
  14223. t['afii57395'] = 0x0663;
  14224. t['afii57396'] = 0x0664;
  14225. t['afii57397'] = 0x0665;
  14226. t['afii57398'] = 0x0666;
  14227. t['afii57399'] = 0x0667;
  14228. t['afii57400'] = 0x0668;
  14229. t['afii57401'] = 0x0669;
  14230. t['afii57403'] = 0x061B;
  14231. t['afii57407'] = 0x061F;
  14232. t['afii57409'] = 0x0621;
  14233. t['afii57410'] = 0x0622;
  14234. t['afii57411'] = 0x0623;
  14235. t['afii57412'] = 0x0624;
  14236. t['afii57413'] = 0x0625;
  14237. t['afii57414'] = 0x0626;
  14238. t['afii57415'] = 0x0627;
  14239. t['afii57416'] = 0x0628;
  14240. t['afii57417'] = 0x0629;
  14241. t['afii57418'] = 0x062A;
  14242. t['afii57419'] = 0x062B;
  14243. t['afii57420'] = 0x062C;
  14244. t['afii57421'] = 0x062D;
  14245. t['afii57422'] = 0x062E;
  14246. t['afii57423'] = 0x062F;
  14247. t['afii57424'] = 0x0630;
  14248. t['afii57425'] = 0x0631;
  14249. t['afii57426'] = 0x0632;
  14250. t['afii57427'] = 0x0633;
  14251. t['afii57428'] = 0x0634;
  14252. t['afii57429'] = 0x0635;
  14253. t['afii57430'] = 0x0636;
  14254. t['afii57431'] = 0x0637;
  14255. t['afii57432'] = 0x0638;
  14256. t['afii57433'] = 0x0639;
  14257. t['afii57434'] = 0x063A;
  14258. t['afii57440'] = 0x0640;
  14259. t['afii57441'] = 0x0641;
  14260. t['afii57442'] = 0x0642;
  14261. t['afii57443'] = 0x0643;
  14262. t['afii57444'] = 0x0644;
  14263. t['afii57445'] = 0x0645;
  14264. t['afii57446'] = 0x0646;
  14265. t['afii57448'] = 0x0648;
  14266. t['afii57449'] = 0x0649;
  14267. t['afii57450'] = 0x064A;
  14268. t['afii57451'] = 0x064B;
  14269. t['afii57452'] = 0x064C;
  14270. t['afii57453'] = 0x064D;
  14271. t['afii57454'] = 0x064E;
  14272. t['afii57455'] = 0x064F;
  14273. t['afii57456'] = 0x0650;
  14274. t['afii57457'] = 0x0651;
  14275. t['afii57458'] = 0x0652;
  14276. t['afii57470'] = 0x0647;
  14277. t['afii57505'] = 0x06A4;
  14278. t['afii57506'] = 0x067E;
  14279. t['afii57507'] = 0x0686;
  14280. t['afii57508'] = 0x0698;
  14281. t['afii57509'] = 0x06AF;
  14282. t['afii57511'] = 0x0679;
  14283. t['afii57512'] = 0x0688;
  14284. t['afii57513'] = 0x0691;
  14285. t['afii57514'] = 0x06BA;
  14286. t['afii57519'] = 0x06D2;
  14287. t['afii57534'] = 0x06D5;
  14288. t['afii57636'] = 0x20AA;
  14289. t['afii57645'] = 0x05BE;
  14290. t['afii57658'] = 0x05C3;
  14291. t['afii57664'] = 0x05D0;
  14292. t['afii57665'] = 0x05D1;
  14293. t['afii57666'] = 0x05D2;
  14294. t['afii57667'] = 0x05D3;
  14295. t['afii57668'] = 0x05D4;
  14296. t['afii57669'] = 0x05D5;
  14297. t['afii57670'] = 0x05D6;
  14298. t['afii57671'] = 0x05D7;
  14299. t['afii57672'] = 0x05D8;
  14300. t['afii57673'] = 0x05D9;
  14301. t['afii57674'] = 0x05DA;
  14302. t['afii57675'] = 0x05DB;
  14303. t['afii57676'] = 0x05DC;
  14304. t['afii57677'] = 0x05DD;
  14305. t['afii57678'] = 0x05DE;
  14306. t['afii57679'] = 0x05DF;
  14307. t['afii57680'] = 0x05E0;
  14308. t['afii57681'] = 0x05E1;
  14309. t['afii57682'] = 0x05E2;
  14310. t['afii57683'] = 0x05E3;
  14311. t['afii57684'] = 0x05E4;
  14312. t['afii57685'] = 0x05E5;
  14313. t['afii57686'] = 0x05E6;
  14314. t['afii57687'] = 0x05E7;
  14315. t['afii57688'] = 0x05E8;
  14316. t['afii57689'] = 0x05E9;
  14317. t['afii57690'] = 0x05EA;
  14318. t['afii57694'] = 0xFB2A;
  14319. t['afii57695'] = 0xFB2B;
  14320. t['afii57700'] = 0xFB4B;
  14321. t['afii57705'] = 0xFB1F;
  14322. t['afii57716'] = 0x05F0;
  14323. t['afii57717'] = 0x05F1;
  14324. t['afii57718'] = 0x05F2;
  14325. t['afii57723'] = 0xFB35;
  14326. t['afii57793'] = 0x05B4;
  14327. t['afii57794'] = 0x05B5;
  14328. t['afii57795'] = 0x05B6;
  14329. t['afii57796'] = 0x05BB;
  14330. t['afii57797'] = 0x05B8;
  14331. t['afii57798'] = 0x05B7;
  14332. t['afii57799'] = 0x05B0;
  14333. t['afii57800'] = 0x05B2;
  14334. t['afii57801'] = 0x05B1;
  14335. t['afii57802'] = 0x05B3;
  14336. t['afii57803'] = 0x05C2;
  14337. t['afii57804'] = 0x05C1;
  14338. t['afii57806'] = 0x05B9;
  14339. t['afii57807'] = 0x05BC;
  14340. t['afii57839'] = 0x05BD;
  14341. t['afii57841'] = 0x05BF;
  14342. t['afii57842'] = 0x05C0;
  14343. t['afii57929'] = 0x02BC;
  14344. t['afii61248'] = 0x2105;
  14345. t['afii61289'] = 0x2113;
  14346. t['afii61352'] = 0x2116;
  14347. t['afii61573'] = 0x202C;
  14348. t['afii61574'] = 0x202D;
  14349. t['afii61575'] = 0x202E;
  14350. t['afii61664'] = 0x200C;
  14351. t['afii63167'] = 0x066D;
  14352. t['afii64937'] = 0x02BD;
  14353. t['agrave'] = 0x00E0;
  14354. t['agujarati'] = 0x0A85;
  14355. t['agurmukhi'] = 0x0A05;
  14356. t['ahiragana'] = 0x3042;
  14357. t['ahookabove'] = 0x1EA3;
  14358. t['aibengali'] = 0x0990;
  14359. t['aibopomofo'] = 0x311E;
  14360. t['aideva'] = 0x0910;
  14361. t['aiecyrillic'] = 0x04D5;
  14362. t['aigujarati'] = 0x0A90;
  14363. t['aigurmukhi'] = 0x0A10;
  14364. t['aimatragurmukhi'] = 0x0A48;
  14365. t['ainarabic'] = 0x0639;
  14366. t['ainfinalarabic'] = 0xFECA;
  14367. t['aininitialarabic'] = 0xFECB;
  14368. t['ainmedialarabic'] = 0xFECC;
  14369. t['ainvertedbreve'] = 0x0203;
  14370. t['aivowelsignbengali'] = 0x09C8;
  14371. t['aivowelsigndeva'] = 0x0948;
  14372. t['aivowelsigngujarati'] = 0x0AC8;
  14373. t['akatakana'] = 0x30A2;
  14374. t['akatakanahalfwidth'] = 0xFF71;
  14375. t['akorean'] = 0x314F;
  14376. t['alef'] = 0x05D0;
  14377. t['alefarabic'] = 0x0627;
  14378. t['alefdageshhebrew'] = 0xFB30;
  14379. t['aleffinalarabic'] = 0xFE8E;
  14380. t['alefhamzaabovearabic'] = 0x0623;
  14381. t['alefhamzaabovefinalarabic'] = 0xFE84;
  14382. t['alefhamzabelowarabic'] = 0x0625;
  14383. t['alefhamzabelowfinalarabic'] = 0xFE88;
  14384. t['alefhebrew'] = 0x05D0;
  14385. t['aleflamedhebrew'] = 0xFB4F;
  14386. t['alefmaddaabovearabic'] = 0x0622;
  14387. t['alefmaddaabovefinalarabic'] = 0xFE82;
  14388. t['alefmaksuraarabic'] = 0x0649;
  14389. t['alefmaksurafinalarabic'] = 0xFEF0;
  14390. t['alefmaksurainitialarabic'] = 0xFEF3;
  14391. t['alefmaksuramedialarabic'] = 0xFEF4;
  14392. t['alefpatahhebrew'] = 0xFB2E;
  14393. t['alefqamatshebrew'] = 0xFB2F;
  14394. t['aleph'] = 0x2135;
  14395. t['allequal'] = 0x224C;
  14396. t['alpha'] = 0x03B1;
  14397. t['alphatonos'] = 0x03AC;
  14398. t['amacron'] = 0x0101;
  14399. t['amonospace'] = 0xFF41;
  14400. t['ampersand'] = 0x0026;
  14401. t['ampersandmonospace'] = 0xFF06;
  14402. t['ampersandsmall'] = 0xF726;
  14403. t['amsquare'] = 0x33C2;
  14404. t['anbopomofo'] = 0x3122;
  14405. t['angbopomofo'] = 0x3124;
  14406. t['angbracketleft'] = 0x3008;
  14407. t['angbracketright'] = 0x3009;
  14408. t['angkhankhuthai'] = 0x0E5A;
  14409. t['angle'] = 0x2220;
  14410. t['anglebracketleft'] = 0x3008;
  14411. t['anglebracketleftvertical'] = 0xFE3F;
  14412. t['anglebracketright'] = 0x3009;
  14413. t['anglebracketrightvertical'] = 0xFE40;
  14414. t['angleleft'] = 0x2329;
  14415. t['angleright'] = 0x232A;
  14416. t['angstrom'] = 0x212B;
  14417. t['anoteleia'] = 0x0387;
  14418. t['anudattadeva'] = 0x0952;
  14419. t['anusvarabengali'] = 0x0982;
  14420. t['anusvaradeva'] = 0x0902;
  14421. t['anusvaragujarati'] = 0x0A82;
  14422. t['aogonek'] = 0x0105;
  14423. t['apaatosquare'] = 0x3300;
  14424. t['aparen'] = 0x249C;
  14425. t['apostrophearmenian'] = 0x055A;
  14426. t['apostrophemod'] = 0x02BC;
  14427. t['apple'] = 0xF8FF;
  14428. t['approaches'] = 0x2250;
  14429. t['approxequal'] = 0x2248;
  14430. t['approxequalorimage'] = 0x2252;
  14431. t['approximatelyequal'] = 0x2245;
  14432. t['araeaekorean'] = 0x318E;
  14433. t['araeakorean'] = 0x318D;
  14434. t['arc'] = 0x2312;
  14435. t['arighthalfring'] = 0x1E9A;
  14436. t['aring'] = 0x00E5;
  14437. t['aringacute'] = 0x01FB;
  14438. t['aringbelow'] = 0x1E01;
  14439. t['arrowboth'] = 0x2194;
  14440. t['arrowdashdown'] = 0x21E3;
  14441. t['arrowdashleft'] = 0x21E0;
  14442. t['arrowdashright'] = 0x21E2;
  14443. t['arrowdashup'] = 0x21E1;
  14444. t['arrowdblboth'] = 0x21D4;
  14445. t['arrowdbldown'] = 0x21D3;
  14446. t['arrowdblleft'] = 0x21D0;
  14447. t['arrowdblright'] = 0x21D2;
  14448. t['arrowdblup'] = 0x21D1;
  14449. t['arrowdown'] = 0x2193;
  14450. t['arrowdownleft'] = 0x2199;
  14451. t['arrowdownright'] = 0x2198;
  14452. t['arrowdownwhite'] = 0x21E9;
  14453. t['arrowheaddownmod'] = 0x02C5;
  14454. t['arrowheadleftmod'] = 0x02C2;
  14455. t['arrowheadrightmod'] = 0x02C3;
  14456. t['arrowheadupmod'] = 0x02C4;
  14457. t['arrowhorizex'] = 0xF8E7;
  14458. t['arrowleft'] = 0x2190;
  14459. t['arrowleftdbl'] = 0x21D0;
  14460. t['arrowleftdblstroke'] = 0x21CD;
  14461. t['arrowleftoverright'] = 0x21C6;
  14462. t['arrowleftwhite'] = 0x21E6;
  14463. t['arrowright'] = 0x2192;
  14464. t['arrowrightdblstroke'] = 0x21CF;
  14465. t['arrowrightheavy'] = 0x279E;
  14466. t['arrowrightoverleft'] = 0x21C4;
  14467. t['arrowrightwhite'] = 0x21E8;
  14468. t['arrowtableft'] = 0x21E4;
  14469. t['arrowtabright'] = 0x21E5;
  14470. t['arrowup'] = 0x2191;
  14471. t['arrowupdn'] = 0x2195;
  14472. t['arrowupdnbse'] = 0x21A8;
  14473. t['arrowupdownbase'] = 0x21A8;
  14474. t['arrowupleft'] = 0x2196;
  14475. t['arrowupleftofdown'] = 0x21C5;
  14476. t['arrowupright'] = 0x2197;
  14477. t['arrowupwhite'] = 0x21E7;
  14478. t['arrowvertex'] = 0xF8E6;
  14479. t['asciicircum'] = 0x005E;
  14480. t['asciicircummonospace'] = 0xFF3E;
  14481. t['asciitilde'] = 0x007E;
  14482. t['asciitildemonospace'] = 0xFF5E;
  14483. t['ascript'] = 0x0251;
  14484. t['ascriptturned'] = 0x0252;
  14485. t['asmallhiragana'] = 0x3041;
  14486. t['asmallkatakana'] = 0x30A1;
  14487. t['asmallkatakanahalfwidth'] = 0xFF67;
  14488. t['asterisk'] = 0x002A;
  14489. t['asteriskaltonearabic'] = 0x066D;
  14490. t['asteriskarabic'] = 0x066D;
  14491. t['asteriskmath'] = 0x2217;
  14492. t['asteriskmonospace'] = 0xFF0A;
  14493. t['asterisksmall'] = 0xFE61;
  14494. t['asterism'] = 0x2042;
  14495. t['asuperior'] = 0xF6E9;
  14496. t['asymptoticallyequal'] = 0x2243;
  14497. t['at'] = 0x0040;
  14498. t['atilde'] = 0x00E3;
  14499. t['atmonospace'] = 0xFF20;
  14500. t['atsmall'] = 0xFE6B;
  14501. t['aturned'] = 0x0250;
  14502. t['aubengali'] = 0x0994;
  14503. t['aubopomofo'] = 0x3120;
  14504. t['audeva'] = 0x0914;
  14505. t['augujarati'] = 0x0A94;
  14506. t['augurmukhi'] = 0x0A14;
  14507. t['aulengthmarkbengali'] = 0x09D7;
  14508. t['aumatragurmukhi'] = 0x0A4C;
  14509. t['auvowelsignbengali'] = 0x09CC;
  14510. t['auvowelsigndeva'] = 0x094C;
  14511. t['auvowelsigngujarati'] = 0x0ACC;
  14512. t['avagrahadeva'] = 0x093D;
  14513. t['aybarmenian'] = 0x0561;
  14514. t['ayin'] = 0x05E2;
  14515. t['ayinaltonehebrew'] = 0xFB20;
  14516. t['ayinhebrew'] = 0x05E2;
  14517. t['b'] = 0x0062;
  14518. t['babengali'] = 0x09AC;
  14519. t['backslash'] = 0x005C;
  14520. t['backslashmonospace'] = 0xFF3C;
  14521. t['badeva'] = 0x092C;
  14522. t['bagujarati'] = 0x0AAC;
  14523. t['bagurmukhi'] = 0x0A2C;
  14524. t['bahiragana'] = 0x3070;
  14525. t['bahtthai'] = 0x0E3F;
  14526. t['bakatakana'] = 0x30D0;
  14527. t['bar'] = 0x007C;
  14528. t['barmonospace'] = 0xFF5C;
  14529. t['bbopomofo'] = 0x3105;
  14530. t['bcircle'] = 0x24D1;
  14531. t['bdotaccent'] = 0x1E03;
  14532. t['bdotbelow'] = 0x1E05;
  14533. t['beamedsixteenthnotes'] = 0x266C;
  14534. t['because'] = 0x2235;
  14535. t['becyrillic'] = 0x0431;
  14536. t['beharabic'] = 0x0628;
  14537. t['behfinalarabic'] = 0xFE90;
  14538. t['behinitialarabic'] = 0xFE91;
  14539. t['behiragana'] = 0x3079;
  14540. t['behmedialarabic'] = 0xFE92;
  14541. t['behmeeminitialarabic'] = 0xFC9F;
  14542. t['behmeemisolatedarabic'] = 0xFC08;
  14543. t['behnoonfinalarabic'] = 0xFC6D;
  14544. t['bekatakana'] = 0x30D9;
  14545. t['benarmenian'] = 0x0562;
  14546. t['bet'] = 0x05D1;
  14547. t['beta'] = 0x03B2;
  14548. t['betasymbolgreek'] = 0x03D0;
  14549. t['betdagesh'] = 0xFB31;
  14550. t['betdageshhebrew'] = 0xFB31;
  14551. t['bethebrew'] = 0x05D1;
  14552. t['betrafehebrew'] = 0xFB4C;
  14553. t['bhabengali'] = 0x09AD;
  14554. t['bhadeva'] = 0x092D;
  14555. t['bhagujarati'] = 0x0AAD;
  14556. t['bhagurmukhi'] = 0x0A2D;
  14557. t['bhook'] = 0x0253;
  14558. t['bihiragana'] = 0x3073;
  14559. t['bikatakana'] = 0x30D3;
  14560. t['bilabialclick'] = 0x0298;
  14561. t['bindigurmukhi'] = 0x0A02;
  14562. t['birusquare'] = 0x3331;
  14563. t['blackcircle'] = 0x25CF;
  14564. t['blackdiamond'] = 0x25C6;
  14565. t['blackdownpointingtriangle'] = 0x25BC;
  14566. t['blackleftpointingpointer'] = 0x25C4;
  14567. t['blackleftpointingtriangle'] = 0x25C0;
  14568. t['blacklenticularbracketleft'] = 0x3010;
  14569. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  14570. t['blacklenticularbracketright'] = 0x3011;
  14571. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  14572. t['blacklowerlefttriangle'] = 0x25E3;
  14573. t['blacklowerrighttriangle'] = 0x25E2;
  14574. t['blackrectangle'] = 0x25AC;
  14575. t['blackrightpointingpointer'] = 0x25BA;
  14576. t['blackrightpointingtriangle'] = 0x25B6;
  14577. t['blacksmallsquare'] = 0x25AA;
  14578. t['blacksmilingface'] = 0x263B;
  14579. t['blacksquare'] = 0x25A0;
  14580. t['blackstar'] = 0x2605;
  14581. t['blackupperlefttriangle'] = 0x25E4;
  14582. t['blackupperrighttriangle'] = 0x25E5;
  14583. t['blackuppointingsmalltriangle'] = 0x25B4;
  14584. t['blackuppointingtriangle'] = 0x25B2;
  14585. t['blank'] = 0x2423;
  14586. t['blinebelow'] = 0x1E07;
  14587. t['block'] = 0x2588;
  14588. t['bmonospace'] = 0xFF42;
  14589. t['bobaimaithai'] = 0x0E1A;
  14590. t['bohiragana'] = 0x307C;
  14591. t['bokatakana'] = 0x30DC;
  14592. t['bparen'] = 0x249D;
  14593. t['bqsquare'] = 0x33C3;
  14594. t['braceex'] = 0xF8F4;
  14595. t['braceleft'] = 0x007B;
  14596. t['braceleftbt'] = 0xF8F3;
  14597. t['braceleftmid'] = 0xF8F2;
  14598. t['braceleftmonospace'] = 0xFF5B;
  14599. t['braceleftsmall'] = 0xFE5B;
  14600. t['bracelefttp'] = 0xF8F1;
  14601. t['braceleftvertical'] = 0xFE37;
  14602. t['braceright'] = 0x007D;
  14603. t['bracerightbt'] = 0xF8FE;
  14604. t['bracerightmid'] = 0xF8FD;
  14605. t['bracerightmonospace'] = 0xFF5D;
  14606. t['bracerightsmall'] = 0xFE5C;
  14607. t['bracerighttp'] = 0xF8FC;
  14608. t['bracerightvertical'] = 0xFE38;
  14609. t['bracketleft'] = 0x005B;
  14610. t['bracketleftbt'] = 0xF8F0;
  14611. t['bracketleftex'] = 0xF8EF;
  14612. t['bracketleftmonospace'] = 0xFF3B;
  14613. t['bracketlefttp'] = 0xF8EE;
  14614. t['bracketright'] = 0x005D;
  14615. t['bracketrightbt'] = 0xF8FB;
  14616. t['bracketrightex'] = 0xF8FA;
  14617. t['bracketrightmonospace'] = 0xFF3D;
  14618. t['bracketrighttp'] = 0xF8F9;
  14619. t['breve'] = 0x02D8;
  14620. t['brevebelowcmb'] = 0x032E;
  14621. t['brevecmb'] = 0x0306;
  14622. t['breveinvertedbelowcmb'] = 0x032F;
  14623. t['breveinvertedcmb'] = 0x0311;
  14624. t['breveinverteddoublecmb'] = 0x0361;
  14625. t['bridgebelowcmb'] = 0x032A;
  14626. t['bridgeinvertedbelowcmb'] = 0x033A;
  14627. t['brokenbar'] = 0x00A6;
  14628. t['bstroke'] = 0x0180;
  14629. t['bsuperior'] = 0xF6EA;
  14630. t['btopbar'] = 0x0183;
  14631. t['buhiragana'] = 0x3076;
  14632. t['bukatakana'] = 0x30D6;
  14633. t['bullet'] = 0x2022;
  14634. t['bulletinverse'] = 0x25D8;
  14635. t['bulletoperator'] = 0x2219;
  14636. t['bullseye'] = 0x25CE;
  14637. t['c'] = 0x0063;
  14638. t['caarmenian'] = 0x056E;
  14639. t['cabengali'] = 0x099A;
  14640. t['cacute'] = 0x0107;
  14641. t['cadeva'] = 0x091A;
  14642. t['cagujarati'] = 0x0A9A;
  14643. t['cagurmukhi'] = 0x0A1A;
  14644. t['calsquare'] = 0x3388;
  14645. t['candrabindubengali'] = 0x0981;
  14646. t['candrabinducmb'] = 0x0310;
  14647. t['candrabindudeva'] = 0x0901;
  14648. t['candrabindugujarati'] = 0x0A81;
  14649. t['capslock'] = 0x21EA;
  14650. t['careof'] = 0x2105;
  14651. t['caron'] = 0x02C7;
  14652. t['caronbelowcmb'] = 0x032C;
  14653. t['caroncmb'] = 0x030C;
  14654. t['carriagereturn'] = 0x21B5;
  14655. t['cbopomofo'] = 0x3118;
  14656. t['ccaron'] = 0x010D;
  14657. t['ccedilla'] = 0x00E7;
  14658. t['ccedillaacute'] = 0x1E09;
  14659. t['ccircle'] = 0x24D2;
  14660. t['ccircumflex'] = 0x0109;
  14661. t['ccurl'] = 0x0255;
  14662. t['cdot'] = 0x010B;
  14663. t['cdotaccent'] = 0x010B;
  14664. t['cdsquare'] = 0x33C5;
  14665. t['cedilla'] = 0x00B8;
  14666. t['cedillacmb'] = 0x0327;
  14667. t['cent'] = 0x00A2;
  14668. t['centigrade'] = 0x2103;
  14669. t['centinferior'] = 0xF6DF;
  14670. t['centmonospace'] = 0xFFE0;
  14671. t['centoldstyle'] = 0xF7A2;
  14672. t['centsuperior'] = 0xF6E0;
  14673. t['chaarmenian'] = 0x0579;
  14674. t['chabengali'] = 0x099B;
  14675. t['chadeva'] = 0x091B;
  14676. t['chagujarati'] = 0x0A9B;
  14677. t['chagurmukhi'] = 0x0A1B;
  14678. t['chbopomofo'] = 0x3114;
  14679. t['cheabkhasiancyrillic'] = 0x04BD;
  14680. t['checkmark'] = 0x2713;
  14681. t['checyrillic'] = 0x0447;
  14682. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  14683. t['chedescendercyrillic'] = 0x04B7;
  14684. t['chedieresiscyrillic'] = 0x04F5;
  14685. t['cheharmenian'] = 0x0573;
  14686. t['chekhakassiancyrillic'] = 0x04CC;
  14687. t['cheverticalstrokecyrillic'] = 0x04B9;
  14688. t['chi'] = 0x03C7;
  14689. t['chieuchacirclekorean'] = 0x3277;
  14690. t['chieuchaparenkorean'] = 0x3217;
  14691. t['chieuchcirclekorean'] = 0x3269;
  14692. t['chieuchkorean'] = 0x314A;
  14693. t['chieuchparenkorean'] = 0x3209;
  14694. t['chochangthai'] = 0x0E0A;
  14695. t['chochanthai'] = 0x0E08;
  14696. t['chochingthai'] = 0x0E09;
  14697. t['chochoethai'] = 0x0E0C;
  14698. t['chook'] = 0x0188;
  14699. t['cieucacirclekorean'] = 0x3276;
  14700. t['cieucaparenkorean'] = 0x3216;
  14701. t['cieuccirclekorean'] = 0x3268;
  14702. t['cieuckorean'] = 0x3148;
  14703. t['cieucparenkorean'] = 0x3208;
  14704. t['cieucuparenkorean'] = 0x321C;
  14705. t['circle'] = 0x25CB;
  14706. t['circlecopyrt'] = 0x00A9;
  14707. t['circlemultiply'] = 0x2297;
  14708. t['circleot'] = 0x2299;
  14709. t['circleplus'] = 0x2295;
  14710. t['circlepostalmark'] = 0x3036;
  14711. t['circlewithlefthalfblack'] = 0x25D0;
  14712. t['circlewithrighthalfblack'] = 0x25D1;
  14713. t['circumflex'] = 0x02C6;
  14714. t['circumflexbelowcmb'] = 0x032D;
  14715. t['circumflexcmb'] = 0x0302;
  14716. t['clear'] = 0x2327;
  14717. t['clickalveolar'] = 0x01C2;
  14718. t['clickdental'] = 0x01C0;
  14719. t['clicklateral'] = 0x01C1;
  14720. t['clickretroflex'] = 0x01C3;
  14721. t['club'] = 0x2663;
  14722. t['clubsuitblack'] = 0x2663;
  14723. t['clubsuitwhite'] = 0x2667;
  14724. t['cmcubedsquare'] = 0x33A4;
  14725. t['cmonospace'] = 0xFF43;
  14726. t['cmsquaredsquare'] = 0x33A0;
  14727. t['coarmenian'] = 0x0581;
  14728. t['colon'] = 0x003A;
  14729. t['colonmonetary'] = 0x20A1;
  14730. t['colonmonospace'] = 0xFF1A;
  14731. t['colonsign'] = 0x20A1;
  14732. t['colonsmall'] = 0xFE55;
  14733. t['colontriangularhalfmod'] = 0x02D1;
  14734. t['colontriangularmod'] = 0x02D0;
  14735. t['comma'] = 0x002C;
  14736. t['commaabovecmb'] = 0x0313;
  14737. t['commaaboverightcmb'] = 0x0315;
  14738. t['commaaccent'] = 0xF6C3;
  14739. t['commaarabic'] = 0x060C;
  14740. t['commaarmenian'] = 0x055D;
  14741. t['commainferior'] = 0xF6E1;
  14742. t['commamonospace'] = 0xFF0C;
  14743. t['commareversedabovecmb'] = 0x0314;
  14744. t['commareversedmod'] = 0x02BD;
  14745. t['commasmall'] = 0xFE50;
  14746. t['commasuperior'] = 0xF6E2;
  14747. t['commaturnedabovecmb'] = 0x0312;
  14748. t['commaturnedmod'] = 0x02BB;
  14749. t['compass'] = 0x263C;
  14750. t['congruent'] = 0x2245;
  14751. t['contourintegral'] = 0x222E;
  14752. t['control'] = 0x2303;
  14753. t['controlACK'] = 0x0006;
  14754. t['controlBEL'] = 0x0007;
  14755. t['controlBS'] = 0x0008;
  14756. t['controlCAN'] = 0x0018;
  14757. t['controlCR'] = 0x000D;
  14758. t['controlDC1'] = 0x0011;
  14759. t['controlDC2'] = 0x0012;
  14760. t['controlDC3'] = 0x0013;
  14761. t['controlDC4'] = 0x0014;
  14762. t['controlDEL'] = 0x007F;
  14763. t['controlDLE'] = 0x0010;
  14764. t['controlEM'] = 0x0019;
  14765. t['controlENQ'] = 0x0005;
  14766. t['controlEOT'] = 0x0004;
  14767. t['controlESC'] = 0x001B;
  14768. t['controlETB'] = 0x0017;
  14769. t['controlETX'] = 0x0003;
  14770. t['controlFF'] = 0x000C;
  14771. t['controlFS'] = 0x001C;
  14772. t['controlGS'] = 0x001D;
  14773. t['controlHT'] = 0x0009;
  14774. t['controlLF'] = 0x000A;
  14775. t['controlNAK'] = 0x0015;
  14776. t['controlNULL'] = 0x0000;
  14777. t['controlRS'] = 0x001E;
  14778. t['controlSI'] = 0x000F;
  14779. t['controlSO'] = 0x000E;
  14780. t['controlSOT'] = 0x0002;
  14781. t['controlSTX'] = 0x0001;
  14782. t['controlSUB'] = 0x001A;
  14783. t['controlSYN'] = 0x0016;
  14784. t['controlUS'] = 0x001F;
  14785. t['controlVT'] = 0x000B;
  14786. t['copyright'] = 0x00A9;
  14787. t['copyrightsans'] = 0xF8E9;
  14788. t['copyrightserif'] = 0xF6D9;
  14789. t['cornerbracketleft'] = 0x300C;
  14790. t['cornerbracketlefthalfwidth'] = 0xFF62;
  14791. t['cornerbracketleftvertical'] = 0xFE41;
  14792. t['cornerbracketright'] = 0x300D;
  14793. t['cornerbracketrighthalfwidth'] = 0xFF63;
  14794. t['cornerbracketrightvertical'] = 0xFE42;
  14795. t['corporationsquare'] = 0x337F;
  14796. t['cosquare'] = 0x33C7;
  14797. t['coverkgsquare'] = 0x33C6;
  14798. t['cparen'] = 0x249E;
  14799. t['cruzeiro'] = 0x20A2;
  14800. t['cstretched'] = 0x0297;
  14801. t['curlyand'] = 0x22CF;
  14802. t['curlyor'] = 0x22CE;
  14803. t['currency'] = 0x00A4;
  14804. t['cyrBreve'] = 0xF6D1;
  14805. t['cyrFlex'] = 0xF6D2;
  14806. t['cyrbreve'] = 0xF6D4;
  14807. t['cyrflex'] = 0xF6D5;
  14808. t['d'] = 0x0064;
  14809. t['daarmenian'] = 0x0564;
  14810. t['dabengali'] = 0x09A6;
  14811. t['dadarabic'] = 0x0636;
  14812. t['dadeva'] = 0x0926;
  14813. t['dadfinalarabic'] = 0xFEBE;
  14814. t['dadinitialarabic'] = 0xFEBF;
  14815. t['dadmedialarabic'] = 0xFEC0;
  14816. t['dagesh'] = 0x05BC;
  14817. t['dageshhebrew'] = 0x05BC;
  14818. t['dagger'] = 0x2020;
  14819. t['daggerdbl'] = 0x2021;
  14820. t['dagujarati'] = 0x0AA6;
  14821. t['dagurmukhi'] = 0x0A26;
  14822. t['dahiragana'] = 0x3060;
  14823. t['dakatakana'] = 0x30C0;
  14824. t['dalarabic'] = 0x062F;
  14825. t['dalet'] = 0x05D3;
  14826. t['daletdagesh'] = 0xFB33;
  14827. t['daletdageshhebrew'] = 0xFB33;
  14828. t['dalethebrew'] = 0x05D3;
  14829. t['dalfinalarabic'] = 0xFEAA;
  14830. t['dammaarabic'] = 0x064F;
  14831. t['dammalowarabic'] = 0x064F;
  14832. t['dammatanaltonearabic'] = 0x064C;
  14833. t['dammatanarabic'] = 0x064C;
  14834. t['danda'] = 0x0964;
  14835. t['dargahebrew'] = 0x05A7;
  14836. t['dargalefthebrew'] = 0x05A7;
  14837. t['dasiapneumatacyrilliccmb'] = 0x0485;
  14838. t['dblGrave'] = 0xF6D3;
  14839. t['dblanglebracketleft'] = 0x300A;
  14840. t['dblanglebracketleftvertical'] = 0xFE3D;
  14841. t['dblanglebracketright'] = 0x300B;
  14842. t['dblanglebracketrightvertical'] = 0xFE3E;
  14843. t['dblarchinvertedbelowcmb'] = 0x032B;
  14844. t['dblarrowleft'] = 0x21D4;
  14845. t['dblarrowright'] = 0x21D2;
  14846. t['dbldanda'] = 0x0965;
  14847. t['dblgrave'] = 0xF6D6;
  14848. t['dblgravecmb'] = 0x030F;
  14849. t['dblintegral'] = 0x222C;
  14850. t['dbllowline'] = 0x2017;
  14851. t['dbllowlinecmb'] = 0x0333;
  14852. t['dbloverlinecmb'] = 0x033F;
  14853. t['dblprimemod'] = 0x02BA;
  14854. t['dblverticalbar'] = 0x2016;
  14855. t['dblverticallineabovecmb'] = 0x030E;
  14856. t['dbopomofo'] = 0x3109;
  14857. t['dbsquare'] = 0x33C8;
  14858. t['dcaron'] = 0x010F;
  14859. t['dcedilla'] = 0x1E11;
  14860. t['dcircle'] = 0x24D3;
  14861. t['dcircumflexbelow'] = 0x1E13;
  14862. t['dcroat'] = 0x0111;
  14863. t['ddabengali'] = 0x09A1;
  14864. t['ddadeva'] = 0x0921;
  14865. t['ddagujarati'] = 0x0AA1;
  14866. t['ddagurmukhi'] = 0x0A21;
  14867. t['ddalarabic'] = 0x0688;
  14868. t['ddalfinalarabic'] = 0xFB89;
  14869. t['dddhadeva'] = 0x095C;
  14870. t['ddhabengali'] = 0x09A2;
  14871. t['ddhadeva'] = 0x0922;
  14872. t['ddhagujarati'] = 0x0AA2;
  14873. t['ddhagurmukhi'] = 0x0A22;
  14874. t['ddotaccent'] = 0x1E0B;
  14875. t['ddotbelow'] = 0x1E0D;
  14876. t['decimalseparatorarabic'] = 0x066B;
  14877. t['decimalseparatorpersian'] = 0x066B;
  14878. t['decyrillic'] = 0x0434;
  14879. t['degree'] = 0x00B0;
  14880. t['dehihebrew'] = 0x05AD;
  14881. t['dehiragana'] = 0x3067;
  14882. t['deicoptic'] = 0x03EF;
  14883. t['dekatakana'] = 0x30C7;
  14884. t['deleteleft'] = 0x232B;
  14885. t['deleteright'] = 0x2326;
  14886. t['delta'] = 0x03B4;
  14887. t['deltaturned'] = 0x018D;
  14888. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  14889. t['dezh'] = 0x02A4;
  14890. t['dhabengali'] = 0x09A7;
  14891. t['dhadeva'] = 0x0927;
  14892. t['dhagujarati'] = 0x0AA7;
  14893. t['dhagurmukhi'] = 0x0A27;
  14894. t['dhook'] = 0x0257;
  14895. t['dialytikatonos'] = 0x0385;
  14896. t['dialytikatonoscmb'] = 0x0344;
  14897. t['diamond'] = 0x2666;
  14898. t['diamondsuitwhite'] = 0x2662;
  14899. t['dieresis'] = 0x00A8;
  14900. t['dieresisacute'] = 0xF6D7;
  14901. t['dieresisbelowcmb'] = 0x0324;
  14902. t['dieresiscmb'] = 0x0308;
  14903. t['dieresisgrave'] = 0xF6D8;
  14904. t['dieresistonos'] = 0x0385;
  14905. t['dihiragana'] = 0x3062;
  14906. t['dikatakana'] = 0x30C2;
  14907. t['dittomark'] = 0x3003;
  14908. t['divide'] = 0x00F7;
  14909. t['divides'] = 0x2223;
  14910. t['divisionslash'] = 0x2215;
  14911. t['djecyrillic'] = 0x0452;
  14912. t['dkshade'] = 0x2593;
  14913. t['dlinebelow'] = 0x1E0F;
  14914. t['dlsquare'] = 0x3397;
  14915. t['dmacron'] = 0x0111;
  14916. t['dmonospace'] = 0xFF44;
  14917. t['dnblock'] = 0x2584;
  14918. t['dochadathai'] = 0x0E0E;
  14919. t['dodekthai'] = 0x0E14;
  14920. t['dohiragana'] = 0x3069;
  14921. t['dokatakana'] = 0x30C9;
  14922. t['dollar'] = 0x0024;
  14923. t['dollarinferior'] = 0xF6E3;
  14924. t['dollarmonospace'] = 0xFF04;
  14925. t['dollaroldstyle'] = 0xF724;
  14926. t['dollarsmall'] = 0xFE69;
  14927. t['dollarsuperior'] = 0xF6E4;
  14928. t['dong'] = 0x20AB;
  14929. t['dorusquare'] = 0x3326;
  14930. t['dotaccent'] = 0x02D9;
  14931. t['dotaccentcmb'] = 0x0307;
  14932. t['dotbelowcmb'] = 0x0323;
  14933. t['dotbelowcomb'] = 0x0323;
  14934. t['dotkatakana'] = 0x30FB;
  14935. t['dotlessi'] = 0x0131;
  14936. t['dotlessj'] = 0xF6BE;
  14937. t['dotlessjstrokehook'] = 0x0284;
  14938. t['dotmath'] = 0x22C5;
  14939. t['dottedcircle'] = 0x25CC;
  14940. t['doubleyodpatah'] = 0xFB1F;
  14941. t['doubleyodpatahhebrew'] = 0xFB1F;
  14942. t['downtackbelowcmb'] = 0x031E;
  14943. t['downtackmod'] = 0x02D5;
  14944. t['dparen'] = 0x249F;
  14945. t['dsuperior'] = 0xF6EB;
  14946. t['dtail'] = 0x0256;
  14947. t['dtopbar'] = 0x018C;
  14948. t['duhiragana'] = 0x3065;
  14949. t['dukatakana'] = 0x30C5;
  14950. t['dz'] = 0x01F3;
  14951. t['dzaltone'] = 0x02A3;
  14952. t['dzcaron'] = 0x01C6;
  14953. t['dzcurl'] = 0x02A5;
  14954. t['dzeabkhasiancyrillic'] = 0x04E1;
  14955. t['dzecyrillic'] = 0x0455;
  14956. t['dzhecyrillic'] = 0x045F;
  14957. t['e'] = 0x0065;
  14958. t['eacute'] = 0x00E9;
  14959. t['earth'] = 0x2641;
  14960. t['ebengali'] = 0x098F;
  14961. t['ebopomofo'] = 0x311C;
  14962. t['ebreve'] = 0x0115;
  14963. t['ecandradeva'] = 0x090D;
  14964. t['ecandragujarati'] = 0x0A8D;
  14965. t['ecandravowelsigndeva'] = 0x0945;
  14966. t['ecandravowelsigngujarati'] = 0x0AC5;
  14967. t['ecaron'] = 0x011B;
  14968. t['ecedillabreve'] = 0x1E1D;
  14969. t['echarmenian'] = 0x0565;
  14970. t['echyiwnarmenian'] = 0x0587;
  14971. t['ecircle'] = 0x24D4;
  14972. t['ecircumflex'] = 0x00EA;
  14973. t['ecircumflexacute'] = 0x1EBF;
  14974. t['ecircumflexbelow'] = 0x1E19;
  14975. t['ecircumflexdotbelow'] = 0x1EC7;
  14976. t['ecircumflexgrave'] = 0x1EC1;
  14977. t['ecircumflexhookabove'] = 0x1EC3;
  14978. t['ecircumflextilde'] = 0x1EC5;
  14979. t['ecyrillic'] = 0x0454;
  14980. t['edblgrave'] = 0x0205;
  14981. t['edeva'] = 0x090F;
  14982. t['edieresis'] = 0x00EB;
  14983. t['edot'] = 0x0117;
  14984. t['edotaccent'] = 0x0117;
  14985. t['edotbelow'] = 0x1EB9;
  14986. t['eegurmukhi'] = 0x0A0F;
  14987. t['eematragurmukhi'] = 0x0A47;
  14988. t['efcyrillic'] = 0x0444;
  14989. t['egrave'] = 0x00E8;
  14990. t['egujarati'] = 0x0A8F;
  14991. t['eharmenian'] = 0x0567;
  14992. t['ehbopomofo'] = 0x311D;
  14993. t['ehiragana'] = 0x3048;
  14994. t['ehookabove'] = 0x1EBB;
  14995. t['eibopomofo'] = 0x311F;
  14996. t['eight'] = 0x0038;
  14997. t['eightarabic'] = 0x0668;
  14998. t['eightbengali'] = 0x09EE;
  14999. t['eightcircle'] = 0x2467;
  15000. t['eightcircleinversesansserif'] = 0x2791;
  15001. t['eightdeva'] = 0x096E;
  15002. t['eighteencircle'] = 0x2471;
  15003. t['eighteenparen'] = 0x2485;
  15004. t['eighteenperiod'] = 0x2499;
  15005. t['eightgujarati'] = 0x0AEE;
  15006. t['eightgurmukhi'] = 0x0A6E;
  15007. t['eighthackarabic'] = 0x0668;
  15008. t['eighthangzhou'] = 0x3028;
  15009. t['eighthnotebeamed'] = 0x266B;
  15010. t['eightideographicparen'] = 0x3227;
  15011. t['eightinferior'] = 0x2088;
  15012. t['eightmonospace'] = 0xFF18;
  15013. t['eightoldstyle'] = 0xF738;
  15014. t['eightparen'] = 0x247B;
  15015. t['eightperiod'] = 0x248F;
  15016. t['eightpersian'] = 0x06F8;
  15017. t['eightroman'] = 0x2177;
  15018. t['eightsuperior'] = 0x2078;
  15019. t['eightthai'] = 0x0E58;
  15020. t['einvertedbreve'] = 0x0207;
  15021. t['eiotifiedcyrillic'] = 0x0465;
  15022. t['ekatakana'] = 0x30A8;
  15023. t['ekatakanahalfwidth'] = 0xFF74;
  15024. t['ekonkargurmukhi'] = 0x0A74;
  15025. t['ekorean'] = 0x3154;
  15026. t['elcyrillic'] = 0x043B;
  15027. t['element'] = 0x2208;
  15028. t['elevencircle'] = 0x246A;
  15029. t['elevenparen'] = 0x247E;
  15030. t['elevenperiod'] = 0x2492;
  15031. t['elevenroman'] = 0x217A;
  15032. t['ellipsis'] = 0x2026;
  15033. t['ellipsisvertical'] = 0x22EE;
  15034. t['emacron'] = 0x0113;
  15035. t['emacronacute'] = 0x1E17;
  15036. t['emacrongrave'] = 0x1E15;
  15037. t['emcyrillic'] = 0x043C;
  15038. t['emdash'] = 0x2014;
  15039. t['emdashvertical'] = 0xFE31;
  15040. t['emonospace'] = 0xFF45;
  15041. t['emphasismarkarmenian'] = 0x055B;
  15042. t['emptyset'] = 0x2205;
  15043. t['enbopomofo'] = 0x3123;
  15044. t['encyrillic'] = 0x043D;
  15045. t['endash'] = 0x2013;
  15046. t['endashvertical'] = 0xFE32;
  15047. t['endescendercyrillic'] = 0x04A3;
  15048. t['eng'] = 0x014B;
  15049. t['engbopomofo'] = 0x3125;
  15050. t['enghecyrillic'] = 0x04A5;
  15051. t['enhookcyrillic'] = 0x04C8;
  15052. t['enspace'] = 0x2002;
  15053. t['eogonek'] = 0x0119;
  15054. t['eokorean'] = 0x3153;
  15055. t['eopen'] = 0x025B;
  15056. t['eopenclosed'] = 0x029A;
  15057. t['eopenreversed'] = 0x025C;
  15058. t['eopenreversedclosed'] = 0x025E;
  15059. t['eopenreversedhook'] = 0x025D;
  15060. t['eparen'] = 0x24A0;
  15061. t['epsilon'] = 0x03B5;
  15062. t['epsilontonos'] = 0x03AD;
  15063. t['equal'] = 0x003D;
  15064. t['equalmonospace'] = 0xFF1D;
  15065. t['equalsmall'] = 0xFE66;
  15066. t['equalsuperior'] = 0x207C;
  15067. t['equivalence'] = 0x2261;
  15068. t['erbopomofo'] = 0x3126;
  15069. t['ercyrillic'] = 0x0440;
  15070. t['ereversed'] = 0x0258;
  15071. t['ereversedcyrillic'] = 0x044D;
  15072. t['escyrillic'] = 0x0441;
  15073. t['esdescendercyrillic'] = 0x04AB;
  15074. t['esh'] = 0x0283;
  15075. t['eshcurl'] = 0x0286;
  15076. t['eshortdeva'] = 0x090E;
  15077. t['eshortvowelsigndeva'] = 0x0946;
  15078. t['eshreversedloop'] = 0x01AA;
  15079. t['eshsquatreversed'] = 0x0285;
  15080. t['esmallhiragana'] = 0x3047;
  15081. t['esmallkatakana'] = 0x30A7;
  15082. t['esmallkatakanahalfwidth'] = 0xFF6A;
  15083. t['estimated'] = 0x212E;
  15084. t['esuperior'] = 0xF6EC;
  15085. t['eta'] = 0x03B7;
  15086. t['etarmenian'] = 0x0568;
  15087. t['etatonos'] = 0x03AE;
  15088. t['eth'] = 0x00F0;
  15089. t['etilde'] = 0x1EBD;
  15090. t['etildebelow'] = 0x1E1B;
  15091. t['etnahtafoukhhebrew'] = 0x0591;
  15092. t['etnahtafoukhlefthebrew'] = 0x0591;
  15093. t['etnahtahebrew'] = 0x0591;
  15094. t['etnahtalefthebrew'] = 0x0591;
  15095. t['eturned'] = 0x01DD;
  15096. t['eukorean'] = 0x3161;
  15097. t['euro'] = 0x20AC;
  15098. t['evowelsignbengali'] = 0x09C7;
  15099. t['evowelsigndeva'] = 0x0947;
  15100. t['evowelsigngujarati'] = 0x0AC7;
  15101. t['exclam'] = 0x0021;
  15102. t['exclamarmenian'] = 0x055C;
  15103. t['exclamdbl'] = 0x203C;
  15104. t['exclamdown'] = 0x00A1;
  15105. t['exclamdownsmall'] = 0xF7A1;
  15106. t['exclammonospace'] = 0xFF01;
  15107. t['exclamsmall'] = 0xF721;
  15108. t['existential'] = 0x2203;
  15109. t['ezh'] = 0x0292;
  15110. t['ezhcaron'] = 0x01EF;
  15111. t['ezhcurl'] = 0x0293;
  15112. t['ezhreversed'] = 0x01B9;
  15113. t['ezhtail'] = 0x01BA;
  15114. t['f'] = 0x0066;
  15115. t['fadeva'] = 0x095E;
  15116. t['fagurmukhi'] = 0x0A5E;
  15117. t['fahrenheit'] = 0x2109;
  15118. t['fathaarabic'] = 0x064E;
  15119. t['fathalowarabic'] = 0x064E;
  15120. t['fathatanarabic'] = 0x064B;
  15121. t['fbopomofo'] = 0x3108;
  15122. t['fcircle'] = 0x24D5;
  15123. t['fdotaccent'] = 0x1E1F;
  15124. t['feharabic'] = 0x0641;
  15125. t['feharmenian'] = 0x0586;
  15126. t['fehfinalarabic'] = 0xFED2;
  15127. t['fehinitialarabic'] = 0xFED3;
  15128. t['fehmedialarabic'] = 0xFED4;
  15129. t['feicoptic'] = 0x03E5;
  15130. t['female'] = 0x2640;
  15131. t['ff'] = 0xFB00;
  15132. t['ffi'] = 0xFB03;
  15133. t['ffl'] = 0xFB04;
  15134. t['fi'] = 0xFB01;
  15135. t['fifteencircle'] = 0x246E;
  15136. t['fifteenparen'] = 0x2482;
  15137. t['fifteenperiod'] = 0x2496;
  15138. t['figuredash'] = 0x2012;
  15139. t['filledbox'] = 0x25A0;
  15140. t['filledrect'] = 0x25AC;
  15141. t['finalkaf'] = 0x05DA;
  15142. t['finalkafdagesh'] = 0xFB3A;
  15143. t['finalkafdageshhebrew'] = 0xFB3A;
  15144. t['finalkafhebrew'] = 0x05DA;
  15145. t['finalmem'] = 0x05DD;
  15146. t['finalmemhebrew'] = 0x05DD;
  15147. t['finalnun'] = 0x05DF;
  15148. t['finalnunhebrew'] = 0x05DF;
  15149. t['finalpe'] = 0x05E3;
  15150. t['finalpehebrew'] = 0x05E3;
  15151. t['finaltsadi'] = 0x05E5;
  15152. t['finaltsadihebrew'] = 0x05E5;
  15153. t['firsttonechinese'] = 0x02C9;
  15154. t['fisheye'] = 0x25C9;
  15155. t['fitacyrillic'] = 0x0473;
  15156. t['five'] = 0x0035;
  15157. t['fivearabic'] = 0x0665;
  15158. t['fivebengali'] = 0x09EB;
  15159. t['fivecircle'] = 0x2464;
  15160. t['fivecircleinversesansserif'] = 0x278E;
  15161. t['fivedeva'] = 0x096B;
  15162. t['fiveeighths'] = 0x215D;
  15163. t['fivegujarati'] = 0x0AEB;
  15164. t['fivegurmukhi'] = 0x0A6B;
  15165. t['fivehackarabic'] = 0x0665;
  15166. t['fivehangzhou'] = 0x3025;
  15167. t['fiveideographicparen'] = 0x3224;
  15168. t['fiveinferior'] = 0x2085;
  15169. t['fivemonospace'] = 0xFF15;
  15170. t['fiveoldstyle'] = 0xF735;
  15171. t['fiveparen'] = 0x2478;
  15172. t['fiveperiod'] = 0x248C;
  15173. t['fivepersian'] = 0x06F5;
  15174. t['fiveroman'] = 0x2174;
  15175. t['fivesuperior'] = 0x2075;
  15176. t['fivethai'] = 0x0E55;
  15177. t['fl'] = 0xFB02;
  15178. t['florin'] = 0x0192;
  15179. t['fmonospace'] = 0xFF46;
  15180. t['fmsquare'] = 0x3399;
  15181. t['fofanthai'] = 0x0E1F;
  15182. t['fofathai'] = 0x0E1D;
  15183. t['fongmanthai'] = 0x0E4F;
  15184. t['forall'] = 0x2200;
  15185. t['four'] = 0x0034;
  15186. t['fourarabic'] = 0x0664;
  15187. t['fourbengali'] = 0x09EA;
  15188. t['fourcircle'] = 0x2463;
  15189. t['fourcircleinversesansserif'] = 0x278D;
  15190. t['fourdeva'] = 0x096A;
  15191. t['fourgujarati'] = 0x0AEA;
  15192. t['fourgurmukhi'] = 0x0A6A;
  15193. t['fourhackarabic'] = 0x0664;
  15194. t['fourhangzhou'] = 0x3024;
  15195. t['fourideographicparen'] = 0x3223;
  15196. t['fourinferior'] = 0x2084;
  15197. t['fourmonospace'] = 0xFF14;
  15198. t['fournumeratorbengali'] = 0x09F7;
  15199. t['fouroldstyle'] = 0xF734;
  15200. t['fourparen'] = 0x2477;
  15201. t['fourperiod'] = 0x248B;
  15202. t['fourpersian'] = 0x06F4;
  15203. t['fourroman'] = 0x2173;
  15204. t['foursuperior'] = 0x2074;
  15205. t['fourteencircle'] = 0x246D;
  15206. t['fourteenparen'] = 0x2481;
  15207. t['fourteenperiod'] = 0x2495;
  15208. t['fourthai'] = 0x0E54;
  15209. t['fourthtonechinese'] = 0x02CB;
  15210. t['fparen'] = 0x24A1;
  15211. t['fraction'] = 0x2044;
  15212. t['franc'] = 0x20A3;
  15213. t['g'] = 0x0067;
  15214. t['gabengali'] = 0x0997;
  15215. t['gacute'] = 0x01F5;
  15216. t['gadeva'] = 0x0917;
  15217. t['gafarabic'] = 0x06AF;
  15218. t['gaffinalarabic'] = 0xFB93;
  15219. t['gafinitialarabic'] = 0xFB94;
  15220. t['gafmedialarabic'] = 0xFB95;
  15221. t['gagujarati'] = 0x0A97;
  15222. t['gagurmukhi'] = 0x0A17;
  15223. t['gahiragana'] = 0x304C;
  15224. t['gakatakana'] = 0x30AC;
  15225. t['gamma'] = 0x03B3;
  15226. t['gammalatinsmall'] = 0x0263;
  15227. t['gammasuperior'] = 0x02E0;
  15228. t['gangiacoptic'] = 0x03EB;
  15229. t['gbopomofo'] = 0x310D;
  15230. t['gbreve'] = 0x011F;
  15231. t['gcaron'] = 0x01E7;
  15232. t['gcedilla'] = 0x0123;
  15233. t['gcircle'] = 0x24D6;
  15234. t['gcircumflex'] = 0x011D;
  15235. t['gcommaaccent'] = 0x0123;
  15236. t['gdot'] = 0x0121;
  15237. t['gdotaccent'] = 0x0121;
  15238. t['gecyrillic'] = 0x0433;
  15239. t['gehiragana'] = 0x3052;
  15240. t['gekatakana'] = 0x30B2;
  15241. t['geometricallyequal'] = 0x2251;
  15242. t['gereshaccenthebrew'] = 0x059C;
  15243. t['gereshhebrew'] = 0x05F3;
  15244. t['gereshmuqdamhebrew'] = 0x059D;
  15245. t['germandbls'] = 0x00DF;
  15246. t['gershayimaccenthebrew'] = 0x059E;
  15247. t['gershayimhebrew'] = 0x05F4;
  15248. t['getamark'] = 0x3013;
  15249. t['ghabengali'] = 0x0998;
  15250. t['ghadarmenian'] = 0x0572;
  15251. t['ghadeva'] = 0x0918;
  15252. t['ghagujarati'] = 0x0A98;
  15253. t['ghagurmukhi'] = 0x0A18;
  15254. t['ghainarabic'] = 0x063A;
  15255. t['ghainfinalarabic'] = 0xFECE;
  15256. t['ghaininitialarabic'] = 0xFECF;
  15257. t['ghainmedialarabic'] = 0xFED0;
  15258. t['ghemiddlehookcyrillic'] = 0x0495;
  15259. t['ghestrokecyrillic'] = 0x0493;
  15260. t['gheupturncyrillic'] = 0x0491;
  15261. t['ghhadeva'] = 0x095A;
  15262. t['ghhagurmukhi'] = 0x0A5A;
  15263. t['ghook'] = 0x0260;
  15264. t['ghzsquare'] = 0x3393;
  15265. t['gihiragana'] = 0x304E;
  15266. t['gikatakana'] = 0x30AE;
  15267. t['gimarmenian'] = 0x0563;
  15268. t['gimel'] = 0x05D2;
  15269. t['gimeldagesh'] = 0xFB32;
  15270. t['gimeldageshhebrew'] = 0xFB32;
  15271. t['gimelhebrew'] = 0x05D2;
  15272. t['gjecyrillic'] = 0x0453;
  15273. t['glottalinvertedstroke'] = 0x01BE;
  15274. t['glottalstop'] = 0x0294;
  15275. t['glottalstopinverted'] = 0x0296;
  15276. t['glottalstopmod'] = 0x02C0;
  15277. t['glottalstopreversed'] = 0x0295;
  15278. t['glottalstopreversedmod'] = 0x02C1;
  15279. t['glottalstopreversedsuperior'] = 0x02E4;
  15280. t['glottalstopstroke'] = 0x02A1;
  15281. t['glottalstopstrokereversed'] = 0x02A2;
  15282. t['gmacron'] = 0x1E21;
  15283. t['gmonospace'] = 0xFF47;
  15284. t['gohiragana'] = 0x3054;
  15285. t['gokatakana'] = 0x30B4;
  15286. t['gparen'] = 0x24A2;
  15287. t['gpasquare'] = 0x33AC;
  15288. t['gradient'] = 0x2207;
  15289. t['grave'] = 0x0060;
  15290. t['gravebelowcmb'] = 0x0316;
  15291. t['gravecmb'] = 0x0300;
  15292. t['gravecomb'] = 0x0300;
  15293. t['gravedeva'] = 0x0953;
  15294. t['gravelowmod'] = 0x02CE;
  15295. t['gravemonospace'] = 0xFF40;
  15296. t['gravetonecmb'] = 0x0340;
  15297. t['greater'] = 0x003E;
  15298. t['greaterequal'] = 0x2265;
  15299. t['greaterequalorless'] = 0x22DB;
  15300. t['greatermonospace'] = 0xFF1E;
  15301. t['greaterorequivalent'] = 0x2273;
  15302. t['greaterorless'] = 0x2277;
  15303. t['greateroverequal'] = 0x2267;
  15304. t['greatersmall'] = 0xFE65;
  15305. t['gscript'] = 0x0261;
  15306. t['gstroke'] = 0x01E5;
  15307. t['guhiragana'] = 0x3050;
  15308. t['guillemotleft'] = 0x00AB;
  15309. t['guillemotright'] = 0x00BB;
  15310. t['guilsinglleft'] = 0x2039;
  15311. t['guilsinglright'] = 0x203A;
  15312. t['gukatakana'] = 0x30B0;
  15313. t['guramusquare'] = 0x3318;
  15314. t['gysquare'] = 0x33C9;
  15315. t['h'] = 0x0068;
  15316. t['haabkhasiancyrillic'] = 0x04A9;
  15317. t['haaltonearabic'] = 0x06C1;
  15318. t['habengali'] = 0x09B9;
  15319. t['hadescendercyrillic'] = 0x04B3;
  15320. t['hadeva'] = 0x0939;
  15321. t['hagujarati'] = 0x0AB9;
  15322. t['hagurmukhi'] = 0x0A39;
  15323. t['haharabic'] = 0x062D;
  15324. t['hahfinalarabic'] = 0xFEA2;
  15325. t['hahinitialarabic'] = 0xFEA3;
  15326. t['hahiragana'] = 0x306F;
  15327. t['hahmedialarabic'] = 0xFEA4;
  15328. t['haitusquare'] = 0x332A;
  15329. t['hakatakana'] = 0x30CF;
  15330. t['hakatakanahalfwidth'] = 0xFF8A;
  15331. t['halantgurmukhi'] = 0x0A4D;
  15332. t['hamzaarabic'] = 0x0621;
  15333. t['hamzalowarabic'] = 0x0621;
  15334. t['hangulfiller'] = 0x3164;
  15335. t['hardsigncyrillic'] = 0x044A;
  15336. t['harpoonleftbarbup'] = 0x21BC;
  15337. t['harpoonrightbarbup'] = 0x21C0;
  15338. t['hasquare'] = 0x33CA;
  15339. t['hatafpatah'] = 0x05B2;
  15340. t['hatafpatah16'] = 0x05B2;
  15341. t['hatafpatah23'] = 0x05B2;
  15342. t['hatafpatah2f'] = 0x05B2;
  15343. t['hatafpatahhebrew'] = 0x05B2;
  15344. t['hatafpatahnarrowhebrew'] = 0x05B2;
  15345. t['hatafpatahquarterhebrew'] = 0x05B2;
  15346. t['hatafpatahwidehebrew'] = 0x05B2;
  15347. t['hatafqamats'] = 0x05B3;
  15348. t['hatafqamats1b'] = 0x05B3;
  15349. t['hatafqamats28'] = 0x05B3;
  15350. t['hatafqamats34'] = 0x05B3;
  15351. t['hatafqamatshebrew'] = 0x05B3;
  15352. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  15353. t['hatafqamatsquarterhebrew'] = 0x05B3;
  15354. t['hatafqamatswidehebrew'] = 0x05B3;
  15355. t['hatafsegol'] = 0x05B1;
  15356. t['hatafsegol17'] = 0x05B1;
  15357. t['hatafsegol24'] = 0x05B1;
  15358. t['hatafsegol30'] = 0x05B1;
  15359. t['hatafsegolhebrew'] = 0x05B1;
  15360. t['hatafsegolnarrowhebrew'] = 0x05B1;
  15361. t['hatafsegolquarterhebrew'] = 0x05B1;
  15362. t['hatafsegolwidehebrew'] = 0x05B1;
  15363. t['hbar'] = 0x0127;
  15364. t['hbopomofo'] = 0x310F;
  15365. t['hbrevebelow'] = 0x1E2B;
  15366. t['hcedilla'] = 0x1E29;
  15367. t['hcircle'] = 0x24D7;
  15368. t['hcircumflex'] = 0x0125;
  15369. t['hdieresis'] = 0x1E27;
  15370. t['hdotaccent'] = 0x1E23;
  15371. t['hdotbelow'] = 0x1E25;
  15372. t['he'] = 0x05D4;
  15373. t['heart'] = 0x2665;
  15374. t['heartsuitblack'] = 0x2665;
  15375. t['heartsuitwhite'] = 0x2661;
  15376. t['hedagesh'] = 0xFB34;
  15377. t['hedageshhebrew'] = 0xFB34;
  15378. t['hehaltonearabic'] = 0x06C1;
  15379. t['heharabic'] = 0x0647;
  15380. t['hehebrew'] = 0x05D4;
  15381. t['hehfinalaltonearabic'] = 0xFBA7;
  15382. t['hehfinalalttwoarabic'] = 0xFEEA;
  15383. t['hehfinalarabic'] = 0xFEEA;
  15384. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  15385. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  15386. t['hehinitialaltonearabic'] = 0xFBA8;
  15387. t['hehinitialarabic'] = 0xFEEB;
  15388. t['hehiragana'] = 0x3078;
  15389. t['hehmedialaltonearabic'] = 0xFBA9;
  15390. t['hehmedialarabic'] = 0xFEEC;
  15391. t['heiseierasquare'] = 0x337B;
  15392. t['hekatakana'] = 0x30D8;
  15393. t['hekatakanahalfwidth'] = 0xFF8D;
  15394. t['hekutaarusquare'] = 0x3336;
  15395. t['henghook'] = 0x0267;
  15396. t['herutusquare'] = 0x3339;
  15397. t['het'] = 0x05D7;
  15398. t['hethebrew'] = 0x05D7;
  15399. t['hhook'] = 0x0266;
  15400. t['hhooksuperior'] = 0x02B1;
  15401. t['hieuhacirclekorean'] = 0x327B;
  15402. t['hieuhaparenkorean'] = 0x321B;
  15403. t['hieuhcirclekorean'] = 0x326D;
  15404. t['hieuhkorean'] = 0x314E;
  15405. t['hieuhparenkorean'] = 0x320D;
  15406. t['hihiragana'] = 0x3072;
  15407. t['hikatakana'] = 0x30D2;
  15408. t['hikatakanahalfwidth'] = 0xFF8B;
  15409. t['hiriq'] = 0x05B4;
  15410. t['hiriq14'] = 0x05B4;
  15411. t['hiriq21'] = 0x05B4;
  15412. t['hiriq2d'] = 0x05B4;
  15413. t['hiriqhebrew'] = 0x05B4;
  15414. t['hiriqnarrowhebrew'] = 0x05B4;
  15415. t['hiriqquarterhebrew'] = 0x05B4;
  15416. t['hiriqwidehebrew'] = 0x05B4;
  15417. t['hlinebelow'] = 0x1E96;
  15418. t['hmonospace'] = 0xFF48;
  15419. t['hoarmenian'] = 0x0570;
  15420. t['hohipthai'] = 0x0E2B;
  15421. t['hohiragana'] = 0x307B;
  15422. t['hokatakana'] = 0x30DB;
  15423. t['hokatakanahalfwidth'] = 0xFF8E;
  15424. t['holam'] = 0x05B9;
  15425. t['holam19'] = 0x05B9;
  15426. t['holam26'] = 0x05B9;
  15427. t['holam32'] = 0x05B9;
  15428. t['holamhebrew'] = 0x05B9;
  15429. t['holamnarrowhebrew'] = 0x05B9;
  15430. t['holamquarterhebrew'] = 0x05B9;
  15431. t['holamwidehebrew'] = 0x05B9;
  15432. t['honokhukthai'] = 0x0E2E;
  15433. t['hookabovecomb'] = 0x0309;
  15434. t['hookcmb'] = 0x0309;
  15435. t['hookpalatalizedbelowcmb'] = 0x0321;
  15436. t['hookretroflexbelowcmb'] = 0x0322;
  15437. t['hoonsquare'] = 0x3342;
  15438. t['horicoptic'] = 0x03E9;
  15439. t['horizontalbar'] = 0x2015;
  15440. t['horncmb'] = 0x031B;
  15441. t['hotsprings'] = 0x2668;
  15442. t['house'] = 0x2302;
  15443. t['hparen'] = 0x24A3;
  15444. t['hsuperior'] = 0x02B0;
  15445. t['hturned'] = 0x0265;
  15446. t['huhiragana'] = 0x3075;
  15447. t['huiitosquare'] = 0x3333;
  15448. t['hukatakana'] = 0x30D5;
  15449. t['hukatakanahalfwidth'] = 0xFF8C;
  15450. t['hungarumlaut'] = 0x02DD;
  15451. t['hungarumlautcmb'] = 0x030B;
  15452. t['hv'] = 0x0195;
  15453. t['hyphen'] = 0x002D;
  15454. t['hypheninferior'] = 0xF6E5;
  15455. t['hyphenmonospace'] = 0xFF0D;
  15456. t['hyphensmall'] = 0xFE63;
  15457. t['hyphensuperior'] = 0xF6E6;
  15458. t['hyphentwo'] = 0x2010;
  15459. t['i'] = 0x0069;
  15460. t['iacute'] = 0x00ED;
  15461. t['iacyrillic'] = 0x044F;
  15462. t['ibengali'] = 0x0987;
  15463. t['ibopomofo'] = 0x3127;
  15464. t['ibreve'] = 0x012D;
  15465. t['icaron'] = 0x01D0;
  15466. t['icircle'] = 0x24D8;
  15467. t['icircumflex'] = 0x00EE;
  15468. t['icyrillic'] = 0x0456;
  15469. t['idblgrave'] = 0x0209;
  15470. t['ideographearthcircle'] = 0x328F;
  15471. t['ideographfirecircle'] = 0x328B;
  15472. t['ideographicallianceparen'] = 0x323F;
  15473. t['ideographiccallparen'] = 0x323A;
  15474. t['ideographiccentrecircle'] = 0x32A5;
  15475. t['ideographicclose'] = 0x3006;
  15476. t['ideographiccomma'] = 0x3001;
  15477. t['ideographiccommaleft'] = 0xFF64;
  15478. t['ideographiccongratulationparen'] = 0x3237;
  15479. t['ideographiccorrectcircle'] = 0x32A3;
  15480. t['ideographicearthparen'] = 0x322F;
  15481. t['ideographicenterpriseparen'] = 0x323D;
  15482. t['ideographicexcellentcircle'] = 0x329D;
  15483. t['ideographicfestivalparen'] = 0x3240;
  15484. t['ideographicfinancialcircle'] = 0x3296;
  15485. t['ideographicfinancialparen'] = 0x3236;
  15486. t['ideographicfireparen'] = 0x322B;
  15487. t['ideographichaveparen'] = 0x3232;
  15488. t['ideographichighcircle'] = 0x32A4;
  15489. t['ideographiciterationmark'] = 0x3005;
  15490. t['ideographiclaborcircle'] = 0x3298;
  15491. t['ideographiclaborparen'] = 0x3238;
  15492. t['ideographicleftcircle'] = 0x32A7;
  15493. t['ideographiclowcircle'] = 0x32A6;
  15494. t['ideographicmedicinecircle'] = 0x32A9;
  15495. t['ideographicmetalparen'] = 0x322E;
  15496. t['ideographicmoonparen'] = 0x322A;
  15497. t['ideographicnameparen'] = 0x3234;
  15498. t['ideographicperiod'] = 0x3002;
  15499. t['ideographicprintcircle'] = 0x329E;
  15500. t['ideographicreachparen'] = 0x3243;
  15501. t['ideographicrepresentparen'] = 0x3239;
  15502. t['ideographicresourceparen'] = 0x323E;
  15503. t['ideographicrightcircle'] = 0x32A8;
  15504. t['ideographicsecretcircle'] = 0x3299;
  15505. t['ideographicselfparen'] = 0x3242;
  15506. t['ideographicsocietyparen'] = 0x3233;
  15507. t['ideographicspace'] = 0x3000;
  15508. t['ideographicspecialparen'] = 0x3235;
  15509. t['ideographicstockparen'] = 0x3231;
  15510. t['ideographicstudyparen'] = 0x323B;
  15511. t['ideographicsunparen'] = 0x3230;
  15512. t['ideographicsuperviseparen'] = 0x323C;
  15513. t['ideographicwaterparen'] = 0x322C;
  15514. t['ideographicwoodparen'] = 0x322D;
  15515. t['ideographiczero'] = 0x3007;
  15516. t['ideographmetalcircle'] = 0x328E;
  15517. t['ideographmooncircle'] = 0x328A;
  15518. t['ideographnamecircle'] = 0x3294;
  15519. t['ideographsuncircle'] = 0x3290;
  15520. t['ideographwatercircle'] = 0x328C;
  15521. t['ideographwoodcircle'] = 0x328D;
  15522. t['ideva'] = 0x0907;
  15523. t['idieresis'] = 0x00EF;
  15524. t['idieresisacute'] = 0x1E2F;
  15525. t['idieresiscyrillic'] = 0x04E5;
  15526. t['idotbelow'] = 0x1ECB;
  15527. t['iebrevecyrillic'] = 0x04D7;
  15528. t['iecyrillic'] = 0x0435;
  15529. t['ieungacirclekorean'] = 0x3275;
  15530. t['ieungaparenkorean'] = 0x3215;
  15531. t['ieungcirclekorean'] = 0x3267;
  15532. t['ieungkorean'] = 0x3147;
  15533. t['ieungparenkorean'] = 0x3207;
  15534. t['igrave'] = 0x00EC;
  15535. t['igujarati'] = 0x0A87;
  15536. t['igurmukhi'] = 0x0A07;
  15537. t['ihiragana'] = 0x3044;
  15538. t['ihookabove'] = 0x1EC9;
  15539. t['iibengali'] = 0x0988;
  15540. t['iicyrillic'] = 0x0438;
  15541. t['iideva'] = 0x0908;
  15542. t['iigujarati'] = 0x0A88;
  15543. t['iigurmukhi'] = 0x0A08;
  15544. t['iimatragurmukhi'] = 0x0A40;
  15545. t['iinvertedbreve'] = 0x020B;
  15546. t['iishortcyrillic'] = 0x0439;
  15547. t['iivowelsignbengali'] = 0x09C0;
  15548. t['iivowelsigndeva'] = 0x0940;
  15549. t['iivowelsigngujarati'] = 0x0AC0;
  15550. t['ij'] = 0x0133;
  15551. t['ikatakana'] = 0x30A4;
  15552. t['ikatakanahalfwidth'] = 0xFF72;
  15553. t['ikorean'] = 0x3163;
  15554. t['ilde'] = 0x02DC;
  15555. t['iluyhebrew'] = 0x05AC;
  15556. t['imacron'] = 0x012B;
  15557. t['imacroncyrillic'] = 0x04E3;
  15558. t['imageorapproximatelyequal'] = 0x2253;
  15559. t['imatragurmukhi'] = 0x0A3F;
  15560. t['imonospace'] = 0xFF49;
  15561. t['increment'] = 0x2206;
  15562. t['infinity'] = 0x221E;
  15563. t['iniarmenian'] = 0x056B;
  15564. t['integral'] = 0x222B;
  15565. t['integralbottom'] = 0x2321;
  15566. t['integralbt'] = 0x2321;
  15567. t['integralex'] = 0xF8F5;
  15568. t['integraltop'] = 0x2320;
  15569. t['integraltp'] = 0x2320;
  15570. t['intersection'] = 0x2229;
  15571. t['intisquare'] = 0x3305;
  15572. t['invbullet'] = 0x25D8;
  15573. t['invcircle'] = 0x25D9;
  15574. t['invsmileface'] = 0x263B;
  15575. t['iocyrillic'] = 0x0451;
  15576. t['iogonek'] = 0x012F;
  15577. t['iota'] = 0x03B9;
  15578. t['iotadieresis'] = 0x03CA;
  15579. t['iotadieresistonos'] = 0x0390;
  15580. t['iotalatin'] = 0x0269;
  15581. t['iotatonos'] = 0x03AF;
  15582. t['iparen'] = 0x24A4;
  15583. t['irigurmukhi'] = 0x0A72;
  15584. t['ismallhiragana'] = 0x3043;
  15585. t['ismallkatakana'] = 0x30A3;
  15586. t['ismallkatakanahalfwidth'] = 0xFF68;
  15587. t['issharbengali'] = 0x09FA;
  15588. t['istroke'] = 0x0268;
  15589. t['isuperior'] = 0xF6ED;
  15590. t['iterationhiragana'] = 0x309D;
  15591. t['iterationkatakana'] = 0x30FD;
  15592. t['itilde'] = 0x0129;
  15593. t['itildebelow'] = 0x1E2D;
  15594. t['iubopomofo'] = 0x3129;
  15595. t['iucyrillic'] = 0x044E;
  15596. t['ivowelsignbengali'] = 0x09BF;
  15597. t['ivowelsigndeva'] = 0x093F;
  15598. t['ivowelsigngujarati'] = 0x0ABF;
  15599. t['izhitsacyrillic'] = 0x0475;
  15600. t['izhitsadblgravecyrillic'] = 0x0477;
  15601. t['j'] = 0x006A;
  15602. t['jaarmenian'] = 0x0571;
  15603. t['jabengali'] = 0x099C;
  15604. t['jadeva'] = 0x091C;
  15605. t['jagujarati'] = 0x0A9C;
  15606. t['jagurmukhi'] = 0x0A1C;
  15607. t['jbopomofo'] = 0x3110;
  15608. t['jcaron'] = 0x01F0;
  15609. t['jcircle'] = 0x24D9;
  15610. t['jcircumflex'] = 0x0135;
  15611. t['jcrossedtail'] = 0x029D;
  15612. t['jdotlessstroke'] = 0x025F;
  15613. t['jecyrillic'] = 0x0458;
  15614. t['jeemarabic'] = 0x062C;
  15615. t['jeemfinalarabic'] = 0xFE9E;
  15616. t['jeeminitialarabic'] = 0xFE9F;
  15617. t['jeemmedialarabic'] = 0xFEA0;
  15618. t['jeharabic'] = 0x0698;
  15619. t['jehfinalarabic'] = 0xFB8B;
  15620. t['jhabengali'] = 0x099D;
  15621. t['jhadeva'] = 0x091D;
  15622. t['jhagujarati'] = 0x0A9D;
  15623. t['jhagurmukhi'] = 0x0A1D;
  15624. t['jheharmenian'] = 0x057B;
  15625. t['jis'] = 0x3004;
  15626. t['jmonospace'] = 0xFF4A;
  15627. t['jparen'] = 0x24A5;
  15628. t['jsuperior'] = 0x02B2;
  15629. t['k'] = 0x006B;
  15630. t['kabashkircyrillic'] = 0x04A1;
  15631. t['kabengali'] = 0x0995;
  15632. t['kacute'] = 0x1E31;
  15633. t['kacyrillic'] = 0x043A;
  15634. t['kadescendercyrillic'] = 0x049B;
  15635. t['kadeva'] = 0x0915;
  15636. t['kaf'] = 0x05DB;
  15637. t['kafarabic'] = 0x0643;
  15638. t['kafdagesh'] = 0xFB3B;
  15639. t['kafdageshhebrew'] = 0xFB3B;
  15640. t['kaffinalarabic'] = 0xFEDA;
  15641. t['kafhebrew'] = 0x05DB;
  15642. t['kafinitialarabic'] = 0xFEDB;
  15643. t['kafmedialarabic'] = 0xFEDC;
  15644. t['kafrafehebrew'] = 0xFB4D;
  15645. t['kagujarati'] = 0x0A95;
  15646. t['kagurmukhi'] = 0x0A15;
  15647. t['kahiragana'] = 0x304B;
  15648. t['kahookcyrillic'] = 0x04C4;
  15649. t['kakatakana'] = 0x30AB;
  15650. t['kakatakanahalfwidth'] = 0xFF76;
  15651. t['kappa'] = 0x03BA;
  15652. t['kappasymbolgreek'] = 0x03F0;
  15653. t['kapyeounmieumkorean'] = 0x3171;
  15654. t['kapyeounphieuphkorean'] = 0x3184;
  15655. t['kapyeounpieupkorean'] = 0x3178;
  15656. t['kapyeounssangpieupkorean'] = 0x3179;
  15657. t['karoriisquare'] = 0x330D;
  15658. t['kashidaautoarabic'] = 0x0640;
  15659. t['kashidaautonosidebearingarabic'] = 0x0640;
  15660. t['kasmallkatakana'] = 0x30F5;
  15661. t['kasquare'] = 0x3384;
  15662. t['kasraarabic'] = 0x0650;
  15663. t['kasratanarabic'] = 0x064D;
  15664. t['kastrokecyrillic'] = 0x049F;
  15665. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  15666. t['kaverticalstrokecyrillic'] = 0x049D;
  15667. t['kbopomofo'] = 0x310E;
  15668. t['kcalsquare'] = 0x3389;
  15669. t['kcaron'] = 0x01E9;
  15670. t['kcedilla'] = 0x0137;
  15671. t['kcircle'] = 0x24DA;
  15672. t['kcommaaccent'] = 0x0137;
  15673. t['kdotbelow'] = 0x1E33;
  15674. t['keharmenian'] = 0x0584;
  15675. t['kehiragana'] = 0x3051;
  15676. t['kekatakana'] = 0x30B1;
  15677. t['kekatakanahalfwidth'] = 0xFF79;
  15678. t['kenarmenian'] = 0x056F;
  15679. t['kesmallkatakana'] = 0x30F6;
  15680. t['kgreenlandic'] = 0x0138;
  15681. t['khabengali'] = 0x0996;
  15682. t['khacyrillic'] = 0x0445;
  15683. t['khadeva'] = 0x0916;
  15684. t['khagujarati'] = 0x0A96;
  15685. t['khagurmukhi'] = 0x0A16;
  15686. t['khaharabic'] = 0x062E;
  15687. t['khahfinalarabic'] = 0xFEA6;
  15688. t['khahinitialarabic'] = 0xFEA7;
  15689. t['khahmedialarabic'] = 0xFEA8;
  15690. t['kheicoptic'] = 0x03E7;
  15691. t['khhadeva'] = 0x0959;
  15692. t['khhagurmukhi'] = 0x0A59;
  15693. t['khieukhacirclekorean'] = 0x3278;
  15694. t['khieukhaparenkorean'] = 0x3218;
  15695. t['khieukhcirclekorean'] = 0x326A;
  15696. t['khieukhkorean'] = 0x314B;
  15697. t['khieukhparenkorean'] = 0x320A;
  15698. t['khokhaithai'] = 0x0E02;
  15699. t['khokhonthai'] = 0x0E05;
  15700. t['khokhuatthai'] = 0x0E03;
  15701. t['khokhwaithai'] = 0x0E04;
  15702. t['khomutthai'] = 0x0E5B;
  15703. t['khook'] = 0x0199;
  15704. t['khorakhangthai'] = 0x0E06;
  15705. t['khzsquare'] = 0x3391;
  15706. t['kihiragana'] = 0x304D;
  15707. t['kikatakana'] = 0x30AD;
  15708. t['kikatakanahalfwidth'] = 0xFF77;
  15709. t['kiroguramusquare'] = 0x3315;
  15710. t['kiromeetorusquare'] = 0x3316;
  15711. t['kirosquare'] = 0x3314;
  15712. t['kiyeokacirclekorean'] = 0x326E;
  15713. t['kiyeokaparenkorean'] = 0x320E;
  15714. t['kiyeokcirclekorean'] = 0x3260;
  15715. t['kiyeokkorean'] = 0x3131;
  15716. t['kiyeokparenkorean'] = 0x3200;
  15717. t['kiyeoksioskorean'] = 0x3133;
  15718. t['kjecyrillic'] = 0x045C;
  15719. t['klinebelow'] = 0x1E35;
  15720. t['klsquare'] = 0x3398;
  15721. t['kmcubedsquare'] = 0x33A6;
  15722. t['kmonospace'] = 0xFF4B;
  15723. t['kmsquaredsquare'] = 0x33A2;
  15724. t['kohiragana'] = 0x3053;
  15725. t['kohmsquare'] = 0x33C0;
  15726. t['kokaithai'] = 0x0E01;
  15727. t['kokatakana'] = 0x30B3;
  15728. t['kokatakanahalfwidth'] = 0xFF7A;
  15729. t['kooposquare'] = 0x331E;
  15730. t['koppacyrillic'] = 0x0481;
  15731. t['koreanstandardsymbol'] = 0x327F;
  15732. t['koroniscmb'] = 0x0343;
  15733. t['kparen'] = 0x24A6;
  15734. t['kpasquare'] = 0x33AA;
  15735. t['ksicyrillic'] = 0x046F;
  15736. t['ktsquare'] = 0x33CF;
  15737. t['kturned'] = 0x029E;
  15738. t['kuhiragana'] = 0x304F;
  15739. t['kukatakana'] = 0x30AF;
  15740. t['kukatakanahalfwidth'] = 0xFF78;
  15741. t['kvsquare'] = 0x33B8;
  15742. t['kwsquare'] = 0x33BE;
  15743. t['l'] = 0x006C;
  15744. t['labengali'] = 0x09B2;
  15745. t['lacute'] = 0x013A;
  15746. t['ladeva'] = 0x0932;
  15747. t['lagujarati'] = 0x0AB2;
  15748. t['lagurmukhi'] = 0x0A32;
  15749. t['lakkhangyaothai'] = 0x0E45;
  15750. t['lamaleffinalarabic'] = 0xFEFC;
  15751. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  15752. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  15753. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  15754. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  15755. t['lamalefisolatedarabic'] = 0xFEFB;
  15756. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  15757. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  15758. t['lamarabic'] = 0x0644;
  15759. t['lambda'] = 0x03BB;
  15760. t['lambdastroke'] = 0x019B;
  15761. t['lamed'] = 0x05DC;
  15762. t['lameddagesh'] = 0xFB3C;
  15763. t['lameddageshhebrew'] = 0xFB3C;
  15764. t['lamedhebrew'] = 0x05DC;
  15765. t['lamfinalarabic'] = 0xFEDE;
  15766. t['lamhahinitialarabic'] = 0xFCCA;
  15767. t['laminitialarabic'] = 0xFEDF;
  15768. t['lamjeeminitialarabic'] = 0xFCC9;
  15769. t['lamkhahinitialarabic'] = 0xFCCB;
  15770. t['lamlamhehisolatedarabic'] = 0xFDF2;
  15771. t['lammedialarabic'] = 0xFEE0;
  15772. t['lammeemhahinitialarabic'] = 0xFD88;
  15773. t['lammeeminitialarabic'] = 0xFCCC;
  15774. t['largecircle'] = 0x25EF;
  15775. t['lbar'] = 0x019A;
  15776. t['lbelt'] = 0x026C;
  15777. t['lbopomofo'] = 0x310C;
  15778. t['lcaron'] = 0x013E;
  15779. t['lcedilla'] = 0x013C;
  15780. t['lcircle'] = 0x24DB;
  15781. t['lcircumflexbelow'] = 0x1E3D;
  15782. t['lcommaaccent'] = 0x013C;
  15783. t['ldot'] = 0x0140;
  15784. t['ldotaccent'] = 0x0140;
  15785. t['ldotbelow'] = 0x1E37;
  15786. t['ldotbelowmacron'] = 0x1E39;
  15787. t['leftangleabovecmb'] = 0x031A;
  15788. t['lefttackbelowcmb'] = 0x0318;
  15789. t['less'] = 0x003C;
  15790. t['lessequal'] = 0x2264;
  15791. t['lessequalorgreater'] = 0x22DA;
  15792. t['lessmonospace'] = 0xFF1C;
  15793. t['lessorequivalent'] = 0x2272;
  15794. t['lessorgreater'] = 0x2276;
  15795. t['lessoverequal'] = 0x2266;
  15796. t['lesssmall'] = 0xFE64;
  15797. t['lezh'] = 0x026E;
  15798. t['lfblock'] = 0x258C;
  15799. t['lhookretroflex'] = 0x026D;
  15800. t['lira'] = 0x20A4;
  15801. t['liwnarmenian'] = 0x056C;
  15802. t['lj'] = 0x01C9;
  15803. t['ljecyrillic'] = 0x0459;
  15804. t['ll'] = 0xF6C0;
  15805. t['lladeva'] = 0x0933;
  15806. t['llagujarati'] = 0x0AB3;
  15807. t['llinebelow'] = 0x1E3B;
  15808. t['llladeva'] = 0x0934;
  15809. t['llvocalicbengali'] = 0x09E1;
  15810. t['llvocalicdeva'] = 0x0961;
  15811. t['llvocalicvowelsignbengali'] = 0x09E3;
  15812. t['llvocalicvowelsigndeva'] = 0x0963;
  15813. t['lmiddletilde'] = 0x026B;
  15814. t['lmonospace'] = 0xFF4C;
  15815. t['lmsquare'] = 0x33D0;
  15816. t['lochulathai'] = 0x0E2C;
  15817. t['logicaland'] = 0x2227;
  15818. t['logicalnot'] = 0x00AC;
  15819. t['logicalnotreversed'] = 0x2310;
  15820. t['logicalor'] = 0x2228;
  15821. t['lolingthai'] = 0x0E25;
  15822. t['longs'] = 0x017F;
  15823. t['lowlinecenterline'] = 0xFE4E;
  15824. t['lowlinecmb'] = 0x0332;
  15825. t['lowlinedashed'] = 0xFE4D;
  15826. t['lozenge'] = 0x25CA;
  15827. t['lparen'] = 0x24A7;
  15828. t['lslash'] = 0x0142;
  15829. t['lsquare'] = 0x2113;
  15830. t['lsuperior'] = 0xF6EE;
  15831. t['ltshade'] = 0x2591;
  15832. t['luthai'] = 0x0E26;
  15833. t['lvocalicbengali'] = 0x098C;
  15834. t['lvocalicdeva'] = 0x090C;
  15835. t['lvocalicvowelsignbengali'] = 0x09E2;
  15836. t['lvocalicvowelsigndeva'] = 0x0962;
  15837. t['lxsquare'] = 0x33D3;
  15838. t['m'] = 0x006D;
  15839. t['mabengali'] = 0x09AE;
  15840. t['macron'] = 0x00AF;
  15841. t['macronbelowcmb'] = 0x0331;
  15842. t['macroncmb'] = 0x0304;
  15843. t['macronlowmod'] = 0x02CD;
  15844. t['macronmonospace'] = 0xFFE3;
  15845. t['macute'] = 0x1E3F;
  15846. t['madeva'] = 0x092E;
  15847. t['magujarati'] = 0x0AAE;
  15848. t['magurmukhi'] = 0x0A2E;
  15849. t['mahapakhhebrew'] = 0x05A4;
  15850. t['mahapakhlefthebrew'] = 0x05A4;
  15851. t['mahiragana'] = 0x307E;
  15852. t['maichattawalowleftthai'] = 0xF895;
  15853. t['maichattawalowrightthai'] = 0xF894;
  15854. t['maichattawathai'] = 0x0E4B;
  15855. t['maichattawaupperleftthai'] = 0xF893;
  15856. t['maieklowleftthai'] = 0xF88C;
  15857. t['maieklowrightthai'] = 0xF88B;
  15858. t['maiekthai'] = 0x0E48;
  15859. t['maiekupperleftthai'] = 0xF88A;
  15860. t['maihanakatleftthai'] = 0xF884;
  15861. t['maihanakatthai'] = 0x0E31;
  15862. t['maitaikhuleftthai'] = 0xF889;
  15863. t['maitaikhuthai'] = 0x0E47;
  15864. t['maitholowleftthai'] = 0xF88F;
  15865. t['maitholowrightthai'] = 0xF88E;
  15866. t['maithothai'] = 0x0E49;
  15867. t['maithoupperleftthai'] = 0xF88D;
  15868. t['maitrilowleftthai'] = 0xF892;
  15869. t['maitrilowrightthai'] = 0xF891;
  15870. t['maitrithai'] = 0x0E4A;
  15871. t['maitriupperleftthai'] = 0xF890;
  15872. t['maiyamokthai'] = 0x0E46;
  15873. t['makatakana'] = 0x30DE;
  15874. t['makatakanahalfwidth'] = 0xFF8F;
  15875. t['male'] = 0x2642;
  15876. t['mansyonsquare'] = 0x3347;
  15877. t['maqafhebrew'] = 0x05BE;
  15878. t['mars'] = 0x2642;
  15879. t['masoracirclehebrew'] = 0x05AF;
  15880. t['masquare'] = 0x3383;
  15881. t['mbopomofo'] = 0x3107;
  15882. t['mbsquare'] = 0x33D4;
  15883. t['mcircle'] = 0x24DC;
  15884. t['mcubedsquare'] = 0x33A5;
  15885. t['mdotaccent'] = 0x1E41;
  15886. t['mdotbelow'] = 0x1E43;
  15887. t['meemarabic'] = 0x0645;
  15888. t['meemfinalarabic'] = 0xFEE2;
  15889. t['meeminitialarabic'] = 0xFEE3;
  15890. t['meemmedialarabic'] = 0xFEE4;
  15891. t['meemmeeminitialarabic'] = 0xFCD1;
  15892. t['meemmeemisolatedarabic'] = 0xFC48;
  15893. t['meetorusquare'] = 0x334D;
  15894. t['mehiragana'] = 0x3081;
  15895. t['meizierasquare'] = 0x337E;
  15896. t['mekatakana'] = 0x30E1;
  15897. t['mekatakanahalfwidth'] = 0xFF92;
  15898. t['mem'] = 0x05DE;
  15899. t['memdagesh'] = 0xFB3E;
  15900. t['memdageshhebrew'] = 0xFB3E;
  15901. t['memhebrew'] = 0x05DE;
  15902. t['menarmenian'] = 0x0574;
  15903. t['merkhahebrew'] = 0x05A5;
  15904. t['merkhakefulahebrew'] = 0x05A6;
  15905. t['merkhakefulalefthebrew'] = 0x05A6;
  15906. t['merkhalefthebrew'] = 0x05A5;
  15907. t['mhook'] = 0x0271;
  15908. t['mhzsquare'] = 0x3392;
  15909. t['middledotkatakanahalfwidth'] = 0xFF65;
  15910. t['middot'] = 0x00B7;
  15911. t['mieumacirclekorean'] = 0x3272;
  15912. t['mieumaparenkorean'] = 0x3212;
  15913. t['mieumcirclekorean'] = 0x3264;
  15914. t['mieumkorean'] = 0x3141;
  15915. t['mieumpansioskorean'] = 0x3170;
  15916. t['mieumparenkorean'] = 0x3204;
  15917. t['mieumpieupkorean'] = 0x316E;
  15918. t['mieumsioskorean'] = 0x316F;
  15919. t['mihiragana'] = 0x307F;
  15920. t['mikatakana'] = 0x30DF;
  15921. t['mikatakanahalfwidth'] = 0xFF90;
  15922. t['minus'] = 0x2212;
  15923. t['minusbelowcmb'] = 0x0320;
  15924. t['minuscircle'] = 0x2296;
  15925. t['minusmod'] = 0x02D7;
  15926. t['minusplus'] = 0x2213;
  15927. t['minute'] = 0x2032;
  15928. t['miribaarusquare'] = 0x334A;
  15929. t['mirisquare'] = 0x3349;
  15930. t['mlonglegturned'] = 0x0270;
  15931. t['mlsquare'] = 0x3396;
  15932. t['mmcubedsquare'] = 0x33A3;
  15933. t['mmonospace'] = 0xFF4D;
  15934. t['mmsquaredsquare'] = 0x339F;
  15935. t['mohiragana'] = 0x3082;
  15936. t['mohmsquare'] = 0x33C1;
  15937. t['mokatakana'] = 0x30E2;
  15938. t['mokatakanahalfwidth'] = 0xFF93;
  15939. t['molsquare'] = 0x33D6;
  15940. t['momathai'] = 0x0E21;
  15941. t['moverssquare'] = 0x33A7;
  15942. t['moverssquaredsquare'] = 0x33A8;
  15943. t['mparen'] = 0x24A8;
  15944. t['mpasquare'] = 0x33AB;
  15945. t['mssquare'] = 0x33B3;
  15946. t['msuperior'] = 0xF6EF;
  15947. t['mturned'] = 0x026F;
  15948. t['mu'] = 0x00B5;
  15949. t['mu1'] = 0x00B5;
  15950. t['muasquare'] = 0x3382;
  15951. t['muchgreater'] = 0x226B;
  15952. t['muchless'] = 0x226A;
  15953. t['mufsquare'] = 0x338C;
  15954. t['mugreek'] = 0x03BC;
  15955. t['mugsquare'] = 0x338D;
  15956. t['muhiragana'] = 0x3080;
  15957. t['mukatakana'] = 0x30E0;
  15958. t['mukatakanahalfwidth'] = 0xFF91;
  15959. t['mulsquare'] = 0x3395;
  15960. t['multiply'] = 0x00D7;
  15961. t['mumsquare'] = 0x339B;
  15962. t['munahhebrew'] = 0x05A3;
  15963. t['munahlefthebrew'] = 0x05A3;
  15964. t['musicalnote'] = 0x266A;
  15965. t['musicalnotedbl'] = 0x266B;
  15966. t['musicflatsign'] = 0x266D;
  15967. t['musicsharpsign'] = 0x266F;
  15968. t['mussquare'] = 0x33B2;
  15969. t['muvsquare'] = 0x33B6;
  15970. t['muwsquare'] = 0x33BC;
  15971. t['mvmegasquare'] = 0x33B9;
  15972. t['mvsquare'] = 0x33B7;
  15973. t['mwmegasquare'] = 0x33BF;
  15974. t['mwsquare'] = 0x33BD;
  15975. t['n'] = 0x006E;
  15976. t['nabengali'] = 0x09A8;
  15977. t['nabla'] = 0x2207;
  15978. t['nacute'] = 0x0144;
  15979. t['nadeva'] = 0x0928;
  15980. t['nagujarati'] = 0x0AA8;
  15981. t['nagurmukhi'] = 0x0A28;
  15982. t['nahiragana'] = 0x306A;
  15983. t['nakatakana'] = 0x30CA;
  15984. t['nakatakanahalfwidth'] = 0xFF85;
  15985. t['napostrophe'] = 0x0149;
  15986. t['nasquare'] = 0x3381;
  15987. t['nbopomofo'] = 0x310B;
  15988. t['nbspace'] = 0x00A0;
  15989. t['ncaron'] = 0x0148;
  15990. t['ncedilla'] = 0x0146;
  15991. t['ncircle'] = 0x24DD;
  15992. t['ncircumflexbelow'] = 0x1E4B;
  15993. t['ncommaaccent'] = 0x0146;
  15994. t['ndotaccent'] = 0x1E45;
  15995. t['ndotbelow'] = 0x1E47;
  15996. t['nehiragana'] = 0x306D;
  15997. t['nekatakana'] = 0x30CD;
  15998. t['nekatakanahalfwidth'] = 0xFF88;
  15999. t['newsheqelsign'] = 0x20AA;
  16000. t['nfsquare'] = 0x338B;
  16001. t['ngabengali'] = 0x0999;
  16002. t['ngadeva'] = 0x0919;
  16003. t['ngagujarati'] = 0x0A99;
  16004. t['ngagurmukhi'] = 0x0A19;
  16005. t['ngonguthai'] = 0x0E07;
  16006. t['nhiragana'] = 0x3093;
  16007. t['nhookleft'] = 0x0272;
  16008. t['nhookretroflex'] = 0x0273;
  16009. t['nieunacirclekorean'] = 0x326F;
  16010. t['nieunaparenkorean'] = 0x320F;
  16011. t['nieuncieuckorean'] = 0x3135;
  16012. t['nieuncirclekorean'] = 0x3261;
  16013. t['nieunhieuhkorean'] = 0x3136;
  16014. t['nieunkorean'] = 0x3134;
  16015. t['nieunpansioskorean'] = 0x3168;
  16016. t['nieunparenkorean'] = 0x3201;
  16017. t['nieunsioskorean'] = 0x3167;
  16018. t['nieuntikeutkorean'] = 0x3166;
  16019. t['nihiragana'] = 0x306B;
  16020. t['nikatakana'] = 0x30CB;
  16021. t['nikatakanahalfwidth'] = 0xFF86;
  16022. t['nikhahitleftthai'] = 0xF899;
  16023. t['nikhahitthai'] = 0x0E4D;
  16024. t['nine'] = 0x0039;
  16025. t['ninearabic'] = 0x0669;
  16026. t['ninebengali'] = 0x09EF;
  16027. t['ninecircle'] = 0x2468;
  16028. t['ninecircleinversesansserif'] = 0x2792;
  16029. t['ninedeva'] = 0x096F;
  16030. t['ninegujarati'] = 0x0AEF;
  16031. t['ninegurmukhi'] = 0x0A6F;
  16032. t['ninehackarabic'] = 0x0669;
  16033. t['ninehangzhou'] = 0x3029;
  16034. t['nineideographicparen'] = 0x3228;
  16035. t['nineinferior'] = 0x2089;
  16036. t['ninemonospace'] = 0xFF19;
  16037. t['nineoldstyle'] = 0xF739;
  16038. t['nineparen'] = 0x247C;
  16039. t['nineperiod'] = 0x2490;
  16040. t['ninepersian'] = 0x06F9;
  16041. t['nineroman'] = 0x2178;
  16042. t['ninesuperior'] = 0x2079;
  16043. t['nineteencircle'] = 0x2472;
  16044. t['nineteenparen'] = 0x2486;
  16045. t['nineteenperiod'] = 0x249A;
  16046. t['ninethai'] = 0x0E59;
  16047. t['nj'] = 0x01CC;
  16048. t['njecyrillic'] = 0x045A;
  16049. t['nkatakana'] = 0x30F3;
  16050. t['nkatakanahalfwidth'] = 0xFF9D;
  16051. t['nlegrightlong'] = 0x019E;
  16052. t['nlinebelow'] = 0x1E49;
  16053. t['nmonospace'] = 0xFF4E;
  16054. t['nmsquare'] = 0x339A;
  16055. t['nnabengali'] = 0x09A3;
  16056. t['nnadeva'] = 0x0923;
  16057. t['nnagujarati'] = 0x0AA3;
  16058. t['nnagurmukhi'] = 0x0A23;
  16059. t['nnnadeva'] = 0x0929;
  16060. t['nohiragana'] = 0x306E;
  16061. t['nokatakana'] = 0x30CE;
  16062. t['nokatakanahalfwidth'] = 0xFF89;
  16063. t['nonbreakingspace'] = 0x00A0;
  16064. t['nonenthai'] = 0x0E13;
  16065. t['nonuthai'] = 0x0E19;
  16066. t['noonarabic'] = 0x0646;
  16067. t['noonfinalarabic'] = 0xFEE6;
  16068. t['noonghunnaarabic'] = 0x06BA;
  16069. t['noonghunnafinalarabic'] = 0xFB9F;
  16070. t['nooninitialarabic'] = 0xFEE7;
  16071. t['noonjeeminitialarabic'] = 0xFCD2;
  16072. t['noonjeemisolatedarabic'] = 0xFC4B;
  16073. t['noonmedialarabic'] = 0xFEE8;
  16074. t['noonmeeminitialarabic'] = 0xFCD5;
  16075. t['noonmeemisolatedarabic'] = 0xFC4E;
  16076. t['noonnoonfinalarabic'] = 0xFC8D;
  16077. t['notcontains'] = 0x220C;
  16078. t['notelement'] = 0x2209;
  16079. t['notelementof'] = 0x2209;
  16080. t['notequal'] = 0x2260;
  16081. t['notgreater'] = 0x226F;
  16082. t['notgreaternorequal'] = 0x2271;
  16083. t['notgreaternorless'] = 0x2279;
  16084. t['notidentical'] = 0x2262;
  16085. t['notless'] = 0x226E;
  16086. t['notlessnorequal'] = 0x2270;
  16087. t['notparallel'] = 0x2226;
  16088. t['notprecedes'] = 0x2280;
  16089. t['notsubset'] = 0x2284;
  16090. t['notsucceeds'] = 0x2281;
  16091. t['notsuperset'] = 0x2285;
  16092. t['nowarmenian'] = 0x0576;
  16093. t['nparen'] = 0x24A9;
  16094. t['nssquare'] = 0x33B1;
  16095. t['nsuperior'] = 0x207F;
  16096. t['ntilde'] = 0x00F1;
  16097. t['nu'] = 0x03BD;
  16098. t['nuhiragana'] = 0x306C;
  16099. t['nukatakana'] = 0x30CC;
  16100. t['nukatakanahalfwidth'] = 0xFF87;
  16101. t['nuktabengali'] = 0x09BC;
  16102. t['nuktadeva'] = 0x093C;
  16103. t['nuktagujarati'] = 0x0ABC;
  16104. t['nuktagurmukhi'] = 0x0A3C;
  16105. t['numbersign'] = 0x0023;
  16106. t['numbersignmonospace'] = 0xFF03;
  16107. t['numbersignsmall'] = 0xFE5F;
  16108. t['numeralsigngreek'] = 0x0374;
  16109. t['numeralsignlowergreek'] = 0x0375;
  16110. t['numero'] = 0x2116;
  16111. t['nun'] = 0x05E0;
  16112. t['nundagesh'] = 0xFB40;
  16113. t['nundageshhebrew'] = 0xFB40;
  16114. t['nunhebrew'] = 0x05E0;
  16115. t['nvsquare'] = 0x33B5;
  16116. t['nwsquare'] = 0x33BB;
  16117. t['nyabengali'] = 0x099E;
  16118. t['nyadeva'] = 0x091E;
  16119. t['nyagujarati'] = 0x0A9E;
  16120. t['nyagurmukhi'] = 0x0A1E;
  16121. t['o'] = 0x006F;
  16122. t['oacute'] = 0x00F3;
  16123. t['oangthai'] = 0x0E2D;
  16124. t['obarred'] = 0x0275;
  16125. t['obarredcyrillic'] = 0x04E9;
  16126. t['obarreddieresiscyrillic'] = 0x04EB;
  16127. t['obengali'] = 0x0993;
  16128. t['obopomofo'] = 0x311B;
  16129. t['obreve'] = 0x014F;
  16130. t['ocandradeva'] = 0x0911;
  16131. t['ocandragujarati'] = 0x0A91;
  16132. t['ocandravowelsigndeva'] = 0x0949;
  16133. t['ocandravowelsigngujarati'] = 0x0AC9;
  16134. t['ocaron'] = 0x01D2;
  16135. t['ocircle'] = 0x24DE;
  16136. t['ocircumflex'] = 0x00F4;
  16137. t['ocircumflexacute'] = 0x1ED1;
  16138. t['ocircumflexdotbelow'] = 0x1ED9;
  16139. t['ocircumflexgrave'] = 0x1ED3;
  16140. t['ocircumflexhookabove'] = 0x1ED5;
  16141. t['ocircumflextilde'] = 0x1ED7;
  16142. t['ocyrillic'] = 0x043E;
  16143. t['odblacute'] = 0x0151;
  16144. t['odblgrave'] = 0x020D;
  16145. t['odeva'] = 0x0913;
  16146. t['odieresis'] = 0x00F6;
  16147. t['odieresiscyrillic'] = 0x04E7;
  16148. t['odotbelow'] = 0x1ECD;
  16149. t['oe'] = 0x0153;
  16150. t['oekorean'] = 0x315A;
  16151. t['ogonek'] = 0x02DB;
  16152. t['ogonekcmb'] = 0x0328;
  16153. t['ograve'] = 0x00F2;
  16154. t['ogujarati'] = 0x0A93;
  16155. t['oharmenian'] = 0x0585;
  16156. t['ohiragana'] = 0x304A;
  16157. t['ohookabove'] = 0x1ECF;
  16158. t['ohorn'] = 0x01A1;
  16159. t['ohornacute'] = 0x1EDB;
  16160. t['ohorndotbelow'] = 0x1EE3;
  16161. t['ohorngrave'] = 0x1EDD;
  16162. t['ohornhookabove'] = 0x1EDF;
  16163. t['ohorntilde'] = 0x1EE1;
  16164. t['ohungarumlaut'] = 0x0151;
  16165. t['oi'] = 0x01A3;
  16166. t['oinvertedbreve'] = 0x020F;
  16167. t['okatakana'] = 0x30AA;
  16168. t['okatakanahalfwidth'] = 0xFF75;
  16169. t['okorean'] = 0x3157;
  16170. t['olehebrew'] = 0x05AB;
  16171. t['omacron'] = 0x014D;
  16172. t['omacronacute'] = 0x1E53;
  16173. t['omacrongrave'] = 0x1E51;
  16174. t['omdeva'] = 0x0950;
  16175. t['omega'] = 0x03C9;
  16176. t['omega1'] = 0x03D6;
  16177. t['omegacyrillic'] = 0x0461;
  16178. t['omegalatinclosed'] = 0x0277;
  16179. t['omegaroundcyrillic'] = 0x047B;
  16180. t['omegatitlocyrillic'] = 0x047D;
  16181. t['omegatonos'] = 0x03CE;
  16182. t['omgujarati'] = 0x0AD0;
  16183. t['omicron'] = 0x03BF;
  16184. t['omicrontonos'] = 0x03CC;
  16185. t['omonospace'] = 0xFF4F;
  16186. t['one'] = 0x0031;
  16187. t['onearabic'] = 0x0661;
  16188. t['onebengali'] = 0x09E7;
  16189. t['onecircle'] = 0x2460;
  16190. t['onecircleinversesansserif'] = 0x278A;
  16191. t['onedeva'] = 0x0967;
  16192. t['onedotenleader'] = 0x2024;
  16193. t['oneeighth'] = 0x215B;
  16194. t['onefitted'] = 0xF6DC;
  16195. t['onegujarati'] = 0x0AE7;
  16196. t['onegurmukhi'] = 0x0A67;
  16197. t['onehackarabic'] = 0x0661;
  16198. t['onehalf'] = 0x00BD;
  16199. t['onehangzhou'] = 0x3021;
  16200. t['oneideographicparen'] = 0x3220;
  16201. t['oneinferior'] = 0x2081;
  16202. t['onemonospace'] = 0xFF11;
  16203. t['onenumeratorbengali'] = 0x09F4;
  16204. t['oneoldstyle'] = 0xF731;
  16205. t['oneparen'] = 0x2474;
  16206. t['oneperiod'] = 0x2488;
  16207. t['onepersian'] = 0x06F1;
  16208. t['onequarter'] = 0x00BC;
  16209. t['oneroman'] = 0x2170;
  16210. t['onesuperior'] = 0x00B9;
  16211. t['onethai'] = 0x0E51;
  16212. t['onethird'] = 0x2153;
  16213. t['oogonek'] = 0x01EB;
  16214. t['oogonekmacron'] = 0x01ED;
  16215. t['oogurmukhi'] = 0x0A13;
  16216. t['oomatragurmukhi'] = 0x0A4B;
  16217. t['oopen'] = 0x0254;
  16218. t['oparen'] = 0x24AA;
  16219. t['openbullet'] = 0x25E6;
  16220. t['option'] = 0x2325;
  16221. t['ordfeminine'] = 0x00AA;
  16222. t['ordmasculine'] = 0x00BA;
  16223. t['orthogonal'] = 0x221F;
  16224. t['oshortdeva'] = 0x0912;
  16225. t['oshortvowelsigndeva'] = 0x094A;
  16226. t['oslash'] = 0x00F8;
  16227. t['oslashacute'] = 0x01FF;
  16228. t['osmallhiragana'] = 0x3049;
  16229. t['osmallkatakana'] = 0x30A9;
  16230. t['osmallkatakanahalfwidth'] = 0xFF6B;
  16231. t['ostrokeacute'] = 0x01FF;
  16232. t['osuperior'] = 0xF6F0;
  16233. t['otcyrillic'] = 0x047F;
  16234. t['otilde'] = 0x00F5;
  16235. t['otildeacute'] = 0x1E4D;
  16236. t['otildedieresis'] = 0x1E4F;
  16237. t['oubopomofo'] = 0x3121;
  16238. t['overline'] = 0x203E;
  16239. t['overlinecenterline'] = 0xFE4A;
  16240. t['overlinecmb'] = 0x0305;
  16241. t['overlinedashed'] = 0xFE49;
  16242. t['overlinedblwavy'] = 0xFE4C;
  16243. t['overlinewavy'] = 0xFE4B;
  16244. t['overscore'] = 0x00AF;
  16245. t['ovowelsignbengali'] = 0x09CB;
  16246. t['ovowelsigndeva'] = 0x094B;
  16247. t['ovowelsigngujarati'] = 0x0ACB;
  16248. t['p'] = 0x0070;
  16249. t['paampssquare'] = 0x3380;
  16250. t['paasentosquare'] = 0x332B;
  16251. t['pabengali'] = 0x09AA;
  16252. t['pacute'] = 0x1E55;
  16253. t['padeva'] = 0x092A;
  16254. t['pagedown'] = 0x21DF;
  16255. t['pageup'] = 0x21DE;
  16256. t['pagujarati'] = 0x0AAA;
  16257. t['pagurmukhi'] = 0x0A2A;
  16258. t['pahiragana'] = 0x3071;
  16259. t['paiyannoithai'] = 0x0E2F;
  16260. t['pakatakana'] = 0x30D1;
  16261. t['palatalizationcyrilliccmb'] = 0x0484;
  16262. t['palochkacyrillic'] = 0x04C0;
  16263. t['pansioskorean'] = 0x317F;
  16264. t['paragraph'] = 0x00B6;
  16265. t['parallel'] = 0x2225;
  16266. t['parenleft'] = 0x0028;
  16267. t['parenleftaltonearabic'] = 0xFD3E;
  16268. t['parenleftbt'] = 0xF8ED;
  16269. t['parenleftex'] = 0xF8EC;
  16270. t['parenleftinferior'] = 0x208D;
  16271. t['parenleftmonospace'] = 0xFF08;
  16272. t['parenleftsmall'] = 0xFE59;
  16273. t['parenleftsuperior'] = 0x207D;
  16274. t['parenlefttp'] = 0xF8EB;
  16275. t['parenleftvertical'] = 0xFE35;
  16276. t['parenright'] = 0x0029;
  16277. t['parenrightaltonearabic'] = 0xFD3F;
  16278. t['parenrightbt'] = 0xF8F8;
  16279. t['parenrightex'] = 0xF8F7;
  16280. t['parenrightinferior'] = 0x208E;
  16281. t['parenrightmonospace'] = 0xFF09;
  16282. t['parenrightsmall'] = 0xFE5A;
  16283. t['parenrightsuperior'] = 0x207E;
  16284. t['parenrighttp'] = 0xF8F6;
  16285. t['parenrightvertical'] = 0xFE36;
  16286. t['partialdiff'] = 0x2202;
  16287. t['paseqhebrew'] = 0x05C0;
  16288. t['pashtahebrew'] = 0x0599;
  16289. t['pasquare'] = 0x33A9;
  16290. t['patah'] = 0x05B7;
  16291. t['patah11'] = 0x05B7;
  16292. t['patah1d'] = 0x05B7;
  16293. t['patah2a'] = 0x05B7;
  16294. t['patahhebrew'] = 0x05B7;
  16295. t['patahnarrowhebrew'] = 0x05B7;
  16296. t['patahquarterhebrew'] = 0x05B7;
  16297. t['patahwidehebrew'] = 0x05B7;
  16298. t['pazerhebrew'] = 0x05A1;
  16299. t['pbopomofo'] = 0x3106;
  16300. t['pcircle'] = 0x24DF;
  16301. t['pdotaccent'] = 0x1E57;
  16302. t['pe'] = 0x05E4;
  16303. t['pecyrillic'] = 0x043F;
  16304. t['pedagesh'] = 0xFB44;
  16305. t['pedageshhebrew'] = 0xFB44;
  16306. t['peezisquare'] = 0x333B;
  16307. t['pefinaldageshhebrew'] = 0xFB43;
  16308. t['peharabic'] = 0x067E;
  16309. t['peharmenian'] = 0x057A;
  16310. t['pehebrew'] = 0x05E4;
  16311. t['pehfinalarabic'] = 0xFB57;
  16312. t['pehinitialarabic'] = 0xFB58;
  16313. t['pehiragana'] = 0x307A;
  16314. t['pehmedialarabic'] = 0xFB59;
  16315. t['pekatakana'] = 0x30DA;
  16316. t['pemiddlehookcyrillic'] = 0x04A7;
  16317. t['perafehebrew'] = 0xFB4E;
  16318. t['percent'] = 0x0025;
  16319. t['percentarabic'] = 0x066A;
  16320. t['percentmonospace'] = 0xFF05;
  16321. t['percentsmall'] = 0xFE6A;
  16322. t['period'] = 0x002E;
  16323. t['periodarmenian'] = 0x0589;
  16324. t['periodcentered'] = 0x00B7;
  16325. t['periodhalfwidth'] = 0xFF61;
  16326. t['periodinferior'] = 0xF6E7;
  16327. t['periodmonospace'] = 0xFF0E;
  16328. t['periodsmall'] = 0xFE52;
  16329. t['periodsuperior'] = 0xF6E8;
  16330. t['perispomenigreekcmb'] = 0x0342;
  16331. t['perpendicular'] = 0x22A5;
  16332. t['perthousand'] = 0x2030;
  16333. t['peseta'] = 0x20A7;
  16334. t['pfsquare'] = 0x338A;
  16335. t['phabengali'] = 0x09AB;
  16336. t['phadeva'] = 0x092B;
  16337. t['phagujarati'] = 0x0AAB;
  16338. t['phagurmukhi'] = 0x0A2B;
  16339. t['phi'] = 0x03C6;
  16340. t['phi1'] = 0x03D5;
  16341. t['phieuphacirclekorean'] = 0x327A;
  16342. t['phieuphaparenkorean'] = 0x321A;
  16343. t['phieuphcirclekorean'] = 0x326C;
  16344. t['phieuphkorean'] = 0x314D;
  16345. t['phieuphparenkorean'] = 0x320C;
  16346. t['philatin'] = 0x0278;
  16347. t['phinthuthai'] = 0x0E3A;
  16348. t['phisymbolgreek'] = 0x03D5;
  16349. t['phook'] = 0x01A5;
  16350. t['phophanthai'] = 0x0E1E;
  16351. t['phophungthai'] = 0x0E1C;
  16352. t['phosamphaothai'] = 0x0E20;
  16353. t['pi'] = 0x03C0;
  16354. t['pieupacirclekorean'] = 0x3273;
  16355. t['pieupaparenkorean'] = 0x3213;
  16356. t['pieupcieuckorean'] = 0x3176;
  16357. t['pieupcirclekorean'] = 0x3265;
  16358. t['pieupkiyeokkorean'] = 0x3172;
  16359. t['pieupkorean'] = 0x3142;
  16360. t['pieupparenkorean'] = 0x3205;
  16361. t['pieupsioskiyeokkorean'] = 0x3174;
  16362. t['pieupsioskorean'] = 0x3144;
  16363. t['pieupsiostikeutkorean'] = 0x3175;
  16364. t['pieupthieuthkorean'] = 0x3177;
  16365. t['pieuptikeutkorean'] = 0x3173;
  16366. t['pihiragana'] = 0x3074;
  16367. t['pikatakana'] = 0x30D4;
  16368. t['pisymbolgreek'] = 0x03D6;
  16369. t['piwrarmenian'] = 0x0583;
  16370. t['plus'] = 0x002B;
  16371. t['plusbelowcmb'] = 0x031F;
  16372. t['pluscircle'] = 0x2295;
  16373. t['plusminus'] = 0x00B1;
  16374. t['plusmod'] = 0x02D6;
  16375. t['plusmonospace'] = 0xFF0B;
  16376. t['plussmall'] = 0xFE62;
  16377. t['plussuperior'] = 0x207A;
  16378. t['pmonospace'] = 0xFF50;
  16379. t['pmsquare'] = 0x33D8;
  16380. t['pohiragana'] = 0x307D;
  16381. t['pointingindexdownwhite'] = 0x261F;
  16382. t['pointingindexleftwhite'] = 0x261C;
  16383. t['pointingindexrightwhite'] = 0x261E;
  16384. t['pointingindexupwhite'] = 0x261D;
  16385. t['pokatakana'] = 0x30DD;
  16386. t['poplathai'] = 0x0E1B;
  16387. t['postalmark'] = 0x3012;
  16388. t['postalmarkface'] = 0x3020;
  16389. t['pparen'] = 0x24AB;
  16390. t['precedes'] = 0x227A;
  16391. t['prescription'] = 0x211E;
  16392. t['primemod'] = 0x02B9;
  16393. t['primereversed'] = 0x2035;
  16394. t['product'] = 0x220F;
  16395. t['projective'] = 0x2305;
  16396. t['prolongedkana'] = 0x30FC;
  16397. t['propellor'] = 0x2318;
  16398. t['propersubset'] = 0x2282;
  16399. t['propersuperset'] = 0x2283;
  16400. t['proportion'] = 0x2237;
  16401. t['proportional'] = 0x221D;
  16402. t['psi'] = 0x03C8;
  16403. t['psicyrillic'] = 0x0471;
  16404. t['psilipneumatacyrilliccmb'] = 0x0486;
  16405. t['pssquare'] = 0x33B0;
  16406. t['puhiragana'] = 0x3077;
  16407. t['pukatakana'] = 0x30D7;
  16408. t['pvsquare'] = 0x33B4;
  16409. t['pwsquare'] = 0x33BA;
  16410. t['q'] = 0x0071;
  16411. t['qadeva'] = 0x0958;
  16412. t['qadmahebrew'] = 0x05A8;
  16413. t['qafarabic'] = 0x0642;
  16414. t['qaffinalarabic'] = 0xFED6;
  16415. t['qafinitialarabic'] = 0xFED7;
  16416. t['qafmedialarabic'] = 0xFED8;
  16417. t['qamats'] = 0x05B8;
  16418. t['qamats10'] = 0x05B8;
  16419. t['qamats1a'] = 0x05B8;
  16420. t['qamats1c'] = 0x05B8;
  16421. t['qamats27'] = 0x05B8;
  16422. t['qamats29'] = 0x05B8;
  16423. t['qamats33'] = 0x05B8;
  16424. t['qamatsde'] = 0x05B8;
  16425. t['qamatshebrew'] = 0x05B8;
  16426. t['qamatsnarrowhebrew'] = 0x05B8;
  16427. t['qamatsqatanhebrew'] = 0x05B8;
  16428. t['qamatsqatannarrowhebrew'] = 0x05B8;
  16429. t['qamatsqatanquarterhebrew'] = 0x05B8;
  16430. t['qamatsqatanwidehebrew'] = 0x05B8;
  16431. t['qamatsquarterhebrew'] = 0x05B8;
  16432. t['qamatswidehebrew'] = 0x05B8;
  16433. t['qarneyparahebrew'] = 0x059F;
  16434. t['qbopomofo'] = 0x3111;
  16435. t['qcircle'] = 0x24E0;
  16436. t['qhook'] = 0x02A0;
  16437. t['qmonospace'] = 0xFF51;
  16438. t['qof'] = 0x05E7;
  16439. t['qofdagesh'] = 0xFB47;
  16440. t['qofdageshhebrew'] = 0xFB47;
  16441. t['qofhebrew'] = 0x05E7;
  16442. t['qparen'] = 0x24AC;
  16443. t['quarternote'] = 0x2669;
  16444. t['qubuts'] = 0x05BB;
  16445. t['qubuts18'] = 0x05BB;
  16446. t['qubuts25'] = 0x05BB;
  16447. t['qubuts31'] = 0x05BB;
  16448. t['qubutshebrew'] = 0x05BB;
  16449. t['qubutsnarrowhebrew'] = 0x05BB;
  16450. t['qubutsquarterhebrew'] = 0x05BB;
  16451. t['qubutswidehebrew'] = 0x05BB;
  16452. t['question'] = 0x003F;
  16453. t['questionarabic'] = 0x061F;
  16454. t['questionarmenian'] = 0x055E;
  16455. t['questiondown'] = 0x00BF;
  16456. t['questiondownsmall'] = 0xF7BF;
  16457. t['questiongreek'] = 0x037E;
  16458. t['questionmonospace'] = 0xFF1F;
  16459. t['questionsmall'] = 0xF73F;
  16460. t['quotedbl'] = 0x0022;
  16461. t['quotedblbase'] = 0x201E;
  16462. t['quotedblleft'] = 0x201C;
  16463. t['quotedblmonospace'] = 0xFF02;
  16464. t['quotedblprime'] = 0x301E;
  16465. t['quotedblprimereversed'] = 0x301D;
  16466. t['quotedblright'] = 0x201D;
  16467. t['quoteleft'] = 0x2018;
  16468. t['quoteleftreversed'] = 0x201B;
  16469. t['quotereversed'] = 0x201B;
  16470. t['quoteright'] = 0x2019;
  16471. t['quoterightn'] = 0x0149;
  16472. t['quotesinglbase'] = 0x201A;
  16473. t['quotesingle'] = 0x0027;
  16474. t['quotesinglemonospace'] = 0xFF07;
  16475. t['r'] = 0x0072;
  16476. t['raarmenian'] = 0x057C;
  16477. t['rabengali'] = 0x09B0;
  16478. t['racute'] = 0x0155;
  16479. t['radeva'] = 0x0930;
  16480. t['radical'] = 0x221A;
  16481. t['radicalex'] = 0xF8E5;
  16482. t['radoverssquare'] = 0x33AE;
  16483. t['radoverssquaredsquare'] = 0x33AF;
  16484. t['radsquare'] = 0x33AD;
  16485. t['rafe'] = 0x05BF;
  16486. t['rafehebrew'] = 0x05BF;
  16487. t['ragujarati'] = 0x0AB0;
  16488. t['ragurmukhi'] = 0x0A30;
  16489. t['rahiragana'] = 0x3089;
  16490. t['rakatakana'] = 0x30E9;
  16491. t['rakatakanahalfwidth'] = 0xFF97;
  16492. t['ralowerdiagonalbengali'] = 0x09F1;
  16493. t['ramiddlediagonalbengali'] = 0x09F0;
  16494. t['ramshorn'] = 0x0264;
  16495. t['ratio'] = 0x2236;
  16496. t['rbopomofo'] = 0x3116;
  16497. t['rcaron'] = 0x0159;
  16498. t['rcedilla'] = 0x0157;
  16499. t['rcircle'] = 0x24E1;
  16500. t['rcommaaccent'] = 0x0157;
  16501. t['rdblgrave'] = 0x0211;
  16502. t['rdotaccent'] = 0x1E59;
  16503. t['rdotbelow'] = 0x1E5B;
  16504. t['rdotbelowmacron'] = 0x1E5D;
  16505. t['referencemark'] = 0x203B;
  16506. t['reflexsubset'] = 0x2286;
  16507. t['reflexsuperset'] = 0x2287;
  16508. t['registered'] = 0x00AE;
  16509. t['registersans'] = 0xF8E8;
  16510. t['registerserif'] = 0xF6DA;
  16511. t['reharabic'] = 0x0631;
  16512. t['reharmenian'] = 0x0580;
  16513. t['rehfinalarabic'] = 0xFEAE;
  16514. t['rehiragana'] = 0x308C;
  16515. t['rekatakana'] = 0x30EC;
  16516. t['rekatakanahalfwidth'] = 0xFF9A;
  16517. t['resh'] = 0x05E8;
  16518. t['reshdageshhebrew'] = 0xFB48;
  16519. t['reshhebrew'] = 0x05E8;
  16520. t['reversedtilde'] = 0x223D;
  16521. t['reviahebrew'] = 0x0597;
  16522. t['reviamugrashhebrew'] = 0x0597;
  16523. t['revlogicalnot'] = 0x2310;
  16524. t['rfishhook'] = 0x027E;
  16525. t['rfishhookreversed'] = 0x027F;
  16526. t['rhabengali'] = 0x09DD;
  16527. t['rhadeva'] = 0x095D;
  16528. t['rho'] = 0x03C1;
  16529. t['rhook'] = 0x027D;
  16530. t['rhookturned'] = 0x027B;
  16531. t['rhookturnedsuperior'] = 0x02B5;
  16532. t['rhosymbolgreek'] = 0x03F1;
  16533. t['rhotichookmod'] = 0x02DE;
  16534. t['rieulacirclekorean'] = 0x3271;
  16535. t['rieulaparenkorean'] = 0x3211;
  16536. t['rieulcirclekorean'] = 0x3263;
  16537. t['rieulhieuhkorean'] = 0x3140;
  16538. t['rieulkiyeokkorean'] = 0x313A;
  16539. t['rieulkiyeoksioskorean'] = 0x3169;
  16540. t['rieulkorean'] = 0x3139;
  16541. t['rieulmieumkorean'] = 0x313B;
  16542. t['rieulpansioskorean'] = 0x316C;
  16543. t['rieulparenkorean'] = 0x3203;
  16544. t['rieulphieuphkorean'] = 0x313F;
  16545. t['rieulpieupkorean'] = 0x313C;
  16546. t['rieulpieupsioskorean'] = 0x316B;
  16547. t['rieulsioskorean'] = 0x313D;
  16548. t['rieulthieuthkorean'] = 0x313E;
  16549. t['rieultikeutkorean'] = 0x316A;
  16550. t['rieulyeorinhieuhkorean'] = 0x316D;
  16551. t['rightangle'] = 0x221F;
  16552. t['righttackbelowcmb'] = 0x0319;
  16553. t['righttriangle'] = 0x22BF;
  16554. t['rihiragana'] = 0x308A;
  16555. t['rikatakana'] = 0x30EA;
  16556. t['rikatakanahalfwidth'] = 0xFF98;
  16557. t['ring'] = 0x02DA;
  16558. t['ringbelowcmb'] = 0x0325;
  16559. t['ringcmb'] = 0x030A;
  16560. t['ringhalfleft'] = 0x02BF;
  16561. t['ringhalfleftarmenian'] = 0x0559;
  16562. t['ringhalfleftbelowcmb'] = 0x031C;
  16563. t['ringhalfleftcentered'] = 0x02D3;
  16564. t['ringhalfright'] = 0x02BE;
  16565. t['ringhalfrightbelowcmb'] = 0x0339;
  16566. t['ringhalfrightcentered'] = 0x02D2;
  16567. t['rinvertedbreve'] = 0x0213;
  16568. t['rittorusquare'] = 0x3351;
  16569. t['rlinebelow'] = 0x1E5F;
  16570. t['rlongleg'] = 0x027C;
  16571. t['rlonglegturned'] = 0x027A;
  16572. t['rmonospace'] = 0xFF52;
  16573. t['rohiragana'] = 0x308D;
  16574. t['rokatakana'] = 0x30ED;
  16575. t['rokatakanahalfwidth'] = 0xFF9B;
  16576. t['roruathai'] = 0x0E23;
  16577. t['rparen'] = 0x24AD;
  16578. t['rrabengali'] = 0x09DC;
  16579. t['rradeva'] = 0x0931;
  16580. t['rragurmukhi'] = 0x0A5C;
  16581. t['rreharabic'] = 0x0691;
  16582. t['rrehfinalarabic'] = 0xFB8D;
  16583. t['rrvocalicbengali'] = 0x09E0;
  16584. t['rrvocalicdeva'] = 0x0960;
  16585. t['rrvocalicgujarati'] = 0x0AE0;
  16586. t['rrvocalicvowelsignbengali'] = 0x09C4;
  16587. t['rrvocalicvowelsigndeva'] = 0x0944;
  16588. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  16589. t['rsuperior'] = 0xF6F1;
  16590. t['rtblock'] = 0x2590;
  16591. t['rturned'] = 0x0279;
  16592. t['rturnedsuperior'] = 0x02B4;
  16593. t['ruhiragana'] = 0x308B;
  16594. t['rukatakana'] = 0x30EB;
  16595. t['rukatakanahalfwidth'] = 0xFF99;
  16596. t['rupeemarkbengali'] = 0x09F2;
  16597. t['rupeesignbengali'] = 0x09F3;
  16598. t['rupiah'] = 0xF6DD;
  16599. t['ruthai'] = 0x0E24;
  16600. t['rvocalicbengali'] = 0x098B;
  16601. t['rvocalicdeva'] = 0x090B;
  16602. t['rvocalicgujarati'] = 0x0A8B;
  16603. t['rvocalicvowelsignbengali'] = 0x09C3;
  16604. t['rvocalicvowelsigndeva'] = 0x0943;
  16605. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  16606. t['s'] = 0x0073;
  16607. t['sabengali'] = 0x09B8;
  16608. t['sacute'] = 0x015B;
  16609. t['sacutedotaccent'] = 0x1E65;
  16610. t['sadarabic'] = 0x0635;
  16611. t['sadeva'] = 0x0938;
  16612. t['sadfinalarabic'] = 0xFEBA;
  16613. t['sadinitialarabic'] = 0xFEBB;
  16614. t['sadmedialarabic'] = 0xFEBC;
  16615. t['sagujarati'] = 0x0AB8;
  16616. t['sagurmukhi'] = 0x0A38;
  16617. t['sahiragana'] = 0x3055;
  16618. t['sakatakana'] = 0x30B5;
  16619. t['sakatakanahalfwidth'] = 0xFF7B;
  16620. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  16621. t['samekh'] = 0x05E1;
  16622. t['samekhdagesh'] = 0xFB41;
  16623. t['samekhdageshhebrew'] = 0xFB41;
  16624. t['samekhhebrew'] = 0x05E1;
  16625. t['saraaathai'] = 0x0E32;
  16626. t['saraaethai'] = 0x0E41;
  16627. t['saraaimaimalaithai'] = 0x0E44;
  16628. t['saraaimaimuanthai'] = 0x0E43;
  16629. t['saraamthai'] = 0x0E33;
  16630. t['saraathai'] = 0x0E30;
  16631. t['saraethai'] = 0x0E40;
  16632. t['saraiileftthai'] = 0xF886;
  16633. t['saraiithai'] = 0x0E35;
  16634. t['saraileftthai'] = 0xF885;
  16635. t['saraithai'] = 0x0E34;
  16636. t['saraothai'] = 0x0E42;
  16637. t['saraueeleftthai'] = 0xF888;
  16638. t['saraueethai'] = 0x0E37;
  16639. t['saraueleftthai'] = 0xF887;
  16640. t['sarauethai'] = 0x0E36;
  16641. t['sarauthai'] = 0x0E38;
  16642. t['sarauuthai'] = 0x0E39;
  16643. t['sbopomofo'] = 0x3119;
  16644. t['scaron'] = 0x0161;
  16645. t['scarondotaccent'] = 0x1E67;
  16646. t['scedilla'] = 0x015F;
  16647. t['schwa'] = 0x0259;
  16648. t['schwacyrillic'] = 0x04D9;
  16649. t['schwadieresiscyrillic'] = 0x04DB;
  16650. t['schwahook'] = 0x025A;
  16651. t['scircle'] = 0x24E2;
  16652. t['scircumflex'] = 0x015D;
  16653. t['scommaaccent'] = 0x0219;
  16654. t['sdotaccent'] = 0x1E61;
  16655. t['sdotbelow'] = 0x1E63;
  16656. t['sdotbelowdotaccent'] = 0x1E69;
  16657. t['seagullbelowcmb'] = 0x033C;
  16658. t['second'] = 0x2033;
  16659. t['secondtonechinese'] = 0x02CA;
  16660. t['section'] = 0x00A7;
  16661. t['seenarabic'] = 0x0633;
  16662. t['seenfinalarabic'] = 0xFEB2;
  16663. t['seeninitialarabic'] = 0xFEB3;
  16664. t['seenmedialarabic'] = 0xFEB4;
  16665. t['segol'] = 0x05B6;
  16666. t['segol13'] = 0x05B6;
  16667. t['segol1f'] = 0x05B6;
  16668. t['segol2c'] = 0x05B6;
  16669. t['segolhebrew'] = 0x05B6;
  16670. t['segolnarrowhebrew'] = 0x05B6;
  16671. t['segolquarterhebrew'] = 0x05B6;
  16672. t['segoltahebrew'] = 0x0592;
  16673. t['segolwidehebrew'] = 0x05B6;
  16674. t['seharmenian'] = 0x057D;
  16675. t['sehiragana'] = 0x305B;
  16676. t['sekatakana'] = 0x30BB;
  16677. t['sekatakanahalfwidth'] = 0xFF7E;
  16678. t['semicolon'] = 0x003B;
  16679. t['semicolonarabic'] = 0x061B;
  16680. t['semicolonmonospace'] = 0xFF1B;
  16681. t['semicolonsmall'] = 0xFE54;
  16682. t['semivoicedmarkkana'] = 0x309C;
  16683. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  16684. t['sentisquare'] = 0x3322;
  16685. t['sentosquare'] = 0x3323;
  16686. t['seven'] = 0x0037;
  16687. t['sevenarabic'] = 0x0667;
  16688. t['sevenbengali'] = 0x09ED;
  16689. t['sevencircle'] = 0x2466;
  16690. t['sevencircleinversesansserif'] = 0x2790;
  16691. t['sevendeva'] = 0x096D;
  16692. t['seveneighths'] = 0x215E;
  16693. t['sevengujarati'] = 0x0AED;
  16694. t['sevengurmukhi'] = 0x0A6D;
  16695. t['sevenhackarabic'] = 0x0667;
  16696. t['sevenhangzhou'] = 0x3027;
  16697. t['sevenideographicparen'] = 0x3226;
  16698. t['seveninferior'] = 0x2087;
  16699. t['sevenmonospace'] = 0xFF17;
  16700. t['sevenoldstyle'] = 0xF737;
  16701. t['sevenparen'] = 0x247A;
  16702. t['sevenperiod'] = 0x248E;
  16703. t['sevenpersian'] = 0x06F7;
  16704. t['sevenroman'] = 0x2176;
  16705. t['sevensuperior'] = 0x2077;
  16706. t['seventeencircle'] = 0x2470;
  16707. t['seventeenparen'] = 0x2484;
  16708. t['seventeenperiod'] = 0x2498;
  16709. t['seventhai'] = 0x0E57;
  16710. t['sfthyphen'] = 0x00AD;
  16711. t['shaarmenian'] = 0x0577;
  16712. t['shabengali'] = 0x09B6;
  16713. t['shacyrillic'] = 0x0448;
  16714. t['shaddaarabic'] = 0x0651;
  16715. t['shaddadammaarabic'] = 0xFC61;
  16716. t['shaddadammatanarabic'] = 0xFC5E;
  16717. t['shaddafathaarabic'] = 0xFC60;
  16718. t['shaddakasraarabic'] = 0xFC62;
  16719. t['shaddakasratanarabic'] = 0xFC5F;
  16720. t['shade'] = 0x2592;
  16721. t['shadedark'] = 0x2593;
  16722. t['shadelight'] = 0x2591;
  16723. t['shademedium'] = 0x2592;
  16724. t['shadeva'] = 0x0936;
  16725. t['shagujarati'] = 0x0AB6;
  16726. t['shagurmukhi'] = 0x0A36;
  16727. t['shalshelethebrew'] = 0x0593;
  16728. t['shbopomofo'] = 0x3115;
  16729. t['shchacyrillic'] = 0x0449;
  16730. t['sheenarabic'] = 0x0634;
  16731. t['sheenfinalarabic'] = 0xFEB6;
  16732. t['sheeninitialarabic'] = 0xFEB7;
  16733. t['sheenmedialarabic'] = 0xFEB8;
  16734. t['sheicoptic'] = 0x03E3;
  16735. t['sheqel'] = 0x20AA;
  16736. t['sheqelhebrew'] = 0x20AA;
  16737. t['sheva'] = 0x05B0;
  16738. t['sheva115'] = 0x05B0;
  16739. t['sheva15'] = 0x05B0;
  16740. t['sheva22'] = 0x05B0;
  16741. t['sheva2e'] = 0x05B0;
  16742. t['shevahebrew'] = 0x05B0;
  16743. t['shevanarrowhebrew'] = 0x05B0;
  16744. t['shevaquarterhebrew'] = 0x05B0;
  16745. t['shevawidehebrew'] = 0x05B0;
  16746. t['shhacyrillic'] = 0x04BB;
  16747. t['shimacoptic'] = 0x03ED;
  16748. t['shin'] = 0x05E9;
  16749. t['shindagesh'] = 0xFB49;
  16750. t['shindageshhebrew'] = 0xFB49;
  16751. t['shindageshshindot'] = 0xFB2C;
  16752. t['shindageshshindothebrew'] = 0xFB2C;
  16753. t['shindageshsindot'] = 0xFB2D;
  16754. t['shindageshsindothebrew'] = 0xFB2D;
  16755. t['shindothebrew'] = 0x05C1;
  16756. t['shinhebrew'] = 0x05E9;
  16757. t['shinshindot'] = 0xFB2A;
  16758. t['shinshindothebrew'] = 0xFB2A;
  16759. t['shinsindot'] = 0xFB2B;
  16760. t['shinsindothebrew'] = 0xFB2B;
  16761. t['shook'] = 0x0282;
  16762. t['sigma'] = 0x03C3;
  16763. t['sigma1'] = 0x03C2;
  16764. t['sigmafinal'] = 0x03C2;
  16765. t['sigmalunatesymbolgreek'] = 0x03F2;
  16766. t['sihiragana'] = 0x3057;
  16767. t['sikatakana'] = 0x30B7;
  16768. t['sikatakanahalfwidth'] = 0xFF7C;
  16769. t['siluqhebrew'] = 0x05BD;
  16770. t['siluqlefthebrew'] = 0x05BD;
  16771. t['similar'] = 0x223C;
  16772. t['sindothebrew'] = 0x05C2;
  16773. t['siosacirclekorean'] = 0x3274;
  16774. t['siosaparenkorean'] = 0x3214;
  16775. t['sioscieuckorean'] = 0x317E;
  16776. t['sioscirclekorean'] = 0x3266;
  16777. t['sioskiyeokkorean'] = 0x317A;
  16778. t['sioskorean'] = 0x3145;
  16779. t['siosnieunkorean'] = 0x317B;
  16780. t['siosparenkorean'] = 0x3206;
  16781. t['siospieupkorean'] = 0x317D;
  16782. t['siostikeutkorean'] = 0x317C;
  16783. t['six'] = 0x0036;
  16784. t['sixarabic'] = 0x0666;
  16785. t['sixbengali'] = 0x09EC;
  16786. t['sixcircle'] = 0x2465;
  16787. t['sixcircleinversesansserif'] = 0x278F;
  16788. t['sixdeva'] = 0x096C;
  16789. t['sixgujarati'] = 0x0AEC;
  16790. t['sixgurmukhi'] = 0x0A6C;
  16791. t['sixhackarabic'] = 0x0666;
  16792. t['sixhangzhou'] = 0x3026;
  16793. t['sixideographicparen'] = 0x3225;
  16794. t['sixinferior'] = 0x2086;
  16795. t['sixmonospace'] = 0xFF16;
  16796. t['sixoldstyle'] = 0xF736;
  16797. t['sixparen'] = 0x2479;
  16798. t['sixperiod'] = 0x248D;
  16799. t['sixpersian'] = 0x06F6;
  16800. t['sixroman'] = 0x2175;
  16801. t['sixsuperior'] = 0x2076;
  16802. t['sixteencircle'] = 0x246F;
  16803. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  16804. t['sixteenparen'] = 0x2483;
  16805. t['sixteenperiod'] = 0x2497;
  16806. t['sixthai'] = 0x0E56;
  16807. t['slash'] = 0x002F;
  16808. t['slashmonospace'] = 0xFF0F;
  16809. t['slong'] = 0x017F;
  16810. t['slongdotaccent'] = 0x1E9B;
  16811. t['smileface'] = 0x263A;
  16812. t['smonospace'] = 0xFF53;
  16813. t['sofpasuqhebrew'] = 0x05C3;
  16814. t['softhyphen'] = 0x00AD;
  16815. t['softsigncyrillic'] = 0x044C;
  16816. t['sohiragana'] = 0x305D;
  16817. t['sokatakana'] = 0x30BD;
  16818. t['sokatakanahalfwidth'] = 0xFF7F;
  16819. t['soliduslongoverlaycmb'] = 0x0338;
  16820. t['solidusshortoverlaycmb'] = 0x0337;
  16821. t['sorusithai'] = 0x0E29;
  16822. t['sosalathai'] = 0x0E28;
  16823. t['sosothai'] = 0x0E0B;
  16824. t['sosuathai'] = 0x0E2A;
  16825. t['space'] = 0x0020;
  16826. t['spacehackarabic'] = 0x0020;
  16827. t['spade'] = 0x2660;
  16828. t['spadesuitblack'] = 0x2660;
  16829. t['spadesuitwhite'] = 0x2664;
  16830. t['sparen'] = 0x24AE;
  16831. t['squarebelowcmb'] = 0x033B;
  16832. t['squarecc'] = 0x33C4;
  16833. t['squarecm'] = 0x339D;
  16834. t['squarediagonalcrosshatchfill'] = 0x25A9;
  16835. t['squarehorizontalfill'] = 0x25A4;
  16836. t['squarekg'] = 0x338F;
  16837. t['squarekm'] = 0x339E;
  16838. t['squarekmcapital'] = 0x33CE;
  16839. t['squareln'] = 0x33D1;
  16840. t['squarelog'] = 0x33D2;
  16841. t['squaremg'] = 0x338E;
  16842. t['squaremil'] = 0x33D5;
  16843. t['squaremm'] = 0x339C;
  16844. t['squaremsquared'] = 0x33A1;
  16845. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  16846. t['squareupperlefttolowerrightfill'] = 0x25A7;
  16847. t['squareupperrighttolowerleftfill'] = 0x25A8;
  16848. t['squareverticalfill'] = 0x25A5;
  16849. t['squarewhitewithsmallblack'] = 0x25A3;
  16850. t['srsquare'] = 0x33DB;
  16851. t['ssabengali'] = 0x09B7;
  16852. t['ssadeva'] = 0x0937;
  16853. t['ssagujarati'] = 0x0AB7;
  16854. t['ssangcieuckorean'] = 0x3149;
  16855. t['ssanghieuhkorean'] = 0x3185;
  16856. t['ssangieungkorean'] = 0x3180;
  16857. t['ssangkiyeokkorean'] = 0x3132;
  16858. t['ssangnieunkorean'] = 0x3165;
  16859. t['ssangpieupkorean'] = 0x3143;
  16860. t['ssangsioskorean'] = 0x3146;
  16861. t['ssangtikeutkorean'] = 0x3138;
  16862. t['ssuperior'] = 0xF6F2;
  16863. t['sterling'] = 0x00A3;
  16864. t['sterlingmonospace'] = 0xFFE1;
  16865. t['strokelongoverlaycmb'] = 0x0336;
  16866. t['strokeshortoverlaycmb'] = 0x0335;
  16867. t['subset'] = 0x2282;
  16868. t['subsetnotequal'] = 0x228A;
  16869. t['subsetorequal'] = 0x2286;
  16870. t['succeeds'] = 0x227B;
  16871. t['suchthat'] = 0x220B;
  16872. t['suhiragana'] = 0x3059;
  16873. t['sukatakana'] = 0x30B9;
  16874. t['sukatakanahalfwidth'] = 0xFF7D;
  16875. t['sukunarabic'] = 0x0652;
  16876. t['summation'] = 0x2211;
  16877. t['sun'] = 0x263C;
  16878. t['superset'] = 0x2283;
  16879. t['supersetnotequal'] = 0x228B;
  16880. t['supersetorequal'] = 0x2287;
  16881. t['svsquare'] = 0x33DC;
  16882. t['syouwaerasquare'] = 0x337C;
  16883. t['t'] = 0x0074;
  16884. t['tabengali'] = 0x09A4;
  16885. t['tackdown'] = 0x22A4;
  16886. t['tackleft'] = 0x22A3;
  16887. t['tadeva'] = 0x0924;
  16888. t['tagujarati'] = 0x0AA4;
  16889. t['tagurmukhi'] = 0x0A24;
  16890. t['taharabic'] = 0x0637;
  16891. t['tahfinalarabic'] = 0xFEC2;
  16892. t['tahinitialarabic'] = 0xFEC3;
  16893. t['tahiragana'] = 0x305F;
  16894. t['tahmedialarabic'] = 0xFEC4;
  16895. t['taisyouerasquare'] = 0x337D;
  16896. t['takatakana'] = 0x30BF;
  16897. t['takatakanahalfwidth'] = 0xFF80;
  16898. t['tatweelarabic'] = 0x0640;
  16899. t['tau'] = 0x03C4;
  16900. t['tav'] = 0x05EA;
  16901. t['tavdages'] = 0xFB4A;
  16902. t['tavdagesh'] = 0xFB4A;
  16903. t['tavdageshhebrew'] = 0xFB4A;
  16904. t['tavhebrew'] = 0x05EA;
  16905. t['tbar'] = 0x0167;
  16906. t['tbopomofo'] = 0x310A;
  16907. t['tcaron'] = 0x0165;
  16908. t['tccurl'] = 0x02A8;
  16909. t['tcedilla'] = 0x0163;
  16910. t['tcheharabic'] = 0x0686;
  16911. t['tchehfinalarabic'] = 0xFB7B;
  16912. t['tchehinitialarabic'] = 0xFB7C;
  16913. t['tchehmedialarabic'] = 0xFB7D;
  16914. t['tcircle'] = 0x24E3;
  16915. t['tcircumflexbelow'] = 0x1E71;
  16916. t['tcommaaccent'] = 0x0163;
  16917. t['tdieresis'] = 0x1E97;
  16918. t['tdotaccent'] = 0x1E6B;
  16919. t['tdotbelow'] = 0x1E6D;
  16920. t['tecyrillic'] = 0x0442;
  16921. t['tedescendercyrillic'] = 0x04AD;
  16922. t['teharabic'] = 0x062A;
  16923. t['tehfinalarabic'] = 0xFE96;
  16924. t['tehhahinitialarabic'] = 0xFCA2;
  16925. t['tehhahisolatedarabic'] = 0xFC0C;
  16926. t['tehinitialarabic'] = 0xFE97;
  16927. t['tehiragana'] = 0x3066;
  16928. t['tehjeeminitialarabic'] = 0xFCA1;
  16929. t['tehjeemisolatedarabic'] = 0xFC0B;
  16930. t['tehmarbutaarabic'] = 0x0629;
  16931. t['tehmarbutafinalarabic'] = 0xFE94;
  16932. t['tehmedialarabic'] = 0xFE98;
  16933. t['tehmeeminitialarabic'] = 0xFCA4;
  16934. t['tehmeemisolatedarabic'] = 0xFC0E;
  16935. t['tehnoonfinalarabic'] = 0xFC73;
  16936. t['tekatakana'] = 0x30C6;
  16937. t['tekatakanahalfwidth'] = 0xFF83;
  16938. t['telephone'] = 0x2121;
  16939. t['telephoneblack'] = 0x260E;
  16940. t['telishagedolahebrew'] = 0x05A0;
  16941. t['telishaqetanahebrew'] = 0x05A9;
  16942. t['tencircle'] = 0x2469;
  16943. t['tenideographicparen'] = 0x3229;
  16944. t['tenparen'] = 0x247D;
  16945. t['tenperiod'] = 0x2491;
  16946. t['tenroman'] = 0x2179;
  16947. t['tesh'] = 0x02A7;
  16948. t['tet'] = 0x05D8;
  16949. t['tetdagesh'] = 0xFB38;
  16950. t['tetdageshhebrew'] = 0xFB38;
  16951. t['tethebrew'] = 0x05D8;
  16952. t['tetsecyrillic'] = 0x04B5;
  16953. t['tevirhebrew'] = 0x059B;
  16954. t['tevirlefthebrew'] = 0x059B;
  16955. t['thabengali'] = 0x09A5;
  16956. t['thadeva'] = 0x0925;
  16957. t['thagujarati'] = 0x0AA5;
  16958. t['thagurmukhi'] = 0x0A25;
  16959. t['thalarabic'] = 0x0630;
  16960. t['thalfinalarabic'] = 0xFEAC;
  16961. t['thanthakhatlowleftthai'] = 0xF898;
  16962. t['thanthakhatlowrightthai'] = 0xF897;
  16963. t['thanthakhatthai'] = 0x0E4C;
  16964. t['thanthakhatupperleftthai'] = 0xF896;
  16965. t['theharabic'] = 0x062B;
  16966. t['thehfinalarabic'] = 0xFE9A;
  16967. t['thehinitialarabic'] = 0xFE9B;
  16968. t['thehmedialarabic'] = 0xFE9C;
  16969. t['thereexists'] = 0x2203;
  16970. t['therefore'] = 0x2234;
  16971. t['theta'] = 0x03B8;
  16972. t['theta1'] = 0x03D1;
  16973. t['thetasymbolgreek'] = 0x03D1;
  16974. t['thieuthacirclekorean'] = 0x3279;
  16975. t['thieuthaparenkorean'] = 0x3219;
  16976. t['thieuthcirclekorean'] = 0x326B;
  16977. t['thieuthkorean'] = 0x314C;
  16978. t['thieuthparenkorean'] = 0x320B;
  16979. t['thirteencircle'] = 0x246C;
  16980. t['thirteenparen'] = 0x2480;
  16981. t['thirteenperiod'] = 0x2494;
  16982. t['thonangmonthothai'] = 0x0E11;
  16983. t['thook'] = 0x01AD;
  16984. t['thophuthaothai'] = 0x0E12;
  16985. t['thorn'] = 0x00FE;
  16986. t['thothahanthai'] = 0x0E17;
  16987. t['thothanthai'] = 0x0E10;
  16988. t['thothongthai'] = 0x0E18;
  16989. t['thothungthai'] = 0x0E16;
  16990. t['thousandcyrillic'] = 0x0482;
  16991. t['thousandsseparatorarabic'] = 0x066C;
  16992. t['thousandsseparatorpersian'] = 0x066C;
  16993. t['three'] = 0x0033;
  16994. t['threearabic'] = 0x0663;
  16995. t['threebengali'] = 0x09E9;
  16996. t['threecircle'] = 0x2462;
  16997. t['threecircleinversesansserif'] = 0x278C;
  16998. t['threedeva'] = 0x0969;
  16999. t['threeeighths'] = 0x215C;
  17000. t['threegujarati'] = 0x0AE9;
  17001. t['threegurmukhi'] = 0x0A69;
  17002. t['threehackarabic'] = 0x0663;
  17003. t['threehangzhou'] = 0x3023;
  17004. t['threeideographicparen'] = 0x3222;
  17005. t['threeinferior'] = 0x2083;
  17006. t['threemonospace'] = 0xFF13;
  17007. t['threenumeratorbengali'] = 0x09F6;
  17008. t['threeoldstyle'] = 0xF733;
  17009. t['threeparen'] = 0x2476;
  17010. t['threeperiod'] = 0x248A;
  17011. t['threepersian'] = 0x06F3;
  17012. t['threequarters'] = 0x00BE;
  17013. t['threequartersemdash'] = 0xF6DE;
  17014. t['threeroman'] = 0x2172;
  17015. t['threesuperior'] = 0x00B3;
  17016. t['threethai'] = 0x0E53;
  17017. t['thzsquare'] = 0x3394;
  17018. t['tihiragana'] = 0x3061;
  17019. t['tikatakana'] = 0x30C1;
  17020. t['tikatakanahalfwidth'] = 0xFF81;
  17021. t['tikeutacirclekorean'] = 0x3270;
  17022. t['tikeutaparenkorean'] = 0x3210;
  17023. t['tikeutcirclekorean'] = 0x3262;
  17024. t['tikeutkorean'] = 0x3137;
  17025. t['tikeutparenkorean'] = 0x3202;
  17026. t['tilde'] = 0x02DC;
  17027. t['tildebelowcmb'] = 0x0330;
  17028. t['tildecmb'] = 0x0303;
  17029. t['tildecomb'] = 0x0303;
  17030. t['tildedoublecmb'] = 0x0360;
  17031. t['tildeoperator'] = 0x223C;
  17032. t['tildeoverlaycmb'] = 0x0334;
  17033. t['tildeverticalcmb'] = 0x033E;
  17034. t['timescircle'] = 0x2297;
  17035. t['tipehahebrew'] = 0x0596;
  17036. t['tipehalefthebrew'] = 0x0596;
  17037. t['tippigurmukhi'] = 0x0A70;
  17038. t['titlocyrilliccmb'] = 0x0483;
  17039. t['tiwnarmenian'] = 0x057F;
  17040. t['tlinebelow'] = 0x1E6F;
  17041. t['tmonospace'] = 0xFF54;
  17042. t['toarmenian'] = 0x0569;
  17043. t['tohiragana'] = 0x3068;
  17044. t['tokatakana'] = 0x30C8;
  17045. t['tokatakanahalfwidth'] = 0xFF84;
  17046. t['tonebarextrahighmod'] = 0x02E5;
  17047. t['tonebarextralowmod'] = 0x02E9;
  17048. t['tonebarhighmod'] = 0x02E6;
  17049. t['tonebarlowmod'] = 0x02E8;
  17050. t['tonebarmidmod'] = 0x02E7;
  17051. t['tonefive'] = 0x01BD;
  17052. t['tonesix'] = 0x0185;
  17053. t['tonetwo'] = 0x01A8;
  17054. t['tonos'] = 0x0384;
  17055. t['tonsquare'] = 0x3327;
  17056. t['topatakthai'] = 0x0E0F;
  17057. t['tortoiseshellbracketleft'] = 0x3014;
  17058. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  17059. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  17060. t['tortoiseshellbracketright'] = 0x3015;
  17061. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  17062. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  17063. t['totaothai'] = 0x0E15;
  17064. t['tpalatalhook'] = 0x01AB;
  17065. t['tparen'] = 0x24AF;
  17066. t['trademark'] = 0x2122;
  17067. t['trademarksans'] = 0xF8EA;
  17068. t['trademarkserif'] = 0xF6DB;
  17069. t['tretroflexhook'] = 0x0288;
  17070. t['triagdn'] = 0x25BC;
  17071. t['triaglf'] = 0x25C4;
  17072. t['triagrt'] = 0x25BA;
  17073. t['triagup'] = 0x25B2;
  17074. t['ts'] = 0x02A6;
  17075. t['tsadi'] = 0x05E6;
  17076. t['tsadidagesh'] = 0xFB46;
  17077. t['tsadidageshhebrew'] = 0xFB46;
  17078. t['tsadihebrew'] = 0x05E6;
  17079. t['tsecyrillic'] = 0x0446;
  17080. t['tsere'] = 0x05B5;
  17081. t['tsere12'] = 0x05B5;
  17082. t['tsere1e'] = 0x05B5;
  17083. t['tsere2b'] = 0x05B5;
  17084. t['tserehebrew'] = 0x05B5;
  17085. t['tserenarrowhebrew'] = 0x05B5;
  17086. t['tserequarterhebrew'] = 0x05B5;
  17087. t['tserewidehebrew'] = 0x05B5;
  17088. t['tshecyrillic'] = 0x045B;
  17089. t['tsuperior'] = 0xF6F3;
  17090. t['ttabengali'] = 0x099F;
  17091. t['ttadeva'] = 0x091F;
  17092. t['ttagujarati'] = 0x0A9F;
  17093. t['ttagurmukhi'] = 0x0A1F;
  17094. t['tteharabic'] = 0x0679;
  17095. t['ttehfinalarabic'] = 0xFB67;
  17096. t['ttehinitialarabic'] = 0xFB68;
  17097. t['ttehmedialarabic'] = 0xFB69;
  17098. t['tthabengali'] = 0x09A0;
  17099. t['tthadeva'] = 0x0920;
  17100. t['tthagujarati'] = 0x0AA0;
  17101. t['tthagurmukhi'] = 0x0A20;
  17102. t['tturned'] = 0x0287;
  17103. t['tuhiragana'] = 0x3064;
  17104. t['tukatakana'] = 0x30C4;
  17105. t['tukatakanahalfwidth'] = 0xFF82;
  17106. t['tusmallhiragana'] = 0x3063;
  17107. t['tusmallkatakana'] = 0x30C3;
  17108. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  17109. t['twelvecircle'] = 0x246B;
  17110. t['twelveparen'] = 0x247F;
  17111. t['twelveperiod'] = 0x2493;
  17112. t['twelveroman'] = 0x217B;
  17113. t['twentycircle'] = 0x2473;
  17114. t['twentyhangzhou'] = 0x5344;
  17115. t['twentyparen'] = 0x2487;
  17116. t['twentyperiod'] = 0x249B;
  17117. t['two'] = 0x0032;
  17118. t['twoarabic'] = 0x0662;
  17119. t['twobengali'] = 0x09E8;
  17120. t['twocircle'] = 0x2461;
  17121. t['twocircleinversesansserif'] = 0x278B;
  17122. t['twodeva'] = 0x0968;
  17123. t['twodotenleader'] = 0x2025;
  17124. t['twodotleader'] = 0x2025;
  17125. t['twodotleadervertical'] = 0xFE30;
  17126. t['twogujarati'] = 0x0AE8;
  17127. t['twogurmukhi'] = 0x0A68;
  17128. t['twohackarabic'] = 0x0662;
  17129. t['twohangzhou'] = 0x3022;
  17130. t['twoideographicparen'] = 0x3221;
  17131. t['twoinferior'] = 0x2082;
  17132. t['twomonospace'] = 0xFF12;
  17133. t['twonumeratorbengali'] = 0x09F5;
  17134. t['twooldstyle'] = 0xF732;
  17135. t['twoparen'] = 0x2475;
  17136. t['twoperiod'] = 0x2489;
  17137. t['twopersian'] = 0x06F2;
  17138. t['tworoman'] = 0x2171;
  17139. t['twostroke'] = 0x01BB;
  17140. t['twosuperior'] = 0x00B2;
  17141. t['twothai'] = 0x0E52;
  17142. t['twothirds'] = 0x2154;
  17143. t['u'] = 0x0075;
  17144. t['uacute'] = 0x00FA;
  17145. t['ubar'] = 0x0289;
  17146. t['ubengali'] = 0x0989;
  17147. t['ubopomofo'] = 0x3128;
  17148. t['ubreve'] = 0x016D;
  17149. t['ucaron'] = 0x01D4;
  17150. t['ucircle'] = 0x24E4;
  17151. t['ucircumflex'] = 0x00FB;
  17152. t['ucircumflexbelow'] = 0x1E77;
  17153. t['ucyrillic'] = 0x0443;
  17154. t['udattadeva'] = 0x0951;
  17155. t['udblacute'] = 0x0171;
  17156. t['udblgrave'] = 0x0215;
  17157. t['udeva'] = 0x0909;
  17158. t['udieresis'] = 0x00FC;
  17159. t['udieresisacute'] = 0x01D8;
  17160. t['udieresisbelow'] = 0x1E73;
  17161. t['udieresiscaron'] = 0x01DA;
  17162. t['udieresiscyrillic'] = 0x04F1;
  17163. t['udieresisgrave'] = 0x01DC;
  17164. t['udieresismacron'] = 0x01D6;
  17165. t['udotbelow'] = 0x1EE5;
  17166. t['ugrave'] = 0x00F9;
  17167. t['ugujarati'] = 0x0A89;
  17168. t['ugurmukhi'] = 0x0A09;
  17169. t['uhiragana'] = 0x3046;
  17170. t['uhookabove'] = 0x1EE7;
  17171. t['uhorn'] = 0x01B0;
  17172. t['uhornacute'] = 0x1EE9;
  17173. t['uhorndotbelow'] = 0x1EF1;
  17174. t['uhorngrave'] = 0x1EEB;
  17175. t['uhornhookabove'] = 0x1EED;
  17176. t['uhorntilde'] = 0x1EEF;
  17177. t['uhungarumlaut'] = 0x0171;
  17178. t['uhungarumlautcyrillic'] = 0x04F3;
  17179. t['uinvertedbreve'] = 0x0217;
  17180. t['ukatakana'] = 0x30A6;
  17181. t['ukatakanahalfwidth'] = 0xFF73;
  17182. t['ukcyrillic'] = 0x0479;
  17183. t['ukorean'] = 0x315C;
  17184. t['umacron'] = 0x016B;
  17185. t['umacroncyrillic'] = 0x04EF;
  17186. t['umacrondieresis'] = 0x1E7B;
  17187. t['umatragurmukhi'] = 0x0A41;
  17188. t['umonospace'] = 0xFF55;
  17189. t['underscore'] = 0x005F;
  17190. t['underscoredbl'] = 0x2017;
  17191. t['underscoremonospace'] = 0xFF3F;
  17192. t['underscorevertical'] = 0xFE33;
  17193. t['underscorewavy'] = 0xFE4F;
  17194. t['union'] = 0x222A;
  17195. t['universal'] = 0x2200;
  17196. t['uogonek'] = 0x0173;
  17197. t['uparen'] = 0x24B0;
  17198. t['upblock'] = 0x2580;
  17199. t['upperdothebrew'] = 0x05C4;
  17200. t['upsilon'] = 0x03C5;
  17201. t['upsilondieresis'] = 0x03CB;
  17202. t['upsilondieresistonos'] = 0x03B0;
  17203. t['upsilonlatin'] = 0x028A;
  17204. t['upsilontonos'] = 0x03CD;
  17205. t['uptackbelowcmb'] = 0x031D;
  17206. t['uptackmod'] = 0x02D4;
  17207. t['uragurmukhi'] = 0x0A73;
  17208. t['uring'] = 0x016F;
  17209. t['ushortcyrillic'] = 0x045E;
  17210. t['usmallhiragana'] = 0x3045;
  17211. t['usmallkatakana'] = 0x30A5;
  17212. t['usmallkatakanahalfwidth'] = 0xFF69;
  17213. t['ustraightcyrillic'] = 0x04AF;
  17214. t['ustraightstrokecyrillic'] = 0x04B1;
  17215. t['utilde'] = 0x0169;
  17216. t['utildeacute'] = 0x1E79;
  17217. t['utildebelow'] = 0x1E75;
  17218. t['uubengali'] = 0x098A;
  17219. t['uudeva'] = 0x090A;
  17220. t['uugujarati'] = 0x0A8A;
  17221. t['uugurmukhi'] = 0x0A0A;
  17222. t['uumatragurmukhi'] = 0x0A42;
  17223. t['uuvowelsignbengali'] = 0x09C2;
  17224. t['uuvowelsigndeva'] = 0x0942;
  17225. t['uuvowelsigngujarati'] = 0x0AC2;
  17226. t['uvowelsignbengali'] = 0x09C1;
  17227. t['uvowelsigndeva'] = 0x0941;
  17228. t['uvowelsigngujarati'] = 0x0AC1;
  17229. t['v'] = 0x0076;
  17230. t['vadeva'] = 0x0935;
  17231. t['vagujarati'] = 0x0AB5;
  17232. t['vagurmukhi'] = 0x0A35;
  17233. t['vakatakana'] = 0x30F7;
  17234. t['vav'] = 0x05D5;
  17235. t['vavdagesh'] = 0xFB35;
  17236. t['vavdagesh65'] = 0xFB35;
  17237. t['vavdageshhebrew'] = 0xFB35;
  17238. t['vavhebrew'] = 0x05D5;
  17239. t['vavholam'] = 0xFB4B;
  17240. t['vavholamhebrew'] = 0xFB4B;
  17241. t['vavvavhebrew'] = 0x05F0;
  17242. t['vavyodhebrew'] = 0x05F1;
  17243. t['vcircle'] = 0x24E5;
  17244. t['vdotbelow'] = 0x1E7F;
  17245. t['vecyrillic'] = 0x0432;
  17246. t['veharabic'] = 0x06A4;
  17247. t['vehfinalarabic'] = 0xFB6B;
  17248. t['vehinitialarabic'] = 0xFB6C;
  17249. t['vehmedialarabic'] = 0xFB6D;
  17250. t['vekatakana'] = 0x30F9;
  17251. t['venus'] = 0x2640;
  17252. t['verticalbar'] = 0x007C;
  17253. t['verticallineabovecmb'] = 0x030D;
  17254. t['verticallinebelowcmb'] = 0x0329;
  17255. t['verticallinelowmod'] = 0x02CC;
  17256. t['verticallinemod'] = 0x02C8;
  17257. t['vewarmenian'] = 0x057E;
  17258. t['vhook'] = 0x028B;
  17259. t['vikatakana'] = 0x30F8;
  17260. t['viramabengali'] = 0x09CD;
  17261. t['viramadeva'] = 0x094D;
  17262. t['viramagujarati'] = 0x0ACD;
  17263. t['visargabengali'] = 0x0983;
  17264. t['visargadeva'] = 0x0903;
  17265. t['visargagujarati'] = 0x0A83;
  17266. t['vmonospace'] = 0xFF56;
  17267. t['voarmenian'] = 0x0578;
  17268. t['voicediterationhiragana'] = 0x309E;
  17269. t['voicediterationkatakana'] = 0x30FE;
  17270. t['voicedmarkkana'] = 0x309B;
  17271. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  17272. t['vokatakana'] = 0x30FA;
  17273. t['vparen'] = 0x24B1;
  17274. t['vtilde'] = 0x1E7D;
  17275. t['vturned'] = 0x028C;
  17276. t['vuhiragana'] = 0x3094;
  17277. t['vukatakana'] = 0x30F4;
  17278. t['w'] = 0x0077;
  17279. t['wacute'] = 0x1E83;
  17280. t['waekorean'] = 0x3159;
  17281. t['wahiragana'] = 0x308F;
  17282. t['wakatakana'] = 0x30EF;
  17283. t['wakatakanahalfwidth'] = 0xFF9C;
  17284. t['wakorean'] = 0x3158;
  17285. t['wasmallhiragana'] = 0x308E;
  17286. t['wasmallkatakana'] = 0x30EE;
  17287. t['wattosquare'] = 0x3357;
  17288. t['wavedash'] = 0x301C;
  17289. t['wavyunderscorevertical'] = 0xFE34;
  17290. t['wawarabic'] = 0x0648;
  17291. t['wawfinalarabic'] = 0xFEEE;
  17292. t['wawhamzaabovearabic'] = 0x0624;
  17293. t['wawhamzaabovefinalarabic'] = 0xFE86;
  17294. t['wbsquare'] = 0x33DD;
  17295. t['wcircle'] = 0x24E6;
  17296. t['wcircumflex'] = 0x0175;
  17297. t['wdieresis'] = 0x1E85;
  17298. t['wdotaccent'] = 0x1E87;
  17299. t['wdotbelow'] = 0x1E89;
  17300. t['wehiragana'] = 0x3091;
  17301. t['weierstrass'] = 0x2118;
  17302. t['wekatakana'] = 0x30F1;
  17303. t['wekorean'] = 0x315E;
  17304. t['weokorean'] = 0x315D;
  17305. t['wgrave'] = 0x1E81;
  17306. t['whitebullet'] = 0x25E6;
  17307. t['whitecircle'] = 0x25CB;
  17308. t['whitecircleinverse'] = 0x25D9;
  17309. t['whitecornerbracketleft'] = 0x300E;
  17310. t['whitecornerbracketleftvertical'] = 0xFE43;
  17311. t['whitecornerbracketright'] = 0x300F;
  17312. t['whitecornerbracketrightvertical'] = 0xFE44;
  17313. t['whitediamond'] = 0x25C7;
  17314. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  17315. t['whitedownpointingsmalltriangle'] = 0x25BF;
  17316. t['whitedownpointingtriangle'] = 0x25BD;
  17317. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  17318. t['whiteleftpointingtriangle'] = 0x25C1;
  17319. t['whitelenticularbracketleft'] = 0x3016;
  17320. t['whitelenticularbracketright'] = 0x3017;
  17321. t['whiterightpointingsmalltriangle'] = 0x25B9;
  17322. t['whiterightpointingtriangle'] = 0x25B7;
  17323. t['whitesmallsquare'] = 0x25AB;
  17324. t['whitesmilingface'] = 0x263A;
  17325. t['whitesquare'] = 0x25A1;
  17326. t['whitestar'] = 0x2606;
  17327. t['whitetelephone'] = 0x260F;
  17328. t['whitetortoiseshellbracketleft'] = 0x3018;
  17329. t['whitetortoiseshellbracketright'] = 0x3019;
  17330. t['whiteuppointingsmalltriangle'] = 0x25B5;
  17331. t['whiteuppointingtriangle'] = 0x25B3;
  17332. t['wihiragana'] = 0x3090;
  17333. t['wikatakana'] = 0x30F0;
  17334. t['wikorean'] = 0x315F;
  17335. t['wmonospace'] = 0xFF57;
  17336. t['wohiragana'] = 0x3092;
  17337. t['wokatakana'] = 0x30F2;
  17338. t['wokatakanahalfwidth'] = 0xFF66;
  17339. t['won'] = 0x20A9;
  17340. t['wonmonospace'] = 0xFFE6;
  17341. t['wowaenthai'] = 0x0E27;
  17342. t['wparen'] = 0x24B2;
  17343. t['wring'] = 0x1E98;
  17344. t['wsuperior'] = 0x02B7;
  17345. t['wturned'] = 0x028D;
  17346. t['wynn'] = 0x01BF;
  17347. t['x'] = 0x0078;
  17348. t['xabovecmb'] = 0x033D;
  17349. t['xbopomofo'] = 0x3112;
  17350. t['xcircle'] = 0x24E7;
  17351. t['xdieresis'] = 0x1E8D;
  17352. t['xdotaccent'] = 0x1E8B;
  17353. t['xeharmenian'] = 0x056D;
  17354. t['xi'] = 0x03BE;
  17355. t['xmonospace'] = 0xFF58;
  17356. t['xparen'] = 0x24B3;
  17357. t['xsuperior'] = 0x02E3;
  17358. t['y'] = 0x0079;
  17359. t['yaadosquare'] = 0x334E;
  17360. t['yabengali'] = 0x09AF;
  17361. t['yacute'] = 0x00FD;
  17362. t['yadeva'] = 0x092F;
  17363. t['yaekorean'] = 0x3152;
  17364. t['yagujarati'] = 0x0AAF;
  17365. t['yagurmukhi'] = 0x0A2F;
  17366. t['yahiragana'] = 0x3084;
  17367. t['yakatakana'] = 0x30E4;
  17368. t['yakatakanahalfwidth'] = 0xFF94;
  17369. t['yakorean'] = 0x3151;
  17370. t['yamakkanthai'] = 0x0E4E;
  17371. t['yasmallhiragana'] = 0x3083;
  17372. t['yasmallkatakana'] = 0x30E3;
  17373. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  17374. t['yatcyrillic'] = 0x0463;
  17375. t['ycircle'] = 0x24E8;
  17376. t['ycircumflex'] = 0x0177;
  17377. t['ydieresis'] = 0x00FF;
  17378. t['ydotaccent'] = 0x1E8F;
  17379. t['ydotbelow'] = 0x1EF5;
  17380. t['yeharabic'] = 0x064A;
  17381. t['yehbarreearabic'] = 0x06D2;
  17382. t['yehbarreefinalarabic'] = 0xFBAF;
  17383. t['yehfinalarabic'] = 0xFEF2;
  17384. t['yehhamzaabovearabic'] = 0x0626;
  17385. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  17386. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  17387. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  17388. t['yehinitialarabic'] = 0xFEF3;
  17389. t['yehmedialarabic'] = 0xFEF4;
  17390. t['yehmeeminitialarabic'] = 0xFCDD;
  17391. t['yehmeemisolatedarabic'] = 0xFC58;
  17392. t['yehnoonfinalarabic'] = 0xFC94;
  17393. t['yehthreedotsbelowarabic'] = 0x06D1;
  17394. t['yekorean'] = 0x3156;
  17395. t['yen'] = 0x00A5;
  17396. t['yenmonospace'] = 0xFFE5;
  17397. t['yeokorean'] = 0x3155;
  17398. t['yeorinhieuhkorean'] = 0x3186;
  17399. t['yerahbenyomohebrew'] = 0x05AA;
  17400. t['yerahbenyomolefthebrew'] = 0x05AA;
  17401. t['yericyrillic'] = 0x044B;
  17402. t['yerudieresiscyrillic'] = 0x04F9;
  17403. t['yesieungkorean'] = 0x3181;
  17404. t['yesieungpansioskorean'] = 0x3183;
  17405. t['yesieungsioskorean'] = 0x3182;
  17406. t['yetivhebrew'] = 0x059A;
  17407. t['ygrave'] = 0x1EF3;
  17408. t['yhook'] = 0x01B4;
  17409. t['yhookabove'] = 0x1EF7;
  17410. t['yiarmenian'] = 0x0575;
  17411. t['yicyrillic'] = 0x0457;
  17412. t['yikorean'] = 0x3162;
  17413. t['yinyang'] = 0x262F;
  17414. t['yiwnarmenian'] = 0x0582;
  17415. t['ymonospace'] = 0xFF59;
  17416. t['yod'] = 0x05D9;
  17417. t['yoddagesh'] = 0xFB39;
  17418. t['yoddageshhebrew'] = 0xFB39;
  17419. t['yodhebrew'] = 0x05D9;
  17420. t['yodyodhebrew'] = 0x05F2;
  17421. t['yodyodpatahhebrew'] = 0xFB1F;
  17422. t['yohiragana'] = 0x3088;
  17423. t['yoikorean'] = 0x3189;
  17424. t['yokatakana'] = 0x30E8;
  17425. t['yokatakanahalfwidth'] = 0xFF96;
  17426. t['yokorean'] = 0x315B;
  17427. t['yosmallhiragana'] = 0x3087;
  17428. t['yosmallkatakana'] = 0x30E7;
  17429. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  17430. t['yotgreek'] = 0x03F3;
  17431. t['yoyaekorean'] = 0x3188;
  17432. t['yoyakorean'] = 0x3187;
  17433. t['yoyakthai'] = 0x0E22;
  17434. t['yoyingthai'] = 0x0E0D;
  17435. t['yparen'] = 0x24B4;
  17436. t['ypogegrammeni'] = 0x037A;
  17437. t['ypogegrammenigreekcmb'] = 0x0345;
  17438. t['yr'] = 0x01A6;
  17439. t['yring'] = 0x1E99;
  17440. t['ysuperior'] = 0x02B8;
  17441. t['ytilde'] = 0x1EF9;
  17442. t['yturned'] = 0x028E;
  17443. t['yuhiragana'] = 0x3086;
  17444. t['yuikorean'] = 0x318C;
  17445. t['yukatakana'] = 0x30E6;
  17446. t['yukatakanahalfwidth'] = 0xFF95;
  17447. t['yukorean'] = 0x3160;
  17448. t['yusbigcyrillic'] = 0x046B;
  17449. t['yusbigiotifiedcyrillic'] = 0x046D;
  17450. t['yuslittlecyrillic'] = 0x0467;
  17451. t['yuslittleiotifiedcyrillic'] = 0x0469;
  17452. t['yusmallhiragana'] = 0x3085;
  17453. t['yusmallkatakana'] = 0x30E5;
  17454. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  17455. t['yuyekorean'] = 0x318B;
  17456. t['yuyeokorean'] = 0x318A;
  17457. t['yyabengali'] = 0x09DF;
  17458. t['yyadeva'] = 0x095F;
  17459. t['z'] = 0x007A;
  17460. t['zaarmenian'] = 0x0566;
  17461. t['zacute'] = 0x017A;
  17462. t['zadeva'] = 0x095B;
  17463. t['zagurmukhi'] = 0x0A5B;
  17464. t['zaharabic'] = 0x0638;
  17465. t['zahfinalarabic'] = 0xFEC6;
  17466. t['zahinitialarabic'] = 0xFEC7;
  17467. t['zahiragana'] = 0x3056;
  17468. t['zahmedialarabic'] = 0xFEC8;
  17469. t['zainarabic'] = 0x0632;
  17470. t['zainfinalarabic'] = 0xFEB0;
  17471. t['zakatakana'] = 0x30B6;
  17472. t['zaqefgadolhebrew'] = 0x0595;
  17473. t['zaqefqatanhebrew'] = 0x0594;
  17474. t['zarqahebrew'] = 0x0598;
  17475. t['zayin'] = 0x05D6;
  17476. t['zayindagesh'] = 0xFB36;
  17477. t['zayindageshhebrew'] = 0xFB36;
  17478. t['zayinhebrew'] = 0x05D6;
  17479. t['zbopomofo'] = 0x3117;
  17480. t['zcaron'] = 0x017E;
  17481. t['zcircle'] = 0x24E9;
  17482. t['zcircumflex'] = 0x1E91;
  17483. t['zcurl'] = 0x0291;
  17484. t['zdot'] = 0x017C;
  17485. t['zdotaccent'] = 0x017C;
  17486. t['zdotbelow'] = 0x1E93;
  17487. t['zecyrillic'] = 0x0437;
  17488. t['zedescendercyrillic'] = 0x0499;
  17489. t['zedieresiscyrillic'] = 0x04DF;
  17490. t['zehiragana'] = 0x305C;
  17491. t['zekatakana'] = 0x30BC;
  17492. t['zero'] = 0x0030;
  17493. t['zeroarabic'] = 0x0660;
  17494. t['zerobengali'] = 0x09E6;
  17495. t['zerodeva'] = 0x0966;
  17496. t['zerogujarati'] = 0x0AE6;
  17497. t['zerogurmukhi'] = 0x0A66;
  17498. t['zerohackarabic'] = 0x0660;
  17499. t['zeroinferior'] = 0x2080;
  17500. t['zeromonospace'] = 0xFF10;
  17501. t['zerooldstyle'] = 0xF730;
  17502. t['zeropersian'] = 0x06F0;
  17503. t['zerosuperior'] = 0x2070;
  17504. t['zerothai'] = 0x0E50;
  17505. t['zerowidthjoiner'] = 0xFEFF;
  17506. t['zerowidthnonjoiner'] = 0x200C;
  17507. t['zerowidthspace'] = 0x200B;
  17508. t['zeta'] = 0x03B6;
  17509. t['zhbopomofo'] = 0x3113;
  17510. t['zhearmenian'] = 0x056A;
  17511. t['zhebrevecyrillic'] = 0x04C2;
  17512. t['zhecyrillic'] = 0x0436;
  17513. t['zhedescendercyrillic'] = 0x0497;
  17514. t['zhedieresiscyrillic'] = 0x04DD;
  17515. t['zihiragana'] = 0x3058;
  17516. t['zikatakana'] = 0x30B8;
  17517. t['zinorhebrew'] = 0x05AE;
  17518. t['zlinebelow'] = 0x1E95;
  17519. t['zmonospace'] = 0xFF5A;
  17520. t['zohiragana'] = 0x305E;
  17521. t['zokatakana'] = 0x30BE;
  17522. t['zparen'] = 0x24B5;
  17523. t['zretroflexhook'] = 0x0290;
  17524. t['zstroke'] = 0x01B6;
  17525. t['zuhiragana'] = 0x305A;
  17526. t['zukatakana'] = 0x30BA;
  17527. t['.notdef'] = 0x0000;
  17528. t['angbracketleftbig'] = 0x2329;
  17529. t['angbracketleftBig'] = 0x2329;
  17530. t['angbracketleftbigg'] = 0x2329;
  17531. t['angbracketleftBigg'] = 0x2329;
  17532. t['angbracketrightBig'] = 0x232A;
  17533. t['angbracketrightbig'] = 0x232A;
  17534. t['angbracketrightBigg'] = 0x232A;
  17535. t['angbracketrightbigg'] = 0x232A;
  17536. t['arrowhookleft'] = 0x21AA;
  17537. t['arrowhookright'] = 0x21A9;
  17538. t['arrowlefttophalf'] = 0x21BC;
  17539. t['arrowleftbothalf'] = 0x21BD;
  17540. t['arrownortheast'] = 0x2197;
  17541. t['arrownorthwest'] = 0x2196;
  17542. t['arrowrighttophalf'] = 0x21C0;
  17543. t['arrowrightbothalf'] = 0x21C1;
  17544. t['arrowsoutheast'] = 0x2198;
  17545. t['arrowsouthwest'] = 0x2199;
  17546. t['backslashbig'] = 0x2216;
  17547. t['backslashBig'] = 0x2216;
  17548. t['backslashBigg'] = 0x2216;
  17549. t['backslashbigg'] = 0x2216;
  17550. t['bardbl'] = 0x2016;
  17551. t['bracehtipdownleft'] = 0xFE37;
  17552. t['bracehtipdownright'] = 0xFE37;
  17553. t['bracehtipupleft'] = 0xFE38;
  17554. t['bracehtipupright'] = 0xFE38;
  17555. t['braceleftBig'] = 0x007B;
  17556. t['braceleftbig'] = 0x007B;
  17557. t['braceleftbigg'] = 0x007B;
  17558. t['braceleftBigg'] = 0x007B;
  17559. t['bracerightBig'] = 0x007D;
  17560. t['bracerightbig'] = 0x007D;
  17561. t['bracerightbigg'] = 0x007D;
  17562. t['bracerightBigg'] = 0x007D;
  17563. t['bracketleftbig'] = 0x005B;
  17564. t['bracketleftBig'] = 0x005B;
  17565. t['bracketleftbigg'] = 0x005B;
  17566. t['bracketleftBigg'] = 0x005B;
  17567. t['bracketrightBig'] = 0x005D;
  17568. t['bracketrightbig'] = 0x005D;
  17569. t['bracketrightbigg'] = 0x005D;
  17570. t['bracketrightBigg'] = 0x005D;
  17571. t['ceilingleftbig'] = 0x2308;
  17572. t['ceilingleftBig'] = 0x2308;
  17573. t['ceilingleftBigg'] = 0x2308;
  17574. t['ceilingleftbigg'] = 0x2308;
  17575. t['ceilingrightbig'] = 0x2309;
  17576. t['ceilingrightBig'] = 0x2309;
  17577. t['ceilingrightbigg'] = 0x2309;
  17578. t['ceilingrightBigg'] = 0x2309;
  17579. t['circledotdisplay'] = 0x2299;
  17580. t['circledottext'] = 0x2299;
  17581. t['circlemultiplydisplay'] = 0x2297;
  17582. t['circlemultiplytext'] = 0x2297;
  17583. t['circleplusdisplay'] = 0x2295;
  17584. t['circleplustext'] = 0x2295;
  17585. t['contintegraldisplay'] = 0x222E;
  17586. t['contintegraltext'] = 0x222E;
  17587. t['coproductdisplay'] = 0x2210;
  17588. t['coproducttext'] = 0x2210;
  17589. t['floorleftBig'] = 0x230A;
  17590. t['floorleftbig'] = 0x230A;
  17591. t['floorleftbigg'] = 0x230A;
  17592. t['floorleftBigg'] = 0x230A;
  17593. t['floorrightbig'] = 0x230B;
  17594. t['floorrightBig'] = 0x230B;
  17595. t['floorrightBigg'] = 0x230B;
  17596. t['floorrightbigg'] = 0x230B;
  17597. t['hatwide'] = 0x0302;
  17598. t['hatwider'] = 0x0302;
  17599. t['hatwidest'] = 0x0302;
  17600. t['intercal'] = 0x1D40;
  17601. t['integraldisplay'] = 0x222B;
  17602. t['integraltext'] = 0x222B;
  17603. t['intersectiondisplay'] = 0x22C2;
  17604. t['intersectiontext'] = 0x22C2;
  17605. t['logicalanddisplay'] = 0x2227;
  17606. t['logicalandtext'] = 0x2227;
  17607. t['logicalordisplay'] = 0x2228;
  17608. t['logicalortext'] = 0x2228;
  17609. t['parenleftBig'] = 0x0028;
  17610. t['parenleftbig'] = 0x0028;
  17611. t['parenleftBigg'] = 0x0028;
  17612. t['parenleftbigg'] = 0x0028;
  17613. t['parenrightBig'] = 0x0029;
  17614. t['parenrightbig'] = 0x0029;
  17615. t['parenrightBigg'] = 0x0029;
  17616. t['parenrightbigg'] = 0x0029;
  17617. t['prime'] = 0x2032;
  17618. t['productdisplay'] = 0x220F;
  17619. t['producttext'] = 0x220F;
  17620. t['radicalbig'] = 0x221A;
  17621. t['radicalBig'] = 0x221A;
  17622. t['radicalBigg'] = 0x221A;
  17623. t['radicalbigg'] = 0x221A;
  17624. t['radicalbt'] = 0x221A;
  17625. t['radicaltp'] = 0x221A;
  17626. t['radicalvertex'] = 0x221A;
  17627. t['slashbig'] = 0x002F;
  17628. t['slashBig'] = 0x002F;
  17629. t['slashBigg'] = 0x002F;
  17630. t['slashbigg'] = 0x002F;
  17631. t['summationdisplay'] = 0x2211;
  17632. t['summationtext'] = 0x2211;
  17633. t['tildewide'] = 0x02DC;
  17634. t['tildewider'] = 0x02DC;
  17635. t['tildewidest'] = 0x02DC;
  17636. t['uniondisplay'] = 0x22C3;
  17637. t['unionmultidisplay'] = 0x228E;
  17638. t['unionmultitext'] = 0x228E;
  17639. t['unionsqdisplay'] = 0x2294;
  17640. t['unionsqtext'] = 0x2294;
  17641. t['uniontext'] = 0x22C3;
  17642. t['vextenddouble'] = 0x2225;
  17643. t['vextendsingle'] = 0x2223;
  17644. });
  17645. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  17646. t['space'] = 0x0020;
  17647. t['a1'] = 0x2701;
  17648. t['a2'] = 0x2702;
  17649. t['a202'] = 0x2703;
  17650. t['a3'] = 0x2704;
  17651. t['a4'] = 0x260E;
  17652. t['a5'] = 0x2706;
  17653. t['a119'] = 0x2707;
  17654. t['a118'] = 0x2708;
  17655. t['a117'] = 0x2709;
  17656. t['a11'] = 0x261B;
  17657. t['a12'] = 0x261E;
  17658. t['a13'] = 0x270C;
  17659. t['a14'] = 0x270D;
  17660. t['a15'] = 0x270E;
  17661. t['a16'] = 0x270F;
  17662. t['a105'] = 0x2710;
  17663. t['a17'] = 0x2711;
  17664. t['a18'] = 0x2712;
  17665. t['a19'] = 0x2713;
  17666. t['a20'] = 0x2714;
  17667. t['a21'] = 0x2715;
  17668. t['a22'] = 0x2716;
  17669. t['a23'] = 0x2717;
  17670. t['a24'] = 0x2718;
  17671. t['a25'] = 0x2719;
  17672. t['a26'] = 0x271A;
  17673. t['a27'] = 0x271B;
  17674. t['a28'] = 0x271C;
  17675. t['a6'] = 0x271D;
  17676. t['a7'] = 0x271E;
  17677. t['a8'] = 0x271F;
  17678. t['a9'] = 0x2720;
  17679. t['a10'] = 0x2721;
  17680. t['a29'] = 0x2722;
  17681. t['a30'] = 0x2723;
  17682. t['a31'] = 0x2724;
  17683. t['a32'] = 0x2725;
  17684. t['a33'] = 0x2726;
  17685. t['a34'] = 0x2727;
  17686. t['a35'] = 0x2605;
  17687. t['a36'] = 0x2729;
  17688. t['a37'] = 0x272A;
  17689. t['a38'] = 0x272B;
  17690. t['a39'] = 0x272C;
  17691. t['a40'] = 0x272D;
  17692. t['a41'] = 0x272E;
  17693. t['a42'] = 0x272F;
  17694. t['a43'] = 0x2730;
  17695. t['a44'] = 0x2731;
  17696. t['a45'] = 0x2732;
  17697. t['a46'] = 0x2733;
  17698. t['a47'] = 0x2734;
  17699. t['a48'] = 0x2735;
  17700. t['a49'] = 0x2736;
  17701. t['a50'] = 0x2737;
  17702. t['a51'] = 0x2738;
  17703. t['a52'] = 0x2739;
  17704. t['a53'] = 0x273A;
  17705. t['a54'] = 0x273B;
  17706. t['a55'] = 0x273C;
  17707. t['a56'] = 0x273D;
  17708. t['a57'] = 0x273E;
  17709. t['a58'] = 0x273F;
  17710. t['a59'] = 0x2740;
  17711. t['a60'] = 0x2741;
  17712. t['a61'] = 0x2742;
  17713. t['a62'] = 0x2743;
  17714. t['a63'] = 0x2744;
  17715. t['a64'] = 0x2745;
  17716. t['a65'] = 0x2746;
  17717. t['a66'] = 0x2747;
  17718. t['a67'] = 0x2748;
  17719. t['a68'] = 0x2749;
  17720. t['a69'] = 0x274A;
  17721. t['a70'] = 0x274B;
  17722. t['a71'] = 0x25CF;
  17723. t['a72'] = 0x274D;
  17724. t['a73'] = 0x25A0;
  17725. t['a74'] = 0x274F;
  17726. t['a203'] = 0x2750;
  17727. t['a75'] = 0x2751;
  17728. t['a204'] = 0x2752;
  17729. t['a76'] = 0x25B2;
  17730. t['a77'] = 0x25BC;
  17731. t['a78'] = 0x25C6;
  17732. t['a79'] = 0x2756;
  17733. t['a81'] = 0x25D7;
  17734. t['a82'] = 0x2758;
  17735. t['a83'] = 0x2759;
  17736. t['a84'] = 0x275A;
  17737. t['a97'] = 0x275B;
  17738. t['a98'] = 0x275C;
  17739. t['a99'] = 0x275D;
  17740. t['a100'] = 0x275E;
  17741. t['a101'] = 0x2761;
  17742. t['a102'] = 0x2762;
  17743. t['a103'] = 0x2763;
  17744. t['a104'] = 0x2764;
  17745. t['a106'] = 0x2765;
  17746. t['a107'] = 0x2766;
  17747. t['a108'] = 0x2767;
  17748. t['a112'] = 0x2663;
  17749. t['a111'] = 0x2666;
  17750. t['a110'] = 0x2665;
  17751. t['a109'] = 0x2660;
  17752. t['a120'] = 0x2460;
  17753. t['a121'] = 0x2461;
  17754. t['a122'] = 0x2462;
  17755. t['a123'] = 0x2463;
  17756. t['a124'] = 0x2464;
  17757. t['a125'] = 0x2465;
  17758. t['a126'] = 0x2466;
  17759. t['a127'] = 0x2467;
  17760. t['a128'] = 0x2468;
  17761. t['a129'] = 0x2469;
  17762. t['a130'] = 0x2776;
  17763. t['a131'] = 0x2777;
  17764. t['a132'] = 0x2778;
  17765. t['a133'] = 0x2779;
  17766. t['a134'] = 0x277A;
  17767. t['a135'] = 0x277B;
  17768. t['a136'] = 0x277C;
  17769. t['a137'] = 0x277D;
  17770. t['a138'] = 0x277E;
  17771. t['a139'] = 0x277F;
  17772. t['a140'] = 0x2780;
  17773. t['a141'] = 0x2781;
  17774. t['a142'] = 0x2782;
  17775. t['a143'] = 0x2783;
  17776. t['a144'] = 0x2784;
  17777. t['a145'] = 0x2785;
  17778. t['a146'] = 0x2786;
  17779. t['a147'] = 0x2787;
  17780. t['a148'] = 0x2788;
  17781. t['a149'] = 0x2789;
  17782. t['a150'] = 0x278A;
  17783. t['a151'] = 0x278B;
  17784. t['a152'] = 0x278C;
  17785. t['a153'] = 0x278D;
  17786. t['a154'] = 0x278E;
  17787. t['a155'] = 0x278F;
  17788. t['a156'] = 0x2790;
  17789. t['a157'] = 0x2791;
  17790. t['a158'] = 0x2792;
  17791. t['a159'] = 0x2793;
  17792. t['a160'] = 0x2794;
  17793. t['a161'] = 0x2192;
  17794. t['a163'] = 0x2194;
  17795. t['a164'] = 0x2195;
  17796. t['a196'] = 0x2798;
  17797. t['a165'] = 0x2799;
  17798. t['a192'] = 0x279A;
  17799. t['a166'] = 0x279B;
  17800. t['a167'] = 0x279C;
  17801. t['a168'] = 0x279D;
  17802. t['a169'] = 0x279E;
  17803. t['a170'] = 0x279F;
  17804. t['a171'] = 0x27A0;
  17805. t['a172'] = 0x27A1;
  17806. t['a173'] = 0x27A2;
  17807. t['a162'] = 0x27A3;
  17808. t['a174'] = 0x27A4;
  17809. t['a175'] = 0x27A5;
  17810. t['a176'] = 0x27A6;
  17811. t['a177'] = 0x27A7;
  17812. t['a178'] = 0x27A8;
  17813. t['a179'] = 0x27A9;
  17814. t['a193'] = 0x27AA;
  17815. t['a180'] = 0x27AB;
  17816. t['a199'] = 0x27AC;
  17817. t['a181'] = 0x27AD;
  17818. t['a200'] = 0x27AE;
  17819. t['a182'] = 0x27AF;
  17820. t['a201'] = 0x27B1;
  17821. t['a183'] = 0x27B2;
  17822. t['a184'] = 0x27B3;
  17823. t['a197'] = 0x27B4;
  17824. t['a185'] = 0x27B5;
  17825. t['a194'] = 0x27B6;
  17826. t['a198'] = 0x27B7;
  17827. t['a186'] = 0x27B8;
  17828. t['a195'] = 0x27B9;
  17829. t['a187'] = 0x27BA;
  17830. t['a188'] = 0x27BB;
  17831. t['a189'] = 0x27BC;
  17832. t['a190'] = 0x27BD;
  17833. t['a191'] = 0x27BE;
  17834. t['a89'] = 0x2768;
  17835. t['a90'] = 0x2769;
  17836. t['a93'] = 0x276A;
  17837. t['a94'] = 0x276B;
  17838. t['a91'] = 0x276C;
  17839. t['a92'] = 0x276D;
  17840. t['a205'] = 0x276E;
  17841. t['a85'] = 0x276F;
  17842. t['a206'] = 0x2770;
  17843. t['a86'] = 0x2771;
  17844. t['a87'] = 0x2772;
  17845. t['a88'] = 0x2773;
  17846. t['a95'] = 0x2774;
  17847. t['a96'] = 0x2775;
  17848. t['.notdef'] = 0x0000;
  17849. });
  17850. exports.getGlyphsUnicode = getGlyphsUnicode;
  17851. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  17852. /***/ }),
  17853. /* 8 */
  17854. /***/ (function(module, exports, __w_pdfjs_require__) {
  17855. "use strict";
  17856. var sharedUtil = __w_pdfjs_require__(0);
  17857. var corePrimitives = __w_pdfjs_require__(1);
  17858. var corePdfManager = __w_pdfjs_require__(33);
  17859. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  17860. var InvalidPDFException = sharedUtil.InvalidPDFException;
  17861. var MessageHandler = sharedUtil.MessageHandler;
  17862. var MissingPDFException = sharedUtil.MissingPDFException;
  17863. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  17864. var PasswordException = sharedUtil.PasswordException;
  17865. var UnknownErrorException = sharedUtil.UnknownErrorException;
  17866. var XRefParseException = sharedUtil.XRefParseException;
  17867. var arrayByteLength = sharedUtil.arrayByteLength;
  17868. var arraysToBytes = sharedUtil.arraysToBytes;
  17869. var assert = sharedUtil.assert;
  17870. var createPromiseCapability = sharedUtil.createPromiseCapability;
  17871. var info = sharedUtil.info;
  17872. var warn = sharedUtil.warn;
  17873. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  17874. var isNodeJS = sharedUtil.isNodeJS;
  17875. var Ref = corePrimitives.Ref;
  17876. var LocalPdfManager = corePdfManager.LocalPdfManager;
  17877. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  17878. var WorkerTask = function WorkerTaskClosure() {
  17879. function WorkerTask(name) {
  17880. this.name = name;
  17881. this.terminated = false;
  17882. this._capability = createPromiseCapability();
  17883. }
  17884. WorkerTask.prototype = {
  17885. get finished() {
  17886. return this._capability.promise;
  17887. },
  17888. finish: function () {
  17889. this._capability.resolve();
  17890. },
  17891. terminate: function () {
  17892. this.terminated = true;
  17893. },
  17894. ensureNotTerminated: function () {
  17895. if (this.terminated) {
  17896. throw new Error('Worker task was terminated');
  17897. }
  17898. }
  17899. };
  17900. return WorkerTask;
  17901. }();
  17902. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  17903. function PDFWorkerStream(params, msgHandler) {
  17904. this._queuedChunks = [];
  17905. var initialData = params.initialData;
  17906. if (initialData && initialData.length > 0) {
  17907. this._queuedChunks.push(initialData);
  17908. }
  17909. this._msgHandler = msgHandler;
  17910. this._isRangeSupported = !params.disableRange;
  17911. this._isStreamingSupported = !params.disableStream;
  17912. this._contentLength = params.length;
  17913. this._fullRequestReader = null;
  17914. this._rangeReaders = [];
  17915. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  17916. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  17917. }
  17918. PDFWorkerStream.prototype = {
  17919. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  17920. if (args.begin === undefined) {
  17921. if (this._fullRequestReader) {
  17922. this._fullRequestReader._enqueue(args.chunk);
  17923. } else {
  17924. this._queuedChunks.push(args.chunk);
  17925. }
  17926. } else {
  17927. var found = this._rangeReaders.some(function (rangeReader) {
  17928. if (rangeReader._begin !== args.begin) {
  17929. return false;
  17930. }
  17931. rangeReader._enqueue(args.chunk);
  17932. return true;
  17933. });
  17934. assert(found);
  17935. }
  17936. },
  17937. _onProgress: function PDFWorkerStream_onProgress(evt) {
  17938. if (this._rangeReaders.length > 0) {
  17939. var firstReader = this._rangeReaders[0];
  17940. if (firstReader.onProgress) {
  17941. firstReader.onProgress({ loaded: evt.loaded });
  17942. }
  17943. }
  17944. },
  17945. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  17946. var i = this._rangeReaders.indexOf(reader);
  17947. if (i >= 0) {
  17948. this._rangeReaders.splice(i, 1);
  17949. }
  17950. },
  17951. getFullReader: function PDFWorkerStream_getFullReader() {
  17952. assert(!this._fullRequestReader);
  17953. var queuedChunks = this._queuedChunks;
  17954. this._queuedChunks = null;
  17955. return new PDFWorkerStreamReader(this, queuedChunks);
  17956. },
  17957. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  17958. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  17959. this._msgHandler.send('RequestDataRange', {
  17960. begin: begin,
  17961. end: end
  17962. });
  17963. this._rangeReaders.push(reader);
  17964. return reader;
  17965. },
  17966. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  17967. if (this._fullRequestReader) {
  17968. this._fullRequestReader.cancel(reason);
  17969. }
  17970. var readers = this._rangeReaders.slice(0);
  17971. readers.forEach(function (rangeReader) {
  17972. rangeReader.cancel(reason);
  17973. });
  17974. }
  17975. };
  17976. function PDFWorkerStreamReader(stream, queuedChunks) {
  17977. this._stream = stream;
  17978. this._done = false;
  17979. this._queuedChunks = queuedChunks || [];
  17980. this._requests = [];
  17981. this._headersReady = Promise.resolve();
  17982. stream._fullRequestReader = this;
  17983. this.onProgress = null;
  17984. }
  17985. PDFWorkerStreamReader.prototype = {
  17986. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  17987. if (this._done) {
  17988. return;
  17989. }
  17990. if (this._requests.length > 0) {
  17991. var requestCapability = this._requests.shift();
  17992. requestCapability.resolve({
  17993. value: chunk,
  17994. done: false
  17995. });
  17996. return;
  17997. }
  17998. this._queuedChunks.push(chunk);
  17999. },
  18000. get headersReady() {
  18001. return this._headersReady;
  18002. },
  18003. get isRangeSupported() {
  18004. return this._stream._isRangeSupported;
  18005. },
  18006. get isStreamingSupported() {
  18007. return this._stream._isStreamingSupported;
  18008. },
  18009. get contentLength() {
  18010. return this._stream._contentLength;
  18011. },
  18012. read: function PDFWorkerStreamReader_read() {
  18013. if (this._queuedChunks.length > 0) {
  18014. var chunk = this._queuedChunks.shift();
  18015. return Promise.resolve({
  18016. value: chunk,
  18017. done: false
  18018. });
  18019. }
  18020. if (this._done) {
  18021. return Promise.resolve({
  18022. value: undefined,
  18023. done: true
  18024. });
  18025. }
  18026. var requestCapability = createPromiseCapability();
  18027. this._requests.push(requestCapability);
  18028. return requestCapability.promise;
  18029. },
  18030. cancel: function PDFWorkerStreamReader_cancel(reason) {
  18031. this._done = true;
  18032. this._requests.forEach(function (requestCapability) {
  18033. requestCapability.resolve({
  18034. value: undefined,
  18035. done: true
  18036. });
  18037. });
  18038. this._requests = [];
  18039. }
  18040. };
  18041. function PDFWorkerStreamRangeReader(stream, begin, end) {
  18042. this._stream = stream;
  18043. this._begin = begin;
  18044. this._end = end;
  18045. this._queuedChunk = null;
  18046. this._requests = [];
  18047. this._done = false;
  18048. this.onProgress = null;
  18049. }
  18050. PDFWorkerStreamRangeReader.prototype = {
  18051. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  18052. if (this._done) {
  18053. return;
  18054. }
  18055. if (this._requests.length === 0) {
  18056. this._queuedChunk = chunk;
  18057. } else {
  18058. var requestsCapability = this._requests.shift();
  18059. requestsCapability.resolve({
  18060. value: chunk,
  18061. done: false
  18062. });
  18063. this._requests.forEach(function (requestCapability) {
  18064. requestCapability.resolve({
  18065. value: undefined,
  18066. done: true
  18067. });
  18068. });
  18069. this._requests = [];
  18070. }
  18071. this._done = true;
  18072. this._stream._removeRangeReader(this);
  18073. },
  18074. get isStreamingSupported() {
  18075. return false;
  18076. },
  18077. read: function PDFWorkerStreamRangeReader_read() {
  18078. if (this._queuedChunk) {
  18079. return Promise.resolve({
  18080. value: this._queuedChunk,
  18081. done: false
  18082. });
  18083. }
  18084. if (this._done) {
  18085. return Promise.resolve({
  18086. value: undefined,
  18087. done: true
  18088. });
  18089. }
  18090. var requestCapability = createPromiseCapability();
  18091. this._requests.push(requestCapability);
  18092. return requestCapability.promise;
  18093. },
  18094. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  18095. this._done = true;
  18096. this._requests.forEach(function (requestCapability) {
  18097. requestCapability.resolve({
  18098. value: undefined,
  18099. done: true
  18100. });
  18101. });
  18102. this._requests = [];
  18103. this._stream._removeRangeReader(this);
  18104. }
  18105. };
  18106. return PDFWorkerStream;
  18107. }();
  18108. var PDFNetworkStream;
  18109. function setPDFNetworkStreamClass(cls) {
  18110. PDFNetworkStream = cls;
  18111. }
  18112. var WorkerMessageHandler = {
  18113. setup: function wphSetup(handler, port) {
  18114. var testMessageProcessed = false;
  18115. handler.on('test', function wphSetupTest(data) {
  18116. if (testMessageProcessed) {
  18117. return;
  18118. }
  18119. testMessageProcessed = true;
  18120. if (!(data instanceof Uint8Array)) {
  18121. handler.send('test', 'main', false);
  18122. return;
  18123. }
  18124. var supportTransfers = data[0] === 255;
  18125. handler.postMessageTransfers = supportTransfers;
  18126. var xhr = new XMLHttpRequest();
  18127. var responseExists = 'response' in xhr;
  18128. try {
  18129. xhr.responseType;
  18130. } catch (e) {
  18131. responseExists = false;
  18132. }
  18133. if (!responseExists) {
  18134. handler.send('test', false);
  18135. return;
  18136. }
  18137. handler.send('test', {
  18138. supportTypedArray: true,
  18139. supportTransfers: supportTransfers
  18140. });
  18141. });
  18142. handler.on('configure', function wphConfigure(data) {
  18143. setVerbosityLevel(data.verbosity);
  18144. });
  18145. handler.on('GetDocRequest', function wphSetupDoc(data) {
  18146. return WorkerMessageHandler.createDocumentHandler(data, port);
  18147. });
  18148. },
  18149. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  18150. var pdfManager;
  18151. var terminated = false;
  18152. var cancelXHRs = null;
  18153. var WorkerTasks = [];
  18154. var docId = docParams.docId;
  18155. var docBaseUrl = docParams.docBaseUrl;
  18156. var workerHandlerName = docParams.docId + '_worker';
  18157. var handler = new MessageHandler(workerHandlerName, docId, port);
  18158. handler.postMessageTransfers = docParams.postMessageTransfers;
  18159. function ensureNotTerminated() {
  18160. if (terminated) {
  18161. throw new Error('Worker was terminated');
  18162. }
  18163. }
  18164. function startWorkerTask(task) {
  18165. WorkerTasks.push(task);
  18166. }
  18167. function finishWorkerTask(task) {
  18168. task.finish();
  18169. var i = WorkerTasks.indexOf(task);
  18170. WorkerTasks.splice(i, 1);
  18171. }
  18172. function loadDocument(recoveryMode) {
  18173. var loadDocumentCapability = createPromiseCapability();
  18174. var parseSuccess = function parseSuccess() {
  18175. var numPagesPromise = pdfManager.ensureDoc('numPages');
  18176. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  18177. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  18178. Promise.all([
  18179. numPagesPromise,
  18180. fingerprintPromise,
  18181. encryptedPromise
  18182. ]).then(function onDocReady(results) {
  18183. var doc = {
  18184. numPages: results[0],
  18185. fingerprint: results[1],
  18186. encrypted: !!results[2]
  18187. };
  18188. loadDocumentCapability.resolve(doc);
  18189. }, parseFailure);
  18190. };
  18191. var parseFailure = function parseFailure(e) {
  18192. loadDocumentCapability.reject(e);
  18193. };
  18194. pdfManager.ensureDoc('checkHeader', []).then(function () {
  18195. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  18196. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  18197. }, parseFailure);
  18198. }, parseFailure);
  18199. return loadDocumentCapability.promise;
  18200. }
  18201. function getPdfManager(data, evaluatorOptions) {
  18202. var pdfManagerCapability = createPromiseCapability();
  18203. var pdfManager;
  18204. var source = data.source;
  18205. if (source.data) {
  18206. try {
  18207. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  18208. pdfManagerCapability.resolve(pdfManager);
  18209. } catch (ex) {
  18210. pdfManagerCapability.reject(ex);
  18211. }
  18212. return pdfManagerCapability.promise;
  18213. }
  18214. var pdfStream;
  18215. try {
  18216. if (source.chunkedViewerLoading) {
  18217. pdfStream = new PDFWorkerStream(source, handler);
  18218. } else {
  18219. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  18220. pdfStream = new PDFNetworkStream(data);
  18221. }
  18222. } catch (ex) {
  18223. pdfManagerCapability.reject(ex);
  18224. return pdfManagerCapability.promise;
  18225. }
  18226. var fullRequest = pdfStream.getFullReader();
  18227. fullRequest.headersReady.then(function () {
  18228. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  18229. fullRequest.onProgress = function (evt) {
  18230. handler.send('DocProgress', {
  18231. loaded: evt.loaded,
  18232. total: evt.total
  18233. });
  18234. };
  18235. }
  18236. if (!fullRequest.isRangeSupported) {
  18237. return;
  18238. }
  18239. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  18240. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  18241. msgHandler: handler,
  18242. url: source.url,
  18243. password: source.password,
  18244. length: fullRequest.contentLength,
  18245. disableAutoFetch: disableAutoFetch,
  18246. rangeChunkSize: source.rangeChunkSize
  18247. }, evaluatorOptions, docBaseUrl);
  18248. pdfManagerCapability.resolve(pdfManager);
  18249. cancelXHRs = null;
  18250. }).catch(function (reason) {
  18251. pdfManagerCapability.reject(reason);
  18252. cancelXHRs = null;
  18253. });
  18254. var cachedChunks = [], loaded = 0;
  18255. var flushChunks = function () {
  18256. var pdfFile = arraysToBytes(cachedChunks);
  18257. if (source.length && pdfFile.length !== source.length) {
  18258. warn('reported HTTP length is different from actual');
  18259. }
  18260. try {
  18261. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  18262. pdfManagerCapability.resolve(pdfManager);
  18263. } catch (ex) {
  18264. pdfManagerCapability.reject(ex);
  18265. }
  18266. cachedChunks = [];
  18267. };
  18268. var readPromise = new Promise(function (resolve, reject) {
  18269. var readChunk = function (chunk) {
  18270. try {
  18271. ensureNotTerminated();
  18272. if (chunk.done) {
  18273. if (!pdfManager) {
  18274. flushChunks();
  18275. }
  18276. cancelXHRs = null;
  18277. return;
  18278. }
  18279. var data = chunk.value;
  18280. loaded += arrayByteLength(data);
  18281. if (!fullRequest.isStreamingSupported) {
  18282. handler.send('DocProgress', {
  18283. loaded: loaded,
  18284. total: Math.max(loaded, fullRequest.contentLength || 0)
  18285. });
  18286. }
  18287. if (pdfManager) {
  18288. pdfManager.sendProgressiveData(data);
  18289. } else {
  18290. cachedChunks.push(data);
  18291. }
  18292. fullRequest.read().then(readChunk, reject);
  18293. } catch (e) {
  18294. reject(e);
  18295. }
  18296. };
  18297. fullRequest.read().then(readChunk, reject);
  18298. });
  18299. readPromise.catch(function (e) {
  18300. pdfManagerCapability.reject(e);
  18301. cancelXHRs = null;
  18302. });
  18303. cancelXHRs = function () {
  18304. pdfStream.cancelAllRequests('abort');
  18305. };
  18306. return pdfManagerCapability.promise;
  18307. }
  18308. function setupDoc(data) {
  18309. function onSuccess(doc) {
  18310. ensureNotTerminated();
  18311. handler.send('GetDoc', { pdfInfo: doc });
  18312. }
  18313. function onFailure(e) {
  18314. if (e instanceof PasswordException) {
  18315. var task = new WorkerTask('PasswordException: response ' + e.code);
  18316. startWorkerTask(task);
  18317. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  18318. finishWorkerTask(task);
  18319. pdfManager.updatePassword(data.password);
  18320. pdfManagerReady();
  18321. }).catch(function (ex) {
  18322. finishWorkerTask(task);
  18323. handler.send('PasswordException', ex);
  18324. }.bind(null, e));
  18325. } else if (e instanceof InvalidPDFException) {
  18326. handler.send('InvalidPDF', e);
  18327. } else if (e instanceof MissingPDFException) {
  18328. handler.send('MissingPDF', e);
  18329. } else if (e instanceof UnexpectedResponseException) {
  18330. handler.send('UnexpectedResponse', e);
  18331. } else {
  18332. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  18333. }
  18334. }
  18335. function pdfManagerReady() {
  18336. ensureNotTerminated();
  18337. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  18338. ensureNotTerminated();
  18339. if (!(ex instanceof XRefParseException)) {
  18340. onFailure(ex);
  18341. return;
  18342. }
  18343. pdfManager.requestLoadedStream();
  18344. pdfManager.onLoadedStream().then(function () {
  18345. ensureNotTerminated();
  18346. loadDocument(true).then(onSuccess, onFailure);
  18347. });
  18348. }, onFailure);
  18349. }
  18350. ensureNotTerminated();
  18351. var evaluatorOptions = {
  18352. forceDataSchema: data.disableCreateObjectURL,
  18353. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  18354. disableFontFace: data.disableFontFace,
  18355. disableNativeImageDecoder: data.disableNativeImageDecoder
  18356. };
  18357. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  18358. if (terminated) {
  18359. newPdfManager.terminate();
  18360. throw new Error('Worker was terminated');
  18361. }
  18362. pdfManager = newPdfManager;
  18363. handler.send('PDFManagerReady', null);
  18364. pdfManager.onLoadedStream().then(function (stream) {
  18365. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  18366. });
  18367. }).then(pdfManagerReady, onFailure);
  18368. }
  18369. handler.on('GetPage', function wphSetupGetPage(data) {
  18370. return pdfManager.getPage(data.pageIndex).then(function (page) {
  18371. var rotatePromise = pdfManager.ensure(page, 'rotate');
  18372. var refPromise = pdfManager.ensure(page, 'ref');
  18373. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  18374. var viewPromise = pdfManager.ensure(page, 'view');
  18375. return Promise.all([
  18376. rotatePromise,
  18377. refPromise,
  18378. userUnitPromise,
  18379. viewPromise
  18380. ]).then(function (results) {
  18381. return {
  18382. rotate: results[0],
  18383. ref: results[1],
  18384. userUnit: results[2],
  18385. view: results[3]
  18386. };
  18387. });
  18388. });
  18389. });
  18390. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  18391. var ref = new Ref(data.ref.num, data.ref.gen);
  18392. var catalog = pdfManager.pdfDocument.catalog;
  18393. return catalog.getPageIndex(ref);
  18394. });
  18395. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  18396. return pdfManager.ensureCatalog('destinations');
  18397. });
  18398. handler.on('GetDestination', function wphSetupGetDestination(data) {
  18399. return pdfManager.ensureCatalog('getDestination', [data.id]);
  18400. });
  18401. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  18402. return pdfManager.ensureCatalog('pageLabels');
  18403. });
  18404. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  18405. return pdfManager.ensureCatalog('attachments');
  18406. });
  18407. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  18408. return pdfManager.ensureCatalog('javaScript');
  18409. });
  18410. handler.on('GetOutline', function wphSetupGetOutline(data) {
  18411. return pdfManager.ensureCatalog('documentOutline');
  18412. });
  18413. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  18414. return Promise.all([
  18415. pdfManager.ensureDoc('documentInfo'),
  18416. pdfManager.ensureCatalog('metadata')
  18417. ]);
  18418. });
  18419. handler.on('GetData', function wphSetupGetData(data) {
  18420. pdfManager.requestLoadedStream();
  18421. return pdfManager.onLoadedStream().then(function (stream) {
  18422. return stream.bytes;
  18423. });
  18424. });
  18425. handler.on('GetStats', function wphSetupGetStats(data) {
  18426. return pdfManager.pdfDocument.xref.stats;
  18427. });
  18428. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  18429. return pdfManager.getPage(data.pageIndex).then(function (page) {
  18430. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  18431. });
  18432. });
  18433. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  18434. var pageIndex = data.pageIndex;
  18435. pdfManager.getPage(pageIndex).then(function (page) {
  18436. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  18437. startWorkerTask(task);
  18438. var pageNum = pageIndex + 1;
  18439. var start = Date.now();
  18440. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  18441. finishWorkerTask(task);
  18442. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  18443. }, function (e) {
  18444. finishWorkerTask(task);
  18445. if (task.terminated) {
  18446. return;
  18447. }
  18448. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  18449. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  18450. var wrappedException;
  18451. if (typeof e === 'string') {
  18452. wrappedException = {
  18453. message: e,
  18454. stack: minimumStackMessage
  18455. };
  18456. } else if (typeof e === 'object') {
  18457. wrappedException = {
  18458. message: e.message || e.toString(),
  18459. stack: e.stack || minimumStackMessage
  18460. };
  18461. } else {
  18462. wrappedException = {
  18463. message: 'Unknown exception type: ' + typeof e,
  18464. stack: minimumStackMessage
  18465. };
  18466. }
  18467. handler.send('PageError', {
  18468. pageNum: pageNum,
  18469. error: wrappedException,
  18470. intent: data.intent
  18471. });
  18472. });
  18473. });
  18474. }, this);
  18475. handler.on('GetTextContent', function wphExtractText(data) {
  18476. var pageIndex = data.pageIndex;
  18477. var normalizeWhitespace = data.normalizeWhitespace;
  18478. var combineTextItems = data.combineTextItems;
  18479. return pdfManager.getPage(pageIndex).then(function (page) {
  18480. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  18481. startWorkerTask(task);
  18482. var pageNum = pageIndex + 1;
  18483. var start = Date.now();
  18484. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  18485. finishWorkerTask(task);
  18486. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  18487. return textContent;
  18488. }, function (reason) {
  18489. finishWorkerTask(task);
  18490. if (task.terminated) {
  18491. return;
  18492. }
  18493. throw reason;
  18494. });
  18495. });
  18496. });
  18497. handler.on('Cleanup', function wphCleanup(data) {
  18498. return pdfManager.cleanup();
  18499. });
  18500. handler.on('Terminate', function wphTerminate(data) {
  18501. terminated = true;
  18502. if (pdfManager) {
  18503. pdfManager.terminate();
  18504. pdfManager = null;
  18505. }
  18506. if (cancelXHRs) {
  18507. cancelXHRs();
  18508. }
  18509. var waitOn = [];
  18510. WorkerTasks.forEach(function (task) {
  18511. waitOn.push(task.finished);
  18512. task.terminate();
  18513. });
  18514. return Promise.all(waitOn).then(function () {
  18515. handler.destroy();
  18516. handler = null;
  18517. });
  18518. });
  18519. handler.on('Ready', function wphReady(data) {
  18520. setupDoc(docParams);
  18521. docParams = null;
  18522. });
  18523. return workerHandlerName;
  18524. }
  18525. };
  18526. function initializeWorker() {
  18527. var handler = new MessageHandler('worker', 'main', self);
  18528. WorkerMessageHandler.setup(handler, self);
  18529. handler.send('ready', null);
  18530. }
  18531. if (typeof window === 'undefined' && !isNodeJS()) {
  18532. initializeWorker();
  18533. }
  18534. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  18535. exports.WorkerTask = WorkerTask;
  18536. exports.WorkerMessageHandler = WorkerMessageHandler;
  18537. /***/ }),
  18538. /* 9 */
  18539. /***/ (function(module, exports) {
  18540. var g;
  18541. g = function () {
  18542. return this;
  18543. }();
  18544. try {
  18545. g = g || Function("return this")() || (1, eval)("this");
  18546. } catch (e) {
  18547. if (typeof window === "object")
  18548. g = window;
  18549. }
  18550. module.exports = g;
  18551. /***/ }),
  18552. /* 10 */
  18553. /***/ (function(module, exports, __w_pdfjs_require__) {
  18554. "use strict";
  18555. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  18556. var QeTable = [
  18557. {
  18558. qe: 0x5601,
  18559. nmps: 1,
  18560. nlps: 1,
  18561. switchFlag: 1
  18562. },
  18563. {
  18564. qe: 0x3401,
  18565. nmps: 2,
  18566. nlps: 6,
  18567. switchFlag: 0
  18568. },
  18569. {
  18570. qe: 0x1801,
  18571. nmps: 3,
  18572. nlps: 9,
  18573. switchFlag: 0
  18574. },
  18575. {
  18576. qe: 0x0AC1,
  18577. nmps: 4,
  18578. nlps: 12,
  18579. switchFlag: 0
  18580. },
  18581. {
  18582. qe: 0x0521,
  18583. nmps: 5,
  18584. nlps: 29,
  18585. switchFlag: 0
  18586. },
  18587. {
  18588. qe: 0x0221,
  18589. nmps: 38,
  18590. nlps: 33,
  18591. switchFlag: 0
  18592. },
  18593. {
  18594. qe: 0x5601,
  18595. nmps: 7,
  18596. nlps: 6,
  18597. switchFlag: 1
  18598. },
  18599. {
  18600. qe: 0x5401,
  18601. nmps: 8,
  18602. nlps: 14,
  18603. switchFlag: 0
  18604. },
  18605. {
  18606. qe: 0x4801,
  18607. nmps: 9,
  18608. nlps: 14,
  18609. switchFlag: 0
  18610. },
  18611. {
  18612. qe: 0x3801,
  18613. nmps: 10,
  18614. nlps: 14,
  18615. switchFlag: 0
  18616. },
  18617. {
  18618. qe: 0x3001,
  18619. nmps: 11,
  18620. nlps: 17,
  18621. switchFlag: 0
  18622. },
  18623. {
  18624. qe: 0x2401,
  18625. nmps: 12,
  18626. nlps: 18,
  18627. switchFlag: 0
  18628. },
  18629. {
  18630. qe: 0x1C01,
  18631. nmps: 13,
  18632. nlps: 20,
  18633. switchFlag: 0
  18634. },
  18635. {
  18636. qe: 0x1601,
  18637. nmps: 29,
  18638. nlps: 21,
  18639. switchFlag: 0
  18640. },
  18641. {
  18642. qe: 0x5601,
  18643. nmps: 15,
  18644. nlps: 14,
  18645. switchFlag: 1
  18646. },
  18647. {
  18648. qe: 0x5401,
  18649. nmps: 16,
  18650. nlps: 14,
  18651. switchFlag: 0
  18652. },
  18653. {
  18654. qe: 0x5101,
  18655. nmps: 17,
  18656. nlps: 15,
  18657. switchFlag: 0
  18658. },
  18659. {
  18660. qe: 0x4801,
  18661. nmps: 18,
  18662. nlps: 16,
  18663. switchFlag: 0
  18664. },
  18665. {
  18666. qe: 0x3801,
  18667. nmps: 19,
  18668. nlps: 17,
  18669. switchFlag: 0
  18670. },
  18671. {
  18672. qe: 0x3401,
  18673. nmps: 20,
  18674. nlps: 18,
  18675. switchFlag: 0
  18676. },
  18677. {
  18678. qe: 0x3001,
  18679. nmps: 21,
  18680. nlps: 19,
  18681. switchFlag: 0
  18682. },
  18683. {
  18684. qe: 0x2801,
  18685. nmps: 22,
  18686. nlps: 19,
  18687. switchFlag: 0
  18688. },
  18689. {
  18690. qe: 0x2401,
  18691. nmps: 23,
  18692. nlps: 20,
  18693. switchFlag: 0
  18694. },
  18695. {
  18696. qe: 0x2201,
  18697. nmps: 24,
  18698. nlps: 21,
  18699. switchFlag: 0
  18700. },
  18701. {
  18702. qe: 0x1C01,
  18703. nmps: 25,
  18704. nlps: 22,
  18705. switchFlag: 0
  18706. },
  18707. {
  18708. qe: 0x1801,
  18709. nmps: 26,
  18710. nlps: 23,
  18711. switchFlag: 0
  18712. },
  18713. {
  18714. qe: 0x1601,
  18715. nmps: 27,
  18716. nlps: 24,
  18717. switchFlag: 0
  18718. },
  18719. {
  18720. qe: 0x1401,
  18721. nmps: 28,
  18722. nlps: 25,
  18723. switchFlag: 0
  18724. },
  18725. {
  18726. qe: 0x1201,
  18727. nmps: 29,
  18728. nlps: 26,
  18729. switchFlag: 0
  18730. },
  18731. {
  18732. qe: 0x1101,
  18733. nmps: 30,
  18734. nlps: 27,
  18735. switchFlag: 0
  18736. },
  18737. {
  18738. qe: 0x0AC1,
  18739. nmps: 31,
  18740. nlps: 28,
  18741. switchFlag: 0
  18742. },
  18743. {
  18744. qe: 0x09C1,
  18745. nmps: 32,
  18746. nlps: 29,
  18747. switchFlag: 0
  18748. },
  18749. {
  18750. qe: 0x08A1,
  18751. nmps: 33,
  18752. nlps: 30,
  18753. switchFlag: 0
  18754. },
  18755. {
  18756. qe: 0x0521,
  18757. nmps: 34,
  18758. nlps: 31,
  18759. switchFlag: 0
  18760. },
  18761. {
  18762. qe: 0x0441,
  18763. nmps: 35,
  18764. nlps: 32,
  18765. switchFlag: 0
  18766. },
  18767. {
  18768. qe: 0x02A1,
  18769. nmps: 36,
  18770. nlps: 33,
  18771. switchFlag: 0
  18772. },
  18773. {
  18774. qe: 0x0221,
  18775. nmps: 37,
  18776. nlps: 34,
  18777. switchFlag: 0
  18778. },
  18779. {
  18780. qe: 0x0141,
  18781. nmps: 38,
  18782. nlps: 35,
  18783. switchFlag: 0
  18784. },
  18785. {
  18786. qe: 0x0111,
  18787. nmps: 39,
  18788. nlps: 36,
  18789. switchFlag: 0
  18790. },
  18791. {
  18792. qe: 0x0085,
  18793. nmps: 40,
  18794. nlps: 37,
  18795. switchFlag: 0
  18796. },
  18797. {
  18798. qe: 0x0049,
  18799. nmps: 41,
  18800. nlps: 38,
  18801. switchFlag: 0
  18802. },
  18803. {
  18804. qe: 0x0025,
  18805. nmps: 42,
  18806. nlps: 39,
  18807. switchFlag: 0
  18808. },
  18809. {
  18810. qe: 0x0015,
  18811. nmps: 43,
  18812. nlps: 40,
  18813. switchFlag: 0
  18814. },
  18815. {
  18816. qe: 0x0009,
  18817. nmps: 44,
  18818. nlps: 41,
  18819. switchFlag: 0
  18820. },
  18821. {
  18822. qe: 0x0005,
  18823. nmps: 45,
  18824. nlps: 42,
  18825. switchFlag: 0
  18826. },
  18827. {
  18828. qe: 0x0001,
  18829. nmps: 45,
  18830. nlps: 43,
  18831. switchFlag: 0
  18832. },
  18833. {
  18834. qe: 0x5601,
  18835. nmps: 46,
  18836. nlps: 46,
  18837. switchFlag: 0
  18838. }
  18839. ];
  18840. function ArithmeticDecoder(data, start, end) {
  18841. this.data = data;
  18842. this.bp = start;
  18843. this.dataEnd = end;
  18844. this.chigh = data[start];
  18845. this.clow = 0;
  18846. this.byteIn();
  18847. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  18848. this.clow = this.clow << 7 & 0xFFFF;
  18849. this.ct -= 7;
  18850. this.a = 0x8000;
  18851. }
  18852. ArithmeticDecoder.prototype = {
  18853. byteIn: function ArithmeticDecoder_byteIn() {
  18854. var data = this.data;
  18855. var bp = this.bp;
  18856. if (data[bp] === 0xFF) {
  18857. var b1 = data[bp + 1];
  18858. if (b1 > 0x8F) {
  18859. this.clow += 0xFF00;
  18860. this.ct = 8;
  18861. } else {
  18862. bp++;
  18863. this.clow += data[bp] << 9;
  18864. this.ct = 7;
  18865. this.bp = bp;
  18866. }
  18867. } else {
  18868. bp++;
  18869. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  18870. this.ct = 8;
  18871. this.bp = bp;
  18872. }
  18873. if (this.clow > 0xFFFF) {
  18874. this.chigh += this.clow >> 16;
  18875. this.clow &= 0xFFFF;
  18876. }
  18877. },
  18878. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  18879. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  18880. var qeTableIcx = QeTable[cx_index];
  18881. var qeIcx = qeTableIcx.qe;
  18882. var d;
  18883. var a = this.a - qeIcx;
  18884. if (this.chigh < qeIcx) {
  18885. if (a < qeIcx) {
  18886. a = qeIcx;
  18887. d = cx_mps;
  18888. cx_index = qeTableIcx.nmps;
  18889. } else {
  18890. a = qeIcx;
  18891. d = 1 ^ cx_mps;
  18892. if (qeTableIcx.switchFlag === 1) {
  18893. cx_mps = d;
  18894. }
  18895. cx_index = qeTableIcx.nlps;
  18896. }
  18897. } else {
  18898. this.chigh -= qeIcx;
  18899. if ((a & 0x8000) !== 0) {
  18900. this.a = a;
  18901. return cx_mps;
  18902. }
  18903. if (a < qeIcx) {
  18904. d = 1 ^ cx_mps;
  18905. if (qeTableIcx.switchFlag === 1) {
  18906. cx_mps = d;
  18907. }
  18908. cx_index = qeTableIcx.nlps;
  18909. } else {
  18910. d = cx_mps;
  18911. cx_index = qeTableIcx.nmps;
  18912. }
  18913. }
  18914. do {
  18915. if (this.ct === 0) {
  18916. this.byteIn();
  18917. }
  18918. a <<= 1;
  18919. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  18920. this.clow = this.clow << 1 & 0xFFFF;
  18921. this.ct--;
  18922. } while ((a & 0x8000) === 0);
  18923. this.a = a;
  18924. contexts[pos] = cx_index << 1 | cx_mps;
  18925. return d;
  18926. }
  18927. };
  18928. return ArithmeticDecoder;
  18929. }();
  18930. exports.ArithmeticDecoder = ArithmeticDecoder;
  18931. /***/ }),
  18932. /* 11 */
  18933. /***/ (function(module, exports, __w_pdfjs_require__) {
  18934. "use strict";
  18935. var sharedUtil = __w_pdfjs_require__(0);
  18936. var coreCharsets = __w_pdfjs_require__(22);
  18937. var coreEncodings = __w_pdfjs_require__(4);
  18938. var error = sharedUtil.error;
  18939. var info = sharedUtil.info;
  18940. var bytesToString = sharedUtil.bytesToString;
  18941. var warn = sharedUtil.warn;
  18942. var isArray = sharedUtil.isArray;
  18943. var Util = sharedUtil.Util;
  18944. var stringToBytes = sharedUtil.stringToBytes;
  18945. var assert = sharedUtil.assert;
  18946. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  18947. var ExpertCharset = coreCharsets.ExpertCharset;
  18948. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  18949. var StandardEncoding = coreEncodings.StandardEncoding;
  18950. var ExpertEncoding = coreEncodings.ExpertEncoding;
  18951. var MAX_SUBR_NESTING = 10;
  18952. var CFFStandardStrings = [
  18953. '.notdef',
  18954. 'space',
  18955. 'exclam',
  18956. 'quotedbl',
  18957. 'numbersign',
  18958. 'dollar',
  18959. 'percent',
  18960. 'ampersand',
  18961. 'quoteright',
  18962. 'parenleft',
  18963. 'parenright',
  18964. 'asterisk',
  18965. 'plus',
  18966. 'comma',
  18967. 'hyphen',
  18968. 'period',
  18969. 'slash',
  18970. 'zero',
  18971. 'one',
  18972. 'two',
  18973. 'three',
  18974. 'four',
  18975. 'five',
  18976. 'six',
  18977. 'seven',
  18978. 'eight',
  18979. 'nine',
  18980. 'colon',
  18981. 'semicolon',
  18982. 'less',
  18983. 'equal',
  18984. 'greater',
  18985. 'question',
  18986. 'at',
  18987. 'A',
  18988. 'B',
  18989. 'C',
  18990. 'D',
  18991. 'E',
  18992. 'F',
  18993. 'G',
  18994. 'H',
  18995. 'I',
  18996. 'J',
  18997. 'K',
  18998. 'L',
  18999. 'M',
  19000. 'N',
  19001. 'O',
  19002. 'P',
  19003. 'Q',
  19004. 'R',
  19005. 'S',
  19006. 'T',
  19007. 'U',
  19008. 'V',
  19009. 'W',
  19010. 'X',
  19011. 'Y',
  19012. 'Z',
  19013. 'bracketleft',
  19014. 'backslash',
  19015. 'bracketright',
  19016. 'asciicircum',
  19017. 'underscore',
  19018. 'quoteleft',
  19019. 'a',
  19020. 'b',
  19021. 'c',
  19022. 'd',
  19023. 'e',
  19024. 'f',
  19025. 'g',
  19026. 'h',
  19027. 'i',
  19028. 'j',
  19029. 'k',
  19030. 'l',
  19031. 'm',
  19032. 'n',
  19033. 'o',
  19034. 'p',
  19035. 'q',
  19036. 'r',
  19037. 's',
  19038. 't',
  19039. 'u',
  19040. 'v',
  19041. 'w',
  19042. 'x',
  19043. 'y',
  19044. 'z',
  19045. 'braceleft',
  19046. 'bar',
  19047. 'braceright',
  19048. 'asciitilde',
  19049. 'exclamdown',
  19050. 'cent',
  19051. 'sterling',
  19052. 'fraction',
  19053. 'yen',
  19054. 'florin',
  19055. 'section',
  19056. 'currency',
  19057. 'quotesingle',
  19058. 'quotedblleft',
  19059. 'guillemotleft',
  19060. 'guilsinglleft',
  19061. 'guilsinglright',
  19062. 'fi',
  19063. 'fl',
  19064. 'endash',
  19065. 'dagger',
  19066. 'daggerdbl',
  19067. 'periodcentered',
  19068. 'paragraph',
  19069. 'bullet',
  19070. 'quotesinglbase',
  19071. 'quotedblbase',
  19072. 'quotedblright',
  19073. 'guillemotright',
  19074. 'ellipsis',
  19075. 'perthousand',
  19076. 'questiondown',
  19077. 'grave',
  19078. 'acute',
  19079. 'circumflex',
  19080. 'tilde',
  19081. 'macron',
  19082. 'breve',
  19083. 'dotaccent',
  19084. 'dieresis',
  19085. 'ring',
  19086. 'cedilla',
  19087. 'hungarumlaut',
  19088. 'ogonek',
  19089. 'caron',
  19090. 'emdash',
  19091. 'AE',
  19092. 'ordfeminine',
  19093. 'Lslash',
  19094. 'Oslash',
  19095. 'OE',
  19096. 'ordmasculine',
  19097. 'ae',
  19098. 'dotlessi',
  19099. 'lslash',
  19100. 'oslash',
  19101. 'oe',
  19102. 'germandbls',
  19103. 'onesuperior',
  19104. 'logicalnot',
  19105. 'mu',
  19106. 'trademark',
  19107. 'Eth',
  19108. 'onehalf',
  19109. 'plusminus',
  19110. 'Thorn',
  19111. 'onequarter',
  19112. 'divide',
  19113. 'brokenbar',
  19114. 'degree',
  19115. 'thorn',
  19116. 'threequarters',
  19117. 'twosuperior',
  19118. 'registered',
  19119. 'minus',
  19120. 'eth',
  19121. 'multiply',
  19122. 'threesuperior',
  19123. 'copyright',
  19124. 'Aacute',
  19125. 'Acircumflex',
  19126. 'Adieresis',
  19127. 'Agrave',
  19128. 'Aring',
  19129. 'Atilde',
  19130. 'Ccedilla',
  19131. 'Eacute',
  19132. 'Ecircumflex',
  19133. 'Edieresis',
  19134. 'Egrave',
  19135. 'Iacute',
  19136. 'Icircumflex',
  19137. 'Idieresis',
  19138. 'Igrave',
  19139. 'Ntilde',
  19140. 'Oacute',
  19141. 'Ocircumflex',
  19142. 'Odieresis',
  19143. 'Ograve',
  19144. 'Otilde',
  19145. 'Scaron',
  19146. 'Uacute',
  19147. 'Ucircumflex',
  19148. 'Udieresis',
  19149. 'Ugrave',
  19150. 'Yacute',
  19151. 'Ydieresis',
  19152. 'Zcaron',
  19153. 'aacute',
  19154. 'acircumflex',
  19155. 'adieresis',
  19156. 'agrave',
  19157. 'aring',
  19158. 'atilde',
  19159. 'ccedilla',
  19160. 'eacute',
  19161. 'ecircumflex',
  19162. 'edieresis',
  19163. 'egrave',
  19164. 'iacute',
  19165. 'icircumflex',
  19166. 'idieresis',
  19167. 'igrave',
  19168. 'ntilde',
  19169. 'oacute',
  19170. 'ocircumflex',
  19171. 'odieresis',
  19172. 'ograve',
  19173. 'otilde',
  19174. 'scaron',
  19175. 'uacute',
  19176. 'ucircumflex',
  19177. 'udieresis',
  19178. 'ugrave',
  19179. 'yacute',
  19180. 'ydieresis',
  19181. 'zcaron',
  19182. 'exclamsmall',
  19183. 'Hungarumlautsmall',
  19184. 'dollaroldstyle',
  19185. 'dollarsuperior',
  19186. 'ampersandsmall',
  19187. 'Acutesmall',
  19188. 'parenleftsuperior',
  19189. 'parenrightsuperior',
  19190. 'twodotenleader',
  19191. 'onedotenleader',
  19192. 'zerooldstyle',
  19193. 'oneoldstyle',
  19194. 'twooldstyle',
  19195. 'threeoldstyle',
  19196. 'fouroldstyle',
  19197. 'fiveoldstyle',
  19198. 'sixoldstyle',
  19199. 'sevenoldstyle',
  19200. 'eightoldstyle',
  19201. 'nineoldstyle',
  19202. 'commasuperior',
  19203. 'threequartersemdash',
  19204. 'periodsuperior',
  19205. 'questionsmall',
  19206. 'asuperior',
  19207. 'bsuperior',
  19208. 'centsuperior',
  19209. 'dsuperior',
  19210. 'esuperior',
  19211. 'isuperior',
  19212. 'lsuperior',
  19213. 'msuperior',
  19214. 'nsuperior',
  19215. 'osuperior',
  19216. 'rsuperior',
  19217. 'ssuperior',
  19218. 'tsuperior',
  19219. 'ff',
  19220. 'ffi',
  19221. 'ffl',
  19222. 'parenleftinferior',
  19223. 'parenrightinferior',
  19224. 'Circumflexsmall',
  19225. 'hyphensuperior',
  19226. 'Gravesmall',
  19227. 'Asmall',
  19228. 'Bsmall',
  19229. 'Csmall',
  19230. 'Dsmall',
  19231. 'Esmall',
  19232. 'Fsmall',
  19233. 'Gsmall',
  19234. 'Hsmall',
  19235. 'Ismall',
  19236. 'Jsmall',
  19237. 'Ksmall',
  19238. 'Lsmall',
  19239. 'Msmall',
  19240. 'Nsmall',
  19241. 'Osmall',
  19242. 'Psmall',
  19243. 'Qsmall',
  19244. 'Rsmall',
  19245. 'Ssmall',
  19246. 'Tsmall',
  19247. 'Usmall',
  19248. 'Vsmall',
  19249. 'Wsmall',
  19250. 'Xsmall',
  19251. 'Ysmall',
  19252. 'Zsmall',
  19253. 'colonmonetary',
  19254. 'onefitted',
  19255. 'rupiah',
  19256. 'Tildesmall',
  19257. 'exclamdownsmall',
  19258. 'centoldstyle',
  19259. 'Lslashsmall',
  19260. 'Scaronsmall',
  19261. 'Zcaronsmall',
  19262. 'Dieresissmall',
  19263. 'Brevesmall',
  19264. 'Caronsmall',
  19265. 'Dotaccentsmall',
  19266. 'Macronsmall',
  19267. 'figuredash',
  19268. 'hypheninferior',
  19269. 'Ogoneksmall',
  19270. 'Ringsmall',
  19271. 'Cedillasmall',
  19272. 'questiondownsmall',
  19273. 'oneeighth',
  19274. 'threeeighths',
  19275. 'fiveeighths',
  19276. 'seveneighths',
  19277. 'onethird',
  19278. 'twothirds',
  19279. 'zerosuperior',
  19280. 'foursuperior',
  19281. 'fivesuperior',
  19282. 'sixsuperior',
  19283. 'sevensuperior',
  19284. 'eightsuperior',
  19285. 'ninesuperior',
  19286. 'zeroinferior',
  19287. 'oneinferior',
  19288. 'twoinferior',
  19289. 'threeinferior',
  19290. 'fourinferior',
  19291. 'fiveinferior',
  19292. 'sixinferior',
  19293. 'seveninferior',
  19294. 'eightinferior',
  19295. 'nineinferior',
  19296. 'centinferior',
  19297. 'dollarinferior',
  19298. 'periodinferior',
  19299. 'commainferior',
  19300. 'Agravesmall',
  19301. 'Aacutesmall',
  19302. 'Acircumflexsmall',
  19303. 'Atildesmall',
  19304. 'Adieresissmall',
  19305. 'Aringsmall',
  19306. 'AEsmall',
  19307. 'Ccedillasmall',
  19308. 'Egravesmall',
  19309. 'Eacutesmall',
  19310. 'Ecircumflexsmall',
  19311. 'Edieresissmall',
  19312. 'Igravesmall',
  19313. 'Iacutesmall',
  19314. 'Icircumflexsmall',
  19315. 'Idieresissmall',
  19316. 'Ethsmall',
  19317. 'Ntildesmall',
  19318. 'Ogravesmall',
  19319. 'Oacutesmall',
  19320. 'Ocircumflexsmall',
  19321. 'Otildesmall',
  19322. 'Odieresissmall',
  19323. 'OEsmall',
  19324. 'Oslashsmall',
  19325. 'Ugravesmall',
  19326. 'Uacutesmall',
  19327. 'Ucircumflexsmall',
  19328. 'Udieresissmall',
  19329. 'Yacutesmall',
  19330. 'Thornsmall',
  19331. 'Ydieresissmall',
  19332. '001.000',
  19333. '001.001',
  19334. '001.002',
  19335. '001.003',
  19336. 'Black',
  19337. 'Bold',
  19338. 'Book',
  19339. 'Light',
  19340. 'Medium',
  19341. 'Regular',
  19342. 'Roman',
  19343. 'Semibold'
  19344. ];
  19345. var CFFParser = function CFFParserClosure() {
  19346. var CharstringValidationData = [
  19347. null,
  19348. {
  19349. id: 'hstem',
  19350. min: 2,
  19351. stackClearing: true,
  19352. stem: true
  19353. },
  19354. null,
  19355. {
  19356. id: 'vstem',
  19357. min: 2,
  19358. stackClearing: true,
  19359. stem: true
  19360. },
  19361. {
  19362. id: 'vmoveto',
  19363. min: 1,
  19364. stackClearing: true
  19365. },
  19366. {
  19367. id: 'rlineto',
  19368. min: 2,
  19369. resetStack: true
  19370. },
  19371. {
  19372. id: 'hlineto',
  19373. min: 1,
  19374. resetStack: true
  19375. },
  19376. {
  19377. id: 'vlineto',
  19378. min: 1,
  19379. resetStack: true
  19380. },
  19381. {
  19382. id: 'rrcurveto',
  19383. min: 6,
  19384. resetStack: true
  19385. },
  19386. null,
  19387. {
  19388. id: 'callsubr',
  19389. min: 1,
  19390. undefStack: true
  19391. },
  19392. {
  19393. id: 'return',
  19394. min: 0,
  19395. undefStack: true
  19396. },
  19397. null,
  19398. null,
  19399. {
  19400. id: 'endchar',
  19401. min: 0,
  19402. stackClearing: true
  19403. },
  19404. null,
  19405. null,
  19406. null,
  19407. {
  19408. id: 'hstemhm',
  19409. min: 2,
  19410. stackClearing: true,
  19411. stem: true
  19412. },
  19413. {
  19414. id: 'hintmask',
  19415. min: 0,
  19416. stackClearing: true
  19417. },
  19418. {
  19419. id: 'cntrmask',
  19420. min: 0,
  19421. stackClearing: true
  19422. },
  19423. {
  19424. id: 'rmoveto',
  19425. min: 2,
  19426. stackClearing: true
  19427. },
  19428. {
  19429. id: 'hmoveto',
  19430. min: 1,
  19431. stackClearing: true
  19432. },
  19433. {
  19434. id: 'vstemhm',
  19435. min: 2,
  19436. stackClearing: true,
  19437. stem: true
  19438. },
  19439. {
  19440. id: 'rcurveline',
  19441. min: 8,
  19442. resetStack: true
  19443. },
  19444. {
  19445. id: 'rlinecurve',
  19446. min: 8,
  19447. resetStack: true
  19448. },
  19449. {
  19450. id: 'vvcurveto',
  19451. min: 4,
  19452. resetStack: true
  19453. },
  19454. {
  19455. id: 'hhcurveto',
  19456. min: 4,
  19457. resetStack: true
  19458. },
  19459. null,
  19460. {
  19461. id: 'callgsubr',
  19462. min: 1,
  19463. undefStack: true
  19464. },
  19465. {
  19466. id: 'vhcurveto',
  19467. min: 4,
  19468. resetStack: true
  19469. },
  19470. {
  19471. id: 'hvcurveto',
  19472. min: 4,
  19473. resetStack: true
  19474. }
  19475. ];
  19476. var CharstringValidationData12 = [
  19477. null,
  19478. null,
  19479. null,
  19480. {
  19481. id: 'and',
  19482. min: 2,
  19483. stackDelta: -1
  19484. },
  19485. {
  19486. id: 'or',
  19487. min: 2,
  19488. stackDelta: -1
  19489. },
  19490. {
  19491. id: 'not',
  19492. min: 1,
  19493. stackDelta: 0
  19494. },
  19495. null,
  19496. null,
  19497. null,
  19498. {
  19499. id: 'abs',
  19500. min: 1,
  19501. stackDelta: 0
  19502. },
  19503. {
  19504. id: 'add',
  19505. min: 2,
  19506. stackDelta: -1,
  19507. stackFn: function stack_div(stack, index) {
  19508. stack[index - 2] = stack[index - 2] + stack[index - 1];
  19509. }
  19510. },
  19511. {
  19512. id: 'sub',
  19513. min: 2,
  19514. stackDelta: -1,
  19515. stackFn: function stack_div(stack, index) {
  19516. stack[index - 2] = stack[index - 2] - stack[index - 1];
  19517. }
  19518. },
  19519. {
  19520. id: 'div',
  19521. min: 2,
  19522. stackDelta: -1,
  19523. stackFn: function stack_div(stack, index) {
  19524. stack[index - 2] = stack[index - 2] / stack[index - 1];
  19525. }
  19526. },
  19527. null,
  19528. {
  19529. id: 'neg',
  19530. min: 1,
  19531. stackDelta: 0,
  19532. stackFn: function stack_div(stack, index) {
  19533. stack[index - 1] = -stack[index - 1];
  19534. }
  19535. },
  19536. {
  19537. id: 'eq',
  19538. min: 2,
  19539. stackDelta: -1
  19540. },
  19541. null,
  19542. null,
  19543. {
  19544. id: 'drop',
  19545. min: 1,
  19546. stackDelta: -1
  19547. },
  19548. null,
  19549. {
  19550. id: 'put',
  19551. min: 2,
  19552. stackDelta: -2
  19553. },
  19554. {
  19555. id: 'get',
  19556. min: 1,
  19557. stackDelta: 0
  19558. },
  19559. {
  19560. id: 'ifelse',
  19561. min: 4,
  19562. stackDelta: -3
  19563. },
  19564. {
  19565. id: 'random',
  19566. min: 0,
  19567. stackDelta: 1
  19568. },
  19569. {
  19570. id: 'mul',
  19571. min: 2,
  19572. stackDelta: -1,
  19573. stackFn: function stack_div(stack, index) {
  19574. stack[index - 2] = stack[index - 2] * stack[index - 1];
  19575. }
  19576. },
  19577. null,
  19578. {
  19579. id: 'sqrt',
  19580. min: 1,
  19581. stackDelta: 0
  19582. },
  19583. {
  19584. id: 'dup',
  19585. min: 1,
  19586. stackDelta: 1
  19587. },
  19588. {
  19589. id: 'exch',
  19590. min: 2,
  19591. stackDelta: 0
  19592. },
  19593. {
  19594. id: 'index',
  19595. min: 2,
  19596. stackDelta: 0
  19597. },
  19598. {
  19599. id: 'roll',
  19600. min: 3,
  19601. stackDelta: -2
  19602. },
  19603. null,
  19604. null,
  19605. null,
  19606. {
  19607. id: 'hflex',
  19608. min: 7,
  19609. resetStack: true
  19610. },
  19611. {
  19612. id: 'flex',
  19613. min: 13,
  19614. resetStack: true
  19615. },
  19616. {
  19617. id: 'hflex1',
  19618. min: 9,
  19619. resetStack: true
  19620. },
  19621. {
  19622. id: 'flex1',
  19623. min: 11,
  19624. resetStack: true
  19625. }
  19626. ];
  19627. function CFFParser(file, properties, seacAnalysisEnabled) {
  19628. this.bytes = file.getBytes();
  19629. this.properties = properties;
  19630. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  19631. }
  19632. CFFParser.prototype = {
  19633. parse: function CFFParser_parse() {
  19634. var properties = this.properties;
  19635. var cff = new CFF();
  19636. this.cff = cff;
  19637. var header = this.parseHeader();
  19638. var nameIndex = this.parseIndex(header.endPos);
  19639. var topDictIndex = this.parseIndex(nameIndex.endPos);
  19640. var stringIndex = this.parseIndex(topDictIndex.endPos);
  19641. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  19642. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  19643. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  19644. cff.header = header.obj;
  19645. cff.names = this.parseNameIndex(nameIndex.obj);
  19646. cff.strings = this.parseStringIndex(stringIndex.obj);
  19647. cff.topDict = topDict;
  19648. cff.globalSubrIndex = globalSubrIndex.obj;
  19649. this.parsePrivateDict(cff.topDict);
  19650. cff.isCIDFont = topDict.hasName('ROS');
  19651. var charStringOffset = topDict.getByName('CharStrings');
  19652. var charStringIndex = this.parseIndex(charStringOffset).obj;
  19653. var fontMatrix = topDict.getByName('FontMatrix');
  19654. if (fontMatrix) {
  19655. properties.fontMatrix = fontMatrix;
  19656. }
  19657. var fontBBox = topDict.getByName('FontBBox');
  19658. if (fontBBox) {
  19659. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  19660. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  19661. properties.ascentScaled = true;
  19662. }
  19663. var charset, encoding;
  19664. if (cff.isCIDFont) {
  19665. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  19666. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  19667. var dictRaw = fdArrayIndex.get(i);
  19668. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  19669. this.parsePrivateDict(fontDict);
  19670. cff.fdArray.push(fontDict);
  19671. }
  19672. encoding = null;
  19673. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  19674. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  19675. } else {
  19676. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  19677. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  19678. }
  19679. cff.charset = charset;
  19680. cff.encoding = encoding;
  19681. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  19682. cff.charStrings = charStringsAndSeacs.charStrings;
  19683. cff.seacs = charStringsAndSeacs.seacs;
  19684. cff.widths = charStringsAndSeacs.widths;
  19685. return cff;
  19686. },
  19687. parseHeader: function CFFParser_parseHeader() {
  19688. var bytes = this.bytes;
  19689. var bytesLength = bytes.length;
  19690. var offset = 0;
  19691. while (offset < bytesLength && bytes[offset] !== 1) {
  19692. ++offset;
  19693. }
  19694. if (offset >= bytesLength) {
  19695. error('Invalid CFF header');
  19696. } else if (offset !== 0) {
  19697. info('cff data is shifted');
  19698. bytes = bytes.subarray(offset);
  19699. this.bytes = bytes;
  19700. }
  19701. var major = bytes[0];
  19702. var minor = bytes[1];
  19703. var hdrSize = bytes[2];
  19704. var offSize = bytes[3];
  19705. var header = new CFFHeader(major, minor, hdrSize, offSize);
  19706. return {
  19707. obj: header,
  19708. endPos: hdrSize
  19709. };
  19710. },
  19711. parseDict: function CFFParser_parseDict(dict) {
  19712. var pos = 0;
  19713. function parseOperand() {
  19714. var value = dict[pos++];
  19715. if (value === 30) {
  19716. return parseFloatOperand();
  19717. } else if (value === 28) {
  19718. value = dict[pos++];
  19719. value = (value << 24 | dict[pos++] << 16) >> 16;
  19720. return value;
  19721. } else if (value === 29) {
  19722. value = dict[pos++];
  19723. value = value << 8 | dict[pos++];
  19724. value = value << 8 | dict[pos++];
  19725. value = value << 8 | dict[pos++];
  19726. return value;
  19727. } else if (value >= 32 && value <= 246) {
  19728. return value - 139;
  19729. } else if (value >= 247 && value <= 250) {
  19730. return (value - 247) * 256 + dict[pos++] + 108;
  19731. } else if (value >= 251 && value <= 254) {
  19732. return -((value - 251) * 256) - dict[pos++] - 108;
  19733. }
  19734. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  19735. return NaN;
  19736. }
  19737. function parseFloatOperand() {
  19738. var str = '';
  19739. var eof = 15;
  19740. var lookup = [
  19741. '0',
  19742. '1',
  19743. '2',
  19744. '3',
  19745. '4',
  19746. '5',
  19747. '6',
  19748. '7',
  19749. '8',
  19750. '9',
  19751. '.',
  19752. 'E',
  19753. 'E-',
  19754. null,
  19755. '-'
  19756. ];
  19757. var length = dict.length;
  19758. while (pos < length) {
  19759. var b = dict[pos++];
  19760. var b1 = b >> 4;
  19761. var b2 = b & 15;
  19762. if (b1 === eof) {
  19763. break;
  19764. }
  19765. str += lookup[b1];
  19766. if (b2 === eof) {
  19767. break;
  19768. }
  19769. str += lookup[b2];
  19770. }
  19771. return parseFloat(str);
  19772. }
  19773. var operands = [];
  19774. var entries = [];
  19775. pos = 0;
  19776. var end = dict.length;
  19777. while (pos < end) {
  19778. var b = dict[pos];
  19779. if (b <= 21) {
  19780. if (b === 12) {
  19781. b = b << 8 | dict[++pos];
  19782. }
  19783. entries.push([
  19784. b,
  19785. operands
  19786. ]);
  19787. operands = [];
  19788. ++pos;
  19789. } else {
  19790. operands.push(parseOperand());
  19791. }
  19792. }
  19793. return entries;
  19794. },
  19795. parseIndex: function CFFParser_parseIndex(pos) {
  19796. var cffIndex = new CFFIndex();
  19797. var bytes = this.bytes;
  19798. var count = bytes[pos++] << 8 | bytes[pos++];
  19799. var offsets = [];
  19800. var end = pos;
  19801. var i, ii;
  19802. if (count !== 0) {
  19803. var offsetSize = bytes[pos++];
  19804. var startPos = pos + (count + 1) * offsetSize - 1;
  19805. for (i = 0, ii = count + 1; i < ii; ++i) {
  19806. var offset = 0;
  19807. for (var j = 0; j < offsetSize; ++j) {
  19808. offset <<= 8;
  19809. offset += bytes[pos++];
  19810. }
  19811. offsets.push(startPos + offset);
  19812. }
  19813. end = offsets[count];
  19814. }
  19815. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  19816. var offsetStart = offsets[i];
  19817. var offsetEnd = offsets[i + 1];
  19818. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  19819. }
  19820. return {
  19821. obj: cffIndex,
  19822. endPos: end
  19823. };
  19824. },
  19825. parseNameIndex: function CFFParser_parseNameIndex(index) {
  19826. var names = [];
  19827. for (var i = 0, ii = index.count; i < ii; ++i) {
  19828. var name = index.get(i);
  19829. var length = Math.min(name.length, 127);
  19830. var data = [];
  19831. for (var j = 0; j < length; ++j) {
  19832. var c = name[j];
  19833. if (j === 0 && c === 0) {
  19834. data[j] = c;
  19835. continue;
  19836. }
  19837. if (c < 33 || c > 126 || c === 91 || c === 93 || c === 40 || c === 41 || c === 123 || c === 125 || c === 60 || c === 62 || c === 47 || c === 37 || c === 35) {
  19838. data[j] = 95;
  19839. continue;
  19840. }
  19841. data[j] = c;
  19842. }
  19843. names.push(bytesToString(data));
  19844. }
  19845. return names;
  19846. },
  19847. parseStringIndex: function CFFParser_parseStringIndex(index) {
  19848. var strings = new CFFStrings();
  19849. for (var i = 0, ii = index.count; i < ii; ++i) {
  19850. var data = index.get(i);
  19851. strings.add(bytesToString(data));
  19852. }
  19853. return strings;
  19854. },
  19855. createDict: function CFFParser_createDict(Type, dict, strings) {
  19856. var cffDict = new Type(strings);
  19857. for (var i = 0, ii = dict.length; i < ii; ++i) {
  19858. var pair = dict[i];
  19859. var key = pair[0];
  19860. var value = pair[1];
  19861. cffDict.setByKey(key, value);
  19862. }
  19863. return cffDict;
  19864. },
  19865. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  19866. if (state.callDepth > MAX_SUBR_NESTING) {
  19867. return false;
  19868. }
  19869. var stackSize = state.stackSize;
  19870. var stack = state.stack;
  19871. var length = data.length;
  19872. for (var j = 0; j < length;) {
  19873. var value = data[j++];
  19874. var validationCommand = null;
  19875. if (value === 12) {
  19876. var q = data[j++];
  19877. if (q === 0) {
  19878. data[j - 2] = 139;
  19879. data[j - 1] = 22;
  19880. stackSize = 0;
  19881. } else {
  19882. validationCommand = CharstringValidationData12[q];
  19883. }
  19884. } else if (value === 28) {
  19885. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  19886. j += 2;
  19887. stackSize++;
  19888. } else if (value === 14) {
  19889. if (stackSize >= 4) {
  19890. stackSize -= 4;
  19891. if (this.seacAnalysisEnabled) {
  19892. state.seac = stack.slice(stackSize, stackSize + 4);
  19893. return false;
  19894. }
  19895. }
  19896. validationCommand = CharstringValidationData[value];
  19897. } else if (value >= 32 && value <= 246) {
  19898. stack[stackSize] = value - 139;
  19899. stackSize++;
  19900. } else if (value >= 247 && value <= 254) {
  19901. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  19902. j++;
  19903. stackSize++;
  19904. } else if (value === 255) {
  19905. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  19906. j += 4;
  19907. stackSize++;
  19908. } else if (value === 19 || value === 20) {
  19909. state.hints += stackSize >> 1;
  19910. j += state.hints + 7 >> 3;
  19911. stackSize %= 2;
  19912. validationCommand = CharstringValidationData[value];
  19913. } else if (value === 10 || value === 29) {
  19914. var subrsIndex;
  19915. if (value === 10) {
  19916. subrsIndex = localSubrIndex;
  19917. } else {
  19918. subrsIndex = globalSubrIndex;
  19919. }
  19920. if (!subrsIndex) {
  19921. validationCommand = CharstringValidationData[value];
  19922. warn('Missing subrsIndex for ' + validationCommand.id);
  19923. return false;
  19924. }
  19925. var bias = 32768;
  19926. if (subrsIndex.count < 1240) {
  19927. bias = 107;
  19928. } else if (subrsIndex.count < 33900) {
  19929. bias = 1131;
  19930. }
  19931. var subrNumber = stack[--stackSize] + bias;
  19932. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  19933. validationCommand = CharstringValidationData[value];
  19934. warn('Out of bounds subrIndex for ' + validationCommand.id);
  19935. return false;
  19936. }
  19937. state.stackSize = stackSize;
  19938. state.callDepth++;
  19939. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  19940. if (!valid) {
  19941. return false;
  19942. }
  19943. state.callDepth--;
  19944. stackSize = state.stackSize;
  19945. continue;
  19946. } else if (value === 11) {
  19947. state.stackSize = stackSize;
  19948. return true;
  19949. } else {
  19950. validationCommand = CharstringValidationData[value];
  19951. }
  19952. if (validationCommand) {
  19953. if (validationCommand.stem) {
  19954. state.hints += stackSize >> 1;
  19955. }
  19956. if ('min' in validationCommand) {
  19957. if (!state.undefStack && stackSize < validationCommand.min) {
  19958. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  19959. return false;
  19960. }
  19961. }
  19962. if (state.firstStackClearing && validationCommand.stackClearing) {
  19963. state.firstStackClearing = false;
  19964. stackSize -= validationCommand.min;
  19965. if (stackSize >= 2 && validationCommand.stem) {
  19966. stackSize %= 2;
  19967. } else if (stackSize > 1) {
  19968. warn('Found too many parameters for stack-clearing command');
  19969. }
  19970. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  19971. state.width = stack[stackSize - 1];
  19972. }
  19973. }
  19974. if ('stackDelta' in validationCommand) {
  19975. if ('stackFn' in validationCommand) {
  19976. validationCommand.stackFn(stack, stackSize);
  19977. }
  19978. stackSize += validationCommand.stackDelta;
  19979. } else if (validationCommand.stackClearing) {
  19980. stackSize = 0;
  19981. } else if (validationCommand.resetStack) {
  19982. stackSize = 0;
  19983. state.undefStack = false;
  19984. } else if (validationCommand.undefStack) {
  19985. stackSize = 0;
  19986. state.undefStack = true;
  19987. state.firstStackClearing = false;
  19988. }
  19989. }
  19990. }
  19991. state.stackSize = stackSize;
  19992. return true;
  19993. },
  19994. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  19995. var seacs = [];
  19996. var widths = [];
  19997. var count = charStrings.count;
  19998. for (var i = 0; i < count; i++) {
  19999. var charstring = charStrings.get(i);
  20000. var state = {
  20001. callDepth: 0,
  20002. stackSize: 0,
  20003. stack: [],
  20004. undefStack: true,
  20005. hints: 0,
  20006. firstStackClearing: true,
  20007. seac: null,
  20008. width: null
  20009. };
  20010. var valid = true;
  20011. var localSubrToUse = null;
  20012. if (fdSelect && fdArray.length) {
  20013. var fdIndex = fdSelect.getFDIndex(i);
  20014. if (fdIndex === -1) {
  20015. warn('Glyph index is not in fd select.');
  20016. valid = false;
  20017. }
  20018. if (fdIndex >= fdArray.length) {
  20019. warn('Invalid fd index for glyph index.');
  20020. valid = false;
  20021. }
  20022. if (valid) {
  20023. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  20024. }
  20025. } else if (localSubrIndex) {
  20026. localSubrToUse = localSubrIndex;
  20027. }
  20028. if (valid) {
  20029. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  20030. }
  20031. if (state.width !== null) {
  20032. widths[i] = state.width;
  20033. }
  20034. if (state.seac !== null) {
  20035. seacs[i] = state.seac;
  20036. }
  20037. if (!valid) {
  20038. charStrings.set(i, new Uint8Array([14]));
  20039. }
  20040. }
  20041. return {
  20042. charStrings: charStrings,
  20043. seacs: seacs,
  20044. widths: widths
  20045. };
  20046. },
  20047. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  20048. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  20049. parentDict.setByKey(18, [
  20050. 0,
  20051. 0
  20052. ]);
  20053. parentDict.privateDict = privateDict;
  20054. },
  20055. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  20056. if (!parentDict.hasName('Private')) {
  20057. this.emptyPrivateDictionary(parentDict);
  20058. return;
  20059. }
  20060. var privateOffset = parentDict.getByName('Private');
  20061. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  20062. parentDict.removeByName('Private');
  20063. return;
  20064. }
  20065. var size = privateOffset[0];
  20066. var offset = privateOffset[1];
  20067. if (size === 0 || offset >= this.bytes.length) {
  20068. this.emptyPrivateDictionary(parentDict);
  20069. return;
  20070. }
  20071. var privateDictEnd = offset + size;
  20072. var dictData = this.bytes.subarray(offset, privateDictEnd);
  20073. var dict = this.parseDict(dictData);
  20074. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  20075. parentDict.privateDict = privateDict;
  20076. if (!privateDict.getByName('Subrs')) {
  20077. return;
  20078. }
  20079. var subrsOffset = privateDict.getByName('Subrs');
  20080. var relativeOffset = offset + subrsOffset;
  20081. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  20082. this.emptyPrivateDictionary(parentDict);
  20083. return;
  20084. }
  20085. var subrsIndex = this.parseIndex(relativeOffset);
  20086. privateDict.subrsIndex = subrsIndex.obj;
  20087. },
  20088. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  20089. if (pos === 0) {
  20090. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  20091. } else if (pos === 1) {
  20092. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  20093. } else if (pos === 2) {
  20094. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  20095. }
  20096. var bytes = this.bytes;
  20097. var start = pos;
  20098. var format = bytes[pos++];
  20099. var charset = ['.notdef'];
  20100. var id, count, i;
  20101. length -= 1;
  20102. switch (format) {
  20103. case 0:
  20104. for (i = 0; i < length; i++) {
  20105. id = bytes[pos++] << 8 | bytes[pos++];
  20106. charset.push(cid ? id : strings.get(id));
  20107. }
  20108. break;
  20109. case 1:
  20110. while (charset.length <= length) {
  20111. id = bytes[pos++] << 8 | bytes[pos++];
  20112. count = bytes[pos++];
  20113. for (i = 0; i <= count; i++) {
  20114. charset.push(cid ? id++ : strings.get(id++));
  20115. }
  20116. }
  20117. break;
  20118. case 2:
  20119. while (charset.length <= length) {
  20120. id = bytes[pos++] << 8 | bytes[pos++];
  20121. count = bytes[pos++] << 8 | bytes[pos++];
  20122. for (i = 0; i <= count; i++) {
  20123. charset.push(cid ? id++ : strings.get(id++));
  20124. }
  20125. }
  20126. break;
  20127. default:
  20128. error('Unknown charset format');
  20129. }
  20130. var end = pos;
  20131. var raw = bytes.subarray(start, end);
  20132. return new CFFCharset(false, format, charset, raw);
  20133. },
  20134. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  20135. var encoding = Object.create(null);
  20136. var bytes = this.bytes;
  20137. var predefined = false;
  20138. var format, i, ii;
  20139. var raw = null;
  20140. function readSupplement() {
  20141. var supplementsCount = bytes[pos++];
  20142. for (i = 0; i < supplementsCount; i++) {
  20143. var code = bytes[pos++];
  20144. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  20145. encoding[code] = charset.indexOf(strings.get(sid));
  20146. }
  20147. }
  20148. if (pos === 0 || pos === 1) {
  20149. predefined = true;
  20150. format = pos;
  20151. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  20152. for (i = 0, ii = charset.length; i < ii; i++) {
  20153. var index = baseEncoding.indexOf(charset[i]);
  20154. if (index !== -1) {
  20155. encoding[index] = i;
  20156. }
  20157. }
  20158. } else {
  20159. var dataStart = pos;
  20160. format = bytes[pos++];
  20161. switch (format & 0x7f) {
  20162. case 0:
  20163. var glyphsCount = bytes[pos++];
  20164. for (i = 1; i <= glyphsCount; i++) {
  20165. encoding[bytes[pos++]] = i;
  20166. }
  20167. break;
  20168. case 1:
  20169. var rangesCount = bytes[pos++];
  20170. var gid = 1;
  20171. for (i = 0; i < rangesCount; i++) {
  20172. var start = bytes[pos++];
  20173. var left = bytes[pos++];
  20174. for (var j = start; j <= start + left; j++) {
  20175. encoding[j] = gid++;
  20176. }
  20177. }
  20178. break;
  20179. default:
  20180. error('Unknown encoding format: ' + format + ' in CFF');
  20181. break;
  20182. }
  20183. var dataEnd = pos;
  20184. if (format & 0x80) {
  20185. bytes[dataStart] &= 0x7f;
  20186. readSupplement();
  20187. }
  20188. raw = bytes.subarray(dataStart, dataEnd);
  20189. }
  20190. format = format & 0x7f;
  20191. return new CFFEncoding(predefined, format, encoding, raw);
  20192. },
  20193. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  20194. var start = pos;
  20195. var bytes = this.bytes;
  20196. var format = bytes[pos++];
  20197. var fdSelect = [], rawBytes;
  20198. var i, invalidFirstGID = false;
  20199. switch (format) {
  20200. case 0:
  20201. for (i = 0; i < length; ++i) {
  20202. var id = bytes[pos++];
  20203. fdSelect.push(id);
  20204. }
  20205. rawBytes = bytes.subarray(start, pos);
  20206. break;
  20207. case 3:
  20208. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  20209. for (i = 0; i < rangesCount; ++i) {
  20210. var first = bytes[pos++] << 8 | bytes[pos++];
  20211. if (i === 0 && first !== 0) {
  20212. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  20213. invalidFirstGID = true;
  20214. first = 0;
  20215. }
  20216. var fdIndex = bytes[pos++];
  20217. var next = bytes[pos] << 8 | bytes[pos + 1];
  20218. for (var j = first; j < next; ++j) {
  20219. fdSelect.push(fdIndex);
  20220. }
  20221. }
  20222. pos += 2;
  20223. rawBytes = bytes.subarray(start, pos);
  20224. if (invalidFirstGID) {
  20225. rawBytes[3] = rawBytes[4] = 0;
  20226. }
  20227. break;
  20228. default:
  20229. error('parseFDSelect: Unknown format "' + format + '".');
  20230. break;
  20231. }
  20232. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  20233. return new CFFFDSelect(fdSelect, rawBytes);
  20234. }
  20235. };
  20236. return CFFParser;
  20237. }();
  20238. var CFF = function CFFClosure() {
  20239. function CFF() {
  20240. this.header = null;
  20241. this.names = [];
  20242. this.topDict = null;
  20243. this.strings = new CFFStrings();
  20244. this.globalSubrIndex = null;
  20245. this.encoding = null;
  20246. this.charset = null;
  20247. this.charStrings = null;
  20248. this.fdArray = [];
  20249. this.fdSelect = null;
  20250. this.isCIDFont = false;
  20251. }
  20252. return CFF;
  20253. }();
  20254. var CFFHeader = function CFFHeaderClosure() {
  20255. function CFFHeader(major, minor, hdrSize, offSize) {
  20256. this.major = major;
  20257. this.minor = minor;
  20258. this.hdrSize = hdrSize;
  20259. this.offSize = offSize;
  20260. }
  20261. return CFFHeader;
  20262. }();
  20263. var CFFStrings = function CFFStringsClosure() {
  20264. function CFFStrings() {
  20265. this.strings = [];
  20266. }
  20267. CFFStrings.prototype = {
  20268. get: function CFFStrings_get(index) {
  20269. if (index >= 0 && index <= 390) {
  20270. return CFFStandardStrings[index];
  20271. }
  20272. if (index - 391 <= this.strings.length) {
  20273. return this.strings[index - 391];
  20274. }
  20275. return CFFStandardStrings[0];
  20276. },
  20277. add: function CFFStrings_add(value) {
  20278. this.strings.push(value);
  20279. },
  20280. get count() {
  20281. return this.strings.length;
  20282. }
  20283. };
  20284. return CFFStrings;
  20285. }();
  20286. var CFFIndex = function CFFIndexClosure() {
  20287. function CFFIndex() {
  20288. this.objects = [];
  20289. this.length = 0;
  20290. }
  20291. CFFIndex.prototype = {
  20292. add: function CFFIndex_add(data) {
  20293. this.length += data.length;
  20294. this.objects.push(data);
  20295. },
  20296. set: function CFFIndex_set(index, data) {
  20297. this.length += data.length - this.objects[index].length;
  20298. this.objects[index] = data;
  20299. },
  20300. get: function CFFIndex_get(index) {
  20301. return this.objects[index];
  20302. },
  20303. get count() {
  20304. return this.objects.length;
  20305. }
  20306. };
  20307. return CFFIndex;
  20308. }();
  20309. var CFFDict = function CFFDictClosure() {
  20310. function CFFDict(tables, strings) {
  20311. this.keyToNameMap = tables.keyToNameMap;
  20312. this.nameToKeyMap = tables.nameToKeyMap;
  20313. this.defaults = tables.defaults;
  20314. this.types = tables.types;
  20315. this.opcodes = tables.opcodes;
  20316. this.order = tables.order;
  20317. this.strings = strings;
  20318. this.values = Object.create(null);
  20319. }
  20320. CFFDict.prototype = {
  20321. setByKey: function CFFDict_setByKey(key, value) {
  20322. if (!(key in this.keyToNameMap)) {
  20323. return false;
  20324. }
  20325. var valueLength = value.length;
  20326. if (valueLength === 0) {
  20327. return true;
  20328. }
  20329. for (var i = 0; i < valueLength; i++) {
  20330. if (isNaN(value[i])) {
  20331. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  20332. return true;
  20333. }
  20334. }
  20335. var type = this.types[key];
  20336. if (type === 'num' || type === 'sid' || type === 'offset') {
  20337. value = value[0];
  20338. }
  20339. this.values[key] = value;
  20340. return true;
  20341. },
  20342. setByName: function CFFDict_setByName(name, value) {
  20343. if (!(name in this.nameToKeyMap)) {
  20344. error('Invalid dictionary name "' + name + '"');
  20345. }
  20346. this.values[this.nameToKeyMap[name]] = value;
  20347. },
  20348. hasName: function CFFDict_hasName(name) {
  20349. return this.nameToKeyMap[name] in this.values;
  20350. },
  20351. getByName: function CFFDict_getByName(name) {
  20352. if (!(name in this.nameToKeyMap)) {
  20353. error('Invalid dictionary name "' + name + '"');
  20354. }
  20355. var key = this.nameToKeyMap[name];
  20356. if (!(key in this.values)) {
  20357. return this.defaults[key];
  20358. }
  20359. return this.values[key];
  20360. },
  20361. removeByName: function CFFDict_removeByName(name) {
  20362. delete this.values[this.nameToKeyMap[name]];
  20363. }
  20364. };
  20365. CFFDict.createTables = function CFFDict_createTables(layout) {
  20366. var tables = {
  20367. keyToNameMap: {},
  20368. nameToKeyMap: {},
  20369. defaults: {},
  20370. types: {},
  20371. opcodes: {},
  20372. order: []
  20373. };
  20374. for (var i = 0, ii = layout.length; i < ii; ++i) {
  20375. var entry = layout[i];
  20376. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  20377. tables.keyToNameMap[key] = entry[1];
  20378. tables.nameToKeyMap[entry[1]] = key;
  20379. tables.types[key] = entry[2];
  20380. tables.defaults[key] = entry[3];
  20381. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  20382. tables.order.push(key);
  20383. }
  20384. return tables;
  20385. };
  20386. return CFFDict;
  20387. }();
  20388. var CFFTopDict = function CFFTopDictClosure() {
  20389. var layout = [
  20390. [
  20391. [
  20392. 12,
  20393. 30
  20394. ],
  20395. 'ROS',
  20396. [
  20397. 'sid',
  20398. 'sid',
  20399. 'num'
  20400. ],
  20401. null
  20402. ],
  20403. [
  20404. [
  20405. 12,
  20406. 20
  20407. ],
  20408. 'SyntheticBase',
  20409. 'num',
  20410. null
  20411. ],
  20412. [
  20413. 0,
  20414. 'version',
  20415. 'sid',
  20416. null
  20417. ],
  20418. [
  20419. 1,
  20420. 'Notice',
  20421. 'sid',
  20422. null
  20423. ],
  20424. [
  20425. [
  20426. 12,
  20427. 0
  20428. ],
  20429. 'Copyright',
  20430. 'sid',
  20431. null
  20432. ],
  20433. [
  20434. 2,
  20435. 'FullName',
  20436. 'sid',
  20437. null
  20438. ],
  20439. [
  20440. 3,
  20441. 'FamilyName',
  20442. 'sid',
  20443. null
  20444. ],
  20445. [
  20446. 4,
  20447. 'Weight',
  20448. 'sid',
  20449. null
  20450. ],
  20451. [
  20452. [
  20453. 12,
  20454. 1
  20455. ],
  20456. 'isFixedPitch',
  20457. 'num',
  20458. 0
  20459. ],
  20460. [
  20461. [
  20462. 12,
  20463. 2
  20464. ],
  20465. 'ItalicAngle',
  20466. 'num',
  20467. 0
  20468. ],
  20469. [
  20470. [
  20471. 12,
  20472. 3
  20473. ],
  20474. 'UnderlinePosition',
  20475. 'num',
  20476. -100
  20477. ],
  20478. [
  20479. [
  20480. 12,
  20481. 4
  20482. ],
  20483. 'UnderlineThickness',
  20484. 'num',
  20485. 50
  20486. ],
  20487. [
  20488. [
  20489. 12,
  20490. 5
  20491. ],
  20492. 'PaintType',
  20493. 'num',
  20494. 0
  20495. ],
  20496. [
  20497. [
  20498. 12,
  20499. 6
  20500. ],
  20501. 'CharstringType',
  20502. 'num',
  20503. 2
  20504. ],
  20505. [
  20506. [
  20507. 12,
  20508. 7
  20509. ],
  20510. 'FontMatrix',
  20511. [
  20512. 'num',
  20513. 'num',
  20514. 'num',
  20515. 'num',
  20516. 'num',
  20517. 'num'
  20518. ],
  20519. [
  20520. 0.001,
  20521. 0,
  20522. 0,
  20523. 0.001,
  20524. 0,
  20525. 0
  20526. ]
  20527. ],
  20528. [
  20529. 13,
  20530. 'UniqueID',
  20531. 'num',
  20532. null
  20533. ],
  20534. [
  20535. 5,
  20536. 'FontBBox',
  20537. [
  20538. 'num',
  20539. 'num',
  20540. 'num',
  20541. 'num'
  20542. ],
  20543. [
  20544. 0,
  20545. 0,
  20546. 0,
  20547. 0
  20548. ]
  20549. ],
  20550. [
  20551. [
  20552. 12,
  20553. 8
  20554. ],
  20555. 'StrokeWidth',
  20556. 'num',
  20557. 0
  20558. ],
  20559. [
  20560. 14,
  20561. 'XUID',
  20562. 'array',
  20563. null
  20564. ],
  20565. [
  20566. 15,
  20567. 'charset',
  20568. 'offset',
  20569. 0
  20570. ],
  20571. [
  20572. 16,
  20573. 'Encoding',
  20574. 'offset',
  20575. 0
  20576. ],
  20577. [
  20578. 17,
  20579. 'CharStrings',
  20580. 'offset',
  20581. 0
  20582. ],
  20583. [
  20584. 18,
  20585. 'Private',
  20586. [
  20587. 'offset',
  20588. 'offset'
  20589. ],
  20590. null
  20591. ],
  20592. [
  20593. [
  20594. 12,
  20595. 21
  20596. ],
  20597. 'PostScript',
  20598. 'sid',
  20599. null
  20600. ],
  20601. [
  20602. [
  20603. 12,
  20604. 22
  20605. ],
  20606. 'BaseFontName',
  20607. 'sid',
  20608. null
  20609. ],
  20610. [
  20611. [
  20612. 12,
  20613. 23
  20614. ],
  20615. 'BaseFontBlend',
  20616. 'delta',
  20617. null
  20618. ],
  20619. [
  20620. [
  20621. 12,
  20622. 31
  20623. ],
  20624. 'CIDFontVersion',
  20625. 'num',
  20626. 0
  20627. ],
  20628. [
  20629. [
  20630. 12,
  20631. 32
  20632. ],
  20633. 'CIDFontRevision',
  20634. 'num',
  20635. 0
  20636. ],
  20637. [
  20638. [
  20639. 12,
  20640. 33
  20641. ],
  20642. 'CIDFontType',
  20643. 'num',
  20644. 0
  20645. ],
  20646. [
  20647. [
  20648. 12,
  20649. 34
  20650. ],
  20651. 'CIDCount',
  20652. 'num',
  20653. 8720
  20654. ],
  20655. [
  20656. [
  20657. 12,
  20658. 35
  20659. ],
  20660. 'UIDBase',
  20661. 'num',
  20662. null
  20663. ],
  20664. [
  20665. [
  20666. 12,
  20667. 37
  20668. ],
  20669. 'FDSelect',
  20670. 'offset',
  20671. null
  20672. ],
  20673. [
  20674. [
  20675. 12,
  20676. 36
  20677. ],
  20678. 'FDArray',
  20679. 'offset',
  20680. null
  20681. ],
  20682. [
  20683. [
  20684. 12,
  20685. 38
  20686. ],
  20687. 'FontName',
  20688. 'sid',
  20689. null
  20690. ]
  20691. ];
  20692. var tables = null;
  20693. function CFFTopDict(strings) {
  20694. if (tables === null) {
  20695. tables = CFFDict.createTables(layout);
  20696. }
  20697. CFFDict.call(this, tables, strings);
  20698. this.privateDict = null;
  20699. }
  20700. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  20701. return CFFTopDict;
  20702. }();
  20703. var CFFPrivateDict = function CFFPrivateDictClosure() {
  20704. var layout = [
  20705. [
  20706. 6,
  20707. 'BlueValues',
  20708. 'delta',
  20709. null
  20710. ],
  20711. [
  20712. 7,
  20713. 'OtherBlues',
  20714. 'delta',
  20715. null
  20716. ],
  20717. [
  20718. 8,
  20719. 'FamilyBlues',
  20720. 'delta',
  20721. null
  20722. ],
  20723. [
  20724. 9,
  20725. 'FamilyOtherBlues',
  20726. 'delta',
  20727. null
  20728. ],
  20729. [
  20730. [
  20731. 12,
  20732. 9
  20733. ],
  20734. 'BlueScale',
  20735. 'num',
  20736. 0.039625
  20737. ],
  20738. [
  20739. [
  20740. 12,
  20741. 10
  20742. ],
  20743. 'BlueShift',
  20744. 'num',
  20745. 7
  20746. ],
  20747. [
  20748. [
  20749. 12,
  20750. 11
  20751. ],
  20752. 'BlueFuzz',
  20753. 'num',
  20754. 1
  20755. ],
  20756. [
  20757. 10,
  20758. 'StdHW',
  20759. 'num',
  20760. null
  20761. ],
  20762. [
  20763. 11,
  20764. 'StdVW',
  20765. 'num',
  20766. null
  20767. ],
  20768. [
  20769. [
  20770. 12,
  20771. 12
  20772. ],
  20773. 'StemSnapH',
  20774. 'delta',
  20775. null
  20776. ],
  20777. [
  20778. [
  20779. 12,
  20780. 13
  20781. ],
  20782. 'StemSnapV',
  20783. 'delta',
  20784. null
  20785. ],
  20786. [
  20787. [
  20788. 12,
  20789. 14
  20790. ],
  20791. 'ForceBold',
  20792. 'num',
  20793. 0
  20794. ],
  20795. [
  20796. [
  20797. 12,
  20798. 17
  20799. ],
  20800. 'LanguageGroup',
  20801. 'num',
  20802. 0
  20803. ],
  20804. [
  20805. [
  20806. 12,
  20807. 18
  20808. ],
  20809. 'ExpansionFactor',
  20810. 'num',
  20811. 0.06
  20812. ],
  20813. [
  20814. [
  20815. 12,
  20816. 19
  20817. ],
  20818. 'initialRandomSeed',
  20819. 'num',
  20820. 0
  20821. ],
  20822. [
  20823. 20,
  20824. 'defaultWidthX',
  20825. 'num',
  20826. 0
  20827. ],
  20828. [
  20829. 21,
  20830. 'nominalWidthX',
  20831. 'num',
  20832. 0
  20833. ],
  20834. [
  20835. 19,
  20836. 'Subrs',
  20837. 'offset',
  20838. null
  20839. ]
  20840. ];
  20841. var tables = null;
  20842. function CFFPrivateDict(strings) {
  20843. if (tables === null) {
  20844. tables = CFFDict.createTables(layout);
  20845. }
  20846. CFFDict.call(this, tables, strings);
  20847. this.subrsIndex = null;
  20848. }
  20849. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  20850. return CFFPrivateDict;
  20851. }();
  20852. var CFFCharsetPredefinedTypes = {
  20853. ISO_ADOBE: 0,
  20854. EXPERT: 1,
  20855. EXPERT_SUBSET: 2
  20856. };
  20857. var CFFCharset = function CFFCharsetClosure() {
  20858. function CFFCharset(predefined, format, charset, raw) {
  20859. this.predefined = predefined;
  20860. this.format = format;
  20861. this.charset = charset;
  20862. this.raw = raw;
  20863. }
  20864. return CFFCharset;
  20865. }();
  20866. var CFFEncoding = function CFFEncodingClosure() {
  20867. function CFFEncoding(predefined, format, encoding, raw) {
  20868. this.predefined = predefined;
  20869. this.format = format;
  20870. this.encoding = encoding;
  20871. this.raw = raw;
  20872. }
  20873. return CFFEncoding;
  20874. }();
  20875. var CFFFDSelect = function CFFFDSelectClosure() {
  20876. function CFFFDSelect(fdSelect, raw) {
  20877. this.fdSelect = fdSelect;
  20878. this.raw = raw;
  20879. }
  20880. CFFFDSelect.prototype = {
  20881. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  20882. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  20883. return -1;
  20884. }
  20885. return this.fdSelect[glyphIndex];
  20886. }
  20887. };
  20888. return CFFFDSelect;
  20889. }();
  20890. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  20891. function CFFOffsetTracker() {
  20892. this.offsets = Object.create(null);
  20893. }
  20894. CFFOffsetTracker.prototype = {
  20895. isTracking: function CFFOffsetTracker_isTracking(key) {
  20896. return key in this.offsets;
  20897. },
  20898. track: function CFFOffsetTracker_track(key, location) {
  20899. if (key in this.offsets) {
  20900. error('Already tracking location of ' + key);
  20901. }
  20902. this.offsets[key] = location;
  20903. },
  20904. offset: function CFFOffsetTracker_offset(value) {
  20905. for (var key in this.offsets) {
  20906. this.offsets[key] += value;
  20907. }
  20908. },
  20909. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  20910. if (!(key in this.offsets)) {
  20911. error('Not tracking location of ' + key);
  20912. }
  20913. var data = output.data;
  20914. var dataOffset = this.offsets[key];
  20915. var size = 5;
  20916. for (var i = 0, ii = values.length; i < ii; ++i) {
  20917. var offset0 = i * size + dataOffset;
  20918. var offset1 = offset0 + 1;
  20919. var offset2 = offset0 + 2;
  20920. var offset3 = offset0 + 3;
  20921. var offset4 = offset0 + 4;
  20922. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  20923. error('writing to an offset that is not empty');
  20924. }
  20925. var value = values[i];
  20926. data[offset0] = 0x1d;
  20927. data[offset1] = value >> 24 & 0xFF;
  20928. data[offset2] = value >> 16 & 0xFF;
  20929. data[offset3] = value >> 8 & 0xFF;
  20930. data[offset4] = value & 0xFF;
  20931. }
  20932. }
  20933. };
  20934. return CFFOffsetTracker;
  20935. }();
  20936. var CFFCompiler = function CFFCompilerClosure() {
  20937. function CFFCompiler(cff) {
  20938. this.cff = cff;
  20939. }
  20940. CFFCompiler.prototype = {
  20941. compile: function CFFCompiler_compile() {
  20942. var cff = this.cff;
  20943. var output = {
  20944. data: [],
  20945. length: 0,
  20946. add: function CFFCompiler_add(data) {
  20947. this.data = this.data.concat(data);
  20948. this.length = this.data.length;
  20949. }
  20950. };
  20951. var header = this.compileHeader(cff.header);
  20952. output.add(header);
  20953. var nameIndex = this.compileNameIndex(cff.names);
  20954. output.add(nameIndex);
  20955. if (cff.isCIDFont) {
  20956. if (cff.topDict.hasName('FontMatrix')) {
  20957. var base = cff.topDict.getByName('FontMatrix');
  20958. cff.topDict.removeByName('FontMatrix');
  20959. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  20960. var subDict = cff.fdArray[i];
  20961. var matrix = base.slice(0);
  20962. if (subDict.hasName('FontMatrix')) {
  20963. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  20964. }
  20965. subDict.setByName('FontMatrix', matrix);
  20966. }
  20967. }
  20968. }
  20969. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  20970. output.add(compiled.output);
  20971. var topDictTracker = compiled.trackers[0];
  20972. var stringIndex = this.compileStringIndex(cff.strings.strings);
  20973. output.add(stringIndex);
  20974. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  20975. output.add(globalSubrIndex);
  20976. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  20977. if (cff.encoding.predefined) {
  20978. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  20979. } else {
  20980. var encoding = this.compileEncoding(cff.encoding);
  20981. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  20982. output.add(encoding);
  20983. }
  20984. }
  20985. if (cff.charset && cff.topDict.hasName('charset')) {
  20986. if (cff.charset.predefined) {
  20987. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  20988. } else {
  20989. var charset = this.compileCharset(cff.charset);
  20990. topDictTracker.setEntryLocation('charset', [output.length], output);
  20991. output.add(charset);
  20992. }
  20993. }
  20994. var charStrings = this.compileCharStrings(cff.charStrings);
  20995. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  20996. output.add(charStrings);
  20997. if (cff.isCIDFont) {
  20998. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  20999. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  21000. output.add(fdSelect);
  21001. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  21002. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  21003. output.add(compiled.output);
  21004. var fontDictTrackers = compiled.trackers;
  21005. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  21006. }
  21007. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  21008. output.add([0]);
  21009. return output.data;
  21010. },
  21011. encodeNumber: function CFFCompiler_encodeNumber(value) {
  21012. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  21013. return this.encodeInteger(value);
  21014. }
  21015. return this.encodeFloat(value);
  21016. },
  21017. encodeFloat: function CFFCompiler_encodeFloat(num) {
  21018. var value = num.toString();
  21019. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  21020. if (m) {
  21021. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  21022. value = (Math.round(num * epsilon) / epsilon).toString();
  21023. }
  21024. var nibbles = '';
  21025. var i, ii;
  21026. for (i = 0, ii = value.length; i < ii; ++i) {
  21027. var a = value[i];
  21028. if (a === 'e') {
  21029. nibbles += value[++i] === '-' ? 'c' : 'b';
  21030. } else if (a === '.') {
  21031. nibbles += 'a';
  21032. } else if (a === '-') {
  21033. nibbles += 'e';
  21034. } else {
  21035. nibbles += a;
  21036. }
  21037. }
  21038. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  21039. var out = [30];
  21040. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  21041. out.push(parseInt(nibbles.substr(i, 2), 16));
  21042. }
  21043. return out;
  21044. },
  21045. encodeInteger: function CFFCompiler_encodeInteger(value) {
  21046. var code;
  21047. if (value >= -107 && value <= 107) {
  21048. code = [value + 139];
  21049. } else if (value >= 108 && value <= 1131) {
  21050. value = value - 108;
  21051. code = [
  21052. (value >> 8) + 247,
  21053. value & 0xFF
  21054. ];
  21055. } else if (value >= -1131 && value <= -108) {
  21056. value = -value - 108;
  21057. code = [
  21058. (value >> 8) + 251,
  21059. value & 0xFF
  21060. ];
  21061. } else if (value >= -32768 && value <= 32767) {
  21062. code = [
  21063. 0x1c,
  21064. value >> 8 & 0xFF,
  21065. value & 0xFF
  21066. ];
  21067. } else {
  21068. code = [
  21069. 0x1d,
  21070. value >> 24 & 0xFF,
  21071. value >> 16 & 0xFF,
  21072. value >> 8 & 0xFF,
  21073. value & 0xFF
  21074. ];
  21075. }
  21076. return code;
  21077. },
  21078. compileHeader: function CFFCompiler_compileHeader(header) {
  21079. return [
  21080. header.major,
  21081. header.minor,
  21082. header.hdrSize,
  21083. header.offSize
  21084. ];
  21085. },
  21086. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  21087. var nameIndex = new CFFIndex();
  21088. for (var i = 0, ii = names.length; i < ii; ++i) {
  21089. nameIndex.add(stringToBytes(names[i]));
  21090. }
  21091. return this.compileIndex(nameIndex);
  21092. },
  21093. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  21094. var fontDictTrackers = [];
  21095. var fdArrayIndex = new CFFIndex();
  21096. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  21097. var fontDict = dicts[i];
  21098. if (removeCidKeys) {
  21099. fontDict.removeByName('CIDFontVersion');
  21100. fontDict.removeByName('CIDFontRevision');
  21101. fontDict.removeByName('CIDFontType');
  21102. fontDict.removeByName('CIDCount');
  21103. fontDict.removeByName('UIDBase');
  21104. }
  21105. var fontDictTracker = new CFFOffsetTracker();
  21106. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  21107. fontDictTrackers.push(fontDictTracker);
  21108. fdArrayIndex.add(fontDictData);
  21109. fontDictTracker.offset(length);
  21110. }
  21111. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  21112. return {
  21113. trackers: fontDictTrackers,
  21114. output: fdArrayIndex
  21115. };
  21116. },
  21117. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  21118. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  21119. var fontDict = dicts[i];
  21120. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  21121. var privateDict = fontDict.privateDict;
  21122. var privateDictTracker = new CFFOffsetTracker();
  21123. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  21124. var outputLength = output.length;
  21125. privateDictTracker.offset(outputLength);
  21126. if (!privateDictData.length) {
  21127. outputLength = 0;
  21128. }
  21129. trackers[i].setEntryLocation('Private', [
  21130. privateDictData.length,
  21131. outputLength
  21132. ], output);
  21133. output.add(privateDictData);
  21134. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  21135. var subrs = this.compileIndex(privateDict.subrsIndex);
  21136. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  21137. output.add(subrs);
  21138. }
  21139. }
  21140. },
  21141. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  21142. var out = [];
  21143. var order = dict.order;
  21144. for (var i = 0; i < order.length; ++i) {
  21145. var key = order[i];
  21146. if (!(key in dict.values)) {
  21147. continue;
  21148. }
  21149. var values = dict.values[key];
  21150. var types = dict.types[key];
  21151. if (!isArray(types)) {
  21152. types = [types];
  21153. }
  21154. if (!isArray(values)) {
  21155. values = [values];
  21156. }
  21157. if (values.length === 0) {
  21158. continue;
  21159. }
  21160. for (var j = 0, jj = types.length; j < jj; ++j) {
  21161. var type = types[j];
  21162. var value = values[j];
  21163. switch (type) {
  21164. case 'num':
  21165. case 'sid':
  21166. out = out.concat(this.encodeNumber(value));
  21167. break;
  21168. case 'offset':
  21169. var name = dict.keyToNameMap[key];
  21170. if (!offsetTracker.isTracking(name)) {
  21171. offsetTracker.track(name, out.length);
  21172. }
  21173. out = out.concat([
  21174. 0x1d,
  21175. 0,
  21176. 0,
  21177. 0,
  21178. 0
  21179. ]);
  21180. break;
  21181. case 'array':
  21182. case 'delta':
  21183. out = out.concat(this.encodeNumber(value));
  21184. for (var k = 1, kk = values.length; k < kk; ++k) {
  21185. out = out.concat(this.encodeNumber(values[k]));
  21186. }
  21187. break;
  21188. default:
  21189. error('Unknown data type of ' + type);
  21190. break;
  21191. }
  21192. }
  21193. out = out.concat(dict.opcodes[key]);
  21194. }
  21195. return out;
  21196. },
  21197. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  21198. var stringIndex = new CFFIndex();
  21199. for (var i = 0, ii = strings.length; i < ii; ++i) {
  21200. stringIndex.add(stringToBytes(strings[i]));
  21201. }
  21202. return this.compileIndex(stringIndex);
  21203. },
  21204. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  21205. var globalSubrIndex = this.cff.globalSubrIndex;
  21206. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  21207. },
  21208. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  21209. return this.compileIndex(charStrings);
  21210. },
  21211. compileCharset: function CFFCompiler_compileCharset(charset) {
  21212. return this.compileTypedArray(charset.raw);
  21213. },
  21214. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  21215. return this.compileTypedArray(encoding.raw);
  21216. },
  21217. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  21218. return this.compileTypedArray(fdSelect);
  21219. },
  21220. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  21221. var out = [];
  21222. for (var i = 0, ii = data.length; i < ii; ++i) {
  21223. out[i] = data[i];
  21224. }
  21225. return out;
  21226. },
  21227. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  21228. trackers = trackers || [];
  21229. var objects = index.objects;
  21230. var count = objects.length;
  21231. if (count === 0) {
  21232. return [
  21233. 0,
  21234. 0,
  21235. 0
  21236. ];
  21237. }
  21238. var data = [
  21239. count >> 8 & 0xFF,
  21240. count & 0xff
  21241. ];
  21242. var lastOffset = 1, i;
  21243. for (i = 0; i < count; ++i) {
  21244. lastOffset += objects[i].length;
  21245. }
  21246. var offsetSize;
  21247. if (lastOffset < 0x100) {
  21248. offsetSize = 1;
  21249. } else if (lastOffset < 0x10000) {
  21250. offsetSize = 2;
  21251. } else if (lastOffset < 0x1000000) {
  21252. offsetSize = 3;
  21253. } else {
  21254. offsetSize = 4;
  21255. }
  21256. data.push(offsetSize);
  21257. var relativeOffset = 1;
  21258. for (i = 0; i < count + 1; i++) {
  21259. if (offsetSize === 1) {
  21260. data.push(relativeOffset & 0xFF);
  21261. } else if (offsetSize === 2) {
  21262. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  21263. } else if (offsetSize === 3) {
  21264. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  21265. } else {
  21266. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  21267. }
  21268. if (objects[i]) {
  21269. relativeOffset += objects[i].length;
  21270. }
  21271. }
  21272. for (i = 0; i < count; i++) {
  21273. if (trackers[i]) {
  21274. trackers[i].offset(data.length);
  21275. }
  21276. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  21277. data.push(objects[i][j]);
  21278. }
  21279. }
  21280. return data;
  21281. }
  21282. };
  21283. return CFFCompiler;
  21284. }();
  21285. exports.CFFStandardStrings = CFFStandardStrings;
  21286. exports.CFFParser = CFFParser;
  21287. exports.CFF = CFF;
  21288. exports.CFFHeader = CFFHeader;
  21289. exports.CFFStrings = CFFStrings;
  21290. exports.CFFIndex = CFFIndex;
  21291. exports.CFFCharset = CFFCharset;
  21292. exports.CFFTopDict = CFFTopDict;
  21293. exports.CFFPrivateDict = CFFPrivateDict;
  21294. exports.CFFCompiler = CFFCompiler;
  21295. /***/ }),
  21296. /* 12 */
  21297. /***/ (function(module, exports, __w_pdfjs_require__) {
  21298. "use strict";
  21299. var sharedUtil = __w_pdfjs_require__(0);
  21300. var MissingDataException = sharedUtil.MissingDataException;
  21301. var arrayByteLength = sharedUtil.arrayByteLength;
  21302. var arraysToBytes = sharedUtil.arraysToBytes;
  21303. var assert = sharedUtil.assert;
  21304. var createPromiseCapability = sharedUtil.createPromiseCapability;
  21305. var isInt = sharedUtil.isInt;
  21306. var isEmptyObj = sharedUtil.isEmptyObj;
  21307. var ChunkedStream = function ChunkedStreamClosure() {
  21308. function ChunkedStream(length, chunkSize, manager) {
  21309. this.bytes = new Uint8Array(length);
  21310. this.start = 0;
  21311. this.pos = 0;
  21312. this.end = length;
  21313. this.chunkSize = chunkSize;
  21314. this.loadedChunks = [];
  21315. this.numChunksLoaded = 0;
  21316. this.numChunks = Math.ceil(length / chunkSize);
  21317. this.manager = manager;
  21318. this.progressiveDataLength = 0;
  21319. this.lastSuccessfulEnsureByteChunk = -1;
  21320. }
  21321. ChunkedStream.prototype = {
  21322. getMissingChunks: function ChunkedStream_getMissingChunks() {
  21323. var chunks = [];
  21324. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  21325. if (!this.loadedChunks[chunk]) {
  21326. chunks.push(chunk);
  21327. }
  21328. }
  21329. return chunks;
  21330. },
  21331. getBaseStreams: function ChunkedStream_getBaseStreams() {
  21332. return [this];
  21333. },
  21334. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  21335. return this.numChunksLoaded === this.numChunks;
  21336. },
  21337. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  21338. var end = begin + chunk.byteLength;
  21339. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  21340. var length = this.bytes.length;
  21341. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  21342. this.bytes.set(new Uint8Array(chunk), begin);
  21343. var chunkSize = this.chunkSize;
  21344. var beginChunk = Math.floor(begin / chunkSize);
  21345. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  21346. var curChunk;
  21347. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  21348. if (!this.loadedChunks[curChunk]) {
  21349. this.loadedChunks[curChunk] = true;
  21350. ++this.numChunksLoaded;
  21351. }
  21352. }
  21353. },
  21354. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  21355. var position = this.progressiveDataLength;
  21356. var beginChunk = Math.floor(position / this.chunkSize);
  21357. this.bytes.set(new Uint8Array(data), position);
  21358. position += data.byteLength;
  21359. this.progressiveDataLength = position;
  21360. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  21361. var curChunk;
  21362. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  21363. if (!this.loadedChunks[curChunk]) {
  21364. this.loadedChunks[curChunk] = true;
  21365. ++this.numChunksLoaded;
  21366. }
  21367. }
  21368. },
  21369. ensureByte: function ChunkedStream_ensureByte(pos) {
  21370. var chunk = Math.floor(pos / this.chunkSize);
  21371. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  21372. return;
  21373. }
  21374. if (!this.loadedChunks[chunk]) {
  21375. throw new MissingDataException(pos, pos + 1);
  21376. }
  21377. this.lastSuccessfulEnsureByteChunk = chunk;
  21378. },
  21379. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  21380. if (begin >= end) {
  21381. return;
  21382. }
  21383. if (end <= this.progressiveDataLength) {
  21384. return;
  21385. }
  21386. var chunkSize = this.chunkSize;
  21387. var beginChunk = Math.floor(begin / chunkSize);
  21388. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  21389. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  21390. if (!this.loadedChunks[chunk]) {
  21391. throw new MissingDataException(begin, end);
  21392. }
  21393. }
  21394. },
  21395. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  21396. var chunk, numChunks = this.numChunks;
  21397. for (var i = 0; i < numChunks; ++i) {
  21398. chunk = (beginChunk + i) % numChunks;
  21399. if (!this.loadedChunks[chunk]) {
  21400. return chunk;
  21401. }
  21402. }
  21403. return null;
  21404. },
  21405. hasChunk: function ChunkedStream_hasChunk(chunk) {
  21406. return !!this.loadedChunks[chunk];
  21407. },
  21408. get length() {
  21409. return this.end - this.start;
  21410. },
  21411. get isEmpty() {
  21412. return this.length === 0;
  21413. },
  21414. getByte: function ChunkedStream_getByte() {
  21415. var pos = this.pos;
  21416. if (pos >= this.end) {
  21417. return -1;
  21418. }
  21419. this.ensureByte(pos);
  21420. return this.bytes[this.pos++];
  21421. },
  21422. getUint16: function ChunkedStream_getUint16() {
  21423. var b0 = this.getByte();
  21424. var b1 = this.getByte();
  21425. if (b0 === -1 || b1 === -1) {
  21426. return -1;
  21427. }
  21428. return (b0 << 8) + b1;
  21429. },
  21430. getInt32: function ChunkedStream_getInt32() {
  21431. var b0 = this.getByte();
  21432. var b1 = this.getByte();
  21433. var b2 = this.getByte();
  21434. var b3 = this.getByte();
  21435. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  21436. },
  21437. getBytes: function ChunkedStream_getBytes(length) {
  21438. var bytes = this.bytes;
  21439. var pos = this.pos;
  21440. var strEnd = this.end;
  21441. if (!length) {
  21442. this.ensureRange(pos, strEnd);
  21443. return bytes.subarray(pos, strEnd);
  21444. }
  21445. var end = pos + length;
  21446. if (end > strEnd) {
  21447. end = strEnd;
  21448. }
  21449. this.ensureRange(pos, end);
  21450. this.pos = end;
  21451. return bytes.subarray(pos, end);
  21452. },
  21453. peekByte: function ChunkedStream_peekByte() {
  21454. var peekedByte = this.getByte();
  21455. this.pos--;
  21456. return peekedByte;
  21457. },
  21458. peekBytes: function ChunkedStream_peekBytes(length) {
  21459. var bytes = this.getBytes(length);
  21460. this.pos -= bytes.length;
  21461. return bytes;
  21462. },
  21463. getByteRange: function ChunkedStream_getBytes(begin, end) {
  21464. this.ensureRange(begin, end);
  21465. return this.bytes.subarray(begin, end);
  21466. },
  21467. skip: function ChunkedStream_skip(n) {
  21468. if (!n) {
  21469. n = 1;
  21470. }
  21471. this.pos += n;
  21472. },
  21473. reset: function ChunkedStream_reset() {
  21474. this.pos = this.start;
  21475. },
  21476. moveStart: function ChunkedStream_moveStart() {
  21477. this.start = this.pos;
  21478. },
  21479. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  21480. this.ensureRange(start, start + length);
  21481. function ChunkedStreamSubstream() {
  21482. }
  21483. ChunkedStreamSubstream.prototype = Object.create(this);
  21484. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  21485. var chunkSize = this.chunkSize;
  21486. var beginChunk = Math.floor(this.start / chunkSize);
  21487. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  21488. var missingChunks = [];
  21489. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  21490. if (!this.loadedChunks[chunk]) {
  21491. missingChunks.push(chunk);
  21492. }
  21493. }
  21494. return missingChunks;
  21495. };
  21496. var subStream = new ChunkedStreamSubstream();
  21497. subStream.pos = subStream.start = start;
  21498. subStream.end = start + length || this.end;
  21499. subStream.dict = dict;
  21500. return subStream;
  21501. }
  21502. };
  21503. return ChunkedStream;
  21504. }();
  21505. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  21506. function ChunkedStreamManager(pdfNetworkStream, args) {
  21507. var chunkSize = args.rangeChunkSize;
  21508. var length = args.length;
  21509. this.stream = new ChunkedStream(length, chunkSize, this);
  21510. this.length = length;
  21511. this.chunkSize = chunkSize;
  21512. this.pdfNetworkStream = pdfNetworkStream;
  21513. this.url = args.url;
  21514. this.disableAutoFetch = args.disableAutoFetch;
  21515. this.msgHandler = args.msgHandler;
  21516. this.currRequestId = 0;
  21517. this.chunksNeededByRequest = Object.create(null);
  21518. this.requestsByChunk = Object.create(null);
  21519. this.promisesByRequest = Object.create(null);
  21520. this.progressiveDataLength = 0;
  21521. this.aborted = false;
  21522. this._loadedStreamCapability = createPromiseCapability();
  21523. }
  21524. ChunkedStreamManager.prototype = {
  21525. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  21526. return this._loadedStreamCapability.promise;
  21527. },
  21528. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  21529. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  21530. if (!rangeReader.isStreamingSupported) {
  21531. rangeReader.onProgress = this.onProgress.bind(this);
  21532. }
  21533. var chunks = [], loaded = 0;
  21534. var manager = this;
  21535. var promise = new Promise(function (resolve, reject) {
  21536. var readChunk = function (chunk) {
  21537. try {
  21538. if (!chunk.done) {
  21539. var data = chunk.value;
  21540. chunks.push(data);
  21541. loaded += arrayByteLength(data);
  21542. if (rangeReader.isStreamingSupported) {
  21543. manager.onProgress({ loaded: loaded });
  21544. }
  21545. rangeReader.read().then(readChunk, reject);
  21546. return;
  21547. }
  21548. var chunkData = arraysToBytes(chunks);
  21549. chunks = null;
  21550. resolve(chunkData);
  21551. } catch (e) {
  21552. reject(e);
  21553. }
  21554. };
  21555. rangeReader.read().then(readChunk, reject);
  21556. });
  21557. promise.then(function (data) {
  21558. if (this.aborted) {
  21559. return;
  21560. }
  21561. this.onReceiveData({
  21562. chunk: data,
  21563. begin: begin
  21564. });
  21565. }.bind(this));
  21566. },
  21567. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  21568. var missingChunks = this.stream.getMissingChunks();
  21569. this._requestChunks(missingChunks);
  21570. return this._loadedStreamCapability.promise;
  21571. },
  21572. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  21573. var requestId = this.currRequestId++;
  21574. var i, ii;
  21575. var chunksNeeded = Object.create(null);
  21576. this.chunksNeededByRequest[requestId] = chunksNeeded;
  21577. for (i = 0, ii = chunks.length; i < ii; i++) {
  21578. if (!this.stream.hasChunk(chunks[i])) {
  21579. chunksNeeded[chunks[i]] = true;
  21580. }
  21581. }
  21582. if (isEmptyObj(chunksNeeded)) {
  21583. return Promise.resolve();
  21584. }
  21585. var capability = createPromiseCapability();
  21586. this.promisesByRequest[requestId] = capability;
  21587. var chunksToRequest = [];
  21588. for (var chunk in chunksNeeded) {
  21589. chunk = chunk | 0;
  21590. if (!(chunk in this.requestsByChunk)) {
  21591. this.requestsByChunk[chunk] = [];
  21592. chunksToRequest.push(chunk);
  21593. }
  21594. this.requestsByChunk[chunk].push(requestId);
  21595. }
  21596. if (!chunksToRequest.length) {
  21597. return capability.promise;
  21598. }
  21599. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  21600. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  21601. var groupedChunk = groupedChunksToRequest[i];
  21602. var begin = groupedChunk.beginChunk * this.chunkSize;
  21603. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  21604. this.sendRequest(begin, end);
  21605. }
  21606. return capability.promise;
  21607. },
  21608. getStream: function ChunkedStreamManager_getStream() {
  21609. return this.stream;
  21610. },
  21611. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  21612. end = Math.min(end, this.length);
  21613. var beginChunk = this.getBeginChunk(begin);
  21614. var endChunk = this.getEndChunk(end);
  21615. var chunks = [];
  21616. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  21617. chunks.push(chunk);
  21618. }
  21619. return this._requestChunks(chunks);
  21620. },
  21621. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  21622. ranges = ranges || [];
  21623. var chunksToRequest = [];
  21624. for (var i = 0; i < ranges.length; i++) {
  21625. var beginChunk = this.getBeginChunk(ranges[i].begin);
  21626. var endChunk = this.getEndChunk(ranges[i].end);
  21627. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  21628. if (chunksToRequest.indexOf(chunk) < 0) {
  21629. chunksToRequest.push(chunk);
  21630. }
  21631. }
  21632. }
  21633. chunksToRequest.sort(function (a, b) {
  21634. return a - b;
  21635. });
  21636. return this._requestChunks(chunksToRequest);
  21637. },
  21638. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  21639. var groupedChunks = [];
  21640. var beginChunk = -1;
  21641. var prevChunk = -1;
  21642. for (var i = 0; i < chunks.length; ++i) {
  21643. var chunk = chunks[i];
  21644. if (beginChunk < 0) {
  21645. beginChunk = chunk;
  21646. }
  21647. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  21648. groupedChunks.push({
  21649. beginChunk: beginChunk,
  21650. endChunk: prevChunk + 1
  21651. });
  21652. beginChunk = chunk;
  21653. }
  21654. if (i + 1 === chunks.length) {
  21655. groupedChunks.push({
  21656. beginChunk: beginChunk,
  21657. endChunk: chunk + 1
  21658. });
  21659. }
  21660. prevChunk = chunk;
  21661. }
  21662. return groupedChunks;
  21663. },
  21664. onProgress: function ChunkedStreamManager_onProgress(args) {
  21665. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  21666. this.msgHandler.send('DocProgress', {
  21667. loaded: bytesLoaded,
  21668. total: this.length
  21669. });
  21670. },
  21671. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  21672. var chunk = args.chunk;
  21673. var isProgressive = args.begin === undefined;
  21674. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  21675. var end = begin + chunk.byteLength;
  21676. var beginChunk = Math.floor(begin / this.chunkSize);
  21677. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  21678. if (isProgressive) {
  21679. this.stream.onReceiveProgressiveData(chunk);
  21680. this.progressiveDataLength = end;
  21681. } else {
  21682. this.stream.onReceiveData(begin, chunk);
  21683. }
  21684. if (this.stream.allChunksLoaded()) {
  21685. this._loadedStreamCapability.resolve(this.stream);
  21686. }
  21687. var loadedRequests = [];
  21688. var i, requestId;
  21689. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  21690. var requestIds = this.requestsByChunk[chunk] || [];
  21691. delete this.requestsByChunk[chunk];
  21692. for (i = 0; i < requestIds.length; ++i) {
  21693. requestId = requestIds[i];
  21694. var chunksNeeded = this.chunksNeededByRequest[requestId];
  21695. if (chunk in chunksNeeded) {
  21696. delete chunksNeeded[chunk];
  21697. }
  21698. if (!isEmptyObj(chunksNeeded)) {
  21699. continue;
  21700. }
  21701. loadedRequests.push(requestId);
  21702. }
  21703. }
  21704. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  21705. var nextEmptyChunk;
  21706. if (this.stream.numChunksLoaded === 1) {
  21707. var lastChunk = this.stream.numChunks - 1;
  21708. if (!this.stream.hasChunk(lastChunk)) {
  21709. nextEmptyChunk = lastChunk;
  21710. }
  21711. } else {
  21712. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  21713. }
  21714. if (isInt(nextEmptyChunk)) {
  21715. this._requestChunks([nextEmptyChunk]);
  21716. }
  21717. }
  21718. for (i = 0; i < loadedRequests.length; ++i) {
  21719. requestId = loadedRequests[i];
  21720. var capability = this.promisesByRequest[requestId];
  21721. delete this.promisesByRequest[requestId];
  21722. capability.resolve();
  21723. }
  21724. this.msgHandler.send('DocProgress', {
  21725. loaded: this.stream.numChunksLoaded * this.chunkSize,
  21726. total: this.length
  21727. });
  21728. },
  21729. onError: function ChunkedStreamManager_onError(err) {
  21730. this._loadedStreamCapability.reject(err);
  21731. },
  21732. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  21733. var chunk = Math.floor(begin / this.chunkSize);
  21734. return chunk;
  21735. },
  21736. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  21737. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  21738. return chunk;
  21739. },
  21740. abort: function ChunkedStreamManager_abort() {
  21741. this.aborted = true;
  21742. if (this.pdfNetworkStream) {
  21743. this.pdfNetworkStream.cancelAllRequests('abort');
  21744. }
  21745. for (var requestId in this.promisesByRequest) {
  21746. var capability = this.promisesByRequest[requestId];
  21747. capability.reject(new Error('Request was aborted'));
  21748. }
  21749. }
  21750. };
  21751. return ChunkedStreamManager;
  21752. }();
  21753. exports.ChunkedStream = ChunkedStream;
  21754. exports.ChunkedStreamManager = ChunkedStreamManager;
  21755. /***/ }),
  21756. /* 13 */
  21757. /***/ (function(module, exports, __w_pdfjs_require__) {
  21758. "use strict";
  21759. var sharedUtil = __w_pdfjs_require__(0);
  21760. var corePrimitives = __w_pdfjs_require__(1);
  21761. var coreStream = __w_pdfjs_require__(2);
  21762. var PasswordException = sharedUtil.PasswordException;
  21763. var PasswordResponses = sharedUtil.PasswordResponses;
  21764. var bytesToString = sharedUtil.bytesToString;
  21765. var warn = sharedUtil.warn;
  21766. var error = sharedUtil.error;
  21767. var assert = sharedUtil.assert;
  21768. var isInt = sharedUtil.isInt;
  21769. var stringToBytes = sharedUtil.stringToBytes;
  21770. var utf8StringToString = sharedUtil.utf8StringToString;
  21771. var Name = corePrimitives.Name;
  21772. var isName = corePrimitives.isName;
  21773. var isDict = corePrimitives.isDict;
  21774. var DecryptStream = coreStream.DecryptStream;
  21775. var ARCFourCipher = function ARCFourCipherClosure() {
  21776. function ARCFourCipher(key) {
  21777. this.a = 0;
  21778. this.b = 0;
  21779. var s = new Uint8Array(256);
  21780. var i, j = 0, tmp, keyLength = key.length;
  21781. for (i = 0; i < 256; ++i) {
  21782. s[i] = i;
  21783. }
  21784. for (i = 0; i < 256; ++i) {
  21785. tmp = s[i];
  21786. j = j + tmp + key[i % keyLength] & 0xFF;
  21787. s[i] = s[j];
  21788. s[j] = tmp;
  21789. }
  21790. this.s = s;
  21791. }
  21792. ARCFourCipher.prototype = {
  21793. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  21794. var i, n = data.length, tmp, tmp2;
  21795. var a = this.a, b = this.b, s = this.s;
  21796. var output = new Uint8Array(n);
  21797. for (i = 0; i < n; ++i) {
  21798. a = a + 1 & 0xFF;
  21799. tmp = s[a];
  21800. b = b + tmp & 0xFF;
  21801. tmp2 = s[b];
  21802. s[a] = tmp2;
  21803. s[b] = tmp;
  21804. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  21805. }
  21806. this.a = a;
  21807. this.b = b;
  21808. return output;
  21809. }
  21810. };
  21811. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  21812. return ARCFourCipher;
  21813. }();
  21814. var calculateMD5 = function calculateMD5Closure() {
  21815. var r = new Uint8Array([
  21816. 7,
  21817. 12,
  21818. 17,
  21819. 22,
  21820. 7,
  21821. 12,
  21822. 17,
  21823. 22,
  21824. 7,
  21825. 12,
  21826. 17,
  21827. 22,
  21828. 7,
  21829. 12,
  21830. 17,
  21831. 22,
  21832. 5,
  21833. 9,
  21834. 14,
  21835. 20,
  21836. 5,
  21837. 9,
  21838. 14,
  21839. 20,
  21840. 5,
  21841. 9,
  21842. 14,
  21843. 20,
  21844. 5,
  21845. 9,
  21846. 14,
  21847. 20,
  21848. 4,
  21849. 11,
  21850. 16,
  21851. 23,
  21852. 4,
  21853. 11,
  21854. 16,
  21855. 23,
  21856. 4,
  21857. 11,
  21858. 16,
  21859. 23,
  21860. 4,
  21861. 11,
  21862. 16,
  21863. 23,
  21864. 6,
  21865. 10,
  21866. 15,
  21867. 21,
  21868. 6,
  21869. 10,
  21870. 15,
  21871. 21,
  21872. 6,
  21873. 10,
  21874. 15,
  21875. 21,
  21876. 6,
  21877. 10,
  21878. 15,
  21879. 21
  21880. ]);
  21881. var k = new Int32Array([
  21882. -680876936,
  21883. -389564586,
  21884. 606105819,
  21885. -1044525330,
  21886. -176418897,
  21887. 1200080426,
  21888. -1473231341,
  21889. -45705983,
  21890. 1770035416,
  21891. -1958414417,
  21892. -42063,
  21893. -1990404162,
  21894. 1804603682,
  21895. -40341101,
  21896. -1502002290,
  21897. 1236535329,
  21898. -165796510,
  21899. -1069501632,
  21900. 643717713,
  21901. -373897302,
  21902. -701558691,
  21903. 38016083,
  21904. -660478335,
  21905. -405537848,
  21906. 568446438,
  21907. -1019803690,
  21908. -187363961,
  21909. 1163531501,
  21910. -1444681467,
  21911. -51403784,
  21912. 1735328473,
  21913. -1926607734,
  21914. -378558,
  21915. -2022574463,
  21916. 1839030562,
  21917. -35309556,
  21918. -1530992060,
  21919. 1272893353,
  21920. -155497632,
  21921. -1094730640,
  21922. 681279174,
  21923. -358537222,
  21924. -722521979,
  21925. 76029189,
  21926. -640364487,
  21927. -421815835,
  21928. 530742520,
  21929. -995338651,
  21930. -198630844,
  21931. 1126891415,
  21932. -1416354905,
  21933. -57434055,
  21934. 1700485571,
  21935. -1894986606,
  21936. -1051523,
  21937. -2054922799,
  21938. 1873313359,
  21939. -30611744,
  21940. -1560198380,
  21941. 1309151649,
  21942. -145523070,
  21943. -1120210379,
  21944. 718787259,
  21945. -343485551
  21946. ]);
  21947. function hash(data, offset, length) {
  21948. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  21949. var paddedLength = length + 72 & ~63;
  21950. var padded = new Uint8Array(paddedLength);
  21951. var i, j, n;
  21952. for (i = 0; i < length; ++i) {
  21953. padded[i] = data[offset++];
  21954. }
  21955. padded[i++] = 0x80;
  21956. n = paddedLength - 8;
  21957. while (i < n) {
  21958. padded[i++] = 0;
  21959. }
  21960. padded[i++] = length << 3 & 0xFF;
  21961. padded[i++] = length >> 5 & 0xFF;
  21962. padded[i++] = length >> 13 & 0xFF;
  21963. padded[i++] = length >> 21 & 0xFF;
  21964. padded[i++] = length >>> 29 & 0xFF;
  21965. padded[i++] = 0;
  21966. padded[i++] = 0;
  21967. padded[i++] = 0;
  21968. var w = new Int32Array(16);
  21969. for (i = 0; i < paddedLength;) {
  21970. for (j = 0; j < 16; ++j, i += 4) {
  21971. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  21972. }
  21973. var a = h0, b = h1, c = h2, d = h3, f, g;
  21974. for (j = 0; j < 64; ++j) {
  21975. if (j < 16) {
  21976. f = b & c | ~b & d;
  21977. g = j;
  21978. } else if (j < 32) {
  21979. f = d & b | ~d & c;
  21980. g = 5 * j + 1 & 15;
  21981. } else if (j < 48) {
  21982. f = b ^ c ^ d;
  21983. g = 3 * j + 5 & 15;
  21984. } else {
  21985. f = c ^ (b | ~d);
  21986. g = 7 * j & 15;
  21987. }
  21988. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  21989. d = c;
  21990. c = b;
  21991. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  21992. a = tmp;
  21993. }
  21994. h0 = h0 + a | 0;
  21995. h1 = h1 + b | 0;
  21996. h2 = h2 + c | 0;
  21997. h3 = h3 + d | 0;
  21998. }
  21999. return new Uint8Array([
  22000. h0 & 0xFF,
  22001. h0 >> 8 & 0xFF,
  22002. h0 >> 16 & 0xFF,
  22003. h0 >>> 24 & 0xFF,
  22004. h1 & 0xFF,
  22005. h1 >> 8 & 0xFF,
  22006. h1 >> 16 & 0xFF,
  22007. h1 >>> 24 & 0xFF,
  22008. h2 & 0xFF,
  22009. h2 >> 8 & 0xFF,
  22010. h2 >> 16 & 0xFF,
  22011. h2 >>> 24 & 0xFF,
  22012. h3 & 0xFF,
  22013. h3 >> 8 & 0xFF,
  22014. h3 >> 16 & 0xFF,
  22015. h3 >>> 24 & 0xFF
  22016. ]);
  22017. }
  22018. return hash;
  22019. }();
  22020. var Word64 = function Word64Closure() {
  22021. function Word64(highInteger, lowInteger) {
  22022. this.high = highInteger | 0;
  22023. this.low = lowInteger | 0;
  22024. }
  22025. Word64.prototype = {
  22026. and: function Word64_and(word) {
  22027. this.high &= word.high;
  22028. this.low &= word.low;
  22029. },
  22030. xor: function Word64_xor(word) {
  22031. this.high ^= word.high;
  22032. this.low ^= word.low;
  22033. },
  22034. or: function Word64_or(word) {
  22035. this.high |= word.high;
  22036. this.low |= word.low;
  22037. },
  22038. shiftRight: function Word64_shiftRight(places) {
  22039. if (places >= 32) {
  22040. this.low = this.high >>> places - 32 | 0;
  22041. this.high = 0;
  22042. } else {
  22043. this.low = this.low >>> places | this.high << 32 - places;
  22044. this.high = this.high >>> places | 0;
  22045. }
  22046. },
  22047. shiftLeft: function Word64_shiftLeft(places) {
  22048. if (places >= 32) {
  22049. this.high = this.low << places - 32;
  22050. this.low = 0;
  22051. } else {
  22052. this.high = this.high << places | this.low >>> 32 - places;
  22053. this.low = this.low << places;
  22054. }
  22055. },
  22056. rotateRight: function Word64_rotateRight(places) {
  22057. var low, high;
  22058. if (places & 32) {
  22059. high = this.low;
  22060. low = this.high;
  22061. } else {
  22062. low = this.low;
  22063. high = this.high;
  22064. }
  22065. places &= 31;
  22066. this.low = low >>> places | high << 32 - places;
  22067. this.high = high >>> places | low << 32 - places;
  22068. },
  22069. not: function Word64_not() {
  22070. this.high = ~this.high;
  22071. this.low = ~this.low;
  22072. },
  22073. add: function Word64_add(word) {
  22074. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  22075. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  22076. if (lowAdd > 0xFFFFFFFF) {
  22077. highAdd += 1;
  22078. }
  22079. this.low = lowAdd | 0;
  22080. this.high = highAdd | 0;
  22081. },
  22082. copyTo: function Word64_copyTo(bytes, offset) {
  22083. bytes[offset] = this.high >>> 24 & 0xFF;
  22084. bytes[offset + 1] = this.high >> 16 & 0xFF;
  22085. bytes[offset + 2] = this.high >> 8 & 0xFF;
  22086. bytes[offset + 3] = this.high & 0xFF;
  22087. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  22088. bytes[offset + 5] = this.low >> 16 & 0xFF;
  22089. bytes[offset + 6] = this.low >> 8 & 0xFF;
  22090. bytes[offset + 7] = this.low & 0xFF;
  22091. },
  22092. assign: function Word64_assign(word) {
  22093. this.high = word.high;
  22094. this.low = word.low;
  22095. }
  22096. };
  22097. return Word64;
  22098. }();
  22099. var calculateSHA256 = function calculateSHA256Closure() {
  22100. function rotr(x, n) {
  22101. return x >>> n | x << 32 - n;
  22102. }
  22103. function ch(x, y, z) {
  22104. return x & y ^ ~x & z;
  22105. }
  22106. function maj(x, y, z) {
  22107. return x & y ^ x & z ^ y & z;
  22108. }
  22109. function sigma(x) {
  22110. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  22111. }
  22112. function sigmaPrime(x) {
  22113. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  22114. }
  22115. function littleSigma(x) {
  22116. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  22117. }
  22118. function littleSigmaPrime(x) {
  22119. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  22120. }
  22121. var k = [
  22122. 0x428a2f98,
  22123. 0x71374491,
  22124. 0xb5c0fbcf,
  22125. 0xe9b5dba5,
  22126. 0x3956c25b,
  22127. 0x59f111f1,
  22128. 0x923f82a4,
  22129. 0xab1c5ed5,
  22130. 0xd807aa98,
  22131. 0x12835b01,
  22132. 0x243185be,
  22133. 0x550c7dc3,
  22134. 0x72be5d74,
  22135. 0x80deb1fe,
  22136. 0x9bdc06a7,
  22137. 0xc19bf174,
  22138. 0xe49b69c1,
  22139. 0xefbe4786,
  22140. 0x0fc19dc6,
  22141. 0x240ca1cc,
  22142. 0x2de92c6f,
  22143. 0x4a7484aa,
  22144. 0x5cb0a9dc,
  22145. 0x76f988da,
  22146. 0x983e5152,
  22147. 0xa831c66d,
  22148. 0xb00327c8,
  22149. 0xbf597fc7,
  22150. 0xc6e00bf3,
  22151. 0xd5a79147,
  22152. 0x06ca6351,
  22153. 0x14292967,
  22154. 0x27b70a85,
  22155. 0x2e1b2138,
  22156. 0x4d2c6dfc,
  22157. 0x53380d13,
  22158. 0x650a7354,
  22159. 0x766a0abb,
  22160. 0x81c2c92e,
  22161. 0x92722c85,
  22162. 0xa2bfe8a1,
  22163. 0xa81a664b,
  22164. 0xc24b8b70,
  22165. 0xc76c51a3,
  22166. 0xd192e819,
  22167. 0xd6990624,
  22168. 0xf40e3585,
  22169. 0x106aa070,
  22170. 0x19a4c116,
  22171. 0x1e376c08,
  22172. 0x2748774c,
  22173. 0x34b0bcb5,
  22174. 0x391c0cb3,
  22175. 0x4ed8aa4a,
  22176. 0x5b9cca4f,
  22177. 0x682e6ff3,
  22178. 0x748f82ee,
  22179. 0x78a5636f,
  22180. 0x84c87814,
  22181. 0x8cc70208,
  22182. 0x90befffa,
  22183. 0xa4506ceb,
  22184. 0xbef9a3f7,
  22185. 0xc67178f2
  22186. ];
  22187. function hash(data, offset, length) {
  22188. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  22189. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  22190. var padded = new Uint8Array(paddedLength);
  22191. var i, j, n;
  22192. for (i = 0; i < length; ++i) {
  22193. padded[i] = data[offset++];
  22194. }
  22195. padded[i++] = 0x80;
  22196. n = paddedLength - 8;
  22197. while (i < n) {
  22198. padded[i++] = 0;
  22199. }
  22200. padded[i++] = 0;
  22201. padded[i++] = 0;
  22202. padded[i++] = 0;
  22203. padded[i++] = length >>> 29 & 0xFF;
  22204. padded[i++] = length >> 21 & 0xFF;
  22205. padded[i++] = length >> 13 & 0xFF;
  22206. padded[i++] = length >> 5 & 0xFF;
  22207. padded[i++] = length << 3 & 0xFF;
  22208. var w = new Uint32Array(64);
  22209. for (i = 0; i < paddedLength;) {
  22210. for (j = 0; j < 16; ++j) {
  22211. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  22212. i += 4;
  22213. }
  22214. for (j = 16; j < 64; ++j) {
  22215. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  22216. }
  22217. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  22218. for (j = 0; j < 64; ++j) {
  22219. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  22220. t2 = sigma(a) + maj(a, b, c);
  22221. h = g;
  22222. g = f;
  22223. f = e;
  22224. e = d + t1 | 0;
  22225. d = c;
  22226. c = b;
  22227. b = a;
  22228. a = t1 + t2 | 0;
  22229. }
  22230. h0 = h0 + a | 0;
  22231. h1 = h1 + b | 0;
  22232. h2 = h2 + c | 0;
  22233. h3 = h3 + d | 0;
  22234. h4 = h4 + e | 0;
  22235. h5 = h5 + f | 0;
  22236. h6 = h6 + g | 0;
  22237. h7 = h7 + h | 0;
  22238. }
  22239. return new Uint8Array([
  22240. h0 >> 24 & 0xFF,
  22241. h0 >> 16 & 0xFF,
  22242. h0 >> 8 & 0xFF,
  22243. h0 & 0xFF,
  22244. h1 >> 24 & 0xFF,
  22245. h1 >> 16 & 0xFF,
  22246. h1 >> 8 & 0xFF,
  22247. h1 & 0xFF,
  22248. h2 >> 24 & 0xFF,
  22249. h2 >> 16 & 0xFF,
  22250. h2 >> 8 & 0xFF,
  22251. h2 & 0xFF,
  22252. h3 >> 24 & 0xFF,
  22253. h3 >> 16 & 0xFF,
  22254. h3 >> 8 & 0xFF,
  22255. h3 & 0xFF,
  22256. h4 >> 24 & 0xFF,
  22257. h4 >> 16 & 0xFF,
  22258. h4 >> 8 & 0xFF,
  22259. h4 & 0xFF,
  22260. h5 >> 24 & 0xFF,
  22261. h5 >> 16 & 0xFF,
  22262. h5 >> 8 & 0xFF,
  22263. h5 & 0xFF,
  22264. h6 >> 24 & 0xFF,
  22265. h6 >> 16 & 0xFF,
  22266. h6 >> 8 & 0xFF,
  22267. h6 & 0xFF,
  22268. h7 >> 24 & 0xFF,
  22269. h7 >> 16 & 0xFF,
  22270. h7 >> 8 & 0xFF,
  22271. h7 & 0xFF
  22272. ]);
  22273. }
  22274. return hash;
  22275. }();
  22276. var calculateSHA512 = function calculateSHA512Closure() {
  22277. function ch(result, x, y, z, tmp) {
  22278. result.assign(x);
  22279. result.and(y);
  22280. tmp.assign(x);
  22281. tmp.not();
  22282. tmp.and(z);
  22283. result.xor(tmp);
  22284. }
  22285. function maj(result, x, y, z, tmp) {
  22286. result.assign(x);
  22287. result.and(y);
  22288. tmp.assign(x);
  22289. tmp.and(z);
  22290. result.xor(tmp);
  22291. tmp.assign(y);
  22292. tmp.and(z);
  22293. result.xor(tmp);
  22294. }
  22295. function sigma(result, x, tmp) {
  22296. result.assign(x);
  22297. result.rotateRight(28);
  22298. tmp.assign(x);
  22299. tmp.rotateRight(34);
  22300. result.xor(tmp);
  22301. tmp.assign(x);
  22302. tmp.rotateRight(39);
  22303. result.xor(tmp);
  22304. }
  22305. function sigmaPrime(result, x, tmp) {
  22306. result.assign(x);
  22307. result.rotateRight(14);
  22308. tmp.assign(x);
  22309. tmp.rotateRight(18);
  22310. result.xor(tmp);
  22311. tmp.assign(x);
  22312. tmp.rotateRight(41);
  22313. result.xor(tmp);
  22314. }
  22315. function littleSigma(result, x, tmp) {
  22316. result.assign(x);
  22317. result.rotateRight(1);
  22318. tmp.assign(x);
  22319. tmp.rotateRight(8);
  22320. result.xor(tmp);
  22321. tmp.assign(x);
  22322. tmp.shiftRight(7);
  22323. result.xor(tmp);
  22324. }
  22325. function littleSigmaPrime(result, x, tmp) {
  22326. result.assign(x);
  22327. result.rotateRight(19);
  22328. tmp.assign(x);
  22329. tmp.rotateRight(61);
  22330. result.xor(tmp);
  22331. tmp.assign(x);
  22332. tmp.shiftRight(6);
  22333. result.xor(tmp);
  22334. }
  22335. var k = [
  22336. new Word64(0x428a2f98, 0xd728ae22),
  22337. new Word64(0x71374491, 0x23ef65cd),
  22338. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  22339. new Word64(0xe9b5dba5, 0x8189dbbc),
  22340. new Word64(0x3956c25b, 0xf348b538),
  22341. new Word64(0x59f111f1, 0xb605d019),
  22342. new Word64(0x923f82a4, 0xaf194f9b),
  22343. new Word64(0xab1c5ed5, 0xda6d8118),
  22344. new Word64(0xd807aa98, 0xa3030242),
  22345. new Word64(0x12835b01, 0x45706fbe),
  22346. new Word64(0x243185be, 0x4ee4b28c),
  22347. new Word64(0x550c7dc3, 0xd5ffb4e2),
  22348. new Word64(0x72be5d74, 0xf27b896f),
  22349. new Word64(0x80deb1fe, 0x3b1696b1),
  22350. new Word64(0x9bdc06a7, 0x25c71235),
  22351. new Word64(0xc19bf174, 0xcf692694),
  22352. new Word64(0xe49b69c1, 0x9ef14ad2),
  22353. new Word64(0xefbe4786, 0x384f25e3),
  22354. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  22355. new Word64(0x240ca1cc, 0x77ac9c65),
  22356. new Word64(0x2de92c6f, 0x592b0275),
  22357. new Word64(0x4a7484aa, 0x6ea6e483),
  22358. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  22359. new Word64(0x76f988da, 0x831153b5),
  22360. new Word64(0x983e5152, 0xee66dfab),
  22361. new Word64(0xa831c66d, 0x2db43210),
  22362. new Word64(0xb00327c8, 0x98fb213f),
  22363. new Word64(0xbf597fc7, 0xbeef0ee4),
  22364. new Word64(0xc6e00bf3, 0x3da88fc2),
  22365. new Word64(0xd5a79147, 0x930aa725),
  22366. new Word64(0x06ca6351, 0xe003826f),
  22367. new Word64(0x14292967, 0x0a0e6e70),
  22368. new Word64(0x27b70a85, 0x46d22ffc),
  22369. new Word64(0x2e1b2138, 0x5c26c926),
  22370. new Word64(0x4d2c6dfc, 0x5ac42aed),
  22371. new Word64(0x53380d13, 0x9d95b3df),
  22372. new Word64(0x650a7354, 0x8baf63de),
  22373. new Word64(0x766a0abb, 0x3c77b2a8),
  22374. new Word64(0x81c2c92e, 0x47edaee6),
  22375. new Word64(0x92722c85, 0x1482353b),
  22376. new Word64(0xa2bfe8a1, 0x4cf10364),
  22377. new Word64(0xa81a664b, 0xbc423001),
  22378. new Word64(0xc24b8b70, 0xd0f89791),
  22379. new Word64(0xc76c51a3, 0x0654be30),
  22380. new Word64(0xd192e819, 0xd6ef5218),
  22381. new Word64(0xd6990624, 0x5565a910),
  22382. new Word64(0xf40e3585, 0x5771202a),
  22383. new Word64(0x106aa070, 0x32bbd1b8),
  22384. new Word64(0x19a4c116, 0xb8d2d0c8),
  22385. new Word64(0x1e376c08, 0x5141ab53),
  22386. new Word64(0x2748774c, 0xdf8eeb99),
  22387. new Word64(0x34b0bcb5, 0xe19b48a8),
  22388. new Word64(0x391c0cb3, 0xc5c95a63),
  22389. new Word64(0x4ed8aa4a, 0xe3418acb),
  22390. new Word64(0x5b9cca4f, 0x7763e373),
  22391. new Word64(0x682e6ff3, 0xd6b2b8a3),
  22392. new Word64(0x748f82ee, 0x5defb2fc),
  22393. new Word64(0x78a5636f, 0x43172f60),
  22394. new Word64(0x84c87814, 0xa1f0ab72),
  22395. new Word64(0x8cc70208, 0x1a6439ec),
  22396. new Word64(0x90befffa, 0x23631e28),
  22397. new Word64(0xa4506ceb, 0xde82bde9),
  22398. new Word64(0xbef9a3f7, 0xb2c67915),
  22399. new Word64(0xc67178f2, 0xe372532b),
  22400. new Word64(0xca273ece, 0xea26619c),
  22401. new Word64(0xd186b8c7, 0x21c0c207),
  22402. new Word64(0xeada7dd6, 0xcde0eb1e),
  22403. new Word64(0xf57d4f7f, 0xee6ed178),
  22404. new Word64(0x06f067aa, 0x72176fba),
  22405. new Word64(0x0a637dc5, 0xa2c898a6),
  22406. new Word64(0x113f9804, 0xbef90dae),
  22407. new Word64(0x1b710b35, 0x131c471b),
  22408. new Word64(0x28db77f5, 0x23047d84),
  22409. new Word64(0x32caab7b, 0x40c72493),
  22410. new Word64(0x3c9ebe0a, 0x15c9bebc),
  22411. new Word64(0x431d67c4, 0x9c100d4c),
  22412. new Word64(0x4cc5d4be, 0xcb3e42b6),
  22413. new Word64(0x597f299c, 0xfc657e2a),
  22414. new Word64(0x5fcb6fab, 0x3ad6faec),
  22415. new Word64(0x6c44198c, 0x4a475817)
  22416. ];
  22417. function hash(data, offset, length, mode384) {
  22418. mode384 = !!mode384;
  22419. var h0, h1, h2, h3, h4, h5, h6, h7;
  22420. if (!mode384) {
  22421. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  22422. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  22423. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  22424. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  22425. h4 = new Word64(0x510e527f, 0xade682d1);
  22426. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  22427. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  22428. h7 = new Word64(0x5be0cd19, 0x137e2179);
  22429. } else {
  22430. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  22431. h1 = new Word64(0x629a292a, 0x367cd507);
  22432. h2 = new Word64(0x9159015a, 0x3070dd17);
  22433. h3 = new Word64(0x152fecd8, 0xf70e5939);
  22434. h4 = new Word64(0x67332667, 0xffc00b31);
  22435. h5 = new Word64(0x8eb44a87, 0x68581511);
  22436. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  22437. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  22438. }
  22439. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  22440. var padded = new Uint8Array(paddedLength);
  22441. var i, j, n;
  22442. for (i = 0; i < length; ++i) {
  22443. padded[i] = data[offset++];
  22444. }
  22445. padded[i++] = 0x80;
  22446. n = paddedLength - 16;
  22447. while (i < n) {
  22448. padded[i++] = 0;
  22449. }
  22450. padded[i++] = 0;
  22451. padded[i++] = 0;
  22452. padded[i++] = 0;
  22453. padded[i++] = 0;
  22454. padded[i++] = 0;
  22455. padded[i++] = 0;
  22456. padded[i++] = 0;
  22457. padded[i++] = 0;
  22458. padded[i++] = 0;
  22459. padded[i++] = 0;
  22460. padded[i++] = 0;
  22461. padded[i++] = length >>> 29 & 0xFF;
  22462. padded[i++] = length >> 21 & 0xFF;
  22463. padded[i++] = length >> 13 & 0xFF;
  22464. padded[i++] = length >> 5 & 0xFF;
  22465. padded[i++] = length << 3 & 0xFF;
  22466. var w = new Array(80);
  22467. for (i = 0; i < 80; i++) {
  22468. w[i] = new Word64(0, 0);
  22469. }
  22470. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  22471. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  22472. var g = new Word64(0, 0), h = new Word64(0, 0);
  22473. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  22474. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  22475. for (i = 0; i < paddedLength;) {
  22476. for (j = 0; j < 16; ++j) {
  22477. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  22478. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  22479. i += 8;
  22480. }
  22481. for (j = 16; j < 80; ++j) {
  22482. tmp3 = w[j];
  22483. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  22484. tmp3.add(w[j - 7]);
  22485. littleSigma(tmp1, w[j - 15], tmp2);
  22486. tmp3.add(tmp1);
  22487. tmp3.add(w[j - 16]);
  22488. }
  22489. a.assign(h0);
  22490. b.assign(h1);
  22491. c.assign(h2);
  22492. d.assign(h3);
  22493. e.assign(h4);
  22494. f.assign(h5);
  22495. g.assign(h6);
  22496. h.assign(h7);
  22497. for (j = 0; j < 80; ++j) {
  22498. t1.assign(h);
  22499. sigmaPrime(tmp1, e, tmp2);
  22500. t1.add(tmp1);
  22501. ch(tmp1, e, f, g, tmp2);
  22502. t1.add(tmp1);
  22503. t1.add(k[j]);
  22504. t1.add(w[j]);
  22505. sigma(t2, a, tmp2);
  22506. maj(tmp1, a, b, c, tmp2);
  22507. t2.add(tmp1);
  22508. tmp3 = h;
  22509. h = g;
  22510. g = f;
  22511. f = e;
  22512. d.add(t1);
  22513. e = d;
  22514. d = c;
  22515. c = b;
  22516. b = a;
  22517. tmp3.assign(t1);
  22518. tmp3.add(t2);
  22519. a = tmp3;
  22520. }
  22521. h0.add(a);
  22522. h1.add(b);
  22523. h2.add(c);
  22524. h3.add(d);
  22525. h4.add(e);
  22526. h5.add(f);
  22527. h6.add(g);
  22528. h7.add(h);
  22529. }
  22530. var result;
  22531. if (!mode384) {
  22532. result = new Uint8Array(64);
  22533. h0.copyTo(result, 0);
  22534. h1.copyTo(result, 8);
  22535. h2.copyTo(result, 16);
  22536. h3.copyTo(result, 24);
  22537. h4.copyTo(result, 32);
  22538. h5.copyTo(result, 40);
  22539. h6.copyTo(result, 48);
  22540. h7.copyTo(result, 56);
  22541. } else {
  22542. result = new Uint8Array(48);
  22543. h0.copyTo(result, 0);
  22544. h1.copyTo(result, 8);
  22545. h2.copyTo(result, 16);
  22546. h3.copyTo(result, 24);
  22547. h4.copyTo(result, 32);
  22548. h5.copyTo(result, 40);
  22549. }
  22550. return result;
  22551. }
  22552. return hash;
  22553. }();
  22554. var calculateSHA384 = function calculateSHA384Closure() {
  22555. function hash(data, offset, length) {
  22556. return calculateSHA512(data, offset, length, true);
  22557. }
  22558. return hash;
  22559. }();
  22560. var NullCipher = function NullCipherClosure() {
  22561. function NullCipher() {
  22562. }
  22563. NullCipher.prototype = {
  22564. decryptBlock: function NullCipher_decryptBlock(data) {
  22565. return data;
  22566. }
  22567. };
  22568. return NullCipher;
  22569. }();
  22570. var AES128Cipher = function AES128CipherClosure() {
  22571. var rcon = new Uint8Array([
  22572. 0x8d,
  22573. 0x01,
  22574. 0x02,
  22575. 0x04,
  22576. 0x08,
  22577. 0x10,
  22578. 0x20,
  22579. 0x40,
  22580. 0x80,
  22581. 0x1b,
  22582. 0x36,
  22583. 0x6c,
  22584. 0xd8,
  22585. 0xab,
  22586. 0x4d,
  22587. 0x9a,
  22588. 0x2f,
  22589. 0x5e,
  22590. 0xbc,
  22591. 0x63,
  22592. 0xc6,
  22593. 0x97,
  22594. 0x35,
  22595. 0x6a,
  22596. 0xd4,
  22597. 0xb3,
  22598. 0x7d,
  22599. 0xfa,
  22600. 0xef,
  22601. 0xc5,
  22602. 0x91,
  22603. 0x39,
  22604. 0x72,
  22605. 0xe4,
  22606. 0xd3,
  22607. 0xbd,
  22608. 0x61,
  22609. 0xc2,
  22610. 0x9f,
  22611. 0x25,
  22612. 0x4a,
  22613. 0x94,
  22614. 0x33,
  22615. 0x66,
  22616. 0xcc,
  22617. 0x83,
  22618. 0x1d,
  22619. 0x3a,
  22620. 0x74,
  22621. 0xe8,
  22622. 0xcb,
  22623. 0x8d,
  22624. 0x01,
  22625. 0x02,
  22626. 0x04,
  22627. 0x08,
  22628. 0x10,
  22629. 0x20,
  22630. 0x40,
  22631. 0x80,
  22632. 0x1b,
  22633. 0x36,
  22634. 0x6c,
  22635. 0xd8,
  22636. 0xab,
  22637. 0x4d,
  22638. 0x9a,
  22639. 0x2f,
  22640. 0x5e,
  22641. 0xbc,
  22642. 0x63,
  22643. 0xc6,
  22644. 0x97,
  22645. 0x35,
  22646. 0x6a,
  22647. 0xd4,
  22648. 0xb3,
  22649. 0x7d,
  22650. 0xfa,
  22651. 0xef,
  22652. 0xc5,
  22653. 0x91,
  22654. 0x39,
  22655. 0x72,
  22656. 0xe4,
  22657. 0xd3,
  22658. 0xbd,
  22659. 0x61,
  22660. 0xc2,
  22661. 0x9f,
  22662. 0x25,
  22663. 0x4a,
  22664. 0x94,
  22665. 0x33,
  22666. 0x66,
  22667. 0xcc,
  22668. 0x83,
  22669. 0x1d,
  22670. 0x3a,
  22671. 0x74,
  22672. 0xe8,
  22673. 0xcb,
  22674. 0x8d,
  22675. 0x01,
  22676. 0x02,
  22677. 0x04,
  22678. 0x08,
  22679. 0x10,
  22680. 0x20,
  22681. 0x40,
  22682. 0x80,
  22683. 0x1b,
  22684. 0x36,
  22685. 0x6c,
  22686. 0xd8,
  22687. 0xab,
  22688. 0x4d,
  22689. 0x9a,
  22690. 0x2f,
  22691. 0x5e,
  22692. 0xbc,
  22693. 0x63,
  22694. 0xc6,
  22695. 0x97,
  22696. 0x35,
  22697. 0x6a,
  22698. 0xd4,
  22699. 0xb3,
  22700. 0x7d,
  22701. 0xfa,
  22702. 0xef,
  22703. 0xc5,
  22704. 0x91,
  22705. 0x39,
  22706. 0x72,
  22707. 0xe4,
  22708. 0xd3,
  22709. 0xbd,
  22710. 0x61,
  22711. 0xc2,
  22712. 0x9f,
  22713. 0x25,
  22714. 0x4a,
  22715. 0x94,
  22716. 0x33,
  22717. 0x66,
  22718. 0xcc,
  22719. 0x83,
  22720. 0x1d,
  22721. 0x3a,
  22722. 0x74,
  22723. 0xe8,
  22724. 0xcb,
  22725. 0x8d,
  22726. 0x01,
  22727. 0x02,
  22728. 0x04,
  22729. 0x08,
  22730. 0x10,
  22731. 0x20,
  22732. 0x40,
  22733. 0x80,
  22734. 0x1b,
  22735. 0x36,
  22736. 0x6c,
  22737. 0xd8,
  22738. 0xab,
  22739. 0x4d,
  22740. 0x9a,
  22741. 0x2f,
  22742. 0x5e,
  22743. 0xbc,
  22744. 0x63,
  22745. 0xc6,
  22746. 0x97,
  22747. 0x35,
  22748. 0x6a,
  22749. 0xd4,
  22750. 0xb3,
  22751. 0x7d,
  22752. 0xfa,
  22753. 0xef,
  22754. 0xc5,
  22755. 0x91,
  22756. 0x39,
  22757. 0x72,
  22758. 0xe4,
  22759. 0xd3,
  22760. 0xbd,
  22761. 0x61,
  22762. 0xc2,
  22763. 0x9f,
  22764. 0x25,
  22765. 0x4a,
  22766. 0x94,
  22767. 0x33,
  22768. 0x66,
  22769. 0xcc,
  22770. 0x83,
  22771. 0x1d,
  22772. 0x3a,
  22773. 0x74,
  22774. 0xe8,
  22775. 0xcb,
  22776. 0x8d,
  22777. 0x01,
  22778. 0x02,
  22779. 0x04,
  22780. 0x08,
  22781. 0x10,
  22782. 0x20,
  22783. 0x40,
  22784. 0x80,
  22785. 0x1b,
  22786. 0x36,
  22787. 0x6c,
  22788. 0xd8,
  22789. 0xab,
  22790. 0x4d,
  22791. 0x9a,
  22792. 0x2f,
  22793. 0x5e,
  22794. 0xbc,
  22795. 0x63,
  22796. 0xc6,
  22797. 0x97,
  22798. 0x35,
  22799. 0x6a,
  22800. 0xd4,
  22801. 0xb3,
  22802. 0x7d,
  22803. 0xfa,
  22804. 0xef,
  22805. 0xc5,
  22806. 0x91,
  22807. 0x39,
  22808. 0x72,
  22809. 0xe4,
  22810. 0xd3,
  22811. 0xbd,
  22812. 0x61,
  22813. 0xc2,
  22814. 0x9f,
  22815. 0x25,
  22816. 0x4a,
  22817. 0x94,
  22818. 0x33,
  22819. 0x66,
  22820. 0xcc,
  22821. 0x83,
  22822. 0x1d,
  22823. 0x3a,
  22824. 0x74,
  22825. 0xe8,
  22826. 0xcb,
  22827. 0x8d
  22828. ]);
  22829. var s = new Uint8Array([
  22830. 0x63,
  22831. 0x7c,
  22832. 0x77,
  22833. 0x7b,
  22834. 0xf2,
  22835. 0x6b,
  22836. 0x6f,
  22837. 0xc5,
  22838. 0x30,
  22839. 0x01,
  22840. 0x67,
  22841. 0x2b,
  22842. 0xfe,
  22843. 0xd7,
  22844. 0xab,
  22845. 0x76,
  22846. 0xca,
  22847. 0x82,
  22848. 0xc9,
  22849. 0x7d,
  22850. 0xfa,
  22851. 0x59,
  22852. 0x47,
  22853. 0xf0,
  22854. 0xad,
  22855. 0xd4,
  22856. 0xa2,
  22857. 0xaf,
  22858. 0x9c,
  22859. 0xa4,
  22860. 0x72,
  22861. 0xc0,
  22862. 0xb7,
  22863. 0xfd,
  22864. 0x93,
  22865. 0x26,
  22866. 0x36,
  22867. 0x3f,
  22868. 0xf7,
  22869. 0xcc,
  22870. 0x34,
  22871. 0xa5,
  22872. 0xe5,
  22873. 0xf1,
  22874. 0x71,
  22875. 0xd8,
  22876. 0x31,
  22877. 0x15,
  22878. 0x04,
  22879. 0xc7,
  22880. 0x23,
  22881. 0xc3,
  22882. 0x18,
  22883. 0x96,
  22884. 0x05,
  22885. 0x9a,
  22886. 0x07,
  22887. 0x12,
  22888. 0x80,
  22889. 0xe2,
  22890. 0xeb,
  22891. 0x27,
  22892. 0xb2,
  22893. 0x75,
  22894. 0x09,
  22895. 0x83,
  22896. 0x2c,
  22897. 0x1a,
  22898. 0x1b,
  22899. 0x6e,
  22900. 0x5a,
  22901. 0xa0,
  22902. 0x52,
  22903. 0x3b,
  22904. 0xd6,
  22905. 0xb3,
  22906. 0x29,
  22907. 0xe3,
  22908. 0x2f,
  22909. 0x84,
  22910. 0x53,
  22911. 0xd1,
  22912. 0x00,
  22913. 0xed,
  22914. 0x20,
  22915. 0xfc,
  22916. 0xb1,
  22917. 0x5b,
  22918. 0x6a,
  22919. 0xcb,
  22920. 0xbe,
  22921. 0x39,
  22922. 0x4a,
  22923. 0x4c,
  22924. 0x58,
  22925. 0xcf,
  22926. 0xd0,
  22927. 0xef,
  22928. 0xaa,
  22929. 0xfb,
  22930. 0x43,
  22931. 0x4d,
  22932. 0x33,
  22933. 0x85,
  22934. 0x45,
  22935. 0xf9,
  22936. 0x02,
  22937. 0x7f,
  22938. 0x50,
  22939. 0x3c,
  22940. 0x9f,
  22941. 0xa8,
  22942. 0x51,
  22943. 0xa3,
  22944. 0x40,
  22945. 0x8f,
  22946. 0x92,
  22947. 0x9d,
  22948. 0x38,
  22949. 0xf5,
  22950. 0xbc,
  22951. 0xb6,
  22952. 0xda,
  22953. 0x21,
  22954. 0x10,
  22955. 0xff,
  22956. 0xf3,
  22957. 0xd2,
  22958. 0xcd,
  22959. 0x0c,
  22960. 0x13,
  22961. 0xec,
  22962. 0x5f,
  22963. 0x97,
  22964. 0x44,
  22965. 0x17,
  22966. 0xc4,
  22967. 0xa7,
  22968. 0x7e,
  22969. 0x3d,
  22970. 0x64,
  22971. 0x5d,
  22972. 0x19,
  22973. 0x73,
  22974. 0x60,
  22975. 0x81,
  22976. 0x4f,
  22977. 0xdc,
  22978. 0x22,
  22979. 0x2a,
  22980. 0x90,
  22981. 0x88,
  22982. 0x46,
  22983. 0xee,
  22984. 0xb8,
  22985. 0x14,
  22986. 0xde,
  22987. 0x5e,
  22988. 0x0b,
  22989. 0xdb,
  22990. 0xe0,
  22991. 0x32,
  22992. 0x3a,
  22993. 0x0a,
  22994. 0x49,
  22995. 0x06,
  22996. 0x24,
  22997. 0x5c,
  22998. 0xc2,
  22999. 0xd3,
  23000. 0xac,
  23001. 0x62,
  23002. 0x91,
  23003. 0x95,
  23004. 0xe4,
  23005. 0x79,
  23006. 0xe7,
  23007. 0xc8,
  23008. 0x37,
  23009. 0x6d,
  23010. 0x8d,
  23011. 0xd5,
  23012. 0x4e,
  23013. 0xa9,
  23014. 0x6c,
  23015. 0x56,
  23016. 0xf4,
  23017. 0xea,
  23018. 0x65,
  23019. 0x7a,
  23020. 0xae,
  23021. 0x08,
  23022. 0xba,
  23023. 0x78,
  23024. 0x25,
  23025. 0x2e,
  23026. 0x1c,
  23027. 0xa6,
  23028. 0xb4,
  23029. 0xc6,
  23030. 0xe8,
  23031. 0xdd,
  23032. 0x74,
  23033. 0x1f,
  23034. 0x4b,
  23035. 0xbd,
  23036. 0x8b,
  23037. 0x8a,
  23038. 0x70,
  23039. 0x3e,
  23040. 0xb5,
  23041. 0x66,
  23042. 0x48,
  23043. 0x03,
  23044. 0xf6,
  23045. 0x0e,
  23046. 0x61,
  23047. 0x35,
  23048. 0x57,
  23049. 0xb9,
  23050. 0x86,
  23051. 0xc1,
  23052. 0x1d,
  23053. 0x9e,
  23054. 0xe1,
  23055. 0xf8,
  23056. 0x98,
  23057. 0x11,
  23058. 0x69,
  23059. 0xd9,
  23060. 0x8e,
  23061. 0x94,
  23062. 0x9b,
  23063. 0x1e,
  23064. 0x87,
  23065. 0xe9,
  23066. 0xce,
  23067. 0x55,
  23068. 0x28,
  23069. 0xdf,
  23070. 0x8c,
  23071. 0xa1,
  23072. 0x89,
  23073. 0x0d,
  23074. 0xbf,
  23075. 0xe6,
  23076. 0x42,
  23077. 0x68,
  23078. 0x41,
  23079. 0x99,
  23080. 0x2d,
  23081. 0x0f,
  23082. 0xb0,
  23083. 0x54,
  23084. 0xbb,
  23085. 0x16
  23086. ]);
  23087. var inv_s = new Uint8Array([
  23088. 0x52,
  23089. 0x09,
  23090. 0x6a,
  23091. 0xd5,
  23092. 0x30,
  23093. 0x36,
  23094. 0xa5,
  23095. 0x38,
  23096. 0xbf,
  23097. 0x40,
  23098. 0xa3,
  23099. 0x9e,
  23100. 0x81,
  23101. 0xf3,
  23102. 0xd7,
  23103. 0xfb,
  23104. 0x7c,
  23105. 0xe3,
  23106. 0x39,
  23107. 0x82,
  23108. 0x9b,
  23109. 0x2f,
  23110. 0xff,
  23111. 0x87,
  23112. 0x34,
  23113. 0x8e,
  23114. 0x43,
  23115. 0x44,
  23116. 0xc4,
  23117. 0xde,
  23118. 0xe9,
  23119. 0xcb,
  23120. 0x54,
  23121. 0x7b,
  23122. 0x94,
  23123. 0x32,
  23124. 0xa6,
  23125. 0xc2,
  23126. 0x23,
  23127. 0x3d,
  23128. 0xee,
  23129. 0x4c,
  23130. 0x95,
  23131. 0x0b,
  23132. 0x42,
  23133. 0xfa,
  23134. 0xc3,
  23135. 0x4e,
  23136. 0x08,
  23137. 0x2e,
  23138. 0xa1,
  23139. 0x66,
  23140. 0x28,
  23141. 0xd9,
  23142. 0x24,
  23143. 0xb2,
  23144. 0x76,
  23145. 0x5b,
  23146. 0xa2,
  23147. 0x49,
  23148. 0x6d,
  23149. 0x8b,
  23150. 0xd1,
  23151. 0x25,
  23152. 0x72,
  23153. 0xf8,
  23154. 0xf6,
  23155. 0x64,
  23156. 0x86,
  23157. 0x68,
  23158. 0x98,
  23159. 0x16,
  23160. 0xd4,
  23161. 0xa4,
  23162. 0x5c,
  23163. 0xcc,
  23164. 0x5d,
  23165. 0x65,
  23166. 0xb6,
  23167. 0x92,
  23168. 0x6c,
  23169. 0x70,
  23170. 0x48,
  23171. 0x50,
  23172. 0xfd,
  23173. 0xed,
  23174. 0xb9,
  23175. 0xda,
  23176. 0x5e,
  23177. 0x15,
  23178. 0x46,
  23179. 0x57,
  23180. 0xa7,
  23181. 0x8d,
  23182. 0x9d,
  23183. 0x84,
  23184. 0x90,
  23185. 0xd8,
  23186. 0xab,
  23187. 0x00,
  23188. 0x8c,
  23189. 0xbc,
  23190. 0xd3,
  23191. 0x0a,
  23192. 0xf7,
  23193. 0xe4,
  23194. 0x58,
  23195. 0x05,
  23196. 0xb8,
  23197. 0xb3,
  23198. 0x45,
  23199. 0x06,
  23200. 0xd0,
  23201. 0x2c,
  23202. 0x1e,
  23203. 0x8f,
  23204. 0xca,
  23205. 0x3f,
  23206. 0x0f,
  23207. 0x02,
  23208. 0xc1,
  23209. 0xaf,
  23210. 0xbd,
  23211. 0x03,
  23212. 0x01,
  23213. 0x13,
  23214. 0x8a,
  23215. 0x6b,
  23216. 0x3a,
  23217. 0x91,
  23218. 0x11,
  23219. 0x41,
  23220. 0x4f,
  23221. 0x67,
  23222. 0xdc,
  23223. 0xea,
  23224. 0x97,
  23225. 0xf2,
  23226. 0xcf,
  23227. 0xce,
  23228. 0xf0,
  23229. 0xb4,
  23230. 0xe6,
  23231. 0x73,
  23232. 0x96,
  23233. 0xac,
  23234. 0x74,
  23235. 0x22,
  23236. 0xe7,
  23237. 0xad,
  23238. 0x35,
  23239. 0x85,
  23240. 0xe2,
  23241. 0xf9,
  23242. 0x37,
  23243. 0xe8,
  23244. 0x1c,
  23245. 0x75,
  23246. 0xdf,
  23247. 0x6e,
  23248. 0x47,
  23249. 0xf1,
  23250. 0x1a,
  23251. 0x71,
  23252. 0x1d,
  23253. 0x29,
  23254. 0xc5,
  23255. 0x89,
  23256. 0x6f,
  23257. 0xb7,
  23258. 0x62,
  23259. 0x0e,
  23260. 0xaa,
  23261. 0x18,
  23262. 0xbe,
  23263. 0x1b,
  23264. 0xfc,
  23265. 0x56,
  23266. 0x3e,
  23267. 0x4b,
  23268. 0xc6,
  23269. 0xd2,
  23270. 0x79,
  23271. 0x20,
  23272. 0x9a,
  23273. 0xdb,
  23274. 0xc0,
  23275. 0xfe,
  23276. 0x78,
  23277. 0xcd,
  23278. 0x5a,
  23279. 0xf4,
  23280. 0x1f,
  23281. 0xdd,
  23282. 0xa8,
  23283. 0x33,
  23284. 0x88,
  23285. 0x07,
  23286. 0xc7,
  23287. 0x31,
  23288. 0xb1,
  23289. 0x12,
  23290. 0x10,
  23291. 0x59,
  23292. 0x27,
  23293. 0x80,
  23294. 0xec,
  23295. 0x5f,
  23296. 0x60,
  23297. 0x51,
  23298. 0x7f,
  23299. 0xa9,
  23300. 0x19,
  23301. 0xb5,
  23302. 0x4a,
  23303. 0x0d,
  23304. 0x2d,
  23305. 0xe5,
  23306. 0x7a,
  23307. 0x9f,
  23308. 0x93,
  23309. 0xc9,
  23310. 0x9c,
  23311. 0xef,
  23312. 0xa0,
  23313. 0xe0,
  23314. 0x3b,
  23315. 0x4d,
  23316. 0xae,
  23317. 0x2a,
  23318. 0xf5,
  23319. 0xb0,
  23320. 0xc8,
  23321. 0xeb,
  23322. 0xbb,
  23323. 0x3c,
  23324. 0x83,
  23325. 0x53,
  23326. 0x99,
  23327. 0x61,
  23328. 0x17,
  23329. 0x2b,
  23330. 0x04,
  23331. 0x7e,
  23332. 0xba,
  23333. 0x77,
  23334. 0xd6,
  23335. 0x26,
  23336. 0xe1,
  23337. 0x69,
  23338. 0x14,
  23339. 0x63,
  23340. 0x55,
  23341. 0x21,
  23342. 0x0c,
  23343. 0x7d
  23344. ]);
  23345. var mixCol = new Uint8Array(256);
  23346. for (var i = 0; i < 256; i++) {
  23347. if (i < 128) {
  23348. mixCol[i] = i << 1;
  23349. } else {
  23350. mixCol[i] = i << 1 ^ 0x1b;
  23351. }
  23352. }
  23353. var mix = new Uint32Array([
  23354. 0x00000000,
  23355. 0x0e090d0b,
  23356. 0x1c121a16,
  23357. 0x121b171d,
  23358. 0x3824342c,
  23359. 0x362d3927,
  23360. 0x24362e3a,
  23361. 0x2a3f2331,
  23362. 0x70486858,
  23363. 0x7e416553,
  23364. 0x6c5a724e,
  23365. 0x62537f45,
  23366. 0x486c5c74,
  23367. 0x4665517f,
  23368. 0x547e4662,
  23369. 0x5a774b69,
  23370. 0xe090d0b0,
  23371. 0xee99ddbb,
  23372. 0xfc82caa6,
  23373. 0xf28bc7ad,
  23374. 0xd8b4e49c,
  23375. 0xd6bde997,
  23376. 0xc4a6fe8a,
  23377. 0xcaaff381,
  23378. 0x90d8b8e8,
  23379. 0x9ed1b5e3,
  23380. 0x8ccaa2fe,
  23381. 0x82c3aff5,
  23382. 0xa8fc8cc4,
  23383. 0xa6f581cf,
  23384. 0xb4ee96d2,
  23385. 0xbae79bd9,
  23386. 0xdb3bbb7b,
  23387. 0xd532b670,
  23388. 0xc729a16d,
  23389. 0xc920ac66,
  23390. 0xe31f8f57,
  23391. 0xed16825c,
  23392. 0xff0d9541,
  23393. 0xf104984a,
  23394. 0xab73d323,
  23395. 0xa57ade28,
  23396. 0xb761c935,
  23397. 0xb968c43e,
  23398. 0x9357e70f,
  23399. 0x9d5eea04,
  23400. 0x8f45fd19,
  23401. 0x814cf012,
  23402. 0x3bab6bcb,
  23403. 0x35a266c0,
  23404. 0x27b971dd,
  23405. 0x29b07cd6,
  23406. 0x038f5fe7,
  23407. 0x0d8652ec,
  23408. 0x1f9d45f1,
  23409. 0x119448fa,
  23410. 0x4be30393,
  23411. 0x45ea0e98,
  23412. 0x57f11985,
  23413. 0x59f8148e,
  23414. 0x73c737bf,
  23415. 0x7dce3ab4,
  23416. 0x6fd52da9,
  23417. 0x61dc20a2,
  23418. 0xad766df6,
  23419. 0xa37f60fd,
  23420. 0xb16477e0,
  23421. 0xbf6d7aeb,
  23422. 0x955259da,
  23423. 0x9b5b54d1,
  23424. 0x894043cc,
  23425. 0x87494ec7,
  23426. 0xdd3e05ae,
  23427. 0xd33708a5,
  23428. 0xc12c1fb8,
  23429. 0xcf2512b3,
  23430. 0xe51a3182,
  23431. 0xeb133c89,
  23432. 0xf9082b94,
  23433. 0xf701269f,
  23434. 0x4de6bd46,
  23435. 0x43efb04d,
  23436. 0x51f4a750,
  23437. 0x5ffdaa5b,
  23438. 0x75c2896a,
  23439. 0x7bcb8461,
  23440. 0x69d0937c,
  23441. 0x67d99e77,
  23442. 0x3daed51e,
  23443. 0x33a7d815,
  23444. 0x21bccf08,
  23445. 0x2fb5c203,
  23446. 0x058ae132,
  23447. 0x0b83ec39,
  23448. 0x1998fb24,
  23449. 0x1791f62f,
  23450. 0x764dd68d,
  23451. 0x7844db86,
  23452. 0x6a5fcc9b,
  23453. 0x6456c190,
  23454. 0x4e69e2a1,
  23455. 0x4060efaa,
  23456. 0x527bf8b7,
  23457. 0x5c72f5bc,
  23458. 0x0605bed5,
  23459. 0x080cb3de,
  23460. 0x1a17a4c3,
  23461. 0x141ea9c8,
  23462. 0x3e218af9,
  23463. 0x302887f2,
  23464. 0x223390ef,
  23465. 0x2c3a9de4,
  23466. 0x96dd063d,
  23467. 0x98d40b36,
  23468. 0x8acf1c2b,
  23469. 0x84c61120,
  23470. 0xaef93211,
  23471. 0xa0f03f1a,
  23472. 0xb2eb2807,
  23473. 0xbce2250c,
  23474. 0xe6956e65,
  23475. 0xe89c636e,
  23476. 0xfa877473,
  23477. 0xf48e7978,
  23478. 0xdeb15a49,
  23479. 0xd0b85742,
  23480. 0xc2a3405f,
  23481. 0xccaa4d54,
  23482. 0x41ecdaf7,
  23483. 0x4fe5d7fc,
  23484. 0x5dfec0e1,
  23485. 0x53f7cdea,
  23486. 0x79c8eedb,
  23487. 0x77c1e3d0,
  23488. 0x65daf4cd,
  23489. 0x6bd3f9c6,
  23490. 0x31a4b2af,
  23491. 0x3fadbfa4,
  23492. 0x2db6a8b9,
  23493. 0x23bfa5b2,
  23494. 0x09808683,
  23495. 0x07898b88,
  23496. 0x15929c95,
  23497. 0x1b9b919e,
  23498. 0xa17c0a47,
  23499. 0xaf75074c,
  23500. 0xbd6e1051,
  23501. 0xb3671d5a,
  23502. 0x99583e6b,
  23503. 0x97513360,
  23504. 0x854a247d,
  23505. 0x8b432976,
  23506. 0xd134621f,
  23507. 0xdf3d6f14,
  23508. 0xcd267809,
  23509. 0xc32f7502,
  23510. 0xe9105633,
  23511. 0xe7195b38,
  23512. 0xf5024c25,
  23513. 0xfb0b412e,
  23514. 0x9ad7618c,
  23515. 0x94de6c87,
  23516. 0x86c57b9a,
  23517. 0x88cc7691,
  23518. 0xa2f355a0,
  23519. 0xacfa58ab,
  23520. 0xbee14fb6,
  23521. 0xb0e842bd,
  23522. 0xea9f09d4,
  23523. 0xe49604df,
  23524. 0xf68d13c2,
  23525. 0xf8841ec9,
  23526. 0xd2bb3df8,
  23527. 0xdcb230f3,
  23528. 0xcea927ee,
  23529. 0xc0a02ae5,
  23530. 0x7a47b13c,
  23531. 0x744ebc37,
  23532. 0x6655ab2a,
  23533. 0x685ca621,
  23534. 0x42638510,
  23535. 0x4c6a881b,
  23536. 0x5e719f06,
  23537. 0x5078920d,
  23538. 0x0a0fd964,
  23539. 0x0406d46f,
  23540. 0x161dc372,
  23541. 0x1814ce79,
  23542. 0x322bed48,
  23543. 0x3c22e043,
  23544. 0x2e39f75e,
  23545. 0x2030fa55,
  23546. 0xec9ab701,
  23547. 0xe293ba0a,
  23548. 0xf088ad17,
  23549. 0xfe81a01c,
  23550. 0xd4be832d,
  23551. 0xdab78e26,
  23552. 0xc8ac993b,
  23553. 0xc6a59430,
  23554. 0x9cd2df59,
  23555. 0x92dbd252,
  23556. 0x80c0c54f,
  23557. 0x8ec9c844,
  23558. 0xa4f6eb75,
  23559. 0xaaffe67e,
  23560. 0xb8e4f163,
  23561. 0xb6edfc68,
  23562. 0x0c0a67b1,
  23563. 0x02036aba,
  23564. 0x10187da7,
  23565. 0x1e1170ac,
  23566. 0x342e539d,
  23567. 0x3a275e96,
  23568. 0x283c498b,
  23569. 0x26354480,
  23570. 0x7c420fe9,
  23571. 0x724b02e2,
  23572. 0x605015ff,
  23573. 0x6e5918f4,
  23574. 0x44663bc5,
  23575. 0x4a6f36ce,
  23576. 0x587421d3,
  23577. 0x567d2cd8,
  23578. 0x37a10c7a,
  23579. 0x39a80171,
  23580. 0x2bb3166c,
  23581. 0x25ba1b67,
  23582. 0x0f853856,
  23583. 0x018c355d,
  23584. 0x13972240,
  23585. 0x1d9e2f4b,
  23586. 0x47e96422,
  23587. 0x49e06929,
  23588. 0x5bfb7e34,
  23589. 0x55f2733f,
  23590. 0x7fcd500e,
  23591. 0x71c45d05,
  23592. 0x63df4a18,
  23593. 0x6dd64713,
  23594. 0xd731dcca,
  23595. 0xd938d1c1,
  23596. 0xcb23c6dc,
  23597. 0xc52acbd7,
  23598. 0xef15e8e6,
  23599. 0xe11ce5ed,
  23600. 0xf307f2f0,
  23601. 0xfd0efffb,
  23602. 0xa779b492,
  23603. 0xa970b999,
  23604. 0xbb6bae84,
  23605. 0xb562a38f,
  23606. 0x9f5d80be,
  23607. 0x91548db5,
  23608. 0x834f9aa8,
  23609. 0x8d4697a3
  23610. ]);
  23611. function expandKey128(cipherKey) {
  23612. var b = 176, result = new Uint8Array(b);
  23613. result.set(cipherKey);
  23614. for (var j = 16, i = 1; j < b; ++i) {
  23615. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  23616. t1 = s[t1];
  23617. t2 = s[t2];
  23618. t3 = s[t3];
  23619. t4 = s[t4];
  23620. t1 = t1 ^ rcon[i];
  23621. for (var n = 0; n < 4; ++n) {
  23622. result[j] = t1 ^= result[j - 16];
  23623. j++;
  23624. result[j] = t2 ^= result[j - 16];
  23625. j++;
  23626. result[j] = t3 ^= result[j - 16];
  23627. j++;
  23628. result[j] = t4 ^= result[j - 16];
  23629. j++;
  23630. }
  23631. }
  23632. return result;
  23633. }
  23634. function decrypt128(input, key) {
  23635. var state = new Uint8Array(16);
  23636. state.set(input);
  23637. var i, j, k;
  23638. var t, u, v;
  23639. for (j = 0, k = 160; j < 16; ++j, ++k) {
  23640. state[j] ^= key[k];
  23641. }
  23642. for (i = 9; i >= 1; --i) {
  23643. t = state[13];
  23644. state[13] = state[9];
  23645. state[9] = state[5];
  23646. state[5] = state[1];
  23647. state[1] = t;
  23648. t = state[14];
  23649. u = state[10];
  23650. state[14] = state[6];
  23651. state[10] = state[2];
  23652. state[6] = t;
  23653. state[2] = u;
  23654. t = state[15];
  23655. u = state[11];
  23656. v = state[7];
  23657. state[15] = state[3];
  23658. state[11] = t;
  23659. state[7] = u;
  23660. state[3] = v;
  23661. for (j = 0; j < 16; ++j) {
  23662. state[j] = inv_s[state[j]];
  23663. }
  23664. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  23665. state[j] ^= key[k];
  23666. }
  23667. for (j = 0; j < 16; j += 4) {
  23668. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  23669. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  23670. state[j] = t >>> 24 & 0xFF;
  23671. state[j + 1] = t >> 16 & 0xFF;
  23672. state[j + 2] = t >> 8 & 0xFF;
  23673. state[j + 3] = t & 0xFF;
  23674. }
  23675. }
  23676. t = state[13];
  23677. state[13] = state[9];
  23678. state[9] = state[5];
  23679. state[5] = state[1];
  23680. state[1] = t;
  23681. t = state[14];
  23682. u = state[10];
  23683. state[14] = state[6];
  23684. state[10] = state[2];
  23685. state[6] = t;
  23686. state[2] = u;
  23687. t = state[15];
  23688. u = state[11];
  23689. v = state[7];
  23690. state[15] = state[3];
  23691. state[11] = t;
  23692. state[7] = u;
  23693. state[3] = v;
  23694. for (j = 0; j < 16; ++j) {
  23695. state[j] = inv_s[state[j]];
  23696. state[j] ^= key[j];
  23697. }
  23698. return state;
  23699. }
  23700. function encrypt128(input, key) {
  23701. var t, u, v, k;
  23702. var state = new Uint8Array(16);
  23703. state.set(input);
  23704. for (j = 0; j < 16; ++j) {
  23705. state[j] ^= key[j];
  23706. }
  23707. for (i = 1; i < 10; i++) {
  23708. for (j = 0; j < 16; ++j) {
  23709. state[j] = s[state[j]];
  23710. }
  23711. v = state[1];
  23712. state[1] = state[5];
  23713. state[5] = state[9];
  23714. state[9] = state[13];
  23715. state[13] = v;
  23716. v = state[2];
  23717. u = state[6];
  23718. state[2] = state[10];
  23719. state[6] = state[14];
  23720. state[10] = v;
  23721. state[14] = u;
  23722. v = state[3];
  23723. u = state[7];
  23724. t = state[11];
  23725. state[3] = state[15];
  23726. state[7] = v;
  23727. state[11] = u;
  23728. state[15] = t;
  23729. for (var j = 0; j < 16; j += 4) {
  23730. var s0 = state[j + 0], s1 = state[j + 1];
  23731. var s2 = state[j + 2], s3 = state[j + 3];
  23732. t = s0 ^ s1 ^ s2 ^ s3;
  23733. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  23734. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  23735. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  23736. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  23737. }
  23738. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  23739. state[j] ^= key[k];
  23740. }
  23741. }
  23742. for (j = 0; j < 16; ++j) {
  23743. state[j] = s[state[j]];
  23744. }
  23745. v = state[1];
  23746. state[1] = state[5];
  23747. state[5] = state[9];
  23748. state[9] = state[13];
  23749. state[13] = v;
  23750. v = state[2];
  23751. u = state[6];
  23752. state[2] = state[10];
  23753. state[6] = state[14];
  23754. state[10] = v;
  23755. state[14] = u;
  23756. v = state[3];
  23757. u = state[7];
  23758. t = state[11];
  23759. state[3] = state[15];
  23760. state[7] = v;
  23761. state[11] = u;
  23762. state[15] = t;
  23763. for (j = 0, k = 160; j < 16; ++j, ++k) {
  23764. state[j] ^= key[k];
  23765. }
  23766. return state;
  23767. }
  23768. function AES128Cipher(key) {
  23769. this.key = expandKey128(key);
  23770. this.buffer = new Uint8Array(16);
  23771. this.bufferPosition = 0;
  23772. }
  23773. function decryptBlock2(data, finalize) {
  23774. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  23775. for (i = 0; i < sourceLength; ++i) {
  23776. buffer[bufferLength] = data[i];
  23777. ++bufferLength;
  23778. if (bufferLength < 16) {
  23779. continue;
  23780. }
  23781. var plain = decrypt128(buffer, this.key);
  23782. for (j = 0; j < 16; ++j) {
  23783. plain[j] ^= iv[j];
  23784. }
  23785. iv = buffer;
  23786. result.push(plain);
  23787. buffer = new Uint8Array(16);
  23788. bufferLength = 0;
  23789. }
  23790. this.buffer = buffer;
  23791. this.bufferLength = bufferLength;
  23792. this.iv = iv;
  23793. if (result.length === 0) {
  23794. return new Uint8Array([]);
  23795. }
  23796. var outputLength = 16 * result.length;
  23797. if (finalize) {
  23798. var lastBlock = result[result.length - 1];
  23799. var psLen = lastBlock[15];
  23800. if (psLen <= 16) {
  23801. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  23802. if (lastBlock[i] !== psLen) {
  23803. psLen = 0;
  23804. break;
  23805. }
  23806. }
  23807. outputLength -= psLen;
  23808. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  23809. }
  23810. }
  23811. var output = new Uint8Array(outputLength);
  23812. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  23813. output.set(result[i], j);
  23814. }
  23815. return output;
  23816. }
  23817. AES128Cipher.prototype = {
  23818. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  23819. var i, sourceLength = data.length;
  23820. var buffer = this.buffer, bufferLength = this.bufferPosition;
  23821. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  23822. buffer[bufferLength] = data[i];
  23823. }
  23824. if (bufferLength < 16) {
  23825. this.bufferLength = bufferLength;
  23826. return new Uint8Array([]);
  23827. }
  23828. this.iv = buffer;
  23829. this.buffer = new Uint8Array(16);
  23830. this.bufferLength = 0;
  23831. this.decryptBlock = decryptBlock2;
  23832. return this.decryptBlock(data.subarray(16), finalize);
  23833. },
  23834. encrypt: function AES128Cipher_encrypt(data, iv) {
  23835. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  23836. if (!iv) {
  23837. iv = new Uint8Array(16);
  23838. }
  23839. for (i = 0; i < sourceLength; ++i) {
  23840. buffer[bufferLength] = data[i];
  23841. ++bufferLength;
  23842. if (bufferLength < 16) {
  23843. continue;
  23844. }
  23845. for (j = 0; j < 16; ++j) {
  23846. buffer[j] ^= iv[j];
  23847. }
  23848. var cipher = encrypt128(buffer, this.key);
  23849. iv = cipher;
  23850. result.push(cipher);
  23851. buffer = new Uint8Array(16);
  23852. bufferLength = 0;
  23853. }
  23854. this.buffer = buffer;
  23855. this.bufferLength = bufferLength;
  23856. this.iv = iv;
  23857. if (result.length === 0) {
  23858. return new Uint8Array([]);
  23859. }
  23860. var outputLength = 16 * result.length;
  23861. var output = new Uint8Array(outputLength);
  23862. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  23863. output.set(result[i], j);
  23864. }
  23865. return output;
  23866. }
  23867. };
  23868. return AES128Cipher;
  23869. }();
  23870. var AES256Cipher = function AES256CipherClosure() {
  23871. var s = new Uint8Array([
  23872. 0x63,
  23873. 0x7c,
  23874. 0x77,
  23875. 0x7b,
  23876. 0xf2,
  23877. 0x6b,
  23878. 0x6f,
  23879. 0xc5,
  23880. 0x30,
  23881. 0x01,
  23882. 0x67,
  23883. 0x2b,
  23884. 0xfe,
  23885. 0xd7,
  23886. 0xab,
  23887. 0x76,
  23888. 0xca,
  23889. 0x82,
  23890. 0xc9,
  23891. 0x7d,
  23892. 0xfa,
  23893. 0x59,
  23894. 0x47,
  23895. 0xf0,
  23896. 0xad,
  23897. 0xd4,
  23898. 0xa2,
  23899. 0xaf,
  23900. 0x9c,
  23901. 0xa4,
  23902. 0x72,
  23903. 0xc0,
  23904. 0xb7,
  23905. 0xfd,
  23906. 0x93,
  23907. 0x26,
  23908. 0x36,
  23909. 0x3f,
  23910. 0xf7,
  23911. 0xcc,
  23912. 0x34,
  23913. 0xa5,
  23914. 0xe5,
  23915. 0xf1,
  23916. 0x71,
  23917. 0xd8,
  23918. 0x31,
  23919. 0x15,
  23920. 0x04,
  23921. 0xc7,
  23922. 0x23,
  23923. 0xc3,
  23924. 0x18,
  23925. 0x96,
  23926. 0x05,
  23927. 0x9a,
  23928. 0x07,
  23929. 0x12,
  23930. 0x80,
  23931. 0xe2,
  23932. 0xeb,
  23933. 0x27,
  23934. 0xb2,
  23935. 0x75,
  23936. 0x09,
  23937. 0x83,
  23938. 0x2c,
  23939. 0x1a,
  23940. 0x1b,
  23941. 0x6e,
  23942. 0x5a,
  23943. 0xa0,
  23944. 0x52,
  23945. 0x3b,
  23946. 0xd6,
  23947. 0xb3,
  23948. 0x29,
  23949. 0xe3,
  23950. 0x2f,
  23951. 0x84,
  23952. 0x53,
  23953. 0xd1,
  23954. 0x00,
  23955. 0xed,
  23956. 0x20,
  23957. 0xfc,
  23958. 0xb1,
  23959. 0x5b,
  23960. 0x6a,
  23961. 0xcb,
  23962. 0xbe,
  23963. 0x39,
  23964. 0x4a,
  23965. 0x4c,
  23966. 0x58,
  23967. 0xcf,
  23968. 0xd0,
  23969. 0xef,
  23970. 0xaa,
  23971. 0xfb,
  23972. 0x43,
  23973. 0x4d,
  23974. 0x33,
  23975. 0x85,
  23976. 0x45,
  23977. 0xf9,
  23978. 0x02,
  23979. 0x7f,
  23980. 0x50,
  23981. 0x3c,
  23982. 0x9f,
  23983. 0xa8,
  23984. 0x51,
  23985. 0xa3,
  23986. 0x40,
  23987. 0x8f,
  23988. 0x92,
  23989. 0x9d,
  23990. 0x38,
  23991. 0xf5,
  23992. 0xbc,
  23993. 0xb6,
  23994. 0xda,
  23995. 0x21,
  23996. 0x10,
  23997. 0xff,
  23998. 0xf3,
  23999. 0xd2,
  24000. 0xcd,
  24001. 0x0c,
  24002. 0x13,
  24003. 0xec,
  24004. 0x5f,
  24005. 0x97,
  24006. 0x44,
  24007. 0x17,
  24008. 0xc4,
  24009. 0xa7,
  24010. 0x7e,
  24011. 0x3d,
  24012. 0x64,
  24013. 0x5d,
  24014. 0x19,
  24015. 0x73,
  24016. 0x60,
  24017. 0x81,
  24018. 0x4f,
  24019. 0xdc,
  24020. 0x22,
  24021. 0x2a,
  24022. 0x90,
  24023. 0x88,
  24024. 0x46,
  24025. 0xee,
  24026. 0xb8,
  24027. 0x14,
  24028. 0xde,
  24029. 0x5e,
  24030. 0x0b,
  24031. 0xdb,
  24032. 0xe0,
  24033. 0x32,
  24034. 0x3a,
  24035. 0x0a,
  24036. 0x49,
  24037. 0x06,
  24038. 0x24,
  24039. 0x5c,
  24040. 0xc2,
  24041. 0xd3,
  24042. 0xac,
  24043. 0x62,
  24044. 0x91,
  24045. 0x95,
  24046. 0xe4,
  24047. 0x79,
  24048. 0xe7,
  24049. 0xc8,
  24050. 0x37,
  24051. 0x6d,
  24052. 0x8d,
  24053. 0xd5,
  24054. 0x4e,
  24055. 0xa9,
  24056. 0x6c,
  24057. 0x56,
  24058. 0xf4,
  24059. 0xea,
  24060. 0x65,
  24061. 0x7a,
  24062. 0xae,
  24063. 0x08,
  24064. 0xba,
  24065. 0x78,
  24066. 0x25,
  24067. 0x2e,
  24068. 0x1c,
  24069. 0xa6,
  24070. 0xb4,
  24071. 0xc6,
  24072. 0xe8,
  24073. 0xdd,
  24074. 0x74,
  24075. 0x1f,
  24076. 0x4b,
  24077. 0xbd,
  24078. 0x8b,
  24079. 0x8a,
  24080. 0x70,
  24081. 0x3e,
  24082. 0xb5,
  24083. 0x66,
  24084. 0x48,
  24085. 0x03,
  24086. 0xf6,
  24087. 0x0e,
  24088. 0x61,
  24089. 0x35,
  24090. 0x57,
  24091. 0xb9,
  24092. 0x86,
  24093. 0xc1,
  24094. 0x1d,
  24095. 0x9e,
  24096. 0xe1,
  24097. 0xf8,
  24098. 0x98,
  24099. 0x11,
  24100. 0x69,
  24101. 0xd9,
  24102. 0x8e,
  24103. 0x94,
  24104. 0x9b,
  24105. 0x1e,
  24106. 0x87,
  24107. 0xe9,
  24108. 0xce,
  24109. 0x55,
  24110. 0x28,
  24111. 0xdf,
  24112. 0x8c,
  24113. 0xa1,
  24114. 0x89,
  24115. 0x0d,
  24116. 0xbf,
  24117. 0xe6,
  24118. 0x42,
  24119. 0x68,
  24120. 0x41,
  24121. 0x99,
  24122. 0x2d,
  24123. 0x0f,
  24124. 0xb0,
  24125. 0x54,
  24126. 0xbb,
  24127. 0x16
  24128. ]);
  24129. var inv_s = new Uint8Array([
  24130. 0x52,
  24131. 0x09,
  24132. 0x6a,
  24133. 0xd5,
  24134. 0x30,
  24135. 0x36,
  24136. 0xa5,
  24137. 0x38,
  24138. 0xbf,
  24139. 0x40,
  24140. 0xa3,
  24141. 0x9e,
  24142. 0x81,
  24143. 0xf3,
  24144. 0xd7,
  24145. 0xfb,
  24146. 0x7c,
  24147. 0xe3,
  24148. 0x39,
  24149. 0x82,
  24150. 0x9b,
  24151. 0x2f,
  24152. 0xff,
  24153. 0x87,
  24154. 0x34,
  24155. 0x8e,
  24156. 0x43,
  24157. 0x44,
  24158. 0xc4,
  24159. 0xde,
  24160. 0xe9,
  24161. 0xcb,
  24162. 0x54,
  24163. 0x7b,
  24164. 0x94,
  24165. 0x32,
  24166. 0xa6,
  24167. 0xc2,
  24168. 0x23,
  24169. 0x3d,
  24170. 0xee,
  24171. 0x4c,
  24172. 0x95,
  24173. 0x0b,
  24174. 0x42,
  24175. 0xfa,
  24176. 0xc3,
  24177. 0x4e,
  24178. 0x08,
  24179. 0x2e,
  24180. 0xa1,
  24181. 0x66,
  24182. 0x28,
  24183. 0xd9,
  24184. 0x24,
  24185. 0xb2,
  24186. 0x76,
  24187. 0x5b,
  24188. 0xa2,
  24189. 0x49,
  24190. 0x6d,
  24191. 0x8b,
  24192. 0xd1,
  24193. 0x25,
  24194. 0x72,
  24195. 0xf8,
  24196. 0xf6,
  24197. 0x64,
  24198. 0x86,
  24199. 0x68,
  24200. 0x98,
  24201. 0x16,
  24202. 0xd4,
  24203. 0xa4,
  24204. 0x5c,
  24205. 0xcc,
  24206. 0x5d,
  24207. 0x65,
  24208. 0xb6,
  24209. 0x92,
  24210. 0x6c,
  24211. 0x70,
  24212. 0x48,
  24213. 0x50,
  24214. 0xfd,
  24215. 0xed,
  24216. 0xb9,
  24217. 0xda,
  24218. 0x5e,
  24219. 0x15,
  24220. 0x46,
  24221. 0x57,
  24222. 0xa7,
  24223. 0x8d,
  24224. 0x9d,
  24225. 0x84,
  24226. 0x90,
  24227. 0xd8,
  24228. 0xab,
  24229. 0x00,
  24230. 0x8c,
  24231. 0xbc,
  24232. 0xd3,
  24233. 0x0a,
  24234. 0xf7,
  24235. 0xe4,
  24236. 0x58,
  24237. 0x05,
  24238. 0xb8,
  24239. 0xb3,
  24240. 0x45,
  24241. 0x06,
  24242. 0xd0,
  24243. 0x2c,
  24244. 0x1e,
  24245. 0x8f,
  24246. 0xca,
  24247. 0x3f,
  24248. 0x0f,
  24249. 0x02,
  24250. 0xc1,
  24251. 0xaf,
  24252. 0xbd,
  24253. 0x03,
  24254. 0x01,
  24255. 0x13,
  24256. 0x8a,
  24257. 0x6b,
  24258. 0x3a,
  24259. 0x91,
  24260. 0x11,
  24261. 0x41,
  24262. 0x4f,
  24263. 0x67,
  24264. 0xdc,
  24265. 0xea,
  24266. 0x97,
  24267. 0xf2,
  24268. 0xcf,
  24269. 0xce,
  24270. 0xf0,
  24271. 0xb4,
  24272. 0xe6,
  24273. 0x73,
  24274. 0x96,
  24275. 0xac,
  24276. 0x74,
  24277. 0x22,
  24278. 0xe7,
  24279. 0xad,
  24280. 0x35,
  24281. 0x85,
  24282. 0xe2,
  24283. 0xf9,
  24284. 0x37,
  24285. 0xe8,
  24286. 0x1c,
  24287. 0x75,
  24288. 0xdf,
  24289. 0x6e,
  24290. 0x47,
  24291. 0xf1,
  24292. 0x1a,
  24293. 0x71,
  24294. 0x1d,
  24295. 0x29,
  24296. 0xc5,
  24297. 0x89,
  24298. 0x6f,
  24299. 0xb7,
  24300. 0x62,
  24301. 0x0e,
  24302. 0xaa,
  24303. 0x18,
  24304. 0xbe,
  24305. 0x1b,
  24306. 0xfc,
  24307. 0x56,
  24308. 0x3e,
  24309. 0x4b,
  24310. 0xc6,
  24311. 0xd2,
  24312. 0x79,
  24313. 0x20,
  24314. 0x9a,
  24315. 0xdb,
  24316. 0xc0,
  24317. 0xfe,
  24318. 0x78,
  24319. 0xcd,
  24320. 0x5a,
  24321. 0xf4,
  24322. 0x1f,
  24323. 0xdd,
  24324. 0xa8,
  24325. 0x33,
  24326. 0x88,
  24327. 0x07,
  24328. 0xc7,
  24329. 0x31,
  24330. 0xb1,
  24331. 0x12,
  24332. 0x10,
  24333. 0x59,
  24334. 0x27,
  24335. 0x80,
  24336. 0xec,
  24337. 0x5f,
  24338. 0x60,
  24339. 0x51,
  24340. 0x7f,
  24341. 0xa9,
  24342. 0x19,
  24343. 0xb5,
  24344. 0x4a,
  24345. 0x0d,
  24346. 0x2d,
  24347. 0xe5,
  24348. 0x7a,
  24349. 0x9f,
  24350. 0x93,
  24351. 0xc9,
  24352. 0x9c,
  24353. 0xef,
  24354. 0xa0,
  24355. 0xe0,
  24356. 0x3b,
  24357. 0x4d,
  24358. 0xae,
  24359. 0x2a,
  24360. 0xf5,
  24361. 0xb0,
  24362. 0xc8,
  24363. 0xeb,
  24364. 0xbb,
  24365. 0x3c,
  24366. 0x83,
  24367. 0x53,
  24368. 0x99,
  24369. 0x61,
  24370. 0x17,
  24371. 0x2b,
  24372. 0x04,
  24373. 0x7e,
  24374. 0xba,
  24375. 0x77,
  24376. 0xd6,
  24377. 0x26,
  24378. 0xe1,
  24379. 0x69,
  24380. 0x14,
  24381. 0x63,
  24382. 0x55,
  24383. 0x21,
  24384. 0x0c,
  24385. 0x7d
  24386. ]);
  24387. var mixCol = new Uint8Array(256);
  24388. for (var i = 0; i < 256; i++) {
  24389. if (i < 128) {
  24390. mixCol[i] = i << 1;
  24391. } else {
  24392. mixCol[i] = i << 1 ^ 0x1b;
  24393. }
  24394. }
  24395. var mix = new Uint32Array([
  24396. 0x00000000,
  24397. 0x0e090d0b,
  24398. 0x1c121a16,
  24399. 0x121b171d,
  24400. 0x3824342c,
  24401. 0x362d3927,
  24402. 0x24362e3a,
  24403. 0x2a3f2331,
  24404. 0x70486858,
  24405. 0x7e416553,
  24406. 0x6c5a724e,
  24407. 0x62537f45,
  24408. 0x486c5c74,
  24409. 0x4665517f,
  24410. 0x547e4662,
  24411. 0x5a774b69,
  24412. 0xe090d0b0,
  24413. 0xee99ddbb,
  24414. 0xfc82caa6,
  24415. 0xf28bc7ad,
  24416. 0xd8b4e49c,
  24417. 0xd6bde997,
  24418. 0xc4a6fe8a,
  24419. 0xcaaff381,
  24420. 0x90d8b8e8,
  24421. 0x9ed1b5e3,
  24422. 0x8ccaa2fe,
  24423. 0x82c3aff5,
  24424. 0xa8fc8cc4,
  24425. 0xa6f581cf,
  24426. 0xb4ee96d2,
  24427. 0xbae79bd9,
  24428. 0xdb3bbb7b,
  24429. 0xd532b670,
  24430. 0xc729a16d,
  24431. 0xc920ac66,
  24432. 0xe31f8f57,
  24433. 0xed16825c,
  24434. 0xff0d9541,
  24435. 0xf104984a,
  24436. 0xab73d323,
  24437. 0xa57ade28,
  24438. 0xb761c935,
  24439. 0xb968c43e,
  24440. 0x9357e70f,
  24441. 0x9d5eea04,
  24442. 0x8f45fd19,
  24443. 0x814cf012,
  24444. 0x3bab6bcb,
  24445. 0x35a266c0,
  24446. 0x27b971dd,
  24447. 0x29b07cd6,
  24448. 0x038f5fe7,
  24449. 0x0d8652ec,
  24450. 0x1f9d45f1,
  24451. 0x119448fa,
  24452. 0x4be30393,
  24453. 0x45ea0e98,
  24454. 0x57f11985,
  24455. 0x59f8148e,
  24456. 0x73c737bf,
  24457. 0x7dce3ab4,
  24458. 0x6fd52da9,
  24459. 0x61dc20a2,
  24460. 0xad766df6,
  24461. 0xa37f60fd,
  24462. 0xb16477e0,
  24463. 0xbf6d7aeb,
  24464. 0x955259da,
  24465. 0x9b5b54d1,
  24466. 0x894043cc,
  24467. 0x87494ec7,
  24468. 0xdd3e05ae,
  24469. 0xd33708a5,
  24470. 0xc12c1fb8,
  24471. 0xcf2512b3,
  24472. 0xe51a3182,
  24473. 0xeb133c89,
  24474. 0xf9082b94,
  24475. 0xf701269f,
  24476. 0x4de6bd46,
  24477. 0x43efb04d,
  24478. 0x51f4a750,
  24479. 0x5ffdaa5b,
  24480. 0x75c2896a,
  24481. 0x7bcb8461,
  24482. 0x69d0937c,
  24483. 0x67d99e77,
  24484. 0x3daed51e,
  24485. 0x33a7d815,
  24486. 0x21bccf08,
  24487. 0x2fb5c203,
  24488. 0x058ae132,
  24489. 0x0b83ec39,
  24490. 0x1998fb24,
  24491. 0x1791f62f,
  24492. 0x764dd68d,
  24493. 0x7844db86,
  24494. 0x6a5fcc9b,
  24495. 0x6456c190,
  24496. 0x4e69e2a1,
  24497. 0x4060efaa,
  24498. 0x527bf8b7,
  24499. 0x5c72f5bc,
  24500. 0x0605bed5,
  24501. 0x080cb3de,
  24502. 0x1a17a4c3,
  24503. 0x141ea9c8,
  24504. 0x3e218af9,
  24505. 0x302887f2,
  24506. 0x223390ef,
  24507. 0x2c3a9de4,
  24508. 0x96dd063d,
  24509. 0x98d40b36,
  24510. 0x8acf1c2b,
  24511. 0x84c61120,
  24512. 0xaef93211,
  24513. 0xa0f03f1a,
  24514. 0xb2eb2807,
  24515. 0xbce2250c,
  24516. 0xe6956e65,
  24517. 0xe89c636e,
  24518. 0xfa877473,
  24519. 0xf48e7978,
  24520. 0xdeb15a49,
  24521. 0xd0b85742,
  24522. 0xc2a3405f,
  24523. 0xccaa4d54,
  24524. 0x41ecdaf7,
  24525. 0x4fe5d7fc,
  24526. 0x5dfec0e1,
  24527. 0x53f7cdea,
  24528. 0x79c8eedb,
  24529. 0x77c1e3d0,
  24530. 0x65daf4cd,
  24531. 0x6bd3f9c6,
  24532. 0x31a4b2af,
  24533. 0x3fadbfa4,
  24534. 0x2db6a8b9,
  24535. 0x23bfa5b2,
  24536. 0x09808683,
  24537. 0x07898b88,
  24538. 0x15929c95,
  24539. 0x1b9b919e,
  24540. 0xa17c0a47,
  24541. 0xaf75074c,
  24542. 0xbd6e1051,
  24543. 0xb3671d5a,
  24544. 0x99583e6b,
  24545. 0x97513360,
  24546. 0x854a247d,
  24547. 0x8b432976,
  24548. 0xd134621f,
  24549. 0xdf3d6f14,
  24550. 0xcd267809,
  24551. 0xc32f7502,
  24552. 0xe9105633,
  24553. 0xe7195b38,
  24554. 0xf5024c25,
  24555. 0xfb0b412e,
  24556. 0x9ad7618c,
  24557. 0x94de6c87,
  24558. 0x86c57b9a,
  24559. 0x88cc7691,
  24560. 0xa2f355a0,
  24561. 0xacfa58ab,
  24562. 0xbee14fb6,
  24563. 0xb0e842bd,
  24564. 0xea9f09d4,
  24565. 0xe49604df,
  24566. 0xf68d13c2,
  24567. 0xf8841ec9,
  24568. 0xd2bb3df8,
  24569. 0xdcb230f3,
  24570. 0xcea927ee,
  24571. 0xc0a02ae5,
  24572. 0x7a47b13c,
  24573. 0x744ebc37,
  24574. 0x6655ab2a,
  24575. 0x685ca621,
  24576. 0x42638510,
  24577. 0x4c6a881b,
  24578. 0x5e719f06,
  24579. 0x5078920d,
  24580. 0x0a0fd964,
  24581. 0x0406d46f,
  24582. 0x161dc372,
  24583. 0x1814ce79,
  24584. 0x322bed48,
  24585. 0x3c22e043,
  24586. 0x2e39f75e,
  24587. 0x2030fa55,
  24588. 0xec9ab701,
  24589. 0xe293ba0a,
  24590. 0xf088ad17,
  24591. 0xfe81a01c,
  24592. 0xd4be832d,
  24593. 0xdab78e26,
  24594. 0xc8ac993b,
  24595. 0xc6a59430,
  24596. 0x9cd2df59,
  24597. 0x92dbd252,
  24598. 0x80c0c54f,
  24599. 0x8ec9c844,
  24600. 0xa4f6eb75,
  24601. 0xaaffe67e,
  24602. 0xb8e4f163,
  24603. 0xb6edfc68,
  24604. 0x0c0a67b1,
  24605. 0x02036aba,
  24606. 0x10187da7,
  24607. 0x1e1170ac,
  24608. 0x342e539d,
  24609. 0x3a275e96,
  24610. 0x283c498b,
  24611. 0x26354480,
  24612. 0x7c420fe9,
  24613. 0x724b02e2,
  24614. 0x605015ff,
  24615. 0x6e5918f4,
  24616. 0x44663bc5,
  24617. 0x4a6f36ce,
  24618. 0x587421d3,
  24619. 0x567d2cd8,
  24620. 0x37a10c7a,
  24621. 0x39a80171,
  24622. 0x2bb3166c,
  24623. 0x25ba1b67,
  24624. 0x0f853856,
  24625. 0x018c355d,
  24626. 0x13972240,
  24627. 0x1d9e2f4b,
  24628. 0x47e96422,
  24629. 0x49e06929,
  24630. 0x5bfb7e34,
  24631. 0x55f2733f,
  24632. 0x7fcd500e,
  24633. 0x71c45d05,
  24634. 0x63df4a18,
  24635. 0x6dd64713,
  24636. 0xd731dcca,
  24637. 0xd938d1c1,
  24638. 0xcb23c6dc,
  24639. 0xc52acbd7,
  24640. 0xef15e8e6,
  24641. 0xe11ce5ed,
  24642. 0xf307f2f0,
  24643. 0xfd0efffb,
  24644. 0xa779b492,
  24645. 0xa970b999,
  24646. 0xbb6bae84,
  24647. 0xb562a38f,
  24648. 0x9f5d80be,
  24649. 0x91548db5,
  24650. 0x834f9aa8,
  24651. 0x8d4697a3
  24652. ]);
  24653. function expandKey256(cipherKey) {
  24654. var b = 240, result = new Uint8Array(b);
  24655. var r = 1;
  24656. result.set(cipherKey);
  24657. for (var j = 32, i = 1; j < b; ++i) {
  24658. if (j % 32 === 16) {
  24659. t1 = s[t1];
  24660. t2 = s[t2];
  24661. t3 = s[t3];
  24662. t4 = s[t4];
  24663. } else if (j % 32 === 0) {
  24664. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  24665. t1 = s[t1];
  24666. t2 = s[t2];
  24667. t3 = s[t3];
  24668. t4 = s[t4];
  24669. t1 = t1 ^ r;
  24670. if ((r <<= 1) >= 256) {
  24671. r = (r ^ 0x1b) & 0xFF;
  24672. }
  24673. }
  24674. for (var n = 0; n < 4; ++n) {
  24675. result[j] = t1 ^= result[j - 32];
  24676. j++;
  24677. result[j] = t2 ^= result[j - 32];
  24678. j++;
  24679. result[j] = t3 ^= result[j - 32];
  24680. j++;
  24681. result[j] = t4 ^= result[j - 32];
  24682. j++;
  24683. }
  24684. }
  24685. return result;
  24686. }
  24687. function decrypt256(input, key) {
  24688. var state = new Uint8Array(16);
  24689. state.set(input);
  24690. var i, j, k;
  24691. var t, u, v;
  24692. for (j = 0, k = 224; j < 16; ++j, ++k) {
  24693. state[j] ^= key[k];
  24694. }
  24695. for (i = 13; i >= 1; --i) {
  24696. t = state[13];
  24697. state[13] = state[9];
  24698. state[9] = state[5];
  24699. state[5] = state[1];
  24700. state[1] = t;
  24701. t = state[14];
  24702. u = state[10];
  24703. state[14] = state[6];
  24704. state[10] = state[2];
  24705. state[6] = t;
  24706. state[2] = u;
  24707. t = state[15];
  24708. u = state[11];
  24709. v = state[7];
  24710. state[15] = state[3];
  24711. state[11] = t;
  24712. state[7] = u;
  24713. state[3] = v;
  24714. for (j = 0; j < 16; ++j) {
  24715. state[j] = inv_s[state[j]];
  24716. }
  24717. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  24718. state[j] ^= key[k];
  24719. }
  24720. for (j = 0; j < 16; j += 4) {
  24721. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  24722. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  24723. state[j] = t >>> 24 & 0xFF;
  24724. state[j + 1] = t >> 16 & 0xFF;
  24725. state[j + 2] = t >> 8 & 0xFF;
  24726. state[j + 3] = t & 0xFF;
  24727. }
  24728. }
  24729. t = state[13];
  24730. state[13] = state[9];
  24731. state[9] = state[5];
  24732. state[5] = state[1];
  24733. state[1] = t;
  24734. t = state[14];
  24735. u = state[10];
  24736. state[14] = state[6];
  24737. state[10] = state[2];
  24738. state[6] = t;
  24739. state[2] = u;
  24740. t = state[15];
  24741. u = state[11];
  24742. v = state[7];
  24743. state[15] = state[3];
  24744. state[11] = t;
  24745. state[7] = u;
  24746. state[3] = v;
  24747. for (j = 0; j < 16; ++j) {
  24748. state[j] = inv_s[state[j]];
  24749. state[j] ^= key[j];
  24750. }
  24751. return state;
  24752. }
  24753. function encrypt256(input, key) {
  24754. var t, u, v, k;
  24755. var state = new Uint8Array(16);
  24756. state.set(input);
  24757. for (j = 0; j < 16; ++j) {
  24758. state[j] ^= key[j];
  24759. }
  24760. for (i = 1; i < 14; i++) {
  24761. for (j = 0; j < 16; ++j) {
  24762. state[j] = s[state[j]];
  24763. }
  24764. v = state[1];
  24765. state[1] = state[5];
  24766. state[5] = state[9];
  24767. state[9] = state[13];
  24768. state[13] = v;
  24769. v = state[2];
  24770. u = state[6];
  24771. state[2] = state[10];
  24772. state[6] = state[14];
  24773. state[10] = v;
  24774. state[14] = u;
  24775. v = state[3];
  24776. u = state[7];
  24777. t = state[11];
  24778. state[3] = state[15];
  24779. state[7] = v;
  24780. state[11] = u;
  24781. state[15] = t;
  24782. for (var j = 0; j < 16; j += 4) {
  24783. var s0 = state[j + 0], s1 = state[j + 1];
  24784. var s2 = state[j + 2], s3 = state[j + 3];
  24785. t = s0 ^ s1 ^ s2 ^ s3;
  24786. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  24787. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  24788. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  24789. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  24790. }
  24791. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  24792. state[j] ^= key[k];
  24793. }
  24794. }
  24795. for (j = 0; j < 16; ++j) {
  24796. state[j] = s[state[j]];
  24797. }
  24798. v = state[1];
  24799. state[1] = state[5];
  24800. state[5] = state[9];
  24801. state[9] = state[13];
  24802. state[13] = v;
  24803. v = state[2];
  24804. u = state[6];
  24805. state[2] = state[10];
  24806. state[6] = state[14];
  24807. state[10] = v;
  24808. state[14] = u;
  24809. v = state[3];
  24810. u = state[7];
  24811. t = state[11];
  24812. state[3] = state[15];
  24813. state[7] = v;
  24814. state[11] = u;
  24815. state[15] = t;
  24816. for (j = 0, k = 224; j < 16; ++j, ++k) {
  24817. state[j] ^= key[k];
  24818. }
  24819. return state;
  24820. }
  24821. function AES256Cipher(key) {
  24822. this.key = expandKey256(key);
  24823. this.buffer = new Uint8Array(16);
  24824. this.bufferPosition = 0;
  24825. }
  24826. function decryptBlock2(data, finalize) {
  24827. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  24828. for (i = 0; i < sourceLength; ++i) {
  24829. buffer[bufferLength] = data[i];
  24830. ++bufferLength;
  24831. if (bufferLength < 16) {
  24832. continue;
  24833. }
  24834. var plain = decrypt256(buffer, this.key);
  24835. for (j = 0; j < 16; ++j) {
  24836. plain[j] ^= iv[j];
  24837. }
  24838. iv = buffer;
  24839. result.push(plain);
  24840. buffer = new Uint8Array(16);
  24841. bufferLength = 0;
  24842. }
  24843. this.buffer = buffer;
  24844. this.bufferLength = bufferLength;
  24845. this.iv = iv;
  24846. if (result.length === 0) {
  24847. return new Uint8Array([]);
  24848. }
  24849. var outputLength = 16 * result.length;
  24850. if (finalize) {
  24851. var lastBlock = result[result.length - 1];
  24852. var psLen = lastBlock[15];
  24853. if (psLen <= 16) {
  24854. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  24855. if (lastBlock[i] !== psLen) {
  24856. psLen = 0;
  24857. break;
  24858. }
  24859. }
  24860. outputLength -= psLen;
  24861. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  24862. }
  24863. }
  24864. var output = new Uint8Array(outputLength);
  24865. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  24866. output.set(result[i], j);
  24867. }
  24868. return output;
  24869. }
  24870. AES256Cipher.prototype = {
  24871. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  24872. var i, sourceLength = data.length;
  24873. var buffer = this.buffer, bufferLength = this.bufferPosition;
  24874. if (iv) {
  24875. this.iv = iv;
  24876. } else {
  24877. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  24878. buffer[bufferLength] = data[i];
  24879. }
  24880. if (bufferLength < 16) {
  24881. this.bufferLength = bufferLength;
  24882. return new Uint8Array([]);
  24883. }
  24884. this.iv = buffer;
  24885. data = data.subarray(16);
  24886. }
  24887. this.buffer = new Uint8Array(16);
  24888. this.bufferLength = 0;
  24889. this.decryptBlock = decryptBlock2;
  24890. return this.decryptBlock(data, finalize);
  24891. },
  24892. encrypt: function AES256Cipher_encrypt(data, iv) {
  24893. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  24894. if (!iv) {
  24895. iv = new Uint8Array(16);
  24896. }
  24897. for (i = 0; i < sourceLength; ++i) {
  24898. buffer[bufferLength] = data[i];
  24899. ++bufferLength;
  24900. if (bufferLength < 16) {
  24901. continue;
  24902. }
  24903. for (j = 0; j < 16; ++j) {
  24904. buffer[j] ^= iv[j];
  24905. }
  24906. var cipher = encrypt256(buffer, this.key);
  24907. this.iv = cipher;
  24908. result.push(cipher);
  24909. buffer = new Uint8Array(16);
  24910. bufferLength = 0;
  24911. }
  24912. this.buffer = buffer;
  24913. this.bufferLength = bufferLength;
  24914. this.iv = iv;
  24915. if (result.length === 0) {
  24916. return new Uint8Array([]);
  24917. }
  24918. var outputLength = 16 * result.length;
  24919. var output = new Uint8Array(outputLength);
  24920. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  24921. output.set(result[i], j);
  24922. }
  24923. return output;
  24924. }
  24925. };
  24926. return AES256Cipher;
  24927. }();
  24928. var PDF17 = function PDF17Closure() {
  24929. function compareByteArrays(array1, array2) {
  24930. if (array1.length !== array2.length) {
  24931. return false;
  24932. }
  24933. for (var i = 0; i < array1.length; i++) {
  24934. if (array1[i] !== array2[i]) {
  24935. return false;
  24936. }
  24937. }
  24938. return true;
  24939. }
  24940. function PDF17() {
  24941. }
  24942. PDF17.prototype = {
  24943. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  24944. var hashData = new Uint8Array(password.length + 56);
  24945. hashData.set(password, 0);
  24946. hashData.set(ownerValidationSalt, password.length);
  24947. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  24948. var result = calculateSHA256(hashData, 0, hashData.length);
  24949. return compareByteArrays(result, ownerPassword);
  24950. },
  24951. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  24952. var hashData = new Uint8Array(password.length + 8);
  24953. hashData.set(password, 0);
  24954. hashData.set(userValidationSalt, password.length);
  24955. var result = calculateSHA256(hashData, 0, hashData.length);
  24956. return compareByteArrays(result, userPassword);
  24957. },
  24958. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  24959. var hashData = new Uint8Array(password.length + 56);
  24960. hashData.set(password, 0);
  24961. hashData.set(ownerKeySalt, password.length);
  24962. hashData.set(userBytes, password.length + ownerKeySalt.length);
  24963. var key = calculateSHA256(hashData, 0, hashData.length);
  24964. var cipher = new AES256Cipher(key);
  24965. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  24966. },
  24967. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  24968. var hashData = new Uint8Array(password.length + 8);
  24969. hashData.set(password, 0);
  24970. hashData.set(userKeySalt, password.length);
  24971. var key = calculateSHA256(hashData, 0, hashData.length);
  24972. var cipher = new AES256Cipher(key);
  24973. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  24974. }
  24975. };
  24976. return PDF17;
  24977. }();
  24978. var PDF20 = function PDF20Closure() {
  24979. function concatArrays(array1, array2) {
  24980. var t = new Uint8Array(array1.length + array2.length);
  24981. t.set(array1, 0);
  24982. t.set(array2, array1.length);
  24983. return t;
  24984. }
  24985. function calculatePDF20Hash(password, input, userBytes) {
  24986. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  24987. var e = [0];
  24988. var i = 0;
  24989. while (i < 64 || e[e.length - 1] > i - 32) {
  24990. var arrayLength = password.length + k.length + userBytes.length;
  24991. var k1 = new Uint8Array(arrayLength * 64);
  24992. var array = concatArrays(password, k);
  24993. array = concatArrays(array, userBytes);
  24994. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  24995. k1.set(array, pos);
  24996. }
  24997. var cipher = new AES128Cipher(k.subarray(0, 16));
  24998. e = cipher.encrypt(k1, k.subarray(16, 32));
  24999. var remainder = 0;
  25000. for (var z = 0; z < 16; z++) {
  25001. remainder *= 256 % 3;
  25002. remainder %= 3;
  25003. remainder += (e[z] >>> 0) % 3;
  25004. remainder %= 3;
  25005. }
  25006. if (remainder === 0) {
  25007. k = calculateSHA256(e, 0, e.length);
  25008. } else if (remainder === 1) {
  25009. k = calculateSHA384(e, 0, e.length);
  25010. } else if (remainder === 2) {
  25011. k = calculateSHA512(e, 0, e.length);
  25012. }
  25013. i++;
  25014. }
  25015. return k.subarray(0, 32);
  25016. }
  25017. function PDF20() {
  25018. }
  25019. function compareByteArrays(array1, array2) {
  25020. if (array1.length !== array2.length) {
  25021. return false;
  25022. }
  25023. for (var i = 0; i < array1.length; i++) {
  25024. if (array1[i] !== array2[i]) {
  25025. return false;
  25026. }
  25027. }
  25028. return true;
  25029. }
  25030. PDF20.prototype = {
  25031. hash: function PDF20_hash(password, concatBytes, userBytes) {
  25032. return calculatePDF20Hash(password, concatBytes, userBytes);
  25033. },
  25034. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  25035. var hashData = new Uint8Array(password.length + 56);
  25036. hashData.set(password, 0);
  25037. hashData.set(ownerValidationSalt, password.length);
  25038. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  25039. var result = calculatePDF20Hash(password, hashData, userBytes);
  25040. return compareByteArrays(result, ownerPassword);
  25041. },
  25042. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  25043. var hashData = new Uint8Array(password.length + 8);
  25044. hashData.set(password, 0);
  25045. hashData.set(userValidationSalt, password.length);
  25046. var result = calculatePDF20Hash(password, hashData, []);
  25047. return compareByteArrays(result, userPassword);
  25048. },
  25049. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  25050. var hashData = new Uint8Array(password.length + 56);
  25051. hashData.set(password, 0);
  25052. hashData.set(ownerKeySalt, password.length);
  25053. hashData.set(userBytes, password.length + ownerKeySalt.length);
  25054. var key = calculatePDF20Hash(password, hashData, userBytes);
  25055. var cipher = new AES256Cipher(key);
  25056. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  25057. },
  25058. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  25059. var hashData = new Uint8Array(password.length + 8);
  25060. hashData.set(password, 0);
  25061. hashData.set(userKeySalt, password.length);
  25062. var key = calculatePDF20Hash(password, hashData, []);
  25063. var cipher = new AES256Cipher(key);
  25064. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  25065. }
  25066. };
  25067. return PDF20;
  25068. }();
  25069. var CipherTransform = function CipherTransformClosure() {
  25070. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  25071. this.StringCipherConstructor = stringCipherConstructor;
  25072. this.StreamCipherConstructor = streamCipherConstructor;
  25073. }
  25074. CipherTransform.prototype = {
  25075. createStream: function CipherTransform_createStream(stream, length) {
  25076. var cipher = new this.StreamCipherConstructor();
  25077. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  25078. return cipher.decryptBlock(data, finalize);
  25079. });
  25080. },
  25081. decryptString: function CipherTransform_decryptString(s) {
  25082. var cipher = new this.StringCipherConstructor();
  25083. var data = stringToBytes(s);
  25084. data = cipher.decryptBlock(data, true);
  25085. return bytesToString(data);
  25086. }
  25087. };
  25088. return CipherTransform;
  25089. }();
  25090. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  25091. var defaultPasswordBytes = new Uint8Array([
  25092. 0x28,
  25093. 0xBF,
  25094. 0x4E,
  25095. 0x5E,
  25096. 0x4E,
  25097. 0x75,
  25098. 0x8A,
  25099. 0x41,
  25100. 0x64,
  25101. 0x00,
  25102. 0x4E,
  25103. 0x56,
  25104. 0xFF,
  25105. 0xFA,
  25106. 0x01,
  25107. 0x08,
  25108. 0x2E,
  25109. 0x2E,
  25110. 0x00,
  25111. 0xB6,
  25112. 0xD0,
  25113. 0x68,
  25114. 0x3E,
  25115. 0x80,
  25116. 0x2F,
  25117. 0x0C,
  25118. 0xA9,
  25119. 0xFE,
  25120. 0x64,
  25121. 0x53,
  25122. 0x69,
  25123. 0x7A
  25124. ]);
  25125. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  25126. if (password) {
  25127. var passwordLength = Math.min(127, password.length);
  25128. password = password.subarray(0, passwordLength);
  25129. } else {
  25130. password = [];
  25131. }
  25132. var pdfAlgorithm;
  25133. if (revision === 6) {
  25134. pdfAlgorithm = new PDF20();
  25135. } else {
  25136. pdfAlgorithm = new PDF17();
  25137. }
  25138. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  25139. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  25140. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  25141. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  25142. }
  25143. return null;
  25144. }
  25145. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  25146. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  25147. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  25148. if (password) {
  25149. n = Math.min(32, password.length);
  25150. for (; i < n; ++i) {
  25151. hashData[i] = password[i];
  25152. }
  25153. }
  25154. j = 0;
  25155. while (i < 32) {
  25156. hashData[i++] = defaultPasswordBytes[j++];
  25157. }
  25158. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  25159. hashData[i++] = ownerPassword[j];
  25160. }
  25161. hashData[i++] = flags & 0xFF;
  25162. hashData[i++] = flags >> 8 & 0xFF;
  25163. hashData[i++] = flags >> 16 & 0xFF;
  25164. hashData[i++] = flags >>> 24 & 0xFF;
  25165. for (j = 0, n = fileId.length; j < n; ++j) {
  25166. hashData[i++] = fileId[j];
  25167. }
  25168. if (revision >= 4 && !encryptMetadata) {
  25169. hashData[i++] = 0xFF;
  25170. hashData[i++] = 0xFF;
  25171. hashData[i++] = 0xFF;
  25172. hashData[i++] = 0xFF;
  25173. }
  25174. var hash = calculateMD5(hashData, 0, i);
  25175. var keyLengthInBytes = keyLength >> 3;
  25176. if (revision >= 3) {
  25177. for (j = 0; j < 50; ++j) {
  25178. hash = calculateMD5(hash, 0, keyLengthInBytes);
  25179. }
  25180. }
  25181. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  25182. var cipher, checkData;
  25183. if (revision >= 3) {
  25184. for (i = 0; i < 32; ++i) {
  25185. hashData[i] = defaultPasswordBytes[i];
  25186. }
  25187. for (j = 0, n = fileId.length; j < n; ++j) {
  25188. hashData[i++] = fileId[j];
  25189. }
  25190. cipher = new ARCFourCipher(encryptionKey);
  25191. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  25192. n = encryptionKey.length;
  25193. var derivedKey = new Uint8Array(n), k;
  25194. for (j = 1; j <= 19; ++j) {
  25195. for (k = 0; k < n; ++k) {
  25196. derivedKey[k] = encryptionKey[k] ^ j;
  25197. }
  25198. cipher = new ARCFourCipher(derivedKey);
  25199. checkData = cipher.encryptBlock(checkData);
  25200. }
  25201. for (j = 0, n = checkData.length; j < n; ++j) {
  25202. if (userPassword[j] !== checkData[j]) {
  25203. return null;
  25204. }
  25205. }
  25206. } else {
  25207. cipher = new ARCFourCipher(encryptionKey);
  25208. checkData = cipher.encryptBlock(defaultPasswordBytes);
  25209. for (j = 0, n = checkData.length; j < n; ++j) {
  25210. if (userPassword[j] !== checkData[j]) {
  25211. return null;
  25212. }
  25213. }
  25214. }
  25215. return encryptionKey;
  25216. }
  25217. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  25218. var hashData = new Uint8Array(32), i = 0, j, n;
  25219. n = Math.min(32, password.length);
  25220. for (; i < n; ++i) {
  25221. hashData[i] = password[i];
  25222. }
  25223. j = 0;
  25224. while (i < 32) {
  25225. hashData[i++] = defaultPasswordBytes[j++];
  25226. }
  25227. var hash = calculateMD5(hashData, 0, i);
  25228. var keyLengthInBytes = keyLength >> 3;
  25229. if (revision >= 3) {
  25230. for (j = 0; j < 50; ++j) {
  25231. hash = calculateMD5(hash, 0, hash.length);
  25232. }
  25233. }
  25234. var cipher, userPassword;
  25235. if (revision >= 3) {
  25236. userPassword = ownerPassword;
  25237. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  25238. for (j = 19; j >= 0; j--) {
  25239. for (k = 0; k < keyLengthInBytes; ++k) {
  25240. derivedKey[k] = hash[k] ^ j;
  25241. }
  25242. cipher = new ARCFourCipher(derivedKey);
  25243. userPassword = cipher.encryptBlock(userPassword);
  25244. }
  25245. } else {
  25246. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  25247. userPassword = cipher.encryptBlock(ownerPassword);
  25248. }
  25249. return userPassword;
  25250. }
  25251. var identityName = Name.get('Identity');
  25252. function CipherTransformFactory(dict, fileId, password) {
  25253. var filter = dict.get('Filter');
  25254. if (!isName(filter, 'Standard')) {
  25255. error('unknown encryption method');
  25256. }
  25257. this.dict = dict;
  25258. var algorithm = dict.get('V');
  25259. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  25260. error('unsupported encryption algorithm');
  25261. }
  25262. this.algorithm = algorithm;
  25263. var keyLength = dict.get('Length');
  25264. if (!keyLength) {
  25265. if (algorithm <= 3) {
  25266. keyLength = 40;
  25267. } else {
  25268. var cfDict = dict.get('CF');
  25269. var streamCryptoName = dict.get('StmF');
  25270. if (isDict(cfDict) && isName(streamCryptoName)) {
  25271. cfDict.suppressEncryption = true;
  25272. var handlerDict = cfDict.get(streamCryptoName.name);
  25273. keyLength = handlerDict && handlerDict.get('Length') || 128;
  25274. if (keyLength < 40) {
  25275. keyLength <<= 3;
  25276. }
  25277. }
  25278. }
  25279. }
  25280. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  25281. error('invalid key length');
  25282. }
  25283. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  25284. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  25285. var flags = dict.get('P');
  25286. var revision = dict.get('R');
  25287. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  25288. this.encryptMetadata = encryptMetadata;
  25289. var fileIdBytes = stringToBytes(fileId);
  25290. var passwordBytes;
  25291. if (password) {
  25292. if (revision === 6) {
  25293. try {
  25294. password = utf8StringToString(password);
  25295. } catch (ex) {
  25296. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  25297. }
  25298. }
  25299. passwordBytes = stringToBytes(password);
  25300. }
  25301. var encryptionKey;
  25302. if (algorithm !== 5) {
  25303. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  25304. } else {
  25305. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  25306. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  25307. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  25308. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  25309. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  25310. var ownerEncryption = stringToBytes(dict.get('OE'));
  25311. var userEncryption = stringToBytes(dict.get('UE'));
  25312. var perms = stringToBytes(dict.get('Perms'));
  25313. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  25314. }
  25315. if (!encryptionKey && !password) {
  25316. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  25317. } else if (!encryptionKey && password) {
  25318. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  25319. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  25320. }
  25321. if (!encryptionKey) {
  25322. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  25323. }
  25324. this.encryptionKey = encryptionKey;
  25325. if (algorithm >= 4) {
  25326. var cf = dict.get('CF');
  25327. if (isDict(cf)) {
  25328. cf.suppressEncryption = true;
  25329. }
  25330. this.cf = cf;
  25331. this.stmf = dict.get('StmF') || identityName;
  25332. this.strf = dict.get('StrF') || identityName;
  25333. this.eff = dict.get('EFF') || this.stmf;
  25334. }
  25335. }
  25336. function buildObjectKey(num, gen, encryptionKey, isAes) {
  25337. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  25338. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  25339. key[i] = encryptionKey[i];
  25340. }
  25341. key[i++] = num & 0xFF;
  25342. key[i++] = num >> 8 & 0xFF;
  25343. key[i++] = num >> 16 & 0xFF;
  25344. key[i++] = gen & 0xFF;
  25345. key[i++] = gen >> 8 & 0xFF;
  25346. if (isAes) {
  25347. key[i++] = 0x73;
  25348. key[i++] = 0x41;
  25349. key[i++] = 0x6C;
  25350. key[i++] = 0x54;
  25351. }
  25352. var hash = calculateMD5(key, 0, i);
  25353. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  25354. }
  25355. function buildCipherConstructor(cf, name, num, gen, key) {
  25356. assert(isName(name), 'Invalid crypt filter name.');
  25357. var cryptFilter = cf.get(name.name);
  25358. var cfm;
  25359. if (cryptFilter !== null && cryptFilter !== undefined) {
  25360. cfm = cryptFilter.get('CFM');
  25361. }
  25362. if (!cfm || cfm.name === 'None') {
  25363. return function cipherTransformFactoryBuildCipherConstructorNone() {
  25364. return new NullCipher();
  25365. };
  25366. }
  25367. if (cfm.name === 'V2') {
  25368. return function cipherTransformFactoryBuildCipherConstructorV2() {
  25369. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  25370. };
  25371. }
  25372. if (cfm.name === 'AESV2') {
  25373. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  25374. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  25375. };
  25376. }
  25377. if (cfm.name === 'AESV3') {
  25378. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  25379. return new AES256Cipher(key);
  25380. };
  25381. }
  25382. error('Unknown crypto method');
  25383. }
  25384. CipherTransformFactory.prototype = {
  25385. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  25386. if (this.algorithm === 4 || this.algorithm === 5) {
  25387. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  25388. }
  25389. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  25390. var cipherConstructor = function buildCipherCipherConstructor() {
  25391. return new ARCFourCipher(key);
  25392. };
  25393. return new CipherTransform(cipherConstructor, cipherConstructor);
  25394. }
  25395. };
  25396. return CipherTransformFactory;
  25397. }();
  25398. exports.AES128Cipher = AES128Cipher;
  25399. exports.AES256Cipher = AES256Cipher;
  25400. exports.ARCFourCipher = ARCFourCipher;
  25401. exports.CipherTransformFactory = CipherTransformFactory;
  25402. exports.PDF17 = PDF17;
  25403. exports.PDF20 = PDF20;
  25404. exports.calculateMD5 = calculateMD5;
  25405. exports.calculateSHA256 = calculateSHA256;
  25406. exports.calculateSHA384 = calculateSHA384;
  25407. exports.calculateSHA512 = calculateSHA512;
  25408. /***/ }),
  25409. /* 14 */
  25410. /***/ (function(module, exports, __w_pdfjs_require__) {
  25411. "use strict";
  25412. var sharedUtil = __w_pdfjs_require__(0);
  25413. var corePrimitives = __w_pdfjs_require__(1);
  25414. var coreStream = __w_pdfjs_require__(2);
  25415. var coreParser = __w_pdfjs_require__(5);
  25416. var coreImage = __w_pdfjs_require__(27);
  25417. var coreColorSpace = __w_pdfjs_require__(3);
  25418. var coreMurmurHash3 = __w_pdfjs_require__(31);
  25419. var coreFonts = __w_pdfjs_require__(26);
  25420. var coreFunction = __w_pdfjs_require__(6);
  25421. var corePattern = __w_pdfjs_require__(32);
  25422. var coreCMap = __w_pdfjs_require__(23);
  25423. var coreMetrics = __w_pdfjs_require__(30);
  25424. var coreBidi = __w_pdfjs_require__(21);
  25425. var coreEncodings = __w_pdfjs_require__(4);
  25426. var coreStandardFonts = __w_pdfjs_require__(17);
  25427. var coreUnicode = __w_pdfjs_require__(18);
  25428. var coreGlyphList = __w_pdfjs_require__(7);
  25429. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  25430. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  25431. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  25432. var ImageKind = sharedUtil.ImageKind;
  25433. var OPS = sharedUtil.OPS;
  25434. var TextRenderingMode = sharedUtil.TextRenderingMode;
  25435. var CMapCompressionType = sharedUtil.CMapCompressionType;
  25436. var Util = sharedUtil.Util;
  25437. var assert = sharedUtil.assert;
  25438. var createPromiseCapability = sharedUtil.createPromiseCapability;
  25439. var error = sharedUtil.error;
  25440. var info = sharedUtil.info;
  25441. var isArray = sharedUtil.isArray;
  25442. var isNum = sharedUtil.isNum;
  25443. var isString = sharedUtil.isString;
  25444. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  25445. var warn = sharedUtil.warn;
  25446. var Dict = corePrimitives.Dict;
  25447. var Name = corePrimitives.Name;
  25448. var isEOF = corePrimitives.isEOF;
  25449. var isCmd = corePrimitives.isCmd;
  25450. var isDict = corePrimitives.isDict;
  25451. var isName = corePrimitives.isName;
  25452. var isRef = corePrimitives.isRef;
  25453. var isStream = corePrimitives.isStream;
  25454. var DecodeStream = coreStream.DecodeStream;
  25455. var JpegStream = coreStream.JpegStream;
  25456. var Stream = coreStream.Stream;
  25457. var Lexer = coreParser.Lexer;
  25458. var Parser = coreParser.Parser;
  25459. var PDFImage = coreImage.PDFImage;
  25460. var ColorSpace = coreColorSpace.ColorSpace;
  25461. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  25462. var ErrorFont = coreFonts.ErrorFont;
  25463. var FontFlags = coreFonts.FontFlags;
  25464. var Font = coreFonts.Font;
  25465. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  25466. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  25467. var getFontType = coreFonts.getFontType;
  25468. var isPDFFunction = coreFunction.isPDFFunction;
  25469. var PDFFunction = coreFunction.PDFFunction;
  25470. var Pattern = corePattern.Pattern;
  25471. var getTilingPatternIR = corePattern.getTilingPatternIR;
  25472. var CMapFactory = coreCMap.CMapFactory;
  25473. var IdentityCMap = coreCMap.IdentityCMap;
  25474. var getMetrics = coreMetrics.getMetrics;
  25475. var bidi = coreBidi.bidi;
  25476. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  25477. var StandardEncoding = coreEncodings.StandardEncoding;
  25478. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  25479. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  25480. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  25481. var getEncoding = coreEncodings.getEncoding;
  25482. var getStdFontMap = coreStandardFonts.getStdFontMap;
  25483. var getSerifFonts = coreStandardFonts.getSerifFonts;
  25484. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  25485. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  25486. var reverseIfRtl = coreUnicode.reverseIfRtl;
  25487. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  25488. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  25489. var PartialEvaluator = function PartialEvaluatorClosure() {
  25490. var DefaultPartialEvaluatorOptions = {
  25491. forceDataSchema: false,
  25492. maxImageSize: -1,
  25493. disableFontFace: false,
  25494. disableNativeImageDecoder: false
  25495. };
  25496. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  25497. this.xref = xref;
  25498. this.resources = resources;
  25499. this.handler = handler;
  25500. this.forceDataSchema = forceDataSchema;
  25501. }
  25502. NativeImageDecoder.prototype = {
  25503. canDecode: function (image) {
  25504. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  25505. },
  25506. decode: function (image) {
  25507. var dict = image.dict;
  25508. var colorSpace = dict.get('ColorSpace', 'CS');
  25509. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  25510. var numComps = colorSpace.numComps;
  25511. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  25512. image.getIR(this.forceDataSchema),
  25513. numComps
  25514. ]);
  25515. return decodePromise.then(function (message) {
  25516. var data = message.data;
  25517. return new Stream(data, 0, data.length, image.dict);
  25518. });
  25519. }
  25520. };
  25521. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  25522. var dict = image.dict;
  25523. if (dict.has('DecodeParms') || dict.has('DP')) {
  25524. return false;
  25525. }
  25526. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  25527. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  25528. };
  25529. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  25530. var dict = image.dict;
  25531. if (dict.has('DecodeParms') || dict.has('DP')) {
  25532. return false;
  25533. }
  25534. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  25535. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  25536. };
  25537. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options) {
  25538. this.pdfManager = pdfManager;
  25539. this.xref = xref;
  25540. this.handler = handler;
  25541. this.pageIndex = pageIndex;
  25542. this.idFactory = idFactory;
  25543. this.fontCache = fontCache;
  25544. this.builtInCMapCache = builtInCMapCache;
  25545. this.options = options || DefaultPartialEvaluatorOptions;
  25546. this.fetchBuiltInCMap = function (name) {
  25547. var cachedCMap = builtInCMapCache[name];
  25548. if (cachedCMap) {
  25549. return Promise.resolve(cachedCMap);
  25550. }
  25551. return handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) {
  25552. if (data.compressionType !== CMapCompressionType.NONE) {
  25553. builtInCMapCache[name] = data;
  25554. }
  25555. return data;
  25556. });
  25557. };
  25558. }
  25559. var TIME_SLOT_DURATION_MS = 20;
  25560. var CHECK_TIME_EVERY = 100;
  25561. function TimeSlotManager() {
  25562. this.reset();
  25563. }
  25564. TimeSlotManager.prototype = {
  25565. check: function TimeSlotManager_check() {
  25566. if (++this.checked < CHECK_TIME_EVERY) {
  25567. return false;
  25568. }
  25569. this.checked = 0;
  25570. return this.endTime <= Date.now();
  25571. },
  25572. reset: function TimeSlotManager_reset() {
  25573. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  25574. this.checked = 0;
  25575. }
  25576. };
  25577. var deferred = Promise.resolve();
  25578. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  25579. PartialEvaluator.prototype = {
  25580. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  25581. if (!isDict(resources)) {
  25582. return false;
  25583. }
  25584. var processed = Object.create(null);
  25585. if (resources.objId) {
  25586. processed[resources.objId] = true;
  25587. }
  25588. var nodes = [resources], xref = this.xref;
  25589. while (nodes.length) {
  25590. var key, i, ii;
  25591. var node = nodes.shift();
  25592. var graphicStates = node.get('ExtGState');
  25593. if (isDict(graphicStates)) {
  25594. var graphicStatesKeys = graphicStates.getKeys();
  25595. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  25596. key = graphicStatesKeys[i];
  25597. var graphicState = graphicStates.get(key);
  25598. var bm = graphicState.get('BM');
  25599. if (isName(bm) && bm.name !== 'Normal') {
  25600. return true;
  25601. }
  25602. }
  25603. }
  25604. var xObjects = node.get('XObject');
  25605. if (!isDict(xObjects)) {
  25606. continue;
  25607. }
  25608. var xObjectsKeys = xObjects.getKeys();
  25609. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  25610. key = xObjectsKeys[i];
  25611. var xObject = xObjects.getRaw(key);
  25612. if (isRef(xObject)) {
  25613. if (processed[xObject.toString()]) {
  25614. continue;
  25615. }
  25616. xObject = xref.fetch(xObject);
  25617. }
  25618. if (!isStream(xObject)) {
  25619. continue;
  25620. }
  25621. if (xObject.dict.objId) {
  25622. if (processed[xObject.dict.objId]) {
  25623. continue;
  25624. }
  25625. processed[xObject.dict.objId] = true;
  25626. }
  25627. var xResources = xObject.dict.get('Resources');
  25628. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  25629. nodes.push(xResources);
  25630. if (xResources.objId) {
  25631. processed[xResources.objId] = true;
  25632. }
  25633. }
  25634. }
  25635. }
  25636. return false;
  25637. },
  25638. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  25639. var matrix = xobj.dict.getArray('Matrix');
  25640. var bbox = xobj.dict.getArray('BBox');
  25641. var group = xobj.dict.get('Group');
  25642. if (group) {
  25643. var groupOptions = {
  25644. matrix: matrix,
  25645. bbox: bbox,
  25646. smask: smask,
  25647. isolated: false,
  25648. knockout: false
  25649. };
  25650. var groupSubtype = group.get('S');
  25651. var colorSpace;
  25652. if (isName(groupSubtype, 'Transparency')) {
  25653. groupOptions.isolated = group.get('I') || false;
  25654. groupOptions.knockout = group.get('K') || false;
  25655. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  25656. }
  25657. if (smask && smask.backdrop) {
  25658. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  25659. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  25660. }
  25661. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  25662. }
  25663. operatorList.addOp(OPS.paintFormXObjectBegin, [
  25664. matrix,
  25665. bbox
  25666. ]);
  25667. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  25668. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  25669. if (group) {
  25670. operatorList.addOp(OPS.endGroup, [groupOptions]);
  25671. }
  25672. });
  25673. },
  25674. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  25675. var self = this;
  25676. var dict = image.dict;
  25677. var w = dict.get('Width', 'W');
  25678. var h = dict.get('Height', 'H');
  25679. if (!(w && isNum(w)) || !(h && isNum(h))) {
  25680. warn('Image dimensions are missing, or not numbers.');
  25681. return;
  25682. }
  25683. var maxImageSize = this.options.maxImageSize;
  25684. if (maxImageSize !== -1 && w * h > maxImageSize) {
  25685. warn('Image exceeded maximum allowed size and was removed.');
  25686. return;
  25687. }
  25688. var imageMask = dict.get('ImageMask', 'IM') || false;
  25689. var imgData, args;
  25690. if (imageMask) {
  25691. var width = dict.get('Width', 'W');
  25692. var height = dict.get('Height', 'H');
  25693. var bitStrideLength = width + 7 >> 3;
  25694. var imgArray = image.getBytes(bitStrideLength * height);
  25695. var decode = dict.getArray('Decode', 'D');
  25696. var inverseDecode = !!decode && decode[0] > 0;
  25697. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  25698. imgData.cached = true;
  25699. args = [imgData];
  25700. operatorList.addOp(OPS.paintImageMaskXObject, args);
  25701. if (cacheKey) {
  25702. imageCache[cacheKey] = {
  25703. fn: OPS.paintImageMaskXObject,
  25704. args: args
  25705. };
  25706. }
  25707. return;
  25708. }
  25709. var softMask = dict.get('SMask', 'SM') || false;
  25710. var mask = dict.get('Mask') || false;
  25711. var SMALL_IMAGE_DIMENSIONS = 200;
  25712. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  25713. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  25714. imgData = imageObj.createImageData(true);
  25715. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  25716. return;
  25717. }
  25718. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  25719. var objId = 'img_' + this.idFactory.createObjId();
  25720. operatorList.addDependency(objId);
  25721. args = [
  25722. objId,
  25723. w,
  25724. h
  25725. ];
  25726. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  25727. operatorList.addOp(OPS.paintJpegXObject, args);
  25728. this.handler.send('obj', [
  25729. objId,
  25730. this.pageIndex,
  25731. 'JpegStream',
  25732. image.getIR(this.options.forceDataSchema)
  25733. ]);
  25734. return;
  25735. }
  25736. var nativeImageDecoder = null;
  25737. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  25738. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  25739. }
  25740. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  25741. var imgData = imageObj.createImageData(false);
  25742. self.handler.send('obj', [
  25743. objId,
  25744. self.pageIndex,
  25745. 'Image',
  25746. imgData
  25747. ], [imgData.data.buffer]);
  25748. }).then(undefined, function (reason) {
  25749. warn('Unable to decode image: ' + reason);
  25750. self.handler.send('obj', [
  25751. objId,
  25752. self.pageIndex,
  25753. 'Image',
  25754. null
  25755. ]);
  25756. });
  25757. operatorList.addOp(OPS.paintImageXObject, args);
  25758. if (cacheKey) {
  25759. imageCache[cacheKey] = {
  25760. fn: OPS.paintImageXObject,
  25761. args: args
  25762. };
  25763. }
  25764. },
  25765. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  25766. var smaskContent = smask.get('G');
  25767. var smaskOptions = {
  25768. subtype: smask.get('S').name,
  25769. backdrop: smask.get('BC')
  25770. };
  25771. var transferObj = smask.get('TR');
  25772. if (isPDFFunction(transferObj)) {
  25773. var transferFn = PDFFunction.parse(this.xref, transferObj);
  25774. var transferMap = new Uint8Array(256);
  25775. var tmp = new Float32Array(1);
  25776. for (var i = 0; i < 256; i++) {
  25777. tmp[0] = i / 255;
  25778. transferFn(tmp, 0, tmp, 0);
  25779. transferMap[i] = tmp[0] * 255 | 0;
  25780. }
  25781. smaskOptions.transferMap = transferMap;
  25782. }
  25783. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  25784. },
  25785. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  25786. var tilingOpList = new OperatorList();
  25787. var resourcesArray = [
  25788. patternDict.get('Resources'),
  25789. resources
  25790. ];
  25791. var patternResources = Dict.merge(this.xref, resourcesArray);
  25792. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  25793. operatorList.addDependencies(tilingOpList.dependencies);
  25794. operatorList.addOp(fn, getTilingPatternIR({
  25795. fnArray: tilingOpList.fnArray,
  25796. argsArray: tilingOpList.argsArray
  25797. }, patternDict, args));
  25798. });
  25799. },
  25800. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  25801. var fontName;
  25802. if (fontArgs) {
  25803. fontArgs = fontArgs.slice();
  25804. fontName = fontArgs[0].name;
  25805. }
  25806. var self = this;
  25807. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  25808. if (!translated.font.isType3Font) {
  25809. return translated;
  25810. }
  25811. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  25812. return translated;
  25813. }, function (reason) {
  25814. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  25815. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  25816. });
  25817. }).then(function (translated) {
  25818. state.font = translated.font;
  25819. translated.send(self.handler);
  25820. return translated.loadedName;
  25821. });
  25822. },
  25823. handleText: function PartialEvaluator_handleText(chars, state) {
  25824. var font = state.font;
  25825. var glyphs = font.charsToGlyphs(chars);
  25826. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  25827. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  25828. var buildPath = function (fontChar) {
  25829. if (!font.renderer.hasBuiltPath(fontChar)) {
  25830. var path = font.renderer.getPathJs(fontChar);
  25831. this.handler.send('commonobj', [
  25832. font.loadedName + '_path_' + fontChar,
  25833. 'FontPath',
  25834. path
  25835. ]);
  25836. }
  25837. }.bind(this);
  25838. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  25839. var glyph = glyphs[i];
  25840. buildPath(glyph.fontChar);
  25841. var accent = glyph.accent;
  25842. if (accent && accent.fontChar) {
  25843. buildPath(accent.fontChar);
  25844. }
  25845. }
  25846. }
  25847. return glyphs;
  25848. },
  25849. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  25850. var gStateObj = [];
  25851. var gStateKeys = gState.getKeys();
  25852. var self = this;
  25853. var promise = Promise.resolve();
  25854. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  25855. var key = gStateKeys[i];
  25856. var value = gState.get(key);
  25857. switch (key) {
  25858. case 'Type':
  25859. break;
  25860. case 'LW':
  25861. case 'LC':
  25862. case 'LJ':
  25863. case 'ML':
  25864. case 'D':
  25865. case 'RI':
  25866. case 'FL':
  25867. case 'CA':
  25868. case 'ca':
  25869. gStateObj.push([
  25870. key,
  25871. value
  25872. ]);
  25873. break;
  25874. case 'Font':
  25875. promise = promise.then(function () {
  25876. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  25877. operatorList.addDependency(loadedName);
  25878. gStateObj.push([
  25879. key,
  25880. [
  25881. loadedName,
  25882. value[1]
  25883. ]
  25884. ]);
  25885. });
  25886. });
  25887. break;
  25888. case 'BM':
  25889. gStateObj.push([
  25890. key,
  25891. value
  25892. ]);
  25893. break;
  25894. case 'SMask':
  25895. if (isName(value, 'None')) {
  25896. gStateObj.push([
  25897. key,
  25898. false
  25899. ]);
  25900. break;
  25901. }
  25902. if (isDict(value)) {
  25903. promise = promise.then(function (dict) {
  25904. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  25905. }.bind(this, value));
  25906. gStateObj.push([
  25907. key,
  25908. true
  25909. ]);
  25910. } else {
  25911. warn('Unsupported SMask type');
  25912. }
  25913. break;
  25914. case 'OP':
  25915. case 'op':
  25916. case 'OPM':
  25917. case 'BG':
  25918. case 'BG2':
  25919. case 'UCR':
  25920. case 'UCR2':
  25921. case 'TR':
  25922. case 'TR2':
  25923. case 'HT':
  25924. case 'SM':
  25925. case 'SA':
  25926. case 'AIS':
  25927. case 'TK':
  25928. info('graphic state operator ' + key);
  25929. break;
  25930. default:
  25931. info('Unknown graphic state operator ' + key);
  25932. break;
  25933. }
  25934. }
  25935. return promise.then(function () {
  25936. if (gStateObj.length > 0) {
  25937. operatorList.addOp(OPS.setGState, [gStateObj]);
  25938. }
  25939. });
  25940. },
  25941. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  25942. function errorFont() {
  25943. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  25944. }
  25945. var fontRef;
  25946. if (font) {
  25947. assert(isRef(font));
  25948. fontRef = font;
  25949. } else {
  25950. var fontRes = resources.get('Font');
  25951. if (fontRes) {
  25952. fontRef = fontRes.getRaw(fontName);
  25953. } else {
  25954. warn('fontRes not available');
  25955. return errorFont();
  25956. }
  25957. }
  25958. if (!fontRef) {
  25959. warn('fontRef not available');
  25960. return errorFont();
  25961. }
  25962. if (this.fontCache.has(fontRef)) {
  25963. return this.fontCache.get(fontRef);
  25964. }
  25965. font = xref.fetchIfRef(fontRef);
  25966. if (!isDict(font)) {
  25967. return errorFont();
  25968. }
  25969. if (font.translated) {
  25970. return font.translated;
  25971. }
  25972. var fontCapability = createPromiseCapability();
  25973. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  25974. var descriptor = preEvaluatedFont.descriptor;
  25975. var fontRefIsRef = isRef(fontRef), fontID;
  25976. if (fontRefIsRef) {
  25977. fontID = fontRef.toString();
  25978. }
  25979. if (isDict(descriptor)) {
  25980. if (!descriptor.fontAliases) {
  25981. descriptor.fontAliases = Object.create(null);
  25982. }
  25983. var fontAliases = descriptor.fontAliases;
  25984. var hash = preEvaluatedFont.hash;
  25985. if (fontAliases[hash]) {
  25986. var aliasFontRef = fontAliases[hash].aliasRef;
  25987. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  25988. this.fontCache.putAlias(fontRef, aliasFontRef);
  25989. return this.fontCache.get(fontRef);
  25990. }
  25991. } else {
  25992. fontAliases[hash] = { fontID: Font.getFontID() };
  25993. }
  25994. if (fontRefIsRef) {
  25995. fontAliases[hash].aliasRef = fontRef;
  25996. }
  25997. fontID = fontAliases[hash].fontID;
  25998. }
  25999. if (fontRefIsRef) {
  26000. this.fontCache.put(fontRef, fontCapability.promise);
  26001. } else {
  26002. if (!fontID) {
  26003. fontID = this.idFactory.createObjId();
  26004. }
  26005. this.fontCache.put('id_' + fontID, fontCapability.promise);
  26006. }
  26007. assert(fontID, 'The "fontID" must be defined.');
  26008. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  26009. font.translated = fontCapability.promise;
  26010. var translatedPromise;
  26011. try {
  26012. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  26013. } catch (e) {
  26014. translatedPromise = Promise.reject(e);
  26015. }
  26016. var self = this;
  26017. translatedPromise.then(function (translatedFont) {
  26018. if (translatedFont.fontType !== undefined) {
  26019. var xrefFontStats = xref.stats.fontTypes;
  26020. xrefFontStats[translatedFont.fontType] = true;
  26021. }
  26022. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  26023. }, function (reason) {
  26024. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  26025. try {
  26026. var descriptor = preEvaluatedFont.descriptor;
  26027. var fontFile3 = descriptor && descriptor.get('FontFile3');
  26028. var subtype = fontFile3 && fontFile3.get('Subtype');
  26029. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  26030. var xrefFontStats = xref.stats.fontTypes;
  26031. xrefFontStats[fontType] = true;
  26032. } catch (ex) {
  26033. }
  26034. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  26035. });
  26036. return fontCapability.promise;
  26037. },
  26038. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  26039. var lastIndex = operatorList.length - 1;
  26040. if (!args) {
  26041. args = [];
  26042. }
  26043. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  26044. operatorList.addOp(OPS.constructPath, [
  26045. [fn],
  26046. args
  26047. ]);
  26048. } else {
  26049. var opArgs = operatorList.argsArray[lastIndex];
  26050. opArgs[0].push(fn);
  26051. Array.prototype.push.apply(opArgs[1], args);
  26052. }
  26053. },
  26054. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  26055. var patternName = args[args.length - 1];
  26056. var pattern;
  26057. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  26058. var dict = isStream(pattern) ? pattern.dict : pattern;
  26059. var typeNum = dict.get('PatternType');
  26060. if (typeNum === TILING_PATTERN) {
  26061. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  26062. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  26063. } else if (typeNum === SHADING_PATTERN) {
  26064. var shading = dict.get('Shading');
  26065. var matrix = dict.getArray('Matrix');
  26066. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  26067. operatorList.addOp(fn, pattern.getIR());
  26068. return Promise.resolve();
  26069. }
  26070. return Promise.reject('Unknown PatternType: ' + typeNum);
  26071. }
  26072. operatorList.addOp(fn, args);
  26073. return Promise.resolve();
  26074. },
  26075. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  26076. var self = this;
  26077. var xref = this.xref;
  26078. var imageCache = Object.create(null);
  26079. assert(operatorList);
  26080. resources = resources || Dict.empty;
  26081. var xobjs = resources.get('XObject') || Dict.empty;
  26082. var patterns = resources.get('Pattern') || Dict.empty;
  26083. var stateManager = new StateManager(initialState || new EvalState());
  26084. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  26085. var timeSlotManager = new TimeSlotManager();
  26086. return new Promise(function promiseBody(resolve, reject) {
  26087. var next = function (promise) {
  26088. promise.then(function () {
  26089. try {
  26090. promiseBody(resolve, reject);
  26091. } catch (ex) {
  26092. reject(ex);
  26093. }
  26094. }, reject);
  26095. };
  26096. task.ensureNotTerminated();
  26097. timeSlotManager.reset();
  26098. var stop, operation = {}, i, ii, cs;
  26099. while (!(stop = timeSlotManager.check())) {
  26100. operation.args = null;
  26101. if (!preprocessor.read(operation)) {
  26102. break;
  26103. }
  26104. var args = operation.args;
  26105. var fn = operation.fn;
  26106. switch (fn | 0) {
  26107. case OPS.paintXObject:
  26108. if (args[0].code) {
  26109. break;
  26110. }
  26111. var name = args[0].name;
  26112. if (!name) {
  26113. warn('XObject must be referred to by name.');
  26114. continue;
  26115. }
  26116. if (imageCache[name] !== undefined) {
  26117. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  26118. args = null;
  26119. continue;
  26120. }
  26121. var xobj = xobjs.get(name);
  26122. if (xobj) {
  26123. assert(isStream(xobj), 'XObject should be a stream');
  26124. var type = xobj.dict.get('Subtype');
  26125. assert(isName(type), 'XObject should have a Name subtype');
  26126. if (type.name === 'Form') {
  26127. stateManager.save();
  26128. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  26129. stateManager.restore();
  26130. }));
  26131. return;
  26132. } else if (type.name === 'Image') {
  26133. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  26134. args = null;
  26135. continue;
  26136. } else if (type.name === 'PS') {
  26137. info('Ignored XObject subtype PS');
  26138. continue;
  26139. } else {
  26140. error('Unhandled XObject subtype ' + type.name);
  26141. }
  26142. }
  26143. break;
  26144. case OPS.setFont:
  26145. var fontSize = args[1];
  26146. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  26147. operatorList.addDependency(loadedName);
  26148. operatorList.addOp(OPS.setFont, [
  26149. loadedName,
  26150. fontSize
  26151. ]);
  26152. }));
  26153. return;
  26154. case OPS.endInlineImage:
  26155. var cacheKey = args[0].cacheKey;
  26156. if (cacheKey) {
  26157. var cacheEntry = imageCache[cacheKey];
  26158. if (cacheEntry !== undefined) {
  26159. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  26160. args = null;
  26161. continue;
  26162. }
  26163. }
  26164. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  26165. args = null;
  26166. continue;
  26167. case OPS.showText:
  26168. args[0] = self.handleText(args[0], stateManager.state);
  26169. break;
  26170. case OPS.showSpacedText:
  26171. var arr = args[0];
  26172. var combinedGlyphs = [];
  26173. var arrLength = arr.length;
  26174. var state = stateManager.state;
  26175. for (i = 0; i < arrLength; ++i) {
  26176. var arrItem = arr[i];
  26177. if (isString(arrItem)) {
  26178. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  26179. } else if (isNum(arrItem)) {
  26180. combinedGlyphs.push(arrItem);
  26181. }
  26182. }
  26183. args[0] = combinedGlyphs;
  26184. fn = OPS.showText;
  26185. break;
  26186. case OPS.nextLineShowText:
  26187. operatorList.addOp(OPS.nextLine);
  26188. args[0] = self.handleText(args[0], stateManager.state);
  26189. fn = OPS.showText;
  26190. break;
  26191. case OPS.nextLineSetSpacingShowText:
  26192. operatorList.addOp(OPS.nextLine);
  26193. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  26194. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  26195. args[0] = self.handleText(args[0], stateManager.state);
  26196. fn = OPS.showText;
  26197. break;
  26198. case OPS.setTextRenderingMode:
  26199. stateManager.state.textRenderingMode = args[0];
  26200. break;
  26201. case OPS.setFillColorSpace:
  26202. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  26203. continue;
  26204. case OPS.setStrokeColorSpace:
  26205. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  26206. continue;
  26207. case OPS.setFillColor:
  26208. cs = stateManager.state.fillColorSpace;
  26209. args = cs.getRgb(args, 0);
  26210. fn = OPS.setFillRGBColor;
  26211. break;
  26212. case OPS.setStrokeColor:
  26213. cs = stateManager.state.strokeColorSpace;
  26214. args = cs.getRgb(args, 0);
  26215. fn = OPS.setStrokeRGBColor;
  26216. break;
  26217. case OPS.setFillGray:
  26218. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  26219. args = ColorSpace.singletons.gray.getRgb(args, 0);
  26220. fn = OPS.setFillRGBColor;
  26221. break;
  26222. case OPS.setStrokeGray:
  26223. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  26224. args = ColorSpace.singletons.gray.getRgb(args, 0);
  26225. fn = OPS.setStrokeRGBColor;
  26226. break;
  26227. case OPS.setFillCMYKColor:
  26228. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  26229. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  26230. fn = OPS.setFillRGBColor;
  26231. break;
  26232. case OPS.setStrokeCMYKColor:
  26233. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  26234. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  26235. fn = OPS.setStrokeRGBColor;
  26236. break;
  26237. case OPS.setFillRGBColor:
  26238. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  26239. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  26240. break;
  26241. case OPS.setStrokeRGBColor:
  26242. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  26243. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  26244. break;
  26245. case OPS.setFillColorN:
  26246. cs = stateManager.state.fillColorSpace;
  26247. if (cs.name === 'Pattern') {
  26248. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  26249. return;
  26250. }
  26251. args = cs.getRgb(args, 0);
  26252. fn = OPS.setFillRGBColor;
  26253. break;
  26254. case OPS.setStrokeColorN:
  26255. cs = stateManager.state.strokeColorSpace;
  26256. if (cs.name === 'Pattern') {
  26257. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  26258. return;
  26259. }
  26260. args = cs.getRgb(args, 0);
  26261. fn = OPS.setStrokeRGBColor;
  26262. break;
  26263. case OPS.shadingFill:
  26264. var shadingRes = resources.get('Shading');
  26265. if (!shadingRes) {
  26266. error('No shading resource found');
  26267. }
  26268. var shading = shadingRes.get(args[0].name);
  26269. if (!shading) {
  26270. error('No shading object found');
  26271. }
  26272. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  26273. var patternIR = shadingFill.getIR();
  26274. args = [patternIR];
  26275. fn = OPS.shadingFill;
  26276. break;
  26277. case OPS.setGState:
  26278. var dictName = args[0];
  26279. var extGState = resources.get('ExtGState');
  26280. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  26281. break;
  26282. }
  26283. var gState = extGState.get(dictName.name);
  26284. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  26285. return;
  26286. case OPS.moveTo:
  26287. case OPS.lineTo:
  26288. case OPS.curveTo:
  26289. case OPS.curveTo2:
  26290. case OPS.curveTo3:
  26291. case OPS.closePath:
  26292. self.buildPath(operatorList, fn, args);
  26293. continue;
  26294. case OPS.rectangle:
  26295. self.buildPath(operatorList, fn, args);
  26296. continue;
  26297. case OPS.markPoint:
  26298. case OPS.markPointProps:
  26299. case OPS.beginMarkedContent:
  26300. case OPS.beginMarkedContentProps:
  26301. case OPS.endMarkedContent:
  26302. case OPS.beginCompat:
  26303. case OPS.endCompat:
  26304. continue;
  26305. default:
  26306. if (args !== null) {
  26307. for (i = 0, ii = args.length; i < ii; i++) {
  26308. if (args[i] instanceof Dict) {
  26309. break;
  26310. }
  26311. }
  26312. if (i < ii) {
  26313. warn('getOperatorList - ignoring operator: ' + fn);
  26314. continue;
  26315. }
  26316. }
  26317. }
  26318. operatorList.addOp(fn, args);
  26319. }
  26320. if (stop) {
  26321. next(deferred);
  26322. return;
  26323. }
  26324. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  26325. operatorList.addOp(OPS.restore, []);
  26326. }
  26327. resolve();
  26328. });
  26329. },
  26330. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  26331. stateManager = stateManager || new StateManager(new TextState());
  26332. var WhitespaceRegexp = /\s/g;
  26333. var textContent = {
  26334. items: [],
  26335. styles: Object.create(null)
  26336. };
  26337. var textContentItem = {
  26338. initialized: false,
  26339. str: [],
  26340. width: 0,
  26341. height: 0,
  26342. vertical: false,
  26343. lastAdvanceWidth: 0,
  26344. lastAdvanceHeight: 0,
  26345. textAdvanceScale: 0,
  26346. spaceWidth: 0,
  26347. fakeSpaceMin: Infinity,
  26348. fakeMultiSpaceMin: Infinity,
  26349. fakeMultiSpaceMax: -0,
  26350. textRunBreakAllowed: false,
  26351. transform: null,
  26352. fontName: null
  26353. };
  26354. var SPACE_FACTOR = 0.3;
  26355. var MULTI_SPACE_FACTOR = 1.5;
  26356. var MULTI_SPACE_FACTOR_MAX = 4;
  26357. var self = this;
  26358. var xref = this.xref;
  26359. resources = xref.fetchIfRef(resources) || Dict.empty;
  26360. var xobjs = null;
  26361. var xobjsCache = Object.create(null);
  26362. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  26363. var textState;
  26364. function ensureTextContentItem() {
  26365. if (textContentItem.initialized) {
  26366. return textContentItem;
  26367. }
  26368. var font = textState.font;
  26369. if (!(font.loadedName in textContent.styles)) {
  26370. textContent.styles[font.loadedName] = {
  26371. fontFamily: font.fallbackName,
  26372. ascent: font.ascent,
  26373. descent: font.descent,
  26374. vertical: font.vertical
  26375. };
  26376. }
  26377. textContentItem.fontName = font.loadedName;
  26378. var tsm = [
  26379. textState.fontSize * textState.textHScale,
  26380. 0,
  26381. 0,
  26382. textState.fontSize,
  26383. 0,
  26384. textState.textRise
  26385. ];
  26386. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  26387. var glyphHeight = font.bbox[3] - font.bbox[1];
  26388. if (glyphHeight > 0) {
  26389. glyphHeight = glyphHeight * textState.fontMatrix[3];
  26390. tsm[3] *= glyphHeight;
  26391. }
  26392. }
  26393. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  26394. textContentItem.transform = trm;
  26395. if (!font.vertical) {
  26396. textContentItem.width = 0;
  26397. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  26398. textContentItem.vertical = false;
  26399. } else {
  26400. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  26401. textContentItem.height = 0;
  26402. textContentItem.vertical = true;
  26403. }
  26404. var a = textState.textLineMatrix[0];
  26405. var b = textState.textLineMatrix[1];
  26406. var scaleLineX = Math.sqrt(a * a + b * b);
  26407. a = textState.ctm[0];
  26408. b = textState.ctm[1];
  26409. var scaleCtmX = Math.sqrt(a * a + b * b);
  26410. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  26411. textContentItem.lastAdvanceWidth = 0;
  26412. textContentItem.lastAdvanceHeight = 0;
  26413. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  26414. if (spaceWidth) {
  26415. textContentItem.spaceWidth = spaceWidth;
  26416. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  26417. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  26418. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  26419. textContentItem.textRunBreakAllowed = !font.isMonospace;
  26420. } else {
  26421. textContentItem.spaceWidth = 0;
  26422. textContentItem.fakeSpaceMin = Infinity;
  26423. textContentItem.fakeMultiSpaceMin = Infinity;
  26424. textContentItem.fakeMultiSpaceMax = 0;
  26425. textContentItem.textRunBreakAllowed = false;
  26426. }
  26427. textContentItem.initialized = true;
  26428. return textContentItem;
  26429. }
  26430. function replaceWhitespace(str) {
  26431. var i = 0, ii = str.length, code;
  26432. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  26433. i++;
  26434. }
  26435. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  26436. }
  26437. function runBidiTransform(textChunk) {
  26438. var str = textChunk.str.join('');
  26439. var bidiResult = bidi(str, -1, textChunk.vertical);
  26440. return {
  26441. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  26442. dir: bidiResult.dir,
  26443. width: textChunk.width,
  26444. height: textChunk.height,
  26445. transform: textChunk.transform,
  26446. fontName: textChunk.fontName
  26447. };
  26448. }
  26449. function handleSetFont(fontName, fontRef) {
  26450. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  26451. textState.font = translated.font;
  26452. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  26453. });
  26454. }
  26455. function buildTextContentItem(chars) {
  26456. var font = textState.font;
  26457. var textChunk = ensureTextContentItem();
  26458. var width = 0;
  26459. var height = 0;
  26460. var glyphs = font.charsToGlyphs(chars);
  26461. for (var i = 0; i < glyphs.length; i++) {
  26462. var glyph = glyphs[i];
  26463. var glyphWidth = null;
  26464. if (font.vertical && glyph.vmetric) {
  26465. glyphWidth = glyph.vmetric[0];
  26466. } else {
  26467. glyphWidth = glyph.width;
  26468. }
  26469. var glyphUnicode = glyph.unicode;
  26470. var NormalizedUnicodes = getNormalizedUnicodes();
  26471. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  26472. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  26473. }
  26474. glyphUnicode = reverseIfRtl(glyphUnicode);
  26475. var charSpacing = textState.charSpacing;
  26476. if (glyph.isSpace) {
  26477. var wordSpacing = textState.wordSpacing;
  26478. charSpacing += wordSpacing;
  26479. if (wordSpacing > 0) {
  26480. addFakeSpaces(wordSpacing, textChunk.str);
  26481. }
  26482. }
  26483. var tx = 0;
  26484. var ty = 0;
  26485. if (!font.vertical) {
  26486. var w0 = glyphWidth * textState.fontMatrix[0];
  26487. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  26488. width += tx;
  26489. } else {
  26490. var w1 = glyphWidth * textState.fontMatrix[0];
  26491. ty = w1 * textState.fontSize + charSpacing;
  26492. height += ty;
  26493. }
  26494. textState.translateTextMatrix(tx, ty);
  26495. textChunk.str.push(glyphUnicode);
  26496. }
  26497. if (!font.vertical) {
  26498. textChunk.lastAdvanceWidth = width;
  26499. textChunk.width += width;
  26500. } else {
  26501. textChunk.lastAdvanceHeight = height;
  26502. textChunk.height += Math.abs(height);
  26503. }
  26504. return textChunk;
  26505. }
  26506. function addFakeSpaces(width, strBuf) {
  26507. if (width < textContentItem.fakeSpaceMin) {
  26508. return;
  26509. }
  26510. if (width < textContentItem.fakeMultiSpaceMin) {
  26511. strBuf.push(' ');
  26512. return;
  26513. }
  26514. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  26515. while (fakeSpaces-- > 0) {
  26516. strBuf.push(' ');
  26517. }
  26518. }
  26519. function flushTextContentItem() {
  26520. if (!textContentItem.initialized) {
  26521. return;
  26522. }
  26523. textContentItem.width *= textContentItem.textAdvanceScale;
  26524. textContentItem.height *= textContentItem.textAdvanceScale;
  26525. textContent.items.push(runBidiTransform(textContentItem));
  26526. textContentItem.initialized = false;
  26527. textContentItem.str.length = 0;
  26528. }
  26529. var timeSlotManager = new TimeSlotManager();
  26530. return new Promise(function promiseBody(resolve, reject) {
  26531. var next = function (promise) {
  26532. promise.then(function () {
  26533. try {
  26534. promiseBody(resolve, reject);
  26535. } catch (ex) {
  26536. reject(ex);
  26537. }
  26538. }, reject);
  26539. };
  26540. task.ensureNotTerminated();
  26541. timeSlotManager.reset();
  26542. var stop, operation = {}, args = [];
  26543. while (!(stop = timeSlotManager.check())) {
  26544. args.length = 0;
  26545. operation.args = args;
  26546. if (!preprocessor.read(operation)) {
  26547. break;
  26548. }
  26549. textState = stateManager.state;
  26550. var fn = operation.fn;
  26551. args = operation.args;
  26552. var advance, diff;
  26553. switch (fn | 0) {
  26554. case OPS.setFont:
  26555. var fontNameArg = args[0].name, fontSizeArg = args[1];
  26556. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  26557. break;
  26558. }
  26559. flushTextContentItem();
  26560. textState.fontName = fontNameArg;
  26561. textState.fontSize = fontSizeArg;
  26562. next(handleSetFont(fontNameArg, null));
  26563. return;
  26564. case OPS.setTextRise:
  26565. flushTextContentItem();
  26566. textState.textRise = args[0];
  26567. break;
  26568. case OPS.setHScale:
  26569. flushTextContentItem();
  26570. textState.textHScale = args[0] / 100;
  26571. break;
  26572. case OPS.setLeading:
  26573. flushTextContentItem();
  26574. textState.leading = args[0];
  26575. break;
  26576. case OPS.moveText:
  26577. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  26578. advance = args[0] - args[1];
  26579. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  26580. textState.translateTextLineMatrix(args[0], args[1]);
  26581. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  26582. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  26583. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  26584. addFakeSpaces(diff, textContentItem.str);
  26585. break;
  26586. }
  26587. flushTextContentItem();
  26588. textState.translateTextLineMatrix(args[0], args[1]);
  26589. textState.textMatrix = textState.textLineMatrix.slice();
  26590. break;
  26591. case OPS.setLeadingMoveText:
  26592. flushTextContentItem();
  26593. textState.leading = -args[1];
  26594. textState.translateTextLineMatrix(args[0], args[1]);
  26595. textState.textMatrix = textState.textLineMatrix.slice();
  26596. break;
  26597. case OPS.nextLine:
  26598. flushTextContentItem();
  26599. textState.carriageReturn();
  26600. break;
  26601. case OPS.setTextMatrix:
  26602. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  26603. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  26604. textState.translateTextLineMatrix(advance.width, advance.height);
  26605. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  26606. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  26607. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  26608. addFakeSpaces(diff, textContentItem.str);
  26609. break;
  26610. }
  26611. flushTextContentItem();
  26612. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  26613. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  26614. break;
  26615. case OPS.setCharSpacing:
  26616. textState.charSpacing = args[0];
  26617. break;
  26618. case OPS.setWordSpacing:
  26619. textState.wordSpacing = args[0];
  26620. break;
  26621. case OPS.beginText:
  26622. flushTextContentItem();
  26623. textState.textMatrix = IDENTITY_MATRIX.slice();
  26624. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  26625. break;
  26626. case OPS.showSpacedText:
  26627. var items = args[0];
  26628. var offset;
  26629. for (var j = 0, jj = items.length; j < jj; j++) {
  26630. if (typeof items[j] === 'string') {
  26631. buildTextContentItem(items[j]);
  26632. } else if (isNum(items[j])) {
  26633. ensureTextContentItem();
  26634. advance = items[j] * textState.fontSize / 1000;
  26635. var breakTextRun = false;
  26636. if (textState.font.vertical) {
  26637. offset = advance;
  26638. textState.translateTextMatrix(0, offset);
  26639. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  26640. if (!breakTextRun) {
  26641. textContentItem.height += offset;
  26642. }
  26643. } else {
  26644. advance = -advance;
  26645. offset = advance * textState.textHScale;
  26646. textState.translateTextMatrix(offset, 0);
  26647. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  26648. if (!breakTextRun) {
  26649. textContentItem.width += offset;
  26650. }
  26651. }
  26652. if (breakTextRun) {
  26653. flushTextContentItem();
  26654. } else if (advance > 0) {
  26655. addFakeSpaces(advance, textContentItem.str);
  26656. }
  26657. }
  26658. }
  26659. break;
  26660. case OPS.showText:
  26661. buildTextContentItem(args[0]);
  26662. break;
  26663. case OPS.nextLineShowText:
  26664. flushTextContentItem();
  26665. textState.carriageReturn();
  26666. buildTextContentItem(args[0]);
  26667. break;
  26668. case OPS.nextLineSetSpacingShowText:
  26669. flushTextContentItem();
  26670. textState.wordSpacing = args[0];
  26671. textState.charSpacing = args[1];
  26672. textState.carriageReturn();
  26673. buildTextContentItem(args[2]);
  26674. break;
  26675. case OPS.paintXObject:
  26676. flushTextContentItem();
  26677. if (args[0].code) {
  26678. break;
  26679. }
  26680. if (!xobjs) {
  26681. xobjs = resources.get('XObject') || Dict.empty;
  26682. }
  26683. var name = args[0].name;
  26684. if (xobjsCache.key === name) {
  26685. if (xobjsCache.texts) {
  26686. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  26687. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  26688. }
  26689. break;
  26690. }
  26691. var xobj = xobjs.get(name);
  26692. if (!xobj) {
  26693. break;
  26694. }
  26695. assert(isStream(xobj), 'XObject should be a stream');
  26696. var type = xobj.dict.get('Subtype');
  26697. assert(isName(type), 'XObject should have a Name subtype');
  26698. if ('Form' !== type.name) {
  26699. xobjsCache.key = name;
  26700. xobjsCache.texts = null;
  26701. break;
  26702. }
  26703. stateManager.save();
  26704. var matrix = xobj.dict.getArray('Matrix');
  26705. if (isArray(matrix) && matrix.length === 6) {
  26706. stateManager.transform(matrix);
  26707. }
  26708. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  26709. Util.appendToArray(textContent.items, formTextContent.items);
  26710. Util.extendObj(textContent.styles, formTextContent.styles);
  26711. stateManager.restore();
  26712. xobjsCache.key = name;
  26713. xobjsCache.texts = formTextContent;
  26714. }));
  26715. return;
  26716. case OPS.setGState:
  26717. flushTextContentItem();
  26718. var dictName = args[0];
  26719. var extGState = resources.get('ExtGState');
  26720. if (!isDict(extGState) || !isName(dictName)) {
  26721. break;
  26722. }
  26723. var gState = extGState.get(dictName.name);
  26724. if (!isDict(gState)) {
  26725. break;
  26726. }
  26727. var gStateFont = gState.get('Font');
  26728. if (gStateFont) {
  26729. textState.fontName = null;
  26730. textState.fontSize = gStateFont[1];
  26731. next(handleSetFont(null, gStateFont[0]));
  26732. return;
  26733. }
  26734. break;
  26735. }
  26736. }
  26737. if (stop) {
  26738. next(deferred);
  26739. return;
  26740. }
  26741. flushTextContentItem();
  26742. resolve(textContent);
  26743. });
  26744. },
  26745. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  26746. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  26747. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  26748. if (properties.composite) {
  26749. var cidSystemInfo = dict.get('CIDSystemInfo');
  26750. if (isDict(cidSystemInfo)) {
  26751. properties.cidSystemInfo = {
  26752. registry: cidSystemInfo.get('Registry'),
  26753. ordering: cidSystemInfo.get('Ordering'),
  26754. supplement: cidSystemInfo.get('Supplement')
  26755. };
  26756. }
  26757. var cidToGidMap = dict.get('CIDToGIDMap');
  26758. if (isStream(cidToGidMap)) {
  26759. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  26760. }
  26761. }
  26762. var differences = [];
  26763. var baseEncodingName = null;
  26764. var encoding;
  26765. if (dict.has('Encoding')) {
  26766. encoding = dict.get('Encoding');
  26767. if (isDict(encoding)) {
  26768. baseEncodingName = encoding.get('BaseEncoding');
  26769. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  26770. if (encoding.has('Differences')) {
  26771. var diffEncoding = encoding.get('Differences');
  26772. var index = 0;
  26773. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  26774. var data = xref.fetchIfRef(diffEncoding[j]);
  26775. if (isNum(data)) {
  26776. index = data;
  26777. } else if (isName(data)) {
  26778. differences[index++] = data.name;
  26779. } else {
  26780. error('Invalid entry in \'Differences\' array: ' + data);
  26781. }
  26782. }
  26783. }
  26784. } else if (isName(encoding)) {
  26785. baseEncodingName = encoding.name;
  26786. } else {
  26787. error('Encoding is not a Name nor a Dict');
  26788. }
  26789. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  26790. baseEncodingName = null;
  26791. }
  26792. }
  26793. if (baseEncodingName) {
  26794. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  26795. } else {
  26796. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  26797. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  26798. encoding = StandardEncoding;
  26799. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  26800. encoding = WinAnsiEncoding;
  26801. }
  26802. if (isSymbolicFont) {
  26803. encoding = MacRomanEncoding;
  26804. if (!properties.file) {
  26805. if (/Symbol/i.test(properties.name)) {
  26806. encoding = SymbolSetEncoding;
  26807. } else if (/Dingbats/i.test(properties.name)) {
  26808. encoding = ZapfDingbatsEncoding;
  26809. }
  26810. }
  26811. }
  26812. properties.defaultEncoding = encoding;
  26813. }
  26814. properties.differences = differences;
  26815. properties.baseEncodingName = baseEncodingName;
  26816. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  26817. properties.dict = dict;
  26818. return toUnicodePromise.then(function (toUnicode) {
  26819. properties.toUnicode = toUnicode;
  26820. return this.buildToUnicode(properties);
  26821. }.bind(this)).then(function (toUnicode) {
  26822. properties.toUnicode = toUnicode;
  26823. return properties;
  26824. });
  26825. },
  26826. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  26827. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  26828. if (properties.hasIncludedToUnicodeMap) {
  26829. return Promise.resolve(properties.toUnicode);
  26830. }
  26831. var toUnicode, charcode, glyphName;
  26832. if (!properties.composite) {
  26833. toUnicode = [];
  26834. var encoding = properties.defaultEncoding.slice();
  26835. var baseEncodingName = properties.baseEncodingName;
  26836. var differences = properties.differences;
  26837. for (charcode in differences) {
  26838. glyphName = differences[charcode];
  26839. if (glyphName === '.notdef') {
  26840. continue;
  26841. }
  26842. encoding[charcode] = glyphName;
  26843. }
  26844. var glyphsUnicodeMap = getGlyphsUnicode();
  26845. for (charcode in encoding) {
  26846. glyphName = encoding[charcode];
  26847. if (glyphName === '') {
  26848. continue;
  26849. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  26850. var code = 0;
  26851. switch (glyphName[0]) {
  26852. case 'G':
  26853. if (glyphName.length === 3) {
  26854. code = parseInt(glyphName.substr(1), 16);
  26855. }
  26856. break;
  26857. case 'g':
  26858. if (glyphName.length === 5) {
  26859. code = parseInt(glyphName.substr(1), 16);
  26860. }
  26861. break;
  26862. case 'C':
  26863. case 'c':
  26864. if (glyphName.length >= 3) {
  26865. code = +glyphName.substr(1);
  26866. }
  26867. break;
  26868. default:
  26869. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  26870. if (unicode !== -1) {
  26871. code = unicode;
  26872. }
  26873. }
  26874. if (code) {
  26875. if (baseEncodingName && code === +charcode) {
  26876. var baseEncoding = getEncoding(baseEncodingName);
  26877. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  26878. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  26879. continue;
  26880. }
  26881. }
  26882. toUnicode[charcode] = String.fromCharCode(code);
  26883. }
  26884. continue;
  26885. }
  26886. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  26887. }
  26888. return Promise.resolve(new ToUnicodeMap(toUnicode));
  26889. }
  26890. if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof IdentityCMap) || properties.cidSystemInfo.registry === 'Adobe' && (properties.cidSystemInfo.ordering === 'GB1' || properties.cidSystemInfo.ordering === 'CNS1' || properties.cidSystemInfo.ordering === 'Japan1' || properties.cidSystemInfo.ordering === 'Korea1'))) {
  26891. var registry = properties.cidSystemInfo.registry;
  26892. var ordering = properties.cidSystemInfo.ordering;
  26893. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  26894. return CMapFactory.create({
  26895. encoding: ucs2CMapName,
  26896. fetchBuiltInCMap: this.fetchBuiltInCMap,
  26897. useCMap: null
  26898. }).then(function (ucs2CMap) {
  26899. var cMap = properties.cMap;
  26900. toUnicode = [];
  26901. cMap.forEach(function (charcode, cid) {
  26902. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  26903. var ucs2 = ucs2CMap.lookup(cid);
  26904. if (ucs2) {
  26905. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  26906. }
  26907. });
  26908. return new ToUnicodeMap(toUnicode);
  26909. });
  26910. }
  26911. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  26912. },
  26913. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  26914. var cmapObj = toUnicode;
  26915. if (isName(cmapObj)) {
  26916. return CMapFactory.create({
  26917. encoding: cmapObj,
  26918. fetchBuiltInCMap: this.fetchBuiltInCMap,
  26919. useCMap: null
  26920. }).then(function (cmap) {
  26921. if (cmap instanceof IdentityCMap) {
  26922. return new IdentityToUnicodeMap(0, 0xFFFF);
  26923. }
  26924. return new ToUnicodeMap(cmap.getMap());
  26925. });
  26926. } else if (isStream(cmapObj)) {
  26927. return CMapFactory.create({
  26928. encoding: cmapObj,
  26929. fetchBuiltInCMap: this.fetchBuiltInCMap,
  26930. useCMap: null
  26931. }).then(function (cmap) {
  26932. if (cmap instanceof IdentityCMap) {
  26933. return new IdentityToUnicodeMap(0, 0xFFFF);
  26934. }
  26935. var map = new Array(cmap.length);
  26936. cmap.forEach(function (charCode, token) {
  26937. var str = [];
  26938. for (var k = 0; k < token.length; k += 2) {
  26939. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  26940. if ((w1 & 0xF800) !== 0xD800) {
  26941. str.push(w1);
  26942. continue;
  26943. }
  26944. k += 2;
  26945. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  26946. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  26947. }
  26948. map[charCode] = String.fromCharCode.apply(String, str);
  26949. });
  26950. return new ToUnicodeMap(map);
  26951. });
  26952. }
  26953. return Promise.resolve(null);
  26954. },
  26955. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  26956. var glyphsData = cidToGidStream.getBytes();
  26957. var result = [];
  26958. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  26959. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  26960. if (glyphID === 0) {
  26961. continue;
  26962. }
  26963. var code = j >> 1;
  26964. result[code] = glyphID;
  26965. }
  26966. return result;
  26967. },
  26968. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  26969. var glyphsWidths = [];
  26970. var defaultWidth = 0;
  26971. var glyphsVMetrics = [];
  26972. var defaultVMetrics;
  26973. var i, ii, j, jj, start, code, widths;
  26974. if (properties.composite) {
  26975. defaultWidth = dict.get('DW') || 1000;
  26976. widths = dict.get('W');
  26977. if (widths) {
  26978. for (i = 0, ii = widths.length; i < ii; i++) {
  26979. start = xref.fetchIfRef(widths[i++]);
  26980. code = xref.fetchIfRef(widths[i]);
  26981. if (isArray(code)) {
  26982. for (j = 0, jj = code.length; j < jj; j++) {
  26983. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  26984. }
  26985. } else {
  26986. var width = xref.fetchIfRef(widths[++i]);
  26987. for (j = start; j <= code; j++) {
  26988. glyphsWidths[j] = width;
  26989. }
  26990. }
  26991. }
  26992. }
  26993. if (properties.vertical) {
  26994. var vmetrics = dict.getArray('DW2') || [
  26995. 880,
  26996. -1000
  26997. ];
  26998. defaultVMetrics = [
  26999. vmetrics[1],
  27000. defaultWidth * 0.5,
  27001. vmetrics[0]
  27002. ];
  27003. vmetrics = dict.get('W2');
  27004. if (vmetrics) {
  27005. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  27006. start = xref.fetchIfRef(vmetrics[i++]);
  27007. code = xref.fetchIfRef(vmetrics[i]);
  27008. if (isArray(code)) {
  27009. for (j = 0, jj = code.length; j < jj; j++) {
  27010. glyphsVMetrics[start++] = [
  27011. xref.fetchIfRef(code[j++]),
  27012. xref.fetchIfRef(code[j++]),
  27013. xref.fetchIfRef(code[j])
  27014. ];
  27015. }
  27016. } else {
  27017. var vmetric = [
  27018. xref.fetchIfRef(vmetrics[++i]),
  27019. xref.fetchIfRef(vmetrics[++i]),
  27020. xref.fetchIfRef(vmetrics[++i])
  27021. ];
  27022. for (j = start; j <= code; j++) {
  27023. glyphsVMetrics[j] = vmetric;
  27024. }
  27025. }
  27026. }
  27027. }
  27028. }
  27029. } else {
  27030. var firstChar = properties.firstChar;
  27031. widths = dict.get('Widths');
  27032. if (widths) {
  27033. j = firstChar;
  27034. for (i = 0, ii = widths.length; i < ii; i++) {
  27035. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  27036. }
  27037. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  27038. } else {
  27039. var baseFontName = dict.get('BaseFont');
  27040. if (isName(baseFontName)) {
  27041. var metrics = this.getBaseFontMetrics(baseFontName.name);
  27042. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  27043. defaultWidth = metrics.defaultWidth;
  27044. }
  27045. }
  27046. }
  27047. var isMonospace = true;
  27048. var firstWidth = defaultWidth;
  27049. for (var glyph in glyphsWidths) {
  27050. var glyphWidth = glyphsWidths[glyph];
  27051. if (!glyphWidth) {
  27052. continue;
  27053. }
  27054. if (!firstWidth) {
  27055. firstWidth = glyphWidth;
  27056. continue;
  27057. }
  27058. if (firstWidth !== glyphWidth) {
  27059. isMonospace = false;
  27060. break;
  27061. }
  27062. }
  27063. if (isMonospace) {
  27064. properties.flags |= FontFlags.FixedPitch;
  27065. }
  27066. properties.defaultWidth = defaultWidth;
  27067. properties.widths = glyphsWidths;
  27068. properties.defaultVMetrics = defaultVMetrics;
  27069. properties.vmetrics = glyphsVMetrics;
  27070. },
  27071. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  27072. var fontNameWoStyle = baseFontName.split('-')[0];
  27073. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  27074. },
  27075. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  27076. var defaultWidth = 0;
  27077. var widths = [];
  27078. var monospace = false;
  27079. var stdFontMap = getStdFontMap();
  27080. var lookupName = stdFontMap[name] || name;
  27081. var Metrics = getMetrics();
  27082. if (!(lookupName in Metrics)) {
  27083. if (this.isSerifFont(name)) {
  27084. lookupName = 'Times-Roman';
  27085. } else {
  27086. lookupName = 'Helvetica';
  27087. }
  27088. }
  27089. var glyphWidths = Metrics[lookupName];
  27090. if (isNum(glyphWidths)) {
  27091. defaultWidth = glyphWidths;
  27092. monospace = true;
  27093. } else {
  27094. widths = glyphWidths();
  27095. }
  27096. return {
  27097. defaultWidth: defaultWidth,
  27098. monospace: monospace,
  27099. widths: widths
  27100. };
  27101. },
  27102. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  27103. var widths = Object.create(null);
  27104. var differences = properties.differences;
  27105. var encoding = properties.defaultEncoding;
  27106. for (var charCode = 0; charCode < 256; charCode++) {
  27107. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  27108. widths[charCode] = widthsByGlyphName[differences[charCode]];
  27109. continue;
  27110. }
  27111. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  27112. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  27113. continue;
  27114. }
  27115. }
  27116. return widths;
  27117. },
  27118. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  27119. var baseDict = dict;
  27120. var type = dict.get('Subtype');
  27121. assert(isName(type), 'invalid font Subtype');
  27122. var composite = false;
  27123. var uint8array;
  27124. if (type.name === 'Type0') {
  27125. var df = dict.get('DescendantFonts');
  27126. if (!df) {
  27127. error('Descendant fonts are not specified');
  27128. }
  27129. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  27130. type = dict.get('Subtype');
  27131. assert(isName(type), 'invalid font Subtype');
  27132. composite = true;
  27133. }
  27134. var descriptor = dict.get('FontDescriptor');
  27135. if (descriptor) {
  27136. var hash = new MurmurHash3_64();
  27137. var encoding = baseDict.getRaw('Encoding');
  27138. if (isName(encoding)) {
  27139. hash.update(encoding.name);
  27140. } else if (isRef(encoding)) {
  27141. hash.update(encoding.toString());
  27142. } else if (isDict(encoding)) {
  27143. var keys = encoding.getKeys();
  27144. for (var i = 0, ii = keys.length; i < ii; i++) {
  27145. var entry = encoding.getRaw(keys[i]);
  27146. if (isName(entry)) {
  27147. hash.update(entry.name);
  27148. } else if (isRef(entry)) {
  27149. hash.update(entry.toString());
  27150. } else if (isArray(entry)) {
  27151. var diffLength = entry.length, diffBuf = new Array(diffLength);
  27152. for (var j = 0; j < diffLength; j++) {
  27153. var diffEntry = entry[j];
  27154. if (isName(diffEntry)) {
  27155. diffBuf[j] = diffEntry.name;
  27156. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  27157. diffBuf[j] = diffEntry.toString();
  27158. }
  27159. }
  27160. hash.update(diffBuf.join());
  27161. }
  27162. }
  27163. }
  27164. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  27165. if (isStream(toUnicode)) {
  27166. var stream = toUnicode.str || toUnicode;
  27167. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  27168. hash.update(uint8array);
  27169. } else if (isName(toUnicode)) {
  27170. hash.update(toUnicode.name);
  27171. }
  27172. var widths = dict.get('Widths') || baseDict.get('Widths');
  27173. if (widths) {
  27174. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  27175. hash.update(uint8array);
  27176. }
  27177. }
  27178. return {
  27179. descriptor: descriptor,
  27180. dict: dict,
  27181. baseDict: baseDict,
  27182. composite: composite,
  27183. type: type.name,
  27184. hash: hash ? hash.hexdigest() : ''
  27185. };
  27186. },
  27187. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  27188. var baseDict = preEvaluatedFont.baseDict;
  27189. var dict = preEvaluatedFont.dict;
  27190. var composite = preEvaluatedFont.composite;
  27191. var descriptor = preEvaluatedFont.descriptor;
  27192. var type = preEvaluatedFont.type;
  27193. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  27194. var properties;
  27195. if (!descriptor) {
  27196. if (type === 'Type3') {
  27197. descriptor = new Dict(null);
  27198. descriptor.set('FontName', Name.get(type));
  27199. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  27200. } else {
  27201. var baseFontName = dict.get('BaseFont');
  27202. if (!isName(baseFontName)) {
  27203. error('Base font is not specified');
  27204. }
  27205. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  27206. var metrics = this.getBaseFontMetrics(baseFontName);
  27207. var fontNameWoStyle = baseFontName.split('-')[0];
  27208. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  27209. properties = {
  27210. type: type,
  27211. name: baseFontName,
  27212. widths: metrics.widths,
  27213. defaultWidth: metrics.defaultWidth,
  27214. flags: flags,
  27215. firstChar: 0,
  27216. lastChar: maxCharIndex
  27217. };
  27218. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  27219. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  27220. return new Font(baseFontName, null, properties);
  27221. }.bind(this));
  27222. }
  27223. }
  27224. var firstChar = dict.get('FirstChar') || 0;
  27225. var lastChar = dict.get('LastChar') || maxCharIndex;
  27226. var fontName = descriptor.get('FontName');
  27227. var baseFont = dict.get('BaseFont');
  27228. if (isString(fontName)) {
  27229. fontName = Name.get(fontName);
  27230. }
  27231. if (isString(baseFont)) {
  27232. baseFont = Name.get(baseFont);
  27233. }
  27234. if (type !== 'Type3') {
  27235. var fontNameStr = fontName && fontName.name;
  27236. var baseFontStr = baseFont && baseFont.name;
  27237. if (fontNameStr !== baseFontStr) {
  27238. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  27239. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  27240. fontName = baseFont;
  27241. }
  27242. }
  27243. }
  27244. fontName = fontName || baseFont;
  27245. assert(isName(fontName), 'invalid font name');
  27246. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  27247. if (fontFile) {
  27248. if (fontFile.dict) {
  27249. var subtype = fontFile.dict.get('Subtype');
  27250. if (subtype) {
  27251. subtype = subtype.name;
  27252. }
  27253. var length1 = fontFile.dict.get('Length1');
  27254. var length2 = fontFile.dict.get('Length2');
  27255. var length3 = fontFile.dict.get('Length3');
  27256. }
  27257. }
  27258. properties = {
  27259. type: type,
  27260. name: fontName.name,
  27261. subtype: subtype,
  27262. file: fontFile,
  27263. length1: length1,
  27264. length2: length2,
  27265. length3: length3,
  27266. loadedName: baseDict.loadedName,
  27267. composite: composite,
  27268. wideChars: composite,
  27269. fixedPitch: false,
  27270. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  27271. firstChar: firstChar || 0,
  27272. lastChar: lastChar || maxCharIndex,
  27273. bbox: descriptor.getArray('FontBBox'),
  27274. ascent: descriptor.get('Ascent'),
  27275. descent: descriptor.get('Descent'),
  27276. xHeight: descriptor.get('XHeight'),
  27277. capHeight: descriptor.get('CapHeight'),
  27278. flags: descriptor.get('Flags'),
  27279. italicAngle: descriptor.get('ItalicAngle'),
  27280. coded: false
  27281. };
  27282. var cMapPromise;
  27283. if (composite) {
  27284. var cidEncoding = baseDict.get('Encoding');
  27285. if (isName(cidEncoding)) {
  27286. properties.cidEncoding = cidEncoding.name;
  27287. }
  27288. cMapPromise = CMapFactory.create({
  27289. encoding: cidEncoding,
  27290. fetchBuiltInCMap: this.fetchBuiltInCMap,
  27291. useCMap: null
  27292. }).then(function (cMap) {
  27293. properties.cMap = cMap;
  27294. properties.vertical = properties.cMap.vertical;
  27295. });
  27296. } else {
  27297. cMapPromise = Promise.resolve(undefined);
  27298. }
  27299. return cMapPromise.then(function () {
  27300. return this.extractDataStructures(dict, baseDict, xref, properties);
  27301. }.bind(this)).then(function (properties) {
  27302. this.extractWidths(dict, xref, descriptor, properties);
  27303. if (type === 'Type3') {
  27304. properties.isType3Font = true;
  27305. }
  27306. return new Font(fontName.name, fontFile, properties);
  27307. }.bind(this));
  27308. }
  27309. };
  27310. return PartialEvaluator;
  27311. }();
  27312. var TranslatedFont = function TranslatedFontClosure() {
  27313. function TranslatedFont(loadedName, font, dict) {
  27314. this.loadedName = loadedName;
  27315. this.font = font;
  27316. this.dict = dict;
  27317. this.type3Loaded = null;
  27318. this.sent = false;
  27319. }
  27320. TranslatedFont.prototype = {
  27321. send: function (handler) {
  27322. if (this.sent) {
  27323. return;
  27324. }
  27325. var fontData = this.font.exportData();
  27326. handler.send('commonobj', [
  27327. this.loadedName,
  27328. 'Font',
  27329. fontData
  27330. ]);
  27331. this.sent = true;
  27332. },
  27333. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  27334. assert(this.font.isType3Font);
  27335. if (this.type3Loaded) {
  27336. return this.type3Loaded;
  27337. }
  27338. var translatedFont = this.font;
  27339. var loadCharProcsPromise = Promise.resolve();
  27340. var charProcs = this.dict.get('CharProcs');
  27341. var fontResources = this.dict.get('Resources') || resources;
  27342. var charProcKeys = charProcs.getKeys();
  27343. var charProcOperatorList = Object.create(null);
  27344. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  27345. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  27346. var glyphStream = charProcs.get(key);
  27347. var operatorList = new OperatorList();
  27348. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  27349. charProcOperatorList[key] = operatorList.getIR();
  27350. parentOperatorList.addDependencies(operatorList.dependencies);
  27351. }, function (reason) {
  27352. warn('Type3 font resource \"' + key + '\" is not available');
  27353. var operatorList = new OperatorList();
  27354. charProcOperatorList[key] = operatorList.getIR();
  27355. });
  27356. }.bind(this, charProcKeys[i]));
  27357. }
  27358. this.type3Loaded = loadCharProcsPromise.then(function () {
  27359. translatedFont.charProcOperatorList = charProcOperatorList;
  27360. });
  27361. return this.type3Loaded;
  27362. }
  27363. };
  27364. return TranslatedFont;
  27365. }();
  27366. var OperatorList = function OperatorListClosure() {
  27367. var CHUNK_SIZE = 1000;
  27368. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  27369. function getTransfers(queue) {
  27370. var transfers = [];
  27371. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  27372. for (var i = 0, ii = queue.length; i < ii; i++) {
  27373. switch (fnArray[i]) {
  27374. case OPS.paintInlineImageXObject:
  27375. case OPS.paintInlineImageXObjectGroup:
  27376. case OPS.paintImageMaskXObject:
  27377. var arg = argsArray[i][0];
  27378. if (!arg.cached) {
  27379. transfers.push(arg.data.buffer);
  27380. }
  27381. break;
  27382. }
  27383. }
  27384. return transfers;
  27385. }
  27386. function OperatorList(intent, messageHandler, pageIndex) {
  27387. this.messageHandler = messageHandler;
  27388. this.fnArray = [];
  27389. this.argsArray = [];
  27390. this.dependencies = Object.create(null);
  27391. this._totalLength = 0;
  27392. this.pageIndex = pageIndex;
  27393. this.intent = intent;
  27394. }
  27395. OperatorList.prototype = {
  27396. get length() {
  27397. return this.argsArray.length;
  27398. },
  27399. get totalLength() {
  27400. return this._totalLength + this.length;
  27401. },
  27402. addOp: function (fn, args) {
  27403. this.fnArray.push(fn);
  27404. this.argsArray.push(args);
  27405. if (this.messageHandler) {
  27406. if (this.fnArray.length >= CHUNK_SIZE) {
  27407. this.flush();
  27408. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  27409. this.flush();
  27410. }
  27411. }
  27412. },
  27413. addDependency: function (dependency) {
  27414. if (dependency in this.dependencies) {
  27415. return;
  27416. }
  27417. this.dependencies[dependency] = true;
  27418. this.addOp(OPS.dependency, [dependency]);
  27419. },
  27420. addDependencies: function (dependencies) {
  27421. for (var key in dependencies) {
  27422. this.addDependency(key);
  27423. }
  27424. },
  27425. addOpList: function (opList) {
  27426. Util.extendObj(this.dependencies, opList.dependencies);
  27427. for (var i = 0, ii = opList.length; i < ii; i++) {
  27428. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  27429. }
  27430. },
  27431. getIR: function () {
  27432. return {
  27433. fnArray: this.fnArray,
  27434. argsArray: this.argsArray,
  27435. length: this.length
  27436. };
  27437. },
  27438. flush: function (lastChunk) {
  27439. if (this.intent !== 'oplist') {
  27440. new QueueOptimizer().optimize(this);
  27441. }
  27442. var transfers = getTransfers(this);
  27443. var length = this.length;
  27444. this._totalLength += length;
  27445. this.messageHandler.send('RenderPageChunk', {
  27446. operatorList: {
  27447. fnArray: this.fnArray,
  27448. argsArray: this.argsArray,
  27449. lastChunk: lastChunk,
  27450. length: length
  27451. },
  27452. pageIndex: this.pageIndex,
  27453. intent: this.intent
  27454. }, transfers);
  27455. this.dependencies = Object.create(null);
  27456. this.fnArray.length = 0;
  27457. this.argsArray.length = 0;
  27458. }
  27459. };
  27460. return OperatorList;
  27461. }();
  27462. var StateManager = function StateManagerClosure() {
  27463. function StateManager(initialState) {
  27464. this.state = initialState;
  27465. this.stateStack = [];
  27466. }
  27467. StateManager.prototype = {
  27468. save: function () {
  27469. var old = this.state;
  27470. this.stateStack.push(this.state);
  27471. this.state = old.clone();
  27472. },
  27473. restore: function () {
  27474. var prev = this.stateStack.pop();
  27475. if (prev) {
  27476. this.state = prev;
  27477. }
  27478. },
  27479. transform: function (args) {
  27480. this.state.ctm = Util.transform(this.state.ctm, args);
  27481. }
  27482. };
  27483. return StateManager;
  27484. }();
  27485. var TextState = function TextStateClosure() {
  27486. function TextState() {
  27487. this.ctm = new Float32Array(IDENTITY_MATRIX);
  27488. this.fontName = null;
  27489. this.fontSize = 0;
  27490. this.font = null;
  27491. this.fontMatrix = FONT_IDENTITY_MATRIX;
  27492. this.textMatrix = IDENTITY_MATRIX.slice();
  27493. this.textLineMatrix = IDENTITY_MATRIX.slice();
  27494. this.charSpacing = 0;
  27495. this.wordSpacing = 0;
  27496. this.leading = 0;
  27497. this.textHScale = 1;
  27498. this.textRise = 0;
  27499. }
  27500. TextState.prototype = {
  27501. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  27502. var m = this.textMatrix;
  27503. m[0] = a;
  27504. m[1] = b;
  27505. m[2] = c;
  27506. m[3] = d;
  27507. m[4] = e;
  27508. m[5] = f;
  27509. },
  27510. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  27511. var m = this.textLineMatrix;
  27512. m[0] = a;
  27513. m[1] = b;
  27514. m[2] = c;
  27515. m[3] = d;
  27516. m[4] = e;
  27517. m[5] = f;
  27518. },
  27519. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  27520. var m = this.textMatrix;
  27521. m[4] = m[0] * x + m[2] * y + m[4];
  27522. m[5] = m[1] * x + m[3] * y + m[5];
  27523. },
  27524. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  27525. var m = this.textLineMatrix;
  27526. m[4] = m[0] * x + m[2] * y + m[4];
  27527. m[5] = m[1] * x + m[3] * y + m[5];
  27528. },
  27529. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  27530. var font = this.font;
  27531. if (!font) {
  27532. return null;
  27533. }
  27534. var m = this.textLineMatrix;
  27535. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  27536. return null;
  27537. }
  27538. var txDiff = e - m[4], tyDiff = f - m[5];
  27539. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  27540. return null;
  27541. }
  27542. var tx, ty, denominator = a * d - b * c;
  27543. if (font.vertical) {
  27544. tx = -tyDiff * c / denominator;
  27545. ty = tyDiff * a / denominator;
  27546. } else {
  27547. tx = txDiff * d / denominator;
  27548. ty = -txDiff * b / denominator;
  27549. }
  27550. return {
  27551. width: tx,
  27552. height: ty,
  27553. value: font.vertical ? ty : tx
  27554. };
  27555. },
  27556. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  27557. var tsm = [
  27558. this.fontSize * this.textHScale,
  27559. 0,
  27560. 0,
  27561. this.fontSize,
  27562. 0,
  27563. this.textRise
  27564. ];
  27565. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  27566. },
  27567. carriageReturn: function TextState_carriageReturn() {
  27568. this.translateTextLineMatrix(0, -this.leading);
  27569. this.textMatrix = this.textLineMatrix.slice();
  27570. },
  27571. clone: function TextState_clone() {
  27572. var clone = Object.create(this);
  27573. clone.textMatrix = this.textMatrix.slice();
  27574. clone.textLineMatrix = this.textLineMatrix.slice();
  27575. clone.fontMatrix = this.fontMatrix.slice();
  27576. return clone;
  27577. }
  27578. };
  27579. return TextState;
  27580. }();
  27581. var EvalState = function EvalStateClosure() {
  27582. function EvalState() {
  27583. this.ctm = new Float32Array(IDENTITY_MATRIX);
  27584. this.font = null;
  27585. this.textRenderingMode = TextRenderingMode.FILL;
  27586. this.fillColorSpace = ColorSpace.singletons.gray;
  27587. this.strokeColorSpace = ColorSpace.singletons.gray;
  27588. }
  27589. EvalState.prototype = {
  27590. clone: function CanvasExtraState_clone() {
  27591. return Object.create(this);
  27592. }
  27593. };
  27594. return EvalState;
  27595. }();
  27596. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  27597. var getOPMap = getLookupTableFactory(function (t) {
  27598. t['w'] = {
  27599. id: OPS.setLineWidth,
  27600. numArgs: 1,
  27601. variableArgs: false
  27602. };
  27603. t['J'] = {
  27604. id: OPS.setLineCap,
  27605. numArgs: 1,
  27606. variableArgs: false
  27607. };
  27608. t['j'] = {
  27609. id: OPS.setLineJoin,
  27610. numArgs: 1,
  27611. variableArgs: false
  27612. };
  27613. t['M'] = {
  27614. id: OPS.setMiterLimit,
  27615. numArgs: 1,
  27616. variableArgs: false
  27617. };
  27618. t['d'] = {
  27619. id: OPS.setDash,
  27620. numArgs: 2,
  27621. variableArgs: false
  27622. };
  27623. t['ri'] = {
  27624. id: OPS.setRenderingIntent,
  27625. numArgs: 1,
  27626. variableArgs: false
  27627. };
  27628. t['i'] = {
  27629. id: OPS.setFlatness,
  27630. numArgs: 1,
  27631. variableArgs: false
  27632. };
  27633. t['gs'] = {
  27634. id: OPS.setGState,
  27635. numArgs: 1,
  27636. variableArgs: false
  27637. };
  27638. t['q'] = {
  27639. id: OPS.save,
  27640. numArgs: 0,
  27641. variableArgs: false
  27642. };
  27643. t['Q'] = {
  27644. id: OPS.restore,
  27645. numArgs: 0,
  27646. variableArgs: false
  27647. };
  27648. t['cm'] = {
  27649. id: OPS.transform,
  27650. numArgs: 6,
  27651. variableArgs: false
  27652. };
  27653. t['m'] = {
  27654. id: OPS.moveTo,
  27655. numArgs: 2,
  27656. variableArgs: false
  27657. };
  27658. t['l'] = {
  27659. id: OPS.lineTo,
  27660. numArgs: 2,
  27661. variableArgs: false
  27662. };
  27663. t['c'] = {
  27664. id: OPS.curveTo,
  27665. numArgs: 6,
  27666. variableArgs: false
  27667. };
  27668. t['v'] = {
  27669. id: OPS.curveTo2,
  27670. numArgs: 4,
  27671. variableArgs: false
  27672. };
  27673. t['y'] = {
  27674. id: OPS.curveTo3,
  27675. numArgs: 4,
  27676. variableArgs: false
  27677. };
  27678. t['h'] = {
  27679. id: OPS.closePath,
  27680. numArgs: 0,
  27681. variableArgs: false
  27682. };
  27683. t['re'] = {
  27684. id: OPS.rectangle,
  27685. numArgs: 4,
  27686. variableArgs: false
  27687. };
  27688. t['S'] = {
  27689. id: OPS.stroke,
  27690. numArgs: 0,
  27691. variableArgs: false
  27692. };
  27693. t['s'] = {
  27694. id: OPS.closeStroke,
  27695. numArgs: 0,
  27696. variableArgs: false
  27697. };
  27698. t['f'] = {
  27699. id: OPS.fill,
  27700. numArgs: 0,
  27701. variableArgs: false
  27702. };
  27703. t['F'] = {
  27704. id: OPS.fill,
  27705. numArgs: 0,
  27706. variableArgs: false
  27707. };
  27708. t['f*'] = {
  27709. id: OPS.eoFill,
  27710. numArgs: 0,
  27711. variableArgs: false
  27712. };
  27713. t['B'] = {
  27714. id: OPS.fillStroke,
  27715. numArgs: 0,
  27716. variableArgs: false
  27717. };
  27718. t['B*'] = {
  27719. id: OPS.eoFillStroke,
  27720. numArgs: 0,
  27721. variableArgs: false
  27722. };
  27723. t['b'] = {
  27724. id: OPS.closeFillStroke,
  27725. numArgs: 0,
  27726. variableArgs: false
  27727. };
  27728. t['b*'] = {
  27729. id: OPS.closeEOFillStroke,
  27730. numArgs: 0,
  27731. variableArgs: false
  27732. };
  27733. t['n'] = {
  27734. id: OPS.endPath,
  27735. numArgs: 0,
  27736. variableArgs: false
  27737. };
  27738. t['W'] = {
  27739. id: OPS.clip,
  27740. numArgs: 0,
  27741. variableArgs: false
  27742. };
  27743. t['W*'] = {
  27744. id: OPS.eoClip,
  27745. numArgs: 0,
  27746. variableArgs: false
  27747. };
  27748. t['BT'] = {
  27749. id: OPS.beginText,
  27750. numArgs: 0,
  27751. variableArgs: false
  27752. };
  27753. t['ET'] = {
  27754. id: OPS.endText,
  27755. numArgs: 0,
  27756. variableArgs: false
  27757. };
  27758. t['Tc'] = {
  27759. id: OPS.setCharSpacing,
  27760. numArgs: 1,
  27761. variableArgs: false
  27762. };
  27763. t['Tw'] = {
  27764. id: OPS.setWordSpacing,
  27765. numArgs: 1,
  27766. variableArgs: false
  27767. };
  27768. t['Tz'] = {
  27769. id: OPS.setHScale,
  27770. numArgs: 1,
  27771. variableArgs: false
  27772. };
  27773. t['TL'] = {
  27774. id: OPS.setLeading,
  27775. numArgs: 1,
  27776. variableArgs: false
  27777. };
  27778. t['Tf'] = {
  27779. id: OPS.setFont,
  27780. numArgs: 2,
  27781. variableArgs: false
  27782. };
  27783. t['Tr'] = {
  27784. id: OPS.setTextRenderingMode,
  27785. numArgs: 1,
  27786. variableArgs: false
  27787. };
  27788. t['Ts'] = {
  27789. id: OPS.setTextRise,
  27790. numArgs: 1,
  27791. variableArgs: false
  27792. };
  27793. t['Td'] = {
  27794. id: OPS.moveText,
  27795. numArgs: 2,
  27796. variableArgs: false
  27797. };
  27798. t['TD'] = {
  27799. id: OPS.setLeadingMoveText,
  27800. numArgs: 2,
  27801. variableArgs: false
  27802. };
  27803. t['Tm'] = {
  27804. id: OPS.setTextMatrix,
  27805. numArgs: 6,
  27806. variableArgs: false
  27807. };
  27808. t['T*'] = {
  27809. id: OPS.nextLine,
  27810. numArgs: 0,
  27811. variableArgs: false
  27812. };
  27813. t['Tj'] = {
  27814. id: OPS.showText,
  27815. numArgs: 1,
  27816. variableArgs: false
  27817. };
  27818. t['TJ'] = {
  27819. id: OPS.showSpacedText,
  27820. numArgs: 1,
  27821. variableArgs: false
  27822. };
  27823. t['\''] = {
  27824. id: OPS.nextLineShowText,
  27825. numArgs: 1,
  27826. variableArgs: false
  27827. };
  27828. t['"'] = {
  27829. id: OPS.nextLineSetSpacingShowText,
  27830. numArgs: 3,
  27831. variableArgs: false
  27832. };
  27833. t['d0'] = {
  27834. id: OPS.setCharWidth,
  27835. numArgs: 2,
  27836. variableArgs: false
  27837. };
  27838. t['d1'] = {
  27839. id: OPS.setCharWidthAndBounds,
  27840. numArgs: 6,
  27841. variableArgs: false
  27842. };
  27843. t['CS'] = {
  27844. id: OPS.setStrokeColorSpace,
  27845. numArgs: 1,
  27846. variableArgs: false
  27847. };
  27848. t['cs'] = {
  27849. id: OPS.setFillColorSpace,
  27850. numArgs: 1,
  27851. variableArgs: false
  27852. };
  27853. t['SC'] = {
  27854. id: OPS.setStrokeColor,
  27855. numArgs: 4,
  27856. variableArgs: true
  27857. };
  27858. t['SCN'] = {
  27859. id: OPS.setStrokeColorN,
  27860. numArgs: 33,
  27861. variableArgs: true
  27862. };
  27863. t['sc'] = {
  27864. id: OPS.setFillColor,
  27865. numArgs: 4,
  27866. variableArgs: true
  27867. };
  27868. t['scn'] = {
  27869. id: OPS.setFillColorN,
  27870. numArgs: 33,
  27871. variableArgs: true
  27872. };
  27873. t['G'] = {
  27874. id: OPS.setStrokeGray,
  27875. numArgs: 1,
  27876. variableArgs: false
  27877. };
  27878. t['g'] = {
  27879. id: OPS.setFillGray,
  27880. numArgs: 1,
  27881. variableArgs: false
  27882. };
  27883. t['RG'] = {
  27884. id: OPS.setStrokeRGBColor,
  27885. numArgs: 3,
  27886. variableArgs: false
  27887. };
  27888. t['rg'] = {
  27889. id: OPS.setFillRGBColor,
  27890. numArgs: 3,
  27891. variableArgs: false
  27892. };
  27893. t['K'] = {
  27894. id: OPS.setStrokeCMYKColor,
  27895. numArgs: 4,
  27896. variableArgs: false
  27897. };
  27898. t['k'] = {
  27899. id: OPS.setFillCMYKColor,
  27900. numArgs: 4,
  27901. variableArgs: false
  27902. };
  27903. t['sh'] = {
  27904. id: OPS.shadingFill,
  27905. numArgs: 1,
  27906. variableArgs: false
  27907. };
  27908. t['BI'] = {
  27909. id: OPS.beginInlineImage,
  27910. numArgs: 0,
  27911. variableArgs: false
  27912. };
  27913. t['ID'] = {
  27914. id: OPS.beginImageData,
  27915. numArgs: 0,
  27916. variableArgs: false
  27917. };
  27918. t['EI'] = {
  27919. id: OPS.endInlineImage,
  27920. numArgs: 1,
  27921. variableArgs: false
  27922. };
  27923. t['Do'] = {
  27924. id: OPS.paintXObject,
  27925. numArgs: 1,
  27926. variableArgs: false
  27927. };
  27928. t['MP'] = {
  27929. id: OPS.markPoint,
  27930. numArgs: 1,
  27931. variableArgs: false
  27932. };
  27933. t['DP'] = {
  27934. id: OPS.markPointProps,
  27935. numArgs: 2,
  27936. variableArgs: false
  27937. };
  27938. t['BMC'] = {
  27939. id: OPS.beginMarkedContent,
  27940. numArgs: 1,
  27941. variableArgs: false
  27942. };
  27943. t['BDC'] = {
  27944. id: OPS.beginMarkedContentProps,
  27945. numArgs: 2,
  27946. variableArgs: false
  27947. };
  27948. t['EMC'] = {
  27949. id: OPS.endMarkedContent,
  27950. numArgs: 0,
  27951. variableArgs: false
  27952. };
  27953. t['BX'] = {
  27954. id: OPS.beginCompat,
  27955. numArgs: 0,
  27956. variableArgs: false
  27957. };
  27958. t['EX'] = {
  27959. id: OPS.endCompat,
  27960. numArgs: 0,
  27961. variableArgs: false
  27962. };
  27963. t['BM'] = null;
  27964. t['BD'] = null;
  27965. t['true'] = null;
  27966. t['fa'] = null;
  27967. t['fal'] = null;
  27968. t['fals'] = null;
  27969. t['false'] = null;
  27970. t['nu'] = null;
  27971. t['nul'] = null;
  27972. t['null'] = null;
  27973. });
  27974. function EvaluatorPreprocessor(stream, xref, stateManager) {
  27975. this.opMap = getOPMap();
  27976. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  27977. this.stateManager = stateManager;
  27978. this.nonProcessedArgs = [];
  27979. }
  27980. EvaluatorPreprocessor.prototype = {
  27981. get savedStatesDepth() {
  27982. return this.stateManager.stateStack.length;
  27983. },
  27984. read: function EvaluatorPreprocessor_read(operation) {
  27985. var args = operation.args;
  27986. while (true) {
  27987. var obj = this.parser.getObj();
  27988. if (isCmd(obj)) {
  27989. var cmd = obj.cmd;
  27990. var opSpec = this.opMap[cmd];
  27991. if (!opSpec) {
  27992. warn('Unknown command "' + cmd + '"');
  27993. continue;
  27994. }
  27995. var fn = opSpec.id;
  27996. var numArgs = opSpec.numArgs;
  27997. var argsLength = args !== null ? args.length : 0;
  27998. if (!opSpec.variableArgs) {
  27999. if (argsLength !== numArgs) {
  28000. var nonProcessedArgs = this.nonProcessedArgs;
  28001. while (argsLength > numArgs) {
  28002. nonProcessedArgs.push(args.shift());
  28003. argsLength--;
  28004. }
  28005. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  28006. if (args === null) {
  28007. args = [];
  28008. }
  28009. args.unshift(nonProcessedArgs.pop());
  28010. argsLength++;
  28011. }
  28012. }
  28013. if (argsLength < numArgs) {
  28014. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  28015. if (args !== null) {
  28016. args.length = 0;
  28017. }
  28018. continue;
  28019. }
  28020. } else if (argsLength > numArgs) {
  28021. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  28022. }
  28023. this.preprocessCommand(fn, args);
  28024. operation.fn = fn;
  28025. operation.args = args;
  28026. return true;
  28027. }
  28028. if (isEOF(obj)) {
  28029. return false;
  28030. }
  28031. if (obj !== null) {
  28032. if (args === null) {
  28033. args = [];
  28034. }
  28035. args.push(obj);
  28036. assert(args.length <= 33, 'Too many arguments');
  28037. }
  28038. }
  28039. },
  28040. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  28041. switch (fn | 0) {
  28042. case OPS.save:
  28043. this.stateManager.save();
  28044. break;
  28045. case OPS.restore:
  28046. this.stateManager.restore();
  28047. break;
  28048. case OPS.transform:
  28049. this.stateManager.transform(args);
  28050. break;
  28051. }
  28052. }
  28053. };
  28054. return EvaluatorPreprocessor;
  28055. }();
  28056. var QueueOptimizer = function QueueOptimizerClosure() {
  28057. function addState(parentState, pattern, fn) {
  28058. var state = parentState;
  28059. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  28060. var item = pattern[i];
  28061. state = state[item] || (state[item] = []);
  28062. }
  28063. state[pattern[pattern.length - 1]] = fn;
  28064. }
  28065. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  28066. var iFirstPIMXO = iFirstSave + 2;
  28067. for (var i = 0; i < count; i++) {
  28068. var arg = argsArray[iFirstPIMXO + 4 * i];
  28069. var imageMask = arg.length === 1 && arg[0];
  28070. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  28071. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  28072. continue;
  28073. }
  28074. break;
  28075. }
  28076. return count - i;
  28077. }
  28078. var InitialState = [];
  28079. addState(InitialState, [
  28080. OPS.save,
  28081. OPS.transform,
  28082. OPS.paintInlineImageXObject,
  28083. OPS.restore
  28084. ], function foundInlineImageGroup(context) {
  28085. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  28086. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  28087. var MAX_WIDTH = 1000;
  28088. var IMAGE_PADDING = 1;
  28089. var fnArray = context.fnArray, argsArray = context.argsArray;
  28090. var curr = context.iCurr;
  28091. var iFirstSave = curr - 3;
  28092. var iFirstTransform = curr - 2;
  28093. var iFirstPIIXO = curr - 1;
  28094. var i = iFirstSave + 4;
  28095. var ii = fnArray.length;
  28096. while (i + 3 < ii) {
  28097. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  28098. break;
  28099. }
  28100. i += 4;
  28101. }
  28102. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  28103. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  28104. return i;
  28105. }
  28106. var maxX = 0;
  28107. var map = [], maxLineHeight = 0;
  28108. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  28109. var q;
  28110. for (q = 0; q < count; q++) {
  28111. var transform = argsArray[iFirstTransform + (q << 2)];
  28112. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  28113. if (currentX + img.width > MAX_WIDTH) {
  28114. maxX = Math.max(maxX, currentX);
  28115. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  28116. currentX = 0;
  28117. maxLineHeight = 0;
  28118. }
  28119. map.push({
  28120. transform: transform,
  28121. x: currentX,
  28122. y: currentY,
  28123. w: img.width,
  28124. h: img.height
  28125. });
  28126. currentX += img.width + 2 * IMAGE_PADDING;
  28127. maxLineHeight = Math.max(maxLineHeight, img.height);
  28128. }
  28129. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  28130. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  28131. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  28132. var imgRowSize = imgWidth << 2;
  28133. for (q = 0; q < count; q++) {
  28134. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  28135. var rowSize = map[q].w << 2;
  28136. var dataOffset = 0;
  28137. var offset = map[q].x + map[q].y * imgWidth << 2;
  28138. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  28139. for (var k = 0, kk = map[q].h; k < kk; k++) {
  28140. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  28141. dataOffset += rowSize;
  28142. offset += imgRowSize;
  28143. }
  28144. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  28145. while (offset >= 0) {
  28146. data[offset - 4] = data[offset];
  28147. data[offset - 3] = data[offset + 1];
  28148. data[offset - 2] = data[offset + 2];
  28149. data[offset - 1] = data[offset + 3];
  28150. data[offset + rowSize] = data[offset + rowSize - 4];
  28151. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  28152. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  28153. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  28154. offset -= imgRowSize;
  28155. }
  28156. }
  28157. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  28158. argsArray.splice(iFirstSave, count * 4, [
  28159. {
  28160. width: imgWidth,
  28161. height: imgHeight,
  28162. kind: ImageKind.RGBA_32BPP,
  28163. data: imgData
  28164. },
  28165. map
  28166. ]);
  28167. return iFirstSave + 1;
  28168. });
  28169. addState(InitialState, [
  28170. OPS.save,
  28171. OPS.transform,
  28172. OPS.paintImageMaskXObject,
  28173. OPS.restore
  28174. ], function foundImageMaskGroup(context) {
  28175. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  28176. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  28177. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  28178. var fnArray = context.fnArray, argsArray = context.argsArray;
  28179. var curr = context.iCurr;
  28180. var iFirstSave = curr - 3;
  28181. var iFirstTransform = curr - 2;
  28182. var iFirstPIMXO = curr - 1;
  28183. var i = iFirstSave + 4;
  28184. var ii = fnArray.length;
  28185. while (i + 3 < ii) {
  28186. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  28187. break;
  28188. }
  28189. i += 4;
  28190. }
  28191. var count = (i - iFirstSave) / 4;
  28192. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  28193. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  28194. return i;
  28195. }
  28196. var q;
  28197. var isSameImage = false;
  28198. var iTransform, transformArgs;
  28199. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  28200. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  28201. isSameImage = true;
  28202. var firstTransformArg0 = argsArray[iFirstTransform][0];
  28203. var firstTransformArg3 = argsArray[iFirstTransform][3];
  28204. iTransform = iFirstTransform + 4;
  28205. var iPIMXO = iFirstPIMXO + 4;
  28206. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  28207. transformArgs = argsArray[iTransform];
  28208. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  28209. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  28210. isSameImage = false;
  28211. } else {
  28212. count = q;
  28213. }
  28214. break;
  28215. }
  28216. }
  28217. }
  28218. if (isSameImage) {
  28219. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  28220. var positions = new Float32Array(count * 2);
  28221. iTransform = iFirstTransform;
  28222. for (q = 0; q < count; q++, iTransform += 4) {
  28223. transformArgs = argsArray[iTransform];
  28224. positions[q << 1] = transformArgs[4];
  28225. positions[(q << 1) + 1] = transformArgs[5];
  28226. }
  28227. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  28228. argsArray.splice(iFirstSave, count * 4, [
  28229. firstPIMXOArg0,
  28230. firstTransformArg0,
  28231. firstTransformArg3,
  28232. positions
  28233. ]);
  28234. } else {
  28235. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  28236. var images = [];
  28237. for (q = 0; q < count; q++) {
  28238. transformArgs = argsArray[iFirstTransform + (q << 2)];
  28239. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  28240. images.push({
  28241. data: maskParams.data,
  28242. width: maskParams.width,
  28243. height: maskParams.height,
  28244. transform: transformArgs
  28245. });
  28246. }
  28247. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  28248. argsArray.splice(iFirstSave, count * 4, [images]);
  28249. }
  28250. return iFirstSave + 1;
  28251. });
  28252. addState(InitialState, [
  28253. OPS.save,
  28254. OPS.transform,
  28255. OPS.paintImageXObject,
  28256. OPS.restore
  28257. ], function (context) {
  28258. var MIN_IMAGES_IN_BLOCK = 3;
  28259. var MAX_IMAGES_IN_BLOCK = 1000;
  28260. var fnArray = context.fnArray, argsArray = context.argsArray;
  28261. var curr = context.iCurr;
  28262. var iFirstSave = curr - 3;
  28263. var iFirstTransform = curr - 2;
  28264. var iFirstPIXO = curr - 1;
  28265. var iFirstRestore = curr;
  28266. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  28267. return iFirstRestore + 1;
  28268. }
  28269. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  28270. var firstTransformArg0 = argsArray[iFirstTransform][0];
  28271. var firstTransformArg3 = argsArray[iFirstTransform][3];
  28272. var i = iFirstSave + 4;
  28273. var ii = fnArray.length;
  28274. while (i + 3 < ii) {
  28275. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  28276. break;
  28277. }
  28278. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  28279. break;
  28280. }
  28281. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  28282. break;
  28283. }
  28284. i += 4;
  28285. }
  28286. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  28287. if (count < MIN_IMAGES_IN_BLOCK) {
  28288. return i;
  28289. }
  28290. var positions = new Float32Array(count * 2);
  28291. var iTransform = iFirstTransform;
  28292. for (var q = 0; q < count; q++, iTransform += 4) {
  28293. var transformArgs = argsArray[iTransform];
  28294. positions[q << 1] = transformArgs[4];
  28295. positions[(q << 1) + 1] = transformArgs[5];
  28296. }
  28297. var args = [
  28298. firstPIXOArg0,
  28299. firstTransformArg0,
  28300. firstTransformArg3,
  28301. positions
  28302. ];
  28303. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  28304. argsArray.splice(iFirstSave, count * 4, args);
  28305. return iFirstSave + 1;
  28306. });
  28307. addState(InitialState, [
  28308. OPS.beginText,
  28309. OPS.setFont,
  28310. OPS.setTextMatrix,
  28311. OPS.showText,
  28312. OPS.endText
  28313. ], function (context) {
  28314. var MIN_CHARS_IN_BLOCK = 3;
  28315. var MAX_CHARS_IN_BLOCK = 1000;
  28316. var fnArray = context.fnArray, argsArray = context.argsArray;
  28317. var curr = context.iCurr;
  28318. var iFirstBeginText = curr - 4;
  28319. var iFirstSetFont = curr - 3;
  28320. var iFirstSetTextMatrix = curr - 2;
  28321. var iFirstShowText = curr - 1;
  28322. var iFirstEndText = curr;
  28323. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  28324. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  28325. var i = iFirstBeginText + 5;
  28326. var ii = fnArray.length;
  28327. while (i + 4 < ii) {
  28328. if (fnArray[i] !== OPS.beginText || fnArray[i + 1] !== OPS.setFont || fnArray[i + 2] !== OPS.setTextMatrix || fnArray[i + 3] !== OPS.showText || fnArray[i + 4] !== OPS.endText) {
  28329. break;
  28330. }
  28331. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  28332. break;
  28333. }
  28334. i += 5;
  28335. }
  28336. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  28337. if (count < MIN_CHARS_IN_BLOCK) {
  28338. return i;
  28339. }
  28340. var iFirst = iFirstBeginText;
  28341. if (iFirstBeginText >= 4 && fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] && fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] && fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] && fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] && argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 && argsArray[iFirstBeginText - 4][1] === firstSetFontArg1) {
  28342. count++;
  28343. iFirst -= 5;
  28344. }
  28345. var iEndText = iFirst + 4;
  28346. for (var q = 1; q < count; q++) {
  28347. fnArray.splice(iEndText, 3);
  28348. argsArray.splice(iEndText, 3);
  28349. iEndText += 2;
  28350. }
  28351. return iEndText + 1;
  28352. });
  28353. function QueueOptimizer() {
  28354. }
  28355. QueueOptimizer.prototype = {
  28356. optimize: function QueueOptimizer_optimize(queue) {
  28357. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  28358. var context = {
  28359. iCurr: 0,
  28360. fnArray: fnArray,
  28361. argsArray: argsArray
  28362. };
  28363. var state;
  28364. var i = 0, ii = fnArray.length;
  28365. while (i < ii) {
  28366. state = (state || InitialState)[fnArray[i]];
  28367. if (typeof state === 'function') {
  28368. context.iCurr = i;
  28369. i = state(context);
  28370. state = undefined;
  28371. ii = context.fnArray.length;
  28372. } else {
  28373. i++;
  28374. }
  28375. }
  28376. }
  28377. };
  28378. return QueueOptimizer;
  28379. }();
  28380. exports.OperatorList = OperatorList;
  28381. exports.PartialEvaluator = PartialEvaluator;
  28382. /***/ }),
  28383. /* 15 */
  28384. /***/ (function(module, exports, __w_pdfjs_require__) {
  28385. "use strict";
  28386. var sharedUtil = __w_pdfjs_require__(0);
  28387. var coreArithmeticDecoder = __w_pdfjs_require__(10);
  28388. var info = sharedUtil.info;
  28389. var warn = sharedUtil.warn;
  28390. var error = sharedUtil.error;
  28391. var log2 = sharedUtil.log2;
  28392. var readUint16 = sharedUtil.readUint16;
  28393. var readUint32 = sharedUtil.readUint32;
  28394. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  28395. var JpxImage = function JpxImageClosure() {
  28396. var SubbandsGainLog2 = {
  28397. 'LL': 0,
  28398. 'LH': 1,
  28399. 'HL': 1,
  28400. 'HH': 2
  28401. };
  28402. function JpxImage() {
  28403. this.failOnCorruptedImage = false;
  28404. }
  28405. JpxImage.prototype = {
  28406. parse: function JpxImage_parse(data) {
  28407. var head = readUint16(data, 0);
  28408. if (head === 0xFF4F) {
  28409. this.parseCodestream(data, 0, data.length);
  28410. return;
  28411. }
  28412. var position = 0, length = data.length;
  28413. while (position < length) {
  28414. var headerSize = 8;
  28415. var lbox = readUint32(data, position);
  28416. var tbox = readUint32(data, position + 4);
  28417. position += headerSize;
  28418. if (lbox === 1) {
  28419. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  28420. position += 8;
  28421. headerSize += 8;
  28422. }
  28423. if (lbox === 0) {
  28424. lbox = length - position + headerSize;
  28425. }
  28426. if (lbox < headerSize) {
  28427. error('JPX Error: Invalid box field size');
  28428. }
  28429. var dataLength = lbox - headerSize;
  28430. var jumpDataLength = true;
  28431. switch (tbox) {
  28432. case 0x6A703268:
  28433. jumpDataLength = false;
  28434. break;
  28435. case 0x636F6C72:
  28436. var method = data[position];
  28437. if (method === 1) {
  28438. var colorspace = readUint32(data, position + 3);
  28439. switch (colorspace) {
  28440. case 16:
  28441. case 17:
  28442. case 18:
  28443. break;
  28444. default:
  28445. warn('Unknown colorspace ' + colorspace);
  28446. break;
  28447. }
  28448. } else if (method === 2) {
  28449. info('ICC profile not supported');
  28450. }
  28451. break;
  28452. case 0x6A703263:
  28453. this.parseCodestream(data, position, position + dataLength);
  28454. break;
  28455. case 0x6A502020:
  28456. if (0x0d0a870a !== readUint32(data, position)) {
  28457. warn('Invalid JP2 signature');
  28458. }
  28459. break;
  28460. case 0x6A501A1A:
  28461. case 0x66747970:
  28462. case 0x72726571:
  28463. case 0x72657320:
  28464. case 0x69686472:
  28465. break;
  28466. default:
  28467. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  28468. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  28469. break;
  28470. }
  28471. if (jumpDataLength) {
  28472. position += dataLength;
  28473. }
  28474. }
  28475. },
  28476. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  28477. var newByte = stream.getByte();
  28478. while (newByte >= 0) {
  28479. var oldByte = newByte;
  28480. newByte = stream.getByte();
  28481. var code = oldByte << 8 | newByte;
  28482. if (code === 0xFF51) {
  28483. stream.skip(4);
  28484. var Xsiz = stream.getInt32() >>> 0;
  28485. var Ysiz = stream.getInt32() >>> 0;
  28486. var XOsiz = stream.getInt32() >>> 0;
  28487. var YOsiz = stream.getInt32() >>> 0;
  28488. stream.skip(16);
  28489. var Csiz = stream.getUint16();
  28490. this.width = Xsiz - XOsiz;
  28491. this.height = Ysiz - YOsiz;
  28492. this.componentsCount = Csiz;
  28493. this.bitsPerComponent = 8;
  28494. return;
  28495. }
  28496. }
  28497. error('JPX Error: No size marker found in JPX stream');
  28498. },
  28499. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  28500. var context = {};
  28501. var doNotRecover = false;
  28502. try {
  28503. var position = start;
  28504. while (position + 1 < end) {
  28505. var code = readUint16(data, position);
  28506. position += 2;
  28507. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  28508. switch (code) {
  28509. case 0xFF4F:
  28510. context.mainHeader = true;
  28511. break;
  28512. case 0xFFD9:
  28513. break;
  28514. case 0xFF51:
  28515. length = readUint16(data, position);
  28516. var siz = {};
  28517. siz.Xsiz = readUint32(data, position + 4);
  28518. siz.Ysiz = readUint32(data, position + 8);
  28519. siz.XOsiz = readUint32(data, position + 12);
  28520. siz.YOsiz = readUint32(data, position + 16);
  28521. siz.XTsiz = readUint32(data, position + 20);
  28522. siz.YTsiz = readUint32(data, position + 24);
  28523. siz.XTOsiz = readUint32(data, position + 28);
  28524. siz.YTOsiz = readUint32(data, position + 32);
  28525. var componentsCount = readUint16(data, position + 36);
  28526. siz.Csiz = componentsCount;
  28527. var components = [];
  28528. j = position + 38;
  28529. for (var i = 0; i < componentsCount; i++) {
  28530. var component = {
  28531. precision: (data[j] & 0x7F) + 1,
  28532. isSigned: !!(data[j] & 0x80),
  28533. XRsiz: data[j + 1],
  28534. YRsiz: data[j + 1]
  28535. };
  28536. calculateComponentDimensions(component, siz);
  28537. components.push(component);
  28538. }
  28539. context.SIZ = siz;
  28540. context.components = components;
  28541. calculateTileGrids(context, components);
  28542. context.QCC = [];
  28543. context.COC = [];
  28544. break;
  28545. case 0xFF5C:
  28546. length = readUint16(data, position);
  28547. var qcd = {};
  28548. j = position + 2;
  28549. sqcd = data[j++];
  28550. switch (sqcd & 0x1F) {
  28551. case 0:
  28552. spqcdSize = 8;
  28553. scalarExpounded = true;
  28554. break;
  28555. case 1:
  28556. spqcdSize = 16;
  28557. scalarExpounded = false;
  28558. break;
  28559. case 2:
  28560. spqcdSize = 16;
  28561. scalarExpounded = true;
  28562. break;
  28563. default:
  28564. throw new Error('Invalid SQcd value ' + sqcd);
  28565. }
  28566. qcd.noQuantization = spqcdSize === 8;
  28567. qcd.scalarExpounded = scalarExpounded;
  28568. qcd.guardBits = sqcd >> 5;
  28569. spqcds = [];
  28570. while (j < length + position) {
  28571. var spqcd = {};
  28572. if (spqcdSize === 8) {
  28573. spqcd.epsilon = data[j++] >> 3;
  28574. spqcd.mu = 0;
  28575. } else {
  28576. spqcd.epsilon = data[j] >> 3;
  28577. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  28578. j += 2;
  28579. }
  28580. spqcds.push(spqcd);
  28581. }
  28582. qcd.SPqcds = spqcds;
  28583. if (context.mainHeader) {
  28584. context.QCD = qcd;
  28585. } else {
  28586. context.currentTile.QCD = qcd;
  28587. context.currentTile.QCC = [];
  28588. }
  28589. break;
  28590. case 0xFF5D:
  28591. length = readUint16(data, position);
  28592. var qcc = {};
  28593. j = position + 2;
  28594. var cqcc;
  28595. if (context.SIZ.Csiz < 257) {
  28596. cqcc = data[j++];
  28597. } else {
  28598. cqcc = readUint16(data, j);
  28599. j += 2;
  28600. }
  28601. sqcd = data[j++];
  28602. switch (sqcd & 0x1F) {
  28603. case 0:
  28604. spqcdSize = 8;
  28605. scalarExpounded = true;
  28606. break;
  28607. case 1:
  28608. spqcdSize = 16;
  28609. scalarExpounded = false;
  28610. break;
  28611. case 2:
  28612. spqcdSize = 16;
  28613. scalarExpounded = true;
  28614. break;
  28615. default:
  28616. throw new Error('Invalid SQcd value ' + sqcd);
  28617. }
  28618. qcc.noQuantization = spqcdSize === 8;
  28619. qcc.scalarExpounded = scalarExpounded;
  28620. qcc.guardBits = sqcd >> 5;
  28621. spqcds = [];
  28622. while (j < length + position) {
  28623. spqcd = {};
  28624. if (spqcdSize === 8) {
  28625. spqcd.epsilon = data[j++] >> 3;
  28626. spqcd.mu = 0;
  28627. } else {
  28628. spqcd.epsilon = data[j] >> 3;
  28629. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  28630. j += 2;
  28631. }
  28632. spqcds.push(spqcd);
  28633. }
  28634. qcc.SPqcds = spqcds;
  28635. if (context.mainHeader) {
  28636. context.QCC[cqcc] = qcc;
  28637. } else {
  28638. context.currentTile.QCC[cqcc] = qcc;
  28639. }
  28640. break;
  28641. case 0xFF52:
  28642. length = readUint16(data, position);
  28643. var cod = {};
  28644. j = position + 2;
  28645. var scod = data[j++];
  28646. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  28647. cod.sopMarkerUsed = !!(scod & 2);
  28648. cod.ephMarkerUsed = !!(scod & 4);
  28649. cod.progressionOrder = data[j++];
  28650. cod.layersCount = readUint16(data, j);
  28651. j += 2;
  28652. cod.multipleComponentTransform = data[j++];
  28653. cod.decompositionLevelsCount = data[j++];
  28654. cod.xcb = (data[j++] & 0xF) + 2;
  28655. cod.ycb = (data[j++] & 0xF) + 2;
  28656. var blockStyle = data[j++];
  28657. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  28658. cod.resetContextProbabilities = !!(blockStyle & 2);
  28659. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  28660. cod.verticalyStripe = !!(blockStyle & 8);
  28661. cod.predictableTermination = !!(blockStyle & 16);
  28662. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  28663. cod.reversibleTransformation = data[j++];
  28664. if (cod.entropyCoderWithCustomPrecincts) {
  28665. var precinctsSizes = [];
  28666. while (j < length + position) {
  28667. var precinctsSize = data[j++];
  28668. precinctsSizes.push({
  28669. PPx: precinctsSize & 0xF,
  28670. PPy: precinctsSize >> 4
  28671. });
  28672. }
  28673. cod.precinctsSizes = precinctsSizes;
  28674. }
  28675. var unsupported = [];
  28676. if (cod.selectiveArithmeticCodingBypass) {
  28677. unsupported.push('selectiveArithmeticCodingBypass');
  28678. }
  28679. if (cod.resetContextProbabilities) {
  28680. unsupported.push('resetContextProbabilities');
  28681. }
  28682. if (cod.terminationOnEachCodingPass) {
  28683. unsupported.push('terminationOnEachCodingPass');
  28684. }
  28685. if (cod.verticalyStripe) {
  28686. unsupported.push('verticalyStripe');
  28687. }
  28688. if (cod.predictableTermination) {
  28689. unsupported.push('predictableTermination');
  28690. }
  28691. if (unsupported.length > 0) {
  28692. doNotRecover = true;
  28693. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  28694. }
  28695. if (context.mainHeader) {
  28696. context.COD = cod;
  28697. } else {
  28698. context.currentTile.COD = cod;
  28699. context.currentTile.COC = [];
  28700. }
  28701. break;
  28702. case 0xFF90:
  28703. length = readUint16(data, position);
  28704. tile = {};
  28705. tile.index = readUint16(data, position + 2);
  28706. tile.length = readUint32(data, position + 4);
  28707. tile.dataEnd = tile.length + position - 2;
  28708. tile.partIndex = data[position + 8];
  28709. tile.partsCount = data[position + 9];
  28710. context.mainHeader = false;
  28711. if (tile.partIndex === 0) {
  28712. tile.COD = context.COD;
  28713. tile.COC = context.COC.slice(0);
  28714. tile.QCD = context.QCD;
  28715. tile.QCC = context.QCC.slice(0);
  28716. }
  28717. context.currentTile = tile;
  28718. break;
  28719. case 0xFF93:
  28720. tile = context.currentTile;
  28721. if (tile.partIndex === 0) {
  28722. initializeTile(context, tile.index);
  28723. buildPackets(context);
  28724. }
  28725. length = tile.dataEnd - position;
  28726. parseTilePackets(context, data, position, length);
  28727. break;
  28728. case 0xFF55:
  28729. case 0xFF57:
  28730. case 0xFF58:
  28731. case 0xFF64:
  28732. length = readUint16(data, position);
  28733. break;
  28734. case 0xFF53:
  28735. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  28736. default:
  28737. throw new Error('Unknown codestream code: ' + code.toString(16));
  28738. }
  28739. position += length;
  28740. }
  28741. } catch (e) {
  28742. if (doNotRecover || this.failOnCorruptedImage) {
  28743. error('JPX Error: ' + e.message);
  28744. } else {
  28745. warn('JPX: Trying to recover from: ' + e.message);
  28746. }
  28747. }
  28748. this.tiles = transformComponents(context);
  28749. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  28750. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  28751. this.componentsCount = context.SIZ.Csiz;
  28752. }
  28753. };
  28754. function calculateComponentDimensions(component, siz) {
  28755. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  28756. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  28757. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  28758. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  28759. component.width = component.x1 - component.x0;
  28760. component.height = component.y1 - component.y0;
  28761. }
  28762. function calculateTileGrids(context, components) {
  28763. var siz = context.SIZ;
  28764. var tile, tiles = [];
  28765. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  28766. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  28767. for (var q = 0; q < numYtiles; q++) {
  28768. for (var p = 0; p < numXtiles; p++) {
  28769. tile = {};
  28770. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  28771. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  28772. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  28773. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  28774. tile.width = tile.tx1 - tile.tx0;
  28775. tile.height = tile.ty1 - tile.ty0;
  28776. tile.components = [];
  28777. tiles.push(tile);
  28778. }
  28779. }
  28780. context.tiles = tiles;
  28781. var componentsCount = siz.Csiz;
  28782. for (var i = 0, ii = componentsCount; i < ii; i++) {
  28783. var component = components[i];
  28784. for (var j = 0, jj = tiles.length; j < jj; j++) {
  28785. var tileComponent = {};
  28786. tile = tiles[j];
  28787. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  28788. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  28789. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  28790. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  28791. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  28792. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  28793. tile.components[i] = tileComponent;
  28794. }
  28795. }
  28796. }
  28797. function getBlocksDimensions(context, component, r) {
  28798. var codOrCoc = component.codingStyleParameters;
  28799. var result = {};
  28800. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  28801. result.PPx = 15;
  28802. result.PPy = 15;
  28803. } else {
  28804. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  28805. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  28806. }
  28807. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  28808. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  28809. return result;
  28810. }
  28811. function buildPrecincts(context, resolution, dimensions) {
  28812. var precinctWidth = 1 << dimensions.PPx;
  28813. var precinctHeight = 1 << dimensions.PPy;
  28814. var isZeroRes = resolution.resLevel === 0;
  28815. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  28816. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  28817. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  28818. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  28819. var numprecincts = numprecinctswide * numprecinctshigh;
  28820. resolution.precinctParameters = {
  28821. precinctWidth: precinctWidth,
  28822. precinctHeight: precinctHeight,
  28823. numprecinctswide: numprecinctswide,
  28824. numprecinctshigh: numprecinctshigh,
  28825. numprecincts: numprecincts,
  28826. precinctWidthInSubband: precinctWidthInSubband,
  28827. precinctHeightInSubband: precinctHeightInSubband
  28828. };
  28829. }
  28830. function buildCodeblocks(context, subband, dimensions) {
  28831. var xcb_ = dimensions.xcb_;
  28832. var ycb_ = dimensions.ycb_;
  28833. var codeblockWidth = 1 << xcb_;
  28834. var codeblockHeight = 1 << ycb_;
  28835. var cbx0 = subband.tbx0 >> xcb_;
  28836. var cby0 = subband.tby0 >> ycb_;
  28837. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  28838. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  28839. var precinctParameters = subband.resolution.precinctParameters;
  28840. var codeblocks = [];
  28841. var precincts = [];
  28842. var i, j, codeblock, precinctNumber;
  28843. for (j = cby0; j < cby1; j++) {
  28844. for (i = cbx0; i < cbx1; i++) {
  28845. codeblock = {
  28846. cbx: i,
  28847. cby: j,
  28848. tbx0: codeblockWidth * i,
  28849. tby0: codeblockHeight * j,
  28850. tbx1: codeblockWidth * (i + 1),
  28851. tby1: codeblockHeight * (j + 1)
  28852. };
  28853. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  28854. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  28855. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  28856. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  28857. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  28858. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  28859. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  28860. codeblock.precinctNumber = precinctNumber;
  28861. codeblock.subbandType = subband.type;
  28862. codeblock.Lblock = 3;
  28863. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  28864. continue;
  28865. }
  28866. codeblocks.push(codeblock);
  28867. var precinct = precincts[precinctNumber];
  28868. if (precinct !== undefined) {
  28869. if (i < precinct.cbxMin) {
  28870. precinct.cbxMin = i;
  28871. } else if (i > precinct.cbxMax) {
  28872. precinct.cbxMax = i;
  28873. }
  28874. if (j < precinct.cbyMin) {
  28875. precinct.cbxMin = j;
  28876. } else if (j > precinct.cbyMax) {
  28877. precinct.cbyMax = j;
  28878. }
  28879. } else {
  28880. precincts[precinctNumber] = precinct = {
  28881. cbxMin: i,
  28882. cbyMin: j,
  28883. cbxMax: i,
  28884. cbyMax: j
  28885. };
  28886. }
  28887. codeblock.precinct = precinct;
  28888. }
  28889. }
  28890. subband.codeblockParameters = {
  28891. codeblockWidth: xcb_,
  28892. codeblockHeight: ycb_,
  28893. numcodeblockwide: cbx1 - cbx0 + 1,
  28894. numcodeblockhigh: cby1 - cby0 + 1
  28895. };
  28896. subband.codeblocks = codeblocks;
  28897. subband.precincts = precincts;
  28898. }
  28899. function createPacket(resolution, precinctNumber, layerNumber) {
  28900. var precinctCodeblocks = [];
  28901. var subbands = resolution.subbands;
  28902. for (var i = 0, ii = subbands.length; i < ii; i++) {
  28903. var subband = subbands[i];
  28904. var codeblocks = subband.codeblocks;
  28905. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  28906. var codeblock = codeblocks[j];
  28907. if (codeblock.precinctNumber !== precinctNumber) {
  28908. continue;
  28909. }
  28910. precinctCodeblocks.push(codeblock);
  28911. }
  28912. }
  28913. return {
  28914. layerNumber: layerNumber,
  28915. codeblocks: precinctCodeblocks
  28916. };
  28917. }
  28918. function LayerResolutionComponentPositionIterator(context) {
  28919. var siz = context.SIZ;
  28920. var tileIndex = context.currentTile.index;
  28921. var tile = context.tiles[tileIndex];
  28922. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  28923. var componentsCount = siz.Csiz;
  28924. var maxDecompositionLevelsCount = 0;
  28925. for (var q = 0; q < componentsCount; q++) {
  28926. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  28927. }
  28928. var l = 0, r = 0, i = 0, k = 0;
  28929. this.nextPacket = function JpxImage_nextPacket() {
  28930. for (; l < layersCount; l++) {
  28931. for (; r <= maxDecompositionLevelsCount; r++) {
  28932. for (; i < componentsCount; i++) {
  28933. var component = tile.components[i];
  28934. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  28935. continue;
  28936. }
  28937. var resolution = component.resolutions[r];
  28938. var numprecincts = resolution.precinctParameters.numprecincts;
  28939. for (; k < numprecincts;) {
  28940. var packet = createPacket(resolution, k, l);
  28941. k++;
  28942. return packet;
  28943. }
  28944. k = 0;
  28945. }
  28946. i = 0;
  28947. }
  28948. r = 0;
  28949. }
  28950. error('JPX Error: Out of packets');
  28951. };
  28952. }
  28953. function ResolutionLayerComponentPositionIterator(context) {
  28954. var siz = context.SIZ;
  28955. var tileIndex = context.currentTile.index;
  28956. var tile = context.tiles[tileIndex];
  28957. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  28958. var componentsCount = siz.Csiz;
  28959. var maxDecompositionLevelsCount = 0;
  28960. for (var q = 0; q < componentsCount; q++) {
  28961. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  28962. }
  28963. var r = 0, l = 0, i = 0, k = 0;
  28964. this.nextPacket = function JpxImage_nextPacket() {
  28965. for (; r <= maxDecompositionLevelsCount; r++) {
  28966. for (; l < layersCount; l++) {
  28967. for (; i < componentsCount; i++) {
  28968. var component = tile.components[i];
  28969. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  28970. continue;
  28971. }
  28972. var resolution = component.resolutions[r];
  28973. var numprecincts = resolution.precinctParameters.numprecincts;
  28974. for (; k < numprecincts;) {
  28975. var packet = createPacket(resolution, k, l);
  28976. k++;
  28977. return packet;
  28978. }
  28979. k = 0;
  28980. }
  28981. i = 0;
  28982. }
  28983. l = 0;
  28984. }
  28985. error('JPX Error: Out of packets');
  28986. };
  28987. }
  28988. function ResolutionPositionComponentLayerIterator(context) {
  28989. var siz = context.SIZ;
  28990. var tileIndex = context.currentTile.index;
  28991. var tile = context.tiles[tileIndex];
  28992. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  28993. var componentsCount = siz.Csiz;
  28994. var l, r, c, p;
  28995. var maxDecompositionLevelsCount = 0;
  28996. for (c = 0; c < componentsCount; c++) {
  28997. var component = tile.components[c];
  28998. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  28999. }
  29000. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  29001. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  29002. var maxNumPrecincts = 0;
  29003. for (c = 0; c < componentsCount; ++c) {
  29004. var resolutions = tile.components[c].resolutions;
  29005. if (r < resolutions.length) {
  29006. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  29007. }
  29008. }
  29009. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  29010. }
  29011. l = 0;
  29012. r = 0;
  29013. c = 0;
  29014. p = 0;
  29015. this.nextPacket = function JpxImage_nextPacket() {
  29016. for (; r <= maxDecompositionLevelsCount; r++) {
  29017. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  29018. for (; c < componentsCount; c++) {
  29019. var component = tile.components[c];
  29020. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  29021. continue;
  29022. }
  29023. var resolution = component.resolutions[r];
  29024. var numprecincts = resolution.precinctParameters.numprecincts;
  29025. if (p >= numprecincts) {
  29026. continue;
  29027. }
  29028. for (; l < layersCount;) {
  29029. var packet = createPacket(resolution, p, l);
  29030. l++;
  29031. return packet;
  29032. }
  29033. l = 0;
  29034. }
  29035. c = 0;
  29036. }
  29037. p = 0;
  29038. }
  29039. error('JPX Error: Out of packets');
  29040. };
  29041. }
  29042. function PositionComponentResolutionLayerIterator(context) {
  29043. var siz = context.SIZ;
  29044. var tileIndex = context.currentTile.index;
  29045. var tile = context.tiles[tileIndex];
  29046. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  29047. var componentsCount = siz.Csiz;
  29048. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  29049. var precinctsIterationSizes = precinctsSizes;
  29050. var l = 0, r = 0, c = 0, px = 0, py = 0;
  29051. this.nextPacket = function JpxImage_nextPacket() {
  29052. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  29053. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  29054. for (; c < componentsCount; c++) {
  29055. var component = tile.components[c];
  29056. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  29057. for (; r <= decompositionLevelsCount; r++) {
  29058. var resolution = component.resolutions[r];
  29059. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  29060. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  29061. if (k === null) {
  29062. continue;
  29063. }
  29064. for (; l < layersCount;) {
  29065. var packet = createPacket(resolution, k, l);
  29066. l++;
  29067. return packet;
  29068. }
  29069. l = 0;
  29070. }
  29071. r = 0;
  29072. }
  29073. c = 0;
  29074. }
  29075. px = 0;
  29076. }
  29077. error('JPX Error: Out of packets');
  29078. };
  29079. }
  29080. function ComponentPositionResolutionLayerIterator(context) {
  29081. var siz = context.SIZ;
  29082. var tileIndex = context.currentTile.index;
  29083. var tile = context.tiles[tileIndex];
  29084. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  29085. var componentsCount = siz.Csiz;
  29086. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  29087. var l = 0, r = 0, c = 0, px = 0, py = 0;
  29088. this.nextPacket = function JpxImage_nextPacket() {
  29089. for (; c < componentsCount; ++c) {
  29090. var component = tile.components[c];
  29091. var precinctsIterationSizes = precinctsSizes.components[c];
  29092. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  29093. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  29094. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  29095. for (; r <= decompositionLevelsCount; r++) {
  29096. var resolution = component.resolutions[r];
  29097. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  29098. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  29099. if (k === null) {
  29100. continue;
  29101. }
  29102. for (; l < layersCount;) {
  29103. var packet = createPacket(resolution, k, l);
  29104. l++;
  29105. return packet;
  29106. }
  29107. l = 0;
  29108. }
  29109. r = 0;
  29110. }
  29111. px = 0;
  29112. }
  29113. py = 0;
  29114. }
  29115. error('JPX Error: Out of packets');
  29116. };
  29117. }
  29118. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  29119. var posX = pxIndex * precinctIterationSizes.minWidth;
  29120. var posY = pyIndex * precinctIterationSizes.minHeight;
  29121. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  29122. return null;
  29123. }
  29124. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  29125. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  29126. }
  29127. function getPrecinctSizesInImageScale(tile) {
  29128. var componentsCount = tile.components.length;
  29129. var minWidth = Number.MAX_VALUE;
  29130. var minHeight = Number.MAX_VALUE;
  29131. var maxNumWide = 0;
  29132. var maxNumHigh = 0;
  29133. var sizePerComponent = new Array(componentsCount);
  29134. for (var c = 0; c < componentsCount; c++) {
  29135. var component = tile.components[c];
  29136. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  29137. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  29138. var minWidthCurrentComponent = Number.MAX_VALUE;
  29139. var minHeightCurrentComponent = Number.MAX_VALUE;
  29140. var maxNumWideCurrentComponent = 0;
  29141. var maxNumHighCurrentComponent = 0;
  29142. var scale = 1;
  29143. for (var r = decompositionLevelsCount; r >= 0; --r) {
  29144. var resolution = component.resolutions[r];
  29145. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  29146. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  29147. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  29148. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  29149. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  29150. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  29151. sizePerResolution[r] = {
  29152. width: widthCurrentResolution,
  29153. height: heightCurrentResolution
  29154. };
  29155. scale <<= 1;
  29156. }
  29157. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  29158. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  29159. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  29160. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  29161. sizePerComponent[c] = {
  29162. resolutions: sizePerResolution,
  29163. minWidth: minWidthCurrentComponent,
  29164. minHeight: minHeightCurrentComponent,
  29165. maxNumWide: maxNumWideCurrentComponent,
  29166. maxNumHigh: maxNumHighCurrentComponent
  29167. };
  29168. }
  29169. return {
  29170. components: sizePerComponent,
  29171. minWidth: minWidth,
  29172. minHeight: minHeight,
  29173. maxNumWide: maxNumWide,
  29174. maxNumHigh: maxNumHigh
  29175. };
  29176. }
  29177. function buildPackets(context) {
  29178. var siz = context.SIZ;
  29179. var tileIndex = context.currentTile.index;
  29180. var tile = context.tiles[tileIndex];
  29181. var componentsCount = siz.Csiz;
  29182. for (var c = 0; c < componentsCount; c++) {
  29183. var component = tile.components[c];
  29184. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  29185. var resolutions = [];
  29186. var subbands = [];
  29187. for (var r = 0; r <= decompositionLevelsCount; r++) {
  29188. var blocksDimensions = getBlocksDimensions(context, component, r);
  29189. var resolution = {};
  29190. var scale = 1 << decompositionLevelsCount - r;
  29191. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  29192. resolution.try0 = Math.ceil(component.tcy0 / scale);
  29193. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  29194. resolution.try1 = Math.ceil(component.tcy1 / scale);
  29195. resolution.resLevel = r;
  29196. buildPrecincts(context, resolution, blocksDimensions);
  29197. resolutions.push(resolution);
  29198. var subband;
  29199. if (r === 0) {
  29200. subband = {};
  29201. subband.type = 'LL';
  29202. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  29203. subband.tby0 = Math.ceil(component.tcy0 / scale);
  29204. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  29205. subband.tby1 = Math.ceil(component.tcy1 / scale);
  29206. subband.resolution = resolution;
  29207. buildCodeblocks(context, subband, blocksDimensions);
  29208. subbands.push(subband);
  29209. resolution.subbands = [subband];
  29210. } else {
  29211. var bscale = 1 << decompositionLevelsCount - r + 1;
  29212. var resolutionSubbands = [];
  29213. subband = {};
  29214. subband.type = 'HL';
  29215. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  29216. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  29217. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  29218. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  29219. subband.resolution = resolution;
  29220. buildCodeblocks(context, subband, blocksDimensions);
  29221. subbands.push(subband);
  29222. resolutionSubbands.push(subband);
  29223. subband = {};
  29224. subband.type = 'LH';
  29225. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  29226. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  29227. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  29228. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  29229. subband.resolution = resolution;
  29230. buildCodeblocks(context, subband, blocksDimensions);
  29231. subbands.push(subband);
  29232. resolutionSubbands.push(subband);
  29233. subband = {};
  29234. subband.type = 'HH';
  29235. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  29236. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  29237. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  29238. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  29239. subband.resolution = resolution;
  29240. buildCodeblocks(context, subband, blocksDimensions);
  29241. subbands.push(subband);
  29242. resolutionSubbands.push(subband);
  29243. resolution.subbands = resolutionSubbands;
  29244. }
  29245. }
  29246. component.resolutions = resolutions;
  29247. component.subbands = subbands;
  29248. }
  29249. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  29250. switch (progressionOrder) {
  29251. case 0:
  29252. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  29253. break;
  29254. case 1:
  29255. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  29256. break;
  29257. case 2:
  29258. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  29259. break;
  29260. case 3:
  29261. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  29262. break;
  29263. case 4:
  29264. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  29265. break;
  29266. default:
  29267. error('JPX Error: Unsupported progression order ' + progressionOrder);
  29268. }
  29269. }
  29270. function parseTilePackets(context, data, offset, dataLength) {
  29271. var position = 0;
  29272. var buffer, bufferSize = 0, skipNextBit = false;
  29273. function readBits(count) {
  29274. while (bufferSize < count) {
  29275. var b = data[offset + position];
  29276. position++;
  29277. if (skipNextBit) {
  29278. buffer = buffer << 7 | b;
  29279. bufferSize += 7;
  29280. skipNextBit = false;
  29281. } else {
  29282. buffer = buffer << 8 | b;
  29283. bufferSize += 8;
  29284. }
  29285. if (b === 0xFF) {
  29286. skipNextBit = true;
  29287. }
  29288. }
  29289. bufferSize -= count;
  29290. return buffer >>> bufferSize & (1 << count) - 1;
  29291. }
  29292. function skipMarkerIfEqual(value) {
  29293. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  29294. skipBytes(1);
  29295. return true;
  29296. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  29297. skipBytes(2);
  29298. return true;
  29299. }
  29300. return false;
  29301. }
  29302. function skipBytes(count) {
  29303. position += count;
  29304. }
  29305. function alignToByte() {
  29306. bufferSize = 0;
  29307. if (skipNextBit) {
  29308. position++;
  29309. skipNextBit = false;
  29310. }
  29311. }
  29312. function readCodingpasses() {
  29313. if (readBits(1) === 0) {
  29314. return 1;
  29315. }
  29316. if (readBits(1) === 0) {
  29317. return 2;
  29318. }
  29319. var value = readBits(2);
  29320. if (value < 3) {
  29321. return value + 3;
  29322. }
  29323. value = readBits(5);
  29324. if (value < 31) {
  29325. return value + 6;
  29326. }
  29327. value = readBits(7);
  29328. return value + 37;
  29329. }
  29330. var tileIndex = context.currentTile.index;
  29331. var tile = context.tiles[tileIndex];
  29332. var sopMarkerUsed = context.COD.sopMarkerUsed;
  29333. var ephMarkerUsed = context.COD.ephMarkerUsed;
  29334. var packetsIterator = tile.packetsIterator;
  29335. while (position < dataLength) {
  29336. alignToByte();
  29337. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  29338. skipBytes(4);
  29339. }
  29340. var packet = packetsIterator.nextPacket();
  29341. if (!readBits(1)) {
  29342. continue;
  29343. }
  29344. var layerNumber = packet.layerNumber;
  29345. var queue = [], codeblock;
  29346. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  29347. codeblock = packet.codeblocks[i];
  29348. var precinct = codeblock.precinct;
  29349. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  29350. var codeblockRow = codeblock.cby - precinct.cbyMin;
  29351. var codeblockIncluded = false;
  29352. var firstTimeInclusion = false;
  29353. var valueReady;
  29354. if (codeblock['included'] !== undefined) {
  29355. codeblockIncluded = !!readBits(1);
  29356. } else {
  29357. precinct = codeblock.precinct;
  29358. var inclusionTree, zeroBitPlanesTree;
  29359. if (precinct['inclusionTree'] !== undefined) {
  29360. inclusionTree = precinct.inclusionTree;
  29361. } else {
  29362. var width = precinct.cbxMax - precinct.cbxMin + 1;
  29363. var height = precinct.cbyMax - precinct.cbyMin + 1;
  29364. inclusionTree = new InclusionTree(width, height, layerNumber);
  29365. zeroBitPlanesTree = new TagTree(width, height);
  29366. precinct.inclusionTree = inclusionTree;
  29367. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  29368. }
  29369. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  29370. while (true) {
  29371. if (readBits(1)) {
  29372. valueReady = !inclusionTree.nextLevel();
  29373. if (valueReady) {
  29374. codeblock.included = true;
  29375. codeblockIncluded = firstTimeInclusion = true;
  29376. break;
  29377. }
  29378. } else {
  29379. inclusionTree.incrementValue(layerNumber);
  29380. break;
  29381. }
  29382. }
  29383. }
  29384. }
  29385. if (!codeblockIncluded) {
  29386. continue;
  29387. }
  29388. if (firstTimeInclusion) {
  29389. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  29390. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  29391. while (true) {
  29392. if (readBits(1)) {
  29393. valueReady = !zeroBitPlanesTree.nextLevel();
  29394. if (valueReady) {
  29395. break;
  29396. }
  29397. } else {
  29398. zeroBitPlanesTree.incrementValue();
  29399. }
  29400. }
  29401. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  29402. }
  29403. var codingpasses = readCodingpasses();
  29404. while (readBits(1)) {
  29405. codeblock.Lblock++;
  29406. }
  29407. var codingpassesLog2 = log2(codingpasses);
  29408. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  29409. var codedDataLength = readBits(bits);
  29410. queue.push({
  29411. codeblock: codeblock,
  29412. codingpasses: codingpasses,
  29413. dataLength: codedDataLength
  29414. });
  29415. }
  29416. alignToByte();
  29417. if (ephMarkerUsed) {
  29418. skipMarkerIfEqual(0x92);
  29419. }
  29420. while (queue.length > 0) {
  29421. var packetItem = queue.shift();
  29422. codeblock = packetItem.codeblock;
  29423. if (codeblock['data'] === undefined) {
  29424. codeblock.data = [];
  29425. }
  29426. codeblock.data.push({
  29427. data: data,
  29428. start: offset + position,
  29429. end: offset + position + packetItem.dataLength,
  29430. codingpasses: packetItem.codingpasses
  29431. });
  29432. position += packetItem.dataLength;
  29433. }
  29434. }
  29435. return position;
  29436. }
  29437. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  29438. var x0 = subband.tbx0;
  29439. var y0 = subband.tby0;
  29440. var width = subband.tbx1 - subband.tbx0;
  29441. var codeblocks = subband.codeblocks;
  29442. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  29443. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  29444. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  29445. var codeblock = codeblocks[i];
  29446. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  29447. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  29448. if (blockWidth === 0 || blockHeight === 0) {
  29449. continue;
  29450. }
  29451. if (codeblock['data'] === undefined) {
  29452. continue;
  29453. }
  29454. var bitModel, currentCodingpassType;
  29455. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  29456. currentCodingpassType = 2;
  29457. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  29458. var j, jj, dataItem;
  29459. for (j = 0, jj = data.length; j < jj; j++) {
  29460. dataItem = data[j];
  29461. totalLength += dataItem.end - dataItem.start;
  29462. codingpasses += dataItem.codingpasses;
  29463. }
  29464. var encodedData = new Uint8Array(totalLength);
  29465. var position = 0;
  29466. for (j = 0, jj = data.length; j < jj; j++) {
  29467. dataItem = data[j];
  29468. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  29469. encodedData.set(chunk, position);
  29470. position += chunk.length;
  29471. }
  29472. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  29473. bitModel.setDecoder(decoder);
  29474. for (j = 0; j < codingpasses; j++) {
  29475. switch (currentCodingpassType) {
  29476. case 0:
  29477. bitModel.runSignificancePropagationPass();
  29478. break;
  29479. case 1:
  29480. bitModel.runMagnitudeRefinementPass();
  29481. break;
  29482. case 2:
  29483. bitModel.runCleanupPass();
  29484. if (segmentationSymbolUsed) {
  29485. bitModel.checkSegmentationSymbol();
  29486. }
  29487. break;
  29488. }
  29489. currentCodingpassType = (currentCodingpassType + 1) % 3;
  29490. }
  29491. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  29492. var sign = bitModel.coefficentsSign;
  29493. var magnitude = bitModel.coefficentsMagnitude;
  29494. var bitsDecoded = bitModel.bitsDecoded;
  29495. var magnitudeCorrection = reversible ? 0 : 0.5;
  29496. var k, n, nb;
  29497. position = 0;
  29498. var interleave = subband.type !== 'LL';
  29499. for (j = 0; j < blockHeight; j++) {
  29500. var row = offset / width | 0;
  29501. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  29502. for (k = 0; k < blockWidth; k++) {
  29503. n = magnitude[position];
  29504. if (n !== 0) {
  29505. n = (n + magnitudeCorrection) * delta;
  29506. if (sign[position] !== 0) {
  29507. n = -n;
  29508. }
  29509. nb = bitsDecoded[position];
  29510. var pos = interleave ? levelOffset + (offset << 1) : offset;
  29511. if (reversible && nb >= mb) {
  29512. coefficients[pos] = n;
  29513. } else {
  29514. coefficients[pos] = n * (1 << mb - nb);
  29515. }
  29516. }
  29517. offset++;
  29518. position++;
  29519. }
  29520. offset += width - blockWidth;
  29521. }
  29522. }
  29523. }
  29524. function transformTile(context, tile, c) {
  29525. var component = tile.components[c];
  29526. var codingStyleParameters = component.codingStyleParameters;
  29527. var quantizationParameters = component.quantizationParameters;
  29528. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  29529. var spqcds = quantizationParameters.SPqcds;
  29530. var scalarExpounded = quantizationParameters.scalarExpounded;
  29531. var guardBits = quantizationParameters.guardBits;
  29532. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  29533. var precision = context.components[c].precision;
  29534. var reversible = codingStyleParameters.reversibleTransformation;
  29535. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  29536. var subbandCoefficients = [];
  29537. var b = 0;
  29538. for (var i = 0; i <= decompositionLevelsCount; i++) {
  29539. var resolution = component.resolutions[i];
  29540. var width = resolution.trx1 - resolution.trx0;
  29541. var height = resolution.try1 - resolution.try0;
  29542. var coefficients = new Float32Array(width * height);
  29543. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  29544. var mu, epsilon;
  29545. if (!scalarExpounded) {
  29546. mu = spqcds[0].mu;
  29547. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  29548. } else {
  29549. mu = spqcds[b].mu;
  29550. epsilon = spqcds[b].epsilon;
  29551. b++;
  29552. }
  29553. var subband = resolution.subbands[j];
  29554. var gainLog2 = SubbandsGainLog2[subband.type];
  29555. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  29556. var mb = guardBits + epsilon - 1;
  29557. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  29558. }
  29559. subbandCoefficients.push({
  29560. width: width,
  29561. height: height,
  29562. items: coefficients
  29563. });
  29564. }
  29565. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  29566. return {
  29567. left: component.tcx0,
  29568. top: component.tcy0,
  29569. width: result.width,
  29570. height: result.height,
  29571. items: result.items
  29572. };
  29573. }
  29574. function transformComponents(context) {
  29575. var siz = context.SIZ;
  29576. var components = context.components;
  29577. var componentsCount = siz.Csiz;
  29578. var resultImages = [];
  29579. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  29580. var tile = context.tiles[i];
  29581. var transformedTiles = [];
  29582. var c;
  29583. for (c = 0; c < componentsCount; c++) {
  29584. transformedTiles[c] = transformTile(context, tile, c);
  29585. }
  29586. var tile0 = transformedTiles[0];
  29587. var out = new Uint8Array(tile0.items.length * componentsCount);
  29588. var result = {
  29589. left: tile0.left,
  29590. top: tile0.top,
  29591. width: tile0.width,
  29592. height: tile0.height,
  29593. items: out
  29594. };
  29595. var shift, offset, max, min, maxK;
  29596. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  29597. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  29598. var fourComponents = componentsCount === 4;
  29599. var y0items = transformedTiles[0].items;
  29600. var y1items = transformedTiles[1].items;
  29601. var y2items = transformedTiles[2].items;
  29602. var y3items = fourComponents ? transformedTiles[3].items : null;
  29603. shift = components[0].precision - 8;
  29604. offset = (128 << shift) + 0.5;
  29605. max = 255 * (1 << shift);
  29606. maxK = max * 0.5;
  29607. min = -maxK;
  29608. var component0 = tile.components[0];
  29609. var alpha01 = componentsCount - 3;
  29610. jj = y0items.length;
  29611. if (!component0.codingStyleParameters.reversibleTransformation) {
  29612. for (j = 0; j < jj; j++, pos += alpha01) {
  29613. y0 = y0items[j] + offset;
  29614. y1 = y1items[j];
  29615. y2 = y2items[j];
  29616. r = y0 + 1.402 * y2;
  29617. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  29618. b = y0 + 1.772 * y1;
  29619. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  29620. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  29621. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  29622. }
  29623. } else {
  29624. for (j = 0; j < jj; j++, pos += alpha01) {
  29625. y0 = y0items[j] + offset;
  29626. y1 = y1items[j];
  29627. y2 = y2items[j];
  29628. g = y0 - (y2 + y1 >> 2);
  29629. r = g + y2;
  29630. b = g + y1;
  29631. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  29632. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  29633. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  29634. }
  29635. }
  29636. if (fourComponents) {
  29637. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  29638. k = y3items[j];
  29639. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  29640. }
  29641. }
  29642. } else {
  29643. for (c = 0; c < componentsCount; c++) {
  29644. var items = transformedTiles[c].items;
  29645. shift = components[c].precision - 8;
  29646. offset = (128 << shift) + 0.5;
  29647. max = 127.5 * (1 << shift);
  29648. min = -max;
  29649. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  29650. val = items[j];
  29651. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  29652. pos += componentsCount;
  29653. }
  29654. }
  29655. }
  29656. resultImages.push(result);
  29657. }
  29658. return resultImages;
  29659. }
  29660. function initializeTile(context, tileIndex) {
  29661. var siz = context.SIZ;
  29662. var componentsCount = siz.Csiz;
  29663. var tile = context.tiles[tileIndex];
  29664. for (var c = 0; c < componentsCount; c++) {
  29665. var component = tile.components[c];
  29666. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  29667. component.quantizationParameters = qcdOrQcc;
  29668. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  29669. component.codingStyleParameters = codOrCoc;
  29670. }
  29671. tile.codingStyleDefaultParameters = context.currentTile.COD;
  29672. }
  29673. var TagTree = function TagTreeClosure() {
  29674. function TagTree(width, height) {
  29675. var levelsLength = log2(Math.max(width, height)) + 1;
  29676. this.levels = [];
  29677. for (var i = 0; i < levelsLength; i++) {
  29678. var level = {
  29679. width: width,
  29680. height: height,
  29681. items: []
  29682. };
  29683. this.levels.push(level);
  29684. width = Math.ceil(width / 2);
  29685. height = Math.ceil(height / 2);
  29686. }
  29687. }
  29688. TagTree.prototype = {
  29689. reset: function TagTree_reset(i, j) {
  29690. var currentLevel = 0, value = 0, level;
  29691. while (currentLevel < this.levels.length) {
  29692. level = this.levels[currentLevel];
  29693. var index = i + j * level.width;
  29694. if (level.items[index] !== undefined) {
  29695. value = level.items[index];
  29696. break;
  29697. }
  29698. level.index = index;
  29699. i >>= 1;
  29700. j >>= 1;
  29701. currentLevel++;
  29702. }
  29703. currentLevel--;
  29704. level = this.levels[currentLevel];
  29705. level.items[level.index] = value;
  29706. this.currentLevel = currentLevel;
  29707. delete this.value;
  29708. },
  29709. incrementValue: function TagTree_incrementValue() {
  29710. var level = this.levels[this.currentLevel];
  29711. level.items[level.index]++;
  29712. },
  29713. nextLevel: function TagTree_nextLevel() {
  29714. var currentLevel = this.currentLevel;
  29715. var level = this.levels[currentLevel];
  29716. var value = level.items[level.index];
  29717. currentLevel--;
  29718. if (currentLevel < 0) {
  29719. this.value = value;
  29720. return false;
  29721. }
  29722. this.currentLevel = currentLevel;
  29723. level = this.levels[currentLevel];
  29724. level.items[level.index] = value;
  29725. return true;
  29726. }
  29727. };
  29728. return TagTree;
  29729. }();
  29730. var InclusionTree = function InclusionTreeClosure() {
  29731. function InclusionTree(width, height, defaultValue) {
  29732. var levelsLength = log2(Math.max(width, height)) + 1;
  29733. this.levels = [];
  29734. for (var i = 0; i < levelsLength; i++) {
  29735. var items = new Uint8Array(width * height);
  29736. for (var j = 0, jj = items.length; j < jj; j++) {
  29737. items[j] = defaultValue;
  29738. }
  29739. var level = {
  29740. width: width,
  29741. height: height,
  29742. items: items
  29743. };
  29744. this.levels.push(level);
  29745. width = Math.ceil(width / 2);
  29746. height = Math.ceil(height / 2);
  29747. }
  29748. }
  29749. InclusionTree.prototype = {
  29750. reset: function InclusionTree_reset(i, j, stopValue) {
  29751. var currentLevel = 0;
  29752. while (currentLevel < this.levels.length) {
  29753. var level = this.levels[currentLevel];
  29754. var index = i + j * level.width;
  29755. level.index = index;
  29756. var value = level.items[index];
  29757. if (value === 0xFF) {
  29758. break;
  29759. }
  29760. if (value > stopValue) {
  29761. this.currentLevel = currentLevel;
  29762. this.propagateValues();
  29763. return false;
  29764. }
  29765. i >>= 1;
  29766. j >>= 1;
  29767. currentLevel++;
  29768. }
  29769. this.currentLevel = currentLevel - 1;
  29770. return true;
  29771. },
  29772. incrementValue: function InclusionTree_incrementValue(stopValue) {
  29773. var level = this.levels[this.currentLevel];
  29774. level.items[level.index] = stopValue + 1;
  29775. this.propagateValues();
  29776. },
  29777. propagateValues: function InclusionTree_propagateValues() {
  29778. var levelIndex = this.currentLevel;
  29779. var level = this.levels[levelIndex];
  29780. var currentValue = level.items[level.index];
  29781. while (--levelIndex >= 0) {
  29782. level = this.levels[levelIndex];
  29783. level.items[level.index] = currentValue;
  29784. }
  29785. },
  29786. nextLevel: function InclusionTree_nextLevel() {
  29787. var currentLevel = this.currentLevel;
  29788. var level = this.levels[currentLevel];
  29789. var value = level.items[level.index];
  29790. level.items[level.index] = 0xFF;
  29791. currentLevel--;
  29792. if (currentLevel < 0) {
  29793. return false;
  29794. }
  29795. this.currentLevel = currentLevel;
  29796. level = this.levels[currentLevel];
  29797. level.items[level.index] = value;
  29798. return true;
  29799. }
  29800. };
  29801. return InclusionTree;
  29802. }();
  29803. var BitModel = function BitModelClosure() {
  29804. var UNIFORM_CONTEXT = 17;
  29805. var RUNLENGTH_CONTEXT = 18;
  29806. var LLAndLHContextsLabel = new Uint8Array([
  29807. 0,
  29808. 5,
  29809. 8,
  29810. 0,
  29811. 3,
  29812. 7,
  29813. 8,
  29814. 0,
  29815. 4,
  29816. 7,
  29817. 8,
  29818. 0,
  29819. 0,
  29820. 0,
  29821. 0,
  29822. 0,
  29823. 1,
  29824. 6,
  29825. 8,
  29826. 0,
  29827. 3,
  29828. 7,
  29829. 8,
  29830. 0,
  29831. 4,
  29832. 7,
  29833. 8,
  29834. 0,
  29835. 0,
  29836. 0,
  29837. 0,
  29838. 0,
  29839. 2,
  29840. 6,
  29841. 8,
  29842. 0,
  29843. 3,
  29844. 7,
  29845. 8,
  29846. 0,
  29847. 4,
  29848. 7,
  29849. 8,
  29850. 0,
  29851. 0,
  29852. 0,
  29853. 0,
  29854. 0,
  29855. 2,
  29856. 6,
  29857. 8,
  29858. 0,
  29859. 3,
  29860. 7,
  29861. 8,
  29862. 0,
  29863. 4,
  29864. 7,
  29865. 8,
  29866. 0,
  29867. 0,
  29868. 0,
  29869. 0,
  29870. 0,
  29871. 2,
  29872. 6,
  29873. 8,
  29874. 0,
  29875. 3,
  29876. 7,
  29877. 8,
  29878. 0,
  29879. 4,
  29880. 7,
  29881. 8
  29882. ]);
  29883. var HLContextLabel = new Uint8Array([
  29884. 0,
  29885. 3,
  29886. 4,
  29887. 0,
  29888. 5,
  29889. 7,
  29890. 7,
  29891. 0,
  29892. 8,
  29893. 8,
  29894. 8,
  29895. 0,
  29896. 0,
  29897. 0,
  29898. 0,
  29899. 0,
  29900. 1,
  29901. 3,
  29902. 4,
  29903. 0,
  29904. 6,
  29905. 7,
  29906. 7,
  29907. 0,
  29908. 8,
  29909. 8,
  29910. 8,
  29911. 0,
  29912. 0,
  29913. 0,
  29914. 0,
  29915. 0,
  29916. 2,
  29917. 3,
  29918. 4,
  29919. 0,
  29920. 6,
  29921. 7,
  29922. 7,
  29923. 0,
  29924. 8,
  29925. 8,
  29926. 8,
  29927. 0,
  29928. 0,
  29929. 0,
  29930. 0,
  29931. 0,
  29932. 2,
  29933. 3,
  29934. 4,
  29935. 0,
  29936. 6,
  29937. 7,
  29938. 7,
  29939. 0,
  29940. 8,
  29941. 8,
  29942. 8,
  29943. 0,
  29944. 0,
  29945. 0,
  29946. 0,
  29947. 0,
  29948. 2,
  29949. 3,
  29950. 4,
  29951. 0,
  29952. 6,
  29953. 7,
  29954. 7,
  29955. 0,
  29956. 8,
  29957. 8,
  29958. 8
  29959. ]);
  29960. var HHContextLabel = new Uint8Array([
  29961. 0,
  29962. 1,
  29963. 2,
  29964. 0,
  29965. 1,
  29966. 2,
  29967. 2,
  29968. 0,
  29969. 2,
  29970. 2,
  29971. 2,
  29972. 0,
  29973. 0,
  29974. 0,
  29975. 0,
  29976. 0,
  29977. 3,
  29978. 4,
  29979. 5,
  29980. 0,
  29981. 4,
  29982. 5,
  29983. 5,
  29984. 0,
  29985. 5,
  29986. 5,
  29987. 5,
  29988. 0,
  29989. 0,
  29990. 0,
  29991. 0,
  29992. 0,
  29993. 6,
  29994. 7,
  29995. 7,
  29996. 0,
  29997. 7,
  29998. 7,
  29999. 7,
  30000. 0,
  30001. 7,
  30002. 7,
  30003. 7,
  30004. 0,
  30005. 0,
  30006. 0,
  30007. 0,
  30008. 0,
  30009. 8,
  30010. 8,
  30011. 8,
  30012. 0,
  30013. 8,
  30014. 8,
  30015. 8,
  30016. 0,
  30017. 8,
  30018. 8,
  30019. 8,
  30020. 0,
  30021. 0,
  30022. 0,
  30023. 0,
  30024. 0,
  30025. 8,
  30026. 8,
  30027. 8,
  30028. 0,
  30029. 8,
  30030. 8,
  30031. 8,
  30032. 0,
  30033. 8,
  30034. 8,
  30035. 8
  30036. ]);
  30037. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  30038. this.width = width;
  30039. this.height = height;
  30040. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  30041. var coefficientCount = width * height;
  30042. this.neighborsSignificance = new Uint8Array(coefficientCount);
  30043. this.coefficentsSign = new Uint8Array(coefficientCount);
  30044. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  30045. this.processingFlags = new Uint8Array(coefficientCount);
  30046. var bitsDecoded = new Uint8Array(coefficientCount);
  30047. if (zeroBitPlanes !== 0) {
  30048. for (var i = 0; i < coefficientCount; i++) {
  30049. bitsDecoded[i] = zeroBitPlanes;
  30050. }
  30051. }
  30052. this.bitsDecoded = bitsDecoded;
  30053. this.reset();
  30054. }
  30055. BitModel.prototype = {
  30056. setDecoder: function BitModel_setDecoder(decoder) {
  30057. this.decoder = decoder;
  30058. },
  30059. reset: function BitModel_reset() {
  30060. this.contexts = new Int8Array(19);
  30061. this.contexts[0] = 4 << 1 | 0;
  30062. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  30063. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  30064. },
  30065. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  30066. var neighborsSignificance = this.neighborsSignificance;
  30067. var width = this.width, height = this.height;
  30068. var left = column > 0;
  30069. var right = column + 1 < width;
  30070. var i;
  30071. if (row > 0) {
  30072. i = index - width;
  30073. if (left) {
  30074. neighborsSignificance[i - 1] += 0x10;
  30075. }
  30076. if (right) {
  30077. neighborsSignificance[i + 1] += 0x10;
  30078. }
  30079. neighborsSignificance[i] += 0x04;
  30080. }
  30081. if (row + 1 < height) {
  30082. i = index + width;
  30083. if (left) {
  30084. neighborsSignificance[i - 1] += 0x10;
  30085. }
  30086. if (right) {
  30087. neighborsSignificance[i + 1] += 0x10;
  30088. }
  30089. neighborsSignificance[i] += 0x04;
  30090. }
  30091. if (left) {
  30092. neighborsSignificance[index - 1] += 0x01;
  30093. }
  30094. if (right) {
  30095. neighborsSignificance[index + 1] += 0x01;
  30096. }
  30097. neighborsSignificance[index] |= 0x80;
  30098. },
  30099. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  30100. var decoder = this.decoder;
  30101. var width = this.width, height = this.height;
  30102. var coefficentsMagnitude = this.coefficentsMagnitude;
  30103. var coefficentsSign = this.coefficentsSign;
  30104. var neighborsSignificance = this.neighborsSignificance;
  30105. var processingFlags = this.processingFlags;
  30106. var contexts = this.contexts;
  30107. var labels = this.contextLabelTable;
  30108. var bitsDecoded = this.bitsDecoded;
  30109. var processedInverseMask = ~1;
  30110. var processedMask = 1;
  30111. var firstMagnitudeBitMask = 2;
  30112. for (var i0 = 0; i0 < height; i0 += 4) {
  30113. for (var j = 0; j < width; j++) {
  30114. var index = i0 * width + j;
  30115. for (var i1 = 0; i1 < 4; i1++, index += width) {
  30116. var i = i0 + i1;
  30117. if (i >= height) {
  30118. break;
  30119. }
  30120. processingFlags[index] &= processedInverseMask;
  30121. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  30122. continue;
  30123. }
  30124. var contextLabel = labels[neighborsSignificance[index]];
  30125. var decision = decoder.readBit(contexts, contextLabel);
  30126. if (decision) {
  30127. var sign = this.decodeSignBit(i, j, index);
  30128. coefficentsSign[index] = sign;
  30129. coefficentsMagnitude[index] = 1;
  30130. this.setNeighborsSignificance(i, j, index);
  30131. processingFlags[index] |= firstMagnitudeBitMask;
  30132. }
  30133. bitsDecoded[index]++;
  30134. processingFlags[index] |= processedMask;
  30135. }
  30136. }
  30137. }
  30138. },
  30139. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  30140. var width = this.width, height = this.height;
  30141. var coefficentsMagnitude = this.coefficentsMagnitude;
  30142. var coefficentsSign = this.coefficentsSign;
  30143. var contribution, sign0, sign1, significance1;
  30144. var contextLabel, decoded;
  30145. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  30146. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  30147. sign1 = coefficentsSign[index + 1];
  30148. if (significance1) {
  30149. sign0 = coefficentsSign[index - 1];
  30150. contribution = 1 - sign1 - sign0;
  30151. } else {
  30152. contribution = 1 - sign1 - sign1;
  30153. }
  30154. } else if (significance1) {
  30155. sign0 = coefficentsSign[index - 1];
  30156. contribution = 1 - sign0 - sign0;
  30157. } else {
  30158. contribution = 0;
  30159. }
  30160. var horizontalContribution = 3 * contribution;
  30161. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  30162. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  30163. sign1 = coefficentsSign[index + width];
  30164. if (significance1) {
  30165. sign0 = coefficentsSign[index - width];
  30166. contribution = 1 - sign1 - sign0 + horizontalContribution;
  30167. } else {
  30168. contribution = 1 - sign1 - sign1 + horizontalContribution;
  30169. }
  30170. } else if (significance1) {
  30171. sign0 = coefficentsSign[index - width];
  30172. contribution = 1 - sign0 - sign0 + horizontalContribution;
  30173. } else {
  30174. contribution = horizontalContribution;
  30175. }
  30176. if (contribution >= 0) {
  30177. contextLabel = 9 + contribution;
  30178. decoded = this.decoder.readBit(this.contexts, contextLabel);
  30179. } else {
  30180. contextLabel = 9 - contribution;
  30181. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  30182. }
  30183. return decoded;
  30184. },
  30185. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  30186. var decoder = this.decoder;
  30187. var width = this.width, height = this.height;
  30188. var coefficentsMagnitude = this.coefficentsMagnitude;
  30189. var neighborsSignificance = this.neighborsSignificance;
  30190. var contexts = this.contexts;
  30191. var bitsDecoded = this.bitsDecoded;
  30192. var processingFlags = this.processingFlags;
  30193. var processedMask = 1;
  30194. var firstMagnitudeBitMask = 2;
  30195. var length = width * height;
  30196. var width4 = width * 4;
  30197. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  30198. indexNext = Math.min(length, index0 + width4);
  30199. for (var j = 0; j < width; j++) {
  30200. for (var index = index0 + j; index < indexNext; index += width) {
  30201. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  30202. continue;
  30203. }
  30204. var contextLabel = 16;
  30205. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  30206. processingFlags[index] ^= firstMagnitudeBitMask;
  30207. var significance = neighborsSignificance[index] & 127;
  30208. contextLabel = significance === 0 ? 15 : 14;
  30209. }
  30210. var bit = decoder.readBit(contexts, contextLabel);
  30211. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  30212. bitsDecoded[index]++;
  30213. processingFlags[index] |= processedMask;
  30214. }
  30215. }
  30216. }
  30217. },
  30218. runCleanupPass: function BitModel_runCleanupPass() {
  30219. var decoder = this.decoder;
  30220. var width = this.width, height = this.height;
  30221. var neighborsSignificance = this.neighborsSignificance;
  30222. var coefficentsMagnitude = this.coefficentsMagnitude;
  30223. var coefficentsSign = this.coefficentsSign;
  30224. var contexts = this.contexts;
  30225. var labels = this.contextLabelTable;
  30226. var bitsDecoded = this.bitsDecoded;
  30227. var processingFlags = this.processingFlags;
  30228. var processedMask = 1;
  30229. var firstMagnitudeBitMask = 2;
  30230. var oneRowDown = width;
  30231. var twoRowsDown = width * 2;
  30232. var threeRowsDown = width * 3;
  30233. var iNext;
  30234. for (var i0 = 0; i0 < height; i0 = iNext) {
  30235. iNext = Math.min(i0 + 4, height);
  30236. var indexBase = i0 * width;
  30237. var checkAllEmpty = i0 + 3 < height;
  30238. for (var j = 0; j < width; j++) {
  30239. var index0 = indexBase + j;
  30240. var allEmpty = checkAllEmpty && processingFlags[index0] === 0 && processingFlags[index0 + oneRowDown] === 0 && processingFlags[index0 + twoRowsDown] === 0 && processingFlags[index0 + threeRowsDown] === 0 && neighborsSignificance[index0] === 0 && neighborsSignificance[index0 + oneRowDown] === 0 && neighborsSignificance[index0 + twoRowsDown] === 0 && neighborsSignificance[index0 + threeRowsDown] === 0;
  30241. var i1 = 0, index = index0;
  30242. var i = i0, sign;
  30243. if (allEmpty) {
  30244. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  30245. if (!hasSignificantCoefficent) {
  30246. bitsDecoded[index0]++;
  30247. bitsDecoded[index0 + oneRowDown]++;
  30248. bitsDecoded[index0 + twoRowsDown]++;
  30249. bitsDecoded[index0 + threeRowsDown]++;
  30250. continue;
  30251. }
  30252. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  30253. if (i1 !== 0) {
  30254. i = i0 + i1;
  30255. index += i1 * width;
  30256. }
  30257. sign = this.decodeSignBit(i, j, index);
  30258. coefficentsSign[index] = sign;
  30259. coefficentsMagnitude[index] = 1;
  30260. this.setNeighborsSignificance(i, j, index);
  30261. processingFlags[index] |= firstMagnitudeBitMask;
  30262. index = index0;
  30263. for (var i2 = i0; i2 <= i; i2++, index += width) {
  30264. bitsDecoded[index]++;
  30265. }
  30266. i1++;
  30267. }
  30268. for (i = i0 + i1; i < iNext; i++, index += width) {
  30269. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  30270. continue;
  30271. }
  30272. var contextLabel = labels[neighborsSignificance[index]];
  30273. var decision = decoder.readBit(contexts, contextLabel);
  30274. if (decision === 1) {
  30275. sign = this.decodeSignBit(i, j, index);
  30276. coefficentsSign[index] = sign;
  30277. coefficentsMagnitude[index] = 1;
  30278. this.setNeighborsSignificance(i, j, index);
  30279. processingFlags[index] |= firstMagnitudeBitMask;
  30280. }
  30281. bitsDecoded[index]++;
  30282. }
  30283. }
  30284. }
  30285. },
  30286. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  30287. var decoder = this.decoder;
  30288. var contexts = this.contexts;
  30289. var symbol = decoder.readBit(contexts, UNIFORM_CONTEXT) << 3 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 2 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  30290. if (symbol !== 0xA) {
  30291. error('JPX Error: Invalid segmentation symbol');
  30292. }
  30293. }
  30294. };
  30295. return BitModel;
  30296. }();
  30297. var Transform = function TransformClosure() {
  30298. function Transform() {
  30299. }
  30300. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  30301. var ll = subbands[0];
  30302. for (var i = 1, ii = subbands.length; i < ii; i++) {
  30303. ll = this.iterate(ll, subbands[i], u0, v0);
  30304. }
  30305. return ll;
  30306. };
  30307. Transform.prototype.extend = function extend(buffer, offset, size) {
  30308. var i1 = offset - 1, j1 = offset + 1;
  30309. var i2 = offset + size - 2, j2 = offset + size;
  30310. buffer[i1--] = buffer[j1++];
  30311. buffer[j2++] = buffer[i2--];
  30312. buffer[i1--] = buffer[j1++];
  30313. buffer[j2++] = buffer[i2--];
  30314. buffer[i1--] = buffer[j1++];
  30315. buffer[j2++] = buffer[i2--];
  30316. buffer[i1] = buffer[j1];
  30317. buffer[j2] = buffer[i2];
  30318. };
  30319. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  30320. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  30321. var width = hl_lh_hh.width;
  30322. var height = hl_lh_hh.height;
  30323. var items = hl_lh_hh.items;
  30324. var i, j, k, l, u, v;
  30325. for (k = 0, i = 0; i < llHeight; i++) {
  30326. l = i * 2 * width;
  30327. for (j = 0; j < llWidth; j++, k++, l += 2) {
  30328. items[l] = llItems[k];
  30329. }
  30330. }
  30331. llItems = ll.items = null;
  30332. var bufferPadding = 4;
  30333. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  30334. if (width === 1) {
  30335. if ((u0 & 1) !== 0) {
  30336. for (v = 0, k = 0; v < height; v++, k += width) {
  30337. items[k] *= 0.5;
  30338. }
  30339. }
  30340. } else {
  30341. for (v = 0, k = 0; v < height; v++, k += width) {
  30342. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  30343. this.extend(rowBuffer, bufferPadding, width);
  30344. this.filter(rowBuffer, bufferPadding, width);
  30345. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  30346. }
  30347. }
  30348. var numBuffers = 16;
  30349. var colBuffers = [];
  30350. for (i = 0; i < numBuffers; i++) {
  30351. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  30352. }
  30353. var b, currentBuffer = 0;
  30354. ll = bufferPadding + height;
  30355. if (height === 1) {
  30356. if ((v0 & 1) !== 0) {
  30357. for (u = 0; u < width; u++) {
  30358. items[u] *= 0.5;
  30359. }
  30360. }
  30361. } else {
  30362. for (u = 0; u < width; u++) {
  30363. if (currentBuffer === 0) {
  30364. numBuffers = Math.min(width - u, numBuffers);
  30365. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  30366. for (b = 0; b < numBuffers; b++) {
  30367. colBuffers[b][l] = items[k + b];
  30368. }
  30369. }
  30370. currentBuffer = numBuffers;
  30371. }
  30372. currentBuffer--;
  30373. var buffer = colBuffers[currentBuffer];
  30374. this.extend(buffer, bufferPadding, height);
  30375. this.filter(buffer, bufferPadding, height);
  30376. if (currentBuffer === 0) {
  30377. k = u - numBuffers + 1;
  30378. for (l = bufferPadding; l < ll; k += width, l++) {
  30379. for (b = 0; b < numBuffers; b++) {
  30380. items[k + b] = colBuffers[b][l];
  30381. }
  30382. }
  30383. }
  30384. }
  30385. }
  30386. return {
  30387. width: width,
  30388. height: height,
  30389. items: items
  30390. };
  30391. };
  30392. return Transform;
  30393. }();
  30394. var IrreversibleTransform = function IrreversibleTransformClosure() {
  30395. function IrreversibleTransform() {
  30396. Transform.call(this);
  30397. }
  30398. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  30399. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  30400. var len = length >> 1;
  30401. offset = offset | 0;
  30402. var j, n, current, next;
  30403. var alpha = -1.586134342059924;
  30404. var beta = -0.052980118572961;
  30405. var gamma = 0.882911075530934;
  30406. var delta = 0.443506852043971;
  30407. var K = 1.230174104914001;
  30408. var K_ = 1 / K;
  30409. j = offset - 3;
  30410. for (n = len + 4; n--; j += 2) {
  30411. x[j] *= K_;
  30412. }
  30413. j = offset - 2;
  30414. current = delta * x[j - 1];
  30415. for (n = len + 3; n--; j += 2) {
  30416. next = delta * x[j + 1];
  30417. x[j] = K * x[j] - current - next;
  30418. if (n--) {
  30419. j += 2;
  30420. current = delta * x[j + 1];
  30421. x[j] = K * x[j] - current - next;
  30422. } else {
  30423. break;
  30424. }
  30425. }
  30426. j = offset - 1;
  30427. current = gamma * x[j - 1];
  30428. for (n = len + 2; n--; j += 2) {
  30429. next = gamma * x[j + 1];
  30430. x[j] -= current + next;
  30431. if (n--) {
  30432. j += 2;
  30433. current = gamma * x[j + 1];
  30434. x[j] -= current + next;
  30435. } else {
  30436. break;
  30437. }
  30438. }
  30439. j = offset;
  30440. current = beta * x[j - 1];
  30441. for (n = len + 1; n--; j += 2) {
  30442. next = beta * x[j + 1];
  30443. x[j] -= current + next;
  30444. if (n--) {
  30445. j += 2;
  30446. current = beta * x[j + 1];
  30447. x[j] -= current + next;
  30448. } else {
  30449. break;
  30450. }
  30451. }
  30452. if (len !== 0) {
  30453. j = offset + 1;
  30454. current = alpha * x[j - 1];
  30455. for (n = len; n--; j += 2) {
  30456. next = alpha * x[j + 1];
  30457. x[j] -= current + next;
  30458. if (n--) {
  30459. j += 2;
  30460. current = alpha * x[j + 1];
  30461. x[j] -= current + next;
  30462. } else {
  30463. break;
  30464. }
  30465. }
  30466. }
  30467. };
  30468. return IrreversibleTransform;
  30469. }();
  30470. var ReversibleTransform = function ReversibleTransformClosure() {
  30471. function ReversibleTransform() {
  30472. Transform.call(this);
  30473. }
  30474. ReversibleTransform.prototype = Object.create(Transform.prototype);
  30475. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  30476. var len = length >> 1;
  30477. offset = offset | 0;
  30478. var j, n;
  30479. for (j = offset, n = len + 1; n--; j += 2) {
  30480. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  30481. }
  30482. for (j = offset + 1, n = len; n--; j += 2) {
  30483. x[j] += x[j - 1] + x[j + 1] >> 1;
  30484. }
  30485. };
  30486. return ReversibleTransform;
  30487. }();
  30488. return JpxImage;
  30489. }();
  30490. exports.JpxImage = JpxImage;
  30491. /***/ }),
  30492. /* 16 */
  30493. /***/ (function(module, exports, __w_pdfjs_require__) {
  30494. "use strict";
  30495. var sharedUtil = __w_pdfjs_require__(0);
  30496. var corePrimitives = __w_pdfjs_require__(1);
  30497. var coreCrypto = __w_pdfjs_require__(13);
  30498. var coreParser = __w_pdfjs_require__(5);
  30499. var coreChunkedStream = __w_pdfjs_require__(12);
  30500. var coreColorSpace = __w_pdfjs_require__(3);
  30501. var InvalidPDFException = sharedUtil.InvalidPDFException;
  30502. var MissingDataException = sharedUtil.MissingDataException;
  30503. var XRefParseException = sharedUtil.XRefParseException;
  30504. var assert = sharedUtil.assert;
  30505. var bytesToString = sharedUtil.bytesToString;
  30506. var createPromiseCapability = sharedUtil.createPromiseCapability;
  30507. var error = sharedUtil.error;
  30508. var info = sharedUtil.info;
  30509. var isArray = sharedUtil.isArray;
  30510. var isBool = sharedUtil.isBool;
  30511. var isInt = sharedUtil.isInt;
  30512. var isString = sharedUtil.isString;
  30513. var shadow = sharedUtil.shadow;
  30514. var stringToPDFString = sharedUtil.stringToPDFString;
  30515. var stringToUTF8String = sharedUtil.stringToUTF8String;
  30516. var warn = sharedUtil.warn;
  30517. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  30518. var Util = sharedUtil.Util;
  30519. var Ref = corePrimitives.Ref;
  30520. var RefSet = corePrimitives.RefSet;
  30521. var RefSetCache = corePrimitives.RefSetCache;
  30522. var isName = corePrimitives.isName;
  30523. var isCmd = corePrimitives.isCmd;
  30524. var isDict = corePrimitives.isDict;
  30525. var isRef = corePrimitives.isRef;
  30526. var isRefsEqual = corePrimitives.isRefsEqual;
  30527. var isStream = corePrimitives.isStream;
  30528. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  30529. var Lexer = coreParser.Lexer;
  30530. var Parser = coreParser.Parser;
  30531. var ChunkedStream = coreChunkedStream.ChunkedStream;
  30532. var ColorSpace = coreColorSpace.ColorSpace;
  30533. var Catalog = function CatalogClosure() {
  30534. function Catalog(pdfManager, xref, pageFactory) {
  30535. this.pdfManager = pdfManager;
  30536. this.xref = xref;
  30537. this.catDict = xref.getCatalogObj();
  30538. this.fontCache = new RefSetCache();
  30539. this.builtInCMapCache = Object.create(null);
  30540. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  30541. this.pageFactory = pageFactory;
  30542. this.pagePromises = [];
  30543. }
  30544. Catalog.prototype = {
  30545. get metadata() {
  30546. var streamRef = this.catDict.getRaw('Metadata');
  30547. if (!isRef(streamRef)) {
  30548. return shadow(this, 'metadata', null);
  30549. }
  30550. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  30551. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  30552. var metadata;
  30553. if (stream && isDict(stream.dict)) {
  30554. var type = stream.dict.get('Type');
  30555. var subtype = stream.dict.get('Subtype');
  30556. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  30557. try {
  30558. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  30559. } catch (e) {
  30560. info('Skipping invalid metadata.');
  30561. }
  30562. }
  30563. }
  30564. return shadow(this, 'metadata', metadata);
  30565. },
  30566. get toplevelPagesDict() {
  30567. var pagesObj = this.catDict.get('Pages');
  30568. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  30569. return shadow(this, 'toplevelPagesDict', pagesObj);
  30570. },
  30571. get documentOutline() {
  30572. var obj = null;
  30573. try {
  30574. obj = this.readDocumentOutline();
  30575. } catch (ex) {
  30576. if (ex instanceof MissingDataException) {
  30577. throw ex;
  30578. }
  30579. warn('Unable to read document outline');
  30580. }
  30581. return shadow(this, 'documentOutline', obj);
  30582. },
  30583. readDocumentOutline: function Catalog_readDocumentOutline() {
  30584. var obj = this.catDict.get('Outlines');
  30585. if (!isDict(obj)) {
  30586. return null;
  30587. }
  30588. obj = obj.getRaw('First');
  30589. if (!isRef(obj)) {
  30590. return null;
  30591. }
  30592. var root = { items: [] };
  30593. var queue = [{
  30594. obj: obj,
  30595. parent: root
  30596. }];
  30597. var processed = new RefSet();
  30598. processed.put(obj);
  30599. var xref = this.xref, blackColor = new Uint8Array(3);
  30600. while (queue.length > 0) {
  30601. var i = queue.shift();
  30602. var outlineDict = xref.fetchIfRef(i.obj);
  30603. if (outlineDict === null) {
  30604. continue;
  30605. }
  30606. assert(outlineDict.has('Title'), 'Invalid outline item');
  30607. var data = {
  30608. url: null,
  30609. dest: null
  30610. };
  30611. Catalog.parseDestDictionary({
  30612. destDict: outlineDict,
  30613. resultObj: data,
  30614. docBaseUrl: this.pdfManager.docBaseUrl
  30615. });
  30616. var title = outlineDict.get('Title');
  30617. var flags = outlineDict.get('F') || 0;
  30618. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  30619. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  30620. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  30621. }
  30622. var outlineItem = {
  30623. dest: data.dest,
  30624. url: data.url,
  30625. unsafeUrl: data.unsafeUrl,
  30626. newWindow: data.newWindow,
  30627. title: stringToPDFString(title),
  30628. color: rgbColor,
  30629. count: outlineDict.get('Count'),
  30630. bold: !!(flags & 2),
  30631. italic: !!(flags & 1),
  30632. items: []
  30633. };
  30634. i.parent.items.push(outlineItem);
  30635. obj = outlineDict.getRaw('First');
  30636. if (isRef(obj) && !processed.has(obj)) {
  30637. queue.push({
  30638. obj: obj,
  30639. parent: outlineItem
  30640. });
  30641. processed.put(obj);
  30642. }
  30643. obj = outlineDict.getRaw('Next');
  30644. if (isRef(obj) && !processed.has(obj)) {
  30645. queue.push({
  30646. obj: obj,
  30647. parent: i.parent
  30648. });
  30649. processed.put(obj);
  30650. }
  30651. }
  30652. return root.items.length > 0 ? root.items : null;
  30653. },
  30654. get numPages() {
  30655. var obj = this.toplevelPagesDict.get('Count');
  30656. assert(isInt(obj), 'page count in top level pages object is not an integer');
  30657. return shadow(this, 'num', obj);
  30658. },
  30659. get destinations() {
  30660. function fetchDestination(dest) {
  30661. return isDict(dest) ? dest.get('D') : dest;
  30662. }
  30663. var xref = this.xref;
  30664. var dests = {}, nameTreeRef, nameDictionaryRef;
  30665. var obj = this.catDict.get('Names');
  30666. if (obj && obj.has('Dests')) {
  30667. nameTreeRef = obj.getRaw('Dests');
  30668. } else if (this.catDict.has('Dests')) {
  30669. nameDictionaryRef = this.catDict.get('Dests');
  30670. }
  30671. if (nameDictionaryRef) {
  30672. obj = nameDictionaryRef;
  30673. obj.forEach(function catalogForEach(key, value) {
  30674. if (!value) {
  30675. return;
  30676. }
  30677. dests[key] = fetchDestination(value);
  30678. });
  30679. }
  30680. if (nameTreeRef) {
  30681. var nameTree = new NameTree(nameTreeRef, xref);
  30682. var names = nameTree.getAll();
  30683. for (var name in names) {
  30684. dests[name] = fetchDestination(names[name]);
  30685. }
  30686. }
  30687. return shadow(this, 'destinations', dests);
  30688. },
  30689. getDestination: function Catalog_getDestination(destinationId) {
  30690. function fetchDestination(dest) {
  30691. return isDict(dest) ? dest.get('D') : dest;
  30692. }
  30693. var xref = this.xref;
  30694. var dest = null, nameTreeRef, nameDictionaryRef;
  30695. var obj = this.catDict.get('Names');
  30696. if (obj && obj.has('Dests')) {
  30697. nameTreeRef = obj.getRaw('Dests');
  30698. } else if (this.catDict.has('Dests')) {
  30699. nameDictionaryRef = this.catDict.get('Dests');
  30700. }
  30701. if (nameDictionaryRef) {
  30702. var value = nameDictionaryRef.get(destinationId);
  30703. if (value) {
  30704. dest = fetchDestination(value);
  30705. }
  30706. }
  30707. if (nameTreeRef) {
  30708. var nameTree = new NameTree(nameTreeRef, xref);
  30709. dest = fetchDestination(nameTree.get(destinationId));
  30710. }
  30711. return dest;
  30712. },
  30713. get pageLabels() {
  30714. var obj = null;
  30715. try {
  30716. obj = this.readPageLabels();
  30717. } catch (ex) {
  30718. if (ex instanceof MissingDataException) {
  30719. throw ex;
  30720. }
  30721. warn('Unable to read page labels.');
  30722. }
  30723. return shadow(this, 'pageLabels', obj);
  30724. },
  30725. readPageLabels: function Catalog_readPageLabels() {
  30726. var obj = this.catDict.getRaw('PageLabels');
  30727. if (!obj) {
  30728. return null;
  30729. }
  30730. var pageLabels = new Array(this.numPages);
  30731. var style = null;
  30732. var prefix = '';
  30733. var numberTree = new NumberTree(obj, this.xref);
  30734. var nums = numberTree.getAll();
  30735. var currentLabel = '', currentIndex = 1;
  30736. for (var i = 0, ii = this.numPages; i < ii; i++) {
  30737. if (i in nums) {
  30738. var labelDict = nums[i];
  30739. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  30740. var type = labelDict.get('Type');
  30741. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  30742. var s = labelDict.get('S');
  30743. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  30744. style = s ? s.name : null;
  30745. var p = labelDict.get('P');
  30746. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  30747. prefix = p ? stringToPDFString(p) : '';
  30748. var st = labelDict.get('St');
  30749. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  30750. currentIndex = st || 1;
  30751. }
  30752. switch (style) {
  30753. case 'D':
  30754. currentLabel = currentIndex;
  30755. break;
  30756. case 'R':
  30757. case 'r':
  30758. currentLabel = Util.toRoman(currentIndex, style === 'r');
  30759. break;
  30760. case 'A':
  30761. case 'a':
  30762. var LIMIT = 26;
  30763. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  30764. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  30765. var letterIndex = currentIndex - 1;
  30766. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  30767. var charBuf = [];
  30768. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  30769. charBuf.push(character);
  30770. }
  30771. currentLabel = charBuf.join('');
  30772. break;
  30773. default:
  30774. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  30775. }
  30776. pageLabels[i] = prefix + currentLabel;
  30777. currentLabel = '';
  30778. currentIndex++;
  30779. }
  30780. return pageLabels;
  30781. },
  30782. get attachments() {
  30783. var xref = this.xref;
  30784. var attachments = null, nameTreeRef;
  30785. var obj = this.catDict.get('Names');
  30786. if (obj) {
  30787. nameTreeRef = obj.getRaw('EmbeddedFiles');
  30788. }
  30789. if (nameTreeRef) {
  30790. var nameTree = new NameTree(nameTreeRef, xref);
  30791. var names = nameTree.getAll();
  30792. for (var name in names) {
  30793. var fs = new FileSpec(names[name], xref);
  30794. if (!attachments) {
  30795. attachments = Object.create(null);
  30796. }
  30797. attachments[stringToPDFString(name)] = fs.serializable;
  30798. }
  30799. }
  30800. return shadow(this, 'attachments', attachments);
  30801. },
  30802. get javaScript() {
  30803. var xref = this.xref;
  30804. var obj = this.catDict.get('Names');
  30805. var javaScript = [];
  30806. function appendIfJavaScriptDict(jsDict) {
  30807. var type = jsDict.get('S');
  30808. if (!isName(type, 'JavaScript')) {
  30809. return;
  30810. }
  30811. var js = jsDict.get('JS');
  30812. if (isStream(js)) {
  30813. js = bytesToString(js.getBytes());
  30814. } else if (!isString(js)) {
  30815. return;
  30816. }
  30817. javaScript.push(stringToPDFString(js));
  30818. }
  30819. if (obj && obj.has('JavaScript')) {
  30820. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  30821. var names = nameTree.getAll();
  30822. for (var name in names) {
  30823. var jsDict = names[name];
  30824. if (isDict(jsDict)) {
  30825. appendIfJavaScriptDict(jsDict);
  30826. }
  30827. }
  30828. }
  30829. var openactionDict = this.catDict.get('OpenAction');
  30830. if (isDict(openactionDict, 'Action')) {
  30831. var actionType = openactionDict.get('S');
  30832. if (isName(actionType, 'Named')) {
  30833. var action = openactionDict.get('N');
  30834. if (isName(action, 'Print')) {
  30835. javaScript.push('print({});');
  30836. }
  30837. } else {
  30838. appendIfJavaScriptDict(openactionDict);
  30839. }
  30840. }
  30841. return shadow(this, 'javaScript', javaScript);
  30842. },
  30843. cleanup: function Catalog_cleanup() {
  30844. var promises = [];
  30845. this.fontCache.forEach(function (promise) {
  30846. promises.push(promise);
  30847. });
  30848. return Promise.all(promises).then(function (translatedFonts) {
  30849. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  30850. var font = translatedFonts[i].dict;
  30851. delete font.translated;
  30852. }
  30853. this.fontCache.clear();
  30854. this.builtInCMapCache = Object.create(null);
  30855. }.bind(this));
  30856. },
  30857. getPage: function Catalog_getPage(pageIndex) {
  30858. if (!(pageIndex in this.pagePromises)) {
  30859. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  30860. var dict = a[0];
  30861. var ref = a[1];
  30862. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache, this.builtInCMapCache);
  30863. }.bind(this));
  30864. }
  30865. return this.pagePromises[pageIndex];
  30866. },
  30867. getPageDict: function Catalog_getPageDict(pageIndex) {
  30868. var capability = createPromiseCapability();
  30869. var nodesToVisit = [this.catDict.getRaw('Pages')];
  30870. var currentPageIndex = 0;
  30871. var xref = this.xref;
  30872. function next() {
  30873. while (nodesToVisit.length) {
  30874. var currentNode = nodesToVisit.pop();
  30875. if (isRef(currentNode)) {
  30876. xref.fetchAsync(currentNode).then(function (obj) {
  30877. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  30878. if (pageIndex === currentPageIndex) {
  30879. capability.resolve([
  30880. obj,
  30881. currentNode
  30882. ]);
  30883. } else {
  30884. currentPageIndex++;
  30885. next();
  30886. }
  30887. return;
  30888. }
  30889. nodesToVisit.push(obj);
  30890. next();
  30891. }, capability.reject);
  30892. return;
  30893. }
  30894. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  30895. var count = currentNode.get('Count');
  30896. if (currentPageIndex + count <= pageIndex) {
  30897. currentPageIndex += count;
  30898. continue;
  30899. }
  30900. var kids = currentNode.get('Kids');
  30901. assert(isArray(kids), 'page dictionary kids object is not an array');
  30902. for (var last = kids.length - 1; last >= 0; last--) {
  30903. nodesToVisit.push(kids[last]);
  30904. }
  30905. }
  30906. capability.reject('Page index ' + pageIndex + ' not found.');
  30907. }
  30908. next();
  30909. return capability.promise;
  30910. },
  30911. getPageIndex: function Catalog_getPageIndex(pageRef) {
  30912. var xref = this.xref;
  30913. function pagesBeforeRef(kidRef) {
  30914. var total = 0;
  30915. var parentRef;
  30916. return xref.fetchAsync(kidRef).then(function (node) {
  30917. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  30918. throw new Error('The reference does not point to a /Page Dict.');
  30919. }
  30920. if (!node) {
  30921. return null;
  30922. }
  30923. assert(isDict(node), 'node must be a Dict.');
  30924. parentRef = node.getRaw('Parent');
  30925. return node.getAsync('Parent');
  30926. }).then(function (parent) {
  30927. if (!parent) {
  30928. return null;
  30929. }
  30930. assert(isDict(parent), 'parent must be a Dict.');
  30931. return parent.getAsync('Kids');
  30932. }).then(function (kids) {
  30933. if (!kids) {
  30934. return null;
  30935. }
  30936. var kidPromises = [];
  30937. var found = false;
  30938. for (var i = 0; i < kids.length; i++) {
  30939. var kid = kids[i];
  30940. assert(isRef(kid), 'kid must be a Ref.');
  30941. if (kid.num === kidRef.num) {
  30942. found = true;
  30943. break;
  30944. }
  30945. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  30946. if (kid.has('Count')) {
  30947. var count = kid.get('Count');
  30948. total += count;
  30949. } else {
  30950. total++;
  30951. }
  30952. }));
  30953. }
  30954. if (!found) {
  30955. error('kid ref not found in parents kids');
  30956. }
  30957. return Promise.all(kidPromises).then(function () {
  30958. return [
  30959. total,
  30960. parentRef
  30961. ];
  30962. });
  30963. });
  30964. }
  30965. var total = 0;
  30966. function next(ref) {
  30967. return pagesBeforeRef(ref).then(function (args) {
  30968. if (!args) {
  30969. return total;
  30970. }
  30971. var count = args[0];
  30972. var parentRef = args[1];
  30973. total += count;
  30974. return next(parentRef);
  30975. });
  30976. }
  30977. return next(pageRef);
  30978. }
  30979. };
  30980. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  30981. function addDefaultProtocolToUrl(url) {
  30982. if (url.indexOf('www.') === 0) {
  30983. return 'http://' + url;
  30984. }
  30985. return url;
  30986. }
  30987. function tryConvertUrlEncoding(url) {
  30988. try {
  30989. return stringToUTF8String(url);
  30990. } catch (e) {
  30991. return url;
  30992. }
  30993. }
  30994. var destDict = params.destDict;
  30995. if (!isDict(destDict)) {
  30996. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  30997. return;
  30998. }
  30999. var resultObj = params.resultObj;
  31000. if (typeof resultObj !== 'object') {
  31001. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  31002. return;
  31003. }
  31004. var docBaseUrl = params.docBaseUrl || null;
  31005. var action = destDict.get('A'), url, dest;
  31006. if (isDict(action)) {
  31007. var linkType = action.get('S').name;
  31008. switch (linkType) {
  31009. case 'URI':
  31010. url = action.get('URI');
  31011. if (isName(url)) {
  31012. url = '/' + url.name;
  31013. } else if (isString(url)) {
  31014. url = addDefaultProtocolToUrl(url);
  31015. }
  31016. break;
  31017. case 'GoTo':
  31018. dest = action.get('D');
  31019. break;
  31020. case 'Launch':
  31021. case 'GoToR':
  31022. var urlDict = action.get('F');
  31023. if (isDict(urlDict)) {
  31024. url = urlDict.get('F') || null;
  31025. } else if (isString(urlDict)) {
  31026. url = urlDict;
  31027. }
  31028. var remoteDest = action.get('D');
  31029. if (remoteDest) {
  31030. if (isName(remoteDest)) {
  31031. remoteDest = remoteDest.name;
  31032. }
  31033. if (isString(url)) {
  31034. var baseUrl = url.split('#')[0];
  31035. if (isString(remoteDest)) {
  31036. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  31037. } else if (isArray(remoteDest)) {
  31038. url = baseUrl + '#' + JSON.stringify(remoteDest);
  31039. }
  31040. }
  31041. }
  31042. var newWindow = action.get('NewWindow');
  31043. if (isBool(newWindow)) {
  31044. resultObj.newWindow = newWindow;
  31045. }
  31046. break;
  31047. case 'Named':
  31048. var namedAction = action.get('N');
  31049. if (isName(namedAction)) {
  31050. resultObj.action = namedAction.name;
  31051. }
  31052. break;
  31053. case 'JavaScript':
  31054. var jsAction = action.get('JS'), js;
  31055. if (isStream(jsAction)) {
  31056. js = bytesToString(jsAction.getBytes());
  31057. } else if (isString(jsAction)) {
  31058. js = jsAction;
  31059. }
  31060. if (js) {
  31061. var URL_OPEN_METHODS = [
  31062. 'app.launchURL',
  31063. 'window.open'
  31064. ];
  31065. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  31066. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  31067. if (jsUrl && jsUrl[1]) {
  31068. url = jsUrl[1];
  31069. break;
  31070. }
  31071. }
  31072. default:
  31073. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  31074. break;
  31075. }
  31076. } else if (destDict.has('Dest')) {
  31077. dest = destDict.get('Dest');
  31078. }
  31079. if (isString(url)) {
  31080. url = tryConvertUrlEncoding(url);
  31081. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  31082. if (absoluteUrl) {
  31083. resultObj.url = absoluteUrl.href;
  31084. }
  31085. resultObj.unsafeUrl = url;
  31086. }
  31087. if (dest) {
  31088. if (isName(dest)) {
  31089. dest = dest.name;
  31090. }
  31091. if (isString(dest) || isArray(dest)) {
  31092. resultObj.dest = dest;
  31093. }
  31094. }
  31095. };
  31096. return Catalog;
  31097. }();
  31098. var XRef = function XRefClosure() {
  31099. function XRef(stream, pdfManager) {
  31100. this.stream = stream;
  31101. this.pdfManager = pdfManager;
  31102. this.entries = [];
  31103. this.xrefstms = Object.create(null);
  31104. this.cache = [];
  31105. this.stats = {
  31106. streamTypes: [],
  31107. fontTypes: []
  31108. };
  31109. }
  31110. XRef.prototype = {
  31111. setStartXRef: function XRef_setStartXRef(startXRef) {
  31112. this.startXRefQueue = [startXRef];
  31113. },
  31114. parse: function XRef_parse(recoveryMode) {
  31115. var trailerDict;
  31116. if (!recoveryMode) {
  31117. trailerDict = this.readXRef();
  31118. } else {
  31119. warn('Indexing all PDF objects');
  31120. trailerDict = this.indexObjects();
  31121. }
  31122. trailerDict.assignXref(this);
  31123. this.trailer = trailerDict;
  31124. var encrypt = trailerDict.get('Encrypt');
  31125. if (isDict(encrypt)) {
  31126. var ids = trailerDict.get('ID');
  31127. var fileId = ids && ids.length ? ids[0] : '';
  31128. encrypt.suppressEncryption = true;
  31129. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  31130. }
  31131. if (!(this.root = trailerDict.get('Root'))) {
  31132. error('Invalid root reference');
  31133. }
  31134. },
  31135. processXRefTable: function XRef_processXRefTable(parser) {
  31136. if (!('tableState' in this)) {
  31137. this.tableState = {
  31138. entryNum: 0,
  31139. streamPos: parser.lexer.stream.pos,
  31140. parserBuf1: parser.buf1,
  31141. parserBuf2: parser.buf2
  31142. };
  31143. }
  31144. var obj = this.readXRefTable(parser);
  31145. if (!isCmd(obj, 'trailer')) {
  31146. error('Invalid XRef table: could not find trailer dictionary');
  31147. }
  31148. var dict = parser.getObj();
  31149. if (!isDict(dict) && dict.dict) {
  31150. dict = dict.dict;
  31151. }
  31152. if (!isDict(dict)) {
  31153. error('Invalid XRef table: could not parse trailer dictionary');
  31154. }
  31155. delete this.tableState;
  31156. return dict;
  31157. },
  31158. readXRefTable: function XRef_readXRefTable(parser) {
  31159. var stream = parser.lexer.stream;
  31160. var tableState = this.tableState;
  31161. stream.pos = tableState.streamPos;
  31162. parser.buf1 = tableState.parserBuf1;
  31163. parser.buf2 = tableState.parserBuf2;
  31164. var obj;
  31165. while (true) {
  31166. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  31167. if (isCmd(obj = parser.getObj(), 'trailer')) {
  31168. break;
  31169. }
  31170. tableState.firstEntryNum = obj;
  31171. tableState.entryCount = parser.getObj();
  31172. }
  31173. var first = tableState.firstEntryNum;
  31174. var count = tableState.entryCount;
  31175. if (!isInt(first) || !isInt(count)) {
  31176. error('Invalid XRef table: wrong types in subsection header');
  31177. }
  31178. for (var i = tableState.entryNum; i < count; i++) {
  31179. tableState.streamPos = stream.pos;
  31180. tableState.entryNum = i;
  31181. tableState.parserBuf1 = parser.buf1;
  31182. tableState.parserBuf2 = parser.buf2;
  31183. var entry = {};
  31184. entry.offset = parser.getObj();
  31185. entry.gen = parser.getObj();
  31186. var type = parser.getObj();
  31187. if (isCmd(type, 'f')) {
  31188. entry.free = true;
  31189. } else if (isCmd(type, 'n')) {
  31190. entry.uncompressed = true;
  31191. }
  31192. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  31193. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  31194. }
  31195. if (i === 0 && entry.free && first === 1) {
  31196. first = 0;
  31197. }
  31198. if (!this.entries[i + first]) {
  31199. this.entries[i + first] = entry;
  31200. }
  31201. }
  31202. tableState.entryNum = 0;
  31203. tableState.streamPos = stream.pos;
  31204. tableState.parserBuf1 = parser.buf1;
  31205. tableState.parserBuf2 = parser.buf2;
  31206. delete tableState.firstEntryNum;
  31207. delete tableState.entryCount;
  31208. }
  31209. if (this.entries[0] && !this.entries[0].free) {
  31210. error('Invalid XRef table: unexpected first object');
  31211. }
  31212. return obj;
  31213. },
  31214. processXRefStream: function XRef_processXRefStream(stream) {
  31215. if (!('streamState' in this)) {
  31216. var streamParameters = stream.dict;
  31217. var byteWidths = streamParameters.get('W');
  31218. var range = streamParameters.get('Index');
  31219. if (!range) {
  31220. range = [
  31221. 0,
  31222. streamParameters.get('Size')
  31223. ];
  31224. }
  31225. this.streamState = {
  31226. entryRanges: range,
  31227. byteWidths: byteWidths,
  31228. entryNum: 0,
  31229. streamPos: stream.pos
  31230. };
  31231. }
  31232. this.readXRefStream(stream);
  31233. delete this.streamState;
  31234. return stream.dict;
  31235. },
  31236. readXRefStream: function XRef_readXRefStream(stream) {
  31237. var i, j;
  31238. var streamState = this.streamState;
  31239. stream.pos = streamState.streamPos;
  31240. var byteWidths = streamState.byteWidths;
  31241. var typeFieldWidth = byteWidths[0];
  31242. var offsetFieldWidth = byteWidths[1];
  31243. var generationFieldWidth = byteWidths[2];
  31244. var entryRanges = streamState.entryRanges;
  31245. while (entryRanges.length > 0) {
  31246. var first = entryRanges[0];
  31247. var n = entryRanges[1];
  31248. if (!isInt(first) || !isInt(n)) {
  31249. error('Invalid XRef range fields: ' + first + ', ' + n);
  31250. }
  31251. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  31252. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  31253. }
  31254. for (i = streamState.entryNum; i < n; ++i) {
  31255. streamState.entryNum = i;
  31256. streamState.streamPos = stream.pos;
  31257. var type = 0, offset = 0, generation = 0;
  31258. for (j = 0; j < typeFieldWidth; ++j) {
  31259. type = type << 8 | stream.getByte();
  31260. }
  31261. if (typeFieldWidth === 0) {
  31262. type = 1;
  31263. }
  31264. for (j = 0; j < offsetFieldWidth; ++j) {
  31265. offset = offset << 8 | stream.getByte();
  31266. }
  31267. for (j = 0; j < generationFieldWidth; ++j) {
  31268. generation = generation << 8 | stream.getByte();
  31269. }
  31270. var entry = {};
  31271. entry.offset = offset;
  31272. entry.gen = generation;
  31273. switch (type) {
  31274. case 0:
  31275. entry.free = true;
  31276. break;
  31277. case 1:
  31278. entry.uncompressed = true;
  31279. break;
  31280. case 2:
  31281. break;
  31282. default:
  31283. error('Invalid XRef entry type: ' + type);
  31284. }
  31285. if (!this.entries[first + i]) {
  31286. this.entries[first + i] = entry;
  31287. }
  31288. }
  31289. streamState.entryNum = 0;
  31290. streamState.streamPos = stream.pos;
  31291. entryRanges.splice(0, 2);
  31292. }
  31293. },
  31294. indexObjects: function XRef_indexObjects() {
  31295. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  31296. var PERCENT = 0x25, LT = 0x3C;
  31297. function readToken(data, offset) {
  31298. var token = '', ch = data[offset];
  31299. while (ch !== LF && ch !== CR && ch !== LT) {
  31300. if (++offset >= data.length) {
  31301. break;
  31302. }
  31303. token += String.fromCharCode(ch);
  31304. ch = data[offset];
  31305. }
  31306. return token;
  31307. }
  31308. function skipUntil(data, offset, what) {
  31309. var length = what.length, dataLength = data.length;
  31310. var skipped = 0;
  31311. while (offset < dataLength) {
  31312. var i = 0;
  31313. while (i < length && data[offset + i] === what[i]) {
  31314. ++i;
  31315. }
  31316. if (i >= length) {
  31317. break;
  31318. }
  31319. offset++;
  31320. skipped++;
  31321. }
  31322. return skipped;
  31323. }
  31324. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  31325. var trailerBytes = new Uint8Array([
  31326. 116,
  31327. 114,
  31328. 97,
  31329. 105,
  31330. 108,
  31331. 101,
  31332. 114
  31333. ]);
  31334. var startxrefBytes = new Uint8Array([
  31335. 115,
  31336. 116,
  31337. 97,
  31338. 114,
  31339. 116,
  31340. 120,
  31341. 114,
  31342. 101,
  31343. 102
  31344. ]);
  31345. var endobjBytes = new Uint8Array([
  31346. 101,
  31347. 110,
  31348. 100,
  31349. 111,
  31350. 98,
  31351. 106
  31352. ]);
  31353. var xrefBytes = new Uint8Array([
  31354. 47,
  31355. 88,
  31356. 82,
  31357. 101,
  31358. 102
  31359. ]);
  31360. this.entries.length = 0;
  31361. var stream = this.stream;
  31362. stream.pos = 0;
  31363. var buffer = stream.getBytes();
  31364. var position = stream.start, length = buffer.length;
  31365. var trailers = [], xrefStms = [];
  31366. while (position < length) {
  31367. var ch = buffer[position];
  31368. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  31369. ++position;
  31370. continue;
  31371. }
  31372. if (ch === PERCENT) {
  31373. do {
  31374. ++position;
  31375. if (position >= length) {
  31376. break;
  31377. }
  31378. ch = buffer[position];
  31379. } while (ch !== LF && ch !== CR);
  31380. continue;
  31381. }
  31382. var token = readToken(buffer, position);
  31383. var m;
  31384. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  31385. position += skipUntil(buffer, position, trailerBytes);
  31386. trailers.push(position);
  31387. position += skipUntil(buffer, position, startxrefBytes);
  31388. } else if (m = objRegExp.exec(token)) {
  31389. if (typeof this.entries[m[1]] === 'undefined') {
  31390. this.entries[m[1]] = {
  31391. offset: position - stream.start,
  31392. gen: m[2] | 0,
  31393. uncompressed: true
  31394. };
  31395. }
  31396. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  31397. var content = buffer.subarray(position, position + contentLength);
  31398. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  31399. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  31400. xrefStms.push(position - stream.start);
  31401. this.xrefstms[position - stream.start] = 1;
  31402. }
  31403. position += contentLength;
  31404. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  31405. trailers.push(position);
  31406. position += skipUntil(buffer, position, startxrefBytes);
  31407. } else {
  31408. position += token.length + 1;
  31409. }
  31410. }
  31411. var i, ii;
  31412. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  31413. this.startXRefQueue.push(xrefStms[i]);
  31414. this.readXRef(true);
  31415. }
  31416. var dict;
  31417. for (i = 0, ii = trailers.length; i < ii; ++i) {
  31418. stream.pos = trailers[i];
  31419. var parser = new Parser(new Lexer(stream), true, this, true);
  31420. var obj = parser.getObj();
  31421. if (!isCmd(obj, 'trailer')) {
  31422. continue;
  31423. }
  31424. dict = parser.getObj();
  31425. if (!isDict(dict)) {
  31426. continue;
  31427. }
  31428. if (dict.has('ID')) {
  31429. return dict;
  31430. }
  31431. }
  31432. if (dict) {
  31433. return dict;
  31434. }
  31435. throw new InvalidPDFException('Invalid PDF structure');
  31436. },
  31437. readXRef: function XRef_readXRef(recoveryMode) {
  31438. var stream = this.stream;
  31439. try {
  31440. while (this.startXRefQueue.length) {
  31441. var startXRef = this.startXRefQueue[0];
  31442. stream.pos = startXRef + stream.start;
  31443. var parser = new Parser(new Lexer(stream), true, this);
  31444. var obj = parser.getObj();
  31445. var dict;
  31446. if (isCmd(obj, 'xref')) {
  31447. dict = this.processXRefTable(parser);
  31448. if (!this.topDict) {
  31449. this.topDict = dict;
  31450. }
  31451. obj = dict.get('XRefStm');
  31452. if (isInt(obj)) {
  31453. var pos = obj;
  31454. if (!(pos in this.xrefstms)) {
  31455. this.xrefstms[pos] = 1;
  31456. this.startXRefQueue.push(pos);
  31457. }
  31458. }
  31459. } else if (isInt(obj)) {
  31460. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  31461. error('Invalid XRef stream');
  31462. }
  31463. dict = this.processXRefStream(obj);
  31464. if (!this.topDict) {
  31465. this.topDict = dict;
  31466. }
  31467. if (!dict) {
  31468. error('Failed to read XRef stream');
  31469. }
  31470. } else {
  31471. error('Invalid XRef stream header');
  31472. }
  31473. obj = dict.get('Prev');
  31474. if (isInt(obj)) {
  31475. this.startXRefQueue.push(obj);
  31476. } else if (isRef(obj)) {
  31477. this.startXRefQueue.push(obj.num);
  31478. }
  31479. this.startXRefQueue.shift();
  31480. }
  31481. return this.topDict;
  31482. } catch (e) {
  31483. if (e instanceof MissingDataException) {
  31484. throw e;
  31485. }
  31486. info('(while reading XRef): ' + e);
  31487. }
  31488. if (recoveryMode) {
  31489. return;
  31490. }
  31491. throw new XRefParseException();
  31492. },
  31493. getEntry: function XRef_getEntry(i) {
  31494. var xrefEntry = this.entries[i];
  31495. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  31496. return xrefEntry;
  31497. }
  31498. return null;
  31499. },
  31500. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  31501. if (!isRef(obj)) {
  31502. return obj;
  31503. }
  31504. return this.fetch(obj, suppressEncryption);
  31505. },
  31506. fetch: function XRef_fetch(ref, suppressEncryption) {
  31507. assert(isRef(ref), 'ref object is not a reference');
  31508. var num = ref.num;
  31509. if (num in this.cache) {
  31510. var cacheEntry = this.cache[num];
  31511. if (isDict(cacheEntry) && !cacheEntry.objId) {
  31512. cacheEntry.objId = ref.toString();
  31513. }
  31514. return cacheEntry;
  31515. }
  31516. var xrefEntry = this.getEntry(num);
  31517. if (xrefEntry === null) {
  31518. return this.cache[num] = null;
  31519. }
  31520. if (xrefEntry.uncompressed) {
  31521. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  31522. } else {
  31523. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  31524. }
  31525. if (isDict(xrefEntry)) {
  31526. xrefEntry.objId = ref.toString();
  31527. } else if (isStream(xrefEntry)) {
  31528. xrefEntry.dict.objId = ref.toString();
  31529. }
  31530. return xrefEntry;
  31531. },
  31532. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  31533. var gen = ref.gen;
  31534. var num = ref.num;
  31535. if (xrefEntry.gen !== gen) {
  31536. error('inconsistent generation in XRef');
  31537. }
  31538. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  31539. var parser = new Parser(new Lexer(stream), true, this);
  31540. var obj1 = parser.getObj();
  31541. var obj2 = parser.getObj();
  31542. var obj3 = parser.getObj();
  31543. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  31544. error('bad XRef entry');
  31545. }
  31546. if (!isCmd(obj3, 'obj')) {
  31547. if (obj3.cmd.indexOf('obj') === 0) {
  31548. num = parseInt(obj3.cmd.substring(3), 10);
  31549. if (!isNaN(num)) {
  31550. return num;
  31551. }
  31552. }
  31553. error('bad XRef entry');
  31554. }
  31555. if (this.encrypt && !suppressEncryption) {
  31556. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  31557. } else {
  31558. xrefEntry = parser.getObj();
  31559. }
  31560. if (!isStream(xrefEntry)) {
  31561. this.cache[num] = xrefEntry;
  31562. }
  31563. return xrefEntry;
  31564. },
  31565. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  31566. var tableOffset = xrefEntry.offset;
  31567. var stream = this.fetch(new Ref(tableOffset, 0));
  31568. if (!isStream(stream)) {
  31569. error('bad ObjStm stream');
  31570. }
  31571. var first = stream.dict.get('First');
  31572. var n = stream.dict.get('N');
  31573. if (!isInt(first) || !isInt(n)) {
  31574. error('invalid first and n parameters for ObjStm stream');
  31575. }
  31576. var parser = new Parser(new Lexer(stream), false, this);
  31577. parser.allowStreams = true;
  31578. var i, entries = [], num, nums = [];
  31579. for (i = 0; i < n; ++i) {
  31580. num = parser.getObj();
  31581. if (!isInt(num)) {
  31582. error('invalid object number in the ObjStm stream: ' + num);
  31583. }
  31584. nums.push(num);
  31585. var offset = parser.getObj();
  31586. if (!isInt(offset)) {
  31587. error('invalid object offset in the ObjStm stream: ' + offset);
  31588. }
  31589. }
  31590. for (i = 0; i < n; ++i) {
  31591. entries.push(parser.getObj());
  31592. if (isCmd(parser.buf1, 'endobj')) {
  31593. parser.shift();
  31594. }
  31595. num = nums[i];
  31596. var entry = this.entries[num];
  31597. if (entry && entry.offset === tableOffset && entry.gen === i) {
  31598. this.cache[num] = entries[i];
  31599. }
  31600. }
  31601. xrefEntry = entries[xrefEntry.gen];
  31602. if (xrefEntry === undefined) {
  31603. error('bad XRef entry for compressed object');
  31604. }
  31605. return xrefEntry;
  31606. },
  31607. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  31608. if (!isRef(obj)) {
  31609. return Promise.resolve(obj);
  31610. }
  31611. return this.fetchAsync(obj, suppressEncryption);
  31612. },
  31613. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  31614. var streamManager = this.stream.manager;
  31615. var xref = this;
  31616. return new Promise(function tryFetch(resolve, reject) {
  31617. try {
  31618. resolve(xref.fetch(ref, suppressEncryption));
  31619. } catch (e) {
  31620. if (e instanceof MissingDataException) {
  31621. streamManager.requestRange(e.begin, e.end).then(function () {
  31622. tryFetch(resolve, reject);
  31623. }, reject);
  31624. return;
  31625. }
  31626. reject(e);
  31627. }
  31628. });
  31629. },
  31630. getCatalogObj: function XRef_getCatalogObj() {
  31631. return this.root;
  31632. }
  31633. };
  31634. return XRef;
  31635. }();
  31636. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  31637. function NameOrNumberTree(root, xref) {
  31638. throw new Error('Cannot initialize NameOrNumberTree.');
  31639. }
  31640. NameOrNumberTree.prototype = {
  31641. getAll: function NameOrNumberTree_getAll() {
  31642. var dict = Object.create(null);
  31643. if (!this.root) {
  31644. return dict;
  31645. }
  31646. var xref = this.xref;
  31647. var processed = new RefSet();
  31648. processed.put(this.root);
  31649. var queue = [this.root];
  31650. while (queue.length > 0) {
  31651. var i, n;
  31652. var obj = xref.fetchIfRef(queue.shift());
  31653. if (!isDict(obj)) {
  31654. continue;
  31655. }
  31656. if (obj.has('Kids')) {
  31657. var kids = obj.get('Kids');
  31658. for (i = 0, n = kids.length; i < n; i++) {
  31659. var kid = kids[i];
  31660. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  31661. queue.push(kid);
  31662. processed.put(kid);
  31663. }
  31664. continue;
  31665. }
  31666. var entries = obj.get(this._type);
  31667. if (isArray(entries)) {
  31668. for (i = 0, n = entries.length; i < n; i += 2) {
  31669. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  31670. }
  31671. }
  31672. }
  31673. return dict;
  31674. },
  31675. get: function NameOrNumberTree_get(key) {
  31676. if (!this.root) {
  31677. return null;
  31678. }
  31679. var xref = this.xref;
  31680. var kidsOrEntries = xref.fetchIfRef(this.root);
  31681. var loopCount = 0;
  31682. var MAX_LEVELS = 10;
  31683. var l, r, m;
  31684. while (kidsOrEntries.has('Kids')) {
  31685. if (++loopCount > MAX_LEVELS) {
  31686. warn('Search depth limit reached for "' + this._type + '" tree.');
  31687. return null;
  31688. }
  31689. var kids = kidsOrEntries.get('Kids');
  31690. if (!isArray(kids)) {
  31691. return null;
  31692. }
  31693. l = 0;
  31694. r = kids.length - 1;
  31695. while (l <= r) {
  31696. m = l + r >> 1;
  31697. var kid = xref.fetchIfRef(kids[m]);
  31698. var limits = kid.get('Limits');
  31699. if (key < xref.fetchIfRef(limits[0])) {
  31700. r = m - 1;
  31701. } else if (key > xref.fetchIfRef(limits[1])) {
  31702. l = m + 1;
  31703. } else {
  31704. kidsOrEntries = xref.fetchIfRef(kids[m]);
  31705. break;
  31706. }
  31707. }
  31708. if (l > r) {
  31709. return null;
  31710. }
  31711. }
  31712. var entries = kidsOrEntries.get(this._type);
  31713. if (isArray(entries)) {
  31714. l = 0;
  31715. r = entries.length - 2;
  31716. while (l <= r) {
  31717. m = l + r & ~1;
  31718. var currentKey = xref.fetchIfRef(entries[m]);
  31719. if (key < currentKey) {
  31720. r = m - 2;
  31721. } else if (key > currentKey) {
  31722. l = m + 2;
  31723. } else {
  31724. return xref.fetchIfRef(entries[m + 1]);
  31725. }
  31726. }
  31727. }
  31728. return null;
  31729. }
  31730. };
  31731. return NameOrNumberTree;
  31732. }();
  31733. var NameTree = function NameTreeClosure() {
  31734. function NameTree(root, xref) {
  31735. this.root = root;
  31736. this.xref = xref;
  31737. this._type = 'Names';
  31738. }
  31739. Util.inherit(NameTree, NameOrNumberTree, {});
  31740. return NameTree;
  31741. }();
  31742. var NumberTree = function NumberTreeClosure() {
  31743. function NumberTree(root, xref) {
  31744. this.root = root;
  31745. this.xref = xref;
  31746. this._type = 'Nums';
  31747. }
  31748. Util.inherit(NumberTree, NameOrNumberTree, {});
  31749. return NumberTree;
  31750. }();
  31751. var FileSpec = function FileSpecClosure() {
  31752. function FileSpec(root, xref) {
  31753. if (!root || !isDict(root)) {
  31754. return;
  31755. }
  31756. this.xref = xref;
  31757. this.root = root;
  31758. if (root.has('FS')) {
  31759. this.fs = root.get('FS');
  31760. }
  31761. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  31762. if (root.has('RF')) {
  31763. warn('Related file specifications are not supported');
  31764. }
  31765. this.contentAvailable = true;
  31766. if (!root.has('EF')) {
  31767. this.contentAvailable = false;
  31768. warn('Non-embedded file specifications are not supported');
  31769. }
  31770. }
  31771. function pickPlatformItem(dict) {
  31772. if (dict.has('UF')) {
  31773. return dict.get('UF');
  31774. } else if (dict.has('F')) {
  31775. return dict.get('F');
  31776. } else if (dict.has('Unix')) {
  31777. return dict.get('Unix');
  31778. } else if (dict.has('Mac')) {
  31779. return dict.get('Mac');
  31780. } else if (dict.has('DOS')) {
  31781. return dict.get('DOS');
  31782. }
  31783. return null;
  31784. }
  31785. FileSpec.prototype = {
  31786. get filename() {
  31787. if (!this._filename && this.root) {
  31788. var filename = pickPlatformItem(this.root) || 'unnamed';
  31789. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  31790. }
  31791. return this._filename;
  31792. },
  31793. get content() {
  31794. if (!this.contentAvailable) {
  31795. return null;
  31796. }
  31797. if (!this.contentRef && this.root) {
  31798. this.contentRef = pickPlatformItem(this.root.get('EF'));
  31799. }
  31800. var content = null;
  31801. if (this.contentRef) {
  31802. var xref = this.xref;
  31803. var fileObj = xref.fetchIfRef(this.contentRef);
  31804. if (fileObj && isStream(fileObj)) {
  31805. content = fileObj.getBytes();
  31806. } else {
  31807. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  31808. }
  31809. } else {
  31810. warn('Embedded file specification does not have a content');
  31811. }
  31812. return content;
  31813. },
  31814. get serializable() {
  31815. return {
  31816. filename: this.filename,
  31817. content: this.content
  31818. };
  31819. }
  31820. };
  31821. return FileSpec;
  31822. }();
  31823. var ObjectLoader = function () {
  31824. function mayHaveChildren(value) {
  31825. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  31826. }
  31827. function addChildren(node, nodesToVisit) {
  31828. var value;
  31829. if (isDict(node) || isStream(node)) {
  31830. var map;
  31831. if (isDict(node)) {
  31832. map = node.map;
  31833. } else {
  31834. map = node.dict.map;
  31835. }
  31836. for (var key in map) {
  31837. value = map[key];
  31838. if (mayHaveChildren(value)) {
  31839. nodesToVisit.push(value);
  31840. }
  31841. }
  31842. } else if (isArray(node)) {
  31843. for (var i = 0, ii = node.length; i < ii; i++) {
  31844. value = node[i];
  31845. if (mayHaveChildren(value)) {
  31846. nodesToVisit.push(value);
  31847. }
  31848. }
  31849. }
  31850. }
  31851. function ObjectLoader(obj, keys, xref) {
  31852. this.obj = obj;
  31853. this.keys = keys;
  31854. this.xref = xref;
  31855. this.refSet = null;
  31856. this.capability = null;
  31857. }
  31858. ObjectLoader.prototype = {
  31859. load: function ObjectLoader_load() {
  31860. var keys = this.keys;
  31861. this.capability = createPromiseCapability();
  31862. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  31863. this.capability.resolve();
  31864. return this.capability.promise;
  31865. }
  31866. this.refSet = new RefSet();
  31867. var nodesToVisit = [];
  31868. for (var i = 0; i < keys.length; i++) {
  31869. nodesToVisit.push(this.obj[keys[i]]);
  31870. }
  31871. this._walk(nodesToVisit);
  31872. return this.capability.promise;
  31873. },
  31874. _walk: function ObjectLoader_walk(nodesToVisit) {
  31875. var nodesToRevisit = [];
  31876. var pendingRequests = [];
  31877. while (nodesToVisit.length) {
  31878. var currentNode = nodesToVisit.pop();
  31879. if (isRef(currentNode)) {
  31880. if (this.refSet.has(currentNode)) {
  31881. continue;
  31882. }
  31883. try {
  31884. var ref = currentNode;
  31885. this.refSet.put(ref);
  31886. currentNode = this.xref.fetch(currentNode);
  31887. } catch (e) {
  31888. if (!(e instanceof MissingDataException)) {
  31889. throw e;
  31890. }
  31891. nodesToRevisit.push(currentNode);
  31892. pendingRequests.push({
  31893. begin: e.begin,
  31894. end: e.end
  31895. });
  31896. }
  31897. }
  31898. if (currentNode && currentNode.getBaseStreams) {
  31899. var baseStreams = currentNode.getBaseStreams();
  31900. var foundMissingData = false;
  31901. for (var i = 0; i < baseStreams.length; i++) {
  31902. var stream = baseStreams[i];
  31903. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  31904. foundMissingData = true;
  31905. pendingRequests.push({
  31906. begin: stream.start,
  31907. end: stream.end
  31908. });
  31909. }
  31910. }
  31911. if (foundMissingData) {
  31912. nodesToRevisit.push(currentNode);
  31913. }
  31914. }
  31915. addChildren(currentNode, nodesToVisit);
  31916. }
  31917. if (pendingRequests.length) {
  31918. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  31919. nodesToVisit = nodesToRevisit;
  31920. for (var i = 0; i < nodesToRevisit.length; i++) {
  31921. var node = nodesToRevisit[i];
  31922. if (isRef(node)) {
  31923. this.refSet.remove(node);
  31924. }
  31925. }
  31926. this._walk(nodesToVisit);
  31927. }.bind(this), this.capability.reject);
  31928. return;
  31929. }
  31930. this.refSet = null;
  31931. this.capability.resolve();
  31932. }
  31933. };
  31934. return ObjectLoader;
  31935. }();
  31936. exports.Catalog = Catalog;
  31937. exports.ObjectLoader = ObjectLoader;
  31938. exports.XRef = XRef;
  31939. exports.FileSpec = FileSpec;
  31940. /***/ }),
  31941. /* 17 */
  31942. /***/ (function(module, exports, __w_pdfjs_require__) {
  31943. "use strict";
  31944. var sharedUtil = __w_pdfjs_require__(0);
  31945. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  31946. var getStdFontMap = getLookupTableFactory(function (t) {
  31947. t['ArialNarrow'] = 'Helvetica';
  31948. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  31949. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  31950. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  31951. t['ArialBlack'] = 'Helvetica';
  31952. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  31953. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  31954. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  31955. t['Arial-Black'] = 'Helvetica';
  31956. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  31957. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  31958. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  31959. t['Arial'] = 'Helvetica';
  31960. t['Arial-Bold'] = 'Helvetica-Bold';
  31961. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  31962. t['Arial-Italic'] = 'Helvetica-Oblique';
  31963. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  31964. t['Arial-BoldMT'] = 'Helvetica-Bold';
  31965. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  31966. t['ArialMT'] = 'Helvetica';
  31967. t['Courier-Bold'] = 'Courier-Bold';
  31968. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  31969. t['Courier-Italic'] = 'Courier-Oblique';
  31970. t['CourierNew'] = 'Courier';
  31971. t['CourierNew-Bold'] = 'Courier-Bold';
  31972. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  31973. t['CourierNew-Italic'] = 'Courier-Oblique';
  31974. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  31975. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  31976. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  31977. t['CourierNewPSMT'] = 'Courier';
  31978. t['Helvetica'] = 'Helvetica';
  31979. t['Helvetica-Bold'] = 'Helvetica-Bold';
  31980. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  31981. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  31982. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  31983. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  31984. t['Symbol-Bold'] = 'Symbol';
  31985. t['Symbol-BoldItalic'] = 'Symbol';
  31986. t['Symbol-Italic'] = 'Symbol';
  31987. t['TimesNewRoman'] = 'Times-Roman';
  31988. t['TimesNewRoman-Bold'] = 'Times-Bold';
  31989. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  31990. t['TimesNewRoman-Italic'] = 'Times-Italic';
  31991. t['TimesNewRomanPS'] = 'Times-Roman';
  31992. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  31993. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  31994. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  31995. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  31996. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  31997. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  31998. t['TimesNewRomanPSMT'] = 'Times-Roman';
  31999. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  32000. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  32001. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  32002. });
  32003. var getNonStdFontMap = getLookupTableFactory(function (t) {
  32004. t['CenturyGothic'] = 'Helvetica';
  32005. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  32006. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  32007. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  32008. t['ComicSansMS'] = 'Comic Sans MS';
  32009. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  32010. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  32011. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  32012. t['LucidaConsole'] = 'Courier';
  32013. t['LucidaConsole-Bold'] = 'Courier-Bold';
  32014. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  32015. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  32016. t['MS-Gothic'] = 'MS Gothic';
  32017. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  32018. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  32019. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  32020. t['MS-Mincho'] = 'MS Mincho';
  32021. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  32022. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  32023. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  32024. t['MS-PGothic'] = 'MS PGothic';
  32025. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  32026. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  32027. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  32028. t['MS-PMincho'] = 'MS PMincho';
  32029. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  32030. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  32031. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  32032. t['NuptialScript'] = 'Times-Italic';
  32033. t['Wingdings'] = 'ZapfDingbats';
  32034. });
  32035. var getSerifFonts = getLookupTableFactory(function (t) {
  32036. t['Adobe Jenson'] = true;
  32037. t['Adobe Text'] = true;
  32038. t['Albertus'] = true;
  32039. t['Aldus'] = true;
  32040. t['Alexandria'] = true;
  32041. t['Algerian'] = true;
  32042. t['American Typewriter'] = true;
  32043. t['Antiqua'] = true;
  32044. t['Apex'] = true;
  32045. t['Arno'] = true;
  32046. t['Aster'] = true;
  32047. t['Aurora'] = true;
  32048. t['Baskerville'] = true;
  32049. t['Bell'] = true;
  32050. t['Bembo'] = true;
  32051. t['Bembo Schoolbook'] = true;
  32052. t['Benguiat'] = true;
  32053. t['Berkeley Old Style'] = true;
  32054. t['Bernhard Modern'] = true;
  32055. t['Berthold City'] = true;
  32056. t['Bodoni'] = true;
  32057. t['Bauer Bodoni'] = true;
  32058. t['Book Antiqua'] = true;
  32059. t['Bookman'] = true;
  32060. t['Bordeaux Roman'] = true;
  32061. t['Californian FB'] = true;
  32062. t['Calisto'] = true;
  32063. t['Calvert'] = true;
  32064. t['Capitals'] = true;
  32065. t['Cambria'] = true;
  32066. t['Cartier'] = true;
  32067. t['Caslon'] = true;
  32068. t['Catull'] = true;
  32069. t['Centaur'] = true;
  32070. t['Century Old Style'] = true;
  32071. t['Century Schoolbook'] = true;
  32072. t['Chaparral'] = true;
  32073. t['Charis SIL'] = true;
  32074. t['Cheltenham'] = true;
  32075. t['Cholla Slab'] = true;
  32076. t['Clarendon'] = true;
  32077. t['Clearface'] = true;
  32078. t['Cochin'] = true;
  32079. t['Colonna'] = true;
  32080. t['Computer Modern'] = true;
  32081. t['Concrete Roman'] = true;
  32082. t['Constantia'] = true;
  32083. t['Cooper Black'] = true;
  32084. t['Corona'] = true;
  32085. t['Ecotype'] = true;
  32086. t['Egyptienne'] = true;
  32087. t['Elephant'] = true;
  32088. t['Excelsior'] = true;
  32089. t['Fairfield'] = true;
  32090. t['FF Scala'] = true;
  32091. t['Folkard'] = true;
  32092. t['Footlight'] = true;
  32093. t['FreeSerif'] = true;
  32094. t['Friz Quadrata'] = true;
  32095. t['Garamond'] = true;
  32096. t['Gentium'] = true;
  32097. t['Georgia'] = true;
  32098. t['Gloucester'] = true;
  32099. t['Goudy Old Style'] = true;
  32100. t['Goudy Schoolbook'] = true;
  32101. t['Goudy Pro Font'] = true;
  32102. t['Granjon'] = true;
  32103. t['Guardian Egyptian'] = true;
  32104. t['Heather'] = true;
  32105. t['Hercules'] = true;
  32106. t['High Tower Text'] = true;
  32107. t['Hiroshige'] = true;
  32108. t['Hoefler Text'] = true;
  32109. t['Humana Serif'] = true;
  32110. t['Imprint'] = true;
  32111. t['Ionic No. 5'] = true;
  32112. t['Janson'] = true;
  32113. t['Joanna'] = true;
  32114. t['Korinna'] = true;
  32115. t['Lexicon'] = true;
  32116. t['Liberation Serif'] = true;
  32117. t['Linux Libertine'] = true;
  32118. t['Literaturnaya'] = true;
  32119. t['Lucida'] = true;
  32120. t['Lucida Bright'] = true;
  32121. t['Melior'] = true;
  32122. t['Memphis'] = true;
  32123. t['Miller'] = true;
  32124. t['Minion'] = true;
  32125. t['Modern'] = true;
  32126. t['Mona Lisa'] = true;
  32127. t['Mrs Eaves'] = true;
  32128. t['MS Serif'] = true;
  32129. t['Museo Slab'] = true;
  32130. t['New York'] = true;
  32131. t['Nimbus Roman'] = true;
  32132. t['NPS Rawlinson Roadway'] = true;
  32133. t['NuptialScript'] = true;
  32134. t['Palatino'] = true;
  32135. t['Perpetua'] = true;
  32136. t['Plantin'] = true;
  32137. t['Plantin Schoolbook'] = true;
  32138. t['Playbill'] = true;
  32139. t['Poor Richard'] = true;
  32140. t['Rawlinson Roadway'] = true;
  32141. t['Renault'] = true;
  32142. t['Requiem'] = true;
  32143. t['Rockwell'] = true;
  32144. t['Roman'] = true;
  32145. t['Rotis Serif'] = true;
  32146. t['Sabon'] = true;
  32147. t['Scala'] = true;
  32148. t['Seagull'] = true;
  32149. t['Sistina'] = true;
  32150. t['Souvenir'] = true;
  32151. t['STIX'] = true;
  32152. t['Stone Informal'] = true;
  32153. t['Stone Serif'] = true;
  32154. t['Sylfaen'] = true;
  32155. t['Times'] = true;
  32156. t['Trajan'] = true;
  32157. t['Trinité'] = true;
  32158. t['Trump Mediaeval'] = true;
  32159. t['Utopia'] = true;
  32160. t['Vale Type'] = true;
  32161. t['Bitstream Vera'] = true;
  32162. t['Vera Serif'] = true;
  32163. t['Versailles'] = true;
  32164. t['Wanted'] = true;
  32165. t['Weiss'] = true;
  32166. t['Wide Latin'] = true;
  32167. t['Windsor'] = true;
  32168. t['XITS'] = true;
  32169. });
  32170. var getSymbolsFonts = getLookupTableFactory(function (t) {
  32171. t['Dingbats'] = true;
  32172. t['Symbol'] = true;
  32173. t['ZapfDingbats'] = true;
  32174. });
  32175. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  32176. t[2] = 10;
  32177. t[3] = 32;
  32178. t[4] = 33;
  32179. t[5] = 34;
  32180. t[6] = 35;
  32181. t[7] = 36;
  32182. t[8] = 37;
  32183. t[9] = 38;
  32184. t[10] = 39;
  32185. t[11] = 40;
  32186. t[12] = 41;
  32187. t[13] = 42;
  32188. t[14] = 43;
  32189. t[15] = 44;
  32190. t[16] = 45;
  32191. t[17] = 46;
  32192. t[18] = 47;
  32193. t[19] = 48;
  32194. t[20] = 49;
  32195. t[21] = 50;
  32196. t[22] = 51;
  32197. t[23] = 52;
  32198. t[24] = 53;
  32199. t[25] = 54;
  32200. t[26] = 55;
  32201. t[27] = 56;
  32202. t[28] = 57;
  32203. t[29] = 58;
  32204. t[30] = 894;
  32205. t[31] = 60;
  32206. t[32] = 61;
  32207. t[33] = 62;
  32208. t[34] = 63;
  32209. t[35] = 64;
  32210. t[36] = 65;
  32211. t[37] = 66;
  32212. t[38] = 67;
  32213. t[39] = 68;
  32214. t[40] = 69;
  32215. t[41] = 70;
  32216. t[42] = 71;
  32217. t[43] = 72;
  32218. t[44] = 73;
  32219. t[45] = 74;
  32220. t[46] = 75;
  32221. t[47] = 76;
  32222. t[48] = 77;
  32223. t[49] = 78;
  32224. t[50] = 79;
  32225. t[51] = 80;
  32226. t[52] = 81;
  32227. t[53] = 82;
  32228. t[54] = 83;
  32229. t[55] = 84;
  32230. t[56] = 85;
  32231. t[57] = 86;
  32232. t[58] = 87;
  32233. t[59] = 88;
  32234. t[60] = 89;
  32235. t[61] = 90;
  32236. t[62] = 91;
  32237. t[63] = 92;
  32238. t[64] = 93;
  32239. t[65] = 94;
  32240. t[66] = 95;
  32241. t[67] = 96;
  32242. t[68] = 97;
  32243. t[69] = 98;
  32244. t[70] = 99;
  32245. t[71] = 100;
  32246. t[72] = 101;
  32247. t[73] = 102;
  32248. t[74] = 103;
  32249. t[75] = 104;
  32250. t[76] = 105;
  32251. t[77] = 106;
  32252. t[78] = 107;
  32253. t[79] = 108;
  32254. t[80] = 109;
  32255. t[81] = 110;
  32256. t[82] = 111;
  32257. t[83] = 112;
  32258. t[84] = 113;
  32259. t[85] = 114;
  32260. t[86] = 115;
  32261. t[87] = 116;
  32262. t[88] = 117;
  32263. t[89] = 118;
  32264. t[90] = 119;
  32265. t[91] = 120;
  32266. t[92] = 121;
  32267. t[93] = 122;
  32268. t[94] = 123;
  32269. t[95] = 124;
  32270. t[96] = 125;
  32271. t[97] = 126;
  32272. t[98] = 196;
  32273. t[99] = 197;
  32274. t[100] = 199;
  32275. t[101] = 201;
  32276. t[102] = 209;
  32277. t[103] = 214;
  32278. t[104] = 220;
  32279. t[105] = 225;
  32280. t[106] = 224;
  32281. t[107] = 226;
  32282. t[108] = 228;
  32283. t[109] = 227;
  32284. t[110] = 229;
  32285. t[111] = 231;
  32286. t[112] = 233;
  32287. t[113] = 232;
  32288. t[114] = 234;
  32289. t[115] = 235;
  32290. t[116] = 237;
  32291. t[117] = 236;
  32292. t[118] = 238;
  32293. t[119] = 239;
  32294. t[120] = 241;
  32295. t[121] = 243;
  32296. t[122] = 242;
  32297. t[123] = 244;
  32298. t[124] = 246;
  32299. t[125] = 245;
  32300. t[126] = 250;
  32301. t[127] = 249;
  32302. t[128] = 251;
  32303. t[129] = 252;
  32304. t[130] = 8224;
  32305. t[131] = 176;
  32306. t[132] = 162;
  32307. t[133] = 163;
  32308. t[134] = 167;
  32309. t[135] = 8226;
  32310. t[136] = 182;
  32311. t[137] = 223;
  32312. t[138] = 174;
  32313. t[139] = 169;
  32314. t[140] = 8482;
  32315. t[141] = 180;
  32316. t[142] = 168;
  32317. t[143] = 8800;
  32318. t[144] = 198;
  32319. t[145] = 216;
  32320. t[146] = 8734;
  32321. t[147] = 177;
  32322. t[148] = 8804;
  32323. t[149] = 8805;
  32324. t[150] = 165;
  32325. t[151] = 181;
  32326. t[152] = 8706;
  32327. t[153] = 8721;
  32328. t[154] = 8719;
  32329. t[156] = 8747;
  32330. t[157] = 170;
  32331. t[158] = 186;
  32332. t[159] = 8486;
  32333. t[160] = 230;
  32334. t[161] = 248;
  32335. t[162] = 191;
  32336. t[163] = 161;
  32337. t[164] = 172;
  32338. t[165] = 8730;
  32339. t[166] = 402;
  32340. t[167] = 8776;
  32341. t[168] = 8710;
  32342. t[169] = 171;
  32343. t[170] = 187;
  32344. t[171] = 8230;
  32345. t[210] = 218;
  32346. t[223] = 711;
  32347. t[224] = 321;
  32348. t[225] = 322;
  32349. t[227] = 353;
  32350. t[229] = 382;
  32351. t[234] = 253;
  32352. t[252] = 263;
  32353. t[253] = 268;
  32354. t[254] = 269;
  32355. t[258] = 258;
  32356. t[260] = 260;
  32357. t[261] = 261;
  32358. t[265] = 280;
  32359. t[266] = 281;
  32360. t[268] = 283;
  32361. t[269] = 313;
  32362. t[275] = 323;
  32363. t[276] = 324;
  32364. t[278] = 328;
  32365. t[284] = 345;
  32366. t[285] = 346;
  32367. t[286] = 347;
  32368. t[292] = 367;
  32369. t[295] = 377;
  32370. t[296] = 378;
  32371. t[298] = 380;
  32372. t[305] = 963;
  32373. t[306] = 964;
  32374. t[307] = 966;
  32375. t[308] = 8215;
  32376. t[309] = 8252;
  32377. t[310] = 8319;
  32378. t[311] = 8359;
  32379. t[312] = 8592;
  32380. t[313] = 8593;
  32381. t[337] = 9552;
  32382. t[493] = 1039;
  32383. t[494] = 1040;
  32384. t[705] = 1524;
  32385. t[706] = 8362;
  32386. t[710] = 64288;
  32387. t[711] = 64298;
  32388. t[759] = 1617;
  32389. t[761] = 1776;
  32390. t[763] = 1778;
  32391. t[775] = 1652;
  32392. t[777] = 1764;
  32393. t[778] = 1780;
  32394. t[779] = 1781;
  32395. t[780] = 1782;
  32396. t[782] = 771;
  32397. t[783] = 64726;
  32398. t[786] = 8363;
  32399. t[788] = 8532;
  32400. t[790] = 768;
  32401. t[791] = 769;
  32402. t[792] = 768;
  32403. t[795] = 803;
  32404. t[797] = 64336;
  32405. t[798] = 64337;
  32406. t[799] = 64342;
  32407. t[800] = 64343;
  32408. t[801] = 64344;
  32409. t[802] = 64345;
  32410. t[803] = 64362;
  32411. t[804] = 64363;
  32412. t[805] = 64364;
  32413. t[2424] = 7821;
  32414. t[2425] = 7822;
  32415. t[2426] = 7823;
  32416. t[2427] = 7824;
  32417. t[2428] = 7825;
  32418. t[2429] = 7826;
  32419. t[2430] = 7827;
  32420. t[2433] = 7682;
  32421. t[2678] = 8045;
  32422. t[2679] = 8046;
  32423. t[2830] = 1552;
  32424. t[2838] = 686;
  32425. t[2840] = 751;
  32426. t[2842] = 753;
  32427. t[2843] = 754;
  32428. t[2844] = 755;
  32429. t[2846] = 757;
  32430. t[2856] = 767;
  32431. t[2857] = 848;
  32432. t[2858] = 849;
  32433. t[2862] = 853;
  32434. t[2863] = 854;
  32435. t[2864] = 855;
  32436. t[2865] = 861;
  32437. t[2866] = 862;
  32438. t[2906] = 7460;
  32439. t[2908] = 7462;
  32440. t[2909] = 7463;
  32441. t[2910] = 7464;
  32442. t[2912] = 7466;
  32443. t[2913] = 7467;
  32444. t[2914] = 7468;
  32445. t[2916] = 7470;
  32446. t[2917] = 7471;
  32447. t[2918] = 7472;
  32448. t[2920] = 7474;
  32449. t[2921] = 7475;
  32450. t[2922] = 7476;
  32451. t[2924] = 7478;
  32452. t[2925] = 7479;
  32453. t[2926] = 7480;
  32454. t[2928] = 7482;
  32455. t[2929] = 7483;
  32456. t[2930] = 7484;
  32457. t[2932] = 7486;
  32458. t[2933] = 7487;
  32459. t[2934] = 7488;
  32460. t[2936] = 7490;
  32461. t[2937] = 7491;
  32462. t[2938] = 7492;
  32463. t[2940] = 7494;
  32464. t[2941] = 7495;
  32465. t[2942] = 7496;
  32466. t[2944] = 7498;
  32467. t[2946] = 7500;
  32468. t[2948] = 7502;
  32469. t[2950] = 7504;
  32470. t[2951] = 7505;
  32471. t[2952] = 7506;
  32472. t[2954] = 7508;
  32473. t[2955] = 7509;
  32474. t[2956] = 7510;
  32475. t[2958] = 7512;
  32476. t[2959] = 7513;
  32477. t[2960] = 7514;
  32478. t[2962] = 7516;
  32479. t[2963] = 7517;
  32480. t[2964] = 7518;
  32481. t[2966] = 7520;
  32482. t[2967] = 7521;
  32483. t[2968] = 7522;
  32484. t[2970] = 7524;
  32485. t[2971] = 7525;
  32486. t[2972] = 7526;
  32487. t[2974] = 7528;
  32488. t[2975] = 7529;
  32489. t[2976] = 7530;
  32490. t[2978] = 1537;
  32491. t[2979] = 1538;
  32492. t[2980] = 1539;
  32493. t[2982] = 1549;
  32494. t[2983] = 1551;
  32495. t[2984] = 1552;
  32496. t[2986] = 1554;
  32497. t[2987] = 1555;
  32498. t[2988] = 1556;
  32499. t[2990] = 1623;
  32500. t[2991] = 1624;
  32501. t[2995] = 1775;
  32502. t[2999] = 1791;
  32503. t[3002] = 64290;
  32504. t[3003] = 64291;
  32505. t[3004] = 64292;
  32506. t[3006] = 64294;
  32507. t[3007] = 64295;
  32508. t[3008] = 64296;
  32509. t[3011] = 1900;
  32510. t[3014] = 8223;
  32511. t[3015] = 8244;
  32512. t[3017] = 7532;
  32513. t[3018] = 7533;
  32514. t[3019] = 7534;
  32515. t[3075] = 7590;
  32516. t[3076] = 7591;
  32517. t[3079] = 7594;
  32518. t[3080] = 7595;
  32519. t[3083] = 7598;
  32520. t[3084] = 7599;
  32521. t[3087] = 7602;
  32522. t[3088] = 7603;
  32523. t[3091] = 7606;
  32524. t[3092] = 7607;
  32525. t[3095] = 7610;
  32526. t[3096] = 7611;
  32527. t[3099] = 7614;
  32528. t[3100] = 7615;
  32529. t[3103] = 7618;
  32530. t[3104] = 7619;
  32531. t[3107] = 8337;
  32532. t[3108] = 8338;
  32533. t[3116] = 1884;
  32534. t[3119] = 1885;
  32535. t[3120] = 1885;
  32536. t[3123] = 1886;
  32537. t[3124] = 1886;
  32538. t[3127] = 1887;
  32539. t[3128] = 1887;
  32540. t[3131] = 1888;
  32541. t[3132] = 1888;
  32542. t[3135] = 1889;
  32543. t[3136] = 1889;
  32544. t[3139] = 1890;
  32545. t[3140] = 1890;
  32546. t[3143] = 1891;
  32547. t[3144] = 1891;
  32548. t[3147] = 1892;
  32549. t[3148] = 1892;
  32550. t[3153] = 580;
  32551. t[3154] = 581;
  32552. t[3157] = 584;
  32553. t[3158] = 585;
  32554. t[3161] = 588;
  32555. t[3162] = 589;
  32556. t[3165] = 891;
  32557. t[3166] = 892;
  32558. t[3169] = 1274;
  32559. t[3170] = 1275;
  32560. t[3173] = 1278;
  32561. t[3174] = 1279;
  32562. t[3181] = 7622;
  32563. t[3182] = 7623;
  32564. t[3282] = 11799;
  32565. t[3316] = 578;
  32566. t[3379] = 42785;
  32567. t[3393] = 1159;
  32568. t[3416] = 8377;
  32569. });
  32570. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  32571. t[227] = 322;
  32572. t[264] = 261;
  32573. t[291] = 346;
  32574. });
  32575. exports.getStdFontMap = getStdFontMap;
  32576. exports.getNonStdFontMap = getNonStdFontMap;
  32577. exports.getSerifFonts = getSerifFonts;
  32578. exports.getSymbolsFonts = getSymbolsFonts;
  32579. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  32580. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  32581. /***/ }),
  32582. /* 18 */
  32583. /***/ (function(module, exports, __w_pdfjs_require__) {
  32584. "use strict";
  32585. var sharedUtil = __w_pdfjs_require__(0);
  32586. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  32587. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  32588. t[63721] = 0x00A9;
  32589. t[63193] = 0x00A9;
  32590. t[63720] = 0x00AE;
  32591. t[63194] = 0x00AE;
  32592. t[63722] = 0x2122;
  32593. t[63195] = 0x2122;
  32594. t[63729] = 0x23A7;
  32595. t[63730] = 0x23A8;
  32596. t[63731] = 0x23A9;
  32597. t[63740] = 0x23AB;
  32598. t[63741] = 0x23AC;
  32599. t[63742] = 0x23AD;
  32600. t[63726] = 0x23A1;
  32601. t[63727] = 0x23A2;
  32602. t[63728] = 0x23A3;
  32603. t[63737] = 0x23A4;
  32604. t[63738] = 0x23A5;
  32605. t[63739] = 0x23A6;
  32606. t[63723] = 0x239B;
  32607. t[63724] = 0x239C;
  32608. t[63725] = 0x239D;
  32609. t[63734] = 0x239E;
  32610. t[63735] = 0x239F;
  32611. t[63736] = 0x23A0;
  32612. });
  32613. function mapSpecialUnicodeValues(code) {
  32614. if (code >= 0xFFF0 && code <= 0xFFFF) {
  32615. return 0;
  32616. } else if (code >= 0xF600 && code <= 0xF8FF) {
  32617. return getSpecialPUASymbols()[code] || code;
  32618. }
  32619. return code;
  32620. }
  32621. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  32622. var unicode = glyphsUnicodeMap[name];
  32623. if (unicode !== undefined) {
  32624. return unicode;
  32625. }
  32626. if (!name) {
  32627. return -1;
  32628. }
  32629. if (name[0] === 'u') {
  32630. var nameLen = name.length, hexStr;
  32631. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  32632. hexStr = name.substr(3);
  32633. } else if (nameLen >= 5 && nameLen <= 7) {
  32634. hexStr = name.substr(1);
  32635. } else {
  32636. return -1;
  32637. }
  32638. if (hexStr === hexStr.toUpperCase()) {
  32639. unicode = parseInt(hexStr, 16);
  32640. if (unicode >= 0) {
  32641. return unicode;
  32642. }
  32643. }
  32644. }
  32645. return -1;
  32646. }
  32647. var UnicodeRanges = [
  32648. {
  32649. 'begin': 0x0000,
  32650. 'end': 0x007F
  32651. },
  32652. {
  32653. 'begin': 0x0080,
  32654. 'end': 0x00FF
  32655. },
  32656. {
  32657. 'begin': 0x0100,
  32658. 'end': 0x017F
  32659. },
  32660. {
  32661. 'begin': 0x0180,
  32662. 'end': 0x024F
  32663. },
  32664. {
  32665. 'begin': 0x0250,
  32666. 'end': 0x02AF
  32667. },
  32668. {
  32669. 'begin': 0x02B0,
  32670. 'end': 0x02FF
  32671. },
  32672. {
  32673. 'begin': 0x0300,
  32674. 'end': 0x036F
  32675. },
  32676. {
  32677. 'begin': 0x0370,
  32678. 'end': 0x03FF
  32679. },
  32680. {
  32681. 'begin': 0x2C80,
  32682. 'end': 0x2CFF
  32683. },
  32684. {
  32685. 'begin': 0x0400,
  32686. 'end': 0x04FF
  32687. },
  32688. {
  32689. 'begin': 0x0530,
  32690. 'end': 0x058F
  32691. },
  32692. {
  32693. 'begin': 0x0590,
  32694. 'end': 0x05FF
  32695. },
  32696. {
  32697. 'begin': 0xA500,
  32698. 'end': 0xA63F
  32699. },
  32700. {
  32701. 'begin': 0x0600,
  32702. 'end': 0x06FF
  32703. },
  32704. {
  32705. 'begin': 0x07C0,
  32706. 'end': 0x07FF
  32707. },
  32708. {
  32709. 'begin': 0x0900,
  32710. 'end': 0x097F
  32711. },
  32712. {
  32713. 'begin': 0x0980,
  32714. 'end': 0x09FF
  32715. },
  32716. {
  32717. 'begin': 0x0A00,
  32718. 'end': 0x0A7F
  32719. },
  32720. {
  32721. 'begin': 0x0A80,
  32722. 'end': 0x0AFF
  32723. },
  32724. {
  32725. 'begin': 0x0B00,
  32726. 'end': 0x0B7F
  32727. },
  32728. {
  32729. 'begin': 0x0B80,
  32730. 'end': 0x0BFF
  32731. },
  32732. {
  32733. 'begin': 0x0C00,
  32734. 'end': 0x0C7F
  32735. },
  32736. {
  32737. 'begin': 0x0C80,
  32738. 'end': 0x0CFF
  32739. },
  32740. {
  32741. 'begin': 0x0D00,
  32742. 'end': 0x0D7F
  32743. },
  32744. {
  32745. 'begin': 0x0E00,
  32746. 'end': 0x0E7F
  32747. },
  32748. {
  32749. 'begin': 0x0E80,
  32750. 'end': 0x0EFF
  32751. },
  32752. {
  32753. 'begin': 0x10A0,
  32754. 'end': 0x10FF
  32755. },
  32756. {
  32757. 'begin': 0x1B00,
  32758. 'end': 0x1B7F
  32759. },
  32760. {
  32761. 'begin': 0x1100,
  32762. 'end': 0x11FF
  32763. },
  32764. {
  32765. 'begin': 0x1E00,
  32766. 'end': 0x1EFF
  32767. },
  32768. {
  32769. 'begin': 0x1F00,
  32770. 'end': 0x1FFF
  32771. },
  32772. {
  32773. 'begin': 0x2000,
  32774. 'end': 0x206F
  32775. },
  32776. {
  32777. 'begin': 0x2070,
  32778. 'end': 0x209F
  32779. },
  32780. {
  32781. 'begin': 0x20A0,
  32782. 'end': 0x20CF
  32783. },
  32784. {
  32785. 'begin': 0x20D0,
  32786. 'end': 0x20FF
  32787. },
  32788. {
  32789. 'begin': 0x2100,
  32790. 'end': 0x214F
  32791. },
  32792. {
  32793. 'begin': 0x2150,
  32794. 'end': 0x218F
  32795. },
  32796. {
  32797. 'begin': 0x2190,
  32798. 'end': 0x21FF
  32799. },
  32800. {
  32801. 'begin': 0x2200,
  32802. 'end': 0x22FF
  32803. },
  32804. {
  32805. 'begin': 0x2300,
  32806. 'end': 0x23FF
  32807. },
  32808. {
  32809. 'begin': 0x2400,
  32810. 'end': 0x243F
  32811. },
  32812. {
  32813. 'begin': 0x2440,
  32814. 'end': 0x245F
  32815. },
  32816. {
  32817. 'begin': 0x2460,
  32818. 'end': 0x24FF
  32819. },
  32820. {
  32821. 'begin': 0x2500,
  32822. 'end': 0x257F
  32823. },
  32824. {
  32825. 'begin': 0x2580,
  32826. 'end': 0x259F
  32827. },
  32828. {
  32829. 'begin': 0x25A0,
  32830. 'end': 0x25FF
  32831. },
  32832. {
  32833. 'begin': 0x2600,
  32834. 'end': 0x26FF
  32835. },
  32836. {
  32837. 'begin': 0x2700,
  32838. 'end': 0x27BF
  32839. },
  32840. {
  32841. 'begin': 0x3000,
  32842. 'end': 0x303F
  32843. },
  32844. {
  32845. 'begin': 0x3040,
  32846. 'end': 0x309F
  32847. },
  32848. {
  32849. 'begin': 0x30A0,
  32850. 'end': 0x30FF
  32851. },
  32852. {
  32853. 'begin': 0x3100,
  32854. 'end': 0x312F
  32855. },
  32856. {
  32857. 'begin': 0x3130,
  32858. 'end': 0x318F
  32859. },
  32860. {
  32861. 'begin': 0xA840,
  32862. 'end': 0xA87F
  32863. },
  32864. {
  32865. 'begin': 0x3200,
  32866. 'end': 0x32FF
  32867. },
  32868. {
  32869. 'begin': 0x3300,
  32870. 'end': 0x33FF
  32871. },
  32872. {
  32873. 'begin': 0xAC00,
  32874. 'end': 0xD7AF
  32875. },
  32876. {
  32877. 'begin': 0xD800,
  32878. 'end': 0xDFFF
  32879. },
  32880. {
  32881. 'begin': 0x10900,
  32882. 'end': 0x1091F
  32883. },
  32884. {
  32885. 'begin': 0x4E00,
  32886. 'end': 0x9FFF
  32887. },
  32888. {
  32889. 'begin': 0xE000,
  32890. 'end': 0xF8FF
  32891. },
  32892. {
  32893. 'begin': 0x31C0,
  32894. 'end': 0x31EF
  32895. },
  32896. {
  32897. 'begin': 0xFB00,
  32898. 'end': 0xFB4F
  32899. },
  32900. {
  32901. 'begin': 0xFB50,
  32902. 'end': 0xFDFF
  32903. },
  32904. {
  32905. 'begin': 0xFE20,
  32906. 'end': 0xFE2F
  32907. },
  32908. {
  32909. 'begin': 0xFE10,
  32910. 'end': 0xFE1F
  32911. },
  32912. {
  32913. 'begin': 0xFE50,
  32914. 'end': 0xFE6F
  32915. },
  32916. {
  32917. 'begin': 0xFE70,
  32918. 'end': 0xFEFF
  32919. },
  32920. {
  32921. 'begin': 0xFF00,
  32922. 'end': 0xFFEF
  32923. },
  32924. {
  32925. 'begin': 0xFFF0,
  32926. 'end': 0xFFFF
  32927. },
  32928. {
  32929. 'begin': 0x0F00,
  32930. 'end': 0x0FFF
  32931. },
  32932. {
  32933. 'begin': 0x0700,
  32934. 'end': 0x074F
  32935. },
  32936. {
  32937. 'begin': 0x0780,
  32938. 'end': 0x07BF
  32939. },
  32940. {
  32941. 'begin': 0x0D80,
  32942. 'end': 0x0DFF
  32943. },
  32944. {
  32945. 'begin': 0x1000,
  32946. 'end': 0x109F
  32947. },
  32948. {
  32949. 'begin': 0x1200,
  32950. 'end': 0x137F
  32951. },
  32952. {
  32953. 'begin': 0x13A0,
  32954. 'end': 0x13FF
  32955. },
  32956. {
  32957. 'begin': 0x1400,
  32958. 'end': 0x167F
  32959. },
  32960. {
  32961. 'begin': 0x1680,
  32962. 'end': 0x169F
  32963. },
  32964. {
  32965. 'begin': 0x16A0,
  32966. 'end': 0x16FF
  32967. },
  32968. {
  32969. 'begin': 0x1780,
  32970. 'end': 0x17FF
  32971. },
  32972. {
  32973. 'begin': 0x1800,
  32974. 'end': 0x18AF
  32975. },
  32976. {
  32977. 'begin': 0x2800,
  32978. 'end': 0x28FF
  32979. },
  32980. {
  32981. 'begin': 0xA000,
  32982. 'end': 0xA48F
  32983. },
  32984. {
  32985. 'begin': 0x1700,
  32986. 'end': 0x171F
  32987. },
  32988. {
  32989. 'begin': 0x10300,
  32990. 'end': 0x1032F
  32991. },
  32992. {
  32993. 'begin': 0x10330,
  32994. 'end': 0x1034F
  32995. },
  32996. {
  32997. 'begin': 0x10400,
  32998. 'end': 0x1044F
  32999. },
  33000. {
  33001. 'begin': 0x1D000,
  33002. 'end': 0x1D0FF
  33003. },
  33004. {
  33005. 'begin': 0x1D400,
  33006. 'end': 0x1D7FF
  33007. },
  33008. {
  33009. 'begin': 0xFF000,
  33010. 'end': 0xFFFFD
  33011. },
  33012. {
  33013. 'begin': 0xFE00,
  33014. 'end': 0xFE0F
  33015. },
  33016. {
  33017. 'begin': 0xE0000,
  33018. 'end': 0xE007F
  33019. },
  33020. {
  33021. 'begin': 0x1900,
  33022. 'end': 0x194F
  33023. },
  33024. {
  33025. 'begin': 0x1950,
  33026. 'end': 0x197F
  33027. },
  33028. {
  33029. 'begin': 0x1980,
  33030. 'end': 0x19DF
  33031. },
  33032. {
  33033. 'begin': 0x1A00,
  33034. 'end': 0x1A1F
  33035. },
  33036. {
  33037. 'begin': 0x2C00,
  33038. 'end': 0x2C5F
  33039. },
  33040. {
  33041. 'begin': 0x2D30,
  33042. 'end': 0x2D7F
  33043. },
  33044. {
  33045. 'begin': 0x4DC0,
  33046. 'end': 0x4DFF
  33047. },
  33048. {
  33049. 'begin': 0xA800,
  33050. 'end': 0xA82F
  33051. },
  33052. {
  33053. 'begin': 0x10000,
  33054. 'end': 0x1007F
  33055. },
  33056. {
  33057. 'begin': 0x10140,
  33058. 'end': 0x1018F
  33059. },
  33060. {
  33061. 'begin': 0x10380,
  33062. 'end': 0x1039F
  33063. },
  33064. {
  33065. 'begin': 0x103A0,
  33066. 'end': 0x103DF
  33067. },
  33068. {
  33069. 'begin': 0x10450,
  33070. 'end': 0x1047F
  33071. },
  33072. {
  33073. 'begin': 0x10480,
  33074. 'end': 0x104AF
  33075. },
  33076. {
  33077. 'begin': 0x10800,
  33078. 'end': 0x1083F
  33079. },
  33080. {
  33081. 'begin': 0x10A00,
  33082. 'end': 0x10A5F
  33083. },
  33084. {
  33085. 'begin': 0x1D300,
  33086. 'end': 0x1D35F
  33087. },
  33088. {
  33089. 'begin': 0x12000,
  33090. 'end': 0x123FF
  33091. },
  33092. {
  33093. 'begin': 0x1D360,
  33094. 'end': 0x1D37F
  33095. },
  33096. {
  33097. 'begin': 0x1B80,
  33098. 'end': 0x1BBF
  33099. },
  33100. {
  33101. 'begin': 0x1C00,
  33102. 'end': 0x1C4F
  33103. },
  33104. {
  33105. 'begin': 0x1C50,
  33106. 'end': 0x1C7F
  33107. },
  33108. {
  33109. 'begin': 0xA880,
  33110. 'end': 0xA8DF
  33111. },
  33112. {
  33113. 'begin': 0xA900,
  33114. 'end': 0xA92F
  33115. },
  33116. {
  33117. 'begin': 0xA930,
  33118. 'end': 0xA95F
  33119. },
  33120. {
  33121. 'begin': 0xAA00,
  33122. 'end': 0xAA5F
  33123. },
  33124. {
  33125. 'begin': 0x10190,
  33126. 'end': 0x101CF
  33127. },
  33128. {
  33129. 'begin': 0x101D0,
  33130. 'end': 0x101FF
  33131. },
  33132. {
  33133. 'begin': 0x102A0,
  33134. 'end': 0x102DF
  33135. },
  33136. {
  33137. 'begin': 0x1F030,
  33138. 'end': 0x1F09F
  33139. }
  33140. ];
  33141. function getUnicodeRangeFor(value) {
  33142. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  33143. var range = UnicodeRanges[i];
  33144. if (value >= range.begin && value < range.end) {
  33145. return i;
  33146. }
  33147. }
  33148. return -1;
  33149. }
  33150. function isRTLRangeFor(value) {
  33151. var range = UnicodeRanges[13];
  33152. if (value >= range.begin && value < range.end) {
  33153. return true;
  33154. }
  33155. range = UnicodeRanges[11];
  33156. if (value >= range.begin && value < range.end) {
  33157. return true;
  33158. }
  33159. return false;
  33160. }
  33161. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  33162. t['\u00A8'] = '\u0020\u0308';
  33163. t['\u00AF'] = '\u0020\u0304';
  33164. t['\u00B4'] = '\u0020\u0301';
  33165. t['\u00B5'] = '\u03BC';
  33166. t['\u00B8'] = '\u0020\u0327';
  33167. t['\u0132'] = '\u0049\u004A';
  33168. t['\u0133'] = '\u0069\u006A';
  33169. t['\u013F'] = '\u004C\u00B7';
  33170. t['\u0140'] = '\u006C\u00B7';
  33171. t['\u0149'] = '\u02BC\u006E';
  33172. t['\u017F'] = '\u0073';
  33173. t['\u01C4'] = '\u0044\u017D';
  33174. t['\u01C5'] = '\u0044\u017E';
  33175. t['\u01C6'] = '\u0064\u017E';
  33176. t['\u01C7'] = '\u004C\u004A';
  33177. t['\u01C8'] = '\u004C\u006A';
  33178. t['\u01C9'] = '\u006C\u006A';
  33179. t['\u01CA'] = '\u004E\u004A';
  33180. t['\u01CB'] = '\u004E\u006A';
  33181. t['\u01CC'] = '\u006E\u006A';
  33182. t['\u01F1'] = '\u0044\u005A';
  33183. t['\u01F2'] = '\u0044\u007A';
  33184. t['\u01F3'] = '\u0064\u007A';
  33185. t['\u02D8'] = '\u0020\u0306';
  33186. t['\u02D9'] = '\u0020\u0307';
  33187. t['\u02DA'] = '\u0020\u030A';
  33188. t['\u02DB'] = '\u0020\u0328';
  33189. t['\u02DC'] = '\u0020\u0303';
  33190. t['\u02DD'] = '\u0020\u030B';
  33191. t['\u037A'] = '\u0020\u0345';
  33192. t['\u0384'] = '\u0020\u0301';
  33193. t['\u03D0'] = '\u03B2';
  33194. t['\u03D1'] = '\u03B8';
  33195. t['\u03D2'] = '\u03A5';
  33196. t['\u03D5'] = '\u03C6';
  33197. t['\u03D6'] = '\u03C0';
  33198. t['\u03F0'] = '\u03BA';
  33199. t['\u03F1'] = '\u03C1';
  33200. t['\u03F2'] = '\u03C2';
  33201. t['\u03F4'] = '\u0398';
  33202. t['\u03F5'] = '\u03B5';
  33203. t['\u03F9'] = '\u03A3';
  33204. t['\u0587'] = '\u0565\u0582';
  33205. t['\u0675'] = '\u0627\u0674';
  33206. t['\u0676'] = '\u0648\u0674';
  33207. t['\u0677'] = '\u06C7\u0674';
  33208. t['\u0678'] = '\u064A\u0674';
  33209. t['\u0E33'] = '\u0E4D\u0E32';
  33210. t['\u0EB3'] = '\u0ECD\u0EB2';
  33211. t['\u0EDC'] = '\u0EAB\u0E99';
  33212. t['\u0EDD'] = '\u0EAB\u0EA1';
  33213. t['\u0F77'] = '\u0FB2\u0F81';
  33214. t['\u0F79'] = '\u0FB3\u0F81';
  33215. t['\u1E9A'] = '\u0061\u02BE';
  33216. t['\u1FBD'] = '\u0020\u0313';
  33217. t['\u1FBF'] = '\u0020\u0313';
  33218. t['\u1FC0'] = '\u0020\u0342';
  33219. t['\u1FFE'] = '\u0020\u0314';
  33220. t['\u2002'] = '\u0020';
  33221. t['\u2003'] = '\u0020';
  33222. t['\u2004'] = '\u0020';
  33223. t['\u2005'] = '\u0020';
  33224. t['\u2006'] = '\u0020';
  33225. t['\u2008'] = '\u0020';
  33226. t['\u2009'] = '\u0020';
  33227. t['\u200A'] = '\u0020';
  33228. t['\u2017'] = '\u0020\u0333';
  33229. t['\u2024'] = '\u002E';
  33230. t['\u2025'] = '\u002E\u002E';
  33231. t['\u2026'] = '\u002E\u002E\u002E';
  33232. t['\u2033'] = '\u2032\u2032';
  33233. t['\u2034'] = '\u2032\u2032\u2032';
  33234. t['\u2036'] = '\u2035\u2035';
  33235. t['\u2037'] = '\u2035\u2035\u2035';
  33236. t['\u203C'] = '\u0021\u0021';
  33237. t['\u203E'] = '\u0020\u0305';
  33238. t['\u2047'] = '\u003F\u003F';
  33239. t['\u2048'] = '\u003F\u0021';
  33240. t['\u2049'] = '\u0021\u003F';
  33241. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  33242. t['\u205F'] = '\u0020';
  33243. t['\u20A8'] = '\u0052\u0073';
  33244. t['\u2100'] = '\u0061\u002F\u0063';
  33245. t['\u2101'] = '\u0061\u002F\u0073';
  33246. t['\u2103'] = '\u00B0\u0043';
  33247. t['\u2105'] = '\u0063\u002F\u006F';
  33248. t['\u2106'] = '\u0063\u002F\u0075';
  33249. t['\u2107'] = '\u0190';
  33250. t['\u2109'] = '\u00B0\u0046';
  33251. t['\u2116'] = '\u004E\u006F';
  33252. t['\u2121'] = '\u0054\u0045\u004C';
  33253. t['\u2135'] = '\u05D0';
  33254. t['\u2136'] = '\u05D1';
  33255. t['\u2137'] = '\u05D2';
  33256. t['\u2138'] = '\u05D3';
  33257. t['\u213B'] = '\u0046\u0041\u0058';
  33258. t['\u2160'] = '\u0049';
  33259. t['\u2161'] = '\u0049\u0049';
  33260. t['\u2162'] = '\u0049\u0049\u0049';
  33261. t['\u2163'] = '\u0049\u0056';
  33262. t['\u2164'] = '\u0056';
  33263. t['\u2165'] = '\u0056\u0049';
  33264. t['\u2166'] = '\u0056\u0049\u0049';
  33265. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  33266. t['\u2168'] = '\u0049\u0058';
  33267. t['\u2169'] = '\u0058';
  33268. t['\u216A'] = '\u0058\u0049';
  33269. t['\u216B'] = '\u0058\u0049\u0049';
  33270. t['\u216C'] = '\u004C';
  33271. t['\u216D'] = '\u0043';
  33272. t['\u216E'] = '\u0044';
  33273. t['\u216F'] = '\u004D';
  33274. t['\u2170'] = '\u0069';
  33275. t['\u2171'] = '\u0069\u0069';
  33276. t['\u2172'] = '\u0069\u0069\u0069';
  33277. t['\u2173'] = '\u0069\u0076';
  33278. t['\u2174'] = '\u0076';
  33279. t['\u2175'] = '\u0076\u0069';
  33280. t['\u2176'] = '\u0076\u0069\u0069';
  33281. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  33282. t['\u2178'] = '\u0069\u0078';
  33283. t['\u2179'] = '\u0078';
  33284. t['\u217A'] = '\u0078\u0069';
  33285. t['\u217B'] = '\u0078\u0069\u0069';
  33286. t['\u217C'] = '\u006C';
  33287. t['\u217D'] = '\u0063';
  33288. t['\u217E'] = '\u0064';
  33289. t['\u217F'] = '\u006D';
  33290. t['\u222C'] = '\u222B\u222B';
  33291. t['\u222D'] = '\u222B\u222B\u222B';
  33292. t['\u222F'] = '\u222E\u222E';
  33293. t['\u2230'] = '\u222E\u222E\u222E';
  33294. t['\u2474'] = '\u0028\u0031\u0029';
  33295. t['\u2475'] = '\u0028\u0032\u0029';
  33296. t['\u2476'] = '\u0028\u0033\u0029';
  33297. t['\u2477'] = '\u0028\u0034\u0029';
  33298. t['\u2478'] = '\u0028\u0035\u0029';
  33299. t['\u2479'] = '\u0028\u0036\u0029';
  33300. t['\u247A'] = '\u0028\u0037\u0029';
  33301. t['\u247B'] = '\u0028\u0038\u0029';
  33302. t['\u247C'] = '\u0028\u0039\u0029';
  33303. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  33304. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  33305. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  33306. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  33307. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  33308. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  33309. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  33310. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  33311. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  33312. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  33313. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  33314. t['\u2488'] = '\u0031\u002E';
  33315. t['\u2489'] = '\u0032\u002E';
  33316. t['\u248A'] = '\u0033\u002E';
  33317. t['\u248B'] = '\u0034\u002E';
  33318. t['\u248C'] = '\u0035\u002E';
  33319. t['\u248D'] = '\u0036\u002E';
  33320. t['\u248E'] = '\u0037\u002E';
  33321. t['\u248F'] = '\u0038\u002E';
  33322. t['\u2490'] = '\u0039\u002E';
  33323. t['\u2491'] = '\u0031\u0030\u002E';
  33324. t['\u2492'] = '\u0031\u0031\u002E';
  33325. t['\u2493'] = '\u0031\u0032\u002E';
  33326. t['\u2494'] = '\u0031\u0033\u002E';
  33327. t['\u2495'] = '\u0031\u0034\u002E';
  33328. t['\u2496'] = '\u0031\u0035\u002E';
  33329. t['\u2497'] = '\u0031\u0036\u002E';
  33330. t['\u2498'] = '\u0031\u0037\u002E';
  33331. t['\u2499'] = '\u0031\u0038\u002E';
  33332. t['\u249A'] = '\u0031\u0039\u002E';
  33333. t['\u249B'] = '\u0032\u0030\u002E';
  33334. t['\u249C'] = '\u0028\u0061\u0029';
  33335. t['\u249D'] = '\u0028\u0062\u0029';
  33336. t['\u249E'] = '\u0028\u0063\u0029';
  33337. t['\u249F'] = '\u0028\u0064\u0029';
  33338. t['\u24A0'] = '\u0028\u0065\u0029';
  33339. t['\u24A1'] = '\u0028\u0066\u0029';
  33340. t['\u24A2'] = '\u0028\u0067\u0029';
  33341. t['\u24A3'] = '\u0028\u0068\u0029';
  33342. t['\u24A4'] = '\u0028\u0069\u0029';
  33343. t['\u24A5'] = '\u0028\u006A\u0029';
  33344. t['\u24A6'] = '\u0028\u006B\u0029';
  33345. t['\u24A7'] = '\u0028\u006C\u0029';
  33346. t['\u24A8'] = '\u0028\u006D\u0029';
  33347. t['\u24A9'] = '\u0028\u006E\u0029';
  33348. t['\u24AA'] = '\u0028\u006F\u0029';
  33349. t['\u24AB'] = '\u0028\u0070\u0029';
  33350. t['\u24AC'] = '\u0028\u0071\u0029';
  33351. t['\u24AD'] = '\u0028\u0072\u0029';
  33352. t['\u24AE'] = '\u0028\u0073\u0029';
  33353. t['\u24AF'] = '\u0028\u0074\u0029';
  33354. t['\u24B0'] = '\u0028\u0075\u0029';
  33355. t['\u24B1'] = '\u0028\u0076\u0029';
  33356. t['\u24B2'] = '\u0028\u0077\u0029';
  33357. t['\u24B3'] = '\u0028\u0078\u0029';
  33358. t['\u24B4'] = '\u0028\u0079\u0029';
  33359. t['\u24B5'] = '\u0028\u007A\u0029';
  33360. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  33361. t['\u2A74'] = '\u003A\u003A\u003D';
  33362. t['\u2A75'] = '\u003D\u003D';
  33363. t['\u2A76'] = '\u003D\u003D\u003D';
  33364. t['\u2E9F'] = '\u6BCD';
  33365. t['\u2EF3'] = '\u9F9F';
  33366. t['\u2F00'] = '\u4E00';
  33367. t['\u2F01'] = '\u4E28';
  33368. t['\u2F02'] = '\u4E36';
  33369. t['\u2F03'] = '\u4E3F';
  33370. t['\u2F04'] = '\u4E59';
  33371. t['\u2F05'] = '\u4E85';
  33372. t['\u2F06'] = '\u4E8C';
  33373. t['\u2F07'] = '\u4EA0';
  33374. t['\u2F08'] = '\u4EBA';
  33375. t['\u2F09'] = '\u513F';
  33376. t['\u2F0A'] = '\u5165';
  33377. t['\u2F0B'] = '\u516B';
  33378. t['\u2F0C'] = '\u5182';
  33379. t['\u2F0D'] = '\u5196';
  33380. t['\u2F0E'] = '\u51AB';
  33381. t['\u2F0F'] = '\u51E0';
  33382. t['\u2F10'] = '\u51F5';
  33383. t['\u2F11'] = '\u5200';
  33384. t['\u2F12'] = '\u529B';
  33385. t['\u2F13'] = '\u52F9';
  33386. t['\u2F14'] = '\u5315';
  33387. t['\u2F15'] = '\u531A';
  33388. t['\u2F16'] = '\u5338';
  33389. t['\u2F17'] = '\u5341';
  33390. t['\u2F18'] = '\u535C';
  33391. t['\u2F19'] = '\u5369';
  33392. t['\u2F1A'] = '\u5382';
  33393. t['\u2F1B'] = '\u53B6';
  33394. t['\u2F1C'] = '\u53C8';
  33395. t['\u2F1D'] = '\u53E3';
  33396. t['\u2F1E'] = '\u56D7';
  33397. t['\u2F1F'] = '\u571F';
  33398. t['\u2F20'] = '\u58EB';
  33399. t['\u2F21'] = '\u5902';
  33400. t['\u2F22'] = '\u590A';
  33401. t['\u2F23'] = '\u5915';
  33402. t['\u2F24'] = '\u5927';
  33403. t['\u2F25'] = '\u5973';
  33404. t['\u2F26'] = '\u5B50';
  33405. t['\u2F27'] = '\u5B80';
  33406. t['\u2F28'] = '\u5BF8';
  33407. t['\u2F29'] = '\u5C0F';
  33408. t['\u2F2A'] = '\u5C22';
  33409. t['\u2F2B'] = '\u5C38';
  33410. t['\u2F2C'] = '\u5C6E';
  33411. t['\u2F2D'] = '\u5C71';
  33412. t['\u2F2E'] = '\u5DDB';
  33413. t['\u2F2F'] = '\u5DE5';
  33414. t['\u2F30'] = '\u5DF1';
  33415. t['\u2F31'] = '\u5DFE';
  33416. t['\u2F32'] = '\u5E72';
  33417. t['\u2F33'] = '\u5E7A';
  33418. t['\u2F34'] = '\u5E7F';
  33419. t['\u2F35'] = '\u5EF4';
  33420. t['\u2F36'] = '\u5EFE';
  33421. t['\u2F37'] = '\u5F0B';
  33422. t['\u2F38'] = '\u5F13';
  33423. t['\u2F39'] = '\u5F50';
  33424. t['\u2F3A'] = '\u5F61';
  33425. t['\u2F3B'] = '\u5F73';
  33426. t['\u2F3C'] = '\u5FC3';
  33427. t['\u2F3D'] = '\u6208';
  33428. t['\u2F3E'] = '\u6236';
  33429. t['\u2F3F'] = '\u624B';
  33430. t['\u2F40'] = '\u652F';
  33431. t['\u2F41'] = '\u6534';
  33432. t['\u2F42'] = '\u6587';
  33433. t['\u2F43'] = '\u6597';
  33434. t['\u2F44'] = '\u65A4';
  33435. t['\u2F45'] = '\u65B9';
  33436. t['\u2F46'] = '\u65E0';
  33437. t['\u2F47'] = '\u65E5';
  33438. t['\u2F48'] = '\u66F0';
  33439. t['\u2F49'] = '\u6708';
  33440. t['\u2F4A'] = '\u6728';
  33441. t['\u2F4B'] = '\u6B20';
  33442. t['\u2F4C'] = '\u6B62';
  33443. t['\u2F4D'] = '\u6B79';
  33444. t['\u2F4E'] = '\u6BB3';
  33445. t['\u2F4F'] = '\u6BCB';
  33446. t['\u2F50'] = '\u6BD4';
  33447. t['\u2F51'] = '\u6BDB';
  33448. t['\u2F52'] = '\u6C0F';
  33449. t['\u2F53'] = '\u6C14';
  33450. t['\u2F54'] = '\u6C34';
  33451. t['\u2F55'] = '\u706B';
  33452. t['\u2F56'] = '\u722A';
  33453. t['\u2F57'] = '\u7236';
  33454. t['\u2F58'] = '\u723B';
  33455. t['\u2F59'] = '\u723F';
  33456. t['\u2F5A'] = '\u7247';
  33457. t['\u2F5B'] = '\u7259';
  33458. t['\u2F5C'] = '\u725B';
  33459. t['\u2F5D'] = '\u72AC';
  33460. t['\u2F5E'] = '\u7384';
  33461. t['\u2F5F'] = '\u7389';
  33462. t['\u2F60'] = '\u74DC';
  33463. t['\u2F61'] = '\u74E6';
  33464. t['\u2F62'] = '\u7518';
  33465. t['\u2F63'] = '\u751F';
  33466. t['\u2F64'] = '\u7528';
  33467. t['\u2F65'] = '\u7530';
  33468. t['\u2F66'] = '\u758B';
  33469. t['\u2F67'] = '\u7592';
  33470. t['\u2F68'] = '\u7676';
  33471. t['\u2F69'] = '\u767D';
  33472. t['\u2F6A'] = '\u76AE';
  33473. t['\u2F6B'] = '\u76BF';
  33474. t['\u2F6C'] = '\u76EE';
  33475. t['\u2F6D'] = '\u77DB';
  33476. t['\u2F6E'] = '\u77E2';
  33477. t['\u2F6F'] = '\u77F3';
  33478. t['\u2F70'] = '\u793A';
  33479. t['\u2F71'] = '\u79B8';
  33480. t['\u2F72'] = '\u79BE';
  33481. t['\u2F73'] = '\u7A74';
  33482. t['\u2F74'] = '\u7ACB';
  33483. t['\u2F75'] = '\u7AF9';
  33484. t['\u2F76'] = '\u7C73';
  33485. t['\u2F77'] = '\u7CF8';
  33486. t['\u2F78'] = '\u7F36';
  33487. t['\u2F79'] = '\u7F51';
  33488. t['\u2F7A'] = '\u7F8A';
  33489. t['\u2F7B'] = '\u7FBD';
  33490. t['\u2F7C'] = '\u8001';
  33491. t['\u2F7D'] = '\u800C';
  33492. t['\u2F7E'] = '\u8012';
  33493. t['\u2F7F'] = '\u8033';
  33494. t['\u2F80'] = '\u807F';
  33495. t['\u2F81'] = '\u8089';
  33496. t['\u2F82'] = '\u81E3';
  33497. t['\u2F83'] = '\u81EA';
  33498. t['\u2F84'] = '\u81F3';
  33499. t['\u2F85'] = '\u81FC';
  33500. t['\u2F86'] = '\u820C';
  33501. t['\u2F87'] = '\u821B';
  33502. t['\u2F88'] = '\u821F';
  33503. t['\u2F89'] = '\u826E';
  33504. t['\u2F8A'] = '\u8272';
  33505. t['\u2F8B'] = '\u8278';
  33506. t['\u2F8C'] = '\u864D';
  33507. t['\u2F8D'] = '\u866B';
  33508. t['\u2F8E'] = '\u8840';
  33509. t['\u2F8F'] = '\u884C';
  33510. t['\u2F90'] = '\u8863';
  33511. t['\u2F91'] = '\u897E';
  33512. t['\u2F92'] = '\u898B';
  33513. t['\u2F93'] = '\u89D2';
  33514. t['\u2F94'] = '\u8A00';
  33515. t['\u2F95'] = '\u8C37';
  33516. t['\u2F96'] = '\u8C46';
  33517. t['\u2F97'] = '\u8C55';
  33518. t['\u2F98'] = '\u8C78';
  33519. t['\u2F99'] = '\u8C9D';
  33520. t['\u2F9A'] = '\u8D64';
  33521. t['\u2F9B'] = '\u8D70';
  33522. t['\u2F9C'] = '\u8DB3';
  33523. t['\u2F9D'] = '\u8EAB';
  33524. t['\u2F9E'] = '\u8ECA';
  33525. t['\u2F9F'] = '\u8F9B';
  33526. t['\u2FA0'] = '\u8FB0';
  33527. t['\u2FA1'] = '\u8FB5';
  33528. t['\u2FA2'] = '\u9091';
  33529. t['\u2FA3'] = '\u9149';
  33530. t['\u2FA4'] = '\u91C6';
  33531. t['\u2FA5'] = '\u91CC';
  33532. t['\u2FA6'] = '\u91D1';
  33533. t['\u2FA7'] = '\u9577';
  33534. t['\u2FA8'] = '\u9580';
  33535. t['\u2FA9'] = '\u961C';
  33536. t['\u2FAA'] = '\u96B6';
  33537. t['\u2FAB'] = '\u96B9';
  33538. t['\u2FAC'] = '\u96E8';
  33539. t['\u2FAD'] = '\u9751';
  33540. t['\u2FAE'] = '\u975E';
  33541. t['\u2FAF'] = '\u9762';
  33542. t['\u2FB0'] = '\u9769';
  33543. t['\u2FB1'] = '\u97CB';
  33544. t['\u2FB2'] = '\u97ED';
  33545. t['\u2FB3'] = '\u97F3';
  33546. t['\u2FB4'] = '\u9801';
  33547. t['\u2FB5'] = '\u98A8';
  33548. t['\u2FB6'] = '\u98DB';
  33549. t['\u2FB7'] = '\u98DF';
  33550. t['\u2FB8'] = '\u9996';
  33551. t['\u2FB9'] = '\u9999';
  33552. t['\u2FBA'] = '\u99AC';
  33553. t['\u2FBB'] = '\u9AA8';
  33554. t['\u2FBC'] = '\u9AD8';
  33555. t['\u2FBD'] = '\u9ADF';
  33556. t['\u2FBE'] = '\u9B25';
  33557. t['\u2FBF'] = '\u9B2F';
  33558. t['\u2FC0'] = '\u9B32';
  33559. t['\u2FC1'] = '\u9B3C';
  33560. t['\u2FC2'] = '\u9B5A';
  33561. t['\u2FC3'] = '\u9CE5';
  33562. t['\u2FC4'] = '\u9E75';
  33563. t['\u2FC5'] = '\u9E7F';
  33564. t['\u2FC6'] = '\u9EA5';
  33565. t['\u2FC7'] = '\u9EBB';
  33566. t['\u2FC8'] = '\u9EC3';
  33567. t['\u2FC9'] = '\u9ECD';
  33568. t['\u2FCA'] = '\u9ED1';
  33569. t['\u2FCB'] = '\u9EF9';
  33570. t['\u2FCC'] = '\u9EFD';
  33571. t['\u2FCD'] = '\u9F0E';
  33572. t['\u2FCE'] = '\u9F13';
  33573. t['\u2FCF'] = '\u9F20';
  33574. t['\u2FD0'] = '\u9F3B';
  33575. t['\u2FD1'] = '\u9F4A';
  33576. t['\u2FD2'] = '\u9F52';
  33577. t['\u2FD3'] = '\u9F8D';
  33578. t['\u2FD4'] = '\u9F9C';
  33579. t['\u2FD5'] = '\u9FA0';
  33580. t['\u3036'] = '\u3012';
  33581. t['\u3038'] = '\u5341';
  33582. t['\u3039'] = '\u5344';
  33583. t['\u303A'] = '\u5345';
  33584. t['\u309B'] = '\u0020\u3099';
  33585. t['\u309C'] = '\u0020\u309A';
  33586. t['\u3131'] = '\u1100';
  33587. t['\u3132'] = '\u1101';
  33588. t['\u3133'] = '\u11AA';
  33589. t['\u3134'] = '\u1102';
  33590. t['\u3135'] = '\u11AC';
  33591. t['\u3136'] = '\u11AD';
  33592. t['\u3137'] = '\u1103';
  33593. t['\u3138'] = '\u1104';
  33594. t['\u3139'] = '\u1105';
  33595. t['\u313A'] = '\u11B0';
  33596. t['\u313B'] = '\u11B1';
  33597. t['\u313C'] = '\u11B2';
  33598. t['\u313D'] = '\u11B3';
  33599. t['\u313E'] = '\u11B4';
  33600. t['\u313F'] = '\u11B5';
  33601. t['\u3140'] = '\u111A';
  33602. t['\u3141'] = '\u1106';
  33603. t['\u3142'] = '\u1107';
  33604. t['\u3143'] = '\u1108';
  33605. t['\u3144'] = '\u1121';
  33606. t['\u3145'] = '\u1109';
  33607. t['\u3146'] = '\u110A';
  33608. t['\u3147'] = '\u110B';
  33609. t['\u3148'] = '\u110C';
  33610. t['\u3149'] = '\u110D';
  33611. t['\u314A'] = '\u110E';
  33612. t['\u314B'] = '\u110F';
  33613. t['\u314C'] = '\u1110';
  33614. t['\u314D'] = '\u1111';
  33615. t['\u314E'] = '\u1112';
  33616. t['\u314F'] = '\u1161';
  33617. t['\u3150'] = '\u1162';
  33618. t['\u3151'] = '\u1163';
  33619. t['\u3152'] = '\u1164';
  33620. t['\u3153'] = '\u1165';
  33621. t['\u3154'] = '\u1166';
  33622. t['\u3155'] = '\u1167';
  33623. t['\u3156'] = '\u1168';
  33624. t['\u3157'] = '\u1169';
  33625. t['\u3158'] = '\u116A';
  33626. t['\u3159'] = '\u116B';
  33627. t['\u315A'] = '\u116C';
  33628. t['\u315B'] = '\u116D';
  33629. t['\u315C'] = '\u116E';
  33630. t['\u315D'] = '\u116F';
  33631. t['\u315E'] = '\u1170';
  33632. t['\u315F'] = '\u1171';
  33633. t['\u3160'] = '\u1172';
  33634. t['\u3161'] = '\u1173';
  33635. t['\u3162'] = '\u1174';
  33636. t['\u3163'] = '\u1175';
  33637. t['\u3164'] = '\u1160';
  33638. t['\u3165'] = '\u1114';
  33639. t['\u3166'] = '\u1115';
  33640. t['\u3167'] = '\u11C7';
  33641. t['\u3168'] = '\u11C8';
  33642. t['\u3169'] = '\u11CC';
  33643. t['\u316A'] = '\u11CE';
  33644. t['\u316B'] = '\u11D3';
  33645. t['\u316C'] = '\u11D7';
  33646. t['\u316D'] = '\u11D9';
  33647. t['\u316E'] = '\u111C';
  33648. t['\u316F'] = '\u11DD';
  33649. t['\u3170'] = '\u11DF';
  33650. t['\u3171'] = '\u111D';
  33651. t['\u3172'] = '\u111E';
  33652. t['\u3173'] = '\u1120';
  33653. t['\u3174'] = '\u1122';
  33654. t['\u3175'] = '\u1123';
  33655. t['\u3176'] = '\u1127';
  33656. t['\u3177'] = '\u1129';
  33657. t['\u3178'] = '\u112B';
  33658. t['\u3179'] = '\u112C';
  33659. t['\u317A'] = '\u112D';
  33660. t['\u317B'] = '\u112E';
  33661. t['\u317C'] = '\u112F';
  33662. t['\u317D'] = '\u1132';
  33663. t['\u317E'] = '\u1136';
  33664. t['\u317F'] = '\u1140';
  33665. t['\u3180'] = '\u1147';
  33666. t['\u3181'] = '\u114C';
  33667. t['\u3182'] = '\u11F1';
  33668. t['\u3183'] = '\u11F2';
  33669. t['\u3184'] = '\u1157';
  33670. t['\u3185'] = '\u1158';
  33671. t['\u3186'] = '\u1159';
  33672. t['\u3187'] = '\u1184';
  33673. t['\u3188'] = '\u1185';
  33674. t['\u3189'] = '\u1188';
  33675. t['\u318A'] = '\u1191';
  33676. t['\u318B'] = '\u1192';
  33677. t['\u318C'] = '\u1194';
  33678. t['\u318D'] = '\u119E';
  33679. t['\u318E'] = '\u11A1';
  33680. t['\u3200'] = '\u0028\u1100\u0029';
  33681. t['\u3201'] = '\u0028\u1102\u0029';
  33682. t['\u3202'] = '\u0028\u1103\u0029';
  33683. t['\u3203'] = '\u0028\u1105\u0029';
  33684. t['\u3204'] = '\u0028\u1106\u0029';
  33685. t['\u3205'] = '\u0028\u1107\u0029';
  33686. t['\u3206'] = '\u0028\u1109\u0029';
  33687. t['\u3207'] = '\u0028\u110B\u0029';
  33688. t['\u3208'] = '\u0028\u110C\u0029';
  33689. t['\u3209'] = '\u0028\u110E\u0029';
  33690. t['\u320A'] = '\u0028\u110F\u0029';
  33691. t['\u320B'] = '\u0028\u1110\u0029';
  33692. t['\u320C'] = '\u0028\u1111\u0029';
  33693. t['\u320D'] = '\u0028\u1112\u0029';
  33694. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  33695. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  33696. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  33697. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  33698. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  33699. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  33700. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  33701. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  33702. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  33703. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  33704. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  33705. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  33706. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  33707. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  33708. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  33709. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  33710. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  33711. t['\u3220'] = '\u0028\u4E00\u0029';
  33712. t['\u3221'] = '\u0028\u4E8C\u0029';
  33713. t['\u3222'] = '\u0028\u4E09\u0029';
  33714. t['\u3223'] = '\u0028\u56DB\u0029';
  33715. t['\u3224'] = '\u0028\u4E94\u0029';
  33716. t['\u3225'] = '\u0028\u516D\u0029';
  33717. t['\u3226'] = '\u0028\u4E03\u0029';
  33718. t['\u3227'] = '\u0028\u516B\u0029';
  33719. t['\u3228'] = '\u0028\u4E5D\u0029';
  33720. t['\u3229'] = '\u0028\u5341\u0029';
  33721. t['\u322A'] = '\u0028\u6708\u0029';
  33722. t['\u322B'] = '\u0028\u706B\u0029';
  33723. t['\u322C'] = '\u0028\u6C34\u0029';
  33724. t['\u322D'] = '\u0028\u6728\u0029';
  33725. t['\u322E'] = '\u0028\u91D1\u0029';
  33726. t['\u322F'] = '\u0028\u571F\u0029';
  33727. t['\u3230'] = '\u0028\u65E5\u0029';
  33728. t['\u3231'] = '\u0028\u682A\u0029';
  33729. t['\u3232'] = '\u0028\u6709\u0029';
  33730. t['\u3233'] = '\u0028\u793E\u0029';
  33731. t['\u3234'] = '\u0028\u540D\u0029';
  33732. t['\u3235'] = '\u0028\u7279\u0029';
  33733. t['\u3236'] = '\u0028\u8CA1\u0029';
  33734. t['\u3237'] = '\u0028\u795D\u0029';
  33735. t['\u3238'] = '\u0028\u52B4\u0029';
  33736. t['\u3239'] = '\u0028\u4EE3\u0029';
  33737. t['\u323A'] = '\u0028\u547C\u0029';
  33738. t['\u323B'] = '\u0028\u5B66\u0029';
  33739. t['\u323C'] = '\u0028\u76E3\u0029';
  33740. t['\u323D'] = '\u0028\u4F01\u0029';
  33741. t['\u323E'] = '\u0028\u8CC7\u0029';
  33742. t['\u323F'] = '\u0028\u5354\u0029';
  33743. t['\u3240'] = '\u0028\u796D\u0029';
  33744. t['\u3241'] = '\u0028\u4F11\u0029';
  33745. t['\u3242'] = '\u0028\u81EA\u0029';
  33746. t['\u3243'] = '\u0028\u81F3\u0029';
  33747. t['\u32C0'] = '\u0031\u6708';
  33748. t['\u32C1'] = '\u0032\u6708';
  33749. t['\u32C2'] = '\u0033\u6708';
  33750. t['\u32C3'] = '\u0034\u6708';
  33751. t['\u32C4'] = '\u0035\u6708';
  33752. t['\u32C5'] = '\u0036\u6708';
  33753. t['\u32C6'] = '\u0037\u6708';
  33754. t['\u32C7'] = '\u0038\u6708';
  33755. t['\u32C8'] = '\u0039\u6708';
  33756. t['\u32C9'] = '\u0031\u0030\u6708';
  33757. t['\u32CA'] = '\u0031\u0031\u6708';
  33758. t['\u32CB'] = '\u0031\u0032\u6708';
  33759. t['\u3358'] = '\u0030\u70B9';
  33760. t['\u3359'] = '\u0031\u70B9';
  33761. t['\u335A'] = '\u0032\u70B9';
  33762. t['\u335B'] = '\u0033\u70B9';
  33763. t['\u335C'] = '\u0034\u70B9';
  33764. t['\u335D'] = '\u0035\u70B9';
  33765. t['\u335E'] = '\u0036\u70B9';
  33766. t['\u335F'] = '\u0037\u70B9';
  33767. t['\u3360'] = '\u0038\u70B9';
  33768. t['\u3361'] = '\u0039\u70B9';
  33769. t['\u3362'] = '\u0031\u0030\u70B9';
  33770. t['\u3363'] = '\u0031\u0031\u70B9';
  33771. t['\u3364'] = '\u0031\u0032\u70B9';
  33772. t['\u3365'] = '\u0031\u0033\u70B9';
  33773. t['\u3366'] = '\u0031\u0034\u70B9';
  33774. t['\u3367'] = '\u0031\u0035\u70B9';
  33775. t['\u3368'] = '\u0031\u0036\u70B9';
  33776. t['\u3369'] = '\u0031\u0037\u70B9';
  33777. t['\u336A'] = '\u0031\u0038\u70B9';
  33778. t['\u336B'] = '\u0031\u0039\u70B9';
  33779. t['\u336C'] = '\u0032\u0030\u70B9';
  33780. t['\u336D'] = '\u0032\u0031\u70B9';
  33781. t['\u336E'] = '\u0032\u0032\u70B9';
  33782. t['\u336F'] = '\u0032\u0033\u70B9';
  33783. t['\u3370'] = '\u0032\u0034\u70B9';
  33784. t['\u33E0'] = '\u0031\u65E5';
  33785. t['\u33E1'] = '\u0032\u65E5';
  33786. t['\u33E2'] = '\u0033\u65E5';
  33787. t['\u33E3'] = '\u0034\u65E5';
  33788. t['\u33E4'] = '\u0035\u65E5';
  33789. t['\u33E5'] = '\u0036\u65E5';
  33790. t['\u33E6'] = '\u0037\u65E5';
  33791. t['\u33E7'] = '\u0038\u65E5';
  33792. t['\u33E8'] = '\u0039\u65E5';
  33793. t['\u33E9'] = '\u0031\u0030\u65E5';
  33794. t['\u33EA'] = '\u0031\u0031\u65E5';
  33795. t['\u33EB'] = '\u0031\u0032\u65E5';
  33796. t['\u33EC'] = '\u0031\u0033\u65E5';
  33797. t['\u33ED'] = '\u0031\u0034\u65E5';
  33798. t['\u33EE'] = '\u0031\u0035\u65E5';
  33799. t['\u33EF'] = '\u0031\u0036\u65E5';
  33800. t['\u33F0'] = '\u0031\u0037\u65E5';
  33801. t['\u33F1'] = '\u0031\u0038\u65E5';
  33802. t['\u33F2'] = '\u0031\u0039\u65E5';
  33803. t['\u33F3'] = '\u0032\u0030\u65E5';
  33804. t['\u33F4'] = '\u0032\u0031\u65E5';
  33805. t['\u33F5'] = '\u0032\u0032\u65E5';
  33806. t['\u33F6'] = '\u0032\u0033\u65E5';
  33807. t['\u33F7'] = '\u0032\u0034\u65E5';
  33808. t['\u33F8'] = '\u0032\u0035\u65E5';
  33809. t['\u33F9'] = '\u0032\u0036\u65E5';
  33810. t['\u33FA'] = '\u0032\u0037\u65E5';
  33811. t['\u33FB'] = '\u0032\u0038\u65E5';
  33812. t['\u33FC'] = '\u0032\u0039\u65E5';
  33813. t['\u33FD'] = '\u0033\u0030\u65E5';
  33814. t['\u33FE'] = '\u0033\u0031\u65E5';
  33815. t['\uFB00'] = '\u0066\u0066';
  33816. t['\uFB01'] = '\u0066\u0069';
  33817. t['\uFB02'] = '\u0066\u006C';
  33818. t['\uFB03'] = '\u0066\u0066\u0069';
  33819. t['\uFB04'] = '\u0066\u0066\u006C';
  33820. t['\uFB05'] = '\u017F\u0074';
  33821. t['\uFB06'] = '\u0073\u0074';
  33822. t['\uFB13'] = '\u0574\u0576';
  33823. t['\uFB14'] = '\u0574\u0565';
  33824. t['\uFB15'] = '\u0574\u056B';
  33825. t['\uFB16'] = '\u057E\u0576';
  33826. t['\uFB17'] = '\u0574\u056D';
  33827. t['\uFB4F'] = '\u05D0\u05DC';
  33828. t['\uFB50'] = '\u0671';
  33829. t['\uFB51'] = '\u0671';
  33830. t['\uFB52'] = '\u067B';
  33831. t['\uFB53'] = '\u067B';
  33832. t['\uFB54'] = '\u067B';
  33833. t['\uFB55'] = '\u067B';
  33834. t['\uFB56'] = '\u067E';
  33835. t['\uFB57'] = '\u067E';
  33836. t['\uFB58'] = '\u067E';
  33837. t['\uFB59'] = '\u067E';
  33838. t['\uFB5A'] = '\u0680';
  33839. t['\uFB5B'] = '\u0680';
  33840. t['\uFB5C'] = '\u0680';
  33841. t['\uFB5D'] = '\u0680';
  33842. t['\uFB5E'] = '\u067A';
  33843. t['\uFB5F'] = '\u067A';
  33844. t['\uFB60'] = '\u067A';
  33845. t['\uFB61'] = '\u067A';
  33846. t['\uFB62'] = '\u067F';
  33847. t['\uFB63'] = '\u067F';
  33848. t['\uFB64'] = '\u067F';
  33849. t['\uFB65'] = '\u067F';
  33850. t['\uFB66'] = '\u0679';
  33851. t['\uFB67'] = '\u0679';
  33852. t['\uFB68'] = '\u0679';
  33853. t['\uFB69'] = '\u0679';
  33854. t['\uFB6A'] = '\u06A4';
  33855. t['\uFB6B'] = '\u06A4';
  33856. t['\uFB6C'] = '\u06A4';
  33857. t['\uFB6D'] = '\u06A4';
  33858. t['\uFB6E'] = '\u06A6';
  33859. t['\uFB6F'] = '\u06A6';
  33860. t['\uFB70'] = '\u06A6';
  33861. t['\uFB71'] = '\u06A6';
  33862. t['\uFB72'] = '\u0684';
  33863. t['\uFB73'] = '\u0684';
  33864. t['\uFB74'] = '\u0684';
  33865. t['\uFB75'] = '\u0684';
  33866. t['\uFB76'] = '\u0683';
  33867. t['\uFB77'] = '\u0683';
  33868. t['\uFB78'] = '\u0683';
  33869. t['\uFB79'] = '\u0683';
  33870. t['\uFB7A'] = '\u0686';
  33871. t['\uFB7B'] = '\u0686';
  33872. t['\uFB7C'] = '\u0686';
  33873. t['\uFB7D'] = '\u0686';
  33874. t['\uFB7E'] = '\u0687';
  33875. t['\uFB7F'] = '\u0687';
  33876. t['\uFB80'] = '\u0687';
  33877. t['\uFB81'] = '\u0687';
  33878. t['\uFB82'] = '\u068D';
  33879. t['\uFB83'] = '\u068D';
  33880. t['\uFB84'] = '\u068C';
  33881. t['\uFB85'] = '\u068C';
  33882. t['\uFB86'] = '\u068E';
  33883. t['\uFB87'] = '\u068E';
  33884. t['\uFB88'] = '\u0688';
  33885. t['\uFB89'] = '\u0688';
  33886. t['\uFB8A'] = '\u0698';
  33887. t['\uFB8B'] = '\u0698';
  33888. t['\uFB8C'] = '\u0691';
  33889. t['\uFB8D'] = '\u0691';
  33890. t['\uFB8E'] = '\u06A9';
  33891. t['\uFB8F'] = '\u06A9';
  33892. t['\uFB90'] = '\u06A9';
  33893. t['\uFB91'] = '\u06A9';
  33894. t['\uFB92'] = '\u06AF';
  33895. t['\uFB93'] = '\u06AF';
  33896. t['\uFB94'] = '\u06AF';
  33897. t['\uFB95'] = '\u06AF';
  33898. t['\uFB96'] = '\u06B3';
  33899. t['\uFB97'] = '\u06B3';
  33900. t['\uFB98'] = '\u06B3';
  33901. t['\uFB99'] = '\u06B3';
  33902. t['\uFB9A'] = '\u06B1';
  33903. t['\uFB9B'] = '\u06B1';
  33904. t['\uFB9C'] = '\u06B1';
  33905. t['\uFB9D'] = '\u06B1';
  33906. t['\uFB9E'] = '\u06BA';
  33907. t['\uFB9F'] = '\u06BA';
  33908. t['\uFBA0'] = '\u06BB';
  33909. t['\uFBA1'] = '\u06BB';
  33910. t['\uFBA2'] = '\u06BB';
  33911. t['\uFBA3'] = '\u06BB';
  33912. t['\uFBA4'] = '\u06C0';
  33913. t['\uFBA5'] = '\u06C0';
  33914. t['\uFBA6'] = '\u06C1';
  33915. t['\uFBA7'] = '\u06C1';
  33916. t['\uFBA8'] = '\u06C1';
  33917. t['\uFBA9'] = '\u06C1';
  33918. t['\uFBAA'] = '\u06BE';
  33919. t['\uFBAB'] = '\u06BE';
  33920. t['\uFBAC'] = '\u06BE';
  33921. t['\uFBAD'] = '\u06BE';
  33922. t['\uFBAE'] = '\u06D2';
  33923. t['\uFBAF'] = '\u06D2';
  33924. t['\uFBB0'] = '\u06D3';
  33925. t['\uFBB1'] = '\u06D3';
  33926. t['\uFBD3'] = '\u06AD';
  33927. t['\uFBD4'] = '\u06AD';
  33928. t['\uFBD5'] = '\u06AD';
  33929. t['\uFBD6'] = '\u06AD';
  33930. t['\uFBD7'] = '\u06C7';
  33931. t['\uFBD8'] = '\u06C7';
  33932. t['\uFBD9'] = '\u06C6';
  33933. t['\uFBDA'] = '\u06C6';
  33934. t['\uFBDB'] = '\u06C8';
  33935. t['\uFBDC'] = '\u06C8';
  33936. t['\uFBDD'] = '\u0677';
  33937. t['\uFBDE'] = '\u06CB';
  33938. t['\uFBDF'] = '\u06CB';
  33939. t['\uFBE0'] = '\u06C5';
  33940. t['\uFBE1'] = '\u06C5';
  33941. t['\uFBE2'] = '\u06C9';
  33942. t['\uFBE3'] = '\u06C9';
  33943. t['\uFBE4'] = '\u06D0';
  33944. t['\uFBE5'] = '\u06D0';
  33945. t['\uFBE6'] = '\u06D0';
  33946. t['\uFBE7'] = '\u06D0';
  33947. t['\uFBE8'] = '\u0649';
  33948. t['\uFBE9'] = '\u0649';
  33949. t['\uFBEA'] = '\u0626\u0627';
  33950. t['\uFBEB'] = '\u0626\u0627';
  33951. t['\uFBEC'] = '\u0626\u06D5';
  33952. t['\uFBED'] = '\u0626\u06D5';
  33953. t['\uFBEE'] = '\u0626\u0648';
  33954. t['\uFBEF'] = '\u0626\u0648';
  33955. t['\uFBF0'] = '\u0626\u06C7';
  33956. t['\uFBF1'] = '\u0626\u06C7';
  33957. t['\uFBF2'] = '\u0626\u06C6';
  33958. t['\uFBF3'] = '\u0626\u06C6';
  33959. t['\uFBF4'] = '\u0626\u06C8';
  33960. t['\uFBF5'] = '\u0626\u06C8';
  33961. t['\uFBF6'] = '\u0626\u06D0';
  33962. t['\uFBF7'] = '\u0626\u06D0';
  33963. t['\uFBF8'] = '\u0626\u06D0';
  33964. t['\uFBF9'] = '\u0626\u0649';
  33965. t['\uFBFA'] = '\u0626\u0649';
  33966. t['\uFBFB'] = '\u0626\u0649';
  33967. t['\uFBFC'] = '\u06CC';
  33968. t['\uFBFD'] = '\u06CC';
  33969. t['\uFBFE'] = '\u06CC';
  33970. t['\uFBFF'] = '\u06CC';
  33971. t['\uFC00'] = '\u0626\u062C';
  33972. t['\uFC01'] = '\u0626\u062D';
  33973. t['\uFC02'] = '\u0626\u0645';
  33974. t['\uFC03'] = '\u0626\u0649';
  33975. t['\uFC04'] = '\u0626\u064A';
  33976. t['\uFC05'] = '\u0628\u062C';
  33977. t['\uFC06'] = '\u0628\u062D';
  33978. t['\uFC07'] = '\u0628\u062E';
  33979. t['\uFC08'] = '\u0628\u0645';
  33980. t['\uFC09'] = '\u0628\u0649';
  33981. t['\uFC0A'] = '\u0628\u064A';
  33982. t['\uFC0B'] = '\u062A\u062C';
  33983. t['\uFC0C'] = '\u062A\u062D';
  33984. t['\uFC0D'] = '\u062A\u062E';
  33985. t['\uFC0E'] = '\u062A\u0645';
  33986. t['\uFC0F'] = '\u062A\u0649';
  33987. t['\uFC10'] = '\u062A\u064A';
  33988. t['\uFC11'] = '\u062B\u062C';
  33989. t['\uFC12'] = '\u062B\u0645';
  33990. t['\uFC13'] = '\u062B\u0649';
  33991. t['\uFC14'] = '\u062B\u064A';
  33992. t['\uFC15'] = '\u062C\u062D';
  33993. t['\uFC16'] = '\u062C\u0645';
  33994. t['\uFC17'] = '\u062D\u062C';
  33995. t['\uFC18'] = '\u062D\u0645';
  33996. t['\uFC19'] = '\u062E\u062C';
  33997. t['\uFC1A'] = '\u062E\u062D';
  33998. t['\uFC1B'] = '\u062E\u0645';
  33999. t['\uFC1C'] = '\u0633\u062C';
  34000. t['\uFC1D'] = '\u0633\u062D';
  34001. t['\uFC1E'] = '\u0633\u062E';
  34002. t['\uFC1F'] = '\u0633\u0645';
  34003. t['\uFC20'] = '\u0635\u062D';
  34004. t['\uFC21'] = '\u0635\u0645';
  34005. t['\uFC22'] = '\u0636\u062C';
  34006. t['\uFC23'] = '\u0636\u062D';
  34007. t['\uFC24'] = '\u0636\u062E';
  34008. t['\uFC25'] = '\u0636\u0645';
  34009. t['\uFC26'] = '\u0637\u062D';
  34010. t['\uFC27'] = '\u0637\u0645';
  34011. t['\uFC28'] = '\u0638\u0645';
  34012. t['\uFC29'] = '\u0639\u062C';
  34013. t['\uFC2A'] = '\u0639\u0645';
  34014. t['\uFC2B'] = '\u063A\u062C';
  34015. t['\uFC2C'] = '\u063A\u0645';
  34016. t['\uFC2D'] = '\u0641\u062C';
  34017. t['\uFC2E'] = '\u0641\u062D';
  34018. t['\uFC2F'] = '\u0641\u062E';
  34019. t['\uFC30'] = '\u0641\u0645';
  34020. t['\uFC31'] = '\u0641\u0649';
  34021. t['\uFC32'] = '\u0641\u064A';
  34022. t['\uFC33'] = '\u0642\u062D';
  34023. t['\uFC34'] = '\u0642\u0645';
  34024. t['\uFC35'] = '\u0642\u0649';
  34025. t['\uFC36'] = '\u0642\u064A';
  34026. t['\uFC37'] = '\u0643\u0627';
  34027. t['\uFC38'] = '\u0643\u062C';
  34028. t['\uFC39'] = '\u0643\u062D';
  34029. t['\uFC3A'] = '\u0643\u062E';
  34030. t['\uFC3B'] = '\u0643\u0644';
  34031. t['\uFC3C'] = '\u0643\u0645';
  34032. t['\uFC3D'] = '\u0643\u0649';
  34033. t['\uFC3E'] = '\u0643\u064A';
  34034. t['\uFC3F'] = '\u0644\u062C';
  34035. t['\uFC40'] = '\u0644\u062D';
  34036. t['\uFC41'] = '\u0644\u062E';
  34037. t['\uFC42'] = '\u0644\u0645';
  34038. t['\uFC43'] = '\u0644\u0649';
  34039. t['\uFC44'] = '\u0644\u064A';
  34040. t['\uFC45'] = '\u0645\u062C';
  34041. t['\uFC46'] = '\u0645\u062D';
  34042. t['\uFC47'] = '\u0645\u062E';
  34043. t['\uFC48'] = '\u0645\u0645';
  34044. t['\uFC49'] = '\u0645\u0649';
  34045. t['\uFC4A'] = '\u0645\u064A';
  34046. t['\uFC4B'] = '\u0646\u062C';
  34047. t['\uFC4C'] = '\u0646\u062D';
  34048. t['\uFC4D'] = '\u0646\u062E';
  34049. t['\uFC4E'] = '\u0646\u0645';
  34050. t['\uFC4F'] = '\u0646\u0649';
  34051. t['\uFC50'] = '\u0646\u064A';
  34052. t['\uFC51'] = '\u0647\u062C';
  34053. t['\uFC52'] = '\u0647\u0645';
  34054. t['\uFC53'] = '\u0647\u0649';
  34055. t['\uFC54'] = '\u0647\u064A';
  34056. t['\uFC55'] = '\u064A\u062C';
  34057. t['\uFC56'] = '\u064A\u062D';
  34058. t['\uFC57'] = '\u064A\u062E';
  34059. t['\uFC58'] = '\u064A\u0645';
  34060. t['\uFC59'] = '\u064A\u0649';
  34061. t['\uFC5A'] = '\u064A\u064A';
  34062. t['\uFC5B'] = '\u0630\u0670';
  34063. t['\uFC5C'] = '\u0631\u0670';
  34064. t['\uFC5D'] = '\u0649\u0670';
  34065. t['\uFC5E'] = '\u0020\u064C\u0651';
  34066. t['\uFC5F'] = '\u0020\u064D\u0651';
  34067. t['\uFC60'] = '\u0020\u064E\u0651';
  34068. t['\uFC61'] = '\u0020\u064F\u0651';
  34069. t['\uFC62'] = '\u0020\u0650\u0651';
  34070. t['\uFC63'] = '\u0020\u0651\u0670';
  34071. t['\uFC64'] = '\u0626\u0631';
  34072. t['\uFC65'] = '\u0626\u0632';
  34073. t['\uFC66'] = '\u0626\u0645';
  34074. t['\uFC67'] = '\u0626\u0646';
  34075. t['\uFC68'] = '\u0626\u0649';
  34076. t['\uFC69'] = '\u0626\u064A';
  34077. t['\uFC6A'] = '\u0628\u0631';
  34078. t['\uFC6B'] = '\u0628\u0632';
  34079. t['\uFC6C'] = '\u0628\u0645';
  34080. t['\uFC6D'] = '\u0628\u0646';
  34081. t['\uFC6E'] = '\u0628\u0649';
  34082. t['\uFC6F'] = '\u0628\u064A';
  34083. t['\uFC70'] = '\u062A\u0631';
  34084. t['\uFC71'] = '\u062A\u0632';
  34085. t['\uFC72'] = '\u062A\u0645';
  34086. t['\uFC73'] = '\u062A\u0646';
  34087. t['\uFC74'] = '\u062A\u0649';
  34088. t['\uFC75'] = '\u062A\u064A';
  34089. t['\uFC76'] = '\u062B\u0631';
  34090. t['\uFC77'] = '\u062B\u0632';
  34091. t['\uFC78'] = '\u062B\u0645';
  34092. t['\uFC79'] = '\u062B\u0646';
  34093. t['\uFC7A'] = '\u062B\u0649';
  34094. t['\uFC7B'] = '\u062B\u064A';
  34095. t['\uFC7C'] = '\u0641\u0649';
  34096. t['\uFC7D'] = '\u0641\u064A';
  34097. t['\uFC7E'] = '\u0642\u0649';
  34098. t['\uFC7F'] = '\u0642\u064A';
  34099. t['\uFC80'] = '\u0643\u0627';
  34100. t['\uFC81'] = '\u0643\u0644';
  34101. t['\uFC82'] = '\u0643\u0645';
  34102. t['\uFC83'] = '\u0643\u0649';
  34103. t['\uFC84'] = '\u0643\u064A';
  34104. t['\uFC85'] = '\u0644\u0645';
  34105. t['\uFC86'] = '\u0644\u0649';
  34106. t['\uFC87'] = '\u0644\u064A';
  34107. t['\uFC88'] = '\u0645\u0627';
  34108. t['\uFC89'] = '\u0645\u0645';
  34109. t['\uFC8A'] = '\u0646\u0631';
  34110. t['\uFC8B'] = '\u0646\u0632';
  34111. t['\uFC8C'] = '\u0646\u0645';
  34112. t['\uFC8D'] = '\u0646\u0646';
  34113. t['\uFC8E'] = '\u0646\u0649';
  34114. t['\uFC8F'] = '\u0646\u064A';
  34115. t['\uFC90'] = '\u0649\u0670';
  34116. t['\uFC91'] = '\u064A\u0631';
  34117. t['\uFC92'] = '\u064A\u0632';
  34118. t['\uFC93'] = '\u064A\u0645';
  34119. t['\uFC94'] = '\u064A\u0646';
  34120. t['\uFC95'] = '\u064A\u0649';
  34121. t['\uFC96'] = '\u064A\u064A';
  34122. t['\uFC97'] = '\u0626\u062C';
  34123. t['\uFC98'] = '\u0626\u062D';
  34124. t['\uFC99'] = '\u0626\u062E';
  34125. t['\uFC9A'] = '\u0626\u0645';
  34126. t['\uFC9B'] = '\u0626\u0647';
  34127. t['\uFC9C'] = '\u0628\u062C';
  34128. t['\uFC9D'] = '\u0628\u062D';
  34129. t['\uFC9E'] = '\u0628\u062E';
  34130. t['\uFC9F'] = '\u0628\u0645';
  34131. t['\uFCA0'] = '\u0628\u0647';
  34132. t['\uFCA1'] = '\u062A\u062C';
  34133. t['\uFCA2'] = '\u062A\u062D';
  34134. t['\uFCA3'] = '\u062A\u062E';
  34135. t['\uFCA4'] = '\u062A\u0645';
  34136. t['\uFCA5'] = '\u062A\u0647';
  34137. t['\uFCA6'] = '\u062B\u0645';
  34138. t['\uFCA7'] = '\u062C\u062D';
  34139. t['\uFCA8'] = '\u062C\u0645';
  34140. t['\uFCA9'] = '\u062D\u062C';
  34141. t['\uFCAA'] = '\u062D\u0645';
  34142. t['\uFCAB'] = '\u062E\u062C';
  34143. t['\uFCAC'] = '\u062E\u0645';
  34144. t['\uFCAD'] = '\u0633\u062C';
  34145. t['\uFCAE'] = '\u0633\u062D';
  34146. t['\uFCAF'] = '\u0633\u062E';
  34147. t['\uFCB0'] = '\u0633\u0645';
  34148. t['\uFCB1'] = '\u0635\u062D';
  34149. t['\uFCB2'] = '\u0635\u062E';
  34150. t['\uFCB3'] = '\u0635\u0645';
  34151. t['\uFCB4'] = '\u0636\u062C';
  34152. t['\uFCB5'] = '\u0636\u062D';
  34153. t['\uFCB6'] = '\u0636\u062E';
  34154. t['\uFCB7'] = '\u0636\u0645';
  34155. t['\uFCB8'] = '\u0637\u062D';
  34156. t['\uFCB9'] = '\u0638\u0645';
  34157. t['\uFCBA'] = '\u0639\u062C';
  34158. t['\uFCBB'] = '\u0639\u0645';
  34159. t['\uFCBC'] = '\u063A\u062C';
  34160. t['\uFCBD'] = '\u063A\u0645';
  34161. t['\uFCBE'] = '\u0641\u062C';
  34162. t['\uFCBF'] = '\u0641\u062D';
  34163. t['\uFCC0'] = '\u0641\u062E';
  34164. t['\uFCC1'] = '\u0641\u0645';
  34165. t['\uFCC2'] = '\u0642\u062D';
  34166. t['\uFCC3'] = '\u0642\u0645';
  34167. t['\uFCC4'] = '\u0643\u062C';
  34168. t['\uFCC5'] = '\u0643\u062D';
  34169. t['\uFCC6'] = '\u0643\u062E';
  34170. t['\uFCC7'] = '\u0643\u0644';
  34171. t['\uFCC8'] = '\u0643\u0645';
  34172. t['\uFCC9'] = '\u0644\u062C';
  34173. t['\uFCCA'] = '\u0644\u062D';
  34174. t['\uFCCB'] = '\u0644\u062E';
  34175. t['\uFCCC'] = '\u0644\u0645';
  34176. t['\uFCCD'] = '\u0644\u0647';
  34177. t['\uFCCE'] = '\u0645\u062C';
  34178. t['\uFCCF'] = '\u0645\u062D';
  34179. t['\uFCD0'] = '\u0645\u062E';
  34180. t['\uFCD1'] = '\u0645\u0645';
  34181. t['\uFCD2'] = '\u0646\u062C';
  34182. t['\uFCD3'] = '\u0646\u062D';
  34183. t['\uFCD4'] = '\u0646\u062E';
  34184. t['\uFCD5'] = '\u0646\u0645';
  34185. t['\uFCD6'] = '\u0646\u0647';
  34186. t['\uFCD7'] = '\u0647\u062C';
  34187. t['\uFCD8'] = '\u0647\u0645';
  34188. t['\uFCD9'] = '\u0647\u0670';
  34189. t['\uFCDA'] = '\u064A\u062C';
  34190. t['\uFCDB'] = '\u064A\u062D';
  34191. t['\uFCDC'] = '\u064A\u062E';
  34192. t['\uFCDD'] = '\u064A\u0645';
  34193. t['\uFCDE'] = '\u064A\u0647';
  34194. t['\uFCDF'] = '\u0626\u0645';
  34195. t['\uFCE0'] = '\u0626\u0647';
  34196. t['\uFCE1'] = '\u0628\u0645';
  34197. t['\uFCE2'] = '\u0628\u0647';
  34198. t['\uFCE3'] = '\u062A\u0645';
  34199. t['\uFCE4'] = '\u062A\u0647';
  34200. t['\uFCE5'] = '\u062B\u0645';
  34201. t['\uFCE6'] = '\u062B\u0647';
  34202. t['\uFCE7'] = '\u0633\u0645';
  34203. t['\uFCE8'] = '\u0633\u0647';
  34204. t['\uFCE9'] = '\u0634\u0645';
  34205. t['\uFCEA'] = '\u0634\u0647';
  34206. t['\uFCEB'] = '\u0643\u0644';
  34207. t['\uFCEC'] = '\u0643\u0645';
  34208. t['\uFCED'] = '\u0644\u0645';
  34209. t['\uFCEE'] = '\u0646\u0645';
  34210. t['\uFCEF'] = '\u0646\u0647';
  34211. t['\uFCF0'] = '\u064A\u0645';
  34212. t['\uFCF1'] = '\u064A\u0647';
  34213. t['\uFCF2'] = '\u0640\u064E\u0651';
  34214. t['\uFCF3'] = '\u0640\u064F\u0651';
  34215. t['\uFCF4'] = '\u0640\u0650\u0651';
  34216. t['\uFCF5'] = '\u0637\u0649';
  34217. t['\uFCF6'] = '\u0637\u064A';
  34218. t['\uFCF7'] = '\u0639\u0649';
  34219. t['\uFCF8'] = '\u0639\u064A';
  34220. t['\uFCF9'] = '\u063A\u0649';
  34221. t['\uFCFA'] = '\u063A\u064A';
  34222. t['\uFCFB'] = '\u0633\u0649';
  34223. t['\uFCFC'] = '\u0633\u064A';
  34224. t['\uFCFD'] = '\u0634\u0649';
  34225. t['\uFCFE'] = '\u0634\u064A';
  34226. t['\uFCFF'] = '\u062D\u0649';
  34227. t['\uFD00'] = '\u062D\u064A';
  34228. t['\uFD01'] = '\u062C\u0649';
  34229. t['\uFD02'] = '\u062C\u064A';
  34230. t['\uFD03'] = '\u062E\u0649';
  34231. t['\uFD04'] = '\u062E\u064A';
  34232. t['\uFD05'] = '\u0635\u0649';
  34233. t['\uFD06'] = '\u0635\u064A';
  34234. t['\uFD07'] = '\u0636\u0649';
  34235. t['\uFD08'] = '\u0636\u064A';
  34236. t['\uFD09'] = '\u0634\u062C';
  34237. t['\uFD0A'] = '\u0634\u062D';
  34238. t['\uFD0B'] = '\u0634\u062E';
  34239. t['\uFD0C'] = '\u0634\u0645';
  34240. t['\uFD0D'] = '\u0634\u0631';
  34241. t['\uFD0E'] = '\u0633\u0631';
  34242. t['\uFD0F'] = '\u0635\u0631';
  34243. t['\uFD10'] = '\u0636\u0631';
  34244. t['\uFD11'] = '\u0637\u0649';
  34245. t['\uFD12'] = '\u0637\u064A';
  34246. t['\uFD13'] = '\u0639\u0649';
  34247. t['\uFD14'] = '\u0639\u064A';
  34248. t['\uFD15'] = '\u063A\u0649';
  34249. t['\uFD16'] = '\u063A\u064A';
  34250. t['\uFD17'] = '\u0633\u0649';
  34251. t['\uFD18'] = '\u0633\u064A';
  34252. t['\uFD19'] = '\u0634\u0649';
  34253. t['\uFD1A'] = '\u0634\u064A';
  34254. t['\uFD1B'] = '\u062D\u0649';
  34255. t['\uFD1C'] = '\u062D\u064A';
  34256. t['\uFD1D'] = '\u062C\u0649';
  34257. t['\uFD1E'] = '\u062C\u064A';
  34258. t['\uFD1F'] = '\u062E\u0649';
  34259. t['\uFD20'] = '\u062E\u064A';
  34260. t['\uFD21'] = '\u0635\u0649';
  34261. t['\uFD22'] = '\u0635\u064A';
  34262. t['\uFD23'] = '\u0636\u0649';
  34263. t['\uFD24'] = '\u0636\u064A';
  34264. t['\uFD25'] = '\u0634\u062C';
  34265. t['\uFD26'] = '\u0634\u062D';
  34266. t['\uFD27'] = '\u0634\u062E';
  34267. t['\uFD28'] = '\u0634\u0645';
  34268. t['\uFD29'] = '\u0634\u0631';
  34269. t['\uFD2A'] = '\u0633\u0631';
  34270. t['\uFD2B'] = '\u0635\u0631';
  34271. t['\uFD2C'] = '\u0636\u0631';
  34272. t['\uFD2D'] = '\u0634\u062C';
  34273. t['\uFD2E'] = '\u0634\u062D';
  34274. t['\uFD2F'] = '\u0634\u062E';
  34275. t['\uFD30'] = '\u0634\u0645';
  34276. t['\uFD31'] = '\u0633\u0647';
  34277. t['\uFD32'] = '\u0634\u0647';
  34278. t['\uFD33'] = '\u0637\u0645';
  34279. t['\uFD34'] = '\u0633\u062C';
  34280. t['\uFD35'] = '\u0633\u062D';
  34281. t['\uFD36'] = '\u0633\u062E';
  34282. t['\uFD37'] = '\u0634\u062C';
  34283. t['\uFD38'] = '\u0634\u062D';
  34284. t['\uFD39'] = '\u0634\u062E';
  34285. t['\uFD3A'] = '\u0637\u0645';
  34286. t['\uFD3B'] = '\u0638\u0645';
  34287. t['\uFD3C'] = '\u0627\u064B';
  34288. t['\uFD3D'] = '\u0627\u064B';
  34289. t['\uFD50'] = '\u062A\u062C\u0645';
  34290. t['\uFD51'] = '\u062A\u062D\u062C';
  34291. t['\uFD52'] = '\u062A\u062D\u062C';
  34292. t['\uFD53'] = '\u062A\u062D\u0645';
  34293. t['\uFD54'] = '\u062A\u062E\u0645';
  34294. t['\uFD55'] = '\u062A\u0645\u062C';
  34295. t['\uFD56'] = '\u062A\u0645\u062D';
  34296. t['\uFD57'] = '\u062A\u0645\u062E';
  34297. t['\uFD58'] = '\u062C\u0645\u062D';
  34298. t['\uFD59'] = '\u062C\u0645\u062D';
  34299. t['\uFD5A'] = '\u062D\u0645\u064A';
  34300. t['\uFD5B'] = '\u062D\u0645\u0649';
  34301. t['\uFD5C'] = '\u0633\u062D\u062C';
  34302. t['\uFD5D'] = '\u0633\u062C\u062D';
  34303. t['\uFD5E'] = '\u0633\u062C\u0649';
  34304. t['\uFD5F'] = '\u0633\u0645\u062D';
  34305. t['\uFD60'] = '\u0633\u0645\u062D';
  34306. t['\uFD61'] = '\u0633\u0645\u062C';
  34307. t['\uFD62'] = '\u0633\u0645\u0645';
  34308. t['\uFD63'] = '\u0633\u0645\u0645';
  34309. t['\uFD64'] = '\u0635\u062D\u062D';
  34310. t['\uFD65'] = '\u0635\u062D\u062D';
  34311. t['\uFD66'] = '\u0635\u0645\u0645';
  34312. t['\uFD67'] = '\u0634\u062D\u0645';
  34313. t['\uFD68'] = '\u0634\u062D\u0645';
  34314. t['\uFD69'] = '\u0634\u062C\u064A';
  34315. t['\uFD6A'] = '\u0634\u0645\u062E';
  34316. t['\uFD6B'] = '\u0634\u0645\u062E';
  34317. t['\uFD6C'] = '\u0634\u0645\u0645';
  34318. t['\uFD6D'] = '\u0634\u0645\u0645';
  34319. t['\uFD6E'] = '\u0636\u062D\u0649';
  34320. t['\uFD6F'] = '\u0636\u062E\u0645';
  34321. t['\uFD70'] = '\u0636\u062E\u0645';
  34322. t['\uFD71'] = '\u0637\u0645\u062D';
  34323. t['\uFD72'] = '\u0637\u0645\u062D';
  34324. t['\uFD73'] = '\u0637\u0645\u0645';
  34325. t['\uFD74'] = '\u0637\u0645\u064A';
  34326. t['\uFD75'] = '\u0639\u062C\u0645';
  34327. t['\uFD76'] = '\u0639\u0645\u0645';
  34328. t['\uFD77'] = '\u0639\u0645\u0645';
  34329. t['\uFD78'] = '\u0639\u0645\u0649';
  34330. t['\uFD79'] = '\u063A\u0645\u0645';
  34331. t['\uFD7A'] = '\u063A\u0645\u064A';
  34332. t['\uFD7B'] = '\u063A\u0645\u0649';
  34333. t['\uFD7C'] = '\u0641\u062E\u0645';
  34334. t['\uFD7D'] = '\u0641\u062E\u0645';
  34335. t['\uFD7E'] = '\u0642\u0645\u062D';
  34336. t['\uFD7F'] = '\u0642\u0645\u0645';
  34337. t['\uFD80'] = '\u0644\u062D\u0645';
  34338. t['\uFD81'] = '\u0644\u062D\u064A';
  34339. t['\uFD82'] = '\u0644\u062D\u0649';
  34340. t['\uFD83'] = '\u0644\u062C\u062C';
  34341. t['\uFD84'] = '\u0644\u062C\u062C';
  34342. t['\uFD85'] = '\u0644\u062E\u0645';
  34343. t['\uFD86'] = '\u0644\u062E\u0645';
  34344. t['\uFD87'] = '\u0644\u0645\u062D';
  34345. t['\uFD88'] = '\u0644\u0645\u062D';
  34346. t['\uFD89'] = '\u0645\u062D\u062C';
  34347. t['\uFD8A'] = '\u0645\u062D\u0645';
  34348. t['\uFD8B'] = '\u0645\u062D\u064A';
  34349. t['\uFD8C'] = '\u0645\u062C\u062D';
  34350. t['\uFD8D'] = '\u0645\u062C\u0645';
  34351. t['\uFD8E'] = '\u0645\u062E\u062C';
  34352. t['\uFD8F'] = '\u0645\u062E\u0645';
  34353. t['\uFD92'] = '\u0645\u062C\u062E';
  34354. t['\uFD93'] = '\u0647\u0645\u062C';
  34355. t['\uFD94'] = '\u0647\u0645\u0645';
  34356. t['\uFD95'] = '\u0646\u062D\u0645';
  34357. t['\uFD96'] = '\u0646\u062D\u0649';
  34358. t['\uFD97'] = '\u0646\u062C\u0645';
  34359. t['\uFD98'] = '\u0646\u062C\u0645';
  34360. t['\uFD99'] = '\u0646\u062C\u0649';
  34361. t['\uFD9A'] = '\u0646\u0645\u064A';
  34362. t['\uFD9B'] = '\u0646\u0645\u0649';
  34363. t['\uFD9C'] = '\u064A\u0645\u0645';
  34364. t['\uFD9D'] = '\u064A\u0645\u0645';
  34365. t['\uFD9E'] = '\u0628\u062E\u064A';
  34366. t['\uFD9F'] = '\u062A\u062C\u064A';
  34367. t['\uFDA0'] = '\u062A\u062C\u0649';
  34368. t['\uFDA1'] = '\u062A\u062E\u064A';
  34369. t['\uFDA2'] = '\u062A\u062E\u0649';
  34370. t['\uFDA3'] = '\u062A\u0645\u064A';
  34371. t['\uFDA4'] = '\u062A\u0645\u0649';
  34372. t['\uFDA5'] = '\u062C\u0645\u064A';
  34373. t['\uFDA6'] = '\u062C\u062D\u0649';
  34374. t['\uFDA7'] = '\u062C\u0645\u0649';
  34375. t['\uFDA8'] = '\u0633\u062E\u0649';
  34376. t['\uFDA9'] = '\u0635\u062D\u064A';
  34377. t['\uFDAA'] = '\u0634\u062D\u064A';
  34378. t['\uFDAB'] = '\u0636\u062D\u064A';
  34379. t['\uFDAC'] = '\u0644\u062C\u064A';
  34380. t['\uFDAD'] = '\u0644\u0645\u064A';
  34381. t['\uFDAE'] = '\u064A\u062D\u064A';
  34382. t['\uFDAF'] = '\u064A\u062C\u064A';
  34383. t['\uFDB0'] = '\u064A\u0645\u064A';
  34384. t['\uFDB1'] = '\u0645\u0645\u064A';
  34385. t['\uFDB2'] = '\u0642\u0645\u064A';
  34386. t['\uFDB3'] = '\u0646\u062D\u064A';
  34387. t['\uFDB4'] = '\u0642\u0645\u062D';
  34388. t['\uFDB5'] = '\u0644\u062D\u0645';
  34389. t['\uFDB6'] = '\u0639\u0645\u064A';
  34390. t['\uFDB7'] = '\u0643\u0645\u064A';
  34391. t['\uFDB8'] = '\u0646\u062C\u062D';
  34392. t['\uFDB9'] = '\u0645\u062E\u064A';
  34393. t['\uFDBA'] = '\u0644\u062C\u0645';
  34394. t['\uFDBB'] = '\u0643\u0645\u0645';
  34395. t['\uFDBC'] = '\u0644\u062C\u0645';
  34396. t['\uFDBD'] = '\u0646\u062C\u062D';
  34397. t['\uFDBE'] = '\u062C\u062D\u064A';
  34398. t['\uFDBF'] = '\u062D\u062C\u064A';
  34399. t['\uFDC0'] = '\u0645\u062C\u064A';
  34400. t['\uFDC1'] = '\u0641\u0645\u064A';
  34401. t['\uFDC2'] = '\u0628\u062D\u064A';
  34402. t['\uFDC3'] = '\u0643\u0645\u0645';
  34403. t['\uFDC4'] = '\u0639\u062C\u0645';
  34404. t['\uFDC5'] = '\u0635\u0645\u0645';
  34405. t['\uFDC6'] = '\u0633\u062E\u064A';
  34406. t['\uFDC7'] = '\u0646\u062C\u064A';
  34407. t['\uFE49'] = '\u203E';
  34408. t['\uFE4A'] = '\u203E';
  34409. t['\uFE4B'] = '\u203E';
  34410. t['\uFE4C'] = '\u203E';
  34411. t['\uFE4D'] = '\u005F';
  34412. t['\uFE4E'] = '\u005F';
  34413. t['\uFE4F'] = '\u005F';
  34414. t['\uFE80'] = '\u0621';
  34415. t['\uFE81'] = '\u0622';
  34416. t['\uFE82'] = '\u0622';
  34417. t['\uFE83'] = '\u0623';
  34418. t['\uFE84'] = '\u0623';
  34419. t['\uFE85'] = '\u0624';
  34420. t['\uFE86'] = '\u0624';
  34421. t['\uFE87'] = '\u0625';
  34422. t['\uFE88'] = '\u0625';
  34423. t['\uFE89'] = '\u0626';
  34424. t['\uFE8A'] = '\u0626';
  34425. t['\uFE8B'] = '\u0626';
  34426. t['\uFE8C'] = '\u0626';
  34427. t['\uFE8D'] = '\u0627';
  34428. t['\uFE8E'] = '\u0627';
  34429. t['\uFE8F'] = '\u0628';
  34430. t['\uFE90'] = '\u0628';
  34431. t['\uFE91'] = '\u0628';
  34432. t['\uFE92'] = '\u0628';
  34433. t['\uFE93'] = '\u0629';
  34434. t['\uFE94'] = '\u0629';
  34435. t['\uFE95'] = '\u062A';
  34436. t['\uFE96'] = '\u062A';
  34437. t['\uFE97'] = '\u062A';
  34438. t['\uFE98'] = '\u062A';
  34439. t['\uFE99'] = '\u062B';
  34440. t['\uFE9A'] = '\u062B';
  34441. t['\uFE9B'] = '\u062B';
  34442. t['\uFE9C'] = '\u062B';
  34443. t['\uFE9D'] = '\u062C';
  34444. t['\uFE9E'] = '\u062C';
  34445. t['\uFE9F'] = '\u062C';
  34446. t['\uFEA0'] = '\u062C';
  34447. t['\uFEA1'] = '\u062D';
  34448. t['\uFEA2'] = '\u062D';
  34449. t['\uFEA3'] = '\u062D';
  34450. t['\uFEA4'] = '\u062D';
  34451. t['\uFEA5'] = '\u062E';
  34452. t['\uFEA6'] = '\u062E';
  34453. t['\uFEA7'] = '\u062E';
  34454. t['\uFEA8'] = '\u062E';
  34455. t['\uFEA9'] = '\u062F';
  34456. t['\uFEAA'] = '\u062F';
  34457. t['\uFEAB'] = '\u0630';
  34458. t['\uFEAC'] = '\u0630';
  34459. t['\uFEAD'] = '\u0631';
  34460. t['\uFEAE'] = '\u0631';
  34461. t['\uFEAF'] = '\u0632';
  34462. t['\uFEB0'] = '\u0632';
  34463. t['\uFEB1'] = '\u0633';
  34464. t['\uFEB2'] = '\u0633';
  34465. t['\uFEB3'] = '\u0633';
  34466. t['\uFEB4'] = '\u0633';
  34467. t['\uFEB5'] = '\u0634';
  34468. t['\uFEB6'] = '\u0634';
  34469. t['\uFEB7'] = '\u0634';
  34470. t['\uFEB8'] = '\u0634';
  34471. t['\uFEB9'] = '\u0635';
  34472. t['\uFEBA'] = '\u0635';
  34473. t['\uFEBB'] = '\u0635';
  34474. t['\uFEBC'] = '\u0635';
  34475. t['\uFEBD'] = '\u0636';
  34476. t['\uFEBE'] = '\u0636';
  34477. t['\uFEBF'] = '\u0636';
  34478. t['\uFEC0'] = '\u0636';
  34479. t['\uFEC1'] = '\u0637';
  34480. t['\uFEC2'] = '\u0637';
  34481. t['\uFEC3'] = '\u0637';
  34482. t['\uFEC4'] = '\u0637';
  34483. t['\uFEC5'] = '\u0638';
  34484. t['\uFEC6'] = '\u0638';
  34485. t['\uFEC7'] = '\u0638';
  34486. t['\uFEC8'] = '\u0638';
  34487. t['\uFEC9'] = '\u0639';
  34488. t['\uFECA'] = '\u0639';
  34489. t['\uFECB'] = '\u0639';
  34490. t['\uFECC'] = '\u0639';
  34491. t['\uFECD'] = '\u063A';
  34492. t['\uFECE'] = '\u063A';
  34493. t['\uFECF'] = '\u063A';
  34494. t['\uFED0'] = '\u063A';
  34495. t['\uFED1'] = '\u0641';
  34496. t['\uFED2'] = '\u0641';
  34497. t['\uFED3'] = '\u0641';
  34498. t['\uFED4'] = '\u0641';
  34499. t['\uFED5'] = '\u0642';
  34500. t['\uFED6'] = '\u0642';
  34501. t['\uFED7'] = '\u0642';
  34502. t['\uFED8'] = '\u0642';
  34503. t['\uFED9'] = '\u0643';
  34504. t['\uFEDA'] = '\u0643';
  34505. t['\uFEDB'] = '\u0643';
  34506. t['\uFEDC'] = '\u0643';
  34507. t['\uFEDD'] = '\u0644';
  34508. t['\uFEDE'] = '\u0644';
  34509. t['\uFEDF'] = '\u0644';
  34510. t['\uFEE0'] = '\u0644';
  34511. t['\uFEE1'] = '\u0645';
  34512. t['\uFEE2'] = '\u0645';
  34513. t['\uFEE3'] = '\u0645';
  34514. t['\uFEE4'] = '\u0645';
  34515. t['\uFEE5'] = '\u0646';
  34516. t['\uFEE6'] = '\u0646';
  34517. t['\uFEE7'] = '\u0646';
  34518. t['\uFEE8'] = '\u0646';
  34519. t['\uFEE9'] = '\u0647';
  34520. t['\uFEEA'] = '\u0647';
  34521. t['\uFEEB'] = '\u0647';
  34522. t['\uFEEC'] = '\u0647';
  34523. t['\uFEED'] = '\u0648';
  34524. t['\uFEEE'] = '\u0648';
  34525. t['\uFEEF'] = '\u0649';
  34526. t['\uFEF0'] = '\u0649';
  34527. t['\uFEF1'] = '\u064A';
  34528. t['\uFEF2'] = '\u064A';
  34529. t['\uFEF3'] = '\u064A';
  34530. t['\uFEF4'] = '\u064A';
  34531. t['\uFEF5'] = '\u0644\u0622';
  34532. t['\uFEF6'] = '\u0644\u0622';
  34533. t['\uFEF7'] = '\u0644\u0623';
  34534. t['\uFEF8'] = '\u0644\u0623';
  34535. t['\uFEF9'] = '\u0644\u0625';
  34536. t['\uFEFA'] = '\u0644\u0625';
  34537. t['\uFEFB'] = '\u0644\u0627';
  34538. t['\uFEFC'] = '\u0644\u0627';
  34539. });
  34540. function reverseIfRtl(chars) {
  34541. var charsLength = chars.length;
  34542. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  34543. return chars;
  34544. }
  34545. var s = '';
  34546. for (var ii = charsLength - 1; ii >= 0; ii--) {
  34547. s += chars[ii];
  34548. }
  34549. return s;
  34550. }
  34551. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  34552. exports.reverseIfRtl = reverseIfRtl;
  34553. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  34554. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  34555. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  34556. /***/ }),
  34557. /* 19 */
  34558. /***/ (function(module, exports, __w_pdfjs_require__) {
  34559. "use strict";
  34560. var sharedUtil = __w_pdfjs_require__(0);
  34561. var coreWorker = __w_pdfjs_require__(8);
  34562. var OK_RESPONSE = 200;
  34563. var PARTIAL_CONTENT_RESPONSE = 206;
  34564. function NetworkManager(url, args) {
  34565. this.url = url;
  34566. args = args || {};
  34567. this.isHttp = /^https?:/i.test(url);
  34568. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  34569. this.withCredentials = args.withCredentials || false;
  34570. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  34571. return new XMLHttpRequest();
  34572. };
  34573. this.currXhrId = 0;
  34574. this.pendingRequests = Object.create(null);
  34575. this.loadedRequests = Object.create(null);
  34576. }
  34577. function getArrayBuffer(xhr) {
  34578. var data = xhr.response;
  34579. if (typeof data !== 'string') {
  34580. return data;
  34581. }
  34582. var length = data.length;
  34583. var array = new Uint8Array(length);
  34584. for (var i = 0; i < length; i++) {
  34585. array[i] = data.charCodeAt(i) & 0xFF;
  34586. }
  34587. return array.buffer;
  34588. }
  34589. var supportsMozChunked = function supportsMozChunkedClosure() {
  34590. try {
  34591. var x = new XMLHttpRequest();
  34592. x.open('GET', 'https://example.com');
  34593. x.responseType = 'moz-chunked-arraybuffer';
  34594. return x.responseType === 'moz-chunked-arraybuffer';
  34595. } catch (e) {
  34596. return false;
  34597. }
  34598. }();
  34599. NetworkManager.prototype = {
  34600. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  34601. var args = {
  34602. begin: begin,
  34603. end: end
  34604. };
  34605. for (var prop in listeners) {
  34606. args[prop] = listeners[prop];
  34607. }
  34608. return this.request(args);
  34609. },
  34610. requestFull: function NetworkManager_requestFull(listeners) {
  34611. return this.request(listeners);
  34612. },
  34613. request: function NetworkManager_request(args) {
  34614. var xhr = this.getXhr();
  34615. var xhrId = this.currXhrId++;
  34616. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  34617. xhr.open('GET', this.url);
  34618. xhr.withCredentials = this.withCredentials;
  34619. for (var property in this.httpHeaders) {
  34620. var value = this.httpHeaders[property];
  34621. if (typeof value === 'undefined') {
  34622. continue;
  34623. }
  34624. xhr.setRequestHeader(property, value);
  34625. }
  34626. if (this.isHttp && 'begin' in args && 'end' in args) {
  34627. var rangeStr = args.begin + '-' + (args.end - 1);
  34628. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  34629. pendingRequest.expectedStatus = 206;
  34630. } else {
  34631. pendingRequest.expectedStatus = 200;
  34632. }
  34633. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  34634. if (useMozChunkedLoading) {
  34635. xhr.responseType = 'moz-chunked-arraybuffer';
  34636. pendingRequest.onProgressiveData = args.onProgressiveData;
  34637. pendingRequest.mozChunked = true;
  34638. } else {
  34639. xhr.responseType = 'arraybuffer';
  34640. }
  34641. if (args.onError) {
  34642. xhr.onerror = function (evt) {
  34643. args.onError(xhr.status);
  34644. };
  34645. }
  34646. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  34647. xhr.onprogress = this.onProgress.bind(this, xhrId);
  34648. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  34649. pendingRequest.onDone = args.onDone;
  34650. pendingRequest.onError = args.onError;
  34651. pendingRequest.onProgress = args.onProgress;
  34652. xhr.send(null);
  34653. return xhrId;
  34654. },
  34655. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  34656. var pendingRequest = this.pendingRequests[xhrId];
  34657. if (!pendingRequest) {
  34658. return;
  34659. }
  34660. if (pendingRequest.mozChunked) {
  34661. var chunk = getArrayBuffer(pendingRequest.xhr);
  34662. pendingRequest.onProgressiveData(chunk);
  34663. }
  34664. var onProgress = pendingRequest.onProgress;
  34665. if (onProgress) {
  34666. onProgress(evt);
  34667. }
  34668. },
  34669. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  34670. var pendingRequest = this.pendingRequests[xhrId];
  34671. if (!pendingRequest) {
  34672. return;
  34673. }
  34674. var xhr = pendingRequest.xhr;
  34675. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  34676. pendingRequest.onHeadersReceived();
  34677. delete pendingRequest.onHeadersReceived;
  34678. }
  34679. if (xhr.readyState !== 4) {
  34680. return;
  34681. }
  34682. if (!(xhrId in this.pendingRequests)) {
  34683. return;
  34684. }
  34685. delete this.pendingRequests[xhrId];
  34686. if (xhr.status === 0 && this.isHttp) {
  34687. if (pendingRequest.onError) {
  34688. pendingRequest.onError(xhr.status);
  34689. }
  34690. return;
  34691. }
  34692. var xhrStatus = xhr.status || OK_RESPONSE;
  34693. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  34694. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  34695. if (pendingRequest.onError) {
  34696. pendingRequest.onError(xhr.status);
  34697. }
  34698. return;
  34699. }
  34700. this.loadedRequests[xhrId] = true;
  34701. var chunk = getArrayBuffer(xhr);
  34702. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  34703. var rangeHeader = xhr.getResponseHeader('Content-Range');
  34704. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  34705. var begin = parseInt(matches[1], 10);
  34706. pendingRequest.onDone({
  34707. begin: begin,
  34708. chunk: chunk
  34709. });
  34710. } else if (pendingRequest.onProgressiveData) {
  34711. pendingRequest.onDone(null);
  34712. } else if (chunk) {
  34713. pendingRequest.onDone({
  34714. begin: 0,
  34715. chunk: chunk
  34716. });
  34717. } else if (pendingRequest.onError) {
  34718. pendingRequest.onError(xhr.status);
  34719. }
  34720. },
  34721. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  34722. for (var xhrId in this.pendingRequests) {
  34723. return true;
  34724. }
  34725. return false;
  34726. },
  34727. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  34728. return this.pendingRequests[xhrId].xhr;
  34729. },
  34730. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  34731. return !!this.pendingRequests[xhrId].onProgressiveData;
  34732. },
  34733. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  34734. return xhrId in this.pendingRequests;
  34735. },
  34736. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  34737. return xhrId in this.loadedRequests;
  34738. },
  34739. abortAllRequests: function NetworkManager_abortAllRequests() {
  34740. for (var xhrId in this.pendingRequests) {
  34741. this.abortRequest(xhrId | 0);
  34742. }
  34743. },
  34744. abortRequest: function NetworkManager_abortRequest(xhrId) {
  34745. var xhr = this.pendingRequests[xhrId].xhr;
  34746. delete this.pendingRequests[xhrId];
  34747. xhr.abort();
  34748. }
  34749. };
  34750. var assert = sharedUtil.assert;
  34751. var createPromiseCapability = sharedUtil.createPromiseCapability;
  34752. var isInt = sharedUtil.isInt;
  34753. var MissingPDFException = sharedUtil.MissingPDFException;
  34754. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  34755. function PDFNetworkStream(options) {
  34756. this._options = options;
  34757. var source = options.source;
  34758. this._manager = new NetworkManager(source.url, {
  34759. httpHeaders: source.httpHeaders,
  34760. withCredentials: source.withCredentials
  34761. });
  34762. this._rangeChunkSize = source.rangeChunkSize;
  34763. this._fullRequestReader = null;
  34764. this._rangeRequestReaders = [];
  34765. }
  34766. PDFNetworkStream.prototype = {
  34767. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  34768. var i = this._rangeRequestReaders.indexOf(reader);
  34769. if (i >= 0) {
  34770. this._rangeRequestReaders.splice(i, 1);
  34771. }
  34772. },
  34773. getFullReader: function PDFNetworkStream_getFullReader() {
  34774. assert(!this._fullRequestReader);
  34775. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  34776. return this._fullRequestReader;
  34777. },
  34778. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  34779. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  34780. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  34781. this._rangeRequestReaders.push(reader);
  34782. return reader;
  34783. },
  34784. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  34785. if (this._fullRequestReader) {
  34786. this._fullRequestReader.cancel(reason);
  34787. }
  34788. var readers = this._rangeRequestReaders.slice(0);
  34789. readers.forEach(function (reader) {
  34790. reader.cancel(reason);
  34791. });
  34792. }
  34793. };
  34794. function PDFNetworkStreamFullRequestReader(manager, options) {
  34795. this._manager = manager;
  34796. var source = options.source;
  34797. var args = {
  34798. onHeadersReceived: this._onHeadersReceived.bind(this),
  34799. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  34800. onDone: this._onDone.bind(this),
  34801. onError: this._onError.bind(this),
  34802. onProgress: this._onProgress.bind(this)
  34803. };
  34804. this._url = source.url;
  34805. this._fullRequestId = manager.requestFull(args);
  34806. this._headersReceivedCapability = createPromiseCapability();
  34807. this._disableRange = options.disableRange || false;
  34808. this._contentLength = source.length;
  34809. this._rangeChunkSize = source.rangeChunkSize;
  34810. if (!this._rangeChunkSize && !this._disableRange) {
  34811. this._disableRange = true;
  34812. }
  34813. this._isStreamingSupported = false;
  34814. this._isRangeSupported = false;
  34815. this._cachedChunks = [];
  34816. this._requests = [];
  34817. this._done = false;
  34818. this._storedError = undefined;
  34819. this.onProgress = null;
  34820. }
  34821. PDFNetworkStreamFullRequestReader.prototype = {
  34822. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  34823. if (this._disableRange) {
  34824. return false;
  34825. }
  34826. var networkManager = this._manager;
  34827. if (!networkManager.isHttp) {
  34828. return false;
  34829. }
  34830. var fullRequestXhrId = this._fullRequestId;
  34831. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  34832. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  34833. return false;
  34834. }
  34835. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  34836. if (contentEncoding !== 'identity') {
  34837. return false;
  34838. }
  34839. var length = fullRequestXhr.getResponseHeader('Content-Length');
  34840. length = parseInt(length, 10);
  34841. if (!isInt(length)) {
  34842. return false;
  34843. }
  34844. this._contentLength = length;
  34845. if (length <= 2 * this._rangeChunkSize) {
  34846. return false;
  34847. }
  34848. return true;
  34849. },
  34850. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  34851. if (this._validateRangeRequestCapabilities()) {
  34852. this._isRangeSupported = true;
  34853. }
  34854. var networkManager = this._manager;
  34855. var fullRequestXhrId = this._fullRequestId;
  34856. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  34857. this._isStreamingSupported = true;
  34858. } else if (this._isRangeSupported) {
  34859. networkManager.abortRequest(fullRequestXhrId);
  34860. }
  34861. this._headersReceivedCapability.resolve();
  34862. },
  34863. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  34864. if (this._requests.length > 0) {
  34865. var requestCapability = this._requests.shift();
  34866. requestCapability.resolve({
  34867. value: chunk,
  34868. done: false
  34869. });
  34870. } else {
  34871. this._cachedChunks.push(chunk);
  34872. }
  34873. },
  34874. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  34875. if (args) {
  34876. this._onProgressiveData(args.chunk);
  34877. }
  34878. this._done = true;
  34879. if (this._cachedChunks.length > 0) {
  34880. return;
  34881. }
  34882. this._requests.forEach(function (requestCapability) {
  34883. requestCapability.resolve({
  34884. value: undefined,
  34885. done: true
  34886. });
  34887. });
  34888. this._requests = [];
  34889. },
  34890. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  34891. var url = this._url;
  34892. var exception;
  34893. if (status === 404 || status === 0 && /^file:/.test(url)) {
  34894. exception = new MissingPDFException('Missing PDF "' + url + '".');
  34895. } else {
  34896. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  34897. }
  34898. this._storedError = exception;
  34899. this._headersReceivedCapability.reject(exception);
  34900. this._requests.forEach(function (requestCapability) {
  34901. requestCapability.reject(exception);
  34902. });
  34903. this._requests = [];
  34904. this._cachedChunks = [];
  34905. },
  34906. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  34907. if (this.onProgress) {
  34908. this.onProgress({
  34909. loaded: data.loaded,
  34910. total: data.lengthComputable ? data.total : this._contentLength
  34911. });
  34912. }
  34913. },
  34914. get isRangeSupported() {
  34915. return this._isRangeSupported;
  34916. },
  34917. get isStreamingSupported() {
  34918. return this._isStreamingSupported;
  34919. },
  34920. get contentLength() {
  34921. return this._contentLength;
  34922. },
  34923. get headersReady() {
  34924. return this._headersReceivedCapability.promise;
  34925. },
  34926. read: function PDFNetworkStreamFullRequestReader_read() {
  34927. if (this._storedError) {
  34928. return Promise.reject(this._storedError);
  34929. }
  34930. if (this._cachedChunks.length > 0) {
  34931. var chunk = this._cachedChunks.shift();
  34932. return Promise.resolve(chunk);
  34933. }
  34934. if (this._done) {
  34935. return Promise.resolve({
  34936. value: undefined,
  34937. done: true
  34938. });
  34939. }
  34940. var requestCapability = createPromiseCapability();
  34941. this._requests.push(requestCapability);
  34942. return requestCapability.promise;
  34943. },
  34944. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  34945. this._done = true;
  34946. this._headersReceivedCapability.reject(reason);
  34947. this._requests.forEach(function (requestCapability) {
  34948. requestCapability.resolve({
  34949. value: undefined,
  34950. done: true
  34951. });
  34952. });
  34953. this._requests = [];
  34954. if (this._manager.isPendingRequest(this._fullRequestId)) {
  34955. this._manager.abortRequest(this._fullRequestId);
  34956. }
  34957. this._fullRequestReader = null;
  34958. }
  34959. };
  34960. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  34961. this._manager = manager;
  34962. var args = {
  34963. onDone: this._onDone.bind(this),
  34964. onProgress: this._onProgress.bind(this)
  34965. };
  34966. this._requestId = manager.requestRange(begin, end, args);
  34967. this._requests = [];
  34968. this._queuedChunk = null;
  34969. this._done = false;
  34970. this.onProgress = null;
  34971. this.onClosed = null;
  34972. }
  34973. PDFNetworkStreamRangeRequestReader.prototype = {
  34974. _close: function PDFNetworkStreamRangeRequestReader_close() {
  34975. if (this.onClosed) {
  34976. this.onClosed(this);
  34977. }
  34978. },
  34979. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  34980. var chunk = data.chunk;
  34981. if (this._requests.length > 0) {
  34982. var requestCapability = this._requests.shift();
  34983. requestCapability.resolve({
  34984. value: chunk,
  34985. done: false
  34986. });
  34987. } else {
  34988. this._queuedChunk = chunk;
  34989. }
  34990. this._done = true;
  34991. this._requests.forEach(function (requestCapability) {
  34992. requestCapability.resolve({
  34993. value: undefined,
  34994. done: true
  34995. });
  34996. });
  34997. this._requests = [];
  34998. this._close();
  34999. },
  35000. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  35001. if (!this.isStreamingSupported && this.onProgress) {
  35002. this.onProgress({ loaded: evt.loaded });
  35003. }
  35004. },
  35005. get isStreamingSupported() {
  35006. return false;
  35007. },
  35008. read: function PDFNetworkStreamRangeRequestReader_read() {
  35009. if (this._queuedChunk !== null) {
  35010. var chunk = this._queuedChunk;
  35011. this._queuedChunk = null;
  35012. return Promise.resolve({
  35013. value: chunk,
  35014. done: false
  35015. });
  35016. }
  35017. if (this._done) {
  35018. return Promise.resolve({
  35019. value: undefined,
  35020. done: true
  35021. });
  35022. }
  35023. var requestCapability = createPromiseCapability();
  35024. this._requests.push(requestCapability);
  35025. return requestCapability.promise;
  35026. },
  35027. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  35028. this._done = true;
  35029. this._requests.forEach(function (requestCapability) {
  35030. requestCapability.resolve({
  35031. value: undefined,
  35032. done: true
  35033. });
  35034. });
  35035. this._requests = [];
  35036. if (this._manager.isPendingRequest(this._requestId)) {
  35037. this._manager.abortRequest(this._requestId);
  35038. }
  35039. this._close();
  35040. }
  35041. };
  35042. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  35043. exports.PDFNetworkStream = PDFNetworkStream;
  35044. exports.NetworkManager = NetworkManager;
  35045. /***/ }),
  35046. /* 20 */
  35047. /***/ (function(module, exports, __w_pdfjs_require__) {
  35048. "use strict";
  35049. var sharedUtil = __w_pdfjs_require__(0);
  35050. var corePrimitives = __w_pdfjs_require__(1);
  35051. var coreStream = __w_pdfjs_require__(2);
  35052. var coreColorSpace = __w_pdfjs_require__(3);
  35053. var coreObj = __w_pdfjs_require__(16);
  35054. var coreEvaluator = __w_pdfjs_require__(14);
  35055. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  35056. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  35057. var AnnotationFlag = sharedUtil.AnnotationFlag;
  35058. var AnnotationType = sharedUtil.AnnotationType;
  35059. var OPS = sharedUtil.OPS;
  35060. var Util = sharedUtil.Util;
  35061. var isArray = sharedUtil.isArray;
  35062. var isInt = sharedUtil.isInt;
  35063. var stringToBytes = sharedUtil.stringToBytes;
  35064. var stringToPDFString = sharedUtil.stringToPDFString;
  35065. var warn = sharedUtil.warn;
  35066. var Dict = corePrimitives.Dict;
  35067. var isDict = corePrimitives.isDict;
  35068. var isName = corePrimitives.isName;
  35069. var isRef = corePrimitives.isRef;
  35070. var isStream = corePrimitives.isStream;
  35071. var Stream = coreStream.Stream;
  35072. var ColorSpace = coreColorSpace.ColorSpace;
  35073. var Catalog = coreObj.Catalog;
  35074. var ObjectLoader = coreObj.ObjectLoader;
  35075. var FileSpec = coreObj.FileSpec;
  35076. var OperatorList = coreEvaluator.OperatorList;
  35077. function AnnotationFactory() {
  35078. }
  35079. AnnotationFactory.prototype = {
  35080. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  35081. var dict = xref.fetchIfRef(ref);
  35082. if (!isDict(dict)) {
  35083. return;
  35084. }
  35085. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  35086. var subtype = dict.get('Subtype');
  35087. subtype = isName(subtype) ? subtype.name : null;
  35088. var parameters = {
  35089. xref: xref,
  35090. dict: dict,
  35091. ref: isRef(ref) ? ref : null,
  35092. subtype: subtype,
  35093. id: id,
  35094. pdfManager: pdfManager
  35095. };
  35096. switch (subtype) {
  35097. case 'Link':
  35098. return new LinkAnnotation(parameters);
  35099. case 'Text':
  35100. return new TextAnnotation(parameters);
  35101. case 'Widget':
  35102. var fieldType = Util.getInheritableProperty(dict, 'FT');
  35103. fieldType = isName(fieldType) ? fieldType.name : null;
  35104. switch (fieldType) {
  35105. case 'Tx':
  35106. return new TextWidgetAnnotation(parameters);
  35107. case 'Btn':
  35108. return new ButtonWidgetAnnotation(parameters);
  35109. case 'Ch':
  35110. return new ChoiceWidgetAnnotation(parameters);
  35111. }
  35112. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  35113. return new WidgetAnnotation(parameters);
  35114. case 'Popup':
  35115. return new PopupAnnotation(parameters);
  35116. case 'Highlight':
  35117. return new HighlightAnnotation(parameters);
  35118. case 'Underline':
  35119. return new UnderlineAnnotation(parameters);
  35120. case 'Squiggly':
  35121. return new SquigglyAnnotation(parameters);
  35122. case 'StrikeOut':
  35123. return new StrikeOutAnnotation(parameters);
  35124. case 'FileAttachment':
  35125. return new FileAttachmentAnnotation(parameters);
  35126. default:
  35127. if (!subtype) {
  35128. warn('Annotation is missing the required /Subtype.');
  35129. } else {
  35130. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  35131. }
  35132. return new Annotation(parameters);
  35133. }
  35134. }
  35135. };
  35136. var Annotation = function AnnotationClosure() {
  35137. function getTransformMatrix(rect, bbox, matrix) {
  35138. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  35139. var minX = bounds[0];
  35140. var minY = bounds[1];
  35141. var maxX = bounds[2];
  35142. var maxY = bounds[3];
  35143. if (minX === maxX || minY === maxY) {
  35144. return [
  35145. 1,
  35146. 0,
  35147. 0,
  35148. 1,
  35149. rect[0],
  35150. rect[1]
  35151. ];
  35152. }
  35153. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  35154. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  35155. return [
  35156. xRatio,
  35157. 0,
  35158. 0,
  35159. yRatio,
  35160. rect[0] - minX * xRatio,
  35161. rect[1] - minY * yRatio
  35162. ];
  35163. }
  35164. function Annotation(params) {
  35165. var dict = params.dict;
  35166. this.setFlags(dict.get('F'));
  35167. this.setRectangle(dict.getArray('Rect'));
  35168. this.setColor(dict.getArray('C'));
  35169. this.setBorderStyle(dict);
  35170. this.setAppearance(dict);
  35171. this.data = {};
  35172. this.data.id = params.id;
  35173. this.data.subtype = params.subtype;
  35174. this.data.annotationFlags = this.flags;
  35175. this.data.rect = this.rectangle;
  35176. this.data.color = this.color;
  35177. this.data.borderStyle = this.borderStyle;
  35178. this.data.hasAppearance = !!this.appearance;
  35179. }
  35180. Annotation.prototype = {
  35181. _hasFlag: function Annotation_hasFlag(flags, flag) {
  35182. return !!(flags & flag);
  35183. },
  35184. _isViewable: function Annotation_isViewable(flags) {
  35185. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  35186. },
  35187. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  35188. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  35189. },
  35190. get viewable() {
  35191. if (this.flags === 0) {
  35192. return true;
  35193. }
  35194. return this._isViewable(this.flags);
  35195. },
  35196. get printable() {
  35197. if (this.flags === 0) {
  35198. return false;
  35199. }
  35200. return this._isPrintable(this.flags);
  35201. },
  35202. setFlags: function Annotation_setFlags(flags) {
  35203. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  35204. },
  35205. hasFlag: function Annotation_hasFlag(flag) {
  35206. return this._hasFlag(this.flags, flag);
  35207. },
  35208. setRectangle: function Annotation_setRectangle(rectangle) {
  35209. if (isArray(rectangle) && rectangle.length === 4) {
  35210. this.rectangle = Util.normalizeRect(rectangle);
  35211. } else {
  35212. this.rectangle = [
  35213. 0,
  35214. 0,
  35215. 0,
  35216. 0
  35217. ];
  35218. }
  35219. },
  35220. setColor: function Annotation_setColor(color) {
  35221. var rgbColor = new Uint8Array(3);
  35222. if (!isArray(color)) {
  35223. this.color = rgbColor;
  35224. return;
  35225. }
  35226. switch (color.length) {
  35227. case 0:
  35228. this.color = null;
  35229. break;
  35230. case 1:
  35231. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  35232. this.color = rgbColor;
  35233. break;
  35234. case 3:
  35235. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  35236. this.color = rgbColor;
  35237. break;
  35238. case 4:
  35239. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  35240. this.color = rgbColor;
  35241. break;
  35242. default:
  35243. this.color = rgbColor;
  35244. break;
  35245. }
  35246. },
  35247. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  35248. this.borderStyle = new AnnotationBorderStyle();
  35249. if (!isDict(borderStyle)) {
  35250. return;
  35251. }
  35252. if (borderStyle.has('BS')) {
  35253. var dict = borderStyle.get('BS');
  35254. var dictType = dict.get('Type');
  35255. if (!dictType || isName(dictType, 'Border')) {
  35256. this.borderStyle.setWidth(dict.get('W'));
  35257. this.borderStyle.setStyle(dict.get('S'));
  35258. this.borderStyle.setDashArray(dict.getArray('D'));
  35259. }
  35260. } else if (borderStyle.has('Border')) {
  35261. var array = borderStyle.getArray('Border');
  35262. if (isArray(array) && array.length >= 3) {
  35263. this.borderStyle.setHorizontalCornerRadius(array[0]);
  35264. this.borderStyle.setVerticalCornerRadius(array[1]);
  35265. this.borderStyle.setWidth(array[2]);
  35266. if (array.length === 4) {
  35267. this.borderStyle.setDashArray(array[3]);
  35268. }
  35269. }
  35270. } else {
  35271. this.borderStyle.setWidth(0);
  35272. }
  35273. },
  35274. setAppearance: function Annotation_setAppearance(dict) {
  35275. this.appearance = null;
  35276. var appearanceStates = dict.get('AP');
  35277. if (!isDict(appearanceStates)) {
  35278. return;
  35279. }
  35280. var normalAppearanceState = appearanceStates.get('N');
  35281. if (isStream(normalAppearanceState)) {
  35282. this.appearance = normalAppearanceState;
  35283. return;
  35284. }
  35285. if (!isDict(normalAppearanceState)) {
  35286. return;
  35287. }
  35288. var as = dict.get('AS');
  35289. if (!isName(as) || !normalAppearanceState.has(as.name)) {
  35290. return;
  35291. }
  35292. this.appearance = normalAppearanceState.get(as.name);
  35293. },
  35294. _preparePopup: function Annotation_preparePopup(dict) {
  35295. if (!dict.has('C')) {
  35296. this.data.color = null;
  35297. }
  35298. this.data.hasPopup = dict.has('Popup');
  35299. this.data.title = stringToPDFString(dict.get('T') || '');
  35300. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  35301. },
  35302. loadResources: function Annotation_loadResources(keys) {
  35303. return new Promise(function (resolve, reject) {
  35304. this.appearance.dict.getAsync('Resources').then(function (resources) {
  35305. if (!resources) {
  35306. resolve();
  35307. return;
  35308. }
  35309. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  35310. objectLoader.load().then(function () {
  35311. resolve(resources);
  35312. }, reject);
  35313. }, reject);
  35314. }.bind(this));
  35315. },
  35316. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  35317. if (!this.appearance) {
  35318. return Promise.resolve(new OperatorList());
  35319. }
  35320. var data = this.data;
  35321. var appearanceDict = this.appearance.dict;
  35322. var resourcesPromise = this.loadResources([
  35323. 'ExtGState',
  35324. 'ColorSpace',
  35325. 'Pattern',
  35326. 'Shading',
  35327. 'XObject',
  35328. 'Font'
  35329. ]);
  35330. var bbox = appearanceDict.getArray('BBox') || [
  35331. 0,
  35332. 0,
  35333. 1,
  35334. 1
  35335. ];
  35336. var matrix = appearanceDict.getArray('Matrix') || [
  35337. 1,
  35338. 0,
  35339. 0,
  35340. 1,
  35341. 0,
  35342. 0
  35343. ];
  35344. var transform = getTransformMatrix(data.rect, bbox, matrix);
  35345. var self = this;
  35346. return resourcesPromise.then(function (resources) {
  35347. var opList = new OperatorList();
  35348. opList.addOp(OPS.beginAnnotation, [
  35349. data.rect,
  35350. transform,
  35351. matrix
  35352. ]);
  35353. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  35354. opList.addOp(OPS.endAnnotation, []);
  35355. self.appearance.reset();
  35356. return opList;
  35357. });
  35358. });
  35359. }
  35360. };
  35361. return Annotation;
  35362. }();
  35363. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  35364. function AnnotationBorderStyle() {
  35365. this.width = 1;
  35366. this.style = AnnotationBorderStyleType.SOLID;
  35367. this.dashArray = [3];
  35368. this.horizontalCornerRadius = 0;
  35369. this.verticalCornerRadius = 0;
  35370. }
  35371. AnnotationBorderStyle.prototype = {
  35372. setWidth: function AnnotationBorderStyle_setWidth(width) {
  35373. if (width === (width | 0)) {
  35374. this.width = width;
  35375. }
  35376. },
  35377. setStyle: function AnnotationBorderStyle_setStyle(style) {
  35378. if (!style) {
  35379. return;
  35380. }
  35381. switch (style.name) {
  35382. case 'S':
  35383. this.style = AnnotationBorderStyleType.SOLID;
  35384. break;
  35385. case 'D':
  35386. this.style = AnnotationBorderStyleType.DASHED;
  35387. break;
  35388. case 'B':
  35389. this.style = AnnotationBorderStyleType.BEVELED;
  35390. break;
  35391. case 'I':
  35392. this.style = AnnotationBorderStyleType.INSET;
  35393. break;
  35394. case 'U':
  35395. this.style = AnnotationBorderStyleType.UNDERLINE;
  35396. break;
  35397. default:
  35398. break;
  35399. }
  35400. },
  35401. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  35402. if (isArray(dashArray) && dashArray.length > 0) {
  35403. var isValid = true;
  35404. var allZeros = true;
  35405. for (var i = 0, len = dashArray.length; i < len; i++) {
  35406. var element = dashArray[i];
  35407. var validNumber = +element >= 0;
  35408. if (!validNumber) {
  35409. isValid = false;
  35410. break;
  35411. } else if (element > 0) {
  35412. allZeros = false;
  35413. }
  35414. }
  35415. if (isValid && !allZeros) {
  35416. this.dashArray = dashArray;
  35417. } else {
  35418. this.width = 0;
  35419. }
  35420. } else if (dashArray) {
  35421. this.width = 0;
  35422. }
  35423. },
  35424. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  35425. if (radius === (radius | 0)) {
  35426. this.horizontalCornerRadius = radius;
  35427. }
  35428. },
  35429. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  35430. if (radius === (radius | 0)) {
  35431. this.verticalCornerRadius = radius;
  35432. }
  35433. }
  35434. };
  35435. return AnnotationBorderStyle;
  35436. }();
  35437. var WidgetAnnotation = function WidgetAnnotationClosure() {
  35438. function WidgetAnnotation(params) {
  35439. Annotation.call(this, params);
  35440. var dict = params.dict;
  35441. var data = this.data;
  35442. data.annotationType = AnnotationType.WIDGET;
  35443. data.fieldName = this._constructFieldName(dict);
  35444. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  35445. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  35446. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  35447. var fieldType = Util.getInheritableProperty(dict, 'FT');
  35448. data.fieldType = isName(fieldType) ? fieldType.name : null;
  35449. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  35450. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  35451. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  35452. data.fieldFlags = 0;
  35453. }
  35454. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  35455. if (data.fieldType === 'Sig') {
  35456. this.setFlags(AnnotationFlag.HIDDEN);
  35457. }
  35458. }
  35459. Util.inherit(WidgetAnnotation, Annotation, {
  35460. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  35461. if (!dict.has('T') && !dict.has('Parent')) {
  35462. warn('Unknown field name, falling back to empty field name.');
  35463. return '';
  35464. }
  35465. if (!dict.has('Parent')) {
  35466. return stringToPDFString(dict.get('T'));
  35467. }
  35468. var fieldName = [];
  35469. if (dict.has('T')) {
  35470. fieldName.unshift(stringToPDFString(dict.get('T')));
  35471. }
  35472. var loopDict = dict;
  35473. while (loopDict.has('Parent')) {
  35474. loopDict = loopDict.get('Parent');
  35475. if (loopDict.has('T')) {
  35476. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  35477. }
  35478. }
  35479. return fieldName.join('.');
  35480. },
  35481. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  35482. return !!(this.data.fieldFlags & flag);
  35483. }
  35484. });
  35485. return WidgetAnnotation;
  35486. }();
  35487. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  35488. function TextWidgetAnnotation(params) {
  35489. WidgetAnnotation.call(this, params);
  35490. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  35491. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  35492. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  35493. alignment = null;
  35494. }
  35495. this.data.textAlignment = alignment;
  35496. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  35497. if (!isInt(maximumLength) || maximumLength < 0) {
  35498. maximumLength = null;
  35499. }
  35500. this.data.maxLen = maximumLength;
  35501. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  35502. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  35503. }
  35504. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  35505. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  35506. var operatorList = new OperatorList();
  35507. if (renderForms) {
  35508. return Promise.resolve(operatorList);
  35509. }
  35510. if (this.appearance) {
  35511. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  35512. }
  35513. if (!this.data.defaultAppearance) {
  35514. return Promise.resolve(operatorList);
  35515. }
  35516. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  35517. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  35518. return operatorList;
  35519. });
  35520. }
  35521. });
  35522. return TextWidgetAnnotation;
  35523. }();
  35524. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  35525. function ButtonWidgetAnnotation(params) {
  35526. WidgetAnnotation.call(this, params);
  35527. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  35528. if (this.data.checkBox) {
  35529. if (!isName(this.data.fieldValue)) {
  35530. return;
  35531. }
  35532. this.data.fieldValue = this.data.fieldValue.name;
  35533. }
  35534. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  35535. if (this.data.radioButton) {
  35536. this.data.fieldValue = this.data.buttonValue = null;
  35537. var fieldParent = params.dict.get('Parent');
  35538. if (isDict(fieldParent) && fieldParent.has('V')) {
  35539. var fieldParentValue = fieldParent.get('V');
  35540. if (isName(fieldParentValue)) {
  35541. this.data.fieldValue = fieldParentValue.name;
  35542. }
  35543. }
  35544. var appearanceStates = params.dict.get('AP');
  35545. if (!isDict(appearanceStates)) {
  35546. return;
  35547. }
  35548. var normalAppearanceState = appearanceStates.get('N');
  35549. if (!isDict(normalAppearanceState)) {
  35550. return;
  35551. }
  35552. var keys = normalAppearanceState.getKeys();
  35553. for (var i = 0, ii = keys.length; i < ii; i++) {
  35554. if (keys[i] !== 'Off') {
  35555. this.data.buttonValue = keys[i];
  35556. break;
  35557. }
  35558. }
  35559. }
  35560. }
  35561. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  35562. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  35563. var operatorList = new OperatorList();
  35564. if (renderForms) {
  35565. return Promise.resolve(operatorList);
  35566. }
  35567. if (this.appearance) {
  35568. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  35569. }
  35570. return Promise.resolve(operatorList);
  35571. }
  35572. });
  35573. return ButtonWidgetAnnotation;
  35574. }();
  35575. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  35576. function ChoiceWidgetAnnotation(params) {
  35577. WidgetAnnotation.call(this, params);
  35578. this.data.options = [];
  35579. var options = Util.getInheritableProperty(params.dict, 'Opt');
  35580. if (isArray(options)) {
  35581. var xref = params.xref;
  35582. for (var i = 0, ii = options.length; i < ii; i++) {
  35583. var option = xref.fetchIfRef(options[i]);
  35584. var isOptionArray = isArray(option);
  35585. this.data.options[i] = {
  35586. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  35587. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  35588. };
  35589. }
  35590. }
  35591. if (!isArray(this.data.fieldValue)) {
  35592. this.data.fieldValue = [this.data.fieldValue];
  35593. }
  35594. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  35595. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  35596. }
  35597. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  35598. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  35599. var operatorList = new OperatorList();
  35600. if (renderForms) {
  35601. return Promise.resolve(operatorList);
  35602. }
  35603. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  35604. }
  35605. });
  35606. return ChoiceWidgetAnnotation;
  35607. }();
  35608. var TextAnnotation = function TextAnnotationClosure() {
  35609. var DEFAULT_ICON_SIZE = 22;
  35610. function TextAnnotation(parameters) {
  35611. Annotation.call(this, parameters);
  35612. this.data.annotationType = AnnotationType.TEXT;
  35613. if (this.data.hasAppearance) {
  35614. this.data.name = 'NoIcon';
  35615. } else {
  35616. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  35617. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  35618. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  35619. }
  35620. this._preparePopup(parameters.dict);
  35621. }
  35622. Util.inherit(TextAnnotation, Annotation, {});
  35623. return TextAnnotation;
  35624. }();
  35625. var LinkAnnotation = function LinkAnnotationClosure() {
  35626. function LinkAnnotation(params) {
  35627. Annotation.call(this, params);
  35628. var data = this.data;
  35629. data.annotationType = AnnotationType.LINK;
  35630. Catalog.parseDestDictionary({
  35631. destDict: params.dict,
  35632. resultObj: data,
  35633. docBaseUrl: params.pdfManager.docBaseUrl
  35634. });
  35635. }
  35636. Util.inherit(LinkAnnotation, Annotation, {});
  35637. return LinkAnnotation;
  35638. }();
  35639. var PopupAnnotation = function PopupAnnotationClosure() {
  35640. function PopupAnnotation(parameters) {
  35641. Annotation.call(this, parameters);
  35642. this.data.annotationType = AnnotationType.POPUP;
  35643. var dict = parameters.dict;
  35644. var parentItem = dict.get('Parent');
  35645. if (!parentItem) {
  35646. warn('Popup annotation has a missing or invalid parent annotation.');
  35647. return;
  35648. }
  35649. this.data.parentId = dict.getRaw('Parent').toString();
  35650. this.data.title = stringToPDFString(parentItem.get('T') || '');
  35651. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  35652. if (!parentItem.has('C')) {
  35653. this.data.color = null;
  35654. } else {
  35655. this.setColor(parentItem.getArray('C'));
  35656. this.data.color = this.color;
  35657. }
  35658. if (!this.viewable) {
  35659. var parentFlags = parentItem.get('F');
  35660. if (this._isViewable(parentFlags)) {
  35661. this.setFlags(parentFlags);
  35662. }
  35663. }
  35664. }
  35665. Util.inherit(PopupAnnotation, Annotation, {});
  35666. return PopupAnnotation;
  35667. }();
  35668. var HighlightAnnotation = function HighlightAnnotationClosure() {
  35669. function HighlightAnnotation(parameters) {
  35670. Annotation.call(this, parameters);
  35671. this.data.annotationType = AnnotationType.HIGHLIGHT;
  35672. this._preparePopup(parameters.dict);
  35673. this.data.borderStyle.setWidth(0);
  35674. }
  35675. Util.inherit(HighlightAnnotation, Annotation, {});
  35676. return HighlightAnnotation;
  35677. }();
  35678. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  35679. function UnderlineAnnotation(parameters) {
  35680. Annotation.call(this, parameters);
  35681. this.data.annotationType = AnnotationType.UNDERLINE;
  35682. this._preparePopup(parameters.dict);
  35683. this.data.borderStyle.setWidth(0);
  35684. }
  35685. Util.inherit(UnderlineAnnotation, Annotation, {});
  35686. return UnderlineAnnotation;
  35687. }();
  35688. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  35689. function SquigglyAnnotation(parameters) {
  35690. Annotation.call(this, parameters);
  35691. this.data.annotationType = AnnotationType.SQUIGGLY;
  35692. this._preparePopup(parameters.dict);
  35693. this.data.borderStyle.setWidth(0);
  35694. }
  35695. Util.inherit(SquigglyAnnotation, Annotation, {});
  35696. return SquigglyAnnotation;
  35697. }();
  35698. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  35699. function StrikeOutAnnotation(parameters) {
  35700. Annotation.call(this, parameters);
  35701. this.data.annotationType = AnnotationType.STRIKEOUT;
  35702. this._preparePopup(parameters.dict);
  35703. this.data.borderStyle.setWidth(0);
  35704. }
  35705. Util.inherit(StrikeOutAnnotation, Annotation, {});
  35706. return StrikeOutAnnotation;
  35707. }();
  35708. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  35709. function FileAttachmentAnnotation(parameters) {
  35710. Annotation.call(this, parameters);
  35711. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  35712. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  35713. this.data.file = file.serializable;
  35714. this._preparePopup(parameters.dict);
  35715. }
  35716. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  35717. return FileAttachmentAnnotation;
  35718. }();
  35719. exports.Annotation = Annotation;
  35720. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  35721. exports.AnnotationFactory = AnnotationFactory;
  35722. /***/ }),
  35723. /* 21 */
  35724. /***/ (function(module, exports, __w_pdfjs_require__) {
  35725. "use strict";
  35726. var sharedUtil = __w_pdfjs_require__(0);
  35727. var warn = sharedUtil.warn;
  35728. var baseTypes = [
  35729. 'BN',
  35730. 'BN',
  35731. 'BN',
  35732. 'BN',
  35733. 'BN',
  35734. 'BN',
  35735. 'BN',
  35736. 'BN',
  35737. 'BN',
  35738. 'S',
  35739. 'B',
  35740. 'S',
  35741. 'WS',
  35742. 'B',
  35743. 'BN',
  35744. 'BN',
  35745. 'BN',
  35746. 'BN',
  35747. 'BN',
  35748. 'BN',
  35749. 'BN',
  35750. 'BN',
  35751. 'BN',
  35752. 'BN',
  35753. 'BN',
  35754. 'BN',
  35755. 'BN',
  35756. 'BN',
  35757. 'B',
  35758. 'B',
  35759. 'B',
  35760. 'S',
  35761. 'WS',
  35762. 'ON',
  35763. 'ON',
  35764. 'ET',
  35765. 'ET',
  35766. 'ET',
  35767. 'ON',
  35768. 'ON',
  35769. 'ON',
  35770. 'ON',
  35771. 'ON',
  35772. 'ES',
  35773. 'CS',
  35774. 'ES',
  35775. 'CS',
  35776. 'CS',
  35777. 'EN',
  35778. 'EN',
  35779. 'EN',
  35780. 'EN',
  35781. 'EN',
  35782. 'EN',
  35783. 'EN',
  35784. 'EN',
  35785. 'EN',
  35786. 'EN',
  35787. 'CS',
  35788. 'ON',
  35789. 'ON',
  35790. 'ON',
  35791. 'ON',
  35792. 'ON',
  35793. 'ON',
  35794. 'L',
  35795. 'L',
  35796. 'L',
  35797. 'L',
  35798. 'L',
  35799. 'L',
  35800. 'L',
  35801. 'L',
  35802. 'L',
  35803. 'L',
  35804. 'L',
  35805. 'L',
  35806. 'L',
  35807. 'L',
  35808. 'L',
  35809. 'L',
  35810. 'L',
  35811. 'L',
  35812. 'L',
  35813. 'L',
  35814. 'L',
  35815. 'L',
  35816. 'L',
  35817. 'L',
  35818. 'L',
  35819. 'L',
  35820. 'ON',
  35821. 'ON',
  35822. 'ON',
  35823. 'ON',
  35824. 'ON',
  35825. 'ON',
  35826. 'L',
  35827. 'L',
  35828. 'L',
  35829. 'L',
  35830. 'L',
  35831. 'L',
  35832. 'L',
  35833. 'L',
  35834. 'L',
  35835. 'L',
  35836. 'L',
  35837. 'L',
  35838. 'L',
  35839. 'L',
  35840. 'L',
  35841. 'L',
  35842. 'L',
  35843. 'L',
  35844. 'L',
  35845. 'L',
  35846. 'L',
  35847. 'L',
  35848. 'L',
  35849. 'L',
  35850. 'L',
  35851. 'L',
  35852. 'ON',
  35853. 'ON',
  35854. 'ON',
  35855. 'ON',
  35856. 'BN',
  35857. 'BN',
  35858. 'BN',
  35859. 'BN',
  35860. 'BN',
  35861. 'BN',
  35862. 'B',
  35863. 'BN',
  35864. 'BN',
  35865. 'BN',
  35866. 'BN',
  35867. 'BN',
  35868. 'BN',
  35869. 'BN',
  35870. 'BN',
  35871. 'BN',
  35872. 'BN',
  35873. 'BN',
  35874. 'BN',
  35875. 'BN',
  35876. 'BN',
  35877. 'BN',
  35878. 'BN',
  35879. 'BN',
  35880. 'BN',
  35881. 'BN',
  35882. 'BN',
  35883. 'BN',
  35884. 'BN',
  35885. 'BN',
  35886. 'BN',
  35887. 'BN',
  35888. 'BN',
  35889. 'CS',
  35890. 'ON',
  35891. 'ET',
  35892. 'ET',
  35893. 'ET',
  35894. 'ET',
  35895. 'ON',
  35896. 'ON',
  35897. 'ON',
  35898. 'ON',
  35899. 'L',
  35900. 'ON',
  35901. 'ON',
  35902. 'BN',
  35903. 'ON',
  35904. 'ON',
  35905. 'ET',
  35906. 'ET',
  35907. 'EN',
  35908. 'EN',
  35909. 'ON',
  35910. 'L',
  35911. 'ON',
  35912. 'ON',
  35913. 'ON',
  35914. 'EN',
  35915. 'L',
  35916. 'ON',
  35917. 'ON',
  35918. 'ON',
  35919. 'ON',
  35920. 'ON',
  35921. 'L',
  35922. 'L',
  35923. 'L',
  35924. 'L',
  35925. 'L',
  35926. 'L',
  35927. 'L',
  35928. 'L',
  35929. 'L',
  35930. 'L',
  35931. 'L',
  35932. 'L',
  35933. 'L',
  35934. 'L',
  35935. 'L',
  35936. 'L',
  35937. 'L',
  35938. 'L',
  35939. 'L',
  35940. 'L',
  35941. 'L',
  35942. 'L',
  35943. 'L',
  35944. 'ON',
  35945. 'L',
  35946. 'L',
  35947. 'L',
  35948. 'L',
  35949. 'L',
  35950. 'L',
  35951. 'L',
  35952. 'L',
  35953. 'L',
  35954. 'L',
  35955. 'L',
  35956. 'L',
  35957. 'L',
  35958. 'L',
  35959. 'L',
  35960. 'L',
  35961. 'L',
  35962. 'L',
  35963. 'L',
  35964. 'L',
  35965. 'L',
  35966. 'L',
  35967. 'L',
  35968. 'L',
  35969. 'L',
  35970. 'L',
  35971. 'L',
  35972. 'L',
  35973. 'L',
  35974. 'L',
  35975. 'L',
  35976. 'ON',
  35977. 'L',
  35978. 'L',
  35979. 'L',
  35980. 'L',
  35981. 'L',
  35982. 'L',
  35983. 'L',
  35984. 'L'
  35985. ];
  35986. var arabicTypes = [
  35987. 'AN',
  35988. 'AN',
  35989. 'AN',
  35990. 'AN',
  35991. 'AN',
  35992. 'AN',
  35993. 'ON',
  35994. 'ON',
  35995. 'AL',
  35996. 'ET',
  35997. 'ET',
  35998. 'AL',
  35999. 'CS',
  36000. 'AL',
  36001. 'ON',
  36002. 'ON',
  36003. 'NSM',
  36004. 'NSM',
  36005. 'NSM',
  36006. 'NSM',
  36007. 'NSM',
  36008. 'NSM',
  36009. 'NSM',
  36010. 'NSM',
  36011. 'NSM',
  36012. 'NSM',
  36013. 'NSM',
  36014. 'AL',
  36015. 'AL',
  36016. '',
  36017. 'AL',
  36018. 'AL',
  36019. 'AL',
  36020. 'AL',
  36021. 'AL',
  36022. 'AL',
  36023. 'AL',
  36024. 'AL',
  36025. 'AL',
  36026. 'AL',
  36027. 'AL',
  36028. 'AL',
  36029. 'AL',
  36030. 'AL',
  36031. 'AL',
  36032. 'AL',
  36033. 'AL',
  36034. 'AL',
  36035. 'AL',
  36036. 'AL',
  36037. 'AL',
  36038. 'AL',
  36039. 'AL',
  36040. 'AL',
  36041. 'AL',
  36042. 'AL',
  36043. 'AL',
  36044. 'AL',
  36045. 'AL',
  36046. 'AL',
  36047. 'AL',
  36048. 'AL',
  36049. 'AL',
  36050. 'AL',
  36051. 'AL',
  36052. 'AL',
  36053. 'AL',
  36054. 'AL',
  36055. 'AL',
  36056. 'AL',
  36057. 'AL',
  36058. 'AL',
  36059. 'AL',
  36060. 'AL',
  36061. 'AL',
  36062. 'NSM',
  36063. 'NSM',
  36064. 'NSM',
  36065. 'NSM',
  36066. 'NSM',
  36067. 'NSM',
  36068. 'NSM',
  36069. 'NSM',
  36070. 'NSM',
  36071. 'NSM',
  36072. 'NSM',
  36073. 'NSM',
  36074. 'NSM',
  36075. 'NSM',
  36076. 'NSM',
  36077. 'NSM',
  36078. 'NSM',
  36079. 'NSM',
  36080. 'NSM',
  36081. 'NSM',
  36082. 'NSM',
  36083. 'AN',
  36084. 'AN',
  36085. 'AN',
  36086. 'AN',
  36087. 'AN',
  36088. 'AN',
  36089. 'AN',
  36090. 'AN',
  36091. 'AN',
  36092. 'AN',
  36093. 'ET',
  36094. 'AN',
  36095. 'AN',
  36096. 'AL',
  36097. 'AL',
  36098. 'AL',
  36099. 'NSM',
  36100. 'AL',
  36101. 'AL',
  36102. 'AL',
  36103. 'AL',
  36104. 'AL',
  36105. 'AL',
  36106. 'AL',
  36107. 'AL',
  36108. 'AL',
  36109. 'AL',
  36110. 'AL',
  36111. 'AL',
  36112. 'AL',
  36113. 'AL',
  36114. 'AL',
  36115. 'AL',
  36116. 'AL',
  36117. 'AL',
  36118. 'AL',
  36119. 'AL',
  36120. 'AL',
  36121. 'AL',
  36122. 'AL',
  36123. 'AL',
  36124. 'AL',
  36125. 'AL',
  36126. 'AL',
  36127. 'AL',
  36128. 'AL',
  36129. 'AL',
  36130. 'AL',
  36131. 'AL',
  36132. 'AL',
  36133. 'AL',
  36134. 'AL',
  36135. 'AL',
  36136. 'AL',
  36137. 'AL',
  36138. 'AL',
  36139. 'AL',
  36140. 'AL',
  36141. 'AL',
  36142. 'AL',
  36143. 'AL',
  36144. 'AL',
  36145. 'AL',
  36146. 'AL',
  36147. 'AL',
  36148. 'AL',
  36149. 'AL',
  36150. 'AL',
  36151. 'AL',
  36152. 'AL',
  36153. 'AL',
  36154. 'AL',
  36155. 'AL',
  36156. 'AL',
  36157. 'AL',
  36158. 'AL',
  36159. 'AL',
  36160. 'AL',
  36161. 'AL',
  36162. 'AL',
  36163. 'AL',
  36164. 'AL',
  36165. 'AL',
  36166. 'AL',
  36167. 'AL',
  36168. 'AL',
  36169. 'AL',
  36170. 'AL',
  36171. 'AL',
  36172. 'AL',
  36173. 'AL',
  36174. 'AL',
  36175. 'AL',
  36176. 'AL',
  36177. 'AL',
  36178. 'AL',
  36179. 'AL',
  36180. 'AL',
  36181. 'AL',
  36182. 'AL',
  36183. 'AL',
  36184. 'AL',
  36185. 'AL',
  36186. 'AL',
  36187. 'AL',
  36188. 'AL',
  36189. 'AL',
  36190. 'AL',
  36191. 'AL',
  36192. 'AL',
  36193. 'AL',
  36194. 'AL',
  36195. 'AL',
  36196. 'AL',
  36197. 'AL',
  36198. 'AL',
  36199. 'AL',
  36200. 'AL',
  36201. 'NSM',
  36202. 'NSM',
  36203. 'NSM',
  36204. 'NSM',
  36205. 'NSM',
  36206. 'NSM',
  36207. 'NSM',
  36208. 'AN',
  36209. 'ON',
  36210. 'NSM',
  36211. 'NSM',
  36212. 'NSM',
  36213. 'NSM',
  36214. 'NSM',
  36215. 'NSM',
  36216. 'AL',
  36217. 'AL',
  36218. 'NSM',
  36219. 'NSM',
  36220. 'ON',
  36221. 'NSM',
  36222. 'NSM',
  36223. 'NSM',
  36224. 'NSM',
  36225. 'AL',
  36226. 'AL',
  36227. 'EN',
  36228. 'EN',
  36229. 'EN',
  36230. 'EN',
  36231. 'EN',
  36232. 'EN',
  36233. 'EN',
  36234. 'EN',
  36235. 'EN',
  36236. 'EN',
  36237. 'AL',
  36238. 'AL',
  36239. 'AL',
  36240. 'AL',
  36241. 'AL',
  36242. 'AL'
  36243. ];
  36244. function isOdd(i) {
  36245. return (i & 1) !== 0;
  36246. }
  36247. function isEven(i) {
  36248. return (i & 1) === 0;
  36249. }
  36250. function findUnequal(arr, start, value) {
  36251. for (var j = start, jj = arr.length; j < jj; ++j) {
  36252. if (arr[j] !== value) {
  36253. return j;
  36254. }
  36255. }
  36256. return j;
  36257. }
  36258. function setValues(arr, start, end, value) {
  36259. for (var j = start; j < end; ++j) {
  36260. arr[j] = value;
  36261. }
  36262. }
  36263. function reverseValues(arr, start, end) {
  36264. for (var i = start, j = end - 1; i < j; ++i, --j) {
  36265. var temp = arr[i];
  36266. arr[i] = arr[j];
  36267. arr[j] = temp;
  36268. }
  36269. }
  36270. function createBidiText(str, isLTR, vertical) {
  36271. return {
  36272. str: str,
  36273. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  36274. };
  36275. }
  36276. var chars = [];
  36277. var types = [];
  36278. function bidi(str, startLevel, vertical) {
  36279. var isLTR = true;
  36280. var strLength = str.length;
  36281. if (strLength === 0 || vertical) {
  36282. return createBidiText(str, isLTR, vertical);
  36283. }
  36284. chars.length = strLength;
  36285. types.length = strLength;
  36286. var numBidi = 0;
  36287. var i, ii;
  36288. for (i = 0; i < strLength; ++i) {
  36289. chars[i] = str.charAt(i);
  36290. var charCode = str.charCodeAt(i);
  36291. var charType = 'L';
  36292. if (charCode <= 0x00ff) {
  36293. charType = baseTypes[charCode];
  36294. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  36295. charType = 'R';
  36296. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  36297. charType = arabicTypes[charCode & 0xff];
  36298. if (!charType) {
  36299. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  36300. }
  36301. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  36302. charType = 'AL';
  36303. }
  36304. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  36305. numBidi++;
  36306. }
  36307. types[i] = charType;
  36308. }
  36309. if (numBidi === 0) {
  36310. isLTR = true;
  36311. return createBidiText(str, isLTR);
  36312. }
  36313. if (startLevel === -1) {
  36314. if (numBidi / strLength < 0.3) {
  36315. isLTR = true;
  36316. startLevel = 0;
  36317. } else {
  36318. isLTR = false;
  36319. startLevel = 1;
  36320. }
  36321. }
  36322. var levels = [];
  36323. for (i = 0; i < strLength; ++i) {
  36324. levels[i] = startLevel;
  36325. }
  36326. var e = isOdd(startLevel) ? 'R' : 'L';
  36327. var sor = e;
  36328. var eor = sor;
  36329. var lastType = sor;
  36330. for (i = 0; i < strLength; ++i) {
  36331. if (types[i] === 'NSM') {
  36332. types[i] = lastType;
  36333. } else {
  36334. lastType = types[i];
  36335. }
  36336. }
  36337. lastType = sor;
  36338. var t;
  36339. for (i = 0; i < strLength; ++i) {
  36340. t = types[i];
  36341. if (t === 'EN') {
  36342. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  36343. } else if (t === 'R' || t === 'L' || t === 'AL') {
  36344. lastType = t;
  36345. }
  36346. }
  36347. for (i = 0; i < strLength; ++i) {
  36348. t = types[i];
  36349. if (t === 'AL') {
  36350. types[i] = 'R';
  36351. }
  36352. }
  36353. for (i = 1; i < strLength - 1; ++i) {
  36354. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  36355. types[i] = 'EN';
  36356. }
  36357. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  36358. types[i] = types[i - 1];
  36359. }
  36360. }
  36361. for (i = 0; i < strLength; ++i) {
  36362. if (types[i] === 'EN') {
  36363. var j;
  36364. for (j = i - 1; j >= 0; --j) {
  36365. if (types[j] !== 'ET') {
  36366. break;
  36367. }
  36368. types[j] = 'EN';
  36369. }
  36370. for (j = i + 1; j < strLength; ++j) {
  36371. if (types[j] !== 'ET') {
  36372. break;
  36373. }
  36374. types[j] = 'EN';
  36375. }
  36376. }
  36377. }
  36378. for (i = 0; i < strLength; ++i) {
  36379. t = types[i];
  36380. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  36381. types[i] = 'ON';
  36382. }
  36383. }
  36384. lastType = sor;
  36385. for (i = 0; i < strLength; ++i) {
  36386. t = types[i];
  36387. if (t === 'EN') {
  36388. types[i] = lastType === 'L' ? 'L' : 'EN';
  36389. } else if (t === 'R' || t === 'L') {
  36390. lastType = t;
  36391. }
  36392. }
  36393. for (i = 0; i < strLength; ++i) {
  36394. if (types[i] === 'ON') {
  36395. var end = findUnequal(types, i + 1, 'ON');
  36396. var before = sor;
  36397. if (i > 0) {
  36398. before = types[i - 1];
  36399. }
  36400. var after = eor;
  36401. if (end + 1 < strLength) {
  36402. after = types[end + 1];
  36403. }
  36404. if (before !== 'L') {
  36405. before = 'R';
  36406. }
  36407. if (after !== 'L') {
  36408. after = 'R';
  36409. }
  36410. if (before === after) {
  36411. setValues(types, i, end, before);
  36412. }
  36413. i = end - 1;
  36414. }
  36415. }
  36416. for (i = 0; i < strLength; ++i) {
  36417. if (types[i] === 'ON') {
  36418. types[i] = e;
  36419. }
  36420. }
  36421. for (i = 0; i < strLength; ++i) {
  36422. t = types[i];
  36423. if (isEven(levels[i])) {
  36424. if (t === 'R') {
  36425. levels[i] += 1;
  36426. } else if (t === 'AN' || t === 'EN') {
  36427. levels[i] += 2;
  36428. }
  36429. } else {
  36430. if (t === 'L' || t === 'AN' || t === 'EN') {
  36431. levels[i] += 1;
  36432. }
  36433. }
  36434. }
  36435. var highestLevel = -1;
  36436. var lowestOddLevel = 99;
  36437. var level;
  36438. for (i = 0, ii = levels.length; i < ii; ++i) {
  36439. level = levels[i];
  36440. if (highestLevel < level) {
  36441. highestLevel = level;
  36442. }
  36443. if (lowestOddLevel > level && isOdd(level)) {
  36444. lowestOddLevel = level;
  36445. }
  36446. }
  36447. for (level = highestLevel; level >= lowestOddLevel; --level) {
  36448. var start = -1;
  36449. for (i = 0, ii = levels.length; i < ii; ++i) {
  36450. if (levels[i] < level) {
  36451. if (start >= 0) {
  36452. reverseValues(chars, start, i);
  36453. start = -1;
  36454. }
  36455. } else if (start < 0) {
  36456. start = i;
  36457. }
  36458. }
  36459. if (start >= 0) {
  36460. reverseValues(chars, start, levels.length);
  36461. }
  36462. }
  36463. for (i = 0, ii = chars.length; i < ii; ++i) {
  36464. var ch = chars[i];
  36465. if (ch === '<' || ch === '>') {
  36466. chars[i] = '';
  36467. }
  36468. }
  36469. return createBidiText(chars.join(''), isLTR);
  36470. }
  36471. exports.bidi = bidi;
  36472. /***/ }),
  36473. /* 22 */
  36474. /***/ (function(module, exports, __w_pdfjs_require__) {
  36475. "use strict";
  36476. var ISOAdobeCharset = [
  36477. '.notdef',
  36478. 'space',
  36479. 'exclam',
  36480. 'quotedbl',
  36481. 'numbersign',
  36482. 'dollar',
  36483. 'percent',
  36484. 'ampersand',
  36485. 'quoteright',
  36486. 'parenleft',
  36487. 'parenright',
  36488. 'asterisk',
  36489. 'plus',
  36490. 'comma',
  36491. 'hyphen',
  36492. 'period',
  36493. 'slash',
  36494. 'zero',
  36495. 'one',
  36496. 'two',
  36497. 'three',
  36498. 'four',
  36499. 'five',
  36500. 'six',
  36501. 'seven',
  36502. 'eight',
  36503. 'nine',
  36504. 'colon',
  36505. 'semicolon',
  36506. 'less',
  36507. 'equal',
  36508. 'greater',
  36509. 'question',
  36510. 'at',
  36511. 'A',
  36512. 'B',
  36513. 'C',
  36514. 'D',
  36515. 'E',
  36516. 'F',
  36517. 'G',
  36518. 'H',
  36519. 'I',
  36520. 'J',
  36521. 'K',
  36522. 'L',
  36523. 'M',
  36524. 'N',
  36525. 'O',
  36526. 'P',
  36527. 'Q',
  36528. 'R',
  36529. 'S',
  36530. 'T',
  36531. 'U',
  36532. 'V',
  36533. 'W',
  36534. 'X',
  36535. 'Y',
  36536. 'Z',
  36537. 'bracketleft',
  36538. 'backslash',
  36539. 'bracketright',
  36540. 'asciicircum',
  36541. 'underscore',
  36542. 'quoteleft',
  36543. 'a',
  36544. 'b',
  36545. 'c',
  36546. 'd',
  36547. 'e',
  36548. 'f',
  36549. 'g',
  36550. 'h',
  36551. 'i',
  36552. 'j',
  36553. 'k',
  36554. 'l',
  36555. 'm',
  36556. 'n',
  36557. 'o',
  36558. 'p',
  36559. 'q',
  36560. 'r',
  36561. 's',
  36562. 't',
  36563. 'u',
  36564. 'v',
  36565. 'w',
  36566. 'x',
  36567. 'y',
  36568. 'z',
  36569. 'braceleft',
  36570. 'bar',
  36571. 'braceright',
  36572. 'asciitilde',
  36573. 'exclamdown',
  36574. 'cent',
  36575. 'sterling',
  36576. 'fraction',
  36577. 'yen',
  36578. 'florin',
  36579. 'section',
  36580. 'currency',
  36581. 'quotesingle',
  36582. 'quotedblleft',
  36583. 'guillemotleft',
  36584. 'guilsinglleft',
  36585. 'guilsinglright',
  36586. 'fi',
  36587. 'fl',
  36588. 'endash',
  36589. 'dagger',
  36590. 'daggerdbl',
  36591. 'periodcentered',
  36592. 'paragraph',
  36593. 'bullet',
  36594. 'quotesinglbase',
  36595. 'quotedblbase',
  36596. 'quotedblright',
  36597. 'guillemotright',
  36598. 'ellipsis',
  36599. 'perthousand',
  36600. 'questiondown',
  36601. 'grave',
  36602. 'acute',
  36603. 'circumflex',
  36604. 'tilde',
  36605. 'macron',
  36606. 'breve',
  36607. 'dotaccent',
  36608. 'dieresis',
  36609. 'ring',
  36610. 'cedilla',
  36611. 'hungarumlaut',
  36612. 'ogonek',
  36613. 'caron',
  36614. 'emdash',
  36615. 'AE',
  36616. 'ordfeminine',
  36617. 'Lslash',
  36618. 'Oslash',
  36619. 'OE',
  36620. 'ordmasculine',
  36621. 'ae',
  36622. 'dotlessi',
  36623. 'lslash',
  36624. 'oslash',
  36625. 'oe',
  36626. 'germandbls',
  36627. 'onesuperior',
  36628. 'logicalnot',
  36629. 'mu',
  36630. 'trademark',
  36631. 'Eth',
  36632. 'onehalf',
  36633. 'plusminus',
  36634. 'Thorn',
  36635. 'onequarter',
  36636. 'divide',
  36637. 'brokenbar',
  36638. 'degree',
  36639. 'thorn',
  36640. 'threequarters',
  36641. 'twosuperior',
  36642. 'registered',
  36643. 'minus',
  36644. 'eth',
  36645. 'multiply',
  36646. 'threesuperior',
  36647. 'copyright',
  36648. 'Aacute',
  36649. 'Acircumflex',
  36650. 'Adieresis',
  36651. 'Agrave',
  36652. 'Aring',
  36653. 'Atilde',
  36654. 'Ccedilla',
  36655. 'Eacute',
  36656. 'Ecircumflex',
  36657. 'Edieresis',
  36658. 'Egrave',
  36659. 'Iacute',
  36660. 'Icircumflex',
  36661. 'Idieresis',
  36662. 'Igrave',
  36663. 'Ntilde',
  36664. 'Oacute',
  36665. 'Ocircumflex',
  36666. 'Odieresis',
  36667. 'Ograve',
  36668. 'Otilde',
  36669. 'Scaron',
  36670. 'Uacute',
  36671. 'Ucircumflex',
  36672. 'Udieresis',
  36673. 'Ugrave',
  36674. 'Yacute',
  36675. 'Ydieresis',
  36676. 'Zcaron',
  36677. 'aacute',
  36678. 'acircumflex',
  36679. 'adieresis',
  36680. 'agrave',
  36681. 'aring',
  36682. 'atilde',
  36683. 'ccedilla',
  36684. 'eacute',
  36685. 'ecircumflex',
  36686. 'edieresis',
  36687. 'egrave',
  36688. 'iacute',
  36689. 'icircumflex',
  36690. 'idieresis',
  36691. 'igrave',
  36692. 'ntilde',
  36693. 'oacute',
  36694. 'ocircumflex',
  36695. 'odieresis',
  36696. 'ograve',
  36697. 'otilde',
  36698. 'scaron',
  36699. 'uacute',
  36700. 'ucircumflex',
  36701. 'udieresis',
  36702. 'ugrave',
  36703. 'yacute',
  36704. 'ydieresis',
  36705. 'zcaron'
  36706. ];
  36707. var ExpertCharset = [
  36708. '.notdef',
  36709. 'space',
  36710. 'exclamsmall',
  36711. 'Hungarumlautsmall',
  36712. 'dollaroldstyle',
  36713. 'dollarsuperior',
  36714. 'ampersandsmall',
  36715. 'Acutesmall',
  36716. 'parenleftsuperior',
  36717. 'parenrightsuperior',
  36718. 'twodotenleader',
  36719. 'onedotenleader',
  36720. 'comma',
  36721. 'hyphen',
  36722. 'period',
  36723. 'fraction',
  36724. 'zerooldstyle',
  36725. 'oneoldstyle',
  36726. 'twooldstyle',
  36727. 'threeoldstyle',
  36728. 'fouroldstyle',
  36729. 'fiveoldstyle',
  36730. 'sixoldstyle',
  36731. 'sevenoldstyle',
  36732. 'eightoldstyle',
  36733. 'nineoldstyle',
  36734. 'colon',
  36735. 'semicolon',
  36736. 'commasuperior',
  36737. 'threequartersemdash',
  36738. 'periodsuperior',
  36739. 'questionsmall',
  36740. 'asuperior',
  36741. 'bsuperior',
  36742. 'centsuperior',
  36743. 'dsuperior',
  36744. 'esuperior',
  36745. 'isuperior',
  36746. 'lsuperior',
  36747. 'msuperior',
  36748. 'nsuperior',
  36749. 'osuperior',
  36750. 'rsuperior',
  36751. 'ssuperior',
  36752. 'tsuperior',
  36753. 'ff',
  36754. 'fi',
  36755. 'fl',
  36756. 'ffi',
  36757. 'ffl',
  36758. 'parenleftinferior',
  36759. 'parenrightinferior',
  36760. 'Circumflexsmall',
  36761. 'hyphensuperior',
  36762. 'Gravesmall',
  36763. 'Asmall',
  36764. 'Bsmall',
  36765. 'Csmall',
  36766. 'Dsmall',
  36767. 'Esmall',
  36768. 'Fsmall',
  36769. 'Gsmall',
  36770. 'Hsmall',
  36771. 'Ismall',
  36772. 'Jsmall',
  36773. 'Ksmall',
  36774. 'Lsmall',
  36775. 'Msmall',
  36776. 'Nsmall',
  36777. 'Osmall',
  36778. 'Psmall',
  36779. 'Qsmall',
  36780. 'Rsmall',
  36781. 'Ssmall',
  36782. 'Tsmall',
  36783. 'Usmall',
  36784. 'Vsmall',
  36785. 'Wsmall',
  36786. 'Xsmall',
  36787. 'Ysmall',
  36788. 'Zsmall',
  36789. 'colonmonetary',
  36790. 'onefitted',
  36791. 'rupiah',
  36792. 'Tildesmall',
  36793. 'exclamdownsmall',
  36794. 'centoldstyle',
  36795. 'Lslashsmall',
  36796. 'Scaronsmall',
  36797. 'Zcaronsmall',
  36798. 'Dieresissmall',
  36799. 'Brevesmall',
  36800. 'Caronsmall',
  36801. 'Dotaccentsmall',
  36802. 'Macronsmall',
  36803. 'figuredash',
  36804. 'hypheninferior',
  36805. 'Ogoneksmall',
  36806. 'Ringsmall',
  36807. 'Cedillasmall',
  36808. 'onequarter',
  36809. 'onehalf',
  36810. 'threequarters',
  36811. 'questiondownsmall',
  36812. 'oneeighth',
  36813. 'threeeighths',
  36814. 'fiveeighths',
  36815. 'seveneighths',
  36816. 'onethird',
  36817. 'twothirds',
  36818. 'zerosuperior',
  36819. 'onesuperior',
  36820. 'twosuperior',
  36821. 'threesuperior',
  36822. 'foursuperior',
  36823. 'fivesuperior',
  36824. 'sixsuperior',
  36825. 'sevensuperior',
  36826. 'eightsuperior',
  36827. 'ninesuperior',
  36828. 'zeroinferior',
  36829. 'oneinferior',
  36830. 'twoinferior',
  36831. 'threeinferior',
  36832. 'fourinferior',
  36833. 'fiveinferior',
  36834. 'sixinferior',
  36835. 'seveninferior',
  36836. 'eightinferior',
  36837. 'nineinferior',
  36838. 'centinferior',
  36839. 'dollarinferior',
  36840. 'periodinferior',
  36841. 'commainferior',
  36842. 'Agravesmall',
  36843. 'Aacutesmall',
  36844. 'Acircumflexsmall',
  36845. 'Atildesmall',
  36846. 'Adieresissmall',
  36847. 'Aringsmall',
  36848. 'AEsmall',
  36849. 'Ccedillasmall',
  36850. 'Egravesmall',
  36851. 'Eacutesmall',
  36852. 'Ecircumflexsmall',
  36853. 'Edieresissmall',
  36854. 'Igravesmall',
  36855. 'Iacutesmall',
  36856. 'Icircumflexsmall',
  36857. 'Idieresissmall',
  36858. 'Ethsmall',
  36859. 'Ntildesmall',
  36860. 'Ogravesmall',
  36861. 'Oacutesmall',
  36862. 'Ocircumflexsmall',
  36863. 'Otildesmall',
  36864. 'Odieresissmall',
  36865. 'OEsmall',
  36866. 'Oslashsmall',
  36867. 'Ugravesmall',
  36868. 'Uacutesmall',
  36869. 'Ucircumflexsmall',
  36870. 'Udieresissmall',
  36871. 'Yacutesmall',
  36872. 'Thornsmall',
  36873. 'Ydieresissmall'
  36874. ];
  36875. var ExpertSubsetCharset = [
  36876. '.notdef',
  36877. 'space',
  36878. 'dollaroldstyle',
  36879. 'dollarsuperior',
  36880. 'parenleftsuperior',
  36881. 'parenrightsuperior',
  36882. 'twodotenleader',
  36883. 'onedotenleader',
  36884. 'comma',
  36885. 'hyphen',
  36886. 'period',
  36887. 'fraction',
  36888. 'zerooldstyle',
  36889. 'oneoldstyle',
  36890. 'twooldstyle',
  36891. 'threeoldstyle',
  36892. 'fouroldstyle',
  36893. 'fiveoldstyle',
  36894. 'sixoldstyle',
  36895. 'sevenoldstyle',
  36896. 'eightoldstyle',
  36897. 'nineoldstyle',
  36898. 'colon',
  36899. 'semicolon',
  36900. 'commasuperior',
  36901. 'threequartersemdash',
  36902. 'periodsuperior',
  36903. 'asuperior',
  36904. 'bsuperior',
  36905. 'centsuperior',
  36906. 'dsuperior',
  36907. 'esuperior',
  36908. 'isuperior',
  36909. 'lsuperior',
  36910. 'msuperior',
  36911. 'nsuperior',
  36912. 'osuperior',
  36913. 'rsuperior',
  36914. 'ssuperior',
  36915. 'tsuperior',
  36916. 'ff',
  36917. 'fi',
  36918. 'fl',
  36919. 'ffi',
  36920. 'ffl',
  36921. 'parenleftinferior',
  36922. 'parenrightinferior',
  36923. 'hyphensuperior',
  36924. 'colonmonetary',
  36925. 'onefitted',
  36926. 'rupiah',
  36927. 'centoldstyle',
  36928. 'figuredash',
  36929. 'hypheninferior',
  36930. 'onequarter',
  36931. 'onehalf',
  36932. 'threequarters',
  36933. 'oneeighth',
  36934. 'threeeighths',
  36935. 'fiveeighths',
  36936. 'seveneighths',
  36937. 'onethird',
  36938. 'twothirds',
  36939. 'zerosuperior',
  36940. 'onesuperior',
  36941. 'twosuperior',
  36942. 'threesuperior',
  36943. 'foursuperior',
  36944. 'fivesuperior',
  36945. 'sixsuperior',
  36946. 'sevensuperior',
  36947. 'eightsuperior',
  36948. 'ninesuperior',
  36949. 'zeroinferior',
  36950. 'oneinferior',
  36951. 'twoinferior',
  36952. 'threeinferior',
  36953. 'fourinferior',
  36954. 'fiveinferior',
  36955. 'sixinferior',
  36956. 'seveninferior',
  36957. 'eightinferior',
  36958. 'nineinferior',
  36959. 'centinferior',
  36960. 'dollarinferior',
  36961. 'periodinferior',
  36962. 'commainferior'
  36963. ];
  36964. exports.ISOAdobeCharset = ISOAdobeCharset;
  36965. exports.ExpertCharset = ExpertCharset;
  36966. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  36967. /***/ }),
  36968. /* 23 */
  36969. /***/ (function(module, exports, __w_pdfjs_require__) {
  36970. "use strict";
  36971. var sharedUtil = __w_pdfjs_require__(0);
  36972. var corePrimitives = __w_pdfjs_require__(1);
  36973. var coreStream = __w_pdfjs_require__(2);
  36974. var coreParser = __w_pdfjs_require__(5);
  36975. var Util = sharedUtil.Util;
  36976. var assert = sharedUtil.assert;
  36977. var warn = sharedUtil.warn;
  36978. var error = sharedUtil.error;
  36979. var isInt = sharedUtil.isInt;
  36980. var isString = sharedUtil.isString;
  36981. var MissingDataException = sharedUtil.MissingDataException;
  36982. var CMapCompressionType = sharedUtil.CMapCompressionType;
  36983. var isEOF = corePrimitives.isEOF;
  36984. var isName = corePrimitives.isName;
  36985. var isCmd = corePrimitives.isCmd;
  36986. var isStream = corePrimitives.isStream;
  36987. var Stream = coreStream.Stream;
  36988. var Lexer = coreParser.Lexer;
  36989. var BUILT_IN_CMAPS = [
  36990. 'Adobe-GB1-UCS2',
  36991. 'Adobe-CNS1-UCS2',
  36992. 'Adobe-Japan1-UCS2',
  36993. 'Adobe-Korea1-UCS2',
  36994. '78-EUC-H',
  36995. '78-EUC-V',
  36996. '78-H',
  36997. '78-RKSJ-H',
  36998. '78-RKSJ-V',
  36999. '78-V',
  37000. '78ms-RKSJ-H',
  37001. '78ms-RKSJ-V',
  37002. '83pv-RKSJ-H',
  37003. '90ms-RKSJ-H',
  37004. '90ms-RKSJ-V',
  37005. '90msp-RKSJ-H',
  37006. '90msp-RKSJ-V',
  37007. '90pv-RKSJ-H',
  37008. '90pv-RKSJ-V',
  37009. 'Add-H',
  37010. 'Add-RKSJ-H',
  37011. 'Add-RKSJ-V',
  37012. 'Add-V',
  37013. 'Adobe-CNS1-0',
  37014. 'Adobe-CNS1-1',
  37015. 'Adobe-CNS1-2',
  37016. 'Adobe-CNS1-3',
  37017. 'Adobe-CNS1-4',
  37018. 'Adobe-CNS1-5',
  37019. 'Adobe-CNS1-6',
  37020. 'Adobe-GB1-0',
  37021. 'Adobe-GB1-1',
  37022. 'Adobe-GB1-2',
  37023. 'Adobe-GB1-3',
  37024. 'Adobe-GB1-4',
  37025. 'Adobe-GB1-5',
  37026. 'Adobe-Japan1-0',
  37027. 'Adobe-Japan1-1',
  37028. 'Adobe-Japan1-2',
  37029. 'Adobe-Japan1-3',
  37030. 'Adobe-Japan1-4',
  37031. 'Adobe-Japan1-5',
  37032. 'Adobe-Japan1-6',
  37033. 'Adobe-Korea1-0',
  37034. 'Adobe-Korea1-1',
  37035. 'Adobe-Korea1-2',
  37036. 'B5-H',
  37037. 'B5-V',
  37038. 'B5pc-H',
  37039. 'B5pc-V',
  37040. 'CNS-EUC-H',
  37041. 'CNS-EUC-V',
  37042. 'CNS1-H',
  37043. 'CNS1-V',
  37044. 'CNS2-H',
  37045. 'CNS2-V',
  37046. 'ETHK-B5-H',
  37047. 'ETHK-B5-V',
  37048. 'ETen-B5-H',
  37049. 'ETen-B5-V',
  37050. 'ETenms-B5-H',
  37051. 'ETenms-B5-V',
  37052. 'EUC-H',
  37053. 'EUC-V',
  37054. 'Ext-H',
  37055. 'Ext-RKSJ-H',
  37056. 'Ext-RKSJ-V',
  37057. 'Ext-V',
  37058. 'GB-EUC-H',
  37059. 'GB-EUC-V',
  37060. 'GB-H',
  37061. 'GB-V',
  37062. 'GBK-EUC-H',
  37063. 'GBK-EUC-V',
  37064. 'GBK2K-H',
  37065. 'GBK2K-V',
  37066. 'GBKp-EUC-H',
  37067. 'GBKp-EUC-V',
  37068. 'GBT-EUC-H',
  37069. 'GBT-EUC-V',
  37070. 'GBT-H',
  37071. 'GBT-V',
  37072. 'GBTpc-EUC-H',
  37073. 'GBTpc-EUC-V',
  37074. 'GBpc-EUC-H',
  37075. 'GBpc-EUC-V',
  37076. 'H',
  37077. 'HKdla-B5-H',
  37078. 'HKdla-B5-V',
  37079. 'HKdlb-B5-H',
  37080. 'HKdlb-B5-V',
  37081. 'HKgccs-B5-H',
  37082. 'HKgccs-B5-V',
  37083. 'HKm314-B5-H',
  37084. 'HKm314-B5-V',
  37085. 'HKm471-B5-H',
  37086. 'HKm471-B5-V',
  37087. 'HKscs-B5-H',
  37088. 'HKscs-B5-V',
  37089. 'Hankaku',
  37090. 'Hiragana',
  37091. 'KSC-EUC-H',
  37092. 'KSC-EUC-V',
  37093. 'KSC-H',
  37094. 'KSC-Johab-H',
  37095. 'KSC-Johab-V',
  37096. 'KSC-V',
  37097. 'KSCms-UHC-H',
  37098. 'KSCms-UHC-HW-H',
  37099. 'KSCms-UHC-HW-V',
  37100. 'KSCms-UHC-V',
  37101. 'KSCpc-EUC-H',
  37102. 'KSCpc-EUC-V',
  37103. 'Katakana',
  37104. 'NWP-H',
  37105. 'NWP-V',
  37106. 'RKSJ-H',
  37107. 'RKSJ-V',
  37108. 'Roman',
  37109. 'UniCNS-UCS2-H',
  37110. 'UniCNS-UCS2-V',
  37111. 'UniCNS-UTF16-H',
  37112. 'UniCNS-UTF16-V',
  37113. 'UniCNS-UTF32-H',
  37114. 'UniCNS-UTF32-V',
  37115. 'UniCNS-UTF8-H',
  37116. 'UniCNS-UTF8-V',
  37117. 'UniGB-UCS2-H',
  37118. 'UniGB-UCS2-V',
  37119. 'UniGB-UTF16-H',
  37120. 'UniGB-UTF16-V',
  37121. 'UniGB-UTF32-H',
  37122. 'UniGB-UTF32-V',
  37123. 'UniGB-UTF8-H',
  37124. 'UniGB-UTF8-V',
  37125. 'UniJIS-UCS2-H',
  37126. 'UniJIS-UCS2-HW-H',
  37127. 'UniJIS-UCS2-HW-V',
  37128. 'UniJIS-UCS2-V',
  37129. 'UniJIS-UTF16-H',
  37130. 'UniJIS-UTF16-V',
  37131. 'UniJIS-UTF32-H',
  37132. 'UniJIS-UTF32-V',
  37133. 'UniJIS-UTF8-H',
  37134. 'UniJIS-UTF8-V',
  37135. 'UniJIS2004-UTF16-H',
  37136. 'UniJIS2004-UTF16-V',
  37137. 'UniJIS2004-UTF32-H',
  37138. 'UniJIS2004-UTF32-V',
  37139. 'UniJIS2004-UTF8-H',
  37140. 'UniJIS2004-UTF8-V',
  37141. 'UniJISPro-UCS2-HW-V',
  37142. 'UniJISPro-UCS2-V',
  37143. 'UniJISPro-UTF8-V',
  37144. 'UniJISX0213-UTF32-H',
  37145. 'UniJISX0213-UTF32-V',
  37146. 'UniJISX02132004-UTF32-H',
  37147. 'UniJISX02132004-UTF32-V',
  37148. 'UniKS-UCS2-H',
  37149. 'UniKS-UCS2-V',
  37150. 'UniKS-UTF16-H',
  37151. 'UniKS-UTF16-V',
  37152. 'UniKS-UTF32-H',
  37153. 'UniKS-UTF32-V',
  37154. 'UniKS-UTF8-H',
  37155. 'UniKS-UTF8-V',
  37156. 'V',
  37157. 'WP-Symbol'
  37158. ];
  37159. var CMap = function CMapClosure() {
  37160. function CMap(builtInCMap) {
  37161. this.codespaceRanges = [
  37162. [],
  37163. [],
  37164. [],
  37165. []
  37166. ];
  37167. this.numCodespaceRanges = 0;
  37168. this._map = [];
  37169. this.name = '';
  37170. this.vertical = false;
  37171. this.useCMap = null;
  37172. this.builtInCMap = builtInCMap;
  37173. }
  37174. CMap.prototype = {
  37175. addCodespaceRange: function (n, low, high) {
  37176. this.codespaceRanges[n - 1].push(low, high);
  37177. this.numCodespaceRanges++;
  37178. },
  37179. mapCidRange: function (low, high, dstLow) {
  37180. while (low <= high) {
  37181. this._map[low++] = dstLow++;
  37182. }
  37183. },
  37184. mapBfRange: function (low, high, dstLow) {
  37185. var lastByte = dstLow.length - 1;
  37186. while (low <= high) {
  37187. this._map[low++] = dstLow;
  37188. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  37189. }
  37190. },
  37191. mapBfRangeToArray: function (low, high, array) {
  37192. var i = 0, ii = array.length;
  37193. while (low <= high && i < ii) {
  37194. this._map[low] = array[i++];
  37195. ++low;
  37196. }
  37197. },
  37198. mapOne: function (src, dst) {
  37199. this._map[src] = dst;
  37200. },
  37201. lookup: function (code) {
  37202. return this._map[code];
  37203. },
  37204. contains: function (code) {
  37205. return this._map[code] !== undefined;
  37206. },
  37207. forEach: function (callback) {
  37208. var map = this._map;
  37209. var length = map.length;
  37210. var i;
  37211. if (length <= 0x10000) {
  37212. for (i = 0; i < length; i++) {
  37213. if (map[i] !== undefined) {
  37214. callback(i, map[i]);
  37215. }
  37216. }
  37217. } else {
  37218. for (i in this._map) {
  37219. callback(i, map[i]);
  37220. }
  37221. }
  37222. },
  37223. charCodeOf: function (value) {
  37224. return this._map.indexOf(value);
  37225. },
  37226. getMap: function () {
  37227. return this._map;
  37228. },
  37229. readCharCode: function (str, offset, out) {
  37230. var c = 0;
  37231. var codespaceRanges = this.codespaceRanges;
  37232. var codespaceRangesLen = this.codespaceRanges.length;
  37233. for (var n = 0; n < codespaceRangesLen; n++) {
  37234. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  37235. var codespaceRange = codespaceRanges[n];
  37236. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  37237. var low = codespaceRange[k++];
  37238. var high = codespaceRange[k++];
  37239. if (c >= low && c <= high) {
  37240. out.charcode = c;
  37241. out.length = n + 1;
  37242. return;
  37243. }
  37244. }
  37245. }
  37246. out.charcode = 0;
  37247. out.length = 1;
  37248. },
  37249. get length() {
  37250. return this._map.length;
  37251. },
  37252. get isIdentityCMap() {
  37253. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  37254. return false;
  37255. }
  37256. if (this._map.length !== 0x10000) {
  37257. return false;
  37258. }
  37259. for (var i = 0; i < 0x10000; i++) {
  37260. if (this._map[i] !== i) {
  37261. return false;
  37262. }
  37263. }
  37264. return true;
  37265. }
  37266. };
  37267. return CMap;
  37268. }();
  37269. var IdentityCMap = function IdentityCMapClosure() {
  37270. function IdentityCMap(vertical, n) {
  37271. CMap.call(this);
  37272. this.vertical = vertical;
  37273. this.addCodespaceRange(n, 0, 0xffff);
  37274. }
  37275. Util.inherit(IdentityCMap, CMap, {});
  37276. IdentityCMap.prototype = {
  37277. addCodespaceRange: CMap.prototype.addCodespaceRange,
  37278. mapCidRange: function (low, high, dstLow) {
  37279. error('should not call mapCidRange');
  37280. },
  37281. mapBfRange: function (low, high, dstLow) {
  37282. error('should not call mapBfRange');
  37283. },
  37284. mapBfRangeToArray: function (low, high, array) {
  37285. error('should not call mapBfRangeToArray');
  37286. },
  37287. mapOne: function (src, dst) {
  37288. error('should not call mapCidOne');
  37289. },
  37290. lookup: function (code) {
  37291. return isInt(code) && code <= 0xffff ? code : undefined;
  37292. },
  37293. contains: function (code) {
  37294. return isInt(code) && code <= 0xffff;
  37295. },
  37296. forEach: function (callback) {
  37297. for (var i = 0; i <= 0xffff; i++) {
  37298. callback(i, i);
  37299. }
  37300. },
  37301. charCodeOf: function (value) {
  37302. return isInt(value) && value <= 0xffff ? value : -1;
  37303. },
  37304. getMap: function () {
  37305. var map = new Array(0x10000);
  37306. for (var i = 0; i <= 0xffff; i++) {
  37307. map[i] = i;
  37308. }
  37309. return map;
  37310. },
  37311. readCharCode: CMap.prototype.readCharCode,
  37312. get length() {
  37313. return 0x10000;
  37314. },
  37315. get isIdentityCMap() {
  37316. error('should not access .isIdentityCMap');
  37317. }
  37318. };
  37319. return IdentityCMap;
  37320. }();
  37321. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  37322. function hexToInt(a, size) {
  37323. var n = 0;
  37324. for (var i = 0; i <= size; i++) {
  37325. n = n << 8 | a[i];
  37326. }
  37327. return n >>> 0;
  37328. }
  37329. function hexToStr(a, size) {
  37330. if (size === 1) {
  37331. return String.fromCharCode(a[0], a[1]);
  37332. }
  37333. if (size === 3) {
  37334. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  37335. }
  37336. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  37337. }
  37338. function addHex(a, b, size) {
  37339. var c = 0;
  37340. for (var i = size; i >= 0; i--) {
  37341. c += a[i] + b[i];
  37342. a[i] = c & 255;
  37343. c >>= 8;
  37344. }
  37345. }
  37346. function incHex(a, size) {
  37347. var c = 1;
  37348. for (var i = size; i >= 0 && c > 0; i--) {
  37349. c += a[i];
  37350. a[i] = c & 255;
  37351. c >>= 8;
  37352. }
  37353. }
  37354. var MAX_NUM_SIZE = 16;
  37355. var MAX_ENCODED_NUM_SIZE = 19;
  37356. function BinaryCMapStream(data) {
  37357. this.buffer = data;
  37358. this.pos = 0;
  37359. this.end = data.length;
  37360. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  37361. }
  37362. BinaryCMapStream.prototype = {
  37363. readByte: function () {
  37364. if (this.pos >= this.end) {
  37365. return -1;
  37366. }
  37367. return this.buffer[this.pos++];
  37368. },
  37369. readNumber: function () {
  37370. var n = 0;
  37371. var last;
  37372. do {
  37373. var b = this.readByte();
  37374. if (b < 0) {
  37375. error('unexpected EOF in bcmap');
  37376. }
  37377. last = !(b & 0x80);
  37378. n = n << 7 | b & 0x7F;
  37379. } while (!last);
  37380. return n;
  37381. },
  37382. readSigned: function () {
  37383. var n = this.readNumber();
  37384. return n & 1 ? ~(n >>> 1) : n >>> 1;
  37385. },
  37386. readHex: function (num, size) {
  37387. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  37388. this.pos += size + 1;
  37389. },
  37390. readHexNumber: function (num, size) {
  37391. var last;
  37392. var stack = this.tmpBuf, sp = 0;
  37393. do {
  37394. var b = this.readByte();
  37395. if (b < 0) {
  37396. error('unexpected EOF in bcmap');
  37397. }
  37398. last = !(b & 0x80);
  37399. stack[sp++] = b & 0x7F;
  37400. } while (!last);
  37401. var i = size, buffer = 0, bufferSize = 0;
  37402. while (i >= 0) {
  37403. while (bufferSize < 8 && stack.length > 0) {
  37404. buffer = stack[--sp] << bufferSize | buffer;
  37405. bufferSize += 7;
  37406. }
  37407. num[i] = buffer & 255;
  37408. i--;
  37409. buffer >>= 8;
  37410. bufferSize -= 8;
  37411. }
  37412. },
  37413. readHexSigned: function (num, size) {
  37414. this.readHexNumber(num, size);
  37415. var sign = num[size] & 1 ? 255 : 0;
  37416. var c = 0;
  37417. for (var i = 0; i <= size; i++) {
  37418. c = (c & 1) << 8 | num[i];
  37419. num[i] = c >> 1 ^ sign;
  37420. }
  37421. },
  37422. readString: function () {
  37423. var len = this.readNumber();
  37424. var s = '';
  37425. for (var i = 0; i < len; i++) {
  37426. s += String.fromCharCode(this.readNumber());
  37427. }
  37428. return s;
  37429. }
  37430. };
  37431. function processBinaryCMap(data, cMap, extend) {
  37432. return new Promise(function (resolve, reject) {
  37433. var stream = new BinaryCMapStream(data);
  37434. var header = stream.readByte();
  37435. cMap.vertical = !!(header & 1);
  37436. var useCMap = null;
  37437. var start = new Uint8Array(MAX_NUM_SIZE);
  37438. var end = new Uint8Array(MAX_NUM_SIZE);
  37439. var char = new Uint8Array(MAX_NUM_SIZE);
  37440. var charCode = new Uint8Array(MAX_NUM_SIZE);
  37441. var tmp = new Uint8Array(MAX_NUM_SIZE);
  37442. var code;
  37443. var b;
  37444. while ((b = stream.readByte()) >= 0) {
  37445. var type = b >> 5;
  37446. if (type === 7) {
  37447. switch (b & 0x1F) {
  37448. case 0:
  37449. stream.readString();
  37450. break;
  37451. case 1:
  37452. useCMap = stream.readString();
  37453. break;
  37454. }
  37455. continue;
  37456. }
  37457. var sequence = !!(b & 0x10);
  37458. var dataSize = b & 15;
  37459. assert(dataSize + 1 <= MAX_NUM_SIZE);
  37460. var ucs2DataSize = 1;
  37461. var subitemsCount = stream.readNumber();
  37462. var i;
  37463. switch (type) {
  37464. case 0:
  37465. stream.readHex(start, dataSize);
  37466. stream.readHexNumber(end, dataSize);
  37467. addHex(end, start, dataSize);
  37468. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  37469. for (i = 1; i < subitemsCount; i++) {
  37470. incHex(end, dataSize);
  37471. stream.readHexNumber(start, dataSize);
  37472. addHex(start, end, dataSize);
  37473. stream.readHexNumber(end, dataSize);
  37474. addHex(end, start, dataSize);
  37475. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  37476. }
  37477. break;
  37478. case 1:
  37479. stream.readHex(start, dataSize);
  37480. stream.readHexNumber(end, dataSize);
  37481. addHex(end, start, dataSize);
  37482. code = stream.readNumber();
  37483. for (i = 1; i < subitemsCount; i++) {
  37484. incHex(end, dataSize);
  37485. stream.readHexNumber(start, dataSize);
  37486. addHex(start, end, dataSize);
  37487. stream.readHexNumber(end, dataSize);
  37488. addHex(end, start, dataSize);
  37489. code = stream.readNumber();
  37490. }
  37491. break;
  37492. case 2:
  37493. stream.readHex(char, dataSize);
  37494. code = stream.readNumber();
  37495. cMap.mapOne(hexToInt(char, dataSize), code);
  37496. for (i = 1; i < subitemsCount; i++) {
  37497. incHex(char, dataSize);
  37498. if (!sequence) {
  37499. stream.readHexNumber(tmp, dataSize);
  37500. addHex(char, tmp, dataSize);
  37501. }
  37502. code = stream.readSigned() + (code + 1);
  37503. cMap.mapOne(hexToInt(char, dataSize), code);
  37504. }
  37505. break;
  37506. case 3:
  37507. stream.readHex(start, dataSize);
  37508. stream.readHexNumber(end, dataSize);
  37509. addHex(end, start, dataSize);
  37510. code = stream.readNumber();
  37511. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  37512. for (i = 1; i < subitemsCount; i++) {
  37513. incHex(end, dataSize);
  37514. if (!sequence) {
  37515. stream.readHexNumber(start, dataSize);
  37516. addHex(start, end, dataSize);
  37517. } else {
  37518. start.set(end);
  37519. }
  37520. stream.readHexNumber(end, dataSize);
  37521. addHex(end, start, dataSize);
  37522. code = stream.readNumber();
  37523. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  37524. }
  37525. break;
  37526. case 4:
  37527. stream.readHex(char, ucs2DataSize);
  37528. stream.readHex(charCode, dataSize);
  37529. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  37530. for (i = 1; i < subitemsCount; i++) {
  37531. incHex(char, ucs2DataSize);
  37532. if (!sequence) {
  37533. stream.readHexNumber(tmp, ucs2DataSize);
  37534. addHex(char, tmp, ucs2DataSize);
  37535. }
  37536. incHex(charCode, dataSize);
  37537. stream.readHexSigned(tmp, dataSize);
  37538. addHex(charCode, tmp, dataSize);
  37539. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  37540. }
  37541. break;
  37542. case 5:
  37543. stream.readHex(start, ucs2DataSize);
  37544. stream.readHexNumber(end, ucs2DataSize);
  37545. addHex(end, start, ucs2DataSize);
  37546. stream.readHex(charCode, dataSize);
  37547. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  37548. for (i = 1; i < subitemsCount; i++) {
  37549. incHex(end, ucs2DataSize);
  37550. if (!sequence) {
  37551. stream.readHexNumber(start, ucs2DataSize);
  37552. addHex(start, end, ucs2DataSize);
  37553. } else {
  37554. start.set(end);
  37555. }
  37556. stream.readHexNumber(end, ucs2DataSize);
  37557. addHex(end, start, ucs2DataSize);
  37558. stream.readHex(charCode, dataSize);
  37559. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  37560. }
  37561. break;
  37562. default:
  37563. reject(new Error('processBinaryCMap: Unknown type: ' + type));
  37564. return;
  37565. }
  37566. }
  37567. if (useCMap) {
  37568. resolve(extend(useCMap));
  37569. return;
  37570. }
  37571. resolve(cMap);
  37572. });
  37573. }
  37574. function BinaryCMapReader() {
  37575. }
  37576. BinaryCMapReader.prototype = { process: processBinaryCMap };
  37577. return BinaryCMapReader;
  37578. }();
  37579. var CMapFactory = function CMapFactoryClosure() {
  37580. function strToInt(str) {
  37581. var a = 0;
  37582. for (var i = 0; i < str.length; i++) {
  37583. a = a << 8 | str.charCodeAt(i);
  37584. }
  37585. return a >>> 0;
  37586. }
  37587. function expectString(obj) {
  37588. if (!isString(obj)) {
  37589. error('Malformed CMap: expected string.');
  37590. }
  37591. }
  37592. function expectInt(obj) {
  37593. if (!isInt(obj)) {
  37594. error('Malformed CMap: expected int.');
  37595. }
  37596. }
  37597. function parseBfChar(cMap, lexer) {
  37598. while (true) {
  37599. var obj = lexer.getObj();
  37600. if (isEOF(obj)) {
  37601. break;
  37602. }
  37603. if (isCmd(obj, 'endbfchar')) {
  37604. return;
  37605. }
  37606. expectString(obj);
  37607. var src = strToInt(obj);
  37608. obj = lexer.getObj();
  37609. expectString(obj);
  37610. var dst = obj;
  37611. cMap.mapOne(src, dst);
  37612. }
  37613. }
  37614. function parseBfRange(cMap, lexer) {
  37615. while (true) {
  37616. var obj = lexer.getObj();
  37617. if (isEOF(obj)) {
  37618. break;
  37619. }
  37620. if (isCmd(obj, 'endbfrange')) {
  37621. return;
  37622. }
  37623. expectString(obj);
  37624. var low = strToInt(obj);
  37625. obj = lexer.getObj();
  37626. expectString(obj);
  37627. var high = strToInt(obj);
  37628. obj = lexer.getObj();
  37629. if (isInt(obj) || isString(obj)) {
  37630. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  37631. cMap.mapBfRange(low, high, dstLow);
  37632. } else if (isCmd(obj, '[')) {
  37633. obj = lexer.getObj();
  37634. var array = [];
  37635. while (!isCmd(obj, ']') && !isEOF(obj)) {
  37636. array.push(obj);
  37637. obj = lexer.getObj();
  37638. }
  37639. cMap.mapBfRangeToArray(low, high, array);
  37640. } else {
  37641. break;
  37642. }
  37643. }
  37644. error('Invalid bf range.');
  37645. }
  37646. function parseCidChar(cMap, lexer) {
  37647. while (true) {
  37648. var obj = lexer.getObj();
  37649. if (isEOF(obj)) {
  37650. break;
  37651. }
  37652. if (isCmd(obj, 'endcidchar')) {
  37653. return;
  37654. }
  37655. expectString(obj);
  37656. var src = strToInt(obj);
  37657. obj = lexer.getObj();
  37658. expectInt(obj);
  37659. var dst = obj;
  37660. cMap.mapOne(src, dst);
  37661. }
  37662. }
  37663. function parseCidRange(cMap, lexer) {
  37664. while (true) {
  37665. var obj = lexer.getObj();
  37666. if (isEOF(obj)) {
  37667. break;
  37668. }
  37669. if (isCmd(obj, 'endcidrange')) {
  37670. return;
  37671. }
  37672. expectString(obj);
  37673. var low = strToInt(obj);
  37674. obj = lexer.getObj();
  37675. expectString(obj);
  37676. var high = strToInt(obj);
  37677. obj = lexer.getObj();
  37678. expectInt(obj);
  37679. var dstLow = obj;
  37680. cMap.mapCidRange(low, high, dstLow);
  37681. }
  37682. }
  37683. function parseCodespaceRange(cMap, lexer) {
  37684. while (true) {
  37685. var obj = lexer.getObj();
  37686. if (isEOF(obj)) {
  37687. break;
  37688. }
  37689. if (isCmd(obj, 'endcodespacerange')) {
  37690. return;
  37691. }
  37692. if (!isString(obj)) {
  37693. break;
  37694. }
  37695. var low = strToInt(obj);
  37696. obj = lexer.getObj();
  37697. if (!isString(obj)) {
  37698. break;
  37699. }
  37700. var high = strToInt(obj);
  37701. cMap.addCodespaceRange(obj.length, low, high);
  37702. }
  37703. error('Invalid codespace range.');
  37704. }
  37705. function parseWMode(cMap, lexer) {
  37706. var obj = lexer.getObj();
  37707. if (isInt(obj)) {
  37708. cMap.vertical = !!obj;
  37709. }
  37710. }
  37711. function parseCMapName(cMap, lexer) {
  37712. var obj = lexer.getObj();
  37713. if (isName(obj) && isString(obj.name)) {
  37714. cMap.name = obj.name;
  37715. }
  37716. }
  37717. function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  37718. var previous;
  37719. var embededUseCMap;
  37720. objLoop:
  37721. while (true) {
  37722. try {
  37723. var obj = lexer.getObj();
  37724. if (isEOF(obj)) {
  37725. break;
  37726. } else if (isName(obj)) {
  37727. if (obj.name === 'WMode') {
  37728. parseWMode(cMap, lexer);
  37729. } else if (obj.name === 'CMapName') {
  37730. parseCMapName(cMap, lexer);
  37731. }
  37732. previous = obj;
  37733. } else if (isCmd(obj)) {
  37734. switch (obj.cmd) {
  37735. case 'endcmap':
  37736. break objLoop;
  37737. case 'usecmap':
  37738. if (isName(previous)) {
  37739. embededUseCMap = previous.name;
  37740. }
  37741. break;
  37742. case 'begincodespacerange':
  37743. parseCodespaceRange(cMap, lexer);
  37744. break;
  37745. case 'beginbfchar':
  37746. parseBfChar(cMap, lexer);
  37747. break;
  37748. case 'begincidchar':
  37749. parseCidChar(cMap, lexer);
  37750. break;
  37751. case 'beginbfrange':
  37752. parseBfRange(cMap, lexer);
  37753. break;
  37754. case 'begincidrange':
  37755. parseCidRange(cMap, lexer);
  37756. break;
  37757. }
  37758. }
  37759. } catch (ex) {
  37760. if (ex instanceof MissingDataException) {
  37761. throw ex;
  37762. }
  37763. warn('Invalid cMap data: ' + ex);
  37764. continue;
  37765. }
  37766. }
  37767. if (!useCMap && embededUseCMap) {
  37768. useCMap = embededUseCMap;
  37769. }
  37770. if (useCMap) {
  37771. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  37772. }
  37773. return Promise.resolve(cMap);
  37774. }
  37775. function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  37776. return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
  37777. cMap.useCMap = newCMap;
  37778. if (cMap.numCodespaceRanges === 0) {
  37779. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  37780. for (var i = 0; i < useCodespaceRanges.length; i++) {
  37781. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  37782. }
  37783. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  37784. }
  37785. cMap.useCMap.forEach(function (key, value) {
  37786. if (!cMap.contains(key)) {
  37787. cMap.mapOne(key, cMap.useCMap.lookup(key));
  37788. }
  37789. });
  37790. return cMap;
  37791. });
  37792. }
  37793. function createBuiltInCMap(name, fetchBuiltInCMap) {
  37794. if (name === 'Identity-H') {
  37795. return Promise.resolve(new IdentityCMap(false, 2));
  37796. } else if (name === 'Identity-V') {
  37797. return Promise.resolve(new IdentityCMap(true, 2));
  37798. }
  37799. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  37800. return Promise.reject(new Error('Unknown cMap name: ' + name));
  37801. }
  37802. assert(fetchBuiltInCMap, 'Built-in CMap parameters are not provided.');
  37803. return fetchBuiltInCMap(name).then(function (data) {
  37804. var cMapData = data.cMapData, compressionType = data.compressionType;
  37805. var cMap = new CMap(true);
  37806. if (compressionType === CMapCompressionType.BINARY) {
  37807. return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
  37808. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  37809. });
  37810. }
  37811. assert(compressionType === CMapCompressionType.NONE, 'TODO: Only BINARY/NONE CMap compression is currently supported.');
  37812. var lexer = new Lexer(new Stream(cMapData));
  37813. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  37814. });
  37815. }
  37816. return {
  37817. create: function (params) {
  37818. var encoding = params.encoding;
  37819. var fetchBuiltInCMap = params.fetchBuiltInCMap;
  37820. var useCMap = params.useCMap;
  37821. if (isName(encoding)) {
  37822. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  37823. } else if (isStream(encoding)) {
  37824. var cMap = new CMap();
  37825. var lexer = new Lexer(encoding);
  37826. return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
  37827. if (parsedCMap.isIdentityCMap) {
  37828. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  37829. }
  37830. return parsedCMap;
  37831. });
  37832. }
  37833. return Promise.reject(new Error('Encoding required.'));
  37834. }
  37835. };
  37836. }();
  37837. exports.CMap = CMap;
  37838. exports.CMapFactory = CMapFactory;
  37839. exports.IdentityCMap = IdentityCMap;
  37840. /***/ }),
  37841. /* 24 */
  37842. /***/ (function(module, exports, __w_pdfjs_require__) {
  37843. "use strict";
  37844. var sharedUtil = __w_pdfjs_require__(0);
  37845. var corePrimitives = __w_pdfjs_require__(1);
  37846. var coreStream = __w_pdfjs_require__(2);
  37847. var coreObj = __w_pdfjs_require__(16);
  37848. var coreParser = __w_pdfjs_require__(5);
  37849. var coreCrypto = __w_pdfjs_require__(13);
  37850. var coreEvaluator = __w_pdfjs_require__(14);
  37851. var coreAnnotation = __w_pdfjs_require__(20);
  37852. var OPS = sharedUtil.OPS;
  37853. var MissingDataException = sharedUtil.MissingDataException;
  37854. var Util = sharedUtil.Util;
  37855. var assert = sharedUtil.assert;
  37856. var error = sharedUtil.error;
  37857. var info = sharedUtil.info;
  37858. var isArray = sharedUtil.isArray;
  37859. var isArrayBuffer = sharedUtil.isArrayBuffer;
  37860. var isNum = sharedUtil.isNum;
  37861. var isString = sharedUtil.isString;
  37862. var shadow = sharedUtil.shadow;
  37863. var stringToBytes = sharedUtil.stringToBytes;
  37864. var stringToPDFString = sharedUtil.stringToPDFString;
  37865. var warn = sharedUtil.warn;
  37866. var isSpace = sharedUtil.isSpace;
  37867. var Dict = corePrimitives.Dict;
  37868. var isDict = corePrimitives.isDict;
  37869. var isName = corePrimitives.isName;
  37870. var isStream = corePrimitives.isStream;
  37871. var NullStream = coreStream.NullStream;
  37872. var Stream = coreStream.Stream;
  37873. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  37874. var Catalog = coreObj.Catalog;
  37875. var ObjectLoader = coreObj.ObjectLoader;
  37876. var XRef = coreObj.XRef;
  37877. var Linearization = coreParser.Linearization;
  37878. var calculateMD5 = coreCrypto.calculateMD5;
  37879. var OperatorList = coreEvaluator.OperatorList;
  37880. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  37881. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  37882. var Page = function PageClosure() {
  37883. var DEFAULT_USER_UNIT = 1.0;
  37884. var LETTER_SIZE_MEDIABOX = [
  37885. 0,
  37886. 0,
  37887. 612,
  37888. 792
  37889. ];
  37890. function isAnnotationRenderable(annotation, intent) {
  37891. return intent === 'display' && annotation.viewable || intent === 'print' && annotation.printable;
  37892. }
  37893. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache, builtInCMapCache) {
  37894. this.pdfManager = pdfManager;
  37895. this.pageIndex = pageIndex;
  37896. this.pageDict = pageDict;
  37897. this.xref = xref;
  37898. this.ref = ref;
  37899. this.fontCache = fontCache;
  37900. this.builtInCMapCache = builtInCMapCache;
  37901. this.evaluatorOptions = pdfManager.evaluatorOptions;
  37902. this.resourcesPromise = null;
  37903. var uniquePrefix = 'p' + this.pageIndex + '_';
  37904. var idCounters = { obj: 0 };
  37905. this.idFactory = {
  37906. createObjId: function () {
  37907. return uniquePrefix + ++idCounters.obj;
  37908. }
  37909. };
  37910. }
  37911. Page.prototype = {
  37912. getPageProp: function Page_getPageProp(key) {
  37913. return this.pageDict.get(key);
  37914. },
  37915. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  37916. var dict = this.pageDict, valueArray = null, loopCount = 0;
  37917. var MAX_LOOP_COUNT = 100;
  37918. getArray = getArray || false;
  37919. while (dict) {
  37920. var value = getArray ? dict.getArray(key) : dict.get(key);
  37921. if (value) {
  37922. if (!valueArray) {
  37923. valueArray = [];
  37924. }
  37925. valueArray.push(value);
  37926. }
  37927. if (++loopCount > MAX_LOOP_COUNT) {
  37928. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  37929. break;
  37930. }
  37931. dict = dict.get('Parent');
  37932. }
  37933. if (!valueArray) {
  37934. return Dict.empty;
  37935. }
  37936. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  37937. return valueArray[0];
  37938. }
  37939. return Dict.merge(this.xref, valueArray);
  37940. },
  37941. get content() {
  37942. return this.getPageProp('Contents');
  37943. },
  37944. get resources() {
  37945. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  37946. },
  37947. get mediaBox() {
  37948. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  37949. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  37950. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  37951. }
  37952. return shadow(this, 'mediaBox', mediaBox);
  37953. },
  37954. get cropBox() {
  37955. var cropBox = this.getInheritedPageProp('CropBox', true);
  37956. if (!isArray(cropBox) || cropBox.length !== 4) {
  37957. return shadow(this, 'cropBox', this.mediaBox);
  37958. }
  37959. return shadow(this, 'cropBox', cropBox);
  37960. },
  37961. get userUnit() {
  37962. var obj = this.getPageProp('UserUnit');
  37963. if (!isNum(obj) || obj <= 0) {
  37964. obj = DEFAULT_USER_UNIT;
  37965. }
  37966. return shadow(this, 'userUnit', obj);
  37967. },
  37968. get view() {
  37969. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  37970. if (mediaBox === cropBox) {
  37971. return shadow(this, 'view', mediaBox);
  37972. }
  37973. var intersection = Util.intersect(cropBox, mediaBox);
  37974. return shadow(this, 'view', intersection || mediaBox);
  37975. },
  37976. get rotate() {
  37977. var rotate = this.getInheritedPageProp('Rotate') || 0;
  37978. if (rotate % 90 !== 0) {
  37979. rotate = 0;
  37980. } else if (rotate >= 360) {
  37981. rotate = rotate % 360;
  37982. } else if (rotate < 0) {
  37983. rotate = (rotate % 360 + 360) % 360;
  37984. }
  37985. return shadow(this, 'rotate', rotate);
  37986. },
  37987. getContentStream: function Page_getContentStream() {
  37988. var content = this.content;
  37989. var stream;
  37990. if (isArray(content)) {
  37991. var xref = this.xref;
  37992. var i, n = content.length;
  37993. var streams = [];
  37994. for (i = 0; i < n; ++i) {
  37995. streams.push(xref.fetchIfRef(content[i]));
  37996. }
  37997. stream = new StreamsSequenceStream(streams);
  37998. } else if (isStream(content)) {
  37999. stream = content;
  38000. } else {
  38001. stream = new NullStream();
  38002. }
  38003. return stream;
  38004. },
  38005. loadResources: function Page_loadResources(keys) {
  38006. if (!this.resourcesPromise) {
  38007. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  38008. }
  38009. return this.resourcesPromise.then(function resourceSuccess() {
  38010. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  38011. return objectLoader.load();
  38012. }.bind(this));
  38013. },
  38014. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  38015. var self = this;
  38016. var pdfManager = this.pdfManager;
  38017. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  38018. var resourcesPromise = this.loadResources([
  38019. 'ExtGState',
  38020. 'ColorSpace',
  38021. 'Pattern',
  38022. 'Shading',
  38023. 'XObject',
  38024. 'Font'
  38025. ]);
  38026. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.builtInCMapCache, this.evaluatorOptions);
  38027. var dataPromises = Promise.all([
  38028. contentStreamPromise,
  38029. resourcesPromise
  38030. ]);
  38031. var pageListPromise = dataPromises.then(function (data) {
  38032. var contentStream = data[0];
  38033. var opList = new OperatorList(intent, handler, self.pageIndex);
  38034. handler.send('StartRenderPage', {
  38035. transparency: partialEvaluator.hasBlendModes(self.resources),
  38036. pageIndex: self.pageIndex,
  38037. intent: intent
  38038. });
  38039. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  38040. return opList;
  38041. });
  38042. });
  38043. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  38044. return Promise.all([
  38045. pageListPromise,
  38046. annotationsPromise
  38047. ]).then(function (datas) {
  38048. var pageOpList = datas[0];
  38049. var annotations = datas[1];
  38050. if (annotations.length === 0) {
  38051. pageOpList.flush(true);
  38052. return pageOpList;
  38053. }
  38054. var i, ii, opListPromises = [];
  38055. for (i = 0, ii = annotations.length; i < ii; i++) {
  38056. if (isAnnotationRenderable(annotations[i], intent)) {
  38057. opListPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderInteractiveForms));
  38058. }
  38059. }
  38060. return Promise.all(opListPromises).then(function (opLists) {
  38061. pageOpList.addOp(OPS.beginAnnotations, []);
  38062. for (i = 0, ii = opLists.length; i < ii; i++) {
  38063. pageOpList.addOpList(opLists[i]);
  38064. }
  38065. pageOpList.addOp(OPS.endAnnotations, []);
  38066. pageOpList.flush(true);
  38067. return pageOpList;
  38068. });
  38069. });
  38070. },
  38071. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  38072. var handler = {
  38073. on: function nullHandlerOn() {
  38074. },
  38075. send: function nullHandlerSend() {
  38076. }
  38077. };
  38078. var self = this;
  38079. var pdfManager = this.pdfManager;
  38080. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  38081. var resourcesPromise = this.loadResources([
  38082. 'ExtGState',
  38083. 'XObject',
  38084. 'Font'
  38085. ]);
  38086. var dataPromises = Promise.all([
  38087. contentStreamPromise,
  38088. resourcesPromise
  38089. ]);
  38090. return dataPromises.then(function (data) {
  38091. var contentStream = data[0];
  38092. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.builtInCMapCache, self.evaluatorOptions);
  38093. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  38094. });
  38095. },
  38096. getAnnotationsData: function Page_getAnnotationsData(intent) {
  38097. var annotations = this.annotations;
  38098. var annotationsData = [];
  38099. for (var i = 0, n = annotations.length; i < n; ++i) {
  38100. if (!intent || isAnnotationRenderable(annotations[i], intent)) {
  38101. annotationsData.push(annotations[i].data);
  38102. }
  38103. }
  38104. return annotationsData;
  38105. },
  38106. get annotations() {
  38107. var annotations = [];
  38108. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  38109. var annotationFactory = new AnnotationFactory();
  38110. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  38111. var annotationRef = annotationRefs[i];
  38112. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  38113. if (annotation) {
  38114. annotations.push(annotation);
  38115. }
  38116. }
  38117. return shadow(this, 'annotations', annotations);
  38118. }
  38119. };
  38120. return Page;
  38121. }();
  38122. var PDFDocument = function PDFDocumentClosure() {
  38123. var FINGERPRINT_FIRST_BYTES = 1024;
  38124. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  38125. function PDFDocument(pdfManager, arg) {
  38126. var stream;
  38127. if (isStream(arg)) {
  38128. stream = arg;
  38129. } else if (isArrayBuffer(arg)) {
  38130. stream = new Stream(arg);
  38131. } else {
  38132. error('PDFDocument: Unknown argument type');
  38133. }
  38134. assert(stream.length > 0, 'stream must have data');
  38135. this.pdfManager = pdfManager;
  38136. this.stream = stream;
  38137. this.xref = new XRef(stream, pdfManager);
  38138. }
  38139. function find(stream, needle, limit, backwards) {
  38140. var pos = stream.pos;
  38141. var end = stream.end;
  38142. var strBuf = [];
  38143. if (pos + limit > end) {
  38144. limit = end - pos;
  38145. }
  38146. for (var n = 0; n < limit; ++n) {
  38147. strBuf.push(String.fromCharCode(stream.getByte()));
  38148. }
  38149. var str = strBuf.join('');
  38150. stream.pos = pos;
  38151. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  38152. if (index === -1) {
  38153. return false;
  38154. }
  38155. stream.pos += index;
  38156. return true;
  38157. }
  38158. var DocumentInfoValidators = {
  38159. get entries() {
  38160. return shadow(this, 'entries', {
  38161. Title: isString,
  38162. Author: isString,
  38163. Subject: isString,
  38164. Keywords: isString,
  38165. Creator: isString,
  38166. Producer: isString,
  38167. CreationDate: isString,
  38168. ModDate: isString,
  38169. Trapped: isName
  38170. });
  38171. }
  38172. };
  38173. PDFDocument.prototype = {
  38174. parse: function PDFDocument_parse(recoveryMode) {
  38175. this.setup(recoveryMode);
  38176. var version = this.catalog.catDict.get('Version');
  38177. if (isName(version)) {
  38178. this.pdfFormatVersion = version.name;
  38179. }
  38180. try {
  38181. this.acroForm = this.catalog.catDict.get('AcroForm');
  38182. if (this.acroForm) {
  38183. this.xfa = this.acroForm.get('XFA');
  38184. var fields = this.acroForm.get('Fields');
  38185. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  38186. this.acroForm = null;
  38187. }
  38188. }
  38189. } catch (ex) {
  38190. info('Something wrong with AcroForm entry');
  38191. this.acroForm = null;
  38192. }
  38193. },
  38194. get linearization() {
  38195. var linearization = null;
  38196. if (this.stream.length) {
  38197. try {
  38198. linearization = Linearization.create(this.stream);
  38199. } catch (err) {
  38200. if (err instanceof MissingDataException) {
  38201. throw err;
  38202. }
  38203. info(err);
  38204. }
  38205. }
  38206. return shadow(this, 'linearization', linearization);
  38207. },
  38208. get startXRef() {
  38209. var stream = this.stream;
  38210. var startXRef = 0;
  38211. var linearization = this.linearization;
  38212. if (linearization) {
  38213. stream.reset();
  38214. if (find(stream, 'endobj', 1024)) {
  38215. startXRef = stream.pos + 6;
  38216. }
  38217. } else {
  38218. var step = 1024;
  38219. var found = false, pos = stream.end;
  38220. while (!found && pos > 0) {
  38221. pos -= step - 'startxref'.length;
  38222. if (pos < 0) {
  38223. pos = 0;
  38224. }
  38225. stream.pos = pos;
  38226. found = find(stream, 'startxref', step, true);
  38227. }
  38228. if (found) {
  38229. stream.skip(9);
  38230. var ch;
  38231. do {
  38232. ch = stream.getByte();
  38233. } while (isSpace(ch));
  38234. var str = '';
  38235. while (ch >= 0x20 && ch <= 0x39) {
  38236. str += String.fromCharCode(ch);
  38237. ch = stream.getByte();
  38238. }
  38239. startXRef = parseInt(str, 10);
  38240. if (isNaN(startXRef)) {
  38241. startXRef = 0;
  38242. }
  38243. }
  38244. }
  38245. return shadow(this, 'startXRef', startXRef);
  38246. },
  38247. get mainXRefEntriesOffset() {
  38248. var mainXRefEntriesOffset = 0;
  38249. var linearization = this.linearization;
  38250. if (linearization) {
  38251. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  38252. }
  38253. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  38254. },
  38255. checkHeader: function PDFDocument_checkHeader() {
  38256. var stream = this.stream;
  38257. stream.reset();
  38258. if (find(stream, '%PDF-', 1024)) {
  38259. stream.moveStart();
  38260. var MAX_VERSION_LENGTH = 12;
  38261. var version = '', ch;
  38262. while ((ch = stream.getByte()) > 0x20) {
  38263. if (version.length >= MAX_VERSION_LENGTH) {
  38264. break;
  38265. }
  38266. version += String.fromCharCode(ch);
  38267. }
  38268. if (!this.pdfFormatVersion) {
  38269. this.pdfFormatVersion = version.substring(5);
  38270. }
  38271. return;
  38272. }
  38273. },
  38274. parseStartXRef: function PDFDocument_parseStartXRef() {
  38275. var startXRef = this.startXRef;
  38276. this.xref.setStartXRef(startXRef);
  38277. },
  38278. setup: function PDFDocument_setup(recoveryMode) {
  38279. this.xref.parse(recoveryMode);
  38280. var self = this;
  38281. var pageFactory = {
  38282. createPage: function (pageIndex, dict, ref, fontCache, builtInCMapCache) {
  38283. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache, builtInCMapCache);
  38284. }
  38285. };
  38286. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  38287. },
  38288. get numPages() {
  38289. var linearization = this.linearization;
  38290. var num = linearization ? linearization.numPages : this.catalog.numPages;
  38291. return shadow(this, 'numPages', num);
  38292. },
  38293. get documentInfo() {
  38294. var docInfo = {
  38295. PDFFormatVersion: this.pdfFormatVersion,
  38296. IsAcroFormPresent: !!this.acroForm,
  38297. IsXFAPresent: !!this.xfa
  38298. };
  38299. var infoDict;
  38300. try {
  38301. infoDict = this.xref.trailer.get('Info');
  38302. } catch (err) {
  38303. info('The document information dictionary is invalid.');
  38304. }
  38305. if (infoDict) {
  38306. var validEntries = DocumentInfoValidators.entries;
  38307. for (var key in validEntries) {
  38308. if (infoDict.has(key)) {
  38309. var value = infoDict.get(key);
  38310. if (validEntries[key](value)) {
  38311. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  38312. } else {
  38313. info('Bad value in document info for "' + key + '"');
  38314. }
  38315. }
  38316. }
  38317. }
  38318. return shadow(this, 'documentInfo', docInfo);
  38319. },
  38320. get fingerprint() {
  38321. var xref = this.xref, hash, fileID = '';
  38322. var idArray = xref.trailer.get('ID');
  38323. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  38324. hash = stringToBytes(idArray[0]);
  38325. } else {
  38326. if (this.stream.ensureRange) {
  38327. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  38328. }
  38329. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  38330. }
  38331. for (var i = 0, n = hash.length; i < n; i++) {
  38332. var hex = hash[i].toString(16);
  38333. fileID += hex.length === 1 ? '0' + hex : hex;
  38334. }
  38335. return shadow(this, 'fingerprint', fileID);
  38336. },
  38337. getPage: function PDFDocument_getPage(pageIndex) {
  38338. return this.catalog.getPage(pageIndex);
  38339. },
  38340. cleanup: function PDFDocument_cleanup() {
  38341. return this.catalog.cleanup();
  38342. }
  38343. };
  38344. return PDFDocument;
  38345. }();
  38346. exports.Page = Page;
  38347. exports.PDFDocument = PDFDocument;
  38348. /***/ }),
  38349. /* 25 */
  38350. /***/ (function(module, exports, __w_pdfjs_require__) {
  38351. "use strict";
  38352. var sharedUtil = __w_pdfjs_require__(0);
  38353. var coreStream = __w_pdfjs_require__(2);
  38354. var coreGlyphList = __w_pdfjs_require__(7);
  38355. var coreEncodings = __w_pdfjs_require__(4);
  38356. var coreCFFParser = __w_pdfjs_require__(11);
  38357. var Util = sharedUtil.Util;
  38358. var bytesToString = sharedUtil.bytesToString;
  38359. var error = sharedUtil.error;
  38360. var Stream = coreStream.Stream;
  38361. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  38362. var StandardEncoding = coreEncodings.StandardEncoding;
  38363. var CFFParser = coreCFFParser.CFFParser;
  38364. var FontRendererFactory = function FontRendererFactoryClosure() {
  38365. function getLong(data, offset) {
  38366. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  38367. }
  38368. function getUshort(data, offset) {
  38369. return data[offset] << 8 | data[offset + 1];
  38370. }
  38371. function parseCmap(data, start, end) {
  38372. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  38373. var format = getUshort(data, start + offset);
  38374. var ranges, p, i;
  38375. if (format === 4) {
  38376. getUshort(data, start + offset + 2);
  38377. var segCount = getUshort(data, start + offset + 6) >> 1;
  38378. p = start + offset + 14;
  38379. ranges = [];
  38380. for (i = 0; i < segCount; i++, p += 2) {
  38381. ranges[i] = { end: getUshort(data, p) };
  38382. }
  38383. p += 2;
  38384. for (i = 0; i < segCount; i++, p += 2) {
  38385. ranges[i].start = getUshort(data, p);
  38386. }
  38387. for (i = 0; i < segCount; i++, p += 2) {
  38388. ranges[i].idDelta = getUshort(data, p);
  38389. }
  38390. for (i = 0; i < segCount; i++, p += 2) {
  38391. var idOffset = getUshort(data, p);
  38392. if (idOffset === 0) {
  38393. continue;
  38394. }
  38395. ranges[i].ids = [];
  38396. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  38397. ranges[i].ids[j] = getUshort(data, p + idOffset);
  38398. idOffset += 2;
  38399. }
  38400. }
  38401. return ranges;
  38402. } else if (format === 12) {
  38403. getLong(data, start + offset + 4);
  38404. var groups = getLong(data, start + offset + 12);
  38405. p = start + offset + 16;
  38406. ranges = [];
  38407. for (i = 0; i < groups; i++) {
  38408. ranges.push({
  38409. start: getLong(data, p),
  38410. end: getLong(data, p + 4),
  38411. idDelta: getLong(data, p + 8) - getLong(data, p)
  38412. });
  38413. p += 12;
  38414. }
  38415. return ranges;
  38416. }
  38417. error('not supported cmap: ' + format);
  38418. }
  38419. function parseCff(data, start, end, seacAnalysisEnabled) {
  38420. var properties = {};
  38421. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  38422. var cff = parser.parse();
  38423. return {
  38424. glyphs: cff.charStrings.objects,
  38425. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  38426. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  38427. };
  38428. }
  38429. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  38430. var itemSize, itemDecode;
  38431. if (isGlyphLocationsLong) {
  38432. itemSize = 4;
  38433. itemDecode = function fontItemDecodeLong(data, offset) {
  38434. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  38435. };
  38436. } else {
  38437. itemSize = 2;
  38438. itemDecode = function fontItemDecode(data, offset) {
  38439. return data[offset] << 9 | data[offset + 1] << 1;
  38440. };
  38441. }
  38442. var glyphs = [];
  38443. var startOffset = itemDecode(loca, 0);
  38444. for (var j = itemSize; j < loca.length; j += itemSize) {
  38445. var endOffset = itemDecode(loca, j);
  38446. glyphs.push(glyf.subarray(startOffset, endOffset));
  38447. startOffset = endOffset;
  38448. }
  38449. return glyphs;
  38450. }
  38451. function lookupCmap(ranges, unicode) {
  38452. var code = unicode.charCodeAt(0), gid = 0;
  38453. var l = 0, r = ranges.length - 1;
  38454. while (l < r) {
  38455. var c = l + r + 1 >> 1;
  38456. if (code < ranges[c].start) {
  38457. r = c - 1;
  38458. } else {
  38459. l = c;
  38460. }
  38461. }
  38462. if (ranges[l].start <= code && code <= ranges[l].end) {
  38463. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  38464. }
  38465. return {
  38466. charCode: code,
  38467. glyphId: gid
  38468. };
  38469. }
  38470. function compileGlyf(code, cmds, font) {
  38471. function moveTo(x, y) {
  38472. cmds.push({
  38473. cmd: 'moveTo',
  38474. args: [
  38475. x,
  38476. y
  38477. ]
  38478. });
  38479. }
  38480. function lineTo(x, y) {
  38481. cmds.push({
  38482. cmd: 'lineTo',
  38483. args: [
  38484. x,
  38485. y
  38486. ]
  38487. });
  38488. }
  38489. function quadraticCurveTo(xa, ya, x, y) {
  38490. cmds.push({
  38491. cmd: 'quadraticCurveTo',
  38492. args: [
  38493. xa,
  38494. ya,
  38495. x,
  38496. y
  38497. ]
  38498. });
  38499. }
  38500. var i = 0;
  38501. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  38502. var flags;
  38503. var x = 0, y = 0;
  38504. i += 10;
  38505. if (numberOfContours < 0) {
  38506. do {
  38507. flags = code[i] << 8 | code[i + 1];
  38508. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  38509. i += 4;
  38510. var arg1, arg2;
  38511. if (flags & 0x01) {
  38512. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  38513. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  38514. i += 4;
  38515. } else {
  38516. arg1 = code[i++];
  38517. arg2 = code[i++];
  38518. }
  38519. if (flags & 0x02) {
  38520. x = arg1;
  38521. y = arg2;
  38522. } else {
  38523. x = 0;
  38524. y = 0;
  38525. }
  38526. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  38527. if (flags & 0x08) {
  38528. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  38529. i += 2;
  38530. } else if (flags & 0x40) {
  38531. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  38532. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  38533. i += 4;
  38534. } else if (flags & 0x80) {
  38535. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  38536. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  38537. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  38538. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  38539. i += 8;
  38540. }
  38541. var subglyph = font.glyphs[glyphIndex];
  38542. if (subglyph) {
  38543. cmds.push({ cmd: 'save' });
  38544. cmds.push({
  38545. cmd: 'transform',
  38546. args: [
  38547. scaleX,
  38548. scale01,
  38549. scale10,
  38550. scaleY,
  38551. x,
  38552. y
  38553. ]
  38554. });
  38555. compileGlyf(subglyph, cmds, font);
  38556. cmds.push({ cmd: 'restore' });
  38557. }
  38558. } while (flags & 0x20);
  38559. } else {
  38560. var endPtsOfContours = [];
  38561. var j, jj;
  38562. for (j = 0; j < numberOfContours; j++) {
  38563. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  38564. i += 2;
  38565. }
  38566. var instructionLength = code[i] << 8 | code[i + 1];
  38567. i += 2 + instructionLength;
  38568. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  38569. var points = [];
  38570. while (points.length < numberOfPoints) {
  38571. flags = code[i++];
  38572. var repeat = 1;
  38573. if (flags & 0x08) {
  38574. repeat += code[i++];
  38575. }
  38576. while (repeat-- > 0) {
  38577. points.push({ flags: flags });
  38578. }
  38579. }
  38580. for (j = 0; j < numberOfPoints; j++) {
  38581. switch (points[j].flags & 0x12) {
  38582. case 0x00:
  38583. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  38584. i += 2;
  38585. break;
  38586. case 0x02:
  38587. x -= code[i++];
  38588. break;
  38589. case 0x12:
  38590. x += code[i++];
  38591. break;
  38592. }
  38593. points[j].x = x;
  38594. }
  38595. for (j = 0; j < numberOfPoints; j++) {
  38596. switch (points[j].flags & 0x24) {
  38597. case 0x00:
  38598. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  38599. i += 2;
  38600. break;
  38601. case 0x04:
  38602. y -= code[i++];
  38603. break;
  38604. case 0x24:
  38605. y += code[i++];
  38606. break;
  38607. }
  38608. points[j].y = y;
  38609. }
  38610. var startPoint = 0;
  38611. for (i = 0; i < numberOfContours; i++) {
  38612. var endPoint = endPtsOfContours[i];
  38613. var contour = points.slice(startPoint, endPoint + 1);
  38614. if (contour[0].flags & 1) {
  38615. contour.push(contour[0]);
  38616. } else if (contour[contour.length - 1].flags & 1) {
  38617. contour.unshift(contour[contour.length - 1]);
  38618. } else {
  38619. var p = {
  38620. flags: 1,
  38621. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  38622. y: (contour[0].y + contour[contour.length - 1].y) / 2
  38623. };
  38624. contour.unshift(p);
  38625. contour.push(p);
  38626. }
  38627. moveTo(contour[0].x, contour[0].y);
  38628. for (j = 1, jj = contour.length; j < jj; j++) {
  38629. if (contour[j].flags & 1) {
  38630. lineTo(contour[j].x, contour[j].y);
  38631. } else if (contour[j + 1].flags & 1) {
  38632. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  38633. j++;
  38634. } else {
  38635. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  38636. }
  38637. }
  38638. startPoint = endPoint + 1;
  38639. }
  38640. }
  38641. }
  38642. function compileCharString(code, cmds, font) {
  38643. var stack = [];
  38644. var x = 0, y = 0;
  38645. var stems = 0;
  38646. function moveTo(x, y) {
  38647. cmds.push({
  38648. cmd: 'moveTo',
  38649. args: [
  38650. x,
  38651. y
  38652. ]
  38653. });
  38654. }
  38655. function lineTo(x, y) {
  38656. cmds.push({
  38657. cmd: 'lineTo',
  38658. args: [
  38659. x,
  38660. y
  38661. ]
  38662. });
  38663. }
  38664. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  38665. cmds.push({
  38666. cmd: 'bezierCurveTo',
  38667. args: [
  38668. x1,
  38669. y1,
  38670. x2,
  38671. y2,
  38672. x,
  38673. y
  38674. ]
  38675. });
  38676. }
  38677. function parse(code) {
  38678. var i = 0;
  38679. while (i < code.length) {
  38680. var stackClean = false;
  38681. var v = code[i++];
  38682. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  38683. switch (v) {
  38684. case 1:
  38685. stems += stack.length >> 1;
  38686. stackClean = true;
  38687. break;
  38688. case 3:
  38689. stems += stack.length >> 1;
  38690. stackClean = true;
  38691. break;
  38692. case 4:
  38693. y += stack.pop();
  38694. moveTo(x, y);
  38695. stackClean = true;
  38696. break;
  38697. case 5:
  38698. while (stack.length > 0) {
  38699. x += stack.shift();
  38700. y += stack.shift();
  38701. lineTo(x, y);
  38702. }
  38703. break;
  38704. case 6:
  38705. while (stack.length > 0) {
  38706. x += stack.shift();
  38707. lineTo(x, y);
  38708. if (stack.length === 0) {
  38709. break;
  38710. }
  38711. y += stack.shift();
  38712. lineTo(x, y);
  38713. }
  38714. break;
  38715. case 7:
  38716. while (stack.length > 0) {
  38717. y += stack.shift();
  38718. lineTo(x, y);
  38719. if (stack.length === 0) {
  38720. break;
  38721. }
  38722. x += stack.shift();
  38723. lineTo(x, y);
  38724. }
  38725. break;
  38726. case 8:
  38727. while (stack.length > 0) {
  38728. xa = x + stack.shift();
  38729. ya = y + stack.shift();
  38730. xb = xa + stack.shift();
  38731. yb = ya + stack.shift();
  38732. x = xb + stack.shift();
  38733. y = yb + stack.shift();
  38734. bezierCurveTo(xa, ya, xb, yb, x, y);
  38735. }
  38736. break;
  38737. case 10:
  38738. n = stack.pop() + font.subrsBias;
  38739. subrCode = font.subrs[n];
  38740. if (subrCode) {
  38741. parse(subrCode);
  38742. }
  38743. break;
  38744. case 11:
  38745. return;
  38746. case 12:
  38747. v = code[i++];
  38748. switch (v) {
  38749. case 34:
  38750. xa = x + stack.shift();
  38751. xb = xa + stack.shift();
  38752. y1 = y + stack.shift();
  38753. x = xb + stack.shift();
  38754. bezierCurveTo(xa, y, xb, y1, x, y1);
  38755. xa = x + stack.shift();
  38756. xb = xa + stack.shift();
  38757. x = xb + stack.shift();
  38758. bezierCurveTo(xa, y1, xb, y, x, y);
  38759. break;
  38760. case 35:
  38761. xa = x + stack.shift();
  38762. ya = y + stack.shift();
  38763. xb = xa + stack.shift();
  38764. yb = ya + stack.shift();
  38765. x = xb + stack.shift();
  38766. y = yb + stack.shift();
  38767. bezierCurveTo(xa, ya, xb, yb, x, y);
  38768. xa = x + stack.shift();
  38769. ya = y + stack.shift();
  38770. xb = xa + stack.shift();
  38771. yb = ya + stack.shift();
  38772. x = xb + stack.shift();
  38773. y = yb + stack.shift();
  38774. bezierCurveTo(xa, ya, xb, yb, x, y);
  38775. stack.pop();
  38776. break;
  38777. case 36:
  38778. xa = x + stack.shift();
  38779. y1 = y + stack.shift();
  38780. xb = xa + stack.shift();
  38781. y2 = y1 + stack.shift();
  38782. x = xb + stack.shift();
  38783. bezierCurveTo(xa, y1, xb, y2, x, y2);
  38784. xa = x + stack.shift();
  38785. xb = xa + stack.shift();
  38786. y3 = y2 + stack.shift();
  38787. x = xb + stack.shift();
  38788. bezierCurveTo(xa, y2, xb, y3, x, y);
  38789. break;
  38790. case 37:
  38791. var x0 = x, y0 = y;
  38792. xa = x + stack.shift();
  38793. ya = y + stack.shift();
  38794. xb = xa + stack.shift();
  38795. yb = ya + stack.shift();
  38796. x = xb + stack.shift();
  38797. y = yb + stack.shift();
  38798. bezierCurveTo(xa, ya, xb, yb, x, y);
  38799. xa = x + stack.shift();
  38800. ya = y + stack.shift();
  38801. xb = xa + stack.shift();
  38802. yb = ya + stack.shift();
  38803. x = xb;
  38804. y = yb;
  38805. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  38806. x += stack.shift();
  38807. } else {
  38808. y += stack.shift();
  38809. }
  38810. bezierCurveTo(xa, ya, xb, yb, x, y);
  38811. break;
  38812. default:
  38813. error('unknown operator: 12 ' + v);
  38814. }
  38815. break;
  38816. case 14:
  38817. if (stack.length >= 4) {
  38818. var achar = stack.pop();
  38819. var bchar = stack.pop();
  38820. y = stack.pop();
  38821. x = stack.pop();
  38822. cmds.push({ cmd: 'save' });
  38823. cmds.push({
  38824. cmd: 'translate',
  38825. args: [
  38826. x,
  38827. y
  38828. ]
  38829. });
  38830. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  38831. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  38832. cmds.push({ cmd: 'restore' });
  38833. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  38834. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  38835. }
  38836. return;
  38837. case 18:
  38838. stems += stack.length >> 1;
  38839. stackClean = true;
  38840. break;
  38841. case 19:
  38842. stems += stack.length >> 1;
  38843. i += stems + 7 >> 3;
  38844. stackClean = true;
  38845. break;
  38846. case 20:
  38847. stems += stack.length >> 1;
  38848. i += stems + 7 >> 3;
  38849. stackClean = true;
  38850. break;
  38851. case 21:
  38852. y += stack.pop();
  38853. x += stack.pop();
  38854. moveTo(x, y);
  38855. stackClean = true;
  38856. break;
  38857. case 22:
  38858. x += stack.pop();
  38859. moveTo(x, y);
  38860. stackClean = true;
  38861. break;
  38862. case 23:
  38863. stems += stack.length >> 1;
  38864. stackClean = true;
  38865. break;
  38866. case 24:
  38867. while (stack.length > 2) {
  38868. xa = x + stack.shift();
  38869. ya = y + stack.shift();
  38870. xb = xa + stack.shift();
  38871. yb = ya + stack.shift();
  38872. x = xb + stack.shift();
  38873. y = yb + stack.shift();
  38874. bezierCurveTo(xa, ya, xb, yb, x, y);
  38875. }
  38876. x += stack.shift();
  38877. y += stack.shift();
  38878. lineTo(x, y);
  38879. break;
  38880. case 25:
  38881. while (stack.length > 6) {
  38882. x += stack.shift();
  38883. y += stack.shift();
  38884. lineTo(x, y);
  38885. }
  38886. xa = x + stack.shift();
  38887. ya = y + stack.shift();
  38888. xb = xa + stack.shift();
  38889. yb = ya + stack.shift();
  38890. x = xb + stack.shift();
  38891. y = yb + stack.shift();
  38892. bezierCurveTo(xa, ya, xb, yb, x, y);
  38893. break;
  38894. case 26:
  38895. if (stack.length % 2) {
  38896. x += stack.shift();
  38897. }
  38898. while (stack.length > 0) {
  38899. xa = x;
  38900. ya = y + stack.shift();
  38901. xb = xa + stack.shift();
  38902. yb = ya + stack.shift();
  38903. x = xb;
  38904. y = yb + stack.shift();
  38905. bezierCurveTo(xa, ya, xb, yb, x, y);
  38906. }
  38907. break;
  38908. case 27:
  38909. if (stack.length % 2) {
  38910. y += stack.shift();
  38911. }
  38912. while (stack.length > 0) {
  38913. xa = x + stack.shift();
  38914. ya = y;
  38915. xb = xa + stack.shift();
  38916. yb = ya + stack.shift();
  38917. x = xb + stack.shift();
  38918. y = yb;
  38919. bezierCurveTo(xa, ya, xb, yb, x, y);
  38920. }
  38921. break;
  38922. case 28:
  38923. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  38924. i += 2;
  38925. break;
  38926. case 29:
  38927. n = stack.pop() + font.gsubrsBias;
  38928. subrCode = font.gsubrs[n];
  38929. if (subrCode) {
  38930. parse(subrCode);
  38931. }
  38932. break;
  38933. case 30:
  38934. while (stack.length > 0) {
  38935. xa = x;
  38936. ya = y + stack.shift();
  38937. xb = xa + stack.shift();
  38938. yb = ya + stack.shift();
  38939. x = xb + stack.shift();
  38940. y = yb + (stack.length === 1 ? stack.shift() : 0);
  38941. bezierCurveTo(xa, ya, xb, yb, x, y);
  38942. if (stack.length === 0) {
  38943. break;
  38944. }
  38945. xa = x + stack.shift();
  38946. ya = y;
  38947. xb = xa + stack.shift();
  38948. yb = ya + stack.shift();
  38949. y = yb + stack.shift();
  38950. x = xb + (stack.length === 1 ? stack.shift() : 0);
  38951. bezierCurveTo(xa, ya, xb, yb, x, y);
  38952. }
  38953. break;
  38954. case 31:
  38955. while (stack.length > 0) {
  38956. xa = x + stack.shift();
  38957. ya = y;
  38958. xb = xa + stack.shift();
  38959. yb = ya + stack.shift();
  38960. y = yb + stack.shift();
  38961. x = xb + (stack.length === 1 ? stack.shift() : 0);
  38962. bezierCurveTo(xa, ya, xb, yb, x, y);
  38963. if (stack.length === 0) {
  38964. break;
  38965. }
  38966. xa = x;
  38967. ya = y + stack.shift();
  38968. xb = xa + stack.shift();
  38969. yb = ya + stack.shift();
  38970. x = xb + stack.shift();
  38971. y = yb + (stack.length === 1 ? stack.shift() : 0);
  38972. bezierCurveTo(xa, ya, xb, yb, x, y);
  38973. }
  38974. break;
  38975. default:
  38976. if (v < 32) {
  38977. error('unknown operator: ' + v);
  38978. }
  38979. if (v < 247) {
  38980. stack.push(v - 139);
  38981. } else if (v < 251) {
  38982. stack.push((v - 247) * 256 + code[i++] + 108);
  38983. } else if (v < 255) {
  38984. stack.push(-(v - 251) * 256 - code[i++] - 108);
  38985. } else {
  38986. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  38987. i += 4;
  38988. }
  38989. break;
  38990. }
  38991. if (stackClean) {
  38992. stack.length = 0;
  38993. }
  38994. }
  38995. }
  38996. parse(code);
  38997. }
  38998. var noop = '';
  38999. function CompiledFont(fontMatrix) {
  39000. this.compiledGlyphs = Object.create(null);
  39001. this.compiledCharCodeToGlyphId = Object.create(null);
  39002. this.fontMatrix = fontMatrix;
  39003. }
  39004. CompiledFont.prototype = {
  39005. getPathJs: function (unicode) {
  39006. var cmap = lookupCmap(this.cmap, unicode);
  39007. var fn = this.compiledGlyphs[cmap.glyphId];
  39008. if (!fn) {
  39009. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  39010. this.compiledGlyphs[cmap.glyphId] = fn;
  39011. }
  39012. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  39013. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  39014. }
  39015. return fn;
  39016. },
  39017. compileGlyph: function (code) {
  39018. if (!code || code.length === 0 || code[0] === 14) {
  39019. return noop;
  39020. }
  39021. var cmds = [];
  39022. cmds.push({ cmd: 'save' });
  39023. cmds.push({
  39024. cmd: 'transform',
  39025. args: this.fontMatrix.slice()
  39026. });
  39027. cmds.push({
  39028. cmd: 'scale',
  39029. args: [
  39030. 'size',
  39031. '-size'
  39032. ]
  39033. });
  39034. this.compileGlyphImpl(code, cmds);
  39035. cmds.push({ cmd: 'restore' });
  39036. return cmds;
  39037. },
  39038. compileGlyphImpl: function () {
  39039. error('Children classes should implement this.');
  39040. },
  39041. hasBuiltPath: function (unicode) {
  39042. var cmap = lookupCmap(this.cmap, unicode);
  39043. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  39044. }
  39045. };
  39046. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  39047. fontMatrix = fontMatrix || [
  39048. 0.000488,
  39049. 0,
  39050. 0,
  39051. 0.000488,
  39052. 0,
  39053. 0
  39054. ];
  39055. CompiledFont.call(this, fontMatrix);
  39056. this.glyphs = glyphs;
  39057. this.cmap = cmap;
  39058. }
  39059. Util.inherit(TrueTypeCompiled, CompiledFont, {
  39060. compileGlyphImpl: function (code, cmds) {
  39061. compileGlyf(code, cmds, this);
  39062. }
  39063. });
  39064. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  39065. fontMatrix = fontMatrix || [
  39066. 0.001,
  39067. 0,
  39068. 0,
  39069. 0.001,
  39070. 0,
  39071. 0
  39072. ];
  39073. CompiledFont.call(this, fontMatrix);
  39074. this.glyphs = cffInfo.glyphs;
  39075. this.gsubrs = cffInfo.gsubrs || [];
  39076. this.subrs = cffInfo.subrs || [];
  39077. this.cmap = cmap;
  39078. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  39079. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  39080. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  39081. }
  39082. Util.inherit(Type2Compiled, CompiledFont, {
  39083. compileGlyphImpl: function (code, cmds) {
  39084. compileCharString(code, cmds, this);
  39085. }
  39086. });
  39087. return {
  39088. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  39089. var data = new Uint8Array(font.data);
  39090. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  39091. var numTables = getUshort(data, 4);
  39092. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  39093. var tag = bytesToString(data.subarray(p, p + 4));
  39094. var offset = getLong(data, p + 8);
  39095. var length = getLong(data, p + 12);
  39096. switch (tag) {
  39097. case 'cmap':
  39098. cmap = parseCmap(data, offset, offset + length);
  39099. break;
  39100. case 'glyf':
  39101. glyf = data.subarray(offset, offset + length);
  39102. break;
  39103. case 'loca':
  39104. loca = data.subarray(offset, offset + length);
  39105. break;
  39106. case 'head':
  39107. unitsPerEm = getUshort(data, offset + 18);
  39108. indexToLocFormat = getUshort(data, offset + 50);
  39109. break;
  39110. case 'CFF ':
  39111. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  39112. break;
  39113. }
  39114. }
  39115. if (glyf) {
  39116. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  39117. 1 / unitsPerEm,
  39118. 0,
  39119. 0,
  39120. 1 / unitsPerEm,
  39121. 0,
  39122. 0
  39123. ];
  39124. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  39125. }
  39126. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  39127. }
  39128. };
  39129. }();
  39130. exports.FontRendererFactory = FontRendererFactory;
  39131. /***/ }),
  39132. /* 26 */
  39133. /***/ (function(module, exports, __w_pdfjs_require__) {
  39134. "use strict";
  39135. var sharedUtil = __w_pdfjs_require__(0);
  39136. var corePrimitives = __w_pdfjs_require__(1);
  39137. var coreStream = __w_pdfjs_require__(2);
  39138. var coreGlyphList = __w_pdfjs_require__(7);
  39139. var coreFontRenderer = __w_pdfjs_require__(25);
  39140. var coreEncodings = __w_pdfjs_require__(4);
  39141. var coreStandardFonts = __w_pdfjs_require__(17);
  39142. var coreUnicode = __w_pdfjs_require__(18);
  39143. var coreType1Parser = __w_pdfjs_require__(35);
  39144. var coreCFFParser = __w_pdfjs_require__(11);
  39145. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  39146. var FontType = sharedUtil.FontType;
  39147. var assert = sharedUtil.assert;
  39148. var bytesToString = sharedUtil.bytesToString;
  39149. var error = sharedUtil.error;
  39150. var info = sharedUtil.info;
  39151. var isArray = sharedUtil.isArray;
  39152. var isInt = sharedUtil.isInt;
  39153. var isNum = sharedUtil.isNum;
  39154. var readUint32 = sharedUtil.readUint32;
  39155. var shadow = sharedUtil.shadow;
  39156. var string32 = sharedUtil.string32;
  39157. var warn = sharedUtil.warn;
  39158. var MissingDataException = sharedUtil.MissingDataException;
  39159. var isSpace = sharedUtil.isSpace;
  39160. var Stream = coreStream.Stream;
  39161. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  39162. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  39163. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  39164. var StandardEncoding = coreEncodings.StandardEncoding;
  39165. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  39166. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  39167. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  39168. var getEncoding = coreEncodings.getEncoding;
  39169. var getStdFontMap = coreStandardFonts.getStdFontMap;
  39170. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  39171. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  39172. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  39173. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  39174. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  39175. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  39176. var Type1Parser = coreType1Parser.Type1Parser;
  39177. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  39178. var CFFParser = coreCFFParser.CFFParser;
  39179. var CFFCompiler = coreCFFParser.CFFCompiler;
  39180. var CFF = coreCFFParser.CFF;
  39181. var CFFHeader = coreCFFParser.CFFHeader;
  39182. var CFFTopDict = coreCFFParser.CFFTopDict;
  39183. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  39184. var CFFStrings = coreCFFParser.CFFStrings;
  39185. var CFFIndex = coreCFFParser.CFFIndex;
  39186. var CFFCharset = coreCFFParser.CFFCharset;
  39187. var PRIVATE_USE_OFFSET_START = 0xE000;
  39188. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  39189. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  39190. var PDF_GLYPH_SPACE_UNITS = 1000;
  39191. var SEAC_ANALYSIS_ENABLED = false;
  39192. var FontFlags = {
  39193. FixedPitch: 1,
  39194. Serif: 2,
  39195. Symbolic: 4,
  39196. Script: 8,
  39197. Nonsymbolic: 32,
  39198. Italic: 64,
  39199. AllCap: 65536,
  39200. SmallCap: 131072,
  39201. ForceBold: 262144
  39202. };
  39203. var MacStandardGlyphOrdering = [
  39204. '.notdef',
  39205. '.null',
  39206. 'nonmarkingreturn',
  39207. 'space',
  39208. 'exclam',
  39209. 'quotedbl',
  39210. 'numbersign',
  39211. 'dollar',
  39212. 'percent',
  39213. 'ampersand',
  39214. 'quotesingle',
  39215. 'parenleft',
  39216. 'parenright',
  39217. 'asterisk',
  39218. 'plus',
  39219. 'comma',
  39220. 'hyphen',
  39221. 'period',
  39222. 'slash',
  39223. 'zero',
  39224. 'one',
  39225. 'two',
  39226. 'three',
  39227. 'four',
  39228. 'five',
  39229. 'six',
  39230. 'seven',
  39231. 'eight',
  39232. 'nine',
  39233. 'colon',
  39234. 'semicolon',
  39235. 'less',
  39236. 'equal',
  39237. 'greater',
  39238. 'question',
  39239. 'at',
  39240. 'A',
  39241. 'B',
  39242. 'C',
  39243. 'D',
  39244. 'E',
  39245. 'F',
  39246. 'G',
  39247. 'H',
  39248. 'I',
  39249. 'J',
  39250. 'K',
  39251. 'L',
  39252. 'M',
  39253. 'N',
  39254. 'O',
  39255. 'P',
  39256. 'Q',
  39257. 'R',
  39258. 'S',
  39259. 'T',
  39260. 'U',
  39261. 'V',
  39262. 'W',
  39263. 'X',
  39264. 'Y',
  39265. 'Z',
  39266. 'bracketleft',
  39267. 'backslash',
  39268. 'bracketright',
  39269. 'asciicircum',
  39270. 'underscore',
  39271. 'grave',
  39272. 'a',
  39273. 'b',
  39274. 'c',
  39275. 'd',
  39276. 'e',
  39277. 'f',
  39278. 'g',
  39279. 'h',
  39280. 'i',
  39281. 'j',
  39282. 'k',
  39283. 'l',
  39284. 'm',
  39285. 'n',
  39286. 'o',
  39287. 'p',
  39288. 'q',
  39289. 'r',
  39290. 's',
  39291. 't',
  39292. 'u',
  39293. 'v',
  39294. 'w',
  39295. 'x',
  39296. 'y',
  39297. 'z',
  39298. 'braceleft',
  39299. 'bar',
  39300. 'braceright',
  39301. 'asciitilde',
  39302. 'Adieresis',
  39303. 'Aring',
  39304. 'Ccedilla',
  39305. 'Eacute',
  39306. 'Ntilde',
  39307. 'Odieresis',
  39308. 'Udieresis',
  39309. 'aacute',
  39310. 'agrave',
  39311. 'acircumflex',
  39312. 'adieresis',
  39313. 'atilde',
  39314. 'aring',
  39315. 'ccedilla',
  39316. 'eacute',
  39317. 'egrave',
  39318. 'ecircumflex',
  39319. 'edieresis',
  39320. 'iacute',
  39321. 'igrave',
  39322. 'icircumflex',
  39323. 'idieresis',
  39324. 'ntilde',
  39325. 'oacute',
  39326. 'ograve',
  39327. 'ocircumflex',
  39328. 'odieresis',
  39329. 'otilde',
  39330. 'uacute',
  39331. 'ugrave',
  39332. 'ucircumflex',
  39333. 'udieresis',
  39334. 'dagger',
  39335. 'degree',
  39336. 'cent',
  39337. 'sterling',
  39338. 'section',
  39339. 'bullet',
  39340. 'paragraph',
  39341. 'germandbls',
  39342. 'registered',
  39343. 'copyright',
  39344. 'trademark',
  39345. 'acute',
  39346. 'dieresis',
  39347. 'notequal',
  39348. 'AE',
  39349. 'Oslash',
  39350. 'infinity',
  39351. 'plusminus',
  39352. 'lessequal',
  39353. 'greaterequal',
  39354. 'yen',
  39355. 'mu',
  39356. 'partialdiff',
  39357. 'summation',
  39358. 'product',
  39359. 'pi',
  39360. 'integral',
  39361. 'ordfeminine',
  39362. 'ordmasculine',
  39363. 'Omega',
  39364. 'ae',
  39365. 'oslash',
  39366. 'questiondown',
  39367. 'exclamdown',
  39368. 'logicalnot',
  39369. 'radical',
  39370. 'florin',
  39371. 'approxequal',
  39372. 'Delta',
  39373. 'guillemotleft',
  39374. 'guillemotright',
  39375. 'ellipsis',
  39376. 'nonbreakingspace',
  39377. 'Agrave',
  39378. 'Atilde',
  39379. 'Otilde',
  39380. 'OE',
  39381. 'oe',
  39382. 'endash',
  39383. 'emdash',
  39384. 'quotedblleft',
  39385. 'quotedblright',
  39386. 'quoteleft',
  39387. 'quoteright',
  39388. 'divide',
  39389. 'lozenge',
  39390. 'ydieresis',
  39391. 'Ydieresis',
  39392. 'fraction',
  39393. 'currency',
  39394. 'guilsinglleft',
  39395. 'guilsinglright',
  39396. 'fi',
  39397. 'fl',
  39398. 'daggerdbl',
  39399. 'periodcentered',
  39400. 'quotesinglbase',
  39401. 'quotedblbase',
  39402. 'perthousand',
  39403. 'Acircumflex',
  39404. 'Ecircumflex',
  39405. 'Aacute',
  39406. 'Edieresis',
  39407. 'Egrave',
  39408. 'Iacute',
  39409. 'Icircumflex',
  39410. 'Idieresis',
  39411. 'Igrave',
  39412. 'Oacute',
  39413. 'Ocircumflex',
  39414. 'apple',
  39415. 'Ograve',
  39416. 'Uacute',
  39417. 'Ucircumflex',
  39418. 'Ugrave',
  39419. 'dotlessi',
  39420. 'circumflex',
  39421. 'tilde',
  39422. 'macron',
  39423. 'breve',
  39424. 'dotaccent',
  39425. 'ring',
  39426. 'cedilla',
  39427. 'hungarumlaut',
  39428. 'ogonek',
  39429. 'caron',
  39430. 'Lslash',
  39431. 'lslash',
  39432. 'Scaron',
  39433. 'scaron',
  39434. 'Zcaron',
  39435. 'zcaron',
  39436. 'brokenbar',
  39437. 'Eth',
  39438. 'eth',
  39439. 'Yacute',
  39440. 'yacute',
  39441. 'Thorn',
  39442. 'thorn',
  39443. 'minus',
  39444. 'multiply',
  39445. 'onesuperior',
  39446. 'twosuperior',
  39447. 'threesuperior',
  39448. 'onehalf',
  39449. 'onequarter',
  39450. 'threequarters',
  39451. 'franc',
  39452. 'Gbreve',
  39453. 'gbreve',
  39454. 'Idotaccent',
  39455. 'Scedilla',
  39456. 'scedilla',
  39457. 'Cacute',
  39458. 'cacute',
  39459. 'Ccaron',
  39460. 'ccaron',
  39461. 'dcroat'
  39462. ];
  39463. function adjustWidths(properties) {
  39464. if (!properties.fontMatrix) {
  39465. return;
  39466. }
  39467. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  39468. return;
  39469. }
  39470. var scale = 0.001 / properties.fontMatrix[0];
  39471. var glyphsWidths = properties.widths;
  39472. for (var glyph in glyphsWidths) {
  39473. glyphsWidths[glyph] *= scale;
  39474. }
  39475. properties.defaultWidth *= scale;
  39476. }
  39477. function adjustToUnicode(properties, builtInEncoding) {
  39478. if (properties.hasIncludedToUnicodeMap) {
  39479. return;
  39480. }
  39481. if (properties.hasEncoding) {
  39482. return;
  39483. }
  39484. if (builtInEncoding === properties.defaultEncoding) {
  39485. return;
  39486. }
  39487. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  39488. return;
  39489. }
  39490. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  39491. for (var charCode in builtInEncoding) {
  39492. var glyphName = builtInEncoding[charCode];
  39493. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  39494. if (unicode !== -1) {
  39495. toUnicode[charCode] = String.fromCharCode(unicode);
  39496. }
  39497. }
  39498. properties.toUnicode.amend(toUnicode);
  39499. }
  39500. function getFontType(type, subtype) {
  39501. switch (type) {
  39502. case 'Type1':
  39503. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  39504. case 'CIDFontType0':
  39505. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  39506. case 'OpenType':
  39507. return FontType.OPENTYPE;
  39508. case 'TrueType':
  39509. return FontType.TRUETYPE;
  39510. case 'CIDFontType2':
  39511. return FontType.CIDFONTTYPE2;
  39512. case 'MMType1':
  39513. return FontType.MMTYPE1;
  39514. case 'Type0':
  39515. return FontType.TYPE0;
  39516. default:
  39517. return FontType.UNKNOWN;
  39518. }
  39519. }
  39520. function recoverGlyphName(name, glyphsUnicodeMap) {
  39521. if (glyphsUnicodeMap[name] !== undefined) {
  39522. return name;
  39523. }
  39524. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  39525. if (unicode !== -1) {
  39526. for (var key in glyphsUnicodeMap) {
  39527. if (glyphsUnicodeMap[key] === unicode) {
  39528. return key;
  39529. }
  39530. }
  39531. }
  39532. info('Unable to recover a standard glyph name for: ' + name);
  39533. return name;
  39534. }
  39535. var Glyph = function GlyphClosure() {
  39536. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  39537. this.fontChar = fontChar;
  39538. this.unicode = unicode;
  39539. this.accent = accent;
  39540. this.width = width;
  39541. this.vmetric = vmetric;
  39542. this.operatorListId = operatorListId;
  39543. this.isSpace = isSpace;
  39544. this.isInFont = isInFont;
  39545. }
  39546. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  39547. return this.fontChar === fontChar && this.unicode === unicode && this.accent === accent && this.width === width && this.vmetric === vmetric && this.operatorListId === operatorListId && this.isSpace === isSpace && this.isInFont === isInFont;
  39548. };
  39549. return Glyph;
  39550. }();
  39551. var ToUnicodeMap = function ToUnicodeMapClosure() {
  39552. function ToUnicodeMap(cmap) {
  39553. this._map = cmap;
  39554. }
  39555. ToUnicodeMap.prototype = {
  39556. get length() {
  39557. return this._map.length;
  39558. },
  39559. forEach: function (callback) {
  39560. for (var charCode in this._map) {
  39561. callback(charCode, this._map[charCode].charCodeAt(0));
  39562. }
  39563. },
  39564. has: function (i) {
  39565. return this._map[i] !== undefined;
  39566. },
  39567. get: function (i) {
  39568. return this._map[i];
  39569. },
  39570. charCodeOf: function (v) {
  39571. return this._map.indexOf(v);
  39572. },
  39573. amend: function (map) {
  39574. for (var charCode in map) {
  39575. this._map[charCode] = map[charCode];
  39576. }
  39577. }
  39578. };
  39579. return ToUnicodeMap;
  39580. }();
  39581. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  39582. function IdentityToUnicodeMap(firstChar, lastChar) {
  39583. this.firstChar = firstChar;
  39584. this.lastChar = lastChar;
  39585. }
  39586. IdentityToUnicodeMap.prototype = {
  39587. get length() {
  39588. return this.lastChar + 1 - this.firstChar;
  39589. },
  39590. forEach: function (callback) {
  39591. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  39592. callback(i, i);
  39593. }
  39594. },
  39595. has: function (i) {
  39596. return this.firstChar <= i && i <= this.lastChar;
  39597. },
  39598. get: function (i) {
  39599. if (this.firstChar <= i && i <= this.lastChar) {
  39600. return String.fromCharCode(i);
  39601. }
  39602. return undefined;
  39603. },
  39604. charCodeOf: function (v) {
  39605. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  39606. },
  39607. amend: function (map) {
  39608. error('Should not call amend()');
  39609. }
  39610. };
  39611. return IdentityToUnicodeMap;
  39612. }();
  39613. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  39614. function writeInt16(dest, offset, num) {
  39615. dest[offset] = num >> 8 & 0xFF;
  39616. dest[offset + 1] = num & 0xFF;
  39617. }
  39618. function writeInt32(dest, offset, num) {
  39619. dest[offset] = num >> 24 & 0xFF;
  39620. dest[offset + 1] = num >> 16 & 0xFF;
  39621. dest[offset + 2] = num >> 8 & 0xFF;
  39622. dest[offset + 3] = num & 0xFF;
  39623. }
  39624. function writeData(dest, offset, data) {
  39625. var i, ii;
  39626. if (data instanceof Uint8Array) {
  39627. dest.set(data, offset);
  39628. } else if (typeof data === 'string') {
  39629. for (i = 0, ii = data.length; i < ii; i++) {
  39630. dest[offset++] = data.charCodeAt(i) & 0xFF;
  39631. }
  39632. } else {
  39633. for (i = 0, ii = data.length; i < ii; i++) {
  39634. dest[offset++] = data[i] & 0xFF;
  39635. }
  39636. }
  39637. }
  39638. function OpenTypeFileBuilder(sfnt) {
  39639. this.sfnt = sfnt;
  39640. this.tables = Object.create(null);
  39641. }
  39642. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  39643. var maxPower2 = 1, log2 = 0;
  39644. while ((maxPower2 ^ entriesCount) > maxPower2) {
  39645. maxPower2 <<= 1;
  39646. log2++;
  39647. }
  39648. var searchRange = maxPower2 * entrySize;
  39649. return {
  39650. range: searchRange,
  39651. entry: log2,
  39652. rangeShift: entrySize * entriesCount - searchRange
  39653. };
  39654. };
  39655. var OTF_HEADER_SIZE = 12;
  39656. var OTF_TABLE_ENTRY_SIZE = 16;
  39657. OpenTypeFileBuilder.prototype = {
  39658. toArray: function OpenTypeFileBuilder_toArray() {
  39659. var sfnt = this.sfnt;
  39660. var tables = this.tables;
  39661. var tablesNames = Object.keys(tables);
  39662. tablesNames.sort();
  39663. var numTables = tablesNames.length;
  39664. var i, j, jj, table, tableName;
  39665. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  39666. var tableOffsets = [offset];
  39667. for (i = 0; i < numTables; i++) {
  39668. table = tables[tablesNames[i]];
  39669. var paddedLength = (table.length + 3 & ~3) >>> 0;
  39670. offset += paddedLength;
  39671. tableOffsets.push(offset);
  39672. }
  39673. var file = new Uint8Array(offset);
  39674. for (i = 0; i < numTables; i++) {
  39675. table = tables[tablesNames[i]];
  39676. writeData(file, tableOffsets[i], table);
  39677. }
  39678. if (sfnt === 'true') {
  39679. sfnt = string32(0x00010000);
  39680. }
  39681. file[0] = sfnt.charCodeAt(0) & 0xFF;
  39682. file[1] = sfnt.charCodeAt(1) & 0xFF;
  39683. file[2] = sfnt.charCodeAt(2) & 0xFF;
  39684. file[3] = sfnt.charCodeAt(3) & 0xFF;
  39685. writeInt16(file, 4, numTables);
  39686. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  39687. writeInt16(file, 6, searchParams.range);
  39688. writeInt16(file, 8, searchParams.entry);
  39689. writeInt16(file, 10, searchParams.rangeShift);
  39690. offset = OTF_HEADER_SIZE;
  39691. for (i = 0; i < numTables; i++) {
  39692. tableName = tablesNames[i];
  39693. file[offset] = tableName.charCodeAt(0) & 0xFF;
  39694. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  39695. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  39696. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  39697. var checksum = 0;
  39698. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  39699. var quad = readUint32(file, j);
  39700. checksum = checksum + quad >>> 0;
  39701. }
  39702. writeInt32(file, offset + 4, checksum);
  39703. writeInt32(file, offset + 8, tableOffsets[i]);
  39704. writeInt32(file, offset + 12, tables[tableName].length);
  39705. offset += OTF_TABLE_ENTRY_SIZE;
  39706. }
  39707. return file;
  39708. },
  39709. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  39710. if (tag in this.tables) {
  39711. throw new Error('Table ' + tag + ' already exists');
  39712. }
  39713. this.tables[tag] = data;
  39714. }
  39715. };
  39716. return OpenTypeFileBuilder;
  39717. }();
  39718. var ProblematicCharRanges = new Int32Array([
  39719. 0x0000,
  39720. 0x0020,
  39721. 0x007F,
  39722. 0x00A1,
  39723. 0x00AD,
  39724. 0x00AE,
  39725. 0x0600,
  39726. 0x0780,
  39727. 0x08A0,
  39728. 0x10A0,
  39729. 0x1780,
  39730. 0x1800,
  39731. 0x1C00,
  39732. 0x1C50,
  39733. 0x2000,
  39734. 0x2010,
  39735. 0x2011,
  39736. 0x2012,
  39737. 0x2028,
  39738. 0x2030,
  39739. 0x205F,
  39740. 0x2070,
  39741. 0x25CC,
  39742. 0x25CD,
  39743. 0x3000,
  39744. 0x3001,
  39745. 0xAA60,
  39746. 0xAA80,
  39747. 0xFFF0,
  39748. 0x10000
  39749. ]);
  39750. var Font = function FontClosure() {
  39751. function Font(name, file, properties) {
  39752. var charCode, glyphName, unicode;
  39753. this.name = name;
  39754. this.loadedName = properties.loadedName;
  39755. this.isType3Font = properties.isType3Font;
  39756. this.sizes = [];
  39757. this.missingFile = false;
  39758. this.glyphCache = Object.create(null);
  39759. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  39760. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  39761. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  39762. var type = properties.type;
  39763. var subtype = properties.subtype;
  39764. this.type = type;
  39765. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  39766. this.differences = properties.differences;
  39767. this.widths = properties.widths;
  39768. this.defaultWidth = properties.defaultWidth;
  39769. this.composite = properties.composite;
  39770. this.wideChars = properties.wideChars;
  39771. this.cMap = properties.cMap;
  39772. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  39773. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  39774. this.fontMatrix = properties.fontMatrix;
  39775. this.bbox = properties.bbox;
  39776. this.toUnicode = properties.toUnicode;
  39777. this.toFontChar = [];
  39778. if (properties.type === 'Type3') {
  39779. for (charCode = 0; charCode < 256; charCode++) {
  39780. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  39781. }
  39782. this.fontType = FontType.TYPE3;
  39783. return;
  39784. }
  39785. this.cidEncoding = properties.cidEncoding;
  39786. this.vertical = properties.vertical;
  39787. if (this.vertical) {
  39788. this.vmetrics = properties.vmetrics;
  39789. this.defaultVMetrics = properties.defaultVMetrics;
  39790. }
  39791. var glyphsUnicodeMap;
  39792. if (!file || file.isEmpty) {
  39793. if (file) {
  39794. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  39795. }
  39796. this.missingFile = true;
  39797. var fontName = name.replace(/[,_]/g, '-');
  39798. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  39799. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  39800. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  39801. this.bold = fontName.search(/bold/gi) !== -1;
  39802. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  39803. this.black = name.search(/Black/g) !== -1;
  39804. this.remeasure = Object.keys(this.widths).length > 0;
  39805. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  39806. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  39807. var map = [];
  39808. for (charCode in GlyphMapForStandardFonts) {
  39809. map[+charCode] = GlyphMapForStandardFonts[charCode];
  39810. }
  39811. if (/Arial-?Black/i.test(name)) {
  39812. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  39813. for (charCode in SupplementalGlyphMapForArialBlack) {
  39814. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  39815. }
  39816. }
  39817. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  39818. if (!isIdentityUnicode) {
  39819. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  39820. map[+charCode] = unicodeCharCode;
  39821. });
  39822. }
  39823. this.toFontChar = map;
  39824. this.toUnicode = new ToUnicodeMap(map);
  39825. } else if (/Symbol/i.test(fontName)) {
  39826. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  39827. } else if (/Dingbats/i.test(fontName)) {
  39828. if (/Wingdings/i.test(name)) {
  39829. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  39830. }
  39831. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  39832. } else if (isStandardFont) {
  39833. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  39834. } else {
  39835. glyphsUnicodeMap = getGlyphsUnicode();
  39836. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  39837. if (!this.composite) {
  39838. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  39839. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  39840. if (unicode !== -1) {
  39841. unicodeCharCode = unicode;
  39842. }
  39843. }
  39844. this.toFontChar[charCode] = unicodeCharCode;
  39845. }.bind(this));
  39846. }
  39847. this.loadedName = fontName.split('-')[0];
  39848. this.loading = false;
  39849. this.fontType = getFontType(type, subtype);
  39850. return;
  39851. }
  39852. if (subtype === 'Type1C') {
  39853. if (type !== 'Type1' && type !== 'MMType1') {
  39854. if (isTrueTypeFile(file)) {
  39855. subtype = 'TrueType';
  39856. } else {
  39857. type = 'Type1';
  39858. }
  39859. } else if (isOpenTypeFile(file)) {
  39860. type = subtype = 'OpenType';
  39861. }
  39862. }
  39863. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  39864. type = 'CIDFontType0';
  39865. }
  39866. if (subtype === 'OpenType') {
  39867. type = 'OpenType';
  39868. }
  39869. if (type === 'CIDFontType0') {
  39870. if (isType1File(file)) {
  39871. subtype = 'CIDFontType0';
  39872. } else if (isOpenTypeFile(file)) {
  39873. type = subtype = 'OpenType';
  39874. } else {
  39875. subtype = 'CIDFontType0C';
  39876. }
  39877. }
  39878. var data;
  39879. switch (type) {
  39880. case 'MMType1':
  39881. info('MMType1 font (' + name + '), falling back to Type1.');
  39882. case 'Type1':
  39883. case 'CIDFontType0':
  39884. this.mimetype = 'font/opentype';
  39885. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  39886. adjustWidths(properties);
  39887. data = this.convert(name, cff, properties);
  39888. break;
  39889. case 'OpenType':
  39890. case 'TrueType':
  39891. case 'CIDFontType2':
  39892. this.mimetype = 'font/opentype';
  39893. data = this.checkAndRepair(name, file, properties);
  39894. if (this.isOpenType) {
  39895. adjustWidths(properties);
  39896. type = 'OpenType';
  39897. }
  39898. break;
  39899. default:
  39900. error('Font ' + type + ' is not supported');
  39901. break;
  39902. }
  39903. this.data = data;
  39904. this.fontType = getFontType(type, subtype);
  39905. this.fontMatrix = properties.fontMatrix;
  39906. this.widths = properties.widths;
  39907. this.defaultWidth = properties.defaultWidth;
  39908. this.toUnicode = properties.toUnicode;
  39909. this.encoding = properties.baseEncoding;
  39910. this.seacMap = properties.seacMap;
  39911. this.loading = true;
  39912. }
  39913. Font.getFontID = function () {
  39914. var ID = 1;
  39915. return function Font_getFontID() {
  39916. return String(ID++);
  39917. };
  39918. }();
  39919. function int16(b0, b1) {
  39920. return (b0 << 8) + b1;
  39921. }
  39922. function signedInt16(b0, b1) {
  39923. var value = (b0 << 8) + b1;
  39924. return value & 1 << 15 ? value - 0x10000 : value;
  39925. }
  39926. function int32(b0, b1, b2, b3) {
  39927. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  39928. }
  39929. function string16(value) {
  39930. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  39931. }
  39932. function safeString16(value) {
  39933. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  39934. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  39935. }
  39936. function isTrueTypeFile(file) {
  39937. var header = file.peekBytes(4);
  39938. return readUint32(header, 0) === 0x00010000;
  39939. }
  39940. function isOpenTypeFile(file) {
  39941. var header = file.peekBytes(4);
  39942. return bytesToString(header) === 'OTTO';
  39943. }
  39944. function isType1File(file) {
  39945. var header = file.peekBytes(2);
  39946. if (header[0] === 0x25 && header[1] === 0x21) {
  39947. return true;
  39948. }
  39949. if (header[0] === 0x80 && header[1] === 0x01) {
  39950. return true;
  39951. }
  39952. return false;
  39953. }
  39954. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  39955. var toFontChar = [], unicode;
  39956. for (var i = 0, ii = encoding.length; i < ii; i++) {
  39957. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  39958. if (unicode !== -1) {
  39959. toFontChar[i] = unicode;
  39960. }
  39961. }
  39962. for (var charCode in differences) {
  39963. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  39964. if (unicode !== -1) {
  39965. toFontChar[+charCode] = unicode;
  39966. }
  39967. }
  39968. return toFontChar;
  39969. }
  39970. function isProblematicUnicodeLocation(code) {
  39971. var i = 0, j = ProblematicCharRanges.length - 1;
  39972. while (i < j) {
  39973. var c = i + j + 1 >> 1;
  39974. if (code < ProblematicCharRanges[c]) {
  39975. j = c - 1;
  39976. } else {
  39977. i = c;
  39978. }
  39979. }
  39980. return !(i & 1);
  39981. }
  39982. function adjustMapping(charCodeToGlyphId, properties) {
  39983. var toUnicode = properties.toUnicode;
  39984. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  39985. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  39986. var newMap = Object.create(null);
  39987. var toFontChar = [];
  39988. var usedFontCharCodes = [];
  39989. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  39990. for (var originalCharCode in charCodeToGlyphId) {
  39991. originalCharCode |= 0;
  39992. var glyphId = charCodeToGlyphId[originalCharCode];
  39993. var fontCharCode = originalCharCode;
  39994. var hasUnicodeValue = false;
  39995. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  39996. hasUnicodeValue = true;
  39997. var unicode = toUnicode.get(fontCharCode);
  39998. if (unicode.length === 1) {
  39999. fontCharCode = unicode.charCodeAt(0);
  40000. }
  40001. }
  40002. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  40003. do {
  40004. fontCharCode = nextAvailableFontCharCode++;
  40005. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  40006. fontCharCode = 0xF020;
  40007. nextAvailableFontCharCode = fontCharCode + 1;
  40008. }
  40009. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  40010. }
  40011. newMap[fontCharCode] = glyphId;
  40012. toFontChar[originalCharCode] = fontCharCode;
  40013. usedFontCharCodes[fontCharCode] = true;
  40014. }
  40015. return {
  40016. toFontChar: toFontChar,
  40017. charCodeToGlyphId: newMap,
  40018. nextAvailableFontCharCode: nextAvailableFontCharCode
  40019. };
  40020. }
  40021. function getRanges(glyphs, numGlyphs) {
  40022. var codes = [];
  40023. for (var charCode in glyphs) {
  40024. if (glyphs[charCode] >= numGlyphs) {
  40025. continue;
  40026. }
  40027. codes.push({
  40028. fontCharCode: charCode | 0,
  40029. glyphId: glyphs[charCode]
  40030. });
  40031. }
  40032. codes.sort(function fontGetRangesSort(a, b) {
  40033. return a.fontCharCode - b.fontCharCode;
  40034. });
  40035. var ranges = [];
  40036. var length = codes.length;
  40037. for (var n = 0; n < length;) {
  40038. var start = codes[n].fontCharCode;
  40039. var codeIndices = [codes[n].glyphId];
  40040. ++n;
  40041. var end = start;
  40042. while (n < length && end + 1 === codes[n].fontCharCode) {
  40043. codeIndices.push(codes[n].glyphId);
  40044. ++end;
  40045. ++n;
  40046. if (end === 0xFFFF) {
  40047. break;
  40048. }
  40049. }
  40050. ranges.push([
  40051. start,
  40052. end,
  40053. codeIndices
  40054. ]);
  40055. }
  40056. return ranges;
  40057. }
  40058. function createCmapTable(glyphs, numGlyphs) {
  40059. var ranges = getRanges(glyphs, numGlyphs);
  40060. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  40061. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  40062. var i, ii, j, jj;
  40063. for (i = ranges.length - 1; i >= 0; --i) {
  40064. if (ranges[i][0] <= 0xFFFF) {
  40065. break;
  40066. }
  40067. }
  40068. var bmpLength = i + 1;
  40069. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  40070. ranges[i][1] = 0xFFFE;
  40071. }
  40072. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  40073. var segCount = bmpLength + trailingRangesCount;
  40074. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  40075. var startCount = '';
  40076. var endCount = '';
  40077. var idDeltas = '';
  40078. var idRangeOffsets = '';
  40079. var glyphsIds = '';
  40080. var bias = 0;
  40081. var range, start, end, codes;
  40082. for (i = 0, ii = bmpLength; i < ii; i++) {
  40083. range = ranges[i];
  40084. start = range[0];
  40085. end = range[1];
  40086. startCount += string16(start);
  40087. endCount += string16(end);
  40088. codes = range[2];
  40089. var contiguous = true;
  40090. for (j = 1, jj = codes.length; j < jj; ++j) {
  40091. if (codes[j] !== codes[j - 1] + 1) {
  40092. contiguous = false;
  40093. break;
  40094. }
  40095. }
  40096. if (!contiguous) {
  40097. var offset = (segCount - i) * 2 + bias * 2;
  40098. bias += end - start + 1;
  40099. idDeltas += string16(0);
  40100. idRangeOffsets += string16(offset);
  40101. for (j = 0, jj = codes.length; j < jj; ++j) {
  40102. glyphsIds += string16(codes[j]);
  40103. }
  40104. } else {
  40105. var startCode = codes[0];
  40106. idDeltas += string16(startCode - start & 0xFFFF);
  40107. idRangeOffsets += string16(0);
  40108. }
  40109. }
  40110. if (trailingRangesCount > 0) {
  40111. endCount += '\xFF\xFF';
  40112. startCount += '\xFF\xFF';
  40113. idDeltas += '\x00\x01';
  40114. idRangeOffsets += '\x00\x00';
  40115. }
  40116. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  40117. var format31012 = '';
  40118. var header31012 = '';
  40119. if (numTables > 1) {
  40120. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  40121. format31012 = '';
  40122. for (i = 0, ii = ranges.length; i < ii; i++) {
  40123. range = ranges[i];
  40124. start = range[0];
  40125. codes = range[2];
  40126. var code = codes[0];
  40127. for (j = 1, jj = codes.length; j < jj; ++j) {
  40128. if (codes[j] !== codes[j - 1] + 1) {
  40129. end = range[0] + j - 1;
  40130. format31012 += string32(start) + string32(end) + string32(code);
  40131. start = end + 1;
  40132. code = codes[j];
  40133. }
  40134. }
  40135. format31012 += string32(start) + string32(range[1]) + string32(code);
  40136. }
  40137. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  40138. }
  40139. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  40140. }
  40141. function validateOS2Table(os2) {
  40142. var stream = new Stream(os2.data);
  40143. var version = stream.getUint16();
  40144. stream.getBytes(60);
  40145. var selection = stream.getUint16();
  40146. if (version < 4 && selection & 0x0300) {
  40147. return false;
  40148. }
  40149. var firstChar = stream.getUint16();
  40150. var lastChar = stream.getUint16();
  40151. if (firstChar > lastChar) {
  40152. return false;
  40153. }
  40154. stream.getBytes(6);
  40155. var usWinAscent = stream.getUint16();
  40156. if (usWinAscent === 0) {
  40157. return false;
  40158. }
  40159. os2.data[8] = os2.data[9] = 0;
  40160. return true;
  40161. }
  40162. function createOS2Table(properties, charstrings, override) {
  40163. override = override || {
  40164. unitsPerEm: 0,
  40165. yMax: 0,
  40166. yMin: 0,
  40167. ascent: 0,
  40168. descent: 0
  40169. };
  40170. var ulUnicodeRange1 = 0;
  40171. var ulUnicodeRange2 = 0;
  40172. var ulUnicodeRange3 = 0;
  40173. var ulUnicodeRange4 = 0;
  40174. var firstCharIndex = null;
  40175. var lastCharIndex = 0;
  40176. if (charstrings) {
  40177. for (var code in charstrings) {
  40178. code |= 0;
  40179. if (firstCharIndex > code || !firstCharIndex) {
  40180. firstCharIndex = code;
  40181. }
  40182. if (lastCharIndex < code) {
  40183. lastCharIndex = code;
  40184. }
  40185. var position = getUnicodeRangeFor(code);
  40186. if (position < 32) {
  40187. ulUnicodeRange1 |= 1 << position;
  40188. } else if (position < 64) {
  40189. ulUnicodeRange2 |= 1 << position - 32;
  40190. } else if (position < 96) {
  40191. ulUnicodeRange3 |= 1 << position - 64;
  40192. } else if (position < 123) {
  40193. ulUnicodeRange4 |= 1 << position - 96;
  40194. } else {
  40195. error('Unicode ranges Bits > 123 are reserved for internal usage');
  40196. }
  40197. }
  40198. } else {
  40199. firstCharIndex = 0;
  40200. lastCharIndex = 255;
  40201. }
  40202. var bbox = properties.bbox || [
  40203. 0,
  40204. 0,
  40205. 0,
  40206. 0
  40207. ];
  40208. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  40209. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  40210. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  40211. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  40212. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  40213. typoDescent = -typoDescent;
  40214. }
  40215. var winAscent = override.yMax || typoAscent;
  40216. var winDescent = -override.yMin || -typoDescent;
  40217. return '\x00\x03' + '\x02\x24' + '\x01\xF4' + '\x00\x05' + '\x00\x00' + '\x02\x8A' + '\x02\xBB' + '\x00\x00' + '\x00\x8C' + '\x02\x8A' + '\x02\xBB' + '\x00\x00' + '\x01\xDF' + '\x00\x31' + '\x01\x02' + '\x00\x00' + '\x00\x00\x06' + String.fromCharCode(properties.fixedPitch ? 0x09 : 0x00) + '\x00\x00\x00\x00\x00\x00' + string32(ulUnicodeRange1) + string32(ulUnicodeRange2) + string32(ulUnicodeRange3) + string32(ulUnicodeRange4) + '\x2A\x32\x31\x2A' + string16(properties.italicAngle ? 1 : 0) + string16(firstCharIndex || properties.firstChar) + string16(lastCharIndex || properties.lastChar) + string16(typoAscent) + string16(typoDescent) + '\x00\x64' + string16(winAscent) + string16(winDescent) + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + string16(properties.xHeight) + string16(properties.capHeight) + string16(0) + string16(firstCharIndex || properties.firstChar) + '\x00\x03';
  40218. }
  40219. function createPostTable(properties) {
  40220. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  40221. return '\x00\x03\x00\x00' + string32(angle) + '\x00\x00' + '\x00\x00' + string32(properties.fixedPitch) + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00';
  40222. }
  40223. function createNameTable(name, proto) {
  40224. if (!proto) {
  40225. proto = [
  40226. [],
  40227. []
  40228. ];
  40229. }
  40230. var strings = [
  40231. proto[0][0] || 'Original licence',
  40232. proto[0][1] || name,
  40233. proto[0][2] || 'Unknown',
  40234. proto[0][3] || 'uniqueID',
  40235. proto[0][4] || name,
  40236. proto[0][5] || 'Version 0.11',
  40237. proto[0][6] || '',
  40238. proto[0][7] || 'Unknown',
  40239. proto[0][8] || 'Unknown',
  40240. proto[0][9] || 'Unknown'
  40241. ];
  40242. var stringsUnicode = [];
  40243. var i, ii, j, jj, str;
  40244. for (i = 0, ii = strings.length; i < ii; i++) {
  40245. str = proto[1][i] || strings[i];
  40246. var strBufUnicode = [];
  40247. for (j = 0, jj = str.length; j < jj; j++) {
  40248. strBufUnicode.push(string16(str.charCodeAt(j)));
  40249. }
  40250. stringsUnicode.push(strBufUnicode.join(''));
  40251. }
  40252. var names = [
  40253. strings,
  40254. stringsUnicode
  40255. ];
  40256. var platforms = [
  40257. '\x00\x01',
  40258. '\x00\x03'
  40259. ];
  40260. var encodings = [
  40261. '\x00\x00',
  40262. '\x00\x01'
  40263. ];
  40264. var languages = [
  40265. '\x00\x00',
  40266. '\x04\x09'
  40267. ];
  40268. var namesRecordCount = strings.length * platforms.length;
  40269. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  40270. var strOffset = 0;
  40271. for (i = 0, ii = platforms.length; i < ii; i++) {
  40272. var strs = names[i];
  40273. for (j = 0, jj = strs.length; j < jj; j++) {
  40274. str = strs[j];
  40275. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  40276. nameTable += nameRecord;
  40277. strOffset += str.length;
  40278. }
  40279. }
  40280. nameTable += strings.join('') + stringsUnicode.join('');
  40281. return nameTable;
  40282. }
  40283. Font.prototype = {
  40284. name: null,
  40285. font: null,
  40286. mimetype: null,
  40287. encoding: null,
  40288. get renderer() {
  40289. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  40290. return shadow(this, 'renderer', renderer);
  40291. },
  40292. exportData: function Font_exportData() {
  40293. var data = {};
  40294. for (var i in this) {
  40295. if (this.hasOwnProperty(i)) {
  40296. data[i] = this[i];
  40297. }
  40298. }
  40299. return data;
  40300. },
  40301. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  40302. function readTableEntry(file) {
  40303. var tag = bytesToString(file.getBytes(4));
  40304. var checksum = file.getInt32() >>> 0;
  40305. var offset = file.getInt32() >>> 0;
  40306. var length = file.getInt32() >>> 0;
  40307. var previousPosition = file.pos;
  40308. file.pos = file.start ? file.start : 0;
  40309. file.skip(offset);
  40310. var data = file.getBytes(length);
  40311. file.pos = previousPosition;
  40312. if (tag === 'head') {
  40313. data[8] = data[9] = data[10] = data[11] = 0;
  40314. data[17] |= 0x20;
  40315. }
  40316. return {
  40317. tag: tag,
  40318. checksum: checksum,
  40319. length: length,
  40320. offset: offset,
  40321. data: data
  40322. };
  40323. }
  40324. function readOpenTypeHeader(ttf) {
  40325. return {
  40326. version: bytesToString(ttf.getBytes(4)),
  40327. numTables: ttf.getUint16(),
  40328. searchRange: ttf.getUint16(),
  40329. entrySelector: ttf.getUint16(),
  40330. rangeShift: ttf.getUint16()
  40331. };
  40332. }
  40333. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  40334. if (!cmap) {
  40335. warn('No cmap table available.');
  40336. return {
  40337. platformId: -1,
  40338. encodingId: -1,
  40339. mappings: [],
  40340. hasShortCmap: false
  40341. };
  40342. }
  40343. var segment;
  40344. var start = (font.start ? font.start : 0) + cmap.offset;
  40345. font.pos = start;
  40346. font.getUint16();
  40347. var numTables = font.getUint16();
  40348. var potentialTable;
  40349. var canBreak = false;
  40350. for (var i = 0; i < numTables; i++) {
  40351. var platformId = font.getUint16();
  40352. var encodingId = font.getUint16();
  40353. var offset = font.getInt32() >>> 0;
  40354. var useTable = false;
  40355. if (platformId === 0 && encodingId === 0) {
  40356. useTable = true;
  40357. } else if (platformId === 1 && encodingId === 0) {
  40358. useTable = true;
  40359. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  40360. useTable = true;
  40361. if (!isSymbolicFont) {
  40362. canBreak = true;
  40363. }
  40364. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  40365. useTable = true;
  40366. canBreak = true;
  40367. }
  40368. if (useTable) {
  40369. potentialTable = {
  40370. platformId: platformId,
  40371. encodingId: encodingId,
  40372. offset: offset
  40373. };
  40374. }
  40375. if (canBreak) {
  40376. break;
  40377. }
  40378. }
  40379. if (potentialTable) {
  40380. font.pos = start + potentialTable.offset;
  40381. }
  40382. if (!potentialTable || font.peekByte() === -1) {
  40383. warn('Could not find a preferred cmap table.');
  40384. return {
  40385. platformId: -1,
  40386. encodingId: -1,
  40387. mappings: [],
  40388. hasShortCmap: false
  40389. };
  40390. }
  40391. var format = font.getUint16();
  40392. font.getUint16();
  40393. font.getUint16();
  40394. var hasShortCmap = false;
  40395. var mappings = [];
  40396. var j, glyphId;
  40397. if (format === 0) {
  40398. for (j = 0; j < 256; j++) {
  40399. var index = font.getByte();
  40400. if (!index) {
  40401. continue;
  40402. }
  40403. mappings.push({
  40404. charCode: j,
  40405. glyphId: index
  40406. });
  40407. }
  40408. hasShortCmap = true;
  40409. } else if (format === 4) {
  40410. var segCount = font.getUint16() >> 1;
  40411. font.getBytes(6);
  40412. var segIndex, segments = [];
  40413. for (segIndex = 0; segIndex < segCount; segIndex++) {
  40414. segments.push({ end: font.getUint16() });
  40415. }
  40416. font.getUint16();
  40417. for (segIndex = 0; segIndex < segCount; segIndex++) {
  40418. segments[segIndex].start = font.getUint16();
  40419. }
  40420. for (segIndex = 0; segIndex < segCount; segIndex++) {
  40421. segments[segIndex].delta = font.getUint16();
  40422. }
  40423. var offsetsCount = 0;
  40424. for (segIndex = 0; segIndex < segCount; segIndex++) {
  40425. segment = segments[segIndex];
  40426. var rangeOffset = font.getUint16();
  40427. if (!rangeOffset) {
  40428. segment.offsetIndex = -1;
  40429. continue;
  40430. }
  40431. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  40432. segment.offsetIndex = offsetIndex;
  40433. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  40434. }
  40435. var offsets = [];
  40436. for (j = 0; j < offsetsCount; j++) {
  40437. offsets.push(font.getUint16());
  40438. }
  40439. for (segIndex = 0; segIndex < segCount; segIndex++) {
  40440. segment = segments[segIndex];
  40441. start = segment.start;
  40442. var end = segment.end;
  40443. var delta = segment.delta;
  40444. offsetIndex = segment.offsetIndex;
  40445. for (j = start; j <= end; j++) {
  40446. if (j === 0xFFFF) {
  40447. continue;
  40448. }
  40449. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  40450. glyphId = glyphId + delta & 0xFFFF;
  40451. if (glyphId === 0) {
  40452. continue;
  40453. }
  40454. mappings.push({
  40455. charCode: j,
  40456. glyphId: glyphId
  40457. });
  40458. }
  40459. }
  40460. } else if (format === 6) {
  40461. var firstCode = font.getUint16();
  40462. var entryCount = font.getUint16();
  40463. for (j = 0; j < entryCount; j++) {
  40464. glyphId = font.getUint16();
  40465. var charCode = firstCode + j;
  40466. mappings.push({
  40467. charCode: charCode,
  40468. glyphId: glyphId
  40469. });
  40470. }
  40471. } else {
  40472. warn('cmap table has unsupported format: ' + format);
  40473. return {
  40474. platformId: -1,
  40475. encodingId: -1,
  40476. mappings: [],
  40477. hasShortCmap: false
  40478. };
  40479. }
  40480. mappings.sort(function (a, b) {
  40481. return a.charCode - b.charCode;
  40482. });
  40483. for (i = 1; i < mappings.length; i++) {
  40484. if (mappings[i - 1].charCode === mappings[i].charCode) {
  40485. mappings.splice(i, 1);
  40486. i--;
  40487. }
  40488. }
  40489. return {
  40490. platformId: potentialTable.platformId,
  40491. encodingId: potentialTable.encodingId,
  40492. mappings: mappings,
  40493. hasShortCmap: hasShortCmap
  40494. };
  40495. }
  40496. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  40497. if (!header) {
  40498. if (metrics) {
  40499. metrics.data = null;
  40500. }
  40501. return;
  40502. }
  40503. font.pos = (font.start ? font.start : 0) + header.offset;
  40504. font.pos += header.length - 2;
  40505. var numOfMetrics = font.getUint16();
  40506. if (numOfMetrics > numGlyphs) {
  40507. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  40508. numOfMetrics = numGlyphs;
  40509. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  40510. header.data[35] = numOfMetrics & 0x00ff;
  40511. }
  40512. var numOfSidebearings = numGlyphs - numOfMetrics;
  40513. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  40514. if (numMissing > 0) {
  40515. var entries = new Uint8Array(metrics.length + numMissing * 2);
  40516. entries.set(metrics.data);
  40517. metrics.data = entries;
  40518. }
  40519. }
  40520. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  40521. if (sourceEnd - sourceStart <= 12) {
  40522. return 0;
  40523. }
  40524. var glyf = source.subarray(sourceStart, sourceEnd);
  40525. var contoursCount = glyf[0] << 8 | glyf[1];
  40526. if (contoursCount & 0x8000) {
  40527. dest.set(glyf, destStart);
  40528. return glyf.length;
  40529. }
  40530. var i, j = 10, flagsCount = 0;
  40531. for (i = 0; i < contoursCount; i++) {
  40532. var endPoint = glyf[j] << 8 | glyf[j + 1];
  40533. flagsCount = endPoint + 1;
  40534. j += 2;
  40535. }
  40536. var instructionsStart = j;
  40537. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  40538. j += 2 + instructionsLength;
  40539. var instructionsEnd = j;
  40540. var coordinatesLength = 0;
  40541. for (i = 0; i < flagsCount; i++) {
  40542. var flag = glyf[j++];
  40543. if (flag & 0xC0) {
  40544. glyf[j - 1] = flag & 0x3F;
  40545. }
  40546. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  40547. coordinatesLength += xyLength;
  40548. if (flag & 8) {
  40549. var repeat = glyf[j++];
  40550. i += repeat;
  40551. coordinatesLength += repeat * xyLength;
  40552. }
  40553. }
  40554. if (coordinatesLength === 0) {
  40555. return 0;
  40556. }
  40557. var glyphDataLength = j + coordinatesLength;
  40558. if (glyphDataLength > glyf.length) {
  40559. return 0;
  40560. }
  40561. if (!hintsValid && instructionsLength > 0) {
  40562. dest.set(glyf.subarray(0, instructionsStart), destStart);
  40563. dest.set([
  40564. 0,
  40565. 0
  40566. ], destStart + instructionsStart);
  40567. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  40568. glyphDataLength -= instructionsLength;
  40569. if (glyf.length - glyphDataLength > 3) {
  40570. glyphDataLength = glyphDataLength + 3 & ~3;
  40571. }
  40572. return glyphDataLength;
  40573. }
  40574. if (glyf.length - glyphDataLength > 3) {
  40575. glyphDataLength = glyphDataLength + 3 & ~3;
  40576. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  40577. return glyphDataLength;
  40578. }
  40579. dest.set(glyf, destStart);
  40580. return glyf.length;
  40581. }
  40582. function sanitizeHead(head, numGlyphs, locaLength) {
  40583. var data = head.data;
  40584. var version = int32(data[0], data[1], data[2], data[3]);
  40585. if (version >> 16 !== 1) {
  40586. info('Attempting to fix invalid version in head table: ' + version);
  40587. data[0] = 0;
  40588. data[1] = 1;
  40589. data[2] = 0;
  40590. data[3] = 0;
  40591. }
  40592. var indexToLocFormat = int16(data[50], data[51]);
  40593. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  40594. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  40595. var numGlyphsPlusOne = numGlyphs + 1;
  40596. if (locaLength === numGlyphsPlusOne << 1) {
  40597. data[50] = 0;
  40598. data[51] = 0;
  40599. } else if (locaLength === numGlyphsPlusOne << 2) {
  40600. data[50] = 0;
  40601. data[51] = 1;
  40602. } else {
  40603. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  40604. }
  40605. }
  40606. }
  40607. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  40608. var itemSize, itemDecode, itemEncode;
  40609. if (isGlyphLocationsLong) {
  40610. itemSize = 4;
  40611. itemDecode = function fontItemDecodeLong(data, offset) {
  40612. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  40613. };
  40614. itemEncode = function fontItemEncodeLong(data, offset, value) {
  40615. data[offset] = value >>> 24 & 0xFF;
  40616. data[offset + 1] = value >> 16 & 0xFF;
  40617. data[offset + 2] = value >> 8 & 0xFF;
  40618. data[offset + 3] = value & 0xFF;
  40619. };
  40620. } else {
  40621. itemSize = 2;
  40622. itemDecode = function fontItemDecode(data, offset) {
  40623. return data[offset] << 9 | data[offset + 1] << 1;
  40624. };
  40625. itemEncode = function fontItemEncode(data, offset, value) {
  40626. data[offset] = value >> 9 & 0xFF;
  40627. data[offset + 1] = value >> 1 & 0xFF;
  40628. };
  40629. }
  40630. var locaData = loca.data;
  40631. var locaDataSize = itemSize * (1 + numGlyphs);
  40632. if (locaData.length !== locaDataSize) {
  40633. locaData = new Uint8Array(locaDataSize);
  40634. locaData.set(loca.data.subarray(0, locaDataSize));
  40635. loca.data = locaData;
  40636. }
  40637. var oldGlyfData = glyf.data;
  40638. var oldGlyfDataLength = oldGlyfData.length;
  40639. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  40640. var startOffset = itemDecode(locaData, 0);
  40641. var writeOffset = 0;
  40642. var missingGlyphData = Object.create(null);
  40643. itemEncode(locaData, 0, writeOffset);
  40644. var i, j;
  40645. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  40646. var endOffset = itemDecode(locaData, j);
  40647. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  40648. endOffset = oldGlyfDataLength;
  40649. }
  40650. if (endOffset > oldGlyfDataLength) {
  40651. itemEncode(locaData, j, writeOffset);
  40652. startOffset = endOffset;
  40653. continue;
  40654. }
  40655. if (startOffset === endOffset) {
  40656. missingGlyphData[i] = true;
  40657. }
  40658. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  40659. writeOffset += newLength;
  40660. itemEncode(locaData, j, writeOffset);
  40661. startOffset = endOffset;
  40662. }
  40663. if (writeOffset === 0) {
  40664. var simpleGlyph = new Uint8Array([
  40665. 0,
  40666. 1,
  40667. 0,
  40668. 0,
  40669. 0,
  40670. 0,
  40671. 0,
  40672. 0,
  40673. 0,
  40674. 0,
  40675. 0,
  40676. 0,
  40677. 0,
  40678. 0,
  40679. 49,
  40680. 0
  40681. ]);
  40682. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  40683. itemEncode(locaData, j, simpleGlyph.length);
  40684. }
  40685. glyf.data = simpleGlyph;
  40686. return missingGlyphData;
  40687. }
  40688. if (dupFirstEntry) {
  40689. var firstEntryLength = itemDecode(locaData, itemSize);
  40690. if (newGlyfData.length > firstEntryLength + writeOffset) {
  40691. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  40692. } else {
  40693. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  40694. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  40695. }
  40696. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  40697. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  40698. } else {
  40699. glyf.data = newGlyfData.subarray(0, writeOffset);
  40700. }
  40701. return missingGlyphData;
  40702. }
  40703. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  40704. var start = (font.start ? font.start : 0) + post.offset;
  40705. font.pos = start;
  40706. var length = post.length, end = start + length;
  40707. var version = font.getInt32();
  40708. font.getBytes(28);
  40709. var glyphNames;
  40710. var valid = true;
  40711. var i;
  40712. switch (version) {
  40713. case 0x00010000:
  40714. glyphNames = MacStandardGlyphOrdering;
  40715. break;
  40716. case 0x00020000:
  40717. var numGlyphs = font.getUint16();
  40718. if (numGlyphs !== maxpNumGlyphs) {
  40719. valid = false;
  40720. break;
  40721. }
  40722. var glyphNameIndexes = [];
  40723. for (i = 0; i < numGlyphs; ++i) {
  40724. var index = font.getUint16();
  40725. if (index >= 32768) {
  40726. valid = false;
  40727. break;
  40728. }
  40729. glyphNameIndexes.push(index);
  40730. }
  40731. if (!valid) {
  40732. break;
  40733. }
  40734. var customNames = [];
  40735. var strBuf = [];
  40736. while (font.pos < end) {
  40737. var stringLength = font.getByte();
  40738. strBuf.length = stringLength;
  40739. for (i = 0; i < stringLength; ++i) {
  40740. strBuf[i] = String.fromCharCode(font.getByte());
  40741. }
  40742. customNames.push(strBuf.join(''));
  40743. }
  40744. glyphNames = [];
  40745. for (i = 0; i < numGlyphs; ++i) {
  40746. var j = glyphNameIndexes[i];
  40747. if (j < 258) {
  40748. glyphNames.push(MacStandardGlyphOrdering[j]);
  40749. continue;
  40750. }
  40751. glyphNames.push(customNames[j - 258]);
  40752. }
  40753. break;
  40754. case 0x00030000:
  40755. break;
  40756. default:
  40757. warn('Unknown/unsupported post table version ' + version);
  40758. valid = false;
  40759. if (properties.defaultEncoding) {
  40760. glyphNames = properties.defaultEncoding;
  40761. }
  40762. break;
  40763. }
  40764. properties.glyphNames = glyphNames;
  40765. return valid;
  40766. }
  40767. function readNameTable(nameTable) {
  40768. var start = (font.start ? font.start : 0) + nameTable.offset;
  40769. font.pos = start;
  40770. var names = [
  40771. [],
  40772. []
  40773. ];
  40774. var length = nameTable.length, end = start + length;
  40775. var format = font.getUint16();
  40776. var FORMAT_0_HEADER_LENGTH = 6;
  40777. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  40778. return names;
  40779. }
  40780. var numRecords = font.getUint16();
  40781. var stringsStart = font.getUint16();
  40782. var records = [];
  40783. var NAME_RECORD_LENGTH = 12;
  40784. var i, ii;
  40785. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  40786. var r = {
  40787. platform: font.getUint16(),
  40788. encoding: font.getUint16(),
  40789. language: font.getUint16(),
  40790. name: font.getUint16(),
  40791. length: font.getUint16(),
  40792. offset: font.getUint16()
  40793. };
  40794. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  40795. records.push(r);
  40796. }
  40797. }
  40798. for (i = 0, ii = records.length; i < ii; i++) {
  40799. var record = records[i];
  40800. if (record.length <= 0) {
  40801. continue;
  40802. }
  40803. var pos = start + stringsStart + record.offset;
  40804. if (pos + record.length > end) {
  40805. continue;
  40806. }
  40807. font.pos = pos;
  40808. var nameIndex = record.name;
  40809. if (record.encoding) {
  40810. var str = '';
  40811. for (var j = 0, jj = record.length; j < jj; j += 2) {
  40812. str += String.fromCharCode(font.getUint16());
  40813. }
  40814. names[1][nameIndex] = str;
  40815. } else {
  40816. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  40817. }
  40818. }
  40819. return names;
  40820. }
  40821. var TTOpsStackDeltas = [
  40822. 0,
  40823. 0,
  40824. 0,
  40825. 0,
  40826. 0,
  40827. 0,
  40828. 0,
  40829. 0,
  40830. -2,
  40831. -2,
  40832. -2,
  40833. -2,
  40834. 0,
  40835. 0,
  40836. -2,
  40837. -5,
  40838. -1,
  40839. -1,
  40840. -1,
  40841. -1,
  40842. -1,
  40843. -1,
  40844. -1,
  40845. -1,
  40846. 0,
  40847. 0,
  40848. -1,
  40849. 0,
  40850. -1,
  40851. -1,
  40852. -1,
  40853. -1,
  40854. 1,
  40855. -1,
  40856. -999,
  40857. 0,
  40858. 1,
  40859. 0,
  40860. -1,
  40861. -2,
  40862. 0,
  40863. -1,
  40864. -2,
  40865. -1,
  40866. -1,
  40867. 0,
  40868. -1,
  40869. -1,
  40870. 0,
  40871. 0,
  40872. -999,
  40873. -999,
  40874. -1,
  40875. -1,
  40876. -1,
  40877. -1,
  40878. -2,
  40879. -999,
  40880. -2,
  40881. -2,
  40882. -999,
  40883. 0,
  40884. -2,
  40885. -2,
  40886. 0,
  40887. 0,
  40888. -2,
  40889. 0,
  40890. -2,
  40891. 0,
  40892. 0,
  40893. 0,
  40894. -2,
  40895. -1,
  40896. -1,
  40897. 1,
  40898. 1,
  40899. 0,
  40900. 0,
  40901. -1,
  40902. -1,
  40903. -1,
  40904. -1,
  40905. -1,
  40906. -1,
  40907. -1,
  40908. 0,
  40909. 0,
  40910. -1,
  40911. 0,
  40912. -1,
  40913. -1,
  40914. 0,
  40915. -999,
  40916. -1,
  40917. -1,
  40918. -1,
  40919. -1,
  40920. -1,
  40921. -1,
  40922. 0,
  40923. 0,
  40924. 0,
  40925. 0,
  40926. 0,
  40927. 0,
  40928. 0,
  40929. 0,
  40930. 0,
  40931. 0,
  40932. 0,
  40933. 0,
  40934. -2,
  40935. -999,
  40936. -999,
  40937. -999,
  40938. -999,
  40939. -999,
  40940. -1,
  40941. -1,
  40942. -2,
  40943. -2,
  40944. 0,
  40945. 0,
  40946. 0,
  40947. 0,
  40948. -1,
  40949. -1,
  40950. -999,
  40951. -2,
  40952. -2,
  40953. 0,
  40954. 0,
  40955. -1,
  40956. -2,
  40957. -2,
  40958. 0,
  40959. 0,
  40960. 0,
  40961. -1,
  40962. -1,
  40963. -1,
  40964. -2
  40965. ];
  40966. function sanitizeTTProgram(table, ttContext) {
  40967. var data = table.data;
  40968. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  40969. var stack = [];
  40970. var callstack = [];
  40971. var functionsCalled = [];
  40972. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  40973. var inFDEF = false, ifLevel = 0, inELSE = 0;
  40974. for (var ii = data.length; i < ii;) {
  40975. var op = data[i++];
  40976. if (op === 0x40) {
  40977. n = data[i++];
  40978. if (inFDEF || inELSE) {
  40979. i += n;
  40980. } else {
  40981. for (j = 0; j < n; j++) {
  40982. stack.push(data[i++]);
  40983. }
  40984. }
  40985. } else if (op === 0x41) {
  40986. n = data[i++];
  40987. if (inFDEF || inELSE) {
  40988. i += n * 2;
  40989. } else {
  40990. for (j = 0; j < n; j++) {
  40991. b = data[i++];
  40992. stack.push(b << 8 | data[i++]);
  40993. }
  40994. }
  40995. } else if ((op & 0xF8) === 0xB0) {
  40996. n = op - 0xB0 + 1;
  40997. if (inFDEF || inELSE) {
  40998. i += n;
  40999. } else {
  41000. for (j = 0; j < n; j++) {
  41001. stack.push(data[i++]);
  41002. }
  41003. }
  41004. } else if ((op & 0xF8) === 0xB8) {
  41005. n = op - 0xB8 + 1;
  41006. if (inFDEF || inELSE) {
  41007. i += n * 2;
  41008. } else {
  41009. for (j = 0; j < n; j++) {
  41010. b = data[i++];
  41011. stack.push(b << 8 | data[i++]);
  41012. }
  41013. }
  41014. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  41015. if (!inFDEF && !inELSE) {
  41016. funcId = stack[stack.length - 1];
  41017. ttContext.functionsUsed[funcId] = true;
  41018. if (funcId in ttContext.functionsStackDeltas) {
  41019. stack.length += ttContext.functionsStackDeltas[funcId];
  41020. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  41021. callstack.push({
  41022. data: data,
  41023. i: i,
  41024. stackTop: stack.length - 1
  41025. });
  41026. functionsCalled.push(funcId);
  41027. pc = ttContext.functionsDefined[funcId];
  41028. if (!pc) {
  41029. warn('TT: CALL non-existent function');
  41030. ttContext.hintsValid = false;
  41031. return;
  41032. }
  41033. data = pc.data;
  41034. i = pc.i;
  41035. }
  41036. }
  41037. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  41038. if (inFDEF || inELSE) {
  41039. warn('TT: nested FDEFs not allowed');
  41040. tooComplexToFollowFunctions = true;
  41041. }
  41042. inFDEF = true;
  41043. lastDeff = i;
  41044. funcId = stack.pop();
  41045. ttContext.functionsDefined[funcId] = {
  41046. data: data,
  41047. i: i
  41048. };
  41049. } else if (op === 0x2D) {
  41050. if (inFDEF) {
  41051. inFDEF = false;
  41052. lastEndf = i;
  41053. } else {
  41054. pc = callstack.pop();
  41055. if (!pc) {
  41056. warn('TT: ENDF bad stack');
  41057. ttContext.hintsValid = false;
  41058. return;
  41059. }
  41060. funcId = functionsCalled.pop();
  41061. data = pc.data;
  41062. i = pc.i;
  41063. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  41064. }
  41065. } else if (op === 0x89) {
  41066. if (inFDEF || inELSE) {
  41067. warn('TT: nested IDEFs not allowed');
  41068. tooComplexToFollowFunctions = true;
  41069. }
  41070. inFDEF = true;
  41071. lastDeff = i;
  41072. } else if (op === 0x58) {
  41073. ++ifLevel;
  41074. } else if (op === 0x1B) {
  41075. inELSE = ifLevel;
  41076. } else if (op === 0x59) {
  41077. if (inELSE === ifLevel) {
  41078. inELSE = 0;
  41079. }
  41080. --ifLevel;
  41081. } else if (op === 0x1C) {
  41082. if (!inFDEF && !inELSE) {
  41083. var offset = stack[stack.length - 1];
  41084. if (offset > 0) {
  41085. i += offset - 1;
  41086. }
  41087. }
  41088. }
  41089. if (!inFDEF && !inELSE) {
  41090. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  41091. if (op >= 0x71 && op <= 0x75) {
  41092. n = stack.pop();
  41093. if (!isNaN(n)) {
  41094. stackDelta = -n * 2;
  41095. }
  41096. }
  41097. while (stackDelta < 0 && stack.length > 0) {
  41098. stack.pop();
  41099. stackDelta++;
  41100. }
  41101. while (stackDelta > 0) {
  41102. stack.push(NaN);
  41103. stackDelta--;
  41104. }
  41105. }
  41106. }
  41107. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  41108. var content = [data];
  41109. if (i > data.length) {
  41110. content.push(new Uint8Array(i - data.length));
  41111. }
  41112. if (lastDeff > lastEndf) {
  41113. warn('TT: complementing a missing function tail');
  41114. content.push(new Uint8Array([
  41115. 0x22,
  41116. 0x2D
  41117. ]));
  41118. }
  41119. foldTTTable(table, content);
  41120. }
  41121. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  41122. if (ttContext.tooComplexToFollowFunctions) {
  41123. return;
  41124. }
  41125. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  41126. warn('TT: more functions defined than expected');
  41127. ttContext.hintsValid = false;
  41128. return;
  41129. }
  41130. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  41131. if (j > maxFunctionDefs) {
  41132. warn('TT: invalid function id: ' + j);
  41133. ttContext.hintsValid = false;
  41134. return;
  41135. }
  41136. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  41137. warn('TT: undefined function: ' + j);
  41138. ttContext.hintsValid = false;
  41139. return;
  41140. }
  41141. }
  41142. }
  41143. function foldTTTable(table, content) {
  41144. if (content.length > 1) {
  41145. var newLength = 0;
  41146. var j, jj;
  41147. for (j = 0, jj = content.length; j < jj; j++) {
  41148. newLength += content[j].length;
  41149. }
  41150. newLength = newLength + 3 & ~3;
  41151. var result = new Uint8Array(newLength);
  41152. var pos = 0;
  41153. for (j = 0, jj = content.length; j < jj; j++) {
  41154. result.set(content[j], pos);
  41155. pos += content[j].length;
  41156. }
  41157. table.data = result;
  41158. table.length = newLength;
  41159. }
  41160. }
  41161. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  41162. var ttContext = {
  41163. functionsDefined: [],
  41164. functionsUsed: [],
  41165. functionsStackDeltas: [],
  41166. tooComplexToFollowFunctions: false,
  41167. hintsValid: true
  41168. };
  41169. if (fpgm) {
  41170. sanitizeTTProgram(fpgm, ttContext);
  41171. }
  41172. if (prep) {
  41173. sanitizeTTProgram(prep, ttContext);
  41174. }
  41175. if (fpgm) {
  41176. checkInvalidFunctions(ttContext, maxFunctionDefs);
  41177. }
  41178. if (cvt && cvt.length & 1) {
  41179. var cvtData = new Uint8Array(cvt.length + 1);
  41180. cvtData.set(cvt.data);
  41181. cvt.data = cvtData;
  41182. }
  41183. return ttContext.hintsValid;
  41184. }
  41185. font = new Stream(new Uint8Array(font.getBytes()));
  41186. var VALID_TABLES = [
  41187. 'OS/2',
  41188. 'cmap',
  41189. 'head',
  41190. 'hhea',
  41191. 'hmtx',
  41192. 'maxp',
  41193. 'name',
  41194. 'post',
  41195. 'loca',
  41196. 'glyf',
  41197. 'fpgm',
  41198. 'prep',
  41199. 'cvt ',
  41200. 'CFF '
  41201. ];
  41202. var header = readOpenTypeHeader(font);
  41203. var numTables = header.numTables;
  41204. var cff, cffFile;
  41205. var tables = Object.create(null);
  41206. tables['OS/2'] = null;
  41207. tables['cmap'] = null;
  41208. tables['head'] = null;
  41209. tables['hhea'] = null;
  41210. tables['hmtx'] = null;
  41211. tables['maxp'] = null;
  41212. tables['name'] = null;
  41213. tables['post'] = null;
  41214. var table;
  41215. for (var i = 0; i < numTables; i++) {
  41216. table = readTableEntry(font);
  41217. if (VALID_TABLES.indexOf(table.tag) < 0) {
  41218. continue;
  41219. }
  41220. if (table.length === 0) {
  41221. continue;
  41222. }
  41223. tables[table.tag] = table;
  41224. }
  41225. var isTrueType = !tables['CFF '];
  41226. if (!isTrueType) {
  41227. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  41228. cffFile = new Stream(tables['CFF '].data);
  41229. cff = new CFFFont(cffFile, properties);
  41230. adjustWidths(properties);
  41231. return this.convert(name, cff, properties);
  41232. }
  41233. delete tables['glyf'];
  41234. delete tables['loca'];
  41235. delete tables['fpgm'];
  41236. delete tables['prep'];
  41237. delete tables['cvt '];
  41238. this.isOpenType = true;
  41239. } else {
  41240. if (!tables['loca']) {
  41241. error('Required "loca" table is not found');
  41242. }
  41243. if (!tables['glyf']) {
  41244. warn('Required "glyf" table is not found -- trying to recover.');
  41245. tables['glyf'] = {
  41246. tag: 'glyf',
  41247. data: new Uint8Array(0)
  41248. };
  41249. }
  41250. this.isOpenType = false;
  41251. }
  41252. if (!tables['maxp']) {
  41253. error('Required "maxp" table is not found');
  41254. }
  41255. font.pos = (font.start || 0) + tables['maxp'].offset;
  41256. var version = font.getInt32();
  41257. var numGlyphs = font.getUint16();
  41258. var maxFunctionDefs = 0;
  41259. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  41260. font.pos += 8;
  41261. var maxZones = font.getUint16();
  41262. if (maxZones > 2) {
  41263. tables['maxp'].data[14] = 0;
  41264. tables['maxp'].data[15] = 2;
  41265. }
  41266. font.pos += 4;
  41267. maxFunctionDefs = font.getUint16();
  41268. }
  41269. var dupFirstEntry = false;
  41270. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  41271. dupFirstEntry = true;
  41272. numGlyphs++;
  41273. tables['maxp'].data[4] = numGlyphs >> 8;
  41274. tables['maxp'].data[5] = numGlyphs & 255;
  41275. }
  41276. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  41277. if (!hintsValid) {
  41278. delete tables['fpgm'];
  41279. delete tables['prep'];
  41280. delete tables['cvt '];
  41281. }
  41282. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  41283. if (!tables['head']) {
  41284. error('Required "head" table is not found');
  41285. }
  41286. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  41287. var missingGlyphs = Object.create(null);
  41288. if (isTrueType) {
  41289. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  41290. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  41291. }
  41292. if (!tables['hhea']) {
  41293. error('Required "hhea" table is not found');
  41294. }
  41295. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  41296. tables['hhea'].data[10] = 0xFF;
  41297. tables['hhea'].data[11] = 0xFF;
  41298. }
  41299. var metricsOverride = {
  41300. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  41301. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  41302. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  41303. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  41304. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  41305. };
  41306. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  41307. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  41308. if (tables['post']) {
  41309. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  41310. if (!valid) {
  41311. tables['post'] = null;
  41312. }
  41313. }
  41314. var charCodeToGlyphId = [], charCode;
  41315. var toUnicode = properties.toUnicode, widths = properties.widths;
  41316. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  41317. function hasGlyph(glyphId, charCode, widthCode) {
  41318. if (!missingGlyphs[glyphId]) {
  41319. return true;
  41320. }
  41321. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  41322. return true;
  41323. }
  41324. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  41325. return true;
  41326. }
  41327. return false;
  41328. }
  41329. if (properties.composite) {
  41330. var cidToGidMap = properties.cidToGidMap || [];
  41331. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  41332. properties.cMap.forEach(function (charCode, cid) {
  41333. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  41334. var glyphId = -1;
  41335. if (isCidToGidMapEmpty) {
  41336. glyphId = cid;
  41337. } else if (cidToGidMap[cid] !== undefined) {
  41338. glyphId = cidToGidMap[cid];
  41339. }
  41340. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  41341. charCodeToGlyphId[charCode] = glyphId;
  41342. }
  41343. });
  41344. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  41345. charCodeToGlyphId[0] = numGlyphs - 1;
  41346. }
  41347. } else {
  41348. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  41349. var cmapPlatformId = cmapTable.platformId;
  41350. var cmapEncodingId = cmapTable.encodingId;
  41351. var cmapMappings = cmapTable.mappings;
  41352. var cmapMappingsLength = cmapMappings.length;
  41353. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  41354. var baseEncoding = [];
  41355. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  41356. baseEncoding = getEncoding(properties.baseEncodingName);
  41357. }
  41358. var glyphsUnicodeMap = getGlyphsUnicode();
  41359. for (charCode = 0; charCode < 256; charCode++) {
  41360. var glyphName, standardGlyphName;
  41361. if (this.differences && charCode in this.differences) {
  41362. glyphName = this.differences[charCode];
  41363. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  41364. glyphName = baseEncoding[charCode];
  41365. } else {
  41366. glyphName = StandardEncoding[charCode];
  41367. }
  41368. if (!glyphName) {
  41369. continue;
  41370. }
  41371. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  41372. var unicodeOrCharCode, isUnicode = false;
  41373. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  41374. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  41375. isUnicode = true;
  41376. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  41377. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  41378. }
  41379. var found = false;
  41380. for (i = 0; i < cmapMappingsLength; ++i) {
  41381. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  41382. continue;
  41383. }
  41384. var code = isUnicode ? charCode : unicodeOrCharCode;
  41385. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  41386. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  41387. found = true;
  41388. break;
  41389. }
  41390. }
  41391. if (!found && properties.glyphNames) {
  41392. var glyphId = properties.glyphNames.indexOf(glyphName);
  41393. if (glyphId === -1 && standardGlyphName !== glyphName) {
  41394. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  41395. }
  41396. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  41397. charCodeToGlyphId[charCode] = glyphId;
  41398. found = true;
  41399. }
  41400. }
  41401. if (!found) {
  41402. charCodeToGlyphId[charCode] = 0;
  41403. }
  41404. }
  41405. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  41406. for (i = 0; i < cmapMappingsLength; ++i) {
  41407. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  41408. }
  41409. } else {
  41410. for (i = 0; i < cmapMappingsLength; ++i) {
  41411. charCode = cmapMappings[i].charCode & 0xFF;
  41412. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  41413. }
  41414. }
  41415. }
  41416. if (charCodeToGlyphId.length === 0) {
  41417. charCodeToGlyphId[0] = 0;
  41418. }
  41419. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  41420. this.toFontChar = newMapping.toFontChar;
  41421. tables['cmap'] = {
  41422. tag: 'cmap',
  41423. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  41424. };
  41425. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  41426. tables['OS/2'] = {
  41427. tag: 'OS/2',
  41428. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  41429. };
  41430. }
  41431. if (!tables['post']) {
  41432. tables['post'] = {
  41433. tag: 'post',
  41434. data: createPostTable(properties)
  41435. };
  41436. }
  41437. if (!isTrueType) {
  41438. try {
  41439. cffFile = new Stream(tables['CFF '].data);
  41440. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  41441. cff = parser.parse();
  41442. var compiler = new CFFCompiler(cff);
  41443. tables['CFF '].data = compiler.compile();
  41444. } catch (e) {
  41445. warn('Failed to compile font ' + properties.loadedName);
  41446. }
  41447. }
  41448. if (!tables['name']) {
  41449. tables['name'] = {
  41450. tag: 'name',
  41451. data: createNameTable(this.name)
  41452. };
  41453. } else {
  41454. var namePrototype = readNameTable(tables['name']);
  41455. tables['name'].data = createNameTable(name, namePrototype);
  41456. }
  41457. var builder = new OpenTypeFileBuilder(header.version);
  41458. for (var tableTag in tables) {
  41459. builder.addTable(tableTag, tables[tableTag].data);
  41460. }
  41461. return builder.toArray();
  41462. },
  41463. convert: function Font_convert(fontName, font, properties) {
  41464. properties.fixedPitch = false;
  41465. if (properties.builtInEncoding) {
  41466. adjustToUnicode(properties, properties.builtInEncoding);
  41467. }
  41468. var mapping = font.getGlyphMapping(properties);
  41469. var newMapping = adjustMapping(mapping, properties);
  41470. this.toFontChar = newMapping.toFontChar;
  41471. var numGlyphs = font.numGlyphs;
  41472. function getCharCodes(charCodeToGlyphId, glyphId) {
  41473. var charCodes = null;
  41474. for (var charCode in charCodeToGlyphId) {
  41475. if (glyphId === charCodeToGlyphId[charCode]) {
  41476. if (!charCodes) {
  41477. charCodes = [];
  41478. }
  41479. charCodes.push(charCode | 0);
  41480. }
  41481. }
  41482. return charCodes;
  41483. }
  41484. function createCharCode(charCodeToGlyphId, glyphId) {
  41485. for (var charCode in charCodeToGlyphId) {
  41486. if (glyphId === charCodeToGlyphId[charCode]) {
  41487. return charCode | 0;
  41488. }
  41489. }
  41490. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  41491. return newMapping.nextAvailableFontCharCode++;
  41492. }
  41493. var seacs = font.seacs;
  41494. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  41495. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  41496. var charset = font.getCharset();
  41497. var seacMap = Object.create(null);
  41498. for (var glyphId in seacs) {
  41499. glyphId |= 0;
  41500. var seac = seacs[glyphId];
  41501. var baseGlyphName = StandardEncoding[seac[2]];
  41502. var accentGlyphName = StandardEncoding[seac[3]];
  41503. var baseGlyphId = charset.indexOf(baseGlyphName);
  41504. var accentGlyphId = charset.indexOf(accentGlyphName);
  41505. if (baseGlyphId < 0 || accentGlyphId < 0) {
  41506. continue;
  41507. }
  41508. var accentOffset = {
  41509. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  41510. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  41511. };
  41512. var charCodes = getCharCodes(mapping, glyphId);
  41513. if (!charCodes) {
  41514. continue;
  41515. }
  41516. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  41517. var charCode = charCodes[i];
  41518. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  41519. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  41520. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  41521. seacMap[charCode] = {
  41522. baseFontCharCode: baseFontCharCode,
  41523. accentFontCharCode: accentFontCharCode,
  41524. accentOffset: accentOffset
  41525. };
  41526. }
  41527. }
  41528. properties.seacMap = seacMap;
  41529. }
  41530. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  41531. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  41532. builder.addTable('CFF ', font.data);
  41533. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  41534. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  41535. builder.addTable('head', '\x00\x01\x00\x00' + '\x00\x00\x10\x00' + '\x00\x00\x00\x00' + '\x5F\x0F\x3C\xF5' + '\x00\x00' + safeString16(unitsPerEm) + '\x00\x00\x00\x00\x9e\x0b\x7e\x27' + '\x00\x00\x00\x00\x9e\x0b\x7e\x27' + '\x00\x00' + safeString16(properties.descent) + '\x0F\xFF' + safeString16(properties.ascent) + string16(properties.italicAngle ? 2 : 0) + '\x00\x11' + '\x00\x00' + '\x00\x00' + '\x00\x00');
  41536. builder.addTable('hhea', '\x00\x01\x00\x00' + safeString16(properties.ascent) + safeString16(properties.descent) + '\x00\x00' + '\xFF\xFF' + '\x00\x00' + '\x00\x00' + '\x00\x00' + safeString16(properties.capHeight) + safeString16(Math.tan(properties.italicAngle) * properties.xHeight) + '\x00\x00' + '\x00\x00' + '\x00\x00' + '\x00\x00' + '\x00\x00' + '\x00\x00' + string16(numGlyphs));
  41537. builder.addTable('hmtx', function fontFieldsHmtx() {
  41538. var charstrings = font.charstrings;
  41539. var cffWidths = font.cff ? font.cff.widths : null;
  41540. var hmtx = '\x00\x00\x00\x00';
  41541. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  41542. var width = 0;
  41543. if (charstrings) {
  41544. var charstring = charstrings[i - 1];
  41545. width = 'width' in charstring ? charstring.width : 0;
  41546. } else if (cffWidths) {
  41547. width = Math.ceil(cffWidths[i] || 0);
  41548. }
  41549. hmtx += string16(width) + string16(0);
  41550. }
  41551. return hmtx;
  41552. }());
  41553. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  41554. builder.addTable('name', createNameTable(fontName));
  41555. builder.addTable('post', createPostTable(properties));
  41556. return builder.toArray();
  41557. },
  41558. get spaceWidth() {
  41559. if ('_shadowWidth' in this) {
  41560. return this._shadowWidth;
  41561. }
  41562. var possibleSpaceReplacements = [
  41563. 'space',
  41564. 'minus',
  41565. 'one',
  41566. 'i',
  41567. 'I'
  41568. ];
  41569. var width;
  41570. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  41571. var glyphName = possibleSpaceReplacements[i];
  41572. if (glyphName in this.widths) {
  41573. width = this.widths[glyphName];
  41574. break;
  41575. }
  41576. var glyphsUnicodeMap = getGlyphsUnicode();
  41577. var glyphUnicode = glyphsUnicodeMap[glyphName];
  41578. var charcode = 0;
  41579. if (this.composite) {
  41580. if (this.cMap.contains(glyphUnicode)) {
  41581. charcode = this.cMap.lookup(glyphUnicode);
  41582. }
  41583. }
  41584. if (!charcode && this.toUnicode) {
  41585. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  41586. }
  41587. if (charcode <= 0) {
  41588. charcode = glyphUnicode;
  41589. }
  41590. width = this.widths[charcode];
  41591. if (width) {
  41592. break;
  41593. }
  41594. }
  41595. width = width || this.defaultWidth;
  41596. this._shadowWidth = width;
  41597. return width;
  41598. },
  41599. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  41600. var fontCharCode, width, operatorListId;
  41601. var widthCode = charcode;
  41602. if (this.cMap && this.cMap.contains(charcode)) {
  41603. widthCode = this.cMap.lookup(charcode);
  41604. }
  41605. width = this.widths[widthCode];
  41606. width = isNum(width) ? width : this.defaultWidth;
  41607. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  41608. var unicode = this.toUnicode.get(charcode) || charcode;
  41609. if (typeof unicode === 'number') {
  41610. unicode = String.fromCharCode(unicode);
  41611. }
  41612. var isInFont = charcode in this.toFontChar;
  41613. fontCharCode = this.toFontChar[charcode] || charcode;
  41614. if (this.missingFile) {
  41615. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  41616. }
  41617. if (this.isType3Font) {
  41618. operatorListId = fontCharCode;
  41619. }
  41620. var accent = null;
  41621. if (this.seacMap && this.seacMap[charcode]) {
  41622. isInFont = true;
  41623. var seac = this.seacMap[charcode];
  41624. fontCharCode = seac.baseFontCharCode;
  41625. accent = {
  41626. fontChar: String.fromCharCode(seac.accentFontCharCode),
  41627. offset: seac.accentOffset
  41628. };
  41629. }
  41630. var fontChar = String.fromCharCode(fontCharCode);
  41631. var glyph = this.glyphCache[charcode];
  41632. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  41633. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  41634. this.glyphCache[charcode] = glyph;
  41635. }
  41636. return glyph;
  41637. },
  41638. charsToGlyphs: function Font_charsToGlyphs(chars) {
  41639. var charsCache = this.charsCache;
  41640. var glyphs, glyph, charcode;
  41641. if (charsCache) {
  41642. glyphs = charsCache[chars];
  41643. if (glyphs) {
  41644. return glyphs;
  41645. }
  41646. }
  41647. if (!charsCache) {
  41648. charsCache = this.charsCache = Object.create(null);
  41649. }
  41650. glyphs = [];
  41651. var charsCacheKey = chars;
  41652. var i = 0, ii;
  41653. if (this.cMap) {
  41654. var c = Object.create(null);
  41655. while (i < chars.length) {
  41656. this.cMap.readCharCode(chars, i, c);
  41657. charcode = c.charcode;
  41658. var length = c.length;
  41659. i += length;
  41660. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  41661. glyph = this.charToGlyph(charcode, isSpace);
  41662. glyphs.push(glyph);
  41663. }
  41664. } else {
  41665. for (i = 0, ii = chars.length; i < ii; ++i) {
  41666. charcode = chars.charCodeAt(i);
  41667. glyph = this.charToGlyph(charcode, charcode === 0x20);
  41668. glyphs.push(glyph);
  41669. }
  41670. }
  41671. return charsCache[charsCacheKey] = glyphs;
  41672. }
  41673. };
  41674. return Font;
  41675. }();
  41676. var ErrorFont = function ErrorFontClosure() {
  41677. function ErrorFont(error) {
  41678. this.error = error;
  41679. this.loadedName = 'g_font_error';
  41680. this.loading = false;
  41681. }
  41682. ErrorFont.prototype = {
  41683. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  41684. return [];
  41685. },
  41686. exportData: function ErrorFont_exportData() {
  41687. return { error: this.error };
  41688. }
  41689. };
  41690. return ErrorFont;
  41691. }();
  41692. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  41693. var charCodeToGlyphId = Object.create(null);
  41694. var glyphId, charCode, baseEncoding;
  41695. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  41696. if (properties.baseEncodingName) {
  41697. baseEncoding = getEncoding(properties.baseEncodingName);
  41698. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  41699. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  41700. if (glyphId >= 0) {
  41701. charCodeToGlyphId[charCode] = glyphId;
  41702. } else {
  41703. charCodeToGlyphId[charCode] = 0;
  41704. }
  41705. }
  41706. } else if (isSymbolicFont) {
  41707. for (charCode in builtInEncoding) {
  41708. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  41709. }
  41710. } else {
  41711. baseEncoding = StandardEncoding;
  41712. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  41713. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  41714. if (glyphId >= 0) {
  41715. charCodeToGlyphId[charCode] = glyphId;
  41716. } else {
  41717. charCodeToGlyphId[charCode] = 0;
  41718. }
  41719. }
  41720. }
  41721. var differences = properties.differences, glyphsUnicodeMap;
  41722. if (differences) {
  41723. for (charCode in differences) {
  41724. var glyphName = differences[charCode];
  41725. glyphId = glyphNames.indexOf(glyphName);
  41726. if (glyphId === -1) {
  41727. if (!glyphsUnicodeMap) {
  41728. glyphsUnicodeMap = getGlyphsUnicode();
  41729. }
  41730. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  41731. if (standardGlyphName !== glyphName) {
  41732. glyphId = glyphNames.indexOf(standardGlyphName);
  41733. }
  41734. }
  41735. if (glyphId >= 0) {
  41736. charCodeToGlyphId[charCode] = glyphId;
  41737. } else {
  41738. charCodeToGlyphId[charCode] = 0;
  41739. }
  41740. }
  41741. }
  41742. return charCodeToGlyphId;
  41743. }
  41744. var Type1Font = function Type1FontClosure() {
  41745. function findBlock(streamBytes, signature, startIndex) {
  41746. var streamBytesLength = streamBytes.length;
  41747. var signatureLength = signature.length;
  41748. var scanLength = streamBytesLength - signatureLength;
  41749. var i = startIndex, j, found = false;
  41750. while (i < scanLength) {
  41751. j = 0;
  41752. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  41753. j++;
  41754. }
  41755. if (j >= signatureLength) {
  41756. i += j;
  41757. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  41758. i++;
  41759. }
  41760. found = true;
  41761. break;
  41762. }
  41763. i++;
  41764. }
  41765. return {
  41766. found: found,
  41767. length: i
  41768. };
  41769. }
  41770. function getHeaderBlock(stream, suggestedLength) {
  41771. var EEXEC_SIGNATURE = [
  41772. 0x65,
  41773. 0x65,
  41774. 0x78,
  41775. 0x65,
  41776. 0x63
  41777. ];
  41778. var streamStartPos = stream.pos;
  41779. var headerBytes, headerBytesLength, block;
  41780. try {
  41781. headerBytes = stream.getBytes(suggestedLength);
  41782. headerBytesLength = headerBytes.length;
  41783. } catch (ex) {
  41784. if (ex instanceof MissingDataException) {
  41785. throw ex;
  41786. }
  41787. }
  41788. if (headerBytesLength === suggestedLength) {
  41789. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  41790. if (block.found && block.length === suggestedLength) {
  41791. return {
  41792. stream: new Stream(headerBytes),
  41793. length: suggestedLength
  41794. };
  41795. }
  41796. }
  41797. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  41798. stream.pos = streamStartPos;
  41799. var SCAN_BLOCK_LENGTH = 2048;
  41800. var actualLength;
  41801. while (true) {
  41802. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  41803. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  41804. if (block.length === 0) {
  41805. break;
  41806. }
  41807. stream.pos += block.length;
  41808. if (block.found) {
  41809. actualLength = stream.pos - streamStartPos;
  41810. break;
  41811. }
  41812. }
  41813. stream.pos = streamStartPos;
  41814. if (actualLength) {
  41815. return {
  41816. stream: new Stream(stream.getBytes(actualLength)),
  41817. length: actualLength
  41818. };
  41819. }
  41820. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  41821. return {
  41822. stream: new Stream(stream.getBytes(suggestedLength)),
  41823. length: suggestedLength
  41824. };
  41825. }
  41826. function getEexecBlock(stream, suggestedLength) {
  41827. var eexecBytes = stream.getBytes();
  41828. return {
  41829. stream: new Stream(eexecBytes),
  41830. length: eexecBytes.length
  41831. };
  41832. }
  41833. function Type1Font(name, file, properties) {
  41834. var PFB_HEADER_SIZE = 6;
  41835. var headerBlockLength = properties.length1;
  41836. var eexecBlockLength = properties.length2;
  41837. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  41838. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  41839. if (pfbHeaderPresent) {
  41840. file.skip(PFB_HEADER_SIZE);
  41841. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  41842. }
  41843. var headerBlock = getHeaderBlock(file, headerBlockLength);
  41844. headerBlockLength = headerBlock.length;
  41845. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  41846. headerBlockParser.extractFontHeader(properties);
  41847. if (pfbHeaderPresent) {
  41848. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  41849. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  41850. }
  41851. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  41852. eexecBlockLength = eexecBlock.length;
  41853. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  41854. var data = eexecBlockParser.extractFontProgram();
  41855. for (var info in data.properties) {
  41856. properties[info] = data.properties[info];
  41857. }
  41858. var charstrings = data.charstrings;
  41859. var type2Charstrings = this.getType2Charstrings(charstrings);
  41860. var subrs = this.getType2Subrs(data.subrs);
  41861. this.charstrings = charstrings;
  41862. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  41863. this.seacs = this.getSeacs(data.charstrings);
  41864. }
  41865. Type1Font.prototype = {
  41866. get numGlyphs() {
  41867. return this.charstrings.length + 1;
  41868. },
  41869. getCharset: function Type1Font_getCharset() {
  41870. var charset = ['.notdef'];
  41871. var charstrings = this.charstrings;
  41872. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  41873. charset.push(charstrings[glyphId].glyphName);
  41874. }
  41875. return charset;
  41876. },
  41877. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  41878. var charstrings = this.charstrings;
  41879. var glyphNames = ['.notdef'], glyphId;
  41880. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  41881. glyphNames.push(charstrings[glyphId].glyphName);
  41882. }
  41883. var encoding = properties.builtInEncoding;
  41884. if (encoding) {
  41885. var builtInEncoding = Object.create(null);
  41886. for (var charCode in encoding) {
  41887. glyphId = glyphNames.indexOf(encoding[charCode]);
  41888. if (glyphId >= 0) {
  41889. builtInEncoding[charCode] = glyphId;
  41890. }
  41891. }
  41892. }
  41893. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  41894. },
  41895. getSeacs: function Type1Font_getSeacs(charstrings) {
  41896. var i, ii;
  41897. var seacMap = [];
  41898. for (i = 0, ii = charstrings.length; i < ii; i++) {
  41899. var charstring = charstrings[i];
  41900. if (charstring.seac) {
  41901. seacMap[i + 1] = charstring.seac;
  41902. }
  41903. }
  41904. return seacMap;
  41905. },
  41906. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  41907. var type2Charstrings = [];
  41908. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  41909. type2Charstrings.push(type1Charstrings[i].charstring);
  41910. }
  41911. return type2Charstrings;
  41912. },
  41913. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  41914. var bias = 0;
  41915. var count = type1Subrs.length;
  41916. if (count < 1133) {
  41917. bias = 107;
  41918. } else if (count < 33769) {
  41919. bias = 1131;
  41920. } else {
  41921. bias = 32768;
  41922. }
  41923. var type2Subrs = [];
  41924. var i;
  41925. for (i = 0; i < bias; i++) {
  41926. type2Subrs.push([0x0B]);
  41927. }
  41928. for (i = 0; i < count; i++) {
  41929. type2Subrs.push(type1Subrs[i]);
  41930. }
  41931. return type2Subrs;
  41932. },
  41933. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  41934. var cff = new CFF();
  41935. cff.header = new CFFHeader(1, 0, 4, 4);
  41936. cff.names = [name];
  41937. var topDict = new CFFTopDict();
  41938. topDict.setByName('version', 391);
  41939. topDict.setByName('Notice', 392);
  41940. topDict.setByName('FullName', 393);
  41941. topDict.setByName('FamilyName', 394);
  41942. topDict.setByName('Weight', 395);
  41943. topDict.setByName('Encoding', null);
  41944. topDict.setByName('FontMatrix', properties.fontMatrix);
  41945. topDict.setByName('FontBBox', properties.bbox);
  41946. topDict.setByName('charset', null);
  41947. topDict.setByName('CharStrings', null);
  41948. topDict.setByName('Private', null);
  41949. cff.topDict = topDict;
  41950. var strings = new CFFStrings();
  41951. strings.add('Version 0.11');
  41952. strings.add('See original notice');
  41953. strings.add(name);
  41954. strings.add(name);
  41955. strings.add('Medium');
  41956. cff.strings = strings;
  41957. cff.globalSubrIndex = new CFFIndex();
  41958. var count = glyphs.length;
  41959. var charsetArray = [0];
  41960. var i, ii;
  41961. for (i = 0; i < count; i++) {
  41962. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  41963. if (index === -1) {
  41964. index = 0;
  41965. }
  41966. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  41967. }
  41968. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  41969. var charStringsIndex = new CFFIndex();
  41970. charStringsIndex.add([
  41971. 0x8B,
  41972. 0x0E
  41973. ]);
  41974. for (i = 0; i < count; i++) {
  41975. var glyph = glyphs[i];
  41976. if (glyph.length === 0) {
  41977. charStringsIndex.add([
  41978. 0x8B,
  41979. 0x0E
  41980. ]);
  41981. continue;
  41982. }
  41983. charStringsIndex.add(glyph);
  41984. }
  41985. cff.charStrings = charStringsIndex;
  41986. var privateDict = new CFFPrivateDict();
  41987. privateDict.setByName('Subrs', null);
  41988. var fields = [
  41989. 'BlueValues',
  41990. 'OtherBlues',
  41991. 'FamilyBlues',
  41992. 'FamilyOtherBlues',
  41993. 'StemSnapH',
  41994. 'StemSnapV',
  41995. 'BlueShift',
  41996. 'BlueFuzz',
  41997. 'BlueScale',
  41998. 'LanguageGroup',
  41999. 'ExpansionFactor',
  42000. 'ForceBold',
  42001. 'StdHW',
  42002. 'StdVW'
  42003. ];
  42004. for (i = 0, ii = fields.length; i < ii; i++) {
  42005. var field = fields[i];
  42006. if (!(field in properties.privateData)) {
  42007. continue;
  42008. }
  42009. var value = properties.privateData[field];
  42010. if (isArray(value)) {
  42011. for (var j = value.length - 1; j > 0; j--) {
  42012. value[j] -= value[j - 1];
  42013. }
  42014. }
  42015. privateDict.setByName(field, value);
  42016. }
  42017. cff.topDict.privateDict = privateDict;
  42018. var subrIndex = new CFFIndex();
  42019. for (i = 0, ii = subrs.length; i < ii; i++) {
  42020. subrIndex.add(subrs[i]);
  42021. }
  42022. privateDict.subrsIndex = subrIndex;
  42023. var compiler = new CFFCompiler(cff);
  42024. return compiler.compile();
  42025. }
  42026. };
  42027. return Type1Font;
  42028. }();
  42029. var CFFFont = function CFFFontClosure() {
  42030. function CFFFont(file, properties) {
  42031. this.properties = properties;
  42032. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  42033. this.cff = parser.parse();
  42034. var compiler = new CFFCompiler(this.cff);
  42035. this.seacs = this.cff.seacs;
  42036. try {
  42037. this.data = compiler.compile();
  42038. } catch (e) {
  42039. warn('Failed to compile font ' + properties.loadedName);
  42040. this.data = file;
  42041. }
  42042. }
  42043. CFFFont.prototype = {
  42044. get numGlyphs() {
  42045. return this.cff.charStrings.count;
  42046. },
  42047. getCharset: function CFFFont_getCharset() {
  42048. return this.cff.charset.charset;
  42049. },
  42050. getGlyphMapping: function CFFFont_getGlyphMapping() {
  42051. var cff = this.cff;
  42052. var properties = this.properties;
  42053. var charsets = cff.charset.charset;
  42054. var charCodeToGlyphId;
  42055. var glyphId;
  42056. if (properties.composite) {
  42057. charCodeToGlyphId = Object.create(null);
  42058. if (cff.isCIDFont) {
  42059. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  42060. var cid = charsets[glyphId];
  42061. var charCode = properties.cMap.charCodeOf(cid);
  42062. charCodeToGlyphId[charCode] = glyphId;
  42063. }
  42064. } else {
  42065. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  42066. charCodeToGlyphId[glyphId] = glyphId;
  42067. }
  42068. }
  42069. return charCodeToGlyphId;
  42070. }
  42071. var encoding = cff.encoding ? cff.encoding.encoding : null;
  42072. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  42073. return charCodeToGlyphId;
  42074. }
  42075. };
  42076. return CFFFont;
  42077. }();
  42078. (function checkSeacSupport() {
  42079. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  42080. SEAC_ANALYSIS_ENABLED = true;
  42081. }
  42082. }());
  42083. (function checkChromeWindows() {
  42084. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  42085. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  42086. }
  42087. }());
  42088. exports.ErrorFont = ErrorFont;
  42089. exports.Font = Font;
  42090. exports.FontFlags = FontFlags;
  42091. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  42092. exports.ToUnicodeMap = ToUnicodeMap;
  42093. exports.getFontType = getFontType;
  42094. /***/ }),
  42095. /* 27 */
  42096. /***/ (function(module, exports, __w_pdfjs_require__) {
  42097. "use strict";
  42098. var sharedUtil = __w_pdfjs_require__(0);
  42099. var corePrimitives = __w_pdfjs_require__(1);
  42100. var coreColorSpace = __w_pdfjs_require__(3);
  42101. var coreStream = __w_pdfjs_require__(2);
  42102. var coreJpx = __w_pdfjs_require__(15);
  42103. var ImageKind = sharedUtil.ImageKind;
  42104. var assert = sharedUtil.assert;
  42105. var error = sharedUtil.error;
  42106. var info = sharedUtil.info;
  42107. var isArray = sharedUtil.isArray;
  42108. var warn = sharedUtil.warn;
  42109. var Name = corePrimitives.Name;
  42110. var isStream = corePrimitives.isStream;
  42111. var ColorSpace = coreColorSpace.ColorSpace;
  42112. var DecodeStream = coreStream.DecodeStream;
  42113. var JpegStream = coreStream.JpegStream;
  42114. var JpxImage = coreJpx.JpxImage;
  42115. var PDFImage = function PDFImageClosure() {
  42116. function handleImageData(image, nativeDecoder) {
  42117. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  42118. return nativeDecoder.decode(image);
  42119. }
  42120. return Promise.resolve(image);
  42121. }
  42122. function decodeAndClamp(value, addend, coefficient, max) {
  42123. value = addend + value * coefficient;
  42124. return value < 0 ? 0 : value > max ? max : value;
  42125. }
  42126. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  42127. var length = w2 * h2;
  42128. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  42129. var xRatio = w1 / w2;
  42130. var yRatio = h1 / h2;
  42131. var i, j, py, newIndex = 0, oldIndex;
  42132. var xScaled = new Uint16Array(w2);
  42133. var w1Scanline = w1;
  42134. for (i = 0; i < w2; i++) {
  42135. xScaled[i] = Math.floor(i * xRatio);
  42136. }
  42137. for (i = 0; i < h2; i++) {
  42138. py = Math.floor(i * yRatio) * w1Scanline;
  42139. for (j = 0; j < w2; j++) {
  42140. oldIndex = py + xScaled[j];
  42141. dest[newIndex++] = src[oldIndex];
  42142. }
  42143. }
  42144. return dest;
  42145. }
  42146. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  42147. this.image = image;
  42148. var dict = image.dict;
  42149. if (dict.has('Filter')) {
  42150. var filter = dict.get('Filter').name;
  42151. if (filter === 'JPXDecode') {
  42152. var jpxImage = new JpxImage();
  42153. jpxImage.parseImageProperties(image.stream);
  42154. image.stream.reset();
  42155. image.bitsPerComponent = jpxImage.bitsPerComponent;
  42156. image.numComps = jpxImage.componentsCount;
  42157. } else if (filter === 'JBIG2Decode') {
  42158. image.bitsPerComponent = 1;
  42159. image.numComps = 1;
  42160. }
  42161. }
  42162. this.width = dict.get('Width', 'W');
  42163. this.height = dict.get('Height', 'H');
  42164. if (this.width < 1 || this.height < 1) {
  42165. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  42166. }
  42167. this.interpolate = dict.get('Interpolate', 'I') || false;
  42168. this.imageMask = dict.get('ImageMask', 'IM') || false;
  42169. this.matte = dict.get('Matte') || false;
  42170. var bitsPerComponent = image.bitsPerComponent;
  42171. if (!bitsPerComponent) {
  42172. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  42173. if (!bitsPerComponent) {
  42174. if (this.imageMask) {
  42175. bitsPerComponent = 1;
  42176. } else {
  42177. error('Bits per component missing in image: ' + this.imageMask);
  42178. }
  42179. }
  42180. }
  42181. this.bpc = bitsPerComponent;
  42182. if (!this.imageMask) {
  42183. var colorSpace = dict.get('ColorSpace', 'CS');
  42184. if (!colorSpace) {
  42185. info('JPX images (which do not require color spaces)');
  42186. switch (image.numComps) {
  42187. case 1:
  42188. colorSpace = Name.get('DeviceGray');
  42189. break;
  42190. case 3:
  42191. colorSpace = Name.get('DeviceRGB');
  42192. break;
  42193. case 4:
  42194. colorSpace = Name.get('DeviceCMYK');
  42195. break;
  42196. default:
  42197. error('JPX images with ' + this.numComps + ' color components not supported.');
  42198. }
  42199. }
  42200. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  42201. this.numComps = this.colorSpace.numComps;
  42202. }
  42203. this.decode = dict.getArray('Decode', 'D');
  42204. this.needsDecode = false;
  42205. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  42206. this.needsDecode = true;
  42207. var max = (1 << bitsPerComponent) - 1;
  42208. this.decodeCoefficients = [];
  42209. this.decodeAddends = [];
  42210. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  42211. var dmin = this.decode[i];
  42212. var dmax = this.decode[i + 1];
  42213. this.decodeCoefficients[j] = dmax - dmin;
  42214. this.decodeAddends[j] = max * dmin;
  42215. }
  42216. }
  42217. if (smask) {
  42218. this.smask = new PDFImage(xref, res, smask, false);
  42219. } else if (mask) {
  42220. if (isStream(mask)) {
  42221. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  42222. if (!imageMask) {
  42223. warn('Ignoring /Mask in image without /ImageMask.');
  42224. } else {
  42225. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  42226. }
  42227. } else {
  42228. this.mask = mask;
  42229. }
  42230. }
  42231. }
  42232. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  42233. var imagePromise = handleImageData(image, nativeDecoder);
  42234. var smaskPromise;
  42235. var maskPromise;
  42236. var smask = image.dict.get('SMask');
  42237. var mask = image.dict.get('Mask');
  42238. if (smask) {
  42239. smaskPromise = handleImageData(smask, nativeDecoder);
  42240. maskPromise = Promise.resolve(null);
  42241. } else {
  42242. smaskPromise = Promise.resolve(null);
  42243. if (mask) {
  42244. if (isStream(mask)) {
  42245. maskPromise = handleImageData(mask, nativeDecoder);
  42246. } else if (isArray(mask)) {
  42247. maskPromise = Promise.resolve(mask);
  42248. } else {
  42249. warn('Unsupported mask format.');
  42250. maskPromise = Promise.resolve(null);
  42251. }
  42252. } else {
  42253. maskPromise = Promise.resolve(null);
  42254. }
  42255. }
  42256. return Promise.all([
  42257. imagePromise,
  42258. smaskPromise,
  42259. maskPromise
  42260. ]).then(function (results) {
  42261. var imageData = results[0];
  42262. var smaskData = results[1];
  42263. var maskData = results[2];
  42264. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  42265. });
  42266. };
  42267. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  42268. var computedLength = (width + 7 >> 3) * height;
  42269. var actualLength = imgArray.byteLength;
  42270. var haveFullData = computedLength === actualLength;
  42271. var data, i;
  42272. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  42273. data = imgArray;
  42274. } else if (!inverseDecode) {
  42275. data = new Uint8Array(actualLength);
  42276. data.set(imgArray);
  42277. } else {
  42278. data = new Uint8Array(computedLength);
  42279. data.set(imgArray);
  42280. for (i = actualLength; i < computedLength; i++) {
  42281. data[i] = 0xff;
  42282. }
  42283. }
  42284. if (inverseDecode) {
  42285. for (i = 0; i < actualLength; i++) {
  42286. data[i] = ~data[i];
  42287. }
  42288. }
  42289. return {
  42290. data: data,
  42291. width: width,
  42292. height: height
  42293. };
  42294. };
  42295. PDFImage.prototype = {
  42296. get drawWidth() {
  42297. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  42298. },
  42299. get drawHeight() {
  42300. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  42301. },
  42302. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  42303. var bpc = this.bpc;
  42304. var numComps = this.numComps;
  42305. var decodeAddends = this.decodeAddends;
  42306. var decodeCoefficients = this.decodeCoefficients;
  42307. var max = (1 << bpc) - 1;
  42308. var i, ii;
  42309. if (bpc === 1) {
  42310. for (i = 0, ii = buffer.length; i < ii; i++) {
  42311. buffer[i] = +!buffer[i];
  42312. }
  42313. return;
  42314. }
  42315. var index = 0;
  42316. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  42317. for (var j = 0; j < numComps; j++) {
  42318. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  42319. index++;
  42320. }
  42321. }
  42322. },
  42323. getComponents: function PDFImage_getComponents(buffer) {
  42324. var bpc = this.bpc;
  42325. if (bpc === 8) {
  42326. return buffer;
  42327. }
  42328. var width = this.width;
  42329. var height = this.height;
  42330. var numComps = this.numComps;
  42331. var length = width * height * numComps;
  42332. var bufferPos = 0;
  42333. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  42334. var rowComps = width * numComps;
  42335. var max = (1 << bpc) - 1;
  42336. var i = 0, ii, buf;
  42337. if (bpc === 1) {
  42338. var mask, loop1End, loop2End;
  42339. for (var j = 0; j < height; j++) {
  42340. loop1End = i + (rowComps & ~7);
  42341. loop2End = i + rowComps;
  42342. while (i < loop1End) {
  42343. buf = buffer[bufferPos++];
  42344. output[i] = buf >> 7 & 1;
  42345. output[i + 1] = buf >> 6 & 1;
  42346. output[i + 2] = buf >> 5 & 1;
  42347. output[i + 3] = buf >> 4 & 1;
  42348. output[i + 4] = buf >> 3 & 1;
  42349. output[i + 5] = buf >> 2 & 1;
  42350. output[i + 6] = buf >> 1 & 1;
  42351. output[i + 7] = buf & 1;
  42352. i += 8;
  42353. }
  42354. if (i < loop2End) {
  42355. buf = buffer[bufferPos++];
  42356. mask = 128;
  42357. while (i < loop2End) {
  42358. output[i++] = +!!(buf & mask);
  42359. mask >>= 1;
  42360. }
  42361. }
  42362. }
  42363. } else {
  42364. var bits = 0;
  42365. buf = 0;
  42366. for (i = 0, ii = length; i < ii; ++i) {
  42367. if (i % rowComps === 0) {
  42368. buf = 0;
  42369. bits = 0;
  42370. }
  42371. while (bits < bpc) {
  42372. buf = buf << 8 | buffer[bufferPos++];
  42373. bits += 8;
  42374. }
  42375. var remainingBits = bits - bpc;
  42376. var value = buf >> remainingBits;
  42377. output[i] = value < 0 ? 0 : value > max ? max : value;
  42378. buf = buf & (1 << remainingBits) - 1;
  42379. bits = remainingBits;
  42380. }
  42381. }
  42382. return output;
  42383. },
  42384. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  42385. var smask = this.smask;
  42386. var mask = this.mask;
  42387. var alphaBuf, sw, sh, i, ii, j;
  42388. if (smask) {
  42389. sw = smask.width;
  42390. sh = smask.height;
  42391. alphaBuf = new Uint8Array(sw * sh);
  42392. smask.fillGrayBuffer(alphaBuf);
  42393. if (sw !== width || sh !== height) {
  42394. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  42395. }
  42396. } else if (mask) {
  42397. if (mask instanceof PDFImage) {
  42398. sw = mask.width;
  42399. sh = mask.height;
  42400. alphaBuf = new Uint8Array(sw * sh);
  42401. mask.numComps = 1;
  42402. mask.fillGrayBuffer(alphaBuf);
  42403. for (i = 0, ii = sw * sh; i < ii; ++i) {
  42404. alphaBuf[i] = 255 - alphaBuf[i];
  42405. }
  42406. if (sw !== width || sh !== height) {
  42407. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  42408. }
  42409. } else if (isArray(mask)) {
  42410. alphaBuf = new Uint8Array(width * height);
  42411. var numComps = this.numComps;
  42412. for (i = 0, ii = width * height; i < ii; ++i) {
  42413. var opacity = 0;
  42414. var imageOffset = i * numComps;
  42415. for (j = 0; j < numComps; ++j) {
  42416. var color = image[imageOffset + j];
  42417. var maskOffset = j * 2;
  42418. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  42419. opacity = 255;
  42420. break;
  42421. }
  42422. }
  42423. alphaBuf[i] = opacity;
  42424. }
  42425. } else {
  42426. error('Unknown mask format.');
  42427. }
  42428. }
  42429. if (alphaBuf) {
  42430. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  42431. rgbaBuf[j] = alphaBuf[i];
  42432. }
  42433. } else {
  42434. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  42435. rgbaBuf[j] = 255;
  42436. }
  42437. }
  42438. },
  42439. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  42440. var matte = this.smask && this.smask.matte;
  42441. if (!matte) {
  42442. return;
  42443. }
  42444. var matteRgb = this.colorSpace.getRgb(matte, 0);
  42445. var matteR = matteRgb[0];
  42446. var matteG = matteRgb[1];
  42447. var matteB = matteRgb[2];
  42448. var length = width * height * 4;
  42449. var r, g, b;
  42450. for (var i = 0; i < length; i += 4) {
  42451. var alpha = buffer[i + 3];
  42452. if (alpha === 0) {
  42453. buffer[i] = 255;
  42454. buffer[i + 1] = 255;
  42455. buffer[i + 2] = 255;
  42456. continue;
  42457. }
  42458. var k = 255 / alpha;
  42459. r = (buffer[i] - matteR) * k + matteR;
  42460. g = (buffer[i + 1] - matteG) * k + matteG;
  42461. b = (buffer[i + 2] - matteB) * k + matteB;
  42462. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  42463. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  42464. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  42465. }
  42466. },
  42467. createImageData: function PDFImage_createImageData(forceRGBA) {
  42468. var drawWidth = this.drawWidth;
  42469. var drawHeight = this.drawHeight;
  42470. var imgData = {
  42471. width: drawWidth,
  42472. height: drawHeight
  42473. };
  42474. var numComps = this.numComps;
  42475. var originalWidth = this.width;
  42476. var originalHeight = this.height;
  42477. var bpc = this.bpc;
  42478. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  42479. var imgArray;
  42480. if (!forceRGBA) {
  42481. var kind;
  42482. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  42483. kind = ImageKind.GRAYSCALE_1BPP;
  42484. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  42485. kind = ImageKind.RGB_24BPP;
  42486. }
  42487. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  42488. imgData.kind = kind;
  42489. imgArray = this.getImageBytes(originalHeight * rowBytes);
  42490. if (this.image instanceof DecodeStream) {
  42491. imgData.data = imgArray;
  42492. } else {
  42493. var newArray = new Uint8Array(imgArray.length);
  42494. newArray.set(imgArray);
  42495. imgData.data = newArray;
  42496. }
  42497. if (this.needsDecode) {
  42498. assert(kind === ImageKind.GRAYSCALE_1BPP);
  42499. var buffer = imgData.data;
  42500. for (var i = 0, ii = buffer.length; i < ii; i++) {
  42501. buffer[i] ^= 0xff;
  42502. }
  42503. }
  42504. return imgData;
  42505. }
  42506. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  42507. imgData.kind = ImageKind.RGB_24BPP;
  42508. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  42509. return imgData;
  42510. }
  42511. }
  42512. imgArray = this.getImageBytes(originalHeight * rowBytes);
  42513. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  42514. var comps = this.getComponents(imgArray);
  42515. var alpha01, maybeUndoPreblend;
  42516. if (!forceRGBA && !this.smask && !this.mask) {
  42517. imgData.kind = ImageKind.RGB_24BPP;
  42518. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  42519. alpha01 = 0;
  42520. maybeUndoPreblend = false;
  42521. } else {
  42522. imgData.kind = ImageKind.RGBA_32BPP;
  42523. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  42524. alpha01 = 1;
  42525. maybeUndoPreblend = true;
  42526. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  42527. }
  42528. if (this.needsDecode) {
  42529. this.decodeBuffer(comps);
  42530. }
  42531. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  42532. if (maybeUndoPreblend) {
  42533. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  42534. }
  42535. return imgData;
  42536. },
  42537. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  42538. var numComps = this.numComps;
  42539. if (numComps !== 1) {
  42540. error('Reading gray scale from a color image: ' + numComps);
  42541. }
  42542. var width = this.width;
  42543. var height = this.height;
  42544. var bpc = this.bpc;
  42545. var rowBytes = width * numComps * bpc + 7 >> 3;
  42546. var imgArray = this.getImageBytes(height * rowBytes);
  42547. var comps = this.getComponents(imgArray);
  42548. var i, length;
  42549. if (bpc === 1) {
  42550. length = width * height;
  42551. if (this.needsDecode) {
  42552. for (i = 0; i < length; ++i) {
  42553. buffer[i] = comps[i] - 1 & 255;
  42554. }
  42555. } else {
  42556. for (i = 0; i < length; ++i) {
  42557. buffer[i] = -comps[i] & 255;
  42558. }
  42559. }
  42560. return;
  42561. }
  42562. if (this.needsDecode) {
  42563. this.decodeBuffer(comps);
  42564. }
  42565. length = width * height;
  42566. var scale = 255 / ((1 << bpc) - 1);
  42567. for (i = 0; i < length; ++i) {
  42568. buffer[i] = scale * comps[i] | 0;
  42569. }
  42570. },
  42571. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  42572. this.image.reset();
  42573. this.image.drawWidth = drawWidth || this.width;
  42574. this.image.drawHeight = drawHeight || this.height;
  42575. this.image.forceRGB = !!forceRGB;
  42576. return this.image.getBytes(length);
  42577. }
  42578. };
  42579. return PDFImage;
  42580. }();
  42581. exports.PDFImage = PDFImage;
  42582. /***/ }),
  42583. /* 28 */
  42584. /***/ (function(module, exports, __w_pdfjs_require__) {
  42585. "use strict";
  42586. var sharedUtil = __w_pdfjs_require__(0);
  42587. var coreArithmeticDecoder = __w_pdfjs_require__(10);
  42588. var error = sharedUtil.error;
  42589. var log2 = sharedUtil.log2;
  42590. var readInt8 = sharedUtil.readInt8;
  42591. var readUint16 = sharedUtil.readUint16;
  42592. var readUint32 = sharedUtil.readUint32;
  42593. var shadow = sharedUtil.shadow;
  42594. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  42595. var Jbig2Image = function Jbig2ImageClosure() {
  42596. function ContextCache() {
  42597. }
  42598. ContextCache.prototype = {
  42599. getContexts: function (id) {
  42600. if (id in this) {
  42601. return this[id];
  42602. }
  42603. return this[id] = new Int8Array(1 << 16);
  42604. }
  42605. };
  42606. function DecodingContext(data, start, end) {
  42607. this.data = data;
  42608. this.start = start;
  42609. this.end = end;
  42610. }
  42611. DecodingContext.prototype = {
  42612. get decoder() {
  42613. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  42614. return shadow(this, 'decoder', decoder);
  42615. },
  42616. get contextCache() {
  42617. var cache = new ContextCache();
  42618. return shadow(this, 'contextCache', cache);
  42619. }
  42620. };
  42621. function decodeInteger(contextCache, procedure, decoder) {
  42622. var contexts = contextCache.getContexts(procedure);
  42623. var prev = 1;
  42624. function readBits(length) {
  42625. var v = 0;
  42626. for (var i = 0; i < length; i++) {
  42627. var bit = decoder.readBit(contexts, prev);
  42628. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  42629. v = v << 1 | bit;
  42630. }
  42631. return v >>> 0;
  42632. }
  42633. var sign = readBits(1);
  42634. var value = readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(32) + 4436 : readBits(12) + 340 : readBits(8) + 84 : readBits(6) + 20 : readBits(4) + 4 : readBits(2);
  42635. return sign === 0 ? value : value > 0 ? -value : null;
  42636. }
  42637. function decodeIAID(contextCache, decoder, codeLength) {
  42638. var contexts = contextCache.getContexts('IAID');
  42639. var prev = 1;
  42640. for (var i = 0; i < codeLength; i++) {
  42641. var bit = decoder.readBit(contexts, prev);
  42642. prev = prev << 1 | bit;
  42643. }
  42644. if (codeLength < 31) {
  42645. return prev & (1 << codeLength) - 1;
  42646. }
  42647. return prev & 0x7FFFFFFF;
  42648. }
  42649. var SegmentTypes = [
  42650. 'SymbolDictionary',
  42651. null,
  42652. null,
  42653. null,
  42654. 'IntermediateTextRegion',
  42655. null,
  42656. 'ImmediateTextRegion',
  42657. 'ImmediateLosslessTextRegion',
  42658. null,
  42659. null,
  42660. null,
  42661. null,
  42662. null,
  42663. null,
  42664. null,
  42665. null,
  42666. 'patternDictionary',
  42667. null,
  42668. null,
  42669. null,
  42670. 'IntermediateHalftoneRegion',
  42671. null,
  42672. 'ImmediateHalftoneRegion',
  42673. 'ImmediateLosslessHalftoneRegion',
  42674. null,
  42675. null,
  42676. null,
  42677. null,
  42678. null,
  42679. null,
  42680. null,
  42681. null,
  42682. null,
  42683. null,
  42684. null,
  42685. null,
  42686. 'IntermediateGenericRegion',
  42687. null,
  42688. 'ImmediateGenericRegion',
  42689. 'ImmediateLosslessGenericRegion',
  42690. 'IntermediateGenericRefinementRegion',
  42691. null,
  42692. 'ImmediateGenericRefinementRegion',
  42693. 'ImmediateLosslessGenericRefinementRegion',
  42694. null,
  42695. null,
  42696. null,
  42697. null,
  42698. 'PageInformation',
  42699. 'EndOfPage',
  42700. 'EndOfStripe',
  42701. 'EndOfFile',
  42702. 'Profiles',
  42703. 'Tables',
  42704. null,
  42705. null,
  42706. null,
  42707. null,
  42708. null,
  42709. null,
  42710. null,
  42711. null,
  42712. 'Extension'
  42713. ];
  42714. var CodingTemplates = [
  42715. [
  42716. {
  42717. x: -1,
  42718. y: -2
  42719. },
  42720. {
  42721. x: 0,
  42722. y: -2
  42723. },
  42724. {
  42725. x: 1,
  42726. y: -2
  42727. },
  42728. {
  42729. x: -2,
  42730. y: -1
  42731. },
  42732. {
  42733. x: -1,
  42734. y: -1
  42735. },
  42736. {
  42737. x: 0,
  42738. y: -1
  42739. },
  42740. {
  42741. x: 1,
  42742. y: -1
  42743. },
  42744. {
  42745. x: 2,
  42746. y: -1
  42747. },
  42748. {
  42749. x: -4,
  42750. y: 0
  42751. },
  42752. {
  42753. x: -3,
  42754. y: 0
  42755. },
  42756. {
  42757. x: -2,
  42758. y: 0
  42759. },
  42760. {
  42761. x: -1,
  42762. y: 0
  42763. }
  42764. ],
  42765. [
  42766. {
  42767. x: -1,
  42768. y: -2
  42769. },
  42770. {
  42771. x: 0,
  42772. y: -2
  42773. },
  42774. {
  42775. x: 1,
  42776. y: -2
  42777. },
  42778. {
  42779. x: 2,
  42780. y: -2
  42781. },
  42782. {
  42783. x: -2,
  42784. y: -1
  42785. },
  42786. {
  42787. x: -1,
  42788. y: -1
  42789. },
  42790. {
  42791. x: 0,
  42792. y: -1
  42793. },
  42794. {
  42795. x: 1,
  42796. y: -1
  42797. },
  42798. {
  42799. x: 2,
  42800. y: -1
  42801. },
  42802. {
  42803. x: -3,
  42804. y: 0
  42805. },
  42806. {
  42807. x: -2,
  42808. y: 0
  42809. },
  42810. {
  42811. x: -1,
  42812. y: 0
  42813. }
  42814. ],
  42815. [
  42816. {
  42817. x: -1,
  42818. y: -2
  42819. },
  42820. {
  42821. x: 0,
  42822. y: -2
  42823. },
  42824. {
  42825. x: 1,
  42826. y: -2
  42827. },
  42828. {
  42829. x: -2,
  42830. y: -1
  42831. },
  42832. {
  42833. x: -1,
  42834. y: -1
  42835. },
  42836. {
  42837. x: 0,
  42838. y: -1
  42839. },
  42840. {
  42841. x: 1,
  42842. y: -1
  42843. },
  42844. {
  42845. x: -2,
  42846. y: 0
  42847. },
  42848. {
  42849. x: -1,
  42850. y: 0
  42851. }
  42852. ],
  42853. [
  42854. {
  42855. x: -3,
  42856. y: -1
  42857. },
  42858. {
  42859. x: -2,
  42860. y: -1
  42861. },
  42862. {
  42863. x: -1,
  42864. y: -1
  42865. },
  42866. {
  42867. x: 0,
  42868. y: -1
  42869. },
  42870. {
  42871. x: 1,
  42872. y: -1
  42873. },
  42874. {
  42875. x: -4,
  42876. y: 0
  42877. },
  42878. {
  42879. x: -3,
  42880. y: 0
  42881. },
  42882. {
  42883. x: -2,
  42884. y: 0
  42885. },
  42886. {
  42887. x: -1,
  42888. y: 0
  42889. }
  42890. ]
  42891. ];
  42892. var RefinementTemplates = [
  42893. {
  42894. coding: [
  42895. {
  42896. x: 0,
  42897. y: -1
  42898. },
  42899. {
  42900. x: 1,
  42901. y: -1
  42902. },
  42903. {
  42904. x: -1,
  42905. y: 0
  42906. }
  42907. ],
  42908. reference: [
  42909. {
  42910. x: 0,
  42911. y: -1
  42912. },
  42913. {
  42914. x: 1,
  42915. y: -1
  42916. },
  42917. {
  42918. x: -1,
  42919. y: 0
  42920. },
  42921. {
  42922. x: 0,
  42923. y: 0
  42924. },
  42925. {
  42926. x: 1,
  42927. y: 0
  42928. },
  42929. {
  42930. x: -1,
  42931. y: 1
  42932. },
  42933. {
  42934. x: 0,
  42935. y: 1
  42936. },
  42937. {
  42938. x: 1,
  42939. y: 1
  42940. }
  42941. ]
  42942. },
  42943. {
  42944. coding: [
  42945. {
  42946. x: -1,
  42947. y: -1
  42948. },
  42949. {
  42950. x: 0,
  42951. y: -1
  42952. },
  42953. {
  42954. x: 1,
  42955. y: -1
  42956. },
  42957. {
  42958. x: -1,
  42959. y: 0
  42960. }
  42961. ],
  42962. reference: [
  42963. {
  42964. x: 0,
  42965. y: -1
  42966. },
  42967. {
  42968. x: -1,
  42969. y: 0
  42970. },
  42971. {
  42972. x: 0,
  42973. y: 0
  42974. },
  42975. {
  42976. x: 1,
  42977. y: 0
  42978. },
  42979. {
  42980. x: 0,
  42981. y: 1
  42982. },
  42983. {
  42984. x: 1,
  42985. y: 1
  42986. }
  42987. ]
  42988. }
  42989. ];
  42990. var ReusedContexts = [
  42991. 0x9B25,
  42992. 0x0795,
  42993. 0x00E5,
  42994. 0x0195
  42995. ];
  42996. var RefinementReusedContexts = [
  42997. 0x0020,
  42998. 0x0008
  42999. ];
  43000. function decodeBitmapTemplate0(width, height, decodingContext) {
  43001. var decoder = decodingContext.decoder;
  43002. var contexts = decodingContext.contextCache.getContexts('GB');
  43003. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  43004. var OLD_PIXEL_MASK = 0x7BF7;
  43005. for (i = 0; i < height; i++) {
  43006. row = bitmap[i] = new Uint8Array(width);
  43007. row1 = i < 1 ? row : bitmap[i - 1];
  43008. row2 = i < 2 ? row : bitmap[i - 2];
  43009. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  43010. for (j = 0; j < width; j++) {
  43011. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  43012. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  43013. }
  43014. }
  43015. return bitmap;
  43016. }
  43017. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  43018. if (mmr) {
  43019. error('JBIG2 error: MMR encoding is not supported');
  43020. }
  43021. if (templateIndex === 0 && !skip && !prediction && at.length === 4 && at[0].x === 3 && at[0].y === -1 && at[1].x === -3 && at[1].y === -1 && at[2].x === 2 && at[2].y === -2 && at[3].x === -2 && at[3].y === -2) {
  43022. return decodeBitmapTemplate0(width, height, decodingContext);
  43023. }
  43024. var useskip = !!skip;
  43025. var template = CodingTemplates[templateIndex].concat(at);
  43026. template.sort(function (a, b) {
  43027. return a.y - b.y || a.x - b.x;
  43028. });
  43029. var templateLength = template.length;
  43030. var templateX = new Int8Array(templateLength);
  43031. var templateY = new Int8Array(templateLength);
  43032. var changingTemplateEntries = [];
  43033. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  43034. var c, k;
  43035. for (k = 0; k < templateLength; k++) {
  43036. templateX[k] = template[k].x;
  43037. templateY[k] = template[k].y;
  43038. minX = Math.min(minX, template[k].x);
  43039. maxX = Math.max(maxX, template[k].x);
  43040. minY = Math.min(minY, template[k].y);
  43041. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  43042. reuseMask |= 1 << templateLength - 1 - k;
  43043. } else {
  43044. changingTemplateEntries.push(k);
  43045. }
  43046. }
  43047. var changingEntriesLength = changingTemplateEntries.length;
  43048. var changingTemplateX = new Int8Array(changingEntriesLength);
  43049. var changingTemplateY = new Int8Array(changingEntriesLength);
  43050. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  43051. for (c = 0; c < changingEntriesLength; c++) {
  43052. k = changingTemplateEntries[c];
  43053. changingTemplateX[c] = template[k].x;
  43054. changingTemplateY[c] = template[k].y;
  43055. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  43056. }
  43057. var sbb_left = -minX;
  43058. var sbb_top = -minY;
  43059. var sbb_right = width - maxX;
  43060. var pseudoPixelContext = ReusedContexts[templateIndex];
  43061. var row = new Uint8Array(width);
  43062. var bitmap = [];
  43063. var decoder = decodingContext.decoder;
  43064. var contexts = decodingContext.contextCache.getContexts('GB');
  43065. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  43066. for (var i = 0; i < height; i++) {
  43067. if (prediction) {
  43068. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  43069. ltp ^= sltp;
  43070. if (ltp) {
  43071. bitmap.push(row);
  43072. continue;
  43073. }
  43074. }
  43075. row = new Uint8Array(row);
  43076. bitmap.push(row);
  43077. for (j = 0; j < width; j++) {
  43078. if (useskip && skip[i][j]) {
  43079. row[j] = 0;
  43080. continue;
  43081. }
  43082. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  43083. contextLabel = contextLabel << 1 & reuseMask;
  43084. for (k = 0; k < changingEntriesLength; k++) {
  43085. i0 = i + changingTemplateY[k];
  43086. j0 = j + changingTemplateX[k];
  43087. bit = bitmap[i0][j0];
  43088. if (bit) {
  43089. bit = changingTemplateBit[k];
  43090. contextLabel |= bit;
  43091. }
  43092. }
  43093. } else {
  43094. contextLabel = 0;
  43095. shift = templateLength - 1;
  43096. for (k = 0; k < templateLength; k++, shift--) {
  43097. j0 = j + templateX[k];
  43098. if (j0 >= 0 && j0 < width) {
  43099. i0 = i + templateY[k];
  43100. if (i0 >= 0) {
  43101. bit = bitmap[i0][j0];
  43102. if (bit) {
  43103. contextLabel |= bit << shift;
  43104. }
  43105. }
  43106. }
  43107. }
  43108. }
  43109. var pixel = decoder.readBit(contexts, contextLabel);
  43110. row[j] = pixel;
  43111. }
  43112. }
  43113. return bitmap;
  43114. }
  43115. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  43116. var codingTemplate = RefinementTemplates[templateIndex].coding;
  43117. if (templateIndex === 0) {
  43118. codingTemplate = codingTemplate.concat([at[0]]);
  43119. }
  43120. var codingTemplateLength = codingTemplate.length;
  43121. var codingTemplateX = new Int32Array(codingTemplateLength);
  43122. var codingTemplateY = new Int32Array(codingTemplateLength);
  43123. var k;
  43124. for (k = 0; k < codingTemplateLength; k++) {
  43125. codingTemplateX[k] = codingTemplate[k].x;
  43126. codingTemplateY[k] = codingTemplate[k].y;
  43127. }
  43128. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  43129. if (templateIndex === 0) {
  43130. referenceTemplate = referenceTemplate.concat([at[1]]);
  43131. }
  43132. var referenceTemplateLength = referenceTemplate.length;
  43133. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  43134. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  43135. for (k = 0; k < referenceTemplateLength; k++) {
  43136. referenceTemplateX[k] = referenceTemplate[k].x;
  43137. referenceTemplateY[k] = referenceTemplate[k].y;
  43138. }
  43139. var referenceWidth = referenceBitmap[0].length;
  43140. var referenceHeight = referenceBitmap.length;
  43141. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  43142. var bitmap = [];
  43143. var decoder = decodingContext.decoder;
  43144. var contexts = decodingContext.contextCache.getContexts('GR');
  43145. var ltp = 0;
  43146. for (var i = 0; i < height; i++) {
  43147. if (prediction) {
  43148. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  43149. ltp ^= sltp;
  43150. if (ltp) {
  43151. error('JBIG2 error: prediction is not supported');
  43152. }
  43153. }
  43154. var row = new Uint8Array(width);
  43155. bitmap.push(row);
  43156. for (var j = 0; j < width; j++) {
  43157. var i0, j0;
  43158. var contextLabel = 0;
  43159. for (k = 0; k < codingTemplateLength; k++) {
  43160. i0 = i + codingTemplateY[k];
  43161. j0 = j + codingTemplateX[k];
  43162. if (i0 < 0 || j0 < 0 || j0 >= width) {
  43163. contextLabel <<= 1;
  43164. } else {
  43165. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  43166. }
  43167. }
  43168. for (k = 0; k < referenceTemplateLength; k++) {
  43169. i0 = i + referenceTemplateY[k] + offsetY;
  43170. j0 = j + referenceTemplateX[k] + offsetX;
  43171. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  43172. contextLabel <<= 1;
  43173. } else {
  43174. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  43175. }
  43176. }
  43177. var pixel = decoder.readBit(contexts, contextLabel);
  43178. row[j] = pixel;
  43179. }
  43180. }
  43181. return bitmap;
  43182. }
  43183. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  43184. if (huffman) {
  43185. error('JBIG2 error: huffman is not supported');
  43186. }
  43187. var newSymbols = [];
  43188. var currentHeight = 0;
  43189. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  43190. var decoder = decodingContext.decoder;
  43191. var contextCache = decodingContext.contextCache;
  43192. while (newSymbols.length < numberOfNewSymbols) {
  43193. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  43194. currentHeight += deltaHeight;
  43195. var currentWidth = 0;
  43196. while (true) {
  43197. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  43198. if (deltaWidth === null) {
  43199. break;
  43200. }
  43201. currentWidth += deltaWidth;
  43202. var bitmap;
  43203. if (refinement) {
  43204. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  43205. if (numberOfInstances > 1) {
  43206. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  43207. } else {
  43208. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  43209. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  43210. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  43211. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  43212. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  43213. }
  43214. } else {
  43215. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  43216. }
  43217. newSymbols.push(bitmap);
  43218. }
  43219. }
  43220. var exportedSymbols = [];
  43221. var flags = [], currentFlag = false;
  43222. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  43223. while (flags.length < totalSymbolsLength) {
  43224. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  43225. while (runLength--) {
  43226. flags.push(currentFlag);
  43227. }
  43228. currentFlag = !currentFlag;
  43229. }
  43230. for (var i = 0, ii = symbols.length; i < ii; i++) {
  43231. if (flags[i]) {
  43232. exportedSymbols.push(symbols[i]);
  43233. }
  43234. }
  43235. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  43236. if (flags[i]) {
  43237. exportedSymbols.push(newSymbols[j]);
  43238. }
  43239. }
  43240. return exportedSymbols;
  43241. }
  43242. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  43243. if (huffman) {
  43244. error('JBIG2 error: huffman is not supported');
  43245. }
  43246. var bitmap = [];
  43247. var i, row;
  43248. for (i = 0; i < height; i++) {
  43249. row = new Uint8Array(width);
  43250. if (defaultPixelValue) {
  43251. for (var j = 0; j < width; j++) {
  43252. row[j] = defaultPixelValue;
  43253. }
  43254. }
  43255. bitmap.push(row);
  43256. }
  43257. var decoder = decodingContext.decoder;
  43258. var contextCache = decodingContext.contextCache;
  43259. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  43260. var firstS = 0;
  43261. i = 0;
  43262. while (i < numberOfSymbolInstances) {
  43263. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  43264. stripT += deltaT;
  43265. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  43266. firstS += deltaFirstS;
  43267. var currentS = firstS;
  43268. do {
  43269. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  43270. var t = stripSize * stripT + currentT;
  43271. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  43272. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  43273. var symbolBitmap = inputSymbols[symbolId];
  43274. var symbolWidth = symbolBitmap[0].length;
  43275. var symbolHeight = symbolBitmap.length;
  43276. if (applyRefinement) {
  43277. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  43278. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  43279. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  43280. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  43281. symbolWidth += rdw;
  43282. symbolHeight += rdh;
  43283. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  43284. }
  43285. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  43286. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  43287. var s2, t2, symbolRow;
  43288. if (transposed) {
  43289. for (s2 = 0; s2 < symbolHeight; s2++) {
  43290. row = bitmap[offsetS + s2];
  43291. if (!row) {
  43292. continue;
  43293. }
  43294. symbolRow = symbolBitmap[s2];
  43295. var maxWidth = Math.min(width - offsetT, symbolWidth);
  43296. switch (combinationOperator) {
  43297. case 0:
  43298. for (t2 = 0; t2 < maxWidth; t2++) {
  43299. row[offsetT + t2] |= symbolRow[t2];
  43300. }
  43301. break;
  43302. case 2:
  43303. for (t2 = 0; t2 < maxWidth; t2++) {
  43304. row[offsetT + t2] ^= symbolRow[t2];
  43305. }
  43306. break;
  43307. default:
  43308. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  43309. }
  43310. }
  43311. currentS += symbolHeight - 1;
  43312. } else {
  43313. for (t2 = 0; t2 < symbolHeight; t2++) {
  43314. row = bitmap[offsetT + t2];
  43315. if (!row) {
  43316. continue;
  43317. }
  43318. symbolRow = symbolBitmap[t2];
  43319. switch (combinationOperator) {
  43320. case 0:
  43321. for (s2 = 0; s2 < symbolWidth; s2++) {
  43322. row[offsetS + s2] |= symbolRow[s2];
  43323. }
  43324. break;
  43325. case 2:
  43326. for (s2 = 0; s2 < symbolWidth; s2++) {
  43327. row[offsetS + s2] ^= symbolRow[s2];
  43328. }
  43329. break;
  43330. default:
  43331. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  43332. }
  43333. }
  43334. currentS += symbolWidth - 1;
  43335. }
  43336. i++;
  43337. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  43338. if (deltaS === null) {
  43339. break;
  43340. }
  43341. currentS += deltaS + dsOffset;
  43342. } while (true);
  43343. }
  43344. return bitmap;
  43345. }
  43346. function readSegmentHeader(data, start) {
  43347. var segmentHeader = {};
  43348. segmentHeader.number = readUint32(data, start);
  43349. var flags = data[start + 4];
  43350. var segmentType = flags & 0x3F;
  43351. if (!SegmentTypes[segmentType]) {
  43352. error('JBIG2 error: invalid segment type: ' + segmentType);
  43353. }
  43354. segmentHeader.type = segmentType;
  43355. segmentHeader.typeName = SegmentTypes[segmentType];
  43356. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  43357. var pageAssociationFieldSize = !!(flags & 0x40);
  43358. var referredFlags = data[start + 5];
  43359. var referredToCount = referredFlags >> 5 & 7;
  43360. var retainBits = [referredFlags & 31];
  43361. var position = start + 6;
  43362. if (referredFlags === 7) {
  43363. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  43364. position += 3;
  43365. var bytes = referredToCount + 7 >> 3;
  43366. retainBits[0] = data[position++];
  43367. while (--bytes > 0) {
  43368. retainBits.push(data[position++]);
  43369. }
  43370. } else if (referredFlags === 5 || referredFlags === 6) {
  43371. error('JBIG2 error: invalid referred-to flags');
  43372. }
  43373. segmentHeader.retainBits = retainBits;
  43374. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  43375. var referredTo = [];
  43376. var i, ii;
  43377. for (i = 0; i < referredToCount; i++) {
  43378. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  43379. referredTo.push(number);
  43380. position += referredToSegmentNumberSize;
  43381. }
  43382. segmentHeader.referredTo = referredTo;
  43383. if (!pageAssociationFieldSize) {
  43384. segmentHeader.pageAssociation = data[position++];
  43385. } else {
  43386. segmentHeader.pageAssociation = readUint32(data, position);
  43387. position += 4;
  43388. }
  43389. segmentHeader.length = readUint32(data, position);
  43390. position += 4;
  43391. if (segmentHeader.length === 0xFFFFFFFF) {
  43392. if (segmentType === 38) {
  43393. var genericRegionInfo = readRegionSegmentInformation(data, position);
  43394. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  43395. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  43396. var searchPatternLength = 6;
  43397. var searchPattern = new Uint8Array(searchPatternLength);
  43398. if (!genericRegionMmr) {
  43399. searchPattern[0] = 0xFF;
  43400. searchPattern[1] = 0xAC;
  43401. }
  43402. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  43403. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  43404. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  43405. searchPattern[5] = genericRegionInfo.height & 0xFF;
  43406. for (i = position, ii = data.length; i < ii; i++) {
  43407. var j = 0;
  43408. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  43409. j++;
  43410. }
  43411. if (j === searchPatternLength) {
  43412. segmentHeader.length = i + searchPatternLength;
  43413. break;
  43414. }
  43415. }
  43416. if (segmentHeader.length === 0xFFFFFFFF) {
  43417. error('JBIG2 error: segment end was not found');
  43418. }
  43419. } else {
  43420. error('JBIG2 error: invalid unknown segment length');
  43421. }
  43422. }
  43423. segmentHeader.headerEnd = position;
  43424. return segmentHeader;
  43425. }
  43426. function readSegments(header, data, start, end) {
  43427. var segments = [];
  43428. var position = start;
  43429. while (position < end) {
  43430. var segmentHeader = readSegmentHeader(data, position);
  43431. position = segmentHeader.headerEnd;
  43432. var segment = {
  43433. header: segmentHeader,
  43434. data: data
  43435. };
  43436. if (!header.randomAccess) {
  43437. segment.start = position;
  43438. position += segmentHeader.length;
  43439. segment.end = position;
  43440. }
  43441. segments.push(segment);
  43442. if (segmentHeader.type === 51) {
  43443. break;
  43444. }
  43445. }
  43446. if (header.randomAccess) {
  43447. for (var i = 0, ii = segments.length; i < ii; i++) {
  43448. segments[i].start = position;
  43449. position += segments[i].header.length;
  43450. segments[i].end = position;
  43451. }
  43452. }
  43453. return segments;
  43454. }
  43455. function readRegionSegmentInformation(data, start) {
  43456. return {
  43457. width: readUint32(data, start),
  43458. height: readUint32(data, start + 4),
  43459. x: readUint32(data, start + 8),
  43460. y: readUint32(data, start + 12),
  43461. combinationOperator: data[start + 16] & 7
  43462. };
  43463. }
  43464. var RegionSegmentInformationFieldLength = 17;
  43465. function processSegment(segment, visitor) {
  43466. var header = segment.header;
  43467. var data = segment.data, position = segment.start, end = segment.end;
  43468. var args, at, i, atLength;
  43469. switch (header.type) {
  43470. case 0:
  43471. var dictionary = {};
  43472. var dictionaryFlags = readUint16(data, position);
  43473. dictionary.huffman = !!(dictionaryFlags & 1);
  43474. dictionary.refinement = !!(dictionaryFlags & 2);
  43475. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  43476. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  43477. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  43478. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  43479. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  43480. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  43481. dictionary.template = dictionaryFlags >> 10 & 3;
  43482. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  43483. position += 2;
  43484. if (!dictionary.huffman) {
  43485. atLength = dictionary.template === 0 ? 4 : 1;
  43486. at = [];
  43487. for (i = 0; i < atLength; i++) {
  43488. at.push({
  43489. x: readInt8(data, position),
  43490. y: readInt8(data, position + 1)
  43491. });
  43492. position += 2;
  43493. }
  43494. dictionary.at = at;
  43495. }
  43496. if (dictionary.refinement && !dictionary.refinementTemplate) {
  43497. at = [];
  43498. for (i = 0; i < 2; i++) {
  43499. at.push({
  43500. x: readInt8(data, position),
  43501. y: readInt8(data, position + 1)
  43502. });
  43503. position += 2;
  43504. }
  43505. dictionary.refinementAt = at;
  43506. }
  43507. dictionary.numberOfExportedSymbols = readUint32(data, position);
  43508. position += 4;
  43509. dictionary.numberOfNewSymbols = readUint32(data, position);
  43510. position += 4;
  43511. args = [
  43512. dictionary,
  43513. header.number,
  43514. header.referredTo,
  43515. data,
  43516. position,
  43517. end
  43518. ];
  43519. break;
  43520. case 6:
  43521. case 7:
  43522. var textRegion = {};
  43523. textRegion.info = readRegionSegmentInformation(data, position);
  43524. position += RegionSegmentInformationFieldLength;
  43525. var textRegionSegmentFlags = readUint16(data, position);
  43526. position += 2;
  43527. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  43528. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  43529. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  43530. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  43531. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  43532. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  43533. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  43534. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  43535. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  43536. if (textRegion.huffman) {
  43537. var textRegionHuffmanFlags = readUint16(data, position);
  43538. position += 2;
  43539. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  43540. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  43541. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  43542. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  43543. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  43544. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  43545. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  43546. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  43547. }
  43548. if (textRegion.refinement && !textRegion.refinementTemplate) {
  43549. at = [];
  43550. for (i = 0; i < 2; i++) {
  43551. at.push({
  43552. x: readInt8(data, position),
  43553. y: readInt8(data, position + 1)
  43554. });
  43555. position += 2;
  43556. }
  43557. textRegion.refinementAt = at;
  43558. }
  43559. textRegion.numberOfSymbolInstances = readUint32(data, position);
  43560. position += 4;
  43561. if (textRegion.huffman) {
  43562. error('JBIG2 error: huffman is not supported');
  43563. }
  43564. args = [
  43565. textRegion,
  43566. header.referredTo,
  43567. data,
  43568. position,
  43569. end
  43570. ];
  43571. break;
  43572. case 38:
  43573. case 39:
  43574. var genericRegion = {};
  43575. genericRegion.info = readRegionSegmentInformation(data, position);
  43576. position += RegionSegmentInformationFieldLength;
  43577. var genericRegionSegmentFlags = data[position++];
  43578. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  43579. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  43580. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  43581. if (!genericRegion.mmr) {
  43582. atLength = genericRegion.template === 0 ? 4 : 1;
  43583. at = [];
  43584. for (i = 0; i < atLength; i++) {
  43585. at.push({
  43586. x: readInt8(data, position),
  43587. y: readInt8(data, position + 1)
  43588. });
  43589. position += 2;
  43590. }
  43591. genericRegion.at = at;
  43592. }
  43593. args = [
  43594. genericRegion,
  43595. data,
  43596. position,
  43597. end
  43598. ];
  43599. break;
  43600. case 48:
  43601. var pageInfo = {
  43602. width: readUint32(data, position),
  43603. height: readUint32(data, position + 4),
  43604. resolutionX: readUint32(data, position + 8),
  43605. resolutionY: readUint32(data, position + 12)
  43606. };
  43607. if (pageInfo.height === 0xFFFFFFFF) {
  43608. delete pageInfo.height;
  43609. }
  43610. var pageSegmentFlags = data[position + 16];
  43611. readUint16(data, position + 17);
  43612. pageInfo.lossless = !!(pageSegmentFlags & 1);
  43613. pageInfo.refinement = !!(pageSegmentFlags & 2);
  43614. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  43615. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  43616. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  43617. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  43618. args = [pageInfo];
  43619. break;
  43620. case 49:
  43621. break;
  43622. case 50:
  43623. break;
  43624. case 51:
  43625. break;
  43626. case 62:
  43627. break;
  43628. default:
  43629. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  43630. }
  43631. var callbackName = 'on' + header.typeName;
  43632. if (callbackName in visitor) {
  43633. visitor[callbackName].apply(visitor, args);
  43634. }
  43635. }
  43636. function processSegments(segments, visitor) {
  43637. for (var i = 0, ii = segments.length; i < ii; i++) {
  43638. processSegment(segments[i], visitor);
  43639. }
  43640. }
  43641. function parseJbig2(data, start, end) {
  43642. var position = start;
  43643. if (data[position] !== 0x97 || data[position + 1] !== 0x4A || data[position + 2] !== 0x42 || data[position + 3] !== 0x32 || data[position + 4] !== 0x0D || data[position + 5] !== 0x0A || data[position + 6] !== 0x1A || data[position + 7] !== 0x0A) {
  43644. error('JBIG2 error: invalid header');
  43645. }
  43646. var header = {};
  43647. position += 8;
  43648. var flags = data[position++];
  43649. header.randomAccess = !(flags & 1);
  43650. if (!(flags & 2)) {
  43651. header.numberOfPages = readUint32(data, position);
  43652. position += 4;
  43653. }
  43654. readSegments(header, data, position, end);
  43655. error('Not implemented');
  43656. }
  43657. function parseJbig2Chunks(chunks) {
  43658. var visitor = new SimpleSegmentVisitor();
  43659. for (var i = 0, ii = chunks.length; i < ii; i++) {
  43660. var chunk = chunks[i];
  43661. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  43662. processSegments(segments, visitor);
  43663. }
  43664. return visitor.buffer;
  43665. }
  43666. function SimpleSegmentVisitor() {
  43667. }
  43668. SimpleSegmentVisitor.prototype = {
  43669. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  43670. this.currentPageInfo = info;
  43671. var rowSize = info.width + 7 >> 3;
  43672. var buffer = new Uint8Array(rowSize * info.height);
  43673. if (info.defaultPixelValue) {
  43674. for (var i = 0, ii = buffer.length; i < ii; i++) {
  43675. buffer[i] = 0xFF;
  43676. }
  43677. }
  43678. this.buffer = buffer;
  43679. },
  43680. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  43681. var pageInfo = this.currentPageInfo;
  43682. var width = regionInfo.width, height = regionInfo.height;
  43683. var rowSize = pageInfo.width + 7 >> 3;
  43684. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  43685. var buffer = this.buffer;
  43686. var mask0 = 128 >> (regionInfo.x & 7);
  43687. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  43688. var i, j, mask, offset;
  43689. switch (combinationOperator) {
  43690. case 0:
  43691. for (i = 0; i < height; i++) {
  43692. mask = mask0;
  43693. offset = offset0;
  43694. for (j = 0; j < width; j++) {
  43695. if (bitmap[i][j]) {
  43696. buffer[offset] |= mask;
  43697. }
  43698. mask >>= 1;
  43699. if (!mask) {
  43700. mask = 128;
  43701. offset++;
  43702. }
  43703. }
  43704. offset0 += rowSize;
  43705. }
  43706. break;
  43707. case 2:
  43708. for (i = 0; i < height; i++) {
  43709. mask = mask0;
  43710. offset = offset0;
  43711. for (j = 0; j < width; j++) {
  43712. if (bitmap[i][j]) {
  43713. buffer[offset] ^= mask;
  43714. }
  43715. mask >>= 1;
  43716. if (!mask) {
  43717. mask = 128;
  43718. offset++;
  43719. }
  43720. }
  43721. offset0 += rowSize;
  43722. }
  43723. break;
  43724. default:
  43725. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  43726. }
  43727. },
  43728. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  43729. var regionInfo = region.info;
  43730. var decodingContext = new DecodingContext(data, start, end);
  43731. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  43732. this.drawBitmap(regionInfo, bitmap);
  43733. },
  43734. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  43735. this.onImmediateGenericRegion.apply(this, arguments);
  43736. },
  43737. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  43738. var huffmanTables;
  43739. if (dictionary.huffman) {
  43740. error('JBIG2 error: huffman is not supported');
  43741. }
  43742. var symbols = this.symbols;
  43743. if (!symbols) {
  43744. this.symbols = symbols = {};
  43745. }
  43746. var inputSymbols = [];
  43747. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  43748. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  43749. }
  43750. var decodingContext = new DecodingContext(data, start, end);
  43751. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  43752. },
  43753. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  43754. var regionInfo = region.info;
  43755. var huffmanTables;
  43756. var symbols = this.symbols;
  43757. var inputSymbols = [];
  43758. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  43759. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  43760. }
  43761. var symbolCodeLength = log2(inputSymbols.length);
  43762. var decodingContext = new DecodingContext(data, start, end);
  43763. var bitmap = decodeTextRegion(region.huffman, region.refinement, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.numberOfSymbolInstances, region.stripSize, inputSymbols, symbolCodeLength, region.transposed, region.dsOffset, region.referenceCorner, region.combinationOperator, huffmanTables, region.refinementTemplate, region.refinementAt, decodingContext);
  43764. this.drawBitmap(regionInfo, bitmap);
  43765. },
  43766. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  43767. this.onImmediateTextRegion.apply(this, arguments);
  43768. }
  43769. };
  43770. function Jbig2Image() {
  43771. }
  43772. Jbig2Image.prototype = {
  43773. parseChunks: function Jbig2Image_parseChunks(chunks) {
  43774. return parseJbig2Chunks(chunks);
  43775. }
  43776. };
  43777. return Jbig2Image;
  43778. }();
  43779. exports.Jbig2Image = Jbig2Image;
  43780. /***/ }),
  43781. /* 29 */
  43782. /***/ (function(module, exports, __w_pdfjs_require__) {
  43783. "use strict";
  43784. var sharedUtil = __w_pdfjs_require__(0);
  43785. var error = sharedUtil.error;
  43786. var JpegImage = function JpegImageClosure() {
  43787. var dctZigZag = new Uint8Array([
  43788. 0,
  43789. 1,
  43790. 8,
  43791. 16,
  43792. 9,
  43793. 2,
  43794. 3,
  43795. 10,
  43796. 17,
  43797. 24,
  43798. 32,
  43799. 25,
  43800. 18,
  43801. 11,
  43802. 4,
  43803. 5,
  43804. 12,
  43805. 19,
  43806. 26,
  43807. 33,
  43808. 40,
  43809. 48,
  43810. 41,
  43811. 34,
  43812. 27,
  43813. 20,
  43814. 13,
  43815. 6,
  43816. 7,
  43817. 14,
  43818. 21,
  43819. 28,
  43820. 35,
  43821. 42,
  43822. 49,
  43823. 56,
  43824. 57,
  43825. 50,
  43826. 43,
  43827. 36,
  43828. 29,
  43829. 22,
  43830. 15,
  43831. 23,
  43832. 30,
  43833. 37,
  43834. 44,
  43835. 51,
  43836. 58,
  43837. 59,
  43838. 52,
  43839. 45,
  43840. 38,
  43841. 31,
  43842. 39,
  43843. 46,
  43844. 53,
  43845. 60,
  43846. 61,
  43847. 54,
  43848. 47,
  43849. 55,
  43850. 62,
  43851. 63
  43852. ]);
  43853. var dctCos1 = 4017;
  43854. var dctSin1 = 799;
  43855. var dctCos3 = 3406;
  43856. var dctSin3 = 2276;
  43857. var dctCos6 = 1567;
  43858. var dctSin6 = 3784;
  43859. var dctSqrt2 = 5793;
  43860. var dctSqrt1d2 = 2896;
  43861. function JpegImage() {
  43862. this.decodeTransform = null;
  43863. this.colorTransform = -1;
  43864. }
  43865. function buildHuffmanTable(codeLengths, values) {
  43866. var k = 0, code = [], i, j, length = 16;
  43867. while (length > 0 && !codeLengths[length - 1]) {
  43868. length--;
  43869. }
  43870. code.push({
  43871. children: [],
  43872. index: 0
  43873. });
  43874. var p = code[0], q;
  43875. for (i = 0; i < length; i++) {
  43876. for (j = 0; j < codeLengths[i]; j++) {
  43877. p = code.pop();
  43878. p.children[p.index] = values[k];
  43879. while (p.index > 0) {
  43880. p = code.pop();
  43881. }
  43882. p.index++;
  43883. code.push(p);
  43884. while (code.length <= i) {
  43885. code.push(q = {
  43886. children: [],
  43887. index: 0
  43888. });
  43889. p.children[p.index] = q.children;
  43890. p = q;
  43891. }
  43892. k++;
  43893. }
  43894. if (i + 1 < length) {
  43895. code.push(q = {
  43896. children: [],
  43897. index: 0
  43898. });
  43899. p.children[p.index] = q.children;
  43900. p = q;
  43901. }
  43902. }
  43903. return code[0].children;
  43904. }
  43905. function getBlockBufferOffset(component, row, col) {
  43906. return 64 * ((component.blocksPerLine + 1) * row + col);
  43907. }
  43908. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  43909. var mcusPerLine = frame.mcusPerLine;
  43910. var progressive = frame.progressive;
  43911. var startOffset = offset, bitsData = 0, bitsCount = 0;
  43912. function readBit() {
  43913. if (bitsCount > 0) {
  43914. bitsCount--;
  43915. return bitsData >> bitsCount & 1;
  43916. }
  43917. bitsData = data[offset++];
  43918. if (bitsData === 0xFF) {
  43919. var nextByte = data[offset++];
  43920. if (nextByte) {
  43921. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  43922. }
  43923. }
  43924. bitsCount = 7;
  43925. return bitsData >>> 7;
  43926. }
  43927. function decodeHuffman(tree) {
  43928. var node = tree;
  43929. while (true) {
  43930. node = node[readBit()];
  43931. if (typeof node === 'number') {
  43932. return node;
  43933. }
  43934. if (typeof node !== 'object') {
  43935. error('JPEG error: invalid huffman sequence');
  43936. }
  43937. }
  43938. }
  43939. function receive(length) {
  43940. var n = 0;
  43941. while (length > 0) {
  43942. n = n << 1 | readBit();
  43943. length--;
  43944. }
  43945. return n;
  43946. }
  43947. function receiveAndExtend(length) {
  43948. if (length === 1) {
  43949. return readBit() === 1 ? 1 : -1;
  43950. }
  43951. var n = receive(length);
  43952. if (n >= 1 << length - 1) {
  43953. return n;
  43954. }
  43955. return n + (-1 << length) + 1;
  43956. }
  43957. function decodeBaseline(component, offset) {
  43958. var t = decodeHuffman(component.huffmanTableDC);
  43959. var diff = t === 0 ? 0 : receiveAndExtend(t);
  43960. component.blockData[offset] = component.pred += diff;
  43961. var k = 1;
  43962. while (k < 64) {
  43963. var rs = decodeHuffman(component.huffmanTableAC);
  43964. var s = rs & 15, r = rs >> 4;
  43965. if (s === 0) {
  43966. if (r < 15) {
  43967. break;
  43968. }
  43969. k += 16;
  43970. continue;
  43971. }
  43972. k += r;
  43973. var z = dctZigZag[k];
  43974. component.blockData[offset + z] = receiveAndExtend(s);
  43975. k++;
  43976. }
  43977. }
  43978. function decodeDCFirst(component, offset) {
  43979. var t = decodeHuffman(component.huffmanTableDC);
  43980. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  43981. component.blockData[offset] = component.pred += diff;
  43982. }
  43983. function decodeDCSuccessive(component, offset) {
  43984. component.blockData[offset] |= readBit() << successive;
  43985. }
  43986. var eobrun = 0;
  43987. function decodeACFirst(component, offset) {
  43988. if (eobrun > 0) {
  43989. eobrun--;
  43990. return;
  43991. }
  43992. var k = spectralStart, e = spectralEnd;
  43993. while (k <= e) {
  43994. var rs = decodeHuffman(component.huffmanTableAC);
  43995. var s = rs & 15, r = rs >> 4;
  43996. if (s === 0) {
  43997. if (r < 15) {
  43998. eobrun = receive(r) + (1 << r) - 1;
  43999. break;
  44000. }
  44001. k += 16;
  44002. continue;
  44003. }
  44004. k += r;
  44005. var z = dctZigZag[k];
  44006. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  44007. k++;
  44008. }
  44009. }
  44010. var successiveACState = 0, successiveACNextValue;
  44011. function decodeACSuccessive(component, offset) {
  44012. var k = spectralStart;
  44013. var e = spectralEnd;
  44014. var r = 0;
  44015. var s;
  44016. var rs;
  44017. while (k <= e) {
  44018. var z = dctZigZag[k];
  44019. switch (successiveACState) {
  44020. case 0:
  44021. rs = decodeHuffman(component.huffmanTableAC);
  44022. s = rs & 15;
  44023. r = rs >> 4;
  44024. if (s === 0) {
  44025. if (r < 15) {
  44026. eobrun = receive(r) + (1 << r);
  44027. successiveACState = 4;
  44028. } else {
  44029. r = 16;
  44030. successiveACState = 1;
  44031. }
  44032. } else {
  44033. if (s !== 1) {
  44034. error('JPEG error: invalid ACn encoding');
  44035. }
  44036. successiveACNextValue = receiveAndExtend(s);
  44037. successiveACState = r ? 2 : 3;
  44038. }
  44039. continue;
  44040. case 1:
  44041. case 2:
  44042. if (component.blockData[offset + z]) {
  44043. component.blockData[offset + z] += readBit() << successive;
  44044. } else {
  44045. r--;
  44046. if (r === 0) {
  44047. successiveACState = successiveACState === 2 ? 3 : 0;
  44048. }
  44049. }
  44050. break;
  44051. case 3:
  44052. if (component.blockData[offset + z]) {
  44053. component.blockData[offset + z] += readBit() << successive;
  44054. } else {
  44055. component.blockData[offset + z] = successiveACNextValue << successive;
  44056. successiveACState = 0;
  44057. }
  44058. break;
  44059. case 4:
  44060. if (component.blockData[offset + z]) {
  44061. component.blockData[offset + z] += readBit() << successive;
  44062. }
  44063. break;
  44064. }
  44065. k++;
  44066. }
  44067. if (successiveACState === 4) {
  44068. eobrun--;
  44069. if (eobrun === 0) {
  44070. successiveACState = 0;
  44071. }
  44072. }
  44073. }
  44074. function decodeMcu(component, decode, mcu, row, col) {
  44075. var mcuRow = mcu / mcusPerLine | 0;
  44076. var mcuCol = mcu % mcusPerLine;
  44077. var blockRow = mcuRow * component.v + row;
  44078. var blockCol = mcuCol * component.h + col;
  44079. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  44080. decode(component, offset);
  44081. }
  44082. function decodeBlock(component, decode, mcu) {
  44083. var blockRow = mcu / component.blocksPerLine | 0;
  44084. var blockCol = mcu % component.blocksPerLine;
  44085. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  44086. decode(component, offset);
  44087. }
  44088. var componentsLength = components.length;
  44089. var component, i, j, k, n;
  44090. var decodeFn;
  44091. if (progressive) {
  44092. if (spectralStart === 0) {
  44093. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  44094. } else {
  44095. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  44096. }
  44097. } else {
  44098. decodeFn = decodeBaseline;
  44099. }
  44100. var mcu = 0, marker;
  44101. var mcuExpected;
  44102. if (componentsLength === 1) {
  44103. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  44104. } else {
  44105. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  44106. }
  44107. if (!resetInterval) {
  44108. resetInterval = mcuExpected;
  44109. }
  44110. var h, v;
  44111. while (mcu < mcuExpected) {
  44112. for (i = 0; i < componentsLength; i++) {
  44113. components[i].pred = 0;
  44114. }
  44115. eobrun = 0;
  44116. if (componentsLength === 1) {
  44117. component = components[0];
  44118. for (n = 0; n < resetInterval; n++) {
  44119. decodeBlock(component, decodeFn, mcu);
  44120. mcu++;
  44121. }
  44122. } else {
  44123. for (n = 0; n < resetInterval; n++) {
  44124. for (i = 0; i < componentsLength; i++) {
  44125. component = components[i];
  44126. h = component.h;
  44127. v = component.v;
  44128. for (j = 0; j < v; j++) {
  44129. for (k = 0; k < h; k++) {
  44130. decodeMcu(component, decodeFn, mcu, j, k);
  44131. }
  44132. }
  44133. }
  44134. mcu++;
  44135. }
  44136. }
  44137. bitsCount = 0;
  44138. marker = data[offset] << 8 | data[offset + 1];
  44139. while (data[offset] === 0x00 && offset < data.length - 1) {
  44140. offset++;
  44141. marker = data[offset] << 8 | data[offset + 1];
  44142. }
  44143. if (marker <= 0xFF00) {
  44144. error('JPEG error: marker was not found');
  44145. }
  44146. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  44147. offset += 2;
  44148. } else {
  44149. break;
  44150. }
  44151. }
  44152. return offset - startOffset;
  44153. }
  44154. function quantizeAndInverse(component, blockBufferOffset, p) {
  44155. var qt = component.quantizationTable, blockData = component.blockData;
  44156. var v0, v1, v2, v3, v4, v5, v6, v7;
  44157. var p0, p1, p2, p3, p4, p5, p6, p7;
  44158. var t;
  44159. if (!qt) {
  44160. error('JPEG error: missing required Quantization Table.');
  44161. }
  44162. for (var row = 0; row < 64; row += 8) {
  44163. p0 = blockData[blockBufferOffset + row];
  44164. p1 = blockData[blockBufferOffset + row + 1];
  44165. p2 = blockData[blockBufferOffset + row + 2];
  44166. p3 = blockData[blockBufferOffset + row + 3];
  44167. p4 = blockData[blockBufferOffset + row + 4];
  44168. p5 = blockData[blockBufferOffset + row + 5];
  44169. p6 = blockData[blockBufferOffset + row + 6];
  44170. p7 = blockData[blockBufferOffset + row + 7];
  44171. p0 *= qt[row];
  44172. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  44173. t = dctSqrt2 * p0 + 512 >> 10;
  44174. p[row] = t;
  44175. p[row + 1] = t;
  44176. p[row + 2] = t;
  44177. p[row + 3] = t;
  44178. p[row + 4] = t;
  44179. p[row + 5] = t;
  44180. p[row + 6] = t;
  44181. p[row + 7] = t;
  44182. continue;
  44183. }
  44184. p1 *= qt[row + 1];
  44185. p2 *= qt[row + 2];
  44186. p3 *= qt[row + 3];
  44187. p4 *= qt[row + 4];
  44188. p5 *= qt[row + 5];
  44189. p6 *= qt[row + 6];
  44190. p7 *= qt[row + 7];
  44191. v0 = dctSqrt2 * p0 + 128 >> 8;
  44192. v1 = dctSqrt2 * p4 + 128 >> 8;
  44193. v2 = p2;
  44194. v3 = p6;
  44195. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  44196. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  44197. v5 = p3 << 4;
  44198. v6 = p5 << 4;
  44199. v0 = v0 + v1 + 1 >> 1;
  44200. v1 = v0 - v1;
  44201. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  44202. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  44203. v3 = t;
  44204. v4 = v4 + v6 + 1 >> 1;
  44205. v6 = v4 - v6;
  44206. v7 = v7 + v5 + 1 >> 1;
  44207. v5 = v7 - v5;
  44208. v0 = v0 + v3 + 1 >> 1;
  44209. v3 = v0 - v3;
  44210. v1 = v1 + v2 + 1 >> 1;
  44211. v2 = v1 - v2;
  44212. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  44213. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  44214. v7 = t;
  44215. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  44216. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  44217. v6 = t;
  44218. p[row] = v0 + v7;
  44219. p[row + 7] = v0 - v7;
  44220. p[row + 1] = v1 + v6;
  44221. p[row + 6] = v1 - v6;
  44222. p[row + 2] = v2 + v5;
  44223. p[row + 5] = v2 - v5;
  44224. p[row + 3] = v3 + v4;
  44225. p[row + 4] = v3 - v4;
  44226. }
  44227. for (var col = 0; col < 8; ++col) {
  44228. p0 = p[col];
  44229. p1 = p[col + 8];
  44230. p2 = p[col + 16];
  44231. p3 = p[col + 24];
  44232. p4 = p[col + 32];
  44233. p5 = p[col + 40];
  44234. p6 = p[col + 48];
  44235. p7 = p[col + 56];
  44236. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  44237. t = dctSqrt2 * p0 + 8192 >> 14;
  44238. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  44239. blockData[blockBufferOffset + col] = t;
  44240. blockData[blockBufferOffset + col + 8] = t;
  44241. blockData[blockBufferOffset + col + 16] = t;
  44242. blockData[blockBufferOffset + col + 24] = t;
  44243. blockData[blockBufferOffset + col + 32] = t;
  44244. blockData[blockBufferOffset + col + 40] = t;
  44245. blockData[blockBufferOffset + col + 48] = t;
  44246. blockData[blockBufferOffset + col + 56] = t;
  44247. continue;
  44248. }
  44249. v0 = dctSqrt2 * p0 + 2048 >> 12;
  44250. v1 = dctSqrt2 * p4 + 2048 >> 12;
  44251. v2 = p2;
  44252. v3 = p6;
  44253. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  44254. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  44255. v5 = p3;
  44256. v6 = p5;
  44257. v0 = (v0 + v1 + 1 >> 1) + 4112;
  44258. v1 = v0 - v1;
  44259. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  44260. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  44261. v3 = t;
  44262. v4 = v4 + v6 + 1 >> 1;
  44263. v6 = v4 - v6;
  44264. v7 = v7 + v5 + 1 >> 1;
  44265. v5 = v7 - v5;
  44266. v0 = v0 + v3 + 1 >> 1;
  44267. v3 = v0 - v3;
  44268. v1 = v1 + v2 + 1 >> 1;
  44269. v2 = v1 - v2;
  44270. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  44271. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  44272. v7 = t;
  44273. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  44274. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  44275. v6 = t;
  44276. p0 = v0 + v7;
  44277. p7 = v0 - v7;
  44278. p1 = v1 + v6;
  44279. p6 = v1 - v6;
  44280. p2 = v2 + v5;
  44281. p5 = v2 - v5;
  44282. p3 = v3 + v4;
  44283. p4 = v3 - v4;
  44284. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  44285. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  44286. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  44287. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  44288. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  44289. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  44290. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  44291. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  44292. blockData[blockBufferOffset + col] = p0;
  44293. blockData[blockBufferOffset + col + 8] = p1;
  44294. blockData[blockBufferOffset + col + 16] = p2;
  44295. blockData[blockBufferOffset + col + 24] = p3;
  44296. blockData[blockBufferOffset + col + 32] = p4;
  44297. blockData[blockBufferOffset + col + 40] = p5;
  44298. blockData[blockBufferOffset + col + 48] = p6;
  44299. blockData[blockBufferOffset + col + 56] = p7;
  44300. }
  44301. }
  44302. function buildComponentData(frame, component) {
  44303. var blocksPerLine = component.blocksPerLine;
  44304. var blocksPerColumn = component.blocksPerColumn;
  44305. var computationBuffer = new Int16Array(64);
  44306. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  44307. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  44308. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  44309. quantizeAndInverse(component, offset, computationBuffer);
  44310. }
  44311. }
  44312. return component.blockData;
  44313. }
  44314. function clamp0to255(a) {
  44315. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  44316. }
  44317. JpegImage.prototype = {
  44318. parse: function parse(data) {
  44319. function readUint16() {
  44320. var value = data[offset] << 8 | data[offset + 1];
  44321. offset += 2;
  44322. return value;
  44323. }
  44324. function readDataBlock() {
  44325. var length = readUint16();
  44326. var array = data.subarray(offset, offset + length - 2);
  44327. offset += array.length;
  44328. return array;
  44329. }
  44330. function prepareComponents(frame) {
  44331. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  44332. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  44333. for (var i = 0; i < frame.components.length; i++) {
  44334. component = frame.components[i];
  44335. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  44336. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  44337. var blocksPerLineForMcu = mcusPerLine * component.h;
  44338. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  44339. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  44340. component.blockData = new Int16Array(blocksBufferSize);
  44341. component.blocksPerLine = blocksPerLine;
  44342. component.blocksPerColumn = blocksPerColumn;
  44343. }
  44344. frame.mcusPerLine = mcusPerLine;
  44345. frame.mcusPerColumn = mcusPerColumn;
  44346. }
  44347. var offset = 0;
  44348. var jfif = null;
  44349. var adobe = null;
  44350. var frame, resetInterval;
  44351. var quantizationTables = [];
  44352. var huffmanTablesAC = [], huffmanTablesDC = [];
  44353. var fileMarker = readUint16();
  44354. if (fileMarker !== 0xFFD8) {
  44355. error('JPEG error: SOI not found');
  44356. }
  44357. fileMarker = readUint16();
  44358. while (fileMarker !== 0xFFD9) {
  44359. var i, j, l;
  44360. switch (fileMarker) {
  44361. case 0xFFE0:
  44362. case 0xFFE1:
  44363. case 0xFFE2:
  44364. case 0xFFE3:
  44365. case 0xFFE4:
  44366. case 0xFFE5:
  44367. case 0xFFE6:
  44368. case 0xFFE7:
  44369. case 0xFFE8:
  44370. case 0xFFE9:
  44371. case 0xFFEA:
  44372. case 0xFFEB:
  44373. case 0xFFEC:
  44374. case 0xFFED:
  44375. case 0xFFEE:
  44376. case 0xFFEF:
  44377. case 0xFFFE:
  44378. var appData = readDataBlock();
  44379. if (fileMarker === 0xFFE0) {
  44380. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  44381. jfif = {
  44382. version: {
  44383. major: appData[5],
  44384. minor: appData[6]
  44385. },
  44386. densityUnits: appData[7],
  44387. xDensity: appData[8] << 8 | appData[9],
  44388. yDensity: appData[10] << 8 | appData[11],
  44389. thumbWidth: appData[12],
  44390. thumbHeight: appData[13],
  44391. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  44392. };
  44393. }
  44394. }
  44395. if (fileMarker === 0xFFEE) {
  44396. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  44397. adobe = {
  44398. version: appData[5] << 8 | appData[6],
  44399. flags0: appData[7] << 8 | appData[8],
  44400. flags1: appData[9] << 8 | appData[10],
  44401. transformCode: appData[11]
  44402. };
  44403. }
  44404. }
  44405. break;
  44406. case 0xFFDB:
  44407. var quantizationTablesLength = readUint16();
  44408. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  44409. var z;
  44410. while (offset < quantizationTablesEnd) {
  44411. var quantizationTableSpec = data[offset++];
  44412. var tableData = new Uint16Array(64);
  44413. if (quantizationTableSpec >> 4 === 0) {
  44414. for (j = 0; j < 64; j++) {
  44415. z = dctZigZag[j];
  44416. tableData[z] = data[offset++];
  44417. }
  44418. } else if (quantizationTableSpec >> 4 === 1) {
  44419. for (j = 0; j < 64; j++) {
  44420. z = dctZigZag[j];
  44421. tableData[z] = readUint16();
  44422. }
  44423. } else {
  44424. error('JPEG error: DQT - invalid table spec');
  44425. }
  44426. quantizationTables[quantizationTableSpec & 15] = tableData;
  44427. }
  44428. break;
  44429. case 0xFFC0:
  44430. case 0xFFC1:
  44431. case 0xFFC2:
  44432. if (frame) {
  44433. error('JPEG error: Only single frame JPEGs supported');
  44434. }
  44435. readUint16();
  44436. frame = {};
  44437. frame.extended = fileMarker === 0xFFC1;
  44438. frame.progressive = fileMarker === 0xFFC2;
  44439. frame.precision = data[offset++];
  44440. frame.scanLines = readUint16();
  44441. frame.samplesPerLine = readUint16();
  44442. frame.components = [];
  44443. frame.componentIds = {};
  44444. var componentsCount = data[offset++], componentId;
  44445. var maxH = 0, maxV = 0;
  44446. for (i = 0; i < componentsCount; i++) {
  44447. componentId = data[offset];
  44448. var h = data[offset + 1] >> 4;
  44449. var v = data[offset + 1] & 15;
  44450. if (maxH < h) {
  44451. maxH = h;
  44452. }
  44453. if (maxV < v) {
  44454. maxV = v;
  44455. }
  44456. var qId = data[offset + 2];
  44457. l = frame.components.push({
  44458. h: h,
  44459. v: v,
  44460. quantizationId: qId,
  44461. quantizationTable: null
  44462. });
  44463. frame.componentIds[componentId] = l - 1;
  44464. offset += 3;
  44465. }
  44466. frame.maxH = maxH;
  44467. frame.maxV = maxV;
  44468. prepareComponents(frame);
  44469. break;
  44470. case 0xFFC4:
  44471. var huffmanLength = readUint16();
  44472. for (i = 2; i < huffmanLength;) {
  44473. var huffmanTableSpec = data[offset++];
  44474. var codeLengths = new Uint8Array(16);
  44475. var codeLengthSum = 0;
  44476. for (j = 0; j < 16; j++, offset++) {
  44477. codeLengthSum += codeLengths[j] = data[offset];
  44478. }
  44479. var huffmanValues = new Uint8Array(codeLengthSum);
  44480. for (j = 0; j < codeLengthSum; j++, offset++) {
  44481. huffmanValues[j] = data[offset];
  44482. }
  44483. i += 17 + codeLengthSum;
  44484. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  44485. }
  44486. break;
  44487. case 0xFFDD:
  44488. readUint16();
  44489. resetInterval = readUint16();
  44490. break;
  44491. case 0xFFDA:
  44492. readUint16();
  44493. var selectorsCount = data[offset++];
  44494. var components = [], component;
  44495. for (i = 0; i < selectorsCount; i++) {
  44496. var componentIndex = frame.componentIds[data[offset++]];
  44497. component = frame.components[componentIndex];
  44498. var tableSpec = data[offset++];
  44499. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  44500. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  44501. components.push(component);
  44502. }
  44503. var spectralStart = data[offset++];
  44504. var spectralEnd = data[offset++];
  44505. var successiveApproximation = data[offset++];
  44506. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  44507. offset += processed;
  44508. break;
  44509. case 0xFFFF:
  44510. if (data[offset] !== 0xFF) {
  44511. offset--;
  44512. }
  44513. break;
  44514. default:
  44515. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  44516. offset -= 3;
  44517. break;
  44518. }
  44519. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  44520. }
  44521. fileMarker = readUint16();
  44522. }
  44523. this.width = frame.samplesPerLine;
  44524. this.height = frame.scanLines;
  44525. this.jfif = jfif;
  44526. this.adobe = adobe;
  44527. this.components = [];
  44528. for (i = 0; i < frame.components.length; i++) {
  44529. component = frame.components[i];
  44530. var quantizationTable = quantizationTables[component.quantizationId];
  44531. if (quantizationTable) {
  44532. component.quantizationTable = quantizationTable;
  44533. }
  44534. this.components.push({
  44535. output: buildComponentData(frame, component),
  44536. scaleX: component.h / frame.maxH,
  44537. scaleY: component.v / frame.maxV,
  44538. blocksPerLine: component.blocksPerLine,
  44539. blocksPerColumn: component.blocksPerColumn
  44540. });
  44541. }
  44542. this.numComponents = this.components.length;
  44543. },
  44544. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  44545. var scaleX = this.width / width, scaleY = this.height / height;
  44546. var component, componentScaleX, componentScaleY, blocksPerScanline;
  44547. var x, y, i, j, k;
  44548. var index;
  44549. var offset = 0;
  44550. var output;
  44551. var numComponents = this.components.length;
  44552. var dataLength = width * height * numComponents;
  44553. var data = new Uint8Array(dataLength);
  44554. var xScaleBlockOffset = new Uint32Array(width);
  44555. var mask3LSB = 0xfffffff8;
  44556. for (i = 0; i < numComponents; i++) {
  44557. component = this.components[i];
  44558. componentScaleX = component.scaleX * scaleX;
  44559. componentScaleY = component.scaleY * scaleY;
  44560. offset = i;
  44561. output = component.output;
  44562. blocksPerScanline = component.blocksPerLine + 1 << 3;
  44563. for (x = 0; x < width; x++) {
  44564. j = 0 | x * componentScaleX;
  44565. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  44566. }
  44567. for (y = 0; y < height; y++) {
  44568. j = 0 | y * componentScaleY;
  44569. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  44570. for (x = 0; x < width; x++) {
  44571. data[offset] = output[index + xScaleBlockOffset[x]];
  44572. offset += numComponents;
  44573. }
  44574. }
  44575. }
  44576. var transform = this.decodeTransform;
  44577. if (transform) {
  44578. for (i = 0; i < dataLength;) {
  44579. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  44580. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  44581. }
  44582. }
  44583. }
  44584. return data;
  44585. },
  44586. _isColorConversionNeeded: function isColorConversionNeeded() {
  44587. if (this.adobe && this.adobe.transformCode) {
  44588. return true;
  44589. } else if (this.numComponents === 3) {
  44590. if (!this.adobe && this.colorTransform === 0) {
  44591. return false;
  44592. }
  44593. return true;
  44594. }
  44595. if (!this.adobe && this.colorTransform === 1) {
  44596. return true;
  44597. }
  44598. return false;
  44599. },
  44600. _convertYccToRgb: function convertYccToRgb(data) {
  44601. var Y, Cb, Cr;
  44602. for (var i = 0, length = data.length; i < length; i += 3) {
  44603. Y = data[i];
  44604. Cb = data[i + 1];
  44605. Cr = data[i + 2];
  44606. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  44607. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  44608. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  44609. }
  44610. return data;
  44611. },
  44612. _convertYcckToRgb: function convertYcckToRgb(data) {
  44613. var Y, Cb, Cr, k;
  44614. var offset = 0;
  44615. for (var i = 0, length = data.length; i < length; i += 4) {
  44616. Y = data[i];
  44617. Cb = data[i + 1];
  44618. Cr = data[i + 2];
  44619. k = data[i + 3];
  44620. var r = -122.67195406894 + Cb * (-6.60635669420364e-5 * Cb + 0.000437130475926232 * Cr - 5.4080610064599e-5 * Y + 0.00048449797120281 * k - 0.154362151871126) + Cr * (-0.000957964378445773 * Cr + 0.000817076911346625 * Y - 0.00477271405408747 * k + 1.53380253221734) + Y * (0.000961250184130688 * Y - 0.00266257332283933 * k + 0.48357088451265) + k * (-0.000336197177618394 * k + 0.484791561490776);
  44621. var g = 107.268039397724 + Cb * (2.19927104525741e-5 * Cb - 0.000640992018297945 * Cr + 0.000659397001245577 * Y + 0.000426105652938837 * k - 0.176491792462875) + Cr * (-0.000778269941513683 * Cr + 0.00130872261408275 * Y + 0.000770482631801132 * k - 0.151051492775562) + Y * (0.00126935368114843 * Y - 0.00265090189010898 * k + 0.25802910206845) + k * (-0.000318913117588328 * k - 0.213742400323665);
  44622. var b = -20.810012546947 + Cb * (-0.000570115196973677 * Cb - 2.63409051004589e-5 * Cr + 0.0020741088115012 * Y - 0.00288260236853442 * k + 0.814272968359295) + Cr * (-1.53496057440975e-5 * Cr - 0.000132689043961446 * Y + 0.000560833691242812 * k - 0.195152027534049) + Y * (0.00174418132927582 * Y - 0.00255243321439347 * k + 0.116935020465145) + k * (-0.000343531996510555 * k + 0.24165260232407);
  44623. data[offset++] = clamp0to255(r);
  44624. data[offset++] = clamp0to255(g);
  44625. data[offset++] = clamp0to255(b);
  44626. }
  44627. return data;
  44628. },
  44629. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  44630. var Y, Cb, Cr;
  44631. for (var i = 0, length = data.length; i < length; i += 4) {
  44632. Y = data[i];
  44633. Cb = data[i + 1];
  44634. Cr = data[i + 2];
  44635. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  44636. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  44637. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  44638. }
  44639. return data;
  44640. },
  44641. _convertCmykToRgb: function convertCmykToRgb(data) {
  44642. var c, m, y, k;
  44643. var offset = 0;
  44644. var min = -255 * 255 * 255;
  44645. var scale = 1 / 255 / 255;
  44646. for (var i = 0, length = data.length; i < length; i += 4) {
  44647. c = data[i];
  44648. m = data[i + 1];
  44649. y = data[i + 2];
  44650. k = data[i + 3];
  44651. var r = c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k - 72734.4411664936) + m * (1.7149763477362134 * m - 5.6096736904047315 * y - 17.873870861415444 * k - 1401.7366389350734) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 4465.541406466231) - k * (21.86122147463605 * k + 48317.86113160301);
  44652. var g = c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k - 20220.756542821975) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 48691.05921601825) + y * (4.444339102852739 * y + 9.8632861493405 * k - 6341.191035517494) - k * (20.737325471181034 * k + 47890.15695978492);
  44653. var b = c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k - 3616.812083916688) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 28620.90484698408) + y * (0.03296041114873217 * y + 115.60384449646641 * k - 49363.43385999684) - k * (22.33816807309886 * k + 45932.16563550634);
  44654. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  44655. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  44656. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  44657. }
  44658. return data;
  44659. },
  44660. getData: function getData(width, height, forceRGBoutput) {
  44661. if (this.numComponents > 4) {
  44662. error('JPEG error: Unsupported color mode');
  44663. }
  44664. var data = this._getLinearizedBlockData(width, height);
  44665. if (this.numComponents === 1 && forceRGBoutput) {
  44666. var dataLength = data.length;
  44667. var rgbData = new Uint8Array(dataLength * 3);
  44668. var offset = 0;
  44669. for (var i = 0; i < dataLength; i++) {
  44670. var grayColor = data[i];
  44671. rgbData[offset++] = grayColor;
  44672. rgbData[offset++] = grayColor;
  44673. rgbData[offset++] = grayColor;
  44674. }
  44675. return rgbData;
  44676. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  44677. return this._convertYccToRgb(data);
  44678. } else if (this.numComponents === 4) {
  44679. if (this._isColorConversionNeeded()) {
  44680. if (forceRGBoutput) {
  44681. return this._convertYcckToRgb(data);
  44682. }
  44683. return this._convertYcckToCmyk(data);
  44684. } else if (forceRGBoutput) {
  44685. return this._convertCmykToRgb(data);
  44686. }
  44687. }
  44688. return data;
  44689. }
  44690. };
  44691. return JpegImage;
  44692. }();
  44693. exports.JpegImage = JpegImage;
  44694. /***/ }),
  44695. /* 30 */
  44696. /***/ (function(module, exports, __w_pdfjs_require__) {
  44697. "use strict";
  44698. var sharedUtil = __w_pdfjs_require__(0);
  44699. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  44700. var getMetrics = getLookupTableFactory(function (t) {
  44701. t['Courier'] = 600;
  44702. t['Courier-Bold'] = 600;
  44703. t['Courier-BoldOblique'] = 600;
  44704. t['Courier-Oblique'] = 600;
  44705. t['Helvetica'] = getLookupTableFactory(function (t) {
  44706. t['space'] = 278;
  44707. t['exclam'] = 278;
  44708. t['quotedbl'] = 355;
  44709. t['numbersign'] = 556;
  44710. t['dollar'] = 556;
  44711. t['percent'] = 889;
  44712. t['ampersand'] = 667;
  44713. t['quoteright'] = 222;
  44714. t['parenleft'] = 333;
  44715. t['parenright'] = 333;
  44716. t['asterisk'] = 389;
  44717. t['plus'] = 584;
  44718. t['comma'] = 278;
  44719. t['hyphen'] = 333;
  44720. t['period'] = 278;
  44721. t['slash'] = 278;
  44722. t['zero'] = 556;
  44723. t['one'] = 556;
  44724. t['two'] = 556;
  44725. t['three'] = 556;
  44726. t['four'] = 556;
  44727. t['five'] = 556;
  44728. t['six'] = 556;
  44729. t['seven'] = 556;
  44730. t['eight'] = 556;
  44731. t['nine'] = 556;
  44732. t['colon'] = 278;
  44733. t['semicolon'] = 278;
  44734. t['less'] = 584;
  44735. t['equal'] = 584;
  44736. t['greater'] = 584;
  44737. t['question'] = 556;
  44738. t['at'] = 1015;
  44739. t['A'] = 667;
  44740. t['B'] = 667;
  44741. t['C'] = 722;
  44742. t['D'] = 722;
  44743. t['E'] = 667;
  44744. t['F'] = 611;
  44745. t['G'] = 778;
  44746. t['H'] = 722;
  44747. t['I'] = 278;
  44748. t['J'] = 500;
  44749. t['K'] = 667;
  44750. t['L'] = 556;
  44751. t['M'] = 833;
  44752. t['N'] = 722;
  44753. t['O'] = 778;
  44754. t['P'] = 667;
  44755. t['Q'] = 778;
  44756. t['R'] = 722;
  44757. t['S'] = 667;
  44758. t['T'] = 611;
  44759. t['U'] = 722;
  44760. t['V'] = 667;
  44761. t['W'] = 944;
  44762. t['X'] = 667;
  44763. t['Y'] = 667;
  44764. t['Z'] = 611;
  44765. t['bracketleft'] = 278;
  44766. t['backslash'] = 278;
  44767. t['bracketright'] = 278;
  44768. t['asciicircum'] = 469;
  44769. t['underscore'] = 556;
  44770. t['quoteleft'] = 222;
  44771. t['a'] = 556;
  44772. t['b'] = 556;
  44773. t['c'] = 500;
  44774. t['d'] = 556;
  44775. t['e'] = 556;
  44776. t['f'] = 278;
  44777. t['g'] = 556;
  44778. t['h'] = 556;
  44779. t['i'] = 222;
  44780. t['j'] = 222;
  44781. t['k'] = 500;
  44782. t['l'] = 222;
  44783. t['m'] = 833;
  44784. t['n'] = 556;
  44785. t['o'] = 556;
  44786. t['p'] = 556;
  44787. t['q'] = 556;
  44788. t['r'] = 333;
  44789. t['s'] = 500;
  44790. t['t'] = 278;
  44791. t['u'] = 556;
  44792. t['v'] = 500;
  44793. t['w'] = 722;
  44794. t['x'] = 500;
  44795. t['y'] = 500;
  44796. t['z'] = 500;
  44797. t['braceleft'] = 334;
  44798. t['bar'] = 260;
  44799. t['braceright'] = 334;
  44800. t['asciitilde'] = 584;
  44801. t['exclamdown'] = 333;
  44802. t['cent'] = 556;
  44803. t['sterling'] = 556;
  44804. t['fraction'] = 167;
  44805. t['yen'] = 556;
  44806. t['florin'] = 556;
  44807. t['section'] = 556;
  44808. t['currency'] = 556;
  44809. t['quotesingle'] = 191;
  44810. t['quotedblleft'] = 333;
  44811. t['guillemotleft'] = 556;
  44812. t['guilsinglleft'] = 333;
  44813. t['guilsinglright'] = 333;
  44814. t['fi'] = 500;
  44815. t['fl'] = 500;
  44816. t['endash'] = 556;
  44817. t['dagger'] = 556;
  44818. t['daggerdbl'] = 556;
  44819. t['periodcentered'] = 278;
  44820. t['paragraph'] = 537;
  44821. t['bullet'] = 350;
  44822. t['quotesinglbase'] = 222;
  44823. t['quotedblbase'] = 333;
  44824. t['quotedblright'] = 333;
  44825. t['guillemotright'] = 556;
  44826. t['ellipsis'] = 1000;
  44827. t['perthousand'] = 1000;
  44828. t['questiondown'] = 611;
  44829. t['grave'] = 333;
  44830. t['acute'] = 333;
  44831. t['circumflex'] = 333;
  44832. t['tilde'] = 333;
  44833. t['macron'] = 333;
  44834. t['breve'] = 333;
  44835. t['dotaccent'] = 333;
  44836. t['dieresis'] = 333;
  44837. t['ring'] = 333;
  44838. t['cedilla'] = 333;
  44839. t['hungarumlaut'] = 333;
  44840. t['ogonek'] = 333;
  44841. t['caron'] = 333;
  44842. t['emdash'] = 1000;
  44843. t['AE'] = 1000;
  44844. t['ordfeminine'] = 370;
  44845. t['Lslash'] = 556;
  44846. t['Oslash'] = 778;
  44847. t['OE'] = 1000;
  44848. t['ordmasculine'] = 365;
  44849. t['ae'] = 889;
  44850. t['dotlessi'] = 278;
  44851. t['lslash'] = 222;
  44852. t['oslash'] = 611;
  44853. t['oe'] = 944;
  44854. t['germandbls'] = 611;
  44855. t['Idieresis'] = 278;
  44856. t['eacute'] = 556;
  44857. t['abreve'] = 556;
  44858. t['uhungarumlaut'] = 556;
  44859. t['ecaron'] = 556;
  44860. t['Ydieresis'] = 667;
  44861. t['divide'] = 584;
  44862. t['Yacute'] = 667;
  44863. t['Acircumflex'] = 667;
  44864. t['aacute'] = 556;
  44865. t['Ucircumflex'] = 722;
  44866. t['yacute'] = 500;
  44867. t['scommaaccent'] = 500;
  44868. t['ecircumflex'] = 556;
  44869. t['Uring'] = 722;
  44870. t['Udieresis'] = 722;
  44871. t['aogonek'] = 556;
  44872. t['Uacute'] = 722;
  44873. t['uogonek'] = 556;
  44874. t['Edieresis'] = 667;
  44875. t['Dcroat'] = 722;
  44876. t['commaaccent'] = 250;
  44877. t['copyright'] = 737;
  44878. t['Emacron'] = 667;
  44879. t['ccaron'] = 500;
  44880. t['aring'] = 556;
  44881. t['Ncommaaccent'] = 722;
  44882. t['lacute'] = 222;
  44883. t['agrave'] = 556;
  44884. t['Tcommaaccent'] = 611;
  44885. t['Cacute'] = 722;
  44886. t['atilde'] = 556;
  44887. t['Edotaccent'] = 667;
  44888. t['scaron'] = 500;
  44889. t['scedilla'] = 500;
  44890. t['iacute'] = 278;
  44891. t['lozenge'] = 471;
  44892. t['Rcaron'] = 722;
  44893. t['Gcommaaccent'] = 778;
  44894. t['ucircumflex'] = 556;
  44895. t['acircumflex'] = 556;
  44896. t['Amacron'] = 667;
  44897. t['rcaron'] = 333;
  44898. t['ccedilla'] = 500;
  44899. t['Zdotaccent'] = 611;
  44900. t['Thorn'] = 667;
  44901. t['Omacron'] = 778;
  44902. t['Racute'] = 722;
  44903. t['Sacute'] = 667;
  44904. t['dcaron'] = 643;
  44905. t['Umacron'] = 722;
  44906. t['uring'] = 556;
  44907. t['threesuperior'] = 333;
  44908. t['Ograve'] = 778;
  44909. t['Agrave'] = 667;
  44910. t['Abreve'] = 667;
  44911. t['multiply'] = 584;
  44912. t['uacute'] = 556;
  44913. t['Tcaron'] = 611;
  44914. t['partialdiff'] = 476;
  44915. t['ydieresis'] = 500;
  44916. t['Nacute'] = 722;
  44917. t['icircumflex'] = 278;
  44918. t['Ecircumflex'] = 667;
  44919. t['adieresis'] = 556;
  44920. t['edieresis'] = 556;
  44921. t['cacute'] = 500;
  44922. t['nacute'] = 556;
  44923. t['umacron'] = 556;
  44924. t['Ncaron'] = 722;
  44925. t['Iacute'] = 278;
  44926. t['plusminus'] = 584;
  44927. t['brokenbar'] = 260;
  44928. t['registered'] = 737;
  44929. t['Gbreve'] = 778;
  44930. t['Idotaccent'] = 278;
  44931. t['summation'] = 600;
  44932. t['Egrave'] = 667;
  44933. t['racute'] = 333;
  44934. t['omacron'] = 556;
  44935. t['Zacute'] = 611;
  44936. t['Zcaron'] = 611;
  44937. t['greaterequal'] = 549;
  44938. t['Eth'] = 722;
  44939. t['Ccedilla'] = 722;
  44940. t['lcommaaccent'] = 222;
  44941. t['tcaron'] = 317;
  44942. t['eogonek'] = 556;
  44943. t['Uogonek'] = 722;
  44944. t['Aacute'] = 667;
  44945. t['Adieresis'] = 667;
  44946. t['egrave'] = 556;
  44947. t['zacute'] = 500;
  44948. t['iogonek'] = 222;
  44949. t['Oacute'] = 778;
  44950. t['oacute'] = 556;
  44951. t['amacron'] = 556;
  44952. t['sacute'] = 500;
  44953. t['idieresis'] = 278;
  44954. t['Ocircumflex'] = 778;
  44955. t['Ugrave'] = 722;
  44956. t['Delta'] = 612;
  44957. t['thorn'] = 556;
  44958. t['twosuperior'] = 333;
  44959. t['Odieresis'] = 778;
  44960. t['mu'] = 556;
  44961. t['igrave'] = 278;
  44962. t['ohungarumlaut'] = 556;
  44963. t['Eogonek'] = 667;
  44964. t['dcroat'] = 556;
  44965. t['threequarters'] = 834;
  44966. t['Scedilla'] = 667;
  44967. t['lcaron'] = 299;
  44968. t['Kcommaaccent'] = 667;
  44969. t['Lacute'] = 556;
  44970. t['trademark'] = 1000;
  44971. t['edotaccent'] = 556;
  44972. t['Igrave'] = 278;
  44973. t['Imacron'] = 278;
  44974. t['Lcaron'] = 556;
  44975. t['onehalf'] = 834;
  44976. t['lessequal'] = 549;
  44977. t['ocircumflex'] = 556;
  44978. t['ntilde'] = 556;
  44979. t['Uhungarumlaut'] = 722;
  44980. t['Eacute'] = 667;
  44981. t['emacron'] = 556;
  44982. t['gbreve'] = 556;
  44983. t['onequarter'] = 834;
  44984. t['Scaron'] = 667;
  44985. t['Scommaaccent'] = 667;
  44986. t['Ohungarumlaut'] = 778;
  44987. t['degree'] = 400;
  44988. t['ograve'] = 556;
  44989. t['Ccaron'] = 722;
  44990. t['ugrave'] = 556;
  44991. t['radical'] = 453;
  44992. t['Dcaron'] = 722;
  44993. t['rcommaaccent'] = 333;
  44994. t['Ntilde'] = 722;
  44995. t['otilde'] = 556;
  44996. t['Rcommaaccent'] = 722;
  44997. t['Lcommaaccent'] = 556;
  44998. t['Atilde'] = 667;
  44999. t['Aogonek'] = 667;
  45000. t['Aring'] = 667;
  45001. t['Otilde'] = 778;
  45002. t['zdotaccent'] = 500;
  45003. t['Ecaron'] = 667;
  45004. t['Iogonek'] = 278;
  45005. t['kcommaaccent'] = 500;
  45006. t['minus'] = 584;
  45007. t['Icircumflex'] = 278;
  45008. t['ncaron'] = 556;
  45009. t['tcommaaccent'] = 278;
  45010. t['logicalnot'] = 584;
  45011. t['odieresis'] = 556;
  45012. t['udieresis'] = 556;
  45013. t['notequal'] = 549;
  45014. t['gcommaaccent'] = 556;
  45015. t['eth'] = 556;
  45016. t['zcaron'] = 500;
  45017. t['ncommaaccent'] = 556;
  45018. t['onesuperior'] = 333;
  45019. t['imacron'] = 278;
  45020. t['Euro'] = 556;
  45021. });
  45022. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  45023. t['space'] = 278;
  45024. t['exclam'] = 333;
  45025. t['quotedbl'] = 474;
  45026. t['numbersign'] = 556;
  45027. t['dollar'] = 556;
  45028. t['percent'] = 889;
  45029. t['ampersand'] = 722;
  45030. t['quoteright'] = 278;
  45031. t['parenleft'] = 333;
  45032. t['parenright'] = 333;
  45033. t['asterisk'] = 389;
  45034. t['plus'] = 584;
  45035. t['comma'] = 278;
  45036. t['hyphen'] = 333;
  45037. t['period'] = 278;
  45038. t['slash'] = 278;
  45039. t['zero'] = 556;
  45040. t['one'] = 556;
  45041. t['two'] = 556;
  45042. t['three'] = 556;
  45043. t['four'] = 556;
  45044. t['five'] = 556;
  45045. t['six'] = 556;
  45046. t['seven'] = 556;
  45047. t['eight'] = 556;
  45048. t['nine'] = 556;
  45049. t['colon'] = 333;
  45050. t['semicolon'] = 333;
  45051. t['less'] = 584;
  45052. t['equal'] = 584;
  45053. t['greater'] = 584;
  45054. t['question'] = 611;
  45055. t['at'] = 975;
  45056. t['A'] = 722;
  45057. t['B'] = 722;
  45058. t['C'] = 722;
  45059. t['D'] = 722;
  45060. t['E'] = 667;
  45061. t['F'] = 611;
  45062. t['G'] = 778;
  45063. t['H'] = 722;
  45064. t['I'] = 278;
  45065. t['J'] = 556;
  45066. t['K'] = 722;
  45067. t['L'] = 611;
  45068. t['M'] = 833;
  45069. t['N'] = 722;
  45070. t['O'] = 778;
  45071. t['P'] = 667;
  45072. t['Q'] = 778;
  45073. t['R'] = 722;
  45074. t['S'] = 667;
  45075. t['T'] = 611;
  45076. t['U'] = 722;
  45077. t['V'] = 667;
  45078. t['W'] = 944;
  45079. t['X'] = 667;
  45080. t['Y'] = 667;
  45081. t['Z'] = 611;
  45082. t['bracketleft'] = 333;
  45083. t['backslash'] = 278;
  45084. t['bracketright'] = 333;
  45085. t['asciicircum'] = 584;
  45086. t['underscore'] = 556;
  45087. t['quoteleft'] = 278;
  45088. t['a'] = 556;
  45089. t['b'] = 611;
  45090. t['c'] = 556;
  45091. t['d'] = 611;
  45092. t['e'] = 556;
  45093. t['f'] = 333;
  45094. t['g'] = 611;
  45095. t['h'] = 611;
  45096. t['i'] = 278;
  45097. t['j'] = 278;
  45098. t['k'] = 556;
  45099. t['l'] = 278;
  45100. t['m'] = 889;
  45101. t['n'] = 611;
  45102. t['o'] = 611;
  45103. t['p'] = 611;
  45104. t['q'] = 611;
  45105. t['r'] = 389;
  45106. t['s'] = 556;
  45107. t['t'] = 333;
  45108. t['u'] = 611;
  45109. t['v'] = 556;
  45110. t['w'] = 778;
  45111. t['x'] = 556;
  45112. t['y'] = 556;
  45113. t['z'] = 500;
  45114. t['braceleft'] = 389;
  45115. t['bar'] = 280;
  45116. t['braceright'] = 389;
  45117. t['asciitilde'] = 584;
  45118. t['exclamdown'] = 333;
  45119. t['cent'] = 556;
  45120. t['sterling'] = 556;
  45121. t['fraction'] = 167;
  45122. t['yen'] = 556;
  45123. t['florin'] = 556;
  45124. t['section'] = 556;
  45125. t['currency'] = 556;
  45126. t['quotesingle'] = 238;
  45127. t['quotedblleft'] = 500;
  45128. t['guillemotleft'] = 556;
  45129. t['guilsinglleft'] = 333;
  45130. t['guilsinglright'] = 333;
  45131. t['fi'] = 611;
  45132. t['fl'] = 611;
  45133. t['endash'] = 556;
  45134. t['dagger'] = 556;
  45135. t['daggerdbl'] = 556;
  45136. t['periodcentered'] = 278;
  45137. t['paragraph'] = 556;
  45138. t['bullet'] = 350;
  45139. t['quotesinglbase'] = 278;
  45140. t['quotedblbase'] = 500;
  45141. t['quotedblright'] = 500;
  45142. t['guillemotright'] = 556;
  45143. t['ellipsis'] = 1000;
  45144. t['perthousand'] = 1000;
  45145. t['questiondown'] = 611;
  45146. t['grave'] = 333;
  45147. t['acute'] = 333;
  45148. t['circumflex'] = 333;
  45149. t['tilde'] = 333;
  45150. t['macron'] = 333;
  45151. t['breve'] = 333;
  45152. t['dotaccent'] = 333;
  45153. t['dieresis'] = 333;
  45154. t['ring'] = 333;
  45155. t['cedilla'] = 333;
  45156. t['hungarumlaut'] = 333;
  45157. t['ogonek'] = 333;
  45158. t['caron'] = 333;
  45159. t['emdash'] = 1000;
  45160. t['AE'] = 1000;
  45161. t['ordfeminine'] = 370;
  45162. t['Lslash'] = 611;
  45163. t['Oslash'] = 778;
  45164. t['OE'] = 1000;
  45165. t['ordmasculine'] = 365;
  45166. t['ae'] = 889;
  45167. t['dotlessi'] = 278;
  45168. t['lslash'] = 278;
  45169. t['oslash'] = 611;
  45170. t['oe'] = 944;
  45171. t['germandbls'] = 611;
  45172. t['Idieresis'] = 278;
  45173. t['eacute'] = 556;
  45174. t['abreve'] = 556;
  45175. t['uhungarumlaut'] = 611;
  45176. t['ecaron'] = 556;
  45177. t['Ydieresis'] = 667;
  45178. t['divide'] = 584;
  45179. t['Yacute'] = 667;
  45180. t['Acircumflex'] = 722;
  45181. t['aacute'] = 556;
  45182. t['Ucircumflex'] = 722;
  45183. t['yacute'] = 556;
  45184. t['scommaaccent'] = 556;
  45185. t['ecircumflex'] = 556;
  45186. t['Uring'] = 722;
  45187. t['Udieresis'] = 722;
  45188. t['aogonek'] = 556;
  45189. t['Uacute'] = 722;
  45190. t['uogonek'] = 611;
  45191. t['Edieresis'] = 667;
  45192. t['Dcroat'] = 722;
  45193. t['commaaccent'] = 250;
  45194. t['copyright'] = 737;
  45195. t['Emacron'] = 667;
  45196. t['ccaron'] = 556;
  45197. t['aring'] = 556;
  45198. t['Ncommaaccent'] = 722;
  45199. t['lacute'] = 278;
  45200. t['agrave'] = 556;
  45201. t['Tcommaaccent'] = 611;
  45202. t['Cacute'] = 722;
  45203. t['atilde'] = 556;
  45204. t['Edotaccent'] = 667;
  45205. t['scaron'] = 556;
  45206. t['scedilla'] = 556;
  45207. t['iacute'] = 278;
  45208. t['lozenge'] = 494;
  45209. t['Rcaron'] = 722;
  45210. t['Gcommaaccent'] = 778;
  45211. t['ucircumflex'] = 611;
  45212. t['acircumflex'] = 556;
  45213. t['Amacron'] = 722;
  45214. t['rcaron'] = 389;
  45215. t['ccedilla'] = 556;
  45216. t['Zdotaccent'] = 611;
  45217. t['Thorn'] = 667;
  45218. t['Omacron'] = 778;
  45219. t['Racute'] = 722;
  45220. t['Sacute'] = 667;
  45221. t['dcaron'] = 743;
  45222. t['Umacron'] = 722;
  45223. t['uring'] = 611;
  45224. t['threesuperior'] = 333;
  45225. t['Ograve'] = 778;
  45226. t['Agrave'] = 722;
  45227. t['Abreve'] = 722;
  45228. t['multiply'] = 584;
  45229. t['uacute'] = 611;
  45230. t['Tcaron'] = 611;
  45231. t['partialdiff'] = 494;
  45232. t['ydieresis'] = 556;
  45233. t['Nacute'] = 722;
  45234. t['icircumflex'] = 278;
  45235. t['Ecircumflex'] = 667;
  45236. t['adieresis'] = 556;
  45237. t['edieresis'] = 556;
  45238. t['cacute'] = 556;
  45239. t['nacute'] = 611;
  45240. t['umacron'] = 611;
  45241. t['Ncaron'] = 722;
  45242. t['Iacute'] = 278;
  45243. t['plusminus'] = 584;
  45244. t['brokenbar'] = 280;
  45245. t['registered'] = 737;
  45246. t['Gbreve'] = 778;
  45247. t['Idotaccent'] = 278;
  45248. t['summation'] = 600;
  45249. t['Egrave'] = 667;
  45250. t['racute'] = 389;
  45251. t['omacron'] = 611;
  45252. t['Zacute'] = 611;
  45253. t['Zcaron'] = 611;
  45254. t['greaterequal'] = 549;
  45255. t['Eth'] = 722;
  45256. t['Ccedilla'] = 722;
  45257. t['lcommaaccent'] = 278;
  45258. t['tcaron'] = 389;
  45259. t['eogonek'] = 556;
  45260. t['Uogonek'] = 722;
  45261. t['Aacute'] = 722;
  45262. t['Adieresis'] = 722;
  45263. t['egrave'] = 556;
  45264. t['zacute'] = 500;
  45265. t['iogonek'] = 278;
  45266. t['Oacute'] = 778;
  45267. t['oacute'] = 611;
  45268. t['amacron'] = 556;
  45269. t['sacute'] = 556;
  45270. t['idieresis'] = 278;
  45271. t['Ocircumflex'] = 778;
  45272. t['Ugrave'] = 722;
  45273. t['Delta'] = 612;
  45274. t['thorn'] = 611;
  45275. t['twosuperior'] = 333;
  45276. t['Odieresis'] = 778;
  45277. t['mu'] = 611;
  45278. t['igrave'] = 278;
  45279. t['ohungarumlaut'] = 611;
  45280. t['Eogonek'] = 667;
  45281. t['dcroat'] = 611;
  45282. t['threequarters'] = 834;
  45283. t['Scedilla'] = 667;
  45284. t['lcaron'] = 400;
  45285. t['Kcommaaccent'] = 722;
  45286. t['Lacute'] = 611;
  45287. t['trademark'] = 1000;
  45288. t['edotaccent'] = 556;
  45289. t['Igrave'] = 278;
  45290. t['Imacron'] = 278;
  45291. t['Lcaron'] = 611;
  45292. t['onehalf'] = 834;
  45293. t['lessequal'] = 549;
  45294. t['ocircumflex'] = 611;
  45295. t['ntilde'] = 611;
  45296. t['Uhungarumlaut'] = 722;
  45297. t['Eacute'] = 667;
  45298. t['emacron'] = 556;
  45299. t['gbreve'] = 611;
  45300. t['onequarter'] = 834;
  45301. t['Scaron'] = 667;
  45302. t['Scommaaccent'] = 667;
  45303. t['Ohungarumlaut'] = 778;
  45304. t['degree'] = 400;
  45305. t['ograve'] = 611;
  45306. t['Ccaron'] = 722;
  45307. t['ugrave'] = 611;
  45308. t['radical'] = 549;
  45309. t['Dcaron'] = 722;
  45310. t['rcommaaccent'] = 389;
  45311. t['Ntilde'] = 722;
  45312. t['otilde'] = 611;
  45313. t['Rcommaaccent'] = 722;
  45314. t['Lcommaaccent'] = 611;
  45315. t['Atilde'] = 722;
  45316. t['Aogonek'] = 722;
  45317. t['Aring'] = 722;
  45318. t['Otilde'] = 778;
  45319. t['zdotaccent'] = 500;
  45320. t['Ecaron'] = 667;
  45321. t['Iogonek'] = 278;
  45322. t['kcommaaccent'] = 556;
  45323. t['minus'] = 584;
  45324. t['Icircumflex'] = 278;
  45325. t['ncaron'] = 611;
  45326. t['tcommaaccent'] = 333;
  45327. t['logicalnot'] = 584;
  45328. t['odieresis'] = 611;
  45329. t['udieresis'] = 611;
  45330. t['notequal'] = 549;
  45331. t['gcommaaccent'] = 611;
  45332. t['eth'] = 611;
  45333. t['zcaron'] = 500;
  45334. t['ncommaaccent'] = 611;
  45335. t['onesuperior'] = 333;
  45336. t['imacron'] = 278;
  45337. t['Euro'] = 556;
  45338. });
  45339. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  45340. t['space'] = 278;
  45341. t['exclam'] = 333;
  45342. t['quotedbl'] = 474;
  45343. t['numbersign'] = 556;
  45344. t['dollar'] = 556;
  45345. t['percent'] = 889;
  45346. t['ampersand'] = 722;
  45347. t['quoteright'] = 278;
  45348. t['parenleft'] = 333;
  45349. t['parenright'] = 333;
  45350. t['asterisk'] = 389;
  45351. t['plus'] = 584;
  45352. t['comma'] = 278;
  45353. t['hyphen'] = 333;
  45354. t['period'] = 278;
  45355. t['slash'] = 278;
  45356. t['zero'] = 556;
  45357. t['one'] = 556;
  45358. t['two'] = 556;
  45359. t['three'] = 556;
  45360. t['four'] = 556;
  45361. t['five'] = 556;
  45362. t['six'] = 556;
  45363. t['seven'] = 556;
  45364. t['eight'] = 556;
  45365. t['nine'] = 556;
  45366. t['colon'] = 333;
  45367. t['semicolon'] = 333;
  45368. t['less'] = 584;
  45369. t['equal'] = 584;
  45370. t['greater'] = 584;
  45371. t['question'] = 611;
  45372. t['at'] = 975;
  45373. t['A'] = 722;
  45374. t['B'] = 722;
  45375. t['C'] = 722;
  45376. t['D'] = 722;
  45377. t['E'] = 667;
  45378. t['F'] = 611;
  45379. t['G'] = 778;
  45380. t['H'] = 722;
  45381. t['I'] = 278;
  45382. t['J'] = 556;
  45383. t['K'] = 722;
  45384. t['L'] = 611;
  45385. t['M'] = 833;
  45386. t['N'] = 722;
  45387. t['O'] = 778;
  45388. t['P'] = 667;
  45389. t['Q'] = 778;
  45390. t['R'] = 722;
  45391. t['S'] = 667;
  45392. t['T'] = 611;
  45393. t['U'] = 722;
  45394. t['V'] = 667;
  45395. t['W'] = 944;
  45396. t['X'] = 667;
  45397. t['Y'] = 667;
  45398. t['Z'] = 611;
  45399. t['bracketleft'] = 333;
  45400. t['backslash'] = 278;
  45401. t['bracketright'] = 333;
  45402. t['asciicircum'] = 584;
  45403. t['underscore'] = 556;
  45404. t['quoteleft'] = 278;
  45405. t['a'] = 556;
  45406. t['b'] = 611;
  45407. t['c'] = 556;
  45408. t['d'] = 611;
  45409. t['e'] = 556;
  45410. t['f'] = 333;
  45411. t['g'] = 611;
  45412. t['h'] = 611;
  45413. t['i'] = 278;
  45414. t['j'] = 278;
  45415. t['k'] = 556;
  45416. t['l'] = 278;
  45417. t['m'] = 889;
  45418. t['n'] = 611;
  45419. t['o'] = 611;
  45420. t['p'] = 611;
  45421. t['q'] = 611;
  45422. t['r'] = 389;
  45423. t['s'] = 556;
  45424. t['t'] = 333;
  45425. t['u'] = 611;
  45426. t['v'] = 556;
  45427. t['w'] = 778;
  45428. t['x'] = 556;
  45429. t['y'] = 556;
  45430. t['z'] = 500;
  45431. t['braceleft'] = 389;
  45432. t['bar'] = 280;
  45433. t['braceright'] = 389;
  45434. t['asciitilde'] = 584;
  45435. t['exclamdown'] = 333;
  45436. t['cent'] = 556;
  45437. t['sterling'] = 556;
  45438. t['fraction'] = 167;
  45439. t['yen'] = 556;
  45440. t['florin'] = 556;
  45441. t['section'] = 556;
  45442. t['currency'] = 556;
  45443. t['quotesingle'] = 238;
  45444. t['quotedblleft'] = 500;
  45445. t['guillemotleft'] = 556;
  45446. t['guilsinglleft'] = 333;
  45447. t['guilsinglright'] = 333;
  45448. t['fi'] = 611;
  45449. t['fl'] = 611;
  45450. t['endash'] = 556;
  45451. t['dagger'] = 556;
  45452. t['daggerdbl'] = 556;
  45453. t['periodcentered'] = 278;
  45454. t['paragraph'] = 556;
  45455. t['bullet'] = 350;
  45456. t['quotesinglbase'] = 278;
  45457. t['quotedblbase'] = 500;
  45458. t['quotedblright'] = 500;
  45459. t['guillemotright'] = 556;
  45460. t['ellipsis'] = 1000;
  45461. t['perthousand'] = 1000;
  45462. t['questiondown'] = 611;
  45463. t['grave'] = 333;
  45464. t['acute'] = 333;
  45465. t['circumflex'] = 333;
  45466. t['tilde'] = 333;
  45467. t['macron'] = 333;
  45468. t['breve'] = 333;
  45469. t['dotaccent'] = 333;
  45470. t['dieresis'] = 333;
  45471. t['ring'] = 333;
  45472. t['cedilla'] = 333;
  45473. t['hungarumlaut'] = 333;
  45474. t['ogonek'] = 333;
  45475. t['caron'] = 333;
  45476. t['emdash'] = 1000;
  45477. t['AE'] = 1000;
  45478. t['ordfeminine'] = 370;
  45479. t['Lslash'] = 611;
  45480. t['Oslash'] = 778;
  45481. t['OE'] = 1000;
  45482. t['ordmasculine'] = 365;
  45483. t['ae'] = 889;
  45484. t['dotlessi'] = 278;
  45485. t['lslash'] = 278;
  45486. t['oslash'] = 611;
  45487. t['oe'] = 944;
  45488. t['germandbls'] = 611;
  45489. t['Idieresis'] = 278;
  45490. t['eacute'] = 556;
  45491. t['abreve'] = 556;
  45492. t['uhungarumlaut'] = 611;
  45493. t['ecaron'] = 556;
  45494. t['Ydieresis'] = 667;
  45495. t['divide'] = 584;
  45496. t['Yacute'] = 667;
  45497. t['Acircumflex'] = 722;
  45498. t['aacute'] = 556;
  45499. t['Ucircumflex'] = 722;
  45500. t['yacute'] = 556;
  45501. t['scommaaccent'] = 556;
  45502. t['ecircumflex'] = 556;
  45503. t['Uring'] = 722;
  45504. t['Udieresis'] = 722;
  45505. t['aogonek'] = 556;
  45506. t['Uacute'] = 722;
  45507. t['uogonek'] = 611;
  45508. t['Edieresis'] = 667;
  45509. t['Dcroat'] = 722;
  45510. t['commaaccent'] = 250;
  45511. t['copyright'] = 737;
  45512. t['Emacron'] = 667;
  45513. t['ccaron'] = 556;
  45514. t['aring'] = 556;
  45515. t['Ncommaaccent'] = 722;
  45516. t['lacute'] = 278;
  45517. t['agrave'] = 556;
  45518. t['Tcommaaccent'] = 611;
  45519. t['Cacute'] = 722;
  45520. t['atilde'] = 556;
  45521. t['Edotaccent'] = 667;
  45522. t['scaron'] = 556;
  45523. t['scedilla'] = 556;
  45524. t['iacute'] = 278;
  45525. t['lozenge'] = 494;
  45526. t['Rcaron'] = 722;
  45527. t['Gcommaaccent'] = 778;
  45528. t['ucircumflex'] = 611;
  45529. t['acircumflex'] = 556;
  45530. t['Amacron'] = 722;
  45531. t['rcaron'] = 389;
  45532. t['ccedilla'] = 556;
  45533. t['Zdotaccent'] = 611;
  45534. t['Thorn'] = 667;
  45535. t['Omacron'] = 778;
  45536. t['Racute'] = 722;
  45537. t['Sacute'] = 667;
  45538. t['dcaron'] = 743;
  45539. t['Umacron'] = 722;
  45540. t['uring'] = 611;
  45541. t['threesuperior'] = 333;
  45542. t['Ograve'] = 778;
  45543. t['Agrave'] = 722;
  45544. t['Abreve'] = 722;
  45545. t['multiply'] = 584;
  45546. t['uacute'] = 611;
  45547. t['Tcaron'] = 611;
  45548. t['partialdiff'] = 494;
  45549. t['ydieresis'] = 556;
  45550. t['Nacute'] = 722;
  45551. t['icircumflex'] = 278;
  45552. t['Ecircumflex'] = 667;
  45553. t['adieresis'] = 556;
  45554. t['edieresis'] = 556;
  45555. t['cacute'] = 556;
  45556. t['nacute'] = 611;
  45557. t['umacron'] = 611;
  45558. t['Ncaron'] = 722;
  45559. t['Iacute'] = 278;
  45560. t['plusminus'] = 584;
  45561. t['brokenbar'] = 280;
  45562. t['registered'] = 737;
  45563. t['Gbreve'] = 778;
  45564. t['Idotaccent'] = 278;
  45565. t['summation'] = 600;
  45566. t['Egrave'] = 667;
  45567. t['racute'] = 389;
  45568. t['omacron'] = 611;
  45569. t['Zacute'] = 611;
  45570. t['Zcaron'] = 611;
  45571. t['greaterequal'] = 549;
  45572. t['Eth'] = 722;
  45573. t['Ccedilla'] = 722;
  45574. t['lcommaaccent'] = 278;
  45575. t['tcaron'] = 389;
  45576. t['eogonek'] = 556;
  45577. t['Uogonek'] = 722;
  45578. t['Aacute'] = 722;
  45579. t['Adieresis'] = 722;
  45580. t['egrave'] = 556;
  45581. t['zacute'] = 500;
  45582. t['iogonek'] = 278;
  45583. t['Oacute'] = 778;
  45584. t['oacute'] = 611;
  45585. t['amacron'] = 556;
  45586. t['sacute'] = 556;
  45587. t['idieresis'] = 278;
  45588. t['Ocircumflex'] = 778;
  45589. t['Ugrave'] = 722;
  45590. t['Delta'] = 612;
  45591. t['thorn'] = 611;
  45592. t['twosuperior'] = 333;
  45593. t['Odieresis'] = 778;
  45594. t['mu'] = 611;
  45595. t['igrave'] = 278;
  45596. t['ohungarumlaut'] = 611;
  45597. t['Eogonek'] = 667;
  45598. t['dcroat'] = 611;
  45599. t['threequarters'] = 834;
  45600. t['Scedilla'] = 667;
  45601. t['lcaron'] = 400;
  45602. t['Kcommaaccent'] = 722;
  45603. t['Lacute'] = 611;
  45604. t['trademark'] = 1000;
  45605. t['edotaccent'] = 556;
  45606. t['Igrave'] = 278;
  45607. t['Imacron'] = 278;
  45608. t['Lcaron'] = 611;
  45609. t['onehalf'] = 834;
  45610. t['lessequal'] = 549;
  45611. t['ocircumflex'] = 611;
  45612. t['ntilde'] = 611;
  45613. t['Uhungarumlaut'] = 722;
  45614. t['Eacute'] = 667;
  45615. t['emacron'] = 556;
  45616. t['gbreve'] = 611;
  45617. t['onequarter'] = 834;
  45618. t['Scaron'] = 667;
  45619. t['Scommaaccent'] = 667;
  45620. t['Ohungarumlaut'] = 778;
  45621. t['degree'] = 400;
  45622. t['ograve'] = 611;
  45623. t['Ccaron'] = 722;
  45624. t['ugrave'] = 611;
  45625. t['radical'] = 549;
  45626. t['Dcaron'] = 722;
  45627. t['rcommaaccent'] = 389;
  45628. t['Ntilde'] = 722;
  45629. t['otilde'] = 611;
  45630. t['Rcommaaccent'] = 722;
  45631. t['Lcommaaccent'] = 611;
  45632. t['Atilde'] = 722;
  45633. t['Aogonek'] = 722;
  45634. t['Aring'] = 722;
  45635. t['Otilde'] = 778;
  45636. t['zdotaccent'] = 500;
  45637. t['Ecaron'] = 667;
  45638. t['Iogonek'] = 278;
  45639. t['kcommaaccent'] = 556;
  45640. t['minus'] = 584;
  45641. t['Icircumflex'] = 278;
  45642. t['ncaron'] = 611;
  45643. t['tcommaaccent'] = 333;
  45644. t['logicalnot'] = 584;
  45645. t['odieresis'] = 611;
  45646. t['udieresis'] = 611;
  45647. t['notequal'] = 549;
  45648. t['gcommaaccent'] = 611;
  45649. t['eth'] = 611;
  45650. t['zcaron'] = 500;
  45651. t['ncommaaccent'] = 611;
  45652. t['onesuperior'] = 333;
  45653. t['imacron'] = 278;
  45654. t['Euro'] = 556;
  45655. });
  45656. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  45657. t['space'] = 278;
  45658. t['exclam'] = 278;
  45659. t['quotedbl'] = 355;
  45660. t['numbersign'] = 556;
  45661. t['dollar'] = 556;
  45662. t['percent'] = 889;
  45663. t['ampersand'] = 667;
  45664. t['quoteright'] = 222;
  45665. t['parenleft'] = 333;
  45666. t['parenright'] = 333;
  45667. t['asterisk'] = 389;
  45668. t['plus'] = 584;
  45669. t['comma'] = 278;
  45670. t['hyphen'] = 333;
  45671. t['period'] = 278;
  45672. t['slash'] = 278;
  45673. t['zero'] = 556;
  45674. t['one'] = 556;
  45675. t['two'] = 556;
  45676. t['three'] = 556;
  45677. t['four'] = 556;
  45678. t['five'] = 556;
  45679. t['six'] = 556;
  45680. t['seven'] = 556;
  45681. t['eight'] = 556;
  45682. t['nine'] = 556;
  45683. t['colon'] = 278;
  45684. t['semicolon'] = 278;
  45685. t['less'] = 584;
  45686. t['equal'] = 584;
  45687. t['greater'] = 584;
  45688. t['question'] = 556;
  45689. t['at'] = 1015;
  45690. t['A'] = 667;
  45691. t['B'] = 667;
  45692. t['C'] = 722;
  45693. t['D'] = 722;
  45694. t['E'] = 667;
  45695. t['F'] = 611;
  45696. t['G'] = 778;
  45697. t['H'] = 722;
  45698. t['I'] = 278;
  45699. t['J'] = 500;
  45700. t['K'] = 667;
  45701. t['L'] = 556;
  45702. t['M'] = 833;
  45703. t['N'] = 722;
  45704. t['O'] = 778;
  45705. t['P'] = 667;
  45706. t['Q'] = 778;
  45707. t['R'] = 722;
  45708. t['S'] = 667;
  45709. t['T'] = 611;
  45710. t['U'] = 722;
  45711. t['V'] = 667;
  45712. t['W'] = 944;
  45713. t['X'] = 667;
  45714. t['Y'] = 667;
  45715. t['Z'] = 611;
  45716. t['bracketleft'] = 278;
  45717. t['backslash'] = 278;
  45718. t['bracketright'] = 278;
  45719. t['asciicircum'] = 469;
  45720. t['underscore'] = 556;
  45721. t['quoteleft'] = 222;
  45722. t['a'] = 556;
  45723. t['b'] = 556;
  45724. t['c'] = 500;
  45725. t['d'] = 556;
  45726. t['e'] = 556;
  45727. t['f'] = 278;
  45728. t['g'] = 556;
  45729. t['h'] = 556;
  45730. t['i'] = 222;
  45731. t['j'] = 222;
  45732. t['k'] = 500;
  45733. t['l'] = 222;
  45734. t['m'] = 833;
  45735. t['n'] = 556;
  45736. t['o'] = 556;
  45737. t['p'] = 556;
  45738. t['q'] = 556;
  45739. t['r'] = 333;
  45740. t['s'] = 500;
  45741. t['t'] = 278;
  45742. t['u'] = 556;
  45743. t['v'] = 500;
  45744. t['w'] = 722;
  45745. t['x'] = 500;
  45746. t['y'] = 500;
  45747. t['z'] = 500;
  45748. t['braceleft'] = 334;
  45749. t['bar'] = 260;
  45750. t['braceright'] = 334;
  45751. t['asciitilde'] = 584;
  45752. t['exclamdown'] = 333;
  45753. t['cent'] = 556;
  45754. t['sterling'] = 556;
  45755. t['fraction'] = 167;
  45756. t['yen'] = 556;
  45757. t['florin'] = 556;
  45758. t['section'] = 556;
  45759. t['currency'] = 556;
  45760. t['quotesingle'] = 191;
  45761. t['quotedblleft'] = 333;
  45762. t['guillemotleft'] = 556;
  45763. t['guilsinglleft'] = 333;
  45764. t['guilsinglright'] = 333;
  45765. t['fi'] = 500;
  45766. t['fl'] = 500;
  45767. t['endash'] = 556;
  45768. t['dagger'] = 556;
  45769. t['daggerdbl'] = 556;
  45770. t['periodcentered'] = 278;
  45771. t['paragraph'] = 537;
  45772. t['bullet'] = 350;
  45773. t['quotesinglbase'] = 222;
  45774. t['quotedblbase'] = 333;
  45775. t['quotedblright'] = 333;
  45776. t['guillemotright'] = 556;
  45777. t['ellipsis'] = 1000;
  45778. t['perthousand'] = 1000;
  45779. t['questiondown'] = 611;
  45780. t['grave'] = 333;
  45781. t['acute'] = 333;
  45782. t['circumflex'] = 333;
  45783. t['tilde'] = 333;
  45784. t['macron'] = 333;
  45785. t['breve'] = 333;
  45786. t['dotaccent'] = 333;
  45787. t['dieresis'] = 333;
  45788. t['ring'] = 333;
  45789. t['cedilla'] = 333;
  45790. t['hungarumlaut'] = 333;
  45791. t['ogonek'] = 333;
  45792. t['caron'] = 333;
  45793. t['emdash'] = 1000;
  45794. t['AE'] = 1000;
  45795. t['ordfeminine'] = 370;
  45796. t['Lslash'] = 556;
  45797. t['Oslash'] = 778;
  45798. t['OE'] = 1000;
  45799. t['ordmasculine'] = 365;
  45800. t['ae'] = 889;
  45801. t['dotlessi'] = 278;
  45802. t['lslash'] = 222;
  45803. t['oslash'] = 611;
  45804. t['oe'] = 944;
  45805. t['germandbls'] = 611;
  45806. t['Idieresis'] = 278;
  45807. t['eacute'] = 556;
  45808. t['abreve'] = 556;
  45809. t['uhungarumlaut'] = 556;
  45810. t['ecaron'] = 556;
  45811. t['Ydieresis'] = 667;
  45812. t['divide'] = 584;
  45813. t['Yacute'] = 667;
  45814. t['Acircumflex'] = 667;
  45815. t['aacute'] = 556;
  45816. t['Ucircumflex'] = 722;
  45817. t['yacute'] = 500;
  45818. t['scommaaccent'] = 500;
  45819. t['ecircumflex'] = 556;
  45820. t['Uring'] = 722;
  45821. t['Udieresis'] = 722;
  45822. t['aogonek'] = 556;
  45823. t['Uacute'] = 722;
  45824. t['uogonek'] = 556;
  45825. t['Edieresis'] = 667;
  45826. t['Dcroat'] = 722;
  45827. t['commaaccent'] = 250;
  45828. t['copyright'] = 737;
  45829. t['Emacron'] = 667;
  45830. t['ccaron'] = 500;
  45831. t['aring'] = 556;
  45832. t['Ncommaaccent'] = 722;
  45833. t['lacute'] = 222;
  45834. t['agrave'] = 556;
  45835. t['Tcommaaccent'] = 611;
  45836. t['Cacute'] = 722;
  45837. t['atilde'] = 556;
  45838. t['Edotaccent'] = 667;
  45839. t['scaron'] = 500;
  45840. t['scedilla'] = 500;
  45841. t['iacute'] = 278;
  45842. t['lozenge'] = 471;
  45843. t['Rcaron'] = 722;
  45844. t['Gcommaaccent'] = 778;
  45845. t['ucircumflex'] = 556;
  45846. t['acircumflex'] = 556;
  45847. t['Amacron'] = 667;
  45848. t['rcaron'] = 333;
  45849. t['ccedilla'] = 500;
  45850. t['Zdotaccent'] = 611;
  45851. t['Thorn'] = 667;
  45852. t['Omacron'] = 778;
  45853. t['Racute'] = 722;
  45854. t['Sacute'] = 667;
  45855. t['dcaron'] = 643;
  45856. t['Umacron'] = 722;
  45857. t['uring'] = 556;
  45858. t['threesuperior'] = 333;
  45859. t['Ograve'] = 778;
  45860. t['Agrave'] = 667;
  45861. t['Abreve'] = 667;
  45862. t['multiply'] = 584;
  45863. t['uacute'] = 556;
  45864. t['Tcaron'] = 611;
  45865. t['partialdiff'] = 476;
  45866. t['ydieresis'] = 500;
  45867. t['Nacute'] = 722;
  45868. t['icircumflex'] = 278;
  45869. t['Ecircumflex'] = 667;
  45870. t['adieresis'] = 556;
  45871. t['edieresis'] = 556;
  45872. t['cacute'] = 500;
  45873. t['nacute'] = 556;
  45874. t['umacron'] = 556;
  45875. t['Ncaron'] = 722;
  45876. t['Iacute'] = 278;
  45877. t['plusminus'] = 584;
  45878. t['brokenbar'] = 260;
  45879. t['registered'] = 737;
  45880. t['Gbreve'] = 778;
  45881. t['Idotaccent'] = 278;
  45882. t['summation'] = 600;
  45883. t['Egrave'] = 667;
  45884. t['racute'] = 333;
  45885. t['omacron'] = 556;
  45886. t['Zacute'] = 611;
  45887. t['Zcaron'] = 611;
  45888. t['greaterequal'] = 549;
  45889. t['Eth'] = 722;
  45890. t['Ccedilla'] = 722;
  45891. t['lcommaaccent'] = 222;
  45892. t['tcaron'] = 317;
  45893. t['eogonek'] = 556;
  45894. t['Uogonek'] = 722;
  45895. t['Aacute'] = 667;
  45896. t['Adieresis'] = 667;
  45897. t['egrave'] = 556;
  45898. t['zacute'] = 500;
  45899. t['iogonek'] = 222;
  45900. t['Oacute'] = 778;
  45901. t['oacute'] = 556;
  45902. t['amacron'] = 556;
  45903. t['sacute'] = 500;
  45904. t['idieresis'] = 278;
  45905. t['Ocircumflex'] = 778;
  45906. t['Ugrave'] = 722;
  45907. t['Delta'] = 612;
  45908. t['thorn'] = 556;
  45909. t['twosuperior'] = 333;
  45910. t['Odieresis'] = 778;
  45911. t['mu'] = 556;
  45912. t['igrave'] = 278;
  45913. t['ohungarumlaut'] = 556;
  45914. t['Eogonek'] = 667;
  45915. t['dcroat'] = 556;
  45916. t['threequarters'] = 834;
  45917. t['Scedilla'] = 667;
  45918. t['lcaron'] = 299;
  45919. t['Kcommaaccent'] = 667;
  45920. t['Lacute'] = 556;
  45921. t['trademark'] = 1000;
  45922. t['edotaccent'] = 556;
  45923. t['Igrave'] = 278;
  45924. t['Imacron'] = 278;
  45925. t['Lcaron'] = 556;
  45926. t['onehalf'] = 834;
  45927. t['lessequal'] = 549;
  45928. t['ocircumflex'] = 556;
  45929. t['ntilde'] = 556;
  45930. t['Uhungarumlaut'] = 722;
  45931. t['Eacute'] = 667;
  45932. t['emacron'] = 556;
  45933. t['gbreve'] = 556;
  45934. t['onequarter'] = 834;
  45935. t['Scaron'] = 667;
  45936. t['Scommaaccent'] = 667;
  45937. t['Ohungarumlaut'] = 778;
  45938. t['degree'] = 400;
  45939. t['ograve'] = 556;
  45940. t['Ccaron'] = 722;
  45941. t['ugrave'] = 556;
  45942. t['radical'] = 453;
  45943. t['Dcaron'] = 722;
  45944. t['rcommaaccent'] = 333;
  45945. t['Ntilde'] = 722;
  45946. t['otilde'] = 556;
  45947. t['Rcommaaccent'] = 722;
  45948. t['Lcommaaccent'] = 556;
  45949. t['Atilde'] = 667;
  45950. t['Aogonek'] = 667;
  45951. t['Aring'] = 667;
  45952. t['Otilde'] = 778;
  45953. t['zdotaccent'] = 500;
  45954. t['Ecaron'] = 667;
  45955. t['Iogonek'] = 278;
  45956. t['kcommaaccent'] = 500;
  45957. t['minus'] = 584;
  45958. t['Icircumflex'] = 278;
  45959. t['ncaron'] = 556;
  45960. t['tcommaaccent'] = 278;
  45961. t['logicalnot'] = 584;
  45962. t['odieresis'] = 556;
  45963. t['udieresis'] = 556;
  45964. t['notequal'] = 549;
  45965. t['gcommaaccent'] = 556;
  45966. t['eth'] = 556;
  45967. t['zcaron'] = 500;
  45968. t['ncommaaccent'] = 556;
  45969. t['onesuperior'] = 333;
  45970. t['imacron'] = 278;
  45971. t['Euro'] = 556;
  45972. });
  45973. t['Symbol'] = getLookupTableFactory(function (t) {
  45974. t['space'] = 250;
  45975. t['exclam'] = 333;
  45976. t['universal'] = 713;
  45977. t['numbersign'] = 500;
  45978. t['existential'] = 549;
  45979. t['percent'] = 833;
  45980. t['ampersand'] = 778;
  45981. t['suchthat'] = 439;
  45982. t['parenleft'] = 333;
  45983. t['parenright'] = 333;
  45984. t['asteriskmath'] = 500;
  45985. t['plus'] = 549;
  45986. t['comma'] = 250;
  45987. t['minus'] = 549;
  45988. t['period'] = 250;
  45989. t['slash'] = 278;
  45990. t['zero'] = 500;
  45991. t['one'] = 500;
  45992. t['two'] = 500;
  45993. t['three'] = 500;
  45994. t['four'] = 500;
  45995. t['five'] = 500;
  45996. t['six'] = 500;
  45997. t['seven'] = 500;
  45998. t['eight'] = 500;
  45999. t['nine'] = 500;
  46000. t['colon'] = 278;
  46001. t['semicolon'] = 278;
  46002. t['less'] = 549;
  46003. t['equal'] = 549;
  46004. t['greater'] = 549;
  46005. t['question'] = 444;
  46006. t['congruent'] = 549;
  46007. t['Alpha'] = 722;
  46008. t['Beta'] = 667;
  46009. t['Chi'] = 722;
  46010. t['Delta'] = 612;
  46011. t['Epsilon'] = 611;
  46012. t['Phi'] = 763;
  46013. t['Gamma'] = 603;
  46014. t['Eta'] = 722;
  46015. t['Iota'] = 333;
  46016. t['theta1'] = 631;
  46017. t['Kappa'] = 722;
  46018. t['Lambda'] = 686;
  46019. t['Mu'] = 889;
  46020. t['Nu'] = 722;
  46021. t['Omicron'] = 722;
  46022. t['Pi'] = 768;
  46023. t['Theta'] = 741;
  46024. t['Rho'] = 556;
  46025. t['Sigma'] = 592;
  46026. t['Tau'] = 611;
  46027. t['Upsilon'] = 690;
  46028. t['sigma1'] = 439;
  46029. t['Omega'] = 768;
  46030. t['Xi'] = 645;
  46031. t['Psi'] = 795;
  46032. t['Zeta'] = 611;
  46033. t['bracketleft'] = 333;
  46034. t['therefore'] = 863;
  46035. t['bracketright'] = 333;
  46036. t['perpendicular'] = 658;
  46037. t['underscore'] = 500;
  46038. t['radicalex'] = 500;
  46039. t['alpha'] = 631;
  46040. t['beta'] = 549;
  46041. t['chi'] = 549;
  46042. t['delta'] = 494;
  46043. t['epsilon'] = 439;
  46044. t['phi'] = 521;
  46045. t['gamma'] = 411;
  46046. t['eta'] = 603;
  46047. t['iota'] = 329;
  46048. t['phi1'] = 603;
  46049. t['kappa'] = 549;
  46050. t['lambda'] = 549;
  46051. t['mu'] = 576;
  46052. t['nu'] = 521;
  46053. t['omicron'] = 549;
  46054. t['pi'] = 549;
  46055. t['theta'] = 521;
  46056. t['rho'] = 549;
  46057. t['sigma'] = 603;
  46058. t['tau'] = 439;
  46059. t['upsilon'] = 576;
  46060. t['omega1'] = 713;
  46061. t['omega'] = 686;
  46062. t['xi'] = 493;
  46063. t['psi'] = 686;
  46064. t['zeta'] = 494;
  46065. t['braceleft'] = 480;
  46066. t['bar'] = 200;
  46067. t['braceright'] = 480;
  46068. t['similar'] = 549;
  46069. t['Euro'] = 750;
  46070. t['Upsilon1'] = 620;
  46071. t['minute'] = 247;
  46072. t['lessequal'] = 549;
  46073. t['fraction'] = 167;
  46074. t['infinity'] = 713;
  46075. t['florin'] = 500;
  46076. t['club'] = 753;
  46077. t['diamond'] = 753;
  46078. t['heart'] = 753;
  46079. t['spade'] = 753;
  46080. t['arrowboth'] = 1042;
  46081. t['arrowleft'] = 987;
  46082. t['arrowup'] = 603;
  46083. t['arrowright'] = 987;
  46084. t['arrowdown'] = 603;
  46085. t['degree'] = 400;
  46086. t['plusminus'] = 549;
  46087. t['second'] = 411;
  46088. t['greaterequal'] = 549;
  46089. t['multiply'] = 549;
  46090. t['proportional'] = 713;
  46091. t['partialdiff'] = 494;
  46092. t['bullet'] = 460;
  46093. t['divide'] = 549;
  46094. t['notequal'] = 549;
  46095. t['equivalence'] = 549;
  46096. t['approxequal'] = 549;
  46097. t['ellipsis'] = 1000;
  46098. t['arrowvertex'] = 603;
  46099. t['arrowhorizex'] = 1000;
  46100. t['carriagereturn'] = 658;
  46101. t['aleph'] = 823;
  46102. t['Ifraktur'] = 686;
  46103. t['Rfraktur'] = 795;
  46104. t['weierstrass'] = 987;
  46105. t['circlemultiply'] = 768;
  46106. t['circleplus'] = 768;
  46107. t['emptyset'] = 823;
  46108. t['intersection'] = 768;
  46109. t['union'] = 768;
  46110. t['propersuperset'] = 713;
  46111. t['reflexsuperset'] = 713;
  46112. t['notsubset'] = 713;
  46113. t['propersubset'] = 713;
  46114. t['reflexsubset'] = 713;
  46115. t['element'] = 713;
  46116. t['notelement'] = 713;
  46117. t['angle'] = 768;
  46118. t['gradient'] = 713;
  46119. t['registerserif'] = 790;
  46120. t['copyrightserif'] = 790;
  46121. t['trademarkserif'] = 890;
  46122. t['product'] = 823;
  46123. t['radical'] = 549;
  46124. t['dotmath'] = 250;
  46125. t['logicalnot'] = 713;
  46126. t['logicaland'] = 603;
  46127. t['logicalor'] = 603;
  46128. t['arrowdblboth'] = 1042;
  46129. t['arrowdblleft'] = 987;
  46130. t['arrowdblup'] = 603;
  46131. t['arrowdblright'] = 987;
  46132. t['arrowdbldown'] = 603;
  46133. t['lozenge'] = 494;
  46134. t['angleleft'] = 329;
  46135. t['registersans'] = 790;
  46136. t['copyrightsans'] = 790;
  46137. t['trademarksans'] = 786;
  46138. t['summation'] = 713;
  46139. t['parenlefttp'] = 384;
  46140. t['parenleftex'] = 384;
  46141. t['parenleftbt'] = 384;
  46142. t['bracketlefttp'] = 384;
  46143. t['bracketleftex'] = 384;
  46144. t['bracketleftbt'] = 384;
  46145. t['bracelefttp'] = 494;
  46146. t['braceleftmid'] = 494;
  46147. t['braceleftbt'] = 494;
  46148. t['braceex'] = 494;
  46149. t['angleright'] = 329;
  46150. t['integral'] = 274;
  46151. t['integraltp'] = 686;
  46152. t['integralex'] = 686;
  46153. t['integralbt'] = 686;
  46154. t['parenrighttp'] = 384;
  46155. t['parenrightex'] = 384;
  46156. t['parenrightbt'] = 384;
  46157. t['bracketrighttp'] = 384;
  46158. t['bracketrightex'] = 384;
  46159. t['bracketrightbt'] = 384;
  46160. t['bracerighttp'] = 494;
  46161. t['bracerightmid'] = 494;
  46162. t['bracerightbt'] = 494;
  46163. t['apple'] = 790;
  46164. });
  46165. t['Times-Roman'] = getLookupTableFactory(function (t) {
  46166. t['space'] = 250;
  46167. t['exclam'] = 333;
  46168. t['quotedbl'] = 408;
  46169. t['numbersign'] = 500;
  46170. t['dollar'] = 500;
  46171. t['percent'] = 833;
  46172. t['ampersand'] = 778;
  46173. t['quoteright'] = 333;
  46174. t['parenleft'] = 333;
  46175. t['parenright'] = 333;
  46176. t['asterisk'] = 500;
  46177. t['plus'] = 564;
  46178. t['comma'] = 250;
  46179. t['hyphen'] = 333;
  46180. t['period'] = 250;
  46181. t['slash'] = 278;
  46182. t['zero'] = 500;
  46183. t['one'] = 500;
  46184. t['two'] = 500;
  46185. t['three'] = 500;
  46186. t['four'] = 500;
  46187. t['five'] = 500;
  46188. t['six'] = 500;
  46189. t['seven'] = 500;
  46190. t['eight'] = 500;
  46191. t['nine'] = 500;
  46192. t['colon'] = 278;
  46193. t['semicolon'] = 278;
  46194. t['less'] = 564;
  46195. t['equal'] = 564;
  46196. t['greater'] = 564;
  46197. t['question'] = 444;
  46198. t['at'] = 921;
  46199. t['A'] = 722;
  46200. t['B'] = 667;
  46201. t['C'] = 667;
  46202. t['D'] = 722;
  46203. t['E'] = 611;
  46204. t['F'] = 556;
  46205. t['G'] = 722;
  46206. t['H'] = 722;
  46207. t['I'] = 333;
  46208. t['J'] = 389;
  46209. t['K'] = 722;
  46210. t['L'] = 611;
  46211. t['M'] = 889;
  46212. t['N'] = 722;
  46213. t['O'] = 722;
  46214. t['P'] = 556;
  46215. t['Q'] = 722;
  46216. t['R'] = 667;
  46217. t['S'] = 556;
  46218. t['T'] = 611;
  46219. t['U'] = 722;
  46220. t['V'] = 722;
  46221. t['W'] = 944;
  46222. t['X'] = 722;
  46223. t['Y'] = 722;
  46224. t['Z'] = 611;
  46225. t['bracketleft'] = 333;
  46226. t['backslash'] = 278;
  46227. t['bracketright'] = 333;
  46228. t['asciicircum'] = 469;
  46229. t['underscore'] = 500;
  46230. t['quoteleft'] = 333;
  46231. t['a'] = 444;
  46232. t['b'] = 500;
  46233. t['c'] = 444;
  46234. t['d'] = 500;
  46235. t['e'] = 444;
  46236. t['f'] = 333;
  46237. t['g'] = 500;
  46238. t['h'] = 500;
  46239. t['i'] = 278;
  46240. t['j'] = 278;
  46241. t['k'] = 500;
  46242. t['l'] = 278;
  46243. t['m'] = 778;
  46244. t['n'] = 500;
  46245. t['o'] = 500;
  46246. t['p'] = 500;
  46247. t['q'] = 500;
  46248. t['r'] = 333;
  46249. t['s'] = 389;
  46250. t['t'] = 278;
  46251. t['u'] = 500;
  46252. t['v'] = 500;
  46253. t['w'] = 722;
  46254. t['x'] = 500;
  46255. t['y'] = 500;
  46256. t['z'] = 444;
  46257. t['braceleft'] = 480;
  46258. t['bar'] = 200;
  46259. t['braceright'] = 480;
  46260. t['asciitilde'] = 541;
  46261. t['exclamdown'] = 333;
  46262. t['cent'] = 500;
  46263. t['sterling'] = 500;
  46264. t['fraction'] = 167;
  46265. t['yen'] = 500;
  46266. t['florin'] = 500;
  46267. t['section'] = 500;
  46268. t['currency'] = 500;
  46269. t['quotesingle'] = 180;
  46270. t['quotedblleft'] = 444;
  46271. t['guillemotleft'] = 500;
  46272. t['guilsinglleft'] = 333;
  46273. t['guilsinglright'] = 333;
  46274. t['fi'] = 556;
  46275. t['fl'] = 556;
  46276. t['endash'] = 500;
  46277. t['dagger'] = 500;
  46278. t['daggerdbl'] = 500;
  46279. t['periodcentered'] = 250;
  46280. t['paragraph'] = 453;
  46281. t['bullet'] = 350;
  46282. t['quotesinglbase'] = 333;
  46283. t['quotedblbase'] = 444;
  46284. t['quotedblright'] = 444;
  46285. t['guillemotright'] = 500;
  46286. t['ellipsis'] = 1000;
  46287. t['perthousand'] = 1000;
  46288. t['questiondown'] = 444;
  46289. t['grave'] = 333;
  46290. t['acute'] = 333;
  46291. t['circumflex'] = 333;
  46292. t['tilde'] = 333;
  46293. t['macron'] = 333;
  46294. t['breve'] = 333;
  46295. t['dotaccent'] = 333;
  46296. t['dieresis'] = 333;
  46297. t['ring'] = 333;
  46298. t['cedilla'] = 333;
  46299. t['hungarumlaut'] = 333;
  46300. t['ogonek'] = 333;
  46301. t['caron'] = 333;
  46302. t['emdash'] = 1000;
  46303. t['AE'] = 889;
  46304. t['ordfeminine'] = 276;
  46305. t['Lslash'] = 611;
  46306. t['Oslash'] = 722;
  46307. t['OE'] = 889;
  46308. t['ordmasculine'] = 310;
  46309. t['ae'] = 667;
  46310. t['dotlessi'] = 278;
  46311. t['lslash'] = 278;
  46312. t['oslash'] = 500;
  46313. t['oe'] = 722;
  46314. t['germandbls'] = 500;
  46315. t['Idieresis'] = 333;
  46316. t['eacute'] = 444;
  46317. t['abreve'] = 444;
  46318. t['uhungarumlaut'] = 500;
  46319. t['ecaron'] = 444;
  46320. t['Ydieresis'] = 722;
  46321. t['divide'] = 564;
  46322. t['Yacute'] = 722;
  46323. t['Acircumflex'] = 722;
  46324. t['aacute'] = 444;
  46325. t['Ucircumflex'] = 722;
  46326. t['yacute'] = 500;
  46327. t['scommaaccent'] = 389;
  46328. t['ecircumflex'] = 444;
  46329. t['Uring'] = 722;
  46330. t['Udieresis'] = 722;
  46331. t['aogonek'] = 444;
  46332. t['Uacute'] = 722;
  46333. t['uogonek'] = 500;
  46334. t['Edieresis'] = 611;
  46335. t['Dcroat'] = 722;
  46336. t['commaaccent'] = 250;
  46337. t['copyright'] = 760;
  46338. t['Emacron'] = 611;
  46339. t['ccaron'] = 444;
  46340. t['aring'] = 444;
  46341. t['Ncommaaccent'] = 722;
  46342. t['lacute'] = 278;
  46343. t['agrave'] = 444;
  46344. t['Tcommaaccent'] = 611;
  46345. t['Cacute'] = 667;
  46346. t['atilde'] = 444;
  46347. t['Edotaccent'] = 611;
  46348. t['scaron'] = 389;
  46349. t['scedilla'] = 389;
  46350. t['iacute'] = 278;
  46351. t['lozenge'] = 471;
  46352. t['Rcaron'] = 667;
  46353. t['Gcommaaccent'] = 722;
  46354. t['ucircumflex'] = 500;
  46355. t['acircumflex'] = 444;
  46356. t['Amacron'] = 722;
  46357. t['rcaron'] = 333;
  46358. t['ccedilla'] = 444;
  46359. t['Zdotaccent'] = 611;
  46360. t['Thorn'] = 556;
  46361. t['Omacron'] = 722;
  46362. t['Racute'] = 667;
  46363. t['Sacute'] = 556;
  46364. t['dcaron'] = 588;
  46365. t['Umacron'] = 722;
  46366. t['uring'] = 500;
  46367. t['threesuperior'] = 300;
  46368. t['Ograve'] = 722;
  46369. t['Agrave'] = 722;
  46370. t['Abreve'] = 722;
  46371. t['multiply'] = 564;
  46372. t['uacute'] = 500;
  46373. t['Tcaron'] = 611;
  46374. t['partialdiff'] = 476;
  46375. t['ydieresis'] = 500;
  46376. t['Nacute'] = 722;
  46377. t['icircumflex'] = 278;
  46378. t['Ecircumflex'] = 611;
  46379. t['adieresis'] = 444;
  46380. t['edieresis'] = 444;
  46381. t['cacute'] = 444;
  46382. t['nacute'] = 500;
  46383. t['umacron'] = 500;
  46384. t['Ncaron'] = 722;
  46385. t['Iacute'] = 333;
  46386. t['plusminus'] = 564;
  46387. t['brokenbar'] = 200;
  46388. t['registered'] = 760;
  46389. t['Gbreve'] = 722;
  46390. t['Idotaccent'] = 333;
  46391. t['summation'] = 600;
  46392. t['Egrave'] = 611;
  46393. t['racute'] = 333;
  46394. t['omacron'] = 500;
  46395. t['Zacute'] = 611;
  46396. t['Zcaron'] = 611;
  46397. t['greaterequal'] = 549;
  46398. t['Eth'] = 722;
  46399. t['Ccedilla'] = 667;
  46400. t['lcommaaccent'] = 278;
  46401. t['tcaron'] = 326;
  46402. t['eogonek'] = 444;
  46403. t['Uogonek'] = 722;
  46404. t['Aacute'] = 722;
  46405. t['Adieresis'] = 722;
  46406. t['egrave'] = 444;
  46407. t['zacute'] = 444;
  46408. t['iogonek'] = 278;
  46409. t['Oacute'] = 722;
  46410. t['oacute'] = 500;
  46411. t['amacron'] = 444;
  46412. t['sacute'] = 389;
  46413. t['idieresis'] = 278;
  46414. t['Ocircumflex'] = 722;
  46415. t['Ugrave'] = 722;
  46416. t['Delta'] = 612;
  46417. t['thorn'] = 500;
  46418. t['twosuperior'] = 300;
  46419. t['Odieresis'] = 722;
  46420. t['mu'] = 500;
  46421. t['igrave'] = 278;
  46422. t['ohungarumlaut'] = 500;
  46423. t['Eogonek'] = 611;
  46424. t['dcroat'] = 500;
  46425. t['threequarters'] = 750;
  46426. t['Scedilla'] = 556;
  46427. t['lcaron'] = 344;
  46428. t['Kcommaaccent'] = 722;
  46429. t['Lacute'] = 611;
  46430. t['trademark'] = 980;
  46431. t['edotaccent'] = 444;
  46432. t['Igrave'] = 333;
  46433. t['Imacron'] = 333;
  46434. t['Lcaron'] = 611;
  46435. t['onehalf'] = 750;
  46436. t['lessequal'] = 549;
  46437. t['ocircumflex'] = 500;
  46438. t['ntilde'] = 500;
  46439. t['Uhungarumlaut'] = 722;
  46440. t['Eacute'] = 611;
  46441. t['emacron'] = 444;
  46442. t['gbreve'] = 500;
  46443. t['onequarter'] = 750;
  46444. t['Scaron'] = 556;
  46445. t['Scommaaccent'] = 556;
  46446. t['Ohungarumlaut'] = 722;
  46447. t['degree'] = 400;
  46448. t['ograve'] = 500;
  46449. t['Ccaron'] = 667;
  46450. t['ugrave'] = 500;
  46451. t['radical'] = 453;
  46452. t['Dcaron'] = 722;
  46453. t['rcommaaccent'] = 333;
  46454. t['Ntilde'] = 722;
  46455. t['otilde'] = 500;
  46456. t['Rcommaaccent'] = 667;
  46457. t['Lcommaaccent'] = 611;
  46458. t['Atilde'] = 722;
  46459. t['Aogonek'] = 722;
  46460. t['Aring'] = 722;
  46461. t['Otilde'] = 722;
  46462. t['zdotaccent'] = 444;
  46463. t['Ecaron'] = 611;
  46464. t['Iogonek'] = 333;
  46465. t['kcommaaccent'] = 500;
  46466. t['minus'] = 564;
  46467. t['Icircumflex'] = 333;
  46468. t['ncaron'] = 500;
  46469. t['tcommaaccent'] = 278;
  46470. t['logicalnot'] = 564;
  46471. t['odieresis'] = 500;
  46472. t['udieresis'] = 500;
  46473. t['notequal'] = 549;
  46474. t['gcommaaccent'] = 500;
  46475. t['eth'] = 500;
  46476. t['zcaron'] = 444;
  46477. t['ncommaaccent'] = 500;
  46478. t['onesuperior'] = 300;
  46479. t['imacron'] = 278;
  46480. t['Euro'] = 500;
  46481. });
  46482. t['Times-Bold'] = getLookupTableFactory(function (t) {
  46483. t['space'] = 250;
  46484. t['exclam'] = 333;
  46485. t['quotedbl'] = 555;
  46486. t['numbersign'] = 500;
  46487. t['dollar'] = 500;
  46488. t['percent'] = 1000;
  46489. t['ampersand'] = 833;
  46490. t['quoteright'] = 333;
  46491. t['parenleft'] = 333;
  46492. t['parenright'] = 333;
  46493. t['asterisk'] = 500;
  46494. t['plus'] = 570;
  46495. t['comma'] = 250;
  46496. t['hyphen'] = 333;
  46497. t['period'] = 250;
  46498. t['slash'] = 278;
  46499. t['zero'] = 500;
  46500. t['one'] = 500;
  46501. t['two'] = 500;
  46502. t['three'] = 500;
  46503. t['four'] = 500;
  46504. t['five'] = 500;
  46505. t['six'] = 500;
  46506. t['seven'] = 500;
  46507. t['eight'] = 500;
  46508. t['nine'] = 500;
  46509. t['colon'] = 333;
  46510. t['semicolon'] = 333;
  46511. t['less'] = 570;
  46512. t['equal'] = 570;
  46513. t['greater'] = 570;
  46514. t['question'] = 500;
  46515. t['at'] = 930;
  46516. t['A'] = 722;
  46517. t['B'] = 667;
  46518. t['C'] = 722;
  46519. t['D'] = 722;
  46520. t['E'] = 667;
  46521. t['F'] = 611;
  46522. t['G'] = 778;
  46523. t['H'] = 778;
  46524. t['I'] = 389;
  46525. t['J'] = 500;
  46526. t['K'] = 778;
  46527. t['L'] = 667;
  46528. t['M'] = 944;
  46529. t['N'] = 722;
  46530. t['O'] = 778;
  46531. t['P'] = 611;
  46532. t['Q'] = 778;
  46533. t['R'] = 722;
  46534. t['S'] = 556;
  46535. t['T'] = 667;
  46536. t['U'] = 722;
  46537. t['V'] = 722;
  46538. t['W'] = 1000;
  46539. t['X'] = 722;
  46540. t['Y'] = 722;
  46541. t['Z'] = 667;
  46542. t['bracketleft'] = 333;
  46543. t['backslash'] = 278;
  46544. t['bracketright'] = 333;
  46545. t['asciicircum'] = 581;
  46546. t['underscore'] = 500;
  46547. t['quoteleft'] = 333;
  46548. t['a'] = 500;
  46549. t['b'] = 556;
  46550. t['c'] = 444;
  46551. t['d'] = 556;
  46552. t['e'] = 444;
  46553. t['f'] = 333;
  46554. t['g'] = 500;
  46555. t['h'] = 556;
  46556. t['i'] = 278;
  46557. t['j'] = 333;
  46558. t['k'] = 556;
  46559. t['l'] = 278;
  46560. t['m'] = 833;
  46561. t['n'] = 556;
  46562. t['o'] = 500;
  46563. t['p'] = 556;
  46564. t['q'] = 556;
  46565. t['r'] = 444;
  46566. t['s'] = 389;
  46567. t['t'] = 333;
  46568. t['u'] = 556;
  46569. t['v'] = 500;
  46570. t['w'] = 722;
  46571. t['x'] = 500;
  46572. t['y'] = 500;
  46573. t['z'] = 444;
  46574. t['braceleft'] = 394;
  46575. t['bar'] = 220;
  46576. t['braceright'] = 394;
  46577. t['asciitilde'] = 520;
  46578. t['exclamdown'] = 333;
  46579. t['cent'] = 500;
  46580. t['sterling'] = 500;
  46581. t['fraction'] = 167;
  46582. t['yen'] = 500;
  46583. t['florin'] = 500;
  46584. t['section'] = 500;
  46585. t['currency'] = 500;
  46586. t['quotesingle'] = 278;
  46587. t['quotedblleft'] = 500;
  46588. t['guillemotleft'] = 500;
  46589. t['guilsinglleft'] = 333;
  46590. t['guilsinglright'] = 333;
  46591. t['fi'] = 556;
  46592. t['fl'] = 556;
  46593. t['endash'] = 500;
  46594. t['dagger'] = 500;
  46595. t['daggerdbl'] = 500;
  46596. t['periodcentered'] = 250;
  46597. t['paragraph'] = 540;
  46598. t['bullet'] = 350;
  46599. t['quotesinglbase'] = 333;
  46600. t['quotedblbase'] = 500;
  46601. t['quotedblright'] = 500;
  46602. t['guillemotright'] = 500;
  46603. t['ellipsis'] = 1000;
  46604. t['perthousand'] = 1000;
  46605. t['questiondown'] = 500;
  46606. t['grave'] = 333;
  46607. t['acute'] = 333;
  46608. t['circumflex'] = 333;
  46609. t['tilde'] = 333;
  46610. t['macron'] = 333;
  46611. t['breve'] = 333;
  46612. t['dotaccent'] = 333;
  46613. t['dieresis'] = 333;
  46614. t['ring'] = 333;
  46615. t['cedilla'] = 333;
  46616. t['hungarumlaut'] = 333;
  46617. t['ogonek'] = 333;
  46618. t['caron'] = 333;
  46619. t['emdash'] = 1000;
  46620. t['AE'] = 1000;
  46621. t['ordfeminine'] = 300;
  46622. t['Lslash'] = 667;
  46623. t['Oslash'] = 778;
  46624. t['OE'] = 1000;
  46625. t['ordmasculine'] = 330;
  46626. t['ae'] = 722;
  46627. t['dotlessi'] = 278;
  46628. t['lslash'] = 278;
  46629. t['oslash'] = 500;
  46630. t['oe'] = 722;
  46631. t['germandbls'] = 556;
  46632. t['Idieresis'] = 389;
  46633. t['eacute'] = 444;
  46634. t['abreve'] = 500;
  46635. t['uhungarumlaut'] = 556;
  46636. t['ecaron'] = 444;
  46637. t['Ydieresis'] = 722;
  46638. t['divide'] = 570;
  46639. t['Yacute'] = 722;
  46640. t['Acircumflex'] = 722;
  46641. t['aacute'] = 500;
  46642. t['Ucircumflex'] = 722;
  46643. t['yacute'] = 500;
  46644. t['scommaaccent'] = 389;
  46645. t['ecircumflex'] = 444;
  46646. t['Uring'] = 722;
  46647. t['Udieresis'] = 722;
  46648. t['aogonek'] = 500;
  46649. t['Uacute'] = 722;
  46650. t['uogonek'] = 556;
  46651. t['Edieresis'] = 667;
  46652. t['Dcroat'] = 722;
  46653. t['commaaccent'] = 250;
  46654. t['copyright'] = 747;
  46655. t['Emacron'] = 667;
  46656. t['ccaron'] = 444;
  46657. t['aring'] = 500;
  46658. t['Ncommaaccent'] = 722;
  46659. t['lacute'] = 278;
  46660. t['agrave'] = 500;
  46661. t['Tcommaaccent'] = 667;
  46662. t['Cacute'] = 722;
  46663. t['atilde'] = 500;
  46664. t['Edotaccent'] = 667;
  46665. t['scaron'] = 389;
  46666. t['scedilla'] = 389;
  46667. t['iacute'] = 278;
  46668. t['lozenge'] = 494;
  46669. t['Rcaron'] = 722;
  46670. t['Gcommaaccent'] = 778;
  46671. t['ucircumflex'] = 556;
  46672. t['acircumflex'] = 500;
  46673. t['Amacron'] = 722;
  46674. t['rcaron'] = 444;
  46675. t['ccedilla'] = 444;
  46676. t['Zdotaccent'] = 667;
  46677. t['Thorn'] = 611;
  46678. t['Omacron'] = 778;
  46679. t['Racute'] = 722;
  46680. t['Sacute'] = 556;
  46681. t['dcaron'] = 672;
  46682. t['Umacron'] = 722;
  46683. t['uring'] = 556;
  46684. t['threesuperior'] = 300;
  46685. t['Ograve'] = 778;
  46686. t['Agrave'] = 722;
  46687. t['Abreve'] = 722;
  46688. t['multiply'] = 570;
  46689. t['uacute'] = 556;
  46690. t['Tcaron'] = 667;
  46691. t['partialdiff'] = 494;
  46692. t['ydieresis'] = 500;
  46693. t['Nacute'] = 722;
  46694. t['icircumflex'] = 278;
  46695. t['Ecircumflex'] = 667;
  46696. t['adieresis'] = 500;
  46697. t['edieresis'] = 444;
  46698. t['cacute'] = 444;
  46699. t['nacute'] = 556;
  46700. t['umacron'] = 556;
  46701. t['Ncaron'] = 722;
  46702. t['Iacute'] = 389;
  46703. t['plusminus'] = 570;
  46704. t['brokenbar'] = 220;
  46705. t['registered'] = 747;
  46706. t['Gbreve'] = 778;
  46707. t['Idotaccent'] = 389;
  46708. t['summation'] = 600;
  46709. t['Egrave'] = 667;
  46710. t['racute'] = 444;
  46711. t['omacron'] = 500;
  46712. t['Zacute'] = 667;
  46713. t['Zcaron'] = 667;
  46714. t['greaterequal'] = 549;
  46715. t['Eth'] = 722;
  46716. t['Ccedilla'] = 722;
  46717. t['lcommaaccent'] = 278;
  46718. t['tcaron'] = 416;
  46719. t['eogonek'] = 444;
  46720. t['Uogonek'] = 722;
  46721. t['Aacute'] = 722;
  46722. t['Adieresis'] = 722;
  46723. t['egrave'] = 444;
  46724. t['zacute'] = 444;
  46725. t['iogonek'] = 278;
  46726. t['Oacute'] = 778;
  46727. t['oacute'] = 500;
  46728. t['amacron'] = 500;
  46729. t['sacute'] = 389;
  46730. t['idieresis'] = 278;
  46731. t['Ocircumflex'] = 778;
  46732. t['Ugrave'] = 722;
  46733. t['Delta'] = 612;
  46734. t['thorn'] = 556;
  46735. t['twosuperior'] = 300;
  46736. t['Odieresis'] = 778;
  46737. t['mu'] = 556;
  46738. t['igrave'] = 278;
  46739. t['ohungarumlaut'] = 500;
  46740. t['Eogonek'] = 667;
  46741. t['dcroat'] = 556;
  46742. t['threequarters'] = 750;
  46743. t['Scedilla'] = 556;
  46744. t['lcaron'] = 394;
  46745. t['Kcommaaccent'] = 778;
  46746. t['Lacute'] = 667;
  46747. t['trademark'] = 1000;
  46748. t['edotaccent'] = 444;
  46749. t['Igrave'] = 389;
  46750. t['Imacron'] = 389;
  46751. t['Lcaron'] = 667;
  46752. t['onehalf'] = 750;
  46753. t['lessequal'] = 549;
  46754. t['ocircumflex'] = 500;
  46755. t['ntilde'] = 556;
  46756. t['Uhungarumlaut'] = 722;
  46757. t['Eacute'] = 667;
  46758. t['emacron'] = 444;
  46759. t['gbreve'] = 500;
  46760. t['onequarter'] = 750;
  46761. t['Scaron'] = 556;
  46762. t['Scommaaccent'] = 556;
  46763. t['Ohungarumlaut'] = 778;
  46764. t['degree'] = 400;
  46765. t['ograve'] = 500;
  46766. t['Ccaron'] = 722;
  46767. t['ugrave'] = 556;
  46768. t['radical'] = 549;
  46769. t['Dcaron'] = 722;
  46770. t['rcommaaccent'] = 444;
  46771. t['Ntilde'] = 722;
  46772. t['otilde'] = 500;
  46773. t['Rcommaaccent'] = 722;
  46774. t['Lcommaaccent'] = 667;
  46775. t['Atilde'] = 722;
  46776. t['Aogonek'] = 722;
  46777. t['Aring'] = 722;
  46778. t['Otilde'] = 778;
  46779. t['zdotaccent'] = 444;
  46780. t['Ecaron'] = 667;
  46781. t['Iogonek'] = 389;
  46782. t['kcommaaccent'] = 556;
  46783. t['minus'] = 570;
  46784. t['Icircumflex'] = 389;
  46785. t['ncaron'] = 556;
  46786. t['tcommaaccent'] = 333;
  46787. t['logicalnot'] = 570;
  46788. t['odieresis'] = 500;
  46789. t['udieresis'] = 556;
  46790. t['notequal'] = 549;
  46791. t['gcommaaccent'] = 500;
  46792. t['eth'] = 500;
  46793. t['zcaron'] = 444;
  46794. t['ncommaaccent'] = 556;
  46795. t['onesuperior'] = 300;
  46796. t['imacron'] = 278;
  46797. t['Euro'] = 500;
  46798. });
  46799. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  46800. t['space'] = 250;
  46801. t['exclam'] = 389;
  46802. t['quotedbl'] = 555;
  46803. t['numbersign'] = 500;
  46804. t['dollar'] = 500;
  46805. t['percent'] = 833;
  46806. t['ampersand'] = 778;
  46807. t['quoteright'] = 333;
  46808. t['parenleft'] = 333;
  46809. t['parenright'] = 333;
  46810. t['asterisk'] = 500;
  46811. t['plus'] = 570;
  46812. t['comma'] = 250;
  46813. t['hyphen'] = 333;
  46814. t['period'] = 250;
  46815. t['slash'] = 278;
  46816. t['zero'] = 500;
  46817. t['one'] = 500;
  46818. t['two'] = 500;
  46819. t['three'] = 500;
  46820. t['four'] = 500;
  46821. t['five'] = 500;
  46822. t['six'] = 500;
  46823. t['seven'] = 500;
  46824. t['eight'] = 500;
  46825. t['nine'] = 500;
  46826. t['colon'] = 333;
  46827. t['semicolon'] = 333;
  46828. t['less'] = 570;
  46829. t['equal'] = 570;
  46830. t['greater'] = 570;
  46831. t['question'] = 500;
  46832. t['at'] = 832;
  46833. t['A'] = 667;
  46834. t['B'] = 667;
  46835. t['C'] = 667;
  46836. t['D'] = 722;
  46837. t['E'] = 667;
  46838. t['F'] = 667;
  46839. t['G'] = 722;
  46840. t['H'] = 778;
  46841. t['I'] = 389;
  46842. t['J'] = 500;
  46843. t['K'] = 667;
  46844. t['L'] = 611;
  46845. t['M'] = 889;
  46846. t['N'] = 722;
  46847. t['O'] = 722;
  46848. t['P'] = 611;
  46849. t['Q'] = 722;
  46850. t['R'] = 667;
  46851. t['S'] = 556;
  46852. t['T'] = 611;
  46853. t['U'] = 722;
  46854. t['V'] = 667;
  46855. t['W'] = 889;
  46856. t['X'] = 667;
  46857. t['Y'] = 611;
  46858. t['Z'] = 611;
  46859. t['bracketleft'] = 333;
  46860. t['backslash'] = 278;
  46861. t['bracketright'] = 333;
  46862. t['asciicircum'] = 570;
  46863. t['underscore'] = 500;
  46864. t['quoteleft'] = 333;
  46865. t['a'] = 500;
  46866. t['b'] = 500;
  46867. t['c'] = 444;
  46868. t['d'] = 500;
  46869. t['e'] = 444;
  46870. t['f'] = 333;
  46871. t['g'] = 500;
  46872. t['h'] = 556;
  46873. t['i'] = 278;
  46874. t['j'] = 278;
  46875. t['k'] = 500;
  46876. t['l'] = 278;
  46877. t['m'] = 778;
  46878. t['n'] = 556;
  46879. t['o'] = 500;
  46880. t['p'] = 500;
  46881. t['q'] = 500;
  46882. t['r'] = 389;
  46883. t['s'] = 389;
  46884. t['t'] = 278;
  46885. t['u'] = 556;
  46886. t['v'] = 444;
  46887. t['w'] = 667;
  46888. t['x'] = 500;
  46889. t['y'] = 444;
  46890. t['z'] = 389;
  46891. t['braceleft'] = 348;
  46892. t['bar'] = 220;
  46893. t['braceright'] = 348;
  46894. t['asciitilde'] = 570;
  46895. t['exclamdown'] = 389;
  46896. t['cent'] = 500;
  46897. t['sterling'] = 500;
  46898. t['fraction'] = 167;
  46899. t['yen'] = 500;
  46900. t['florin'] = 500;
  46901. t['section'] = 500;
  46902. t['currency'] = 500;
  46903. t['quotesingle'] = 278;
  46904. t['quotedblleft'] = 500;
  46905. t['guillemotleft'] = 500;
  46906. t['guilsinglleft'] = 333;
  46907. t['guilsinglright'] = 333;
  46908. t['fi'] = 556;
  46909. t['fl'] = 556;
  46910. t['endash'] = 500;
  46911. t['dagger'] = 500;
  46912. t['daggerdbl'] = 500;
  46913. t['periodcentered'] = 250;
  46914. t['paragraph'] = 500;
  46915. t['bullet'] = 350;
  46916. t['quotesinglbase'] = 333;
  46917. t['quotedblbase'] = 500;
  46918. t['quotedblright'] = 500;
  46919. t['guillemotright'] = 500;
  46920. t['ellipsis'] = 1000;
  46921. t['perthousand'] = 1000;
  46922. t['questiondown'] = 500;
  46923. t['grave'] = 333;
  46924. t['acute'] = 333;
  46925. t['circumflex'] = 333;
  46926. t['tilde'] = 333;
  46927. t['macron'] = 333;
  46928. t['breve'] = 333;
  46929. t['dotaccent'] = 333;
  46930. t['dieresis'] = 333;
  46931. t['ring'] = 333;
  46932. t['cedilla'] = 333;
  46933. t['hungarumlaut'] = 333;
  46934. t['ogonek'] = 333;
  46935. t['caron'] = 333;
  46936. t['emdash'] = 1000;
  46937. t['AE'] = 944;
  46938. t['ordfeminine'] = 266;
  46939. t['Lslash'] = 611;
  46940. t['Oslash'] = 722;
  46941. t['OE'] = 944;
  46942. t['ordmasculine'] = 300;
  46943. t['ae'] = 722;
  46944. t['dotlessi'] = 278;
  46945. t['lslash'] = 278;
  46946. t['oslash'] = 500;
  46947. t['oe'] = 722;
  46948. t['germandbls'] = 500;
  46949. t['Idieresis'] = 389;
  46950. t['eacute'] = 444;
  46951. t['abreve'] = 500;
  46952. t['uhungarumlaut'] = 556;
  46953. t['ecaron'] = 444;
  46954. t['Ydieresis'] = 611;
  46955. t['divide'] = 570;
  46956. t['Yacute'] = 611;
  46957. t['Acircumflex'] = 667;
  46958. t['aacute'] = 500;
  46959. t['Ucircumflex'] = 722;
  46960. t['yacute'] = 444;
  46961. t['scommaaccent'] = 389;
  46962. t['ecircumflex'] = 444;
  46963. t['Uring'] = 722;
  46964. t['Udieresis'] = 722;
  46965. t['aogonek'] = 500;
  46966. t['Uacute'] = 722;
  46967. t['uogonek'] = 556;
  46968. t['Edieresis'] = 667;
  46969. t['Dcroat'] = 722;
  46970. t['commaaccent'] = 250;
  46971. t['copyright'] = 747;
  46972. t['Emacron'] = 667;
  46973. t['ccaron'] = 444;
  46974. t['aring'] = 500;
  46975. t['Ncommaaccent'] = 722;
  46976. t['lacute'] = 278;
  46977. t['agrave'] = 500;
  46978. t['Tcommaaccent'] = 611;
  46979. t['Cacute'] = 667;
  46980. t['atilde'] = 500;
  46981. t['Edotaccent'] = 667;
  46982. t['scaron'] = 389;
  46983. t['scedilla'] = 389;
  46984. t['iacute'] = 278;
  46985. t['lozenge'] = 494;
  46986. t['Rcaron'] = 667;
  46987. t['Gcommaaccent'] = 722;
  46988. t['ucircumflex'] = 556;
  46989. t['acircumflex'] = 500;
  46990. t['Amacron'] = 667;
  46991. t['rcaron'] = 389;
  46992. t['ccedilla'] = 444;
  46993. t['Zdotaccent'] = 611;
  46994. t['Thorn'] = 611;
  46995. t['Omacron'] = 722;
  46996. t['Racute'] = 667;
  46997. t['Sacute'] = 556;
  46998. t['dcaron'] = 608;
  46999. t['Umacron'] = 722;
  47000. t['uring'] = 556;
  47001. t['threesuperior'] = 300;
  47002. t['Ograve'] = 722;
  47003. t['Agrave'] = 667;
  47004. t['Abreve'] = 667;
  47005. t['multiply'] = 570;
  47006. t['uacute'] = 556;
  47007. t['Tcaron'] = 611;
  47008. t['partialdiff'] = 494;
  47009. t['ydieresis'] = 444;
  47010. t['Nacute'] = 722;
  47011. t['icircumflex'] = 278;
  47012. t['Ecircumflex'] = 667;
  47013. t['adieresis'] = 500;
  47014. t['edieresis'] = 444;
  47015. t['cacute'] = 444;
  47016. t['nacute'] = 556;
  47017. t['umacron'] = 556;
  47018. t['Ncaron'] = 722;
  47019. t['Iacute'] = 389;
  47020. t['plusminus'] = 570;
  47021. t['brokenbar'] = 220;
  47022. t['registered'] = 747;
  47023. t['Gbreve'] = 722;
  47024. t['Idotaccent'] = 389;
  47025. t['summation'] = 600;
  47026. t['Egrave'] = 667;
  47027. t['racute'] = 389;
  47028. t['omacron'] = 500;
  47029. t['Zacute'] = 611;
  47030. t['Zcaron'] = 611;
  47031. t['greaterequal'] = 549;
  47032. t['Eth'] = 722;
  47033. t['Ccedilla'] = 667;
  47034. t['lcommaaccent'] = 278;
  47035. t['tcaron'] = 366;
  47036. t['eogonek'] = 444;
  47037. t['Uogonek'] = 722;
  47038. t['Aacute'] = 667;
  47039. t['Adieresis'] = 667;
  47040. t['egrave'] = 444;
  47041. t['zacute'] = 389;
  47042. t['iogonek'] = 278;
  47043. t['Oacute'] = 722;
  47044. t['oacute'] = 500;
  47045. t['amacron'] = 500;
  47046. t['sacute'] = 389;
  47047. t['idieresis'] = 278;
  47048. t['Ocircumflex'] = 722;
  47049. t['Ugrave'] = 722;
  47050. t['Delta'] = 612;
  47051. t['thorn'] = 500;
  47052. t['twosuperior'] = 300;
  47053. t['Odieresis'] = 722;
  47054. t['mu'] = 576;
  47055. t['igrave'] = 278;
  47056. t['ohungarumlaut'] = 500;
  47057. t['Eogonek'] = 667;
  47058. t['dcroat'] = 500;
  47059. t['threequarters'] = 750;
  47060. t['Scedilla'] = 556;
  47061. t['lcaron'] = 382;
  47062. t['Kcommaaccent'] = 667;
  47063. t['Lacute'] = 611;
  47064. t['trademark'] = 1000;
  47065. t['edotaccent'] = 444;
  47066. t['Igrave'] = 389;
  47067. t['Imacron'] = 389;
  47068. t['Lcaron'] = 611;
  47069. t['onehalf'] = 750;
  47070. t['lessequal'] = 549;
  47071. t['ocircumflex'] = 500;
  47072. t['ntilde'] = 556;
  47073. t['Uhungarumlaut'] = 722;
  47074. t['Eacute'] = 667;
  47075. t['emacron'] = 444;
  47076. t['gbreve'] = 500;
  47077. t['onequarter'] = 750;
  47078. t['Scaron'] = 556;
  47079. t['Scommaaccent'] = 556;
  47080. t['Ohungarumlaut'] = 722;
  47081. t['degree'] = 400;
  47082. t['ograve'] = 500;
  47083. t['Ccaron'] = 667;
  47084. t['ugrave'] = 556;
  47085. t['radical'] = 549;
  47086. t['Dcaron'] = 722;
  47087. t['rcommaaccent'] = 389;
  47088. t['Ntilde'] = 722;
  47089. t['otilde'] = 500;
  47090. t['Rcommaaccent'] = 667;
  47091. t['Lcommaaccent'] = 611;
  47092. t['Atilde'] = 667;
  47093. t['Aogonek'] = 667;
  47094. t['Aring'] = 667;
  47095. t['Otilde'] = 722;
  47096. t['zdotaccent'] = 389;
  47097. t['Ecaron'] = 667;
  47098. t['Iogonek'] = 389;
  47099. t['kcommaaccent'] = 500;
  47100. t['minus'] = 606;
  47101. t['Icircumflex'] = 389;
  47102. t['ncaron'] = 556;
  47103. t['tcommaaccent'] = 278;
  47104. t['logicalnot'] = 606;
  47105. t['odieresis'] = 500;
  47106. t['udieresis'] = 556;
  47107. t['notequal'] = 549;
  47108. t['gcommaaccent'] = 500;
  47109. t['eth'] = 500;
  47110. t['zcaron'] = 389;
  47111. t['ncommaaccent'] = 556;
  47112. t['onesuperior'] = 300;
  47113. t['imacron'] = 278;
  47114. t['Euro'] = 500;
  47115. });
  47116. t['Times-Italic'] = getLookupTableFactory(function (t) {
  47117. t['space'] = 250;
  47118. t['exclam'] = 333;
  47119. t['quotedbl'] = 420;
  47120. t['numbersign'] = 500;
  47121. t['dollar'] = 500;
  47122. t['percent'] = 833;
  47123. t['ampersand'] = 778;
  47124. t['quoteright'] = 333;
  47125. t['parenleft'] = 333;
  47126. t['parenright'] = 333;
  47127. t['asterisk'] = 500;
  47128. t['plus'] = 675;
  47129. t['comma'] = 250;
  47130. t['hyphen'] = 333;
  47131. t['period'] = 250;
  47132. t['slash'] = 278;
  47133. t['zero'] = 500;
  47134. t['one'] = 500;
  47135. t['two'] = 500;
  47136. t['three'] = 500;
  47137. t['four'] = 500;
  47138. t['five'] = 500;
  47139. t['six'] = 500;
  47140. t['seven'] = 500;
  47141. t['eight'] = 500;
  47142. t['nine'] = 500;
  47143. t['colon'] = 333;
  47144. t['semicolon'] = 333;
  47145. t['less'] = 675;
  47146. t['equal'] = 675;
  47147. t['greater'] = 675;
  47148. t['question'] = 500;
  47149. t['at'] = 920;
  47150. t['A'] = 611;
  47151. t['B'] = 611;
  47152. t['C'] = 667;
  47153. t['D'] = 722;
  47154. t['E'] = 611;
  47155. t['F'] = 611;
  47156. t['G'] = 722;
  47157. t['H'] = 722;
  47158. t['I'] = 333;
  47159. t['J'] = 444;
  47160. t['K'] = 667;
  47161. t['L'] = 556;
  47162. t['M'] = 833;
  47163. t['N'] = 667;
  47164. t['O'] = 722;
  47165. t['P'] = 611;
  47166. t['Q'] = 722;
  47167. t['R'] = 611;
  47168. t['S'] = 500;
  47169. t['T'] = 556;
  47170. t['U'] = 722;
  47171. t['V'] = 611;
  47172. t['W'] = 833;
  47173. t['X'] = 611;
  47174. t['Y'] = 556;
  47175. t['Z'] = 556;
  47176. t['bracketleft'] = 389;
  47177. t['backslash'] = 278;
  47178. t['bracketright'] = 389;
  47179. t['asciicircum'] = 422;
  47180. t['underscore'] = 500;
  47181. t['quoteleft'] = 333;
  47182. t['a'] = 500;
  47183. t['b'] = 500;
  47184. t['c'] = 444;
  47185. t['d'] = 500;
  47186. t['e'] = 444;
  47187. t['f'] = 278;
  47188. t['g'] = 500;
  47189. t['h'] = 500;
  47190. t['i'] = 278;
  47191. t['j'] = 278;
  47192. t['k'] = 444;
  47193. t['l'] = 278;
  47194. t['m'] = 722;
  47195. t['n'] = 500;
  47196. t['o'] = 500;
  47197. t['p'] = 500;
  47198. t['q'] = 500;
  47199. t['r'] = 389;
  47200. t['s'] = 389;
  47201. t['t'] = 278;
  47202. t['u'] = 500;
  47203. t['v'] = 444;
  47204. t['w'] = 667;
  47205. t['x'] = 444;
  47206. t['y'] = 444;
  47207. t['z'] = 389;
  47208. t['braceleft'] = 400;
  47209. t['bar'] = 275;
  47210. t['braceright'] = 400;
  47211. t['asciitilde'] = 541;
  47212. t['exclamdown'] = 389;
  47213. t['cent'] = 500;
  47214. t['sterling'] = 500;
  47215. t['fraction'] = 167;
  47216. t['yen'] = 500;
  47217. t['florin'] = 500;
  47218. t['section'] = 500;
  47219. t['currency'] = 500;
  47220. t['quotesingle'] = 214;
  47221. t['quotedblleft'] = 556;
  47222. t['guillemotleft'] = 500;
  47223. t['guilsinglleft'] = 333;
  47224. t['guilsinglright'] = 333;
  47225. t['fi'] = 500;
  47226. t['fl'] = 500;
  47227. t['endash'] = 500;
  47228. t['dagger'] = 500;
  47229. t['daggerdbl'] = 500;
  47230. t['periodcentered'] = 250;
  47231. t['paragraph'] = 523;
  47232. t['bullet'] = 350;
  47233. t['quotesinglbase'] = 333;
  47234. t['quotedblbase'] = 556;
  47235. t['quotedblright'] = 556;
  47236. t['guillemotright'] = 500;
  47237. t['ellipsis'] = 889;
  47238. t['perthousand'] = 1000;
  47239. t['questiondown'] = 500;
  47240. t['grave'] = 333;
  47241. t['acute'] = 333;
  47242. t['circumflex'] = 333;
  47243. t['tilde'] = 333;
  47244. t['macron'] = 333;
  47245. t['breve'] = 333;
  47246. t['dotaccent'] = 333;
  47247. t['dieresis'] = 333;
  47248. t['ring'] = 333;
  47249. t['cedilla'] = 333;
  47250. t['hungarumlaut'] = 333;
  47251. t['ogonek'] = 333;
  47252. t['caron'] = 333;
  47253. t['emdash'] = 889;
  47254. t['AE'] = 889;
  47255. t['ordfeminine'] = 276;
  47256. t['Lslash'] = 556;
  47257. t['Oslash'] = 722;
  47258. t['OE'] = 944;
  47259. t['ordmasculine'] = 310;
  47260. t['ae'] = 667;
  47261. t['dotlessi'] = 278;
  47262. t['lslash'] = 278;
  47263. t['oslash'] = 500;
  47264. t['oe'] = 667;
  47265. t['germandbls'] = 500;
  47266. t['Idieresis'] = 333;
  47267. t['eacute'] = 444;
  47268. t['abreve'] = 500;
  47269. t['uhungarumlaut'] = 500;
  47270. t['ecaron'] = 444;
  47271. t['Ydieresis'] = 556;
  47272. t['divide'] = 675;
  47273. t['Yacute'] = 556;
  47274. t['Acircumflex'] = 611;
  47275. t['aacute'] = 500;
  47276. t['Ucircumflex'] = 722;
  47277. t['yacute'] = 444;
  47278. t['scommaaccent'] = 389;
  47279. t['ecircumflex'] = 444;
  47280. t['Uring'] = 722;
  47281. t['Udieresis'] = 722;
  47282. t['aogonek'] = 500;
  47283. t['Uacute'] = 722;
  47284. t['uogonek'] = 500;
  47285. t['Edieresis'] = 611;
  47286. t['Dcroat'] = 722;
  47287. t['commaaccent'] = 250;
  47288. t['copyright'] = 760;
  47289. t['Emacron'] = 611;
  47290. t['ccaron'] = 444;
  47291. t['aring'] = 500;
  47292. t['Ncommaaccent'] = 667;
  47293. t['lacute'] = 278;
  47294. t['agrave'] = 500;
  47295. t['Tcommaaccent'] = 556;
  47296. t['Cacute'] = 667;
  47297. t['atilde'] = 500;
  47298. t['Edotaccent'] = 611;
  47299. t['scaron'] = 389;
  47300. t['scedilla'] = 389;
  47301. t['iacute'] = 278;
  47302. t['lozenge'] = 471;
  47303. t['Rcaron'] = 611;
  47304. t['Gcommaaccent'] = 722;
  47305. t['ucircumflex'] = 500;
  47306. t['acircumflex'] = 500;
  47307. t['Amacron'] = 611;
  47308. t['rcaron'] = 389;
  47309. t['ccedilla'] = 444;
  47310. t['Zdotaccent'] = 556;
  47311. t['Thorn'] = 611;
  47312. t['Omacron'] = 722;
  47313. t['Racute'] = 611;
  47314. t['Sacute'] = 500;
  47315. t['dcaron'] = 544;
  47316. t['Umacron'] = 722;
  47317. t['uring'] = 500;
  47318. t['threesuperior'] = 300;
  47319. t['Ograve'] = 722;
  47320. t['Agrave'] = 611;
  47321. t['Abreve'] = 611;
  47322. t['multiply'] = 675;
  47323. t['uacute'] = 500;
  47324. t['Tcaron'] = 556;
  47325. t['partialdiff'] = 476;
  47326. t['ydieresis'] = 444;
  47327. t['Nacute'] = 667;
  47328. t['icircumflex'] = 278;
  47329. t['Ecircumflex'] = 611;
  47330. t['adieresis'] = 500;
  47331. t['edieresis'] = 444;
  47332. t['cacute'] = 444;
  47333. t['nacute'] = 500;
  47334. t['umacron'] = 500;
  47335. t['Ncaron'] = 667;
  47336. t['Iacute'] = 333;
  47337. t['plusminus'] = 675;
  47338. t['brokenbar'] = 275;
  47339. t['registered'] = 760;
  47340. t['Gbreve'] = 722;
  47341. t['Idotaccent'] = 333;
  47342. t['summation'] = 600;
  47343. t['Egrave'] = 611;
  47344. t['racute'] = 389;
  47345. t['omacron'] = 500;
  47346. t['Zacute'] = 556;
  47347. t['Zcaron'] = 556;
  47348. t['greaterequal'] = 549;
  47349. t['Eth'] = 722;
  47350. t['Ccedilla'] = 667;
  47351. t['lcommaaccent'] = 278;
  47352. t['tcaron'] = 300;
  47353. t['eogonek'] = 444;
  47354. t['Uogonek'] = 722;
  47355. t['Aacute'] = 611;
  47356. t['Adieresis'] = 611;
  47357. t['egrave'] = 444;
  47358. t['zacute'] = 389;
  47359. t['iogonek'] = 278;
  47360. t['Oacute'] = 722;
  47361. t['oacute'] = 500;
  47362. t['amacron'] = 500;
  47363. t['sacute'] = 389;
  47364. t['idieresis'] = 278;
  47365. t['Ocircumflex'] = 722;
  47366. t['Ugrave'] = 722;
  47367. t['Delta'] = 612;
  47368. t['thorn'] = 500;
  47369. t['twosuperior'] = 300;
  47370. t['Odieresis'] = 722;
  47371. t['mu'] = 500;
  47372. t['igrave'] = 278;
  47373. t['ohungarumlaut'] = 500;
  47374. t['Eogonek'] = 611;
  47375. t['dcroat'] = 500;
  47376. t['threequarters'] = 750;
  47377. t['Scedilla'] = 500;
  47378. t['lcaron'] = 300;
  47379. t['Kcommaaccent'] = 667;
  47380. t['Lacute'] = 556;
  47381. t['trademark'] = 980;
  47382. t['edotaccent'] = 444;
  47383. t['Igrave'] = 333;
  47384. t['Imacron'] = 333;
  47385. t['Lcaron'] = 611;
  47386. t['onehalf'] = 750;
  47387. t['lessequal'] = 549;
  47388. t['ocircumflex'] = 500;
  47389. t['ntilde'] = 500;
  47390. t['Uhungarumlaut'] = 722;
  47391. t['Eacute'] = 611;
  47392. t['emacron'] = 444;
  47393. t['gbreve'] = 500;
  47394. t['onequarter'] = 750;
  47395. t['Scaron'] = 500;
  47396. t['Scommaaccent'] = 500;
  47397. t['Ohungarumlaut'] = 722;
  47398. t['degree'] = 400;
  47399. t['ograve'] = 500;
  47400. t['Ccaron'] = 667;
  47401. t['ugrave'] = 500;
  47402. t['radical'] = 453;
  47403. t['Dcaron'] = 722;
  47404. t['rcommaaccent'] = 389;
  47405. t['Ntilde'] = 667;
  47406. t['otilde'] = 500;
  47407. t['Rcommaaccent'] = 611;
  47408. t['Lcommaaccent'] = 556;
  47409. t['Atilde'] = 611;
  47410. t['Aogonek'] = 611;
  47411. t['Aring'] = 611;
  47412. t['Otilde'] = 722;
  47413. t['zdotaccent'] = 389;
  47414. t['Ecaron'] = 611;
  47415. t['Iogonek'] = 333;
  47416. t['kcommaaccent'] = 444;
  47417. t['minus'] = 675;
  47418. t['Icircumflex'] = 333;
  47419. t['ncaron'] = 500;
  47420. t['tcommaaccent'] = 278;
  47421. t['logicalnot'] = 675;
  47422. t['odieresis'] = 500;
  47423. t['udieresis'] = 500;
  47424. t['notequal'] = 549;
  47425. t['gcommaaccent'] = 500;
  47426. t['eth'] = 500;
  47427. t['zcaron'] = 389;
  47428. t['ncommaaccent'] = 500;
  47429. t['onesuperior'] = 300;
  47430. t['imacron'] = 278;
  47431. t['Euro'] = 500;
  47432. });
  47433. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  47434. t['space'] = 278;
  47435. t['a1'] = 974;
  47436. t['a2'] = 961;
  47437. t['a202'] = 974;
  47438. t['a3'] = 980;
  47439. t['a4'] = 719;
  47440. t['a5'] = 789;
  47441. t['a119'] = 790;
  47442. t['a118'] = 791;
  47443. t['a117'] = 690;
  47444. t['a11'] = 960;
  47445. t['a12'] = 939;
  47446. t['a13'] = 549;
  47447. t['a14'] = 855;
  47448. t['a15'] = 911;
  47449. t['a16'] = 933;
  47450. t['a105'] = 911;
  47451. t['a17'] = 945;
  47452. t['a18'] = 974;
  47453. t['a19'] = 755;
  47454. t['a20'] = 846;
  47455. t['a21'] = 762;
  47456. t['a22'] = 761;
  47457. t['a23'] = 571;
  47458. t['a24'] = 677;
  47459. t['a25'] = 763;
  47460. t['a26'] = 760;
  47461. t['a27'] = 759;
  47462. t['a28'] = 754;
  47463. t['a6'] = 494;
  47464. t['a7'] = 552;
  47465. t['a8'] = 537;
  47466. t['a9'] = 577;
  47467. t['a10'] = 692;
  47468. t['a29'] = 786;
  47469. t['a30'] = 788;
  47470. t['a31'] = 788;
  47471. t['a32'] = 790;
  47472. t['a33'] = 793;
  47473. t['a34'] = 794;
  47474. t['a35'] = 816;
  47475. t['a36'] = 823;
  47476. t['a37'] = 789;
  47477. t['a38'] = 841;
  47478. t['a39'] = 823;
  47479. t['a40'] = 833;
  47480. t['a41'] = 816;
  47481. t['a42'] = 831;
  47482. t['a43'] = 923;
  47483. t['a44'] = 744;
  47484. t['a45'] = 723;
  47485. t['a46'] = 749;
  47486. t['a47'] = 790;
  47487. t['a48'] = 792;
  47488. t['a49'] = 695;
  47489. t['a50'] = 776;
  47490. t['a51'] = 768;
  47491. t['a52'] = 792;
  47492. t['a53'] = 759;
  47493. t['a54'] = 707;
  47494. t['a55'] = 708;
  47495. t['a56'] = 682;
  47496. t['a57'] = 701;
  47497. t['a58'] = 826;
  47498. t['a59'] = 815;
  47499. t['a60'] = 789;
  47500. t['a61'] = 789;
  47501. t['a62'] = 707;
  47502. t['a63'] = 687;
  47503. t['a64'] = 696;
  47504. t['a65'] = 689;
  47505. t['a66'] = 786;
  47506. t['a67'] = 787;
  47507. t['a68'] = 713;
  47508. t['a69'] = 791;
  47509. t['a70'] = 785;
  47510. t['a71'] = 791;
  47511. t['a72'] = 873;
  47512. t['a73'] = 761;
  47513. t['a74'] = 762;
  47514. t['a203'] = 762;
  47515. t['a75'] = 759;
  47516. t['a204'] = 759;
  47517. t['a76'] = 892;
  47518. t['a77'] = 892;
  47519. t['a78'] = 788;
  47520. t['a79'] = 784;
  47521. t['a81'] = 438;
  47522. t['a82'] = 138;
  47523. t['a83'] = 277;
  47524. t['a84'] = 415;
  47525. t['a97'] = 392;
  47526. t['a98'] = 392;
  47527. t['a99'] = 668;
  47528. t['a100'] = 668;
  47529. t['a89'] = 390;
  47530. t['a90'] = 390;
  47531. t['a93'] = 317;
  47532. t['a94'] = 317;
  47533. t['a91'] = 276;
  47534. t['a92'] = 276;
  47535. t['a205'] = 509;
  47536. t['a85'] = 509;
  47537. t['a206'] = 410;
  47538. t['a86'] = 410;
  47539. t['a87'] = 234;
  47540. t['a88'] = 234;
  47541. t['a95'] = 334;
  47542. t['a96'] = 334;
  47543. t['a101'] = 732;
  47544. t['a102'] = 544;
  47545. t['a103'] = 544;
  47546. t['a104'] = 910;
  47547. t['a106'] = 667;
  47548. t['a107'] = 760;
  47549. t['a108'] = 760;
  47550. t['a112'] = 776;
  47551. t['a111'] = 595;
  47552. t['a110'] = 694;
  47553. t['a109'] = 626;
  47554. t['a120'] = 788;
  47555. t['a121'] = 788;
  47556. t['a122'] = 788;
  47557. t['a123'] = 788;
  47558. t['a124'] = 788;
  47559. t['a125'] = 788;
  47560. t['a126'] = 788;
  47561. t['a127'] = 788;
  47562. t['a128'] = 788;
  47563. t['a129'] = 788;
  47564. t['a130'] = 788;
  47565. t['a131'] = 788;
  47566. t['a132'] = 788;
  47567. t['a133'] = 788;
  47568. t['a134'] = 788;
  47569. t['a135'] = 788;
  47570. t['a136'] = 788;
  47571. t['a137'] = 788;
  47572. t['a138'] = 788;
  47573. t['a139'] = 788;
  47574. t['a140'] = 788;
  47575. t['a141'] = 788;
  47576. t['a142'] = 788;
  47577. t['a143'] = 788;
  47578. t['a144'] = 788;
  47579. t['a145'] = 788;
  47580. t['a146'] = 788;
  47581. t['a147'] = 788;
  47582. t['a148'] = 788;
  47583. t['a149'] = 788;
  47584. t['a150'] = 788;
  47585. t['a151'] = 788;
  47586. t['a152'] = 788;
  47587. t['a153'] = 788;
  47588. t['a154'] = 788;
  47589. t['a155'] = 788;
  47590. t['a156'] = 788;
  47591. t['a157'] = 788;
  47592. t['a158'] = 788;
  47593. t['a159'] = 788;
  47594. t['a160'] = 894;
  47595. t['a161'] = 838;
  47596. t['a163'] = 1016;
  47597. t['a164'] = 458;
  47598. t['a196'] = 748;
  47599. t['a165'] = 924;
  47600. t['a192'] = 748;
  47601. t['a166'] = 918;
  47602. t['a167'] = 927;
  47603. t['a168'] = 928;
  47604. t['a169'] = 928;
  47605. t['a170'] = 834;
  47606. t['a171'] = 873;
  47607. t['a172'] = 828;
  47608. t['a173'] = 924;
  47609. t['a162'] = 924;
  47610. t['a174'] = 917;
  47611. t['a175'] = 930;
  47612. t['a176'] = 931;
  47613. t['a177'] = 463;
  47614. t['a178'] = 883;
  47615. t['a179'] = 836;
  47616. t['a193'] = 836;
  47617. t['a180'] = 867;
  47618. t['a199'] = 867;
  47619. t['a181'] = 696;
  47620. t['a200'] = 696;
  47621. t['a182'] = 874;
  47622. t['a201'] = 874;
  47623. t['a183'] = 760;
  47624. t['a184'] = 946;
  47625. t['a197'] = 771;
  47626. t['a185'] = 865;
  47627. t['a194'] = 771;
  47628. t['a198'] = 888;
  47629. t['a186'] = 967;
  47630. t['a195'] = 888;
  47631. t['a187'] = 831;
  47632. t['a188'] = 873;
  47633. t['a189'] = 927;
  47634. t['a190'] = 970;
  47635. t['a191'] = 918;
  47636. });
  47637. });
  47638. exports.getMetrics = getMetrics;
  47639. /***/ }),
  47640. /* 31 */
  47641. /***/ (function(module, exports, __w_pdfjs_require__) {
  47642. "use strict";
  47643. var sharedUtil = __w_pdfjs_require__(0);
  47644. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  47645. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  47646. var MASK_HIGH = 0xffff0000;
  47647. var MASK_LOW = 0xffff;
  47648. function MurmurHash3_64(seed) {
  47649. var SEED = 0xc3d2e1f0;
  47650. this.h1 = seed ? seed & 0xffffffff : SEED;
  47651. this.h2 = seed ? seed & 0xffffffff : SEED;
  47652. }
  47653. var alwaysUseUint32ArrayView = false;
  47654. try {
  47655. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  47656. } catch (e) {
  47657. alwaysUseUint32ArrayView = true;
  47658. }
  47659. MurmurHash3_64.prototype = {
  47660. update: function MurmurHash3_64_update(input) {
  47661. var useUint32ArrayView = alwaysUseUint32ArrayView;
  47662. var i;
  47663. if (typeof input === 'string') {
  47664. var data = new Uint8Array(input.length * 2);
  47665. var length = 0;
  47666. for (i = 0; i < input.length; i++) {
  47667. var code = input.charCodeAt(i);
  47668. if (code <= 0xff) {
  47669. data[length++] = code;
  47670. } else {
  47671. data[length++] = code >>> 8;
  47672. data[length++] = code & 0xff;
  47673. }
  47674. }
  47675. } else if (input instanceof Uint8Array) {
  47676. data = input;
  47677. length = data.length;
  47678. } else if (typeof input === 'object' && 'length' in input) {
  47679. data = input;
  47680. length = data.length;
  47681. useUint32ArrayView = true;
  47682. } else {
  47683. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  47684. }
  47685. var blockCounts = length >> 2;
  47686. var tailLength = length - blockCounts * 4;
  47687. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  47688. var k1 = 0;
  47689. var k2 = 0;
  47690. var h1 = this.h1;
  47691. var h2 = this.h2;
  47692. var C1 = 0xcc9e2d51;
  47693. var C2 = 0x1b873593;
  47694. var C1_LOW = C1 & MASK_LOW;
  47695. var C2_LOW = C2 & MASK_LOW;
  47696. for (i = 0; i < blockCounts; i++) {
  47697. if (i & 1) {
  47698. k1 = dataUint32[i];
  47699. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  47700. k1 = k1 << 15 | k1 >>> 17;
  47701. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  47702. h1 ^= k1;
  47703. h1 = h1 << 13 | h1 >>> 19;
  47704. h1 = h1 * 5 + 0xe6546b64;
  47705. } else {
  47706. k2 = dataUint32[i];
  47707. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  47708. k2 = k2 << 15 | k2 >>> 17;
  47709. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  47710. h2 ^= k2;
  47711. h2 = h2 << 13 | h2 >>> 19;
  47712. h2 = h2 * 5 + 0xe6546b64;
  47713. }
  47714. }
  47715. k1 = 0;
  47716. switch (tailLength) {
  47717. case 3:
  47718. k1 ^= data[blockCounts * 4 + 2] << 16;
  47719. case 2:
  47720. k1 ^= data[blockCounts * 4 + 1] << 8;
  47721. case 1:
  47722. k1 ^= data[blockCounts * 4];
  47723. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  47724. k1 = k1 << 15 | k1 >>> 17;
  47725. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  47726. if (blockCounts & 1) {
  47727. h1 ^= k1;
  47728. } else {
  47729. h2 ^= k1;
  47730. }
  47731. }
  47732. this.h1 = h1;
  47733. this.h2 = h2;
  47734. return this;
  47735. },
  47736. hexdigest: function MurmurHash3_64_hexdigest() {
  47737. var h1 = this.h1;
  47738. var h2 = this.h2;
  47739. h1 ^= h2 >>> 1;
  47740. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  47741. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  47742. h1 ^= h2 >>> 1;
  47743. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  47744. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  47745. h1 ^= h2 >>> 1;
  47746. for (var i = 0, arr = [
  47747. h1,
  47748. h2
  47749. ], str = ''; i < arr.length; i++) {
  47750. var hex = (arr[i] >>> 0).toString(16);
  47751. while (hex.length < 8) {
  47752. hex = '0' + hex;
  47753. }
  47754. str += hex;
  47755. }
  47756. return str;
  47757. }
  47758. };
  47759. return MurmurHash3_64;
  47760. }();
  47761. exports.MurmurHash3_64 = MurmurHash3_64;
  47762. /***/ }),
  47763. /* 32 */
  47764. /***/ (function(module, exports, __w_pdfjs_require__) {
  47765. "use strict";
  47766. var sharedUtil = __w_pdfjs_require__(0);
  47767. var corePrimitives = __w_pdfjs_require__(1);
  47768. var coreFunction = __w_pdfjs_require__(6);
  47769. var coreColorSpace = __w_pdfjs_require__(3);
  47770. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  47771. var MissingDataException = sharedUtil.MissingDataException;
  47772. var Util = sharedUtil.Util;
  47773. var assert = sharedUtil.assert;
  47774. var error = sharedUtil.error;
  47775. var info = sharedUtil.info;
  47776. var warn = sharedUtil.warn;
  47777. var isStream = corePrimitives.isStream;
  47778. var PDFFunction = coreFunction.PDFFunction;
  47779. var ColorSpace = coreColorSpace.ColorSpace;
  47780. var ShadingType = {
  47781. FUNCTION_BASED: 1,
  47782. AXIAL: 2,
  47783. RADIAL: 3,
  47784. FREE_FORM_MESH: 4,
  47785. LATTICE_FORM_MESH: 5,
  47786. COONS_PATCH_MESH: 6,
  47787. TENSOR_PATCH_MESH: 7
  47788. };
  47789. var Pattern = function PatternClosure() {
  47790. function Pattern() {
  47791. error('should not call Pattern constructor');
  47792. }
  47793. Pattern.prototype = {
  47794. getPattern: function Pattern_getPattern(ctx) {
  47795. error('Should not call Pattern.getStyle: ' + ctx);
  47796. }
  47797. };
  47798. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  47799. var dict = isStream(shading) ? shading.dict : shading;
  47800. var type = dict.get('ShadingType');
  47801. try {
  47802. switch (type) {
  47803. case ShadingType.AXIAL:
  47804. case ShadingType.RADIAL:
  47805. return new Shadings.RadialAxial(dict, matrix, xref, res);
  47806. case ShadingType.FREE_FORM_MESH:
  47807. case ShadingType.LATTICE_FORM_MESH:
  47808. case ShadingType.COONS_PATCH_MESH:
  47809. case ShadingType.TENSOR_PATCH_MESH:
  47810. return new Shadings.Mesh(shading, matrix, xref, res);
  47811. default:
  47812. throw new Error('Unsupported ShadingType: ' + type);
  47813. }
  47814. } catch (ex) {
  47815. if (ex instanceof MissingDataException) {
  47816. throw ex;
  47817. }
  47818. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  47819. warn(ex);
  47820. return new Shadings.Dummy();
  47821. }
  47822. };
  47823. return Pattern;
  47824. }();
  47825. var Shadings = {};
  47826. Shadings.SMALL_NUMBER = 1e-6;
  47827. Shadings.RadialAxial = function RadialAxialClosure() {
  47828. function RadialAxial(dict, matrix, xref, res) {
  47829. this.matrix = matrix;
  47830. this.coordsArr = dict.getArray('Coords');
  47831. this.shadingType = dict.get('ShadingType');
  47832. this.type = 'Pattern';
  47833. var cs = dict.get('ColorSpace', 'CS');
  47834. cs = ColorSpace.parse(cs, xref, res);
  47835. this.cs = cs;
  47836. var t0 = 0.0, t1 = 1.0;
  47837. if (dict.has('Domain')) {
  47838. var domainArr = dict.getArray('Domain');
  47839. t0 = domainArr[0];
  47840. t1 = domainArr[1];
  47841. }
  47842. var extendStart = false, extendEnd = false;
  47843. if (dict.has('Extend')) {
  47844. var extendArr = dict.getArray('Extend');
  47845. extendStart = extendArr[0];
  47846. extendEnd = extendArr[1];
  47847. }
  47848. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  47849. var x1 = this.coordsArr[0];
  47850. var y1 = this.coordsArr[1];
  47851. var r1 = this.coordsArr[2];
  47852. var x2 = this.coordsArr[3];
  47853. var y2 = this.coordsArr[4];
  47854. var r2 = this.coordsArr[5];
  47855. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  47856. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  47857. warn('Unsupported radial gradient.');
  47858. }
  47859. }
  47860. this.extendStart = extendStart;
  47861. this.extendEnd = extendEnd;
  47862. var fnObj = dict.get('Function');
  47863. var fn = PDFFunction.parseArray(xref, fnObj);
  47864. var diff = t1 - t0;
  47865. var step = diff / 10;
  47866. var colorStops = this.colorStops = [];
  47867. if (t0 >= t1 || step <= 0) {
  47868. info('Bad shading domain.');
  47869. return;
  47870. }
  47871. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  47872. var rgbColor;
  47873. for (var i = t0; i <= t1; i += step) {
  47874. ratio[0] = i;
  47875. fn(ratio, 0, color, 0);
  47876. rgbColor = cs.getRgb(color, 0);
  47877. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  47878. colorStops.push([
  47879. (i - t0) / diff,
  47880. cssColor
  47881. ]);
  47882. }
  47883. var background = 'transparent';
  47884. if (dict.has('Background')) {
  47885. rgbColor = cs.getRgb(dict.get('Background'), 0);
  47886. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  47887. }
  47888. if (!extendStart) {
  47889. colorStops.unshift([
  47890. 0,
  47891. background
  47892. ]);
  47893. colorStops[1][0] += Shadings.SMALL_NUMBER;
  47894. }
  47895. if (!extendEnd) {
  47896. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  47897. colorStops.push([
  47898. 1,
  47899. background
  47900. ]);
  47901. }
  47902. this.colorStops = colorStops;
  47903. }
  47904. RadialAxial.prototype = {
  47905. getIR: function RadialAxial_getIR() {
  47906. var coordsArr = this.coordsArr;
  47907. var shadingType = this.shadingType;
  47908. var type, p0, p1, r0, r1;
  47909. if (shadingType === ShadingType.AXIAL) {
  47910. p0 = [
  47911. coordsArr[0],
  47912. coordsArr[1]
  47913. ];
  47914. p1 = [
  47915. coordsArr[2],
  47916. coordsArr[3]
  47917. ];
  47918. r0 = null;
  47919. r1 = null;
  47920. type = 'axial';
  47921. } else if (shadingType === ShadingType.RADIAL) {
  47922. p0 = [
  47923. coordsArr[0],
  47924. coordsArr[1]
  47925. ];
  47926. p1 = [
  47927. coordsArr[3],
  47928. coordsArr[4]
  47929. ];
  47930. r0 = coordsArr[2];
  47931. r1 = coordsArr[5];
  47932. type = 'radial';
  47933. } else {
  47934. error('getPattern type unknown: ' + shadingType);
  47935. }
  47936. var matrix = this.matrix;
  47937. if (matrix) {
  47938. p0 = Util.applyTransform(p0, matrix);
  47939. p1 = Util.applyTransform(p1, matrix);
  47940. if (shadingType === ShadingType.RADIAL) {
  47941. var scale = Util.singularValueDecompose2dScale(matrix);
  47942. r0 *= scale[0];
  47943. r1 *= scale[1];
  47944. }
  47945. }
  47946. return [
  47947. 'RadialAxial',
  47948. type,
  47949. this.colorStops,
  47950. p0,
  47951. p1,
  47952. r0,
  47953. r1
  47954. ];
  47955. }
  47956. };
  47957. return RadialAxial;
  47958. }();
  47959. Shadings.Mesh = function MeshClosure() {
  47960. function MeshStreamReader(stream, context) {
  47961. this.stream = stream;
  47962. this.context = context;
  47963. this.buffer = 0;
  47964. this.bufferLength = 0;
  47965. var numComps = context.numComps;
  47966. this.tmpCompsBuf = new Float32Array(numComps);
  47967. var csNumComps = context.colorSpace.numComps;
  47968. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  47969. }
  47970. MeshStreamReader.prototype = {
  47971. get hasData() {
  47972. if (this.stream.end) {
  47973. return this.stream.pos < this.stream.end;
  47974. }
  47975. if (this.bufferLength > 0) {
  47976. return true;
  47977. }
  47978. var nextByte = this.stream.getByte();
  47979. if (nextByte < 0) {
  47980. return false;
  47981. }
  47982. this.buffer = nextByte;
  47983. this.bufferLength = 8;
  47984. return true;
  47985. },
  47986. readBits: function MeshStreamReader_readBits(n) {
  47987. var buffer = this.buffer;
  47988. var bufferLength = this.bufferLength;
  47989. if (n === 32) {
  47990. if (bufferLength === 0) {
  47991. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  47992. }
  47993. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  47994. var nextByte = this.stream.getByte();
  47995. this.buffer = nextByte & (1 << bufferLength) - 1;
  47996. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  47997. }
  47998. if (n === 8 && bufferLength === 0) {
  47999. return this.stream.getByte();
  48000. }
  48001. while (bufferLength < n) {
  48002. buffer = buffer << 8 | this.stream.getByte();
  48003. bufferLength += 8;
  48004. }
  48005. bufferLength -= n;
  48006. this.bufferLength = bufferLength;
  48007. this.buffer = buffer & (1 << bufferLength) - 1;
  48008. return buffer >> bufferLength;
  48009. },
  48010. align: function MeshStreamReader_align() {
  48011. this.buffer = 0;
  48012. this.bufferLength = 0;
  48013. },
  48014. readFlag: function MeshStreamReader_readFlag() {
  48015. return this.readBits(this.context.bitsPerFlag);
  48016. },
  48017. readCoordinate: function MeshStreamReader_readCoordinate() {
  48018. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  48019. var xi = this.readBits(bitsPerCoordinate);
  48020. var yi = this.readBits(bitsPerCoordinate);
  48021. var decode = this.context.decode;
  48022. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  48023. return [
  48024. xi * scale * (decode[1] - decode[0]) + decode[0],
  48025. yi * scale * (decode[3] - decode[2]) + decode[2]
  48026. ];
  48027. },
  48028. readComponents: function MeshStreamReader_readComponents() {
  48029. var numComps = this.context.numComps;
  48030. var bitsPerComponent = this.context.bitsPerComponent;
  48031. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  48032. var decode = this.context.decode;
  48033. var components = this.tmpCompsBuf;
  48034. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  48035. var ci = this.readBits(bitsPerComponent);
  48036. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  48037. }
  48038. var color = this.tmpCsCompsBuf;
  48039. if (this.context.colorFn) {
  48040. this.context.colorFn(components, 0, color, 0);
  48041. }
  48042. return this.context.colorSpace.getRgb(color, 0);
  48043. }
  48044. };
  48045. function decodeType4Shading(mesh, reader) {
  48046. var coords = mesh.coords;
  48047. var colors = mesh.colors;
  48048. var operators = [];
  48049. var ps = [];
  48050. var verticesLeft = 0;
  48051. while (reader.hasData) {
  48052. var f = reader.readFlag();
  48053. var coord = reader.readCoordinate();
  48054. var color = reader.readComponents();
  48055. if (verticesLeft === 0) {
  48056. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  48057. switch (f) {
  48058. case 0:
  48059. verticesLeft = 3;
  48060. break;
  48061. case 1:
  48062. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  48063. verticesLeft = 1;
  48064. break;
  48065. case 2:
  48066. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  48067. verticesLeft = 1;
  48068. break;
  48069. }
  48070. operators.push(f);
  48071. }
  48072. ps.push(coords.length);
  48073. coords.push(coord);
  48074. colors.push(color);
  48075. verticesLeft--;
  48076. reader.align();
  48077. }
  48078. mesh.figures.push({
  48079. type: 'triangles',
  48080. coords: new Int32Array(ps),
  48081. colors: new Int32Array(ps)
  48082. });
  48083. }
  48084. function decodeType5Shading(mesh, reader, verticesPerRow) {
  48085. var coords = mesh.coords;
  48086. var colors = mesh.colors;
  48087. var ps = [];
  48088. while (reader.hasData) {
  48089. var coord = reader.readCoordinate();
  48090. var color = reader.readComponents();
  48091. ps.push(coords.length);
  48092. coords.push(coord);
  48093. colors.push(color);
  48094. }
  48095. mesh.figures.push({
  48096. type: 'lattice',
  48097. coords: new Int32Array(ps),
  48098. colors: new Int32Array(ps),
  48099. verticesPerRow: verticesPerRow
  48100. });
  48101. }
  48102. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  48103. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  48104. var TRIANGLE_DENSITY = 20;
  48105. var getB = function getBClosure() {
  48106. function buildB(count) {
  48107. var lut = [];
  48108. for (var i = 0; i <= count; i++) {
  48109. var t = i / count, t_ = 1 - t;
  48110. lut.push(new Float32Array([
  48111. t_ * t_ * t_,
  48112. 3 * t * t_ * t_,
  48113. 3 * t * t * t_,
  48114. t * t * t
  48115. ]));
  48116. }
  48117. return lut;
  48118. }
  48119. var cache = [];
  48120. return function getB(count) {
  48121. if (!cache[count]) {
  48122. cache[count] = buildB(count);
  48123. }
  48124. return cache[count];
  48125. };
  48126. }();
  48127. function buildFigureFromPatch(mesh, index) {
  48128. var figure = mesh.figures[index];
  48129. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  48130. var coords = mesh.coords, colors = mesh.colors;
  48131. var pi = figure.coords;
  48132. var ci = figure.colors;
  48133. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  48134. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  48135. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  48136. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  48137. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  48138. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  48139. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  48140. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  48141. var verticesPerRow = splitXBy + 1;
  48142. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  48143. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  48144. var k = 0;
  48145. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  48146. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  48147. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  48148. for (var row = 0; row <= splitYBy; row++) {
  48149. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  48150. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  48151. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  48152. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  48153. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  48154. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  48155. for (var col = 0; col <= splitXBy; col++, k++) {
  48156. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  48157. continue;
  48158. }
  48159. var x = 0, y = 0;
  48160. var q = 0;
  48161. for (var i = 0; i <= 3; i++) {
  48162. for (var j = 0; j <= 3; j++, q++) {
  48163. var m = bRow[row][i] * bCol[col][j];
  48164. x += coords[pi[q]][0] * m;
  48165. y += coords[pi[q]][1] * m;
  48166. }
  48167. }
  48168. figureCoords[k] = coords.length;
  48169. coords.push([
  48170. x,
  48171. y
  48172. ]);
  48173. figureColors[k] = colors.length;
  48174. var newColor = new Uint8Array(3);
  48175. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  48176. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  48177. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  48178. colors.push(newColor);
  48179. }
  48180. }
  48181. figureCoords[0] = pi[0];
  48182. figureColors[0] = ci[0];
  48183. figureCoords[splitXBy] = pi[3];
  48184. figureColors[splitXBy] = ci[1];
  48185. figureCoords[verticesPerRow * splitYBy] = pi[12];
  48186. figureColors[verticesPerRow * splitYBy] = ci[2];
  48187. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  48188. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  48189. mesh.figures[index] = {
  48190. type: 'lattice',
  48191. coords: figureCoords,
  48192. colors: figureColors,
  48193. verticesPerRow: verticesPerRow
  48194. };
  48195. }
  48196. function decodeType6Shading(mesh, reader) {
  48197. var coords = mesh.coords;
  48198. var colors = mesh.colors;
  48199. var ps = new Int32Array(16);
  48200. var cs = new Int32Array(4);
  48201. while (reader.hasData) {
  48202. var f = reader.readFlag();
  48203. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  48204. var i, ii;
  48205. var pi = coords.length;
  48206. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  48207. coords.push(reader.readCoordinate());
  48208. }
  48209. var ci = colors.length;
  48210. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  48211. colors.push(reader.readComponents());
  48212. }
  48213. var tmp1, tmp2, tmp3, tmp4;
  48214. switch (f) {
  48215. case 0:
  48216. ps[12] = pi + 3;
  48217. ps[13] = pi + 4;
  48218. ps[14] = pi + 5;
  48219. ps[15] = pi + 6;
  48220. ps[8] = pi + 2;
  48221. ps[11] = pi + 7;
  48222. ps[4] = pi + 1;
  48223. ps[7] = pi + 8;
  48224. ps[0] = pi;
  48225. ps[1] = pi + 11;
  48226. ps[2] = pi + 10;
  48227. ps[3] = pi + 9;
  48228. cs[2] = ci + 1;
  48229. cs[3] = ci + 2;
  48230. cs[0] = ci;
  48231. cs[1] = ci + 3;
  48232. break;
  48233. case 1:
  48234. tmp1 = ps[12];
  48235. tmp2 = ps[13];
  48236. tmp3 = ps[14];
  48237. tmp4 = ps[15];
  48238. ps[12] = tmp4;
  48239. ps[13] = pi + 0;
  48240. ps[14] = pi + 1;
  48241. ps[15] = pi + 2;
  48242. ps[8] = tmp3;
  48243. ps[11] = pi + 3;
  48244. ps[4] = tmp2;
  48245. ps[7] = pi + 4;
  48246. ps[0] = tmp1;
  48247. ps[1] = pi + 7;
  48248. ps[2] = pi + 6;
  48249. ps[3] = pi + 5;
  48250. tmp1 = cs[2];
  48251. tmp2 = cs[3];
  48252. cs[2] = tmp2;
  48253. cs[3] = ci;
  48254. cs[0] = tmp1;
  48255. cs[1] = ci + 1;
  48256. break;
  48257. case 2:
  48258. tmp1 = ps[15];
  48259. tmp2 = ps[11];
  48260. ps[12] = ps[3];
  48261. ps[13] = pi + 0;
  48262. ps[14] = pi + 1;
  48263. ps[15] = pi + 2;
  48264. ps[8] = ps[7];
  48265. ps[11] = pi + 3;
  48266. ps[4] = tmp2;
  48267. ps[7] = pi + 4;
  48268. ps[0] = tmp1;
  48269. ps[1] = pi + 7;
  48270. ps[2] = pi + 6;
  48271. ps[3] = pi + 5;
  48272. tmp1 = cs[3];
  48273. cs[2] = cs[1];
  48274. cs[3] = ci;
  48275. cs[0] = tmp1;
  48276. cs[1] = ci + 1;
  48277. break;
  48278. case 3:
  48279. ps[12] = ps[0];
  48280. ps[13] = pi + 0;
  48281. ps[14] = pi + 1;
  48282. ps[15] = pi + 2;
  48283. ps[8] = ps[1];
  48284. ps[11] = pi + 3;
  48285. ps[4] = ps[2];
  48286. ps[7] = pi + 4;
  48287. ps[0] = ps[3];
  48288. ps[1] = pi + 7;
  48289. ps[2] = pi + 6;
  48290. ps[3] = pi + 5;
  48291. cs[2] = cs[0];
  48292. cs[3] = ci;
  48293. cs[0] = cs[1];
  48294. cs[1] = ci + 1;
  48295. break;
  48296. }
  48297. ps[5] = coords.length;
  48298. coords.push([
  48299. (-4 * coords[ps[0]][0] - coords[ps[15]][0] + 6 * (coords[ps[4]][0] + coords[ps[1]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[13]][0] + coords[ps[7]][0])) / 9,
  48300. (-4 * coords[ps[0]][1] - coords[ps[15]][1] + 6 * (coords[ps[4]][1] + coords[ps[1]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[13]][1] + coords[ps[7]][1])) / 9
  48301. ]);
  48302. ps[6] = coords.length;
  48303. coords.push([
  48304. (-4 * coords[ps[3]][0] - coords[ps[12]][0] + 6 * (coords[ps[2]][0] + coords[ps[7]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[4]][0] + coords[ps[14]][0])) / 9,
  48305. (-4 * coords[ps[3]][1] - coords[ps[12]][1] + 6 * (coords[ps[2]][1] + coords[ps[7]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[4]][1] + coords[ps[14]][1])) / 9
  48306. ]);
  48307. ps[9] = coords.length;
  48308. coords.push([
  48309. (-4 * coords[ps[12]][0] - coords[ps[3]][0] + 6 * (coords[ps[8]][0] + coords[ps[13]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[11]][0] + coords[ps[1]][0])) / 9,
  48310. (-4 * coords[ps[12]][1] - coords[ps[3]][1] + 6 * (coords[ps[8]][1] + coords[ps[13]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[11]][1] + coords[ps[1]][1])) / 9
  48311. ]);
  48312. ps[10] = coords.length;
  48313. coords.push([
  48314. (-4 * coords[ps[15]][0] - coords[ps[0]][0] + 6 * (coords[ps[11]][0] + coords[ps[14]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[2]][0] + coords[ps[8]][0])) / 9,
  48315. (-4 * coords[ps[15]][1] - coords[ps[0]][1] + 6 * (coords[ps[11]][1] + coords[ps[14]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[2]][1] + coords[ps[8]][1])) / 9
  48316. ]);
  48317. mesh.figures.push({
  48318. type: 'patch',
  48319. coords: new Int32Array(ps),
  48320. colors: new Int32Array(cs)
  48321. });
  48322. }
  48323. }
  48324. function decodeType7Shading(mesh, reader) {
  48325. var coords = mesh.coords;
  48326. var colors = mesh.colors;
  48327. var ps = new Int32Array(16);
  48328. var cs = new Int32Array(4);
  48329. while (reader.hasData) {
  48330. var f = reader.readFlag();
  48331. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  48332. var i, ii;
  48333. var pi = coords.length;
  48334. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  48335. coords.push(reader.readCoordinate());
  48336. }
  48337. var ci = colors.length;
  48338. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  48339. colors.push(reader.readComponents());
  48340. }
  48341. var tmp1, tmp2, tmp3, tmp4;
  48342. switch (f) {
  48343. case 0:
  48344. ps[12] = pi + 3;
  48345. ps[13] = pi + 4;
  48346. ps[14] = pi + 5;
  48347. ps[15] = pi + 6;
  48348. ps[8] = pi + 2;
  48349. ps[9] = pi + 13;
  48350. ps[10] = pi + 14;
  48351. ps[11] = pi + 7;
  48352. ps[4] = pi + 1;
  48353. ps[5] = pi + 12;
  48354. ps[6] = pi + 15;
  48355. ps[7] = pi + 8;
  48356. ps[0] = pi;
  48357. ps[1] = pi + 11;
  48358. ps[2] = pi + 10;
  48359. ps[3] = pi + 9;
  48360. cs[2] = ci + 1;
  48361. cs[3] = ci + 2;
  48362. cs[0] = ci;
  48363. cs[1] = ci + 3;
  48364. break;
  48365. case 1:
  48366. tmp1 = ps[12];
  48367. tmp2 = ps[13];
  48368. tmp3 = ps[14];
  48369. tmp4 = ps[15];
  48370. ps[12] = tmp4;
  48371. ps[13] = pi + 0;
  48372. ps[14] = pi + 1;
  48373. ps[15] = pi + 2;
  48374. ps[8] = tmp3;
  48375. ps[9] = pi + 9;
  48376. ps[10] = pi + 10;
  48377. ps[11] = pi + 3;
  48378. ps[4] = tmp2;
  48379. ps[5] = pi + 8;
  48380. ps[6] = pi + 11;
  48381. ps[7] = pi + 4;
  48382. ps[0] = tmp1;
  48383. ps[1] = pi + 7;
  48384. ps[2] = pi + 6;
  48385. ps[3] = pi + 5;
  48386. tmp1 = cs[2];
  48387. tmp2 = cs[3];
  48388. cs[2] = tmp2;
  48389. cs[3] = ci;
  48390. cs[0] = tmp1;
  48391. cs[1] = ci + 1;
  48392. break;
  48393. case 2:
  48394. tmp1 = ps[15];
  48395. tmp2 = ps[11];
  48396. ps[12] = ps[3];
  48397. ps[13] = pi + 0;
  48398. ps[14] = pi + 1;
  48399. ps[15] = pi + 2;
  48400. ps[8] = ps[7];
  48401. ps[9] = pi + 9;
  48402. ps[10] = pi + 10;
  48403. ps[11] = pi + 3;
  48404. ps[4] = tmp2;
  48405. ps[5] = pi + 8;
  48406. ps[6] = pi + 11;
  48407. ps[7] = pi + 4;
  48408. ps[0] = tmp1;
  48409. ps[1] = pi + 7;
  48410. ps[2] = pi + 6;
  48411. ps[3] = pi + 5;
  48412. tmp1 = cs[3];
  48413. cs[2] = cs[1];
  48414. cs[3] = ci;
  48415. cs[0] = tmp1;
  48416. cs[1] = ci + 1;
  48417. break;
  48418. case 3:
  48419. ps[12] = ps[0];
  48420. ps[13] = pi + 0;
  48421. ps[14] = pi + 1;
  48422. ps[15] = pi + 2;
  48423. ps[8] = ps[1];
  48424. ps[9] = pi + 9;
  48425. ps[10] = pi + 10;
  48426. ps[11] = pi + 3;
  48427. ps[4] = ps[2];
  48428. ps[5] = pi + 8;
  48429. ps[6] = pi + 11;
  48430. ps[7] = pi + 4;
  48431. ps[0] = ps[3];
  48432. ps[1] = pi + 7;
  48433. ps[2] = pi + 6;
  48434. ps[3] = pi + 5;
  48435. cs[2] = cs[0];
  48436. cs[3] = ci;
  48437. cs[0] = cs[1];
  48438. cs[1] = ci + 1;
  48439. break;
  48440. }
  48441. mesh.figures.push({
  48442. type: 'patch',
  48443. coords: new Int32Array(ps),
  48444. colors: new Int32Array(cs)
  48445. });
  48446. }
  48447. }
  48448. function updateBounds(mesh) {
  48449. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  48450. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  48451. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  48452. minX = minX > x ? x : minX;
  48453. minY = minY > y ? y : minY;
  48454. maxX = maxX < x ? x : maxX;
  48455. maxY = maxY < y ? y : maxY;
  48456. }
  48457. mesh.bounds = [
  48458. minX,
  48459. minY,
  48460. maxX,
  48461. maxY
  48462. ];
  48463. }
  48464. function packData(mesh) {
  48465. var i, ii, j, jj;
  48466. var coords = mesh.coords;
  48467. var coordsPacked = new Float32Array(coords.length * 2);
  48468. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  48469. var xy = coords[i];
  48470. coordsPacked[j++] = xy[0];
  48471. coordsPacked[j++] = xy[1];
  48472. }
  48473. mesh.coords = coordsPacked;
  48474. var colors = mesh.colors;
  48475. var colorsPacked = new Uint8Array(colors.length * 3);
  48476. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  48477. var c = colors[i];
  48478. colorsPacked[j++] = c[0];
  48479. colorsPacked[j++] = c[1];
  48480. colorsPacked[j++] = c[2];
  48481. }
  48482. mesh.colors = colorsPacked;
  48483. var figures = mesh.figures;
  48484. for (i = 0, ii = figures.length; i < ii; i++) {
  48485. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  48486. for (j = 0, jj = ps.length; j < jj; j++) {
  48487. ps[j] *= 2;
  48488. cs[j] *= 3;
  48489. }
  48490. }
  48491. }
  48492. function Mesh(stream, matrix, xref, res) {
  48493. assert(isStream(stream), 'Mesh data is not a stream');
  48494. var dict = stream.dict;
  48495. this.matrix = matrix;
  48496. this.shadingType = dict.get('ShadingType');
  48497. this.type = 'Pattern';
  48498. this.bbox = dict.getArray('BBox');
  48499. var cs = dict.get('ColorSpace', 'CS');
  48500. cs = ColorSpace.parse(cs, xref, res);
  48501. this.cs = cs;
  48502. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  48503. var fnObj = dict.get('Function');
  48504. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  48505. this.coords = [];
  48506. this.colors = [];
  48507. this.figures = [];
  48508. var decodeContext = {
  48509. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  48510. bitsPerComponent: dict.get('BitsPerComponent'),
  48511. bitsPerFlag: dict.get('BitsPerFlag'),
  48512. decode: dict.getArray('Decode'),
  48513. colorFn: fn,
  48514. colorSpace: cs,
  48515. numComps: fn ? 1 : cs.numComps
  48516. };
  48517. var reader = new MeshStreamReader(stream, decodeContext);
  48518. var patchMesh = false;
  48519. switch (this.shadingType) {
  48520. case ShadingType.FREE_FORM_MESH:
  48521. decodeType4Shading(this, reader);
  48522. break;
  48523. case ShadingType.LATTICE_FORM_MESH:
  48524. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  48525. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  48526. decodeType5Shading(this, reader, verticesPerRow);
  48527. break;
  48528. case ShadingType.COONS_PATCH_MESH:
  48529. decodeType6Shading(this, reader);
  48530. patchMesh = true;
  48531. break;
  48532. case ShadingType.TENSOR_PATCH_MESH:
  48533. decodeType7Shading(this, reader);
  48534. patchMesh = true;
  48535. break;
  48536. default:
  48537. error('Unsupported mesh type.');
  48538. break;
  48539. }
  48540. if (patchMesh) {
  48541. updateBounds(this);
  48542. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  48543. buildFigureFromPatch(this, i);
  48544. }
  48545. }
  48546. updateBounds(this);
  48547. packData(this);
  48548. }
  48549. Mesh.prototype = {
  48550. getIR: function Mesh_getIR() {
  48551. return [
  48552. 'Mesh',
  48553. this.shadingType,
  48554. this.coords,
  48555. this.colors,
  48556. this.figures,
  48557. this.bounds,
  48558. this.matrix,
  48559. this.bbox,
  48560. this.background
  48561. ];
  48562. }
  48563. };
  48564. return Mesh;
  48565. }();
  48566. Shadings.Dummy = function DummyClosure() {
  48567. function Dummy() {
  48568. this.type = 'Pattern';
  48569. }
  48570. Dummy.prototype = {
  48571. getIR: function Dummy_getIR() {
  48572. return ['Dummy'];
  48573. }
  48574. };
  48575. return Dummy;
  48576. }();
  48577. function getTilingPatternIR(operatorList, dict, args) {
  48578. var matrix = dict.getArray('Matrix');
  48579. var bbox = dict.getArray('BBox');
  48580. var xstep = dict.get('XStep');
  48581. var ystep = dict.get('YStep');
  48582. var paintType = dict.get('PaintType');
  48583. var tilingType = dict.get('TilingType');
  48584. return [
  48585. 'TilingPattern',
  48586. args,
  48587. operatorList,
  48588. matrix,
  48589. bbox,
  48590. xstep,
  48591. ystep,
  48592. paintType,
  48593. tilingType
  48594. ];
  48595. }
  48596. exports.Pattern = Pattern;
  48597. exports.getTilingPatternIR = getTilingPatternIR;
  48598. /***/ }),
  48599. /* 33 */
  48600. /***/ (function(module, exports, __w_pdfjs_require__) {
  48601. "use strict";
  48602. var sharedUtil = __w_pdfjs_require__(0);
  48603. var coreStream = __w_pdfjs_require__(2);
  48604. var coreChunkedStream = __w_pdfjs_require__(12);
  48605. var coreDocument = __w_pdfjs_require__(24);
  48606. var warn = sharedUtil.warn;
  48607. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  48608. var shadow = sharedUtil.shadow;
  48609. var NotImplementedException = sharedUtil.NotImplementedException;
  48610. var MissingDataException = sharedUtil.MissingDataException;
  48611. var createPromiseCapability = sharedUtil.createPromiseCapability;
  48612. var Util = sharedUtil.Util;
  48613. var Stream = coreStream.Stream;
  48614. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  48615. var PDFDocument = coreDocument.PDFDocument;
  48616. var BasePdfManager = function BasePdfManagerClosure() {
  48617. function BasePdfManager() {
  48618. throw new Error('Cannot initialize BaseManagerManager');
  48619. }
  48620. BasePdfManager.prototype = {
  48621. get docId() {
  48622. return this._docId;
  48623. },
  48624. get password() {
  48625. return this._password;
  48626. },
  48627. get docBaseUrl() {
  48628. var docBaseUrl = null;
  48629. if (this._docBaseUrl) {
  48630. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  48631. if (absoluteUrl) {
  48632. docBaseUrl = absoluteUrl.href;
  48633. } else {
  48634. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  48635. }
  48636. }
  48637. return shadow(this, 'docBaseUrl', docBaseUrl);
  48638. },
  48639. onLoadedStream: function BasePdfManager_onLoadedStream() {
  48640. throw new NotImplementedException();
  48641. },
  48642. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  48643. return this.ensure(this.pdfDocument, prop, args);
  48644. },
  48645. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  48646. return this.ensure(this.pdfDocument.xref, prop, args);
  48647. },
  48648. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  48649. return this.ensure(this.pdfDocument.catalog, prop, args);
  48650. },
  48651. getPage: function BasePdfManager_getPage(pageIndex) {
  48652. return this.pdfDocument.getPage(pageIndex);
  48653. },
  48654. cleanup: function BasePdfManager_cleanup() {
  48655. return this.pdfDocument.cleanup();
  48656. },
  48657. ensure: function BasePdfManager_ensure(obj, prop, args) {
  48658. return new NotImplementedException();
  48659. },
  48660. requestRange: function BasePdfManager_requestRange(begin, end) {
  48661. return new NotImplementedException();
  48662. },
  48663. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  48664. return new NotImplementedException();
  48665. },
  48666. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  48667. return new NotImplementedException();
  48668. },
  48669. updatePassword: function BasePdfManager_updatePassword(password) {
  48670. this._password = password;
  48671. },
  48672. terminate: function BasePdfManager_terminate() {
  48673. return new NotImplementedException();
  48674. }
  48675. };
  48676. return BasePdfManager;
  48677. }();
  48678. var LocalPdfManager = function LocalPdfManagerClosure() {
  48679. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  48680. this._docId = docId;
  48681. this._password = password;
  48682. this._docBaseUrl = docBaseUrl;
  48683. this.evaluatorOptions = evaluatorOptions;
  48684. var stream = new Stream(data);
  48685. this.pdfDocument = new PDFDocument(this, stream);
  48686. this._loadedStreamCapability = createPromiseCapability();
  48687. this._loadedStreamCapability.resolve(stream);
  48688. }
  48689. Util.inherit(LocalPdfManager, BasePdfManager, {
  48690. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  48691. return new Promise(function (resolve, reject) {
  48692. try {
  48693. var value = obj[prop];
  48694. var result;
  48695. if (typeof value === 'function') {
  48696. result = value.apply(obj, args);
  48697. } else {
  48698. result = value;
  48699. }
  48700. resolve(result);
  48701. } catch (e) {
  48702. reject(e);
  48703. }
  48704. });
  48705. },
  48706. requestRange: function LocalPdfManager_requestRange(begin, end) {
  48707. return Promise.resolve();
  48708. },
  48709. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  48710. },
  48711. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  48712. return this._loadedStreamCapability.promise;
  48713. },
  48714. terminate: function LocalPdfManager_terminate() {
  48715. }
  48716. });
  48717. return LocalPdfManager;
  48718. }();
  48719. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  48720. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  48721. this._docId = docId;
  48722. this._password = args.password;
  48723. this._docBaseUrl = docBaseUrl;
  48724. this.msgHandler = args.msgHandler;
  48725. this.evaluatorOptions = evaluatorOptions;
  48726. var params = {
  48727. msgHandler: args.msgHandler,
  48728. url: args.url,
  48729. length: args.length,
  48730. disableAutoFetch: args.disableAutoFetch,
  48731. rangeChunkSize: args.rangeChunkSize
  48732. };
  48733. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  48734. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  48735. }
  48736. Util.inherit(NetworkPdfManager, BasePdfManager, {
  48737. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  48738. var pdfManager = this;
  48739. return new Promise(function (resolve, reject) {
  48740. function ensureHelper() {
  48741. try {
  48742. var result;
  48743. var value = obj[prop];
  48744. if (typeof value === 'function') {
  48745. result = value.apply(obj, args);
  48746. } else {
  48747. result = value;
  48748. }
  48749. resolve(result);
  48750. } catch (e) {
  48751. if (!(e instanceof MissingDataException)) {
  48752. reject(e);
  48753. return;
  48754. }
  48755. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  48756. }
  48757. }
  48758. ensureHelper();
  48759. });
  48760. },
  48761. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  48762. return this.streamManager.requestRange(begin, end);
  48763. },
  48764. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  48765. this.streamManager.requestAllChunks();
  48766. },
  48767. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  48768. this.streamManager.onReceiveData({ chunk: chunk });
  48769. },
  48770. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  48771. return this.streamManager.onLoadedStream();
  48772. },
  48773. terminate: function NetworkPdfManager_terminate() {
  48774. this.streamManager.abort();
  48775. }
  48776. });
  48777. return NetworkPdfManager;
  48778. }();
  48779. exports.LocalPdfManager = LocalPdfManager;
  48780. exports.NetworkPdfManager = NetworkPdfManager;
  48781. /***/ }),
  48782. /* 34 */
  48783. /***/ (function(module, exports, __w_pdfjs_require__) {
  48784. "use strict";
  48785. var sharedUtil = __w_pdfjs_require__(0);
  48786. var corePrimitives = __w_pdfjs_require__(1);
  48787. var error = sharedUtil.error;
  48788. var isSpace = sharedUtil.isSpace;
  48789. var EOF = corePrimitives.EOF;
  48790. var PostScriptParser = function PostScriptParserClosure() {
  48791. function PostScriptParser(lexer) {
  48792. this.lexer = lexer;
  48793. this.operators = [];
  48794. this.token = null;
  48795. this.prev = null;
  48796. }
  48797. PostScriptParser.prototype = {
  48798. nextToken: function PostScriptParser_nextToken() {
  48799. this.prev = this.token;
  48800. this.token = this.lexer.getToken();
  48801. },
  48802. accept: function PostScriptParser_accept(type) {
  48803. if (this.token.type === type) {
  48804. this.nextToken();
  48805. return true;
  48806. }
  48807. return false;
  48808. },
  48809. expect: function PostScriptParser_expect(type) {
  48810. if (this.accept(type)) {
  48811. return true;
  48812. }
  48813. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  48814. },
  48815. parse: function PostScriptParser_parse() {
  48816. this.nextToken();
  48817. this.expect(PostScriptTokenTypes.LBRACE);
  48818. this.parseBlock();
  48819. this.expect(PostScriptTokenTypes.RBRACE);
  48820. return this.operators;
  48821. },
  48822. parseBlock: function PostScriptParser_parseBlock() {
  48823. while (true) {
  48824. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  48825. this.operators.push(this.prev.value);
  48826. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  48827. this.operators.push(this.prev.value);
  48828. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  48829. this.parseCondition();
  48830. } else {
  48831. return;
  48832. }
  48833. }
  48834. },
  48835. parseCondition: function PostScriptParser_parseCondition() {
  48836. var conditionLocation = this.operators.length;
  48837. this.operators.push(null, null);
  48838. this.parseBlock();
  48839. this.expect(PostScriptTokenTypes.RBRACE);
  48840. if (this.accept(PostScriptTokenTypes.IF)) {
  48841. this.operators[conditionLocation] = this.operators.length;
  48842. this.operators[conditionLocation + 1] = 'jz';
  48843. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  48844. var jumpLocation = this.operators.length;
  48845. this.operators.push(null, null);
  48846. var endOfTrue = this.operators.length;
  48847. this.parseBlock();
  48848. this.expect(PostScriptTokenTypes.RBRACE);
  48849. this.expect(PostScriptTokenTypes.IFELSE);
  48850. this.operators[jumpLocation] = this.operators.length;
  48851. this.operators[jumpLocation + 1] = 'j';
  48852. this.operators[conditionLocation] = endOfTrue;
  48853. this.operators[conditionLocation + 1] = 'jz';
  48854. } else {
  48855. error('PS Function: error parsing conditional.');
  48856. }
  48857. }
  48858. };
  48859. return PostScriptParser;
  48860. }();
  48861. var PostScriptTokenTypes = {
  48862. LBRACE: 0,
  48863. RBRACE: 1,
  48864. NUMBER: 2,
  48865. OPERATOR: 3,
  48866. IF: 4,
  48867. IFELSE: 5
  48868. };
  48869. var PostScriptToken = function PostScriptTokenClosure() {
  48870. function PostScriptToken(type, value) {
  48871. this.type = type;
  48872. this.value = value;
  48873. }
  48874. var opCache = Object.create(null);
  48875. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  48876. var opValue = opCache[op];
  48877. if (opValue) {
  48878. return opValue;
  48879. }
  48880. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  48881. };
  48882. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  48883. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  48884. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  48885. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  48886. return PostScriptToken;
  48887. }();
  48888. var PostScriptLexer = function PostScriptLexerClosure() {
  48889. function PostScriptLexer(stream) {
  48890. this.stream = stream;
  48891. this.nextChar();
  48892. this.strBuf = [];
  48893. }
  48894. PostScriptLexer.prototype = {
  48895. nextChar: function PostScriptLexer_nextChar() {
  48896. return this.currentChar = this.stream.getByte();
  48897. },
  48898. getToken: function PostScriptLexer_getToken() {
  48899. var comment = false;
  48900. var ch = this.currentChar;
  48901. while (true) {
  48902. if (ch < 0) {
  48903. return EOF;
  48904. }
  48905. if (comment) {
  48906. if (ch === 0x0A || ch === 0x0D) {
  48907. comment = false;
  48908. }
  48909. } else if (ch === 0x25) {
  48910. comment = true;
  48911. } else if (!isSpace(ch)) {
  48912. break;
  48913. }
  48914. ch = this.nextChar();
  48915. }
  48916. switch (ch | 0) {
  48917. case 0x30:
  48918. case 0x31:
  48919. case 0x32:
  48920. case 0x33:
  48921. case 0x34:
  48922. case 0x35:
  48923. case 0x36:
  48924. case 0x37:
  48925. case 0x38:
  48926. case 0x39:
  48927. case 0x2B:
  48928. case 0x2D:
  48929. case 0x2E:
  48930. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  48931. case 0x7B:
  48932. this.nextChar();
  48933. return PostScriptToken.LBRACE;
  48934. case 0x7D:
  48935. this.nextChar();
  48936. return PostScriptToken.RBRACE;
  48937. }
  48938. var strBuf = this.strBuf;
  48939. strBuf.length = 0;
  48940. strBuf[0] = String.fromCharCode(ch);
  48941. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  48942. strBuf.push(String.fromCharCode(ch));
  48943. }
  48944. var str = strBuf.join('');
  48945. switch (str.toLowerCase()) {
  48946. case 'if':
  48947. return PostScriptToken.IF;
  48948. case 'ifelse':
  48949. return PostScriptToken.IFELSE;
  48950. default:
  48951. return PostScriptToken.getOperator(str);
  48952. }
  48953. },
  48954. getNumber: function PostScriptLexer_getNumber() {
  48955. var ch = this.currentChar;
  48956. var strBuf = this.strBuf;
  48957. strBuf.length = 0;
  48958. strBuf[0] = String.fromCharCode(ch);
  48959. while ((ch = this.nextChar()) >= 0) {
  48960. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  48961. strBuf.push(String.fromCharCode(ch));
  48962. } else {
  48963. break;
  48964. }
  48965. }
  48966. var value = parseFloat(strBuf.join(''));
  48967. if (isNaN(value)) {
  48968. error('Invalid floating point number: ' + value);
  48969. }
  48970. return value;
  48971. }
  48972. };
  48973. return PostScriptLexer;
  48974. }();
  48975. exports.PostScriptLexer = PostScriptLexer;
  48976. exports.PostScriptParser = PostScriptParser;
  48977. /***/ }),
  48978. /* 35 */
  48979. /***/ (function(module, exports, __w_pdfjs_require__) {
  48980. "use strict";
  48981. var sharedUtil = __w_pdfjs_require__(0);
  48982. var coreStream = __w_pdfjs_require__(2);
  48983. var coreEncodings = __w_pdfjs_require__(4);
  48984. var warn = sharedUtil.warn;
  48985. var isSpace = sharedUtil.isSpace;
  48986. var Stream = coreStream.Stream;
  48987. var getEncoding = coreEncodings.getEncoding;
  48988. var HINTING_ENABLED = false;
  48989. var Type1CharString = function Type1CharStringClosure() {
  48990. var COMMAND_MAP = {
  48991. 'hstem': [1],
  48992. 'vstem': [3],
  48993. 'vmoveto': [4],
  48994. 'rlineto': [5],
  48995. 'hlineto': [6],
  48996. 'vlineto': [7],
  48997. 'rrcurveto': [8],
  48998. 'callsubr': [10],
  48999. 'flex': [
  49000. 12,
  49001. 35
  49002. ],
  49003. 'drop': [
  49004. 12,
  49005. 18
  49006. ],
  49007. 'endchar': [14],
  49008. 'rmoveto': [21],
  49009. 'hmoveto': [22],
  49010. 'vhcurveto': [30],
  49011. 'hvcurveto': [31]
  49012. };
  49013. function Type1CharString() {
  49014. this.width = 0;
  49015. this.lsb = 0;
  49016. this.flexing = false;
  49017. this.output = [];
  49018. this.stack = [];
  49019. }
  49020. Type1CharString.prototype = {
  49021. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  49022. var count = encoded.length;
  49023. var error = false;
  49024. var wx, sbx, subrNumber;
  49025. for (var i = 0; i < count; i++) {
  49026. var value = encoded[i];
  49027. if (value < 32) {
  49028. if (value === 12) {
  49029. value = (value << 8) + encoded[++i];
  49030. }
  49031. switch (value) {
  49032. case 1:
  49033. if (!HINTING_ENABLED) {
  49034. this.stack = [];
  49035. break;
  49036. }
  49037. error = this.executeCommand(2, COMMAND_MAP.hstem);
  49038. break;
  49039. case 3:
  49040. if (!HINTING_ENABLED) {
  49041. this.stack = [];
  49042. break;
  49043. }
  49044. error = this.executeCommand(2, COMMAND_MAP.vstem);
  49045. break;
  49046. case 4:
  49047. if (this.flexing) {
  49048. if (this.stack.length < 1) {
  49049. error = true;
  49050. break;
  49051. }
  49052. var dy = this.stack.pop();
  49053. this.stack.push(0, dy);
  49054. break;
  49055. }
  49056. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  49057. break;
  49058. case 5:
  49059. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  49060. break;
  49061. case 6:
  49062. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  49063. break;
  49064. case 7:
  49065. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  49066. break;
  49067. case 8:
  49068. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  49069. break;
  49070. case 9:
  49071. this.stack = [];
  49072. break;
  49073. case 10:
  49074. if (this.stack.length < 1) {
  49075. error = true;
  49076. break;
  49077. }
  49078. subrNumber = this.stack.pop();
  49079. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  49080. break;
  49081. case 11:
  49082. return error;
  49083. case 13:
  49084. if (this.stack.length < 2) {
  49085. error = true;
  49086. break;
  49087. }
  49088. wx = this.stack.pop();
  49089. sbx = this.stack.pop();
  49090. this.lsb = sbx;
  49091. this.width = wx;
  49092. this.stack.push(wx, sbx);
  49093. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  49094. break;
  49095. case 14:
  49096. this.output.push(COMMAND_MAP.endchar[0]);
  49097. break;
  49098. case 21:
  49099. if (this.flexing) {
  49100. break;
  49101. }
  49102. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  49103. break;
  49104. case 22:
  49105. if (this.flexing) {
  49106. this.stack.push(0);
  49107. break;
  49108. }
  49109. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  49110. break;
  49111. case 30:
  49112. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  49113. break;
  49114. case 31:
  49115. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  49116. break;
  49117. case (12 << 8) + 0:
  49118. this.stack = [];
  49119. break;
  49120. case (12 << 8) + 1:
  49121. if (!HINTING_ENABLED) {
  49122. this.stack = [];
  49123. break;
  49124. }
  49125. error = this.executeCommand(2, COMMAND_MAP.vstem);
  49126. break;
  49127. case (12 << 8) + 2:
  49128. if (!HINTING_ENABLED) {
  49129. this.stack = [];
  49130. break;
  49131. }
  49132. error = this.executeCommand(2, COMMAND_MAP.hstem);
  49133. break;
  49134. case (12 << 8) + 6:
  49135. if (seacAnalysisEnabled) {
  49136. this.seac = this.stack.splice(-4, 4);
  49137. error = this.executeCommand(0, COMMAND_MAP.endchar);
  49138. } else {
  49139. error = this.executeCommand(4, COMMAND_MAP.endchar);
  49140. }
  49141. break;
  49142. case (12 << 8) + 7:
  49143. if (this.stack.length < 4) {
  49144. error = true;
  49145. break;
  49146. }
  49147. this.stack.pop();
  49148. wx = this.stack.pop();
  49149. var sby = this.stack.pop();
  49150. sbx = this.stack.pop();
  49151. this.lsb = sbx;
  49152. this.width = wx;
  49153. this.stack.push(wx, sbx, sby);
  49154. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  49155. break;
  49156. case (12 << 8) + 12:
  49157. if (this.stack.length < 2) {
  49158. error = true;
  49159. break;
  49160. }
  49161. var num2 = this.stack.pop();
  49162. var num1 = this.stack.pop();
  49163. this.stack.push(num1 / num2);
  49164. break;
  49165. case (12 << 8) + 16:
  49166. if (this.stack.length < 2) {
  49167. error = true;
  49168. break;
  49169. }
  49170. subrNumber = this.stack.pop();
  49171. var numArgs = this.stack.pop();
  49172. if (subrNumber === 0 && numArgs === 3) {
  49173. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  49174. this.stack.push(flexArgs[2] + flexArgs[0], flexArgs[3] + flexArgs[1], flexArgs[4], flexArgs[5], flexArgs[6], flexArgs[7], flexArgs[8], flexArgs[9], flexArgs[10], flexArgs[11], flexArgs[12], flexArgs[13], flexArgs[14]);
  49175. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  49176. this.flexing = false;
  49177. this.stack.push(flexArgs[15], flexArgs[16]);
  49178. } else if (subrNumber === 1 && numArgs === 0) {
  49179. this.flexing = true;
  49180. }
  49181. break;
  49182. case (12 << 8) + 17:
  49183. break;
  49184. case (12 << 8) + 33:
  49185. this.stack = [];
  49186. break;
  49187. default:
  49188. warn('Unknown type 1 charstring command of "' + value + '"');
  49189. break;
  49190. }
  49191. if (error) {
  49192. break;
  49193. }
  49194. continue;
  49195. } else if (value <= 246) {
  49196. value = value - 139;
  49197. } else if (value <= 250) {
  49198. value = (value - 247) * 256 + encoded[++i] + 108;
  49199. } else if (value <= 254) {
  49200. value = -((value - 251) * 256) - encoded[++i] - 108;
  49201. } else {
  49202. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  49203. }
  49204. this.stack.push(value);
  49205. }
  49206. return error;
  49207. },
  49208. executeCommand: function (howManyArgs, command, keepStack) {
  49209. var stackLength = this.stack.length;
  49210. if (howManyArgs > stackLength) {
  49211. return true;
  49212. }
  49213. var start = stackLength - howManyArgs;
  49214. for (var i = start; i < stackLength; i++) {
  49215. var value = this.stack[i];
  49216. if (value === (value | 0)) {
  49217. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  49218. } else {
  49219. value = 65536 * value | 0;
  49220. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  49221. }
  49222. }
  49223. this.output.push.apply(this.output, command);
  49224. if (keepStack) {
  49225. this.stack.splice(start, howManyArgs);
  49226. } else {
  49227. this.stack.length = 0;
  49228. }
  49229. return false;
  49230. }
  49231. };
  49232. return Type1CharString;
  49233. }();
  49234. var Type1Parser = function Type1ParserClosure() {
  49235. var EEXEC_ENCRYPT_KEY = 55665;
  49236. var CHAR_STRS_ENCRYPT_KEY = 4330;
  49237. function isHexDigit(code) {
  49238. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  49239. }
  49240. function decrypt(data, key, discardNumber) {
  49241. if (discardNumber >= data.length) {
  49242. return new Uint8Array(0);
  49243. }
  49244. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  49245. for (i = 0; i < discardNumber; i++) {
  49246. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  49247. }
  49248. var count = data.length - discardNumber;
  49249. var decrypted = new Uint8Array(count);
  49250. for (i = discardNumber, j = 0; j < count; i++, j++) {
  49251. var value = data[i];
  49252. decrypted[j] = value ^ r >> 8;
  49253. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  49254. }
  49255. return decrypted;
  49256. }
  49257. function decryptAscii(data, key, discardNumber) {
  49258. var r = key | 0, c1 = 52845, c2 = 22719;
  49259. var count = data.length, maybeLength = count >>> 1;
  49260. var decrypted = new Uint8Array(maybeLength);
  49261. var i, j;
  49262. for (i = 0, j = 0; i < count; i++) {
  49263. var digit1 = data[i];
  49264. if (!isHexDigit(digit1)) {
  49265. continue;
  49266. }
  49267. i++;
  49268. var digit2;
  49269. while (i < count && !isHexDigit(digit2 = data[i])) {
  49270. i++;
  49271. }
  49272. if (i < count) {
  49273. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  49274. decrypted[j++] = value ^ r >> 8;
  49275. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  49276. }
  49277. }
  49278. return Array.prototype.slice.call(decrypted, discardNumber, j);
  49279. }
  49280. function isSpecial(c) {
  49281. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  49282. }
  49283. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  49284. if (encrypted) {
  49285. var data = stream.getBytes();
  49286. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  49287. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  49288. }
  49289. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  49290. this.stream = stream;
  49291. this.nextChar();
  49292. }
  49293. Type1Parser.prototype = {
  49294. readNumberArray: function Type1Parser_readNumberArray() {
  49295. this.getToken();
  49296. var array = [];
  49297. while (true) {
  49298. var token = this.getToken();
  49299. if (token === null || token === ']' || token === '}') {
  49300. break;
  49301. }
  49302. array.push(parseFloat(token || 0));
  49303. }
  49304. return array;
  49305. },
  49306. readNumber: function Type1Parser_readNumber() {
  49307. var token = this.getToken();
  49308. return parseFloat(token || 0);
  49309. },
  49310. readInt: function Type1Parser_readInt() {
  49311. var token = this.getToken();
  49312. return parseInt(token || 0, 10) | 0;
  49313. },
  49314. readBoolean: function Type1Parser_readBoolean() {
  49315. var token = this.getToken();
  49316. return token === 'true' ? 1 : 0;
  49317. },
  49318. nextChar: function Type1_nextChar() {
  49319. return this.currentChar = this.stream.getByte();
  49320. },
  49321. getToken: function Type1Parser_getToken() {
  49322. var comment = false;
  49323. var ch = this.currentChar;
  49324. while (true) {
  49325. if (ch === -1) {
  49326. return null;
  49327. }
  49328. if (comment) {
  49329. if (ch === 0x0A || ch === 0x0D) {
  49330. comment = false;
  49331. }
  49332. } else if (ch === 0x25) {
  49333. comment = true;
  49334. } else if (!isSpace(ch)) {
  49335. break;
  49336. }
  49337. ch = this.nextChar();
  49338. }
  49339. if (isSpecial(ch)) {
  49340. this.nextChar();
  49341. return String.fromCharCode(ch);
  49342. }
  49343. var token = '';
  49344. do {
  49345. token += String.fromCharCode(ch);
  49346. ch = this.nextChar();
  49347. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  49348. return token;
  49349. },
  49350. extractFontProgram: function Type1Parser_extractFontProgram() {
  49351. var stream = this.stream;
  49352. var subrs = [], charstrings = [];
  49353. var privateData = Object.create(null);
  49354. privateData['lenIV'] = 4;
  49355. var program = {
  49356. subrs: [],
  49357. charstrings: [],
  49358. properties: { 'privateData': privateData }
  49359. };
  49360. var token, length, data, lenIV, encoded;
  49361. while ((token = this.getToken()) !== null) {
  49362. if (token !== '/') {
  49363. continue;
  49364. }
  49365. token = this.getToken();
  49366. switch (token) {
  49367. case 'CharStrings':
  49368. this.getToken();
  49369. this.getToken();
  49370. this.getToken();
  49371. this.getToken();
  49372. while (true) {
  49373. token = this.getToken();
  49374. if (token === null || token === 'end') {
  49375. break;
  49376. }
  49377. if (token !== '/') {
  49378. continue;
  49379. }
  49380. var glyph = this.getToken();
  49381. length = this.readInt();
  49382. this.getToken();
  49383. data = stream.makeSubStream(stream.pos, length);
  49384. lenIV = program.properties.privateData['lenIV'];
  49385. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  49386. stream.skip(length);
  49387. this.nextChar();
  49388. token = this.getToken();
  49389. if (token === 'noaccess') {
  49390. this.getToken();
  49391. }
  49392. charstrings.push({
  49393. glyph: glyph,
  49394. encoded: encoded
  49395. });
  49396. }
  49397. break;
  49398. case 'Subrs':
  49399. this.readInt();
  49400. this.getToken();
  49401. while ((token = this.getToken()) === 'dup') {
  49402. var index = this.readInt();
  49403. length = this.readInt();
  49404. this.getToken();
  49405. data = stream.makeSubStream(stream.pos, length);
  49406. lenIV = program.properties.privateData['lenIV'];
  49407. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  49408. stream.skip(length);
  49409. this.nextChar();
  49410. token = this.getToken();
  49411. if (token === 'noaccess') {
  49412. this.getToken();
  49413. }
  49414. subrs[index] = encoded;
  49415. }
  49416. break;
  49417. case 'BlueValues':
  49418. case 'OtherBlues':
  49419. case 'FamilyBlues':
  49420. case 'FamilyOtherBlues':
  49421. var blueArray = this.readNumberArray();
  49422. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  49423. program.properties.privateData[token] = blueArray;
  49424. }
  49425. break;
  49426. case 'StemSnapH':
  49427. case 'StemSnapV':
  49428. program.properties.privateData[token] = this.readNumberArray();
  49429. break;
  49430. case 'StdHW':
  49431. case 'StdVW':
  49432. program.properties.privateData[token] = this.readNumberArray()[0];
  49433. break;
  49434. case 'BlueShift':
  49435. case 'lenIV':
  49436. case 'BlueFuzz':
  49437. case 'BlueScale':
  49438. case 'LanguageGroup':
  49439. case 'ExpansionFactor':
  49440. program.properties.privateData[token] = this.readNumber();
  49441. break;
  49442. case 'ForceBold':
  49443. program.properties.privateData[token] = this.readBoolean();
  49444. break;
  49445. }
  49446. }
  49447. for (var i = 0; i < charstrings.length; i++) {
  49448. glyph = charstrings[i].glyph;
  49449. encoded = charstrings[i].encoded;
  49450. var charString = new Type1CharString();
  49451. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  49452. var output = charString.output;
  49453. if (error) {
  49454. output = [14];
  49455. }
  49456. program.charstrings.push({
  49457. glyphName: glyph,
  49458. charstring: output,
  49459. width: charString.width,
  49460. lsb: charString.lsb,
  49461. seac: charString.seac
  49462. });
  49463. }
  49464. return program;
  49465. },
  49466. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  49467. var token;
  49468. while ((token = this.getToken()) !== null) {
  49469. if (token !== '/') {
  49470. continue;
  49471. }
  49472. token = this.getToken();
  49473. switch (token) {
  49474. case 'FontMatrix':
  49475. var matrix = this.readNumberArray();
  49476. properties.fontMatrix = matrix;
  49477. break;
  49478. case 'Encoding':
  49479. var encodingArg = this.getToken();
  49480. var encoding;
  49481. if (!/^\d+$/.test(encodingArg)) {
  49482. encoding = getEncoding(encodingArg);
  49483. } else {
  49484. encoding = [];
  49485. var size = parseInt(encodingArg, 10) | 0;
  49486. this.getToken();
  49487. for (var j = 0; j < size; j++) {
  49488. token = this.getToken();
  49489. while (token !== 'dup' && token !== 'def') {
  49490. token = this.getToken();
  49491. if (token === null) {
  49492. return;
  49493. }
  49494. }
  49495. if (token === 'def') {
  49496. break;
  49497. }
  49498. var index = this.readInt();
  49499. this.getToken();
  49500. var glyph = this.getToken();
  49501. encoding[index] = glyph;
  49502. this.getToken();
  49503. }
  49504. }
  49505. properties.builtInEncoding = encoding;
  49506. break;
  49507. case 'FontBBox':
  49508. var fontBBox = this.readNumberArray();
  49509. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  49510. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  49511. properties.ascentScaled = true;
  49512. break;
  49513. }
  49514. }
  49515. }
  49516. };
  49517. return Type1Parser;
  49518. }();
  49519. exports.Type1Parser = Type1Parser;
  49520. /***/ }),
  49521. /* 36 */
  49522. /***/ (function(module, exports, __w_pdfjs_require__) {
  49523. "use strict";
  49524. /* WEBPACK VAR INJECTION */(function(global) {
  49525. if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
  49526. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  49527. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  49528. var isAndroid = /Android/.test(userAgent);
  49529. var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent);
  49530. var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent);
  49531. var isChrome = userAgent.indexOf('Chrom') >= 0;
  49532. var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent);
  49533. var isIOSChrome = userAgent.indexOf('CriOS') >= 0;
  49534. var isIE = userAgent.indexOf('Trident') >= 0;
  49535. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  49536. var isOpera = userAgent.indexOf('Opera') >= 0;
  49537. var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent);
  49538. var hasDOM = typeof window === 'object' && typeof document === 'object';
  49539. if (typeof PDFJS === 'undefined') {
  49540. globalScope.PDFJS = {};
  49541. }
  49542. PDFJS.compatibilityChecked = true;
  49543. (function checkTypedArrayCompatibility() {
  49544. if (typeof Uint8Array !== 'undefined') {
  49545. if (typeof Uint8Array.prototype.subarray === 'undefined') {
  49546. Uint8Array.prototype.subarray = function subarray(start, end) {
  49547. return new Uint8Array(this.slice(start, end));
  49548. };
  49549. Float32Array.prototype.subarray = function subarray(start, end) {
  49550. return new Float32Array(this.slice(start, end));
  49551. };
  49552. }
  49553. if (typeof Float64Array === 'undefined') {
  49554. globalScope.Float64Array = Float32Array;
  49555. }
  49556. return;
  49557. }
  49558. function subarray(start, end) {
  49559. return new TypedArray(this.slice(start, end));
  49560. }
  49561. function setArrayOffset(array, offset) {
  49562. if (arguments.length < 2) {
  49563. offset = 0;
  49564. }
  49565. for (var i = 0, n = array.length; i < n; ++i, ++offset) {
  49566. this[offset] = array[i] & 0xFF;
  49567. }
  49568. }
  49569. function TypedArray(arg1) {
  49570. var result, i, n;
  49571. if (typeof arg1 === 'number') {
  49572. result = [];
  49573. for (i = 0; i < arg1; ++i) {
  49574. result[i] = 0;
  49575. }
  49576. } else if ('slice' in arg1) {
  49577. result = arg1.slice(0);
  49578. } else {
  49579. result = [];
  49580. for (i = 0, n = arg1.length; i < n; ++i) {
  49581. result[i] = arg1[i];
  49582. }
  49583. }
  49584. result.subarray = subarray;
  49585. result.buffer = result;
  49586. result.byteLength = result.length;
  49587. result.set = setArrayOffset;
  49588. if (typeof arg1 === 'object' && arg1.buffer) {
  49589. result.buffer = arg1.buffer;
  49590. }
  49591. return result;
  49592. }
  49593. globalScope.Uint8Array = TypedArray;
  49594. globalScope.Int8Array = TypedArray;
  49595. globalScope.Uint32Array = TypedArray;
  49596. globalScope.Int32Array = TypedArray;
  49597. globalScope.Uint16Array = TypedArray;
  49598. globalScope.Float32Array = TypedArray;
  49599. globalScope.Float64Array = TypedArray;
  49600. }());
  49601. (function normalizeURLObject() {
  49602. if (!globalScope.URL) {
  49603. globalScope.URL = globalScope.webkitURL;
  49604. }
  49605. }());
  49606. (function checkObjectDefinePropertyCompatibility() {
  49607. if (typeof Object.defineProperty !== 'undefined') {
  49608. var definePropertyPossible = true;
  49609. try {
  49610. if (hasDOM) {
  49611. Object.defineProperty(new Image(), 'id', { value: 'test' });
  49612. }
  49613. var Test = function Test() {
  49614. };
  49615. Test.prototype = {
  49616. get id() {
  49617. }
  49618. };
  49619. Object.defineProperty(new Test(), 'id', {
  49620. value: '',
  49621. configurable: true,
  49622. enumerable: true,
  49623. writable: false
  49624. });
  49625. } catch (e) {
  49626. definePropertyPossible = false;
  49627. }
  49628. if (definePropertyPossible) {
  49629. return;
  49630. }
  49631. }
  49632. Object.defineProperty = function objectDefineProperty(obj, name, def) {
  49633. delete obj[name];
  49634. if ('get' in def) {
  49635. obj.__defineGetter__(name, def['get']);
  49636. }
  49637. if ('set' in def) {
  49638. obj.__defineSetter__(name, def['set']);
  49639. }
  49640. if ('value' in def) {
  49641. obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
  49642. this.__defineGetter__(name, function objectDefinePropertyGetter() {
  49643. return value;
  49644. });
  49645. return value;
  49646. });
  49647. obj[name] = def.value;
  49648. }
  49649. };
  49650. }());
  49651. (function checkXMLHttpRequestResponseCompatibility() {
  49652. if (typeof XMLHttpRequest === 'undefined') {
  49653. return;
  49654. }
  49655. var xhrPrototype = XMLHttpRequest.prototype;
  49656. var xhr = new XMLHttpRequest();
  49657. if (!('overrideMimeType' in xhr)) {
  49658. Object.defineProperty(xhrPrototype, 'overrideMimeType', {
  49659. value: function xmlHttpRequestOverrideMimeType(mimeType) {
  49660. }
  49661. });
  49662. }
  49663. if ('responseType' in xhr) {
  49664. return;
  49665. }
  49666. Object.defineProperty(xhrPrototype, 'responseType', {
  49667. get: function xmlHttpRequestGetResponseType() {
  49668. return this._responseType || 'text';
  49669. },
  49670. set: function xmlHttpRequestSetResponseType(value) {
  49671. if (value === 'text' || value === 'arraybuffer') {
  49672. this._responseType = value;
  49673. if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') {
  49674. this.overrideMimeType('text/plain; charset=x-user-defined');
  49675. }
  49676. }
  49677. }
  49678. });
  49679. if (typeof VBArray !== 'undefined') {
  49680. Object.defineProperty(xhrPrototype, 'response', {
  49681. get: function xmlHttpRequestResponseGet() {
  49682. if (this.responseType === 'arraybuffer') {
  49683. return new Uint8Array(new VBArray(this.responseBody).toArray());
  49684. }
  49685. return this.responseText;
  49686. }
  49687. });
  49688. return;
  49689. }
  49690. Object.defineProperty(xhrPrototype, 'response', {
  49691. get: function xmlHttpRequestResponseGet() {
  49692. if (this.responseType !== 'arraybuffer') {
  49693. return this.responseText;
  49694. }
  49695. var text = this.responseText;
  49696. var i, n = text.length;
  49697. var result = new Uint8Array(n);
  49698. for (i = 0; i < n; ++i) {
  49699. result[i] = text.charCodeAt(i) & 0xFF;
  49700. }
  49701. return result.buffer;
  49702. }
  49703. });
  49704. }());
  49705. (function checkWindowBtoaCompatibility() {
  49706. if ('btoa' in globalScope) {
  49707. return;
  49708. }
  49709. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  49710. globalScope.btoa = function (chars) {
  49711. var buffer = '';
  49712. var i, n;
  49713. for (i = 0, n = chars.length; i < n; i += 3) {
  49714. var b1 = chars.charCodeAt(i) & 0xFF;
  49715. var b2 = chars.charCodeAt(i + 1) & 0xFF;
  49716. var b3 = chars.charCodeAt(i + 2) & 0xFF;
  49717. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  49718. var d3 = i + 1 < n ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  49719. var d4 = i + 2 < n ? b3 & 0x3F : 64;
  49720. buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4);
  49721. }
  49722. return buffer;
  49723. };
  49724. }());
  49725. (function checkWindowAtobCompatibility() {
  49726. if ('atob' in globalScope) {
  49727. return;
  49728. }
  49729. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  49730. globalScope.atob = function (input) {
  49731. input = input.replace(/=+$/, '');
  49732. if (input.length % 4 === 1) {
  49733. throw new Error('bad atob input');
  49734. }
  49735. for (var bc = 0, bs, buffer, idx = 0, output = ''; buffer = input.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
  49736. buffer = digits.indexOf(buffer);
  49737. }
  49738. return output;
  49739. };
  49740. }());
  49741. (function checkFunctionPrototypeBindCompatibility() {
  49742. if (typeof Function.prototype.bind !== 'undefined') {
  49743. return;
  49744. }
  49745. Function.prototype.bind = function functionPrototypeBind(obj) {
  49746. var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
  49747. var bound = function functionPrototypeBindBound() {
  49748. var args = headArgs.concat(Array.prototype.slice.call(arguments));
  49749. return fn.apply(obj, args);
  49750. };
  49751. return bound;
  49752. };
  49753. }());
  49754. (function checkDatasetProperty() {
  49755. if (!hasDOM) {
  49756. return;
  49757. }
  49758. var div = document.createElement('div');
  49759. if ('dataset' in div) {
  49760. return;
  49761. }
  49762. Object.defineProperty(HTMLElement.prototype, 'dataset', {
  49763. get: function () {
  49764. if (this._dataset) {
  49765. return this._dataset;
  49766. }
  49767. var dataset = {};
  49768. for (var j = 0, jj = this.attributes.length; j < jj; j++) {
  49769. var attribute = this.attributes[j];
  49770. if (attribute.name.substring(0, 5) !== 'data-') {
  49771. continue;
  49772. }
  49773. var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) {
  49774. return ch.toUpperCase();
  49775. });
  49776. dataset[key] = attribute.value;
  49777. }
  49778. Object.defineProperty(this, '_dataset', {
  49779. value: dataset,
  49780. writable: false,
  49781. enumerable: false
  49782. });
  49783. return dataset;
  49784. },
  49785. enumerable: true
  49786. });
  49787. }());
  49788. (function checkClassListProperty() {
  49789. function changeList(element, itemName, add, remove) {
  49790. var s = element.className || '';
  49791. var list = s.split(/\s+/g);
  49792. if (list[0] === '') {
  49793. list.shift();
  49794. }
  49795. var index = list.indexOf(itemName);
  49796. if (index < 0 && add) {
  49797. list.push(itemName);
  49798. }
  49799. if (index >= 0 && remove) {
  49800. list.splice(index, 1);
  49801. }
  49802. element.className = list.join(' ');
  49803. return index >= 0;
  49804. }
  49805. if (!hasDOM) {
  49806. return;
  49807. }
  49808. var div = document.createElement('div');
  49809. if ('classList' in div) {
  49810. return;
  49811. }
  49812. var classListPrototype = {
  49813. add: function (name) {
  49814. changeList(this.element, name, true, false);
  49815. },
  49816. contains: function (name) {
  49817. return changeList(this.element, name, false, false);
  49818. },
  49819. remove: function (name) {
  49820. changeList(this.element, name, false, true);
  49821. },
  49822. toggle: function (name) {
  49823. changeList(this.element, name, true, true);
  49824. }
  49825. };
  49826. Object.defineProperty(HTMLElement.prototype, 'classList', {
  49827. get: function () {
  49828. if (this._classList) {
  49829. return this._classList;
  49830. }
  49831. var classList = Object.create(classListPrototype, {
  49832. element: {
  49833. value: this,
  49834. writable: false,
  49835. enumerable: true
  49836. }
  49837. });
  49838. Object.defineProperty(this, '_classList', {
  49839. value: classList,
  49840. writable: false,
  49841. enumerable: false
  49842. });
  49843. return classList;
  49844. },
  49845. enumerable: true
  49846. });
  49847. }());
  49848. (function checkWorkerConsoleCompatibility() {
  49849. if (typeof importScripts === 'undefined' || 'console' in globalScope) {
  49850. return;
  49851. }
  49852. var consoleTimer = {};
  49853. var workerConsole = {
  49854. log: function log() {
  49855. var args = Array.prototype.slice.call(arguments);
  49856. globalScope.postMessage({
  49857. targetName: 'main',
  49858. action: 'console_log',
  49859. data: args
  49860. });
  49861. },
  49862. error: function error() {
  49863. var args = Array.prototype.slice.call(arguments);
  49864. globalScope.postMessage({
  49865. targetName: 'main',
  49866. action: 'console_error',
  49867. data: args
  49868. });
  49869. },
  49870. time: function time(name) {
  49871. consoleTimer[name] = Date.now();
  49872. },
  49873. timeEnd: function timeEnd(name) {
  49874. var time = consoleTimer[name];
  49875. if (!time) {
  49876. throw new Error('Unknown timer name ' + name);
  49877. }
  49878. this.log('Timer:', name, Date.now() - time);
  49879. }
  49880. };
  49881. globalScope.console = workerConsole;
  49882. }());
  49883. (function checkConsoleCompatibility() {
  49884. if (!hasDOM) {
  49885. return;
  49886. }
  49887. if (!('console' in window)) {
  49888. window.console = {
  49889. log: function () {
  49890. },
  49891. error: function () {
  49892. },
  49893. warn: function () {
  49894. }
  49895. };
  49896. return;
  49897. }
  49898. if (!('bind' in console.log)) {
  49899. console.log = function (fn) {
  49900. return function (msg) {
  49901. return fn(msg);
  49902. };
  49903. }(console.log);
  49904. console.error = function (fn) {
  49905. return function (msg) {
  49906. return fn(msg);
  49907. };
  49908. }(console.error);
  49909. console.warn = function (fn) {
  49910. return function (msg) {
  49911. return fn(msg);
  49912. };
  49913. }(console.warn);
  49914. return;
  49915. }
  49916. }());
  49917. (function checkOnClickCompatibility() {
  49918. function ignoreIfTargetDisabled(event) {
  49919. if (isDisabled(event.target)) {
  49920. event.stopPropagation();
  49921. }
  49922. }
  49923. function isDisabled(node) {
  49924. return node.disabled || node.parentNode && isDisabled(node.parentNode);
  49925. }
  49926. if (isOpera) {
  49927. document.addEventListener('click', ignoreIfTargetDisabled, true);
  49928. }
  49929. }());
  49930. (function checkOnBlobSupport() {
  49931. if (isIE || isIOSChrome) {
  49932. PDFJS.disableCreateObjectURL = true;
  49933. }
  49934. }());
  49935. (function checkNavigatorLanguage() {
  49936. if (typeof navigator === 'undefined') {
  49937. return;
  49938. }
  49939. if ('language' in navigator) {
  49940. return;
  49941. }
  49942. PDFJS.locale = navigator.userLanguage || 'en-US';
  49943. }());
  49944. (function checkRangeRequests() {
  49945. if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) {
  49946. PDFJS.disableRange = true;
  49947. PDFJS.disableStream = true;
  49948. }
  49949. }());
  49950. (function checkHistoryManipulation() {
  49951. if (!hasDOM) {
  49952. return;
  49953. }
  49954. if (!history.pushState || isAndroidPre3) {
  49955. PDFJS.disableHistory = true;
  49956. }
  49957. }());
  49958. (function checkSetPresenceInImageData() {
  49959. if (!hasDOM) {
  49960. return;
  49961. }
  49962. if (window.CanvasPixelArray) {
  49963. if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
  49964. window.CanvasPixelArray.prototype.set = function (arr) {
  49965. for (var i = 0, ii = this.length; i < ii; i++) {
  49966. this[i] = arr[i];
  49967. }
  49968. };
  49969. }
  49970. } else {
  49971. var polyfill = false, versionMatch;
  49972. if (isChrome) {
  49973. versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  49974. polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
  49975. } else if (isAndroid) {
  49976. polyfill = isAndroidPre5;
  49977. } else if (isSafari) {
  49978. versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
  49979. polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
  49980. }
  49981. if (polyfill) {
  49982. var contextPrototype = window.CanvasRenderingContext2D.prototype;
  49983. var createImageData = contextPrototype.createImageData;
  49984. contextPrototype.createImageData = function (w, h) {
  49985. var imageData = createImageData.call(this, w, h);
  49986. imageData.data.set = function (arr) {
  49987. for (var i = 0, ii = this.length; i < ii; i++) {
  49988. this[i] = arr[i];
  49989. }
  49990. };
  49991. return imageData;
  49992. };
  49993. contextPrototype = null;
  49994. }
  49995. }
  49996. }());
  49997. (function checkRequestAnimationFrame() {
  49998. function fakeRequestAnimationFrame(callback) {
  49999. window.setTimeout(callback, 20);
  50000. }
  50001. if (!hasDOM) {
  50002. return;
  50003. }
  50004. if (isIOS) {
  50005. window.requestAnimationFrame = fakeRequestAnimationFrame;
  50006. return;
  50007. }
  50008. if ('requestAnimationFrame' in window) {
  50009. return;
  50010. }
  50011. window.requestAnimationFrame = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || fakeRequestAnimationFrame;
  50012. }());
  50013. (function checkCanvasSizeLimitation() {
  50014. if (isIOS || isAndroid) {
  50015. PDFJS.maxCanvasPixels = 5242880;
  50016. }
  50017. }());
  50018. (function checkFullscreenSupport() {
  50019. if (!hasDOM) {
  50020. return;
  50021. }
  50022. if (isIE && window.parent !== window) {
  50023. PDFJS.disableFullscreen = true;
  50024. }
  50025. }());
  50026. (function checkCurrentScript() {
  50027. if (!hasDOM) {
  50028. return;
  50029. }
  50030. if ('currentScript' in document) {
  50031. return;
  50032. }
  50033. Object.defineProperty(document, 'currentScript', {
  50034. get: function () {
  50035. var scripts = document.getElementsByTagName('script');
  50036. return scripts[scripts.length - 1];
  50037. },
  50038. enumerable: true,
  50039. configurable: true
  50040. });
  50041. }());
  50042. (function checkInputTypeNumberAssign() {
  50043. if (!hasDOM) {
  50044. return;
  50045. }
  50046. var el = document.createElement('input');
  50047. try {
  50048. el.type = 'number';
  50049. } catch (ex) {
  50050. var inputProto = el.constructor.prototype;
  50051. var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type');
  50052. Object.defineProperty(inputProto, 'type', {
  50053. get: function () {
  50054. return typeProperty.get.call(this);
  50055. },
  50056. set: function (value) {
  50057. typeProperty.set.call(this, value === 'number' ? 'text' : value);
  50058. },
  50059. enumerable: true,
  50060. configurable: true
  50061. });
  50062. }
  50063. }());
  50064. (function checkDocumentReadyState() {
  50065. if (!hasDOM) {
  50066. return;
  50067. }
  50068. if (!document.attachEvent) {
  50069. return;
  50070. }
  50071. var documentProto = document.constructor.prototype;
  50072. var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState');
  50073. Object.defineProperty(documentProto, 'readyState', {
  50074. get: function () {
  50075. var value = readyStateProto.get.call(this);
  50076. return value === 'interactive' ? 'loading' : value;
  50077. },
  50078. set: function (value) {
  50079. readyStateProto.set.call(this, value);
  50080. },
  50081. enumerable: true,
  50082. configurable: true
  50083. });
  50084. }());
  50085. (function checkChildNodeRemove() {
  50086. if (!hasDOM) {
  50087. return;
  50088. }
  50089. if (typeof Element.prototype.remove !== 'undefined') {
  50090. return;
  50091. }
  50092. Element.prototype.remove = function () {
  50093. if (this.parentNode) {
  50094. this.parentNode.removeChild(this);
  50095. }
  50096. };
  50097. }());
  50098. (function checkPromise() {
  50099. if (globalScope.Promise) {
  50100. if (typeof globalScope.Promise.all !== 'function') {
  50101. globalScope.Promise.all = function (iterable) {
  50102. var count = 0, results = [], resolve, reject;
  50103. var promise = new globalScope.Promise(function (resolve_, reject_) {
  50104. resolve = resolve_;
  50105. reject = reject_;
  50106. });
  50107. iterable.forEach(function (p, i) {
  50108. count++;
  50109. p.then(function (result) {
  50110. results[i] = result;
  50111. count--;
  50112. if (count === 0) {
  50113. resolve(results);
  50114. }
  50115. }, reject);
  50116. });
  50117. if (count === 0) {
  50118. resolve(results);
  50119. }
  50120. return promise;
  50121. };
  50122. }
  50123. if (typeof globalScope.Promise.resolve !== 'function') {
  50124. globalScope.Promise.resolve = function (value) {
  50125. return new globalScope.Promise(function (resolve) {
  50126. resolve(value);
  50127. });
  50128. };
  50129. }
  50130. if (typeof globalScope.Promise.reject !== 'function') {
  50131. globalScope.Promise.reject = function (reason) {
  50132. return new globalScope.Promise(function (resolve, reject) {
  50133. reject(reason);
  50134. });
  50135. };
  50136. }
  50137. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  50138. globalScope.Promise.prototype.catch = function (onReject) {
  50139. return globalScope.Promise.prototype.then(undefined, onReject);
  50140. };
  50141. }
  50142. return;
  50143. }
  50144. var STATUS_PENDING = 0;
  50145. var STATUS_RESOLVED = 1;
  50146. var STATUS_REJECTED = 2;
  50147. var REJECTION_TIMEOUT = 500;
  50148. var HandlerManager = {
  50149. handlers: [],
  50150. running: false,
  50151. unhandledRejections: [],
  50152. pendingRejectionCheck: false,
  50153. scheduleHandlers: function scheduleHandlers(promise) {
  50154. if (promise._status === STATUS_PENDING) {
  50155. return;
  50156. }
  50157. this.handlers = this.handlers.concat(promise._handlers);
  50158. promise._handlers = [];
  50159. if (this.running) {
  50160. return;
  50161. }
  50162. this.running = true;
  50163. setTimeout(this.runHandlers.bind(this), 0);
  50164. },
  50165. runHandlers: function runHandlers() {
  50166. var RUN_TIMEOUT = 1;
  50167. var timeoutAt = Date.now() + RUN_TIMEOUT;
  50168. while (this.handlers.length > 0) {
  50169. var handler = this.handlers.shift();
  50170. var nextStatus = handler.thisPromise._status;
  50171. var nextValue = handler.thisPromise._value;
  50172. try {
  50173. if (nextStatus === STATUS_RESOLVED) {
  50174. if (typeof handler.onResolve === 'function') {
  50175. nextValue = handler.onResolve(nextValue);
  50176. }
  50177. } else if (typeof handler.onReject === 'function') {
  50178. nextValue = handler.onReject(nextValue);
  50179. nextStatus = STATUS_RESOLVED;
  50180. if (handler.thisPromise._unhandledRejection) {
  50181. this.removeUnhandeledRejection(handler.thisPromise);
  50182. }
  50183. }
  50184. } catch (ex) {
  50185. nextStatus = STATUS_REJECTED;
  50186. nextValue = ex;
  50187. }
  50188. handler.nextPromise._updateStatus(nextStatus, nextValue);
  50189. if (Date.now() >= timeoutAt) {
  50190. break;
  50191. }
  50192. }
  50193. if (this.handlers.length > 0) {
  50194. setTimeout(this.runHandlers.bind(this), 0);
  50195. return;
  50196. }
  50197. this.running = false;
  50198. },
  50199. addUnhandledRejection: function addUnhandledRejection(promise) {
  50200. this.unhandledRejections.push({
  50201. promise: promise,
  50202. time: Date.now()
  50203. });
  50204. this.scheduleRejectionCheck();
  50205. },
  50206. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  50207. promise._unhandledRejection = false;
  50208. for (var i = 0; i < this.unhandledRejections.length; i++) {
  50209. if (this.unhandledRejections[i].promise === promise) {
  50210. this.unhandledRejections.splice(i);
  50211. i--;
  50212. }
  50213. }
  50214. },
  50215. scheduleRejectionCheck: function scheduleRejectionCheck() {
  50216. if (this.pendingRejectionCheck) {
  50217. return;
  50218. }
  50219. this.pendingRejectionCheck = true;
  50220. setTimeout(function rejectionCheck() {
  50221. this.pendingRejectionCheck = false;
  50222. var now = Date.now();
  50223. for (var i = 0; i < this.unhandledRejections.length; i++) {
  50224. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  50225. var unhandled = this.unhandledRejections[i].promise._value;
  50226. var msg = 'Unhandled rejection: ' + unhandled;
  50227. if (unhandled.stack) {
  50228. msg += '\n' + unhandled.stack;
  50229. }
  50230. try {
  50231. throw new Error(msg);
  50232. } catch (_) {
  50233. console.warn(msg);
  50234. }
  50235. this.unhandledRejections.splice(i);
  50236. i--;
  50237. }
  50238. }
  50239. if (this.unhandledRejections.length) {
  50240. this.scheduleRejectionCheck();
  50241. }
  50242. }.bind(this), REJECTION_TIMEOUT);
  50243. }
  50244. };
  50245. var Promise = function Promise(resolver) {
  50246. this._status = STATUS_PENDING;
  50247. this._handlers = [];
  50248. try {
  50249. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  50250. } catch (e) {
  50251. this._reject(e);
  50252. }
  50253. };
  50254. Promise.all = function Promise_all(promises) {
  50255. var resolveAll, rejectAll;
  50256. var deferred = new Promise(function (resolve, reject) {
  50257. resolveAll = resolve;
  50258. rejectAll = reject;
  50259. });
  50260. var unresolved = promises.length;
  50261. var results = [];
  50262. if (unresolved === 0) {
  50263. resolveAll(results);
  50264. return deferred;
  50265. }
  50266. function reject(reason) {
  50267. if (deferred._status === STATUS_REJECTED) {
  50268. return;
  50269. }
  50270. results = [];
  50271. rejectAll(reason);
  50272. }
  50273. for (var i = 0, ii = promises.length; i < ii; ++i) {
  50274. var promise = promises[i];
  50275. var resolve = function (i) {
  50276. return function (value) {
  50277. if (deferred._status === STATUS_REJECTED) {
  50278. return;
  50279. }
  50280. results[i] = value;
  50281. unresolved--;
  50282. if (unresolved === 0) {
  50283. resolveAll(results);
  50284. }
  50285. };
  50286. }(i);
  50287. if (Promise.isPromise(promise)) {
  50288. promise.then(resolve, reject);
  50289. } else {
  50290. resolve(promise);
  50291. }
  50292. }
  50293. return deferred;
  50294. };
  50295. Promise.isPromise = function Promise_isPromise(value) {
  50296. return value && typeof value.then === 'function';
  50297. };
  50298. Promise.resolve = function Promise_resolve(value) {
  50299. return new Promise(function (resolve) {
  50300. resolve(value);
  50301. });
  50302. };
  50303. Promise.reject = function Promise_reject(reason) {
  50304. return new Promise(function (resolve, reject) {
  50305. reject(reason);
  50306. });
  50307. };
  50308. Promise.prototype = {
  50309. _status: null,
  50310. _value: null,
  50311. _handlers: null,
  50312. _unhandledRejection: null,
  50313. _updateStatus: function Promise__updateStatus(status, value) {
  50314. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  50315. return;
  50316. }
  50317. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  50318. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  50319. return;
  50320. }
  50321. this._status = status;
  50322. this._value = value;
  50323. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  50324. this._unhandledRejection = true;
  50325. HandlerManager.addUnhandledRejection(this);
  50326. }
  50327. HandlerManager.scheduleHandlers(this);
  50328. },
  50329. _resolve: function Promise_resolve(value) {
  50330. this._updateStatus(STATUS_RESOLVED, value);
  50331. },
  50332. _reject: function Promise_reject(reason) {
  50333. this._updateStatus(STATUS_REJECTED, reason);
  50334. },
  50335. then: function Promise_then(onResolve, onReject) {
  50336. var nextPromise = new Promise(function (resolve, reject) {
  50337. this.resolve = resolve;
  50338. this.reject = reject;
  50339. });
  50340. this._handlers.push({
  50341. thisPromise: this,
  50342. onResolve: onResolve,
  50343. onReject: onReject,
  50344. nextPromise: nextPromise
  50345. });
  50346. HandlerManager.scheduleHandlers(this);
  50347. return nextPromise;
  50348. },
  50349. catch: function Promise_catch(onReject) {
  50350. return this.then(undefined, onReject);
  50351. }
  50352. };
  50353. globalScope.Promise = Promise;
  50354. }());
  50355. (function checkWeakMap() {
  50356. if (globalScope.WeakMap) {
  50357. return;
  50358. }
  50359. var id = 0;
  50360. function WeakMap() {
  50361. this.id = '$weakmap' + id++;
  50362. }
  50363. WeakMap.prototype = {
  50364. has: function (obj) {
  50365. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  50366. },
  50367. get: function (obj, defaultValue) {
  50368. return this.has(obj) ? obj[this.id] : defaultValue;
  50369. },
  50370. set: function (obj, value) {
  50371. Object.defineProperty(obj, this.id, {
  50372. value: value,
  50373. enumerable: false,
  50374. configurable: true
  50375. });
  50376. },
  50377. delete: function (obj) {
  50378. delete obj[this.id];
  50379. }
  50380. };
  50381. globalScope.WeakMap = WeakMap;
  50382. }());
  50383. (function checkURLConstructor() {
  50384. var hasWorkingUrl = false;
  50385. try {
  50386. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  50387. var u = new URL('b', 'http://a');
  50388. u.pathname = 'c%20d';
  50389. hasWorkingUrl = u.href === 'http://a/c%20d';
  50390. }
  50391. } catch (e) {
  50392. }
  50393. if (hasWorkingUrl) {
  50394. return;
  50395. }
  50396. var relative = Object.create(null);
  50397. relative['ftp'] = 21;
  50398. relative['file'] = 0;
  50399. relative['gopher'] = 70;
  50400. relative['http'] = 80;
  50401. relative['https'] = 443;
  50402. relative['ws'] = 80;
  50403. relative['wss'] = 443;
  50404. var relativePathDotMapping = Object.create(null);
  50405. relativePathDotMapping['%2e'] = '.';
  50406. relativePathDotMapping['.%2e'] = '..';
  50407. relativePathDotMapping['%2e.'] = '..';
  50408. relativePathDotMapping['%2e%2e'] = '..';
  50409. function isRelativeScheme(scheme) {
  50410. return relative[scheme] !== undefined;
  50411. }
  50412. function invalid() {
  50413. clear.call(this);
  50414. this._isInvalid = true;
  50415. }
  50416. function IDNAToASCII(h) {
  50417. if (h === '') {
  50418. invalid.call(this);
  50419. }
  50420. return h.toLowerCase();
  50421. }
  50422. function percentEscape(c) {
  50423. var unicode = c.charCodeAt(0);
  50424. if (unicode > 0x20 && unicode < 0x7F && [
  50425. 0x22,
  50426. 0x23,
  50427. 0x3C,
  50428. 0x3E,
  50429. 0x3F,
  50430. 0x60
  50431. ].indexOf(unicode) === -1) {
  50432. return c;
  50433. }
  50434. return encodeURIComponent(c);
  50435. }
  50436. function percentEscapeQuery(c) {
  50437. var unicode = c.charCodeAt(0);
  50438. if (unicode > 0x20 && unicode < 0x7F && [
  50439. 0x22,
  50440. 0x23,
  50441. 0x3C,
  50442. 0x3E,
  50443. 0x60
  50444. ].indexOf(unicode) === -1) {
  50445. return c;
  50446. }
  50447. return encodeURIComponent(c);
  50448. }
  50449. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  50450. function parse(input, stateOverride, base) {
  50451. function err(message) {
  50452. errors.push(message);
  50453. }
  50454. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  50455. loop:
  50456. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  50457. var c = input[cursor];
  50458. switch (state) {
  50459. case 'scheme start':
  50460. if (c && ALPHA.test(c)) {
  50461. buffer += c.toLowerCase();
  50462. state = 'scheme';
  50463. } else if (!stateOverride) {
  50464. buffer = '';
  50465. state = 'no scheme';
  50466. continue;
  50467. } else {
  50468. err('Invalid scheme.');
  50469. break loop;
  50470. }
  50471. break;
  50472. case 'scheme':
  50473. if (c && ALPHANUMERIC.test(c)) {
  50474. buffer += c.toLowerCase();
  50475. } else if (c === ':') {
  50476. this._scheme = buffer;
  50477. buffer = '';
  50478. if (stateOverride) {
  50479. break loop;
  50480. }
  50481. if (isRelativeScheme(this._scheme)) {
  50482. this._isRelative = true;
  50483. }
  50484. if (this._scheme === 'file') {
  50485. state = 'relative';
  50486. } else if (this._isRelative && base && base._scheme === this._scheme) {
  50487. state = 'relative or authority';
  50488. } else if (this._isRelative) {
  50489. state = 'authority first slash';
  50490. } else {
  50491. state = 'scheme data';
  50492. }
  50493. } else if (!stateOverride) {
  50494. buffer = '';
  50495. cursor = 0;
  50496. state = 'no scheme';
  50497. continue;
  50498. } else if (EOF === c) {
  50499. break loop;
  50500. } else {
  50501. err('Code point not allowed in scheme: ' + c);
  50502. break loop;
  50503. }
  50504. break;
  50505. case 'scheme data':
  50506. if (c === '?') {
  50507. this._query = '?';
  50508. state = 'query';
  50509. } else if (c === '#') {
  50510. this._fragment = '#';
  50511. state = 'fragment';
  50512. } else {
  50513. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  50514. this._schemeData += percentEscape(c);
  50515. }
  50516. }
  50517. break;
  50518. case 'no scheme':
  50519. if (!base || !isRelativeScheme(base._scheme)) {
  50520. err('Missing scheme.');
  50521. invalid.call(this);
  50522. } else {
  50523. state = 'relative';
  50524. continue;
  50525. }
  50526. break;
  50527. case 'relative or authority':
  50528. if (c === '/' && input[cursor + 1] === '/') {
  50529. state = 'authority ignore slashes';
  50530. } else {
  50531. err('Expected /, got: ' + c);
  50532. state = 'relative';
  50533. continue;
  50534. }
  50535. break;
  50536. case 'relative':
  50537. this._isRelative = true;
  50538. if ('file' !== this._scheme) {
  50539. this._scheme = base._scheme;
  50540. }
  50541. if (EOF === c) {
  50542. this._host = base._host;
  50543. this._port = base._port;
  50544. this._path = base._path.slice();
  50545. this._query = base._query;
  50546. this._username = base._username;
  50547. this._password = base._password;
  50548. break loop;
  50549. } else if (c === '/' || c === '\\') {
  50550. if (c === '\\') {
  50551. err('\\ is an invalid code point.');
  50552. }
  50553. state = 'relative slash';
  50554. } else if (c === '?') {
  50555. this._host = base._host;
  50556. this._port = base._port;
  50557. this._path = base._path.slice();
  50558. this._query = '?';
  50559. this._username = base._username;
  50560. this._password = base._password;
  50561. state = 'query';
  50562. } else if (c === '#') {
  50563. this._host = base._host;
  50564. this._port = base._port;
  50565. this._path = base._path.slice();
  50566. this._query = base._query;
  50567. this._fragment = '#';
  50568. this._username = base._username;
  50569. this._password = base._password;
  50570. state = 'fragment';
  50571. } else {
  50572. var nextC = input[cursor + 1];
  50573. var nextNextC = input[cursor + 2];
  50574. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  50575. this._host = base._host;
  50576. this._port = base._port;
  50577. this._username = base._username;
  50578. this._password = base._password;
  50579. this._path = base._path.slice();
  50580. this._path.pop();
  50581. }
  50582. state = 'relative path';
  50583. continue;
  50584. }
  50585. break;
  50586. case 'relative slash':
  50587. if (c === '/' || c === '\\') {
  50588. if (c === '\\') {
  50589. err('\\ is an invalid code point.');
  50590. }
  50591. if (this._scheme === 'file') {
  50592. state = 'file host';
  50593. } else {
  50594. state = 'authority ignore slashes';
  50595. }
  50596. } else {
  50597. if ('file' !== this._scheme) {
  50598. this._host = base._host;
  50599. this._port = base._port;
  50600. this._username = base._username;
  50601. this._password = base._password;
  50602. }
  50603. state = 'relative path';
  50604. continue;
  50605. }
  50606. break;
  50607. case 'authority first slash':
  50608. if (c === '/') {
  50609. state = 'authority second slash';
  50610. } else {
  50611. err('Expected \'/\', got: ' + c);
  50612. state = 'authority ignore slashes';
  50613. continue;
  50614. }
  50615. break;
  50616. case 'authority second slash':
  50617. state = 'authority ignore slashes';
  50618. if ('/' !== c) {
  50619. err('Expected \'/\', got: ' + c);
  50620. continue;
  50621. }
  50622. break;
  50623. case 'authority ignore slashes':
  50624. if ('/' !== c && '\\' !== c) {
  50625. state = 'authority';
  50626. continue;
  50627. } else {
  50628. err('Expected authority, got: ' + c);
  50629. }
  50630. break;
  50631. case 'authority':
  50632. if (c === '@') {
  50633. if (seenAt) {
  50634. err('@ already seen.');
  50635. buffer += '%40';
  50636. }
  50637. seenAt = true;
  50638. for (var i = 0; i < buffer.length; i++) {
  50639. var cp = buffer[i];
  50640. if (cp === '\t' || cp === '\n' || cp === '\r') {
  50641. err('Invalid whitespace in authority.');
  50642. continue;
  50643. }
  50644. if (cp === ':' && this._password === null) {
  50645. this._password = '';
  50646. continue;
  50647. }
  50648. var tempC = percentEscape(cp);
  50649. if (null !== this._password) {
  50650. this._password += tempC;
  50651. } else {
  50652. this._username += tempC;
  50653. }
  50654. }
  50655. buffer = '';
  50656. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  50657. cursor -= buffer.length;
  50658. buffer = '';
  50659. state = 'host';
  50660. continue;
  50661. } else {
  50662. buffer += c;
  50663. }
  50664. break;
  50665. case 'file host':
  50666. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  50667. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  50668. state = 'relative path';
  50669. } else if (buffer.length === 0) {
  50670. state = 'relative path start';
  50671. } else {
  50672. this._host = IDNAToASCII.call(this, buffer);
  50673. buffer = '';
  50674. state = 'relative path start';
  50675. }
  50676. continue;
  50677. } else if (c === '\t' || c === '\n' || c === '\r') {
  50678. err('Invalid whitespace in file host.');
  50679. } else {
  50680. buffer += c;
  50681. }
  50682. break;
  50683. case 'host':
  50684. case 'hostname':
  50685. if (c === ':' && !seenBracket) {
  50686. this._host = IDNAToASCII.call(this, buffer);
  50687. buffer = '';
  50688. state = 'port';
  50689. if (stateOverride === 'hostname') {
  50690. break loop;
  50691. }
  50692. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  50693. this._host = IDNAToASCII.call(this, buffer);
  50694. buffer = '';
  50695. state = 'relative path start';
  50696. if (stateOverride) {
  50697. break loop;
  50698. }
  50699. continue;
  50700. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  50701. if (c === '[') {
  50702. seenBracket = true;
  50703. } else if (c === ']') {
  50704. seenBracket = false;
  50705. }
  50706. buffer += c;
  50707. } else {
  50708. err('Invalid code point in host/hostname: ' + c);
  50709. }
  50710. break;
  50711. case 'port':
  50712. if (/[0-9]/.test(c)) {
  50713. buffer += c;
  50714. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  50715. if ('' !== buffer) {
  50716. var temp = parseInt(buffer, 10);
  50717. if (temp !== relative[this._scheme]) {
  50718. this._port = temp + '';
  50719. }
  50720. buffer = '';
  50721. }
  50722. if (stateOverride) {
  50723. break loop;
  50724. }
  50725. state = 'relative path start';
  50726. continue;
  50727. } else if (c === '\t' || c === '\n' || c === '\r') {
  50728. err('Invalid code point in port: ' + c);
  50729. } else {
  50730. invalid.call(this);
  50731. }
  50732. break;
  50733. case 'relative path start':
  50734. if (c === '\\') {
  50735. err('\'\\\' not allowed in path.');
  50736. }
  50737. state = 'relative path';
  50738. if ('/' !== c && '\\' !== c) {
  50739. continue;
  50740. }
  50741. break;
  50742. case 'relative path':
  50743. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  50744. if (c === '\\') {
  50745. err('\\ not allowed in relative path.');
  50746. }
  50747. var tmp;
  50748. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  50749. buffer = tmp;
  50750. }
  50751. if (buffer === '..') {
  50752. this._path.pop();
  50753. if ('/' !== c && '\\' !== c) {
  50754. this._path.push('');
  50755. }
  50756. } else if (buffer === '.' && '/' !== c && '\\' !== c) {
  50757. this._path.push('');
  50758. } else if ('.' !== buffer) {
  50759. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  50760. buffer = buffer[0] + ':';
  50761. }
  50762. this._path.push(buffer);
  50763. }
  50764. buffer = '';
  50765. if (c === '?') {
  50766. this._query = '?';
  50767. state = 'query';
  50768. } else if (c === '#') {
  50769. this._fragment = '#';
  50770. state = 'fragment';
  50771. }
  50772. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  50773. buffer += percentEscape(c);
  50774. }
  50775. break;
  50776. case 'query':
  50777. if (!stateOverride && c === '#') {
  50778. this._fragment = '#';
  50779. state = 'fragment';
  50780. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  50781. this._query += percentEscapeQuery(c);
  50782. }
  50783. break;
  50784. case 'fragment':
  50785. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  50786. this._fragment += c;
  50787. }
  50788. break;
  50789. }
  50790. cursor++;
  50791. }
  50792. }
  50793. function clear() {
  50794. this._scheme = '';
  50795. this._schemeData = '';
  50796. this._username = '';
  50797. this._password = null;
  50798. this._host = '';
  50799. this._port = '';
  50800. this._path = [];
  50801. this._query = '';
  50802. this._fragment = '';
  50803. this._isInvalid = false;
  50804. this._isRelative = false;
  50805. }
  50806. function JURL(url, base) {
  50807. if (base !== undefined && !(base instanceof JURL)) {
  50808. base = new JURL(String(base));
  50809. }
  50810. this._url = url;
  50811. clear.call(this);
  50812. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  50813. parse.call(this, input, null, base);
  50814. }
  50815. JURL.prototype = {
  50816. toString: function () {
  50817. return this.href;
  50818. },
  50819. get href() {
  50820. if (this._isInvalid) {
  50821. return this._url;
  50822. }
  50823. var authority = '';
  50824. if ('' !== this._username || null !== this._password) {
  50825. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  50826. }
  50827. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  50828. },
  50829. set href(href) {
  50830. clear.call(this);
  50831. parse.call(this, href);
  50832. },
  50833. get protocol() {
  50834. return this._scheme + ':';
  50835. },
  50836. set protocol(protocol) {
  50837. if (this._isInvalid) {
  50838. return;
  50839. }
  50840. parse.call(this, protocol + ':', 'scheme start');
  50841. },
  50842. get host() {
  50843. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  50844. },
  50845. set host(host) {
  50846. if (this._isInvalid || !this._isRelative) {
  50847. return;
  50848. }
  50849. parse.call(this, host, 'host');
  50850. },
  50851. get hostname() {
  50852. return this._host;
  50853. },
  50854. set hostname(hostname) {
  50855. if (this._isInvalid || !this._isRelative) {
  50856. return;
  50857. }
  50858. parse.call(this, hostname, 'hostname');
  50859. },
  50860. get port() {
  50861. return this._port;
  50862. },
  50863. set port(port) {
  50864. if (this._isInvalid || !this._isRelative) {
  50865. return;
  50866. }
  50867. parse.call(this, port, 'port');
  50868. },
  50869. get pathname() {
  50870. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  50871. },
  50872. set pathname(pathname) {
  50873. if (this._isInvalid || !this._isRelative) {
  50874. return;
  50875. }
  50876. this._path = [];
  50877. parse.call(this, pathname, 'relative path start');
  50878. },
  50879. get search() {
  50880. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  50881. },
  50882. set search(search) {
  50883. if (this._isInvalid || !this._isRelative) {
  50884. return;
  50885. }
  50886. this._query = '?';
  50887. if (search[0] === '?') {
  50888. search = search.slice(1);
  50889. }
  50890. parse.call(this, search, 'query');
  50891. },
  50892. get hash() {
  50893. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  50894. },
  50895. set hash(hash) {
  50896. if (this._isInvalid) {
  50897. return;
  50898. }
  50899. this._fragment = '#';
  50900. if (hash[0] === '#') {
  50901. hash = hash.slice(1);
  50902. }
  50903. parse.call(this, hash, 'fragment');
  50904. },
  50905. get origin() {
  50906. var host;
  50907. if (this._isInvalid || !this._scheme) {
  50908. return '';
  50909. }
  50910. switch (this._scheme) {
  50911. case 'data':
  50912. case 'file':
  50913. case 'javascript':
  50914. case 'mailto':
  50915. return 'null';
  50916. }
  50917. host = this.host;
  50918. if (!host) {
  50919. return '';
  50920. }
  50921. return this._scheme + '://' + host;
  50922. }
  50923. };
  50924. var OriginalURL = globalScope.URL;
  50925. if (OriginalURL) {
  50926. JURL.createObjectURL = function (blob) {
  50927. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  50928. };
  50929. JURL.revokeObjectURL = function (url) {
  50930. OriginalURL.revokeObjectURL(url);
  50931. };
  50932. }
  50933. globalScope.URL = JURL;
  50934. }());
  50935. }
  50936. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(9)))
  50937. /***/ }),
  50938. /* 37 */
  50939. /***/ (function(module, exports, __w_pdfjs_require__) {
  50940. "use strict";
  50941. var pdfjsVersion = '1.7.329';
  50942. var pdfjsBuild = '25f772a2';
  50943. var pdfjsCoreWorker = __w_pdfjs_require__(8);
  50944. {
  50945. __w_pdfjs_require__(19);
  50946. }
  50947. exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
  50948. /***/ })
  50949. /******/ ]);
  50950. });