pdf.combined.js 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361
  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.combined", [], factory);
  20. else if(typeof exports === 'object')
  21. exports["pdfjs-dist/build/pdf.combined"] = factory();
  22. else
  23. root["pdfjs-dist/build/pdf.combined"] = root.pdfjsDistBuildPdfCombined = 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 = 47);
  76. /******/ })
  77. /************************************************************************/
  78. /******/ ([
  79. /* 0 */
  80. /***/ (function(module, exports, __w_pdfjs_require__) {
  81. "use strict";
  82. /* WEBPACK VAR INJECTION */(function(global) {
  83. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  84. var FONT_IDENTITY_MATRIX = [
  85. 0.001,
  86. 0,
  87. 0,
  88. 0.001,
  89. 0,
  90. 0
  91. ];
  92. var TextRenderingMode = {
  93. FILL: 0,
  94. STROKE: 1,
  95. FILL_STROKE: 2,
  96. INVISIBLE: 3,
  97. FILL_ADD_TO_PATH: 4,
  98. STROKE_ADD_TO_PATH: 5,
  99. FILL_STROKE_ADD_TO_PATH: 6,
  100. ADD_TO_PATH: 7,
  101. FILL_STROKE_MASK: 3,
  102. ADD_TO_PATH_FLAG: 4
  103. };
  104. var ImageKind = {
  105. GRAYSCALE_1BPP: 1,
  106. RGB_24BPP: 2,
  107. RGBA_32BPP: 3
  108. };
  109. var AnnotationType = {
  110. TEXT: 1,
  111. LINK: 2,
  112. FREETEXT: 3,
  113. LINE: 4,
  114. SQUARE: 5,
  115. CIRCLE: 6,
  116. POLYGON: 7,
  117. POLYLINE: 8,
  118. HIGHLIGHT: 9,
  119. UNDERLINE: 10,
  120. SQUIGGLY: 11,
  121. STRIKEOUT: 12,
  122. STAMP: 13,
  123. CARET: 14,
  124. INK: 15,
  125. POPUP: 16,
  126. FILEATTACHMENT: 17,
  127. SOUND: 18,
  128. MOVIE: 19,
  129. WIDGET: 20,
  130. SCREEN: 21,
  131. PRINTERMARK: 22,
  132. TRAPNET: 23,
  133. WATERMARK: 24,
  134. THREED: 25,
  135. REDACT: 26
  136. };
  137. var AnnotationFlag = {
  138. INVISIBLE: 0x01,
  139. HIDDEN: 0x02,
  140. PRINT: 0x04,
  141. NOZOOM: 0x08,
  142. NOROTATE: 0x10,
  143. NOVIEW: 0x20,
  144. READONLY: 0x40,
  145. LOCKED: 0x80,
  146. TOGGLENOVIEW: 0x100,
  147. LOCKEDCONTENTS: 0x200
  148. };
  149. var AnnotationFieldFlag = {
  150. READONLY: 0x0000001,
  151. REQUIRED: 0x0000002,
  152. NOEXPORT: 0x0000004,
  153. MULTILINE: 0x0001000,
  154. PASSWORD: 0x0002000,
  155. NOTOGGLETOOFF: 0x0004000,
  156. RADIO: 0x0008000,
  157. PUSHBUTTON: 0x0010000,
  158. COMBO: 0x0020000,
  159. EDIT: 0x0040000,
  160. SORT: 0x0080000,
  161. FILESELECT: 0x0100000,
  162. MULTISELECT: 0x0200000,
  163. DONOTSPELLCHECK: 0x0400000,
  164. DONOTSCROLL: 0x0800000,
  165. COMB: 0x1000000,
  166. RICHTEXT: 0x2000000,
  167. RADIOSINUNISON: 0x2000000,
  168. COMMITONSELCHANGE: 0x4000000
  169. };
  170. var AnnotationBorderStyleType = {
  171. SOLID: 1,
  172. DASHED: 2,
  173. BEVELED: 3,
  174. INSET: 4,
  175. UNDERLINE: 5
  176. };
  177. var StreamType = {
  178. UNKNOWN: 0,
  179. FLATE: 1,
  180. LZW: 2,
  181. DCT: 3,
  182. JPX: 4,
  183. JBIG: 5,
  184. A85: 6,
  185. AHX: 7,
  186. CCF: 8,
  187. RL: 9
  188. };
  189. var FontType = {
  190. UNKNOWN: 0,
  191. TYPE1: 1,
  192. TYPE1C: 2,
  193. CIDFONTTYPE0: 3,
  194. CIDFONTTYPE0C: 4,
  195. TRUETYPE: 5,
  196. CIDFONTTYPE2: 6,
  197. TYPE3: 7,
  198. OPENTYPE: 8,
  199. TYPE0: 9,
  200. MMTYPE1: 10
  201. };
  202. var VERBOSITY_LEVELS = {
  203. errors: 0,
  204. warnings: 1,
  205. infos: 5
  206. };
  207. var CMapCompressionType = {
  208. NONE: 0,
  209. BINARY: 1,
  210. STREAM: 2
  211. };
  212. var OPS = {
  213. dependency: 1,
  214. setLineWidth: 2,
  215. setLineCap: 3,
  216. setLineJoin: 4,
  217. setMiterLimit: 5,
  218. setDash: 6,
  219. setRenderingIntent: 7,
  220. setFlatness: 8,
  221. setGState: 9,
  222. save: 10,
  223. restore: 11,
  224. transform: 12,
  225. moveTo: 13,
  226. lineTo: 14,
  227. curveTo: 15,
  228. curveTo2: 16,
  229. curveTo3: 17,
  230. closePath: 18,
  231. rectangle: 19,
  232. stroke: 20,
  233. closeStroke: 21,
  234. fill: 22,
  235. eoFill: 23,
  236. fillStroke: 24,
  237. eoFillStroke: 25,
  238. closeFillStroke: 26,
  239. closeEOFillStroke: 27,
  240. endPath: 28,
  241. clip: 29,
  242. eoClip: 30,
  243. beginText: 31,
  244. endText: 32,
  245. setCharSpacing: 33,
  246. setWordSpacing: 34,
  247. setHScale: 35,
  248. setLeading: 36,
  249. setFont: 37,
  250. setTextRenderingMode: 38,
  251. setTextRise: 39,
  252. moveText: 40,
  253. setLeadingMoveText: 41,
  254. setTextMatrix: 42,
  255. nextLine: 43,
  256. showText: 44,
  257. showSpacedText: 45,
  258. nextLineShowText: 46,
  259. nextLineSetSpacingShowText: 47,
  260. setCharWidth: 48,
  261. setCharWidthAndBounds: 49,
  262. setStrokeColorSpace: 50,
  263. setFillColorSpace: 51,
  264. setStrokeColor: 52,
  265. setStrokeColorN: 53,
  266. setFillColor: 54,
  267. setFillColorN: 55,
  268. setStrokeGray: 56,
  269. setFillGray: 57,
  270. setStrokeRGBColor: 58,
  271. setFillRGBColor: 59,
  272. setStrokeCMYKColor: 60,
  273. setFillCMYKColor: 61,
  274. shadingFill: 62,
  275. beginInlineImage: 63,
  276. beginImageData: 64,
  277. endInlineImage: 65,
  278. paintXObject: 66,
  279. markPoint: 67,
  280. markPointProps: 68,
  281. beginMarkedContent: 69,
  282. beginMarkedContentProps: 70,
  283. endMarkedContent: 71,
  284. beginCompat: 72,
  285. endCompat: 73,
  286. paintFormXObjectBegin: 74,
  287. paintFormXObjectEnd: 75,
  288. beginGroup: 76,
  289. endGroup: 77,
  290. beginAnnotations: 78,
  291. endAnnotations: 79,
  292. beginAnnotation: 80,
  293. endAnnotation: 81,
  294. paintJpegXObject: 82,
  295. paintImageMaskXObject: 83,
  296. paintImageMaskXObjectGroup: 84,
  297. paintImageXObject: 85,
  298. paintInlineImageXObject: 86,
  299. paintInlineImageXObjectGroup: 87,
  300. paintImageXObjectRepeat: 88,
  301. paintImageMaskXObjectRepeat: 89,
  302. paintSolidColorImageMask: 90,
  303. constructPath: 91
  304. };
  305. var verbosity = VERBOSITY_LEVELS.warnings;
  306. function setVerbosityLevel(level) {
  307. verbosity = level;
  308. }
  309. function getVerbosityLevel() {
  310. return verbosity;
  311. }
  312. function info(msg) {
  313. if (verbosity >= VERBOSITY_LEVELS.infos) {
  314. console.log('Info: ' + msg);
  315. }
  316. }
  317. function warn(msg) {
  318. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  319. console.log('Warning: ' + msg);
  320. }
  321. }
  322. function deprecated(details) {
  323. console.log('Deprecated API usage: ' + details);
  324. }
  325. function error(msg) {
  326. if (verbosity >= VERBOSITY_LEVELS.errors) {
  327. console.log('Error: ' + msg);
  328. console.log(backtrace());
  329. }
  330. throw new Error(msg);
  331. }
  332. function backtrace() {
  333. try {
  334. throw new Error();
  335. } catch (e) {
  336. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  337. }
  338. }
  339. function assert(cond, msg) {
  340. if (!cond) {
  341. error(msg);
  342. }
  343. }
  344. var UNSUPPORTED_FEATURES = {
  345. unknown: 'unknown',
  346. forms: 'forms',
  347. javaScript: 'javaScript',
  348. smask: 'smask',
  349. shadingPattern: 'shadingPattern',
  350. font: 'font'
  351. };
  352. function isSameOrigin(baseUrl, otherUrl) {
  353. try {
  354. var base = new URL(baseUrl);
  355. if (!base.origin || base.origin === 'null') {
  356. return false;
  357. }
  358. } catch (e) {
  359. return false;
  360. }
  361. var other = new URL(otherUrl, base);
  362. return base.origin === other.origin;
  363. }
  364. function isValidProtocol(url) {
  365. if (!url) {
  366. return false;
  367. }
  368. switch (url.protocol) {
  369. case 'http:':
  370. case 'https:':
  371. case 'ftp:':
  372. case 'mailto:':
  373. case 'tel:':
  374. return true;
  375. default:
  376. return false;
  377. }
  378. }
  379. function createValidAbsoluteUrl(url, baseUrl) {
  380. if (!url) {
  381. return null;
  382. }
  383. try {
  384. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  385. if (isValidProtocol(absoluteUrl)) {
  386. return absoluteUrl;
  387. }
  388. } catch (ex) {
  389. }
  390. return null;
  391. }
  392. function shadow(obj, prop, value) {
  393. Object.defineProperty(obj, prop, {
  394. value: value,
  395. enumerable: true,
  396. configurable: true,
  397. writable: false
  398. });
  399. return value;
  400. }
  401. function getLookupTableFactory(initializer) {
  402. var lookup;
  403. return function () {
  404. if (initializer) {
  405. lookup = Object.create(null);
  406. initializer(lookup);
  407. initializer = null;
  408. }
  409. return lookup;
  410. };
  411. }
  412. var PasswordResponses = {
  413. NEED_PASSWORD: 1,
  414. INCORRECT_PASSWORD: 2
  415. };
  416. var PasswordException = function PasswordExceptionClosure() {
  417. function PasswordException(msg, code) {
  418. this.name = 'PasswordException';
  419. this.message = msg;
  420. this.code = code;
  421. }
  422. PasswordException.prototype = new Error();
  423. PasswordException.constructor = PasswordException;
  424. return PasswordException;
  425. }();
  426. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  427. function UnknownErrorException(msg, details) {
  428. this.name = 'UnknownErrorException';
  429. this.message = msg;
  430. this.details = details;
  431. }
  432. UnknownErrorException.prototype = new Error();
  433. UnknownErrorException.constructor = UnknownErrorException;
  434. return UnknownErrorException;
  435. }();
  436. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  437. function InvalidPDFException(msg) {
  438. this.name = 'InvalidPDFException';
  439. this.message = msg;
  440. }
  441. InvalidPDFException.prototype = new Error();
  442. InvalidPDFException.constructor = InvalidPDFException;
  443. return InvalidPDFException;
  444. }();
  445. var MissingPDFException = function MissingPDFExceptionClosure() {
  446. function MissingPDFException(msg) {
  447. this.name = 'MissingPDFException';
  448. this.message = msg;
  449. }
  450. MissingPDFException.prototype = new Error();
  451. MissingPDFException.constructor = MissingPDFException;
  452. return MissingPDFException;
  453. }();
  454. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  455. function UnexpectedResponseException(msg, status) {
  456. this.name = 'UnexpectedResponseException';
  457. this.message = msg;
  458. this.status = status;
  459. }
  460. UnexpectedResponseException.prototype = new Error();
  461. UnexpectedResponseException.constructor = UnexpectedResponseException;
  462. return UnexpectedResponseException;
  463. }();
  464. var NotImplementedException = function NotImplementedExceptionClosure() {
  465. function NotImplementedException(msg) {
  466. this.message = msg;
  467. }
  468. NotImplementedException.prototype = new Error();
  469. NotImplementedException.prototype.name = 'NotImplementedException';
  470. NotImplementedException.constructor = NotImplementedException;
  471. return NotImplementedException;
  472. }();
  473. var MissingDataException = function MissingDataExceptionClosure() {
  474. function MissingDataException(begin, end) {
  475. this.begin = begin;
  476. this.end = end;
  477. this.message = 'Missing data [' + begin + ', ' + end + ')';
  478. }
  479. MissingDataException.prototype = new Error();
  480. MissingDataException.prototype.name = 'MissingDataException';
  481. MissingDataException.constructor = MissingDataException;
  482. return MissingDataException;
  483. }();
  484. var XRefParseException = function XRefParseExceptionClosure() {
  485. function XRefParseException(msg) {
  486. this.message = msg;
  487. }
  488. XRefParseException.prototype = new Error();
  489. XRefParseException.prototype.name = 'XRefParseException';
  490. XRefParseException.constructor = XRefParseException;
  491. return XRefParseException;
  492. }();
  493. var NullCharactersRegExp = /\x00/g;
  494. function removeNullCharacters(str) {
  495. if (typeof str !== 'string') {
  496. warn('The argument for removeNullCharacters must be a string.');
  497. return str;
  498. }
  499. return str.replace(NullCharactersRegExp, '');
  500. }
  501. function bytesToString(bytes) {
  502. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  503. var length = bytes.length;
  504. var MAX_ARGUMENT_COUNT = 8192;
  505. if (length < MAX_ARGUMENT_COUNT) {
  506. return String.fromCharCode.apply(null, bytes);
  507. }
  508. var strBuf = [];
  509. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  510. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  511. var chunk = bytes.subarray(i, chunkEnd);
  512. strBuf.push(String.fromCharCode.apply(null, chunk));
  513. }
  514. return strBuf.join('');
  515. }
  516. function stringToBytes(str) {
  517. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  518. var length = str.length;
  519. var bytes = new Uint8Array(length);
  520. for (var i = 0; i < length; ++i) {
  521. bytes[i] = str.charCodeAt(i) & 0xFF;
  522. }
  523. return bytes;
  524. }
  525. function arrayByteLength(arr) {
  526. if (arr.length !== undefined) {
  527. return arr.length;
  528. }
  529. assert(arr.byteLength !== undefined);
  530. return arr.byteLength;
  531. }
  532. function arraysToBytes(arr) {
  533. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  534. return arr[0];
  535. }
  536. var resultLength = 0;
  537. var i, ii = arr.length;
  538. var item, itemLength;
  539. for (i = 0; i < ii; i++) {
  540. item = arr[i];
  541. itemLength = arrayByteLength(item);
  542. resultLength += itemLength;
  543. }
  544. var pos = 0;
  545. var data = new Uint8Array(resultLength);
  546. for (i = 0; i < ii; i++) {
  547. item = arr[i];
  548. if (!(item instanceof Uint8Array)) {
  549. if (typeof item === 'string') {
  550. item = stringToBytes(item);
  551. } else {
  552. item = new Uint8Array(item);
  553. }
  554. }
  555. itemLength = item.byteLength;
  556. data.set(item, pos);
  557. pos += itemLength;
  558. }
  559. return data;
  560. }
  561. function string32(value) {
  562. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  563. }
  564. function log2(x) {
  565. var n = 1, i = 0;
  566. while (x > n) {
  567. n <<= 1;
  568. i++;
  569. }
  570. return i;
  571. }
  572. function readInt8(data, start) {
  573. return data[start] << 24 >> 24;
  574. }
  575. function readUint16(data, offset) {
  576. return data[offset] << 8 | data[offset + 1];
  577. }
  578. function readUint32(data, offset) {
  579. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  580. }
  581. function isLittleEndian() {
  582. var buffer8 = new Uint8Array(2);
  583. buffer8[0] = 1;
  584. var buffer16 = new Uint16Array(buffer8.buffer);
  585. return buffer16[0] === 1;
  586. }
  587. function isEvalSupported() {
  588. try {
  589. new Function('');
  590. return true;
  591. } catch (e) {
  592. return false;
  593. }
  594. }
  595. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  596. function Uint32ArrayView(buffer, length) {
  597. this.buffer = buffer;
  598. this.byteLength = buffer.length;
  599. this.length = length === undefined ? this.byteLength >> 2 : length;
  600. ensureUint32ArrayViewProps(this.length);
  601. }
  602. Uint32ArrayView.prototype = Object.create(null);
  603. var uint32ArrayViewSetters = 0;
  604. function createUint32ArrayProp(index) {
  605. return {
  606. get: function () {
  607. var buffer = this.buffer, offset = index << 2;
  608. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  609. },
  610. set: function (value) {
  611. var buffer = this.buffer, offset = index << 2;
  612. buffer[offset] = value & 255;
  613. buffer[offset + 1] = value >> 8 & 255;
  614. buffer[offset + 2] = value >> 16 & 255;
  615. buffer[offset + 3] = value >>> 24 & 255;
  616. }
  617. };
  618. }
  619. function ensureUint32ArrayViewProps(length) {
  620. while (uint32ArrayViewSetters < length) {
  621. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  622. uint32ArrayViewSetters++;
  623. }
  624. }
  625. return Uint32ArrayView;
  626. }();
  627. exports.Uint32ArrayView = Uint32ArrayView;
  628. var IDENTITY_MATRIX = [
  629. 1,
  630. 0,
  631. 0,
  632. 1,
  633. 0,
  634. 0
  635. ];
  636. var Util = function UtilClosure() {
  637. function Util() {
  638. }
  639. var rgbBuf = [
  640. 'rgb(',
  641. 0,
  642. ',',
  643. 0,
  644. ',',
  645. 0,
  646. ')'
  647. ];
  648. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  649. rgbBuf[1] = r;
  650. rgbBuf[3] = g;
  651. rgbBuf[5] = b;
  652. return rgbBuf.join('');
  653. };
  654. Util.transform = function Util_transform(m1, m2) {
  655. return [
  656. m1[0] * m2[0] + m1[2] * m2[1],
  657. m1[1] * m2[0] + m1[3] * m2[1],
  658. m1[0] * m2[2] + m1[2] * m2[3],
  659. m1[1] * m2[2] + m1[3] * m2[3],
  660. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  661. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  662. ];
  663. };
  664. Util.applyTransform = function Util_applyTransform(p, m) {
  665. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  666. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  667. return [
  668. xt,
  669. yt
  670. ];
  671. };
  672. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  673. var d = m[0] * m[3] - m[1] * m[2];
  674. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  675. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  676. return [
  677. xt,
  678. yt
  679. ];
  680. };
  681. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  682. var p1 = Util.applyTransform(r, m);
  683. var p2 = Util.applyTransform(r.slice(2, 4), m);
  684. var p3 = Util.applyTransform([
  685. r[0],
  686. r[3]
  687. ], m);
  688. var p4 = Util.applyTransform([
  689. r[2],
  690. r[1]
  691. ], m);
  692. return [
  693. Math.min(p1[0], p2[0], p3[0], p4[0]),
  694. Math.min(p1[1], p2[1], p3[1], p4[1]),
  695. Math.max(p1[0], p2[0], p3[0], p4[0]),
  696. Math.max(p1[1], p2[1], p3[1], p4[1])
  697. ];
  698. };
  699. Util.inverseTransform = function Util_inverseTransform(m) {
  700. var d = m[0] * m[3] - m[1] * m[2];
  701. return [
  702. m[3] / d,
  703. -m[1] / d,
  704. -m[2] / d,
  705. m[0] / d,
  706. (m[2] * m[5] - m[4] * m[3]) / d,
  707. (m[4] * m[1] - m[5] * m[0]) / d
  708. ];
  709. };
  710. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  711. return [
  712. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  713. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  714. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  715. ];
  716. };
  717. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  718. var transpose = [
  719. m[0],
  720. m[2],
  721. m[1],
  722. m[3]
  723. ];
  724. var a = m[0] * transpose[0] + m[1] * transpose[2];
  725. var b = m[0] * transpose[1] + m[1] * transpose[3];
  726. var c = m[2] * transpose[0] + m[3] * transpose[2];
  727. var d = m[2] * transpose[1] + m[3] * transpose[3];
  728. var first = (a + d) / 2;
  729. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  730. var sx = first + second || 1;
  731. var sy = first - second || 1;
  732. return [
  733. Math.sqrt(sx),
  734. Math.sqrt(sy)
  735. ];
  736. };
  737. Util.normalizeRect = function Util_normalizeRect(rect) {
  738. var r = rect.slice(0);
  739. if (rect[0] > rect[2]) {
  740. r[0] = rect[2];
  741. r[2] = rect[0];
  742. }
  743. if (rect[1] > rect[3]) {
  744. r[1] = rect[3];
  745. r[3] = rect[1];
  746. }
  747. return r;
  748. };
  749. Util.intersect = function Util_intersect(rect1, rect2) {
  750. function compare(a, b) {
  751. return a - b;
  752. }
  753. var orderedX = [
  754. rect1[0],
  755. rect1[2],
  756. rect2[0],
  757. rect2[2]
  758. ].sort(compare), orderedY = [
  759. rect1[1],
  760. rect1[3],
  761. rect2[1],
  762. rect2[3]
  763. ].sort(compare), result = [];
  764. rect1 = Util.normalizeRect(rect1);
  765. rect2 = Util.normalizeRect(rect2);
  766. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  767. result[0] = orderedX[1];
  768. result[2] = orderedX[2];
  769. } else {
  770. return false;
  771. }
  772. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  773. result[1] = orderedY[1];
  774. result[3] = orderedY[2];
  775. } else {
  776. return false;
  777. }
  778. return result;
  779. };
  780. Util.sign = function Util_sign(num) {
  781. return num < 0 ? -1 : 1;
  782. };
  783. var ROMAN_NUMBER_MAP = [
  784. '',
  785. 'C',
  786. 'CC',
  787. 'CCC',
  788. 'CD',
  789. 'D',
  790. 'DC',
  791. 'DCC',
  792. 'DCCC',
  793. 'CM',
  794. '',
  795. 'X',
  796. 'XX',
  797. 'XXX',
  798. 'XL',
  799. 'L',
  800. 'LX',
  801. 'LXX',
  802. 'LXXX',
  803. 'XC',
  804. '',
  805. 'I',
  806. 'II',
  807. 'III',
  808. 'IV',
  809. 'V',
  810. 'VI',
  811. 'VII',
  812. 'VIII',
  813. 'IX'
  814. ];
  815. Util.toRoman = function Util_toRoman(number, lowerCase) {
  816. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  817. var pos, romanBuf = [];
  818. while (number >= 1000) {
  819. number -= 1000;
  820. romanBuf.push('M');
  821. }
  822. pos = number / 100 | 0;
  823. number %= 100;
  824. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  825. pos = number / 10 | 0;
  826. number %= 10;
  827. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  828. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  829. var romanStr = romanBuf.join('');
  830. return lowerCase ? romanStr.toLowerCase() : romanStr;
  831. };
  832. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  833. Array.prototype.push.apply(arr1, arr2);
  834. };
  835. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  836. Array.prototype.unshift.apply(arr1, arr2);
  837. };
  838. Util.extendObj = function extendObj(obj1, obj2) {
  839. for (var key in obj2) {
  840. obj1[key] = obj2[key];
  841. }
  842. };
  843. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  844. while (dict && !dict.has(name)) {
  845. dict = dict.get('Parent');
  846. }
  847. if (!dict) {
  848. return null;
  849. }
  850. return getArray ? dict.getArray(name) : dict.get(name);
  851. };
  852. Util.inherit = function Util_inherit(sub, base, prototype) {
  853. sub.prototype = Object.create(base.prototype);
  854. sub.prototype.constructor = sub;
  855. for (var prop in prototype) {
  856. sub.prototype[prop] = prototype[prop];
  857. }
  858. };
  859. Util.loadScript = function Util_loadScript(src, callback) {
  860. var script = document.createElement('script');
  861. var loaded = false;
  862. script.setAttribute('src', src);
  863. if (callback) {
  864. script.onload = function () {
  865. if (!loaded) {
  866. callback();
  867. }
  868. loaded = true;
  869. };
  870. }
  871. document.getElementsByTagName('head')[0].appendChild(script);
  872. };
  873. return Util;
  874. }();
  875. var PageViewport = function PageViewportClosure() {
  876. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  877. this.viewBox = viewBox;
  878. this.scale = scale;
  879. this.rotation = rotation;
  880. this.offsetX = offsetX;
  881. this.offsetY = offsetY;
  882. var centerX = (viewBox[2] + viewBox[0]) / 2;
  883. var centerY = (viewBox[3] + viewBox[1]) / 2;
  884. var rotateA, rotateB, rotateC, rotateD;
  885. rotation = rotation % 360;
  886. rotation = rotation < 0 ? rotation + 360 : rotation;
  887. switch (rotation) {
  888. case 180:
  889. rotateA = -1;
  890. rotateB = 0;
  891. rotateC = 0;
  892. rotateD = 1;
  893. break;
  894. case 90:
  895. rotateA = 0;
  896. rotateB = 1;
  897. rotateC = 1;
  898. rotateD = 0;
  899. break;
  900. case 270:
  901. rotateA = 0;
  902. rotateB = -1;
  903. rotateC = -1;
  904. rotateD = 0;
  905. break;
  906. default:
  907. rotateA = 1;
  908. rotateB = 0;
  909. rotateC = 0;
  910. rotateD = -1;
  911. break;
  912. }
  913. if (dontFlip) {
  914. rotateC = -rotateC;
  915. rotateD = -rotateD;
  916. }
  917. var offsetCanvasX, offsetCanvasY;
  918. var width, height;
  919. if (rotateA === 0) {
  920. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  921. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  922. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  923. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  924. } else {
  925. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  926. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  927. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  928. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  929. }
  930. this.transform = [
  931. rotateA * scale,
  932. rotateB * scale,
  933. rotateC * scale,
  934. rotateD * scale,
  935. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  936. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  937. ];
  938. this.width = width;
  939. this.height = height;
  940. this.fontScale = scale;
  941. }
  942. PageViewport.prototype = {
  943. clone: function PageViewPort_clone(args) {
  944. args = args || {};
  945. var scale = 'scale' in args ? args.scale : this.scale;
  946. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  947. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  948. },
  949. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  950. return Util.applyTransform([
  951. x,
  952. y
  953. ], this.transform);
  954. },
  955. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  956. var tl = Util.applyTransform([
  957. rect[0],
  958. rect[1]
  959. ], this.transform);
  960. var br = Util.applyTransform([
  961. rect[2],
  962. rect[3]
  963. ], this.transform);
  964. return [
  965. tl[0],
  966. tl[1],
  967. br[0],
  968. br[1]
  969. ];
  970. },
  971. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  972. return Util.applyInverseTransform([
  973. x,
  974. y
  975. ], this.transform);
  976. }
  977. };
  978. return PageViewport;
  979. }();
  980. var PDFStringTranslateTable = [
  981. 0,
  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. 0x2D8,
  1006. 0x2C7,
  1007. 0x2C6,
  1008. 0x2D9,
  1009. 0x2DD,
  1010. 0x2DB,
  1011. 0x2DA,
  1012. 0x2DC,
  1013. 0,
  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. 0x2022,
  1110. 0x2020,
  1111. 0x2021,
  1112. 0x2026,
  1113. 0x2014,
  1114. 0x2013,
  1115. 0x192,
  1116. 0x2044,
  1117. 0x2039,
  1118. 0x203A,
  1119. 0x2212,
  1120. 0x2030,
  1121. 0x201E,
  1122. 0x201C,
  1123. 0x201D,
  1124. 0x2018,
  1125. 0x2019,
  1126. 0x201A,
  1127. 0x2122,
  1128. 0xFB01,
  1129. 0xFB02,
  1130. 0x141,
  1131. 0x152,
  1132. 0x160,
  1133. 0x178,
  1134. 0x17D,
  1135. 0x131,
  1136. 0x142,
  1137. 0x153,
  1138. 0x161,
  1139. 0x17E,
  1140. 0,
  1141. 0x20AC
  1142. ];
  1143. function stringToPDFString(str) {
  1144. var i, n = str.length, strBuf = [];
  1145. if (str[0] === '\xFE' && str[1] === '\xFF') {
  1146. for (i = 2; i < n; i += 2) {
  1147. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  1148. }
  1149. } else {
  1150. for (i = 0; i < n; ++i) {
  1151. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  1152. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  1153. }
  1154. }
  1155. return strBuf.join('');
  1156. }
  1157. function stringToUTF8String(str) {
  1158. return decodeURIComponent(escape(str));
  1159. }
  1160. function utf8StringToString(str) {
  1161. return unescape(encodeURIComponent(str));
  1162. }
  1163. function isEmptyObj(obj) {
  1164. for (var key in obj) {
  1165. return false;
  1166. }
  1167. return true;
  1168. }
  1169. function isBool(v) {
  1170. return typeof v === 'boolean';
  1171. }
  1172. function isInt(v) {
  1173. return typeof v === 'number' && (v | 0) === v;
  1174. }
  1175. function isNum(v) {
  1176. return typeof v === 'number';
  1177. }
  1178. function isString(v) {
  1179. return typeof v === 'string';
  1180. }
  1181. function isArray(v) {
  1182. return v instanceof Array;
  1183. }
  1184. function isArrayBuffer(v) {
  1185. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  1186. }
  1187. function isSpace(ch) {
  1188. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  1189. }
  1190. function isNodeJS() {
  1191. if (typeof __pdfjsdev_webpack__ === 'undefined') {
  1192. return typeof process === 'object' && process + '' === '[object process]';
  1193. }
  1194. return false;
  1195. }
  1196. function createPromiseCapability() {
  1197. var capability = {};
  1198. capability.promise = new Promise(function (resolve, reject) {
  1199. capability.resolve = resolve;
  1200. capability.reject = reject;
  1201. });
  1202. return capability;
  1203. }
  1204. (function PromiseClosure() {
  1205. if (globalScope.Promise) {
  1206. if (typeof globalScope.Promise.all !== 'function') {
  1207. globalScope.Promise.all = function (iterable) {
  1208. var count = 0, results = [], resolve, reject;
  1209. var promise = new globalScope.Promise(function (resolve_, reject_) {
  1210. resolve = resolve_;
  1211. reject = reject_;
  1212. });
  1213. iterable.forEach(function (p, i) {
  1214. count++;
  1215. p.then(function (result) {
  1216. results[i] = result;
  1217. count--;
  1218. if (count === 0) {
  1219. resolve(results);
  1220. }
  1221. }, reject);
  1222. });
  1223. if (count === 0) {
  1224. resolve(results);
  1225. }
  1226. return promise;
  1227. };
  1228. }
  1229. if (typeof globalScope.Promise.resolve !== 'function') {
  1230. globalScope.Promise.resolve = function (value) {
  1231. return new globalScope.Promise(function (resolve) {
  1232. resolve(value);
  1233. });
  1234. };
  1235. }
  1236. if (typeof globalScope.Promise.reject !== 'function') {
  1237. globalScope.Promise.reject = function (reason) {
  1238. return new globalScope.Promise(function (resolve, reject) {
  1239. reject(reason);
  1240. });
  1241. };
  1242. }
  1243. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  1244. globalScope.Promise.prototype.catch = function (onReject) {
  1245. return globalScope.Promise.prototype.then(undefined, onReject);
  1246. };
  1247. }
  1248. return;
  1249. }
  1250. var STATUS_PENDING = 0;
  1251. var STATUS_RESOLVED = 1;
  1252. var STATUS_REJECTED = 2;
  1253. var REJECTION_TIMEOUT = 500;
  1254. var HandlerManager = {
  1255. handlers: [],
  1256. running: false,
  1257. unhandledRejections: [],
  1258. pendingRejectionCheck: false,
  1259. scheduleHandlers: function scheduleHandlers(promise) {
  1260. if (promise._status === STATUS_PENDING) {
  1261. return;
  1262. }
  1263. this.handlers = this.handlers.concat(promise._handlers);
  1264. promise._handlers = [];
  1265. if (this.running) {
  1266. return;
  1267. }
  1268. this.running = true;
  1269. setTimeout(this.runHandlers.bind(this), 0);
  1270. },
  1271. runHandlers: function runHandlers() {
  1272. var RUN_TIMEOUT = 1;
  1273. var timeoutAt = Date.now() + RUN_TIMEOUT;
  1274. while (this.handlers.length > 0) {
  1275. var handler = this.handlers.shift();
  1276. var nextStatus = handler.thisPromise._status;
  1277. var nextValue = handler.thisPromise._value;
  1278. try {
  1279. if (nextStatus === STATUS_RESOLVED) {
  1280. if (typeof handler.onResolve === 'function') {
  1281. nextValue = handler.onResolve(nextValue);
  1282. }
  1283. } else if (typeof handler.onReject === 'function') {
  1284. nextValue = handler.onReject(nextValue);
  1285. nextStatus = STATUS_RESOLVED;
  1286. if (handler.thisPromise._unhandledRejection) {
  1287. this.removeUnhandeledRejection(handler.thisPromise);
  1288. }
  1289. }
  1290. } catch (ex) {
  1291. nextStatus = STATUS_REJECTED;
  1292. nextValue = ex;
  1293. }
  1294. handler.nextPromise._updateStatus(nextStatus, nextValue);
  1295. if (Date.now() >= timeoutAt) {
  1296. break;
  1297. }
  1298. }
  1299. if (this.handlers.length > 0) {
  1300. setTimeout(this.runHandlers.bind(this), 0);
  1301. return;
  1302. }
  1303. this.running = false;
  1304. },
  1305. addUnhandledRejection: function addUnhandledRejection(promise) {
  1306. this.unhandledRejections.push({
  1307. promise: promise,
  1308. time: Date.now()
  1309. });
  1310. this.scheduleRejectionCheck();
  1311. },
  1312. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  1313. promise._unhandledRejection = false;
  1314. for (var i = 0; i < this.unhandledRejections.length; i++) {
  1315. if (this.unhandledRejections[i].promise === promise) {
  1316. this.unhandledRejections.splice(i);
  1317. i--;
  1318. }
  1319. }
  1320. },
  1321. scheduleRejectionCheck: function scheduleRejectionCheck() {
  1322. if (this.pendingRejectionCheck) {
  1323. return;
  1324. }
  1325. this.pendingRejectionCheck = true;
  1326. setTimeout(function rejectionCheck() {
  1327. this.pendingRejectionCheck = false;
  1328. var now = Date.now();
  1329. for (var i = 0; i < this.unhandledRejections.length; i++) {
  1330. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  1331. var unhandled = this.unhandledRejections[i].promise._value;
  1332. var msg = 'Unhandled rejection: ' + unhandled;
  1333. if (unhandled.stack) {
  1334. msg += '\n' + unhandled.stack;
  1335. }
  1336. warn(msg);
  1337. this.unhandledRejections.splice(i);
  1338. i--;
  1339. }
  1340. }
  1341. if (this.unhandledRejections.length) {
  1342. this.scheduleRejectionCheck();
  1343. }
  1344. }.bind(this), REJECTION_TIMEOUT);
  1345. }
  1346. };
  1347. var Promise = function Promise(resolver) {
  1348. this._status = STATUS_PENDING;
  1349. this._handlers = [];
  1350. try {
  1351. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  1352. } catch (e) {
  1353. this._reject(e);
  1354. }
  1355. };
  1356. Promise.all = function Promise_all(promises) {
  1357. var resolveAll, rejectAll;
  1358. var deferred = new Promise(function (resolve, reject) {
  1359. resolveAll = resolve;
  1360. rejectAll = reject;
  1361. });
  1362. var unresolved = promises.length;
  1363. var results = [];
  1364. if (unresolved === 0) {
  1365. resolveAll(results);
  1366. return deferred;
  1367. }
  1368. function reject(reason) {
  1369. if (deferred._status === STATUS_REJECTED) {
  1370. return;
  1371. }
  1372. results = [];
  1373. rejectAll(reason);
  1374. }
  1375. for (var i = 0, ii = promises.length; i < ii; ++i) {
  1376. var promise = promises[i];
  1377. var resolve = function (i) {
  1378. return function (value) {
  1379. if (deferred._status === STATUS_REJECTED) {
  1380. return;
  1381. }
  1382. results[i] = value;
  1383. unresolved--;
  1384. if (unresolved === 0) {
  1385. resolveAll(results);
  1386. }
  1387. };
  1388. }(i);
  1389. if (Promise.isPromise(promise)) {
  1390. promise.then(resolve, reject);
  1391. } else {
  1392. resolve(promise);
  1393. }
  1394. }
  1395. return deferred;
  1396. };
  1397. Promise.isPromise = function Promise_isPromise(value) {
  1398. return value && typeof value.then === 'function';
  1399. };
  1400. Promise.resolve = function Promise_resolve(value) {
  1401. return new Promise(function (resolve) {
  1402. resolve(value);
  1403. });
  1404. };
  1405. Promise.reject = function Promise_reject(reason) {
  1406. return new Promise(function (resolve, reject) {
  1407. reject(reason);
  1408. });
  1409. };
  1410. Promise.prototype = {
  1411. _status: null,
  1412. _value: null,
  1413. _handlers: null,
  1414. _unhandledRejection: null,
  1415. _updateStatus: function Promise__updateStatus(status, value) {
  1416. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  1417. return;
  1418. }
  1419. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  1420. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  1421. return;
  1422. }
  1423. this._status = status;
  1424. this._value = value;
  1425. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  1426. this._unhandledRejection = true;
  1427. HandlerManager.addUnhandledRejection(this);
  1428. }
  1429. HandlerManager.scheduleHandlers(this);
  1430. },
  1431. _resolve: function Promise_resolve(value) {
  1432. this._updateStatus(STATUS_RESOLVED, value);
  1433. },
  1434. _reject: function Promise_reject(reason) {
  1435. this._updateStatus(STATUS_REJECTED, reason);
  1436. },
  1437. then: function Promise_then(onResolve, onReject) {
  1438. var nextPromise = new Promise(function (resolve, reject) {
  1439. this.resolve = resolve;
  1440. this.reject = reject;
  1441. });
  1442. this._handlers.push({
  1443. thisPromise: this,
  1444. onResolve: onResolve,
  1445. onReject: onReject,
  1446. nextPromise: nextPromise
  1447. });
  1448. HandlerManager.scheduleHandlers(this);
  1449. return nextPromise;
  1450. },
  1451. catch: function Promise_catch(onReject) {
  1452. return this.then(undefined, onReject);
  1453. }
  1454. };
  1455. globalScope.Promise = Promise;
  1456. }());
  1457. (function WeakMapClosure() {
  1458. if (globalScope.WeakMap) {
  1459. return;
  1460. }
  1461. var id = 0;
  1462. function WeakMap() {
  1463. this.id = '$weakmap' + id++;
  1464. }
  1465. WeakMap.prototype = {
  1466. has: function (obj) {
  1467. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  1468. },
  1469. get: function (obj, defaultValue) {
  1470. return this.has(obj) ? obj[this.id] : defaultValue;
  1471. },
  1472. set: function (obj, value) {
  1473. Object.defineProperty(obj, this.id, {
  1474. value: value,
  1475. enumerable: false,
  1476. configurable: true
  1477. });
  1478. },
  1479. delete: function (obj) {
  1480. delete obj[this.id];
  1481. }
  1482. };
  1483. globalScope.WeakMap = WeakMap;
  1484. }());
  1485. var StatTimer = function StatTimerClosure() {
  1486. function rpad(str, pad, length) {
  1487. while (str.length < length) {
  1488. str += pad;
  1489. }
  1490. return str;
  1491. }
  1492. function StatTimer() {
  1493. this.started = Object.create(null);
  1494. this.times = [];
  1495. this.enabled = true;
  1496. }
  1497. StatTimer.prototype = {
  1498. time: function StatTimer_time(name) {
  1499. if (!this.enabled) {
  1500. return;
  1501. }
  1502. if (name in this.started) {
  1503. warn('Timer is already running for ' + name);
  1504. }
  1505. this.started[name] = Date.now();
  1506. },
  1507. timeEnd: function StatTimer_timeEnd(name) {
  1508. if (!this.enabled) {
  1509. return;
  1510. }
  1511. if (!(name in this.started)) {
  1512. warn('Timer has not been started for ' + name);
  1513. }
  1514. this.times.push({
  1515. 'name': name,
  1516. 'start': this.started[name],
  1517. 'end': Date.now()
  1518. });
  1519. delete this.started[name];
  1520. },
  1521. toString: function StatTimer_toString() {
  1522. var i, ii;
  1523. var times = this.times;
  1524. var out = '';
  1525. var longest = 0;
  1526. for (i = 0, ii = times.length; i < ii; ++i) {
  1527. var name = times[i]['name'];
  1528. if (name.length > longest) {
  1529. longest = name.length;
  1530. }
  1531. }
  1532. for (i = 0, ii = times.length; i < ii; ++i) {
  1533. var span = times[i];
  1534. var duration = span.end - span.start;
  1535. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  1536. }
  1537. return out;
  1538. }
  1539. };
  1540. return StatTimer;
  1541. }();
  1542. var createBlob = function createBlob(data, contentType) {
  1543. if (typeof Blob !== 'undefined') {
  1544. return new Blob([data], { type: contentType });
  1545. }
  1546. warn('The "Blob" constructor is not supported.');
  1547. };
  1548. var createObjectURL = function createObjectURLClosure() {
  1549. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1550. return function createObjectURL(data, contentType, forceDataSchema) {
  1551. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  1552. var blob = createBlob(data, contentType);
  1553. return URL.createObjectURL(blob);
  1554. }
  1555. var buffer = 'data:' + contentType + ';base64,';
  1556. for (var i = 0, ii = data.length; i < ii; i += 3) {
  1557. var b1 = data[i] & 0xFF;
  1558. var b2 = data[i + 1] & 0xFF;
  1559. var b3 = data[i + 2] & 0xFF;
  1560. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  1561. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  1562. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  1563. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1564. }
  1565. return buffer;
  1566. };
  1567. }();
  1568. function MessageHandler(sourceName, targetName, comObj) {
  1569. this.sourceName = sourceName;
  1570. this.targetName = targetName;
  1571. this.comObj = comObj;
  1572. this.callbackIndex = 1;
  1573. this.postMessageTransfers = true;
  1574. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1575. var ah = this.actionHandler = Object.create(null);
  1576. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  1577. var data = event.data;
  1578. if (data.targetName !== this.sourceName) {
  1579. return;
  1580. }
  1581. if (data.isReply) {
  1582. var callbackId = data.callbackId;
  1583. if (data.callbackId in callbacksCapabilities) {
  1584. var callback = callbacksCapabilities[callbackId];
  1585. delete callbacksCapabilities[callbackId];
  1586. if ('error' in data) {
  1587. callback.reject(data.error);
  1588. } else {
  1589. callback.resolve(data.data);
  1590. }
  1591. } else {
  1592. error('Cannot resolve callback ' + callbackId);
  1593. }
  1594. } else if (data.action in ah) {
  1595. var action = ah[data.action];
  1596. if (data.callbackId) {
  1597. var sourceName = this.sourceName;
  1598. var targetName = data.sourceName;
  1599. Promise.resolve().then(function () {
  1600. return action[0].call(action[1], data.data);
  1601. }).then(function (result) {
  1602. comObj.postMessage({
  1603. sourceName: sourceName,
  1604. targetName: targetName,
  1605. isReply: true,
  1606. callbackId: data.callbackId,
  1607. data: result
  1608. });
  1609. }, function (reason) {
  1610. if (reason instanceof Error) {
  1611. reason = reason + '';
  1612. }
  1613. comObj.postMessage({
  1614. sourceName: sourceName,
  1615. targetName: targetName,
  1616. isReply: true,
  1617. callbackId: data.callbackId,
  1618. error: reason
  1619. });
  1620. });
  1621. } else {
  1622. action[0].call(action[1], data.data);
  1623. }
  1624. } else {
  1625. error('Unknown action from worker: ' + data.action);
  1626. }
  1627. }.bind(this);
  1628. comObj.addEventListener('message', this._onComObjOnMessage);
  1629. }
  1630. MessageHandler.prototype = {
  1631. on: function messageHandlerOn(actionName, handler, scope) {
  1632. var ah = this.actionHandler;
  1633. if (ah[actionName]) {
  1634. error('There is already an actionName called "' + actionName + '"');
  1635. }
  1636. ah[actionName] = [
  1637. handler,
  1638. scope
  1639. ];
  1640. },
  1641. send: function messageHandlerSend(actionName, data, transfers) {
  1642. var message = {
  1643. sourceName: this.sourceName,
  1644. targetName: this.targetName,
  1645. action: actionName,
  1646. data: data
  1647. };
  1648. this.postMessage(message, transfers);
  1649. },
  1650. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  1651. var callbackId = this.callbackIndex++;
  1652. var message = {
  1653. sourceName: this.sourceName,
  1654. targetName: this.targetName,
  1655. action: actionName,
  1656. data: data,
  1657. callbackId: callbackId
  1658. };
  1659. var capability = createPromiseCapability();
  1660. this.callbacksCapabilities[callbackId] = capability;
  1661. try {
  1662. this.postMessage(message, transfers);
  1663. } catch (e) {
  1664. capability.reject(e);
  1665. }
  1666. return capability.promise;
  1667. },
  1668. postMessage: function (message, transfers) {
  1669. if (transfers && this.postMessageTransfers) {
  1670. this.comObj.postMessage(message, transfers);
  1671. } else {
  1672. this.comObj.postMessage(message);
  1673. }
  1674. },
  1675. destroy: function () {
  1676. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1677. }
  1678. };
  1679. function loadJpegStream(id, imageUrl, objs) {
  1680. var img = new Image();
  1681. img.onload = function loadJpegStream_onloadClosure() {
  1682. objs.resolve(id, img);
  1683. };
  1684. img.onerror = function loadJpegStream_onerrorClosure() {
  1685. objs.resolve(id, null);
  1686. warn('Error during JPEG image loading');
  1687. };
  1688. img.src = imageUrl;
  1689. }
  1690. (function checkURLConstructor(scope) {
  1691. var hasWorkingUrl = false;
  1692. try {
  1693. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  1694. var u = new URL('b', 'http://a');
  1695. u.pathname = 'c%20d';
  1696. hasWorkingUrl = u.href === 'http://a/c%20d';
  1697. }
  1698. } catch (e) {
  1699. }
  1700. if (hasWorkingUrl) {
  1701. return;
  1702. }
  1703. var relative = Object.create(null);
  1704. relative['ftp'] = 21;
  1705. relative['file'] = 0;
  1706. relative['gopher'] = 70;
  1707. relative['http'] = 80;
  1708. relative['https'] = 443;
  1709. relative['ws'] = 80;
  1710. relative['wss'] = 443;
  1711. var relativePathDotMapping = Object.create(null);
  1712. relativePathDotMapping['%2e'] = '.';
  1713. relativePathDotMapping['.%2e'] = '..';
  1714. relativePathDotMapping['%2e.'] = '..';
  1715. relativePathDotMapping['%2e%2e'] = '..';
  1716. function isRelativeScheme(scheme) {
  1717. return relative[scheme] !== undefined;
  1718. }
  1719. function invalid() {
  1720. clear.call(this);
  1721. this._isInvalid = true;
  1722. }
  1723. function IDNAToASCII(h) {
  1724. if (h === '') {
  1725. invalid.call(this);
  1726. }
  1727. return h.toLowerCase();
  1728. }
  1729. function percentEscape(c) {
  1730. var unicode = c.charCodeAt(0);
  1731. if (unicode > 0x20 && unicode < 0x7F && [
  1732. 0x22,
  1733. 0x23,
  1734. 0x3C,
  1735. 0x3E,
  1736. 0x3F,
  1737. 0x60
  1738. ].indexOf(unicode) === -1) {
  1739. return c;
  1740. }
  1741. return encodeURIComponent(c);
  1742. }
  1743. function percentEscapeQuery(c) {
  1744. var unicode = c.charCodeAt(0);
  1745. if (unicode > 0x20 && unicode < 0x7F && [
  1746. 0x22,
  1747. 0x23,
  1748. 0x3C,
  1749. 0x3E,
  1750. 0x60
  1751. ].indexOf(unicode) === -1) {
  1752. return c;
  1753. }
  1754. return encodeURIComponent(c);
  1755. }
  1756. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  1757. function parse(input, stateOverride, base) {
  1758. function err(message) {
  1759. errors.push(message);
  1760. }
  1761. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  1762. loop:
  1763. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  1764. var c = input[cursor];
  1765. switch (state) {
  1766. case 'scheme start':
  1767. if (c && ALPHA.test(c)) {
  1768. buffer += c.toLowerCase();
  1769. state = 'scheme';
  1770. } else if (!stateOverride) {
  1771. buffer = '';
  1772. state = 'no scheme';
  1773. continue;
  1774. } else {
  1775. err('Invalid scheme.');
  1776. break loop;
  1777. }
  1778. break;
  1779. case 'scheme':
  1780. if (c && ALPHANUMERIC.test(c)) {
  1781. buffer += c.toLowerCase();
  1782. } else if (c === ':') {
  1783. this._scheme = buffer;
  1784. buffer = '';
  1785. if (stateOverride) {
  1786. break loop;
  1787. }
  1788. if (isRelativeScheme(this._scheme)) {
  1789. this._isRelative = true;
  1790. }
  1791. if (this._scheme === 'file') {
  1792. state = 'relative';
  1793. } else if (this._isRelative && base && base._scheme === this._scheme) {
  1794. state = 'relative or authority';
  1795. } else if (this._isRelative) {
  1796. state = 'authority first slash';
  1797. } else {
  1798. state = 'scheme data';
  1799. }
  1800. } else if (!stateOverride) {
  1801. buffer = '';
  1802. cursor = 0;
  1803. state = 'no scheme';
  1804. continue;
  1805. } else if (EOF === c) {
  1806. break loop;
  1807. } else {
  1808. err('Code point not allowed in scheme: ' + c);
  1809. break loop;
  1810. }
  1811. break;
  1812. case 'scheme data':
  1813. if (c === '?') {
  1814. this._query = '?';
  1815. state = 'query';
  1816. } else if (c === '#') {
  1817. this._fragment = '#';
  1818. state = 'fragment';
  1819. } else {
  1820. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  1821. this._schemeData += percentEscape(c);
  1822. }
  1823. }
  1824. break;
  1825. case 'no scheme':
  1826. if (!base || !isRelativeScheme(base._scheme)) {
  1827. err('Missing scheme.');
  1828. invalid.call(this);
  1829. } else {
  1830. state = 'relative';
  1831. continue;
  1832. }
  1833. break;
  1834. case 'relative or authority':
  1835. if (c === '/' && input[cursor + 1] === '/') {
  1836. state = 'authority ignore slashes';
  1837. } else {
  1838. err('Expected /, got: ' + c);
  1839. state = 'relative';
  1840. continue;
  1841. }
  1842. break;
  1843. case 'relative':
  1844. this._isRelative = true;
  1845. if ('file' !== this._scheme) {
  1846. this._scheme = base._scheme;
  1847. }
  1848. if (EOF === c) {
  1849. this._host = base._host;
  1850. this._port = base._port;
  1851. this._path = base._path.slice();
  1852. this._query = base._query;
  1853. this._username = base._username;
  1854. this._password = base._password;
  1855. break loop;
  1856. } else if (c === '/' || c === '\\') {
  1857. if (c === '\\') {
  1858. err('\\ is an invalid code point.');
  1859. }
  1860. state = 'relative slash';
  1861. } else if (c === '?') {
  1862. this._host = base._host;
  1863. this._port = base._port;
  1864. this._path = base._path.slice();
  1865. this._query = '?';
  1866. this._username = base._username;
  1867. this._password = base._password;
  1868. state = 'query';
  1869. } else if (c === '#') {
  1870. this._host = base._host;
  1871. this._port = base._port;
  1872. this._path = base._path.slice();
  1873. this._query = base._query;
  1874. this._fragment = '#';
  1875. this._username = base._username;
  1876. this._password = base._password;
  1877. state = 'fragment';
  1878. } else {
  1879. var nextC = input[cursor + 1];
  1880. var nextNextC = input[cursor + 2];
  1881. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  1882. this._host = base._host;
  1883. this._port = base._port;
  1884. this._username = base._username;
  1885. this._password = base._password;
  1886. this._path = base._path.slice();
  1887. this._path.pop();
  1888. }
  1889. state = 'relative path';
  1890. continue;
  1891. }
  1892. break;
  1893. case 'relative slash':
  1894. if (c === '/' || c === '\\') {
  1895. if (c === '\\') {
  1896. err('\\ is an invalid code point.');
  1897. }
  1898. if (this._scheme === 'file') {
  1899. state = 'file host';
  1900. } else {
  1901. state = 'authority ignore slashes';
  1902. }
  1903. } else {
  1904. if ('file' !== this._scheme) {
  1905. this._host = base._host;
  1906. this._port = base._port;
  1907. this._username = base._username;
  1908. this._password = base._password;
  1909. }
  1910. state = 'relative path';
  1911. continue;
  1912. }
  1913. break;
  1914. case 'authority first slash':
  1915. if (c === '/') {
  1916. state = 'authority second slash';
  1917. } else {
  1918. err('Expected \'/\', got: ' + c);
  1919. state = 'authority ignore slashes';
  1920. continue;
  1921. }
  1922. break;
  1923. case 'authority second slash':
  1924. state = 'authority ignore slashes';
  1925. if ('/' !== c) {
  1926. err('Expected \'/\', got: ' + c);
  1927. continue;
  1928. }
  1929. break;
  1930. case 'authority ignore slashes':
  1931. if ('/' !== c && '\\' !== c) {
  1932. state = 'authority';
  1933. continue;
  1934. } else {
  1935. err('Expected authority, got: ' + c);
  1936. }
  1937. break;
  1938. case 'authority':
  1939. if (c === '@') {
  1940. if (seenAt) {
  1941. err('@ already seen.');
  1942. buffer += '%40';
  1943. }
  1944. seenAt = true;
  1945. for (var i = 0; i < buffer.length; i++) {
  1946. var cp = buffer[i];
  1947. if (cp === '\t' || cp === '\n' || cp === '\r') {
  1948. err('Invalid whitespace in authority.');
  1949. continue;
  1950. }
  1951. if (cp === ':' && this._password === null) {
  1952. this._password = '';
  1953. continue;
  1954. }
  1955. var tempC = percentEscape(cp);
  1956. if (null !== this._password) {
  1957. this._password += tempC;
  1958. } else {
  1959. this._username += tempC;
  1960. }
  1961. }
  1962. buffer = '';
  1963. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  1964. cursor -= buffer.length;
  1965. buffer = '';
  1966. state = 'host';
  1967. continue;
  1968. } else {
  1969. buffer += c;
  1970. }
  1971. break;
  1972. case 'file host':
  1973. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  1974. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  1975. state = 'relative path';
  1976. } else if (buffer.length === 0) {
  1977. state = 'relative path start';
  1978. } else {
  1979. this._host = IDNAToASCII.call(this, buffer);
  1980. buffer = '';
  1981. state = 'relative path start';
  1982. }
  1983. continue;
  1984. } else if (c === '\t' || c === '\n' || c === '\r') {
  1985. err('Invalid whitespace in file host.');
  1986. } else {
  1987. buffer += c;
  1988. }
  1989. break;
  1990. case 'host':
  1991. case 'hostname':
  1992. if (c === ':' && !seenBracket) {
  1993. this._host = IDNAToASCII.call(this, buffer);
  1994. buffer = '';
  1995. state = 'port';
  1996. if (stateOverride === 'hostname') {
  1997. break loop;
  1998. }
  1999. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  2000. this._host = IDNAToASCII.call(this, buffer);
  2001. buffer = '';
  2002. state = 'relative path start';
  2003. if (stateOverride) {
  2004. break loop;
  2005. }
  2006. continue;
  2007. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  2008. if (c === '[') {
  2009. seenBracket = true;
  2010. } else if (c === ']') {
  2011. seenBracket = false;
  2012. }
  2013. buffer += c;
  2014. } else {
  2015. err('Invalid code point in host/hostname: ' + c);
  2016. }
  2017. break;
  2018. case 'port':
  2019. if (/[0-9]/.test(c)) {
  2020. buffer += c;
  2021. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  2022. if ('' !== buffer) {
  2023. var temp = parseInt(buffer, 10);
  2024. if (temp !== relative[this._scheme]) {
  2025. this._port = temp + '';
  2026. }
  2027. buffer = '';
  2028. }
  2029. if (stateOverride) {
  2030. break loop;
  2031. }
  2032. state = 'relative path start';
  2033. continue;
  2034. } else if (c === '\t' || c === '\n' || c === '\r') {
  2035. err('Invalid code point in port: ' + c);
  2036. } else {
  2037. invalid.call(this);
  2038. }
  2039. break;
  2040. case 'relative path start':
  2041. if (c === '\\') {
  2042. err('\'\\\' not allowed in path.');
  2043. }
  2044. state = 'relative path';
  2045. if ('/' !== c && '\\' !== c) {
  2046. continue;
  2047. }
  2048. break;
  2049. case 'relative path':
  2050. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  2051. if (c === '\\') {
  2052. err('\\ not allowed in relative path.');
  2053. }
  2054. var tmp;
  2055. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  2056. buffer = tmp;
  2057. }
  2058. if (buffer === '..') {
  2059. this._path.pop();
  2060. if ('/' !== c && '\\' !== c) {
  2061. this._path.push('');
  2062. }
  2063. } else if (buffer === '.' && '/' !== c && '\\' !== c) {
  2064. this._path.push('');
  2065. } else if ('.' !== buffer) {
  2066. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  2067. buffer = buffer[0] + ':';
  2068. }
  2069. this._path.push(buffer);
  2070. }
  2071. buffer = '';
  2072. if (c === '?') {
  2073. this._query = '?';
  2074. state = 'query';
  2075. } else if (c === '#') {
  2076. this._fragment = '#';
  2077. state = 'fragment';
  2078. }
  2079. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  2080. buffer += percentEscape(c);
  2081. }
  2082. break;
  2083. case 'query':
  2084. if (!stateOverride && c === '#') {
  2085. this._fragment = '#';
  2086. state = 'fragment';
  2087. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  2088. this._query += percentEscapeQuery(c);
  2089. }
  2090. break;
  2091. case 'fragment':
  2092. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  2093. this._fragment += c;
  2094. }
  2095. break;
  2096. }
  2097. cursor++;
  2098. }
  2099. }
  2100. function clear() {
  2101. this._scheme = '';
  2102. this._schemeData = '';
  2103. this._username = '';
  2104. this._password = null;
  2105. this._host = '';
  2106. this._port = '';
  2107. this._path = [];
  2108. this._query = '';
  2109. this._fragment = '';
  2110. this._isInvalid = false;
  2111. this._isRelative = false;
  2112. }
  2113. function JURL(url, base) {
  2114. if (base !== undefined && !(base instanceof JURL)) {
  2115. base = new JURL(String(base));
  2116. }
  2117. this._url = url;
  2118. clear.call(this);
  2119. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  2120. parse.call(this, input, null, base);
  2121. }
  2122. JURL.prototype = {
  2123. toString: function () {
  2124. return this.href;
  2125. },
  2126. get href() {
  2127. if (this._isInvalid) {
  2128. return this._url;
  2129. }
  2130. var authority = '';
  2131. if ('' !== this._username || null !== this._password) {
  2132. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  2133. }
  2134. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  2135. },
  2136. set href(href) {
  2137. clear.call(this);
  2138. parse.call(this, href);
  2139. },
  2140. get protocol() {
  2141. return this._scheme + ':';
  2142. },
  2143. set protocol(protocol) {
  2144. if (this._isInvalid) {
  2145. return;
  2146. }
  2147. parse.call(this, protocol + ':', 'scheme start');
  2148. },
  2149. get host() {
  2150. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  2151. },
  2152. set host(host) {
  2153. if (this._isInvalid || !this._isRelative) {
  2154. return;
  2155. }
  2156. parse.call(this, host, 'host');
  2157. },
  2158. get hostname() {
  2159. return this._host;
  2160. },
  2161. set hostname(hostname) {
  2162. if (this._isInvalid || !this._isRelative) {
  2163. return;
  2164. }
  2165. parse.call(this, hostname, 'hostname');
  2166. },
  2167. get port() {
  2168. return this._port;
  2169. },
  2170. set port(port) {
  2171. if (this._isInvalid || !this._isRelative) {
  2172. return;
  2173. }
  2174. parse.call(this, port, 'port');
  2175. },
  2176. get pathname() {
  2177. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  2178. },
  2179. set pathname(pathname) {
  2180. if (this._isInvalid || !this._isRelative) {
  2181. return;
  2182. }
  2183. this._path = [];
  2184. parse.call(this, pathname, 'relative path start');
  2185. },
  2186. get search() {
  2187. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  2188. },
  2189. set search(search) {
  2190. if (this._isInvalid || !this._isRelative) {
  2191. return;
  2192. }
  2193. this._query = '?';
  2194. if (search[0] === '?') {
  2195. search = search.slice(1);
  2196. }
  2197. parse.call(this, search, 'query');
  2198. },
  2199. get hash() {
  2200. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  2201. },
  2202. set hash(hash) {
  2203. if (this._isInvalid) {
  2204. return;
  2205. }
  2206. this._fragment = '#';
  2207. if (hash[0] === '#') {
  2208. hash = hash.slice(1);
  2209. }
  2210. parse.call(this, hash, 'fragment');
  2211. },
  2212. get origin() {
  2213. var host;
  2214. if (this._isInvalid || !this._scheme) {
  2215. return '';
  2216. }
  2217. switch (this._scheme) {
  2218. case 'data':
  2219. case 'file':
  2220. case 'javascript':
  2221. case 'mailto':
  2222. return 'null';
  2223. }
  2224. host = this.host;
  2225. if (!host) {
  2226. return '';
  2227. }
  2228. return this._scheme + '://' + host;
  2229. }
  2230. };
  2231. var OriginalURL = scope.URL;
  2232. if (OriginalURL) {
  2233. JURL.createObjectURL = function (blob) {
  2234. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  2235. };
  2236. JURL.revokeObjectURL = function (url) {
  2237. OriginalURL.revokeObjectURL(url);
  2238. };
  2239. }
  2240. scope.URL = JURL;
  2241. }(globalScope));
  2242. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  2243. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  2244. exports.OPS = OPS;
  2245. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  2246. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  2247. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  2248. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  2249. exports.AnnotationFlag = AnnotationFlag;
  2250. exports.AnnotationType = AnnotationType;
  2251. exports.FontType = FontType;
  2252. exports.ImageKind = ImageKind;
  2253. exports.CMapCompressionType = CMapCompressionType;
  2254. exports.InvalidPDFException = InvalidPDFException;
  2255. exports.MessageHandler = MessageHandler;
  2256. exports.MissingDataException = MissingDataException;
  2257. exports.MissingPDFException = MissingPDFException;
  2258. exports.NotImplementedException = NotImplementedException;
  2259. exports.PageViewport = PageViewport;
  2260. exports.PasswordException = PasswordException;
  2261. exports.PasswordResponses = PasswordResponses;
  2262. exports.StatTimer = StatTimer;
  2263. exports.StreamType = StreamType;
  2264. exports.TextRenderingMode = TextRenderingMode;
  2265. exports.UnexpectedResponseException = UnexpectedResponseException;
  2266. exports.UnknownErrorException = UnknownErrorException;
  2267. exports.Util = Util;
  2268. exports.XRefParseException = XRefParseException;
  2269. exports.arrayByteLength = arrayByteLength;
  2270. exports.arraysToBytes = arraysToBytes;
  2271. exports.assert = assert;
  2272. exports.bytesToString = bytesToString;
  2273. exports.createBlob = createBlob;
  2274. exports.createPromiseCapability = createPromiseCapability;
  2275. exports.createObjectURL = createObjectURL;
  2276. exports.deprecated = deprecated;
  2277. exports.error = error;
  2278. exports.getLookupTableFactory = getLookupTableFactory;
  2279. exports.getVerbosityLevel = getVerbosityLevel;
  2280. exports.globalScope = globalScope;
  2281. exports.info = info;
  2282. exports.isArray = isArray;
  2283. exports.isArrayBuffer = isArrayBuffer;
  2284. exports.isBool = isBool;
  2285. exports.isEmptyObj = isEmptyObj;
  2286. exports.isInt = isInt;
  2287. exports.isNum = isNum;
  2288. exports.isString = isString;
  2289. exports.isSpace = isSpace;
  2290. exports.isNodeJS = isNodeJS;
  2291. exports.isSameOrigin = isSameOrigin;
  2292. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  2293. exports.isLittleEndian = isLittleEndian;
  2294. exports.isEvalSupported = isEvalSupported;
  2295. exports.loadJpegStream = loadJpegStream;
  2296. exports.log2 = log2;
  2297. exports.readInt8 = readInt8;
  2298. exports.readUint16 = readUint16;
  2299. exports.readUint32 = readUint32;
  2300. exports.removeNullCharacters = removeNullCharacters;
  2301. exports.setVerbosityLevel = setVerbosityLevel;
  2302. exports.shadow = shadow;
  2303. exports.string32 = string32;
  2304. exports.stringToBytes = stringToBytes;
  2305. exports.stringToPDFString = stringToPDFString;
  2306. exports.stringToUTF8String = stringToUTF8String;
  2307. exports.utf8StringToString = utf8StringToString;
  2308. exports.warn = warn;
  2309. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(26)))
  2310. /***/ }),
  2311. /* 1 */
  2312. /***/ (function(module, exports, __w_pdfjs_require__) {
  2313. "use strict";
  2314. var sharedUtil = __w_pdfjs_require__(0);
  2315. var isArray = sharedUtil.isArray;
  2316. var EOF = {};
  2317. var Name = function NameClosure() {
  2318. function Name(name) {
  2319. this.name = name;
  2320. }
  2321. Name.prototype = {};
  2322. var nameCache = Object.create(null);
  2323. Name.get = function Name_get(name) {
  2324. var nameValue = nameCache[name];
  2325. return nameValue ? nameValue : nameCache[name] = new Name(name);
  2326. };
  2327. return Name;
  2328. }();
  2329. var Cmd = function CmdClosure() {
  2330. function Cmd(cmd) {
  2331. this.cmd = cmd;
  2332. }
  2333. Cmd.prototype = {};
  2334. var cmdCache = Object.create(null);
  2335. Cmd.get = function Cmd_get(cmd) {
  2336. var cmdValue = cmdCache[cmd];
  2337. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  2338. };
  2339. return Cmd;
  2340. }();
  2341. var Dict = function DictClosure() {
  2342. var nonSerializable = function nonSerializableClosure() {
  2343. return nonSerializable;
  2344. };
  2345. function Dict(xref) {
  2346. this.map = Object.create(null);
  2347. this.xref = xref;
  2348. this.objId = null;
  2349. this.suppressEncryption = false;
  2350. this.__nonSerializable__ = nonSerializable;
  2351. }
  2352. Dict.prototype = {
  2353. assignXref: function Dict_assignXref(newXref) {
  2354. this.xref = newXref;
  2355. },
  2356. get: function Dict_get(key1, key2, key3) {
  2357. var value;
  2358. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2359. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  2360. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2361. }
  2362. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  2363. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2364. }
  2365. value = this.map[key3] || null;
  2366. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2367. },
  2368. getAsync: function Dict_getAsync(key1, key2, key3) {
  2369. var value;
  2370. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2371. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  2372. if (xref) {
  2373. return xref.fetchIfRefAsync(value, suppressEncryption);
  2374. }
  2375. return Promise.resolve(value);
  2376. }
  2377. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  2378. if (xref) {
  2379. return xref.fetchIfRefAsync(value, suppressEncryption);
  2380. }
  2381. return Promise.resolve(value);
  2382. }
  2383. value = this.map[key3] || null;
  2384. if (xref) {
  2385. return xref.fetchIfRefAsync(value, suppressEncryption);
  2386. }
  2387. return Promise.resolve(value);
  2388. },
  2389. getArray: function Dict_getArray(key1, key2, key3) {
  2390. var value = this.get(key1, key2, key3);
  2391. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2392. if (!isArray(value) || !xref) {
  2393. return value;
  2394. }
  2395. value = value.slice();
  2396. for (var i = 0, ii = value.length; i < ii; i++) {
  2397. if (!isRef(value[i])) {
  2398. continue;
  2399. }
  2400. value[i] = xref.fetch(value[i], suppressEncryption);
  2401. }
  2402. return value;
  2403. },
  2404. getRaw: function Dict_getRaw(key) {
  2405. return this.map[key];
  2406. },
  2407. getKeys: function Dict_getKeys() {
  2408. return Object.keys(this.map);
  2409. },
  2410. set: function Dict_set(key, value) {
  2411. this.map[key] = value;
  2412. },
  2413. has: function Dict_has(key) {
  2414. return key in this.map;
  2415. },
  2416. forEach: function Dict_forEach(callback) {
  2417. for (var key in this.map) {
  2418. callback(key, this.get(key));
  2419. }
  2420. }
  2421. };
  2422. Dict.empty = new Dict(null);
  2423. Dict.merge = function Dict_merge(xref, dictArray) {
  2424. var mergedDict = new Dict(xref);
  2425. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  2426. var dict = dictArray[i];
  2427. if (!isDict(dict)) {
  2428. continue;
  2429. }
  2430. for (var keyName in dict.map) {
  2431. if (mergedDict.map[keyName]) {
  2432. continue;
  2433. }
  2434. mergedDict.map[keyName] = dict.map[keyName];
  2435. }
  2436. }
  2437. return mergedDict;
  2438. };
  2439. return Dict;
  2440. }();
  2441. var Ref = function RefClosure() {
  2442. function Ref(num, gen) {
  2443. this.num = num;
  2444. this.gen = gen;
  2445. }
  2446. Ref.prototype = {
  2447. toString: function Ref_toString() {
  2448. var str = this.num + 'R';
  2449. if (this.gen !== 0) {
  2450. str += this.gen;
  2451. }
  2452. return str;
  2453. }
  2454. };
  2455. return Ref;
  2456. }();
  2457. var RefSet = function RefSetClosure() {
  2458. function RefSet() {
  2459. this.dict = Object.create(null);
  2460. }
  2461. RefSet.prototype = {
  2462. has: function RefSet_has(ref) {
  2463. return ref.toString() in this.dict;
  2464. },
  2465. put: function RefSet_put(ref) {
  2466. this.dict[ref.toString()] = true;
  2467. },
  2468. remove: function RefSet_remove(ref) {
  2469. delete this.dict[ref.toString()];
  2470. }
  2471. };
  2472. return RefSet;
  2473. }();
  2474. var RefSetCache = function RefSetCacheClosure() {
  2475. function RefSetCache() {
  2476. this.dict = Object.create(null);
  2477. }
  2478. RefSetCache.prototype = {
  2479. get: function RefSetCache_get(ref) {
  2480. return this.dict[ref.toString()];
  2481. },
  2482. has: function RefSetCache_has(ref) {
  2483. return ref.toString() in this.dict;
  2484. },
  2485. put: function RefSetCache_put(ref, obj) {
  2486. this.dict[ref.toString()] = obj;
  2487. },
  2488. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  2489. this.dict[ref.toString()] = this.get(aliasRef);
  2490. },
  2491. forEach: function RefSetCache_forEach(fn, thisArg) {
  2492. for (var i in this.dict) {
  2493. fn.call(thisArg, this.dict[i]);
  2494. }
  2495. },
  2496. clear: function RefSetCache_clear() {
  2497. this.dict = Object.create(null);
  2498. }
  2499. };
  2500. return RefSetCache;
  2501. }();
  2502. function isEOF(v) {
  2503. return v === EOF;
  2504. }
  2505. function isName(v, name) {
  2506. return v instanceof Name && (name === undefined || v.name === name);
  2507. }
  2508. function isCmd(v, cmd) {
  2509. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  2510. }
  2511. function isDict(v, type) {
  2512. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  2513. }
  2514. function isRef(v) {
  2515. return v instanceof Ref;
  2516. }
  2517. function isRefsEqual(v1, v2) {
  2518. return v1.num === v2.num && v1.gen === v2.gen;
  2519. }
  2520. function isStream(v) {
  2521. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  2522. }
  2523. exports.EOF = EOF;
  2524. exports.Cmd = Cmd;
  2525. exports.Dict = Dict;
  2526. exports.Name = Name;
  2527. exports.Ref = Ref;
  2528. exports.RefSet = RefSet;
  2529. exports.RefSetCache = RefSetCache;
  2530. exports.isEOF = isEOF;
  2531. exports.isCmd = isCmd;
  2532. exports.isDict = isDict;
  2533. exports.isName = isName;
  2534. exports.isRef = isRef;
  2535. exports.isRefsEqual = isRefsEqual;
  2536. exports.isStream = isStream;
  2537. /***/ }),
  2538. /* 2 */
  2539. /***/ (function(module, exports, __w_pdfjs_require__) {
  2540. "use strict";
  2541. var sharedUtil = __w_pdfjs_require__(0);
  2542. var corePrimitives = __w_pdfjs_require__(1);
  2543. var coreJbig2 = __w_pdfjs_require__(35);
  2544. var coreJpg = __w_pdfjs_require__(36);
  2545. var coreJpx = __w_pdfjs_require__(18);
  2546. var Util = sharedUtil.Util;
  2547. var error = sharedUtil.error;
  2548. var info = sharedUtil.info;
  2549. var isInt = sharedUtil.isInt;
  2550. var isArray = sharedUtil.isArray;
  2551. var createObjectURL = sharedUtil.createObjectURL;
  2552. var shadow = sharedUtil.shadow;
  2553. var isSpace = sharedUtil.isSpace;
  2554. var Dict = corePrimitives.Dict;
  2555. var isDict = corePrimitives.isDict;
  2556. var isStream = corePrimitives.isStream;
  2557. var Jbig2Image = coreJbig2.Jbig2Image;
  2558. var JpegImage = coreJpg.JpegImage;
  2559. var JpxImage = coreJpx.JpxImage;
  2560. var Stream = function StreamClosure() {
  2561. function Stream(arrayBuffer, start, length, dict) {
  2562. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  2563. this.start = start || 0;
  2564. this.pos = this.start;
  2565. this.end = start + length || this.bytes.length;
  2566. this.dict = dict;
  2567. }
  2568. Stream.prototype = {
  2569. get length() {
  2570. return this.end - this.start;
  2571. },
  2572. get isEmpty() {
  2573. return this.length === 0;
  2574. },
  2575. getByte: function Stream_getByte() {
  2576. if (this.pos >= this.end) {
  2577. return -1;
  2578. }
  2579. return this.bytes[this.pos++];
  2580. },
  2581. getUint16: function Stream_getUint16() {
  2582. var b0 = this.getByte();
  2583. var b1 = this.getByte();
  2584. if (b0 === -1 || b1 === -1) {
  2585. return -1;
  2586. }
  2587. return (b0 << 8) + b1;
  2588. },
  2589. getInt32: function Stream_getInt32() {
  2590. var b0 = this.getByte();
  2591. var b1 = this.getByte();
  2592. var b2 = this.getByte();
  2593. var b3 = this.getByte();
  2594. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  2595. },
  2596. getBytes: function Stream_getBytes(length) {
  2597. var bytes = this.bytes;
  2598. var pos = this.pos;
  2599. var strEnd = this.end;
  2600. if (!length) {
  2601. return bytes.subarray(pos, strEnd);
  2602. }
  2603. var end = pos + length;
  2604. if (end > strEnd) {
  2605. end = strEnd;
  2606. }
  2607. this.pos = end;
  2608. return bytes.subarray(pos, end);
  2609. },
  2610. peekByte: function Stream_peekByte() {
  2611. var peekedByte = this.getByte();
  2612. this.pos--;
  2613. return peekedByte;
  2614. },
  2615. peekBytes: function Stream_peekBytes(length) {
  2616. var bytes = this.getBytes(length);
  2617. this.pos -= bytes.length;
  2618. return bytes;
  2619. },
  2620. skip: function Stream_skip(n) {
  2621. if (!n) {
  2622. n = 1;
  2623. }
  2624. this.pos += n;
  2625. },
  2626. reset: function Stream_reset() {
  2627. this.pos = this.start;
  2628. },
  2629. moveStart: function Stream_moveStart() {
  2630. this.start = this.pos;
  2631. },
  2632. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  2633. return new Stream(this.bytes.buffer, start, length, dict);
  2634. }
  2635. };
  2636. return Stream;
  2637. }();
  2638. var StringStream = function StringStreamClosure() {
  2639. function StringStream(str) {
  2640. var length = str.length;
  2641. var bytes = new Uint8Array(length);
  2642. for (var n = 0; n < length; ++n) {
  2643. bytes[n] = str.charCodeAt(n);
  2644. }
  2645. Stream.call(this, bytes);
  2646. }
  2647. StringStream.prototype = Stream.prototype;
  2648. return StringStream;
  2649. }();
  2650. var DecodeStream = function DecodeStreamClosure() {
  2651. var emptyBuffer = new Uint8Array(0);
  2652. function DecodeStream(maybeMinBufferLength) {
  2653. this.pos = 0;
  2654. this.bufferLength = 0;
  2655. this.eof = false;
  2656. this.buffer = emptyBuffer;
  2657. this.minBufferLength = 512;
  2658. if (maybeMinBufferLength) {
  2659. while (this.minBufferLength < maybeMinBufferLength) {
  2660. this.minBufferLength *= 2;
  2661. }
  2662. }
  2663. }
  2664. DecodeStream.prototype = {
  2665. get isEmpty() {
  2666. while (!this.eof && this.bufferLength === 0) {
  2667. this.readBlock();
  2668. }
  2669. return this.bufferLength === 0;
  2670. },
  2671. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  2672. var buffer = this.buffer;
  2673. if (requested <= buffer.byteLength) {
  2674. return buffer;
  2675. }
  2676. var size = this.minBufferLength;
  2677. while (size < requested) {
  2678. size *= 2;
  2679. }
  2680. var buffer2 = new Uint8Array(size);
  2681. buffer2.set(buffer);
  2682. return this.buffer = buffer2;
  2683. },
  2684. getByte: function DecodeStream_getByte() {
  2685. var pos = this.pos;
  2686. while (this.bufferLength <= pos) {
  2687. if (this.eof) {
  2688. return -1;
  2689. }
  2690. this.readBlock();
  2691. }
  2692. return this.buffer[this.pos++];
  2693. },
  2694. getUint16: function DecodeStream_getUint16() {
  2695. var b0 = this.getByte();
  2696. var b1 = this.getByte();
  2697. if (b0 === -1 || b1 === -1) {
  2698. return -1;
  2699. }
  2700. return (b0 << 8) + b1;
  2701. },
  2702. getInt32: function DecodeStream_getInt32() {
  2703. var b0 = this.getByte();
  2704. var b1 = this.getByte();
  2705. var b2 = this.getByte();
  2706. var b3 = this.getByte();
  2707. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  2708. },
  2709. getBytes: function DecodeStream_getBytes(length) {
  2710. var end, pos = this.pos;
  2711. if (length) {
  2712. this.ensureBuffer(pos + length);
  2713. end = pos + length;
  2714. while (!this.eof && this.bufferLength < end) {
  2715. this.readBlock();
  2716. }
  2717. var bufEnd = this.bufferLength;
  2718. if (end > bufEnd) {
  2719. end = bufEnd;
  2720. }
  2721. } else {
  2722. while (!this.eof) {
  2723. this.readBlock();
  2724. }
  2725. end = this.bufferLength;
  2726. }
  2727. this.pos = end;
  2728. return this.buffer.subarray(pos, end);
  2729. },
  2730. peekByte: function DecodeStream_peekByte() {
  2731. var peekedByte = this.getByte();
  2732. this.pos--;
  2733. return peekedByte;
  2734. },
  2735. peekBytes: function DecodeStream_peekBytes(length) {
  2736. var bytes = this.getBytes(length);
  2737. this.pos -= bytes.length;
  2738. return bytes;
  2739. },
  2740. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  2741. var end = start + length;
  2742. while (this.bufferLength <= end && !this.eof) {
  2743. this.readBlock();
  2744. }
  2745. return new Stream(this.buffer, start, length, dict);
  2746. },
  2747. skip: function DecodeStream_skip(n) {
  2748. if (!n) {
  2749. n = 1;
  2750. }
  2751. this.pos += n;
  2752. },
  2753. reset: function DecodeStream_reset() {
  2754. this.pos = 0;
  2755. },
  2756. getBaseStreams: function DecodeStream_getBaseStreams() {
  2757. if (this.str && this.str.getBaseStreams) {
  2758. return this.str.getBaseStreams();
  2759. }
  2760. return [];
  2761. }
  2762. };
  2763. return DecodeStream;
  2764. }();
  2765. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  2766. function StreamsSequenceStream(streams) {
  2767. this.streams = streams;
  2768. DecodeStream.call(this, null);
  2769. }
  2770. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  2771. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  2772. var streams = this.streams;
  2773. if (streams.length === 0) {
  2774. this.eof = true;
  2775. return;
  2776. }
  2777. var stream = streams.shift();
  2778. var chunk = stream.getBytes();
  2779. var bufferLength = this.bufferLength;
  2780. var newLength = bufferLength + chunk.length;
  2781. var buffer = this.ensureBuffer(newLength);
  2782. buffer.set(chunk, bufferLength);
  2783. this.bufferLength = newLength;
  2784. };
  2785. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  2786. var baseStreams = [];
  2787. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  2788. var stream = this.streams[i];
  2789. if (stream.getBaseStreams) {
  2790. Util.appendToArray(baseStreams, stream.getBaseStreams());
  2791. }
  2792. }
  2793. return baseStreams;
  2794. };
  2795. return StreamsSequenceStream;
  2796. }();
  2797. var FlateStream = function FlateStreamClosure() {
  2798. var codeLenCodeMap = new Int32Array([
  2799. 16,
  2800. 17,
  2801. 18,
  2802. 0,
  2803. 8,
  2804. 7,
  2805. 9,
  2806. 6,
  2807. 10,
  2808. 5,
  2809. 11,
  2810. 4,
  2811. 12,
  2812. 3,
  2813. 13,
  2814. 2,
  2815. 14,
  2816. 1,
  2817. 15
  2818. ]);
  2819. var lengthDecode = new Int32Array([
  2820. 0x00003,
  2821. 0x00004,
  2822. 0x00005,
  2823. 0x00006,
  2824. 0x00007,
  2825. 0x00008,
  2826. 0x00009,
  2827. 0x0000a,
  2828. 0x1000b,
  2829. 0x1000d,
  2830. 0x1000f,
  2831. 0x10011,
  2832. 0x20013,
  2833. 0x20017,
  2834. 0x2001b,
  2835. 0x2001f,
  2836. 0x30023,
  2837. 0x3002b,
  2838. 0x30033,
  2839. 0x3003b,
  2840. 0x40043,
  2841. 0x40053,
  2842. 0x40063,
  2843. 0x40073,
  2844. 0x50083,
  2845. 0x500a3,
  2846. 0x500c3,
  2847. 0x500e3,
  2848. 0x00102,
  2849. 0x00102,
  2850. 0x00102
  2851. ]);
  2852. var distDecode = new Int32Array([
  2853. 0x00001,
  2854. 0x00002,
  2855. 0x00003,
  2856. 0x00004,
  2857. 0x10005,
  2858. 0x10007,
  2859. 0x20009,
  2860. 0x2000d,
  2861. 0x30011,
  2862. 0x30019,
  2863. 0x40021,
  2864. 0x40031,
  2865. 0x50041,
  2866. 0x50061,
  2867. 0x60081,
  2868. 0x600c1,
  2869. 0x70101,
  2870. 0x70181,
  2871. 0x80201,
  2872. 0x80301,
  2873. 0x90401,
  2874. 0x90601,
  2875. 0xa0801,
  2876. 0xa0c01,
  2877. 0xb1001,
  2878. 0xb1801,
  2879. 0xc2001,
  2880. 0xc3001,
  2881. 0xd4001,
  2882. 0xd6001
  2883. ]);
  2884. var fixedLitCodeTab = [
  2885. new Int32Array([
  2886. 0x70100,
  2887. 0x80050,
  2888. 0x80010,
  2889. 0x80118,
  2890. 0x70110,
  2891. 0x80070,
  2892. 0x80030,
  2893. 0x900c0,
  2894. 0x70108,
  2895. 0x80060,
  2896. 0x80020,
  2897. 0x900a0,
  2898. 0x80000,
  2899. 0x80080,
  2900. 0x80040,
  2901. 0x900e0,
  2902. 0x70104,
  2903. 0x80058,
  2904. 0x80018,
  2905. 0x90090,
  2906. 0x70114,
  2907. 0x80078,
  2908. 0x80038,
  2909. 0x900d0,
  2910. 0x7010c,
  2911. 0x80068,
  2912. 0x80028,
  2913. 0x900b0,
  2914. 0x80008,
  2915. 0x80088,
  2916. 0x80048,
  2917. 0x900f0,
  2918. 0x70102,
  2919. 0x80054,
  2920. 0x80014,
  2921. 0x8011c,
  2922. 0x70112,
  2923. 0x80074,
  2924. 0x80034,
  2925. 0x900c8,
  2926. 0x7010a,
  2927. 0x80064,
  2928. 0x80024,
  2929. 0x900a8,
  2930. 0x80004,
  2931. 0x80084,
  2932. 0x80044,
  2933. 0x900e8,
  2934. 0x70106,
  2935. 0x8005c,
  2936. 0x8001c,
  2937. 0x90098,
  2938. 0x70116,
  2939. 0x8007c,
  2940. 0x8003c,
  2941. 0x900d8,
  2942. 0x7010e,
  2943. 0x8006c,
  2944. 0x8002c,
  2945. 0x900b8,
  2946. 0x8000c,
  2947. 0x8008c,
  2948. 0x8004c,
  2949. 0x900f8,
  2950. 0x70101,
  2951. 0x80052,
  2952. 0x80012,
  2953. 0x8011a,
  2954. 0x70111,
  2955. 0x80072,
  2956. 0x80032,
  2957. 0x900c4,
  2958. 0x70109,
  2959. 0x80062,
  2960. 0x80022,
  2961. 0x900a4,
  2962. 0x80002,
  2963. 0x80082,
  2964. 0x80042,
  2965. 0x900e4,
  2966. 0x70105,
  2967. 0x8005a,
  2968. 0x8001a,
  2969. 0x90094,
  2970. 0x70115,
  2971. 0x8007a,
  2972. 0x8003a,
  2973. 0x900d4,
  2974. 0x7010d,
  2975. 0x8006a,
  2976. 0x8002a,
  2977. 0x900b4,
  2978. 0x8000a,
  2979. 0x8008a,
  2980. 0x8004a,
  2981. 0x900f4,
  2982. 0x70103,
  2983. 0x80056,
  2984. 0x80016,
  2985. 0x8011e,
  2986. 0x70113,
  2987. 0x80076,
  2988. 0x80036,
  2989. 0x900cc,
  2990. 0x7010b,
  2991. 0x80066,
  2992. 0x80026,
  2993. 0x900ac,
  2994. 0x80006,
  2995. 0x80086,
  2996. 0x80046,
  2997. 0x900ec,
  2998. 0x70107,
  2999. 0x8005e,
  3000. 0x8001e,
  3001. 0x9009c,
  3002. 0x70117,
  3003. 0x8007e,
  3004. 0x8003e,
  3005. 0x900dc,
  3006. 0x7010f,
  3007. 0x8006e,
  3008. 0x8002e,
  3009. 0x900bc,
  3010. 0x8000e,
  3011. 0x8008e,
  3012. 0x8004e,
  3013. 0x900fc,
  3014. 0x70100,
  3015. 0x80051,
  3016. 0x80011,
  3017. 0x80119,
  3018. 0x70110,
  3019. 0x80071,
  3020. 0x80031,
  3021. 0x900c2,
  3022. 0x70108,
  3023. 0x80061,
  3024. 0x80021,
  3025. 0x900a2,
  3026. 0x80001,
  3027. 0x80081,
  3028. 0x80041,
  3029. 0x900e2,
  3030. 0x70104,
  3031. 0x80059,
  3032. 0x80019,
  3033. 0x90092,
  3034. 0x70114,
  3035. 0x80079,
  3036. 0x80039,
  3037. 0x900d2,
  3038. 0x7010c,
  3039. 0x80069,
  3040. 0x80029,
  3041. 0x900b2,
  3042. 0x80009,
  3043. 0x80089,
  3044. 0x80049,
  3045. 0x900f2,
  3046. 0x70102,
  3047. 0x80055,
  3048. 0x80015,
  3049. 0x8011d,
  3050. 0x70112,
  3051. 0x80075,
  3052. 0x80035,
  3053. 0x900ca,
  3054. 0x7010a,
  3055. 0x80065,
  3056. 0x80025,
  3057. 0x900aa,
  3058. 0x80005,
  3059. 0x80085,
  3060. 0x80045,
  3061. 0x900ea,
  3062. 0x70106,
  3063. 0x8005d,
  3064. 0x8001d,
  3065. 0x9009a,
  3066. 0x70116,
  3067. 0x8007d,
  3068. 0x8003d,
  3069. 0x900da,
  3070. 0x7010e,
  3071. 0x8006d,
  3072. 0x8002d,
  3073. 0x900ba,
  3074. 0x8000d,
  3075. 0x8008d,
  3076. 0x8004d,
  3077. 0x900fa,
  3078. 0x70101,
  3079. 0x80053,
  3080. 0x80013,
  3081. 0x8011b,
  3082. 0x70111,
  3083. 0x80073,
  3084. 0x80033,
  3085. 0x900c6,
  3086. 0x70109,
  3087. 0x80063,
  3088. 0x80023,
  3089. 0x900a6,
  3090. 0x80003,
  3091. 0x80083,
  3092. 0x80043,
  3093. 0x900e6,
  3094. 0x70105,
  3095. 0x8005b,
  3096. 0x8001b,
  3097. 0x90096,
  3098. 0x70115,
  3099. 0x8007b,
  3100. 0x8003b,
  3101. 0x900d6,
  3102. 0x7010d,
  3103. 0x8006b,
  3104. 0x8002b,
  3105. 0x900b6,
  3106. 0x8000b,
  3107. 0x8008b,
  3108. 0x8004b,
  3109. 0x900f6,
  3110. 0x70103,
  3111. 0x80057,
  3112. 0x80017,
  3113. 0x8011f,
  3114. 0x70113,
  3115. 0x80077,
  3116. 0x80037,
  3117. 0x900ce,
  3118. 0x7010b,
  3119. 0x80067,
  3120. 0x80027,
  3121. 0x900ae,
  3122. 0x80007,
  3123. 0x80087,
  3124. 0x80047,
  3125. 0x900ee,
  3126. 0x70107,
  3127. 0x8005f,
  3128. 0x8001f,
  3129. 0x9009e,
  3130. 0x70117,
  3131. 0x8007f,
  3132. 0x8003f,
  3133. 0x900de,
  3134. 0x7010f,
  3135. 0x8006f,
  3136. 0x8002f,
  3137. 0x900be,
  3138. 0x8000f,
  3139. 0x8008f,
  3140. 0x8004f,
  3141. 0x900fe,
  3142. 0x70100,
  3143. 0x80050,
  3144. 0x80010,
  3145. 0x80118,
  3146. 0x70110,
  3147. 0x80070,
  3148. 0x80030,
  3149. 0x900c1,
  3150. 0x70108,
  3151. 0x80060,
  3152. 0x80020,
  3153. 0x900a1,
  3154. 0x80000,
  3155. 0x80080,
  3156. 0x80040,
  3157. 0x900e1,
  3158. 0x70104,
  3159. 0x80058,
  3160. 0x80018,
  3161. 0x90091,
  3162. 0x70114,
  3163. 0x80078,
  3164. 0x80038,
  3165. 0x900d1,
  3166. 0x7010c,
  3167. 0x80068,
  3168. 0x80028,
  3169. 0x900b1,
  3170. 0x80008,
  3171. 0x80088,
  3172. 0x80048,
  3173. 0x900f1,
  3174. 0x70102,
  3175. 0x80054,
  3176. 0x80014,
  3177. 0x8011c,
  3178. 0x70112,
  3179. 0x80074,
  3180. 0x80034,
  3181. 0x900c9,
  3182. 0x7010a,
  3183. 0x80064,
  3184. 0x80024,
  3185. 0x900a9,
  3186. 0x80004,
  3187. 0x80084,
  3188. 0x80044,
  3189. 0x900e9,
  3190. 0x70106,
  3191. 0x8005c,
  3192. 0x8001c,
  3193. 0x90099,
  3194. 0x70116,
  3195. 0x8007c,
  3196. 0x8003c,
  3197. 0x900d9,
  3198. 0x7010e,
  3199. 0x8006c,
  3200. 0x8002c,
  3201. 0x900b9,
  3202. 0x8000c,
  3203. 0x8008c,
  3204. 0x8004c,
  3205. 0x900f9,
  3206. 0x70101,
  3207. 0x80052,
  3208. 0x80012,
  3209. 0x8011a,
  3210. 0x70111,
  3211. 0x80072,
  3212. 0x80032,
  3213. 0x900c5,
  3214. 0x70109,
  3215. 0x80062,
  3216. 0x80022,
  3217. 0x900a5,
  3218. 0x80002,
  3219. 0x80082,
  3220. 0x80042,
  3221. 0x900e5,
  3222. 0x70105,
  3223. 0x8005a,
  3224. 0x8001a,
  3225. 0x90095,
  3226. 0x70115,
  3227. 0x8007a,
  3228. 0x8003a,
  3229. 0x900d5,
  3230. 0x7010d,
  3231. 0x8006a,
  3232. 0x8002a,
  3233. 0x900b5,
  3234. 0x8000a,
  3235. 0x8008a,
  3236. 0x8004a,
  3237. 0x900f5,
  3238. 0x70103,
  3239. 0x80056,
  3240. 0x80016,
  3241. 0x8011e,
  3242. 0x70113,
  3243. 0x80076,
  3244. 0x80036,
  3245. 0x900cd,
  3246. 0x7010b,
  3247. 0x80066,
  3248. 0x80026,
  3249. 0x900ad,
  3250. 0x80006,
  3251. 0x80086,
  3252. 0x80046,
  3253. 0x900ed,
  3254. 0x70107,
  3255. 0x8005e,
  3256. 0x8001e,
  3257. 0x9009d,
  3258. 0x70117,
  3259. 0x8007e,
  3260. 0x8003e,
  3261. 0x900dd,
  3262. 0x7010f,
  3263. 0x8006e,
  3264. 0x8002e,
  3265. 0x900bd,
  3266. 0x8000e,
  3267. 0x8008e,
  3268. 0x8004e,
  3269. 0x900fd,
  3270. 0x70100,
  3271. 0x80051,
  3272. 0x80011,
  3273. 0x80119,
  3274. 0x70110,
  3275. 0x80071,
  3276. 0x80031,
  3277. 0x900c3,
  3278. 0x70108,
  3279. 0x80061,
  3280. 0x80021,
  3281. 0x900a3,
  3282. 0x80001,
  3283. 0x80081,
  3284. 0x80041,
  3285. 0x900e3,
  3286. 0x70104,
  3287. 0x80059,
  3288. 0x80019,
  3289. 0x90093,
  3290. 0x70114,
  3291. 0x80079,
  3292. 0x80039,
  3293. 0x900d3,
  3294. 0x7010c,
  3295. 0x80069,
  3296. 0x80029,
  3297. 0x900b3,
  3298. 0x80009,
  3299. 0x80089,
  3300. 0x80049,
  3301. 0x900f3,
  3302. 0x70102,
  3303. 0x80055,
  3304. 0x80015,
  3305. 0x8011d,
  3306. 0x70112,
  3307. 0x80075,
  3308. 0x80035,
  3309. 0x900cb,
  3310. 0x7010a,
  3311. 0x80065,
  3312. 0x80025,
  3313. 0x900ab,
  3314. 0x80005,
  3315. 0x80085,
  3316. 0x80045,
  3317. 0x900eb,
  3318. 0x70106,
  3319. 0x8005d,
  3320. 0x8001d,
  3321. 0x9009b,
  3322. 0x70116,
  3323. 0x8007d,
  3324. 0x8003d,
  3325. 0x900db,
  3326. 0x7010e,
  3327. 0x8006d,
  3328. 0x8002d,
  3329. 0x900bb,
  3330. 0x8000d,
  3331. 0x8008d,
  3332. 0x8004d,
  3333. 0x900fb,
  3334. 0x70101,
  3335. 0x80053,
  3336. 0x80013,
  3337. 0x8011b,
  3338. 0x70111,
  3339. 0x80073,
  3340. 0x80033,
  3341. 0x900c7,
  3342. 0x70109,
  3343. 0x80063,
  3344. 0x80023,
  3345. 0x900a7,
  3346. 0x80003,
  3347. 0x80083,
  3348. 0x80043,
  3349. 0x900e7,
  3350. 0x70105,
  3351. 0x8005b,
  3352. 0x8001b,
  3353. 0x90097,
  3354. 0x70115,
  3355. 0x8007b,
  3356. 0x8003b,
  3357. 0x900d7,
  3358. 0x7010d,
  3359. 0x8006b,
  3360. 0x8002b,
  3361. 0x900b7,
  3362. 0x8000b,
  3363. 0x8008b,
  3364. 0x8004b,
  3365. 0x900f7,
  3366. 0x70103,
  3367. 0x80057,
  3368. 0x80017,
  3369. 0x8011f,
  3370. 0x70113,
  3371. 0x80077,
  3372. 0x80037,
  3373. 0x900cf,
  3374. 0x7010b,
  3375. 0x80067,
  3376. 0x80027,
  3377. 0x900af,
  3378. 0x80007,
  3379. 0x80087,
  3380. 0x80047,
  3381. 0x900ef,
  3382. 0x70107,
  3383. 0x8005f,
  3384. 0x8001f,
  3385. 0x9009f,
  3386. 0x70117,
  3387. 0x8007f,
  3388. 0x8003f,
  3389. 0x900df,
  3390. 0x7010f,
  3391. 0x8006f,
  3392. 0x8002f,
  3393. 0x900bf,
  3394. 0x8000f,
  3395. 0x8008f,
  3396. 0x8004f,
  3397. 0x900ff
  3398. ]),
  3399. 9
  3400. ];
  3401. var fixedDistCodeTab = [
  3402. new Int32Array([
  3403. 0x50000,
  3404. 0x50010,
  3405. 0x50008,
  3406. 0x50018,
  3407. 0x50004,
  3408. 0x50014,
  3409. 0x5000c,
  3410. 0x5001c,
  3411. 0x50002,
  3412. 0x50012,
  3413. 0x5000a,
  3414. 0x5001a,
  3415. 0x50006,
  3416. 0x50016,
  3417. 0x5000e,
  3418. 0x00000,
  3419. 0x50001,
  3420. 0x50011,
  3421. 0x50009,
  3422. 0x50019,
  3423. 0x50005,
  3424. 0x50015,
  3425. 0x5000d,
  3426. 0x5001d,
  3427. 0x50003,
  3428. 0x50013,
  3429. 0x5000b,
  3430. 0x5001b,
  3431. 0x50007,
  3432. 0x50017,
  3433. 0x5000f,
  3434. 0x00000
  3435. ]),
  3436. 5
  3437. ];
  3438. function FlateStream(str, maybeLength) {
  3439. this.str = str;
  3440. this.dict = str.dict;
  3441. var cmf = str.getByte();
  3442. var flg = str.getByte();
  3443. if (cmf === -1 || flg === -1) {
  3444. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  3445. }
  3446. if ((cmf & 0x0f) !== 0x08) {
  3447. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  3448. }
  3449. if (((cmf << 8) + flg) % 31 !== 0) {
  3450. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  3451. }
  3452. if (flg & 0x20) {
  3453. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  3454. }
  3455. this.codeSize = 0;
  3456. this.codeBuf = 0;
  3457. DecodeStream.call(this, maybeLength);
  3458. }
  3459. FlateStream.prototype = Object.create(DecodeStream.prototype);
  3460. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  3461. var str = this.str;
  3462. var codeSize = this.codeSize;
  3463. var codeBuf = this.codeBuf;
  3464. var b;
  3465. while (codeSize < bits) {
  3466. if ((b = str.getByte()) === -1) {
  3467. error('Bad encoding in flate stream');
  3468. }
  3469. codeBuf |= b << codeSize;
  3470. codeSize += 8;
  3471. }
  3472. b = codeBuf & (1 << bits) - 1;
  3473. this.codeBuf = codeBuf >> bits;
  3474. this.codeSize = codeSize -= bits;
  3475. return b;
  3476. };
  3477. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  3478. var str = this.str;
  3479. var codes = table[0];
  3480. var maxLen = table[1];
  3481. var codeSize = this.codeSize;
  3482. var codeBuf = this.codeBuf;
  3483. var b;
  3484. while (codeSize < maxLen) {
  3485. if ((b = str.getByte()) === -1) {
  3486. break;
  3487. }
  3488. codeBuf |= b << codeSize;
  3489. codeSize += 8;
  3490. }
  3491. var code = codes[codeBuf & (1 << maxLen) - 1];
  3492. var codeLen = code >> 16;
  3493. var codeVal = code & 0xffff;
  3494. if (codeLen < 1 || codeSize < codeLen) {
  3495. error('Bad encoding in flate stream');
  3496. }
  3497. this.codeBuf = codeBuf >> codeLen;
  3498. this.codeSize = codeSize - codeLen;
  3499. return codeVal;
  3500. };
  3501. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  3502. var n = lengths.length;
  3503. var maxLen = 0;
  3504. var i;
  3505. for (i = 0; i < n; ++i) {
  3506. if (lengths[i] > maxLen) {
  3507. maxLen = lengths[i];
  3508. }
  3509. }
  3510. var size = 1 << maxLen;
  3511. var codes = new Int32Array(size);
  3512. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  3513. for (var val = 0; val < n; ++val) {
  3514. if (lengths[val] === len) {
  3515. var code2 = 0;
  3516. var t = code;
  3517. for (i = 0; i < len; ++i) {
  3518. code2 = code2 << 1 | t & 1;
  3519. t >>= 1;
  3520. }
  3521. for (i = code2; i < size; i += skip) {
  3522. codes[i] = len << 16 | val;
  3523. }
  3524. ++code;
  3525. }
  3526. }
  3527. }
  3528. return [
  3529. codes,
  3530. maxLen
  3531. ];
  3532. };
  3533. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  3534. var buffer, len;
  3535. var str = this.str;
  3536. var hdr = this.getBits(3);
  3537. if (hdr & 1) {
  3538. this.eof = true;
  3539. }
  3540. hdr >>= 1;
  3541. if (hdr === 0) {
  3542. var b;
  3543. if ((b = str.getByte()) === -1) {
  3544. error('Bad block header in flate stream');
  3545. }
  3546. var blockLen = b;
  3547. if ((b = str.getByte()) === -1) {
  3548. error('Bad block header in flate stream');
  3549. }
  3550. blockLen |= b << 8;
  3551. if ((b = str.getByte()) === -1) {
  3552. error('Bad block header in flate stream');
  3553. }
  3554. var check = b;
  3555. if ((b = str.getByte()) === -1) {
  3556. error('Bad block header in flate stream');
  3557. }
  3558. check |= b << 8;
  3559. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  3560. error('Bad uncompressed block length in flate stream');
  3561. }
  3562. this.codeBuf = 0;
  3563. this.codeSize = 0;
  3564. var bufferLength = this.bufferLength;
  3565. buffer = this.ensureBuffer(bufferLength + blockLen);
  3566. var end = bufferLength + blockLen;
  3567. this.bufferLength = end;
  3568. if (blockLen === 0) {
  3569. if (str.peekByte() === -1) {
  3570. this.eof = true;
  3571. }
  3572. } else {
  3573. for (var n = bufferLength; n < end; ++n) {
  3574. if ((b = str.getByte()) === -1) {
  3575. this.eof = true;
  3576. break;
  3577. }
  3578. buffer[n] = b;
  3579. }
  3580. }
  3581. return;
  3582. }
  3583. var litCodeTable;
  3584. var distCodeTable;
  3585. if (hdr === 1) {
  3586. litCodeTable = fixedLitCodeTab;
  3587. distCodeTable = fixedDistCodeTab;
  3588. } else if (hdr === 2) {
  3589. var numLitCodes = this.getBits(5) + 257;
  3590. var numDistCodes = this.getBits(5) + 1;
  3591. var numCodeLenCodes = this.getBits(4) + 4;
  3592. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  3593. var i;
  3594. for (i = 0; i < numCodeLenCodes; ++i) {
  3595. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  3596. }
  3597. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  3598. len = 0;
  3599. i = 0;
  3600. var codes = numLitCodes + numDistCodes;
  3601. var codeLengths = new Uint8Array(codes);
  3602. var bitsLength, bitsOffset, what;
  3603. while (i < codes) {
  3604. var code = this.getCode(codeLenCodeTab);
  3605. if (code === 16) {
  3606. bitsLength = 2;
  3607. bitsOffset = 3;
  3608. what = len;
  3609. } else if (code === 17) {
  3610. bitsLength = 3;
  3611. bitsOffset = 3;
  3612. what = len = 0;
  3613. } else if (code === 18) {
  3614. bitsLength = 7;
  3615. bitsOffset = 11;
  3616. what = len = 0;
  3617. } else {
  3618. codeLengths[i++] = len = code;
  3619. continue;
  3620. }
  3621. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  3622. while (repeatLength-- > 0) {
  3623. codeLengths[i++] = what;
  3624. }
  3625. }
  3626. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  3627. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  3628. } else {
  3629. error('Unknown block type in flate stream');
  3630. }
  3631. buffer = this.buffer;
  3632. var limit = buffer ? buffer.length : 0;
  3633. var pos = this.bufferLength;
  3634. while (true) {
  3635. var code1 = this.getCode(litCodeTable);
  3636. if (code1 < 256) {
  3637. if (pos + 1 >= limit) {
  3638. buffer = this.ensureBuffer(pos + 1);
  3639. limit = buffer.length;
  3640. }
  3641. buffer[pos++] = code1;
  3642. continue;
  3643. }
  3644. if (code1 === 256) {
  3645. this.bufferLength = pos;
  3646. return;
  3647. }
  3648. code1 -= 257;
  3649. code1 = lengthDecode[code1];
  3650. var code2 = code1 >> 16;
  3651. if (code2 > 0) {
  3652. code2 = this.getBits(code2);
  3653. }
  3654. len = (code1 & 0xffff) + code2;
  3655. code1 = this.getCode(distCodeTable);
  3656. code1 = distDecode[code1];
  3657. code2 = code1 >> 16;
  3658. if (code2 > 0) {
  3659. code2 = this.getBits(code2);
  3660. }
  3661. var dist = (code1 & 0xffff) + code2;
  3662. if (pos + len >= limit) {
  3663. buffer = this.ensureBuffer(pos + len);
  3664. limit = buffer.length;
  3665. }
  3666. for (var k = 0; k < len; ++k, ++pos) {
  3667. buffer[pos] = buffer[pos - dist];
  3668. }
  3669. }
  3670. };
  3671. return FlateStream;
  3672. }();
  3673. var PredictorStream = function PredictorStreamClosure() {
  3674. function PredictorStream(str, maybeLength, params) {
  3675. if (!isDict(params)) {
  3676. return str;
  3677. }
  3678. var predictor = this.predictor = params.get('Predictor') || 1;
  3679. if (predictor <= 1) {
  3680. return str;
  3681. }
  3682. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  3683. error('Unsupported predictor: ' + predictor);
  3684. }
  3685. if (predictor === 2) {
  3686. this.readBlock = this.readBlockTiff;
  3687. } else {
  3688. this.readBlock = this.readBlockPng;
  3689. }
  3690. this.str = str;
  3691. this.dict = str.dict;
  3692. var colors = this.colors = params.get('Colors') || 1;
  3693. var bits = this.bits = params.get('BitsPerComponent') || 8;
  3694. var columns = this.columns = params.get('Columns') || 1;
  3695. this.pixBytes = colors * bits + 7 >> 3;
  3696. this.rowBytes = columns * colors * bits + 7 >> 3;
  3697. DecodeStream.call(this, maybeLength);
  3698. return this;
  3699. }
  3700. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  3701. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  3702. var rowBytes = this.rowBytes;
  3703. var bufferLength = this.bufferLength;
  3704. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  3705. var bits = this.bits;
  3706. var colors = this.colors;
  3707. var rawBytes = this.str.getBytes(rowBytes);
  3708. this.eof = !rawBytes.length;
  3709. if (this.eof) {
  3710. return;
  3711. }
  3712. var inbuf = 0, outbuf = 0;
  3713. var inbits = 0, outbits = 0;
  3714. var pos = bufferLength;
  3715. var i;
  3716. if (bits === 1 && colors === 1) {
  3717. for (i = 0; i < rowBytes; ++i) {
  3718. var c = rawBytes[i] ^ inbuf;
  3719. c ^= c >> 1;
  3720. c ^= c >> 2;
  3721. c ^= c >> 4;
  3722. inbuf = (c & 1) << 7;
  3723. buffer[pos++] = c;
  3724. }
  3725. } else if (bits === 8) {
  3726. for (i = 0; i < colors; ++i) {
  3727. buffer[pos++] = rawBytes[i];
  3728. }
  3729. for (; i < rowBytes; ++i) {
  3730. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  3731. pos++;
  3732. }
  3733. } else {
  3734. var compArray = new Uint8Array(colors + 1);
  3735. var bitMask = (1 << bits) - 1;
  3736. var j = 0, k = bufferLength;
  3737. var columns = this.columns;
  3738. for (i = 0; i < columns; ++i) {
  3739. for (var kk = 0; kk < colors; ++kk) {
  3740. if (inbits < bits) {
  3741. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  3742. inbits += 8;
  3743. }
  3744. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  3745. inbits -= bits;
  3746. outbuf = outbuf << bits | compArray[kk];
  3747. outbits += bits;
  3748. if (outbits >= 8) {
  3749. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  3750. outbits -= 8;
  3751. }
  3752. }
  3753. }
  3754. if (outbits > 0) {
  3755. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  3756. }
  3757. }
  3758. this.bufferLength += rowBytes;
  3759. };
  3760. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  3761. var rowBytes = this.rowBytes;
  3762. var pixBytes = this.pixBytes;
  3763. var predictor = this.str.getByte();
  3764. var rawBytes = this.str.getBytes(rowBytes);
  3765. this.eof = !rawBytes.length;
  3766. if (this.eof) {
  3767. return;
  3768. }
  3769. var bufferLength = this.bufferLength;
  3770. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  3771. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  3772. if (prevRow.length === 0) {
  3773. prevRow = new Uint8Array(rowBytes);
  3774. }
  3775. var i, j = bufferLength, up, c;
  3776. switch (predictor) {
  3777. case 0:
  3778. for (i = 0; i < rowBytes; ++i) {
  3779. buffer[j++] = rawBytes[i];
  3780. }
  3781. break;
  3782. case 1:
  3783. for (i = 0; i < pixBytes; ++i) {
  3784. buffer[j++] = rawBytes[i];
  3785. }
  3786. for (; i < rowBytes; ++i) {
  3787. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  3788. j++;
  3789. }
  3790. break;
  3791. case 2:
  3792. for (i = 0; i < rowBytes; ++i) {
  3793. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  3794. }
  3795. break;
  3796. case 3:
  3797. for (i = 0; i < pixBytes; ++i) {
  3798. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  3799. }
  3800. for (; i < rowBytes; ++i) {
  3801. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  3802. j++;
  3803. }
  3804. break;
  3805. case 4:
  3806. for (i = 0; i < pixBytes; ++i) {
  3807. up = prevRow[i];
  3808. c = rawBytes[i];
  3809. buffer[j++] = up + c;
  3810. }
  3811. for (; i < rowBytes; ++i) {
  3812. up = prevRow[i];
  3813. var upLeft = prevRow[i - pixBytes];
  3814. var left = buffer[j - pixBytes];
  3815. var p = left + up - upLeft;
  3816. var pa = p - left;
  3817. if (pa < 0) {
  3818. pa = -pa;
  3819. }
  3820. var pb = p - up;
  3821. if (pb < 0) {
  3822. pb = -pb;
  3823. }
  3824. var pc = p - upLeft;
  3825. if (pc < 0) {
  3826. pc = -pc;
  3827. }
  3828. c = rawBytes[i];
  3829. if (pa <= pb && pa <= pc) {
  3830. buffer[j++] = left + c;
  3831. } else if (pb <= pc) {
  3832. buffer[j++] = up + c;
  3833. } else {
  3834. buffer[j++] = upLeft + c;
  3835. }
  3836. }
  3837. break;
  3838. default:
  3839. error('Unsupported predictor: ' + predictor);
  3840. }
  3841. this.bufferLength += rowBytes;
  3842. };
  3843. return PredictorStream;
  3844. }();
  3845. var JpegStream = function JpegStreamClosure() {
  3846. function JpegStream(stream, maybeLength, dict, params) {
  3847. var ch;
  3848. while ((ch = stream.getByte()) !== -1) {
  3849. if (ch === 0xFF) {
  3850. stream.skip(-1);
  3851. break;
  3852. }
  3853. }
  3854. this.stream = stream;
  3855. this.maybeLength = maybeLength;
  3856. this.dict = dict;
  3857. this.params = params;
  3858. DecodeStream.call(this, maybeLength);
  3859. }
  3860. JpegStream.prototype = Object.create(DecodeStream.prototype);
  3861. Object.defineProperty(JpegStream.prototype, 'bytes', {
  3862. get: function JpegStream_bytes() {
  3863. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3864. },
  3865. configurable: true
  3866. });
  3867. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  3868. if (this.bufferLength) {
  3869. return;
  3870. }
  3871. var jpegImage = new JpegImage();
  3872. var decodeArr = this.dict.getArray('Decode', 'D');
  3873. if (this.forceRGB && isArray(decodeArr)) {
  3874. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  3875. var decodeArrLength = decodeArr.length;
  3876. var transform = new Int32Array(decodeArrLength);
  3877. var transformNeeded = false;
  3878. var maxValue = (1 << bitsPerComponent) - 1;
  3879. for (var i = 0; i < decodeArrLength; i += 2) {
  3880. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  3881. transform[i + 1] = decodeArr[i] * maxValue | 0;
  3882. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  3883. transformNeeded = true;
  3884. }
  3885. }
  3886. if (transformNeeded) {
  3887. jpegImage.decodeTransform = transform;
  3888. }
  3889. }
  3890. if (isDict(this.params)) {
  3891. var colorTransform = this.params.get('ColorTransform');
  3892. if (isInt(colorTransform)) {
  3893. jpegImage.colorTransform = colorTransform;
  3894. }
  3895. }
  3896. jpegImage.parse(this.bytes);
  3897. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  3898. this.buffer = data;
  3899. this.bufferLength = data.length;
  3900. this.eof = true;
  3901. };
  3902. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  3903. this.ensureBuffer();
  3904. return this.buffer;
  3905. };
  3906. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  3907. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  3908. };
  3909. return JpegStream;
  3910. }();
  3911. var JpxStream = function JpxStreamClosure() {
  3912. function JpxStream(stream, maybeLength, dict, params) {
  3913. this.stream = stream;
  3914. this.maybeLength = maybeLength;
  3915. this.dict = dict;
  3916. this.params = params;
  3917. DecodeStream.call(this, maybeLength);
  3918. }
  3919. JpxStream.prototype = Object.create(DecodeStream.prototype);
  3920. Object.defineProperty(JpxStream.prototype, 'bytes', {
  3921. get: function JpxStream_bytes() {
  3922. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3923. },
  3924. configurable: true
  3925. });
  3926. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  3927. if (this.bufferLength) {
  3928. return;
  3929. }
  3930. var jpxImage = new JpxImage();
  3931. jpxImage.parse(this.bytes);
  3932. var width = jpxImage.width;
  3933. var height = jpxImage.height;
  3934. var componentsCount = jpxImage.componentsCount;
  3935. var tileCount = jpxImage.tiles.length;
  3936. if (tileCount === 1) {
  3937. this.buffer = jpxImage.tiles[0].items;
  3938. } else {
  3939. var data = new Uint8Array(width * height * componentsCount);
  3940. for (var k = 0; k < tileCount; k++) {
  3941. var tileComponents = jpxImage.tiles[k];
  3942. var tileWidth = tileComponents.width;
  3943. var tileHeight = tileComponents.height;
  3944. var tileLeft = tileComponents.left;
  3945. var tileTop = tileComponents.top;
  3946. var src = tileComponents.items;
  3947. var srcPosition = 0;
  3948. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  3949. var imgRowSize = width * componentsCount;
  3950. var tileRowSize = tileWidth * componentsCount;
  3951. for (var j = 0; j < tileHeight; j++) {
  3952. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  3953. data.set(rowBytes, dataPosition);
  3954. srcPosition += tileRowSize;
  3955. dataPosition += imgRowSize;
  3956. }
  3957. }
  3958. this.buffer = data;
  3959. }
  3960. this.bufferLength = this.buffer.length;
  3961. this.eof = true;
  3962. };
  3963. return JpxStream;
  3964. }();
  3965. var Jbig2Stream = function Jbig2StreamClosure() {
  3966. function Jbig2Stream(stream, maybeLength, dict, params) {
  3967. this.stream = stream;
  3968. this.maybeLength = maybeLength;
  3969. this.dict = dict;
  3970. this.params = params;
  3971. DecodeStream.call(this, maybeLength);
  3972. }
  3973. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  3974. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  3975. get: function Jbig2Stream_bytes() {
  3976. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3977. },
  3978. configurable: true
  3979. });
  3980. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  3981. if (this.bufferLength) {
  3982. return;
  3983. }
  3984. var jbig2Image = new Jbig2Image();
  3985. var chunks = [];
  3986. if (isDict(this.params)) {
  3987. var globalsStream = this.params.get('JBIG2Globals');
  3988. if (isStream(globalsStream)) {
  3989. var globals = globalsStream.getBytes();
  3990. chunks.push({
  3991. data: globals,
  3992. start: 0,
  3993. end: globals.length
  3994. });
  3995. }
  3996. }
  3997. chunks.push({
  3998. data: this.bytes,
  3999. start: 0,
  4000. end: this.bytes.length
  4001. });
  4002. var data = jbig2Image.parseChunks(chunks);
  4003. var dataLength = data.length;
  4004. for (var i = 0; i < dataLength; i++) {
  4005. data[i] ^= 0xFF;
  4006. }
  4007. this.buffer = data;
  4008. this.bufferLength = dataLength;
  4009. this.eof = true;
  4010. };
  4011. return Jbig2Stream;
  4012. }();
  4013. var DecryptStream = function DecryptStreamClosure() {
  4014. function DecryptStream(str, maybeLength, decrypt) {
  4015. this.str = str;
  4016. this.dict = str.dict;
  4017. this.decrypt = decrypt;
  4018. this.nextChunk = null;
  4019. this.initialized = false;
  4020. DecodeStream.call(this, maybeLength);
  4021. }
  4022. var chunkSize = 512;
  4023. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  4024. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  4025. var chunk;
  4026. if (this.initialized) {
  4027. chunk = this.nextChunk;
  4028. } else {
  4029. chunk = this.str.getBytes(chunkSize);
  4030. this.initialized = true;
  4031. }
  4032. if (!chunk || chunk.length === 0) {
  4033. this.eof = true;
  4034. return;
  4035. }
  4036. this.nextChunk = this.str.getBytes(chunkSize);
  4037. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  4038. var decrypt = this.decrypt;
  4039. chunk = decrypt(chunk, !hasMoreData);
  4040. var bufferLength = this.bufferLength;
  4041. var i, n = chunk.length;
  4042. var buffer = this.ensureBuffer(bufferLength + n);
  4043. for (i = 0; i < n; i++) {
  4044. buffer[bufferLength++] = chunk[i];
  4045. }
  4046. this.bufferLength = bufferLength;
  4047. };
  4048. return DecryptStream;
  4049. }();
  4050. var Ascii85Stream = function Ascii85StreamClosure() {
  4051. function Ascii85Stream(str, maybeLength) {
  4052. this.str = str;
  4053. this.dict = str.dict;
  4054. this.input = new Uint8Array(5);
  4055. if (maybeLength) {
  4056. maybeLength = 0.8 * maybeLength;
  4057. }
  4058. DecodeStream.call(this, maybeLength);
  4059. }
  4060. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  4061. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  4062. var TILDA_CHAR = 0x7E;
  4063. var Z_LOWER_CHAR = 0x7A;
  4064. var EOF = -1;
  4065. var str = this.str;
  4066. var c = str.getByte();
  4067. while (isSpace(c)) {
  4068. c = str.getByte();
  4069. }
  4070. if (c === EOF || c === TILDA_CHAR) {
  4071. this.eof = true;
  4072. return;
  4073. }
  4074. var bufferLength = this.bufferLength, buffer;
  4075. var i;
  4076. if (c === Z_LOWER_CHAR) {
  4077. buffer = this.ensureBuffer(bufferLength + 4);
  4078. for (i = 0; i < 4; ++i) {
  4079. buffer[bufferLength + i] = 0;
  4080. }
  4081. this.bufferLength += 4;
  4082. } else {
  4083. var input = this.input;
  4084. input[0] = c;
  4085. for (i = 1; i < 5; ++i) {
  4086. c = str.getByte();
  4087. while (isSpace(c)) {
  4088. c = str.getByte();
  4089. }
  4090. input[i] = c;
  4091. if (c === EOF || c === TILDA_CHAR) {
  4092. break;
  4093. }
  4094. }
  4095. buffer = this.ensureBuffer(bufferLength + i - 1);
  4096. this.bufferLength += i - 1;
  4097. if (i < 5) {
  4098. for (; i < 5; ++i) {
  4099. input[i] = 0x21 + 84;
  4100. }
  4101. this.eof = true;
  4102. }
  4103. var t = 0;
  4104. for (i = 0; i < 5; ++i) {
  4105. t = t * 85 + (input[i] - 0x21);
  4106. }
  4107. for (i = 3; i >= 0; --i) {
  4108. buffer[bufferLength + i] = t & 0xFF;
  4109. t >>= 8;
  4110. }
  4111. }
  4112. };
  4113. return Ascii85Stream;
  4114. }();
  4115. var AsciiHexStream = function AsciiHexStreamClosure() {
  4116. function AsciiHexStream(str, maybeLength) {
  4117. this.str = str;
  4118. this.dict = str.dict;
  4119. this.firstDigit = -1;
  4120. if (maybeLength) {
  4121. maybeLength = 0.5 * maybeLength;
  4122. }
  4123. DecodeStream.call(this, maybeLength);
  4124. }
  4125. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  4126. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  4127. var UPSTREAM_BLOCK_SIZE = 8000;
  4128. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  4129. if (!bytes.length) {
  4130. this.eof = true;
  4131. return;
  4132. }
  4133. var maxDecodeLength = bytes.length + 1 >> 1;
  4134. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  4135. var bufferLength = this.bufferLength;
  4136. var firstDigit = this.firstDigit;
  4137. for (var i = 0, ii = bytes.length; i < ii; i++) {
  4138. var ch = bytes[i], digit;
  4139. if (ch >= 0x30 && ch <= 0x39) {
  4140. digit = ch & 0x0F;
  4141. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  4142. digit = (ch & 0x0F) + 9;
  4143. } else if (ch === 0x3E) {
  4144. this.eof = true;
  4145. break;
  4146. } else {
  4147. continue;
  4148. }
  4149. if (firstDigit < 0) {
  4150. firstDigit = digit;
  4151. } else {
  4152. buffer[bufferLength++] = firstDigit << 4 | digit;
  4153. firstDigit = -1;
  4154. }
  4155. }
  4156. if (firstDigit >= 0 && this.eof) {
  4157. buffer[bufferLength++] = firstDigit << 4;
  4158. firstDigit = -1;
  4159. }
  4160. this.firstDigit = firstDigit;
  4161. this.bufferLength = bufferLength;
  4162. };
  4163. return AsciiHexStream;
  4164. }();
  4165. var RunLengthStream = function RunLengthStreamClosure() {
  4166. function RunLengthStream(str, maybeLength) {
  4167. this.str = str;
  4168. this.dict = str.dict;
  4169. DecodeStream.call(this, maybeLength);
  4170. }
  4171. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  4172. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  4173. var repeatHeader = this.str.getBytes(2);
  4174. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  4175. this.eof = true;
  4176. return;
  4177. }
  4178. var buffer;
  4179. var bufferLength = this.bufferLength;
  4180. var n = repeatHeader[0];
  4181. if (n < 128) {
  4182. buffer = this.ensureBuffer(bufferLength + n + 1);
  4183. buffer[bufferLength++] = repeatHeader[1];
  4184. if (n > 0) {
  4185. var source = this.str.getBytes(n);
  4186. buffer.set(source, bufferLength);
  4187. bufferLength += n;
  4188. }
  4189. } else {
  4190. n = 257 - n;
  4191. var b = repeatHeader[1];
  4192. buffer = this.ensureBuffer(bufferLength + n + 1);
  4193. for (var i = 0; i < n; i++) {
  4194. buffer[bufferLength++] = b;
  4195. }
  4196. }
  4197. this.bufferLength = bufferLength;
  4198. };
  4199. return RunLengthStream;
  4200. }();
  4201. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  4202. var ccittEOL = -2;
  4203. var ccittEOF = -1;
  4204. var twoDimPass = 0;
  4205. var twoDimHoriz = 1;
  4206. var twoDimVert0 = 2;
  4207. var twoDimVertR1 = 3;
  4208. var twoDimVertL1 = 4;
  4209. var twoDimVertR2 = 5;
  4210. var twoDimVertL2 = 6;
  4211. var twoDimVertR3 = 7;
  4212. var twoDimVertL3 = 8;
  4213. var twoDimTable = [
  4214. [
  4215. -1,
  4216. -1
  4217. ],
  4218. [
  4219. -1,
  4220. -1
  4221. ],
  4222. [
  4223. 7,
  4224. twoDimVertL3
  4225. ],
  4226. [
  4227. 7,
  4228. twoDimVertR3
  4229. ],
  4230. [
  4231. 6,
  4232. twoDimVertL2
  4233. ],
  4234. [
  4235. 6,
  4236. twoDimVertL2
  4237. ],
  4238. [
  4239. 6,
  4240. twoDimVertR2
  4241. ],
  4242. [
  4243. 6,
  4244. twoDimVertR2
  4245. ],
  4246. [
  4247. 4,
  4248. twoDimPass
  4249. ],
  4250. [
  4251. 4,
  4252. twoDimPass
  4253. ],
  4254. [
  4255. 4,
  4256. twoDimPass
  4257. ],
  4258. [
  4259. 4,
  4260. twoDimPass
  4261. ],
  4262. [
  4263. 4,
  4264. twoDimPass
  4265. ],
  4266. [
  4267. 4,
  4268. twoDimPass
  4269. ],
  4270. [
  4271. 4,
  4272. twoDimPass
  4273. ],
  4274. [
  4275. 4,
  4276. twoDimPass
  4277. ],
  4278. [
  4279. 3,
  4280. twoDimHoriz
  4281. ],
  4282. [
  4283. 3,
  4284. twoDimHoriz
  4285. ],
  4286. [
  4287. 3,
  4288. twoDimHoriz
  4289. ],
  4290. [
  4291. 3,
  4292. twoDimHoriz
  4293. ],
  4294. [
  4295. 3,
  4296. twoDimHoriz
  4297. ],
  4298. [
  4299. 3,
  4300. twoDimHoriz
  4301. ],
  4302. [
  4303. 3,
  4304. twoDimHoriz
  4305. ],
  4306. [
  4307. 3,
  4308. twoDimHoriz
  4309. ],
  4310. [
  4311. 3,
  4312. twoDimHoriz
  4313. ],
  4314. [
  4315. 3,
  4316. twoDimHoriz
  4317. ],
  4318. [
  4319. 3,
  4320. twoDimHoriz
  4321. ],
  4322. [
  4323. 3,
  4324. twoDimHoriz
  4325. ],
  4326. [
  4327. 3,
  4328. twoDimHoriz
  4329. ],
  4330. [
  4331. 3,
  4332. twoDimHoriz
  4333. ],
  4334. [
  4335. 3,
  4336. twoDimHoriz
  4337. ],
  4338. [
  4339. 3,
  4340. twoDimHoriz
  4341. ],
  4342. [
  4343. 3,
  4344. twoDimVertL1
  4345. ],
  4346. [
  4347. 3,
  4348. twoDimVertL1
  4349. ],
  4350. [
  4351. 3,
  4352. twoDimVertL1
  4353. ],
  4354. [
  4355. 3,
  4356. twoDimVertL1
  4357. ],
  4358. [
  4359. 3,
  4360. twoDimVertL1
  4361. ],
  4362. [
  4363. 3,
  4364. twoDimVertL1
  4365. ],
  4366. [
  4367. 3,
  4368. twoDimVertL1
  4369. ],
  4370. [
  4371. 3,
  4372. twoDimVertL1
  4373. ],
  4374. [
  4375. 3,
  4376. twoDimVertL1
  4377. ],
  4378. [
  4379. 3,
  4380. twoDimVertL1
  4381. ],
  4382. [
  4383. 3,
  4384. twoDimVertL1
  4385. ],
  4386. [
  4387. 3,
  4388. twoDimVertL1
  4389. ],
  4390. [
  4391. 3,
  4392. twoDimVertL1
  4393. ],
  4394. [
  4395. 3,
  4396. twoDimVertL1
  4397. ],
  4398. [
  4399. 3,
  4400. twoDimVertL1
  4401. ],
  4402. [
  4403. 3,
  4404. twoDimVertL1
  4405. ],
  4406. [
  4407. 3,
  4408. twoDimVertR1
  4409. ],
  4410. [
  4411. 3,
  4412. twoDimVertR1
  4413. ],
  4414. [
  4415. 3,
  4416. twoDimVertR1
  4417. ],
  4418. [
  4419. 3,
  4420. twoDimVertR1
  4421. ],
  4422. [
  4423. 3,
  4424. twoDimVertR1
  4425. ],
  4426. [
  4427. 3,
  4428. twoDimVertR1
  4429. ],
  4430. [
  4431. 3,
  4432. twoDimVertR1
  4433. ],
  4434. [
  4435. 3,
  4436. twoDimVertR1
  4437. ],
  4438. [
  4439. 3,
  4440. twoDimVertR1
  4441. ],
  4442. [
  4443. 3,
  4444. twoDimVertR1
  4445. ],
  4446. [
  4447. 3,
  4448. twoDimVertR1
  4449. ],
  4450. [
  4451. 3,
  4452. twoDimVertR1
  4453. ],
  4454. [
  4455. 3,
  4456. twoDimVertR1
  4457. ],
  4458. [
  4459. 3,
  4460. twoDimVertR1
  4461. ],
  4462. [
  4463. 3,
  4464. twoDimVertR1
  4465. ],
  4466. [
  4467. 3,
  4468. twoDimVertR1
  4469. ],
  4470. [
  4471. 1,
  4472. twoDimVert0
  4473. ],
  4474. [
  4475. 1,
  4476. twoDimVert0
  4477. ],
  4478. [
  4479. 1,
  4480. twoDimVert0
  4481. ],
  4482. [
  4483. 1,
  4484. twoDimVert0
  4485. ],
  4486. [
  4487. 1,
  4488. twoDimVert0
  4489. ],
  4490. [
  4491. 1,
  4492. twoDimVert0
  4493. ],
  4494. [
  4495. 1,
  4496. twoDimVert0
  4497. ],
  4498. [
  4499. 1,
  4500. twoDimVert0
  4501. ],
  4502. [
  4503. 1,
  4504. twoDimVert0
  4505. ],
  4506. [
  4507. 1,
  4508. twoDimVert0
  4509. ],
  4510. [
  4511. 1,
  4512. twoDimVert0
  4513. ],
  4514. [
  4515. 1,
  4516. twoDimVert0
  4517. ],
  4518. [
  4519. 1,
  4520. twoDimVert0
  4521. ],
  4522. [
  4523. 1,
  4524. twoDimVert0
  4525. ],
  4526. [
  4527. 1,
  4528. twoDimVert0
  4529. ],
  4530. [
  4531. 1,
  4532. twoDimVert0
  4533. ],
  4534. [
  4535. 1,
  4536. twoDimVert0
  4537. ],
  4538. [
  4539. 1,
  4540. twoDimVert0
  4541. ],
  4542. [
  4543. 1,
  4544. twoDimVert0
  4545. ],
  4546. [
  4547. 1,
  4548. twoDimVert0
  4549. ],
  4550. [
  4551. 1,
  4552. twoDimVert0
  4553. ],
  4554. [
  4555. 1,
  4556. twoDimVert0
  4557. ],
  4558. [
  4559. 1,
  4560. twoDimVert0
  4561. ],
  4562. [
  4563. 1,
  4564. twoDimVert0
  4565. ],
  4566. [
  4567. 1,
  4568. twoDimVert0
  4569. ],
  4570. [
  4571. 1,
  4572. twoDimVert0
  4573. ],
  4574. [
  4575. 1,
  4576. twoDimVert0
  4577. ],
  4578. [
  4579. 1,
  4580. twoDimVert0
  4581. ],
  4582. [
  4583. 1,
  4584. twoDimVert0
  4585. ],
  4586. [
  4587. 1,
  4588. twoDimVert0
  4589. ],
  4590. [
  4591. 1,
  4592. twoDimVert0
  4593. ],
  4594. [
  4595. 1,
  4596. twoDimVert0
  4597. ],
  4598. [
  4599. 1,
  4600. twoDimVert0
  4601. ],
  4602. [
  4603. 1,
  4604. twoDimVert0
  4605. ],
  4606. [
  4607. 1,
  4608. twoDimVert0
  4609. ],
  4610. [
  4611. 1,
  4612. twoDimVert0
  4613. ],
  4614. [
  4615. 1,
  4616. twoDimVert0
  4617. ],
  4618. [
  4619. 1,
  4620. twoDimVert0
  4621. ],
  4622. [
  4623. 1,
  4624. twoDimVert0
  4625. ],
  4626. [
  4627. 1,
  4628. twoDimVert0
  4629. ],
  4630. [
  4631. 1,
  4632. twoDimVert0
  4633. ],
  4634. [
  4635. 1,
  4636. twoDimVert0
  4637. ],
  4638. [
  4639. 1,
  4640. twoDimVert0
  4641. ],
  4642. [
  4643. 1,
  4644. twoDimVert0
  4645. ],
  4646. [
  4647. 1,
  4648. twoDimVert0
  4649. ],
  4650. [
  4651. 1,
  4652. twoDimVert0
  4653. ],
  4654. [
  4655. 1,
  4656. twoDimVert0
  4657. ],
  4658. [
  4659. 1,
  4660. twoDimVert0
  4661. ],
  4662. [
  4663. 1,
  4664. twoDimVert0
  4665. ],
  4666. [
  4667. 1,
  4668. twoDimVert0
  4669. ],
  4670. [
  4671. 1,
  4672. twoDimVert0
  4673. ],
  4674. [
  4675. 1,
  4676. twoDimVert0
  4677. ],
  4678. [
  4679. 1,
  4680. twoDimVert0
  4681. ],
  4682. [
  4683. 1,
  4684. twoDimVert0
  4685. ],
  4686. [
  4687. 1,
  4688. twoDimVert0
  4689. ],
  4690. [
  4691. 1,
  4692. twoDimVert0
  4693. ],
  4694. [
  4695. 1,
  4696. twoDimVert0
  4697. ],
  4698. [
  4699. 1,
  4700. twoDimVert0
  4701. ],
  4702. [
  4703. 1,
  4704. twoDimVert0
  4705. ],
  4706. [
  4707. 1,
  4708. twoDimVert0
  4709. ],
  4710. [
  4711. 1,
  4712. twoDimVert0
  4713. ],
  4714. [
  4715. 1,
  4716. twoDimVert0
  4717. ],
  4718. [
  4719. 1,
  4720. twoDimVert0
  4721. ],
  4722. [
  4723. 1,
  4724. twoDimVert0
  4725. ]
  4726. ];
  4727. var whiteTable1 = [
  4728. [
  4729. -1,
  4730. -1
  4731. ],
  4732. [
  4733. 12,
  4734. ccittEOL
  4735. ],
  4736. [
  4737. -1,
  4738. -1
  4739. ],
  4740. [
  4741. -1,
  4742. -1
  4743. ],
  4744. [
  4745. -1,
  4746. -1
  4747. ],
  4748. [
  4749. -1,
  4750. -1
  4751. ],
  4752. [
  4753. -1,
  4754. -1
  4755. ],
  4756. [
  4757. -1,
  4758. -1
  4759. ],
  4760. [
  4761. -1,
  4762. -1
  4763. ],
  4764. [
  4765. -1,
  4766. -1
  4767. ],
  4768. [
  4769. -1,
  4770. -1
  4771. ],
  4772. [
  4773. -1,
  4774. -1
  4775. ],
  4776. [
  4777. -1,
  4778. -1
  4779. ],
  4780. [
  4781. -1,
  4782. -1
  4783. ],
  4784. [
  4785. -1,
  4786. -1
  4787. ],
  4788. [
  4789. -1,
  4790. -1
  4791. ],
  4792. [
  4793. 11,
  4794. 1792
  4795. ],
  4796. [
  4797. 11,
  4798. 1792
  4799. ],
  4800. [
  4801. 12,
  4802. 1984
  4803. ],
  4804. [
  4805. 12,
  4806. 2048
  4807. ],
  4808. [
  4809. 12,
  4810. 2112
  4811. ],
  4812. [
  4813. 12,
  4814. 2176
  4815. ],
  4816. [
  4817. 12,
  4818. 2240
  4819. ],
  4820. [
  4821. 12,
  4822. 2304
  4823. ],
  4824. [
  4825. 11,
  4826. 1856
  4827. ],
  4828. [
  4829. 11,
  4830. 1856
  4831. ],
  4832. [
  4833. 11,
  4834. 1920
  4835. ],
  4836. [
  4837. 11,
  4838. 1920
  4839. ],
  4840. [
  4841. 12,
  4842. 2368
  4843. ],
  4844. [
  4845. 12,
  4846. 2432
  4847. ],
  4848. [
  4849. 12,
  4850. 2496
  4851. ],
  4852. [
  4853. 12,
  4854. 2560
  4855. ]
  4856. ];
  4857. var whiteTable2 = [
  4858. [
  4859. -1,
  4860. -1
  4861. ],
  4862. [
  4863. -1,
  4864. -1
  4865. ],
  4866. [
  4867. -1,
  4868. -1
  4869. ],
  4870. [
  4871. -1,
  4872. -1
  4873. ],
  4874. [
  4875. 8,
  4876. 29
  4877. ],
  4878. [
  4879. 8,
  4880. 29
  4881. ],
  4882. [
  4883. 8,
  4884. 30
  4885. ],
  4886. [
  4887. 8,
  4888. 30
  4889. ],
  4890. [
  4891. 8,
  4892. 45
  4893. ],
  4894. [
  4895. 8,
  4896. 45
  4897. ],
  4898. [
  4899. 8,
  4900. 46
  4901. ],
  4902. [
  4903. 8,
  4904. 46
  4905. ],
  4906. [
  4907. 7,
  4908. 22
  4909. ],
  4910. [
  4911. 7,
  4912. 22
  4913. ],
  4914. [
  4915. 7,
  4916. 22
  4917. ],
  4918. [
  4919. 7,
  4920. 22
  4921. ],
  4922. [
  4923. 7,
  4924. 23
  4925. ],
  4926. [
  4927. 7,
  4928. 23
  4929. ],
  4930. [
  4931. 7,
  4932. 23
  4933. ],
  4934. [
  4935. 7,
  4936. 23
  4937. ],
  4938. [
  4939. 8,
  4940. 47
  4941. ],
  4942. [
  4943. 8,
  4944. 47
  4945. ],
  4946. [
  4947. 8,
  4948. 48
  4949. ],
  4950. [
  4951. 8,
  4952. 48
  4953. ],
  4954. [
  4955. 6,
  4956. 13
  4957. ],
  4958. [
  4959. 6,
  4960. 13
  4961. ],
  4962. [
  4963. 6,
  4964. 13
  4965. ],
  4966. [
  4967. 6,
  4968. 13
  4969. ],
  4970. [
  4971. 6,
  4972. 13
  4973. ],
  4974. [
  4975. 6,
  4976. 13
  4977. ],
  4978. [
  4979. 6,
  4980. 13
  4981. ],
  4982. [
  4983. 6,
  4984. 13
  4985. ],
  4986. [
  4987. 7,
  4988. 20
  4989. ],
  4990. [
  4991. 7,
  4992. 20
  4993. ],
  4994. [
  4995. 7,
  4996. 20
  4997. ],
  4998. [
  4999. 7,
  5000. 20
  5001. ],
  5002. [
  5003. 8,
  5004. 33
  5005. ],
  5006. [
  5007. 8,
  5008. 33
  5009. ],
  5010. [
  5011. 8,
  5012. 34
  5013. ],
  5014. [
  5015. 8,
  5016. 34
  5017. ],
  5018. [
  5019. 8,
  5020. 35
  5021. ],
  5022. [
  5023. 8,
  5024. 35
  5025. ],
  5026. [
  5027. 8,
  5028. 36
  5029. ],
  5030. [
  5031. 8,
  5032. 36
  5033. ],
  5034. [
  5035. 8,
  5036. 37
  5037. ],
  5038. [
  5039. 8,
  5040. 37
  5041. ],
  5042. [
  5043. 8,
  5044. 38
  5045. ],
  5046. [
  5047. 8,
  5048. 38
  5049. ],
  5050. [
  5051. 7,
  5052. 19
  5053. ],
  5054. [
  5055. 7,
  5056. 19
  5057. ],
  5058. [
  5059. 7,
  5060. 19
  5061. ],
  5062. [
  5063. 7,
  5064. 19
  5065. ],
  5066. [
  5067. 8,
  5068. 31
  5069. ],
  5070. [
  5071. 8,
  5072. 31
  5073. ],
  5074. [
  5075. 8,
  5076. 32
  5077. ],
  5078. [
  5079. 8,
  5080. 32
  5081. ],
  5082. [
  5083. 6,
  5084. 1
  5085. ],
  5086. [
  5087. 6,
  5088. 1
  5089. ],
  5090. [
  5091. 6,
  5092. 1
  5093. ],
  5094. [
  5095. 6,
  5096. 1
  5097. ],
  5098. [
  5099. 6,
  5100. 1
  5101. ],
  5102. [
  5103. 6,
  5104. 1
  5105. ],
  5106. [
  5107. 6,
  5108. 1
  5109. ],
  5110. [
  5111. 6,
  5112. 1
  5113. ],
  5114. [
  5115. 6,
  5116. 12
  5117. ],
  5118. [
  5119. 6,
  5120. 12
  5121. ],
  5122. [
  5123. 6,
  5124. 12
  5125. ],
  5126. [
  5127. 6,
  5128. 12
  5129. ],
  5130. [
  5131. 6,
  5132. 12
  5133. ],
  5134. [
  5135. 6,
  5136. 12
  5137. ],
  5138. [
  5139. 6,
  5140. 12
  5141. ],
  5142. [
  5143. 6,
  5144. 12
  5145. ],
  5146. [
  5147. 8,
  5148. 53
  5149. ],
  5150. [
  5151. 8,
  5152. 53
  5153. ],
  5154. [
  5155. 8,
  5156. 54
  5157. ],
  5158. [
  5159. 8,
  5160. 54
  5161. ],
  5162. [
  5163. 7,
  5164. 26
  5165. ],
  5166. [
  5167. 7,
  5168. 26
  5169. ],
  5170. [
  5171. 7,
  5172. 26
  5173. ],
  5174. [
  5175. 7,
  5176. 26
  5177. ],
  5178. [
  5179. 8,
  5180. 39
  5181. ],
  5182. [
  5183. 8,
  5184. 39
  5185. ],
  5186. [
  5187. 8,
  5188. 40
  5189. ],
  5190. [
  5191. 8,
  5192. 40
  5193. ],
  5194. [
  5195. 8,
  5196. 41
  5197. ],
  5198. [
  5199. 8,
  5200. 41
  5201. ],
  5202. [
  5203. 8,
  5204. 42
  5205. ],
  5206. [
  5207. 8,
  5208. 42
  5209. ],
  5210. [
  5211. 8,
  5212. 43
  5213. ],
  5214. [
  5215. 8,
  5216. 43
  5217. ],
  5218. [
  5219. 8,
  5220. 44
  5221. ],
  5222. [
  5223. 8,
  5224. 44
  5225. ],
  5226. [
  5227. 7,
  5228. 21
  5229. ],
  5230. [
  5231. 7,
  5232. 21
  5233. ],
  5234. [
  5235. 7,
  5236. 21
  5237. ],
  5238. [
  5239. 7,
  5240. 21
  5241. ],
  5242. [
  5243. 7,
  5244. 28
  5245. ],
  5246. [
  5247. 7,
  5248. 28
  5249. ],
  5250. [
  5251. 7,
  5252. 28
  5253. ],
  5254. [
  5255. 7,
  5256. 28
  5257. ],
  5258. [
  5259. 8,
  5260. 61
  5261. ],
  5262. [
  5263. 8,
  5264. 61
  5265. ],
  5266. [
  5267. 8,
  5268. 62
  5269. ],
  5270. [
  5271. 8,
  5272. 62
  5273. ],
  5274. [
  5275. 8,
  5276. 63
  5277. ],
  5278. [
  5279. 8,
  5280. 63
  5281. ],
  5282. [
  5283. 8,
  5284. 0
  5285. ],
  5286. [
  5287. 8,
  5288. 0
  5289. ],
  5290. [
  5291. 8,
  5292. 320
  5293. ],
  5294. [
  5295. 8,
  5296. 320
  5297. ],
  5298. [
  5299. 8,
  5300. 384
  5301. ],
  5302. [
  5303. 8,
  5304. 384
  5305. ],
  5306. [
  5307. 5,
  5308. 10
  5309. ],
  5310. [
  5311. 5,
  5312. 10
  5313. ],
  5314. [
  5315. 5,
  5316. 10
  5317. ],
  5318. [
  5319. 5,
  5320. 10
  5321. ],
  5322. [
  5323. 5,
  5324. 10
  5325. ],
  5326. [
  5327. 5,
  5328. 10
  5329. ],
  5330. [
  5331. 5,
  5332. 10
  5333. ],
  5334. [
  5335. 5,
  5336. 10
  5337. ],
  5338. [
  5339. 5,
  5340. 10
  5341. ],
  5342. [
  5343. 5,
  5344. 10
  5345. ],
  5346. [
  5347. 5,
  5348. 10
  5349. ],
  5350. [
  5351. 5,
  5352. 10
  5353. ],
  5354. [
  5355. 5,
  5356. 10
  5357. ],
  5358. [
  5359. 5,
  5360. 10
  5361. ],
  5362. [
  5363. 5,
  5364. 10
  5365. ],
  5366. [
  5367. 5,
  5368. 10
  5369. ],
  5370. [
  5371. 5,
  5372. 11
  5373. ],
  5374. [
  5375. 5,
  5376. 11
  5377. ],
  5378. [
  5379. 5,
  5380. 11
  5381. ],
  5382. [
  5383. 5,
  5384. 11
  5385. ],
  5386. [
  5387. 5,
  5388. 11
  5389. ],
  5390. [
  5391. 5,
  5392. 11
  5393. ],
  5394. [
  5395. 5,
  5396. 11
  5397. ],
  5398. [
  5399. 5,
  5400. 11
  5401. ],
  5402. [
  5403. 5,
  5404. 11
  5405. ],
  5406. [
  5407. 5,
  5408. 11
  5409. ],
  5410. [
  5411. 5,
  5412. 11
  5413. ],
  5414. [
  5415. 5,
  5416. 11
  5417. ],
  5418. [
  5419. 5,
  5420. 11
  5421. ],
  5422. [
  5423. 5,
  5424. 11
  5425. ],
  5426. [
  5427. 5,
  5428. 11
  5429. ],
  5430. [
  5431. 5,
  5432. 11
  5433. ],
  5434. [
  5435. 7,
  5436. 27
  5437. ],
  5438. [
  5439. 7,
  5440. 27
  5441. ],
  5442. [
  5443. 7,
  5444. 27
  5445. ],
  5446. [
  5447. 7,
  5448. 27
  5449. ],
  5450. [
  5451. 8,
  5452. 59
  5453. ],
  5454. [
  5455. 8,
  5456. 59
  5457. ],
  5458. [
  5459. 8,
  5460. 60
  5461. ],
  5462. [
  5463. 8,
  5464. 60
  5465. ],
  5466. [
  5467. 9,
  5468. 1472
  5469. ],
  5470. [
  5471. 9,
  5472. 1536
  5473. ],
  5474. [
  5475. 9,
  5476. 1600
  5477. ],
  5478. [
  5479. 9,
  5480. 1728
  5481. ],
  5482. [
  5483. 7,
  5484. 18
  5485. ],
  5486. [
  5487. 7,
  5488. 18
  5489. ],
  5490. [
  5491. 7,
  5492. 18
  5493. ],
  5494. [
  5495. 7,
  5496. 18
  5497. ],
  5498. [
  5499. 7,
  5500. 24
  5501. ],
  5502. [
  5503. 7,
  5504. 24
  5505. ],
  5506. [
  5507. 7,
  5508. 24
  5509. ],
  5510. [
  5511. 7,
  5512. 24
  5513. ],
  5514. [
  5515. 8,
  5516. 49
  5517. ],
  5518. [
  5519. 8,
  5520. 49
  5521. ],
  5522. [
  5523. 8,
  5524. 50
  5525. ],
  5526. [
  5527. 8,
  5528. 50
  5529. ],
  5530. [
  5531. 8,
  5532. 51
  5533. ],
  5534. [
  5535. 8,
  5536. 51
  5537. ],
  5538. [
  5539. 8,
  5540. 52
  5541. ],
  5542. [
  5543. 8,
  5544. 52
  5545. ],
  5546. [
  5547. 7,
  5548. 25
  5549. ],
  5550. [
  5551. 7,
  5552. 25
  5553. ],
  5554. [
  5555. 7,
  5556. 25
  5557. ],
  5558. [
  5559. 7,
  5560. 25
  5561. ],
  5562. [
  5563. 8,
  5564. 55
  5565. ],
  5566. [
  5567. 8,
  5568. 55
  5569. ],
  5570. [
  5571. 8,
  5572. 56
  5573. ],
  5574. [
  5575. 8,
  5576. 56
  5577. ],
  5578. [
  5579. 8,
  5580. 57
  5581. ],
  5582. [
  5583. 8,
  5584. 57
  5585. ],
  5586. [
  5587. 8,
  5588. 58
  5589. ],
  5590. [
  5591. 8,
  5592. 58
  5593. ],
  5594. [
  5595. 6,
  5596. 192
  5597. ],
  5598. [
  5599. 6,
  5600. 192
  5601. ],
  5602. [
  5603. 6,
  5604. 192
  5605. ],
  5606. [
  5607. 6,
  5608. 192
  5609. ],
  5610. [
  5611. 6,
  5612. 192
  5613. ],
  5614. [
  5615. 6,
  5616. 192
  5617. ],
  5618. [
  5619. 6,
  5620. 192
  5621. ],
  5622. [
  5623. 6,
  5624. 192
  5625. ],
  5626. [
  5627. 6,
  5628. 1664
  5629. ],
  5630. [
  5631. 6,
  5632. 1664
  5633. ],
  5634. [
  5635. 6,
  5636. 1664
  5637. ],
  5638. [
  5639. 6,
  5640. 1664
  5641. ],
  5642. [
  5643. 6,
  5644. 1664
  5645. ],
  5646. [
  5647. 6,
  5648. 1664
  5649. ],
  5650. [
  5651. 6,
  5652. 1664
  5653. ],
  5654. [
  5655. 6,
  5656. 1664
  5657. ],
  5658. [
  5659. 8,
  5660. 448
  5661. ],
  5662. [
  5663. 8,
  5664. 448
  5665. ],
  5666. [
  5667. 8,
  5668. 512
  5669. ],
  5670. [
  5671. 8,
  5672. 512
  5673. ],
  5674. [
  5675. 9,
  5676. 704
  5677. ],
  5678. [
  5679. 9,
  5680. 768
  5681. ],
  5682. [
  5683. 8,
  5684. 640
  5685. ],
  5686. [
  5687. 8,
  5688. 640
  5689. ],
  5690. [
  5691. 8,
  5692. 576
  5693. ],
  5694. [
  5695. 8,
  5696. 576
  5697. ],
  5698. [
  5699. 9,
  5700. 832
  5701. ],
  5702. [
  5703. 9,
  5704. 896
  5705. ],
  5706. [
  5707. 9,
  5708. 960
  5709. ],
  5710. [
  5711. 9,
  5712. 1024
  5713. ],
  5714. [
  5715. 9,
  5716. 1088
  5717. ],
  5718. [
  5719. 9,
  5720. 1152
  5721. ],
  5722. [
  5723. 9,
  5724. 1216
  5725. ],
  5726. [
  5727. 9,
  5728. 1280
  5729. ],
  5730. [
  5731. 9,
  5732. 1344
  5733. ],
  5734. [
  5735. 9,
  5736. 1408
  5737. ],
  5738. [
  5739. 7,
  5740. 256
  5741. ],
  5742. [
  5743. 7,
  5744. 256
  5745. ],
  5746. [
  5747. 7,
  5748. 256
  5749. ],
  5750. [
  5751. 7,
  5752. 256
  5753. ],
  5754. [
  5755. 4,
  5756. 2
  5757. ],
  5758. [
  5759. 4,
  5760. 2
  5761. ],
  5762. [
  5763. 4,
  5764. 2
  5765. ],
  5766. [
  5767. 4,
  5768. 2
  5769. ],
  5770. [
  5771. 4,
  5772. 2
  5773. ],
  5774. [
  5775. 4,
  5776. 2
  5777. ],
  5778. [
  5779. 4,
  5780. 2
  5781. ],
  5782. [
  5783. 4,
  5784. 2
  5785. ],
  5786. [
  5787. 4,
  5788. 2
  5789. ],
  5790. [
  5791. 4,
  5792. 2
  5793. ],
  5794. [
  5795. 4,
  5796. 2
  5797. ],
  5798. [
  5799. 4,
  5800. 2
  5801. ],
  5802. [
  5803. 4,
  5804. 2
  5805. ],
  5806. [
  5807. 4,
  5808. 2
  5809. ],
  5810. [
  5811. 4,
  5812. 2
  5813. ],
  5814. [
  5815. 4,
  5816. 2
  5817. ],
  5818. [
  5819. 4,
  5820. 2
  5821. ],
  5822. [
  5823. 4,
  5824. 2
  5825. ],
  5826. [
  5827. 4,
  5828. 2
  5829. ],
  5830. [
  5831. 4,
  5832. 2
  5833. ],
  5834. [
  5835. 4,
  5836. 2
  5837. ],
  5838. [
  5839. 4,
  5840. 2
  5841. ],
  5842. [
  5843. 4,
  5844. 2
  5845. ],
  5846. [
  5847. 4,
  5848. 2
  5849. ],
  5850. [
  5851. 4,
  5852. 2
  5853. ],
  5854. [
  5855. 4,
  5856. 2
  5857. ],
  5858. [
  5859. 4,
  5860. 2
  5861. ],
  5862. [
  5863. 4,
  5864. 2
  5865. ],
  5866. [
  5867. 4,
  5868. 2
  5869. ],
  5870. [
  5871. 4,
  5872. 2
  5873. ],
  5874. [
  5875. 4,
  5876. 2
  5877. ],
  5878. [
  5879. 4,
  5880. 2
  5881. ],
  5882. [
  5883. 4,
  5884. 3
  5885. ],
  5886. [
  5887. 4,
  5888. 3
  5889. ],
  5890. [
  5891. 4,
  5892. 3
  5893. ],
  5894. [
  5895. 4,
  5896. 3
  5897. ],
  5898. [
  5899. 4,
  5900. 3
  5901. ],
  5902. [
  5903. 4,
  5904. 3
  5905. ],
  5906. [
  5907. 4,
  5908. 3
  5909. ],
  5910. [
  5911. 4,
  5912. 3
  5913. ],
  5914. [
  5915. 4,
  5916. 3
  5917. ],
  5918. [
  5919. 4,
  5920. 3
  5921. ],
  5922. [
  5923. 4,
  5924. 3
  5925. ],
  5926. [
  5927. 4,
  5928. 3
  5929. ],
  5930. [
  5931. 4,
  5932. 3
  5933. ],
  5934. [
  5935. 4,
  5936. 3
  5937. ],
  5938. [
  5939. 4,
  5940. 3
  5941. ],
  5942. [
  5943. 4,
  5944. 3
  5945. ],
  5946. [
  5947. 4,
  5948. 3
  5949. ],
  5950. [
  5951. 4,
  5952. 3
  5953. ],
  5954. [
  5955. 4,
  5956. 3
  5957. ],
  5958. [
  5959. 4,
  5960. 3
  5961. ],
  5962. [
  5963. 4,
  5964. 3
  5965. ],
  5966. [
  5967. 4,
  5968. 3
  5969. ],
  5970. [
  5971. 4,
  5972. 3
  5973. ],
  5974. [
  5975. 4,
  5976. 3
  5977. ],
  5978. [
  5979. 4,
  5980. 3
  5981. ],
  5982. [
  5983. 4,
  5984. 3
  5985. ],
  5986. [
  5987. 4,
  5988. 3
  5989. ],
  5990. [
  5991. 4,
  5992. 3
  5993. ],
  5994. [
  5995. 4,
  5996. 3
  5997. ],
  5998. [
  5999. 4,
  6000. 3
  6001. ],
  6002. [
  6003. 4,
  6004. 3
  6005. ],
  6006. [
  6007. 4,
  6008. 3
  6009. ],
  6010. [
  6011. 5,
  6012. 128
  6013. ],
  6014. [
  6015. 5,
  6016. 128
  6017. ],
  6018. [
  6019. 5,
  6020. 128
  6021. ],
  6022. [
  6023. 5,
  6024. 128
  6025. ],
  6026. [
  6027. 5,
  6028. 128
  6029. ],
  6030. [
  6031. 5,
  6032. 128
  6033. ],
  6034. [
  6035. 5,
  6036. 128
  6037. ],
  6038. [
  6039. 5,
  6040. 128
  6041. ],
  6042. [
  6043. 5,
  6044. 128
  6045. ],
  6046. [
  6047. 5,
  6048. 128
  6049. ],
  6050. [
  6051. 5,
  6052. 128
  6053. ],
  6054. [
  6055. 5,
  6056. 128
  6057. ],
  6058. [
  6059. 5,
  6060. 128
  6061. ],
  6062. [
  6063. 5,
  6064. 128
  6065. ],
  6066. [
  6067. 5,
  6068. 128
  6069. ],
  6070. [
  6071. 5,
  6072. 128
  6073. ],
  6074. [
  6075. 5,
  6076. 8
  6077. ],
  6078. [
  6079. 5,
  6080. 8
  6081. ],
  6082. [
  6083. 5,
  6084. 8
  6085. ],
  6086. [
  6087. 5,
  6088. 8
  6089. ],
  6090. [
  6091. 5,
  6092. 8
  6093. ],
  6094. [
  6095. 5,
  6096. 8
  6097. ],
  6098. [
  6099. 5,
  6100. 8
  6101. ],
  6102. [
  6103. 5,
  6104. 8
  6105. ],
  6106. [
  6107. 5,
  6108. 8
  6109. ],
  6110. [
  6111. 5,
  6112. 8
  6113. ],
  6114. [
  6115. 5,
  6116. 8
  6117. ],
  6118. [
  6119. 5,
  6120. 8
  6121. ],
  6122. [
  6123. 5,
  6124. 8
  6125. ],
  6126. [
  6127. 5,
  6128. 8
  6129. ],
  6130. [
  6131. 5,
  6132. 8
  6133. ],
  6134. [
  6135. 5,
  6136. 8
  6137. ],
  6138. [
  6139. 5,
  6140. 9
  6141. ],
  6142. [
  6143. 5,
  6144. 9
  6145. ],
  6146. [
  6147. 5,
  6148. 9
  6149. ],
  6150. [
  6151. 5,
  6152. 9
  6153. ],
  6154. [
  6155. 5,
  6156. 9
  6157. ],
  6158. [
  6159. 5,
  6160. 9
  6161. ],
  6162. [
  6163. 5,
  6164. 9
  6165. ],
  6166. [
  6167. 5,
  6168. 9
  6169. ],
  6170. [
  6171. 5,
  6172. 9
  6173. ],
  6174. [
  6175. 5,
  6176. 9
  6177. ],
  6178. [
  6179. 5,
  6180. 9
  6181. ],
  6182. [
  6183. 5,
  6184. 9
  6185. ],
  6186. [
  6187. 5,
  6188. 9
  6189. ],
  6190. [
  6191. 5,
  6192. 9
  6193. ],
  6194. [
  6195. 5,
  6196. 9
  6197. ],
  6198. [
  6199. 5,
  6200. 9
  6201. ],
  6202. [
  6203. 6,
  6204. 16
  6205. ],
  6206. [
  6207. 6,
  6208. 16
  6209. ],
  6210. [
  6211. 6,
  6212. 16
  6213. ],
  6214. [
  6215. 6,
  6216. 16
  6217. ],
  6218. [
  6219. 6,
  6220. 16
  6221. ],
  6222. [
  6223. 6,
  6224. 16
  6225. ],
  6226. [
  6227. 6,
  6228. 16
  6229. ],
  6230. [
  6231. 6,
  6232. 16
  6233. ],
  6234. [
  6235. 6,
  6236. 17
  6237. ],
  6238. [
  6239. 6,
  6240. 17
  6241. ],
  6242. [
  6243. 6,
  6244. 17
  6245. ],
  6246. [
  6247. 6,
  6248. 17
  6249. ],
  6250. [
  6251. 6,
  6252. 17
  6253. ],
  6254. [
  6255. 6,
  6256. 17
  6257. ],
  6258. [
  6259. 6,
  6260. 17
  6261. ],
  6262. [
  6263. 6,
  6264. 17
  6265. ],
  6266. [
  6267. 4,
  6268. 4
  6269. ],
  6270. [
  6271. 4,
  6272. 4
  6273. ],
  6274. [
  6275. 4,
  6276. 4
  6277. ],
  6278. [
  6279. 4,
  6280. 4
  6281. ],
  6282. [
  6283. 4,
  6284. 4
  6285. ],
  6286. [
  6287. 4,
  6288. 4
  6289. ],
  6290. [
  6291. 4,
  6292. 4
  6293. ],
  6294. [
  6295. 4,
  6296. 4
  6297. ],
  6298. [
  6299. 4,
  6300. 4
  6301. ],
  6302. [
  6303. 4,
  6304. 4
  6305. ],
  6306. [
  6307. 4,
  6308. 4
  6309. ],
  6310. [
  6311. 4,
  6312. 4
  6313. ],
  6314. [
  6315. 4,
  6316. 4
  6317. ],
  6318. [
  6319. 4,
  6320. 4
  6321. ],
  6322. [
  6323. 4,
  6324. 4
  6325. ],
  6326. [
  6327. 4,
  6328. 4
  6329. ],
  6330. [
  6331. 4,
  6332. 4
  6333. ],
  6334. [
  6335. 4,
  6336. 4
  6337. ],
  6338. [
  6339. 4,
  6340. 4
  6341. ],
  6342. [
  6343. 4,
  6344. 4
  6345. ],
  6346. [
  6347. 4,
  6348. 4
  6349. ],
  6350. [
  6351. 4,
  6352. 4
  6353. ],
  6354. [
  6355. 4,
  6356. 4
  6357. ],
  6358. [
  6359. 4,
  6360. 4
  6361. ],
  6362. [
  6363. 4,
  6364. 4
  6365. ],
  6366. [
  6367. 4,
  6368. 4
  6369. ],
  6370. [
  6371. 4,
  6372. 4
  6373. ],
  6374. [
  6375. 4,
  6376. 4
  6377. ],
  6378. [
  6379. 4,
  6380. 4
  6381. ],
  6382. [
  6383. 4,
  6384. 4
  6385. ],
  6386. [
  6387. 4,
  6388. 4
  6389. ],
  6390. [
  6391. 4,
  6392. 4
  6393. ],
  6394. [
  6395. 4,
  6396. 5
  6397. ],
  6398. [
  6399. 4,
  6400. 5
  6401. ],
  6402. [
  6403. 4,
  6404. 5
  6405. ],
  6406. [
  6407. 4,
  6408. 5
  6409. ],
  6410. [
  6411. 4,
  6412. 5
  6413. ],
  6414. [
  6415. 4,
  6416. 5
  6417. ],
  6418. [
  6419. 4,
  6420. 5
  6421. ],
  6422. [
  6423. 4,
  6424. 5
  6425. ],
  6426. [
  6427. 4,
  6428. 5
  6429. ],
  6430. [
  6431. 4,
  6432. 5
  6433. ],
  6434. [
  6435. 4,
  6436. 5
  6437. ],
  6438. [
  6439. 4,
  6440. 5
  6441. ],
  6442. [
  6443. 4,
  6444. 5
  6445. ],
  6446. [
  6447. 4,
  6448. 5
  6449. ],
  6450. [
  6451. 4,
  6452. 5
  6453. ],
  6454. [
  6455. 4,
  6456. 5
  6457. ],
  6458. [
  6459. 4,
  6460. 5
  6461. ],
  6462. [
  6463. 4,
  6464. 5
  6465. ],
  6466. [
  6467. 4,
  6468. 5
  6469. ],
  6470. [
  6471. 4,
  6472. 5
  6473. ],
  6474. [
  6475. 4,
  6476. 5
  6477. ],
  6478. [
  6479. 4,
  6480. 5
  6481. ],
  6482. [
  6483. 4,
  6484. 5
  6485. ],
  6486. [
  6487. 4,
  6488. 5
  6489. ],
  6490. [
  6491. 4,
  6492. 5
  6493. ],
  6494. [
  6495. 4,
  6496. 5
  6497. ],
  6498. [
  6499. 4,
  6500. 5
  6501. ],
  6502. [
  6503. 4,
  6504. 5
  6505. ],
  6506. [
  6507. 4,
  6508. 5
  6509. ],
  6510. [
  6511. 4,
  6512. 5
  6513. ],
  6514. [
  6515. 4,
  6516. 5
  6517. ],
  6518. [
  6519. 4,
  6520. 5
  6521. ],
  6522. [
  6523. 6,
  6524. 14
  6525. ],
  6526. [
  6527. 6,
  6528. 14
  6529. ],
  6530. [
  6531. 6,
  6532. 14
  6533. ],
  6534. [
  6535. 6,
  6536. 14
  6537. ],
  6538. [
  6539. 6,
  6540. 14
  6541. ],
  6542. [
  6543. 6,
  6544. 14
  6545. ],
  6546. [
  6547. 6,
  6548. 14
  6549. ],
  6550. [
  6551. 6,
  6552. 14
  6553. ],
  6554. [
  6555. 6,
  6556. 15
  6557. ],
  6558. [
  6559. 6,
  6560. 15
  6561. ],
  6562. [
  6563. 6,
  6564. 15
  6565. ],
  6566. [
  6567. 6,
  6568. 15
  6569. ],
  6570. [
  6571. 6,
  6572. 15
  6573. ],
  6574. [
  6575. 6,
  6576. 15
  6577. ],
  6578. [
  6579. 6,
  6580. 15
  6581. ],
  6582. [
  6583. 6,
  6584. 15
  6585. ],
  6586. [
  6587. 5,
  6588. 64
  6589. ],
  6590. [
  6591. 5,
  6592. 64
  6593. ],
  6594. [
  6595. 5,
  6596. 64
  6597. ],
  6598. [
  6599. 5,
  6600. 64
  6601. ],
  6602. [
  6603. 5,
  6604. 64
  6605. ],
  6606. [
  6607. 5,
  6608. 64
  6609. ],
  6610. [
  6611. 5,
  6612. 64
  6613. ],
  6614. [
  6615. 5,
  6616. 64
  6617. ],
  6618. [
  6619. 5,
  6620. 64
  6621. ],
  6622. [
  6623. 5,
  6624. 64
  6625. ],
  6626. [
  6627. 5,
  6628. 64
  6629. ],
  6630. [
  6631. 5,
  6632. 64
  6633. ],
  6634. [
  6635. 5,
  6636. 64
  6637. ],
  6638. [
  6639. 5,
  6640. 64
  6641. ],
  6642. [
  6643. 5,
  6644. 64
  6645. ],
  6646. [
  6647. 5,
  6648. 64
  6649. ],
  6650. [
  6651. 4,
  6652. 6
  6653. ],
  6654. [
  6655. 4,
  6656. 6
  6657. ],
  6658. [
  6659. 4,
  6660. 6
  6661. ],
  6662. [
  6663. 4,
  6664. 6
  6665. ],
  6666. [
  6667. 4,
  6668. 6
  6669. ],
  6670. [
  6671. 4,
  6672. 6
  6673. ],
  6674. [
  6675. 4,
  6676. 6
  6677. ],
  6678. [
  6679. 4,
  6680. 6
  6681. ],
  6682. [
  6683. 4,
  6684. 6
  6685. ],
  6686. [
  6687. 4,
  6688. 6
  6689. ],
  6690. [
  6691. 4,
  6692. 6
  6693. ],
  6694. [
  6695. 4,
  6696. 6
  6697. ],
  6698. [
  6699. 4,
  6700. 6
  6701. ],
  6702. [
  6703. 4,
  6704. 6
  6705. ],
  6706. [
  6707. 4,
  6708. 6
  6709. ],
  6710. [
  6711. 4,
  6712. 6
  6713. ],
  6714. [
  6715. 4,
  6716. 6
  6717. ],
  6718. [
  6719. 4,
  6720. 6
  6721. ],
  6722. [
  6723. 4,
  6724. 6
  6725. ],
  6726. [
  6727. 4,
  6728. 6
  6729. ],
  6730. [
  6731. 4,
  6732. 6
  6733. ],
  6734. [
  6735. 4,
  6736. 6
  6737. ],
  6738. [
  6739. 4,
  6740. 6
  6741. ],
  6742. [
  6743. 4,
  6744. 6
  6745. ],
  6746. [
  6747. 4,
  6748. 6
  6749. ],
  6750. [
  6751. 4,
  6752. 6
  6753. ],
  6754. [
  6755. 4,
  6756. 6
  6757. ],
  6758. [
  6759. 4,
  6760. 6
  6761. ],
  6762. [
  6763. 4,
  6764. 6
  6765. ],
  6766. [
  6767. 4,
  6768. 6
  6769. ],
  6770. [
  6771. 4,
  6772. 6
  6773. ],
  6774. [
  6775. 4,
  6776. 6
  6777. ],
  6778. [
  6779. 4,
  6780. 7
  6781. ],
  6782. [
  6783. 4,
  6784. 7
  6785. ],
  6786. [
  6787. 4,
  6788. 7
  6789. ],
  6790. [
  6791. 4,
  6792. 7
  6793. ],
  6794. [
  6795. 4,
  6796. 7
  6797. ],
  6798. [
  6799. 4,
  6800. 7
  6801. ],
  6802. [
  6803. 4,
  6804. 7
  6805. ],
  6806. [
  6807. 4,
  6808. 7
  6809. ],
  6810. [
  6811. 4,
  6812. 7
  6813. ],
  6814. [
  6815. 4,
  6816. 7
  6817. ],
  6818. [
  6819. 4,
  6820. 7
  6821. ],
  6822. [
  6823. 4,
  6824. 7
  6825. ],
  6826. [
  6827. 4,
  6828. 7
  6829. ],
  6830. [
  6831. 4,
  6832. 7
  6833. ],
  6834. [
  6835. 4,
  6836. 7
  6837. ],
  6838. [
  6839. 4,
  6840. 7
  6841. ],
  6842. [
  6843. 4,
  6844. 7
  6845. ],
  6846. [
  6847. 4,
  6848. 7
  6849. ],
  6850. [
  6851. 4,
  6852. 7
  6853. ],
  6854. [
  6855. 4,
  6856. 7
  6857. ],
  6858. [
  6859. 4,
  6860. 7
  6861. ],
  6862. [
  6863. 4,
  6864. 7
  6865. ],
  6866. [
  6867. 4,
  6868. 7
  6869. ],
  6870. [
  6871. 4,
  6872. 7
  6873. ],
  6874. [
  6875. 4,
  6876. 7
  6877. ],
  6878. [
  6879. 4,
  6880. 7
  6881. ],
  6882. [
  6883. 4,
  6884. 7
  6885. ],
  6886. [
  6887. 4,
  6888. 7
  6889. ],
  6890. [
  6891. 4,
  6892. 7
  6893. ],
  6894. [
  6895. 4,
  6896. 7
  6897. ],
  6898. [
  6899. 4,
  6900. 7
  6901. ],
  6902. [
  6903. 4,
  6904. 7
  6905. ]
  6906. ];
  6907. var blackTable1 = [
  6908. [
  6909. -1,
  6910. -1
  6911. ],
  6912. [
  6913. -1,
  6914. -1
  6915. ],
  6916. [
  6917. 12,
  6918. ccittEOL
  6919. ],
  6920. [
  6921. 12,
  6922. ccittEOL
  6923. ],
  6924. [
  6925. -1,
  6926. -1
  6927. ],
  6928. [
  6929. -1,
  6930. -1
  6931. ],
  6932. [
  6933. -1,
  6934. -1
  6935. ],
  6936. [
  6937. -1,
  6938. -1
  6939. ],
  6940. [
  6941. -1,
  6942. -1
  6943. ],
  6944. [
  6945. -1,
  6946. -1
  6947. ],
  6948. [
  6949. -1,
  6950. -1
  6951. ],
  6952. [
  6953. -1,
  6954. -1
  6955. ],
  6956. [
  6957. -1,
  6958. -1
  6959. ],
  6960. [
  6961. -1,
  6962. -1
  6963. ],
  6964. [
  6965. -1,
  6966. -1
  6967. ],
  6968. [
  6969. -1,
  6970. -1
  6971. ],
  6972. [
  6973. -1,
  6974. -1
  6975. ],
  6976. [
  6977. -1,
  6978. -1
  6979. ],
  6980. [
  6981. -1,
  6982. -1
  6983. ],
  6984. [
  6985. -1,
  6986. -1
  6987. ],
  6988. [
  6989. -1,
  6990. -1
  6991. ],
  6992. [
  6993. -1,
  6994. -1
  6995. ],
  6996. [
  6997. -1,
  6998. -1
  6999. ],
  7000. [
  7001. -1,
  7002. -1
  7003. ],
  7004. [
  7005. -1,
  7006. -1
  7007. ],
  7008. [
  7009. -1,
  7010. -1
  7011. ],
  7012. [
  7013. -1,
  7014. -1
  7015. ],
  7016. [
  7017. -1,
  7018. -1
  7019. ],
  7020. [
  7021. -1,
  7022. -1
  7023. ],
  7024. [
  7025. -1,
  7026. -1
  7027. ],
  7028. [
  7029. -1,
  7030. -1
  7031. ],
  7032. [
  7033. -1,
  7034. -1
  7035. ],
  7036. [
  7037. 11,
  7038. 1792
  7039. ],
  7040. [
  7041. 11,
  7042. 1792
  7043. ],
  7044. [
  7045. 11,
  7046. 1792
  7047. ],
  7048. [
  7049. 11,
  7050. 1792
  7051. ],
  7052. [
  7053. 12,
  7054. 1984
  7055. ],
  7056. [
  7057. 12,
  7058. 1984
  7059. ],
  7060. [
  7061. 12,
  7062. 2048
  7063. ],
  7064. [
  7065. 12,
  7066. 2048
  7067. ],
  7068. [
  7069. 12,
  7070. 2112
  7071. ],
  7072. [
  7073. 12,
  7074. 2112
  7075. ],
  7076. [
  7077. 12,
  7078. 2176
  7079. ],
  7080. [
  7081. 12,
  7082. 2176
  7083. ],
  7084. [
  7085. 12,
  7086. 2240
  7087. ],
  7088. [
  7089. 12,
  7090. 2240
  7091. ],
  7092. [
  7093. 12,
  7094. 2304
  7095. ],
  7096. [
  7097. 12,
  7098. 2304
  7099. ],
  7100. [
  7101. 11,
  7102. 1856
  7103. ],
  7104. [
  7105. 11,
  7106. 1856
  7107. ],
  7108. [
  7109. 11,
  7110. 1856
  7111. ],
  7112. [
  7113. 11,
  7114. 1856
  7115. ],
  7116. [
  7117. 11,
  7118. 1920
  7119. ],
  7120. [
  7121. 11,
  7122. 1920
  7123. ],
  7124. [
  7125. 11,
  7126. 1920
  7127. ],
  7128. [
  7129. 11,
  7130. 1920
  7131. ],
  7132. [
  7133. 12,
  7134. 2368
  7135. ],
  7136. [
  7137. 12,
  7138. 2368
  7139. ],
  7140. [
  7141. 12,
  7142. 2432
  7143. ],
  7144. [
  7145. 12,
  7146. 2432
  7147. ],
  7148. [
  7149. 12,
  7150. 2496
  7151. ],
  7152. [
  7153. 12,
  7154. 2496
  7155. ],
  7156. [
  7157. 12,
  7158. 2560
  7159. ],
  7160. [
  7161. 12,
  7162. 2560
  7163. ],
  7164. [
  7165. 10,
  7166. 18
  7167. ],
  7168. [
  7169. 10,
  7170. 18
  7171. ],
  7172. [
  7173. 10,
  7174. 18
  7175. ],
  7176. [
  7177. 10,
  7178. 18
  7179. ],
  7180. [
  7181. 10,
  7182. 18
  7183. ],
  7184. [
  7185. 10,
  7186. 18
  7187. ],
  7188. [
  7189. 10,
  7190. 18
  7191. ],
  7192. [
  7193. 10,
  7194. 18
  7195. ],
  7196. [
  7197. 12,
  7198. 52
  7199. ],
  7200. [
  7201. 12,
  7202. 52
  7203. ],
  7204. [
  7205. 13,
  7206. 640
  7207. ],
  7208. [
  7209. 13,
  7210. 704
  7211. ],
  7212. [
  7213. 13,
  7214. 768
  7215. ],
  7216. [
  7217. 13,
  7218. 832
  7219. ],
  7220. [
  7221. 12,
  7222. 55
  7223. ],
  7224. [
  7225. 12,
  7226. 55
  7227. ],
  7228. [
  7229. 12,
  7230. 56
  7231. ],
  7232. [
  7233. 12,
  7234. 56
  7235. ],
  7236. [
  7237. 13,
  7238. 1280
  7239. ],
  7240. [
  7241. 13,
  7242. 1344
  7243. ],
  7244. [
  7245. 13,
  7246. 1408
  7247. ],
  7248. [
  7249. 13,
  7250. 1472
  7251. ],
  7252. [
  7253. 12,
  7254. 59
  7255. ],
  7256. [
  7257. 12,
  7258. 59
  7259. ],
  7260. [
  7261. 12,
  7262. 60
  7263. ],
  7264. [
  7265. 12,
  7266. 60
  7267. ],
  7268. [
  7269. 13,
  7270. 1536
  7271. ],
  7272. [
  7273. 13,
  7274. 1600
  7275. ],
  7276. [
  7277. 11,
  7278. 24
  7279. ],
  7280. [
  7281. 11,
  7282. 24
  7283. ],
  7284. [
  7285. 11,
  7286. 24
  7287. ],
  7288. [
  7289. 11,
  7290. 24
  7291. ],
  7292. [
  7293. 11,
  7294. 25
  7295. ],
  7296. [
  7297. 11,
  7298. 25
  7299. ],
  7300. [
  7301. 11,
  7302. 25
  7303. ],
  7304. [
  7305. 11,
  7306. 25
  7307. ],
  7308. [
  7309. 13,
  7310. 1664
  7311. ],
  7312. [
  7313. 13,
  7314. 1728
  7315. ],
  7316. [
  7317. 12,
  7318. 320
  7319. ],
  7320. [
  7321. 12,
  7322. 320
  7323. ],
  7324. [
  7325. 12,
  7326. 384
  7327. ],
  7328. [
  7329. 12,
  7330. 384
  7331. ],
  7332. [
  7333. 12,
  7334. 448
  7335. ],
  7336. [
  7337. 12,
  7338. 448
  7339. ],
  7340. [
  7341. 13,
  7342. 512
  7343. ],
  7344. [
  7345. 13,
  7346. 576
  7347. ],
  7348. [
  7349. 12,
  7350. 53
  7351. ],
  7352. [
  7353. 12,
  7354. 53
  7355. ],
  7356. [
  7357. 12,
  7358. 54
  7359. ],
  7360. [
  7361. 12,
  7362. 54
  7363. ],
  7364. [
  7365. 13,
  7366. 896
  7367. ],
  7368. [
  7369. 13,
  7370. 960
  7371. ],
  7372. [
  7373. 13,
  7374. 1024
  7375. ],
  7376. [
  7377. 13,
  7378. 1088
  7379. ],
  7380. [
  7381. 13,
  7382. 1152
  7383. ],
  7384. [
  7385. 13,
  7386. 1216
  7387. ],
  7388. [
  7389. 10,
  7390. 64
  7391. ],
  7392. [
  7393. 10,
  7394. 64
  7395. ],
  7396. [
  7397. 10,
  7398. 64
  7399. ],
  7400. [
  7401. 10,
  7402. 64
  7403. ],
  7404. [
  7405. 10,
  7406. 64
  7407. ],
  7408. [
  7409. 10,
  7410. 64
  7411. ],
  7412. [
  7413. 10,
  7414. 64
  7415. ],
  7416. [
  7417. 10,
  7418. 64
  7419. ]
  7420. ];
  7421. var blackTable2 = [
  7422. [
  7423. 8,
  7424. 13
  7425. ],
  7426. [
  7427. 8,
  7428. 13
  7429. ],
  7430. [
  7431. 8,
  7432. 13
  7433. ],
  7434. [
  7435. 8,
  7436. 13
  7437. ],
  7438. [
  7439. 8,
  7440. 13
  7441. ],
  7442. [
  7443. 8,
  7444. 13
  7445. ],
  7446. [
  7447. 8,
  7448. 13
  7449. ],
  7450. [
  7451. 8,
  7452. 13
  7453. ],
  7454. [
  7455. 8,
  7456. 13
  7457. ],
  7458. [
  7459. 8,
  7460. 13
  7461. ],
  7462. [
  7463. 8,
  7464. 13
  7465. ],
  7466. [
  7467. 8,
  7468. 13
  7469. ],
  7470. [
  7471. 8,
  7472. 13
  7473. ],
  7474. [
  7475. 8,
  7476. 13
  7477. ],
  7478. [
  7479. 8,
  7480. 13
  7481. ],
  7482. [
  7483. 8,
  7484. 13
  7485. ],
  7486. [
  7487. 11,
  7488. 23
  7489. ],
  7490. [
  7491. 11,
  7492. 23
  7493. ],
  7494. [
  7495. 12,
  7496. 50
  7497. ],
  7498. [
  7499. 12,
  7500. 51
  7501. ],
  7502. [
  7503. 12,
  7504. 44
  7505. ],
  7506. [
  7507. 12,
  7508. 45
  7509. ],
  7510. [
  7511. 12,
  7512. 46
  7513. ],
  7514. [
  7515. 12,
  7516. 47
  7517. ],
  7518. [
  7519. 12,
  7520. 57
  7521. ],
  7522. [
  7523. 12,
  7524. 58
  7525. ],
  7526. [
  7527. 12,
  7528. 61
  7529. ],
  7530. [
  7531. 12,
  7532. 256
  7533. ],
  7534. [
  7535. 10,
  7536. 16
  7537. ],
  7538. [
  7539. 10,
  7540. 16
  7541. ],
  7542. [
  7543. 10,
  7544. 16
  7545. ],
  7546. [
  7547. 10,
  7548. 16
  7549. ],
  7550. [
  7551. 10,
  7552. 17
  7553. ],
  7554. [
  7555. 10,
  7556. 17
  7557. ],
  7558. [
  7559. 10,
  7560. 17
  7561. ],
  7562. [
  7563. 10,
  7564. 17
  7565. ],
  7566. [
  7567. 12,
  7568. 48
  7569. ],
  7570. [
  7571. 12,
  7572. 49
  7573. ],
  7574. [
  7575. 12,
  7576. 62
  7577. ],
  7578. [
  7579. 12,
  7580. 63
  7581. ],
  7582. [
  7583. 12,
  7584. 30
  7585. ],
  7586. [
  7587. 12,
  7588. 31
  7589. ],
  7590. [
  7591. 12,
  7592. 32
  7593. ],
  7594. [
  7595. 12,
  7596. 33
  7597. ],
  7598. [
  7599. 12,
  7600. 40
  7601. ],
  7602. [
  7603. 12,
  7604. 41
  7605. ],
  7606. [
  7607. 11,
  7608. 22
  7609. ],
  7610. [
  7611. 11,
  7612. 22
  7613. ],
  7614. [
  7615. 8,
  7616. 14
  7617. ],
  7618. [
  7619. 8,
  7620. 14
  7621. ],
  7622. [
  7623. 8,
  7624. 14
  7625. ],
  7626. [
  7627. 8,
  7628. 14
  7629. ],
  7630. [
  7631. 8,
  7632. 14
  7633. ],
  7634. [
  7635. 8,
  7636. 14
  7637. ],
  7638. [
  7639. 8,
  7640. 14
  7641. ],
  7642. [
  7643. 8,
  7644. 14
  7645. ],
  7646. [
  7647. 8,
  7648. 14
  7649. ],
  7650. [
  7651. 8,
  7652. 14
  7653. ],
  7654. [
  7655. 8,
  7656. 14
  7657. ],
  7658. [
  7659. 8,
  7660. 14
  7661. ],
  7662. [
  7663. 8,
  7664. 14
  7665. ],
  7666. [
  7667. 8,
  7668. 14
  7669. ],
  7670. [
  7671. 8,
  7672. 14
  7673. ],
  7674. [
  7675. 8,
  7676. 14
  7677. ],
  7678. [
  7679. 7,
  7680. 10
  7681. ],
  7682. [
  7683. 7,
  7684. 10
  7685. ],
  7686. [
  7687. 7,
  7688. 10
  7689. ],
  7690. [
  7691. 7,
  7692. 10
  7693. ],
  7694. [
  7695. 7,
  7696. 10
  7697. ],
  7698. [
  7699. 7,
  7700. 10
  7701. ],
  7702. [
  7703. 7,
  7704. 10
  7705. ],
  7706. [
  7707. 7,
  7708. 10
  7709. ],
  7710. [
  7711. 7,
  7712. 10
  7713. ],
  7714. [
  7715. 7,
  7716. 10
  7717. ],
  7718. [
  7719. 7,
  7720. 10
  7721. ],
  7722. [
  7723. 7,
  7724. 10
  7725. ],
  7726. [
  7727. 7,
  7728. 10
  7729. ],
  7730. [
  7731. 7,
  7732. 10
  7733. ],
  7734. [
  7735. 7,
  7736. 10
  7737. ],
  7738. [
  7739. 7,
  7740. 10
  7741. ],
  7742. [
  7743. 7,
  7744. 10
  7745. ],
  7746. [
  7747. 7,
  7748. 10
  7749. ],
  7750. [
  7751. 7,
  7752. 10
  7753. ],
  7754. [
  7755. 7,
  7756. 10
  7757. ],
  7758. [
  7759. 7,
  7760. 10
  7761. ],
  7762. [
  7763. 7,
  7764. 10
  7765. ],
  7766. [
  7767. 7,
  7768. 10
  7769. ],
  7770. [
  7771. 7,
  7772. 10
  7773. ],
  7774. [
  7775. 7,
  7776. 10
  7777. ],
  7778. [
  7779. 7,
  7780. 10
  7781. ],
  7782. [
  7783. 7,
  7784. 10
  7785. ],
  7786. [
  7787. 7,
  7788. 10
  7789. ],
  7790. [
  7791. 7,
  7792. 10
  7793. ],
  7794. [
  7795. 7,
  7796. 10
  7797. ],
  7798. [
  7799. 7,
  7800. 10
  7801. ],
  7802. [
  7803. 7,
  7804. 10
  7805. ],
  7806. [
  7807. 7,
  7808. 11
  7809. ],
  7810. [
  7811. 7,
  7812. 11
  7813. ],
  7814. [
  7815. 7,
  7816. 11
  7817. ],
  7818. [
  7819. 7,
  7820. 11
  7821. ],
  7822. [
  7823. 7,
  7824. 11
  7825. ],
  7826. [
  7827. 7,
  7828. 11
  7829. ],
  7830. [
  7831. 7,
  7832. 11
  7833. ],
  7834. [
  7835. 7,
  7836. 11
  7837. ],
  7838. [
  7839. 7,
  7840. 11
  7841. ],
  7842. [
  7843. 7,
  7844. 11
  7845. ],
  7846. [
  7847. 7,
  7848. 11
  7849. ],
  7850. [
  7851. 7,
  7852. 11
  7853. ],
  7854. [
  7855. 7,
  7856. 11
  7857. ],
  7858. [
  7859. 7,
  7860. 11
  7861. ],
  7862. [
  7863. 7,
  7864. 11
  7865. ],
  7866. [
  7867. 7,
  7868. 11
  7869. ],
  7870. [
  7871. 7,
  7872. 11
  7873. ],
  7874. [
  7875. 7,
  7876. 11
  7877. ],
  7878. [
  7879. 7,
  7880. 11
  7881. ],
  7882. [
  7883. 7,
  7884. 11
  7885. ],
  7886. [
  7887. 7,
  7888. 11
  7889. ],
  7890. [
  7891. 7,
  7892. 11
  7893. ],
  7894. [
  7895. 7,
  7896. 11
  7897. ],
  7898. [
  7899. 7,
  7900. 11
  7901. ],
  7902. [
  7903. 7,
  7904. 11
  7905. ],
  7906. [
  7907. 7,
  7908. 11
  7909. ],
  7910. [
  7911. 7,
  7912. 11
  7913. ],
  7914. [
  7915. 7,
  7916. 11
  7917. ],
  7918. [
  7919. 7,
  7920. 11
  7921. ],
  7922. [
  7923. 7,
  7924. 11
  7925. ],
  7926. [
  7927. 7,
  7928. 11
  7929. ],
  7930. [
  7931. 7,
  7932. 11
  7933. ],
  7934. [
  7935. 9,
  7936. 15
  7937. ],
  7938. [
  7939. 9,
  7940. 15
  7941. ],
  7942. [
  7943. 9,
  7944. 15
  7945. ],
  7946. [
  7947. 9,
  7948. 15
  7949. ],
  7950. [
  7951. 9,
  7952. 15
  7953. ],
  7954. [
  7955. 9,
  7956. 15
  7957. ],
  7958. [
  7959. 9,
  7960. 15
  7961. ],
  7962. [
  7963. 9,
  7964. 15
  7965. ],
  7966. [
  7967. 12,
  7968. 128
  7969. ],
  7970. [
  7971. 12,
  7972. 192
  7973. ],
  7974. [
  7975. 12,
  7976. 26
  7977. ],
  7978. [
  7979. 12,
  7980. 27
  7981. ],
  7982. [
  7983. 12,
  7984. 28
  7985. ],
  7986. [
  7987. 12,
  7988. 29
  7989. ],
  7990. [
  7991. 11,
  7992. 19
  7993. ],
  7994. [
  7995. 11,
  7996. 19
  7997. ],
  7998. [
  7999. 11,
  8000. 20
  8001. ],
  8002. [
  8003. 11,
  8004. 20
  8005. ],
  8006. [
  8007. 12,
  8008. 34
  8009. ],
  8010. [
  8011. 12,
  8012. 35
  8013. ],
  8014. [
  8015. 12,
  8016. 36
  8017. ],
  8018. [
  8019. 12,
  8020. 37
  8021. ],
  8022. [
  8023. 12,
  8024. 38
  8025. ],
  8026. [
  8027. 12,
  8028. 39
  8029. ],
  8030. [
  8031. 11,
  8032. 21
  8033. ],
  8034. [
  8035. 11,
  8036. 21
  8037. ],
  8038. [
  8039. 12,
  8040. 42
  8041. ],
  8042. [
  8043. 12,
  8044. 43
  8045. ],
  8046. [
  8047. 10,
  8048. 0
  8049. ],
  8050. [
  8051. 10,
  8052. 0
  8053. ],
  8054. [
  8055. 10,
  8056. 0
  8057. ],
  8058. [
  8059. 10,
  8060. 0
  8061. ],
  8062. [
  8063. 7,
  8064. 12
  8065. ],
  8066. [
  8067. 7,
  8068. 12
  8069. ],
  8070. [
  8071. 7,
  8072. 12
  8073. ],
  8074. [
  8075. 7,
  8076. 12
  8077. ],
  8078. [
  8079. 7,
  8080. 12
  8081. ],
  8082. [
  8083. 7,
  8084. 12
  8085. ],
  8086. [
  8087. 7,
  8088. 12
  8089. ],
  8090. [
  8091. 7,
  8092. 12
  8093. ],
  8094. [
  8095. 7,
  8096. 12
  8097. ],
  8098. [
  8099. 7,
  8100. 12
  8101. ],
  8102. [
  8103. 7,
  8104. 12
  8105. ],
  8106. [
  8107. 7,
  8108. 12
  8109. ],
  8110. [
  8111. 7,
  8112. 12
  8113. ],
  8114. [
  8115. 7,
  8116. 12
  8117. ],
  8118. [
  8119. 7,
  8120. 12
  8121. ],
  8122. [
  8123. 7,
  8124. 12
  8125. ],
  8126. [
  8127. 7,
  8128. 12
  8129. ],
  8130. [
  8131. 7,
  8132. 12
  8133. ],
  8134. [
  8135. 7,
  8136. 12
  8137. ],
  8138. [
  8139. 7,
  8140. 12
  8141. ],
  8142. [
  8143. 7,
  8144. 12
  8145. ],
  8146. [
  8147. 7,
  8148. 12
  8149. ],
  8150. [
  8151. 7,
  8152. 12
  8153. ],
  8154. [
  8155. 7,
  8156. 12
  8157. ],
  8158. [
  8159. 7,
  8160. 12
  8161. ],
  8162. [
  8163. 7,
  8164. 12
  8165. ],
  8166. [
  8167. 7,
  8168. 12
  8169. ],
  8170. [
  8171. 7,
  8172. 12
  8173. ],
  8174. [
  8175. 7,
  8176. 12
  8177. ],
  8178. [
  8179. 7,
  8180. 12
  8181. ],
  8182. [
  8183. 7,
  8184. 12
  8185. ],
  8186. [
  8187. 7,
  8188. 12
  8189. ]
  8190. ];
  8191. var blackTable3 = [
  8192. [
  8193. -1,
  8194. -1
  8195. ],
  8196. [
  8197. -1,
  8198. -1
  8199. ],
  8200. [
  8201. -1,
  8202. -1
  8203. ],
  8204. [
  8205. -1,
  8206. -1
  8207. ],
  8208. [
  8209. 6,
  8210. 9
  8211. ],
  8212. [
  8213. 6,
  8214. 8
  8215. ],
  8216. [
  8217. 5,
  8218. 7
  8219. ],
  8220. [
  8221. 5,
  8222. 7
  8223. ],
  8224. [
  8225. 4,
  8226. 6
  8227. ],
  8228. [
  8229. 4,
  8230. 6
  8231. ],
  8232. [
  8233. 4,
  8234. 6
  8235. ],
  8236. [
  8237. 4,
  8238. 6
  8239. ],
  8240. [
  8241. 4,
  8242. 5
  8243. ],
  8244. [
  8245. 4,
  8246. 5
  8247. ],
  8248. [
  8249. 4,
  8250. 5
  8251. ],
  8252. [
  8253. 4,
  8254. 5
  8255. ],
  8256. [
  8257. 3,
  8258. 1
  8259. ],
  8260. [
  8261. 3,
  8262. 1
  8263. ],
  8264. [
  8265. 3,
  8266. 1
  8267. ],
  8268. [
  8269. 3,
  8270. 1
  8271. ],
  8272. [
  8273. 3,
  8274. 1
  8275. ],
  8276. [
  8277. 3,
  8278. 1
  8279. ],
  8280. [
  8281. 3,
  8282. 1
  8283. ],
  8284. [
  8285. 3,
  8286. 1
  8287. ],
  8288. [
  8289. 3,
  8290. 4
  8291. ],
  8292. [
  8293. 3,
  8294. 4
  8295. ],
  8296. [
  8297. 3,
  8298. 4
  8299. ],
  8300. [
  8301. 3,
  8302. 4
  8303. ],
  8304. [
  8305. 3,
  8306. 4
  8307. ],
  8308. [
  8309. 3,
  8310. 4
  8311. ],
  8312. [
  8313. 3,
  8314. 4
  8315. ],
  8316. [
  8317. 3,
  8318. 4
  8319. ],
  8320. [
  8321. 2,
  8322. 3
  8323. ],
  8324. [
  8325. 2,
  8326. 3
  8327. ],
  8328. [
  8329. 2,
  8330. 3
  8331. ],
  8332. [
  8333. 2,
  8334. 3
  8335. ],
  8336. [
  8337. 2,
  8338. 3
  8339. ],
  8340. [
  8341. 2,
  8342. 3
  8343. ],
  8344. [
  8345. 2,
  8346. 3
  8347. ],
  8348. [
  8349. 2,
  8350. 3
  8351. ],
  8352. [
  8353. 2,
  8354. 3
  8355. ],
  8356. [
  8357. 2,
  8358. 3
  8359. ],
  8360. [
  8361. 2,
  8362. 3
  8363. ],
  8364. [
  8365. 2,
  8366. 3
  8367. ],
  8368. [
  8369. 2,
  8370. 3
  8371. ],
  8372. [
  8373. 2,
  8374. 3
  8375. ],
  8376. [
  8377. 2,
  8378. 3
  8379. ],
  8380. [
  8381. 2,
  8382. 3
  8383. ],
  8384. [
  8385. 2,
  8386. 2
  8387. ],
  8388. [
  8389. 2,
  8390. 2
  8391. ],
  8392. [
  8393. 2,
  8394. 2
  8395. ],
  8396. [
  8397. 2,
  8398. 2
  8399. ],
  8400. [
  8401. 2,
  8402. 2
  8403. ],
  8404. [
  8405. 2,
  8406. 2
  8407. ],
  8408. [
  8409. 2,
  8410. 2
  8411. ],
  8412. [
  8413. 2,
  8414. 2
  8415. ],
  8416. [
  8417. 2,
  8418. 2
  8419. ],
  8420. [
  8421. 2,
  8422. 2
  8423. ],
  8424. [
  8425. 2,
  8426. 2
  8427. ],
  8428. [
  8429. 2,
  8430. 2
  8431. ],
  8432. [
  8433. 2,
  8434. 2
  8435. ],
  8436. [
  8437. 2,
  8438. 2
  8439. ],
  8440. [
  8441. 2,
  8442. 2
  8443. ],
  8444. [
  8445. 2,
  8446. 2
  8447. ]
  8448. ];
  8449. function CCITTFaxStream(str, maybeLength, params) {
  8450. this.str = str;
  8451. this.dict = str.dict;
  8452. params = params || Dict.empty;
  8453. this.encoding = params.get('K') || 0;
  8454. this.eoline = params.get('EndOfLine') || false;
  8455. this.byteAlign = params.get('EncodedByteAlign') || false;
  8456. this.columns = params.get('Columns') || 1728;
  8457. this.rows = params.get('Rows') || 0;
  8458. var eoblock = params.get('EndOfBlock');
  8459. if (eoblock === null || eoblock === undefined) {
  8460. eoblock = true;
  8461. }
  8462. this.eoblock = eoblock;
  8463. this.black = params.get('BlackIs1') || false;
  8464. this.codingLine = new Uint32Array(this.columns + 1);
  8465. this.refLine = new Uint32Array(this.columns + 2);
  8466. this.codingLine[0] = this.columns;
  8467. this.codingPos = 0;
  8468. this.row = 0;
  8469. this.nextLine2D = this.encoding < 0;
  8470. this.inputBits = 0;
  8471. this.inputBuf = 0;
  8472. this.outputBits = 0;
  8473. var code1;
  8474. while ((code1 = this.lookBits(12)) === 0) {
  8475. this.eatBits(1);
  8476. }
  8477. if (code1 === 1) {
  8478. this.eatBits(12);
  8479. }
  8480. if (this.encoding > 0) {
  8481. this.nextLine2D = !this.lookBits(1);
  8482. this.eatBits(1);
  8483. }
  8484. DecodeStream.call(this, maybeLength);
  8485. }
  8486. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  8487. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  8488. while (!this.eof) {
  8489. var c = this.lookChar();
  8490. this.ensureBuffer(this.bufferLength + 1);
  8491. this.buffer[this.bufferLength++] = c;
  8492. }
  8493. };
  8494. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  8495. var codingLine = this.codingLine;
  8496. var codingPos = this.codingPos;
  8497. if (a1 > codingLine[codingPos]) {
  8498. if (a1 > this.columns) {
  8499. info('row is wrong length');
  8500. this.err = true;
  8501. a1 = this.columns;
  8502. }
  8503. if (codingPos & 1 ^ blackPixels) {
  8504. ++codingPos;
  8505. }
  8506. codingLine[codingPos] = a1;
  8507. }
  8508. this.codingPos = codingPos;
  8509. };
  8510. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  8511. var codingLine = this.codingLine;
  8512. var codingPos = this.codingPos;
  8513. if (a1 > codingLine[codingPos]) {
  8514. if (a1 > this.columns) {
  8515. info('row is wrong length');
  8516. this.err = true;
  8517. a1 = this.columns;
  8518. }
  8519. if (codingPos & 1 ^ blackPixels) {
  8520. ++codingPos;
  8521. }
  8522. codingLine[codingPos] = a1;
  8523. } else if (a1 < codingLine[codingPos]) {
  8524. if (a1 < 0) {
  8525. info('invalid code');
  8526. this.err = true;
  8527. a1 = 0;
  8528. }
  8529. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  8530. --codingPos;
  8531. }
  8532. codingLine[codingPos] = a1;
  8533. }
  8534. this.codingPos = codingPos;
  8535. };
  8536. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  8537. var refLine = this.refLine;
  8538. var codingLine = this.codingLine;
  8539. var columns = this.columns;
  8540. var refPos, blackPixels, bits, i;
  8541. if (this.outputBits === 0) {
  8542. if (this.eof) {
  8543. return null;
  8544. }
  8545. this.err = false;
  8546. var code1, code2, code3;
  8547. if (this.nextLine2D) {
  8548. for (i = 0; codingLine[i] < columns; ++i) {
  8549. refLine[i] = codingLine[i];
  8550. }
  8551. refLine[i++] = columns;
  8552. refLine[i] = columns;
  8553. codingLine[0] = 0;
  8554. this.codingPos = 0;
  8555. refPos = 0;
  8556. blackPixels = 0;
  8557. while (codingLine[this.codingPos] < columns) {
  8558. code1 = this.getTwoDimCode();
  8559. switch (code1) {
  8560. case twoDimPass:
  8561. this.addPixels(refLine[refPos + 1], blackPixels);
  8562. if (refLine[refPos + 1] < columns) {
  8563. refPos += 2;
  8564. }
  8565. break;
  8566. case twoDimHoriz:
  8567. code1 = code2 = 0;
  8568. if (blackPixels) {
  8569. do {
  8570. code1 += code3 = this.getBlackCode();
  8571. } while (code3 >= 64);
  8572. do {
  8573. code2 += code3 = this.getWhiteCode();
  8574. } while (code3 >= 64);
  8575. } else {
  8576. do {
  8577. code1 += code3 = this.getWhiteCode();
  8578. } while (code3 >= 64);
  8579. do {
  8580. code2 += code3 = this.getBlackCode();
  8581. } while (code3 >= 64);
  8582. }
  8583. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  8584. if (codingLine[this.codingPos] < columns) {
  8585. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  8586. }
  8587. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8588. refPos += 2;
  8589. }
  8590. break;
  8591. case twoDimVertR3:
  8592. this.addPixels(refLine[refPos] + 3, blackPixels);
  8593. blackPixels ^= 1;
  8594. if (codingLine[this.codingPos] < columns) {
  8595. ++refPos;
  8596. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8597. refPos += 2;
  8598. }
  8599. }
  8600. break;
  8601. case twoDimVertR2:
  8602. this.addPixels(refLine[refPos] + 2, blackPixels);
  8603. blackPixels ^= 1;
  8604. if (codingLine[this.codingPos] < columns) {
  8605. ++refPos;
  8606. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8607. refPos += 2;
  8608. }
  8609. }
  8610. break;
  8611. case twoDimVertR1:
  8612. this.addPixels(refLine[refPos] + 1, blackPixels);
  8613. blackPixels ^= 1;
  8614. if (codingLine[this.codingPos] < columns) {
  8615. ++refPos;
  8616. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8617. refPos += 2;
  8618. }
  8619. }
  8620. break;
  8621. case twoDimVert0:
  8622. this.addPixels(refLine[refPos], blackPixels);
  8623. blackPixels ^= 1;
  8624. if (codingLine[this.codingPos] < columns) {
  8625. ++refPos;
  8626. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8627. refPos += 2;
  8628. }
  8629. }
  8630. break;
  8631. case twoDimVertL3:
  8632. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  8633. blackPixels ^= 1;
  8634. if (codingLine[this.codingPos] < columns) {
  8635. if (refPos > 0) {
  8636. --refPos;
  8637. } else {
  8638. ++refPos;
  8639. }
  8640. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8641. refPos += 2;
  8642. }
  8643. }
  8644. break;
  8645. case twoDimVertL2:
  8646. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  8647. blackPixels ^= 1;
  8648. if (codingLine[this.codingPos] < columns) {
  8649. if (refPos > 0) {
  8650. --refPos;
  8651. } else {
  8652. ++refPos;
  8653. }
  8654. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8655. refPos += 2;
  8656. }
  8657. }
  8658. break;
  8659. case twoDimVertL1:
  8660. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  8661. blackPixels ^= 1;
  8662. if (codingLine[this.codingPos] < columns) {
  8663. if (refPos > 0) {
  8664. --refPos;
  8665. } else {
  8666. ++refPos;
  8667. }
  8668. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8669. refPos += 2;
  8670. }
  8671. }
  8672. break;
  8673. case ccittEOF:
  8674. this.addPixels(columns, 0);
  8675. this.eof = true;
  8676. break;
  8677. default:
  8678. info('bad 2d code');
  8679. this.addPixels(columns, 0);
  8680. this.err = true;
  8681. }
  8682. }
  8683. } else {
  8684. codingLine[0] = 0;
  8685. this.codingPos = 0;
  8686. blackPixels = 0;
  8687. while (codingLine[this.codingPos] < columns) {
  8688. code1 = 0;
  8689. if (blackPixels) {
  8690. do {
  8691. code1 += code3 = this.getBlackCode();
  8692. } while (code3 >= 64);
  8693. } else {
  8694. do {
  8695. code1 += code3 = this.getWhiteCode();
  8696. } while (code3 >= 64);
  8697. }
  8698. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  8699. blackPixels ^= 1;
  8700. }
  8701. }
  8702. var gotEOL = false;
  8703. if (this.byteAlign) {
  8704. this.inputBits &= ~7;
  8705. }
  8706. if (!this.eoblock && this.row === this.rows - 1) {
  8707. this.eof = true;
  8708. } else {
  8709. code1 = this.lookBits(12);
  8710. if (this.eoline) {
  8711. while (code1 !== ccittEOF && code1 !== 1) {
  8712. this.eatBits(1);
  8713. code1 = this.lookBits(12);
  8714. }
  8715. } else {
  8716. while (code1 === 0) {
  8717. this.eatBits(1);
  8718. code1 = this.lookBits(12);
  8719. }
  8720. }
  8721. if (code1 === 1) {
  8722. this.eatBits(12);
  8723. gotEOL = true;
  8724. } else if (code1 === ccittEOF) {
  8725. this.eof = true;
  8726. }
  8727. }
  8728. if (!this.eof && this.encoding > 0) {
  8729. this.nextLine2D = !this.lookBits(1);
  8730. this.eatBits(1);
  8731. }
  8732. if (this.eoblock && gotEOL && this.byteAlign) {
  8733. code1 = this.lookBits(12);
  8734. if (code1 === 1) {
  8735. this.eatBits(12);
  8736. if (this.encoding > 0) {
  8737. this.lookBits(1);
  8738. this.eatBits(1);
  8739. }
  8740. if (this.encoding >= 0) {
  8741. for (i = 0; i < 4; ++i) {
  8742. code1 = this.lookBits(12);
  8743. if (code1 !== 1) {
  8744. info('bad rtc code: ' + code1);
  8745. }
  8746. this.eatBits(12);
  8747. if (this.encoding > 0) {
  8748. this.lookBits(1);
  8749. this.eatBits(1);
  8750. }
  8751. }
  8752. }
  8753. this.eof = true;
  8754. }
  8755. } else if (this.err && this.eoline) {
  8756. while (true) {
  8757. code1 = this.lookBits(13);
  8758. if (code1 === ccittEOF) {
  8759. this.eof = true;
  8760. return null;
  8761. }
  8762. if (code1 >> 1 === 1) {
  8763. break;
  8764. }
  8765. this.eatBits(1);
  8766. }
  8767. this.eatBits(12);
  8768. if (this.encoding > 0) {
  8769. this.eatBits(1);
  8770. this.nextLine2D = !(code1 & 1);
  8771. }
  8772. }
  8773. if (codingLine[0] > 0) {
  8774. this.outputBits = codingLine[this.codingPos = 0];
  8775. } else {
  8776. this.outputBits = codingLine[this.codingPos = 1];
  8777. }
  8778. this.row++;
  8779. }
  8780. var c;
  8781. if (this.outputBits >= 8) {
  8782. c = this.codingPos & 1 ? 0 : 0xFF;
  8783. this.outputBits -= 8;
  8784. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  8785. this.codingPos++;
  8786. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  8787. }
  8788. } else {
  8789. bits = 8;
  8790. c = 0;
  8791. do {
  8792. if (this.outputBits > bits) {
  8793. c <<= bits;
  8794. if (!(this.codingPos & 1)) {
  8795. c |= 0xFF >> 8 - bits;
  8796. }
  8797. this.outputBits -= bits;
  8798. bits = 0;
  8799. } else {
  8800. c <<= this.outputBits;
  8801. if (!(this.codingPos & 1)) {
  8802. c |= 0xFF >> 8 - this.outputBits;
  8803. }
  8804. bits -= this.outputBits;
  8805. this.outputBits = 0;
  8806. if (codingLine[this.codingPos] < columns) {
  8807. this.codingPos++;
  8808. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  8809. } else if (bits > 0) {
  8810. c <<= bits;
  8811. bits = 0;
  8812. }
  8813. }
  8814. } while (bits);
  8815. }
  8816. if (this.black) {
  8817. c ^= 0xFF;
  8818. }
  8819. return c;
  8820. };
  8821. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  8822. var limitValue = limit || 0;
  8823. for (var i = start; i <= end; ++i) {
  8824. var code = this.lookBits(i);
  8825. if (code === ccittEOF) {
  8826. return [
  8827. true,
  8828. 1,
  8829. false
  8830. ];
  8831. }
  8832. if (i < end) {
  8833. code <<= end - i;
  8834. }
  8835. if (!limitValue || code >= limitValue) {
  8836. var p = table[code - limitValue];
  8837. if (p[0] === i) {
  8838. this.eatBits(i);
  8839. return [
  8840. true,
  8841. p[1],
  8842. true
  8843. ];
  8844. }
  8845. }
  8846. }
  8847. return [
  8848. false,
  8849. 0,
  8850. false
  8851. ];
  8852. };
  8853. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  8854. var code = 0;
  8855. var p;
  8856. if (this.eoblock) {
  8857. code = this.lookBits(7);
  8858. p = twoDimTable[code];
  8859. if (p && p[0] > 0) {
  8860. this.eatBits(p[0]);
  8861. return p[1];
  8862. }
  8863. } else {
  8864. var result = this.findTableCode(1, 7, twoDimTable);
  8865. if (result[0] && result[2]) {
  8866. return result[1];
  8867. }
  8868. }
  8869. info('Bad two dim code');
  8870. return ccittEOF;
  8871. };
  8872. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  8873. var code = 0;
  8874. var p;
  8875. if (this.eoblock) {
  8876. code = this.lookBits(12);
  8877. if (code === ccittEOF) {
  8878. return 1;
  8879. }
  8880. if (code >> 5 === 0) {
  8881. p = whiteTable1[code];
  8882. } else {
  8883. p = whiteTable2[code >> 3];
  8884. }
  8885. if (p[0] > 0) {
  8886. this.eatBits(p[0]);
  8887. return p[1];
  8888. }
  8889. } else {
  8890. var result = this.findTableCode(1, 9, whiteTable2);
  8891. if (result[0]) {
  8892. return result[1];
  8893. }
  8894. result = this.findTableCode(11, 12, whiteTable1);
  8895. if (result[0]) {
  8896. return result[1];
  8897. }
  8898. }
  8899. info('bad white code');
  8900. this.eatBits(1);
  8901. return 1;
  8902. };
  8903. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  8904. var code, p;
  8905. if (this.eoblock) {
  8906. code = this.lookBits(13);
  8907. if (code === ccittEOF) {
  8908. return 1;
  8909. }
  8910. if (code >> 7 === 0) {
  8911. p = blackTable1[code];
  8912. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  8913. p = blackTable2[(code >> 1) - 64];
  8914. } else {
  8915. p = blackTable3[code >> 7];
  8916. }
  8917. if (p[0] > 0) {
  8918. this.eatBits(p[0]);
  8919. return p[1];
  8920. }
  8921. } else {
  8922. var result = this.findTableCode(2, 6, blackTable3);
  8923. if (result[0]) {
  8924. return result[1];
  8925. }
  8926. result = this.findTableCode(7, 12, blackTable2, 64);
  8927. if (result[0]) {
  8928. return result[1];
  8929. }
  8930. result = this.findTableCode(10, 13, blackTable1);
  8931. if (result[0]) {
  8932. return result[1];
  8933. }
  8934. }
  8935. info('bad black code');
  8936. this.eatBits(1);
  8937. return 1;
  8938. };
  8939. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  8940. var c;
  8941. while (this.inputBits < n) {
  8942. if ((c = this.str.getByte()) === -1) {
  8943. if (this.inputBits === 0) {
  8944. return ccittEOF;
  8945. }
  8946. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  8947. }
  8948. this.inputBuf = this.inputBuf << 8 | c;
  8949. this.inputBits += 8;
  8950. }
  8951. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  8952. };
  8953. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  8954. if ((this.inputBits -= n) < 0) {
  8955. this.inputBits = 0;
  8956. }
  8957. };
  8958. return CCITTFaxStream;
  8959. }();
  8960. var LZWStream = function LZWStreamClosure() {
  8961. function LZWStream(str, maybeLength, earlyChange) {
  8962. this.str = str;
  8963. this.dict = str.dict;
  8964. this.cachedData = 0;
  8965. this.bitsCached = 0;
  8966. var maxLzwDictionarySize = 4096;
  8967. var lzwState = {
  8968. earlyChange: earlyChange,
  8969. codeLength: 9,
  8970. nextCode: 258,
  8971. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  8972. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  8973. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  8974. currentSequence: new Uint8Array(maxLzwDictionarySize),
  8975. currentSequenceLength: 0
  8976. };
  8977. for (var i = 0; i < 256; ++i) {
  8978. lzwState.dictionaryValues[i] = i;
  8979. lzwState.dictionaryLengths[i] = 1;
  8980. }
  8981. this.lzwState = lzwState;
  8982. DecodeStream.call(this, maybeLength);
  8983. }
  8984. LZWStream.prototype = Object.create(DecodeStream.prototype);
  8985. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  8986. var bitsCached = this.bitsCached;
  8987. var cachedData = this.cachedData;
  8988. while (bitsCached < n) {
  8989. var c = this.str.getByte();
  8990. if (c === -1) {
  8991. this.eof = true;
  8992. return null;
  8993. }
  8994. cachedData = cachedData << 8 | c;
  8995. bitsCached += 8;
  8996. }
  8997. this.bitsCached = bitsCached -= n;
  8998. this.cachedData = cachedData;
  8999. this.lastCode = null;
  9000. return cachedData >>> bitsCached & (1 << n) - 1;
  9001. };
  9002. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  9003. var blockSize = 512;
  9004. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  9005. var i, j, q;
  9006. var lzwState = this.lzwState;
  9007. if (!lzwState) {
  9008. return;
  9009. }
  9010. var earlyChange = lzwState.earlyChange;
  9011. var nextCode = lzwState.nextCode;
  9012. var dictionaryValues = lzwState.dictionaryValues;
  9013. var dictionaryLengths = lzwState.dictionaryLengths;
  9014. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  9015. var codeLength = lzwState.codeLength;
  9016. var prevCode = lzwState.prevCode;
  9017. var currentSequence = lzwState.currentSequence;
  9018. var currentSequenceLength = lzwState.currentSequenceLength;
  9019. var decodedLength = 0;
  9020. var currentBufferLength = this.bufferLength;
  9021. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  9022. for (i = 0; i < blockSize; i++) {
  9023. var code = this.readBits(codeLength);
  9024. var hasPrev = currentSequenceLength > 0;
  9025. if (code < 256) {
  9026. currentSequence[0] = code;
  9027. currentSequenceLength = 1;
  9028. } else if (code >= 258) {
  9029. if (code < nextCode) {
  9030. currentSequenceLength = dictionaryLengths[code];
  9031. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  9032. currentSequence[j] = dictionaryValues[q];
  9033. q = dictionaryPrevCodes[q];
  9034. }
  9035. } else {
  9036. currentSequence[currentSequenceLength++] = currentSequence[0];
  9037. }
  9038. } else if (code === 256) {
  9039. codeLength = 9;
  9040. nextCode = 258;
  9041. currentSequenceLength = 0;
  9042. continue;
  9043. } else {
  9044. this.eof = true;
  9045. delete this.lzwState;
  9046. break;
  9047. }
  9048. if (hasPrev) {
  9049. dictionaryPrevCodes[nextCode] = prevCode;
  9050. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  9051. dictionaryValues[nextCode] = currentSequence[0];
  9052. nextCode++;
  9053. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  9054. }
  9055. prevCode = code;
  9056. decodedLength += currentSequenceLength;
  9057. if (estimatedDecodedSize < decodedLength) {
  9058. do {
  9059. estimatedDecodedSize += decodedSizeDelta;
  9060. } while (estimatedDecodedSize < decodedLength);
  9061. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  9062. }
  9063. for (j = 0; j < currentSequenceLength; j++) {
  9064. buffer[currentBufferLength++] = currentSequence[j];
  9065. }
  9066. }
  9067. lzwState.nextCode = nextCode;
  9068. lzwState.codeLength = codeLength;
  9069. lzwState.prevCode = prevCode;
  9070. lzwState.currentSequenceLength = currentSequenceLength;
  9071. this.bufferLength = currentBufferLength;
  9072. };
  9073. return LZWStream;
  9074. }();
  9075. var NullStream = function NullStreamClosure() {
  9076. function NullStream() {
  9077. Stream.call(this, new Uint8Array(0));
  9078. }
  9079. NullStream.prototype = Stream.prototype;
  9080. return NullStream;
  9081. }();
  9082. exports.Ascii85Stream = Ascii85Stream;
  9083. exports.AsciiHexStream = AsciiHexStream;
  9084. exports.CCITTFaxStream = CCITTFaxStream;
  9085. exports.DecryptStream = DecryptStream;
  9086. exports.DecodeStream = DecodeStream;
  9087. exports.FlateStream = FlateStream;
  9088. exports.Jbig2Stream = Jbig2Stream;
  9089. exports.JpegStream = JpegStream;
  9090. exports.JpxStream = JpxStream;
  9091. exports.NullStream = NullStream;
  9092. exports.PredictorStream = PredictorStream;
  9093. exports.RunLengthStream = RunLengthStream;
  9094. exports.Stream = Stream;
  9095. exports.StreamsSequenceStream = StreamsSequenceStream;
  9096. exports.StringStream = StringStream;
  9097. exports.LZWStream = LZWStream;
  9098. /***/ }),
  9099. /* 3 */
  9100. /***/ (function(module, exports, __w_pdfjs_require__) {
  9101. "use strict";
  9102. var sharedUtil = __w_pdfjs_require__(0);
  9103. var assert = sharedUtil.assert;
  9104. var removeNullCharacters = sharedUtil.removeNullCharacters;
  9105. var warn = sharedUtil.warn;
  9106. var deprecated = sharedUtil.deprecated;
  9107. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  9108. var stringToBytes = sharedUtil.stringToBytes;
  9109. var CMapCompressionType = sharedUtil.CMapCompressionType;
  9110. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  9111. function DOMCanvasFactory() {
  9112. }
  9113. DOMCanvasFactory.prototype = {
  9114. create: function DOMCanvasFactory_create(width, height) {
  9115. assert(width > 0 && height > 0, 'invalid canvas size');
  9116. var canvas = document.createElement('canvas');
  9117. var context = canvas.getContext('2d');
  9118. canvas.width = width;
  9119. canvas.height = height;
  9120. return {
  9121. canvas: canvas,
  9122. context: context
  9123. };
  9124. },
  9125. reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) {
  9126. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  9127. assert(width > 0 && height > 0, 'invalid canvas size');
  9128. canvasAndContextPair.canvas.width = width;
  9129. canvasAndContextPair.canvas.height = height;
  9130. },
  9131. destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) {
  9132. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  9133. canvasAndContextPair.canvas.width = 0;
  9134. canvasAndContextPair.canvas.height = 0;
  9135. canvasAndContextPair.canvas = null;
  9136. canvasAndContextPair.context = null;
  9137. }
  9138. };
  9139. var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() {
  9140. function DOMCMapReaderFactory(params) {
  9141. this.baseUrl = params.baseUrl || null;
  9142. this.isCompressed = params.isCompressed || false;
  9143. }
  9144. DOMCMapReaderFactory.prototype = {
  9145. fetch: function (params) {
  9146. if (!params.name) {
  9147. return Promise.reject(new Error('CMap name must be specified.'));
  9148. }
  9149. return new Promise(function (resolve, reject) {
  9150. var url = this.baseUrl + params.name;
  9151. var request = new XMLHttpRequest();
  9152. if (this.isCompressed) {
  9153. url += '.bcmap';
  9154. request.responseType = 'arraybuffer';
  9155. }
  9156. request.onreadystatechange = function () {
  9157. if (request.readyState === XMLHttpRequest.DONE && (request.status === 200 || request.status === 0)) {
  9158. var data;
  9159. if (this.isCompressed && request.response) {
  9160. data = new Uint8Array(request.response);
  9161. } else if (!this.isCompressed && request.responseText) {
  9162. data = stringToBytes(request.responseText);
  9163. }
  9164. if (data) {
  9165. resolve({
  9166. cMapData: data,
  9167. compressionType: this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE
  9168. });
  9169. return;
  9170. }
  9171. reject(new Error('Unable to load ' + (this.isCompressed ? 'binary' : '') + ' CMap at: ' + url));
  9172. }
  9173. }.bind(this);
  9174. request.open('GET', url, true);
  9175. request.send(null);
  9176. }.bind(this));
  9177. }
  9178. };
  9179. return DOMCMapReaderFactory;
  9180. }();
  9181. var CustomStyle = function CustomStyleClosure() {
  9182. var prefixes = [
  9183. 'ms',
  9184. 'Moz',
  9185. 'Webkit',
  9186. 'O'
  9187. ];
  9188. var _cache = Object.create(null);
  9189. function CustomStyle() {
  9190. }
  9191. CustomStyle.getProp = function get(propName, element) {
  9192. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  9193. return _cache[propName];
  9194. }
  9195. element = element || document.documentElement;
  9196. var style = element.style, prefixed, uPropName;
  9197. if (typeof style[propName] === 'string') {
  9198. return _cache[propName] = propName;
  9199. }
  9200. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  9201. for (var i = 0, l = prefixes.length; i < l; i++) {
  9202. prefixed = prefixes[i] + uPropName;
  9203. if (typeof style[prefixed] === 'string') {
  9204. return _cache[propName] = prefixed;
  9205. }
  9206. }
  9207. return _cache[propName] = 'undefined';
  9208. };
  9209. CustomStyle.setProp = function set(propName, element, str) {
  9210. var prop = this.getProp(propName);
  9211. if (prop !== 'undefined') {
  9212. element.style[prop] = str;
  9213. }
  9214. };
  9215. return CustomStyle;
  9216. }();
  9217. var hasCanvasTypedArrays;
  9218. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  9219. var canvas = document.createElement('canvas');
  9220. canvas.width = canvas.height = 1;
  9221. var ctx = canvas.getContext('2d');
  9222. var imageData = ctx.createImageData(1, 1);
  9223. return typeof imageData.data.buffer !== 'undefined';
  9224. };
  9225. var LinkTarget = {
  9226. NONE: 0,
  9227. SELF: 1,
  9228. BLANK: 2,
  9229. PARENT: 3,
  9230. TOP: 4
  9231. };
  9232. var LinkTargetStringMap = [
  9233. '',
  9234. '_self',
  9235. '_blank',
  9236. '_parent',
  9237. '_top'
  9238. ];
  9239. function addLinkAttributes(link, params) {
  9240. var url = params && params.url;
  9241. link.href = link.title = url ? removeNullCharacters(url) : '';
  9242. if (url) {
  9243. var target = params.target;
  9244. if (typeof target === 'undefined') {
  9245. target = getDefaultSetting('externalLinkTarget');
  9246. }
  9247. link.target = LinkTargetStringMap[target];
  9248. var rel = params.rel;
  9249. if (typeof rel === 'undefined') {
  9250. rel = getDefaultSetting('externalLinkRel');
  9251. }
  9252. link.rel = rel;
  9253. }
  9254. }
  9255. function getFilenameFromUrl(url) {
  9256. var anchor = url.indexOf('#');
  9257. var query = url.indexOf('?');
  9258. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  9259. return url.substring(url.lastIndexOf('/', end) + 1, end);
  9260. }
  9261. function getDefaultSetting(id) {
  9262. var globalSettings = sharedUtil.globalScope.PDFJS;
  9263. switch (id) {
  9264. case 'pdfBug':
  9265. return globalSettings ? globalSettings.pdfBug : false;
  9266. case 'disableAutoFetch':
  9267. return globalSettings ? globalSettings.disableAutoFetch : false;
  9268. case 'disableStream':
  9269. return globalSettings ? globalSettings.disableStream : false;
  9270. case 'disableRange':
  9271. return globalSettings ? globalSettings.disableRange : false;
  9272. case 'disableFontFace':
  9273. return globalSettings ? globalSettings.disableFontFace : false;
  9274. case 'disableCreateObjectURL':
  9275. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  9276. case 'disableWebGL':
  9277. return globalSettings ? globalSettings.disableWebGL : true;
  9278. case 'cMapUrl':
  9279. return globalSettings ? globalSettings.cMapUrl : null;
  9280. case 'cMapPacked':
  9281. return globalSettings ? globalSettings.cMapPacked : false;
  9282. case 'postMessageTransfers':
  9283. return globalSettings ? globalSettings.postMessageTransfers : true;
  9284. case 'workerSrc':
  9285. return globalSettings ? globalSettings.workerSrc : null;
  9286. case 'disableWorker':
  9287. return globalSettings ? globalSettings.disableWorker : false;
  9288. case 'maxImageSize':
  9289. return globalSettings ? globalSettings.maxImageSize : -1;
  9290. case 'imageResourcesPath':
  9291. return globalSettings ? globalSettings.imageResourcesPath : '';
  9292. case 'isEvalSupported':
  9293. return globalSettings ? globalSettings.isEvalSupported : true;
  9294. case 'externalLinkTarget':
  9295. if (!globalSettings) {
  9296. return LinkTarget.NONE;
  9297. }
  9298. switch (globalSettings.externalLinkTarget) {
  9299. case LinkTarget.NONE:
  9300. case LinkTarget.SELF:
  9301. case LinkTarget.BLANK:
  9302. case LinkTarget.PARENT:
  9303. case LinkTarget.TOP:
  9304. return globalSettings.externalLinkTarget;
  9305. }
  9306. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  9307. globalSettings.externalLinkTarget = LinkTarget.NONE;
  9308. return LinkTarget.NONE;
  9309. case 'externalLinkRel':
  9310. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  9311. case 'enableStats':
  9312. return !!(globalSettings && globalSettings.enableStats);
  9313. default:
  9314. throw new Error('Unknown default setting: ' + id);
  9315. }
  9316. }
  9317. function isExternalLinkTargetSet() {
  9318. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  9319. switch (externalLinkTarget) {
  9320. case LinkTarget.NONE:
  9321. return false;
  9322. case LinkTarget.SELF:
  9323. case LinkTarget.BLANK:
  9324. case LinkTarget.PARENT:
  9325. case LinkTarget.TOP:
  9326. return true;
  9327. }
  9328. }
  9329. function isValidUrl(url, allowRelative) {
  9330. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  9331. var baseUrl = allowRelative ? 'http://example.com' : null;
  9332. return createValidAbsoluteUrl(url, baseUrl) !== null;
  9333. }
  9334. exports.CustomStyle = CustomStyle;
  9335. exports.addLinkAttributes = addLinkAttributes;
  9336. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  9337. exports.isValidUrl = isValidUrl;
  9338. exports.getFilenameFromUrl = getFilenameFromUrl;
  9339. exports.LinkTarget = LinkTarget;
  9340. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  9341. exports.getDefaultSetting = getDefaultSetting;
  9342. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  9343. exports.DOMCanvasFactory = DOMCanvasFactory;
  9344. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  9345. /***/ }),
  9346. /* 4 */
  9347. /***/ (function(module, exports, __w_pdfjs_require__) {
  9348. "use strict";
  9349. var sharedUtil = __w_pdfjs_require__(0);
  9350. var corePrimitives = __w_pdfjs_require__(1);
  9351. var coreFunction = __w_pdfjs_require__(7);
  9352. var error = sharedUtil.error;
  9353. var info = sharedUtil.info;
  9354. var isArray = sharedUtil.isArray;
  9355. var isString = sharedUtil.isString;
  9356. var shadow = sharedUtil.shadow;
  9357. var warn = sharedUtil.warn;
  9358. var isDict = corePrimitives.isDict;
  9359. var isName = corePrimitives.isName;
  9360. var isStream = corePrimitives.isStream;
  9361. var PDFFunction = coreFunction.PDFFunction;
  9362. var ColorSpace = function ColorSpaceClosure() {
  9363. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  9364. var COMPONENTS = 3;
  9365. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  9366. var xRatio = w1 / w2;
  9367. var yRatio = h1 / h2;
  9368. var i, j, py, newIndex = 0, oldIndex;
  9369. var xScaled = new Uint16Array(w2);
  9370. var w1Scanline = w1 * COMPONENTS;
  9371. for (i = 0; i < w2; i++) {
  9372. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  9373. }
  9374. for (i = 0; i < h2; i++) {
  9375. py = Math.floor(i * yRatio) * w1Scanline;
  9376. for (j = 0; j < w2; j++) {
  9377. oldIndex = py + xScaled[j];
  9378. dest[newIndex++] = src[oldIndex++];
  9379. dest[newIndex++] = src[oldIndex++];
  9380. dest[newIndex++] = src[oldIndex++];
  9381. newIndex += alpha01;
  9382. }
  9383. }
  9384. }
  9385. function ColorSpace() {
  9386. error('should not call ColorSpace constructor');
  9387. }
  9388. ColorSpace.prototype = {
  9389. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  9390. var rgb = new Uint8Array(3);
  9391. this.getRgbItem(src, srcOffset, rgb, 0);
  9392. return rgb;
  9393. },
  9394. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  9395. error('Should not call ColorSpace.getRgbItem');
  9396. },
  9397. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9398. error('Should not call ColorSpace.getRgbBuffer');
  9399. },
  9400. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  9401. error('Should not call ColorSpace.getOutputLength');
  9402. },
  9403. isPassthrough: function ColorSpace_isPassthrough(bits) {
  9404. return false;
  9405. },
  9406. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  9407. var count = originalWidth * originalHeight;
  9408. var rgbBuf = null;
  9409. var numComponentColors = 1 << bpc;
  9410. var needsResizing = originalHeight !== height || originalWidth !== width;
  9411. var i, ii;
  9412. if (this.isPassthrough(bpc)) {
  9413. rgbBuf = comps;
  9414. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  9415. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  9416. var key;
  9417. for (i = 0; i < numComponentColors; i++) {
  9418. allColors[i] = i;
  9419. }
  9420. var colorMap = new Uint8Array(numComponentColors * 3);
  9421. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  9422. var destPos, rgbPos;
  9423. if (!needsResizing) {
  9424. destPos = 0;
  9425. for (i = 0; i < count; ++i) {
  9426. key = comps[i] * 3;
  9427. dest[destPos++] = colorMap[key];
  9428. dest[destPos++] = colorMap[key + 1];
  9429. dest[destPos++] = colorMap[key + 2];
  9430. destPos += alpha01;
  9431. }
  9432. } else {
  9433. rgbBuf = new Uint8Array(count * 3);
  9434. rgbPos = 0;
  9435. for (i = 0; i < count; ++i) {
  9436. key = comps[i] * 3;
  9437. rgbBuf[rgbPos++] = colorMap[key];
  9438. rgbBuf[rgbPos++] = colorMap[key + 1];
  9439. rgbBuf[rgbPos++] = colorMap[key + 2];
  9440. }
  9441. }
  9442. } else {
  9443. if (!needsResizing) {
  9444. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  9445. } else {
  9446. rgbBuf = new Uint8Array(count * 3);
  9447. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  9448. }
  9449. }
  9450. if (rgbBuf) {
  9451. if (needsResizing) {
  9452. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  9453. } else {
  9454. rgbPos = 0;
  9455. destPos = 0;
  9456. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  9457. dest[destPos++] = rgbBuf[rgbPos++];
  9458. dest[destPos++] = rgbBuf[rgbPos++];
  9459. dest[destPos++] = rgbBuf[rgbPos++];
  9460. destPos += alpha01;
  9461. }
  9462. }
  9463. }
  9464. },
  9465. usesZeroToOneRange: true
  9466. };
  9467. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  9468. var IR = ColorSpace.parseToIR(cs, xref, res);
  9469. if (IR instanceof AlternateCS) {
  9470. return IR;
  9471. }
  9472. return ColorSpace.fromIR(IR);
  9473. };
  9474. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  9475. var name = isArray(IR) ? IR[0] : IR;
  9476. var whitePoint, blackPoint, gamma;
  9477. switch (name) {
  9478. case 'DeviceGrayCS':
  9479. return this.singletons.gray;
  9480. case 'DeviceRgbCS':
  9481. return this.singletons.rgb;
  9482. case 'DeviceCmykCS':
  9483. return this.singletons.cmyk;
  9484. case 'CalGrayCS':
  9485. whitePoint = IR[1];
  9486. blackPoint = IR[2];
  9487. gamma = IR[3];
  9488. return new CalGrayCS(whitePoint, blackPoint, gamma);
  9489. case 'CalRGBCS':
  9490. whitePoint = IR[1];
  9491. blackPoint = IR[2];
  9492. gamma = IR[3];
  9493. var matrix = IR[4];
  9494. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  9495. case 'PatternCS':
  9496. var basePatternCS = IR[1];
  9497. if (basePatternCS) {
  9498. basePatternCS = ColorSpace.fromIR(basePatternCS);
  9499. }
  9500. return new PatternCS(basePatternCS);
  9501. case 'IndexedCS':
  9502. var baseIndexedCS = IR[1];
  9503. var hiVal = IR[2];
  9504. var lookup = IR[3];
  9505. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  9506. case 'AlternateCS':
  9507. var numComps = IR[1];
  9508. var alt = IR[2];
  9509. var tintFnIR = IR[3];
  9510. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  9511. case 'LabCS':
  9512. whitePoint = IR[1];
  9513. blackPoint = IR[2];
  9514. var range = IR[3];
  9515. return new LabCS(whitePoint, blackPoint, range);
  9516. default:
  9517. error('Unknown name ' + name);
  9518. }
  9519. return null;
  9520. };
  9521. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  9522. if (isName(cs)) {
  9523. var colorSpaces = res.get('ColorSpace');
  9524. if (isDict(colorSpaces)) {
  9525. var refcs = colorSpaces.get(cs.name);
  9526. if (refcs) {
  9527. cs = refcs;
  9528. }
  9529. }
  9530. }
  9531. cs = xref.fetchIfRef(cs);
  9532. if (isName(cs)) {
  9533. switch (cs.name) {
  9534. case 'DeviceGray':
  9535. case 'G':
  9536. return 'DeviceGrayCS';
  9537. case 'DeviceRGB':
  9538. case 'RGB':
  9539. return 'DeviceRgbCS';
  9540. case 'DeviceCMYK':
  9541. case 'CMYK':
  9542. return 'DeviceCmykCS';
  9543. case 'Pattern':
  9544. return [
  9545. 'PatternCS',
  9546. null
  9547. ];
  9548. default:
  9549. error('unrecognized colorspace ' + cs.name);
  9550. }
  9551. } else if (isArray(cs)) {
  9552. var mode = xref.fetchIfRef(cs[0]).name;
  9553. var numComps, params, alt, whitePoint, blackPoint, gamma;
  9554. switch (mode) {
  9555. case 'DeviceGray':
  9556. case 'G':
  9557. return 'DeviceGrayCS';
  9558. case 'DeviceRGB':
  9559. case 'RGB':
  9560. return 'DeviceRgbCS';
  9561. case 'DeviceCMYK':
  9562. case 'CMYK':
  9563. return 'DeviceCmykCS';
  9564. case 'CalGray':
  9565. params = xref.fetchIfRef(cs[1]);
  9566. whitePoint = params.getArray('WhitePoint');
  9567. blackPoint = params.getArray('BlackPoint');
  9568. gamma = params.get('Gamma');
  9569. return [
  9570. 'CalGrayCS',
  9571. whitePoint,
  9572. blackPoint,
  9573. gamma
  9574. ];
  9575. case 'CalRGB':
  9576. params = xref.fetchIfRef(cs[1]);
  9577. whitePoint = params.getArray('WhitePoint');
  9578. blackPoint = params.getArray('BlackPoint');
  9579. gamma = params.getArray('Gamma');
  9580. var matrix = params.getArray('Matrix');
  9581. return [
  9582. 'CalRGBCS',
  9583. whitePoint,
  9584. blackPoint,
  9585. gamma,
  9586. matrix
  9587. ];
  9588. case 'ICCBased':
  9589. var stream = xref.fetchIfRef(cs[1]);
  9590. var dict = stream.dict;
  9591. numComps = dict.get('N');
  9592. alt = dict.get('Alternate');
  9593. if (alt) {
  9594. var altIR = ColorSpace.parseToIR(alt, xref, res);
  9595. var altCS = ColorSpace.fromIR(altIR);
  9596. if (altCS.numComps === numComps) {
  9597. return altIR;
  9598. }
  9599. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  9600. }
  9601. if (numComps === 1) {
  9602. return 'DeviceGrayCS';
  9603. } else if (numComps === 3) {
  9604. return 'DeviceRgbCS';
  9605. } else if (numComps === 4) {
  9606. return 'DeviceCmykCS';
  9607. }
  9608. break;
  9609. case 'Pattern':
  9610. var basePatternCS = cs[1] || null;
  9611. if (basePatternCS) {
  9612. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  9613. }
  9614. return [
  9615. 'PatternCS',
  9616. basePatternCS
  9617. ];
  9618. case 'Indexed':
  9619. case 'I':
  9620. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  9621. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  9622. var lookup = xref.fetchIfRef(cs[3]);
  9623. if (isStream(lookup)) {
  9624. lookup = lookup.getBytes();
  9625. }
  9626. return [
  9627. 'IndexedCS',
  9628. baseIndexedCS,
  9629. hiVal,
  9630. lookup
  9631. ];
  9632. case 'Separation':
  9633. case 'DeviceN':
  9634. var name = xref.fetchIfRef(cs[1]);
  9635. numComps = isArray(name) ? name.length : 1;
  9636. alt = ColorSpace.parseToIR(cs[2], xref, res);
  9637. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  9638. return [
  9639. 'AlternateCS',
  9640. numComps,
  9641. alt,
  9642. tintFnIR
  9643. ];
  9644. case 'Lab':
  9645. params = xref.fetchIfRef(cs[1]);
  9646. whitePoint = params.getArray('WhitePoint');
  9647. blackPoint = params.getArray('BlackPoint');
  9648. var range = params.getArray('Range');
  9649. return [
  9650. 'LabCS',
  9651. whitePoint,
  9652. blackPoint,
  9653. range
  9654. ];
  9655. default:
  9656. error('unimplemented color space object "' + mode + '"');
  9657. }
  9658. } else {
  9659. error('unrecognized color space object: "' + cs + '"');
  9660. }
  9661. return null;
  9662. };
  9663. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  9664. if (!isArray(decode)) {
  9665. return true;
  9666. }
  9667. if (n * 2 !== decode.length) {
  9668. warn('The decode map is not the correct length');
  9669. return true;
  9670. }
  9671. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  9672. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  9673. return false;
  9674. }
  9675. }
  9676. return true;
  9677. };
  9678. ColorSpace.singletons = {
  9679. get gray() {
  9680. return shadow(this, 'gray', new DeviceGrayCS());
  9681. },
  9682. get rgb() {
  9683. return shadow(this, 'rgb', new DeviceRgbCS());
  9684. },
  9685. get cmyk() {
  9686. return shadow(this, 'cmyk', new DeviceCmykCS());
  9687. }
  9688. };
  9689. return ColorSpace;
  9690. }();
  9691. var AlternateCS = function AlternateCSClosure() {
  9692. function AlternateCS(numComps, base, tintFn) {
  9693. this.name = 'Alternate';
  9694. this.numComps = numComps;
  9695. this.defaultColor = new Float32Array(numComps);
  9696. for (var i = 0; i < numComps; ++i) {
  9697. this.defaultColor[i] = 1;
  9698. }
  9699. this.base = base;
  9700. this.tintFn = tintFn;
  9701. this.tmpBuf = new Float32Array(base.numComps);
  9702. }
  9703. AlternateCS.prototype = {
  9704. getRgb: ColorSpace.prototype.getRgb,
  9705. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9706. var tmpBuf = this.tmpBuf;
  9707. this.tintFn(src, srcOffset, tmpBuf, 0);
  9708. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  9709. },
  9710. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9711. var tintFn = this.tintFn;
  9712. var base = this.base;
  9713. var scale = 1 / ((1 << bits) - 1);
  9714. var baseNumComps = base.numComps;
  9715. var usesZeroToOneRange = base.usesZeroToOneRange;
  9716. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  9717. var pos = isPassthrough ? destOffset : 0;
  9718. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  9719. var numComps = this.numComps;
  9720. var scaled = new Float32Array(numComps);
  9721. var tinted = new Float32Array(baseNumComps);
  9722. var i, j;
  9723. for (i = 0; i < count; i++) {
  9724. for (j = 0; j < numComps; j++) {
  9725. scaled[j] = src[srcOffset++] * scale;
  9726. }
  9727. tintFn(scaled, 0, tinted, 0);
  9728. if (usesZeroToOneRange) {
  9729. for (j = 0; j < baseNumComps; j++) {
  9730. baseBuf[pos++] = tinted[j] * 255;
  9731. }
  9732. } else {
  9733. base.getRgbItem(tinted, 0, baseBuf, pos);
  9734. pos += baseNumComps;
  9735. }
  9736. }
  9737. if (!isPassthrough) {
  9738. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  9739. }
  9740. },
  9741. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  9742. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  9743. },
  9744. isPassthrough: ColorSpace.prototype.isPassthrough,
  9745. fillRgb: ColorSpace.prototype.fillRgb,
  9746. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  9747. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9748. },
  9749. usesZeroToOneRange: true
  9750. };
  9751. return AlternateCS;
  9752. }();
  9753. var PatternCS = function PatternCSClosure() {
  9754. function PatternCS(baseCS) {
  9755. this.name = 'Pattern';
  9756. this.base = baseCS;
  9757. }
  9758. PatternCS.prototype = {};
  9759. return PatternCS;
  9760. }();
  9761. var IndexedCS = function IndexedCSClosure() {
  9762. function IndexedCS(base, highVal, lookup) {
  9763. this.name = 'Indexed';
  9764. this.numComps = 1;
  9765. this.defaultColor = new Uint8Array(this.numComps);
  9766. this.base = base;
  9767. this.highVal = highVal;
  9768. var baseNumComps = base.numComps;
  9769. var length = baseNumComps * highVal;
  9770. if (isStream(lookup)) {
  9771. this.lookup = new Uint8Array(length);
  9772. var bytes = lookup.getBytes(length);
  9773. this.lookup.set(bytes);
  9774. } else if (isString(lookup)) {
  9775. this.lookup = new Uint8Array(length);
  9776. for (var i = 0; i < length; ++i) {
  9777. this.lookup[i] = lookup.charCodeAt(i);
  9778. }
  9779. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  9780. this.lookup = lookup;
  9781. } else {
  9782. error('Unrecognized lookup table: ' + lookup);
  9783. }
  9784. }
  9785. IndexedCS.prototype = {
  9786. getRgb: ColorSpace.prototype.getRgb,
  9787. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9788. var numComps = this.base.numComps;
  9789. var start = src[srcOffset] * numComps;
  9790. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  9791. },
  9792. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9793. var base = this.base;
  9794. var numComps = base.numComps;
  9795. var outputDelta = base.getOutputLength(numComps, alpha01);
  9796. var lookup = this.lookup;
  9797. for (var i = 0; i < count; ++i) {
  9798. var lookupPos = src[srcOffset++] * numComps;
  9799. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  9800. destOffset += outputDelta;
  9801. }
  9802. },
  9803. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  9804. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  9805. },
  9806. isPassthrough: ColorSpace.prototype.isPassthrough,
  9807. fillRgb: ColorSpace.prototype.fillRgb,
  9808. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  9809. return true;
  9810. },
  9811. usesZeroToOneRange: true
  9812. };
  9813. return IndexedCS;
  9814. }();
  9815. var DeviceGrayCS = function DeviceGrayCSClosure() {
  9816. function DeviceGrayCS() {
  9817. this.name = 'DeviceGray';
  9818. this.numComps = 1;
  9819. this.defaultColor = new Float32Array(this.numComps);
  9820. }
  9821. DeviceGrayCS.prototype = {
  9822. getRgb: ColorSpace.prototype.getRgb,
  9823. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9824. var c = src[srcOffset] * 255 | 0;
  9825. c = c < 0 ? 0 : c > 255 ? 255 : c;
  9826. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  9827. },
  9828. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9829. var scale = 255 / ((1 << bits) - 1);
  9830. var j = srcOffset, q = destOffset;
  9831. for (var i = 0; i < count; ++i) {
  9832. var c = scale * src[j++] | 0;
  9833. dest[q++] = c;
  9834. dest[q++] = c;
  9835. dest[q++] = c;
  9836. q += alpha01;
  9837. }
  9838. },
  9839. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  9840. return inputLength * (3 + alpha01);
  9841. },
  9842. isPassthrough: ColorSpace.prototype.isPassthrough,
  9843. fillRgb: ColorSpace.prototype.fillRgb,
  9844. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  9845. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9846. },
  9847. usesZeroToOneRange: true
  9848. };
  9849. return DeviceGrayCS;
  9850. }();
  9851. var DeviceRgbCS = function DeviceRgbCSClosure() {
  9852. function DeviceRgbCS() {
  9853. this.name = 'DeviceRGB';
  9854. this.numComps = 3;
  9855. this.defaultColor = new Float32Array(this.numComps);
  9856. }
  9857. DeviceRgbCS.prototype = {
  9858. getRgb: ColorSpace.prototype.getRgb,
  9859. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9860. var r = src[srcOffset] * 255 | 0;
  9861. var g = src[srcOffset + 1] * 255 | 0;
  9862. var b = src[srcOffset + 2] * 255 | 0;
  9863. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  9864. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  9865. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  9866. },
  9867. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9868. if (bits === 8 && alpha01 === 0) {
  9869. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  9870. return;
  9871. }
  9872. var scale = 255 / ((1 << bits) - 1);
  9873. var j = srcOffset, q = destOffset;
  9874. for (var i = 0; i < count; ++i) {
  9875. dest[q++] = scale * src[j++] | 0;
  9876. dest[q++] = scale * src[j++] | 0;
  9877. dest[q++] = scale * src[j++] | 0;
  9878. q += alpha01;
  9879. }
  9880. },
  9881. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  9882. return inputLength * (3 + alpha01) / 3 | 0;
  9883. },
  9884. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  9885. return bits === 8;
  9886. },
  9887. fillRgb: ColorSpace.prototype.fillRgb,
  9888. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  9889. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9890. },
  9891. usesZeroToOneRange: true
  9892. };
  9893. return DeviceRgbCS;
  9894. }();
  9895. var DeviceCmykCS = function DeviceCmykCSClosure() {
  9896. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  9897. var c = src[srcOffset + 0] * srcScale;
  9898. var m = src[srcOffset + 1] * srcScale;
  9899. var y = src[srcOffset + 2] * srcScale;
  9900. var k = src[srcOffset + 3] * srcScale;
  9901. 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;
  9902. 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;
  9903. 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;
  9904. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  9905. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  9906. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  9907. }
  9908. function DeviceCmykCS() {
  9909. this.name = 'DeviceCMYK';
  9910. this.numComps = 4;
  9911. this.defaultColor = new Float32Array(this.numComps);
  9912. this.defaultColor[3] = 1;
  9913. }
  9914. DeviceCmykCS.prototype = {
  9915. getRgb: ColorSpace.prototype.getRgb,
  9916. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9917. convertToRgb(src, srcOffset, 1, dest, destOffset);
  9918. },
  9919. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9920. var scale = 1 / ((1 << bits) - 1);
  9921. for (var i = 0; i < count; i++) {
  9922. convertToRgb(src, srcOffset, scale, dest, destOffset);
  9923. srcOffset += 4;
  9924. destOffset += 3 + alpha01;
  9925. }
  9926. },
  9927. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  9928. return inputLength / 4 * (3 + alpha01) | 0;
  9929. },
  9930. isPassthrough: ColorSpace.prototype.isPassthrough,
  9931. fillRgb: ColorSpace.prototype.fillRgb,
  9932. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  9933. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9934. },
  9935. usesZeroToOneRange: true
  9936. };
  9937. return DeviceCmykCS;
  9938. }();
  9939. var CalGrayCS = function CalGrayCSClosure() {
  9940. function CalGrayCS(whitePoint, blackPoint, gamma) {
  9941. this.name = 'CalGray';
  9942. this.numComps = 1;
  9943. this.defaultColor = new Float32Array(this.numComps);
  9944. if (!whitePoint) {
  9945. error('WhitePoint missing - required for color space CalGray');
  9946. }
  9947. blackPoint = blackPoint || [
  9948. 0,
  9949. 0,
  9950. 0
  9951. ];
  9952. gamma = gamma || 1;
  9953. this.XW = whitePoint[0];
  9954. this.YW = whitePoint[1];
  9955. this.ZW = whitePoint[2];
  9956. this.XB = blackPoint[0];
  9957. this.YB = blackPoint[1];
  9958. this.ZB = blackPoint[2];
  9959. this.G = gamma;
  9960. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9961. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9962. }
  9963. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9964. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  9965. this.XB = this.YB = this.ZB = 0;
  9966. }
  9967. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  9968. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  9969. }
  9970. if (this.G < 1) {
  9971. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  9972. this.G = 1;
  9973. }
  9974. }
  9975. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9976. var A = src[srcOffset] * scale;
  9977. var AG = Math.pow(A, cs.G);
  9978. var L = cs.YW * AG;
  9979. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  9980. dest[destOffset] = val;
  9981. dest[destOffset + 1] = val;
  9982. dest[destOffset + 2] = val;
  9983. }
  9984. CalGrayCS.prototype = {
  9985. getRgb: ColorSpace.prototype.getRgb,
  9986. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9987. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9988. },
  9989. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9990. var scale = 1 / ((1 << bits) - 1);
  9991. for (var i = 0; i < count; ++i) {
  9992. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9993. srcOffset += 1;
  9994. destOffset += 3 + alpha01;
  9995. }
  9996. },
  9997. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  9998. return inputLength * (3 + alpha01);
  9999. },
  10000. isPassthrough: ColorSpace.prototype.isPassthrough,
  10001. fillRgb: ColorSpace.prototype.fillRgb,
  10002. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  10003. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  10004. },
  10005. usesZeroToOneRange: true
  10006. };
  10007. return CalGrayCS;
  10008. }();
  10009. var CalRGBCS = function CalRGBCSClosure() {
  10010. var BRADFORD_SCALE_MATRIX = new Float32Array([
  10011. 0.8951,
  10012. 0.2664,
  10013. -0.1614,
  10014. -0.7502,
  10015. 1.7135,
  10016. 0.0367,
  10017. 0.0389,
  10018. -0.0685,
  10019. 1.0296
  10020. ]);
  10021. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  10022. 0.9869929,
  10023. -0.1470543,
  10024. 0.1599627,
  10025. 0.4323053,
  10026. 0.5183603,
  10027. 0.0492912,
  10028. -0.0085287,
  10029. 0.0400428,
  10030. 0.9684867
  10031. ]);
  10032. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  10033. 3.2404542,
  10034. -1.5371385,
  10035. -0.4985314,
  10036. -0.9692660,
  10037. 1.8760108,
  10038. 0.0415560,
  10039. 0.0556434,
  10040. -0.2040259,
  10041. 1.0572252
  10042. ]);
  10043. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  10044. 1,
  10045. 1,
  10046. 1
  10047. ]);
  10048. var tempNormalizeMatrix = new Float32Array(3);
  10049. var tempConvertMatrix1 = new Float32Array(3);
  10050. var tempConvertMatrix2 = new Float32Array(3);
  10051. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  10052. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  10053. this.name = 'CalRGB';
  10054. this.numComps = 3;
  10055. this.defaultColor = new Float32Array(this.numComps);
  10056. if (!whitePoint) {
  10057. error('WhitePoint missing - required for color space CalRGB');
  10058. }
  10059. blackPoint = blackPoint || new Float32Array(3);
  10060. gamma = gamma || new Float32Array([
  10061. 1,
  10062. 1,
  10063. 1
  10064. ]);
  10065. matrix = matrix || new Float32Array([
  10066. 1,
  10067. 0,
  10068. 0,
  10069. 0,
  10070. 1,
  10071. 0,
  10072. 0,
  10073. 0,
  10074. 1
  10075. ]);
  10076. var XW = whitePoint[0];
  10077. var YW = whitePoint[1];
  10078. var ZW = whitePoint[2];
  10079. this.whitePoint = whitePoint;
  10080. var XB = blackPoint[0];
  10081. var YB = blackPoint[1];
  10082. var ZB = blackPoint[2];
  10083. this.blackPoint = blackPoint;
  10084. this.GR = gamma[0];
  10085. this.GG = gamma[1];
  10086. this.GB = gamma[2];
  10087. this.MXA = matrix[0];
  10088. this.MYA = matrix[1];
  10089. this.MZA = matrix[2];
  10090. this.MXB = matrix[3];
  10091. this.MYB = matrix[4];
  10092. this.MZB = matrix[5];
  10093. this.MXC = matrix[6];
  10094. this.MYC = matrix[7];
  10095. this.MZC = matrix[8];
  10096. if (XW < 0 || ZW < 0 || YW !== 1) {
  10097. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  10098. }
  10099. if (XB < 0 || YB < 0 || ZB < 0) {
  10100. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  10101. this.blackPoint = new Float32Array(3);
  10102. }
  10103. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  10104. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  10105. this.GR = this.GG = this.GB = 1;
  10106. }
  10107. 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) {
  10108. 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');
  10109. this.MXA = this.MYB = this.MZC = 1;
  10110. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  10111. }
  10112. }
  10113. function matrixProduct(a, b, result) {
  10114. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  10115. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  10116. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  10117. }
  10118. function convertToFlat(sourceWhitePoint, LMS, result) {
  10119. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  10120. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  10121. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  10122. }
  10123. function convertToD65(sourceWhitePoint, LMS, result) {
  10124. var D65X = 0.95047;
  10125. var D65Y = 1;
  10126. var D65Z = 1.08883;
  10127. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  10128. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  10129. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  10130. }
  10131. function sRGBTransferFunction(color) {
  10132. if (color <= 0.0031308) {
  10133. return adjustToRange(0, 1, 12.92 * color);
  10134. }
  10135. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  10136. }
  10137. function adjustToRange(min, max, value) {
  10138. return Math.max(min, Math.min(max, value));
  10139. }
  10140. function decodeL(L) {
  10141. if (L < 0) {
  10142. return -decodeL(-L);
  10143. }
  10144. if (L > 8.0) {
  10145. return Math.pow((L + 16) / 116, 3);
  10146. }
  10147. return L * DECODE_L_CONSTANT;
  10148. }
  10149. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  10150. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  10151. result[0] = XYZ_Flat[0];
  10152. result[1] = XYZ_Flat[1];
  10153. result[2] = XYZ_Flat[2];
  10154. return;
  10155. }
  10156. var zeroDecodeL = decodeL(0);
  10157. var X_DST = zeroDecodeL;
  10158. var X_SRC = decodeL(sourceBlackPoint[0]);
  10159. var Y_DST = zeroDecodeL;
  10160. var Y_SRC = decodeL(sourceBlackPoint[1]);
  10161. var Z_DST = zeroDecodeL;
  10162. var Z_SRC = decodeL(sourceBlackPoint[2]);
  10163. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  10164. var X_Offset = 1 - X_Scale;
  10165. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  10166. var Y_Offset = 1 - Y_Scale;
  10167. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  10168. var Z_Offset = 1 - Z_Scale;
  10169. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  10170. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  10171. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  10172. }
  10173. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  10174. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  10175. result[0] = XYZ_In[0];
  10176. result[1] = XYZ_In[1];
  10177. result[2] = XYZ_In[2];
  10178. return;
  10179. }
  10180. var LMS = result;
  10181. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  10182. var LMS_Flat = tempNormalizeMatrix;
  10183. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  10184. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  10185. }
  10186. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  10187. var LMS = result;
  10188. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  10189. var LMS_D65 = tempNormalizeMatrix;
  10190. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  10191. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  10192. }
  10193. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  10194. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  10195. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  10196. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  10197. var AGR = Math.pow(A, cs.GR);
  10198. var BGG = Math.pow(B, cs.GG);
  10199. var CGB = Math.pow(C, cs.GB);
  10200. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  10201. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  10202. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  10203. var XYZ = tempConvertMatrix1;
  10204. XYZ[0] = X;
  10205. XYZ[1] = Y;
  10206. XYZ[2] = Z;
  10207. var XYZ_Flat = tempConvertMatrix2;
  10208. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  10209. var XYZ_Black = tempConvertMatrix1;
  10210. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  10211. var XYZ_D65 = tempConvertMatrix2;
  10212. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  10213. var SRGB = tempConvertMatrix1;
  10214. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  10215. var sR = sRGBTransferFunction(SRGB[0]);
  10216. var sG = sRGBTransferFunction(SRGB[1]);
  10217. var sB = sRGBTransferFunction(SRGB[2]);
  10218. dest[destOffset] = Math.round(sR * 255);
  10219. dest[destOffset + 1] = Math.round(sG * 255);
  10220. dest[destOffset + 2] = Math.round(sB * 255);
  10221. }
  10222. CalRGBCS.prototype = {
  10223. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  10224. var rgb = new Uint8Array(3);
  10225. this.getRgbItem(src, srcOffset, rgb, 0);
  10226. return rgb;
  10227. },
  10228. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  10229. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  10230. },
  10231. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  10232. var scale = 1 / ((1 << bits) - 1);
  10233. for (var i = 0; i < count; ++i) {
  10234. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  10235. srcOffset += 3;
  10236. destOffset += 3 + alpha01;
  10237. }
  10238. },
  10239. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  10240. return inputLength * (3 + alpha01) / 3 | 0;
  10241. },
  10242. isPassthrough: ColorSpace.prototype.isPassthrough,
  10243. fillRgb: ColorSpace.prototype.fillRgb,
  10244. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  10245. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  10246. },
  10247. usesZeroToOneRange: true
  10248. };
  10249. return CalRGBCS;
  10250. }();
  10251. var LabCS = function LabCSClosure() {
  10252. function LabCS(whitePoint, blackPoint, range) {
  10253. this.name = 'Lab';
  10254. this.numComps = 3;
  10255. this.defaultColor = new Float32Array(this.numComps);
  10256. if (!whitePoint) {
  10257. error('WhitePoint missing - required for color space Lab');
  10258. }
  10259. blackPoint = blackPoint || [
  10260. 0,
  10261. 0,
  10262. 0
  10263. ];
  10264. range = range || [
  10265. -100,
  10266. 100,
  10267. -100,
  10268. 100
  10269. ];
  10270. this.XW = whitePoint[0];
  10271. this.YW = whitePoint[1];
  10272. this.ZW = whitePoint[2];
  10273. this.amin = range[0];
  10274. this.amax = range[1];
  10275. this.bmin = range[2];
  10276. this.bmax = range[3];
  10277. this.XB = blackPoint[0];
  10278. this.YB = blackPoint[1];
  10279. this.ZB = blackPoint[2];
  10280. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  10281. error('Invalid WhitePoint components, no fallback available');
  10282. }
  10283. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  10284. info('Invalid BlackPoint, falling back to default');
  10285. this.XB = this.YB = this.ZB = 0;
  10286. }
  10287. if (this.amin > this.amax || this.bmin > this.bmax) {
  10288. info('Invalid Range, falling back to defaults');
  10289. this.amin = -100;
  10290. this.amax = 100;
  10291. this.bmin = -100;
  10292. this.bmax = 100;
  10293. }
  10294. }
  10295. function fn_g(x) {
  10296. var result;
  10297. if (x >= 6 / 29) {
  10298. result = x * x * x;
  10299. } else {
  10300. result = 108 / 841 * (x - 4 / 29);
  10301. }
  10302. return result;
  10303. }
  10304. function decode(value, high1, low2, high2) {
  10305. return low2 + value * (high2 - low2) / high1;
  10306. }
  10307. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  10308. var Ls = src[srcOffset];
  10309. var as = src[srcOffset + 1];
  10310. var bs = src[srcOffset + 2];
  10311. if (maxVal !== false) {
  10312. Ls = decode(Ls, maxVal, 0, 100);
  10313. as = decode(as, maxVal, cs.amin, cs.amax);
  10314. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  10315. }
  10316. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  10317. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  10318. var M = (Ls + 16) / 116;
  10319. var L = M + as / 500;
  10320. var N = M - bs / 200;
  10321. var X = cs.XW * fn_g(L);
  10322. var Y = cs.YW * fn_g(M);
  10323. var Z = cs.ZW * fn_g(N);
  10324. var r, g, b;
  10325. if (cs.ZW < 1) {
  10326. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  10327. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  10328. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  10329. } else {
  10330. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  10331. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  10332. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  10333. }
  10334. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  10335. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  10336. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  10337. }
  10338. LabCS.prototype = {
  10339. getRgb: ColorSpace.prototype.getRgb,
  10340. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  10341. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  10342. },
  10343. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  10344. var maxVal = (1 << bits) - 1;
  10345. for (var i = 0; i < count; i++) {
  10346. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  10347. srcOffset += 3;
  10348. destOffset += 3 + alpha01;
  10349. }
  10350. },
  10351. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  10352. return inputLength * (3 + alpha01) / 3 | 0;
  10353. },
  10354. isPassthrough: ColorSpace.prototype.isPassthrough,
  10355. fillRgb: ColorSpace.prototype.fillRgb,
  10356. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  10357. return true;
  10358. },
  10359. usesZeroToOneRange: false
  10360. };
  10361. return LabCS;
  10362. }();
  10363. exports.ColorSpace = ColorSpace;
  10364. /***/ }),
  10365. /* 5 */
  10366. /***/ (function(module, exports, __w_pdfjs_require__) {
  10367. "use strict";
  10368. var ExpertEncoding = [
  10369. '',
  10370. '',
  10371. '',
  10372. '',
  10373. '',
  10374. '',
  10375. '',
  10376. '',
  10377. '',
  10378. '',
  10379. '',
  10380. '',
  10381. '',
  10382. '',
  10383. '',
  10384. '',
  10385. '',
  10386. '',
  10387. '',
  10388. '',
  10389. '',
  10390. '',
  10391. '',
  10392. '',
  10393. '',
  10394. '',
  10395. '',
  10396. '',
  10397. '',
  10398. '',
  10399. '',
  10400. '',
  10401. 'space',
  10402. 'exclamsmall',
  10403. 'Hungarumlautsmall',
  10404. '',
  10405. 'dollaroldstyle',
  10406. 'dollarsuperior',
  10407. 'ampersandsmall',
  10408. 'Acutesmall',
  10409. 'parenleftsuperior',
  10410. 'parenrightsuperior',
  10411. 'twodotenleader',
  10412. 'onedotenleader',
  10413. 'comma',
  10414. 'hyphen',
  10415. 'period',
  10416. 'fraction',
  10417. 'zerooldstyle',
  10418. 'oneoldstyle',
  10419. 'twooldstyle',
  10420. 'threeoldstyle',
  10421. 'fouroldstyle',
  10422. 'fiveoldstyle',
  10423. 'sixoldstyle',
  10424. 'sevenoldstyle',
  10425. 'eightoldstyle',
  10426. 'nineoldstyle',
  10427. 'colon',
  10428. 'semicolon',
  10429. 'commasuperior',
  10430. 'threequartersemdash',
  10431. 'periodsuperior',
  10432. 'questionsmall',
  10433. '',
  10434. 'asuperior',
  10435. 'bsuperior',
  10436. 'centsuperior',
  10437. 'dsuperior',
  10438. 'esuperior',
  10439. '',
  10440. '',
  10441. 'isuperior',
  10442. '',
  10443. '',
  10444. 'lsuperior',
  10445. 'msuperior',
  10446. 'nsuperior',
  10447. 'osuperior',
  10448. '',
  10449. '',
  10450. 'rsuperior',
  10451. 'ssuperior',
  10452. 'tsuperior',
  10453. '',
  10454. 'ff',
  10455. 'fi',
  10456. 'fl',
  10457. 'ffi',
  10458. 'ffl',
  10459. 'parenleftinferior',
  10460. '',
  10461. 'parenrightinferior',
  10462. 'Circumflexsmall',
  10463. 'hyphensuperior',
  10464. 'Gravesmall',
  10465. 'Asmall',
  10466. 'Bsmall',
  10467. 'Csmall',
  10468. 'Dsmall',
  10469. 'Esmall',
  10470. 'Fsmall',
  10471. 'Gsmall',
  10472. 'Hsmall',
  10473. 'Ismall',
  10474. 'Jsmall',
  10475. 'Ksmall',
  10476. 'Lsmall',
  10477. 'Msmall',
  10478. 'Nsmall',
  10479. 'Osmall',
  10480. 'Psmall',
  10481. 'Qsmall',
  10482. 'Rsmall',
  10483. 'Ssmall',
  10484. 'Tsmall',
  10485. 'Usmall',
  10486. 'Vsmall',
  10487. 'Wsmall',
  10488. 'Xsmall',
  10489. 'Ysmall',
  10490. 'Zsmall',
  10491. 'colonmonetary',
  10492. 'onefitted',
  10493. 'rupiah',
  10494. 'Tildesmall',
  10495. '',
  10496. '',
  10497. '',
  10498. '',
  10499. '',
  10500. '',
  10501. '',
  10502. '',
  10503. '',
  10504. '',
  10505. '',
  10506. '',
  10507. '',
  10508. '',
  10509. '',
  10510. '',
  10511. '',
  10512. '',
  10513. '',
  10514. '',
  10515. '',
  10516. '',
  10517. '',
  10518. '',
  10519. '',
  10520. '',
  10521. '',
  10522. '',
  10523. '',
  10524. '',
  10525. '',
  10526. '',
  10527. '',
  10528. '',
  10529. 'exclamdownsmall',
  10530. 'centoldstyle',
  10531. 'Lslashsmall',
  10532. '',
  10533. '',
  10534. 'Scaronsmall',
  10535. 'Zcaronsmall',
  10536. 'Dieresissmall',
  10537. 'Brevesmall',
  10538. 'Caronsmall',
  10539. '',
  10540. 'Dotaccentsmall',
  10541. '',
  10542. '',
  10543. 'Macronsmall',
  10544. '',
  10545. '',
  10546. 'figuredash',
  10547. 'hypheninferior',
  10548. '',
  10549. '',
  10550. 'Ogoneksmall',
  10551. 'Ringsmall',
  10552. 'Cedillasmall',
  10553. '',
  10554. '',
  10555. '',
  10556. 'onequarter',
  10557. 'onehalf',
  10558. 'threequarters',
  10559. 'questiondownsmall',
  10560. 'oneeighth',
  10561. 'threeeighths',
  10562. 'fiveeighths',
  10563. 'seveneighths',
  10564. 'onethird',
  10565. 'twothirds',
  10566. '',
  10567. '',
  10568. 'zerosuperior',
  10569. 'onesuperior',
  10570. 'twosuperior',
  10571. 'threesuperior',
  10572. 'foursuperior',
  10573. 'fivesuperior',
  10574. 'sixsuperior',
  10575. 'sevensuperior',
  10576. 'eightsuperior',
  10577. 'ninesuperior',
  10578. 'zeroinferior',
  10579. 'oneinferior',
  10580. 'twoinferior',
  10581. 'threeinferior',
  10582. 'fourinferior',
  10583. 'fiveinferior',
  10584. 'sixinferior',
  10585. 'seveninferior',
  10586. 'eightinferior',
  10587. 'nineinferior',
  10588. 'centinferior',
  10589. 'dollarinferior',
  10590. 'periodinferior',
  10591. 'commainferior',
  10592. 'Agravesmall',
  10593. 'Aacutesmall',
  10594. 'Acircumflexsmall',
  10595. 'Atildesmall',
  10596. 'Adieresissmall',
  10597. 'Aringsmall',
  10598. 'AEsmall',
  10599. 'Ccedillasmall',
  10600. 'Egravesmall',
  10601. 'Eacutesmall',
  10602. 'Ecircumflexsmall',
  10603. 'Edieresissmall',
  10604. 'Igravesmall',
  10605. 'Iacutesmall',
  10606. 'Icircumflexsmall',
  10607. 'Idieresissmall',
  10608. 'Ethsmall',
  10609. 'Ntildesmall',
  10610. 'Ogravesmall',
  10611. 'Oacutesmall',
  10612. 'Ocircumflexsmall',
  10613. 'Otildesmall',
  10614. 'Odieresissmall',
  10615. 'OEsmall',
  10616. 'Oslashsmall',
  10617. 'Ugravesmall',
  10618. 'Uacutesmall',
  10619. 'Ucircumflexsmall',
  10620. 'Udieresissmall',
  10621. 'Yacutesmall',
  10622. 'Thornsmall',
  10623. 'Ydieresissmall'
  10624. ];
  10625. var MacExpertEncoding = [
  10626. '',
  10627. '',
  10628. '',
  10629. '',
  10630. '',
  10631. '',
  10632. '',
  10633. '',
  10634. '',
  10635. '',
  10636. '',
  10637. '',
  10638. '',
  10639. '',
  10640. '',
  10641. '',
  10642. '',
  10643. '',
  10644. '',
  10645. '',
  10646. '',
  10647. '',
  10648. '',
  10649. '',
  10650. '',
  10651. '',
  10652. '',
  10653. '',
  10654. '',
  10655. '',
  10656. '',
  10657. '',
  10658. 'space',
  10659. 'exclamsmall',
  10660. 'Hungarumlautsmall',
  10661. 'centoldstyle',
  10662. 'dollaroldstyle',
  10663. 'dollarsuperior',
  10664. 'ampersandsmall',
  10665. 'Acutesmall',
  10666. 'parenleftsuperior',
  10667. 'parenrightsuperior',
  10668. 'twodotenleader',
  10669. 'onedotenleader',
  10670. 'comma',
  10671. 'hyphen',
  10672. 'period',
  10673. 'fraction',
  10674. 'zerooldstyle',
  10675. 'oneoldstyle',
  10676. 'twooldstyle',
  10677. 'threeoldstyle',
  10678. 'fouroldstyle',
  10679. 'fiveoldstyle',
  10680. 'sixoldstyle',
  10681. 'sevenoldstyle',
  10682. 'eightoldstyle',
  10683. 'nineoldstyle',
  10684. 'colon',
  10685. 'semicolon',
  10686. '',
  10687. 'threequartersemdash',
  10688. '',
  10689. 'questionsmall',
  10690. '',
  10691. '',
  10692. '',
  10693. '',
  10694. 'Ethsmall',
  10695. '',
  10696. '',
  10697. 'onequarter',
  10698. 'onehalf',
  10699. 'threequarters',
  10700. 'oneeighth',
  10701. 'threeeighths',
  10702. 'fiveeighths',
  10703. 'seveneighths',
  10704. 'onethird',
  10705. 'twothirds',
  10706. '',
  10707. '',
  10708. '',
  10709. '',
  10710. '',
  10711. '',
  10712. 'ff',
  10713. 'fi',
  10714. 'fl',
  10715. 'ffi',
  10716. 'ffl',
  10717. 'parenleftinferior',
  10718. '',
  10719. 'parenrightinferior',
  10720. 'Circumflexsmall',
  10721. 'hypheninferior',
  10722. 'Gravesmall',
  10723. 'Asmall',
  10724. 'Bsmall',
  10725. 'Csmall',
  10726. 'Dsmall',
  10727. 'Esmall',
  10728. 'Fsmall',
  10729. 'Gsmall',
  10730. 'Hsmall',
  10731. 'Ismall',
  10732. 'Jsmall',
  10733. 'Ksmall',
  10734. 'Lsmall',
  10735. 'Msmall',
  10736. 'Nsmall',
  10737. 'Osmall',
  10738. 'Psmall',
  10739. 'Qsmall',
  10740. 'Rsmall',
  10741. 'Ssmall',
  10742. 'Tsmall',
  10743. 'Usmall',
  10744. 'Vsmall',
  10745. 'Wsmall',
  10746. 'Xsmall',
  10747. 'Ysmall',
  10748. 'Zsmall',
  10749. 'colonmonetary',
  10750. 'onefitted',
  10751. 'rupiah',
  10752. 'Tildesmall',
  10753. '',
  10754. '',
  10755. 'asuperior',
  10756. 'centsuperior',
  10757. '',
  10758. '',
  10759. '',
  10760. '',
  10761. 'Aacutesmall',
  10762. 'Agravesmall',
  10763. 'Acircumflexsmall',
  10764. 'Adieresissmall',
  10765. 'Atildesmall',
  10766. 'Aringsmall',
  10767. 'Ccedillasmall',
  10768. 'Eacutesmall',
  10769. 'Egravesmall',
  10770. 'Ecircumflexsmall',
  10771. 'Edieresissmall',
  10772. 'Iacutesmall',
  10773. 'Igravesmall',
  10774. 'Icircumflexsmall',
  10775. 'Idieresissmall',
  10776. 'Ntildesmall',
  10777. 'Oacutesmall',
  10778. 'Ogravesmall',
  10779. 'Ocircumflexsmall',
  10780. 'Odieresissmall',
  10781. 'Otildesmall',
  10782. 'Uacutesmall',
  10783. 'Ugravesmall',
  10784. 'Ucircumflexsmall',
  10785. 'Udieresissmall',
  10786. '',
  10787. 'eightsuperior',
  10788. 'fourinferior',
  10789. 'threeinferior',
  10790. 'sixinferior',
  10791. 'eightinferior',
  10792. 'seveninferior',
  10793. 'Scaronsmall',
  10794. '',
  10795. 'centinferior',
  10796. 'twoinferior',
  10797. '',
  10798. 'Dieresissmall',
  10799. '',
  10800. 'Caronsmall',
  10801. 'osuperior',
  10802. 'fiveinferior',
  10803. '',
  10804. 'commainferior',
  10805. 'periodinferior',
  10806. 'Yacutesmall',
  10807. '',
  10808. 'dollarinferior',
  10809. '',
  10810. 'Thornsmall',
  10811. '',
  10812. 'nineinferior',
  10813. 'zeroinferior',
  10814. 'Zcaronsmall',
  10815. 'AEsmall',
  10816. 'Oslashsmall',
  10817. 'questiondownsmall',
  10818. 'oneinferior',
  10819. 'Lslashsmall',
  10820. '',
  10821. '',
  10822. '',
  10823. '',
  10824. '',
  10825. '',
  10826. 'Cedillasmall',
  10827. '',
  10828. '',
  10829. '',
  10830. '',
  10831. '',
  10832. 'OEsmall',
  10833. 'figuredash',
  10834. 'hyphensuperior',
  10835. '',
  10836. '',
  10837. '',
  10838. '',
  10839. 'exclamdownsmall',
  10840. '',
  10841. 'Ydieresissmall',
  10842. '',
  10843. 'onesuperior',
  10844. 'twosuperior',
  10845. 'threesuperior',
  10846. 'foursuperior',
  10847. 'fivesuperior',
  10848. 'sixsuperior',
  10849. 'sevensuperior',
  10850. 'ninesuperior',
  10851. 'zerosuperior',
  10852. '',
  10853. 'esuperior',
  10854. 'rsuperior',
  10855. 'tsuperior',
  10856. '',
  10857. '',
  10858. 'isuperior',
  10859. 'ssuperior',
  10860. 'dsuperior',
  10861. '',
  10862. '',
  10863. '',
  10864. '',
  10865. '',
  10866. 'lsuperior',
  10867. 'Ogoneksmall',
  10868. 'Brevesmall',
  10869. 'Macronsmall',
  10870. 'bsuperior',
  10871. 'nsuperior',
  10872. 'msuperior',
  10873. 'commasuperior',
  10874. 'periodsuperior',
  10875. 'Dotaccentsmall',
  10876. 'Ringsmall'
  10877. ];
  10878. var MacRomanEncoding = [
  10879. '',
  10880. '',
  10881. '',
  10882. '',
  10883. '',
  10884. '',
  10885. '',
  10886. '',
  10887. '',
  10888. '',
  10889. '',
  10890. '',
  10891. '',
  10892. '',
  10893. '',
  10894. '',
  10895. '',
  10896. '',
  10897. '',
  10898. '',
  10899. '',
  10900. '',
  10901. '',
  10902. '',
  10903. '',
  10904. '',
  10905. '',
  10906. '',
  10907. '',
  10908. '',
  10909. '',
  10910. '',
  10911. 'space',
  10912. 'exclam',
  10913. 'quotedbl',
  10914. 'numbersign',
  10915. 'dollar',
  10916. 'percent',
  10917. 'ampersand',
  10918. 'quotesingle',
  10919. 'parenleft',
  10920. 'parenright',
  10921. 'asterisk',
  10922. 'plus',
  10923. 'comma',
  10924. 'hyphen',
  10925. 'period',
  10926. 'slash',
  10927. 'zero',
  10928. 'one',
  10929. 'two',
  10930. 'three',
  10931. 'four',
  10932. 'five',
  10933. 'six',
  10934. 'seven',
  10935. 'eight',
  10936. 'nine',
  10937. 'colon',
  10938. 'semicolon',
  10939. 'less',
  10940. 'equal',
  10941. 'greater',
  10942. 'question',
  10943. 'at',
  10944. 'A',
  10945. 'B',
  10946. 'C',
  10947. 'D',
  10948. 'E',
  10949. 'F',
  10950. 'G',
  10951. 'H',
  10952. 'I',
  10953. 'J',
  10954. 'K',
  10955. 'L',
  10956. 'M',
  10957. 'N',
  10958. 'O',
  10959. 'P',
  10960. 'Q',
  10961. 'R',
  10962. 'S',
  10963. 'T',
  10964. 'U',
  10965. 'V',
  10966. 'W',
  10967. 'X',
  10968. 'Y',
  10969. 'Z',
  10970. 'bracketleft',
  10971. 'backslash',
  10972. 'bracketright',
  10973. 'asciicircum',
  10974. 'underscore',
  10975. 'grave',
  10976. 'a',
  10977. 'b',
  10978. 'c',
  10979. 'd',
  10980. 'e',
  10981. 'f',
  10982. 'g',
  10983. 'h',
  10984. 'i',
  10985. 'j',
  10986. 'k',
  10987. 'l',
  10988. 'm',
  10989. 'n',
  10990. 'o',
  10991. 'p',
  10992. 'q',
  10993. 'r',
  10994. 's',
  10995. 't',
  10996. 'u',
  10997. 'v',
  10998. 'w',
  10999. 'x',
  11000. 'y',
  11001. 'z',
  11002. 'braceleft',
  11003. 'bar',
  11004. 'braceright',
  11005. 'asciitilde',
  11006. '',
  11007. 'Adieresis',
  11008. 'Aring',
  11009. 'Ccedilla',
  11010. 'Eacute',
  11011. 'Ntilde',
  11012. 'Odieresis',
  11013. 'Udieresis',
  11014. 'aacute',
  11015. 'agrave',
  11016. 'acircumflex',
  11017. 'adieresis',
  11018. 'atilde',
  11019. 'aring',
  11020. 'ccedilla',
  11021. 'eacute',
  11022. 'egrave',
  11023. 'ecircumflex',
  11024. 'edieresis',
  11025. 'iacute',
  11026. 'igrave',
  11027. 'icircumflex',
  11028. 'idieresis',
  11029. 'ntilde',
  11030. 'oacute',
  11031. 'ograve',
  11032. 'ocircumflex',
  11033. 'odieresis',
  11034. 'otilde',
  11035. 'uacute',
  11036. 'ugrave',
  11037. 'ucircumflex',
  11038. 'udieresis',
  11039. 'dagger',
  11040. 'degree',
  11041. 'cent',
  11042. 'sterling',
  11043. 'section',
  11044. 'bullet',
  11045. 'paragraph',
  11046. 'germandbls',
  11047. 'registered',
  11048. 'copyright',
  11049. 'trademark',
  11050. 'acute',
  11051. 'dieresis',
  11052. 'notequal',
  11053. 'AE',
  11054. 'Oslash',
  11055. 'infinity',
  11056. 'plusminus',
  11057. 'lessequal',
  11058. 'greaterequal',
  11059. 'yen',
  11060. 'mu',
  11061. 'partialdiff',
  11062. 'summation',
  11063. 'product',
  11064. 'pi',
  11065. 'integral',
  11066. 'ordfeminine',
  11067. 'ordmasculine',
  11068. 'Omega',
  11069. 'ae',
  11070. 'oslash',
  11071. 'questiondown',
  11072. 'exclamdown',
  11073. 'logicalnot',
  11074. 'radical',
  11075. 'florin',
  11076. 'approxequal',
  11077. 'Delta',
  11078. 'guillemotleft',
  11079. 'guillemotright',
  11080. 'ellipsis',
  11081. 'space',
  11082. 'Agrave',
  11083. 'Atilde',
  11084. 'Otilde',
  11085. 'OE',
  11086. 'oe',
  11087. 'endash',
  11088. 'emdash',
  11089. 'quotedblleft',
  11090. 'quotedblright',
  11091. 'quoteleft',
  11092. 'quoteright',
  11093. 'divide',
  11094. 'lozenge',
  11095. 'ydieresis',
  11096. 'Ydieresis',
  11097. 'fraction',
  11098. 'currency',
  11099. 'guilsinglleft',
  11100. 'guilsinglright',
  11101. 'fi',
  11102. 'fl',
  11103. 'daggerdbl',
  11104. 'periodcentered',
  11105. 'quotesinglbase',
  11106. 'quotedblbase',
  11107. 'perthousand',
  11108. 'Acircumflex',
  11109. 'Ecircumflex',
  11110. 'Aacute',
  11111. 'Edieresis',
  11112. 'Egrave',
  11113. 'Iacute',
  11114. 'Icircumflex',
  11115. 'Idieresis',
  11116. 'Igrave',
  11117. 'Oacute',
  11118. 'Ocircumflex',
  11119. 'apple',
  11120. 'Ograve',
  11121. 'Uacute',
  11122. 'Ucircumflex',
  11123. 'Ugrave',
  11124. 'dotlessi',
  11125. 'circumflex',
  11126. 'tilde',
  11127. 'macron',
  11128. 'breve',
  11129. 'dotaccent',
  11130. 'ring',
  11131. 'cedilla',
  11132. 'hungarumlaut',
  11133. 'ogonek',
  11134. 'caron'
  11135. ];
  11136. var StandardEncoding = [
  11137. '',
  11138. '',
  11139. '',
  11140. '',
  11141. '',
  11142. '',
  11143. '',
  11144. '',
  11145. '',
  11146. '',
  11147. '',
  11148. '',
  11149. '',
  11150. '',
  11151. '',
  11152. '',
  11153. '',
  11154. '',
  11155. '',
  11156. '',
  11157. '',
  11158. '',
  11159. '',
  11160. '',
  11161. '',
  11162. '',
  11163. '',
  11164. '',
  11165. '',
  11166. '',
  11167. '',
  11168. '',
  11169. 'space',
  11170. 'exclam',
  11171. 'quotedbl',
  11172. 'numbersign',
  11173. 'dollar',
  11174. 'percent',
  11175. 'ampersand',
  11176. 'quoteright',
  11177. 'parenleft',
  11178. 'parenright',
  11179. 'asterisk',
  11180. 'plus',
  11181. 'comma',
  11182. 'hyphen',
  11183. 'period',
  11184. 'slash',
  11185. 'zero',
  11186. 'one',
  11187. 'two',
  11188. 'three',
  11189. 'four',
  11190. 'five',
  11191. 'six',
  11192. 'seven',
  11193. 'eight',
  11194. 'nine',
  11195. 'colon',
  11196. 'semicolon',
  11197. 'less',
  11198. 'equal',
  11199. 'greater',
  11200. 'question',
  11201. 'at',
  11202. 'A',
  11203. 'B',
  11204. 'C',
  11205. 'D',
  11206. 'E',
  11207. 'F',
  11208. 'G',
  11209. 'H',
  11210. 'I',
  11211. 'J',
  11212. 'K',
  11213. 'L',
  11214. 'M',
  11215. 'N',
  11216. 'O',
  11217. 'P',
  11218. 'Q',
  11219. 'R',
  11220. 'S',
  11221. 'T',
  11222. 'U',
  11223. 'V',
  11224. 'W',
  11225. 'X',
  11226. 'Y',
  11227. 'Z',
  11228. 'bracketleft',
  11229. 'backslash',
  11230. 'bracketright',
  11231. 'asciicircum',
  11232. 'underscore',
  11233. 'quoteleft',
  11234. 'a',
  11235. 'b',
  11236. 'c',
  11237. 'd',
  11238. 'e',
  11239. 'f',
  11240. 'g',
  11241. 'h',
  11242. 'i',
  11243. 'j',
  11244. 'k',
  11245. 'l',
  11246. 'm',
  11247. 'n',
  11248. 'o',
  11249. 'p',
  11250. 'q',
  11251. 'r',
  11252. 's',
  11253. 't',
  11254. 'u',
  11255. 'v',
  11256. 'w',
  11257. 'x',
  11258. 'y',
  11259. 'z',
  11260. 'braceleft',
  11261. 'bar',
  11262. 'braceright',
  11263. 'asciitilde',
  11264. '',
  11265. '',
  11266. '',
  11267. '',
  11268. '',
  11269. '',
  11270. '',
  11271. '',
  11272. '',
  11273. '',
  11274. '',
  11275. '',
  11276. '',
  11277. '',
  11278. '',
  11279. '',
  11280. '',
  11281. '',
  11282. '',
  11283. '',
  11284. '',
  11285. '',
  11286. '',
  11287. '',
  11288. '',
  11289. '',
  11290. '',
  11291. '',
  11292. '',
  11293. '',
  11294. '',
  11295. '',
  11296. '',
  11297. '',
  11298. 'exclamdown',
  11299. 'cent',
  11300. 'sterling',
  11301. 'fraction',
  11302. 'yen',
  11303. 'florin',
  11304. 'section',
  11305. 'currency',
  11306. 'quotesingle',
  11307. 'quotedblleft',
  11308. 'guillemotleft',
  11309. 'guilsinglleft',
  11310. 'guilsinglright',
  11311. 'fi',
  11312. 'fl',
  11313. '',
  11314. 'endash',
  11315. 'dagger',
  11316. 'daggerdbl',
  11317. 'periodcentered',
  11318. '',
  11319. 'paragraph',
  11320. 'bullet',
  11321. 'quotesinglbase',
  11322. 'quotedblbase',
  11323. 'quotedblright',
  11324. 'guillemotright',
  11325. 'ellipsis',
  11326. 'perthousand',
  11327. '',
  11328. 'questiondown',
  11329. '',
  11330. 'grave',
  11331. 'acute',
  11332. 'circumflex',
  11333. 'tilde',
  11334. 'macron',
  11335. 'breve',
  11336. 'dotaccent',
  11337. 'dieresis',
  11338. '',
  11339. 'ring',
  11340. 'cedilla',
  11341. '',
  11342. 'hungarumlaut',
  11343. 'ogonek',
  11344. 'caron',
  11345. 'emdash',
  11346. '',
  11347. '',
  11348. '',
  11349. '',
  11350. '',
  11351. '',
  11352. '',
  11353. '',
  11354. '',
  11355. '',
  11356. '',
  11357. '',
  11358. '',
  11359. '',
  11360. '',
  11361. '',
  11362. 'AE',
  11363. '',
  11364. 'ordfeminine',
  11365. '',
  11366. '',
  11367. '',
  11368. '',
  11369. 'Lslash',
  11370. 'Oslash',
  11371. 'OE',
  11372. 'ordmasculine',
  11373. '',
  11374. '',
  11375. '',
  11376. '',
  11377. '',
  11378. 'ae',
  11379. '',
  11380. '',
  11381. '',
  11382. 'dotlessi',
  11383. '',
  11384. '',
  11385. 'lslash',
  11386. 'oslash',
  11387. 'oe',
  11388. 'germandbls'
  11389. ];
  11390. var WinAnsiEncoding = [
  11391. '',
  11392. '',
  11393. '',
  11394. '',
  11395. '',
  11396. '',
  11397. '',
  11398. '',
  11399. '',
  11400. '',
  11401. '',
  11402. '',
  11403. '',
  11404. '',
  11405. '',
  11406. '',
  11407. '',
  11408. '',
  11409. '',
  11410. '',
  11411. '',
  11412. '',
  11413. '',
  11414. '',
  11415. '',
  11416. '',
  11417. '',
  11418. '',
  11419. '',
  11420. '',
  11421. '',
  11422. '',
  11423. 'space',
  11424. 'exclam',
  11425. 'quotedbl',
  11426. 'numbersign',
  11427. 'dollar',
  11428. 'percent',
  11429. 'ampersand',
  11430. 'quotesingle',
  11431. 'parenleft',
  11432. 'parenright',
  11433. 'asterisk',
  11434. 'plus',
  11435. 'comma',
  11436. 'hyphen',
  11437. 'period',
  11438. 'slash',
  11439. 'zero',
  11440. 'one',
  11441. 'two',
  11442. 'three',
  11443. 'four',
  11444. 'five',
  11445. 'six',
  11446. 'seven',
  11447. 'eight',
  11448. 'nine',
  11449. 'colon',
  11450. 'semicolon',
  11451. 'less',
  11452. 'equal',
  11453. 'greater',
  11454. 'question',
  11455. 'at',
  11456. 'A',
  11457. 'B',
  11458. 'C',
  11459. 'D',
  11460. 'E',
  11461. 'F',
  11462. 'G',
  11463. 'H',
  11464. 'I',
  11465. 'J',
  11466. 'K',
  11467. 'L',
  11468. 'M',
  11469. 'N',
  11470. 'O',
  11471. 'P',
  11472. 'Q',
  11473. 'R',
  11474. 'S',
  11475. 'T',
  11476. 'U',
  11477. 'V',
  11478. 'W',
  11479. 'X',
  11480. 'Y',
  11481. 'Z',
  11482. 'bracketleft',
  11483. 'backslash',
  11484. 'bracketright',
  11485. 'asciicircum',
  11486. 'underscore',
  11487. 'grave',
  11488. 'a',
  11489. 'b',
  11490. 'c',
  11491. 'd',
  11492. 'e',
  11493. 'f',
  11494. 'g',
  11495. 'h',
  11496. 'i',
  11497. 'j',
  11498. 'k',
  11499. 'l',
  11500. 'm',
  11501. 'n',
  11502. 'o',
  11503. 'p',
  11504. 'q',
  11505. 'r',
  11506. 's',
  11507. 't',
  11508. 'u',
  11509. 'v',
  11510. 'w',
  11511. 'x',
  11512. 'y',
  11513. 'z',
  11514. 'braceleft',
  11515. 'bar',
  11516. 'braceright',
  11517. 'asciitilde',
  11518. 'bullet',
  11519. 'Euro',
  11520. 'bullet',
  11521. 'quotesinglbase',
  11522. 'florin',
  11523. 'quotedblbase',
  11524. 'ellipsis',
  11525. 'dagger',
  11526. 'daggerdbl',
  11527. 'circumflex',
  11528. 'perthousand',
  11529. 'Scaron',
  11530. 'guilsinglleft',
  11531. 'OE',
  11532. 'bullet',
  11533. 'Zcaron',
  11534. 'bullet',
  11535. 'bullet',
  11536. 'quoteleft',
  11537. 'quoteright',
  11538. 'quotedblleft',
  11539. 'quotedblright',
  11540. 'bullet',
  11541. 'endash',
  11542. 'emdash',
  11543. 'tilde',
  11544. 'trademark',
  11545. 'scaron',
  11546. 'guilsinglright',
  11547. 'oe',
  11548. 'bullet',
  11549. 'zcaron',
  11550. 'Ydieresis',
  11551. 'space',
  11552. 'exclamdown',
  11553. 'cent',
  11554. 'sterling',
  11555. 'currency',
  11556. 'yen',
  11557. 'brokenbar',
  11558. 'section',
  11559. 'dieresis',
  11560. 'copyright',
  11561. 'ordfeminine',
  11562. 'guillemotleft',
  11563. 'logicalnot',
  11564. 'hyphen',
  11565. 'registered',
  11566. 'macron',
  11567. 'degree',
  11568. 'plusminus',
  11569. 'twosuperior',
  11570. 'threesuperior',
  11571. 'acute',
  11572. 'mu',
  11573. 'paragraph',
  11574. 'periodcentered',
  11575. 'cedilla',
  11576. 'onesuperior',
  11577. 'ordmasculine',
  11578. 'guillemotright',
  11579. 'onequarter',
  11580. 'onehalf',
  11581. 'threequarters',
  11582. 'questiondown',
  11583. 'Agrave',
  11584. 'Aacute',
  11585. 'Acircumflex',
  11586. 'Atilde',
  11587. 'Adieresis',
  11588. 'Aring',
  11589. 'AE',
  11590. 'Ccedilla',
  11591. 'Egrave',
  11592. 'Eacute',
  11593. 'Ecircumflex',
  11594. 'Edieresis',
  11595. 'Igrave',
  11596. 'Iacute',
  11597. 'Icircumflex',
  11598. 'Idieresis',
  11599. 'Eth',
  11600. 'Ntilde',
  11601. 'Ograve',
  11602. 'Oacute',
  11603. 'Ocircumflex',
  11604. 'Otilde',
  11605. 'Odieresis',
  11606. 'multiply',
  11607. 'Oslash',
  11608. 'Ugrave',
  11609. 'Uacute',
  11610. 'Ucircumflex',
  11611. 'Udieresis',
  11612. 'Yacute',
  11613. 'Thorn',
  11614. 'germandbls',
  11615. 'agrave',
  11616. 'aacute',
  11617. 'acircumflex',
  11618. 'atilde',
  11619. 'adieresis',
  11620. 'aring',
  11621. 'ae',
  11622. 'ccedilla',
  11623. 'egrave',
  11624. 'eacute',
  11625. 'ecircumflex',
  11626. 'edieresis',
  11627. 'igrave',
  11628. 'iacute',
  11629. 'icircumflex',
  11630. 'idieresis',
  11631. 'eth',
  11632. 'ntilde',
  11633. 'ograve',
  11634. 'oacute',
  11635. 'ocircumflex',
  11636. 'otilde',
  11637. 'odieresis',
  11638. 'divide',
  11639. 'oslash',
  11640. 'ugrave',
  11641. 'uacute',
  11642. 'ucircumflex',
  11643. 'udieresis',
  11644. 'yacute',
  11645. 'thorn',
  11646. 'ydieresis'
  11647. ];
  11648. var SymbolSetEncoding = [
  11649. '',
  11650. '',
  11651. '',
  11652. '',
  11653. '',
  11654. '',
  11655. '',
  11656. '',
  11657. '',
  11658. '',
  11659. '',
  11660. '',
  11661. '',
  11662. '',
  11663. '',
  11664. '',
  11665. '',
  11666. '',
  11667. '',
  11668. '',
  11669. '',
  11670. '',
  11671. '',
  11672. '',
  11673. '',
  11674. '',
  11675. '',
  11676. '',
  11677. '',
  11678. '',
  11679. '',
  11680. '',
  11681. 'space',
  11682. 'exclam',
  11683. 'universal',
  11684. 'numbersign',
  11685. 'existential',
  11686. 'percent',
  11687. 'ampersand',
  11688. 'suchthat',
  11689. 'parenleft',
  11690. 'parenright',
  11691. 'asteriskmath',
  11692. 'plus',
  11693. 'comma',
  11694. 'minus',
  11695. 'period',
  11696. 'slash',
  11697. 'zero',
  11698. 'one',
  11699. 'two',
  11700. 'three',
  11701. 'four',
  11702. 'five',
  11703. 'six',
  11704. 'seven',
  11705. 'eight',
  11706. 'nine',
  11707. 'colon',
  11708. 'semicolon',
  11709. 'less',
  11710. 'equal',
  11711. 'greater',
  11712. 'question',
  11713. 'congruent',
  11714. 'Alpha',
  11715. 'Beta',
  11716. 'Chi',
  11717. 'Delta',
  11718. 'Epsilon',
  11719. 'Phi',
  11720. 'Gamma',
  11721. 'Eta',
  11722. 'Iota',
  11723. 'theta1',
  11724. 'Kappa',
  11725. 'Lambda',
  11726. 'Mu',
  11727. 'Nu',
  11728. 'Omicron',
  11729. 'Pi',
  11730. 'Theta',
  11731. 'Rho',
  11732. 'Sigma',
  11733. 'Tau',
  11734. 'Upsilon',
  11735. 'sigma1',
  11736. 'Omega',
  11737. 'Xi',
  11738. 'Psi',
  11739. 'Zeta',
  11740. 'bracketleft',
  11741. 'therefore',
  11742. 'bracketright',
  11743. 'perpendicular',
  11744. 'underscore',
  11745. 'radicalex',
  11746. 'alpha',
  11747. 'beta',
  11748. 'chi',
  11749. 'delta',
  11750. 'epsilon',
  11751. 'phi',
  11752. 'gamma',
  11753. 'eta',
  11754. 'iota',
  11755. 'phi1',
  11756. 'kappa',
  11757. 'lambda',
  11758. 'mu',
  11759. 'nu',
  11760. 'omicron',
  11761. 'pi',
  11762. 'theta',
  11763. 'rho',
  11764. 'sigma',
  11765. 'tau',
  11766. 'upsilon',
  11767. 'omega1',
  11768. 'omega',
  11769. 'xi',
  11770. 'psi',
  11771. 'zeta',
  11772. 'braceleft',
  11773. 'bar',
  11774. 'braceright',
  11775. 'similar',
  11776. '',
  11777. '',
  11778. '',
  11779. '',
  11780. '',
  11781. '',
  11782. '',
  11783. '',
  11784. '',
  11785. '',
  11786. '',
  11787. '',
  11788. '',
  11789. '',
  11790. '',
  11791. '',
  11792. '',
  11793. '',
  11794. '',
  11795. '',
  11796. '',
  11797. '',
  11798. '',
  11799. '',
  11800. '',
  11801. '',
  11802. '',
  11803. '',
  11804. '',
  11805. '',
  11806. '',
  11807. '',
  11808. '',
  11809. 'Euro',
  11810. 'Upsilon1',
  11811. 'minute',
  11812. 'lessequal',
  11813. 'fraction',
  11814. 'infinity',
  11815. 'florin',
  11816. 'club',
  11817. 'diamond',
  11818. 'heart',
  11819. 'spade',
  11820. 'arrowboth',
  11821. 'arrowleft',
  11822. 'arrowup',
  11823. 'arrowright',
  11824. 'arrowdown',
  11825. 'degree',
  11826. 'plusminus',
  11827. 'second',
  11828. 'greaterequal',
  11829. 'multiply',
  11830. 'proportional',
  11831. 'partialdiff',
  11832. 'bullet',
  11833. 'divide',
  11834. 'notequal',
  11835. 'equivalence',
  11836. 'approxequal',
  11837. 'ellipsis',
  11838. 'arrowvertex',
  11839. 'arrowhorizex',
  11840. 'carriagereturn',
  11841. 'aleph',
  11842. 'Ifraktur',
  11843. 'Rfraktur',
  11844. 'weierstrass',
  11845. 'circlemultiply',
  11846. 'circleplus',
  11847. 'emptyset',
  11848. 'intersection',
  11849. 'union',
  11850. 'propersuperset',
  11851. 'reflexsuperset',
  11852. 'notsubset',
  11853. 'propersubset',
  11854. 'reflexsubset',
  11855. 'element',
  11856. 'notelement',
  11857. 'angle',
  11858. 'gradient',
  11859. 'registerserif',
  11860. 'copyrightserif',
  11861. 'trademarkserif',
  11862. 'product',
  11863. 'radical',
  11864. 'dotmath',
  11865. 'logicalnot',
  11866. 'logicaland',
  11867. 'logicalor',
  11868. 'arrowdblboth',
  11869. 'arrowdblleft',
  11870. 'arrowdblup',
  11871. 'arrowdblright',
  11872. 'arrowdbldown',
  11873. 'lozenge',
  11874. 'angleleft',
  11875. 'registersans',
  11876. 'copyrightsans',
  11877. 'trademarksans',
  11878. 'summation',
  11879. 'parenlefttp',
  11880. 'parenleftex',
  11881. 'parenleftbt',
  11882. 'bracketlefttp',
  11883. 'bracketleftex',
  11884. 'bracketleftbt',
  11885. 'bracelefttp',
  11886. 'braceleftmid',
  11887. 'braceleftbt',
  11888. 'braceex',
  11889. '',
  11890. 'angleright',
  11891. 'integral',
  11892. 'integraltp',
  11893. 'integralex',
  11894. 'integralbt',
  11895. 'parenrighttp',
  11896. 'parenrightex',
  11897. 'parenrightbt',
  11898. 'bracketrighttp',
  11899. 'bracketrightex',
  11900. 'bracketrightbt',
  11901. 'bracerighttp',
  11902. 'bracerightmid',
  11903. 'bracerightbt'
  11904. ];
  11905. var ZapfDingbatsEncoding = [
  11906. '',
  11907. '',
  11908. '',
  11909. '',
  11910. '',
  11911. '',
  11912. '',
  11913. '',
  11914. '',
  11915. '',
  11916. '',
  11917. '',
  11918. '',
  11919. '',
  11920. '',
  11921. '',
  11922. '',
  11923. '',
  11924. '',
  11925. '',
  11926. '',
  11927. '',
  11928. '',
  11929. '',
  11930. '',
  11931. '',
  11932. '',
  11933. '',
  11934. '',
  11935. '',
  11936. '',
  11937. '',
  11938. 'space',
  11939. 'a1',
  11940. 'a2',
  11941. 'a202',
  11942. 'a3',
  11943. 'a4',
  11944. 'a5',
  11945. 'a119',
  11946. 'a118',
  11947. 'a117',
  11948. 'a11',
  11949. 'a12',
  11950. 'a13',
  11951. 'a14',
  11952. 'a15',
  11953. 'a16',
  11954. 'a105',
  11955. 'a17',
  11956. 'a18',
  11957. 'a19',
  11958. 'a20',
  11959. 'a21',
  11960. 'a22',
  11961. 'a23',
  11962. 'a24',
  11963. 'a25',
  11964. 'a26',
  11965. 'a27',
  11966. 'a28',
  11967. 'a6',
  11968. 'a7',
  11969. 'a8',
  11970. 'a9',
  11971. 'a10',
  11972. 'a29',
  11973. 'a30',
  11974. 'a31',
  11975. 'a32',
  11976. 'a33',
  11977. 'a34',
  11978. 'a35',
  11979. 'a36',
  11980. 'a37',
  11981. 'a38',
  11982. 'a39',
  11983. 'a40',
  11984. 'a41',
  11985. 'a42',
  11986. 'a43',
  11987. 'a44',
  11988. 'a45',
  11989. 'a46',
  11990. 'a47',
  11991. 'a48',
  11992. 'a49',
  11993. 'a50',
  11994. 'a51',
  11995. 'a52',
  11996. 'a53',
  11997. 'a54',
  11998. 'a55',
  11999. 'a56',
  12000. 'a57',
  12001. 'a58',
  12002. 'a59',
  12003. 'a60',
  12004. 'a61',
  12005. 'a62',
  12006. 'a63',
  12007. 'a64',
  12008. 'a65',
  12009. 'a66',
  12010. 'a67',
  12011. 'a68',
  12012. 'a69',
  12013. 'a70',
  12014. 'a71',
  12015. 'a72',
  12016. 'a73',
  12017. 'a74',
  12018. 'a203',
  12019. 'a75',
  12020. 'a204',
  12021. 'a76',
  12022. 'a77',
  12023. 'a78',
  12024. 'a79',
  12025. 'a81',
  12026. 'a82',
  12027. 'a83',
  12028. 'a84',
  12029. 'a97',
  12030. 'a98',
  12031. 'a99',
  12032. 'a100',
  12033. '',
  12034. 'a89',
  12035. 'a90',
  12036. 'a93',
  12037. 'a94',
  12038. 'a91',
  12039. 'a92',
  12040. 'a205',
  12041. 'a85',
  12042. 'a206',
  12043. 'a86',
  12044. 'a87',
  12045. 'a88',
  12046. 'a95',
  12047. 'a96',
  12048. '',
  12049. '',
  12050. '',
  12051. '',
  12052. '',
  12053. '',
  12054. '',
  12055. '',
  12056. '',
  12057. '',
  12058. '',
  12059. '',
  12060. '',
  12061. '',
  12062. '',
  12063. '',
  12064. '',
  12065. '',
  12066. '',
  12067. 'a101',
  12068. 'a102',
  12069. 'a103',
  12070. 'a104',
  12071. 'a106',
  12072. 'a107',
  12073. 'a108',
  12074. 'a112',
  12075. 'a111',
  12076. 'a110',
  12077. 'a109',
  12078. 'a120',
  12079. 'a121',
  12080. 'a122',
  12081. 'a123',
  12082. 'a124',
  12083. 'a125',
  12084. 'a126',
  12085. 'a127',
  12086. 'a128',
  12087. 'a129',
  12088. 'a130',
  12089. 'a131',
  12090. 'a132',
  12091. 'a133',
  12092. 'a134',
  12093. 'a135',
  12094. 'a136',
  12095. 'a137',
  12096. 'a138',
  12097. 'a139',
  12098. 'a140',
  12099. 'a141',
  12100. 'a142',
  12101. 'a143',
  12102. 'a144',
  12103. 'a145',
  12104. 'a146',
  12105. 'a147',
  12106. 'a148',
  12107. 'a149',
  12108. 'a150',
  12109. 'a151',
  12110. 'a152',
  12111. 'a153',
  12112. 'a154',
  12113. 'a155',
  12114. 'a156',
  12115. 'a157',
  12116. 'a158',
  12117. 'a159',
  12118. 'a160',
  12119. 'a161',
  12120. 'a163',
  12121. 'a164',
  12122. 'a196',
  12123. 'a165',
  12124. 'a192',
  12125. 'a166',
  12126. 'a167',
  12127. 'a168',
  12128. 'a169',
  12129. 'a170',
  12130. 'a171',
  12131. 'a172',
  12132. 'a173',
  12133. 'a162',
  12134. 'a174',
  12135. 'a175',
  12136. 'a176',
  12137. 'a177',
  12138. 'a178',
  12139. 'a179',
  12140. 'a193',
  12141. 'a180',
  12142. 'a199',
  12143. 'a181',
  12144. 'a200',
  12145. 'a182',
  12146. '',
  12147. 'a201',
  12148. 'a183',
  12149. 'a184',
  12150. 'a197',
  12151. 'a185',
  12152. 'a194',
  12153. 'a198',
  12154. 'a186',
  12155. 'a195',
  12156. 'a187',
  12157. 'a188',
  12158. 'a189',
  12159. 'a190',
  12160. 'a191'
  12161. ];
  12162. function getEncoding(encodingName) {
  12163. switch (encodingName) {
  12164. case 'WinAnsiEncoding':
  12165. return WinAnsiEncoding;
  12166. case 'StandardEncoding':
  12167. return StandardEncoding;
  12168. case 'MacRomanEncoding':
  12169. return MacRomanEncoding;
  12170. case 'SymbolSetEncoding':
  12171. return SymbolSetEncoding;
  12172. case 'ZapfDingbatsEncoding':
  12173. return ZapfDingbatsEncoding;
  12174. case 'ExpertEncoding':
  12175. return ExpertEncoding;
  12176. case 'MacExpertEncoding':
  12177. return MacExpertEncoding;
  12178. default:
  12179. return null;
  12180. }
  12181. }
  12182. exports.WinAnsiEncoding = WinAnsiEncoding;
  12183. exports.StandardEncoding = StandardEncoding;
  12184. exports.MacRomanEncoding = MacRomanEncoding;
  12185. exports.SymbolSetEncoding = SymbolSetEncoding;
  12186. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  12187. exports.ExpertEncoding = ExpertEncoding;
  12188. exports.getEncoding = getEncoding;
  12189. /***/ }),
  12190. /* 6 */
  12191. /***/ (function(module, exports, __w_pdfjs_require__) {
  12192. "use strict";
  12193. var sharedUtil = __w_pdfjs_require__(0);
  12194. var corePrimitives = __w_pdfjs_require__(1);
  12195. var coreStream = __w_pdfjs_require__(2);
  12196. var MissingDataException = sharedUtil.MissingDataException;
  12197. var StreamType = sharedUtil.StreamType;
  12198. var assert = sharedUtil.assert;
  12199. var error = sharedUtil.error;
  12200. var info = sharedUtil.info;
  12201. var isArray = sharedUtil.isArray;
  12202. var isInt = sharedUtil.isInt;
  12203. var isNum = sharedUtil.isNum;
  12204. var isString = sharedUtil.isString;
  12205. var warn = sharedUtil.warn;
  12206. var EOF = corePrimitives.EOF;
  12207. var Cmd = corePrimitives.Cmd;
  12208. var Dict = corePrimitives.Dict;
  12209. var Name = corePrimitives.Name;
  12210. var Ref = corePrimitives.Ref;
  12211. var isEOF = corePrimitives.isEOF;
  12212. var isCmd = corePrimitives.isCmd;
  12213. var isDict = corePrimitives.isDict;
  12214. var isName = corePrimitives.isName;
  12215. var Ascii85Stream = coreStream.Ascii85Stream;
  12216. var AsciiHexStream = coreStream.AsciiHexStream;
  12217. var CCITTFaxStream = coreStream.CCITTFaxStream;
  12218. var FlateStream = coreStream.FlateStream;
  12219. var Jbig2Stream = coreStream.Jbig2Stream;
  12220. var JpegStream = coreStream.JpegStream;
  12221. var JpxStream = coreStream.JpxStream;
  12222. var LZWStream = coreStream.LZWStream;
  12223. var NullStream = coreStream.NullStream;
  12224. var PredictorStream = coreStream.PredictorStream;
  12225. var RunLengthStream = coreStream.RunLengthStream;
  12226. var MAX_LENGTH_TO_CACHE = 1000;
  12227. var Parser = function ParserClosure() {
  12228. function Parser(lexer, allowStreams, xref, recoveryMode) {
  12229. this.lexer = lexer;
  12230. this.allowStreams = allowStreams;
  12231. this.xref = xref;
  12232. this.recoveryMode = recoveryMode || false;
  12233. this.imageCache = Object.create(null);
  12234. this.refill();
  12235. }
  12236. Parser.prototype = {
  12237. refill: function Parser_refill() {
  12238. this.buf1 = this.lexer.getObj();
  12239. this.buf2 = this.lexer.getObj();
  12240. },
  12241. shift: function Parser_shift() {
  12242. if (isCmd(this.buf2, 'ID')) {
  12243. this.buf1 = this.buf2;
  12244. this.buf2 = null;
  12245. } else {
  12246. this.buf1 = this.buf2;
  12247. this.buf2 = this.lexer.getObj();
  12248. }
  12249. },
  12250. tryShift: function Parser_tryShift() {
  12251. try {
  12252. this.shift();
  12253. return true;
  12254. } catch (e) {
  12255. if (e instanceof MissingDataException) {
  12256. throw e;
  12257. }
  12258. return false;
  12259. }
  12260. },
  12261. getObj: function Parser_getObj(cipherTransform) {
  12262. var buf1 = this.buf1;
  12263. this.shift();
  12264. if (buf1 instanceof Cmd) {
  12265. switch (buf1.cmd) {
  12266. case 'BI':
  12267. return this.makeInlineImage(cipherTransform);
  12268. case '[':
  12269. var array = [];
  12270. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  12271. array.push(this.getObj(cipherTransform));
  12272. }
  12273. if (isEOF(this.buf1)) {
  12274. if (!this.recoveryMode) {
  12275. error('End of file inside array');
  12276. }
  12277. return array;
  12278. }
  12279. this.shift();
  12280. return array;
  12281. case '<<':
  12282. var dict = new Dict(this.xref);
  12283. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  12284. if (!isName(this.buf1)) {
  12285. info('Malformed dictionary: key must be a name object');
  12286. this.shift();
  12287. continue;
  12288. }
  12289. var key = this.buf1.name;
  12290. this.shift();
  12291. if (isEOF(this.buf1)) {
  12292. break;
  12293. }
  12294. dict.set(key, this.getObj(cipherTransform));
  12295. }
  12296. if (isEOF(this.buf1)) {
  12297. if (!this.recoveryMode) {
  12298. error('End of file inside dictionary');
  12299. }
  12300. return dict;
  12301. }
  12302. if (isCmd(this.buf2, 'stream')) {
  12303. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  12304. }
  12305. this.shift();
  12306. return dict;
  12307. default:
  12308. return buf1;
  12309. }
  12310. }
  12311. if (isInt(buf1)) {
  12312. var num = buf1;
  12313. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  12314. var ref = new Ref(num, this.buf1);
  12315. this.shift();
  12316. this.shift();
  12317. return ref;
  12318. }
  12319. return num;
  12320. }
  12321. if (isString(buf1)) {
  12322. var str = buf1;
  12323. if (cipherTransform) {
  12324. str = cipherTransform.decryptString(str);
  12325. }
  12326. return str;
  12327. }
  12328. return buf1;
  12329. },
  12330. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  12331. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  12332. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  12333. while ((ch = stream.getByte()) !== -1) {
  12334. if (state === 0) {
  12335. state = ch === E ? 1 : 0;
  12336. } else if (state === 1) {
  12337. state = ch === I ? 2 : 0;
  12338. } else {
  12339. assert(state === 2);
  12340. if (ch === SPACE || ch === LF || ch === CR) {
  12341. n = 5;
  12342. followingBytes = stream.peekBytes(n);
  12343. for (i = 0; i < n; i++) {
  12344. ch = followingBytes[i];
  12345. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  12346. state = 0;
  12347. break;
  12348. }
  12349. }
  12350. if (state === 2) {
  12351. break;
  12352. }
  12353. } else {
  12354. state = 0;
  12355. }
  12356. }
  12357. }
  12358. return stream.pos - 4 - startPos;
  12359. },
  12360. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  12361. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  12362. while ((b = stream.getByte()) !== -1) {
  12363. if (b !== 0xFF) {
  12364. continue;
  12365. }
  12366. switch (stream.getByte()) {
  12367. case 0x00:
  12368. break;
  12369. case 0xFF:
  12370. stream.skip(-1);
  12371. break;
  12372. case 0xD9:
  12373. foundEOI = true;
  12374. break;
  12375. case 0xC0:
  12376. case 0xC1:
  12377. case 0xC2:
  12378. case 0xC3:
  12379. case 0xC5:
  12380. case 0xC6:
  12381. case 0xC7:
  12382. case 0xC9:
  12383. case 0xCA:
  12384. case 0xCB:
  12385. case 0xCD:
  12386. case 0xCE:
  12387. case 0xCF:
  12388. case 0xC4:
  12389. case 0xCC:
  12390. case 0xDA:
  12391. case 0xDB:
  12392. case 0xDC:
  12393. case 0xDD:
  12394. case 0xDE:
  12395. case 0xDF:
  12396. case 0xE0:
  12397. case 0xE1:
  12398. case 0xE2:
  12399. case 0xE3:
  12400. case 0xE4:
  12401. case 0xE5:
  12402. case 0xE6:
  12403. case 0xE7:
  12404. case 0xE8:
  12405. case 0xE9:
  12406. case 0xEA:
  12407. case 0xEB:
  12408. case 0xEC:
  12409. case 0xED:
  12410. case 0xEE:
  12411. case 0xEF:
  12412. case 0xFE:
  12413. markerLength = stream.getUint16();
  12414. if (markerLength > 2) {
  12415. stream.skip(markerLength - 2);
  12416. } else {
  12417. stream.skip(-2);
  12418. }
  12419. break;
  12420. }
  12421. if (foundEOI) {
  12422. break;
  12423. }
  12424. }
  12425. length = stream.pos - startPos;
  12426. if (b === -1) {
  12427. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  12428. stream.skip(-length);
  12429. return this.findDefaultInlineStreamEnd(stream);
  12430. }
  12431. this.inlineStreamSkipEI(stream);
  12432. return length;
  12433. },
  12434. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  12435. var TILDE = 0x7E, GT = 0x3E;
  12436. var startPos = stream.pos, ch, length;
  12437. while ((ch = stream.getByte()) !== -1) {
  12438. if (ch === TILDE && stream.peekByte() === GT) {
  12439. stream.skip();
  12440. break;
  12441. }
  12442. }
  12443. length = stream.pos - startPos;
  12444. if (ch === -1) {
  12445. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  12446. stream.skip(-length);
  12447. return this.findDefaultInlineStreamEnd(stream);
  12448. }
  12449. this.inlineStreamSkipEI(stream);
  12450. return length;
  12451. },
  12452. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  12453. var GT = 0x3E;
  12454. var startPos = stream.pos, ch, length;
  12455. while ((ch = stream.getByte()) !== -1) {
  12456. if (ch === GT) {
  12457. break;
  12458. }
  12459. }
  12460. length = stream.pos - startPos;
  12461. if (ch === -1) {
  12462. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  12463. stream.skip(-length);
  12464. return this.findDefaultInlineStreamEnd(stream);
  12465. }
  12466. this.inlineStreamSkipEI(stream);
  12467. return length;
  12468. },
  12469. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  12470. var E = 0x45, I = 0x49;
  12471. var state = 0, ch;
  12472. while ((ch = stream.getByte()) !== -1) {
  12473. if (state === 0) {
  12474. state = ch === E ? 1 : 0;
  12475. } else if (state === 1) {
  12476. state = ch === I ? 2 : 0;
  12477. } else if (state === 2) {
  12478. break;
  12479. }
  12480. }
  12481. },
  12482. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  12483. var lexer = this.lexer;
  12484. var stream = lexer.stream;
  12485. var dict = new Dict(this.xref);
  12486. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  12487. if (!isName(this.buf1)) {
  12488. error('Dictionary key must be a name object');
  12489. }
  12490. var key = this.buf1.name;
  12491. this.shift();
  12492. if (isEOF(this.buf1)) {
  12493. break;
  12494. }
  12495. dict.set(key, this.getObj(cipherTransform));
  12496. }
  12497. var filter = dict.get('Filter', 'F'), filterName;
  12498. if (isName(filter)) {
  12499. filterName = filter.name;
  12500. } else if (isArray(filter)) {
  12501. var filterZero = this.xref.fetchIfRef(filter[0]);
  12502. if (isName(filterZero)) {
  12503. filterName = filterZero.name;
  12504. }
  12505. }
  12506. var startPos = stream.pos, length, i, ii;
  12507. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  12508. length = this.findDCTDecodeInlineStreamEnd(stream);
  12509. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  12510. length = this.findASCII85DecodeInlineStreamEnd(stream);
  12511. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  12512. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  12513. } else {
  12514. length = this.findDefaultInlineStreamEnd(stream);
  12515. }
  12516. var imageStream = stream.makeSubStream(startPos, length, dict);
  12517. var adler32;
  12518. if (length < MAX_LENGTH_TO_CACHE) {
  12519. var imageBytes = imageStream.getBytes();
  12520. imageStream.reset();
  12521. var a = 1;
  12522. var b = 0;
  12523. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  12524. a += imageBytes[i] & 0xff;
  12525. b += a;
  12526. }
  12527. adler32 = b % 65521 << 16 | a % 65521;
  12528. if (this.imageCache.adler32 === adler32) {
  12529. this.buf2 = Cmd.get('EI');
  12530. this.shift();
  12531. this.imageCache[adler32].reset();
  12532. return this.imageCache[adler32];
  12533. }
  12534. }
  12535. if (cipherTransform) {
  12536. imageStream = cipherTransform.createStream(imageStream, length);
  12537. }
  12538. imageStream = this.filter(imageStream, dict, length);
  12539. imageStream.dict = dict;
  12540. if (adler32 !== undefined) {
  12541. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  12542. this.imageCache[adler32] = imageStream;
  12543. }
  12544. this.buf2 = Cmd.get('EI');
  12545. this.shift();
  12546. return imageStream;
  12547. },
  12548. makeStream: function Parser_makeStream(dict, cipherTransform) {
  12549. var lexer = this.lexer;
  12550. var stream = lexer.stream;
  12551. lexer.skipToNextLine();
  12552. var pos = stream.pos - 1;
  12553. var length = dict.get('Length');
  12554. if (!isInt(length)) {
  12555. info('Bad ' + length + ' attribute in stream');
  12556. length = 0;
  12557. }
  12558. stream.pos = pos + length;
  12559. lexer.nextChar();
  12560. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  12561. this.shift();
  12562. } else {
  12563. stream.pos = pos;
  12564. var SCAN_BLOCK_SIZE = 2048;
  12565. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  12566. var ENDSTREAM_SIGNATURE = [
  12567. 0x65,
  12568. 0x6E,
  12569. 0x64,
  12570. 0x73,
  12571. 0x74,
  12572. 0x72,
  12573. 0x65,
  12574. 0x61,
  12575. 0x6D
  12576. ];
  12577. var skipped = 0, found = false, i, j;
  12578. while (stream.pos < stream.end) {
  12579. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  12580. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  12581. if (scanLength <= 0) {
  12582. break;
  12583. }
  12584. found = false;
  12585. i = 0;
  12586. while (i < scanLength) {
  12587. j = 0;
  12588. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  12589. j++;
  12590. }
  12591. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  12592. found = true;
  12593. break;
  12594. }
  12595. i++;
  12596. }
  12597. if (found) {
  12598. skipped += i;
  12599. stream.pos += i;
  12600. break;
  12601. }
  12602. skipped += scanLength;
  12603. stream.pos += scanLength;
  12604. }
  12605. if (!found) {
  12606. error('Missing endstream');
  12607. }
  12608. length = skipped;
  12609. lexer.nextChar();
  12610. this.shift();
  12611. this.shift();
  12612. }
  12613. this.shift();
  12614. stream = stream.makeSubStream(pos, length, dict);
  12615. if (cipherTransform) {
  12616. stream = cipherTransform.createStream(stream, length);
  12617. }
  12618. stream = this.filter(stream, dict, length);
  12619. stream.dict = dict;
  12620. return stream;
  12621. },
  12622. filter: function Parser_filter(stream, dict, length) {
  12623. var filter = dict.get('Filter', 'F');
  12624. var params = dict.get('DecodeParms', 'DP');
  12625. if (isName(filter)) {
  12626. if (isArray(params)) {
  12627. params = this.xref.fetchIfRef(params[0]);
  12628. }
  12629. return this.makeFilter(stream, filter.name, length, params);
  12630. }
  12631. var maybeLength = length;
  12632. if (isArray(filter)) {
  12633. var filterArray = filter;
  12634. var paramsArray = params;
  12635. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  12636. filter = this.xref.fetchIfRef(filterArray[i]);
  12637. if (!isName(filter)) {
  12638. error('Bad filter name: ' + filter);
  12639. }
  12640. params = null;
  12641. if (isArray(paramsArray) && i in paramsArray) {
  12642. params = this.xref.fetchIfRef(paramsArray[i]);
  12643. }
  12644. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  12645. maybeLength = null;
  12646. }
  12647. }
  12648. return stream;
  12649. },
  12650. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  12651. if (maybeLength === 0) {
  12652. warn('Empty "' + name + '" stream.');
  12653. return new NullStream(stream);
  12654. }
  12655. try {
  12656. var xrefStreamStats = this.xref.stats.streamTypes;
  12657. if (name === 'FlateDecode' || name === 'Fl') {
  12658. xrefStreamStats[StreamType.FLATE] = true;
  12659. if (params) {
  12660. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  12661. }
  12662. return new FlateStream(stream, maybeLength);
  12663. }
  12664. if (name === 'LZWDecode' || name === 'LZW') {
  12665. xrefStreamStats[StreamType.LZW] = true;
  12666. var earlyChange = 1;
  12667. if (params) {
  12668. if (params.has('EarlyChange')) {
  12669. earlyChange = params.get('EarlyChange');
  12670. }
  12671. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  12672. }
  12673. return new LZWStream(stream, maybeLength, earlyChange);
  12674. }
  12675. if (name === 'DCTDecode' || name === 'DCT') {
  12676. xrefStreamStats[StreamType.DCT] = true;
  12677. return new JpegStream(stream, maybeLength, stream.dict, params);
  12678. }
  12679. if (name === 'JPXDecode' || name === 'JPX') {
  12680. xrefStreamStats[StreamType.JPX] = true;
  12681. return new JpxStream(stream, maybeLength, stream.dict, params);
  12682. }
  12683. if (name === 'ASCII85Decode' || name === 'A85') {
  12684. xrefStreamStats[StreamType.A85] = true;
  12685. return new Ascii85Stream(stream, maybeLength);
  12686. }
  12687. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  12688. xrefStreamStats[StreamType.AHX] = true;
  12689. return new AsciiHexStream(stream, maybeLength);
  12690. }
  12691. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  12692. xrefStreamStats[StreamType.CCF] = true;
  12693. return new CCITTFaxStream(stream, maybeLength, params);
  12694. }
  12695. if (name === 'RunLengthDecode' || name === 'RL') {
  12696. xrefStreamStats[StreamType.RL] = true;
  12697. return new RunLengthStream(stream, maybeLength);
  12698. }
  12699. if (name === 'JBIG2Decode') {
  12700. xrefStreamStats[StreamType.JBIG] = true;
  12701. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  12702. }
  12703. warn('filter "' + name + '" not supported yet');
  12704. return stream;
  12705. } catch (ex) {
  12706. if (ex instanceof MissingDataException) {
  12707. throw ex;
  12708. }
  12709. warn('Invalid stream: \"' + ex + '\"');
  12710. return new NullStream(stream);
  12711. }
  12712. }
  12713. };
  12714. return Parser;
  12715. }();
  12716. var Lexer = function LexerClosure() {
  12717. function Lexer(stream, knownCommands) {
  12718. this.stream = stream;
  12719. this.nextChar();
  12720. this.strBuf = [];
  12721. this.knownCommands = knownCommands;
  12722. }
  12723. var specialChars = [
  12724. 1,
  12725. 0,
  12726. 0,
  12727. 0,
  12728. 0,
  12729. 0,
  12730. 0,
  12731. 0,
  12732. 0,
  12733. 1,
  12734. 1,
  12735. 0,
  12736. 1,
  12737. 1,
  12738. 0,
  12739. 0,
  12740. 0,
  12741. 0,
  12742. 0,
  12743. 0,
  12744. 0,
  12745. 0,
  12746. 0,
  12747. 0,
  12748. 0,
  12749. 0,
  12750. 0,
  12751. 0,
  12752. 0,
  12753. 0,
  12754. 0,
  12755. 0,
  12756. 1,
  12757. 0,
  12758. 0,
  12759. 0,
  12760. 0,
  12761. 2,
  12762. 0,
  12763. 0,
  12764. 2,
  12765. 2,
  12766. 0,
  12767. 0,
  12768. 0,
  12769. 0,
  12770. 0,
  12771. 2,
  12772. 0,
  12773. 0,
  12774. 0,
  12775. 0,
  12776. 0,
  12777. 0,
  12778. 0,
  12779. 0,
  12780. 0,
  12781. 0,
  12782. 0,
  12783. 0,
  12784. 2,
  12785. 0,
  12786. 2,
  12787. 0,
  12788. 0,
  12789. 0,
  12790. 0,
  12791. 0,
  12792. 0,
  12793. 0,
  12794. 0,
  12795. 0,
  12796. 0,
  12797. 0,
  12798. 0,
  12799. 0,
  12800. 0,
  12801. 0,
  12802. 0,
  12803. 0,
  12804. 0,
  12805. 0,
  12806. 0,
  12807. 0,
  12808. 0,
  12809. 0,
  12810. 0,
  12811. 0,
  12812. 0,
  12813. 0,
  12814. 0,
  12815. 2,
  12816. 0,
  12817. 2,
  12818. 0,
  12819. 0,
  12820. 0,
  12821. 0,
  12822. 0,
  12823. 0,
  12824. 0,
  12825. 0,
  12826. 0,
  12827. 0,
  12828. 0,
  12829. 0,
  12830. 0,
  12831. 0,
  12832. 0,
  12833. 0,
  12834. 0,
  12835. 0,
  12836. 0,
  12837. 0,
  12838. 0,
  12839. 0,
  12840. 0,
  12841. 0,
  12842. 0,
  12843. 0,
  12844. 0,
  12845. 0,
  12846. 0,
  12847. 2,
  12848. 0,
  12849. 2,
  12850. 0,
  12851. 0,
  12852. 0,
  12853. 0,
  12854. 0,
  12855. 0,
  12856. 0,
  12857. 0,
  12858. 0,
  12859. 0,
  12860. 0,
  12861. 0,
  12862. 0,
  12863. 0,
  12864. 0,
  12865. 0,
  12866. 0,
  12867. 0,
  12868. 0,
  12869. 0,
  12870. 0,
  12871. 0,
  12872. 0,
  12873. 0,
  12874. 0,
  12875. 0,
  12876. 0,
  12877. 0,
  12878. 0,
  12879. 0,
  12880. 0,
  12881. 0,
  12882. 0,
  12883. 0,
  12884. 0,
  12885. 0,
  12886. 0,
  12887. 0,
  12888. 0,
  12889. 0,
  12890. 0,
  12891. 0,
  12892. 0,
  12893. 0,
  12894. 0,
  12895. 0,
  12896. 0,
  12897. 0,
  12898. 0,
  12899. 0,
  12900. 0,
  12901. 0,
  12902. 0,
  12903. 0,
  12904. 0,
  12905. 0,
  12906. 0,
  12907. 0,
  12908. 0,
  12909. 0,
  12910. 0,
  12911. 0,
  12912. 0,
  12913. 0,
  12914. 0,
  12915. 0,
  12916. 0,
  12917. 0,
  12918. 0,
  12919. 0,
  12920. 0,
  12921. 0,
  12922. 0,
  12923. 0,
  12924. 0,
  12925. 0,
  12926. 0,
  12927. 0,
  12928. 0,
  12929. 0,
  12930. 0,
  12931. 0,
  12932. 0,
  12933. 0,
  12934. 0,
  12935. 0,
  12936. 0,
  12937. 0,
  12938. 0,
  12939. 0,
  12940. 0,
  12941. 0,
  12942. 0,
  12943. 0,
  12944. 0,
  12945. 0,
  12946. 0,
  12947. 0,
  12948. 0,
  12949. 0,
  12950. 0,
  12951. 0,
  12952. 0,
  12953. 0,
  12954. 0,
  12955. 0,
  12956. 0,
  12957. 0,
  12958. 0,
  12959. 0,
  12960. 0,
  12961. 0,
  12962. 0,
  12963. 0,
  12964. 0,
  12965. 0,
  12966. 0,
  12967. 0,
  12968. 0,
  12969. 0,
  12970. 0,
  12971. 0,
  12972. 0,
  12973. 0,
  12974. 0,
  12975. 0,
  12976. 0,
  12977. 0,
  12978. 0,
  12979. 0
  12980. ];
  12981. function toHexDigit(ch) {
  12982. if (ch >= 0x30 && ch <= 0x39) {
  12983. return ch & 0x0F;
  12984. }
  12985. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  12986. return (ch & 0x0F) + 9;
  12987. }
  12988. return -1;
  12989. }
  12990. Lexer.prototype = {
  12991. nextChar: function Lexer_nextChar() {
  12992. return this.currentChar = this.stream.getByte();
  12993. },
  12994. peekChar: function Lexer_peekChar() {
  12995. return this.stream.peekByte();
  12996. },
  12997. getNumber: function Lexer_getNumber() {
  12998. var ch = this.currentChar;
  12999. var eNotation = false;
  13000. var divideBy = 0;
  13001. var sign = 1;
  13002. if (ch === 0x2D) {
  13003. sign = -1;
  13004. ch = this.nextChar();
  13005. if (ch === 0x2D) {
  13006. ch = this.nextChar();
  13007. }
  13008. } else if (ch === 0x2B) {
  13009. ch = this.nextChar();
  13010. }
  13011. if (ch === 0x2E) {
  13012. divideBy = 10;
  13013. ch = this.nextChar();
  13014. }
  13015. if (ch < 0x30 || ch > 0x39) {
  13016. error('Invalid number: ' + String.fromCharCode(ch));
  13017. return 0;
  13018. }
  13019. var baseValue = ch - 0x30;
  13020. var powerValue = 0;
  13021. var powerValueSign = 1;
  13022. while ((ch = this.nextChar()) >= 0) {
  13023. if (0x30 <= ch && ch <= 0x39) {
  13024. var currentDigit = ch - 0x30;
  13025. if (eNotation) {
  13026. powerValue = powerValue * 10 + currentDigit;
  13027. } else {
  13028. if (divideBy !== 0) {
  13029. divideBy *= 10;
  13030. }
  13031. baseValue = baseValue * 10 + currentDigit;
  13032. }
  13033. } else if (ch === 0x2E) {
  13034. if (divideBy === 0) {
  13035. divideBy = 1;
  13036. } else {
  13037. break;
  13038. }
  13039. } else if (ch === 0x2D) {
  13040. warn('Badly formatted number');
  13041. } else if (ch === 0x45 || ch === 0x65) {
  13042. ch = this.peekChar();
  13043. if (ch === 0x2B || ch === 0x2D) {
  13044. powerValueSign = ch === 0x2D ? -1 : 1;
  13045. this.nextChar();
  13046. } else if (ch < 0x30 || ch > 0x39) {
  13047. break;
  13048. }
  13049. eNotation = true;
  13050. } else {
  13051. break;
  13052. }
  13053. }
  13054. if (divideBy !== 0) {
  13055. baseValue /= divideBy;
  13056. }
  13057. if (eNotation) {
  13058. baseValue *= Math.pow(10, powerValueSign * powerValue);
  13059. }
  13060. return sign * baseValue;
  13061. },
  13062. getString: function Lexer_getString() {
  13063. var numParen = 1;
  13064. var done = false;
  13065. var strBuf = this.strBuf;
  13066. strBuf.length = 0;
  13067. var ch = this.nextChar();
  13068. while (true) {
  13069. var charBuffered = false;
  13070. switch (ch | 0) {
  13071. case -1:
  13072. warn('Unterminated string');
  13073. done = true;
  13074. break;
  13075. case 0x28:
  13076. ++numParen;
  13077. strBuf.push('(');
  13078. break;
  13079. case 0x29:
  13080. if (--numParen === 0) {
  13081. this.nextChar();
  13082. done = true;
  13083. } else {
  13084. strBuf.push(')');
  13085. }
  13086. break;
  13087. case 0x5C:
  13088. ch = this.nextChar();
  13089. switch (ch) {
  13090. case -1:
  13091. warn('Unterminated string');
  13092. done = true;
  13093. break;
  13094. case 0x6E:
  13095. strBuf.push('\n');
  13096. break;
  13097. case 0x72:
  13098. strBuf.push('\r');
  13099. break;
  13100. case 0x74:
  13101. strBuf.push('\t');
  13102. break;
  13103. case 0x62:
  13104. strBuf.push('\b');
  13105. break;
  13106. case 0x66:
  13107. strBuf.push('\f');
  13108. break;
  13109. case 0x5C:
  13110. case 0x28:
  13111. case 0x29:
  13112. strBuf.push(String.fromCharCode(ch));
  13113. break;
  13114. case 0x30:
  13115. case 0x31:
  13116. case 0x32:
  13117. case 0x33:
  13118. case 0x34:
  13119. case 0x35:
  13120. case 0x36:
  13121. case 0x37:
  13122. var x = ch & 0x0F;
  13123. ch = this.nextChar();
  13124. charBuffered = true;
  13125. if (ch >= 0x30 && ch <= 0x37) {
  13126. x = (x << 3) + (ch & 0x0F);
  13127. ch = this.nextChar();
  13128. if (ch >= 0x30 && ch <= 0x37) {
  13129. charBuffered = false;
  13130. x = (x << 3) + (ch & 0x0F);
  13131. }
  13132. }
  13133. strBuf.push(String.fromCharCode(x));
  13134. break;
  13135. case 0x0D:
  13136. if (this.peekChar() === 0x0A) {
  13137. this.nextChar();
  13138. }
  13139. break;
  13140. case 0x0A:
  13141. break;
  13142. default:
  13143. strBuf.push(String.fromCharCode(ch));
  13144. break;
  13145. }
  13146. break;
  13147. default:
  13148. strBuf.push(String.fromCharCode(ch));
  13149. break;
  13150. }
  13151. if (done) {
  13152. break;
  13153. }
  13154. if (!charBuffered) {
  13155. ch = this.nextChar();
  13156. }
  13157. }
  13158. return strBuf.join('');
  13159. },
  13160. getName: function Lexer_getName() {
  13161. var ch, previousCh;
  13162. var strBuf = this.strBuf;
  13163. strBuf.length = 0;
  13164. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  13165. if (ch === 0x23) {
  13166. ch = this.nextChar();
  13167. if (specialChars[ch]) {
  13168. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  13169. strBuf.push('#');
  13170. break;
  13171. }
  13172. var x = toHexDigit(ch);
  13173. if (x !== -1) {
  13174. previousCh = ch;
  13175. ch = this.nextChar();
  13176. var x2 = toHexDigit(ch);
  13177. if (x2 === -1) {
  13178. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  13179. strBuf.push('#', String.fromCharCode(previousCh));
  13180. if (specialChars[ch]) {
  13181. break;
  13182. }
  13183. strBuf.push(String.fromCharCode(ch));
  13184. continue;
  13185. }
  13186. strBuf.push(String.fromCharCode(x << 4 | x2));
  13187. } else {
  13188. strBuf.push('#', String.fromCharCode(ch));
  13189. }
  13190. } else {
  13191. strBuf.push(String.fromCharCode(ch));
  13192. }
  13193. }
  13194. if (strBuf.length > 127) {
  13195. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  13196. }
  13197. return Name.get(strBuf.join(''));
  13198. },
  13199. getHexString: function Lexer_getHexString() {
  13200. var strBuf = this.strBuf;
  13201. strBuf.length = 0;
  13202. var ch = this.currentChar;
  13203. var isFirstHex = true;
  13204. var firstDigit;
  13205. var secondDigit;
  13206. while (true) {
  13207. if (ch < 0) {
  13208. warn('Unterminated hex string');
  13209. break;
  13210. } else if (ch === 0x3E) {
  13211. this.nextChar();
  13212. break;
  13213. } else if (specialChars[ch] === 1) {
  13214. ch = this.nextChar();
  13215. continue;
  13216. } else {
  13217. if (isFirstHex) {
  13218. firstDigit = toHexDigit(ch);
  13219. if (firstDigit === -1) {
  13220. warn('Ignoring invalid character "' + ch + '" in hex string');
  13221. ch = this.nextChar();
  13222. continue;
  13223. }
  13224. } else {
  13225. secondDigit = toHexDigit(ch);
  13226. if (secondDigit === -1) {
  13227. warn('Ignoring invalid character "' + ch + '" in hex string');
  13228. ch = this.nextChar();
  13229. continue;
  13230. }
  13231. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  13232. }
  13233. isFirstHex = !isFirstHex;
  13234. ch = this.nextChar();
  13235. }
  13236. }
  13237. return strBuf.join('');
  13238. },
  13239. getObj: function Lexer_getObj() {
  13240. var comment = false;
  13241. var ch = this.currentChar;
  13242. while (true) {
  13243. if (ch < 0) {
  13244. return EOF;
  13245. }
  13246. if (comment) {
  13247. if (ch === 0x0A || ch === 0x0D) {
  13248. comment = false;
  13249. }
  13250. } else if (ch === 0x25) {
  13251. comment = true;
  13252. } else if (specialChars[ch] !== 1) {
  13253. break;
  13254. }
  13255. ch = this.nextChar();
  13256. }
  13257. switch (ch | 0) {
  13258. case 0x30:
  13259. case 0x31:
  13260. case 0x32:
  13261. case 0x33:
  13262. case 0x34:
  13263. case 0x35:
  13264. case 0x36:
  13265. case 0x37:
  13266. case 0x38:
  13267. case 0x39:
  13268. case 0x2B:
  13269. case 0x2D:
  13270. case 0x2E:
  13271. return this.getNumber();
  13272. case 0x28:
  13273. return this.getString();
  13274. case 0x2F:
  13275. return this.getName();
  13276. case 0x5B:
  13277. this.nextChar();
  13278. return Cmd.get('[');
  13279. case 0x5D:
  13280. this.nextChar();
  13281. return Cmd.get(']');
  13282. case 0x3C:
  13283. ch = this.nextChar();
  13284. if (ch === 0x3C) {
  13285. this.nextChar();
  13286. return Cmd.get('<<');
  13287. }
  13288. return this.getHexString();
  13289. case 0x3E:
  13290. ch = this.nextChar();
  13291. if (ch === 0x3E) {
  13292. this.nextChar();
  13293. return Cmd.get('>>');
  13294. }
  13295. return Cmd.get('>');
  13296. case 0x7B:
  13297. this.nextChar();
  13298. return Cmd.get('{');
  13299. case 0x7D:
  13300. this.nextChar();
  13301. return Cmd.get('}');
  13302. case 0x29:
  13303. this.nextChar();
  13304. error('Illegal character: ' + ch);
  13305. break;
  13306. }
  13307. var str = String.fromCharCode(ch);
  13308. var knownCommands = this.knownCommands;
  13309. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  13310. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  13311. var possibleCommand = str + String.fromCharCode(ch);
  13312. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  13313. break;
  13314. }
  13315. if (str.length === 128) {
  13316. error('Command token too long: ' + str.length);
  13317. }
  13318. str = possibleCommand;
  13319. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  13320. }
  13321. if (str === 'true') {
  13322. return true;
  13323. }
  13324. if (str === 'false') {
  13325. return false;
  13326. }
  13327. if (str === 'null') {
  13328. return null;
  13329. }
  13330. return Cmd.get(str);
  13331. },
  13332. skipToNextLine: function Lexer_skipToNextLine() {
  13333. var ch = this.currentChar;
  13334. while (ch >= 0) {
  13335. if (ch === 0x0D) {
  13336. ch = this.nextChar();
  13337. if (ch === 0x0A) {
  13338. this.nextChar();
  13339. }
  13340. break;
  13341. } else if (ch === 0x0A) {
  13342. this.nextChar();
  13343. break;
  13344. }
  13345. ch = this.nextChar();
  13346. }
  13347. }
  13348. };
  13349. return Lexer;
  13350. }();
  13351. var Linearization = {
  13352. create: function LinearizationCreate(stream) {
  13353. function getInt(name, allowZeroValue) {
  13354. var obj = linDict.get(name);
  13355. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  13356. return obj;
  13357. }
  13358. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  13359. }
  13360. function getHints() {
  13361. var hints = linDict.get('H'), hintsLength, item;
  13362. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  13363. for (var index = 0; index < hintsLength; index++) {
  13364. if (!(isInt(item = hints[index]) && item > 0)) {
  13365. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  13366. }
  13367. }
  13368. return hints;
  13369. }
  13370. throw new Error('Hint array in the linearization dictionary is invalid.');
  13371. }
  13372. var parser = new Parser(new Lexer(stream), false, null);
  13373. var obj1 = parser.getObj();
  13374. var obj2 = parser.getObj();
  13375. var obj3 = parser.getObj();
  13376. var linDict = parser.getObj();
  13377. var obj, length;
  13378. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  13379. return null;
  13380. } else if ((length = getInt('L')) !== stream.length) {
  13381. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  13382. }
  13383. return {
  13384. length: length,
  13385. hints: getHints(),
  13386. objectNumberFirst: getInt('O'),
  13387. endFirst: getInt('E'),
  13388. numPages: getInt('N'),
  13389. mainXRefEntriesOffset: getInt('T'),
  13390. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  13391. };
  13392. }
  13393. };
  13394. exports.Lexer = Lexer;
  13395. exports.Linearization = Linearization;
  13396. exports.Parser = Parser;
  13397. /***/ }),
  13398. /* 7 */
  13399. /***/ (function(module, exports, __w_pdfjs_require__) {
  13400. "use strict";
  13401. var sharedUtil = __w_pdfjs_require__(0);
  13402. var corePrimitives = __w_pdfjs_require__(1);
  13403. var corePsParser = __w_pdfjs_require__(42);
  13404. var error = sharedUtil.error;
  13405. var info = sharedUtil.info;
  13406. var isArray = sharedUtil.isArray;
  13407. var isBool = sharedUtil.isBool;
  13408. var isDict = corePrimitives.isDict;
  13409. var isStream = corePrimitives.isStream;
  13410. var PostScriptLexer = corePsParser.PostScriptLexer;
  13411. var PostScriptParser = corePsParser.PostScriptParser;
  13412. var PDFFunction = function PDFFunctionClosure() {
  13413. var CONSTRUCT_SAMPLED = 0;
  13414. var CONSTRUCT_INTERPOLATED = 2;
  13415. var CONSTRUCT_STICHED = 3;
  13416. var CONSTRUCT_POSTSCRIPT = 4;
  13417. return {
  13418. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  13419. var i, ii;
  13420. var length = 1;
  13421. for (i = 0, ii = size.length; i < ii; i++) {
  13422. length *= size[i];
  13423. }
  13424. length *= outputSize;
  13425. var array = new Array(length);
  13426. var codeSize = 0;
  13427. var codeBuf = 0;
  13428. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  13429. var strBytes = str.getBytes((length * bps + 7) / 8);
  13430. var strIdx = 0;
  13431. for (i = 0; i < length; i++) {
  13432. while (codeSize < bps) {
  13433. codeBuf <<= 8;
  13434. codeBuf |= strBytes[strIdx++];
  13435. codeSize += 8;
  13436. }
  13437. codeSize -= bps;
  13438. array[i] = (codeBuf >> codeSize) * sampleMul;
  13439. codeBuf &= (1 << codeSize) - 1;
  13440. }
  13441. return array;
  13442. },
  13443. getIR: function PDFFunction_getIR(xref, fn) {
  13444. var dict = fn.dict;
  13445. if (!dict) {
  13446. dict = fn;
  13447. }
  13448. var types = [
  13449. this.constructSampled,
  13450. null,
  13451. this.constructInterpolated,
  13452. this.constructStiched,
  13453. this.constructPostScript
  13454. ];
  13455. var typeNum = dict.get('FunctionType');
  13456. var typeFn = types[typeNum];
  13457. if (!typeFn) {
  13458. error('Unknown type of function');
  13459. }
  13460. return typeFn.call(this, fn, dict, xref);
  13461. },
  13462. fromIR: function PDFFunction_fromIR(IR) {
  13463. var type = IR[0];
  13464. switch (type) {
  13465. case CONSTRUCT_SAMPLED:
  13466. return this.constructSampledFromIR(IR);
  13467. case CONSTRUCT_INTERPOLATED:
  13468. return this.constructInterpolatedFromIR(IR);
  13469. case CONSTRUCT_STICHED:
  13470. return this.constructStichedFromIR(IR);
  13471. default:
  13472. return this.constructPostScriptFromIR(IR);
  13473. }
  13474. },
  13475. parse: function PDFFunction_parse(xref, fn) {
  13476. var IR = this.getIR(xref, fn);
  13477. return this.fromIR(IR);
  13478. },
  13479. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  13480. if (!isArray(fnObj)) {
  13481. return this.parse(xref, fnObj);
  13482. }
  13483. var fnArray = [];
  13484. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  13485. var obj = xref.fetchIfRef(fnObj[j]);
  13486. fnArray.push(PDFFunction.parse(xref, obj));
  13487. }
  13488. return function (src, srcOffset, dest, destOffset) {
  13489. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  13490. fnArray[i](src, srcOffset, dest, destOffset + i);
  13491. }
  13492. };
  13493. },
  13494. constructSampled: function PDFFunction_constructSampled(str, dict) {
  13495. function toMultiArray(arr) {
  13496. var inputLength = arr.length;
  13497. var out = [];
  13498. var index = 0;
  13499. for (var i = 0; i < inputLength; i += 2) {
  13500. out[index] = [
  13501. arr[i],
  13502. arr[i + 1]
  13503. ];
  13504. ++index;
  13505. }
  13506. return out;
  13507. }
  13508. var domain = dict.getArray('Domain');
  13509. var range = dict.getArray('Range');
  13510. if (!domain || !range) {
  13511. error('No domain or range');
  13512. }
  13513. var inputSize = domain.length / 2;
  13514. var outputSize = range.length / 2;
  13515. domain = toMultiArray(domain);
  13516. range = toMultiArray(range);
  13517. var size = dict.get('Size');
  13518. var bps = dict.get('BitsPerSample');
  13519. var order = dict.get('Order') || 1;
  13520. if (order !== 1) {
  13521. info('No support for cubic spline interpolation: ' + order);
  13522. }
  13523. var encode = dict.getArray('Encode');
  13524. if (!encode) {
  13525. encode = [];
  13526. for (var i = 0; i < inputSize; ++i) {
  13527. encode.push(0);
  13528. encode.push(size[i] - 1);
  13529. }
  13530. }
  13531. encode = toMultiArray(encode);
  13532. var decode = dict.getArray('Decode');
  13533. if (!decode) {
  13534. decode = range;
  13535. } else {
  13536. decode = toMultiArray(decode);
  13537. }
  13538. var samples = this.getSampleArray(size, outputSize, bps, str);
  13539. return [
  13540. CONSTRUCT_SAMPLED,
  13541. inputSize,
  13542. domain,
  13543. encode,
  13544. decode,
  13545. samples,
  13546. size,
  13547. outputSize,
  13548. Math.pow(2, bps) - 1,
  13549. range
  13550. ];
  13551. },
  13552. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  13553. function interpolate(x, xmin, xmax, ymin, ymax) {
  13554. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  13555. }
  13556. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  13557. var m = IR[1];
  13558. var domain = IR[2];
  13559. var encode = IR[3];
  13560. var decode = IR[4];
  13561. var samples = IR[5];
  13562. var size = IR[6];
  13563. var n = IR[7];
  13564. var range = IR[9];
  13565. var cubeVertices = 1 << m;
  13566. var cubeN = new Float64Array(cubeVertices);
  13567. var cubeVertex = new Uint32Array(cubeVertices);
  13568. var i, j;
  13569. for (j = 0; j < cubeVertices; j++) {
  13570. cubeN[j] = 1;
  13571. }
  13572. var k = n, pos = 1;
  13573. for (i = 0; i < m; ++i) {
  13574. var domain_2i = domain[i][0];
  13575. var domain_2i_1 = domain[i][1];
  13576. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  13577. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  13578. var size_i = size[i];
  13579. e = Math.min(Math.max(e, 0), size_i - 1);
  13580. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  13581. var n0 = e0 + 1 - e;
  13582. var n1 = e - e0;
  13583. var offset0 = e0 * k;
  13584. var offset1 = offset0 + k;
  13585. for (j = 0; j < cubeVertices; j++) {
  13586. if (j & pos) {
  13587. cubeN[j] *= n1;
  13588. cubeVertex[j] += offset1;
  13589. } else {
  13590. cubeN[j] *= n0;
  13591. cubeVertex[j] += offset0;
  13592. }
  13593. }
  13594. k *= size_i;
  13595. pos <<= 1;
  13596. }
  13597. for (j = 0; j < n; ++j) {
  13598. var rj = 0;
  13599. for (i = 0; i < cubeVertices; i++) {
  13600. rj += samples[cubeVertex[i] + j] * cubeN[i];
  13601. }
  13602. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  13603. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  13604. }
  13605. };
  13606. },
  13607. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  13608. var c0 = dict.getArray('C0') || [0];
  13609. var c1 = dict.getArray('C1') || [1];
  13610. var n = dict.get('N');
  13611. if (!isArray(c0) || !isArray(c1)) {
  13612. error('Illegal dictionary for interpolated function');
  13613. }
  13614. var length = c0.length;
  13615. var diff = [];
  13616. for (var i = 0; i < length; ++i) {
  13617. diff.push(c1[i] - c0[i]);
  13618. }
  13619. return [
  13620. CONSTRUCT_INTERPOLATED,
  13621. c0,
  13622. diff,
  13623. n
  13624. ];
  13625. },
  13626. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  13627. var c0 = IR[1];
  13628. var diff = IR[2];
  13629. var n = IR[3];
  13630. var length = diff.length;
  13631. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  13632. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  13633. for (var j = 0; j < length; ++j) {
  13634. dest[destOffset + j] = c0[j] + x * diff[j];
  13635. }
  13636. };
  13637. },
  13638. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  13639. var domain = dict.getArray('Domain');
  13640. if (!domain) {
  13641. error('No domain');
  13642. }
  13643. var inputSize = domain.length / 2;
  13644. if (inputSize !== 1) {
  13645. error('Bad domain for stiched function');
  13646. }
  13647. var fnRefs = dict.get('Functions');
  13648. var fns = [];
  13649. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  13650. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  13651. }
  13652. var bounds = dict.getArray('Bounds');
  13653. var encode = dict.getArray('Encode');
  13654. return [
  13655. CONSTRUCT_STICHED,
  13656. domain,
  13657. bounds,
  13658. encode,
  13659. fns
  13660. ];
  13661. },
  13662. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  13663. var domain = IR[1];
  13664. var bounds = IR[2];
  13665. var encode = IR[3];
  13666. var fnsIR = IR[4];
  13667. var fns = [];
  13668. var tmpBuf = new Float32Array(1);
  13669. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  13670. fns.push(PDFFunction.fromIR(fnsIR[i]));
  13671. }
  13672. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  13673. var clip = function constructStichedFromIRClip(v, min, max) {
  13674. if (v > max) {
  13675. v = max;
  13676. } else if (v < min) {
  13677. v = min;
  13678. }
  13679. return v;
  13680. };
  13681. var v = clip(src[srcOffset], domain[0], domain[1]);
  13682. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  13683. if (v < bounds[i]) {
  13684. break;
  13685. }
  13686. }
  13687. var dmin = domain[0];
  13688. if (i > 0) {
  13689. dmin = bounds[i - 1];
  13690. }
  13691. var dmax = domain[1];
  13692. if (i < bounds.length) {
  13693. dmax = bounds[i];
  13694. }
  13695. var rmin = encode[2 * i];
  13696. var rmax = encode[2 * i + 1];
  13697. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  13698. fns[i](tmpBuf, 0, dest, destOffset);
  13699. };
  13700. },
  13701. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  13702. var domain = dict.getArray('Domain');
  13703. var range = dict.getArray('Range');
  13704. if (!domain) {
  13705. error('No domain.');
  13706. }
  13707. if (!range) {
  13708. error('No range.');
  13709. }
  13710. var lexer = new PostScriptLexer(fn);
  13711. var parser = new PostScriptParser(lexer);
  13712. var code = parser.parse();
  13713. return [
  13714. CONSTRUCT_POSTSCRIPT,
  13715. domain,
  13716. range,
  13717. code
  13718. ];
  13719. },
  13720. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  13721. var domain = IR[1];
  13722. var range = IR[2];
  13723. var code = IR[3];
  13724. var compiled = new PostScriptCompiler().compile(code, domain, range);
  13725. if (compiled) {
  13726. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  13727. }
  13728. info('Unable to compile PS function');
  13729. var numOutputs = range.length >> 1;
  13730. var numInputs = domain.length >> 1;
  13731. var evaluator = new PostScriptEvaluator(code);
  13732. var cache = Object.create(null);
  13733. var MAX_CACHE_SIZE = 2048 * 4;
  13734. var cache_available = MAX_CACHE_SIZE;
  13735. var tmpBuf = new Float32Array(numInputs);
  13736. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  13737. var i, value;
  13738. var key = '';
  13739. var input = tmpBuf;
  13740. for (i = 0; i < numInputs; i++) {
  13741. value = src[srcOffset + i];
  13742. input[i] = value;
  13743. key += value + '_';
  13744. }
  13745. var cachedValue = cache[key];
  13746. if (cachedValue !== undefined) {
  13747. dest.set(cachedValue, destOffset);
  13748. return;
  13749. }
  13750. var output = new Float32Array(numOutputs);
  13751. var stack = evaluator.execute(input);
  13752. var stackIndex = stack.length - numOutputs;
  13753. for (i = 0; i < numOutputs; i++) {
  13754. value = stack[stackIndex + i];
  13755. var bound = range[i * 2];
  13756. if (value < bound) {
  13757. value = bound;
  13758. } else {
  13759. bound = range[i * 2 + 1];
  13760. if (value > bound) {
  13761. value = bound;
  13762. }
  13763. }
  13764. output[i] = value;
  13765. }
  13766. if (cache_available > 0) {
  13767. cache_available--;
  13768. cache[key] = output;
  13769. }
  13770. dest.set(output, destOffset);
  13771. };
  13772. }
  13773. };
  13774. }();
  13775. function isPDFFunction(v) {
  13776. var fnDict;
  13777. if (typeof v !== 'object') {
  13778. return false;
  13779. } else if (isDict(v)) {
  13780. fnDict = v;
  13781. } else if (isStream(v)) {
  13782. fnDict = v.dict;
  13783. } else {
  13784. return false;
  13785. }
  13786. return fnDict.has('FunctionType');
  13787. }
  13788. var PostScriptStack = function PostScriptStackClosure() {
  13789. var MAX_STACK_SIZE = 100;
  13790. function PostScriptStack(initialStack) {
  13791. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  13792. }
  13793. PostScriptStack.prototype = {
  13794. push: function PostScriptStack_push(value) {
  13795. if (this.stack.length >= MAX_STACK_SIZE) {
  13796. error('PostScript function stack overflow.');
  13797. }
  13798. this.stack.push(value);
  13799. },
  13800. pop: function PostScriptStack_pop() {
  13801. if (this.stack.length <= 0) {
  13802. error('PostScript function stack underflow.');
  13803. }
  13804. return this.stack.pop();
  13805. },
  13806. copy: function PostScriptStack_copy(n) {
  13807. if (this.stack.length + n >= MAX_STACK_SIZE) {
  13808. error('PostScript function stack overflow.');
  13809. }
  13810. var stack = this.stack;
  13811. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  13812. stack.push(stack[i]);
  13813. }
  13814. },
  13815. index: function PostScriptStack_index(n) {
  13816. this.push(this.stack[this.stack.length - n - 1]);
  13817. },
  13818. roll: function PostScriptStack_roll(n, p) {
  13819. var stack = this.stack;
  13820. var l = stack.length - n;
  13821. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  13822. for (i = l, j = r; i < j; i++, j--) {
  13823. t = stack[i];
  13824. stack[i] = stack[j];
  13825. stack[j] = t;
  13826. }
  13827. for (i = l, j = c - 1; i < j; i++, j--) {
  13828. t = stack[i];
  13829. stack[i] = stack[j];
  13830. stack[j] = t;
  13831. }
  13832. for (i = c, j = r; i < j; i++, j--) {
  13833. t = stack[i];
  13834. stack[i] = stack[j];
  13835. stack[j] = t;
  13836. }
  13837. }
  13838. };
  13839. return PostScriptStack;
  13840. }();
  13841. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  13842. function PostScriptEvaluator(operators) {
  13843. this.operators = operators;
  13844. }
  13845. PostScriptEvaluator.prototype = {
  13846. execute: function PostScriptEvaluator_execute(initialStack) {
  13847. var stack = new PostScriptStack(initialStack);
  13848. var counter = 0;
  13849. var operators = this.operators;
  13850. var length = operators.length;
  13851. var operator, a, b;
  13852. while (counter < length) {
  13853. operator = operators[counter++];
  13854. if (typeof operator === 'number') {
  13855. stack.push(operator);
  13856. continue;
  13857. }
  13858. switch (operator) {
  13859. case 'jz':
  13860. b = stack.pop();
  13861. a = stack.pop();
  13862. if (!a) {
  13863. counter = b;
  13864. }
  13865. break;
  13866. case 'j':
  13867. a = stack.pop();
  13868. counter = a;
  13869. break;
  13870. case 'abs':
  13871. a = stack.pop();
  13872. stack.push(Math.abs(a));
  13873. break;
  13874. case 'add':
  13875. b = stack.pop();
  13876. a = stack.pop();
  13877. stack.push(a + b);
  13878. break;
  13879. case 'and':
  13880. b = stack.pop();
  13881. a = stack.pop();
  13882. if (isBool(a) && isBool(b)) {
  13883. stack.push(a && b);
  13884. } else {
  13885. stack.push(a & b);
  13886. }
  13887. break;
  13888. case 'atan':
  13889. a = stack.pop();
  13890. stack.push(Math.atan(a));
  13891. break;
  13892. case 'bitshift':
  13893. b = stack.pop();
  13894. a = stack.pop();
  13895. if (a > 0) {
  13896. stack.push(a << b);
  13897. } else {
  13898. stack.push(a >> b);
  13899. }
  13900. break;
  13901. case 'ceiling':
  13902. a = stack.pop();
  13903. stack.push(Math.ceil(a));
  13904. break;
  13905. case 'copy':
  13906. a = stack.pop();
  13907. stack.copy(a);
  13908. break;
  13909. case 'cos':
  13910. a = stack.pop();
  13911. stack.push(Math.cos(a));
  13912. break;
  13913. case 'cvi':
  13914. a = stack.pop() | 0;
  13915. stack.push(a);
  13916. break;
  13917. case 'cvr':
  13918. break;
  13919. case 'div':
  13920. b = stack.pop();
  13921. a = stack.pop();
  13922. stack.push(a / b);
  13923. break;
  13924. case 'dup':
  13925. stack.copy(1);
  13926. break;
  13927. case 'eq':
  13928. b = stack.pop();
  13929. a = stack.pop();
  13930. stack.push(a === b);
  13931. break;
  13932. case 'exch':
  13933. stack.roll(2, 1);
  13934. break;
  13935. case 'exp':
  13936. b = stack.pop();
  13937. a = stack.pop();
  13938. stack.push(Math.pow(a, b));
  13939. break;
  13940. case 'false':
  13941. stack.push(false);
  13942. break;
  13943. case 'floor':
  13944. a = stack.pop();
  13945. stack.push(Math.floor(a));
  13946. break;
  13947. case 'ge':
  13948. b = stack.pop();
  13949. a = stack.pop();
  13950. stack.push(a >= b);
  13951. break;
  13952. case 'gt':
  13953. b = stack.pop();
  13954. a = stack.pop();
  13955. stack.push(a > b);
  13956. break;
  13957. case 'idiv':
  13958. b = stack.pop();
  13959. a = stack.pop();
  13960. stack.push(a / b | 0);
  13961. break;
  13962. case 'index':
  13963. a = stack.pop();
  13964. stack.index(a);
  13965. break;
  13966. case 'le':
  13967. b = stack.pop();
  13968. a = stack.pop();
  13969. stack.push(a <= b);
  13970. break;
  13971. case 'ln':
  13972. a = stack.pop();
  13973. stack.push(Math.log(a));
  13974. break;
  13975. case 'log':
  13976. a = stack.pop();
  13977. stack.push(Math.log(a) / Math.LN10);
  13978. break;
  13979. case 'lt':
  13980. b = stack.pop();
  13981. a = stack.pop();
  13982. stack.push(a < b);
  13983. break;
  13984. case 'mod':
  13985. b = stack.pop();
  13986. a = stack.pop();
  13987. stack.push(a % b);
  13988. break;
  13989. case 'mul':
  13990. b = stack.pop();
  13991. a = stack.pop();
  13992. stack.push(a * b);
  13993. break;
  13994. case 'ne':
  13995. b = stack.pop();
  13996. a = stack.pop();
  13997. stack.push(a !== b);
  13998. break;
  13999. case 'neg':
  14000. a = stack.pop();
  14001. stack.push(-a);
  14002. break;
  14003. case 'not':
  14004. a = stack.pop();
  14005. if (isBool(a)) {
  14006. stack.push(!a);
  14007. } else {
  14008. stack.push(~a);
  14009. }
  14010. break;
  14011. case 'or':
  14012. b = stack.pop();
  14013. a = stack.pop();
  14014. if (isBool(a) && isBool(b)) {
  14015. stack.push(a || b);
  14016. } else {
  14017. stack.push(a | b);
  14018. }
  14019. break;
  14020. case 'pop':
  14021. stack.pop();
  14022. break;
  14023. case 'roll':
  14024. b = stack.pop();
  14025. a = stack.pop();
  14026. stack.roll(a, b);
  14027. break;
  14028. case 'round':
  14029. a = stack.pop();
  14030. stack.push(Math.round(a));
  14031. break;
  14032. case 'sin':
  14033. a = stack.pop();
  14034. stack.push(Math.sin(a));
  14035. break;
  14036. case 'sqrt':
  14037. a = stack.pop();
  14038. stack.push(Math.sqrt(a));
  14039. break;
  14040. case 'sub':
  14041. b = stack.pop();
  14042. a = stack.pop();
  14043. stack.push(a - b);
  14044. break;
  14045. case 'true':
  14046. stack.push(true);
  14047. break;
  14048. case 'truncate':
  14049. a = stack.pop();
  14050. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  14051. stack.push(a);
  14052. break;
  14053. case 'xor':
  14054. b = stack.pop();
  14055. a = stack.pop();
  14056. if (isBool(a) && isBool(b)) {
  14057. stack.push(a !== b);
  14058. } else {
  14059. stack.push(a ^ b);
  14060. }
  14061. break;
  14062. default:
  14063. error('Unknown operator ' + operator);
  14064. break;
  14065. }
  14066. }
  14067. return stack.stack;
  14068. }
  14069. };
  14070. return PostScriptEvaluator;
  14071. }();
  14072. var PostScriptCompiler = function PostScriptCompilerClosure() {
  14073. function AstNode(type) {
  14074. this.type = type;
  14075. }
  14076. AstNode.prototype.visit = function (visitor) {
  14077. throw new Error('abstract method');
  14078. };
  14079. function AstArgument(index, min, max) {
  14080. AstNode.call(this, 'args');
  14081. this.index = index;
  14082. this.min = min;
  14083. this.max = max;
  14084. }
  14085. AstArgument.prototype = Object.create(AstNode.prototype);
  14086. AstArgument.prototype.visit = function (visitor) {
  14087. visitor.visitArgument(this);
  14088. };
  14089. function AstLiteral(number) {
  14090. AstNode.call(this, 'literal');
  14091. this.number = number;
  14092. this.min = number;
  14093. this.max = number;
  14094. }
  14095. AstLiteral.prototype = Object.create(AstNode.prototype);
  14096. AstLiteral.prototype.visit = function (visitor) {
  14097. visitor.visitLiteral(this);
  14098. };
  14099. function AstBinaryOperation(op, arg1, arg2, min, max) {
  14100. AstNode.call(this, 'binary');
  14101. this.op = op;
  14102. this.arg1 = arg1;
  14103. this.arg2 = arg2;
  14104. this.min = min;
  14105. this.max = max;
  14106. }
  14107. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  14108. AstBinaryOperation.prototype.visit = function (visitor) {
  14109. visitor.visitBinaryOperation(this);
  14110. };
  14111. function AstMin(arg, max) {
  14112. AstNode.call(this, 'max');
  14113. this.arg = arg;
  14114. this.min = arg.min;
  14115. this.max = max;
  14116. }
  14117. AstMin.prototype = Object.create(AstNode.prototype);
  14118. AstMin.prototype.visit = function (visitor) {
  14119. visitor.visitMin(this);
  14120. };
  14121. function AstVariable(index, min, max) {
  14122. AstNode.call(this, 'var');
  14123. this.index = index;
  14124. this.min = min;
  14125. this.max = max;
  14126. }
  14127. AstVariable.prototype = Object.create(AstNode.prototype);
  14128. AstVariable.prototype.visit = function (visitor) {
  14129. visitor.visitVariable(this);
  14130. };
  14131. function AstVariableDefinition(variable, arg) {
  14132. AstNode.call(this, 'definition');
  14133. this.variable = variable;
  14134. this.arg = arg;
  14135. }
  14136. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  14137. AstVariableDefinition.prototype.visit = function (visitor) {
  14138. visitor.visitVariableDefinition(this);
  14139. };
  14140. function ExpressionBuilderVisitor() {
  14141. this.parts = [];
  14142. }
  14143. ExpressionBuilderVisitor.prototype = {
  14144. visitArgument: function (arg) {
  14145. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  14146. },
  14147. visitVariable: function (variable) {
  14148. this.parts.push('v', variable.index);
  14149. },
  14150. visitLiteral: function (literal) {
  14151. this.parts.push(literal.number);
  14152. },
  14153. visitBinaryOperation: function (operation) {
  14154. this.parts.push('(');
  14155. operation.arg1.visit(this);
  14156. this.parts.push(' ', operation.op, ' ');
  14157. operation.arg2.visit(this);
  14158. this.parts.push(')');
  14159. },
  14160. visitVariableDefinition: function (definition) {
  14161. this.parts.push('var ');
  14162. definition.variable.visit(this);
  14163. this.parts.push(' = ');
  14164. definition.arg.visit(this);
  14165. this.parts.push(';');
  14166. },
  14167. visitMin: function (max) {
  14168. this.parts.push('Math.min(');
  14169. max.arg.visit(this);
  14170. this.parts.push(', ', max.max, ')');
  14171. },
  14172. toString: function () {
  14173. return this.parts.join('');
  14174. }
  14175. };
  14176. function buildAddOperation(num1, num2) {
  14177. if (num2.type === 'literal' && num2.number === 0) {
  14178. return num1;
  14179. }
  14180. if (num1.type === 'literal' && num1.number === 0) {
  14181. return num2;
  14182. }
  14183. if (num2.type === 'literal' && num1.type === 'literal') {
  14184. return new AstLiteral(num1.number + num2.number);
  14185. }
  14186. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  14187. }
  14188. function buildMulOperation(num1, num2) {
  14189. if (num2.type === 'literal') {
  14190. if (num2.number === 0) {
  14191. return new AstLiteral(0);
  14192. } else if (num2.number === 1) {
  14193. return num1;
  14194. } else if (num1.type === 'literal') {
  14195. return new AstLiteral(num1.number * num2.number);
  14196. }
  14197. }
  14198. if (num1.type === 'literal') {
  14199. if (num1.number === 0) {
  14200. return new AstLiteral(0);
  14201. } else if (num1.number === 1) {
  14202. return num2;
  14203. }
  14204. }
  14205. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  14206. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  14207. return new AstBinaryOperation('*', num1, num2, min, max);
  14208. }
  14209. function buildSubOperation(num1, num2) {
  14210. if (num2.type === 'literal') {
  14211. if (num2.number === 0) {
  14212. return num1;
  14213. } else if (num1.type === 'literal') {
  14214. return new AstLiteral(num1.number - num2.number);
  14215. }
  14216. }
  14217. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  14218. return num2.arg2;
  14219. }
  14220. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  14221. }
  14222. function buildMinOperation(num1, max) {
  14223. if (num1.min >= max) {
  14224. return new AstLiteral(max);
  14225. } else if (num1.max <= max) {
  14226. return num1;
  14227. }
  14228. return new AstMin(num1, max);
  14229. }
  14230. function PostScriptCompiler() {
  14231. }
  14232. PostScriptCompiler.prototype = {
  14233. compile: function PostScriptCompiler_compile(code, domain, range) {
  14234. var stack = [];
  14235. var i, ii;
  14236. var instructions = [];
  14237. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  14238. var lastRegister = 0;
  14239. var n, j;
  14240. var num1, num2, ast1, ast2, tmpVar, item;
  14241. for (i = 0; i < inputSize; i++) {
  14242. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  14243. }
  14244. for (i = 0, ii = code.length; i < ii; i++) {
  14245. item = code[i];
  14246. if (typeof item === 'number') {
  14247. stack.push(new AstLiteral(item));
  14248. continue;
  14249. }
  14250. switch (item) {
  14251. case 'add':
  14252. if (stack.length < 2) {
  14253. return null;
  14254. }
  14255. num2 = stack.pop();
  14256. num1 = stack.pop();
  14257. stack.push(buildAddOperation(num1, num2));
  14258. break;
  14259. case 'cvr':
  14260. if (stack.length < 1) {
  14261. return null;
  14262. }
  14263. break;
  14264. case 'mul':
  14265. if (stack.length < 2) {
  14266. return null;
  14267. }
  14268. num2 = stack.pop();
  14269. num1 = stack.pop();
  14270. stack.push(buildMulOperation(num1, num2));
  14271. break;
  14272. case 'sub':
  14273. if (stack.length < 2) {
  14274. return null;
  14275. }
  14276. num2 = stack.pop();
  14277. num1 = stack.pop();
  14278. stack.push(buildSubOperation(num1, num2));
  14279. break;
  14280. case 'exch':
  14281. if (stack.length < 2) {
  14282. return null;
  14283. }
  14284. ast1 = stack.pop();
  14285. ast2 = stack.pop();
  14286. stack.push(ast1, ast2);
  14287. break;
  14288. case 'pop':
  14289. if (stack.length < 1) {
  14290. return null;
  14291. }
  14292. stack.pop();
  14293. break;
  14294. case 'index':
  14295. if (stack.length < 1) {
  14296. return null;
  14297. }
  14298. num1 = stack.pop();
  14299. if (num1.type !== 'literal') {
  14300. return null;
  14301. }
  14302. n = num1.number;
  14303. if (n < 0 || (n | 0) !== n || stack.length < n) {
  14304. return null;
  14305. }
  14306. ast1 = stack[stack.length - n - 1];
  14307. if (ast1.type === 'literal' || ast1.type === 'var') {
  14308. stack.push(ast1);
  14309. break;
  14310. }
  14311. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  14312. stack[stack.length - n - 1] = tmpVar;
  14313. stack.push(tmpVar);
  14314. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  14315. break;
  14316. case 'dup':
  14317. if (stack.length < 1) {
  14318. return null;
  14319. }
  14320. 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]) {
  14321. num1 = stack.pop();
  14322. stack.push(buildMinOperation(num1, code[i + 1]));
  14323. i += 6;
  14324. break;
  14325. }
  14326. ast1 = stack[stack.length - 1];
  14327. if (ast1.type === 'literal' || ast1.type === 'var') {
  14328. stack.push(ast1);
  14329. break;
  14330. }
  14331. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  14332. stack[stack.length - 1] = tmpVar;
  14333. stack.push(tmpVar);
  14334. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  14335. break;
  14336. case 'roll':
  14337. if (stack.length < 2) {
  14338. return null;
  14339. }
  14340. num2 = stack.pop();
  14341. num1 = stack.pop();
  14342. if (num2.type !== 'literal' || num1.type !== 'literal') {
  14343. return null;
  14344. }
  14345. j = num2.number;
  14346. n = num1.number;
  14347. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  14348. return null;
  14349. }
  14350. j = (j % n + n) % n;
  14351. if (j === 0) {
  14352. break;
  14353. }
  14354. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  14355. break;
  14356. default:
  14357. return null;
  14358. }
  14359. }
  14360. if (stack.length !== outputSize) {
  14361. return null;
  14362. }
  14363. var result = [];
  14364. instructions.forEach(function (instruction) {
  14365. var statementBuilder = new ExpressionBuilderVisitor();
  14366. instruction.visit(statementBuilder);
  14367. result.push(statementBuilder.toString());
  14368. });
  14369. stack.forEach(function (expr, i) {
  14370. var statementBuilder = new ExpressionBuilderVisitor();
  14371. expr.visit(statementBuilder);
  14372. var min = range[i * 2], max = range[i * 2 + 1];
  14373. var out = [statementBuilder.toString()];
  14374. if (min > expr.min) {
  14375. out.unshift('Math.max(', min, ', ');
  14376. out.push(')');
  14377. }
  14378. if (max < expr.max) {
  14379. out.unshift('Math.min(', max, ', ');
  14380. out.push(')');
  14381. }
  14382. out.unshift('dest[destOffset + ', i, '] = ');
  14383. out.push(';');
  14384. result.push(out.join(''));
  14385. });
  14386. return result.join('\n');
  14387. }
  14388. };
  14389. return PostScriptCompiler;
  14390. }();
  14391. exports.isPDFFunction = isPDFFunction;
  14392. exports.PDFFunction = PDFFunction;
  14393. exports.PostScriptEvaluator = PostScriptEvaluator;
  14394. exports.PostScriptCompiler = PostScriptCompiler;
  14395. /***/ }),
  14396. /* 8 */
  14397. /***/ (function(module, exports, __w_pdfjs_require__) {
  14398. "use strict";
  14399. var sharedUtil = __w_pdfjs_require__(0);
  14400. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  14401. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  14402. t['A'] = 0x0041;
  14403. t['AE'] = 0x00C6;
  14404. t['AEacute'] = 0x01FC;
  14405. t['AEmacron'] = 0x01E2;
  14406. t['AEsmall'] = 0xF7E6;
  14407. t['Aacute'] = 0x00C1;
  14408. t['Aacutesmall'] = 0xF7E1;
  14409. t['Abreve'] = 0x0102;
  14410. t['Abreveacute'] = 0x1EAE;
  14411. t['Abrevecyrillic'] = 0x04D0;
  14412. t['Abrevedotbelow'] = 0x1EB6;
  14413. t['Abrevegrave'] = 0x1EB0;
  14414. t['Abrevehookabove'] = 0x1EB2;
  14415. t['Abrevetilde'] = 0x1EB4;
  14416. t['Acaron'] = 0x01CD;
  14417. t['Acircle'] = 0x24B6;
  14418. t['Acircumflex'] = 0x00C2;
  14419. t['Acircumflexacute'] = 0x1EA4;
  14420. t['Acircumflexdotbelow'] = 0x1EAC;
  14421. t['Acircumflexgrave'] = 0x1EA6;
  14422. t['Acircumflexhookabove'] = 0x1EA8;
  14423. t['Acircumflexsmall'] = 0xF7E2;
  14424. t['Acircumflextilde'] = 0x1EAA;
  14425. t['Acute'] = 0xF6C9;
  14426. t['Acutesmall'] = 0xF7B4;
  14427. t['Acyrillic'] = 0x0410;
  14428. t['Adblgrave'] = 0x0200;
  14429. t['Adieresis'] = 0x00C4;
  14430. t['Adieresiscyrillic'] = 0x04D2;
  14431. t['Adieresismacron'] = 0x01DE;
  14432. t['Adieresissmall'] = 0xF7E4;
  14433. t['Adotbelow'] = 0x1EA0;
  14434. t['Adotmacron'] = 0x01E0;
  14435. t['Agrave'] = 0x00C0;
  14436. t['Agravesmall'] = 0xF7E0;
  14437. t['Ahookabove'] = 0x1EA2;
  14438. t['Aiecyrillic'] = 0x04D4;
  14439. t['Ainvertedbreve'] = 0x0202;
  14440. t['Alpha'] = 0x0391;
  14441. t['Alphatonos'] = 0x0386;
  14442. t['Amacron'] = 0x0100;
  14443. t['Amonospace'] = 0xFF21;
  14444. t['Aogonek'] = 0x0104;
  14445. t['Aring'] = 0x00C5;
  14446. t['Aringacute'] = 0x01FA;
  14447. t['Aringbelow'] = 0x1E00;
  14448. t['Aringsmall'] = 0xF7E5;
  14449. t['Asmall'] = 0xF761;
  14450. t['Atilde'] = 0x00C3;
  14451. t['Atildesmall'] = 0xF7E3;
  14452. t['Aybarmenian'] = 0x0531;
  14453. t['B'] = 0x0042;
  14454. t['Bcircle'] = 0x24B7;
  14455. t['Bdotaccent'] = 0x1E02;
  14456. t['Bdotbelow'] = 0x1E04;
  14457. t['Becyrillic'] = 0x0411;
  14458. t['Benarmenian'] = 0x0532;
  14459. t['Beta'] = 0x0392;
  14460. t['Bhook'] = 0x0181;
  14461. t['Blinebelow'] = 0x1E06;
  14462. t['Bmonospace'] = 0xFF22;
  14463. t['Brevesmall'] = 0xF6F4;
  14464. t['Bsmall'] = 0xF762;
  14465. t['Btopbar'] = 0x0182;
  14466. t['C'] = 0x0043;
  14467. t['Caarmenian'] = 0x053E;
  14468. t['Cacute'] = 0x0106;
  14469. t['Caron'] = 0xF6CA;
  14470. t['Caronsmall'] = 0xF6F5;
  14471. t['Ccaron'] = 0x010C;
  14472. t['Ccedilla'] = 0x00C7;
  14473. t['Ccedillaacute'] = 0x1E08;
  14474. t['Ccedillasmall'] = 0xF7E7;
  14475. t['Ccircle'] = 0x24B8;
  14476. t['Ccircumflex'] = 0x0108;
  14477. t['Cdot'] = 0x010A;
  14478. t['Cdotaccent'] = 0x010A;
  14479. t['Cedillasmall'] = 0xF7B8;
  14480. t['Chaarmenian'] = 0x0549;
  14481. t['Cheabkhasiancyrillic'] = 0x04BC;
  14482. t['Checyrillic'] = 0x0427;
  14483. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  14484. t['Chedescendercyrillic'] = 0x04B6;
  14485. t['Chedieresiscyrillic'] = 0x04F4;
  14486. t['Cheharmenian'] = 0x0543;
  14487. t['Chekhakassiancyrillic'] = 0x04CB;
  14488. t['Cheverticalstrokecyrillic'] = 0x04B8;
  14489. t['Chi'] = 0x03A7;
  14490. t['Chook'] = 0x0187;
  14491. t['Circumflexsmall'] = 0xF6F6;
  14492. t['Cmonospace'] = 0xFF23;
  14493. t['Coarmenian'] = 0x0551;
  14494. t['Csmall'] = 0xF763;
  14495. t['D'] = 0x0044;
  14496. t['DZ'] = 0x01F1;
  14497. t['DZcaron'] = 0x01C4;
  14498. t['Daarmenian'] = 0x0534;
  14499. t['Dafrican'] = 0x0189;
  14500. t['Dcaron'] = 0x010E;
  14501. t['Dcedilla'] = 0x1E10;
  14502. t['Dcircle'] = 0x24B9;
  14503. t['Dcircumflexbelow'] = 0x1E12;
  14504. t['Dcroat'] = 0x0110;
  14505. t['Ddotaccent'] = 0x1E0A;
  14506. t['Ddotbelow'] = 0x1E0C;
  14507. t['Decyrillic'] = 0x0414;
  14508. t['Deicoptic'] = 0x03EE;
  14509. t['Delta'] = 0x2206;
  14510. t['Deltagreek'] = 0x0394;
  14511. t['Dhook'] = 0x018A;
  14512. t['Dieresis'] = 0xF6CB;
  14513. t['DieresisAcute'] = 0xF6CC;
  14514. t['DieresisGrave'] = 0xF6CD;
  14515. t['Dieresissmall'] = 0xF7A8;
  14516. t['Digammagreek'] = 0x03DC;
  14517. t['Djecyrillic'] = 0x0402;
  14518. t['Dlinebelow'] = 0x1E0E;
  14519. t['Dmonospace'] = 0xFF24;
  14520. t['Dotaccentsmall'] = 0xF6F7;
  14521. t['Dslash'] = 0x0110;
  14522. t['Dsmall'] = 0xF764;
  14523. t['Dtopbar'] = 0x018B;
  14524. t['Dz'] = 0x01F2;
  14525. t['Dzcaron'] = 0x01C5;
  14526. t['Dzeabkhasiancyrillic'] = 0x04E0;
  14527. t['Dzecyrillic'] = 0x0405;
  14528. t['Dzhecyrillic'] = 0x040F;
  14529. t['E'] = 0x0045;
  14530. t['Eacute'] = 0x00C9;
  14531. t['Eacutesmall'] = 0xF7E9;
  14532. t['Ebreve'] = 0x0114;
  14533. t['Ecaron'] = 0x011A;
  14534. t['Ecedillabreve'] = 0x1E1C;
  14535. t['Echarmenian'] = 0x0535;
  14536. t['Ecircle'] = 0x24BA;
  14537. t['Ecircumflex'] = 0x00CA;
  14538. t['Ecircumflexacute'] = 0x1EBE;
  14539. t['Ecircumflexbelow'] = 0x1E18;
  14540. t['Ecircumflexdotbelow'] = 0x1EC6;
  14541. t['Ecircumflexgrave'] = 0x1EC0;
  14542. t['Ecircumflexhookabove'] = 0x1EC2;
  14543. t['Ecircumflexsmall'] = 0xF7EA;
  14544. t['Ecircumflextilde'] = 0x1EC4;
  14545. t['Ecyrillic'] = 0x0404;
  14546. t['Edblgrave'] = 0x0204;
  14547. t['Edieresis'] = 0x00CB;
  14548. t['Edieresissmall'] = 0xF7EB;
  14549. t['Edot'] = 0x0116;
  14550. t['Edotaccent'] = 0x0116;
  14551. t['Edotbelow'] = 0x1EB8;
  14552. t['Efcyrillic'] = 0x0424;
  14553. t['Egrave'] = 0x00C8;
  14554. t['Egravesmall'] = 0xF7E8;
  14555. t['Eharmenian'] = 0x0537;
  14556. t['Ehookabove'] = 0x1EBA;
  14557. t['Eightroman'] = 0x2167;
  14558. t['Einvertedbreve'] = 0x0206;
  14559. t['Eiotifiedcyrillic'] = 0x0464;
  14560. t['Elcyrillic'] = 0x041B;
  14561. t['Elevenroman'] = 0x216A;
  14562. t['Emacron'] = 0x0112;
  14563. t['Emacronacute'] = 0x1E16;
  14564. t['Emacrongrave'] = 0x1E14;
  14565. t['Emcyrillic'] = 0x041C;
  14566. t['Emonospace'] = 0xFF25;
  14567. t['Encyrillic'] = 0x041D;
  14568. t['Endescendercyrillic'] = 0x04A2;
  14569. t['Eng'] = 0x014A;
  14570. t['Enghecyrillic'] = 0x04A4;
  14571. t['Enhookcyrillic'] = 0x04C7;
  14572. t['Eogonek'] = 0x0118;
  14573. t['Eopen'] = 0x0190;
  14574. t['Epsilon'] = 0x0395;
  14575. t['Epsilontonos'] = 0x0388;
  14576. t['Ercyrillic'] = 0x0420;
  14577. t['Ereversed'] = 0x018E;
  14578. t['Ereversedcyrillic'] = 0x042D;
  14579. t['Escyrillic'] = 0x0421;
  14580. t['Esdescendercyrillic'] = 0x04AA;
  14581. t['Esh'] = 0x01A9;
  14582. t['Esmall'] = 0xF765;
  14583. t['Eta'] = 0x0397;
  14584. t['Etarmenian'] = 0x0538;
  14585. t['Etatonos'] = 0x0389;
  14586. t['Eth'] = 0x00D0;
  14587. t['Ethsmall'] = 0xF7F0;
  14588. t['Etilde'] = 0x1EBC;
  14589. t['Etildebelow'] = 0x1E1A;
  14590. t['Euro'] = 0x20AC;
  14591. t['Ezh'] = 0x01B7;
  14592. t['Ezhcaron'] = 0x01EE;
  14593. t['Ezhreversed'] = 0x01B8;
  14594. t['F'] = 0x0046;
  14595. t['Fcircle'] = 0x24BB;
  14596. t['Fdotaccent'] = 0x1E1E;
  14597. t['Feharmenian'] = 0x0556;
  14598. t['Feicoptic'] = 0x03E4;
  14599. t['Fhook'] = 0x0191;
  14600. t['Fitacyrillic'] = 0x0472;
  14601. t['Fiveroman'] = 0x2164;
  14602. t['Fmonospace'] = 0xFF26;
  14603. t['Fourroman'] = 0x2163;
  14604. t['Fsmall'] = 0xF766;
  14605. t['G'] = 0x0047;
  14606. t['GBsquare'] = 0x3387;
  14607. t['Gacute'] = 0x01F4;
  14608. t['Gamma'] = 0x0393;
  14609. t['Gammaafrican'] = 0x0194;
  14610. t['Gangiacoptic'] = 0x03EA;
  14611. t['Gbreve'] = 0x011E;
  14612. t['Gcaron'] = 0x01E6;
  14613. t['Gcedilla'] = 0x0122;
  14614. t['Gcircle'] = 0x24BC;
  14615. t['Gcircumflex'] = 0x011C;
  14616. t['Gcommaaccent'] = 0x0122;
  14617. t['Gdot'] = 0x0120;
  14618. t['Gdotaccent'] = 0x0120;
  14619. t['Gecyrillic'] = 0x0413;
  14620. t['Ghadarmenian'] = 0x0542;
  14621. t['Ghemiddlehookcyrillic'] = 0x0494;
  14622. t['Ghestrokecyrillic'] = 0x0492;
  14623. t['Gheupturncyrillic'] = 0x0490;
  14624. t['Ghook'] = 0x0193;
  14625. t['Gimarmenian'] = 0x0533;
  14626. t['Gjecyrillic'] = 0x0403;
  14627. t['Gmacron'] = 0x1E20;
  14628. t['Gmonospace'] = 0xFF27;
  14629. t['Grave'] = 0xF6CE;
  14630. t['Gravesmall'] = 0xF760;
  14631. t['Gsmall'] = 0xF767;
  14632. t['Gsmallhook'] = 0x029B;
  14633. t['Gstroke'] = 0x01E4;
  14634. t['H'] = 0x0048;
  14635. t['H18533'] = 0x25CF;
  14636. t['H18543'] = 0x25AA;
  14637. t['H18551'] = 0x25AB;
  14638. t['H22073'] = 0x25A1;
  14639. t['HPsquare'] = 0x33CB;
  14640. t['Haabkhasiancyrillic'] = 0x04A8;
  14641. t['Hadescendercyrillic'] = 0x04B2;
  14642. t['Hardsigncyrillic'] = 0x042A;
  14643. t['Hbar'] = 0x0126;
  14644. t['Hbrevebelow'] = 0x1E2A;
  14645. t['Hcedilla'] = 0x1E28;
  14646. t['Hcircle'] = 0x24BD;
  14647. t['Hcircumflex'] = 0x0124;
  14648. t['Hdieresis'] = 0x1E26;
  14649. t['Hdotaccent'] = 0x1E22;
  14650. t['Hdotbelow'] = 0x1E24;
  14651. t['Hmonospace'] = 0xFF28;
  14652. t['Hoarmenian'] = 0x0540;
  14653. t['Horicoptic'] = 0x03E8;
  14654. t['Hsmall'] = 0xF768;
  14655. t['Hungarumlaut'] = 0xF6CF;
  14656. t['Hungarumlautsmall'] = 0xF6F8;
  14657. t['Hzsquare'] = 0x3390;
  14658. t['I'] = 0x0049;
  14659. t['IAcyrillic'] = 0x042F;
  14660. t['IJ'] = 0x0132;
  14661. t['IUcyrillic'] = 0x042E;
  14662. t['Iacute'] = 0x00CD;
  14663. t['Iacutesmall'] = 0xF7ED;
  14664. t['Ibreve'] = 0x012C;
  14665. t['Icaron'] = 0x01CF;
  14666. t['Icircle'] = 0x24BE;
  14667. t['Icircumflex'] = 0x00CE;
  14668. t['Icircumflexsmall'] = 0xF7EE;
  14669. t['Icyrillic'] = 0x0406;
  14670. t['Idblgrave'] = 0x0208;
  14671. t['Idieresis'] = 0x00CF;
  14672. t['Idieresisacute'] = 0x1E2E;
  14673. t['Idieresiscyrillic'] = 0x04E4;
  14674. t['Idieresissmall'] = 0xF7EF;
  14675. t['Idot'] = 0x0130;
  14676. t['Idotaccent'] = 0x0130;
  14677. t['Idotbelow'] = 0x1ECA;
  14678. t['Iebrevecyrillic'] = 0x04D6;
  14679. t['Iecyrillic'] = 0x0415;
  14680. t['Ifraktur'] = 0x2111;
  14681. t['Igrave'] = 0x00CC;
  14682. t['Igravesmall'] = 0xF7EC;
  14683. t['Ihookabove'] = 0x1EC8;
  14684. t['Iicyrillic'] = 0x0418;
  14685. t['Iinvertedbreve'] = 0x020A;
  14686. t['Iishortcyrillic'] = 0x0419;
  14687. t['Imacron'] = 0x012A;
  14688. t['Imacroncyrillic'] = 0x04E2;
  14689. t['Imonospace'] = 0xFF29;
  14690. t['Iniarmenian'] = 0x053B;
  14691. t['Iocyrillic'] = 0x0401;
  14692. t['Iogonek'] = 0x012E;
  14693. t['Iota'] = 0x0399;
  14694. t['Iotaafrican'] = 0x0196;
  14695. t['Iotadieresis'] = 0x03AA;
  14696. t['Iotatonos'] = 0x038A;
  14697. t['Ismall'] = 0xF769;
  14698. t['Istroke'] = 0x0197;
  14699. t['Itilde'] = 0x0128;
  14700. t['Itildebelow'] = 0x1E2C;
  14701. t['Izhitsacyrillic'] = 0x0474;
  14702. t['Izhitsadblgravecyrillic'] = 0x0476;
  14703. t['J'] = 0x004A;
  14704. t['Jaarmenian'] = 0x0541;
  14705. t['Jcircle'] = 0x24BF;
  14706. t['Jcircumflex'] = 0x0134;
  14707. t['Jecyrillic'] = 0x0408;
  14708. t['Jheharmenian'] = 0x054B;
  14709. t['Jmonospace'] = 0xFF2A;
  14710. t['Jsmall'] = 0xF76A;
  14711. t['K'] = 0x004B;
  14712. t['KBsquare'] = 0x3385;
  14713. t['KKsquare'] = 0x33CD;
  14714. t['Kabashkircyrillic'] = 0x04A0;
  14715. t['Kacute'] = 0x1E30;
  14716. t['Kacyrillic'] = 0x041A;
  14717. t['Kadescendercyrillic'] = 0x049A;
  14718. t['Kahookcyrillic'] = 0x04C3;
  14719. t['Kappa'] = 0x039A;
  14720. t['Kastrokecyrillic'] = 0x049E;
  14721. t['Kaverticalstrokecyrillic'] = 0x049C;
  14722. t['Kcaron'] = 0x01E8;
  14723. t['Kcedilla'] = 0x0136;
  14724. t['Kcircle'] = 0x24C0;
  14725. t['Kcommaaccent'] = 0x0136;
  14726. t['Kdotbelow'] = 0x1E32;
  14727. t['Keharmenian'] = 0x0554;
  14728. t['Kenarmenian'] = 0x053F;
  14729. t['Khacyrillic'] = 0x0425;
  14730. t['Kheicoptic'] = 0x03E6;
  14731. t['Khook'] = 0x0198;
  14732. t['Kjecyrillic'] = 0x040C;
  14733. t['Klinebelow'] = 0x1E34;
  14734. t['Kmonospace'] = 0xFF2B;
  14735. t['Koppacyrillic'] = 0x0480;
  14736. t['Koppagreek'] = 0x03DE;
  14737. t['Ksicyrillic'] = 0x046E;
  14738. t['Ksmall'] = 0xF76B;
  14739. t['L'] = 0x004C;
  14740. t['LJ'] = 0x01C7;
  14741. t['LL'] = 0xF6BF;
  14742. t['Lacute'] = 0x0139;
  14743. t['Lambda'] = 0x039B;
  14744. t['Lcaron'] = 0x013D;
  14745. t['Lcedilla'] = 0x013B;
  14746. t['Lcircle'] = 0x24C1;
  14747. t['Lcircumflexbelow'] = 0x1E3C;
  14748. t['Lcommaaccent'] = 0x013B;
  14749. t['Ldot'] = 0x013F;
  14750. t['Ldotaccent'] = 0x013F;
  14751. t['Ldotbelow'] = 0x1E36;
  14752. t['Ldotbelowmacron'] = 0x1E38;
  14753. t['Liwnarmenian'] = 0x053C;
  14754. t['Lj'] = 0x01C8;
  14755. t['Ljecyrillic'] = 0x0409;
  14756. t['Llinebelow'] = 0x1E3A;
  14757. t['Lmonospace'] = 0xFF2C;
  14758. t['Lslash'] = 0x0141;
  14759. t['Lslashsmall'] = 0xF6F9;
  14760. t['Lsmall'] = 0xF76C;
  14761. t['M'] = 0x004D;
  14762. t['MBsquare'] = 0x3386;
  14763. t['Macron'] = 0xF6D0;
  14764. t['Macronsmall'] = 0xF7AF;
  14765. t['Macute'] = 0x1E3E;
  14766. t['Mcircle'] = 0x24C2;
  14767. t['Mdotaccent'] = 0x1E40;
  14768. t['Mdotbelow'] = 0x1E42;
  14769. t['Menarmenian'] = 0x0544;
  14770. t['Mmonospace'] = 0xFF2D;
  14771. t['Msmall'] = 0xF76D;
  14772. t['Mturned'] = 0x019C;
  14773. t['Mu'] = 0x039C;
  14774. t['N'] = 0x004E;
  14775. t['NJ'] = 0x01CA;
  14776. t['Nacute'] = 0x0143;
  14777. t['Ncaron'] = 0x0147;
  14778. t['Ncedilla'] = 0x0145;
  14779. t['Ncircle'] = 0x24C3;
  14780. t['Ncircumflexbelow'] = 0x1E4A;
  14781. t['Ncommaaccent'] = 0x0145;
  14782. t['Ndotaccent'] = 0x1E44;
  14783. t['Ndotbelow'] = 0x1E46;
  14784. t['Nhookleft'] = 0x019D;
  14785. t['Nineroman'] = 0x2168;
  14786. t['Nj'] = 0x01CB;
  14787. t['Njecyrillic'] = 0x040A;
  14788. t['Nlinebelow'] = 0x1E48;
  14789. t['Nmonospace'] = 0xFF2E;
  14790. t['Nowarmenian'] = 0x0546;
  14791. t['Nsmall'] = 0xF76E;
  14792. t['Ntilde'] = 0x00D1;
  14793. t['Ntildesmall'] = 0xF7F1;
  14794. t['Nu'] = 0x039D;
  14795. t['O'] = 0x004F;
  14796. t['OE'] = 0x0152;
  14797. t['OEsmall'] = 0xF6FA;
  14798. t['Oacute'] = 0x00D3;
  14799. t['Oacutesmall'] = 0xF7F3;
  14800. t['Obarredcyrillic'] = 0x04E8;
  14801. t['Obarreddieresiscyrillic'] = 0x04EA;
  14802. t['Obreve'] = 0x014E;
  14803. t['Ocaron'] = 0x01D1;
  14804. t['Ocenteredtilde'] = 0x019F;
  14805. t['Ocircle'] = 0x24C4;
  14806. t['Ocircumflex'] = 0x00D4;
  14807. t['Ocircumflexacute'] = 0x1ED0;
  14808. t['Ocircumflexdotbelow'] = 0x1ED8;
  14809. t['Ocircumflexgrave'] = 0x1ED2;
  14810. t['Ocircumflexhookabove'] = 0x1ED4;
  14811. t['Ocircumflexsmall'] = 0xF7F4;
  14812. t['Ocircumflextilde'] = 0x1ED6;
  14813. t['Ocyrillic'] = 0x041E;
  14814. t['Odblacute'] = 0x0150;
  14815. t['Odblgrave'] = 0x020C;
  14816. t['Odieresis'] = 0x00D6;
  14817. t['Odieresiscyrillic'] = 0x04E6;
  14818. t['Odieresissmall'] = 0xF7F6;
  14819. t['Odotbelow'] = 0x1ECC;
  14820. t['Ogoneksmall'] = 0xF6FB;
  14821. t['Ograve'] = 0x00D2;
  14822. t['Ogravesmall'] = 0xF7F2;
  14823. t['Oharmenian'] = 0x0555;
  14824. t['Ohm'] = 0x2126;
  14825. t['Ohookabove'] = 0x1ECE;
  14826. t['Ohorn'] = 0x01A0;
  14827. t['Ohornacute'] = 0x1EDA;
  14828. t['Ohorndotbelow'] = 0x1EE2;
  14829. t['Ohorngrave'] = 0x1EDC;
  14830. t['Ohornhookabove'] = 0x1EDE;
  14831. t['Ohorntilde'] = 0x1EE0;
  14832. t['Ohungarumlaut'] = 0x0150;
  14833. t['Oi'] = 0x01A2;
  14834. t['Oinvertedbreve'] = 0x020E;
  14835. t['Omacron'] = 0x014C;
  14836. t['Omacronacute'] = 0x1E52;
  14837. t['Omacrongrave'] = 0x1E50;
  14838. t['Omega'] = 0x2126;
  14839. t['Omegacyrillic'] = 0x0460;
  14840. t['Omegagreek'] = 0x03A9;
  14841. t['Omegaroundcyrillic'] = 0x047A;
  14842. t['Omegatitlocyrillic'] = 0x047C;
  14843. t['Omegatonos'] = 0x038F;
  14844. t['Omicron'] = 0x039F;
  14845. t['Omicrontonos'] = 0x038C;
  14846. t['Omonospace'] = 0xFF2F;
  14847. t['Oneroman'] = 0x2160;
  14848. t['Oogonek'] = 0x01EA;
  14849. t['Oogonekmacron'] = 0x01EC;
  14850. t['Oopen'] = 0x0186;
  14851. t['Oslash'] = 0x00D8;
  14852. t['Oslashacute'] = 0x01FE;
  14853. t['Oslashsmall'] = 0xF7F8;
  14854. t['Osmall'] = 0xF76F;
  14855. t['Ostrokeacute'] = 0x01FE;
  14856. t['Otcyrillic'] = 0x047E;
  14857. t['Otilde'] = 0x00D5;
  14858. t['Otildeacute'] = 0x1E4C;
  14859. t['Otildedieresis'] = 0x1E4E;
  14860. t['Otildesmall'] = 0xF7F5;
  14861. t['P'] = 0x0050;
  14862. t['Pacute'] = 0x1E54;
  14863. t['Pcircle'] = 0x24C5;
  14864. t['Pdotaccent'] = 0x1E56;
  14865. t['Pecyrillic'] = 0x041F;
  14866. t['Peharmenian'] = 0x054A;
  14867. t['Pemiddlehookcyrillic'] = 0x04A6;
  14868. t['Phi'] = 0x03A6;
  14869. t['Phook'] = 0x01A4;
  14870. t['Pi'] = 0x03A0;
  14871. t['Piwrarmenian'] = 0x0553;
  14872. t['Pmonospace'] = 0xFF30;
  14873. t['Psi'] = 0x03A8;
  14874. t['Psicyrillic'] = 0x0470;
  14875. t['Psmall'] = 0xF770;
  14876. t['Q'] = 0x0051;
  14877. t['Qcircle'] = 0x24C6;
  14878. t['Qmonospace'] = 0xFF31;
  14879. t['Qsmall'] = 0xF771;
  14880. t['R'] = 0x0052;
  14881. t['Raarmenian'] = 0x054C;
  14882. t['Racute'] = 0x0154;
  14883. t['Rcaron'] = 0x0158;
  14884. t['Rcedilla'] = 0x0156;
  14885. t['Rcircle'] = 0x24C7;
  14886. t['Rcommaaccent'] = 0x0156;
  14887. t['Rdblgrave'] = 0x0210;
  14888. t['Rdotaccent'] = 0x1E58;
  14889. t['Rdotbelow'] = 0x1E5A;
  14890. t['Rdotbelowmacron'] = 0x1E5C;
  14891. t['Reharmenian'] = 0x0550;
  14892. t['Rfraktur'] = 0x211C;
  14893. t['Rho'] = 0x03A1;
  14894. t['Ringsmall'] = 0xF6FC;
  14895. t['Rinvertedbreve'] = 0x0212;
  14896. t['Rlinebelow'] = 0x1E5E;
  14897. t['Rmonospace'] = 0xFF32;
  14898. t['Rsmall'] = 0xF772;
  14899. t['Rsmallinverted'] = 0x0281;
  14900. t['Rsmallinvertedsuperior'] = 0x02B6;
  14901. t['S'] = 0x0053;
  14902. t['SF010000'] = 0x250C;
  14903. t['SF020000'] = 0x2514;
  14904. t['SF030000'] = 0x2510;
  14905. t['SF040000'] = 0x2518;
  14906. t['SF050000'] = 0x253C;
  14907. t['SF060000'] = 0x252C;
  14908. t['SF070000'] = 0x2534;
  14909. t['SF080000'] = 0x251C;
  14910. t['SF090000'] = 0x2524;
  14911. t['SF100000'] = 0x2500;
  14912. t['SF110000'] = 0x2502;
  14913. t['SF190000'] = 0x2561;
  14914. t['SF200000'] = 0x2562;
  14915. t['SF210000'] = 0x2556;
  14916. t['SF220000'] = 0x2555;
  14917. t['SF230000'] = 0x2563;
  14918. t['SF240000'] = 0x2551;
  14919. t['SF250000'] = 0x2557;
  14920. t['SF260000'] = 0x255D;
  14921. t['SF270000'] = 0x255C;
  14922. t['SF280000'] = 0x255B;
  14923. t['SF360000'] = 0x255E;
  14924. t['SF370000'] = 0x255F;
  14925. t['SF380000'] = 0x255A;
  14926. t['SF390000'] = 0x2554;
  14927. t['SF400000'] = 0x2569;
  14928. t['SF410000'] = 0x2566;
  14929. t['SF420000'] = 0x2560;
  14930. t['SF430000'] = 0x2550;
  14931. t['SF440000'] = 0x256C;
  14932. t['SF450000'] = 0x2567;
  14933. t['SF460000'] = 0x2568;
  14934. t['SF470000'] = 0x2564;
  14935. t['SF480000'] = 0x2565;
  14936. t['SF490000'] = 0x2559;
  14937. t['SF500000'] = 0x2558;
  14938. t['SF510000'] = 0x2552;
  14939. t['SF520000'] = 0x2553;
  14940. t['SF530000'] = 0x256B;
  14941. t['SF540000'] = 0x256A;
  14942. t['Sacute'] = 0x015A;
  14943. t['Sacutedotaccent'] = 0x1E64;
  14944. t['Sampigreek'] = 0x03E0;
  14945. t['Scaron'] = 0x0160;
  14946. t['Scarondotaccent'] = 0x1E66;
  14947. t['Scaronsmall'] = 0xF6FD;
  14948. t['Scedilla'] = 0x015E;
  14949. t['Schwa'] = 0x018F;
  14950. t['Schwacyrillic'] = 0x04D8;
  14951. t['Schwadieresiscyrillic'] = 0x04DA;
  14952. t['Scircle'] = 0x24C8;
  14953. t['Scircumflex'] = 0x015C;
  14954. t['Scommaaccent'] = 0x0218;
  14955. t['Sdotaccent'] = 0x1E60;
  14956. t['Sdotbelow'] = 0x1E62;
  14957. t['Sdotbelowdotaccent'] = 0x1E68;
  14958. t['Seharmenian'] = 0x054D;
  14959. t['Sevenroman'] = 0x2166;
  14960. t['Shaarmenian'] = 0x0547;
  14961. t['Shacyrillic'] = 0x0428;
  14962. t['Shchacyrillic'] = 0x0429;
  14963. t['Sheicoptic'] = 0x03E2;
  14964. t['Shhacyrillic'] = 0x04BA;
  14965. t['Shimacoptic'] = 0x03EC;
  14966. t['Sigma'] = 0x03A3;
  14967. t['Sixroman'] = 0x2165;
  14968. t['Smonospace'] = 0xFF33;
  14969. t['Softsigncyrillic'] = 0x042C;
  14970. t['Ssmall'] = 0xF773;
  14971. t['Stigmagreek'] = 0x03DA;
  14972. t['T'] = 0x0054;
  14973. t['Tau'] = 0x03A4;
  14974. t['Tbar'] = 0x0166;
  14975. t['Tcaron'] = 0x0164;
  14976. t['Tcedilla'] = 0x0162;
  14977. t['Tcircle'] = 0x24C9;
  14978. t['Tcircumflexbelow'] = 0x1E70;
  14979. t['Tcommaaccent'] = 0x0162;
  14980. t['Tdotaccent'] = 0x1E6A;
  14981. t['Tdotbelow'] = 0x1E6C;
  14982. t['Tecyrillic'] = 0x0422;
  14983. t['Tedescendercyrillic'] = 0x04AC;
  14984. t['Tenroman'] = 0x2169;
  14985. t['Tetsecyrillic'] = 0x04B4;
  14986. t['Theta'] = 0x0398;
  14987. t['Thook'] = 0x01AC;
  14988. t['Thorn'] = 0x00DE;
  14989. t['Thornsmall'] = 0xF7FE;
  14990. t['Threeroman'] = 0x2162;
  14991. t['Tildesmall'] = 0xF6FE;
  14992. t['Tiwnarmenian'] = 0x054F;
  14993. t['Tlinebelow'] = 0x1E6E;
  14994. t['Tmonospace'] = 0xFF34;
  14995. t['Toarmenian'] = 0x0539;
  14996. t['Tonefive'] = 0x01BC;
  14997. t['Tonesix'] = 0x0184;
  14998. t['Tonetwo'] = 0x01A7;
  14999. t['Tretroflexhook'] = 0x01AE;
  15000. t['Tsecyrillic'] = 0x0426;
  15001. t['Tshecyrillic'] = 0x040B;
  15002. t['Tsmall'] = 0xF774;
  15003. t['Twelveroman'] = 0x216B;
  15004. t['Tworoman'] = 0x2161;
  15005. t['U'] = 0x0055;
  15006. t['Uacute'] = 0x00DA;
  15007. t['Uacutesmall'] = 0xF7FA;
  15008. t['Ubreve'] = 0x016C;
  15009. t['Ucaron'] = 0x01D3;
  15010. t['Ucircle'] = 0x24CA;
  15011. t['Ucircumflex'] = 0x00DB;
  15012. t['Ucircumflexbelow'] = 0x1E76;
  15013. t['Ucircumflexsmall'] = 0xF7FB;
  15014. t['Ucyrillic'] = 0x0423;
  15015. t['Udblacute'] = 0x0170;
  15016. t['Udblgrave'] = 0x0214;
  15017. t['Udieresis'] = 0x00DC;
  15018. t['Udieresisacute'] = 0x01D7;
  15019. t['Udieresisbelow'] = 0x1E72;
  15020. t['Udieresiscaron'] = 0x01D9;
  15021. t['Udieresiscyrillic'] = 0x04F0;
  15022. t['Udieresisgrave'] = 0x01DB;
  15023. t['Udieresismacron'] = 0x01D5;
  15024. t['Udieresissmall'] = 0xF7FC;
  15025. t['Udotbelow'] = 0x1EE4;
  15026. t['Ugrave'] = 0x00D9;
  15027. t['Ugravesmall'] = 0xF7F9;
  15028. t['Uhookabove'] = 0x1EE6;
  15029. t['Uhorn'] = 0x01AF;
  15030. t['Uhornacute'] = 0x1EE8;
  15031. t['Uhorndotbelow'] = 0x1EF0;
  15032. t['Uhorngrave'] = 0x1EEA;
  15033. t['Uhornhookabove'] = 0x1EEC;
  15034. t['Uhorntilde'] = 0x1EEE;
  15035. t['Uhungarumlaut'] = 0x0170;
  15036. t['Uhungarumlautcyrillic'] = 0x04F2;
  15037. t['Uinvertedbreve'] = 0x0216;
  15038. t['Ukcyrillic'] = 0x0478;
  15039. t['Umacron'] = 0x016A;
  15040. t['Umacroncyrillic'] = 0x04EE;
  15041. t['Umacrondieresis'] = 0x1E7A;
  15042. t['Umonospace'] = 0xFF35;
  15043. t['Uogonek'] = 0x0172;
  15044. t['Upsilon'] = 0x03A5;
  15045. t['Upsilon1'] = 0x03D2;
  15046. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  15047. t['Upsilonafrican'] = 0x01B1;
  15048. t['Upsilondieresis'] = 0x03AB;
  15049. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  15050. t['Upsilonhooksymbol'] = 0x03D2;
  15051. t['Upsilontonos'] = 0x038E;
  15052. t['Uring'] = 0x016E;
  15053. t['Ushortcyrillic'] = 0x040E;
  15054. t['Usmall'] = 0xF775;
  15055. t['Ustraightcyrillic'] = 0x04AE;
  15056. t['Ustraightstrokecyrillic'] = 0x04B0;
  15057. t['Utilde'] = 0x0168;
  15058. t['Utildeacute'] = 0x1E78;
  15059. t['Utildebelow'] = 0x1E74;
  15060. t['V'] = 0x0056;
  15061. t['Vcircle'] = 0x24CB;
  15062. t['Vdotbelow'] = 0x1E7E;
  15063. t['Vecyrillic'] = 0x0412;
  15064. t['Vewarmenian'] = 0x054E;
  15065. t['Vhook'] = 0x01B2;
  15066. t['Vmonospace'] = 0xFF36;
  15067. t['Voarmenian'] = 0x0548;
  15068. t['Vsmall'] = 0xF776;
  15069. t['Vtilde'] = 0x1E7C;
  15070. t['W'] = 0x0057;
  15071. t['Wacute'] = 0x1E82;
  15072. t['Wcircle'] = 0x24CC;
  15073. t['Wcircumflex'] = 0x0174;
  15074. t['Wdieresis'] = 0x1E84;
  15075. t['Wdotaccent'] = 0x1E86;
  15076. t['Wdotbelow'] = 0x1E88;
  15077. t['Wgrave'] = 0x1E80;
  15078. t['Wmonospace'] = 0xFF37;
  15079. t['Wsmall'] = 0xF777;
  15080. t['X'] = 0x0058;
  15081. t['Xcircle'] = 0x24CD;
  15082. t['Xdieresis'] = 0x1E8C;
  15083. t['Xdotaccent'] = 0x1E8A;
  15084. t['Xeharmenian'] = 0x053D;
  15085. t['Xi'] = 0x039E;
  15086. t['Xmonospace'] = 0xFF38;
  15087. t['Xsmall'] = 0xF778;
  15088. t['Y'] = 0x0059;
  15089. t['Yacute'] = 0x00DD;
  15090. t['Yacutesmall'] = 0xF7FD;
  15091. t['Yatcyrillic'] = 0x0462;
  15092. t['Ycircle'] = 0x24CE;
  15093. t['Ycircumflex'] = 0x0176;
  15094. t['Ydieresis'] = 0x0178;
  15095. t['Ydieresissmall'] = 0xF7FF;
  15096. t['Ydotaccent'] = 0x1E8E;
  15097. t['Ydotbelow'] = 0x1EF4;
  15098. t['Yericyrillic'] = 0x042B;
  15099. t['Yerudieresiscyrillic'] = 0x04F8;
  15100. t['Ygrave'] = 0x1EF2;
  15101. t['Yhook'] = 0x01B3;
  15102. t['Yhookabove'] = 0x1EF6;
  15103. t['Yiarmenian'] = 0x0545;
  15104. t['Yicyrillic'] = 0x0407;
  15105. t['Yiwnarmenian'] = 0x0552;
  15106. t['Ymonospace'] = 0xFF39;
  15107. t['Ysmall'] = 0xF779;
  15108. t['Ytilde'] = 0x1EF8;
  15109. t['Yusbigcyrillic'] = 0x046A;
  15110. t['Yusbigiotifiedcyrillic'] = 0x046C;
  15111. t['Yuslittlecyrillic'] = 0x0466;
  15112. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  15113. t['Z'] = 0x005A;
  15114. t['Zaarmenian'] = 0x0536;
  15115. t['Zacute'] = 0x0179;
  15116. t['Zcaron'] = 0x017D;
  15117. t['Zcaronsmall'] = 0xF6FF;
  15118. t['Zcircle'] = 0x24CF;
  15119. t['Zcircumflex'] = 0x1E90;
  15120. t['Zdot'] = 0x017B;
  15121. t['Zdotaccent'] = 0x017B;
  15122. t['Zdotbelow'] = 0x1E92;
  15123. t['Zecyrillic'] = 0x0417;
  15124. t['Zedescendercyrillic'] = 0x0498;
  15125. t['Zedieresiscyrillic'] = 0x04DE;
  15126. t['Zeta'] = 0x0396;
  15127. t['Zhearmenian'] = 0x053A;
  15128. t['Zhebrevecyrillic'] = 0x04C1;
  15129. t['Zhecyrillic'] = 0x0416;
  15130. t['Zhedescendercyrillic'] = 0x0496;
  15131. t['Zhedieresiscyrillic'] = 0x04DC;
  15132. t['Zlinebelow'] = 0x1E94;
  15133. t['Zmonospace'] = 0xFF3A;
  15134. t['Zsmall'] = 0xF77A;
  15135. t['Zstroke'] = 0x01B5;
  15136. t['a'] = 0x0061;
  15137. t['aabengali'] = 0x0986;
  15138. t['aacute'] = 0x00E1;
  15139. t['aadeva'] = 0x0906;
  15140. t['aagujarati'] = 0x0A86;
  15141. t['aagurmukhi'] = 0x0A06;
  15142. t['aamatragurmukhi'] = 0x0A3E;
  15143. t['aarusquare'] = 0x3303;
  15144. t['aavowelsignbengali'] = 0x09BE;
  15145. t['aavowelsigndeva'] = 0x093E;
  15146. t['aavowelsigngujarati'] = 0x0ABE;
  15147. t['abbreviationmarkarmenian'] = 0x055F;
  15148. t['abbreviationsigndeva'] = 0x0970;
  15149. t['abengali'] = 0x0985;
  15150. t['abopomofo'] = 0x311A;
  15151. t['abreve'] = 0x0103;
  15152. t['abreveacute'] = 0x1EAF;
  15153. t['abrevecyrillic'] = 0x04D1;
  15154. t['abrevedotbelow'] = 0x1EB7;
  15155. t['abrevegrave'] = 0x1EB1;
  15156. t['abrevehookabove'] = 0x1EB3;
  15157. t['abrevetilde'] = 0x1EB5;
  15158. t['acaron'] = 0x01CE;
  15159. t['acircle'] = 0x24D0;
  15160. t['acircumflex'] = 0x00E2;
  15161. t['acircumflexacute'] = 0x1EA5;
  15162. t['acircumflexdotbelow'] = 0x1EAD;
  15163. t['acircumflexgrave'] = 0x1EA7;
  15164. t['acircumflexhookabove'] = 0x1EA9;
  15165. t['acircumflextilde'] = 0x1EAB;
  15166. t['acute'] = 0x00B4;
  15167. t['acutebelowcmb'] = 0x0317;
  15168. t['acutecmb'] = 0x0301;
  15169. t['acutecomb'] = 0x0301;
  15170. t['acutedeva'] = 0x0954;
  15171. t['acutelowmod'] = 0x02CF;
  15172. t['acutetonecmb'] = 0x0341;
  15173. t['acyrillic'] = 0x0430;
  15174. t['adblgrave'] = 0x0201;
  15175. t['addakgurmukhi'] = 0x0A71;
  15176. t['adeva'] = 0x0905;
  15177. t['adieresis'] = 0x00E4;
  15178. t['adieresiscyrillic'] = 0x04D3;
  15179. t['adieresismacron'] = 0x01DF;
  15180. t['adotbelow'] = 0x1EA1;
  15181. t['adotmacron'] = 0x01E1;
  15182. t['ae'] = 0x00E6;
  15183. t['aeacute'] = 0x01FD;
  15184. t['aekorean'] = 0x3150;
  15185. t['aemacron'] = 0x01E3;
  15186. t['afii00208'] = 0x2015;
  15187. t['afii08941'] = 0x20A4;
  15188. t['afii10017'] = 0x0410;
  15189. t['afii10018'] = 0x0411;
  15190. t['afii10019'] = 0x0412;
  15191. t['afii10020'] = 0x0413;
  15192. t['afii10021'] = 0x0414;
  15193. t['afii10022'] = 0x0415;
  15194. t['afii10023'] = 0x0401;
  15195. t['afii10024'] = 0x0416;
  15196. t['afii10025'] = 0x0417;
  15197. t['afii10026'] = 0x0418;
  15198. t['afii10027'] = 0x0419;
  15199. t['afii10028'] = 0x041A;
  15200. t['afii10029'] = 0x041B;
  15201. t['afii10030'] = 0x041C;
  15202. t['afii10031'] = 0x041D;
  15203. t['afii10032'] = 0x041E;
  15204. t['afii10033'] = 0x041F;
  15205. t['afii10034'] = 0x0420;
  15206. t['afii10035'] = 0x0421;
  15207. t['afii10036'] = 0x0422;
  15208. t['afii10037'] = 0x0423;
  15209. t['afii10038'] = 0x0424;
  15210. t['afii10039'] = 0x0425;
  15211. t['afii10040'] = 0x0426;
  15212. t['afii10041'] = 0x0427;
  15213. t['afii10042'] = 0x0428;
  15214. t['afii10043'] = 0x0429;
  15215. t['afii10044'] = 0x042A;
  15216. t['afii10045'] = 0x042B;
  15217. t['afii10046'] = 0x042C;
  15218. t['afii10047'] = 0x042D;
  15219. t['afii10048'] = 0x042E;
  15220. t['afii10049'] = 0x042F;
  15221. t['afii10050'] = 0x0490;
  15222. t['afii10051'] = 0x0402;
  15223. t['afii10052'] = 0x0403;
  15224. t['afii10053'] = 0x0404;
  15225. t['afii10054'] = 0x0405;
  15226. t['afii10055'] = 0x0406;
  15227. t['afii10056'] = 0x0407;
  15228. t['afii10057'] = 0x0408;
  15229. t['afii10058'] = 0x0409;
  15230. t['afii10059'] = 0x040A;
  15231. t['afii10060'] = 0x040B;
  15232. t['afii10061'] = 0x040C;
  15233. t['afii10062'] = 0x040E;
  15234. t['afii10063'] = 0xF6C4;
  15235. t['afii10064'] = 0xF6C5;
  15236. t['afii10065'] = 0x0430;
  15237. t['afii10066'] = 0x0431;
  15238. t['afii10067'] = 0x0432;
  15239. t['afii10068'] = 0x0433;
  15240. t['afii10069'] = 0x0434;
  15241. t['afii10070'] = 0x0435;
  15242. t['afii10071'] = 0x0451;
  15243. t['afii10072'] = 0x0436;
  15244. t['afii10073'] = 0x0437;
  15245. t['afii10074'] = 0x0438;
  15246. t['afii10075'] = 0x0439;
  15247. t['afii10076'] = 0x043A;
  15248. t['afii10077'] = 0x043B;
  15249. t['afii10078'] = 0x043C;
  15250. t['afii10079'] = 0x043D;
  15251. t['afii10080'] = 0x043E;
  15252. t['afii10081'] = 0x043F;
  15253. t['afii10082'] = 0x0440;
  15254. t['afii10083'] = 0x0441;
  15255. t['afii10084'] = 0x0442;
  15256. t['afii10085'] = 0x0443;
  15257. t['afii10086'] = 0x0444;
  15258. t['afii10087'] = 0x0445;
  15259. t['afii10088'] = 0x0446;
  15260. t['afii10089'] = 0x0447;
  15261. t['afii10090'] = 0x0448;
  15262. t['afii10091'] = 0x0449;
  15263. t['afii10092'] = 0x044A;
  15264. t['afii10093'] = 0x044B;
  15265. t['afii10094'] = 0x044C;
  15266. t['afii10095'] = 0x044D;
  15267. t['afii10096'] = 0x044E;
  15268. t['afii10097'] = 0x044F;
  15269. t['afii10098'] = 0x0491;
  15270. t['afii10099'] = 0x0452;
  15271. t['afii10100'] = 0x0453;
  15272. t['afii10101'] = 0x0454;
  15273. t['afii10102'] = 0x0455;
  15274. t['afii10103'] = 0x0456;
  15275. t['afii10104'] = 0x0457;
  15276. t['afii10105'] = 0x0458;
  15277. t['afii10106'] = 0x0459;
  15278. t['afii10107'] = 0x045A;
  15279. t['afii10108'] = 0x045B;
  15280. t['afii10109'] = 0x045C;
  15281. t['afii10110'] = 0x045E;
  15282. t['afii10145'] = 0x040F;
  15283. t['afii10146'] = 0x0462;
  15284. t['afii10147'] = 0x0472;
  15285. t['afii10148'] = 0x0474;
  15286. t['afii10192'] = 0xF6C6;
  15287. t['afii10193'] = 0x045F;
  15288. t['afii10194'] = 0x0463;
  15289. t['afii10195'] = 0x0473;
  15290. t['afii10196'] = 0x0475;
  15291. t['afii10831'] = 0xF6C7;
  15292. t['afii10832'] = 0xF6C8;
  15293. t['afii10846'] = 0x04D9;
  15294. t['afii299'] = 0x200E;
  15295. t['afii300'] = 0x200F;
  15296. t['afii301'] = 0x200D;
  15297. t['afii57381'] = 0x066A;
  15298. t['afii57388'] = 0x060C;
  15299. t['afii57392'] = 0x0660;
  15300. t['afii57393'] = 0x0661;
  15301. t['afii57394'] = 0x0662;
  15302. t['afii57395'] = 0x0663;
  15303. t['afii57396'] = 0x0664;
  15304. t['afii57397'] = 0x0665;
  15305. t['afii57398'] = 0x0666;
  15306. t['afii57399'] = 0x0667;
  15307. t['afii57400'] = 0x0668;
  15308. t['afii57401'] = 0x0669;
  15309. t['afii57403'] = 0x061B;
  15310. t['afii57407'] = 0x061F;
  15311. t['afii57409'] = 0x0621;
  15312. t['afii57410'] = 0x0622;
  15313. t['afii57411'] = 0x0623;
  15314. t['afii57412'] = 0x0624;
  15315. t['afii57413'] = 0x0625;
  15316. t['afii57414'] = 0x0626;
  15317. t['afii57415'] = 0x0627;
  15318. t['afii57416'] = 0x0628;
  15319. t['afii57417'] = 0x0629;
  15320. t['afii57418'] = 0x062A;
  15321. t['afii57419'] = 0x062B;
  15322. t['afii57420'] = 0x062C;
  15323. t['afii57421'] = 0x062D;
  15324. t['afii57422'] = 0x062E;
  15325. t['afii57423'] = 0x062F;
  15326. t['afii57424'] = 0x0630;
  15327. t['afii57425'] = 0x0631;
  15328. t['afii57426'] = 0x0632;
  15329. t['afii57427'] = 0x0633;
  15330. t['afii57428'] = 0x0634;
  15331. t['afii57429'] = 0x0635;
  15332. t['afii57430'] = 0x0636;
  15333. t['afii57431'] = 0x0637;
  15334. t['afii57432'] = 0x0638;
  15335. t['afii57433'] = 0x0639;
  15336. t['afii57434'] = 0x063A;
  15337. t['afii57440'] = 0x0640;
  15338. t['afii57441'] = 0x0641;
  15339. t['afii57442'] = 0x0642;
  15340. t['afii57443'] = 0x0643;
  15341. t['afii57444'] = 0x0644;
  15342. t['afii57445'] = 0x0645;
  15343. t['afii57446'] = 0x0646;
  15344. t['afii57448'] = 0x0648;
  15345. t['afii57449'] = 0x0649;
  15346. t['afii57450'] = 0x064A;
  15347. t['afii57451'] = 0x064B;
  15348. t['afii57452'] = 0x064C;
  15349. t['afii57453'] = 0x064D;
  15350. t['afii57454'] = 0x064E;
  15351. t['afii57455'] = 0x064F;
  15352. t['afii57456'] = 0x0650;
  15353. t['afii57457'] = 0x0651;
  15354. t['afii57458'] = 0x0652;
  15355. t['afii57470'] = 0x0647;
  15356. t['afii57505'] = 0x06A4;
  15357. t['afii57506'] = 0x067E;
  15358. t['afii57507'] = 0x0686;
  15359. t['afii57508'] = 0x0698;
  15360. t['afii57509'] = 0x06AF;
  15361. t['afii57511'] = 0x0679;
  15362. t['afii57512'] = 0x0688;
  15363. t['afii57513'] = 0x0691;
  15364. t['afii57514'] = 0x06BA;
  15365. t['afii57519'] = 0x06D2;
  15366. t['afii57534'] = 0x06D5;
  15367. t['afii57636'] = 0x20AA;
  15368. t['afii57645'] = 0x05BE;
  15369. t['afii57658'] = 0x05C3;
  15370. t['afii57664'] = 0x05D0;
  15371. t['afii57665'] = 0x05D1;
  15372. t['afii57666'] = 0x05D2;
  15373. t['afii57667'] = 0x05D3;
  15374. t['afii57668'] = 0x05D4;
  15375. t['afii57669'] = 0x05D5;
  15376. t['afii57670'] = 0x05D6;
  15377. t['afii57671'] = 0x05D7;
  15378. t['afii57672'] = 0x05D8;
  15379. t['afii57673'] = 0x05D9;
  15380. t['afii57674'] = 0x05DA;
  15381. t['afii57675'] = 0x05DB;
  15382. t['afii57676'] = 0x05DC;
  15383. t['afii57677'] = 0x05DD;
  15384. t['afii57678'] = 0x05DE;
  15385. t['afii57679'] = 0x05DF;
  15386. t['afii57680'] = 0x05E0;
  15387. t['afii57681'] = 0x05E1;
  15388. t['afii57682'] = 0x05E2;
  15389. t['afii57683'] = 0x05E3;
  15390. t['afii57684'] = 0x05E4;
  15391. t['afii57685'] = 0x05E5;
  15392. t['afii57686'] = 0x05E6;
  15393. t['afii57687'] = 0x05E7;
  15394. t['afii57688'] = 0x05E8;
  15395. t['afii57689'] = 0x05E9;
  15396. t['afii57690'] = 0x05EA;
  15397. t['afii57694'] = 0xFB2A;
  15398. t['afii57695'] = 0xFB2B;
  15399. t['afii57700'] = 0xFB4B;
  15400. t['afii57705'] = 0xFB1F;
  15401. t['afii57716'] = 0x05F0;
  15402. t['afii57717'] = 0x05F1;
  15403. t['afii57718'] = 0x05F2;
  15404. t['afii57723'] = 0xFB35;
  15405. t['afii57793'] = 0x05B4;
  15406. t['afii57794'] = 0x05B5;
  15407. t['afii57795'] = 0x05B6;
  15408. t['afii57796'] = 0x05BB;
  15409. t['afii57797'] = 0x05B8;
  15410. t['afii57798'] = 0x05B7;
  15411. t['afii57799'] = 0x05B0;
  15412. t['afii57800'] = 0x05B2;
  15413. t['afii57801'] = 0x05B1;
  15414. t['afii57802'] = 0x05B3;
  15415. t['afii57803'] = 0x05C2;
  15416. t['afii57804'] = 0x05C1;
  15417. t['afii57806'] = 0x05B9;
  15418. t['afii57807'] = 0x05BC;
  15419. t['afii57839'] = 0x05BD;
  15420. t['afii57841'] = 0x05BF;
  15421. t['afii57842'] = 0x05C0;
  15422. t['afii57929'] = 0x02BC;
  15423. t['afii61248'] = 0x2105;
  15424. t['afii61289'] = 0x2113;
  15425. t['afii61352'] = 0x2116;
  15426. t['afii61573'] = 0x202C;
  15427. t['afii61574'] = 0x202D;
  15428. t['afii61575'] = 0x202E;
  15429. t['afii61664'] = 0x200C;
  15430. t['afii63167'] = 0x066D;
  15431. t['afii64937'] = 0x02BD;
  15432. t['agrave'] = 0x00E0;
  15433. t['agujarati'] = 0x0A85;
  15434. t['agurmukhi'] = 0x0A05;
  15435. t['ahiragana'] = 0x3042;
  15436. t['ahookabove'] = 0x1EA3;
  15437. t['aibengali'] = 0x0990;
  15438. t['aibopomofo'] = 0x311E;
  15439. t['aideva'] = 0x0910;
  15440. t['aiecyrillic'] = 0x04D5;
  15441. t['aigujarati'] = 0x0A90;
  15442. t['aigurmukhi'] = 0x0A10;
  15443. t['aimatragurmukhi'] = 0x0A48;
  15444. t['ainarabic'] = 0x0639;
  15445. t['ainfinalarabic'] = 0xFECA;
  15446. t['aininitialarabic'] = 0xFECB;
  15447. t['ainmedialarabic'] = 0xFECC;
  15448. t['ainvertedbreve'] = 0x0203;
  15449. t['aivowelsignbengali'] = 0x09C8;
  15450. t['aivowelsigndeva'] = 0x0948;
  15451. t['aivowelsigngujarati'] = 0x0AC8;
  15452. t['akatakana'] = 0x30A2;
  15453. t['akatakanahalfwidth'] = 0xFF71;
  15454. t['akorean'] = 0x314F;
  15455. t['alef'] = 0x05D0;
  15456. t['alefarabic'] = 0x0627;
  15457. t['alefdageshhebrew'] = 0xFB30;
  15458. t['aleffinalarabic'] = 0xFE8E;
  15459. t['alefhamzaabovearabic'] = 0x0623;
  15460. t['alefhamzaabovefinalarabic'] = 0xFE84;
  15461. t['alefhamzabelowarabic'] = 0x0625;
  15462. t['alefhamzabelowfinalarabic'] = 0xFE88;
  15463. t['alefhebrew'] = 0x05D0;
  15464. t['aleflamedhebrew'] = 0xFB4F;
  15465. t['alefmaddaabovearabic'] = 0x0622;
  15466. t['alefmaddaabovefinalarabic'] = 0xFE82;
  15467. t['alefmaksuraarabic'] = 0x0649;
  15468. t['alefmaksurafinalarabic'] = 0xFEF0;
  15469. t['alefmaksurainitialarabic'] = 0xFEF3;
  15470. t['alefmaksuramedialarabic'] = 0xFEF4;
  15471. t['alefpatahhebrew'] = 0xFB2E;
  15472. t['alefqamatshebrew'] = 0xFB2F;
  15473. t['aleph'] = 0x2135;
  15474. t['allequal'] = 0x224C;
  15475. t['alpha'] = 0x03B1;
  15476. t['alphatonos'] = 0x03AC;
  15477. t['amacron'] = 0x0101;
  15478. t['amonospace'] = 0xFF41;
  15479. t['ampersand'] = 0x0026;
  15480. t['ampersandmonospace'] = 0xFF06;
  15481. t['ampersandsmall'] = 0xF726;
  15482. t['amsquare'] = 0x33C2;
  15483. t['anbopomofo'] = 0x3122;
  15484. t['angbopomofo'] = 0x3124;
  15485. t['angbracketleft'] = 0x3008;
  15486. t['angbracketright'] = 0x3009;
  15487. t['angkhankhuthai'] = 0x0E5A;
  15488. t['angle'] = 0x2220;
  15489. t['anglebracketleft'] = 0x3008;
  15490. t['anglebracketleftvertical'] = 0xFE3F;
  15491. t['anglebracketright'] = 0x3009;
  15492. t['anglebracketrightvertical'] = 0xFE40;
  15493. t['angleleft'] = 0x2329;
  15494. t['angleright'] = 0x232A;
  15495. t['angstrom'] = 0x212B;
  15496. t['anoteleia'] = 0x0387;
  15497. t['anudattadeva'] = 0x0952;
  15498. t['anusvarabengali'] = 0x0982;
  15499. t['anusvaradeva'] = 0x0902;
  15500. t['anusvaragujarati'] = 0x0A82;
  15501. t['aogonek'] = 0x0105;
  15502. t['apaatosquare'] = 0x3300;
  15503. t['aparen'] = 0x249C;
  15504. t['apostrophearmenian'] = 0x055A;
  15505. t['apostrophemod'] = 0x02BC;
  15506. t['apple'] = 0xF8FF;
  15507. t['approaches'] = 0x2250;
  15508. t['approxequal'] = 0x2248;
  15509. t['approxequalorimage'] = 0x2252;
  15510. t['approximatelyequal'] = 0x2245;
  15511. t['araeaekorean'] = 0x318E;
  15512. t['araeakorean'] = 0x318D;
  15513. t['arc'] = 0x2312;
  15514. t['arighthalfring'] = 0x1E9A;
  15515. t['aring'] = 0x00E5;
  15516. t['aringacute'] = 0x01FB;
  15517. t['aringbelow'] = 0x1E01;
  15518. t['arrowboth'] = 0x2194;
  15519. t['arrowdashdown'] = 0x21E3;
  15520. t['arrowdashleft'] = 0x21E0;
  15521. t['arrowdashright'] = 0x21E2;
  15522. t['arrowdashup'] = 0x21E1;
  15523. t['arrowdblboth'] = 0x21D4;
  15524. t['arrowdbldown'] = 0x21D3;
  15525. t['arrowdblleft'] = 0x21D0;
  15526. t['arrowdblright'] = 0x21D2;
  15527. t['arrowdblup'] = 0x21D1;
  15528. t['arrowdown'] = 0x2193;
  15529. t['arrowdownleft'] = 0x2199;
  15530. t['arrowdownright'] = 0x2198;
  15531. t['arrowdownwhite'] = 0x21E9;
  15532. t['arrowheaddownmod'] = 0x02C5;
  15533. t['arrowheadleftmod'] = 0x02C2;
  15534. t['arrowheadrightmod'] = 0x02C3;
  15535. t['arrowheadupmod'] = 0x02C4;
  15536. t['arrowhorizex'] = 0xF8E7;
  15537. t['arrowleft'] = 0x2190;
  15538. t['arrowleftdbl'] = 0x21D0;
  15539. t['arrowleftdblstroke'] = 0x21CD;
  15540. t['arrowleftoverright'] = 0x21C6;
  15541. t['arrowleftwhite'] = 0x21E6;
  15542. t['arrowright'] = 0x2192;
  15543. t['arrowrightdblstroke'] = 0x21CF;
  15544. t['arrowrightheavy'] = 0x279E;
  15545. t['arrowrightoverleft'] = 0x21C4;
  15546. t['arrowrightwhite'] = 0x21E8;
  15547. t['arrowtableft'] = 0x21E4;
  15548. t['arrowtabright'] = 0x21E5;
  15549. t['arrowup'] = 0x2191;
  15550. t['arrowupdn'] = 0x2195;
  15551. t['arrowupdnbse'] = 0x21A8;
  15552. t['arrowupdownbase'] = 0x21A8;
  15553. t['arrowupleft'] = 0x2196;
  15554. t['arrowupleftofdown'] = 0x21C5;
  15555. t['arrowupright'] = 0x2197;
  15556. t['arrowupwhite'] = 0x21E7;
  15557. t['arrowvertex'] = 0xF8E6;
  15558. t['asciicircum'] = 0x005E;
  15559. t['asciicircummonospace'] = 0xFF3E;
  15560. t['asciitilde'] = 0x007E;
  15561. t['asciitildemonospace'] = 0xFF5E;
  15562. t['ascript'] = 0x0251;
  15563. t['ascriptturned'] = 0x0252;
  15564. t['asmallhiragana'] = 0x3041;
  15565. t['asmallkatakana'] = 0x30A1;
  15566. t['asmallkatakanahalfwidth'] = 0xFF67;
  15567. t['asterisk'] = 0x002A;
  15568. t['asteriskaltonearabic'] = 0x066D;
  15569. t['asteriskarabic'] = 0x066D;
  15570. t['asteriskmath'] = 0x2217;
  15571. t['asteriskmonospace'] = 0xFF0A;
  15572. t['asterisksmall'] = 0xFE61;
  15573. t['asterism'] = 0x2042;
  15574. t['asuperior'] = 0xF6E9;
  15575. t['asymptoticallyequal'] = 0x2243;
  15576. t['at'] = 0x0040;
  15577. t['atilde'] = 0x00E3;
  15578. t['atmonospace'] = 0xFF20;
  15579. t['atsmall'] = 0xFE6B;
  15580. t['aturned'] = 0x0250;
  15581. t['aubengali'] = 0x0994;
  15582. t['aubopomofo'] = 0x3120;
  15583. t['audeva'] = 0x0914;
  15584. t['augujarati'] = 0x0A94;
  15585. t['augurmukhi'] = 0x0A14;
  15586. t['aulengthmarkbengali'] = 0x09D7;
  15587. t['aumatragurmukhi'] = 0x0A4C;
  15588. t['auvowelsignbengali'] = 0x09CC;
  15589. t['auvowelsigndeva'] = 0x094C;
  15590. t['auvowelsigngujarati'] = 0x0ACC;
  15591. t['avagrahadeva'] = 0x093D;
  15592. t['aybarmenian'] = 0x0561;
  15593. t['ayin'] = 0x05E2;
  15594. t['ayinaltonehebrew'] = 0xFB20;
  15595. t['ayinhebrew'] = 0x05E2;
  15596. t['b'] = 0x0062;
  15597. t['babengali'] = 0x09AC;
  15598. t['backslash'] = 0x005C;
  15599. t['backslashmonospace'] = 0xFF3C;
  15600. t['badeva'] = 0x092C;
  15601. t['bagujarati'] = 0x0AAC;
  15602. t['bagurmukhi'] = 0x0A2C;
  15603. t['bahiragana'] = 0x3070;
  15604. t['bahtthai'] = 0x0E3F;
  15605. t['bakatakana'] = 0x30D0;
  15606. t['bar'] = 0x007C;
  15607. t['barmonospace'] = 0xFF5C;
  15608. t['bbopomofo'] = 0x3105;
  15609. t['bcircle'] = 0x24D1;
  15610. t['bdotaccent'] = 0x1E03;
  15611. t['bdotbelow'] = 0x1E05;
  15612. t['beamedsixteenthnotes'] = 0x266C;
  15613. t['because'] = 0x2235;
  15614. t['becyrillic'] = 0x0431;
  15615. t['beharabic'] = 0x0628;
  15616. t['behfinalarabic'] = 0xFE90;
  15617. t['behinitialarabic'] = 0xFE91;
  15618. t['behiragana'] = 0x3079;
  15619. t['behmedialarabic'] = 0xFE92;
  15620. t['behmeeminitialarabic'] = 0xFC9F;
  15621. t['behmeemisolatedarabic'] = 0xFC08;
  15622. t['behnoonfinalarabic'] = 0xFC6D;
  15623. t['bekatakana'] = 0x30D9;
  15624. t['benarmenian'] = 0x0562;
  15625. t['bet'] = 0x05D1;
  15626. t['beta'] = 0x03B2;
  15627. t['betasymbolgreek'] = 0x03D0;
  15628. t['betdagesh'] = 0xFB31;
  15629. t['betdageshhebrew'] = 0xFB31;
  15630. t['bethebrew'] = 0x05D1;
  15631. t['betrafehebrew'] = 0xFB4C;
  15632. t['bhabengali'] = 0x09AD;
  15633. t['bhadeva'] = 0x092D;
  15634. t['bhagujarati'] = 0x0AAD;
  15635. t['bhagurmukhi'] = 0x0A2D;
  15636. t['bhook'] = 0x0253;
  15637. t['bihiragana'] = 0x3073;
  15638. t['bikatakana'] = 0x30D3;
  15639. t['bilabialclick'] = 0x0298;
  15640. t['bindigurmukhi'] = 0x0A02;
  15641. t['birusquare'] = 0x3331;
  15642. t['blackcircle'] = 0x25CF;
  15643. t['blackdiamond'] = 0x25C6;
  15644. t['blackdownpointingtriangle'] = 0x25BC;
  15645. t['blackleftpointingpointer'] = 0x25C4;
  15646. t['blackleftpointingtriangle'] = 0x25C0;
  15647. t['blacklenticularbracketleft'] = 0x3010;
  15648. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  15649. t['blacklenticularbracketright'] = 0x3011;
  15650. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  15651. t['blacklowerlefttriangle'] = 0x25E3;
  15652. t['blacklowerrighttriangle'] = 0x25E2;
  15653. t['blackrectangle'] = 0x25AC;
  15654. t['blackrightpointingpointer'] = 0x25BA;
  15655. t['blackrightpointingtriangle'] = 0x25B6;
  15656. t['blacksmallsquare'] = 0x25AA;
  15657. t['blacksmilingface'] = 0x263B;
  15658. t['blacksquare'] = 0x25A0;
  15659. t['blackstar'] = 0x2605;
  15660. t['blackupperlefttriangle'] = 0x25E4;
  15661. t['blackupperrighttriangle'] = 0x25E5;
  15662. t['blackuppointingsmalltriangle'] = 0x25B4;
  15663. t['blackuppointingtriangle'] = 0x25B2;
  15664. t['blank'] = 0x2423;
  15665. t['blinebelow'] = 0x1E07;
  15666. t['block'] = 0x2588;
  15667. t['bmonospace'] = 0xFF42;
  15668. t['bobaimaithai'] = 0x0E1A;
  15669. t['bohiragana'] = 0x307C;
  15670. t['bokatakana'] = 0x30DC;
  15671. t['bparen'] = 0x249D;
  15672. t['bqsquare'] = 0x33C3;
  15673. t['braceex'] = 0xF8F4;
  15674. t['braceleft'] = 0x007B;
  15675. t['braceleftbt'] = 0xF8F3;
  15676. t['braceleftmid'] = 0xF8F2;
  15677. t['braceleftmonospace'] = 0xFF5B;
  15678. t['braceleftsmall'] = 0xFE5B;
  15679. t['bracelefttp'] = 0xF8F1;
  15680. t['braceleftvertical'] = 0xFE37;
  15681. t['braceright'] = 0x007D;
  15682. t['bracerightbt'] = 0xF8FE;
  15683. t['bracerightmid'] = 0xF8FD;
  15684. t['bracerightmonospace'] = 0xFF5D;
  15685. t['bracerightsmall'] = 0xFE5C;
  15686. t['bracerighttp'] = 0xF8FC;
  15687. t['bracerightvertical'] = 0xFE38;
  15688. t['bracketleft'] = 0x005B;
  15689. t['bracketleftbt'] = 0xF8F0;
  15690. t['bracketleftex'] = 0xF8EF;
  15691. t['bracketleftmonospace'] = 0xFF3B;
  15692. t['bracketlefttp'] = 0xF8EE;
  15693. t['bracketright'] = 0x005D;
  15694. t['bracketrightbt'] = 0xF8FB;
  15695. t['bracketrightex'] = 0xF8FA;
  15696. t['bracketrightmonospace'] = 0xFF3D;
  15697. t['bracketrighttp'] = 0xF8F9;
  15698. t['breve'] = 0x02D8;
  15699. t['brevebelowcmb'] = 0x032E;
  15700. t['brevecmb'] = 0x0306;
  15701. t['breveinvertedbelowcmb'] = 0x032F;
  15702. t['breveinvertedcmb'] = 0x0311;
  15703. t['breveinverteddoublecmb'] = 0x0361;
  15704. t['bridgebelowcmb'] = 0x032A;
  15705. t['bridgeinvertedbelowcmb'] = 0x033A;
  15706. t['brokenbar'] = 0x00A6;
  15707. t['bstroke'] = 0x0180;
  15708. t['bsuperior'] = 0xF6EA;
  15709. t['btopbar'] = 0x0183;
  15710. t['buhiragana'] = 0x3076;
  15711. t['bukatakana'] = 0x30D6;
  15712. t['bullet'] = 0x2022;
  15713. t['bulletinverse'] = 0x25D8;
  15714. t['bulletoperator'] = 0x2219;
  15715. t['bullseye'] = 0x25CE;
  15716. t['c'] = 0x0063;
  15717. t['caarmenian'] = 0x056E;
  15718. t['cabengali'] = 0x099A;
  15719. t['cacute'] = 0x0107;
  15720. t['cadeva'] = 0x091A;
  15721. t['cagujarati'] = 0x0A9A;
  15722. t['cagurmukhi'] = 0x0A1A;
  15723. t['calsquare'] = 0x3388;
  15724. t['candrabindubengali'] = 0x0981;
  15725. t['candrabinducmb'] = 0x0310;
  15726. t['candrabindudeva'] = 0x0901;
  15727. t['candrabindugujarati'] = 0x0A81;
  15728. t['capslock'] = 0x21EA;
  15729. t['careof'] = 0x2105;
  15730. t['caron'] = 0x02C7;
  15731. t['caronbelowcmb'] = 0x032C;
  15732. t['caroncmb'] = 0x030C;
  15733. t['carriagereturn'] = 0x21B5;
  15734. t['cbopomofo'] = 0x3118;
  15735. t['ccaron'] = 0x010D;
  15736. t['ccedilla'] = 0x00E7;
  15737. t['ccedillaacute'] = 0x1E09;
  15738. t['ccircle'] = 0x24D2;
  15739. t['ccircumflex'] = 0x0109;
  15740. t['ccurl'] = 0x0255;
  15741. t['cdot'] = 0x010B;
  15742. t['cdotaccent'] = 0x010B;
  15743. t['cdsquare'] = 0x33C5;
  15744. t['cedilla'] = 0x00B8;
  15745. t['cedillacmb'] = 0x0327;
  15746. t['cent'] = 0x00A2;
  15747. t['centigrade'] = 0x2103;
  15748. t['centinferior'] = 0xF6DF;
  15749. t['centmonospace'] = 0xFFE0;
  15750. t['centoldstyle'] = 0xF7A2;
  15751. t['centsuperior'] = 0xF6E0;
  15752. t['chaarmenian'] = 0x0579;
  15753. t['chabengali'] = 0x099B;
  15754. t['chadeva'] = 0x091B;
  15755. t['chagujarati'] = 0x0A9B;
  15756. t['chagurmukhi'] = 0x0A1B;
  15757. t['chbopomofo'] = 0x3114;
  15758. t['cheabkhasiancyrillic'] = 0x04BD;
  15759. t['checkmark'] = 0x2713;
  15760. t['checyrillic'] = 0x0447;
  15761. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  15762. t['chedescendercyrillic'] = 0x04B7;
  15763. t['chedieresiscyrillic'] = 0x04F5;
  15764. t['cheharmenian'] = 0x0573;
  15765. t['chekhakassiancyrillic'] = 0x04CC;
  15766. t['cheverticalstrokecyrillic'] = 0x04B9;
  15767. t['chi'] = 0x03C7;
  15768. t['chieuchacirclekorean'] = 0x3277;
  15769. t['chieuchaparenkorean'] = 0x3217;
  15770. t['chieuchcirclekorean'] = 0x3269;
  15771. t['chieuchkorean'] = 0x314A;
  15772. t['chieuchparenkorean'] = 0x3209;
  15773. t['chochangthai'] = 0x0E0A;
  15774. t['chochanthai'] = 0x0E08;
  15775. t['chochingthai'] = 0x0E09;
  15776. t['chochoethai'] = 0x0E0C;
  15777. t['chook'] = 0x0188;
  15778. t['cieucacirclekorean'] = 0x3276;
  15779. t['cieucaparenkorean'] = 0x3216;
  15780. t['cieuccirclekorean'] = 0x3268;
  15781. t['cieuckorean'] = 0x3148;
  15782. t['cieucparenkorean'] = 0x3208;
  15783. t['cieucuparenkorean'] = 0x321C;
  15784. t['circle'] = 0x25CB;
  15785. t['circlecopyrt'] = 0x00A9;
  15786. t['circlemultiply'] = 0x2297;
  15787. t['circleot'] = 0x2299;
  15788. t['circleplus'] = 0x2295;
  15789. t['circlepostalmark'] = 0x3036;
  15790. t['circlewithlefthalfblack'] = 0x25D0;
  15791. t['circlewithrighthalfblack'] = 0x25D1;
  15792. t['circumflex'] = 0x02C6;
  15793. t['circumflexbelowcmb'] = 0x032D;
  15794. t['circumflexcmb'] = 0x0302;
  15795. t['clear'] = 0x2327;
  15796. t['clickalveolar'] = 0x01C2;
  15797. t['clickdental'] = 0x01C0;
  15798. t['clicklateral'] = 0x01C1;
  15799. t['clickretroflex'] = 0x01C3;
  15800. t['club'] = 0x2663;
  15801. t['clubsuitblack'] = 0x2663;
  15802. t['clubsuitwhite'] = 0x2667;
  15803. t['cmcubedsquare'] = 0x33A4;
  15804. t['cmonospace'] = 0xFF43;
  15805. t['cmsquaredsquare'] = 0x33A0;
  15806. t['coarmenian'] = 0x0581;
  15807. t['colon'] = 0x003A;
  15808. t['colonmonetary'] = 0x20A1;
  15809. t['colonmonospace'] = 0xFF1A;
  15810. t['colonsign'] = 0x20A1;
  15811. t['colonsmall'] = 0xFE55;
  15812. t['colontriangularhalfmod'] = 0x02D1;
  15813. t['colontriangularmod'] = 0x02D0;
  15814. t['comma'] = 0x002C;
  15815. t['commaabovecmb'] = 0x0313;
  15816. t['commaaboverightcmb'] = 0x0315;
  15817. t['commaaccent'] = 0xF6C3;
  15818. t['commaarabic'] = 0x060C;
  15819. t['commaarmenian'] = 0x055D;
  15820. t['commainferior'] = 0xF6E1;
  15821. t['commamonospace'] = 0xFF0C;
  15822. t['commareversedabovecmb'] = 0x0314;
  15823. t['commareversedmod'] = 0x02BD;
  15824. t['commasmall'] = 0xFE50;
  15825. t['commasuperior'] = 0xF6E2;
  15826. t['commaturnedabovecmb'] = 0x0312;
  15827. t['commaturnedmod'] = 0x02BB;
  15828. t['compass'] = 0x263C;
  15829. t['congruent'] = 0x2245;
  15830. t['contourintegral'] = 0x222E;
  15831. t['control'] = 0x2303;
  15832. t['controlACK'] = 0x0006;
  15833. t['controlBEL'] = 0x0007;
  15834. t['controlBS'] = 0x0008;
  15835. t['controlCAN'] = 0x0018;
  15836. t['controlCR'] = 0x000D;
  15837. t['controlDC1'] = 0x0011;
  15838. t['controlDC2'] = 0x0012;
  15839. t['controlDC3'] = 0x0013;
  15840. t['controlDC4'] = 0x0014;
  15841. t['controlDEL'] = 0x007F;
  15842. t['controlDLE'] = 0x0010;
  15843. t['controlEM'] = 0x0019;
  15844. t['controlENQ'] = 0x0005;
  15845. t['controlEOT'] = 0x0004;
  15846. t['controlESC'] = 0x001B;
  15847. t['controlETB'] = 0x0017;
  15848. t['controlETX'] = 0x0003;
  15849. t['controlFF'] = 0x000C;
  15850. t['controlFS'] = 0x001C;
  15851. t['controlGS'] = 0x001D;
  15852. t['controlHT'] = 0x0009;
  15853. t['controlLF'] = 0x000A;
  15854. t['controlNAK'] = 0x0015;
  15855. t['controlNULL'] = 0x0000;
  15856. t['controlRS'] = 0x001E;
  15857. t['controlSI'] = 0x000F;
  15858. t['controlSO'] = 0x000E;
  15859. t['controlSOT'] = 0x0002;
  15860. t['controlSTX'] = 0x0001;
  15861. t['controlSUB'] = 0x001A;
  15862. t['controlSYN'] = 0x0016;
  15863. t['controlUS'] = 0x001F;
  15864. t['controlVT'] = 0x000B;
  15865. t['copyright'] = 0x00A9;
  15866. t['copyrightsans'] = 0xF8E9;
  15867. t['copyrightserif'] = 0xF6D9;
  15868. t['cornerbracketleft'] = 0x300C;
  15869. t['cornerbracketlefthalfwidth'] = 0xFF62;
  15870. t['cornerbracketleftvertical'] = 0xFE41;
  15871. t['cornerbracketright'] = 0x300D;
  15872. t['cornerbracketrighthalfwidth'] = 0xFF63;
  15873. t['cornerbracketrightvertical'] = 0xFE42;
  15874. t['corporationsquare'] = 0x337F;
  15875. t['cosquare'] = 0x33C7;
  15876. t['coverkgsquare'] = 0x33C6;
  15877. t['cparen'] = 0x249E;
  15878. t['cruzeiro'] = 0x20A2;
  15879. t['cstretched'] = 0x0297;
  15880. t['curlyand'] = 0x22CF;
  15881. t['curlyor'] = 0x22CE;
  15882. t['currency'] = 0x00A4;
  15883. t['cyrBreve'] = 0xF6D1;
  15884. t['cyrFlex'] = 0xF6D2;
  15885. t['cyrbreve'] = 0xF6D4;
  15886. t['cyrflex'] = 0xF6D5;
  15887. t['d'] = 0x0064;
  15888. t['daarmenian'] = 0x0564;
  15889. t['dabengali'] = 0x09A6;
  15890. t['dadarabic'] = 0x0636;
  15891. t['dadeva'] = 0x0926;
  15892. t['dadfinalarabic'] = 0xFEBE;
  15893. t['dadinitialarabic'] = 0xFEBF;
  15894. t['dadmedialarabic'] = 0xFEC0;
  15895. t['dagesh'] = 0x05BC;
  15896. t['dageshhebrew'] = 0x05BC;
  15897. t['dagger'] = 0x2020;
  15898. t['daggerdbl'] = 0x2021;
  15899. t['dagujarati'] = 0x0AA6;
  15900. t['dagurmukhi'] = 0x0A26;
  15901. t['dahiragana'] = 0x3060;
  15902. t['dakatakana'] = 0x30C0;
  15903. t['dalarabic'] = 0x062F;
  15904. t['dalet'] = 0x05D3;
  15905. t['daletdagesh'] = 0xFB33;
  15906. t['daletdageshhebrew'] = 0xFB33;
  15907. t['dalethebrew'] = 0x05D3;
  15908. t['dalfinalarabic'] = 0xFEAA;
  15909. t['dammaarabic'] = 0x064F;
  15910. t['dammalowarabic'] = 0x064F;
  15911. t['dammatanaltonearabic'] = 0x064C;
  15912. t['dammatanarabic'] = 0x064C;
  15913. t['danda'] = 0x0964;
  15914. t['dargahebrew'] = 0x05A7;
  15915. t['dargalefthebrew'] = 0x05A7;
  15916. t['dasiapneumatacyrilliccmb'] = 0x0485;
  15917. t['dblGrave'] = 0xF6D3;
  15918. t['dblanglebracketleft'] = 0x300A;
  15919. t['dblanglebracketleftvertical'] = 0xFE3D;
  15920. t['dblanglebracketright'] = 0x300B;
  15921. t['dblanglebracketrightvertical'] = 0xFE3E;
  15922. t['dblarchinvertedbelowcmb'] = 0x032B;
  15923. t['dblarrowleft'] = 0x21D4;
  15924. t['dblarrowright'] = 0x21D2;
  15925. t['dbldanda'] = 0x0965;
  15926. t['dblgrave'] = 0xF6D6;
  15927. t['dblgravecmb'] = 0x030F;
  15928. t['dblintegral'] = 0x222C;
  15929. t['dbllowline'] = 0x2017;
  15930. t['dbllowlinecmb'] = 0x0333;
  15931. t['dbloverlinecmb'] = 0x033F;
  15932. t['dblprimemod'] = 0x02BA;
  15933. t['dblverticalbar'] = 0x2016;
  15934. t['dblverticallineabovecmb'] = 0x030E;
  15935. t['dbopomofo'] = 0x3109;
  15936. t['dbsquare'] = 0x33C8;
  15937. t['dcaron'] = 0x010F;
  15938. t['dcedilla'] = 0x1E11;
  15939. t['dcircle'] = 0x24D3;
  15940. t['dcircumflexbelow'] = 0x1E13;
  15941. t['dcroat'] = 0x0111;
  15942. t['ddabengali'] = 0x09A1;
  15943. t['ddadeva'] = 0x0921;
  15944. t['ddagujarati'] = 0x0AA1;
  15945. t['ddagurmukhi'] = 0x0A21;
  15946. t['ddalarabic'] = 0x0688;
  15947. t['ddalfinalarabic'] = 0xFB89;
  15948. t['dddhadeva'] = 0x095C;
  15949. t['ddhabengali'] = 0x09A2;
  15950. t['ddhadeva'] = 0x0922;
  15951. t['ddhagujarati'] = 0x0AA2;
  15952. t['ddhagurmukhi'] = 0x0A22;
  15953. t['ddotaccent'] = 0x1E0B;
  15954. t['ddotbelow'] = 0x1E0D;
  15955. t['decimalseparatorarabic'] = 0x066B;
  15956. t['decimalseparatorpersian'] = 0x066B;
  15957. t['decyrillic'] = 0x0434;
  15958. t['degree'] = 0x00B0;
  15959. t['dehihebrew'] = 0x05AD;
  15960. t['dehiragana'] = 0x3067;
  15961. t['deicoptic'] = 0x03EF;
  15962. t['dekatakana'] = 0x30C7;
  15963. t['deleteleft'] = 0x232B;
  15964. t['deleteright'] = 0x2326;
  15965. t['delta'] = 0x03B4;
  15966. t['deltaturned'] = 0x018D;
  15967. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  15968. t['dezh'] = 0x02A4;
  15969. t['dhabengali'] = 0x09A7;
  15970. t['dhadeva'] = 0x0927;
  15971. t['dhagujarati'] = 0x0AA7;
  15972. t['dhagurmukhi'] = 0x0A27;
  15973. t['dhook'] = 0x0257;
  15974. t['dialytikatonos'] = 0x0385;
  15975. t['dialytikatonoscmb'] = 0x0344;
  15976. t['diamond'] = 0x2666;
  15977. t['diamondsuitwhite'] = 0x2662;
  15978. t['dieresis'] = 0x00A8;
  15979. t['dieresisacute'] = 0xF6D7;
  15980. t['dieresisbelowcmb'] = 0x0324;
  15981. t['dieresiscmb'] = 0x0308;
  15982. t['dieresisgrave'] = 0xF6D8;
  15983. t['dieresistonos'] = 0x0385;
  15984. t['dihiragana'] = 0x3062;
  15985. t['dikatakana'] = 0x30C2;
  15986. t['dittomark'] = 0x3003;
  15987. t['divide'] = 0x00F7;
  15988. t['divides'] = 0x2223;
  15989. t['divisionslash'] = 0x2215;
  15990. t['djecyrillic'] = 0x0452;
  15991. t['dkshade'] = 0x2593;
  15992. t['dlinebelow'] = 0x1E0F;
  15993. t['dlsquare'] = 0x3397;
  15994. t['dmacron'] = 0x0111;
  15995. t['dmonospace'] = 0xFF44;
  15996. t['dnblock'] = 0x2584;
  15997. t['dochadathai'] = 0x0E0E;
  15998. t['dodekthai'] = 0x0E14;
  15999. t['dohiragana'] = 0x3069;
  16000. t['dokatakana'] = 0x30C9;
  16001. t['dollar'] = 0x0024;
  16002. t['dollarinferior'] = 0xF6E3;
  16003. t['dollarmonospace'] = 0xFF04;
  16004. t['dollaroldstyle'] = 0xF724;
  16005. t['dollarsmall'] = 0xFE69;
  16006. t['dollarsuperior'] = 0xF6E4;
  16007. t['dong'] = 0x20AB;
  16008. t['dorusquare'] = 0x3326;
  16009. t['dotaccent'] = 0x02D9;
  16010. t['dotaccentcmb'] = 0x0307;
  16011. t['dotbelowcmb'] = 0x0323;
  16012. t['dotbelowcomb'] = 0x0323;
  16013. t['dotkatakana'] = 0x30FB;
  16014. t['dotlessi'] = 0x0131;
  16015. t['dotlessj'] = 0xF6BE;
  16016. t['dotlessjstrokehook'] = 0x0284;
  16017. t['dotmath'] = 0x22C5;
  16018. t['dottedcircle'] = 0x25CC;
  16019. t['doubleyodpatah'] = 0xFB1F;
  16020. t['doubleyodpatahhebrew'] = 0xFB1F;
  16021. t['downtackbelowcmb'] = 0x031E;
  16022. t['downtackmod'] = 0x02D5;
  16023. t['dparen'] = 0x249F;
  16024. t['dsuperior'] = 0xF6EB;
  16025. t['dtail'] = 0x0256;
  16026. t['dtopbar'] = 0x018C;
  16027. t['duhiragana'] = 0x3065;
  16028. t['dukatakana'] = 0x30C5;
  16029. t['dz'] = 0x01F3;
  16030. t['dzaltone'] = 0x02A3;
  16031. t['dzcaron'] = 0x01C6;
  16032. t['dzcurl'] = 0x02A5;
  16033. t['dzeabkhasiancyrillic'] = 0x04E1;
  16034. t['dzecyrillic'] = 0x0455;
  16035. t['dzhecyrillic'] = 0x045F;
  16036. t['e'] = 0x0065;
  16037. t['eacute'] = 0x00E9;
  16038. t['earth'] = 0x2641;
  16039. t['ebengali'] = 0x098F;
  16040. t['ebopomofo'] = 0x311C;
  16041. t['ebreve'] = 0x0115;
  16042. t['ecandradeva'] = 0x090D;
  16043. t['ecandragujarati'] = 0x0A8D;
  16044. t['ecandravowelsigndeva'] = 0x0945;
  16045. t['ecandravowelsigngujarati'] = 0x0AC5;
  16046. t['ecaron'] = 0x011B;
  16047. t['ecedillabreve'] = 0x1E1D;
  16048. t['echarmenian'] = 0x0565;
  16049. t['echyiwnarmenian'] = 0x0587;
  16050. t['ecircle'] = 0x24D4;
  16051. t['ecircumflex'] = 0x00EA;
  16052. t['ecircumflexacute'] = 0x1EBF;
  16053. t['ecircumflexbelow'] = 0x1E19;
  16054. t['ecircumflexdotbelow'] = 0x1EC7;
  16055. t['ecircumflexgrave'] = 0x1EC1;
  16056. t['ecircumflexhookabove'] = 0x1EC3;
  16057. t['ecircumflextilde'] = 0x1EC5;
  16058. t['ecyrillic'] = 0x0454;
  16059. t['edblgrave'] = 0x0205;
  16060. t['edeva'] = 0x090F;
  16061. t['edieresis'] = 0x00EB;
  16062. t['edot'] = 0x0117;
  16063. t['edotaccent'] = 0x0117;
  16064. t['edotbelow'] = 0x1EB9;
  16065. t['eegurmukhi'] = 0x0A0F;
  16066. t['eematragurmukhi'] = 0x0A47;
  16067. t['efcyrillic'] = 0x0444;
  16068. t['egrave'] = 0x00E8;
  16069. t['egujarati'] = 0x0A8F;
  16070. t['eharmenian'] = 0x0567;
  16071. t['ehbopomofo'] = 0x311D;
  16072. t['ehiragana'] = 0x3048;
  16073. t['ehookabove'] = 0x1EBB;
  16074. t['eibopomofo'] = 0x311F;
  16075. t['eight'] = 0x0038;
  16076. t['eightarabic'] = 0x0668;
  16077. t['eightbengali'] = 0x09EE;
  16078. t['eightcircle'] = 0x2467;
  16079. t['eightcircleinversesansserif'] = 0x2791;
  16080. t['eightdeva'] = 0x096E;
  16081. t['eighteencircle'] = 0x2471;
  16082. t['eighteenparen'] = 0x2485;
  16083. t['eighteenperiod'] = 0x2499;
  16084. t['eightgujarati'] = 0x0AEE;
  16085. t['eightgurmukhi'] = 0x0A6E;
  16086. t['eighthackarabic'] = 0x0668;
  16087. t['eighthangzhou'] = 0x3028;
  16088. t['eighthnotebeamed'] = 0x266B;
  16089. t['eightideographicparen'] = 0x3227;
  16090. t['eightinferior'] = 0x2088;
  16091. t['eightmonospace'] = 0xFF18;
  16092. t['eightoldstyle'] = 0xF738;
  16093. t['eightparen'] = 0x247B;
  16094. t['eightperiod'] = 0x248F;
  16095. t['eightpersian'] = 0x06F8;
  16096. t['eightroman'] = 0x2177;
  16097. t['eightsuperior'] = 0x2078;
  16098. t['eightthai'] = 0x0E58;
  16099. t['einvertedbreve'] = 0x0207;
  16100. t['eiotifiedcyrillic'] = 0x0465;
  16101. t['ekatakana'] = 0x30A8;
  16102. t['ekatakanahalfwidth'] = 0xFF74;
  16103. t['ekonkargurmukhi'] = 0x0A74;
  16104. t['ekorean'] = 0x3154;
  16105. t['elcyrillic'] = 0x043B;
  16106. t['element'] = 0x2208;
  16107. t['elevencircle'] = 0x246A;
  16108. t['elevenparen'] = 0x247E;
  16109. t['elevenperiod'] = 0x2492;
  16110. t['elevenroman'] = 0x217A;
  16111. t['ellipsis'] = 0x2026;
  16112. t['ellipsisvertical'] = 0x22EE;
  16113. t['emacron'] = 0x0113;
  16114. t['emacronacute'] = 0x1E17;
  16115. t['emacrongrave'] = 0x1E15;
  16116. t['emcyrillic'] = 0x043C;
  16117. t['emdash'] = 0x2014;
  16118. t['emdashvertical'] = 0xFE31;
  16119. t['emonospace'] = 0xFF45;
  16120. t['emphasismarkarmenian'] = 0x055B;
  16121. t['emptyset'] = 0x2205;
  16122. t['enbopomofo'] = 0x3123;
  16123. t['encyrillic'] = 0x043D;
  16124. t['endash'] = 0x2013;
  16125. t['endashvertical'] = 0xFE32;
  16126. t['endescendercyrillic'] = 0x04A3;
  16127. t['eng'] = 0x014B;
  16128. t['engbopomofo'] = 0x3125;
  16129. t['enghecyrillic'] = 0x04A5;
  16130. t['enhookcyrillic'] = 0x04C8;
  16131. t['enspace'] = 0x2002;
  16132. t['eogonek'] = 0x0119;
  16133. t['eokorean'] = 0x3153;
  16134. t['eopen'] = 0x025B;
  16135. t['eopenclosed'] = 0x029A;
  16136. t['eopenreversed'] = 0x025C;
  16137. t['eopenreversedclosed'] = 0x025E;
  16138. t['eopenreversedhook'] = 0x025D;
  16139. t['eparen'] = 0x24A0;
  16140. t['epsilon'] = 0x03B5;
  16141. t['epsilontonos'] = 0x03AD;
  16142. t['equal'] = 0x003D;
  16143. t['equalmonospace'] = 0xFF1D;
  16144. t['equalsmall'] = 0xFE66;
  16145. t['equalsuperior'] = 0x207C;
  16146. t['equivalence'] = 0x2261;
  16147. t['erbopomofo'] = 0x3126;
  16148. t['ercyrillic'] = 0x0440;
  16149. t['ereversed'] = 0x0258;
  16150. t['ereversedcyrillic'] = 0x044D;
  16151. t['escyrillic'] = 0x0441;
  16152. t['esdescendercyrillic'] = 0x04AB;
  16153. t['esh'] = 0x0283;
  16154. t['eshcurl'] = 0x0286;
  16155. t['eshortdeva'] = 0x090E;
  16156. t['eshortvowelsigndeva'] = 0x0946;
  16157. t['eshreversedloop'] = 0x01AA;
  16158. t['eshsquatreversed'] = 0x0285;
  16159. t['esmallhiragana'] = 0x3047;
  16160. t['esmallkatakana'] = 0x30A7;
  16161. t['esmallkatakanahalfwidth'] = 0xFF6A;
  16162. t['estimated'] = 0x212E;
  16163. t['esuperior'] = 0xF6EC;
  16164. t['eta'] = 0x03B7;
  16165. t['etarmenian'] = 0x0568;
  16166. t['etatonos'] = 0x03AE;
  16167. t['eth'] = 0x00F0;
  16168. t['etilde'] = 0x1EBD;
  16169. t['etildebelow'] = 0x1E1B;
  16170. t['etnahtafoukhhebrew'] = 0x0591;
  16171. t['etnahtafoukhlefthebrew'] = 0x0591;
  16172. t['etnahtahebrew'] = 0x0591;
  16173. t['etnahtalefthebrew'] = 0x0591;
  16174. t['eturned'] = 0x01DD;
  16175. t['eukorean'] = 0x3161;
  16176. t['euro'] = 0x20AC;
  16177. t['evowelsignbengali'] = 0x09C7;
  16178. t['evowelsigndeva'] = 0x0947;
  16179. t['evowelsigngujarati'] = 0x0AC7;
  16180. t['exclam'] = 0x0021;
  16181. t['exclamarmenian'] = 0x055C;
  16182. t['exclamdbl'] = 0x203C;
  16183. t['exclamdown'] = 0x00A1;
  16184. t['exclamdownsmall'] = 0xF7A1;
  16185. t['exclammonospace'] = 0xFF01;
  16186. t['exclamsmall'] = 0xF721;
  16187. t['existential'] = 0x2203;
  16188. t['ezh'] = 0x0292;
  16189. t['ezhcaron'] = 0x01EF;
  16190. t['ezhcurl'] = 0x0293;
  16191. t['ezhreversed'] = 0x01B9;
  16192. t['ezhtail'] = 0x01BA;
  16193. t['f'] = 0x0066;
  16194. t['fadeva'] = 0x095E;
  16195. t['fagurmukhi'] = 0x0A5E;
  16196. t['fahrenheit'] = 0x2109;
  16197. t['fathaarabic'] = 0x064E;
  16198. t['fathalowarabic'] = 0x064E;
  16199. t['fathatanarabic'] = 0x064B;
  16200. t['fbopomofo'] = 0x3108;
  16201. t['fcircle'] = 0x24D5;
  16202. t['fdotaccent'] = 0x1E1F;
  16203. t['feharabic'] = 0x0641;
  16204. t['feharmenian'] = 0x0586;
  16205. t['fehfinalarabic'] = 0xFED2;
  16206. t['fehinitialarabic'] = 0xFED3;
  16207. t['fehmedialarabic'] = 0xFED4;
  16208. t['feicoptic'] = 0x03E5;
  16209. t['female'] = 0x2640;
  16210. t['ff'] = 0xFB00;
  16211. t['ffi'] = 0xFB03;
  16212. t['ffl'] = 0xFB04;
  16213. t['fi'] = 0xFB01;
  16214. t['fifteencircle'] = 0x246E;
  16215. t['fifteenparen'] = 0x2482;
  16216. t['fifteenperiod'] = 0x2496;
  16217. t['figuredash'] = 0x2012;
  16218. t['filledbox'] = 0x25A0;
  16219. t['filledrect'] = 0x25AC;
  16220. t['finalkaf'] = 0x05DA;
  16221. t['finalkafdagesh'] = 0xFB3A;
  16222. t['finalkafdageshhebrew'] = 0xFB3A;
  16223. t['finalkafhebrew'] = 0x05DA;
  16224. t['finalmem'] = 0x05DD;
  16225. t['finalmemhebrew'] = 0x05DD;
  16226. t['finalnun'] = 0x05DF;
  16227. t['finalnunhebrew'] = 0x05DF;
  16228. t['finalpe'] = 0x05E3;
  16229. t['finalpehebrew'] = 0x05E3;
  16230. t['finaltsadi'] = 0x05E5;
  16231. t['finaltsadihebrew'] = 0x05E5;
  16232. t['firsttonechinese'] = 0x02C9;
  16233. t['fisheye'] = 0x25C9;
  16234. t['fitacyrillic'] = 0x0473;
  16235. t['five'] = 0x0035;
  16236. t['fivearabic'] = 0x0665;
  16237. t['fivebengali'] = 0x09EB;
  16238. t['fivecircle'] = 0x2464;
  16239. t['fivecircleinversesansserif'] = 0x278E;
  16240. t['fivedeva'] = 0x096B;
  16241. t['fiveeighths'] = 0x215D;
  16242. t['fivegujarati'] = 0x0AEB;
  16243. t['fivegurmukhi'] = 0x0A6B;
  16244. t['fivehackarabic'] = 0x0665;
  16245. t['fivehangzhou'] = 0x3025;
  16246. t['fiveideographicparen'] = 0x3224;
  16247. t['fiveinferior'] = 0x2085;
  16248. t['fivemonospace'] = 0xFF15;
  16249. t['fiveoldstyle'] = 0xF735;
  16250. t['fiveparen'] = 0x2478;
  16251. t['fiveperiod'] = 0x248C;
  16252. t['fivepersian'] = 0x06F5;
  16253. t['fiveroman'] = 0x2174;
  16254. t['fivesuperior'] = 0x2075;
  16255. t['fivethai'] = 0x0E55;
  16256. t['fl'] = 0xFB02;
  16257. t['florin'] = 0x0192;
  16258. t['fmonospace'] = 0xFF46;
  16259. t['fmsquare'] = 0x3399;
  16260. t['fofanthai'] = 0x0E1F;
  16261. t['fofathai'] = 0x0E1D;
  16262. t['fongmanthai'] = 0x0E4F;
  16263. t['forall'] = 0x2200;
  16264. t['four'] = 0x0034;
  16265. t['fourarabic'] = 0x0664;
  16266. t['fourbengali'] = 0x09EA;
  16267. t['fourcircle'] = 0x2463;
  16268. t['fourcircleinversesansserif'] = 0x278D;
  16269. t['fourdeva'] = 0x096A;
  16270. t['fourgujarati'] = 0x0AEA;
  16271. t['fourgurmukhi'] = 0x0A6A;
  16272. t['fourhackarabic'] = 0x0664;
  16273. t['fourhangzhou'] = 0x3024;
  16274. t['fourideographicparen'] = 0x3223;
  16275. t['fourinferior'] = 0x2084;
  16276. t['fourmonospace'] = 0xFF14;
  16277. t['fournumeratorbengali'] = 0x09F7;
  16278. t['fouroldstyle'] = 0xF734;
  16279. t['fourparen'] = 0x2477;
  16280. t['fourperiod'] = 0x248B;
  16281. t['fourpersian'] = 0x06F4;
  16282. t['fourroman'] = 0x2173;
  16283. t['foursuperior'] = 0x2074;
  16284. t['fourteencircle'] = 0x246D;
  16285. t['fourteenparen'] = 0x2481;
  16286. t['fourteenperiod'] = 0x2495;
  16287. t['fourthai'] = 0x0E54;
  16288. t['fourthtonechinese'] = 0x02CB;
  16289. t['fparen'] = 0x24A1;
  16290. t['fraction'] = 0x2044;
  16291. t['franc'] = 0x20A3;
  16292. t['g'] = 0x0067;
  16293. t['gabengali'] = 0x0997;
  16294. t['gacute'] = 0x01F5;
  16295. t['gadeva'] = 0x0917;
  16296. t['gafarabic'] = 0x06AF;
  16297. t['gaffinalarabic'] = 0xFB93;
  16298. t['gafinitialarabic'] = 0xFB94;
  16299. t['gafmedialarabic'] = 0xFB95;
  16300. t['gagujarati'] = 0x0A97;
  16301. t['gagurmukhi'] = 0x0A17;
  16302. t['gahiragana'] = 0x304C;
  16303. t['gakatakana'] = 0x30AC;
  16304. t['gamma'] = 0x03B3;
  16305. t['gammalatinsmall'] = 0x0263;
  16306. t['gammasuperior'] = 0x02E0;
  16307. t['gangiacoptic'] = 0x03EB;
  16308. t['gbopomofo'] = 0x310D;
  16309. t['gbreve'] = 0x011F;
  16310. t['gcaron'] = 0x01E7;
  16311. t['gcedilla'] = 0x0123;
  16312. t['gcircle'] = 0x24D6;
  16313. t['gcircumflex'] = 0x011D;
  16314. t['gcommaaccent'] = 0x0123;
  16315. t['gdot'] = 0x0121;
  16316. t['gdotaccent'] = 0x0121;
  16317. t['gecyrillic'] = 0x0433;
  16318. t['gehiragana'] = 0x3052;
  16319. t['gekatakana'] = 0x30B2;
  16320. t['geometricallyequal'] = 0x2251;
  16321. t['gereshaccenthebrew'] = 0x059C;
  16322. t['gereshhebrew'] = 0x05F3;
  16323. t['gereshmuqdamhebrew'] = 0x059D;
  16324. t['germandbls'] = 0x00DF;
  16325. t['gershayimaccenthebrew'] = 0x059E;
  16326. t['gershayimhebrew'] = 0x05F4;
  16327. t['getamark'] = 0x3013;
  16328. t['ghabengali'] = 0x0998;
  16329. t['ghadarmenian'] = 0x0572;
  16330. t['ghadeva'] = 0x0918;
  16331. t['ghagujarati'] = 0x0A98;
  16332. t['ghagurmukhi'] = 0x0A18;
  16333. t['ghainarabic'] = 0x063A;
  16334. t['ghainfinalarabic'] = 0xFECE;
  16335. t['ghaininitialarabic'] = 0xFECF;
  16336. t['ghainmedialarabic'] = 0xFED0;
  16337. t['ghemiddlehookcyrillic'] = 0x0495;
  16338. t['ghestrokecyrillic'] = 0x0493;
  16339. t['gheupturncyrillic'] = 0x0491;
  16340. t['ghhadeva'] = 0x095A;
  16341. t['ghhagurmukhi'] = 0x0A5A;
  16342. t['ghook'] = 0x0260;
  16343. t['ghzsquare'] = 0x3393;
  16344. t['gihiragana'] = 0x304E;
  16345. t['gikatakana'] = 0x30AE;
  16346. t['gimarmenian'] = 0x0563;
  16347. t['gimel'] = 0x05D2;
  16348. t['gimeldagesh'] = 0xFB32;
  16349. t['gimeldageshhebrew'] = 0xFB32;
  16350. t['gimelhebrew'] = 0x05D2;
  16351. t['gjecyrillic'] = 0x0453;
  16352. t['glottalinvertedstroke'] = 0x01BE;
  16353. t['glottalstop'] = 0x0294;
  16354. t['glottalstopinverted'] = 0x0296;
  16355. t['glottalstopmod'] = 0x02C0;
  16356. t['glottalstopreversed'] = 0x0295;
  16357. t['glottalstopreversedmod'] = 0x02C1;
  16358. t['glottalstopreversedsuperior'] = 0x02E4;
  16359. t['glottalstopstroke'] = 0x02A1;
  16360. t['glottalstopstrokereversed'] = 0x02A2;
  16361. t['gmacron'] = 0x1E21;
  16362. t['gmonospace'] = 0xFF47;
  16363. t['gohiragana'] = 0x3054;
  16364. t['gokatakana'] = 0x30B4;
  16365. t['gparen'] = 0x24A2;
  16366. t['gpasquare'] = 0x33AC;
  16367. t['gradient'] = 0x2207;
  16368. t['grave'] = 0x0060;
  16369. t['gravebelowcmb'] = 0x0316;
  16370. t['gravecmb'] = 0x0300;
  16371. t['gravecomb'] = 0x0300;
  16372. t['gravedeva'] = 0x0953;
  16373. t['gravelowmod'] = 0x02CE;
  16374. t['gravemonospace'] = 0xFF40;
  16375. t['gravetonecmb'] = 0x0340;
  16376. t['greater'] = 0x003E;
  16377. t['greaterequal'] = 0x2265;
  16378. t['greaterequalorless'] = 0x22DB;
  16379. t['greatermonospace'] = 0xFF1E;
  16380. t['greaterorequivalent'] = 0x2273;
  16381. t['greaterorless'] = 0x2277;
  16382. t['greateroverequal'] = 0x2267;
  16383. t['greatersmall'] = 0xFE65;
  16384. t['gscript'] = 0x0261;
  16385. t['gstroke'] = 0x01E5;
  16386. t['guhiragana'] = 0x3050;
  16387. t['guillemotleft'] = 0x00AB;
  16388. t['guillemotright'] = 0x00BB;
  16389. t['guilsinglleft'] = 0x2039;
  16390. t['guilsinglright'] = 0x203A;
  16391. t['gukatakana'] = 0x30B0;
  16392. t['guramusquare'] = 0x3318;
  16393. t['gysquare'] = 0x33C9;
  16394. t['h'] = 0x0068;
  16395. t['haabkhasiancyrillic'] = 0x04A9;
  16396. t['haaltonearabic'] = 0x06C1;
  16397. t['habengali'] = 0x09B9;
  16398. t['hadescendercyrillic'] = 0x04B3;
  16399. t['hadeva'] = 0x0939;
  16400. t['hagujarati'] = 0x0AB9;
  16401. t['hagurmukhi'] = 0x0A39;
  16402. t['haharabic'] = 0x062D;
  16403. t['hahfinalarabic'] = 0xFEA2;
  16404. t['hahinitialarabic'] = 0xFEA3;
  16405. t['hahiragana'] = 0x306F;
  16406. t['hahmedialarabic'] = 0xFEA4;
  16407. t['haitusquare'] = 0x332A;
  16408. t['hakatakana'] = 0x30CF;
  16409. t['hakatakanahalfwidth'] = 0xFF8A;
  16410. t['halantgurmukhi'] = 0x0A4D;
  16411. t['hamzaarabic'] = 0x0621;
  16412. t['hamzalowarabic'] = 0x0621;
  16413. t['hangulfiller'] = 0x3164;
  16414. t['hardsigncyrillic'] = 0x044A;
  16415. t['harpoonleftbarbup'] = 0x21BC;
  16416. t['harpoonrightbarbup'] = 0x21C0;
  16417. t['hasquare'] = 0x33CA;
  16418. t['hatafpatah'] = 0x05B2;
  16419. t['hatafpatah16'] = 0x05B2;
  16420. t['hatafpatah23'] = 0x05B2;
  16421. t['hatafpatah2f'] = 0x05B2;
  16422. t['hatafpatahhebrew'] = 0x05B2;
  16423. t['hatafpatahnarrowhebrew'] = 0x05B2;
  16424. t['hatafpatahquarterhebrew'] = 0x05B2;
  16425. t['hatafpatahwidehebrew'] = 0x05B2;
  16426. t['hatafqamats'] = 0x05B3;
  16427. t['hatafqamats1b'] = 0x05B3;
  16428. t['hatafqamats28'] = 0x05B3;
  16429. t['hatafqamats34'] = 0x05B3;
  16430. t['hatafqamatshebrew'] = 0x05B3;
  16431. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  16432. t['hatafqamatsquarterhebrew'] = 0x05B3;
  16433. t['hatafqamatswidehebrew'] = 0x05B3;
  16434. t['hatafsegol'] = 0x05B1;
  16435. t['hatafsegol17'] = 0x05B1;
  16436. t['hatafsegol24'] = 0x05B1;
  16437. t['hatafsegol30'] = 0x05B1;
  16438. t['hatafsegolhebrew'] = 0x05B1;
  16439. t['hatafsegolnarrowhebrew'] = 0x05B1;
  16440. t['hatafsegolquarterhebrew'] = 0x05B1;
  16441. t['hatafsegolwidehebrew'] = 0x05B1;
  16442. t['hbar'] = 0x0127;
  16443. t['hbopomofo'] = 0x310F;
  16444. t['hbrevebelow'] = 0x1E2B;
  16445. t['hcedilla'] = 0x1E29;
  16446. t['hcircle'] = 0x24D7;
  16447. t['hcircumflex'] = 0x0125;
  16448. t['hdieresis'] = 0x1E27;
  16449. t['hdotaccent'] = 0x1E23;
  16450. t['hdotbelow'] = 0x1E25;
  16451. t['he'] = 0x05D4;
  16452. t['heart'] = 0x2665;
  16453. t['heartsuitblack'] = 0x2665;
  16454. t['heartsuitwhite'] = 0x2661;
  16455. t['hedagesh'] = 0xFB34;
  16456. t['hedageshhebrew'] = 0xFB34;
  16457. t['hehaltonearabic'] = 0x06C1;
  16458. t['heharabic'] = 0x0647;
  16459. t['hehebrew'] = 0x05D4;
  16460. t['hehfinalaltonearabic'] = 0xFBA7;
  16461. t['hehfinalalttwoarabic'] = 0xFEEA;
  16462. t['hehfinalarabic'] = 0xFEEA;
  16463. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  16464. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  16465. t['hehinitialaltonearabic'] = 0xFBA8;
  16466. t['hehinitialarabic'] = 0xFEEB;
  16467. t['hehiragana'] = 0x3078;
  16468. t['hehmedialaltonearabic'] = 0xFBA9;
  16469. t['hehmedialarabic'] = 0xFEEC;
  16470. t['heiseierasquare'] = 0x337B;
  16471. t['hekatakana'] = 0x30D8;
  16472. t['hekatakanahalfwidth'] = 0xFF8D;
  16473. t['hekutaarusquare'] = 0x3336;
  16474. t['henghook'] = 0x0267;
  16475. t['herutusquare'] = 0x3339;
  16476. t['het'] = 0x05D7;
  16477. t['hethebrew'] = 0x05D7;
  16478. t['hhook'] = 0x0266;
  16479. t['hhooksuperior'] = 0x02B1;
  16480. t['hieuhacirclekorean'] = 0x327B;
  16481. t['hieuhaparenkorean'] = 0x321B;
  16482. t['hieuhcirclekorean'] = 0x326D;
  16483. t['hieuhkorean'] = 0x314E;
  16484. t['hieuhparenkorean'] = 0x320D;
  16485. t['hihiragana'] = 0x3072;
  16486. t['hikatakana'] = 0x30D2;
  16487. t['hikatakanahalfwidth'] = 0xFF8B;
  16488. t['hiriq'] = 0x05B4;
  16489. t['hiriq14'] = 0x05B4;
  16490. t['hiriq21'] = 0x05B4;
  16491. t['hiriq2d'] = 0x05B4;
  16492. t['hiriqhebrew'] = 0x05B4;
  16493. t['hiriqnarrowhebrew'] = 0x05B4;
  16494. t['hiriqquarterhebrew'] = 0x05B4;
  16495. t['hiriqwidehebrew'] = 0x05B4;
  16496. t['hlinebelow'] = 0x1E96;
  16497. t['hmonospace'] = 0xFF48;
  16498. t['hoarmenian'] = 0x0570;
  16499. t['hohipthai'] = 0x0E2B;
  16500. t['hohiragana'] = 0x307B;
  16501. t['hokatakana'] = 0x30DB;
  16502. t['hokatakanahalfwidth'] = 0xFF8E;
  16503. t['holam'] = 0x05B9;
  16504. t['holam19'] = 0x05B9;
  16505. t['holam26'] = 0x05B9;
  16506. t['holam32'] = 0x05B9;
  16507. t['holamhebrew'] = 0x05B9;
  16508. t['holamnarrowhebrew'] = 0x05B9;
  16509. t['holamquarterhebrew'] = 0x05B9;
  16510. t['holamwidehebrew'] = 0x05B9;
  16511. t['honokhukthai'] = 0x0E2E;
  16512. t['hookabovecomb'] = 0x0309;
  16513. t['hookcmb'] = 0x0309;
  16514. t['hookpalatalizedbelowcmb'] = 0x0321;
  16515. t['hookretroflexbelowcmb'] = 0x0322;
  16516. t['hoonsquare'] = 0x3342;
  16517. t['horicoptic'] = 0x03E9;
  16518. t['horizontalbar'] = 0x2015;
  16519. t['horncmb'] = 0x031B;
  16520. t['hotsprings'] = 0x2668;
  16521. t['house'] = 0x2302;
  16522. t['hparen'] = 0x24A3;
  16523. t['hsuperior'] = 0x02B0;
  16524. t['hturned'] = 0x0265;
  16525. t['huhiragana'] = 0x3075;
  16526. t['huiitosquare'] = 0x3333;
  16527. t['hukatakana'] = 0x30D5;
  16528. t['hukatakanahalfwidth'] = 0xFF8C;
  16529. t['hungarumlaut'] = 0x02DD;
  16530. t['hungarumlautcmb'] = 0x030B;
  16531. t['hv'] = 0x0195;
  16532. t['hyphen'] = 0x002D;
  16533. t['hypheninferior'] = 0xF6E5;
  16534. t['hyphenmonospace'] = 0xFF0D;
  16535. t['hyphensmall'] = 0xFE63;
  16536. t['hyphensuperior'] = 0xF6E6;
  16537. t['hyphentwo'] = 0x2010;
  16538. t['i'] = 0x0069;
  16539. t['iacute'] = 0x00ED;
  16540. t['iacyrillic'] = 0x044F;
  16541. t['ibengali'] = 0x0987;
  16542. t['ibopomofo'] = 0x3127;
  16543. t['ibreve'] = 0x012D;
  16544. t['icaron'] = 0x01D0;
  16545. t['icircle'] = 0x24D8;
  16546. t['icircumflex'] = 0x00EE;
  16547. t['icyrillic'] = 0x0456;
  16548. t['idblgrave'] = 0x0209;
  16549. t['ideographearthcircle'] = 0x328F;
  16550. t['ideographfirecircle'] = 0x328B;
  16551. t['ideographicallianceparen'] = 0x323F;
  16552. t['ideographiccallparen'] = 0x323A;
  16553. t['ideographiccentrecircle'] = 0x32A5;
  16554. t['ideographicclose'] = 0x3006;
  16555. t['ideographiccomma'] = 0x3001;
  16556. t['ideographiccommaleft'] = 0xFF64;
  16557. t['ideographiccongratulationparen'] = 0x3237;
  16558. t['ideographiccorrectcircle'] = 0x32A3;
  16559. t['ideographicearthparen'] = 0x322F;
  16560. t['ideographicenterpriseparen'] = 0x323D;
  16561. t['ideographicexcellentcircle'] = 0x329D;
  16562. t['ideographicfestivalparen'] = 0x3240;
  16563. t['ideographicfinancialcircle'] = 0x3296;
  16564. t['ideographicfinancialparen'] = 0x3236;
  16565. t['ideographicfireparen'] = 0x322B;
  16566. t['ideographichaveparen'] = 0x3232;
  16567. t['ideographichighcircle'] = 0x32A4;
  16568. t['ideographiciterationmark'] = 0x3005;
  16569. t['ideographiclaborcircle'] = 0x3298;
  16570. t['ideographiclaborparen'] = 0x3238;
  16571. t['ideographicleftcircle'] = 0x32A7;
  16572. t['ideographiclowcircle'] = 0x32A6;
  16573. t['ideographicmedicinecircle'] = 0x32A9;
  16574. t['ideographicmetalparen'] = 0x322E;
  16575. t['ideographicmoonparen'] = 0x322A;
  16576. t['ideographicnameparen'] = 0x3234;
  16577. t['ideographicperiod'] = 0x3002;
  16578. t['ideographicprintcircle'] = 0x329E;
  16579. t['ideographicreachparen'] = 0x3243;
  16580. t['ideographicrepresentparen'] = 0x3239;
  16581. t['ideographicresourceparen'] = 0x323E;
  16582. t['ideographicrightcircle'] = 0x32A8;
  16583. t['ideographicsecretcircle'] = 0x3299;
  16584. t['ideographicselfparen'] = 0x3242;
  16585. t['ideographicsocietyparen'] = 0x3233;
  16586. t['ideographicspace'] = 0x3000;
  16587. t['ideographicspecialparen'] = 0x3235;
  16588. t['ideographicstockparen'] = 0x3231;
  16589. t['ideographicstudyparen'] = 0x323B;
  16590. t['ideographicsunparen'] = 0x3230;
  16591. t['ideographicsuperviseparen'] = 0x323C;
  16592. t['ideographicwaterparen'] = 0x322C;
  16593. t['ideographicwoodparen'] = 0x322D;
  16594. t['ideographiczero'] = 0x3007;
  16595. t['ideographmetalcircle'] = 0x328E;
  16596. t['ideographmooncircle'] = 0x328A;
  16597. t['ideographnamecircle'] = 0x3294;
  16598. t['ideographsuncircle'] = 0x3290;
  16599. t['ideographwatercircle'] = 0x328C;
  16600. t['ideographwoodcircle'] = 0x328D;
  16601. t['ideva'] = 0x0907;
  16602. t['idieresis'] = 0x00EF;
  16603. t['idieresisacute'] = 0x1E2F;
  16604. t['idieresiscyrillic'] = 0x04E5;
  16605. t['idotbelow'] = 0x1ECB;
  16606. t['iebrevecyrillic'] = 0x04D7;
  16607. t['iecyrillic'] = 0x0435;
  16608. t['ieungacirclekorean'] = 0x3275;
  16609. t['ieungaparenkorean'] = 0x3215;
  16610. t['ieungcirclekorean'] = 0x3267;
  16611. t['ieungkorean'] = 0x3147;
  16612. t['ieungparenkorean'] = 0x3207;
  16613. t['igrave'] = 0x00EC;
  16614. t['igujarati'] = 0x0A87;
  16615. t['igurmukhi'] = 0x0A07;
  16616. t['ihiragana'] = 0x3044;
  16617. t['ihookabove'] = 0x1EC9;
  16618. t['iibengali'] = 0x0988;
  16619. t['iicyrillic'] = 0x0438;
  16620. t['iideva'] = 0x0908;
  16621. t['iigujarati'] = 0x0A88;
  16622. t['iigurmukhi'] = 0x0A08;
  16623. t['iimatragurmukhi'] = 0x0A40;
  16624. t['iinvertedbreve'] = 0x020B;
  16625. t['iishortcyrillic'] = 0x0439;
  16626. t['iivowelsignbengali'] = 0x09C0;
  16627. t['iivowelsigndeva'] = 0x0940;
  16628. t['iivowelsigngujarati'] = 0x0AC0;
  16629. t['ij'] = 0x0133;
  16630. t['ikatakana'] = 0x30A4;
  16631. t['ikatakanahalfwidth'] = 0xFF72;
  16632. t['ikorean'] = 0x3163;
  16633. t['ilde'] = 0x02DC;
  16634. t['iluyhebrew'] = 0x05AC;
  16635. t['imacron'] = 0x012B;
  16636. t['imacroncyrillic'] = 0x04E3;
  16637. t['imageorapproximatelyequal'] = 0x2253;
  16638. t['imatragurmukhi'] = 0x0A3F;
  16639. t['imonospace'] = 0xFF49;
  16640. t['increment'] = 0x2206;
  16641. t['infinity'] = 0x221E;
  16642. t['iniarmenian'] = 0x056B;
  16643. t['integral'] = 0x222B;
  16644. t['integralbottom'] = 0x2321;
  16645. t['integralbt'] = 0x2321;
  16646. t['integralex'] = 0xF8F5;
  16647. t['integraltop'] = 0x2320;
  16648. t['integraltp'] = 0x2320;
  16649. t['intersection'] = 0x2229;
  16650. t['intisquare'] = 0x3305;
  16651. t['invbullet'] = 0x25D8;
  16652. t['invcircle'] = 0x25D9;
  16653. t['invsmileface'] = 0x263B;
  16654. t['iocyrillic'] = 0x0451;
  16655. t['iogonek'] = 0x012F;
  16656. t['iota'] = 0x03B9;
  16657. t['iotadieresis'] = 0x03CA;
  16658. t['iotadieresistonos'] = 0x0390;
  16659. t['iotalatin'] = 0x0269;
  16660. t['iotatonos'] = 0x03AF;
  16661. t['iparen'] = 0x24A4;
  16662. t['irigurmukhi'] = 0x0A72;
  16663. t['ismallhiragana'] = 0x3043;
  16664. t['ismallkatakana'] = 0x30A3;
  16665. t['ismallkatakanahalfwidth'] = 0xFF68;
  16666. t['issharbengali'] = 0x09FA;
  16667. t['istroke'] = 0x0268;
  16668. t['isuperior'] = 0xF6ED;
  16669. t['iterationhiragana'] = 0x309D;
  16670. t['iterationkatakana'] = 0x30FD;
  16671. t['itilde'] = 0x0129;
  16672. t['itildebelow'] = 0x1E2D;
  16673. t['iubopomofo'] = 0x3129;
  16674. t['iucyrillic'] = 0x044E;
  16675. t['ivowelsignbengali'] = 0x09BF;
  16676. t['ivowelsigndeva'] = 0x093F;
  16677. t['ivowelsigngujarati'] = 0x0ABF;
  16678. t['izhitsacyrillic'] = 0x0475;
  16679. t['izhitsadblgravecyrillic'] = 0x0477;
  16680. t['j'] = 0x006A;
  16681. t['jaarmenian'] = 0x0571;
  16682. t['jabengali'] = 0x099C;
  16683. t['jadeva'] = 0x091C;
  16684. t['jagujarati'] = 0x0A9C;
  16685. t['jagurmukhi'] = 0x0A1C;
  16686. t['jbopomofo'] = 0x3110;
  16687. t['jcaron'] = 0x01F0;
  16688. t['jcircle'] = 0x24D9;
  16689. t['jcircumflex'] = 0x0135;
  16690. t['jcrossedtail'] = 0x029D;
  16691. t['jdotlessstroke'] = 0x025F;
  16692. t['jecyrillic'] = 0x0458;
  16693. t['jeemarabic'] = 0x062C;
  16694. t['jeemfinalarabic'] = 0xFE9E;
  16695. t['jeeminitialarabic'] = 0xFE9F;
  16696. t['jeemmedialarabic'] = 0xFEA0;
  16697. t['jeharabic'] = 0x0698;
  16698. t['jehfinalarabic'] = 0xFB8B;
  16699. t['jhabengali'] = 0x099D;
  16700. t['jhadeva'] = 0x091D;
  16701. t['jhagujarati'] = 0x0A9D;
  16702. t['jhagurmukhi'] = 0x0A1D;
  16703. t['jheharmenian'] = 0x057B;
  16704. t['jis'] = 0x3004;
  16705. t['jmonospace'] = 0xFF4A;
  16706. t['jparen'] = 0x24A5;
  16707. t['jsuperior'] = 0x02B2;
  16708. t['k'] = 0x006B;
  16709. t['kabashkircyrillic'] = 0x04A1;
  16710. t['kabengali'] = 0x0995;
  16711. t['kacute'] = 0x1E31;
  16712. t['kacyrillic'] = 0x043A;
  16713. t['kadescendercyrillic'] = 0x049B;
  16714. t['kadeva'] = 0x0915;
  16715. t['kaf'] = 0x05DB;
  16716. t['kafarabic'] = 0x0643;
  16717. t['kafdagesh'] = 0xFB3B;
  16718. t['kafdageshhebrew'] = 0xFB3B;
  16719. t['kaffinalarabic'] = 0xFEDA;
  16720. t['kafhebrew'] = 0x05DB;
  16721. t['kafinitialarabic'] = 0xFEDB;
  16722. t['kafmedialarabic'] = 0xFEDC;
  16723. t['kafrafehebrew'] = 0xFB4D;
  16724. t['kagujarati'] = 0x0A95;
  16725. t['kagurmukhi'] = 0x0A15;
  16726. t['kahiragana'] = 0x304B;
  16727. t['kahookcyrillic'] = 0x04C4;
  16728. t['kakatakana'] = 0x30AB;
  16729. t['kakatakanahalfwidth'] = 0xFF76;
  16730. t['kappa'] = 0x03BA;
  16731. t['kappasymbolgreek'] = 0x03F0;
  16732. t['kapyeounmieumkorean'] = 0x3171;
  16733. t['kapyeounphieuphkorean'] = 0x3184;
  16734. t['kapyeounpieupkorean'] = 0x3178;
  16735. t['kapyeounssangpieupkorean'] = 0x3179;
  16736. t['karoriisquare'] = 0x330D;
  16737. t['kashidaautoarabic'] = 0x0640;
  16738. t['kashidaautonosidebearingarabic'] = 0x0640;
  16739. t['kasmallkatakana'] = 0x30F5;
  16740. t['kasquare'] = 0x3384;
  16741. t['kasraarabic'] = 0x0650;
  16742. t['kasratanarabic'] = 0x064D;
  16743. t['kastrokecyrillic'] = 0x049F;
  16744. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  16745. t['kaverticalstrokecyrillic'] = 0x049D;
  16746. t['kbopomofo'] = 0x310E;
  16747. t['kcalsquare'] = 0x3389;
  16748. t['kcaron'] = 0x01E9;
  16749. t['kcedilla'] = 0x0137;
  16750. t['kcircle'] = 0x24DA;
  16751. t['kcommaaccent'] = 0x0137;
  16752. t['kdotbelow'] = 0x1E33;
  16753. t['keharmenian'] = 0x0584;
  16754. t['kehiragana'] = 0x3051;
  16755. t['kekatakana'] = 0x30B1;
  16756. t['kekatakanahalfwidth'] = 0xFF79;
  16757. t['kenarmenian'] = 0x056F;
  16758. t['kesmallkatakana'] = 0x30F6;
  16759. t['kgreenlandic'] = 0x0138;
  16760. t['khabengali'] = 0x0996;
  16761. t['khacyrillic'] = 0x0445;
  16762. t['khadeva'] = 0x0916;
  16763. t['khagujarati'] = 0x0A96;
  16764. t['khagurmukhi'] = 0x0A16;
  16765. t['khaharabic'] = 0x062E;
  16766. t['khahfinalarabic'] = 0xFEA6;
  16767. t['khahinitialarabic'] = 0xFEA7;
  16768. t['khahmedialarabic'] = 0xFEA8;
  16769. t['kheicoptic'] = 0x03E7;
  16770. t['khhadeva'] = 0x0959;
  16771. t['khhagurmukhi'] = 0x0A59;
  16772. t['khieukhacirclekorean'] = 0x3278;
  16773. t['khieukhaparenkorean'] = 0x3218;
  16774. t['khieukhcirclekorean'] = 0x326A;
  16775. t['khieukhkorean'] = 0x314B;
  16776. t['khieukhparenkorean'] = 0x320A;
  16777. t['khokhaithai'] = 0x0E02;
  16778. t['khokhonthai'] = 0x0E05;
  16779. t['khokhuatthai'] = 0x0E03;
  16780. t['khokhwaithai'] = 0x0E04;
  16781. t['khomutthai'] = 0x0E5B;
  16782. t['khook'] = 0x0199;
  16783. t['khorakhangthai'] = 0x0E06;
  16784. t['khzsquare'] = 0x3391;
  16785. t['kihiragana'] = 0x304D;
  16786. t['kikatakana'] = 0x30AD;
  16787. t['kikatakanahalfwidth'] = 0xFF77;
  16788. t['kiroguramusquare'] = 0x3315;
  16789. t['kiromeetorusquare'] = 0x3316;
  16790. t['kirosquare'] = 0x3314;
  16791. t['kiyeokacirclekorean'] = 0x326E;
  16792. t['kiyeokaparenkorean'] = 0x320E;
  16793. t['kiyeokcirclekorean'] = 0x3260;
  16794. t['kiyeokkorean'] = 0x3131;
  16795. t['kiyeokparenkorean'] = 0x3200;
  16796. t['kiyeoksioskorean'] = 0x3133;
  16797. t['kjecyrillic'] = 0x045C;
  16798. t['klinebelow'] = 0x1E35;
  16799. t['klsquare'] = 0x3398;
  16800. t['kmcubedsquare'] = 0x33A6;
  16801. t['kmonospace'] = 0xFF4B;
  16802. t['kmsquaredsquare'] = 0x33A2;
  16803. t['kohiragana'] = 0x3053;
  16804. t['kohmsquare'] = 0x33C0;
  16805. t['kokaithai'] = 0x0E01;
  16806. t['kokatakana'] = 0x30B3;
  16807. t['kokatakanahalfwidth'] = 0xFF7A;
  16808. t['kooposquare'] = 0x331E;
  16809. t['koppacyrillic'] = 0x0481;
  16810. t['koreanstandardsymbol'] = 0x327F;
  16811. t['koroniscmb'] = 0x0343;
  16812. t['kparen'] = 0x24A6;
  16813. t['kpasquare'] = 0x33AA;
  16814. t['ksicyrillic'] = 0x046F;
  16815. t['ktsquare'] = 0x33CF;
  16816. t['kturned'] = 0x029E;
  16817. t['kuhiragana'] = 0x304F;
  16818. t['kukatakana'] = 0x30AF;
  16819. t['kukatakanahalfwidth'] = 0xFF78;
  16820. t['kvsquare'] = 0x33B8;
  16821. t['kwsquare'] = 0x33BE;
  16822. t['l'] = 0x006C;
  16823. t['labengali'] = 0x09B2;
  16824. t['lacute'] = 0x013A;
  16825. t['ladeva'] = 0x0932;
  16826. t['lagujarati'] = 0x0AB2;
  16827. t['lagurmukhi'] = 0x0A32;
  16828. t['lakkhangyaothai'] = 0x0E45;
  16829. t['lamaleffinalarabic'] = 0xFEFC;
  16830. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  16831. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  16832. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  16833. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  16834. t['lamalefisolatedarabic'] = 0xFEFB;
  16835. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  16836. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  16837. t['lamarabic'] = 0x0644;
  16838. t['lambda'] = 0x03BB;
  16839. t['lambdastroke'] = 0x019B;
  16840. t['lamed'] = 0x05DC;
  16841. t['lameddagesh'] = 0xFB3C;
  16842. t['lameddageshhebrew'] = 0xFB3C;
  16843. t['lamedhebrew'] = 0x05DC;
  16844. t['lamfinalarabic'] = 0xFEDE;
  16845. t['lamhahinitialarabic'] = 0xFCCA;
  16846. t['laminitialarabic'] = 0xFEDF;
  16847. t['lamjeeminitialarabic'] = 0xFCC9;
  16848. t['lamkhahinitialarabic'] = 0xFCCB;
  16849. t['lamlamhehisolatedarabic'] = 0xFDF2;
  16850. t['lammedialarabic'] = 0xFEE0;
  16851. t['lammeemhahinitialarabic'] = 0xFD88;
  16852. t['lammeeminitialarabic'] = 0xFCCC;
  16853. t['largecircle'] = 0x25EF;
  16854. t['lbar'] = 0x019A;
  16855. t['lbelt'] = 0x026C;
  16856. t['lbopomofo'] = 0x310C;
  16857. t['lcaron'] = 0x013E;
  16858. t['lcedilla'] = 0x013C;
  16859. t['lcircle'] = 0x24DB;
  16860. t['lcircumflexbelow'] = 0x1E3D;
  16861. t['lcommaaccent'] = 0x013C;
  16862. t['ldot'] = 0x0140;
  16863. t['ldotaccent'] = 0x0140;
  16864. t['ldotbelow'] = 0x1E37;
  16865. t['ldotbelowmacron'] = 0x1E39;
  16866. t['leftangleabovecmb'] = 0x031A;
  16867. t['lefttackbelowcmb'] = 0x0318;
  16868. t['less'] = 0x003C;
  16869. t['lessequal'] = 0x2264;
  16870. t['lessequalorgreater'] = 0x22DA;
  16871. t['lessmonospace'] = 0xFF1C;
  16872. t['lessorequivalent'] = 0x2272;
  16873. t['lessorgreater'] = 0x2276;
  16874. t['lessoverequal'] = 0x2266;
  16875. t['lesssmall'] = 0xFE64;
  16876. t['lezh'] = 0x026E;
  16877. t['lfblock'] = 0x258C;
  16878. t['lhookretroflex'] = 0x026D;
  16879. t['lira'] = 0x20A4;
  16880. t['liwnarmenian'] = 0x056C;
  16881. t['lj'] = 0x01C9;
  16882. t['ljecyrillic'] = 0x0459;
  16883. t['ll'] = 0xF6C0;
  16884. t['lladeva'] = 0x0933;
  16885. t['llagujarati'] = 0x0AB3;
  16886. t['llinebelow'] = 0x1E3B;
  16887. t['llladeva'] = 0x0934;
  16888. t['llvocalicbengali'] = 0x09E1;
  16889. t['llvocalicdeva'] = 0x0961;
  16890. t['llvocalicvowelsignbengali'] = 0x09E3;
  16891. t['llvocalicvowelsigndeva'] = 0x0963;
  16892. t['lmiddletilde'] = 0x026B;
  16893. t['lmonospace'] = 0xFF4C;
  16894. t['lmsquare'] = 0x33D0;
  16895. t['lochulathai'] = 0x0E2C;
  16896. t['logicaland'] = 0x2227;
  16897. t['logicalnot'] = 0x00AC;
  16898. t['logicalnotreversed'] = 0x2310;
  16899. t['logicalor'] = 0x2228;
  16900. t['lolingthai'] = 0x0E25;
  16901. t['longs'] = 0x017F;
  16902. t['lowlinecenterline'] = 0xFE4E;
  16903. t['lowlinecmb'] = 0x0332;
  16904. t['lowlinedashed'] = 0xFE4D;
  16905. t['lozenge'] = 0x25CA;
  16906. t['lparen'] = 0x24A7;
  16907. t['lslash'] = 0x0142;
  16908. t['lsquare'] = 0x2113;
  16909. t['lsuperior'] = 0xF6EE;
  16910. t['ltshade'] = 0x2591;
  16911. t['luthai'] = 0x0E26;
  16912. t['lvocalicbengali'] = 0x098C;
  16913. t['lvocalicdeva'] = 0x090C;
  16914. t['lvocalicvowelsignbengali'] = 0x09E2;
  16915. t['lvocalicvowelsigndeva'] = 0x0962;
  16916. t['lxsquare'] = 0x33D3;
  16917. t['m'] = 0x006D;
  16918. t['mabengali'] = 0x09AE;
  16919. t['macron'] = 0x00AF;
  16920. t['macronbelowcmb'] = 0x0331;
  16921. t['macroncmb'] = 0x0304;
  16922. t['macronlowmod'] = 0x02CD;
  16923. t['macronmonospace'] = 0xFFE3;
  16924. t['macute'] = 0x1E3F;
  16925. t['madeva'] = 0x092E;
  16926. t['magujarati'] = 0x0AAE;
  16927. t['magurmukhi'] = 0x0A2E;
  16928. t['mahapakhhebrew'] = 0x05A4;
  16929. t['mahapakhlefthebrew'] = 0x05A4;
  16930. t['mahiragana'] = 0x307E;
  16931. t['maichattawalowleftthai'] = 0xF895;
  16932. t['maichattawalowrightthai'] = 0xF894;
  16933. t['maichattawathai'] = 0x0E4B;
  16934. t['maichattawaupperleftthai'] = 0xF893;
  16935. t['maieklowleftthai'] = 0xF88C;
  16936. t['maieklowrightthai'] = 0xF88B;
  16937. t['maiekthai'] = 0x0E48;
  16938. t['maiekupperleftthai'] = 0xF88A;
  16939. t['maihanakatleftthai'] = 0xF884;
  16940. t['maihanakatthai'] = 0x0E31;
  16941. t['maitaikhuleftthai'] = 0xF889;
  16942. t['maitaikhuthai'] = 0x0E47;
  16943. t['maitholowleftthai'] = 0xF88F;
  16944. t['maitholowrightthai'] = 0xF88E;
  16945. t['maithothai'] = 0x0E49;
  16946. t['maithoupperleftthai'] = 0xF88D;
  16947. t['maitrilowleftthai'] = 0xF892;
  16948. t['maitrilowrightthai'] = 0xF891;
  16949. t['maitrithai'] = 0x0E4A;
  16950. t['maitriupperleftthai'] = 0xF890;
  16951. t['maiyamokthai'] = 0x0E46;
  16952. t['makatakana'] = 0x30DE;
  16953. t['makatakanahalfwidth'] = 0xFF8F;
  16954. t['male'] = 0x2642;
  16955. t['mansyonsquare'] = 0x3347;
  16956. t['maqafhebrew'] = 0x05BE;
  16957. t['mars'] = 0x2642;
  16958. t['masoracirclehebrew'] = 0x05AF;
  16959. t['masquare'] = 0x3383;
  16960. t['mbopomofo'] = 0x3107;
  16961. t['mbsquare'] = 0x33D4;
  16962. t['mcircle'] = 0x24DC;
  16963. t['mcubedsquare'] = 0x33A5;
  16964. t['mdotaccent'] = 0x1E41;
  16965. t['mdotbelow'] = 0x1E43;
  16966. t['meemarabic'] = 0x0645;
  16967. t['meemfinalarabic'] = 0xFEE2;
  16968. t['meeminitialarabic'] = 0xFEE3;
  16969. t['meemmedialarabic'] = 0xFEE4;
  16970. t['meemmeeminitialarabic'] = 0xFCD1;
  16971. t['meemmeemisolatedarabic'] = 0xFC48;
  16972. t['meetorusquare'] = 0x334D;
  16973. t['mehiragana'] = 0x3081;
  16974. t['meizierasquare'] = 0x337E;
  16975. t['mekatakana'] = 0x30E1;
  16976. t['mekatakanahalfwidth'] = 0xFF92;
  16977. t['mem'] = 0x05DE;
  16978. t['memdagesh'] = 0xFB3E;
  16979. t['memdageshhebrew'] = 0xFB3E;
  16980. t['memhebrew'] = 0x05DE;
  16981. t['menarmenian'] = 0x0574;
  16982. t['merkhahebrew'] = 0x05A5;
  16983. t['merkhakefulahebrew'] = 0x05A6;
  16984. t['merkhakefulalefthebrew'] = 0x05A6;
  16985. t['merkhalefthebrew'] = 0x05A5;
  16986. t['mhook'] = 0x0271;
  16987. t['mhzsquare'] = 0x3392;
  16988. t['middledotkatakanahalfwidth'] = 0xFF65;
  16989. t['middot'] = 0x00B7;
  16990. t['mieumacirclekorean'] = 0x3272;
  16991. t['mieumaparenkorean'] = 0x3212;
  16992. t['mieumcirclekorean'] = 0x3264;
  16993. t['mieumkorean'] = 0x3141;
  16994. t['mieumpansioskorean'] = 0x3170;
  16995. t['mieumparenkorean'] = 0x3204;
  16996. t['mieumpieupkorean'] = 0x316E;
  16997. t['mieumsioskorean'] = 0x316F;
  16998. t['mihiragana'] = 0x307F;
  16999. t['mikatakana'] = 0x30DF;
  17000. t['mikatakanahalfwidth'] = 0xFF90;
  17001. t['minus'] = 0x2212;
  17002. t['minusbelowcmb'] = 0x0320;
  17003. t['minuscircle'] = 0x2296;
  17004. t['minusmod'] = 0x02D7;
  17005. t['minusplus'] = 0x2213;
  17006. t['minute'] = 0x2032;
  17007. t['miribaarusquare'] = 0x334A;
  17008. t['mirisquare'] = 0x3349;
  17009. t['mlonglegturned'] = 0x0270;
  17010. t['mlsquare'] = 0x3396;
  17011. t['mmcubedsquare'] = 0x33A3;
  17012. t['mmonospace'] = 0xFF4D;
  17013. t['mmsquaredsquare'] = 0x339F;
  17014. t['mohiragana'] = 0x3082;
  17015. t['mohmsquare'] = 0x33C1;
  17016. t['mokatakana'] = 0x30E2;
  17017. t['mokatakanahalfwidth'] = 0xFF93;
  17018. t['molsquare'] = 0x33D6;
  17019. t['momathai'] = 0x0E21;
  17020. t['moverssquare'] = 0x33A7;
  17021. t['moverssquaredsquare'] = 0x33A8;
  17022. t['mparen'] = 0x24A8;
  17023. t['mpasquare'] = 0x33AB;
  17024. t['mssquare'] = 0x33B3;
  17025. t['msuperior'] = 0xF6EF;
  17026. t['mturned'] = 0x026F;
  17027. t['mu'] = 0x00B5;
  17028. t['mu1'] = 0x00B5;
  17029. t['muasquare'] = 0x3382;
  17030. t['muchgreater'] = 0x226B;
  17031. t['muchless'] = 0x226A;
  17032. t['mufsquare'] = 0x338C;
  17033. t['mugreek'] = 0x03BC;
  17034. t['mugsquare'] = 0x338D;
  17035. t['muhiragana'] = 0x3080;
  17036. t['mukatakana'] = 0x30E0;
  17037. t['mukatakanahalfwidth'] = 0xFF91;
  17038. t['mulsquare'] = 0x3395;
  17039. t['multiply'] = 0x00D7;
  17040. t['mumsquare'] = 0x339B;
  17041. t['munahhebrew'] = 0x05A3;
  17042. t['munahlefthebrew'] = 0x05A3;
  17043. t['musicalnote'] = 0x266A;
  17044. t['musicalnotedbl'] = 0x266B;
  17045. t['musicflatsign'] = 0x266D;
  17046. t['musicsharpsign'] = 0x266F;
  17047. t['mussquare'] = 0x33B2;
  17048. t['muvsquare'] = 0x33B6;
  17049. t['muwsquare'] = 0x33BC;
  17050. t['mvmegasquare'] = 0x33B9;
  17051. t['mvsquare'] = 0x33B7;
  17052. t['mwmegasquare'] = 0x33BF;
  17053. t['mwsquare'] = 0x33BD;
  17054. t['n'] = 0x006E;
  17055. t['nabengali'] = 0x09A8;
  17056. t['nabla'] = 0x2207;
  17057. t['nacute'] = 0x0144;
  17058. t['nadeva'] = 0x0928;
  17059. t['nagujarati'] = 0x0AA8;
  17060. t['nagurmukhi'] = 0x0A28;
  17061. t['nahiragana'] = 0x306A;
  17062. t['nakatakana'] = 0x30CA;
  17063. t['nakatakanahalfwidth'] = 0xFF85;
  17064. t['napostrophe'] = 0x0149;
  17065. t['nasquare'] = 0x3381;
  17066. t['nbopomofo'] = 0x310B;
  17067. t['nbspace'] = 0x00A0;
  17068. t['ncaron'] = 0x0148;
  17069. t['ncedilla'] = 0x0146;
  17070. t['ncircle'] = 0x24DD;
  17071. t['ncircumflexbelow'] = 0x1E4B;
  17072. t['ncommaaccent'] = 0x0146;
  17073. t['ndotaccent'] = 0x1E45;
  17074. t['ndotbelow'] = 0x1E47;
  17075. t['nehiragana'] = 0x306D;
  17076. t['nekatakana'] = 0x30CD;
  17077. t['nekatakanahalfwidth'] = 0xFF88;
  17078. t['newsheqelsign'] = 0x20AA;
  17079. t['nfsquare'] = 0x338B;
  17080. t['ngabengali'] = 0x0999;
  17081. t['ngadeva'] = 0x0919;
  17082. t['ngagujarati'] = 0x0A99;
  17083. t['ngagurmukhi'] = 0x0A19;
  17084. t['ngonguthai'] = 0x0E07;
  17085. t['nhiragana'] = 0x3093;
  17086. t['nhookleft'] = 0x0272;
  17087. t['nhookretroflex'] = 0x0273;
  17088. t['nieunacirclekorean'] = 0x326F;
  17089. t['nieunaparenkorean'] = 0x320F;
  17090. t['nieuncieuckorean'] = 0x3135;
  17091. t['nieuncirclekorean'] = 0x3261;
  17092. t['nieunhieuhkorean'] = 0x3136;
  17093. t['nieunkorean'] = 0x3134;
  17094. t['nieunpansioskorean'] = 0x3168;
  17095. t['nieunparenkorean'] = 0x3201;
  17096. t['nieunsioskorean'] = 0x3167;
  17097. t['nieuntikeutkorean'] = 0x3166;
  17098. t['nihiragana'] = 0x306B;
  17099. t['nikatakana'] = 0x30CB;
  17100. t['nikatakanahalfwidth'] = 0xFF86;
  17101. t['nikhahitleftthai'] = 0xF899;
  17102. t['nikhahitthai'] = 0x0E4D;
  17103. t['nine'] = 0x0039;
  17104. t['ninearabic'] = 0x0669;
  17105. t['ninebengali'] = 0x09EF;
  17106. t['ninecircle'] = 0x2468;
  17107. t['ninecircleinversesansserif'] = 0x2792;
  17108. t['ninedeva'] = 0x096F;
  17109. t['ninegujarati'] = 0x0AEF;
  17110. t['ninegurmukhi'] = 0x0A6F;
  17111. t['ninehackarabic'] = 0x0669;
  17112. t['ninehangzhou'] = 0x3029;
  17113. t['nineideographicparen'] = 0x3228;
  17114. t['nineinferior'] = 0x2089;
  17115. t['ninemonospace'] = 0xFF19;
  17116. t['nineoldstyle'] = 0xF739;
  17117. t['nineparen'] = 0x247C;
  17118. t['nineperiod'] = 0x2490;
  17119. t['ninepersian'] = 0x06F9;
  17120. t['nineroman'] = 0x2178;
  17121. t['ninesuperior'] = 0x2079;
  17122. t['nineteencircle'] = 0x2472;
  17123. t['nineteenparen'] = 0x2486;
  17124. t['nineteenperiod'] = 0x249A;
  17125. t['ninethai'] = 0x0E59;
  17126. t['nj'] = 0x01CC;
  17127. t['njecyrillic'] = 0x045A;
  17128. t['nkatakana'] = 0x30F3;
  17129. t['nkatakanahalfwidth'] = 0xFF9D;
  17130. t['nlegrightlong'] = 0x019E;
  17131. t['nlinebelow'] = 0x1E49;
  17132. t['nmonospace'] = 0xFF4E;
  17133. t['nmsquare'] = 0x339A;
  17134. t['nnabengali'] = 0x09A3;
  17135. t['nnadeva'] = 0x0923;
  17136. t['nnagujarati'] = 0x0AA3;
  17137. t['nnagurmukhi'] = 0x0A23;
  17138. t['nnnadeva'] = 0x0929;
  17139. t['nohiragana'] = 0x306E;
  17140. t['nokatakana'] = 0x30CE;
  17141. t['nokatakanahalfwidth'] = 0xFF89;
  17142. t['nonbreakingspace'] = 0x00A0;
  17143. t['nonenthai'] = 0x0E13;
  17144. t['nonuthai'] = 0x0E19;
  17145. t['noonarabic'] = 0x0646;
  17146. t['noonfinalarabic'] = 0xFEE6;
  17147. t['noonghunnaarabic'] = 0x06BA;
  17148. t['noonghunnafinalarabic'] = 0xFB9F;
  17149. t['nooninitialarabic'] = 0xFEE7;
  17150. t['noonjeeminitialarabic'] = 0xFCD2;
  17151. t['noonjeemisolatedarabic'] = 0xFC4B;
  17152. t['noonmedialarabic'] = 0xFEE8;
  17153. t['noonmeeminitialarabic'] = 0xFCD5;
  17154. t['noonmeemisolatedarabic'] = 0xFC4E;
  17155. t['noonnoonfinalarabic'] = 0xFC8D;
  17156. t['notcontains'] = 0x220C;
  17157. t['notelement'] = 0x2209;
  17158. t['notelementof'] = 0x2209;
  17159. t['notequal'] = 0x2260;
  17160. t['notgreater'] = 0x226F;
  17161. t['notgreaternorequal'] = 0x2271;
  17162. t['notgreaternorless'] = 0x2279;
  17163. t['notidentical'] = 0x2262;
  17164. t['notless'] = 0x226E;
  17165. t['notlessnorequal'] = 0x2270;
  17166. t['notparallel'] = 0x2226;
  17167. t['notprecedes'] = 0x2280;
  17168. t['notsubset'] = 0x2284;
  17169. t['notsucceeds'] = 0x2281;
  17170. t['notsuperset'] = 0x2285;
  17171. t['nowarmenian'] = 0x0576;
  17172. t['nparen'] = 0x24A9;
  17173. t['nssquare'] = 0x33B1;
  17174. t['nsuperior'] = 0x207F;
  17175. t['ntilde'] = 0x00F1;
  17176. t['nu'] = 0x03BD;
  17177. t['nuhiragana'] = 0x306C;
  17178. t['nukatakana'] = 0x30CC;
  17179. t['nukatakanahalfwidth'] = 0xFF87;
  17180. t['nuktabengali'] = 0x09BC;
  17181. t['nuktadeva'] = 0x093C;
  17182. t['nuktagujarati'] = 0x0ABC;
  17183. t['nuktagurmukhi'] = 0x0A3C;
  17184. t['numbersign'] = 0x0023;
  17185. t['numbersignmonospace'] = 0xFF03;
  17186. t['numbersignsmall'] = 0xFE5F;
  17187. t['numeralsigngreek'] = 0x0374;
  17188. t['numeralsignlowergreek'] = 0x0375;
  17189. t['numero'] = 0x2116;
  17190. t['nun'] = 0x05E0;
  17191. t['nundagesh'] = 0xFB40;
  17192. t['nundageshhebrew'] = 0xFB40;
  17193. t['nunhebrew'] = 0x05E0;
  17194. t['nvsquare'] = 0x33B5;
  17195. t['nwsquare'] = 0x33BB;
  17196. t['nyabengali'] = 0x099E;
  17197. t['nyadeva'] = 0x091E;
  17198. t['nyagujarati'] = 0x0A9E;
  17199. t['nyagurmukhi'] = 0x0A1E;
  17200. t['o'] = 0x006F;
  17201. t['oacute'] = 0x00F3;
  17202. t['oangthai'] = 0x0E2D;
  17203. t['obarred'] = 0x0275;
  17204. t['obarredcyrillic'] = 0x04E9;
  17205. t['obarreddieresiscyrillic'] = 0x04EB;
  17206. t['obengali'] = 0x0993;
  17207. t['obopomofo'] = 0x311B;
  17208. t['obreve'] = 0x014F;
  17209. t['ocandradeva'] = 0x0911;
  17210. t['ocandragujarati'] = 0x0A91;
  17211. t['ocandravowelsigndeva'] = 0x0949;
  17212. t['ocandravowelsigngujarati'] = 0x0AC9;
  17213. t['ocaron'] = 0x01D2;
  17214. t['ocircle'] = 0x24DE;
  17215. t['ocircumflex'] = 0x00F4;
  17216. t['ocircumflexacute'] = 0x1ED1;
  17217. t['ocircumflexdotbelow'] = 0x1ED9;
  17218. t['ocircumflexgrave'] = 0x1ED3;
  17219. t['ocircumflexhookabove'] = 0x1ED5;
  17220. t['ocircumflextilde'] = 0x1ED7;
  17221. t['ocyrillic'] = 0x043E;
  17222. t['odblacute'] = 0x0151;
  17223. t['odblgrave'] = 0x020D;
  17224. t['odeva'] = 0x0913;
  17225. t['odieresis'] = 0x00F6;
  17226. t['odieresiscyrillic'] = 0x04E7;
  17227. t['odotbelow'] = 0x1ECD;
  17228. t['oe'] = 0x0153;
  17229. t['oekorean'] = 0x315A;
  17230. t['ogonek'] = 0x02DB;
  17231. t['ogonekcmb'] = 0x0328;
  17232. t['ograve'] = 0x00F2;
  17233. t['ogujarati'] = 0x0A93;
  17234. t['oharmenian'] = 0x0585;
  17235. t['ohiragana'] = 0x304A;
  17236. t['ohookabove'] = 0x1ECF;
  17237. t['ohorn'] = 0x01A1;
  17238. t['ohornacute'] = 0x1EDB;
  17239. t['ohorndotbelow'] = 0x1EE3;
  17240. t['ohorngrave'] = 0x1EDD;
  17241. t['ohornhookabove'] = 0x1EDF;
  17242. t['ohorntilde'] = 0x1EE1;
  17243. t['ohungarumlaut'] = 0x0151;
  17244. t['oi'] = 0x01A3;
  17245. t['oinvertedbreve'] = 0x020F;
  17246. t['okatakana'] = 0x30AA;
  17247. t['okatakanahalfwidth'] = 0xFF75;
  17248. t['okorean'] = 0x3157;
  17249. t['olehebrew'] = 0x05AB;
  17250. t['omacron'] = 0x014D;
  17251. t['omacronacute'] = 0x1E53;
  17252. t['omacrongrave'] = 0x1E51;
  17253. t['omdeva'] = 0x0950;
  17254. t['omega'] = 0x03C9;
  17255. t['omega1'] = 0x03D6;
  17256. t['omegacyrillic'] = 0x0461;
  17257. t['omegalatinclosed'] = 0x0277;
  17258. t['omegaroundcyrillic'] = 0x047B;
  17259. t['omegatitlocyrillic'] = 0x047D;
  17260. t['omegatonos'] = 0x03CE;
  17261. t['omgujarati'] = 0x0AD0;
  17262. t['omicron'] = 0x03BF;
  17263. t['omicrontonos'] = 0x03CC;
  17264. t['omonospace'] = 0xFF4F;
  17265. t['one'] = 0x0031;
  17266. t['onearabic'] = 0x0661;
  17267. t['onebengali'] = 0x09E7;
  17268. t['onecircle'] = 0x2460;
  17269. t['onecircleinversesansserif'] = 0x278A;
  17270. t['onedeva'] = 0x0967;
  17271. t['onedotenleader'] = 0x2024;
  17272. t['oneeighth'] = 0x215B;
  17273. t['onefitted'] = 0xF6DC;
  17274. t['onegujarati'] = 0x0AE7;
  17275. t['onegurmukhi'] = 0x0A67;
  17276. t['onehackarabic'] = 0x0661;
  17277. t['onehalf'] = 0x00BD;
  17278. t['onehangzhou'] = 0x3021;
  17279. t['oneideographicparen'] = 0x3220;
  17280. t['oneinferior'] = 0x2081;
  17281. t['onemonospace'] = 0xFF11;
  17282. t['onenumeratorbengali'] = 0x09F4;
  17283. t['oneoldstyle'] = 0xF731;
  17284. t['oneparen'] = 0x2474;
  17285. t['oneperiod'] = 0x2488;
  17286. t['onepersian'] = 0x06F1;
  17287. t['onequarter'] = 0x00BC;
  17288. t['oneroman'] = 0x2170;
  17289. t['onesuperior'] = 0x00B9;
  17290. t['onethai'] = 0x0E51;
  17291. t['onethird'] = 0x2153;
  17292. t['oogonek'] = 0x01EB;
  17293. t['oogonekmacron'] = 0x01ED;
  17294. t['oogurmukhi'] = 0x0A13;
  17295. t['oomatragurmukhi'] = 0x0A4B;
  17296. t['oopen'] = 0x0254;
  17297. t['oparen'] = 0x24AA;
  17298. t['openbullet'] = 0x25E6;
  17299. t['option'] = 0x2325;
  17300. t['ordfeminine'] = 0x00AA;
  17301. t['ordmasculine'] = 0x00BA;
  17302. t['orthogonal'] = 0x221F;
  17303. t['oshortdeva'] = 0x0912;
  17304. t['oshortvowelsigndeva'] = 0x094A;
  17305. t['oslash'] = 0x00F8;
  17306. t['oslashacute'] = 0x01FF;
  17307. t['osmallhiragana'] = 0x3049;
  17308. t['osmallkatakana'] = 0x30A9;
  17309. t['osmallkatakanahalfwidth'] = 0xFF6B;
  17310. t['ostrokeacute'] = 0x01FF;
  17311. t['osuperior'] = 0xF6F0;
  17312. t['otcyrillic'] = 0x047F;
  17313. t['otilde'] = 0x00F5;
  17314. t['otildeacute'] = 0x1E4D;
  17315. t['otildedieresis'] = 0x1E4F;
  17316. t['oubopomofo'] = 0x3121;
  17317. t['overline'] = 0x203E;
  17318. t['overlinecenterline'] = 0xFE4A;
  17319. t['overlinecmb'] = 0x0305;
  17320. t['overlinedashed'] = 0xFE49;
  17321. t['overlinedblwavy'] = 0xFE4C;
  17322. t['overlinewavy'] = 0xFE4B;
  17323. t['overscore'] = 0x00AF;
  17324. t['ovowelsignbengali'] = 0x09CB;
  17325. t['ovowelsigndeva'] = 0x094B;
  17326. t['ovowelsigngujarati'] = 0x0ACB;
  17327. t['p'] = 0x0070;
  17328. t['paampssquare'] = 0x3380;
  17329. t['paasentosquare'] = 0x332B;
  17330. t['pabengali'] = 0x09AA;
  17331. t['pacute'] = 0x1E55;
  17332. t['padeva'] = 0x092A;
  17333. t['pagedown'] = 0x21DF;
  17334. t['pageup'] = 0x21DE;
  17335. t['pagujarati'] = 0x0AAA;
  17336. t['pagurmukhi'] = 0x0A2A;
  17337. t['pahiragana'] = 0x3071;
  17338. t['paiyannoithai'] = 0x0E2F;
  17339. t['pakatakana'] = 0x30D1;
  17340. t['palatalizationcyrilliccmb'] = 0x0484;
  17341. t['palochkacyrillic'] = 0x04C0;
  17342. t['pansioskorean'] = 0x317F;
  17343. t['paragraph'] = 0x00B6;
  17344. t['parallel'] = 0x2225;
  17345. t['parenleft'] = 0x0028;
  17346. t['parenleftaltonearabic'] = 0xFD3E;
  17347. t['parenleftbt'] = 0xF8ED;
  17348. t['parenleftex'] = 0xF8EC;
  17349. t['parenleftinferior'] = 0x208D;
  17350. t['parenleftmonospace'] = 0xFF08;
  17351. t['parenleftsmall'] = 0xFE59;
  17352. t['parenleftsuperior'] = 0x207D;
  17353. t['parenlefttp'] = 0xF8EB;
  17354. t['parenleftvertical'] = 0xFE35;
  17355. t['parenright'] = 0x0029;
  17356. t['parenrightaltonearabic'] = 0xFD3F;
  17357. t['parenrightbt'] = 0xF8F8;
  17358. t['parenrightex'] = 0xF8F7;
  17359. t['parenrightinferior'] = 0x208E;
  17360. t['parenrightmonospace'] = 0xFF09;
  17361. t['parenrightsmall'] = 0xFE5A;
  17362. t['parenrightsuperior'] = 0x207E;
  17363. t['parenrighttp'] = 0xF8F6;
  17364. t['parenrightvertical'] = 0xFE36;
  17365. t['partialdiff'] = 0x2202;
  17366. t['paseqhebrew'] = 0x05C0;
  17367. t['pashtahebrew'] = 0x0599;
  17368. t['pasquare'] = 0x33A9;
  17369. t['patah'] = 0x05B7;
  17370. t['patah11'] = 0x05B7;
  17371. t['patah1d'] = 0x05B7;
  17372. t['patah2a'] = 0x05B7;
  17373. t['patahhebrew'] = 0x05B7;
  17374. t['patahnarrowhebrew'] = 0x05B7;
  17375. t['patahquarterhebrew'] = 0x05B7;
  17376. t['patahwidehebrew'] = 0x05B7;
  17377. t['pazerhebrew'] = 0x05A1;
  17378. t['pbopomofo'] = 0x3106;
  17379. t['pcircle'] = 0x24DF;
  17380. t['pdotaccent'] = 0x1E57;
  17381. t['pe'] = 0x05E4;
  17382. t['pecyrillic'] = 0x043F;
  17383. t['pedagesh'] = 0xFB44;
  17384. t['pedageshhebrew'] = 0xFB44;
  17385. t['peezisquare'] = 0x333B;
  17386. t['pefinaldageshhebrew'] = 0xFB43;
  17387. t['peharabic'] = 0x067E;
  17388. t['peharmenian'] = 0x057A;
  17389. t['pehebrew'] = 0x05E4;
  17390. t['pehfinalarabic'] = 0xFB57;
  17391. t['pehinitialarabic'] = 0xFB58;
  17392. t['pehiragana'] = 0x307A;
  17393. t['pehmedialarabic'] = 0xFB59;
  17394. t['pekatakana'] = 0x30DA;
  17395. t['pemiddlehookcyrillic'] = 0x04A7;
  17396. t['perafehebrew'] = 0xFB4E;
  17397. t['percent'] = 0x0025;
  17398. t['percentarabic'] = 0x066A;
  17399. t['percentmonospace'] = 0xFF05;
  17400. t['percentsmall'] = 0xFE6A;
  17401. t['period'] = 0x002E;
  17402. t['periodarmenian'] = 0x0589;
  17403. t['periodcentered'] = 0x00B7;
  17404. t['periodhalfwidth'] = 0xFF61;
  17405. t['periodinferior'] = 0xF6E7;
  17406. t['periodmonospace'] = 0xFF0E;
  17407. t['periodsmall'] = 0xFE52;
  17408. t['periodsuperior'] = 0xF6E8;
  17409. t['perispomenigreekcmb'] = 0x0342;
  17410. t['perpendicular'] = 0x22A5;
  17411. t['perthousand'] = 0x2030;
  17412. t['peseta'] = 0x20A7;
  17413. t['pfsquare'] = 0x338A;
  17414. t['phabengali'] = 0x09AB;
  17415. t['phadeva'] = 0x092B;
  17416. t['phagujarati'] = 0x0AAB;
  17417. t['phagurmukhi'] = 0x0A2B;
  17418. t['phi'] = 0x03C6;
  17419. t['phi1'] = 0x03D5;
  17420. t['phieuphacirclekorean'] = 0x327A;
  17421. t['phieuphaparenkorean'] = 0x321A;
  17422. t['phieuphcirclekorean'] = 0x326C;
  17423. t['phieuphkorean'] = 0x314D;
  17424. t['phieuphparenkorean'] = 0x320C;
  17425. t['philatin'] = 0x0278;
  17426. t['phinthuthai'] = 0x0E3A;
  17427. t['phisymbolgreek'] = 0x03D5;
  17428. t['phook'] = 0x01A5;
  17429. t['phophanthai'] = 0x0E1E;
  17430. t['phophungthai'] = 0x0E1C;
  17431. t['phosamphaothai'] = 0x0E20;
  17432. t['pi'] = 0x03C0;
  17433. t['pieupacirclekorean'] = 0x3273;
  17434. t['pieupaparenkorean'] = 0x3213;
  17435. t['pieupcieuckorean'] = 0x3176;
  17436. t['pieupcirclekorean'] = 0x3265;
  17437. t['pieupkiyeokkorean'] = 0x3172;
  17438. t['pieupkorean'] = 0x3142;
  17439. t['pieupparenkorean'] = 0x3205;
  17440. t['pieupsioskiyeokkorean'] = 0x3174;
  17441. t['pieupsioskorean'] = 0x3144;
  17442. t['pieupsiostikeutkorean'] = 0x3175;
  17443. t['pieupthieuthkorean'] = 0x3177;
  17444. t['pieuptikeutkorean'] = 0x3173;
  17445. t['pihiragana'] = 0x3074;
  17446. t['pikatakana'] = 0x30D4;
  17447. t['pisymbolgreek'] = 0x03D6;
  17448. t['piwrarmenian'] = 0x0583;
  17449. t['plus'] = 0x002B;
  17450. t['plusbelowcmb'] = 0x031F;
  17451. t['pluscircle'] = 0x2295;
  17452. t['plusminus'] = 0x00B1;
  17453. t['plusmod'] = 0x02D6;
  17454. t['plusmonospace'] = 0xFF0B;
  17455. t['plussmall'] = 0xFE62;
  17456. t['plussuperior'] = 0x207A;
  17457. t['pmonospace'] = 0xFF50;
  17458. t['pmsquare'] = 0x33D8;
  17459. t['pohiragana'] = 0x307D;
  17460. t['pointingindexdownwhite'] = 0x261F;
  17461. t['pointingindexleftwhite'] = 0x261C;
  17462. t['pointingindexrightwhite'] = 0x261E;
  17463. t['pointingindexupwhite'] = 0x261D;
  17464. t['pokatakana'] = 0x30DD;
  17465. t['poplathai'] = 0x0E1B;
  17466. t['postalmark'] = 0x3012;
  17467. t['postalmarkface'] = 0x3020;
  17468. t['pparen'] = 0x24AB;
  17469. t['precedes'] = 0x227A;
  17470. t['prescription'] = 0x211E;
  17471. t['primemod'] = 0x02B9;
  17472. t['primereversed'] = 0x2035;
  17473. t['product'] = 0x220F;
  17474. t['projective'] = 0x2305;
  17475. t['prolongedkana'] = 0x30FC;
  17476. t['propellor'] = 0x2318;
  17477. t['propersubset'] = 0x2282;
  17478. t['propersuperset'] = 0x2283;
  17479. t['proportion'] = 0x2237;
  17480. t['proportional'] = 0x221D;
  17481. t['psi'] = 0x03C8;
  17482. t['psicyrillic'] = 0x0471;
  17483. t['psilipneumatacyrilliccmb'] = 0x0486;
  17484. t['pssquare'] = 0x33B0;
  17485. t['puhiragana'] = 0x3077;
  17486. t['pukatakana'] = 0x30D7;
  17487. t['pvsquare'] = 0x33B4;
  17488. t['pwsquare'] = 0x33BA;
  17489. t['q'] = 0x0071;
  17490. t['qadeva'] = 0x0958;
  17491. t['qadmahebrew'] = 0x05A8;
  17492. t['qafarabic'] = 0x0642;
  17493. t['qaffinalarabic'] = 0xFED6;
  17494. t['qafinitialarabic'] = 0xFED7;
  17495. t['qafmedialarabic'] = 0xFED8;
  17496. t['qamats'] = 0x05B8;
  17497. t['qamats10'] = 0x05B8;
  17498. t['qamats1a'] = 0x05B8;
  17499. t['qamats1c'] = 0x05B8;
  17500. t['qamats27'] = 0x05B8;
  17501. t['qamats29'] = 0x05B8;
  17502. t['qamats33'] = 0x05B8;
  17503. t['qamatsde'] = 0x05B8;
  17504. t['qamatshebrew'] = 0x05B8;
  17505. t['qamatsnarrowhebrew'] = 0x05B8;
  17506. t['qamatsqatanhebrew'] = 0x05B8;
  17507. t['qamatsqatannarrowhebrew'] = 0x05B8;
  17508. t['qamatsqatanquarterhebrew'] = 0x05B8;
  17509. t['qamatsqatanwidehebrew'] = 0x05B8;
  17510. t['qamatsquarterhebrew'] = 0x05B8;
  17511. t['qamatswidehebrew'] = 0x05B8;
  17512. t['qarneyparahebrew'] = 0x059F;
  17513. t['qbopomofo'] = 0x3111;
  17514. t['qcircle'] = 0x24E0;
  17515. t['qhook'] = 0x02A0;
  17516. t['qmonospace'] = 0xFF51;
  17517. t['qof'] = 0x05E7;
  17518. t['qofdagesh'] = 0xFB47;
  17519. t['qofdageshhebrew'] = 0xFB47;
  17520. t['qofhebrew'] = 0x05E7;
  17521. t['qparen'] = 0x24AC;
  17522. t['quarternote'] = 0x2669;
  17523. t['qubuts'] = 0x05BB;
  17524. t['qubuts18'] = 0x05BB;
  17525. t['qubuts25'] = 0x05BB;
  17526. t['qubuts31'] = 0x05BB;
  17527. t['qubutshebrew'] = 0x05BB;
  17528. t['qubutsnarrowhebrew'] = 0x05BB;
  17529. t['qubutsquarterhebrew'] = 0x05BB;
  17530. t['qubutswidehebrew'] = 0x05BB;
  17531. t['question'] = 0x003F;
  17532. t['questionarabic'] = 0x061F;
  17533. t['questionarmenian'] = 0x055E;
  17534. t['questiondown'] = 0x00BF;
  17535. t['questiondownsmall'] = 0xF7BF;
  17536. t['questiongreek'] = 0x037E;
  17537. t['questionmonospace'] = 0xFF1F;
  17538. t['questionsmall'] = 0xF73F;
  17539. t['quotedbl'] = 0x0022;
  17540. t['quotedblbase'] = 0x201E;
  17541. t['quotedblleft'] = 0x201C;
  17542. t['quotedblmonospace'] = 0xFF02;
  17543. t['quotedblprime'] = 0x301E;
  17544. t['quotedblprimereversed'] = 0x301D;
  17545. t['quotedblright'] = 0x201D;
  17546. t['quoteleft'] = 0x2018;
  17547. t['quoteleftreversed'] = 0x201B;
  17548. t['quotereversed'] = 0x201B;
  17549. t['quoteright'] = 0x2019;
  17550. t['quoterightn'] = 0x0149;
  17551. t['quotesinglbase'] = 0x201A;
  17552. t['quotesingle'] = 0x0027;
  17553. t['quotesinglemonospace'] = 0xFF07;
  17554. t['r'] = 0x0072;
  17555. t['raarmenian'] = 0x057C;
  17556. t['rabengali'] = 0x09B0;
  17557. t['racute'] = 0x0155;
  17558. t['radeva'] = 0x0930;
  17559. t['radical'] = 0x221A;
  17560. t['radicalex'] = 0xF8E5;
  17561. t['radoverssquare'] = 0x33AE;
  17562. t['radoverssquaredsquare'] = 0x33AF;
  17563. t['radsquare'] = 0x33AD;
  17564. t['rafe'] = 0x05BF;
  17565. t['rafehebrew'] = 0x05BF;
  17566. t['ragujarati'] = 0x0AB0;
  17567. t['ragurmukhi'] = 0x0A30;
  17568. t['rahiragana'] = 0x3089;
  17569. t['rakatakana'] = 0x30E9;
  17570. t['rakatakanahalfwidth'] = 0xFF97;
  17571. t['ralowerdiagonalbengali'] = 0x09F1;
  17572. t['ramiddlediagonalbengali'] = 0x09F0;
  17573. t['ramshorn'] = 0x0264;
  17574. t['ratio'] = 0x2236;
  17575. t['rbopomofo'] = 0x3116;
  17576. t['rcaron'] = 0x0159;
  17577. t['rcedilla'] = 0x0157;
  17578. t['rcircle'] = 0x24E1;
  17579. t['rcommaaccent'] = 0x0157;
  17580. t['rdblgrave'] = 0x0211;
  17581. t['rdotaccent'] = 0x1E59;
  17582. t['rdotbelow'] = 0x1E5B;
  17583. t['rdotbelowmacron'] = 0x1E5D;
  17584. t['referencemark'] = 0x203B;
  17585. t['reflexsubset'] = 0x2286;
  17586. t['reflexsuperset'] = 0x2287;
  17587. t['registered'] = 0x00AE;
  17588. t['registersans'] = 0xF8E8;
  17589. t['registerserif'] = 0xF6DA;
  17590. t['reharabic'] = 0x0631;
  17591. t['reharmenian'] = 0x0580;
  17592. t['rehfinalarabic'] = 0xFEAE;
  17593. t['rehiragana'] = 0x308C;
  17594. t['rekatakana'] = 0x30EC;
  17595. t['rekatakanahalfwidth'] = 0xFF9A;
  17596. t['resh'] = 0x05E8;
  17597. t['reshdageshhebrew'] = 0xFB48;
  17598. t['reshhebrew'] = 0x05E8;
  17599. t['reversedtilde'] = 0x223D;
  17600. t['reviahebrew'] = 0x0597;
  17601. t['reviamugrashhebrew'] = 0x0597;
  17602. t['revlogicalnot'] = 0x2310;
  17603. t['rfishhook'] = 0x027E;
  17604. t['rfishhookreversed'] = 0x027F;
  17605. t['rhabengali'] = 0x09DD;
  17606. t['rhadeva'] = 0x095D;
  17607. t['rho'] = 0x03C1;
  17608. t['rhook'] = 0x027D;
  17609. t['rhookturned'] = 0x027B;
  17610. t['rhookturnedsuperior'] = 0x02B5;
  17611. t['rhosymbolgreek'] = 0x03F1;
  17612. t['rhotichookmod'] = 0x02DE;
  17613. t['rieulacirclekorean'] = 0x3271;
  17614. t['rieulaparenkorean'] = 0x3211;
  17615. t['rieulcirclekorean'] = 0x3263;
  17616. t['rieulhieuhkorean'] = 0x3140;
  17617. t['rieulkiyeokkorean'] = 0x313A;
  17618. t['rieulkiyeoksioskorean'] = 0x3169;
  17619. t['rieulkorean'] = 0x3139;
  17620. t['rieulmieumkorean'] = 0x313B;
  17621. t['rieulpansioskorean'] = 0x316C;
  17622. t['rieulparenkorean'] = 0x3203;
  17623. t['rieulphieuphkorean'] = 0x313F;
  17624. t['rieulpieupkorean'] = 0x313C;
  17625. t['rieulpieupsioskorean'] = 0x316B;
  17626. t['rieulsioskorean'] = 0x313D;
  17627. t['rieulthieuthkorean'] = 0x313E;
  17628. t['rieultikeutkorean'] = 0x316A;
  17629. t['rieulyeorinhieuhkorean'] = 0x316D;
  17630. t['rightangle'] = 0x221F;
  17631. t['righttackbelowcmb'] = 0x0319;
  17632. t['righttriangle'] = 0x22BF;
  17633. t['rihiragana'] = 0x308A;
  17634. t['rikatakana'] = 0x30EA;
  17635. t['rikatakanahalfwidth'] = 0xFF98;
  17636. t['ring'] = 0x02DA;
  17637. t['ringbelowcmb'] = 0x0325;
  17638. t['ringcmb'] = 0x030A;
  17639. t['ringhalfleft'] = 0x02BF;
  17640. t['ringhalfleftarmenian'] = 0x0559;
  17641. t['ringhalfleftbelowcmb'] = 0x031C;
  17642. t['ringhalfleftcentered'] = 0x02D3;
  17643. t['ringhalfright'] = 0x02BE;
  17644. t['ringhalfrightbelowcmb'] = 0x0339;
  17645. t['ringhalfrightcentered'] = 0x02D2;
  17646. t['rinvertedbreve'] = 0x0213;
  17647. t['rittorusquare'] = 0x3351;
  17648. t['rlinebelow'] = 0x1E5F;
  17649. t['rlongleg'] = 0x027C;
  17650. t['rlonglegturned'] = 0x027A;
  17651. t['rmonospace'] = 0xFF52;
  17652. t['rohiragana'] = 0x308D;
  17653. t['rokatakana'] = 0x30ED;
  17654. t['rokatakanahalfwidth'] = 0xFF9B;
  17655. t['roruathai'] = 0x0E23;
  17656. t['rparen'] = 0x24AD;
  17657. t['rrabengali'] = 0x09DC;
  17658. t['rradeva'] = 0x0931;
  17659. t['rragurmukhi'] = 0x0A5C;
  17660. t['rreharabic'] = 0x0691;
  17661. t['rrehfinalarabic'] = 0xFB8D;
  17662. t['rrvocalicbengali'] = 0x09E0;
  17663. t['rrvocalicdeva'] = 0x0960;
  17664. t['rrvocalicgujarati'] = 0x0AE0;
  17665. t['rrvocalicvowelsignbengali'] = 0x09C4;
  17666. t['rrvocalicvowelsigndeva'] = 0x0944;
  17667. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  17668. t['rsuperior'] = 0xF6F1;
  17669. t['rtblock'] = 0x2590;
  17670. t['rturned'] = 0x0279;
  17671. t['rturnedsuperior'] = 0x02B4;
  17672. t['ruhiragana'] = 0x308B;
  17673. t['rukatakana'] = 0x30EB;
  17674. t['rukatakanahalfwidth'] = 0xFF99;
  17675. t['rupeemarkbengali'] = 0x09F2;
  17676. t['rupeesignbengali'] = 0x09F3;
  17677. t['rupiah'] = 0xF6DD;
  17678. t['ruthai'] = 0x0E24;
  17679. t['rvocalicbengali'] = 0x098B;
  17680. t['rvocalicdeva'] = 0x090B;
  17681. t['rvocalicgujarati'] = 0x0A8B;
  17682. t['rvocalicvowelsignbengali'] = 0x09C3;
  17683. t['rvocalicvowelsigndeva'] = 0x0943;
  17684. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  17685. t['s'] = 0x0073;
  17686. t['sabengali'] = 0x09B8;
  17687. t['sacute'] = 0x015B;
  17688. t['sacutedotaccent'] = 0x1E65;
  17689. t['sadarabic'] = 0x0635;
  17690. t['sadeva'] = 0x0938;
  17691. t['sadfinalarabic'] = 0xFEBA;
  17692. t['sadinitialarabic'] = 0xFEBB;
  17693. t['sadmedialarabic'] = 0xFEBC;
  17694. t['sagujarati'] = 0x0AB8;
  17695. t['sagurmukhi'] = 0x0A38;
  17696. t['sahiragana'] = 0x3055;
  17697. t['sakatakana'] = 0x30B5;
  17698. t['sakatakanahalfwidth'] = 0xFF7B;
  17699. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  17700. t['samekh'] = 0x05E1;
  17701. t['samekhdagesh'] = 0xFB41;
  17702. t['samekhdageshhebrew'] = 0xFB41;
  17703. t['samekhhebrew'] = 0x05E1;
  17704. t['saraaathai'] = 0x0E32;
  17705. t['saraaethai'] = 0x0E41;
  17706. t['saraaimaimalaithai'] = 0x0E44;
  17707. t['saraaimaimuanthai'] = 0x0E43;
  17708. t['saraamthai'] = 0x0E33;
  17709. t['saraathai'] = 0x0E30;
  17710. t['saraethai'] = 0x0E40;
  17711. t['saraiileftthai'] = 0xF886;
  17712. t['saraiithai'] = 0x0E35;
  17713. t['saraileftthai'] = 0xF885;
  17714. t['saraithai'] = 0x0E34;
  17715. t['saraothai'] = 0x0E42;
  17716. t['saraueeleftthai'] = 0xF888;
  17717. t['saraueethai'] = 0x0E37;
  17718. t['saraueleftthai'] = 0xF887;
  17719. t['sarauethai'] = 0x0E36;
  17720. t['sarauthai'] = 0x0E38;
  17721. t['sarauuthai'] = 0x0E39;
  17722. t['sbopomofo'] = 0x3119;
  17723. t['scaron'] = 0x0161;
  17724. t['scarondotaccent'] = 0x1E67;
  17725. t['scedilla'] = 0x015F;
  17726. t['schwa'] = 0x0259;
  17727. t['schwacyrillic'] = 0x04D9;
  17728. t['schwadieresiscyrillic'] = 0x04DB;
  17729. t['schwahook'] = 0x025A;
  17730. t['scircle'] = 0x24E2;
  17731. t['scircumflex'] = 0x015D;
  17732. t['scommaaccent'] = 0x0219;
  17733. t['sdotaccent'] = 0x1E61;
  17734. t['sdotbelow'] = 0x1E63;
  17735. t['sdotbelowdotaccent'] = 0x1E69;
  17736. t['seagullbelowcmb'] = 0x033C;
  17737. t['second'] = 0x2033;
  17738. t['secondtonechinese'] = 0x02CA;
  17739. t['section'] = 0x00A7;
  17740. t['seenarabic'] = 0x0633;
  17741. t['seenfinalarabic'] = 0xFEB2;
  17742. t['seeninitialarabic'] = 0xFEB3;
  17743. t['seenmedialarabic'] = 0xFEB4;
  17744. t['segol'] = 0x05B6;
  17745. t['segol13'] = 0x05B6;
  17746. t['segol1f'] = 0x05B6;
  17747. t['segol2c'] = 0x05B6;
  17748. t['segolhebrew'] = 0x05B6;
  17749. t['segolnarrowhebrew'] = 0x05B6;
  17750. t['segolquarterhebrew'] = 0x05B6;
  17751. t['segoltahebrew'] = 0x0592;
  17752. t['segolwidehebrew'] = 0x05B6;
  17753. t['seharmenian'] = 0x057D;
  17754. t['sehiragana'] = 0x305B;
  17755. t['sekatakana'] = 0x30BB;
  17756. t['sekatakanahalfwidth'] = 0xFF7E;
  17757. t['semicolon'] = 0x003B;
  17758. t['semicolonarabic'] = 0x061B;
  17759. t['semicolonmonospace'] = 0xFF1B;
  17760. t['semicolonsmall'] = 0xFE54;
  17761. t['semivoicedmarkkana'] = 0x309C;
  17762. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  17763. t['sentisquare'] = 0x3322;
  17764. t['sentosquare'] = 0x3323;
  17765. t['seven'] = 0x0037;
  17766. t['sevenarabic'] = 0x0667;
  17767. t['sevenbengali'] = 0x09ED;
  17768. t['sevencircle'] = 0x2466;
  17769. t['sevencircleinversesansserif'] = 0x2790;
  17770. t['sevendeva'] = 0x096D;
  17771. t['seveneighths'] = 0x215E;
  17772. t['sevengujarati'] = 0x0AED;
  17773. t['sevengurmukhi'] = 0x0A6D;
  17774. t['sevenhackarabic'] = 0x0667;
  17775. t['sevenhangzhou'] = 0x3027;
  17776. t['sevenideographicparen'] = 0x3226;
  17777. t['seveninferior'] = 0x2087;
  17778. t['sevenmonospace'] = 0xFF17;
  17779. t['sevenoldstyle'] = 0xF737;
  17780. t['sevenparen'] = 0x247A;
  17781. t['sevenperiod'] = 0x248E;
  17782. t['sevenpersian'] = 0x06F7;
  17783. t['sevenroman'] = 0x2176;
  17784. t['sevensuperior'] = 0x2077;
  17785. t['seventeencircle'] = 0x2470;
  17786. t['seventeenparen'] = 0x2484;
  17787. t['seventeenperiod'] = 0x2498;
  17788. t['seventhai'] = 0x0E57;
  17789. t['sfthyphen'] = 0x00AD;
  17790. t['shaarmenian'] = 0x0577;
  17791. t['shabengali'] = 0x09B6;
  17792. t['shacyrillic'] = 0x0448;
  17793. t['shaddaarabic'] = 0x0651;
  17794. t['shaddadammaarabic'] = 0xFC61;
  17795. t['shaddadammatanarabic'] = 0xFC5E;
  17796. t['shaddafathaarabic'] = 0xFC60;
  17797. t['shaddakasraarabic'] = 0xFC62;
  17798. t['shaddakasratanarabic'] = 0xFC5F;
  17799. t['shade'] = 0x2592;
  17800. t['shadedark'] = 0x2593;
  17801. t['shadelight'] = 0x2591;
  17802. t['shademedium'] = 0x2592;
  17803. t['shadeva'] = 0x0936;
  17804. t['shagujarati'] = 0x0AB6;
  17805. t['shagurmukhi'] = 0x0A36;
  17806. t['shalshelethebrew'] = 0x0593;
  17807. t['shbopomofo'] = 0x3115;
  17808. t['shchacyrillic'] = 0x0449;
  17809. t['sheenarabic'] = 0x0634;
  17810. t['sheenfinalarabic'] = 0xFEB6;
  17811. t['sheeninitialarabic'] = 0xFEB7;
  17812. t['sheenmedialarabic'] = 0xFEB8;
  17813. t['sheicoptic'] = 0x03E3;
  17814. t['sheqel'] = 0x20AA;
  17815. t['sheqelhebrew'] = 0x20AA;
  17816. t['sheva'] = 0x05B0;
  17817. t['sheva115'] = 0x05B0;
  17818. t['sheva15'] = 0x05B0;
  17819. t['sheva22'] = 0x05B0;
  17820. t['sheva2e'] = 0x05B0;
  17821. t['shevahebrew'] = 0x05B0;
  17822. t['shevanarrowhebrew'] = 0x05B0;
  17823. t['shevaquarterhebrew'] = 0x05B0;
  17824. t['shevawidehebrew'] = 0x05B0;
  17825. t['shhacyrillic'] = 0x04BB;
  17826. t['shimacoptic'] = 0x03ED;
  17827. t['shin'] = 0x05E9;
  17828. t['shindagesh'] = 0xFB49;
  17829. t['shindageshhebrew'] = 0xFB49;
  17830. t['shindageshshindot'] = 0xFB2C;
  17831. t['shindageshshindothebrew'] = 0xFB2C;
  17832. t['shindageshsindot'] = 0xFB2D;
  17833. t['shindageshsindothebrew'] = 0xFB2D;
  17834. t['shindothebrew'] = 0x05C1;
  17835. t['shinhebrew'] = 0x05E9;
  17836. t['shinshindot'] = 0xFB2A;
  17837. t['shinshindothebrew'] = 0xFB2A;
  17838. t['shinsindot'] = 0xFB2B;
  17839. t['shinsindothebrew'] = 0xFB2B;
  17840. t['shook'] = 0x0282;
  17841. t['sigma'] = 0x03C3;
  17842. t['sigma1'] = 0x03C2;
  17843. t['sigmafinal'] = 0x03C2;
  17844. t['sigmalunatesymbolgreek'] = 0x03F2;
  17845. t['sihiragana'] = 0x3057;
  17846. t['sikatakana'] = 0x30B7;
  17847. t['sikatakanahalfwidth'] = 0xFF7C;
  17848. t['siluqhebrew'] = 0x05BD;
  17849. t['siluqlefthebrew'] = 0x05BD;
  17850. t['similar'] = 0x223C;
  17851. t['sindothebrew'] = 0x05C2;
  17852. t['siosacirclekorean'] = 0x3274;
  17853. t['siosaparenkorean'] = 0x3214;
  17854. t['sioscieuckorean'] = 0x317E;
  17855. t['sioscirclekorean'] = 0x3266;
  17856. t['sioskiyeokkorean'] = 0x317A;
  17857. t['sioskorean'] = 0x3145;
  17858. t['siosnieunkorean'] = 0x317B;
  17859. t['siosparenkorean'] = 0x3206;
  17860. t['siospieupkorean'] = 0x317D;
  17861. t['siostikeutkorean'] = 0x317C;
  17862. t['six'] = 0x0036;
  17863. t['sixarabic'] = 0x0666;
  17864. t['sixbengali'] = 0x09EC;
  17865. t['sixcircle'] = 0x2465;
  17866. t['sixcircleinversesansserif'] = 0x278F;
  17867. t['sixdeva'] = 0x096C;
  17868. t['sixgujarati'] = 0x0AEC;
  17869. t['sixgurmukhi'] = 0x0A6C;
  17870. t['sixhackarabic'] = 0x0666;
  17871. t['sixhangzhou'] = 0x3026;
  17872. t['sixideographicparen'] = 0x3225;
  17873. t['sixinferior'] = 0x2086;
  17874. t['sixmonospace'] = 0xFF16;
  17875. t['sixoldstyle'] = 0xF736;
  17876. t['sixparen'] = 0x2479;
  17877. t['sixperiod'] = 0x248D;
  17878. t['sixpersian'] = 0x06F6;
  17879. t['sixroman'] = 0x2175;
  17880. t['sixsuperior'] = 0x2076;
  17881. t['sixteencircle'] = 0x246F;
  17882. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  17883. t['sixteenparen'] = 0x2483;
  17884. t['sixteenperiod'] = 0x2497;
  17885. t['sixthai'] = 0x0E56;
  17886. t['slash'] = 0x002F;
  17887. t['slashmonospace'] = 0xFF0F;
  17888. t['slong'] = 0x017F;
  17889. t['slongdotaccent'] = 0x1E9B;
  17890. t['smileface'] = 0x263A;
  17891. t['smonospace'] = 0xFF53;
  17892. t['sofpasuqhebrew'] = 0x05C3;
  17893. t['softhyphen'] = 0x00AD;
  17894. t['softsigncyrillic'] = 0x044C;
  17895. t['sohiragana'] = 0x305D;
  17896. t['sokatakana'] = 0x30BD;
  17897. t['sokatakanahalfwidth'] = 0xFF7F;
  17898. t['soliduslongoverlaycmb'] = 0x0338;
  17899. t['solidusshortoverlaycmb'] = 0x0337;
  17900. t['sorusithai'] = 0x0E29;
  17901. t['sosalathai'] = 0x0E28;
  17902. t['sosothai'] = 0x0E0B;
  17903. t['sosuathai'] = 0x0E2A;
  17904. t['space'] = 0x0020;
  17905. t['spacehackarabic'] = 0x0020;
  17906. t['spade'] = 0x2660;
  17907. t['spadesuitblack'] = 0x2660;
  17908. t['spadesuitwhite'] = 0x2664;
  17909. t['sparen'] = 0x24AE;
  17910. t['squarebelowcmb'] = 0x033B;
  17911. t['squarecc'] = 0x33C4;
  17912. t['squarecm'] = 0x339D;
  17913. t['squarediagonalcrosshatchfill'] = 0x25A9;
  17914. t['squarehorizontalfill'] = 0x25A4;
  17915. t['squarekg'] = 0x338F;
  17916. t['squarekm'] = 0x339E;
  17917. t['squarekmcapital'] = 0x33CE;
  17918. t['squareln'] = 0x33D1;
  17919. t['squarelog'] = 0x33D2;
  17920. t['squaremg'] = 0x338E;
  17921. t['squaremil'] = 0x33D5;
  17922. t['squaremm'] = 0x339C;
  17923. t['squaremsquared'] = 0x33A1;
  17924. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  17925. t['squareupperlefttolowerrightfill'] = 0x25A7;
  17926. t['squareupperrighttolowerleftfill'] = 0x25A8;
  17927. t['squareverticalfill'] = 0x25A5;
  17928. t['squarewhitewithsmallblack'] = 0x25A3;
  17929. t['srsquare'] = 0x33DB;
  17930. t['ssabengali'] = 0x09B7;
  17931. t['ssadeva'] = 0x0937;
  17932. t['ssagujarati'] = 0x0AB7;
  17933. t['ssangcieuckorean'] = 0x3149;
  17934. t['ssanghieuhkorean'] = 0x3185;
  17935. t['ssangieungkorean'] = 0x3180;
  17936. t['ssangkiyeokkorean'] = 0x3132;
  17937. t['ssangnieunkorean'] = 0x3165;
  17938. t['ssangpieupkorean'] = 0x3143;
  17939. t['ssangsioskorean'] = 0x3146;
  17940. t['ssangtikeutkorean'] = 0x3138;
  17941. t['ssuperior'] = 0xF6F2;
  17942. t['sterling'] = 0x00A3;
  17943. t['sterlingmonospace'] = 0xFFE1;
  17944. t['strokelongoverlaycmb'] = 0x0336;
  17945. t['strokeshortoverlaycmb'] = 0x0335;
  17946. t['subset'] = 0x2282;
  17947. t['subsetnotequal'] = 0x228A;
  17948. t['subsetorequal'] = 0x2286;
  17949. t['succeeds'] = 0x227B;
  17950. t['suchthat'] = 0x220B;
  17951. t['suhiragana'] = 0x3059;
  17952. t['sukatakana'] = 0x30B9;
  17953. t['sukatakanahalfwidth'] = 0xFF7D;
  17954. t['sukunarabic'] = 0x0652;
  17955. t['summation'] = 0x2211;
  17956. t['sun'] = 0x263C;
  17957. t['superset'] = 0x2283;
  17958. t['supersetnotequal'] = 0x228B;
  17959. t['supersetorequal'] = 0x2287;
  17960. t['svsquare'] = 0x33DC;
  17961. t['syouwaerasquare'] = 0x337C;
  17962. t['t'] = 0x0074;
  17963. t['tabengali'] = 0x09A4;
  17964. t['tackdown'] = 0x22A4;
  17965. t['tackleft'] = 0x22A3;
  17966. t['tadeva'] = 0x0924;
  17967. t['tagujarati'] = 0x0AA4;
  17968. t['tagurmukhi'] = 0x0A24;
  17969. t['taharabic'] = 0x0637;
  17970. t['tahfinalarabic'] = 0xFEC2;
  17971. t['tahinitialarabic'] = 0xFEC3;
  17972. t['tahiragana'] = 0x305F;
  17973. t['tahmedialarabic'] = 0xFEC4;
  17974. t['taisyouerasquare'] = 0x337D;
  17975. t['takatakana'] = 0x30BF;
  17976. t['takatakanahalfwidth'] = 0xFF80;
  17977. t['tatweelarabic'] = 0x0640;
  17978. t['tau'] = 0x03C4;
  17979. t['tav'] = 0x05EA;
  17980. t['tavdages'] = 0xFB4A;
  17981. t['tavdagesh'] = 0xFB4A;
  17982. t['tavdageshhebrew'] = 0xFB4A;
  17983. t['tavhebrew'] = 0x05EA;
  17984. t['tbar'] = 0x0167;
  17985. t['tbopomofo'] = 0x310A;
  17986. t['tcaron'] = 0x0165;
  17987. t['tccurl'] = 0x02A8;
  17988. t['tcedilla'] = 0x0163;
  17989. t['tcheharabic'] = 0x0686;
  17990. t['tchehfinalarabic'] = 0xFB7B;
  17991. t['tchehinitialarabic'] = 0xFB7C;
  17992. t['tchehmedialarabic'] = 0xFB7D;
  17993. t['tcircle'] = 0x24E3;
  17994. t['tcircumflexbelow'] = 0x1E71;
  17995. t['tcommaaccent'] = 0x0163;
  17996. t['tdieresis'] = 0x1E97;
  17997. t['tdotaccent'] = 0x1E6B;
  17998. t['tdotbelow'] = 0x1E6D;
  17999. t['tecyrillic'] = 0x0442;
  18000. t['tedescendercyrillic'] = 0x04AD;
  18001. t['teharabic'] = 0x062A;
  18002. t['tehfinalarabic'] = 0xFE96;
  18003. t['tehhahinitialarabic'] = 0xFCA2;
  18004. t['tehhahisolatedarabic'] = 0xFC0C;
  18005. t['tehinitialarabic'] = 0xFE97;
  18006. t['tehiragana'] = 0x3066;
  18007. t['tehjeeminitialarabic'] = 0xFCA1;
  18008. t['tehjeemisolatedarabic'] = 0xFC0B;
  18009. t['tehmarbutaarabic'] = 0x0629;
  18010. t['tehmarbutafinalarabic'] = 0xFE94;
  18011. t['tehmedialarabic'] = 0xFE98;
  18012. t['tehmeeminitialarabic'] = 0xFCA4;
  18013. t['tehmeemisolatedarabic'] = 0xFC0E;
  18014. t['tehnoonfinalarabic'] = 0xFC73;
  18015. t['tekatakana'] = 0x30C6;
  18016. t['tekatakanahalfwidth'] = 0xFF83;
  18017. t['telephone'] = 0x2121;
  18018. t['telephoneblack'] = 0x260E;
  18019. t['telishagedolahebrew'] = 0x05A0;
  18020. t['telishaqetanahebrew'] = 0x05A9;
  18021. t['tencircle'] = 0x2469;
  18022. t['tenideographicparen'] = 0x3229;
  18023. t['tenparen'] = 0x247D;
  18024. t['tenperiod'] = 0x2491;
  18025. t['tenroman'] = 0x2179;
  18026. t['tesh'] = 0x02A7;
  18027. t['tet'] = 0x05D8;
  18028. t['tetdagesh'] = 0xFB38;
  18029. t['tetdageshhebrew'] = 0xFB38;
  18030. t['tethebrew'] = 0x05D8;
  18031. t['tetsecyrillic'] = 0x04B5;
  18032. t['tevirhebrew'] = 0x059B;
  18033. t['tevirlefthebrew'] = 0x059B;
  18034. t['thabengali'] = 0x09A5;
  18035. t['thadeva'] = 0x0925;
  18036. t['thagujarati'] = 0x0AA5;
  18037. t['thagurmukhi'] = 0x0A25;
  18038. t['thalarabic'] = 0x0630;
  18039. t['thalfinalarabic'] = 0xFEAC;
  18040. t['thanthakhatlowleftthai'] = 0xF898;
  18041. t['thanthakhatlowrightthai'] = 0xF897;
  18042. t['thanthakhatthai'] = 0x0E4C;
  18043. t['thanthakhatupperleftthai'] = 0xF896;
  18044. t['theharabic'] = 0x062B;
  18045. t['thehfinalarabic'] = 0xFE9A;
  18046. t['thehinitialarabic'] = 0xFE9B;
  18047. t['thehmedialarabic'] = 0xFE9C;
  18048. t['thereexists'] = 0x2203;
  18049. t['therefore'] = 0x2234;
  18050. t['theta'] = 0x03B8;
  18051. t['theta1'] = 0x03D1;
  18052. t['thetasymbolgreek'] = 0x03D1;
  18053. t['thieuthacirclekorean'] = 0x3279;
  18054. t['thieuthaparenkorean'] = 0x3219;
  18055. t['thieuthcirclekorean'] = 0x326B;
  18056. t['thieuthkorean'] = 0x314C;
  18057. t['thieuthparenkorean'] = 0x320B;
  18058. t['thirteencircle'] = 0x246C;
  18059. t['thirteenparen'] = 0x2480;
  18060. t['thirteenperiod'] = 0x2494;
  18061. t['thonangmonthothai'] = 0x0E11;
  18062. t['thook'] = 0x01AD;
  18063. t['thophuthaothai'] = 0x0E12;
  18064. t['thorn'] = 0x00FE;
  18065. t['thothahanthai'] = 0x0E17;
  18066. t['thothanthai'] = 0x0E10;
  18067. t['thothongthai'] = 0x0E18;
  18068. t['thothungthai'] = 0x0E16;
  18069. t['thousandcyrillic'] = 0x0482;
  18070. t['thousandsseparatorarabic'] = 0x066C;
  18071. t['thousandsseparatorpersian'] = 0x066C;
  18072. t['three'] = 0x0033;
  18073. t['threearabic'] = 0x0663;
  18074. t['threebengali'] = 0x09E9;
  18075. t['threecircle'] = 0x2462;
  18076. t['threecircleinversesansserif'] = 0x278C;
  18077. t['threedeva'] = 0x0969;
  18078. t['threeeighths'] = 0x215C;
  18079. t['threegujarati'] = 0x0AE9;
  18080. t['threegurmukhi'] = 0x0A69;
  18081. t['threehackarabic'] = 0x0663;
  18082. t['threehangzhou'] = 0x3023;
  18083. t['threeideographicparen'] = 0x3222;
  18084. t['threeinferior'] = 0x2083;
  18085. t['threemonospace'] = 0xFF13;
  18086. t['threenumeratorbengali'] = 0x09F6;
  18087. t['threeoldstyle'] = 0xF733;
  18088. t['threeparen'] = 0x2476;
  18089. t['threeperiod'] = 0x248A;
  18090. t['threepersian'] = 0x06F3;
  18091. t['threequarters'] = 0x00BE;
  18092. t['threequartersemdash'] = 0xF6DE;
  18093. t['threeroman'] = 0x2172;
  18094. t['threesuperior'] = 0x00B3;
  18095. t['threethai'] = 0x0E53;
  18096. t['thzsquare'] = 0x3394;
  18097. t['tihiragana'] = 0x3061;
  18098. t['tikatakana'] = 0x30C1;
  18099. t['tikatakanahalfwidth'] = 0xFF81;
  18100. t['tikeutacirclekorean'] = 0x3270;
  18101. t['tikeutaparenkorean'] = 0x3210;
  18102. t['tikeutcirclekorean'] = 0x3262;
  18103. t['tikeutkorean'] = 0x3137;
  18104. t['tikeutparenkorean'] = 0x3202;
  18105. t['tilde'] = 0x02DC;
  18106. t['tildebelowcmb'] = 0x0330;
  18107. t['tildecmb'] = 0x0303;
  18108. t['tildecomb'] = 0x0303;
  18109. t['tildedoublecmb'] = 0x0360;
  18110. t['tildeoperator'] = 0x223C;
  18111. t['tildeoverlaycmb'] = 0x0334;
  18112. t['tildeverticalcmb'] = 0x033E;
  18113. t['timescircle'] = 0x2297;
  18114. t['tipehahebrew'] = 0x0596;
  18115. t['tipehalefthebrew'] = 0x0596;
  18116. t['tippigurmukhi'] = 0x0A70;
  18117. t['titlocyrilliccmb'] = 0x0483;
  18118. t['tiwnarmenian'] = 0x057F;
  18119. t['tlinebelow'] = 0x1E6F;
  18120. t['tmonospace'] = 0xFF54;
  18121. t['toarmenian'] = 0x0569;
  18122. t['tohiragana'] = 0x3068;
  18123. t['tokatakana'] = 0x30C8;
  18124. t['tokatakanahalfwidth'] = 0xFF84;
  18125. t['tonebarextrahighmod'] = 0x02E5;
  18126. t['tonebarextralowmod'] = 0x02E9;
  18127. t['tonebarhighmod'] = 0x02E6;
  18128. t['tonebarlowmod'] = 0x02E8;
  18129. t['tonebarmidmod'] = 0x02E7;
  18130. t['tonefive'] = 0x01BD;
  18131. t['tonesix'] = 0x0185;
  18132. t['tonetwo'] = 0x01A8;
  18133. t['tonos'] = 0x0384;
  18134. t['tonsquare'] = 0x3327;
  18135. t['topatakthai'] = 0x0E0F;
  18136. t['tortoiseshellbracketleft'] = 0x3014;
  18137. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  18138. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  18139. t['tortoiseshellbracketright'] = 0x3015;
  18140. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  18141. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  18142. t['totaothai'] = 0x0E15;
  18143. t['tpalatalhook'] = 0x01AB;
  18144. t['tparen'] = 0x24AF;
  18145. t['trademark'] = 0x2122;
  18146. t['trademarksans'] = 0xF8EA;
  18147. t['trademarkserif'] = 0xF6DB;
  18148. t['tretroflexhook'] = 0x0288;
  18149. t['triagdn'] = 0x25BC;
  18150. t['triaglf'] = 0x25C4;
  18151. t['triagrt'] = 0x25BA;
  18152. t['triagup'] = 0x25B2;
  18153. t['ts'] = 0x02A6;
  18154. t['tsadi'] = 0x05E6;
  18155. t['tsadidagesh'] = 0xFB46;
  18156. t['tsadidageshhebrew'] = 0xFB46;
  18157. t['tsadihebrew'] = 0x05E6;
  18158. t['tsecyrillic'] = 0x0446;
  18159. t['tsere'] = 0x05B5;
  18160. t['tsere12'] = 0x05B5;
  18161. t['tsere1e'] = 0x05B5;
  18162. t['tsere2b'] = 0x05B5;
  18163. t['tserehebrew'] = 0x05B5;
  18164. t['tserenarrowhebrew'] = 0x05B5;
  18165. t['tserequarterhebrew'] = 0x05B5;
  18166. t['tserewidehebrew'] = 0x05B5;
  18167. t['tshecyrillic'] = 0x045B;
  18168. t['tsuperior'] = 0xF6F3;
  18169. t['ttabengali'] = 0x099F;
  18170. t['ttadeva'] = 0x091F;
  18171. t['ttagujarati'] = 0x0A9F;
  18172. t['ttagurmukhi'] = 0x0A1F;
  18173. t['tteharabic'] = 0x0679;
  18174. t['ttehfinalarabic'] = 0xFB67;
  18175. t['ttehinitialarabic'] = 0xFB68;
  18176. t['ttehmedialarabic'] = 0xFB69;
  18177. t['tthabengali'] = 0x09A0;
  18178. t['tthadeva'] = 0x0920;
  18179. t['tthagujarati'] = 0x0AA0;
  18180. t['tthagurmukhi'] = 0x0A20;
  18181. t['tturned'] = 0x0287;
  18182. t['tuhiragana'] = 0x3064;
  18183. t['tukatakana'] = 0x30C4;
  18184. t['tukatakanahalfwidth'] = 0xFF82;
  18185. t['tusmallhiragana'] = 0x3063;
  18186. t['tusmallkatakana'] = 0x30C3;
  18187. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  18188. t['twelvecircle'] = 0x246B;
  18189. t['twelveparen'] = 0x247F;
  18190. t['twelveperiod'] = 0x2493;
  18191. t['twelveroman'] = 0x217B;
  18192. t['twentycircle'] = 0x2473;
  18193. t['twentyhangzhou'] = 0x5344;
  18194. t['twentyparen'] = 0x2487;
  18195. t['twentyperiod'] = 0x249B;
  18196. t['two'] = 0x0032;
  18197. t['twoarabic'] = 0x0662;
  18198. t['twobengali'] = 0x09E8;
  18199. t['twocircle'] = 0x2461;
  18200. t['twocircleinversesansserif'] = 0x278B;
  18201. t['twodeva'] = 0x0968;
  18202. t['twodotenleader'] = 0x2025;
  18203. t['twodotleader'] = 0x2025;
  18204. t['twodotleadervertical'] = 0xFE30;
  18205. t['twogujarati'] = 0x0AE8;
  18206. t['twogurmukhi'] = 0x0A68;
  18207. t['twohackarabic'] = 0x0662;
  18208. t['twohangzhou'] = 0x3022;
  18209. t['twoideographicparen'] = 0x3221;
  18210. t['twoinferior'] = 0x2082;
  18211. t['twomonospace'] = 0xFF12;
  18212. t['twonumeratorbengali'] = 0x09F5;
  18213. t['twooldstyle'] = 0xF732;
  18214. t['twoparen'] = 0x2475;
  18215. t['twoperiod'] = 0x2489;
  18216. t['twopersian'] = 0x06F2;
  18217. t['tworoman'] = 0x2171;
  18218. t['twostroke'] = 0x01BB;
  18219. t['twosuperior'] = 0x00B2;
  18220. t['twothai'] = 0x0E52;
  18221. t['twothirds'] = 0x2154;
  18222. t['u'] = 0x0075;
  18223. t['uacute'] = 0x00FA;
  18224. t['ubar'] = 0x0289;
  18225. t['ubengali'] = 0x0989;
  18226. t['ubopomofo'] = 0x3128;
  18227. t['ubreve'] = 0x016D;
  18228. t['ucaron'] = 0x01D4;
  18229. t['ucircle'] = 0x24E4;
  18230. t['ucircumflex'] = 0x00FB;
  18231. t['ucircumflexbelow'] = 0x1E77;
  18232. t['ucyrillic'] = 0x0443;
  18233. t['udattadeva'] = 0x0951;
  18234. t['udblacute'] = 0x0171;
  18235. t['udblgrave'] = 0x0215;
  18236. t['udeva'] = 0x0909;
  18237. t['udieresis'] = 0x00FC;
  18238. t['udieresisacute'] = 0x01D8;
  18239. t['udieresisbelow'] = 0x1E73;
  18240. t['udieresiscaron'] = 0x01DA;
  18241. t['udieresiscyrillic'] = 0x04F1;
  18242. t['udieresisgrave'] = 0x01DC;
  18243. t['udieresismacron'] = 0x01D6;
  18244. t['udotbelow'] = 0x1EE5;
  18245. t['ugrave'] = 0x00F9;
  18246. t['ugujarati'] = 0x0A89;
  18247. t['ugurmukhi'] = 0x0A09;
  18248. t['uhiragana'] = 0x3046;
  18249. t['uhookabove'] = 0x1EE7;
  18250. t['uhorn'] = 0x01B0;
  18251. t['uhornacute'] = 0x1EE9;
  18252. t['uhorndotbelow'] = 0x1EF1;
  18253. t['uhorngrave'] = 0x1EEB;
  18254. t['uhornhookabove'] = 0x1EED;
  18255. t['uhorntilde'] = 0x1EEF;
  18256. t['uhungarumlaut'] = 0x0171;
  18257. t['uhungarumlautcyrillic'] = 0x04F3;
  18258. t['uinvertedbreve'] = 0x0217;
  18259. t['ukatakana'] = 0x30A6;
  18260. t['ukatakanahalfwidth'] = 0xFF73;
  18261. t['ukcyrillic'] = 0x0479;
  18262. t['ukorean'] = 0x315C;
  18263. t['umacron'] = 0x016B;
  18264. t['umacroncyrillic'] = 0x04EF;
  18265. t['umacrondieresis'] = 0x1E7B;
  18266. t['umatragurmukhi'] = 0x0A41;
  18267. t['umonospace'] = 0xFF55;
  18268. t['underscore'] = 0x005F;
  18269. t['underscoredbl'] = 0x2017;
  18270. t['underscoremonospace'] = 0xFF3F;
  18271. t['underscorevertical'] = 0xFE33;
  18272. t['underscorewavy'] = 0xFE4F;
  18273. t['union'] = 0x222A;
  18274. t['universal'] = 0x2200;
  18275. t['uogonek'] = 0x0173;
  18276. t['uparen'] = 0x24B0;
  18277. t['upblock'] = 0x2580;
  18278. t['upperdothebrew'] = 0x05C4;
  18279. t['upsilon'] = 0x03C5;
  18280. t['upsilondieresis'] = 0x03CB;
  18281. t['upsilondieresistonos'] = 0x03B0;
  18282. t['upsilonlatin'] = 0x028A;
  18283. t['upsilontonos'] = 0x03CD;
  18284. t['uptackbelowcmb'] = 0x031D;
  18285. t['uptackmod'] = 0x02D4;
  18286. t['uragurmukhi'] = 0x0A73;
  18287. t['uring'] = 0x016F;
  18288. t['ushortcyrillic'] = 0x045E;
  18289. t['usmallhiragana'] = 0x3045;
  18290. t['usmallkatakana'] = 0x30A5;
  18291. t['usmallkatakanahalfwidth'] = 0xFF69;
  18292. t['ustraightcyrillic'] = 0x04AF;
  18293. t['ustraightstrokecyrillic'] = 0x04B1;
  18294. t['utilde'] = 0x0169;
  18295. t['utildeacute'] = 0x1E79;
  18296. t['utildebelow'] = 0x1E75;
  18297. t['uubengali'] = 0x098A;
  18298. t['uudeva'] = 0x090A;
  18299. t['uugujarati'] = 0x0A8A;
  18300. t['uugurmukhi'] = 0x0A0A;
  18301. t['uumatragurmukhi'] = 0x0A42;
  18302. t['uuvowelsignbengali'] = 0x09C2;
  18303. t['uuvowelsigndeva'] = 0x0942;
  18304. t['uuvowelsigngujarati'] = 0x0AC2;
  18305. t['uvowelsignbengali'] = 0x09C1;
  18306. t['uvowelsigndeva'] = 0x0941;
  18307. t['uvowelsigngujarati'] = 0x0AC1;
  18308. t['v'] = 0x0076;
  18309. t['vadeva'] = 0x0935;
  18310. t['vagujarati'] = 0x0AB5;
  18311. t['vagurmukhi'] = 0x0A35;
  18312. t['vakatakana'] = 0x30F7;
  18313. t['vav'] = 0x05D5;
  18314. t['vavdagesh'] = 0xFB35;
  18315. t['vavdagesh65'] = 0xFB35;
  18316. t['vavdageshhebrew'] = 0xFB35;
  18317. t['vavhebrew'] = 0x05D5;
  18318. t['vavholam'] = 0xFB4B;
  18319. t['vavholamhebrew'] = 0xFB4B;
  18320. t['vavvavhebrew'] = 0x05F0;
  18321. t['vavyodhebrew'] = 0x05F1;
  18322. t['vcircle'] = 0x24E5;
  18323. t['vdotbelow'] = 0x1E7F;
  18324. t['vecyrillic'] = 0x0432;
  18325. t['veharabic'] = 0x06A4;
  18326. t['vehfinalarabic'] = 0xFB6B;
  18327. t['vehinitialarabic'] = 0xFB6C;
  18328. t['vehmedialarabic'] = 0xFB6D;
  18329. t['vekatakana'] = 0x30F9;
  18330. t['venus'] = 0x2640;
  18331. t['verticalbar'] = 0x007C;
  18332. t['verticallineabovecmb'] = 0x030D;
  18333. t['verticallinebelowcmb'] = 0x0329;
  18334. t['verticallinelowmod'] = 0x02CC;
  18335. t['verticallinemod'] = 0x02C8;
  18336. t['vewarmenian'] = 0x057E;
  18337. t['vhook'] = 0x028B;
  18338. t['vikatakana'] = 0x30F8;
  18339. t['viramabengali'] = 0x09CD;
  18340. t['viramadeva'] = 0x094D;
  18341. t['viramagujarati'] = 0x0ACD;
  18342. t['visargabengali'] = 0x0983;
  18343. t['visargadeva'] = 0x0903;
  18344. t['visargagujarati'] = 0x0A83;
  18345. t['vmonospace'] = 0xFF56;
  18346. t['voarmenian'] = 0x0578;
  18347. t['voicediterationhiragana'] = 0x309E;
  18348. t['voicediterationkatakana'] = 0x30FE;
  18349. t['voicedmarkkana'] = 0x309B;
  18350. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  18351. t['vokatakana'] = 0x30FA;
  18352. t['vparen'] = 0x24B1;
  18353. t['vtilde'] = 0x1E7D;
  18354. t['vturned'] = 0x028C;
  18355. t['vuhiragana'] = 0x3094;
  18356. t['vukatakana'] = 0x30F4;
  18357. t['w'] = 0x0077;
  18358. t['wacute'] = 0x1E83;
  18359. t['waekorean'] = 0x3159;
  18360. t['wahiragana'] = 0x308F;
  18361. t['wakatakana'] = 0x30EF;
  18362. t['wakatakanahalfwidth'] = 0xFF9C;
  18363. t['wakorean'] = 0x3158;
  18364. t['wasmallhiragana'] = 0x308E;
  18365. t['wasmallkatakana'] = 0x30EE;
  18366. t['wattosquare'] = 0x3357;
  18367. t['wavedash'] = 0x301C;
  18368. t['wavyunderscorevertical'] = 0xFE34;
  18369. t['wawarabic'] = 0x0648;
  18370. t['wawfinalarabic'] = 0xFEEE;
  18371. t['wawhamzaabovearabic'] = 0x0624;
  18372. t['wawhamzaabovefinalarabic'] = 0xFE86;
  18373. t['wbsquare'] = 0x33DD;
  18374. t['wcircle'] = 0x24E6;
  18375. t['wcircumflex'] = 0x0175;
  18376. t['wdieresis'] = 0x1E85;
  18377. t['wdotaccent'] = 0x1E87;
  18378. t['wdotbelow'] = 0x1E89;
  18379. t['wehiragana'] = 0x3091;
  18380. t['weierstrass'] = 0x2118;
  18381. t['wekatakana'] = 0x30F1;
  18382. t['wekorean'] = 0x315E;
  18383. t['weokorean'] = 0x315D;
  18384. t['wgrave'] = 0x1E81;
  18385. t['whitebullet'] = 0x25E6;
  18386. t['whitecircle'] = 0x25CB;
  18387. t['whitecircleinverse'] = 0x25D9;
  18388. t['whitecornerbracketleft'] = 0x300E;
  18389. t['whitecornerbracketleftvertical'] = 0xFE43;
  18390. t['whitecornerbracketright'] = 0x300F;
  18391. t['whitecornerbracketrightvertical'] = 0xFE44;
  18392. t['whitediamond'] = 0x25C7;
  18393. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  18394. t['whitedownpointingsmalltriangle'] = 0x25BF;
  18395. t['whitedownpointingtriangle'] = 0x25BD;
  18396. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  18397. t['whiteleftpointingtriangle'] = 0x25C1;
  18398. t['whitelenticularbracketleft'] = 0x3016;
  18399. t['whitelenticularbracketright'] = 0x3017;
  18400. t['whiterightpointingsmalltriangle'] = 0x25B9;
  18401. t['whiterightpointingtriangle'] = 0x25B7;
  18402. t['whitesmallsquare'] = 0x25AB;
  18403. t['whitesmilingface'] = 0x263A;
  18404. t['whitesquare'] = 0x25A1;
  18405. t['whitestar'] = 0x2606;
  18406. t['whitetelephone'] = 0x260F;
  18407. t['whitetortoiseshellbracketleft'] = 0x3018;
  18408. t['whitetortoiseshellbracketright'] = 0x3019;
  18409. t['whiteuppointingsmalltriangle'] = 0x25B5;
  18410. t['whiteuppointingtriangle'] = 0x25B3;
  18411. t['wihiragana'] = 0x3090;
  18412. t['wikatakana'] = 0x30F0;
  18413. t['wikorean'] = 0x315F;
  18414. t['wmonospace'] = 0xFF57;
  18415. t['wohiragana'] = 0x3092;
  18416. t['wokatakana'] = 0x30F2;
  18417. t['wokatakanahalfwidth'] = 0xFF66;
  18418. t['won'] = 0x20A9;
  18419. t['wonmonospace'] = 0xFFE6;
  18420. t['wowaenthai'] = 0x0E27;
  18421. t['wparen'] = 0x24B2;
  18422. t['wring'] = 0x1E98;
  18423. t['wsuperior'] = 0x02B7;
  18424. t['wturned'] = 0x028D;
  18425. t['wynn'] = 0x01BF;
  18426. t['x'] = 0x0078;
  18427. t['xabovecmb'] = 0x033D;
  18428. t['xbopomofo'] = 0x3112;
  18429. t['xcircle'] = 0x24E7;
  18430. t['xdieresis'] = 0x1E8D;
  18431. t['xdotaccent'] = 0x1E8B;
  18432. t['xeharmenian'] = 0x056D;
  18433. t['xi'] = 0x03BE;
  18434. t['xmonospace'] = 0xFF58;
  18435. t['xparen'] = 0x24B3;
  18436. t['xsuperior'] = 0x02E3;
  18437. t['y'] = 0x0079;
  18438. t['yaadosquare'] = 0x334E;
  18439. t['yabengali'] = 0x09AF;
  18440. t['yacute'] = 0x00FD;
  18441. t['yadeva'] = 0x092F;
  18442. t['yaekorean'] = 0x3152;
  18443. t['yagujarati'] = 0x0AAF;
  18444. t['yagurmukhi'] = 0x0A2F;
  18445. t['yahiragana'] = 0x3084;
  18446. t['yakatakana'] = 0x30E4;
  18447. t['yakatakanahalfwidth'] = 0xFF94;
  18448. t['yakorean'] = 0x3151;
  18449. t['yamakkanthai'] = 0x0E4E;
  18450. t['yasmallhiragana'] = 0x3083;
  18451. t['yasmallkatakana'] = 0x30E3;
  18452. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  18453. t['yatcyrillic'] = 0x0463;
  18454. t['ycircle'] = 0x24E8;
  18455. t['ycircumflex'] = 0x0177;
  18456. t['ydieresis'] = 0x00FF;
  18457. t['ydotaccent'] = 0x1E8F;
  18458. t['ydotbelow'] = 0x1EF5;
  18459. t['yeharabic'] = 0x064A;
  18460. t['yehbarreearabic'] = 0x06D2;
  18461. t['yehbarreefinalarabic'] = 0xFBAF;
  18462. t['yehfinalarabic'] = 0xFEF2;
  18463. t['yehhamzaabovearabic'] = 0x0626;
  18464. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  18465. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  18466. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  18467. t['yehinitialarabic'] = 0xFEF3;
  18468. t['yehmedialarabic'] = 0xFEF4;
  18469. t['yehmeeminitialarabic'] = 0xFCDD;
  18470. t['yehmeemisolatedarabic'] = 0xFC58;
  18471. t['yehnoonfinalarabic'] = 0xFC94;
  18472. t['yehthreedotsbelowarabic'] = 0x06D1;
  18473. t['yekorean'] = 0x3156;
  18474. t['yen'] = 0x00A5;
  18475. t['yenmonospace'] = 0xFFE5;
  18476. t['yeokorean'] = 0x3155;
  18477. t['yeorinhieuhkorean'] = 0x3186;
  18478. t['yerahbenyomohebrew'] = 0x05AA;
  18479. t['yerahbenyomolefthebrew'] = 0x05AA;
  18480. t['yericyrillic'] = 0x044B;
  18481. t['yerudieresiscyrillic'] = 0x04F9;
  18482. t['yesieungkorean'] = 0x3181;
  18483. t['yesieungpansioskorean'] = 0x3183;
  18484. t['yesieungsioskorean'] = 0x3182;
  18485. t['yetivhebrew'] = 0x059A;
  18486. t['ygrave'] = 0x1EF3;
  18487. t['yhook'] = 0x01B4;
  18488. t['yhookabove'] = 0x1EF7;
  18489. t['yiarmenian'] = 0x0575;
  18490. t['yicyrillic'] = 0x0457;
  18491. t['yikorean'] = 0x3162;
  18492. t['yinyang'] = 0x262F;
  18493. t['yiwnarmenian'] = 0x0582;
  18494. t['ymonospace'] = 0xFF59;
  18495. t['yod'] = 0x05D9;
  18496. t['yoddagesh'] = 0xFB39;
  18497. t['yoddageshhebrew'] = 0xFB39;
  18498. t['yodhebrew'] = 0x05D9;
  18499. t['yodyodhebrew'] = 0x05F2;
  18500. t['yodyodpatahhebrew'] = 0xFB1F;
  18501. t['yohiragana'] = 0x3088;
  18502. t['yoikorean'] = 0x3189;
  18503. t['yokatakana'] = 0x30E8;
  18504. t['yokatakanahalfwidth'] = 0xFF96;
  18505. t['yokorean'] = 0x315B;
  18506. t['yosmallhiragana'] = 0x3087;
  18507. t['yosmallkatakana'] = 0x30E7;
  18508. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  18509. t['yotgreek'] = 0x03F3;
  18510. t['yoyaekorean'] = 0x3188;
  18511. t['yoyakorean'] = 0x3187;
  18512. t['yoyakthai'] = 0x0E22;
  18513. t['yoyingthai'] = 0x0E0D;
  18514. t['yparen'] = 0x24B4;
  18515. t['ypogegrammeni'] = 0x037A;
  18516. t['ypogegrammenigreekcmb'] = 0x0345;
  18517. t['yr'] = 0x01A6;
  18518. t['yring'] = 0x1E99;
  18519. t['ysuperior'] = 0x02B8;
  18520. t['ytilde'] = 0x1EF9;
  18521. t['yturned'] = 0x028E;
  18522. t['yuhiragana'] = 0x3086;
  18523. t['yuikorean'] = 0x318C;
  18524. t['yukatakana'] = 0x30E6;
  18525. t['yukatakanahalfwidth'] = 0xFF95;
  18526. t['yukorean'] = 0x3160;
  18527. t['yusbigcyrillic'] = 0x046B;
  18528. t['yusbigiotifiedcyrillic'] = 0x046D;
  18529. t['yuslittlecyrillic'] = 0x0467;
  18530. t['yuslittleiotifiedcyrillic'] = 0x0469;
  18531. t['yusmallhiragana'] = 0x3085;
  18532. t['yusmallkatakana'] = 0x30E5;
  18533. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  18534. t['yuyekorean'] = 0x318B;
  18535. t['yuyeokorean'] = 0x318A;
  18536. t['yyabengali'] = 0x09DF;
  18537. t['yyadeva'] = 0x095F;
  18538. t['z'] = 0x007A;
  18539. t['zaarmenian'] = 0x0566;
  18540. t['zacute'] = 0x017A;
  18541. t['zadeva'] = 0x095B;
  18542. t['zagurmukhi'] = 0x0A5B;
  18543. t['zaharabic'] = 0x0638;
  18544. t['zahfinalarabic'] = 0xFEC6;
  18545. t['zahinitialarabic'] = 0xFEC7;
  18546. t['zahiragana'] = 0x3056;
  18547. t['zahmedialarabic'] = 0xFEC8;
  18548. t['zainarabic'] = 0x0632;
  18549. t['zainfinalarabic'] = 0xFEB0;
  18550. t['zakatakana'] = 0x30B6;
  18551. t['zaqefgadolhebrew'] = 0x0595;
  18552. t['zaqefqatanhebrew'] = 0x0594;
  18553. t['zarqahebrew'] = 0x0598;
  18554. t['zayin'] = 0x05D6;
  18555. t['zayindagesh'] = 0xFB36;
  18556. t['zayindageshhebrew'] = 0xFB36;
  18557. t['zayinhebrew'] = 0x05D6;
  18558. t['zbopomofo'] = 0x3117;
  18559. t['zcaron'] = 0x017E;
  18560. t['zcircle'] = 0x24E9;
  18561. t['zcircumflex'] = 0x1E91;
  18562. t['zcurl'] = 0x0291;
  18563. t['zdot'] = 0x017C;
  18564. t['zdotaccent'] = 0x017C;
  18565. t['zdotbelow'] = 0x1E93;
  18566. t['zecyrillic'] = 0x0437;
  18567. t['zedescendercyrillic'] = 0x0499;
  18568. t['zedieresiscyrillic'] = 0x04DF;
  18569. t['zehiragana'] = 0x305C;
  18570. t['zekatakana'] = 0x30BC;
  18571. t['zero'] = 0x0030;
  18572. t['zeroarabic'] = 0x0660;
  18573. t['zerobengali'] = 0x09E6;
  18574. t['zerodeva'] = 0x0966;
  18575. t['zerogujarati'] = 0x0AE6;
  18576. t['zerogurmukhi'] = 0x0A66;
  18577. t['zerohackarabic'] = 0x0660;
  18578. t['zeroinferior'] = 0x2080;
  18579. t['zeromonospace'] = 0xFF10;
  18580. t['zerooldstyle'] = 0xF730;
  18581. t['zeropersian'] = 0x06F0;
  18582. t['zerosuperior'] = 0x2070;
  18583. t['zerothai'] = 0x0E50;
  18584. t['zerowidthjoiner'] = 0xFEFF;
  18585. t['zerowidthnonjoiner'] = 0x200C;
  18586. t['zerowidthspace'] = 0x200B;
  18587. t['zeta'] = 0x03B6;
  18588. t['zhbopomofo'] = 0x3113;
  18589. t['zhearmenian'] = 0x056A;
  18590. t['zhebrevecyrillic'] = 0x04C2;
  18591. t['zhecyrillic'] = 0x0436;
  18592. t['zhedescendercyrillic'] = 0x0497;
  18593. t['zhedieresiscyrillic'] = 0x04DD;
  18594. t['zihiragana'] = 0x3058;
  18595. t['zikatakana'] = 0x30B8;
  18596. t['zinorhebrew'] = 0x05AE;
  18597. t['zlinebelow'] = 0x1E95;
  18598. t['zmonospace'] = 0xFF5A;
  18599. t['zohiragana'] = 0x305E;
  18600. t['zokatakana'] = 0x30BE;
  18601. t['zparen'] = 0x24B5;
  18602. t['zretroflexhook'] = 0x0290;
  18603. t['zstroke'] = 0x01B6;
  18604. t['zuhiragana'] = 0x305A;
  18605. t['zukatakana'] = 0x30BA;
  18606. t['.notdef'] = 0x0000;
  18607. t['angbracketleftbig'] = 0x2329;
  18608. t['angbracketleftBig'] = 0x2329;
  18609. t['angbracketleftbigg'] = 0x2329;
  18610. t['angbracketleftBigg'] = 0x2329;
  18611. t['angbracketrightBig'] = 0x232A;
  18612. t['angbracketrightbig'] = 0x232A;
  18613. t['angbracketrightBigg'] = 0x232A;
  18614. t['angbracketrightbigg'] = 0x232A;
  18615. t['arrowhookleft'] = 0x21AA;
  18616. t['arrowhookright'] = 0x21A9;
  18617. t['arrowlefttophalf'] = 0x21BC;
  18618. t['arrowleftbothalf'] = 0x21BD;
  18619. t['arrownortheast'] = 0x2197;
  18620. t['arrownorthwest'] = 0x2196;
  18621. t['arrowrighttophalf'] = 0x21C0;
  18622. t['arrowrightbothalf'] = 0x21C1;
  18623. t['arrowsoutheast'] = 0x2198;
  18624. t['arrowsouthwest'] = 0x2199;
  18625. t['backslashbig'] = 0x2216;
  18626. t['backslashBig'] = 0x2216;
  18627. t['backslashBigg'] = 0x2216;
  18628. t['backslashbigg'] = 0x2216;
  18629. t['bardbl'] = 0x2016;
  18630. t['bracehtipdownleft'] = 0xFE37;
  18631. t['bracehtipdownright'] = 0xFE37;
  18632. t['bracehtipupleft'] = 0xFE38;
  18633. t['bracehtipupright'] = 0xFE38;
  18634. t['braceleftBig'] = 0x007B;
  18635. t['braceleftbig'] = 0x007B;
  18636. t['braceleftbigg'] = 0x007B;
  18637. t['braceleftBigg'] = 0x007B;
  18638. t['bracerightBig'] = 0x007D;
  18639. t['bracerightbig'] = 0x007D;
  18640. t['bracerightbigg'] = 0x007D;
  18641. t['bracerightBigg'] = 0x007D;
  18642. t['bracketleftbig'] = 0x005B;
  18643. t['bracketleftBig'] = 0x005B;
  18644. t['bracketleftbigg'] = 0x005B;
  18645. t['bracketleftBigg'] = 0x005B;
  18646. t['bracketrightBig'] = 0x005D;
  18647. t['bracketrightbig'] = 0x005D;
  18648. t['bracketrightbigg'] = 0x005D;
  18649. t['bracketrightBigg'] = 0x005D;
  18650. t['ceilingleftbig'] = 0x2308;
  18651. t['ceilingleftBig'] = 0x2308;
  18652. t['ceilingleftBigg'] = 0x2308;
  18653. t['ceilingleftbigg'] = 0x2308;
  18654. t['ceilingrightbig'] = 0x2309;
  18655. t['ceilingrightBig'] = 0x2309;
  18656. t['ceilingrightbigg'] = 0x2309;
  18657. t['ceilingrightBigg'] = 0x2309;
  18658. t['circledotdisplay'] = 0x2299;
  18659. t['circledottext'] = 0x2299;
  18660. t['circlemultiplydisplay'] = 0x2297;
  18661. t['circlemultiplytext'] = 0x2297;
  18662. t['circleplusdisplay'] = 0x2295;
  18663. t['circleplustext'] = 0x2295;
  18664. t['contintegraldisplay'] = 0x222E;
  18665. t['contintegraltext'] = 0x222E;
  18666. t['coproductdisplay'] = 0x2210;
  18667. t['coproducttext'] = 0x2210;
  18668. t['floorleftBig'] = 0x230A;
  18669. t['floorleftbig'] = 0x230A;
  18670. t['floorleftbigg'] = 0x230A;
  18671. t['floorleftBigg'] = 0x230A;
  18672. t['floorrightbig'] = 0x230B;
  18673. t['floorrightBig'] = 0x230B;
  18674. t['floorrightBigg'] = 0x230B;
  18675. t['floorrightbigg'] = 0x230B;
  18676. t['hatwide'] = 0x0302;
  18677. t['hatwider'] = 0x0302;
  18678. t['hatwidest'] = 0x0302;
  18679. t['intercal'] = 0x1D40;
  18680. t['integraldisplay'] = 0x222B;
  18681. t['integraltext'] = 0x222B;
  18682. t['intersectiondisplay'] = 0x22C2;
  18683. t['intersectiontext'] = 0x22C2;
  18684. t['logicalanddisplay'] = 0x2227;
  18685. t['logicalandtext'] = 0x2227;
  18686. t['logicalordisplay'] = 0x2228;
  18687. t['logicalortext'] = 0x2228;
  18688. t['parenleftBig'] = 0x0028;
  18689. t['parenleftbig'] = 0x0028;
  18690. t['parenleftBigg'] = 0x0028;
  18691. t['parenleftbigg'] = 0x0028;
  18692. t['parenrightBig'] = 0x0029;
  18693. t['parenrightbig'] = 0x0029;
  18694. t['parenrightBigg'] = 0x0029;
  18695. t['parenrightbigg'] = 0x0029;
  18696. t['prime'] = 0x2032;
  18697. t['productdisplay'] = 0x220F;
  18698. t['producttext'] = 0x220F;
  18699. t['radicalbig'] = 0x221A;
  18700. t['radicalBig'] = 0x221A;
  18701. t['radicalBigg'] = 0x221A;
  18702. t['radicalbigg'] = 0x221A;
  18703. t['radicalbt'] = 0x221A;
  18704. t['radicaltp'] = 0x221A;
  18705. t['radicalvertex'] = 0x221A;
  18706. t['slashbig'] = 0x002F;
  18707. t['slashBig'] = 0x002F;
  18708. t['slashBigg'] = 0x002F;
  18709. t['slashbigg'] = 0x002F;
  18710. t['summationdisplay'] = 0x2211;
  18711. t['summationtext'] = 0x2211;
  18712. t['tildewide'] = 0x02DC;
  18713. t['tildewider'] = 0x02DC;
  18714. t['tildewidest'] = 0x02DC;
  18715. t['uniondisplay'] = 0x22C3;
  18716. t['unionmultidisplay'] = 0x228E;
  18717. t['unionmultitext'] = 0x228E;
  18718. t['unionsqdisplay'] = 0x2294;
  18719. t['unionsqtext'] = 0x2294;
  18720. t['uniontext'] = 0x22C3;
  18721. t['vextenddouble'] = 0x2225;
  18722. t['vextendsingle'] = 0x2223;
  18723. });
  18724. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  18725. t['space'] = 0x0020;
  18726. t['a1'] = 0x2701;
  18727. t['a2'] = 0x2702;
  18728. t['a202'] = 0x2703;
  18729. t['a3'] = 0x2704;
  18730. t['a4'] = 0x260E;
  18731. t['a5'] = 0x2706;
  18732. t['a119'] = 0x2707;
  18733. t['a118'] = 0x2708;
  18734. t['a117'] = 0x2709;
  18735. t['a11'] = 0x261B;
  18736. t['a12'] = 0x261E;
  18737. t['a13'] = 0x270C;
  18738. t['a14'] = 0x270D;
  18739. t['a15'] = 0x270E;
  18740. t['a16'] = 0x270F;
  18741. t['a105'] = 0x2710;
  18742. t['a17'] = 0x2711;
  18743. t['a18'] = 0x2712;
  18744. t['a19'] = 0x2713;
  18745. t['a20'] = 0x2714;
  18746. t['a21'] = 0x2715;
  18747. t['a22'] = 0x2716;
  18748. t['a23'] = 0x2717;
  18749. t['a24'] = 0x2718;
  18750. t['a25'] = 0x2719;
  18751. t['a26'] = 0x271A;
  18752. t['a27'] = 0x271B;
  18753. t['a28'] = 0x271C;
  18754. t['a6'] = 0x271D;
  18755. t['a7'] = 0x271E;
  18756. t['a8'] = 0x271F;
  18757. t['a9'] = 0x2720;
  18758. t['a10'] = 0x2721;
  18759. t['a29'] = 0x2722;
  18760. t['a30'] = 0x2723;
  18761. t['a31'] = 0x2724;
  18762. t['a32'] = 0x2725;
  18763. t['a33'] = 0x2726;
  18764. t['a34'] = 0x2727;
  18765. t['a35'] = 0x2605;
  18766. t['a36'] = 0x2729;
  18767. t['a37'] = 0x272A;
  18768. t['a38'] = 0x272B;
  18769. t['a39'] = 0x272C;
  18770. t['a40'] = 0x272D;
  18771. t['a41'] = 0x272E;
  18772. t['a42'] = 0x272F;
  18773. t['a43'] = 0x2730;
  18774. t['a44'] = 0x2731;
  18775. t['a45'] = 0x2732;
  18776. t['a46'] = 0x2733;
  18777. t['a47'] = 0x2734;
  18778. t['a48'] = 0x2735;
  18779. t['a49'] = 0x2736;
  18780. t['a50'] = 0x2737;
  18781. t['a51'] = 0x2738;
  18782. t['a52'] = 0x2739;
  18783. t['a53'] = 0x273A;
  18784. t['a54'] = 0x273B;
  18785. t['a55'] = 0x273C;
  18786. t['a56'] = 0x273D;
  18787. t['a57'] = 0x273E;
  18788. t['a58'] = 0x273F;
  18789. t['a59'] = 0x2740;
  18790. t['a60'] = 0x2741;
  18791. t['a61'] = 0x2742;
  18792. t['a62'] = 0x2743;
  18793. t['a63'] = 0x2744;
  18794. t['a64'] = 0x2745;
  18795. t['a65'] = 0x2746;
  18796. t['a66'] = 0x2747;
  18797. t['a67'] = 0x2748;
  18798. t['a68'] = 0x2749;
  18799. t['a69'] = 0x274A;
  18800. t['a70'] = 0x274B;
  18801. t['a71'] = 0x25CF;
  18802. t['a72'] = 0x274D;
  18803. t['a73'] = 0x25A0;
  18804. t['a74'] = 0x274F;
  18805. t['a203'] = 0x2750;
  18806. t['a75'] = 0x2751;
  18807. t['a204'] = 0x2752;
  18808. t['a76'] = 0x25B2;
  18809. t['a77'] = 0x25BC;
  18810. t['a78'] = 0x25C6;
  18811. t['a79'] = 0x2756;
  18812. t['a81'] = 0x25D7;
  18813. t['a82'] = 0x2758;
  18814. t['a83'] = 0x2759;
  18815. t['a84'] = 0x275A;
  18816. t['a97'] = 0x275B;
  18817. t['a98'] = 0x275C;
  18818. t['a99'] = 0x275D;
  18819. t['a100'] = 0x275E;
  18820. t['a101'] = 0x2761;
  18821. t['a102'] = 0x2762;
  18822. t['a103'] = 0x2763;
  18823. t['a104'] = 0x2764;
  18824. t['a106'] = 0x2765;
  18825. t['a107'] = 0x2766;
  18826. t['a108'] = 0x2767;
  18827. t['a112'] = 0x2663;
  18828. t['a111'] = 0x2666;
  18829. t['a110'] = 0x2665;
  18830. t['a109'] = 0x2660;
  18831. t['a120'] = 0x2460;
  18832. t['a121'] = 0x2461;
  18833. t['a122'] = 0x2462;
  18834. t['a123'] = 0x2463;
  18835. t['a124'] = 0x2464;
  18836. t['a125'] = 0x2465;
  18837. t['a126'] = 0x2466;
  18838. t['a127'] = 0x2467;
  18839. t['a128'] = 0x2468;
  18840. t['a129'] = 0x2469;
  18841. t['a130'] = 0x2776;
  18842. t['a131'] = 0x2777;
  18843. t['a132'] = 0x2778;
  18844. t['a133'] = 0x2779;
  18845. t['a134'] = 0x277A;
  18846. t['a135'] = 0x277B;
  18847. t['a136'] = 0x277C;
  18848. t['a137'] = 0x277D;
  18849. t['a138'] = 0x277E;
  18850. t['a139'] = 0x277F;
  18851. t['a140'] = 0x2780;
  18852. t['a141'] = 0x2781;
  18853. t['a142'] = 0x2782;
  18854. t['a143'] = 0x2783;
  18855. t['a144'] = 0x2784;
  18856. t['a145'] = 0x2785;
  18857. t['a146'] = 0x2786;
  18858. t['a147'] = 0x2787;
  18859. t['a148'] = 0x2788;
  18860. t['a149'] = 0x2789;
  18861. t['a150'] = 0x278A;
  18862. t['a151'] = 0x278B;
  18863. t['a152'] = 0x278C;
  18864. t['a153'] = 0x278D;
  18865. t['a154'] = 0x278E;
  18866. t['a155'] = 0x278F;
  18867. t['a156'] = 0x2790;
  18868. t['a157'] = 0x2791;
  18869. t['a158'] = 0x2792;
  18870. t['a159'] = 0x2793;
  18871. t['a160'] = 0x2794;
  18872. t['a161'] = 0x2192;
  18873. t['a163'] = 0x2194;
  18874. t['a164'] = 0x2195;
  18875. t['a196'] = 0x2798;
  18876. t['a165'] = 0x2799;
  18877. t['a192'] = 0x279A;
  18878. t['a166'] = 0x279B;
  18879. t['a167'] = 0x279C;
  18880. t['a168'] = 0x279D;
  18881. t['a169'] = 0x279E;
  18882. t['a170'] = 0x279F;
  18883. t['a171'] = 0x27A0;
  18884. t['a172'] = 0x27A1;
  18885. t['a173'] = 0x27A2;
  18886. t['a162'] = 0x27A3;
  18887. t['a174'] = 0x27A4;
  18888. t['a175'] = 0x27A5;
  18889. t['a176'] = 0x27A6;
  18890. t['a177'] = 0x27A7;
  18891. t['a178'] = 0x27A8;
  18892. t['a179'] = 0x27A9;
  18893. t['a193'] = 0x27AA;
  18894. t['a180'] = 0x27AB;
  18895. t['a199'] = 0x27AC;
  18896. t['a181'] = 0x27AD;
  18897. t['a200'] = 0x27AE;
  18898. t['a182'] = 0x27AF;
  18899. t['a201'] = 0x27B1;
  18900. t['a183'] = 0x27B2;
  18901. t['a184'] = 0x27B3;
  18902. t['a197'] = 0x27B4;
  18903. t['a185'] = 0x27B5;
  18904. t['a194'] = 0x27B6;
  18905. t['a198'] = 0x27B7;
  18906. t['a186'] = 0x27B8;
  18907. t['a195'] = 0x27B9;
  18908. t['a187'] = 0x27BA;
  18909. t['a188'] = 0x27BB;
  18910. t['a189'] = 0x27BC;
  18911. t['a190'] = 0x27BD;
  18912. t['a191'] = 0x27BE;
  18913. t['a89'] = 0x2768;
  18914. t['a90'] = 0x2769;
  18915. t['a93'] = 0x276A;
  18916. t['a94'] = 0x276B;
  18917. t['a91'] = 0x276C;
  18918. t['a92'] = 0x276D;
  18919. t['a205'] = 0x276E;
  18920. t['a85'] = 0x276F;
  18921. t['a206'] = 0x2770;
  18922. t['a86'] = 0x2771;
  18923. t['a87'] = 0x2772;
  18924. t['a88'] = 0x2773;
  18925. t['a95'] = 0x2774;
  18926. t['a96'] = 0x2775;
  18927. t['.notdef'] = 0x0000;
  18928. });
  18929. exports.getGlyphsUnicode = getGlyphsUnicode;
  18930. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  18931. /***/ }),
  18932. /* 9 */
  18933. /***/ (function(module, exports, __w_pdfjs_require__) {
  18934. "use strict";
  18935. var sharedUtil = __w_pdfjs_require__(0);
  18936. var displayDOMUtils = __w_pdfjs_require__(3);
  18937. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  18938. var AnnotationType = sharedUtil.AnnotationType;
  18939. var stringToPDFString = sharedUtil.stringToPDFString;
  18940. var Util = sharedUtil.Util;
  18941. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  18942. var LinkTarget = displayDOMUtils.LinkTarget;
  18943. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  18944. var warn = sharedUtil.warn;
  18945. var CustomStyle = displayDOMUtils.CustomStyle;
  18946. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18947. function AnnotationElementFactory() {
  18948. }
  18949. AnnotationElementFactory.prototype = {
  18950. create: function AnnotationElementFactory_create(parameters) {
  18951. var subtype = parameters.data.annotationType;
  18952. switch (subtype) {
  18953. case AnnotationType.LINK:
  18954. return new LinkAnnotationElement(parameters);
  18955. case AnnotationType.TEXT:
  18956. return new TextAnnotationElement(parameters);
  18957. case AnnotationType.WIDGET:
  18958. var fieldType = parameters.data.fieldType;
  18959. switch (fieldType) {
  18960. case 'Tx':
  18961. return new TextWidgetAnnotationElement(parameters);
  18962. case 'Btn':
  18963. if (parameters.data.radioButton) {
  18964. return new RadioButtonWidgetAnnotationElement(parameters);
  18965. } else if (parameters.data.checkBox) {
  18966. return new CheckboxWidgetAnnotationElement(parameters);
  18967. }
  18968. warn('Unimplemented button widget annotation: pushbutton');
  18969. break;
  18970. case 'Ch':
  18971. return new ChoiceWidgetAnnotationElement(parameters);
  18972. }
  18973. return new WidgetAnnotationElement(parameters);
  18974. case AnnotationType.POPUP:
  18975. return new PopupAnnotationElement(parameters);
  18976. case AnnotationType.HIGHLIGHT:
  18977. return new HighlightAnnotationElement(parameters);
  18978. case AnnotationType.UNDERLINE:
  18979. return new UnderlineAnnotationElement(parameters);
  18980. case AnnotationType.SQUIGGLY:
  18981. return new SquigglyAnnotationElement(parameters);
  18982. case AnnotationType.STRIKEOUT:
  18983. return new StrikeOutAnnotationElement(parameters);
  18984. case AnnotationType.FILEATTACHMENT:
  18985. return new FileAttachmentAnnotationElement(parameters);
  18986. default:
  18987. return new AnnotationElement(parameters);
  18988. }
  18989. }
  18990. };
  18991. var AnnotationElement = function AnnotationElementClosure() {
  18992. function AnnotationElement(parameters, isRenderable) {
  18993. this.isRenderable = isRenderable || false;
  18994. this.data = parameters.data;
  18995. this.layer = parameters.layer;
  18996. this.page = parameters.page;
  18997. this.viewport = parameters.viewport;
  18998. this.linkService = parameters.linkService;
  18999. this.downloadManager = parameters.downloadManager;
  19000. this.imageResourcesPath = parameters.imageResourcesPath;
  19001. this.renderInteractiveForms = parameters.renderInteractiveForms;
  19002. if (isRenderable) {
  19003. this.container = this._createContainer();
  19004. }
  19005. }
  19006. AnnotationElement.prototype = {
  19007. _createContainer: function AnnotationElement_createContainer() {
  19008. var data = this.data, page = this.page, viewport = this.viewport;
  19009. var container = document.createElement('section');
  19010. var width = data.rect[2] - data.rect[0];
  19011. var height = data.rect[3] - data.rect[1];
  19012. container.setAttribute('data-annotation-id', data.id);
  19013. var rect = Util.normalizeRect([
  19014. data.rect[0],
  19015. page.view[3] - data.rect[1] + page.view[1],
  19016. data.rect[2],
  19017. page.view[3] - data.rect[3] + page.view[1]
  19018. ]);
  19019. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  19020. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  19021. if (data.borderStyle.width > 0) {
  19022. container.style.borderWidth = data.borderStyle.width + 'px';
  19023. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  19024. width = width - 2 * data.borderStyle.width;
  19025. height = height - 2 * data.borderStyle.width;
  19026. }
  19027. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  19028. var verticalRadius = data.borderStyle.verticalCornerRadius;
  19029. if (horizontalRadius > 0 || verticalRadius > 0) {
  19030. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  19031. CustomStyle.setProp('borderRadius', container, radius);
  19032. }
  19033. switch (data.borderStyle.style) {
  19034. case AnnotationBorderStyleType.SOLID:
  19035. container.style.borderStyle = 'solid';
  19036. break;
  19037. case AnnotationBorderStyleType.DASHED:
  19038. container.style.borderStyle = 'dashed';
  19039. break;
  19040. case AnnotationBorderStyleType.BEVELED:
  19041. warn('Unimplemented border style: beveled');
  19042. break;
  19043. case AnnotationBorderStyleType.INSET:
  19044. warn('Unimplemented border style: inset');
  19045. break;
  19046. case AnnotationBorderStyleType.UNDERLINE:
  19047. container.style.borderBottomStyle = 'solid';
  19048. break;
  19049. default:
  19050. break;
  19051. }
  19052. if (data.color) {
  19053. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  19054. } else {
  19055. container.style.borderWidth = 0;
  19056. }
  19057. }
  19058. container.style.left = rect[0] + 'px';
  19059. container.style.top = rect[1] + 'px';
  19060. container.style.width = width + 'px';
  19061. container.style.height = height + 'px';
  19062. return container;
  19063. },
  19064. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  19065. if (!trigger) {
  19066. trigger = document.createElement('div');
  19067. trigger.style.height = container.style.height;
  19068. trigger.style.width = container.style.width;
  19069. container.appendChild(trigger);
  19070. }
  19071. var popupElement = new PopupElement({
  19072. container: container,
  19073. trigger: trigger,
  19074. color: data.color,
  19075. title: data.title,
  19076. contents: data.contents,
  19077. hideWrapper: true
  19078. });
  19079. var popup = popupElement.render();
  19080. popup.style.left = container.style.width;
  19081. container.appendChild(popup);
  19082. },
  19083. render: function AnnotationElement_render() {
  19084. throw new Error('Abstract method AnnotationElement.render called');
  19085. }
  19086. };
  19087. return AnnotationElement;
  19088. }();
  19089. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  19090. function LinkAnnotationElement(parameters) {
  19091. AnnotationElement.call(this, parameters, true);
  19092. }
  19093. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  19094. render: function LinkAnnotationElement_render() {
  19095. this.container.className = 'linkAnnotation';
  19096. var link = document.createElement('a');
  19097. addLinkAttributes(link, {
  19098. url: this.data.url,
  19099. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  19100. });
  19101. if (!this.data.url) {
  19102. if (this.data.action) {
  19103. this._bindNamedAction(link, this.data.action);
  19104. } else {
  19105. this._bindLink(link, this.data.dest);
  19106. }
  19107. }
  19108. this.container.appendChild(link);
  19109. return this.container;
  19110. },
  19111. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  19112. var self = this;
  19113. link.href = this.linkService.getDestinationHash(destination);
  19114. link.onclick = function () {
  19115. if (destination) {
  19116. self.linkService.navigateTo(destination);
  19117. }
  19118. return false;
  19119. };
  19120. if (destination) {
  19121. link.className = 'internalLink';
  19122. }
  19123. },
  19124. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  19125. var self = this;
  19126. link.href = this.linkService.getAnchorUrl('');
  19127. link.onclick = function () {
  19128. self.linkService.executeNamedAction(action);
  19129. return false;
  19130. };
  19131. link.className = 'internalLink';
  19132. }
  19133. });
  19134. return LinkAnnotationElement;
  19135. }();
  19136. var TextAnnotationElement = function TextAnnotationElementClosure() {
  19137. function TextAnnotationElement(parameters) {
  19138. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19139. AnnotationElement.call(this, parameters, isRenderable);
  19140. }
  19141. Util.inherit(TextAnnotationElement, AnnotationElement, {
  19142. render: function TextAnnotationElement_render() {
  19143. this.container.className = 'textAnnotation';
  19144. var image = document.createElement('img');
  19145. image.style.height = this.container.style.height;
  19146. image.style.width = this.container.style.width;
  19147. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  19148. image.alt = '[{{type}} Annotation]';
  19149. image.dataset.l10nId = 'text_annotation_type';
  19150. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  19151. if (!this.data.hasPopup) {
  19152. this._createPopup(this.container, image, this.data);
  19153. }
  19154. this.container.appendChild(image);
  19155. return this.container;
  19156. }
  19157. });
  19158. return TextAnnotationElement;
  19159. }();
  19160. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  19161. function WidgetAnnotationElement(parameters, isRenderable) {
  19162. AnnotationElement.call(this, parameters, isRenderable);
  19163. }
  19164. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  19165. render: function WidgetAnnotationElement_render() {
  19166. return this.container;
  19167. }
  19168. });
  19169. return WidgetAnnotationElement;
  19170. }();
  19171. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  19172. var TEXT_ALIGNMENT = [
  19173. 'left',
  19174. 'center',
  19175. 'right'
  19176. ];
  19177. function TextWidgetAnnotationElement(parameters) {
  19178. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  19179. WidgetAnnotationElement.call(this, parameters, isRenderable);
  19180. }
  19181. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  19182. render: function TextWidgetAnnotationElement_render() {
  19183. this.container.className = 'textWidgetAnnotation';
  19184. var element = null;
  19185. if (this.renderInteractiveForms) {
  19186. if (this.data.multiLine) {
  19187. element = document.createElement('textarea');
  19188. element.textContent = this.data.fieldValue;
  19189. } else {
  19190. element = document.createElement('input');
  19191. element.type = 'text';
  19192. element.setAttribute('value', this.data.fieldValue);
  19193. }
  19194. element.disabled = this.data.readOnly;
  19195. if (this.data.maxLen !== null) {
  19196. element.maxLength = this.data.maxLen;
  19197. }
  19198. if (this.data.comb) {
  19199. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  19200. var combWidth = fieldWidth / this.data.maxLen;
  19201. element.classList.add('comb');
  19202. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  19203. }
  19204. } else {
  19205. element = document.createElement('div');
  19206. element.textContent = this.data.fieldValue;
  19207. element.style.verticalAlign = 'middle';
  19208. element.style.display = 'table-cell';
  19209. var font = null;
  19210. if (this.data.fontRefName) {
  19211. font = this.page.commonObjs.getData(this.data.fontRefName);
  19212. }
  19213. this._setTextStyle(element, font);
  19214. }
  19215. if (this.data.textAlignment !== null) {
  19216. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  19217. }
  19218. this.container.appendChild(element);
  19219. return this.container;
  19220. },
  19221. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  19222. var style = element.style;
  19223. style.fontSize = this.data.fontSize + 'px';
  19224. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  19225. if (!font) {
  19226. return;
  19227. }
  19228. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  19229. style.fontStyle = font.italic ? 'italic' : 'normal';
  19230. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  19231. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  19232. style.fontFamily = fontFamily + fallbackName;
  19233. }
  19234. });
  19235. return TextWidgetAnnotationElement;
  19236. }();
  19237. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  19238. function CheckboxWidgetAnnotationElement(parameters) {
  19239. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19240. }
  19241. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  19242. render: function CheckboxWidgetAnnotationElement_render() {
  19243. this.container.className = 'buttonWidgetAnnotation checkBox';
  19244. var element = document.createElement('input');
  19245. element.disabled = this.data.readOnly;
  19246. element.type = 'checkbox';
  19247. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  19248. element.setAttribute('checked', true);
  19249. }
  19250. this.container.appendChild(element);
  19251. return this.container;
  19252. }
  19253. });
  19254. return CheckboxWidgetAnnotationElement;
  19255. }();
  19256. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  19257. function RadioButtonWidgetAnnotationElement(parameters) {
  19258. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19259. }
  19260. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  19261. render: function RadioButtonWidgetAnnotationElement_render() {
  19262. this.container.className = 'buttonWidgetAnnotation radioButton';
  19263. var element = document.createElement('input');
  19264. element.disabled = this.data.readOnly;
  19265. element.type = 'radio';
  19266. element.name = this.data.fieldName;
  19267. if (this.data.fieldValue === this.data.buttonValue) {
  19268. element.setAttribute('checked', true);
  19269. }
  19270. this.container.appendChild(element);
  19271. return this.container;
  19272. }
  19273. });
  19274. return RadioButtonWidgetAnnotationElement;
  19275. }();
  19276. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  19277. function ChoiceWidgetAnnotationElement(parameters) {
  19278. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19279. }
  19280. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  19281. render: function ChoiceWidgetAnnotationElement_render() {
  19282. this.container.className = 'choiceWidgetAnnotation';
  19283. var selectElement = document.createElement('select');
  19284. selectElement.disabled = this.data.readOnly;
  19285. if (!this.data.combo) {
  19286. selectElement.size = this.data.options.length;
  19287. if (this.data.multiSelect) {
  19288. selectElement.multiple = true;
  19289. }
  19290. }
  19291. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  19292. var option = this.data.options[i];
  19293. var optionElement = document.createElement('option');
  19294. optionElement.textContent = option.displayValue;
  19295. optionElement.value = option.exportValue;
  19296. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  19297. optionElement.setAttribute('selected', true);
  19298. }
  19299. selectElement.appendChild(optionElement);
  19300. }
  19301. this.container.appendChild(selectElement);
  19302. return this.container;
  19303. }
  19304. });
  19305. return ChoiceWidgetAnnotationElement;
  19306. }();
  19307. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  19308. function PopupAnnotationElement(parameters) {
  19309. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  19310. AnnotationElement.call(this, parameters, isRenderable);
  19311. }
  19312. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  19313. render: function PopupAnnotationElement_render() {
  19314. this.container.className = 'popupAnnotation';
  19315. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  19316. var parentElement = this.layer.querySelector(selector);
  19317. if (!parentElement) {
  19318. return this.container;
  19319. }
  19320. var popup = new PopupElement({
  19321. container: this.container,
  19322. trigger: parentElement,
  19323. color: this.data.color,
  19324. title: this.data.title,
  19325. contents: this.data.contents
  19326. });
  19327. var parentLeft = parseFloat(parentElement.style.left);
  19328. var parentWidth = parseFloat(parentElement.style.width);
  19329. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  19330. this.container.style.left = parentLeft + parentWidth + 'px';
  19331. this.container.appendChild(popup.render());
  19332. return this.container;
  19333. }
  19334. });
  19335. return PopupAnnotationElement;
  19336. }();
  19337. var PopupElement = function PopupElementClosure() {
  19338. var BACKGROUND_ENLIGHT = 0.7;
  19339. function PopupElement(parameters) {
  19340. this.container = parameters.container;
  19341. this.trigger = parameters.trigger;
  19342. this.color = parameters.color;
  19343. this.title = parameters.title;
  19344. this.contents = parameters.contents;
  19345. this.hideWrapper = parameters.hideWrapper || false;
  19346. this.pinned = false;
  19347. }
  19348. PopupElement.prototype = {
  19349. render: function PopupElement_render() {
  19350. var wrapper = document.createElement('div');
  19351. wrapper.className = 'popupWrapper';
  19352. this.hideElement = this.hideWrapper ? wrapper : this.container;
  19353. this.hideElement.setAttribute('hidden', true);
  19354. var popup = document.createElement('div');
  19355. popup.className = 'popup';
  19356. var color = this.color;
  19357. if (color) {
  19358. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  19359. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  19360. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  19361. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  19362. }
  19363. var contents = this._formatContents(this.contents);
  19364. var title = document.createElement('h1');
  19365. title.textContent = this.title;
  19366. this.trigger.addEventListener('click', this._toggle.bind(this));
  19367. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  19368. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  19369. popup.addEventListener('click', this._hide.bind(this, true));
  19370. popup.appendChild(title);
  19371. popup.appendChild(contents);
  19372. wrapper.appendChild(popup);
  19373. return wrapper;
  19374. },
  19375. _formatContents: function PopupElement_formatContents(contents) {
  19376. var p = document.createElement('p');
  19377. var lines = contents.split(/(?:\r\n?|\n)/);
  19378. for (var i = 0, ii = lines.length; i < ii; ++i) {
  19379. var line = lines[i];
  19380. p.appendChild(document.createTextNode(line));
  19381. if (i < ii - 1) {
  19382. p.appendChild(document.createElement('br'));
  19383. }
  19384. }
  19385. return p;
  19386. },
  19387. _toggle: function PopupElement_toggle() {
  19388. if (this.pinned) {
  19389. this._hide(true);
  19390. } else {
  19391. this._show(true);
  19392. }
  19393. },
  19394. _show: function PopupElement_show(pin) {
  19395. if (pin) {
  19396. this.pinned = true;
  19397. }
  19398. if (this.hideElement.hasAttribute('hidden')) {
  19399. this.hideElement.removeAttribute('hidden');
  19400. this.container.style.zIndex += 1;
  19401. }
  19402. },
  19403. _hide: function PopupElement_hide(unpin) {
  19404. if (unpin) {
  19405. this.pinned = false;
  19406. }
  19407. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  19408. this.hideElement.setAttribute('hidden', true);
  19409. this.container.style.zIndex -= 1;
  19410. }
  19411. }
  19412. };
  19413. return PopupElement;
  19414. }();
  19415. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  19416. function HighlightAnnotationElement(parameters) {
  19417. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19418. AnnotationElement.call(this, parameters, isRenderable);
  19419. }
  19420. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  19421. render: function HighlightAnnotationElement_render() {
  19422. this.container.className = 'highlightAnnotation';
  19423. if (!this.data.hasPopup) {
  19424. this._createPopup(this.container, null, this.data);
  19425. }
  19426. return this.container;
  19427. }
  19428. });
  19429. return HighlightAnnotationElement;
  19430. }();
  19431. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  19432. function UnderlineAnnotationElement(parameters) {
  19433. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19434. AnnotationElement.call(this, parameters, isRenderable);
  19435. }
  19436. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  19437. render: function UnderlineAnnotationElement_render() {
  19438. this.container.className = 'underlineAnnotation';
  19439. if (!this.data.hasPopup) {
  19440. this._createPopup(this.container, null, this.data);
  19441. }
  19442. return this.container;
  19443. }
  19444. });
  19445. return UnderlineAnnotationElement;
  19446. }();
  19447. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  19448. function SquigglyAnnotationElement(parameters) {
  19449. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19450. AnnotationElement.call(this, parameters, isRenderable);
  19451. }
  19452. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  19453. render: function SquigglyAnnotationElement_render() {
  19454. this.container.className = 'squigglyAnnotation';
  19455. if (!this.data.hasPopup) {
  19456. this._createPopup(this.container, null, this.data);
  19457. }
  19458. return this.container;
  19459. }
  19460. });
  19461. return SquigglyAnnotationElement;
  19462. }();
  19463. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  19464. function StrikeOutAnnotationElement(parameters) {
  19465. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19466. AnnotationElement.call(this, parameters, isRenderable);
  19467. }
  19468. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  19469. render: function StrikeOutAnnotationElement_render() {
  19470. this.container.className = 'strikeoutAnnotation';
  19471. if (!this.data.hasPopup) {
  19472. this._createPopup(this.container, null, this.data);
  19473. }
  19474. return this.container;
  19475. }
  19476. });
  19477. return StrikeOutAnnotationElement;
  19478. }();
  19479. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  19480. function FileAttachmentAnnotationElement(parameters) {
  19481. AnnotationElement.call(this, parameters, true);
  19482. var file = this.data.file;
  19483. this.filename = getFilenameFromUrl(file.filename);
  19484. this.content = file.content;
  19485. this.linkService.onFileAttachmentAnnotation({
  19486. id: stringToPDFString(file.filename),
  19487. filename: file.filename,
  19488. content: file.content
  19489. });
  19490. }
  19491. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  19492. render: function FileAttachmentAnnotationElement_render() {
  19493. this.container.className = 'fileAttachmentAnnotation';
  19494. var trigger = document.createElement('div');
  19495. trigger.style.height = this.container.style.height;
  19496. trigger.style.width = this.container.style.width;
  19497. trigger.addEventListener('dblclick', this._download.bind(this));
  19498. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  19499. this._createPopup(this.container, trigger, this.data);
  19500. }
  19501. this.container.appendChild(trigger);
  19502. return this.container;
  19503. },
  19504. _download: function FileAttachmentAnnotationElement_download() {
  19505. if (!this.downloadManager) {
  19506. warn('Download cannot be started due to unavailable download manager');
  19507. return;
  19508. }
  19509. this.downloadManager.downloadData(this.content, this.filename, '');
  19510. }
  19511. });
  19512. return FileAttachmentAnnotationElement;
  19513. }();
  19514. var AnnotationLayer = function AnnotationLayerClosure() {
  19515. return {
  19516. render: function AnnotationLayer_render(parameters) {
  19517. var annotationElementFactory = new AnnotationElementFactory();
  19518. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  19519. var data = parameters.annotations[i];
  19520. if (!data) {
  19521. continue;
  19522. }
  19523. var element = annotationElementFactory.create({
  19524. data: data,
  19525. layer: parameters.div,
  19526. page: parameters.page,
  19527. viewport: parameters.viewport,
  19528. linkService: parameters.linkService,
  19529. downloadManager: parameters.downloadManager,
  19530. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  19531. renderInteractiveForms: parameters.renderInteractiveForms || false
  19532. });
  19533. if (element.isRenderable) {
  19534. parameters.div.appendChild(element.render());
  19535. }
  19536. }
  19537. },
  19538. update: function AnnotationLayer_update(parameters) {
  19539. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  19540. var data = parameters.annotations[i];
  19541. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  19542. if (element) {
  19543. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  19544. }
  19545. }
  19546. parameters.div.removeAttribute('hidden');
  19547. }
  19548. };
  19549. }();
  19550. exports.AnnotationLayer = AnnotationLayer;
  19551. /***/ }),
  19552. /* 10 */
  19553. /***/ (function(module, exports, __w_pdfjs_require__) {
  19554. "use strict";
  19555. var sharedUtil = __w_pdfjs_require__(0);
  19556. var displayFontLoader = __w_pdfjs_require__(45);
  19557. var displayCanvas = __w_pdfjs_require__(44);
  19558. var displayMetadata = __w_pdfjs_require__(23);
  19559. var displayDOMUtils = __w_pdfjs_require__(3);
  19560. var amdRequire;
  19561. var InvalidPDFException = sharedUtil.InvalidPDFException;
  19562. var MessageHandler = sharedUtil.MessageHandler;
  19563. var MissingPDFException = sharedUtil.MissingPDFException;
  19564. var PageViewport = sharedUtil.PageViewport;
  19565. var PasswordException = sharedUtil.PasswordException;
  19566. var StatTimer = sharedUtil.StatTimer;
  19567. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  19568. var UnknownErrorException = sharedUtil.UnknownErrorException;
  19569. var Util = sharedUtil.Util;
  19570. var createPromiseCapability = sharedUtil.createPromiseCapability;
  19571. var error = sharedUtil.error;
  19572. var deprecated = sharedUtil.deprecated;
  19573. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  19574. var info = sharedUtil.info;
  19575. var isInt = sharedUtil.isInt;
  19576. var isArray = sharedUtil.isArray;
  19577. var isArrayBuffer = sharedUtil.isArrayBuffer;
  19578. var isSameOrigin = sharedUtil.isSameOrigin;
  19579. var loadJpegStream = sharedUtil.loadJpegStream;
  19580. var stringToBytes = sharedUtil.stringToBytes;
  19581. var globalScope = sharedUtil.globalScope;
  19582. var warn = sharedUtil.warn;
  19583. var FontFaceObject = displayFontLoader.FontFaceObject;
  19584. var FontLoader = displayFontLoader.FontLoader;
  19585. var CanvasGraphics = displayCanvas.CanvasGraphics;
  19586. var Metadata = displayMetadata.Metadata;
  19587. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  19588. var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
  19589. var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory;
  19590. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  19591. var isWorkerDisabled = false;
  19592. var workerSrc;
  19593. var isPostMessageTransfersDisabled = false;
  19594. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  19595. var fakeWorkerFilesLoader = null;
  19596. var useRequireEnsure = false;
  19597. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  19598. var task = new PDFDocumentLoadingTask();
  19599. if (arguments.length > 1) {
  19600. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  19601. }
  19602. if (pdfDataRangeTransport) {
  19603. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  19604. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  19605. pdfDataRangeTransport.length = src.length;
  19606. pdfDataRangeTransport.initialData = src.initialData;
  19607. if (!pdfDataRangeTransport.abort) {
  19608. pdfDataRangeTransport.abort = function () {
  19609. };
  19610. }
  19611. }
  19612. src = Object.create(src);
  19613. src.range = pdfDataRangeTransport;
  19614. }
  19615. task.onPassword = passwordCallback || null;
  19616. task.onProgress = progressCallback || null;
  19617. var source;
  19618. if (typeof src === 'string') {
  19619. source = { url: src };
  19620. } else if (isArrayBuffer(src)) {
  19621. source = { data: src };
  19622. } else if (src instanceof PDFDataRangeTransport) {
  19623. source = { range: src };
  19624. } else {
  19625. if (typeof src !== 'object') {
  19626. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  19627. }
  19628. if (!src.url && !src.data && !src.range) {
  19629. error('Invalid parameter object: need either .data, .range or .url');
  19630. }
  19631. source = src;
  19632. }
  19633. var params = {};
  19634. var rangeTransport = null;
  19635. var worker = null;
  19636. for (var key in source) {
  19637. if (key === 'url' && typeof window !== 'undefined') {
  19638. params[key] = new URL(source[key], window.location).href;
  19639. continue;
  19640. } else if (key === 'range') {
  19641. rangeTransport = source[key];
  19642. continue;
  19643. } else if (key === 'worker') {
  19644. worker = source[key];
  19645. continue;
  19646. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  19647. var pdfBytes = source[key];
  19648. if (typeof pdfBytes === 'string') {
  19649. params[key] = stringToBytes(pdfBytes);
  19650. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  19651. params[key] = new Uint8Array(pdfBytes);
  19652. } else if (isArrayBuffer(pdfBytes)) {
  19653. params[key] = new Uint8Array(pdfBytes);
  19654. } else {
  19655. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  19656. }
  19657. continue;
  19658. }
  19659. params[key] = source[key];
  19660. }
  19661. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  19662. params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
  19663. var CMapReaderFactory = params.CMapReaderFactory || DOMCMapReaderFactory;
  19664. if (!worker) {
  19665. worker = new PDFWorker();
  19666. task._worker = worker;
  19667. }
  19668. var docId = task.docId;
  19669. worker.promise.then(function () {
  19670. if (task.destroyed) {
  19671. throw new Error('Loading aborted');
  19672. }
  19673. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  19674. if (task.destroyed) {
  19675. throw new Error('Loading aborted');
  19676. }
  19677. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  19678. var transport = new WorkerTransport(messageHandler, task, rangeTransport, CMapReaderFactory);
  19679. task._transport = transport;
  19680. messageHandler.send('Ready', null);
  19681. });
  19682. }).catch(task._capability.reject);
  19683. return task;
  19684. }
  19685. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  19686. if (worker.destroyed) {
  19687. return Promise.reject(new Error('Worker was destroyed'));
  19688. }
  19689. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  19690. source.disableStream = getDefaultSetting('disableStream');
  19691. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  19692. if (pdfDataRangeTransport) {
  19693. source.length = pdfDataRangeTransport.length;
  19694. source.initialData = pdfDataRangeTransport.initialData;
  19695. }
  19696. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  19697. docId: docId,
  19698. source: source,
  19699. disableRange: getDefaultSetting('disableRange'),
  19700. maxImageSize: getDefaultSetting('maxImageSize'),
  19701. disableFontFace: getDefaultSetting('disableFontFace'),
  19702. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  19703. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  19704. docBaseUrl: source.docBaseUrl,
  19705. disableNativeImageDecoder: source.disableNativeImageDecoder
  19706. }).then(function (workerId) {
  19707. if (worker.destroyed) {
  19708. throw new Error('Worker was destroyed');
  19709. }
  19710. return workerId;
  19711. });
  19712. }
  19713. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  19714. var nextDocumentId = 0;
  19715. function PDFDocumentLoadingTask() {
  19716. this._capability = createPromiseCapability();
  19717. this._transport = null;
  19718. this._worker = null;
  19719. this.docId = 'd' + nextDocumentId++;
  19720. this.destroyed = false;
  19721. this.onPassword = null;
  19722. this.onProgress = null;
  19723. this.onUnsupportedFeature = null;
  19724. }
  19725. PDFDocumentLoadingTask.prototype = {
  19726. get promise() {
  19727. return this._capability.promise;
  19728. },
  19729. destroy: function () {
  19730. this.destroyed = true;
  19731. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  19732. return transportDestroyed.then(function () {
  19733. this._transport = null;
  19734. if (this._worker) {
  19735. this._worker.destroy();
  19736. this._worker = null;
  19737. }
  19738. }.bind(this));
  19739. },
  19740. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  19741. return this.promise.then.apply(this.promise, arguments);
  19742. }
  19743. };
  19744. return PDFDocumentLoadingTask;
  19745. }();
  19746. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  19747. function PDFDataRangeTransport(length, initialData) {
  19748. this.length = length;
  19749. this.initialData = initialData;
  19750. this._rangeListeners = [];
  19751. this._progressListeners = [];
  19752. this._progressiveReadListeners = [];
  19753. this._readyCapability = createPromiseCapability();
  19754. }
  19755. PDFDataRangeTransport.prototype = {
  19756. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  19757. this._rangeListeners.push(listener);
  19758. },
  19759. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  19760. this._progressListeners.push(listener);
  19761. },
  19762. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  19763. this._progressiveReadListeners.push(listener);
  19764. },
  19765. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  19766. var listeners = this._rangeListeners;
  19767. for (var i = 0, n = listeners.length; i < n; ++i) {
  19768. listeners[i](begin, chunk);
  19769. }
  19770. },
  19771. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  19772. this._readyCapability.promise.then(function () {
  19773. var listeners = this._progressListeners;
  19774. for (var i = 0, n = listeners.length; i < n; ++i) {
  19775. listeners[i](loaded);
  19776. }
  19777. }.bind(this));
  19778. },
  19779. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  19780. this._readyCapability.promise.then(function () {
  19781. var listeners = this._progressiveReadListeners;
  19782. for (var i = 0, n = listeners.length; i < n; ++i) {
  19783. listeners[i](chunk);
  19784. }
  19785. }.bind(this));
  19786. },
  19787. transportReady: function PDFDataRangeTransport_transportReady() {
  19788. this._readyCapability.resolve();
  19789. },
  19790. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  19791. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  19792. },
  19793. abort: function PDFDataRangeTransport_abort() {
  19794. }
  19795. };
  19796. return PDFDataRangeTransport;
  19797. }();
  19798. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  19799. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  19800. this.pdfInfo = pdfInfo;
  19801. this.transport = transport;
  19802. this.loadingTask = loadingTask;
  19803. }
  19804. PDFDocumentProxy.prototype = {
  19805. get numPages() {
  19806. return this.pdfInfo.numPages;
  19807. },
  19808. get fingerprint() {
  19809. return this.pdfInfo.fingerprint;
  19810. },
  19811. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  19812. return this.transport.getPage(pageNumber);
  19813. },
  19814. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  19815. return this.transport.getPageIndex(ref);
  19816. },
  19817. getDestinations: function PDFDocumentProxy_getDestinations() {
  19818. return this.transport.getDestinations();
  19819. },
  19820. getDestination: function PDFDocumentProxy_getDestination(id) {
  19821. return this.transport.getDestination(id);
  19822. },
  19823. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  19824. return this.transport.getPageLabels();
  19825. },
  19826. getAttachments: function PDFDocumentProxy_getAttachments() {
  19827. return this.transport.getAttachments();
  19828. },
  19829. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  19830. return this.transport.getJavaScript();
  19831. },
  19832. getOutline: function PDFDocumentProxy_getOutline() {
  19833. return this.transport.getOutline();
  19834. },
  19835. getMetadata: function PDFDocumentProxy_getMetadata() {
  19836. return this.transport.getMetadata();
  19837. },
  19838. getData: function PDFDocumentProxy_getData() {
  19839. return this.transport.getData();
  19840. },
  19841. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  19842. return this.transport.downloadInfoCapability.promise;
  19843. },
  19844. getStats: function PDFDocumentProxy_getStats() {
  19845. return this.transport.getStats();
  19846. },
  19847. cleanup: function PDFDocumentProxy_cleanup() {
  19848. this.transport.startCleanup();
  19849. },
  19850. destroy: function PDFDocumentProxy_destroy() {
  19851. return this.loadingTask.destroy();
  19852. }
  19853. };
  19854. return PDFDocumentProxy;
  19855. }();
  19856. var PDFPageProxy = function PDFPageProxyClosure() {
  19857. function PDFPageProxy(pageIndex, pageInfo, transport) {
  19858. this.pageIndex = pageIndex;
  19859. this.pageInfo = pageInfo;
  19860. this.transport = transport;
  19861. this.stats = new StatTimer();
  19862. this.stats.enabled = getDefaultSetting('enableStats');
  19863. this.commonObjs = transport.commonObjs;
  19864. this.objs = new PDFObjects();
  19865. this.cleanupAfterRender = false;
  19866. this.pendingCleanup = false;
  19867. this.intentStates = Object.create(null);
  19868. this.destroyed = false;
  19869. }
  19870. PDFPageProxy.prototype = {
  19871. get pageNumber() {
  19872. return this.pageIndex + 1;
  19873. },
  19874. get rotate() {
  19875. return this.pageInfo.rotate;
  19876. },
  19877. get ref() {
  19878. return this.pageInfo.ref;
  19879. },
  19880. get userUnit() {
  19881. return this.pageInfo.userUnit;
  19882. },
  19883. get view() {
  19884. return this.pageInfo.view;
  19885. },
  19886. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  19887. if (arguments.length < 2) {
  19888. rotate = this.rotate;
  19889. }
  19890. return new PageViewport(this.view, scale, rotate, 0, 0);
  19891. },
  19892. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  19893. var intent = params && params.intent || null;
  19894. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  19895. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  19896. this.annotationsIntent = intent;
  19897. }
  19898. return this.annotationsPromise;
  19899. },
  19900. render: function PDFPageProxy_render(params) {
  19901. var stats = this.stats;
  19902. stats.time('Overall');
  19903. this.pendingCleanup = false;
  19904. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  19905. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  19906. var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
  19907. if (!this.intentStates[renderingIntent]) {
  19908. this.intentStates[renderingIntent] = Object.create(null);
  19909. }
  19910. var intentState = this.intentStates[renderingIntent];
  19911. if (!intentState.displayReadyCapability) {
  19912. intentState.receivingOperatorList = true;
  19913. intentState.displayReadyCapability = createPromiseCapability();
  19914. intentState.operatorList = {
  19915. fnArray: [],
  19916. argsArray: [],
  19917. lastChunk: false
  19918. };
  19919. this.stats.time('Page Request');
  19920. this.transport.messageHandler.send('RenderPageRequest', {
  19921. pageIndex: this.pageNumber - 1,
  19922. intent: renderingIntent,
  19923. renderInteractiveForms: renderInteractiveForms
  19924. });
  19925. }
  19926. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  19927. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  19928. if (!intentState.renderTasks) {
  19929. intentState.renderTasks = [];
  19930. }
  19931. intentState.renderTasks.push(internalRenderTask);
  19932. var renderTask = internalRenderTask.task;
  19933. if (params.continueCallback) {
  19934. deprecated('render is used with continueCallback parameter');
  19935. renderTask.onContinue = params.continueCallback;
  19936. }
  19937. var self = this;
  19938. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  19939. if (self.pendingCleanup) {
  19940. complete();
  19941. return;
  19942. }
  19943. stats.time('Rendering');
  19944. internalRenderTask.initializeGraphics(transparency);
  19945. internalRenderTask.operatorListChanged();
  19946. }, function pageDisplayReadPromiseError(reason) {
  19947. complete(reason);
  19948. });
  19949. function complete(error) {
  19950. var i = intentState.renderTasks.indexOf(internalRenderTask);
  19951. if (i >= 0) {
  19952. intentState.renderTasks.splice(i, 1);
  19953. }
  19954. if (self.cleanupAfterRender) {
  19955. self.pendingCleanup = true;
  19956. }
  19957. self._tryCleanup();
  19958. if (error) {
  19959. internalRenderTask.capability.reject(error);
  19960. } else {
  19961. internalRenderTask.capability.resolve();
  19962. }
  19963. stats.timeEnd('Rendering');
  19964. stats.timeEnd('Overall');
  19965. }
  19966. return renderTask;
  19967. },
  19968. getOperatorList: function PDFPageProxy_getOperatorList() {
  19969. function operatorListChanged() {
  19970. if (intentState.operatorList.lastChunk) {
  19971. intentState.opListReadCapability.resolve(intentState.operatorList);
  19972. var i = intentState.renderTasks.indexOf(opListTask);
  19973. if (i >= 0) {
  19974. intentState.renderTasks.splice(i, 1);
  19975. }
  19976. }
  19977. }
  19978. var renderingIntent = 'oplist';
  19979. if (!this.intentStates[renderingIntent]) {
  19980. this.intentStates[renderingIntent] = Object.create(null);
  19981. }
  19982. var intentState = this.intentStates[renderingIntent];
  19983. var opListTask;
  19984. if (!intentState.opListReadCapability) {
  19985. opListTask = {};
  19986. opListTask.operatorListChanged = operatorListChanged;
  19987. intentState.receivingOperatorList = true;
  19988. intentState.opListReadCapability = createPromiseCapability();
  19989. intentState.renderTasks = [];
  19990. intentState.renderTasks.push(opListTask);
  19991. intentState.operatorList = {
  19992. fnArray: [],
  19993. argsArray: [],
  19994. lastChunk: false
  19995. };
  19996. this.transport.messageHandler.send('RenderPageRequest', {
  19997. pageIndex: this.pageIndex,
  19998. intent: renderingIntent
  19999. });
  20000. }
  20001. return intentState.opListReadCapability.promise;
  20002. },
  20003. getTextContent: function PDFPageProxy_getTextContent(params) {
  20004. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  20005. pageIndex: this.pageNumber - 1,
  20006. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  20007. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  20008. });
  20009. },
  20010. _destroy: function PDFPageProxy_destroy() {
  20011. this.destroyed = true;
  20012. this.transport.pageCache[this.pageIndex] = null;
  20013. var waitOn = [];
  20014. Object.keys(this.intentStates).forEach(function (intent) {
  20015. if (intent === 'oplist') {
  20016. return;
  20017. }
  20018. var intentState = this.intentStates[intent];
  20019. intentState.renderTasks.forEach(function (renderTask) {
  20020. var renderCompleted = renderTask.capability.promise.catch(function () {
  20021. });
  20022. waitOn.push(renderCompleted);
  20023. renderTask.cancel();
  20024. });
  20025. }, this);
  20026. this.objs.clear();
  20027. this.annotationsPromise = null;
  20028. this.pendingCleanup = false;
  20029. return Promise.all(waitOn);
  20030. },
  20031. destroy: function () {
  20032. deprecated('page destroy method, use cleanup() instead');
  20033. this.cleanup();
  20034. },
  20035. cleanup: function PDFPageProxy_cleanup() {
  20036. this.pendingCleanup = true;
  20037. this._tryCleanup();
  20038. },
  20039. _tryCleanup: function PDFPageProxy_tryCleanup() {
  20040. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  20041. var intentState = this.intentStates[intent];
  20042. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  20043. }, this)) {
  20044. return;
  20045. }
  20046. Object.keys(this.intentStates).forEach(function (intent) {
  20047. delete this.intentStates[intent];
  20048. }, this);
  20049. this.objs.clear();
  20050. this.annotationsPromise = null;
  20051. this.pendingCleanup = false;
  20052. },
  20053. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  20054. var intentState = this.intentStates[intent];
  20055. if (intentState.displayReadyCapability) {
  20056. intentState.displayReadyCapability.resolve(transparency);
  20057. }
  20058. },
  20059. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  20060. var intentState = this.intentStates[intent];
  20061. var i, ii;
  20062. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  20063. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  20064. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  20065. }
  20066. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  20067. for (i = 0; i < intentState.renderTasks.length; i++) {
  20068. intentState.renderTasks[i].operatorListChanged();
  20069. }
  20070. if (operatorListChunk.lastChunk) {
  20071. intentState.receivingOperatorList = false;
  20072. this._tryCleanup();
  20073. }
  20074. }
  20075. };
  20076. return PDFPageProxy;
  20077. }();
  20078. var PDFWorker = function PDFWorkerClosure() {
  20079. var nextFakeWorkerId = 0;
  20080. function getWorkerSrc() {
  20081. if (typeof workerSrc !== 'undefined') {
  20082. return workerSrc;
  20083. }
  20084. if (getDefaultSetting('workerSrc')) {
  20085. return getDefaultSetting('workerSrc');
  20086. }
  20087. if (pdfjsFilePath) {
  20088. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  20089. }
  20090. error('No PDFJS.workerSrc specified');
  20091. }
  20092. var fakeWorkerFilesLoadedCapability;
  20093. function setupFakeWorkerGlobal() {
  20094. var WorkerMessageHandler;
  20095. if (fakeWorkerFilesLoadedCapability) {
  20096. return fakeWorkerFilesLoadedCapability.promise;
  20097. }
  20098. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  20099. var pdfjsCoreWorker = __w_pdfjs_require__(22);
  20100. __w_pdfjs_require__(39);
  20101. WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
  20102. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  20103. return fakeWorkerFilesLoadedCapability.promise;
  20104. }
  20105. function FakeWorkerPort(defer) {
  20106. this._listeners = [];
  20107. this._defer = defer;
  20108. this._deferred = Promise.resolve(undefined);
  20109. }
  20110. FakeWorkerPort.prototype = {
  20111. postMessage: function (obj, transfers) {
  20112. function cloneValue(value) {
  20113. if (typeof value !== 'object' || value === null) {
  20114. return value;
  20115. }
  20116. if (cloned.has(value)) {
  20117. return cloned.get(value);
  20118. }
  20119. var result;
  20120. var buffer;
  20121. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  20122. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  20123. if (value === buffer) {
  20124. result = value;
  20125. } else if (transferable) {
  20126. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  20127. } else {
  20128. result = new value.constructor(value);
  20129. }
  20130. cloned.set(value, result);
  20131. return result;
  20132. }
  20133. result = isArray(value) ? [] : {};
  20134. cloned.set(value, result);
  20135. for (var i in value) {
  20136. var desc, p = value;
  20137. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  20138. p = Object.getPrototypeOf(p);
  20139. }
  20140. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  20141. continue;
  20142. }
  20143. result[i] = cloneValue(desc.value);
  20144. }
  20145. return result;
  20146. }
  20147. if (!this._defer) {
  20148. this._listeners.forEach(function (listener) {
  20149. listener.call(this, { data: obj });
  20150. }, this);
  20151. return;
  20152. }
  20153. var cloned = new WeakMap();
  20154. var e = { data: cloneValue(obj) };
  20155. this._deferred.then(function () {
  20156. this._listeners.forEach(function (listener) {
  20157. listener.call(this, e);
  20158. }, this);
  20159. }.bind(this));
  20160. },
  20161. addEventListener: function (name, listener) {
  20162. this._listeners.push(listener);
  20163. },
  20164. removeEventListener: function (name, listener) {
  20165. var i = this._listeners.indexOf(listener);
  20166. this._listeners.splice(i, 1);
  20167. },
  20168. terminate: function () {
  20169. this._listeners = [];
  20170. }
  20171. };
  20172. function createCDNWrapper(url) {
  20173. var wrapper = 'importScripts(\'' + url + '\');';
  20174. return URL.createObjectURL(new Blob([wrapper]));
  20175. }
  20176. function PDFWorker(name) {
  20177. this.name = name;
  20178. this.destroyed = false;
  20179. this._readyCapability = createPromiseCapability();
  20180. this._port = null;
  20181. this._webWorker = null;
  20182. this._messageHandler = null;
  20183. this._initialize();
  20184. }
  20185. PDFWorker.prototype = {
  20186. get promise() {
  20187. return this._readyCapability.promise;
  20188. },
  20189. get port() {
  20190. return this._port;
  20191. },
  20192. get messageHandler() {
  20193. return this._messageHandler;
  20194. },
  20195. _initialize: function PDFWorker_initialize() {
  20196. this._setupFakeWorker();
  20197. },
  20198. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  20199. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  20200. warn('Setting up fake worker.');
  20201. isWorkerDisabled = true;
  20202. }
  20203. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  20204. if (this.destroyed) {
  20205. this._readyCapability.reject(new Error('Worker was destroyed'));
  20206. return;
  20207. }
  20208. var isTypedArraysPresent = Uint8Array !== Float32Array;
  20209. var port = new FakeWorkerPort(isTypedArraysPresent);
  20210. this._port = port;
  20211. var id = 'fake' + nextFakeWorkerId++;
  20212. var workerHandler = new MessageHandler(id + '_worker', id, port);
  20213. WorkerMessageHandler.setup(workerHandler, port);
  20214. var messageHandler = new MessageHandler(id, id + '_worker', port);
  20215. this._messageHandler = messageHandler;
  20216. this._readyCapability.resolve();
  20217. }.bind(this));
  20218. },
  20219. destroy: function PDFWorker_destroy() {
  20220. this.destroyed = true;
  20221. if (this._webWorker) {
  20222. this._webWorker.terminate();
  20223. this._webWorker = null;
  20224. }
  20225. this._port = null;
  20226. if (this._messageHandler) {
  20227. this._messageHandler.destroy();
  20228. this._messageHandler = null;
  20229. }
  20230. }
  20231. };
  20232. return PDFWorker;
  20233. }();
  20234. var WorkerTransport = function WorkerTransportClosure() {
  20235. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport, CMapReaderFactory) {
  20236. this.messageHandler = messageHandler;
  20237. this.loadingTask = loadingTask;
  20238. this.pdfDataRangeTransport = pdfDataRangeTransport;
  20239. this.commonObjs = new PDFObjects();
  20240. this.fontLoader = new FontLoader(loadingTask.docId);
  20241. this.CMapReaderFactory = new CMapReaderFactory({
  20242. baseUrl: getDefaultSetting('cMapUrl'),
  20243. isCompressed: getDefaultSetting('cMapPacked')
  20244. });
  20245. this.destroyed = false;
  20246. this.destroyCapability = null;
  20247. this._passwordCapability = null;
  20248. this.pageCache = [];
  20249. this.pagePromises = [];
  20250. this.downloadInfoCapability = createPromiseCapability();
  20251. this.setupMessageHandler();
  20252. }
  20253. WorkerTransport.prototype = {
  20254. destroy: function WorkerTransport_destroy() {
  20255. if (this.destroyCapability) {
  20256. return this.destroyCapability.promise;
  20257. }
  20258. this.destroyed = true;
  20259. this.destroyCapability = createPromiseCapability();
  20260. if (this._passwordCapability) {
  20261. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  20262. }
  20263. var waitOn = [];
  20264. this.pageCache.forEach(function (page) {
  20265. if (page) {
  20266. waitOn.push(page._destroy());
  20267. }
  20268. });
  20269. this.pageCache = [];
  20270. this.pagePromises = [];
  20271. var self = this;
  20272. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  20273. waitOn.push(terminated);
  20274. Promise.all(waitOn).then(function () {
  20275. self.fontLoader.clear();
  20276. if (self.pdfDataRangeTransport) {
  20277. self.pdfDataRangeTransport.abort();
  20278. self.pdfDataRangeTransport = null;
  20279. }
  20280. if (self.messageHandler) {
  20281. self.messageHandler.destroy();
  20282. self.messageHandler = null;
  20283. }
  20284. self.destroyCapability.resolve();
  20285. }, this.destroyCapability.reject);
  20286. return this.destroyCapability.promise;
  20287. },
  20288. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  20289. var messageHandler = this.messageHandler;
  20290. var loadingTask = this.loadingTask;
  20291. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  20292. if (pdfDataRangeTransport) {
  20293. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  20294. messageHandler.send('OnDataRange', {
  20295. begin: begin,
  20296. chunk: chunk
  20297. });
  20298. });
  20299. pdfDataRangeTransport.addProgressListener(function (loaded) {
  20300. messageHandler.send('OnDataProgress', { loaded: loaded });
  20301. });
  20302. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  20303. messageHandler.send('OnDataRange', { chunk: chunk });
  20304. });
  20305. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  20306. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  20307. }, this);
  20308. }
  20309. messageHandler.on('GetDoc', function transportDoc(data) {
  20310. var pdfInfo = data.pdfInfo;
  20311. this.numPages = data.pdfInfo.numPages;
  20312. var loadingTask = this.loadingTask;
  20313. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  20314. this.pdfDocument = pdfDocument;
  20315. loadingTask._capability.resolve(pdfDocument);
  20316. }, this);
  20317. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  20318. this._passwordCapability = createPromiseCapability();
  20319. if (loadingTask.onPassword) {
  20320. var updatePassword = function (password) {
  20321. this._passwordCapability.resolve({ password: password });
  20322. }.bind(this);
  20323. loadingTask.onPassword(updatePassword, exception.code);
  20324. } else {
  20325. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  20326. }
  20327. return this._passwordCapability.promise;
  20328. }, this);
  20329. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  20330. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  20331. }, this);
  20332. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  20333. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  20334. }, this);
  20335. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  20336. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  20337. }, this);
  20338. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  20339. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  20340. }, this);
  20341. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  20342. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  20343. }, this);
  20344. messageHandler.on('DataLoaded', function transportPage(data) {
  20345. this.downloadInfoCapability.resolve(data);
  20346. }, this);
  20347. messageHandler.on('PDFManagerReady', function transportPage(data) {
  20348. if (this.pdfDataRangeTransport) {
  20349. this.pdfDataRangeTransport.transportReady();
  20350. }
  20351. }, this);
  20352. messageHandler.on('StartRenderPage', function transportRender(data) {
  20353. if (this.destroyed) {
  20354. return;
  20355. }
  20356. var page = this.pageCache[data.pageIndex];
  20357. page.stats.timeEnd('Page Request');
  20358. page._startRenderPage(data.transparency, data.intent);
  20359. }, this);
  20360. messageHandler.on('RenderPageChunk', function transportRender(data) {
  20361. if (this.destroyed) {
  20362. return;
  20363. }
  20364. var page = this.pageCache[data.pageIndex];
  20365. page._renderPageChunk(data.operatorList, data.intent);
  20366. }, this);
  20367. messageHandler.on('commonobj', function transportObj(data) {
  20368. if (this.destroyed) {
  20369. return;
  20370. }
  20371. var id = data[0];
  20372. var type = data[1];
  20373. if (this.commonObjs.hasData(id)) {
  20374. return;
  20375. }
  20376. switch (type) {
  20377. case 'Font':
  20378. var exportedData = data[2];
  20379. if ('error' in exportedData) {
  20380. var exportedError = exportedData.error;
  20381. warn('Error during font loading: ' + exportedError);
  20382. this.commonObjs.resolve(id, exportedError);
  20383. break;
  20384. }
  20385. var fontRegistry = null;
  20386. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  20387. fontRegistry = {
  20388. registerFont: function (font, url) {
  20389. globalScope['FontInspector'].fontAdded(font, url);
  20390. }
  20391. };
  20392. }
  20393. var font = new FontFaceObject(exportedData, {
  20394. isEvalSuported: getDefaultSetting('isEvalSupported'),
  20395. disableFontFace: getDefaultSetting('disableFontFace'),
  20396. fontRegistry: fontRegistry
  20397. });
  20398. this.fontLoader.bind([font], function fontReady(fontObjs) {
  20399. this.commonObjs.resolve(id, font);
  20400. }.bind(this));
  20401. break;
  20402. case 'FontPath':
  20403. this.commonObjs.resolve(id, data[2]);
  20404. break;
  20405. default:
  20406. error('Got unknown common object type ' + type);
  20407. }
  20408. }, this);
  20409. messageHandler.on('obj', function transportObj(data) {
  20410. if (this.destroyed) {
  20411. return;
  20412. }
  20413. var id = data[0];
  20414. var pageIndex = data[1];
  20415. var type = data[2];
  20416. var pageProxy = this.pageCache[pageIndex];
  20417. var imageData;
  20418. if (pageProxy.objs.hasData(id)) {
  20419. return;
  20420. }
  20421. switch (type) {
  20422. case 'JpegStream':
  20423. imageData = data[3];
  20424. loadJpegStream(id, imageData, pageProxy.objs);
  20425. break;
  20426. case 'Image':
  20427. imageData = data[3];
  20428. pageProxy.objs.resolve(id, imageData);
  20429. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  20430. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  20431. pageProxy.cleanupAfterRender = true;
  20432. }
  20433. break;
  20434. default:
  20435. error('Got unknown object type ' + type);
  20436. }
  20437. }, this);
  20438. messageHandler.on('DocProgress', function transportDocProgress(data) {
  20439. if (this.destroyed) {
  20440. return;
  20441. }
  20442. var loadingTask = this.loadingTask;
  20443. if (loadingTask.onProgress) {
  20444. loadingTask.onProgress({
  20445. loaded: data.loaded,
  20446. total: data.total
  20447. });
  20448. }
  20449. }, this);
  20450. messageHandler.on('PageError', function transportError(data) {
  20451. if (this.destroyed) {
  20452. return;
  20453. }
  20454. var page = this.pageCache[data.pageNum - 1];
  20455. var intentState = page.intentStates[data.intent];
  20456. if (intentState.displayReadyCapability) {
  20457. intentState.displayReadyCapability.reject(data.error);
  20458. } else {
  20459. error(data.error);
  20460. }
  20461. if (intentState.operatorList) {
  20462. intentState.operatorList.lastChunk = true;
  20463. for (var i = 0; i < intentState.renderTasks.length; i++) {
  20464. intentState.renderTasks[i].operatorListChanged();
  20465. }
  20466. }
  20467. }, this);
  20468. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  20469. if (this.destroyed) {
  20470. return;
  20471. }
  20472. var featureId = data.featureId;
  20473. var loadingTask = this.loadingTask;
  20474. if (loadingTask.onUnsupportedFeature) {
  20475. loadingTask.onUnsupportedFeature(featureId);
  20476. }
  20477. _UnsupportedManager.notify(featureId);
  20478. }, this);
  20479. messageHandler.on('JpegDecode', function (data) {
  20480. if (this.destroyed) {
  20481. return Promise.reject(new Error('Worker was destroyed'));
  20482. }
  20483. if (typeof document === 'undefined') {
  20484. return Promise.reject(new Error('"document" is not defined.'));
  20485. }
  20486. var imageUrl = data[0];
  20487. var components = data[1];
  20488. if (components !== 3 && components !== 1) {
  20489. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  20490. }
  20491. return new Promise(function (resolve, reject) {
  20492. var img = new Image();
  20493. img.onload = function () {
  20494. var width = img.width;
  20495. var height = img.height;
  20496. var size = width * height;
  20497. var rgbaLength = size * 4;
  20498. var buf = new Uint8Array(size * components);
  20499. var tmpCanvas = document.createElement('canvas');
  20500. tmpCanvas.width = width;
  20501. tmpCanvas.height = height;
  20502. var tmpCtx = tmpCanvas.getContext('2d');
  20503. tmpCtx.drawImage(img, 0, 0);
  20504. var data = tmpCtx.getImageData(0, 0, width, height).data;
  20505. var i, j;
  20506. if (components === 3) {
  20507. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  20508. buf[j] = data[i];
  20509. buf[j + 1] = data[i + 1];
  20510. buf[j + 2] = data[i + 2];
  20511. }
  20512. } else if (components === 1) {
  20513. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  20514. buf[j] = data[i];
  20515. }
  20516. }
  20517. resolve({
  20518. data: buf,
  20519. width: width,
  20520. height: height
  20521. });
  20522. };
  20523. img.onerror = function () {
  20524. reject(new Error('JpegDecode failed to load image'));
  20525. };
  20526. img.src = imageUrl;
  20527. });
  20528. }, this);
  20529. messageHandler.on('FetchBuiltInCMap', function (data) {
  20530. if (this.destroyed) {
  20531. return Promise.reject(new Error('Worker was destroyed'));
  20532. }
  20533. return this.CMapReaderFactory.fetch({ name: data.name });
  20534. }, this);
  20535. },
  20536. getData: function WorkerTransport_getData() {
  20537. return this.messageHandler.sendWithPromise('GetData', null);
  20538. },
  20539. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  20540. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  20541. return Promise.reject(new Error('Invalid page request'));
  20542. }
  20543. var pageIndex = pageNumber - 1;
  20544. if (pageIndex in this.pagePromises) {
  20545. return this.pagePromises[pageIndex];
  20546. }
  20547. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  20548. if (this.destroyed) {
  20549. throw new Error('Transport destroyed');
  20550. }
  20551. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  20552. this.pageCache[pageIndex] = page;
  20553. return page;
  20554. }.bind(this));
  20555. this.pagePromises[pageIndex] = promise;
  20556. return promise;
  20557. },
  20558. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  20559. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  20560. return Promise.reject(new Error(reason));
  20561. });
  20562. },
  20563. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  20564. return this.messageHandler.sendWithPromise('GetAnnotations', {
  20565. pageIndex: pageIndex,
  20566. intent: intent
  20567. });
  20568. },
  20569. getDestinations: function WorkerTransport_getDestinations() {
  20570. return this.messageHandler.sendWithPromise('GetDestinations', null);
  20571. },
  20572. getDestination: function WorkerTransport_getDestination(id) {
  20573. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  20574. },
  20575. getPageLabels: function WorkerTransport_getPageLabels() {
  20576. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  20577. },
  20578. getAttachments: function WorkerTransport_getAttachments() {
  20579. return this.messageHandler.sendWithPromise('GetAttachments', null);
  20580. },
  20581. getJavaScript: function WorkerTransport_getJavaScript() {
  20582. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  20583. },
  20584. getOutline: function WorkerTransport_getOutline() {
  20585. return this.messageHandler.sendWithPromise('GetOutline', null);
  20586. },
  20587. getMetadata: function WorkerTransport_getMetadata() {
  20588. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  20589. return {
  20590. info: results[0],
  20591. metadata: results[1] ? new Metadata(results[1]) : null
  20592. };
  20593. });
  20594. },
  20595. getStats: function WorkerTransport_getStats() {
  20596. return this.messageHandler.sendWithPromise('GetStats', null);
  20597. },
  20598. startCleanup: function WorkerTransport_startCleanup() {
  20599. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  20600. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  20601. var page = this.pageCache[i];
  20602. if (page) {
  20603. page.cleanup();
  20604. }
  20605. }
  20606. this.commonObjs.clear();
  20607. this.fontLoader.clear();
  20608. }.bind(this));
  20609. }
  20610. };
  20611. return WorkerTransport;
  20612. }();
  20613. var PDFObjects = function PDFObjectsClosure() {
  20614. function PDFObjects() {
  20615. this.objs = Object.create(null);
  20616. }
  20617. PDFObjects.prototype = {
  20618. ensureObj: function PDFObjects_ensureObj(objId) {
  20619. if (this.objs[objId]) {
  20620. return this.objs[objId];
  20621. }
  20622. var obj = {
  20623. capability: createPromiseCapability(),
  20624. data: null,
  20625. resolved: false
  20626. };
  20627. this.objs[objId] = obj;
  20628. return obj;
  20629. },
  20630. get: function PDFObjects_get(objId, callback) {
  20631. if (callback) {
  20632. this.ensureObj(objId).capability.promise.then(callback);
  20633. return null;
  20634. }
  20635. var obj = this.objs[objId];
  20636. if (!obj || !obj.resolved) {
  20637. error('Requesting object that isn\'t resolved yet ' + objId);
  20638. }
  20639. return obj.data;
  20640. },
  20641. resolve: function PDFObjects_resolve(objId, data) {
  20642. var obj = this.ensureObj(objId);
  20643. obj.resolved = true;
  20644. obj.data = data;
  20645. obj.capability.resolve(data);
  20646. },
  20647. isResolved: function PDFObjects_isResolved(objId) {
  20648. var objs = this.objs;
  20649. if (!objs[objId]) {
  20650. return false;
  20651. }
  20652. return objs[objId].resolved;
  20653. },
  20654. hasData: function PDFObjects_hasData(objId) {
  20655. return this.isResolved(objId);
  20656. },
  20657. getData: function PDFObjects_getData(objId) {
  20658. var objs = this.objs;
  20659. if (!objs[objId] || !objs[objId].resolved) {
  20660. return null;
  20661. }
  20662. return objs[objId].data;
  20663. },
  20664. clear: function PDFObjects_clear() {
  20665. this.objs = Object.create(null);
  20666. }
  20667. };
  20668. return PDFObjects;
  20669. }();
  20670. var RenderTask = function RenderTaskClosure() {
  20671. function RenderTask(internalRenderTask) {
  20672. this._internalRenderTask = internalRenderTask;
  20673. this.onContinue = null;
  20674. }
  20675. RenderTask.prototype = {
  20676. get promise() {
  20677. return this._internalRenderTask.capability.promise;
  20678. },
  20679. cancel: function RenderTask_cancel() {
  20680. this._internalRenderTask.cancel();
  20681. },
  20682. then: function RenderTask_then(onFulfilled, onRejected) {
  20683. return this.promise.then.apply(this.promise, arguments);
  20684. }
  20685. };
  20686. return RenderTask;
  20687. }();
  20688. var InternalRenderTask = function InternalRenderTaskClosure() {
  20689. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  20690. this.callback = callback;
  20691. this.params = params;
  20692. this.objs = objs;
  20693. this.commonObjs = commonObjs;
  20694. this.operatorListIdx = null;
  20695. this.operatorList = operatorList;
  20696. this.pageNumber = pageNumber;
  20697. this.canvasFactory = canvasFactory;
  20698. this.running = false;
  20699. this.graphicsReadyCallback = null;
  20700. this.graphicsReady = false;
  20701. this.useRequestAnimationFrame = false;
  20702. this.cancelled = false;
  20703. this.capability = createPromiseCapability();
  20704. this.task = new RenderTask(this);
  20705. this._continueBound = this._continue.bind(this);
  20706. this._scheduleNextBound = this._scheduleNext.bind(this);
  20707. this._nextBound = this._next.bind(this);
  20708. }
  20709. InternalRenderTask.prototype = {
  20710. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  20711. if (this.cancelled) {
  20712. return;
  20713. }
  20714. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  20715. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  20716. this.stepper.init(this.operatorList);
  20717. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  20718. }
  20719. var params = this.params;
  20720. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  20721. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  20722. this.operatorListIdx = 0;
  20723. this.graphicsReady = true;
  20724. if (this.graphicsReadyCallback) {
  20725. this.graphicsReadyCallback();
  20726. }
  20727. },
  20728. cancel: function InternalRenderTask_cancel() {
  20729. this.running = false;
  20730. this.cancelled = true;
  20731. this.callback('cancelled');
  20732. },
  20733. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  20734. if (!this.graphicsReady) {
  20735. if (!this.graphicsReadyCallback) {
  20736. this.graphicsReadyCallback = this._continueBound;
  20737. }
  20738. return;
  20739. }
  20740. if (this.stepper) {
  20741. this.stepper.updateOperatorList(this.operatorList);
  20742. }
  20743. if (this.running) {
  20744. return;
  20745. }
  20746. this._continue();
  20747. },
  20748. _continue: function InternalRenderTask__continue() {
  20749. this.running = true;
  20750. if (this.cancelled) {
  20751. return;
  20752. }
  20753. if (this.task.onContinue) {
  20754. this.task.onContinue(this._scheduleNextBound);
  20755. } else {
  20756. this._scheduleNext();
  20757. }
  20758. },
  20759. _scheduleNext: function InternalRenderTask__scheduleNext() {
  20760. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  20761. window.requestAnimationFrame(this._nextBound);
  20762. } else {
  20763. Promise.resolve(undefined).then(this._nextBound);
  20764. }
  20765. },
  20766. _next: function InternalRenderTask__next() {
  20767. if (this.cancelled) {
  20768. return;
  20769. }
  20770. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  20771. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  20772. this.running = false;
  20773. if (this.operatorList.lastChunk) {
  20774. this.gfx.endDrawing();
  20775. this.callback();
  20776. }
  20777. }
  20778. }
  20779. };
  20780. return InternalRenderTask;
  20781. }();
  20782. var _UnsupportedManager = function UnsupportedManagerClosure() {
  20783. var listeners = [];
  20784. return {
  20785. listen: function (cb) {
  20786. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  20787. listeners.push(cb);
  20788. },
  20789. notify: function (featureId) {
  20790. for (var i = 0, ii = listeners.length; i < ii; i++) {
  20791. listeners[i](featureId);
  20792. }
  20793. }
  20794. };
  20795. }();
  20796. exports.version = '1.7.312';
  20797. exports.build = 'cada411a';
  20798. exports.getDocument = getDocument;
  20799. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  20800. exports.PDFWorker = PDFWorker;
  20801. exports.PDFDocumentProxy = PDFDocumentProxy;
  20802. exports.PDFPageProxy = PDFPageProxy;
  20803. exports._UnsupportedManager = _UnsupportedManager;
  20804. /***/ }),
  20805. /* 11 */
  20806. /***/ (function(module, exports, __w_pdfjs_require__) {
  20807. "use strict";
  20808. var sharedUtil = __w_pdfjs_require__(0);
  20809. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  20810. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  20811. var ImageKind = sharedUtil.ImageKind;
  20812. var OPS = sharedUtil.OPS;
  20813. var Util = sharedUtil.Util;
  20814. var isNum = sharedUtil.isNum;
  20815. var isArray = sharedUtil.isArray;
  20816. var warn = sharedUtil.warn;
  20817. var createObjectURL = sharedUtil.createObjectURL;
  20818. var SVG_DEFAULTS = {
  20819. fontStyle: 'normal',
  20820. fontWeight: 'normal',
  20821. fillColor: '#000000'
  20822. };
  20823. var convertImgDataToPng = function convertImgDataToPngClosure() {
  20824. var PNG_HEADER = new Uint8Array([
  20825. 0x89,
  20826. 0x50,
  20827. 0x4e,
  20828. 0x47,
  20829. 0x0d,
  20830. 0x0a,
  20831. 0x1a,
  20832. 0x0a
  20833. ]);
  20834. var CHUNK_WRAPPER_SIZE = 12;
  20835. var crcTable = new Int32Array(256);
  20836. for (var i = 0; i < 256; i++) {
  20837. var c = i;
  20838. for (var h = 0; h < 8; h++) {
  20839. if (c & 1) {
  20840. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  20841. } else {
  20842. c = c >> 1 & 0x7fffffff;
  20843. }
  20844. }
  20845. crcTable[i] = c;
  20846. }
  20847. function crc32(data, start, end) {
  20848. var crc = -1;
  20849. for (var i = start; i < end; i++) {
  20850. var a = (crc ^ data[i]) & 0xff;
  20851. var b = crcTable[a];
  20852. crc = crc >>> 8 ^ b;
  20853. }
  20854. return crc ^ -1;
  20855. }
  20856. function writePngChunk(type, body, data, offset) {
  20857. var p = offset;
  20858. var len = body.length;
  20859. data[p] = len >> 24 & 0xff;
  20860. data[p + 1] = len >> 16 & 0xff;
  20861. data[p + 2] = len >> 8 & 0xff;
  20862. data[p + 3] = len & 0xff;
  20863. p += 4;
  20864. data[p] = type.charCodeAt(0) & 0xff;
  20865. data[p + 1] = type.charCodeAt(1) & 0xff;
  20866. data[p + 2] = type.charCodeAt(2) & 0xff;
  20867. data[p + 3] = type.charCodeAt(3) & 0xff;
  20868. p += 4;
  20869. data.set(body, p);
  20870. p += body.length;
  20871. var crc = crc32(data, offset + 4, p);
  20872. data[p] = crc >> 24 & 0xff;
  20873. data[p + 1] = crc >> 16 & 0xff;
  20874. data[p + 2] = crc >> 8 & 0xff;
  20875. data[p + 3] = crc & 0xff;
  20876. }
  20877. function adler32(data, start, end) {
  20878. var a = 1;
  20879. var b = 0;
  20880. for (var i = start; i < end; ++i) {
  20881. a = (a + (data[i] & 0xff)) % 65521;
  20882. b = (b + a) % 65521;
  20883. }
  20884. return b << 16 | a;
  20885. }
  20886. function encode(imgData, kind, forceDataSchema) {
  20887. var width = imgData.width;
  20888. var height = imgData.height;
  20889. var bitDepth, colorType, lineSize;
  20890. var bytes = imgData.data;
  20891. switch (kind) {
  20892. case ImageKind.GRAYSCALE_1BPP:
  20893. colorType = 0;
  20894. bitDepth = 1;
  20895. lineSize = width + 7 >> 3;
  20896. break;
  20897. case ImageKind.RGB_24BPP:
  20898. colorType = 2;
  20899. bitDepth = 8;
  20900. lineSize = width * 3;
  20901. break;
  20902. case ImageKind.RGBA_32BPP:
  20903. colorType = 6;
  20904. bitDepth = 8;
  20905. lineSize = width * 4;
  20906. break;
  20907. default:
  20908. throw new Error('invalid format');
  20909. }
  20910. var literals = new Uint8Array((1 + lineSize) * height);
  20911. var offsetLiterals = 0, offsetBytes = 0;
  20912. var y, i;
  20913. for (y = 0; y < height; ++y) {
  20914. literals[offsetLiterals++] = 0;
  20915. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  20916. offsetBytes += lineSize;
  20917. offsetLiterals += lineSize;
  20918. }
  20919. if (kind === ImageKind.GRAYSCALE_1BPP) {
  20920. offsetLiterals = 0;
  20921. for (y = 0; y < height; y++) {
  20922. offsetLiterals++;
  20923. for (i = 0; i < lineSize; i++) {
  20924. literals[offsetLiterals++] ^= 0xFF;
  20925. }
  20926. }
  20927. }
  20928. var ihdr = new Uint8Array([
  20929. width >> 24 & 0xff,
  20930. width >> 16 & 0xff,
  20931. width >> 8 & 0xff,
  20932. width & 0xff,
  20933. height >> 24 & 0xff,
  20934. height >> 16 & 0xff,
  20935. height >> 8 & 0xff,
  20936. height & 0xff,
  20937. bitDepth,
  20938. colorType,
  20939. 0x00,
  20940. 0x00,
  20941. 0x00
  20942. ]);
  20943. var len = literals.length;
  20944. var maxBlockLength = 0xFFFF;
  20945. var deflateBlocks = Math.ceil(len / maxBlockLength);
  20946. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  20947. var pi = 0;
  20948. idat[pi++] = 0x78;
  20949. idat[pi++] = 0x9c;
  20950. var pos = 0;
  20951. while (len > maxBlockLength) {
  20952. idat[pi++] = 0x00;
  20953. idat[pi++] = 0xff;
  20954. idat[pi++] = 0xff;
  20955. idat[pi++] = 0x00;
  20956. idat[pi++] = 0x00;
  20957. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  20958. pi += maxBlockLength;
  20959. pos += maxBlockLength;
  20960. len -= maxBlockLength;
  20961. }
  20962. idat[pi++] = 0x01;
  20963. idat[pi++] = len & 0xff;
  20964. idat[pi++] = len >> 8 & 0xff;
  20965. idat[pi++] = ~len & 0xffff & 0xff;
  20966. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  20967. idat.set(literals.subarray(pos), pi);
  20968. pi += literals.length - pos;
  20969. var adler = adler32(literals, 0, literals.length);
  20970. idat[pi++] = adler >> 24 & 0xff;
  20971. idat[pi++] = adler >> 16 & 0xff;
  20972. idat[pi++] = adler >> 8 & 0xff;
  20973. idat[pi++] = adler & 0xff;
  20974. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  20975. var data = new Uint8Array(pngLength);
  20976. var offset = 0;
  20977. data.set(PNG_HEADER, offset);
  20978. offset += PNG_HEADER.length;
  20979. writePngChunk('IHDR', ihdr, data, offset);
  20980. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  20981. writePngChunk('IDATA', idat, data, offset);
  20982. offset += CHUNK_WRAPPER_SIZE + idat.length;
  20983. writePngChunk('IEND', new Uint8Array(0), data, offset);
  20984. return createObjectURL(data, 'image/png', forceDataSchema);
  20985. }
  20986. return function convertImgDataToPng(imgData, forceDataSchema) {
  20987. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  20988. return encode(imgData, kind, forceDataSchema);
  20989. };
  20990. }();
  20991. var SVGExtraState = function SVGExtraStateClosure() {
  20992. function SVGExtraState() {
  20993. this.fontSizeScale = 1;
  20994. this.fontWeight = SVG_DEFAULTS.fontWeight;
  20995. this.fontSize = 0;
  20996. this.textMatrix = IDENTITY_MATRIX;
  20997. this.fontMatrix = FONT_IDENTITY_MATRIX;
  20998. this.leading = 0;
  20999. this.x = 0;
  21000. this.y = 0;
  21001. this.lineX = 0;
  21002. this.lineY = 0;
  21003. this.charSpacing = 0;
  21004. this.wordSpacing = 0;
  21005. this.textHScale = 1;
  21006. this.textRise = 0;
  21007. this.fillColor = SVG_DEFAULTS.fillColor;
  21008. this.strokeColor = '#000000';
  21009. this.fillAlpha = 1;
  21010. this.strokeAlpha = 1;
  21011. this.lineWidth = 1;
  21012. this.lineJoin = '';
  21013. this.lineCap = '';
  21014. this.miterLimit = 0;
  21015. this.dashArray = [];
  21016. this.dashPhase = 0;
  21017. this.dependencies = [];
  21018. this.activeClipUrl = null;
  21019. this.clipGroup = null;
  21020. this.maskId = '';
  21021. }
  21022. SVGExtraState.prototype = {
  21023. clone: function SVGExtraState_clone() {
  21024. return Object.create(this);
  21025. },
  21026. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  21027. this.x = x;
  21028. this.y = y;
  21029. }
  21030. };
  21031. return SVGExtraState;
  21032. }();
  21033. var SVGGraphics = function SVGGraphicsClosure() {
  21034. function opListToTree(opList) {
  21035. var opTree = [];
  21036. var tmp = [];
  21037. var opListLen = opList.length;
  21038. for (var x = 0; x < opListLen; x++) {
  21039. if (opList[x].fn === 'save') {
  21040. opTree.push({
  21041. 'fnId': 92,
  21042. 'fn': 'group',
  21043. 'items': []
  21044. });
  21045. tmp.push(opTree);
  21046. opTree = opTree[opTree.length - 1].items;
  21047. continue;
  21048. }
  21049. if (opList[x].fn === 'restore') {
  21050. opTree = tmp.pop();
  21051. } else {
  21052. opTree.push(opList[x]);
  21053. }
  21054. }
  21055. return opTree;
  21056. }
  21057. function pf(value) {
  21058. if (value === (value | 0)) {
  21059. return value.toString();
  21060. }
  21061. var s = value.toFixed(10);
  21062. var i = s.length - 1;
  21063. if (s[i] !== '0') {
  21064. return s;
  21065. }
  21066. do {
  21067. i--;
  21068. } while (s[i] === '0');
  21069. return s.substr(0, s[i] === '.' ? i : i + 1);
  21070. }
  21071. function pm(m) {
  21072. if (m[4] === 0 && m[5] === 0) {
  21073. if (m[1] === 0 && m[2] === 0) {
  21074. if (m[0] === 1 && m[3] === 1) {
  21075. return '';
  21076. }
  21077. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  21078. }
  21079. if (m[0] === m[3] && m[1] === -m[2]) {
  21080. var a = Math.acos(m[0]) * 180 / Math.PI;
  21081. return 'rotate(' + pf(a) + ')';
  21082. }
  21083. } else {
  21084. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  21085. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21086. }
  21087. }
  21088. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21089. }
  21090. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  21091. this.current = new SVGExtraState();
  21092. this.transformMatrix = IDENTITY_MATRIX;
  21093. this.transformStack = [];
  21094. this.extraStack = [];
  21095. this.commonObjs = commonObjs;
  21096. this.objs = objs;
  21097. this.pendingEOFill = false;
  21098. this.embedFonts = false;
  21099. this.embeddedFonts = Object.create(null);
  21100. this.cssStyle = null;
  21101. this.forceDataSchema = !!forceDataSchema;
  21102. }
  21103. var NS = 'http://www.w3.org/2000/svg';
  21104. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  21105. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  21106. var LINE_CAP_STYLES = [
  21107. 'butt',
  21108. 'round',
  21109. 'square'
  21110. ];
  21111. var LINE_JOIN_STYLES = [
  21112. 'miter',
  21113. 'round',
  21114. 'bevel'
  21115. ];
  21116. var clipCount = 0;
  21117. var maskCount = 0;
  21118. SVGGraphics.prototype = {
  21119. save: function SVGGraphics_save() {
  21120. this.transformStack.push(this.transformMatrix);
  21121. var old = this.current;
  21122. this.extraStack.push(old);
  21123. this.current = old.clone();
  21124. },
  21125. restore: function SVGGraphics_restore() {
  21126. this.transformMatrix = this.transformStack.pop();
  21127. this.current = this.extraStack.pop();
  21128. this.tgrp = null;
  21129. },
  21130. group: function SVGGraphics_group(items) {
  21131. this.save();
  21132. this.executeOpTree(items);
  21133. this.restore();
  21134. },
  21135. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  21136. var fnArray = operatorList.fnArray;
  21137. var fnArrayLen = fnArray.length;
  21138. var argsArray = operatorList.argsArray;
  21139. var self = this;
  21140. for (var i = 0; i < fnArrayLen; i++) {
  21141. if (OPS.dependency === fnArray[i]) {
  21142. var deps = argsArray[i];
  21143. for (var n = 0, nn = deps.length; n < nn; n++) {
  21144. var obj = deps[n];
  21145. var common = obj.substring(0, 2) === 'g_';
  21146. var promise;
  21147. if (common) {
  21148. promise = new Promise(function (resolve) {
  21149. self.commonObjs.get(obj, resolve);
  21150. });
  21151. } else {
  21152. promise = new Promise(function (resolve) {
  21153. self.objs.get(obj, resolve);
  21154. });
  21155. }
  21156. this.current.dependencies.push(promise);
  21157. }
  21158. }
  21159. }
  21160. return Promise.all(this.current.dependencies);
  21161. },
  21162. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  21163. var transformMatrix = [
  21164. a,
  21165. b,
  21166. c,
  21167. d,
  21168. e,
  21169. f
  21170. ];
  21171. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  21172. this.tgrp = null;
  21173. },
  21174. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  21175. this.viewport = viewport;
  21176. var svgElement = this._initialize(viewport);
  21177. return this.loadDependencies(operatorList).then(function () {
  21178. this.transformMatrix = IDENTITY_MATRIX;
  21179. var opTree = this.convertOpList(operatorList);
  21180. this.executeOpTree(opTree);
  21181. return svgElement;
  21182. }.bind(this));
  21183. },
  21184. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  21185. var argsArray = operatorList.argsArray;
  21186. var fnArray = operatorList.fnArray;
  21187. var fnArrayLen = fnArray.length;
  21188. var REVOPS = [];
  21189. var opList = [];
  21190. for (var op in OPS) {
  21191. REVOPS[OPS[op]] = op;
  21192. }
  21193. for (var x = 0; x < fnArrayLen; x++) {
  21194. var fnId = fnArray[x];
  21195. opList.push({
  21196. 'fnId': fnId,
  21197. 'fn': REVOPS[fnId],
  21198. 'args': argsArray[x]
  21199. });
  21200. }
  21201. return opListToTree(opList);
  21202. },
  21203. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  21204. var opTreeLen = opTree.length;
  21205. for (var x = 0; x < opTreeLen; x++) {
  21206. var fn = opTree[x].fn;
  21207. var fnId = opTree[x].fnId;
  21208. var args = opTree[x].args;
  21209. switch (fnId | 0) {
  21210. case OPS.beginText:
  21211. this.beginText();
  21212. break;
  21213. case OPS.setLeading:
  21214. this.setLeading(args);
  21215. break;
  21216. case OPS.setLeadingMoveText:
  21217. this.setLeadingMoveText(args[0], args[1]);
  21218. break;
  21219. case OPS.setFont:
  21220. this.setFont(args);
  21221. break;
  21222. case OPS.showText:
  21223. this.showText(args[0]);
  21224. break;
  21225. case OPS.showSpacedText:
  21226. this.showText(args[0]);
  21227. break;
  21228. case OPS.endText:
  21229. this.endText();
  21230. break;
  21231. case OPS.moveText:
  21232. this.moveText(args[0], args[1]);
  21233. break;
  21234. case OPS.setCharSpacing:
  21235. this.setCharSpacing(args[0]);
  21236. break;
  21237. case OPS.setWordSpacing:
  21238. this.setWordSpacing(args[0]);
  21239. break;
  21240. case OPS.setHScale:
  21241. this.setHScale(args[0]);
  21242. break;
  21243. case OPS.setTextMatrix:
  21244. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  21245. break;
  21246. case OPS.setLineWidth:
  21247. this.setLineWidth(args[0]);
  21248. break;
  21249. case OPS.setLineJoin:
  21250. this.setLineJoin(args[0]);
  21251. break;
  21252. case OPS.setLineCap:
  21253. this.setLineCap(args[0]);
  21254. break;
  21255. case OPS.setMiterLimit:
  21256. this.setMiterLimit(args[0]);
  21257. break;
  21258. case OPS.setFillRGBColor:
  21259. this.setFillRGBColor(args[0], args[1], args[2]);
  21260. break;
  21261. case OPS.setStrokeRGBColor:
  21262. this.setStrokeRGBColor(args[0], args[1], args[2]);
  21263. break;
  21264. case OPS.setDash:
  21265. this.setDash(args[0], args[1]);
  21266. break;
  21267. case OPS.setGState:
  21268. this.setGState(args[0]);
  21269. break;
  21270. case OPS.fill:
  21271. this.fill();
  21272. break;
  21273. case OPS.eoFill:
  21274. this.eoFill();
  21275. break;
  21276. case OPS.stroke:
  21277. this.stroke();
  21278. break;
  21279. case OPS.fillStroke:
  21280. this.fillStroke();
  21281. break;
  21282. case OPS.eoFillStroke:
  21283. this.eoFillStroke();
  21284. break;
  21285. case OPS.clip:
  21286. this.clip('nonzero');
  21287. break;
  21288. case OPS.eoClip:
  21289. this.clip('evenodd');
  21290. break;
  21291. case OPS.paintSolidColorImageMask:
  21292. this.paintSolidColorImageMask();
  21293. break;
  21294. case OPS.paintJpegXObject:
  21295. this.paintJpegXObject(args[0], args[1], args[2]);
  21296. break;
  21297. case OPS.paintImageXObject:
  21298. this.paintImageXObject(args[0]);
  21299. break;
  21300. case OPS.paintInlineImageXObject:
  21301. this.paintInlineImageXObject(args[0]);
  21302. break;
  21303. case OPS.paintImageMaskXObject:
  21304. this.paintImageMaskXObject(args[0]);
  21305. break;
  21306. case OPS.paintFormXObjectBegin:
  21307. this.paintFormXObjectBegin(args[0], args[1]);
  21308. break;
  21309. case OPS.paintFormXObjectEnd:
  21310. this.paintFormXObjectEnd();
  21311. break;
  21312. case OPS.closePath:
  21313. this.closePath();
  21314. break;
  21315. case OPS.closeStroke:
  21316. this.closeStroke();
  21317. break;
  21318. case OPS.closeFillStroke:
  21319. this.closeFillStroke();
  21320. break;
  21321. case OPS.nextLine:
  21322. this.nextLine();
  21323. break;
  21324. case OPS.transform:
  21325. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  21326. break;
  21327. case OPS.constructPath:
  21328. this.constructPath(args[0], args[1]);
  21329. break;
  21330. case OPS.endPath:
  21331. this.endPath();
  21332. break;
  21333. case 92:
  21334. this.group(opTree[x].items);
  21335. break;
  21336. default:
  21337. warn('Unimplemented operator ' + fn);
  21338. break;
  21339. }
  21340. }
  21341. },
  21342. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  21343. this.current.wordSpacing = wordSpacing;
  21344. },
  21345. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  21346. this.current.charSpacing = charSpacing;
  21347. },
  21348. nextLine: function SVGGraphics_nextLine() {
  21349. this.moveText(0, this.current.leading);
  21350. },
  21351. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  21352. var current = this.current;
  21353. this.current.textMatrix = this.current.lineMatrix = [
  21354. a,
  21355. b,
  21356. c,
  21357. d,
  21358. e,
  21359. f
  21360. ];
  21361. this.current.x = this.current.lineX = 0;
  21362. this.current.y = this.current.lineY = 0;
  21363. current.xcoords = [];
  21364. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21365. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21366. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21367. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21368. current.txtElement = document.createElementNS(NS, 'svg:text');
  21369. current.txtElement.appendChild(current.tspan);
  21370. },
  21371. beginText: function SVGGraphics_beginText() {
  21372. this.current.x = this.current.lineX = 0;
  21373. this.current.y = this.current.lineY = 0;
  21374. this.current.textMatrix = IDENTITY_MATRIX;
  21375. this.current.lineMatrix = IDENTITY_MATRIX;
  21376. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  21377. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  21378. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  21379. this.current.xcoords = [];
  21380. },
  21381. moveText: function SVGGraphics_moveText(x, y) {
  21382. var current = this.current;
  21383. this.current.x = this.current.lineX += x;
  21384. this.current.y = this.current.lineY += y;
  21385. current.xcoords = [];
  21386. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21387. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21388. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21389. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21390. },
  21391. showText: function SVGGraphics_showText(glyphs) {
  21392. var current = this.current;
  21393. var font = current.font;
  21394. var fontSize = current.fontSize;
  21395. if (fontSize === 0) {
  21396. return;
  21397. }
  21398. var charSpacing = current.charSpacing;
  21399. var wordSpacing = current.wordSpacing;
  21400. var fontDirection = current.fontDirection;
  21401. var textHScale = current.textHScale * fontDirection;
  21402. var glyphsLength = glyphs.length;
  21403. var vertical = font.vertical;
  21404. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  21405. var x = 0, i;
  21406. for (i = 0; i < glyphsLength; ++i) {
  21407. var glyph = glyphs[i];
  21408. if (glyph === null) {
  21409. x += fontDirection * wordSpacing;
  21410. continue;
  21411. } else if (isNum(glyph)) {
  21412. x += -glyph * fontSize * 0.001;
  21413. continue;
  21414. }
  21415. current.xcoords.push(current.x + x * textHScale);
  21416. var width = glyph.width;
  21417. var character = glyph.fontChar;
  21418. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  21419. x += charWidth;
  21420. current.tspan.textContent += character;
  21421. }
  21422. if (vertical) {
  21423. current.y -= x * textHScale;
  21424. } else {
  21425. current.x += x * textHScale;
  21426. }
  21427. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  21428. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21429. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21430. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21431. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  21432. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  21433. }
  21434. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  21435. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  21436. }
  21437. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  21438. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  21439. }
  21440. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  21441. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  21442. current.txtElement.appendChild(current.tspan);
  21443. current.txtgrp.appendChild(current.txtElement);
  21444. this._ensureTransformGroup().appendChild(current.txtElement);
  21445. },
  21446. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  21447. this.setLeading(-y);
  21448. this.moveText(x, y);
  21449. },
  21450. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  21451. if (!this.cssStyle) {
  21452. this.cssStyle = document.createElementNS(NS, 'svg:style');
  21453. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  21454. this.defs.appendChild(this.cssStyle);
  21455. }
  21456. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  21457. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  21458. },
  21459. setFont: function SVGGraphics_setFont(details) {
  21460. var current = this.current;
  21461. var fontObj = this.commonObjs.get(details[0]);
  21462. var size = details[1];
  21463. this.current.font = fontObj;
  21464. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  21465. this.addFontStyle(fontObj);
  21466. this.embeddedFonts[fontObj.loadedName] = fontObj;
  21467. }
  21468. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  21469. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  21470. var italic = fontObj.italic ? 'italic' : 'normal';
  21471. if (size < 0) {
  21472. size = -size;
  21473. current.fontDirection = -1;
  21474. } else {
  21475. current.fontDirection = 1;
  21476. }
  21477. current.fontSize = size;
  21478. current.fontFamily = fontObj.loadedName;
  21479. current.fontWeight = bold;
  21480. current.fontStyle = italic;
  21481. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21482. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21483. current.xcoords = [];
  21484. },
  21485. endText: function SVGGraphics_endText() {
  21486. },
  21487. setLineWidth: function SVGGraphics_setLineWidth(width) {
  21488. this.current.lineWidth = width;
  21489. },
  21490. setLineCap: function SVGGraphics_setLineCap(style) {
  21491. this.current.lineCap = LINE_CAP_STYLES[style];
  21492. },
  21493. setLineJoin: function SVGGraphics_setLineJoin(style) {
  21494. this.current.lineJoin = LINE_JOIN_STYLES[style];
  21495. },
  21496. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  21497. this.current.miterLimit = limit;
  21498. },
  21499. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  21500. var color = Util.makeCssRgb(r, g, b);
  21501. this.current.strokeColor = color;
  21502. },
  21503. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  21504. var color = Util.makeCssRgb(r, g, b);
  21505. this.current.fillColor = color;
  21506. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  21507. this.current.xcoords = [];
  21508. },
  21509. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  21510. this.current.dashArray = dashArray;
  21511. this.current.dashPhase = dashPhase;
  21512. },
  21513. constructPath: function SVGGraphics_constructPath(ops, args) {
  21514. var current = this.current;
  21515. var x = current.x, y = current.y;
  21516. current.path = document.createElementNS(NS, 'svg:path');
  21517. var d = [];
  21518. var opLength = ops.length;
  21519. for (var i = 0, j = 0; i < opLength; i++) {
  21520. switch (ops[i] | 0) {
  21521. case OPS.rectangle:
  21522. x = args[j++];
  21523. y = args[j++];
  21524. var width = args[j++];
  21525. var height = args[j++];
  21526. var xw = x + width;
  21527. var yh = y + height;
  21528. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  21529. break;
  21530. case OPS.moveTo:
  21531. x = args[j++];
  21532. y = args[j++];
  21533. d.push('M', pf(x), pf(y));
  21534. break;
  21535. case OPS.lineTo:
  21536. x = args[j++];
  21537. y = args[j++];
  21538. d.push('L', pf(x), pf(y));
  21539. break;
  21540. case OPS.curveTo:
  21541. x = args[j + 4];
  21542. y = args[j + 5];
  21543. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  21544. j += 6;
  21545. break;
  21546. case OPS.curveTo2:
  21547. x = args[j + 2];
  21548. y = args[j + 3];
  21549. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  21550. j += 4;
  21551. break;
  21552. case OPS.curveTo3:
  21553. x = args[j + 2];
  21554. y = args[j + 3];
  21555. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  21556. j += 4;
  21557. break;
  21558. case OPS.closePath:
  21559. d.push('Z');
  21560. break;
  21561. }
  21562. }
  21563. current.path.setAttributeNS(null, 'd', d.join(' '));
  21564. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  21565. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  21566. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  21567. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  21568. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  21569. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  21570. current.path.setAttributeNS(null, 'fill', 'none');
  21571. this._ensureTransformGroup().appendChild(current.path);
  21572. current.element = current.path;
  21573. current.setCurrentPoint(x, y);
  21574. },
  21575. endPath: function SVGGraphics_endPath() {
  21576. },
  21577. clip: function SVGGraphics_clip(type) {
  21578. var current = this.current;
  21579. var clipId = 'clippath' + clipCount;
  21580. clipCount++;
  21581. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  21582. clipPath.setAttributeNS(null, 'id', clipId);
  21583. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  21584. var clipElement = current.element.cloneNode();
  21585. if (type === 'evenodd') {
  21586. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  21587. } else {
  21588. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  21589. }
  21590. clipPath.appendChild(clipElement);
  21591. this.defs.appendChild(clipPath);
  21592. if (current.activeClipUrl) {
  21593. current.clipGroup = null;
  21594. this.extraStack.forEach(function (prev) {
  21595. prev.clipGroup = null;
  21596. });
  21597. }
  21598. current.activeClipUrl = 'url(#' + clipId + ')';
  21599. this.tgrp = null;
  21600. },
  21601. closePath: function SVGGraphics_closePath() {
  21602. var current = this.current;
  21603. var d = current.path.getAttributeNS(null, 'd');
  21604. d += 'Z';
  21605. current.path.setAttributeNS(null, 'd', d);
  21606. },
  21607. setLeading: function SVGGraphics_setLeading(leading) {
  21608. this.current.leading = -leading;
  21609. },
  21610. setTextRise: function SVGGraphics_setTextRise(textRise) {
  21611. this.current.textRise = textRise;
  21612. },
  21613. setHScale: function SVGGraphics_setHScale(scale) {
  21614. this.current.textHScale = scale / 100;
  21615. },
  21616. setGState: function SVGGraphics_setGState(states) {
  21617. for (var i = 0, ii = states.length; i < ii; i++) {
  21618. var state = states[i];
  21619. var key = state[0];
  21620. var value = state[1];
  21621. switch (key) {
  21622. case 'LW':
  21623. this.setLineWidth(value);
  21624. break;
  21625. case 'LC':
  21626. this.setLineCap(value);
  21627. break;
  21628. case 'LJ':
  21629. this.setLineJoin(value);
  21630. break;
  21631. case 'ML':
  21632. this.setMiterLimit(value);
  21633. break;
  21634. case 'D':
  21635. this.setDash(value[0], value[1]);
  21636. break;
  21637. case 'Font':
  21638. this.setFont(value);
  21639. break;
  21640. default:
  21641. warn('Unimplemented graphic state ' + key);
  21642. break;
  21643. }
  21644. }
  21645. },
  21646. fill: function SVGGraphics_fill() {
  21647. var current = this.current;
  21648. current.element.setAttributeNS(null, 'fill', current.fillColor);
  21649. },
  21650. stroke: function SVGGraphics_stroke() {
  21651. var current = this.current;
  21652. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  21653. current.element.setAttributeNS(null, 'fill', 'none');
  21654. },
  21655. eoFill: function SVGGraphics_eoFill() {
  21656. var current = this.current;
  21657. current.element.setAttributeNS(null, 'fill', current.fillColor);
  21658. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  21659. },
  21660. fillStroke: function SVGGraphics_fillStroke() {
  21661. this.stroke();
  21662. this.fill();
  21663. },
  21664. eoFillStroke: function SVGGraphics_eoFillStroke() {
  21665. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  21666. this.fillStroke();
  21667. },
  21668. closeStroke: function SVGGraphics_closeStroke() {
  21669. this.closePath();
  21670. this.stroke();
  21671. },
  21672. closeFillStroke: function SVGGraphics_closeFillStroke() {
  21673. this.closePath();
  21674. this.fillStroke();
  21675. },
  21676. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  21677. var current = this.current;
  21678. var rect = document.createElementNS(NS, 'svg:rect');
  21679. rect.setAttributeNS(null, 'x', '0');
  21680. rect.setAttributeNS(null, 'y', '0');
  21681. rect.setAttributeNS(null, 'width', '1px');
  21682. rect.setAttributeNS(null, 'height', '1px');
  21683. rect.setAttributeNS(null, 'fill', current.fillColor);
  21684. this._ensureTransformGroup().appendChild(rect);
  21685. },
  21686. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  21687. var imgObj = this.objs.get(objId);
  21688. var imgEl = document.createElementNS(NS, 'svg:image');
  21689. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  21690. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  21691. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  21692. imgEl.setAttributeNS(null, 'x', '0');
  21693. imgEl.setAttributeNS(null, 'y', pf(-h));
  21694. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  21695. this._ensureTransformGroup().appendChild(imgEl);
  21696. },
  21697. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  21698. var imgData = this.objs.get(objId);
  21699. if (!imgData) {
  21700. warn('Dependent image isn\'t ready yet');
  21701. return;
  21702. }
  21703. this.paintInlineImageXObject(imgData);
  21704. },
  21705. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  21706. var width = imgData.width;
  21707. var height = imgData.height;
  21708. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  21709. var cliprect = document.createElementNS(NS, 'svg:rect');
  21710. cliprect.setAttributeNS(null, 'x', '0');
  21711. cliprect.setAttributeNS(null, 'y', '0');
  21712. cliprect.setAttributeNS(null, 'width', pf(width));
  21713. cliprect.setAttributeNS(null, 'height', pf(height));
  21714. this.current.element = cliprect;
  21715. this.clip('nonzero');
  21716. var imgEl = document.createElementNS(NS, 'svg:image');
  21717. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  21718. imgEl.setAttributeNS(null, 'x', '0');
  21719. imgEl.setAttributeNS(null, 'y', pf(-height));
  21720. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  21721. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  21722. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  21723. if (mask) {
  21724. mask.appendChild(imgEl);
  21725. } else {
  21726. this._ensureTransformGroup().appendChild(imgEl);
  21727. }
  21728. },
  21729. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  21730. var current = this.current;
  21731. var width = imgData.width;
  21732. var height = imgData.height;
  21733. var fillColor = current.fillColor;
  21734. current.maskId = 'mask' + maskCount++;
  21735. var mask = document.createElementNS(NS, 'svg:mask');
  21736. mask.setAttributeNS(null, 'id', current.maskId);
  21737. var rect = document.createElementNS(NS, 'svg:rect');
  21738. rect.setAttributeNS(null, 'x', '0');
  21739. rect.setAttributeNS(null, 'y', '0');
  21740. rect.setAttributeNS(null, 'width', pf(width));
  21741. rect.setAttributeNS(null, 'height', pf(height));
  21742. rect.setAttributeNS(null, 'fill', fillColor);
  21743. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  21744. this.defs.appendChild(mask);
  21745. this._ensureTransformGroup().appendChild(rect);
  21746. this.paintInlineImageXObject(imgData, mask);
  21747. },
  21748. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  21749. if (isArray(matrix) && matrix.length === 6) {
  21750. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  21751. }
  21752. if (isArray(bbox) && bbox.length === 4) {
  21753. var width = bbox[2] - bbox[0];
  21754. var height = bbox[3] - bbox[1];
  21755. var cliprect = document.createElementNS(NS, 'svg:rect');
  21756. cliprect.setAttributeNS(null, 'x', bbox[0]);
  21757. cliprect.setAttributeNS(null, 'y', bbox[1]);
  21758. cliprect.setAttributeNS(null, 'width', pf(width));
  21759. cliprect.setAttributeNS(null, 'height', pf(height));
  21760. this.current.element = cliprect;
  21761. this.clip('nonzero');
  21762. this.endPath();
  21763. }
  21764. },
  21765. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  21766. },
  21767. _initialize: function SVGGraphics_initialize(viewport) {
  21768. var svg = document.createElementNS(NS, 'svg:svg');
  21769. svg.setAttributeNS(null, 'version', '1.1');
  21770. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  21771. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  21772. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  21773. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  21774. var definitions = document.createElementNS(NS, 'svg:defs');
  21775. svg.appendChild(definitions);
  21776. this.defs = definitions;
  21777. var rootGroup = document.createElementNS(NS, 'svg:g');
  21778. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  21779. svg.appendChild(rootGroup);
  21780. this.svg = rootGroup;
  21781. return svg;
  21782. },
  21783. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  21784. if (!this.current.clipGroup) {
  21785. var clipGroup = document.createElementNS(NS, 'svg:g');
  21786. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  21787. this.svg.appendChild(clipGroup);
  21788. this.current.clipGroup = clipGroup;
  21789. }
  21790. return this.current.clipGroup;
  21791. },
  21792. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  21793. if (!this.tgrp) {
  21794. this.tgrp = document.createElementNS(NS, 'svg:g');
  21795. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  21796. if (this.current.activeClipUrl) {
  21797. this._ensureClipGroup().appendChild(this.tgrp);
  21798. } else {
  21799. this.svg.appendChild(this.tgrp);
  21800. }
  21801. }
  21802. return this.tgrp;
  21803. }
  21804. };
  21805. return SVGGraphics;
  21806. }();
  21807. exports.SVGGraphics = SVGGraphics;
  21808. /***/ }),
  21809. /* 12 */
  21810. /***/ (function(module, exports, __w_pdfjs_require__) {
  21811. "use strict";
  21812. var sharedUtil = __w_pdfjs_require__(0);
  21813. var displayDOMUtils = __w_pdfjs_require__(3);
  21814. var Util = sharedUtil.Util;
  21815. var createPromiseCapability = sharedUtil.createPromiseCapability;
  21816. var CustomStyle = displayDOMUtils.CustomStyle;
  21817. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  21818. var renderTextLayer = function renderTextLayerClosure() {
  21819. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  21820. var NonWhitespaceRegexp = /\S/;
  21821. function isAllWhitespace(str) {
  21822. return !NonWhitespaceRegexp.test(str);
  21823. }
  21824. var styleBuf = [
  21825. 'left: ',
  21826. 0,
  21827. 'px; top: ',
  21828. 0,
  21829. 'px; font-size: ',
  21830. 0,
  21831. 'px; font-family: ',
  21832. '',
  21833. ';'
  21834. ];
  21835. function appendText(task, geom, styles) {
  21836. var textDiv = document.createElement('div');
  21837. var textDivProperties = {
  21838. style: null,
  21839. angle: 0,
  21840. canvasWidth: 0,
  21841. isWhitespace: false,
  21842. originalTransform: null,
  21843. paddingBottom: 0,
  21844. paddingLeft: 0,
  21845. paddingRight: 0,
  21846. paddingTop: 0,
  21847. scale: 1
  21848. };
  21849. task._textDivs.push(textDiv);
  21850. if (isAllWhitespace(geom.str)) {
  21851. textDivProperties.isWhitespace = true;
  21852. task._textDivProperties.set(textDiv, textDivProperties);
  21853. return;
  21854. }
  21855. var tx = Util.transform(task._viewport.transform, geom.transform);
  21856. var angle = Math.atan2(tx[1], tx[0]);
  21857. var style = styles[geom.fontName];
  21858. if (style.vertical) {
  21859. angle += Math.PI / 2;
  21860. }
  21861. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  21862. var fontAscent = fontHeight;
  21863. if (style.ascent) {
  21864. fontAscent = style.ascent * fontAscent;
  21865. } else if (style.descent) {
  21866. fontAscent = (1 + style.descent) * fontAscent;
  21867. }
  21868. var left;
  21869. var top;
  21870. if (angle === 0) {
  21871. left = tx[4];
  21872. top = tx[5] - fontAscent;
  21873. } else {
  21874. left = tx[4] + fontAscent * Math.sin(angle);
  21875. top = tx[5] - fontAscent * Math.cos(angle);
  21876. }
  21877. styleBuf[1] = left;
  21878. styleBuf[3] = top;
  21879. styleBuf[5] = fontHeight;
  21880. styleBuf[7] = style.fontFamily;
  21881. textDivProperties.style = styleBuf.join('');
  21882. textDiv.setAttribute('style', textDivProperties.style);
  21883. textDiv.textContent = geom.str;
  21884. if (getDefaultSetting('pdfBug')) {
  21885. textDiv.dataset.fontName = geom.fontName;
  21886. }
  21887. if (angle !== 0) {
  21888. textDivProperties.angle = angle * (180 / Math.PI);
  21889. }
  21890. if (geom.str.length > 1) {
  21891. if (style.vertical) {
  21892. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  21893. } else {
  21894. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  21895. }
  21896. }
  21897. task._textDivProperties.set(textDiv, textDivProperties);
  21898. if (task._enhanceTextSelection) {
  21899. var angleCos = 1, angleSin = 0;
  21900. if (angle !== 0) {
  21901. angleCos = Math.cos(angle);
  21902. angleSin = Math.sin(angle);
  21903. }
  21904. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  21905. var divHeight = fontHeight;
  21906. var m, b;
  21907. if (angle !== 0) {
  21908. m = [
  21909. angleCos,
  21910. angleSin,
  21911. -angleSin,
  21912. angleCos,
  21913. left,
  21914. top
  21915. ];
  21916. b = Util.getAxialAlignedBoundingBox([
  21917. 0,
  21918. 0,
  21919. divWidth,
  21920. divHeight
  21921. ], m);
  21922. } else {
  21923. b = [
  21924. left,
  21925. top,
  21926. left + divWidth,
  21927. top + divHeight
  21928. ];
  21929. }
  21930. task._bounds.push({
  21931. left: b[0],
  21932. top: b[1],
  21933. right: b[2],
  21934. bottom: b[3],
  21935. div: textDiv,
  21936. size: [
  21937. divWidth,
  21938. divHeight
  21939. ],
  21940. m: m
  21941. });
  21942. }
  21943. }
  21944. function render(task) {
  21945. if (task._canceled) {
  21946. return;
  21947. }
  21948. var textLayerFrag = task._container;
  21949. var textDivs = task._textDivs;
  21950. var capability = task._capability;
  21951. var textDivsLength = textDivs.length;
  21952. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  21953. task._renderingDone = true;
  21954. capability.resolve();
  21955. return;
  21956. }
  21957. var canvas = document.createElement('canvas');
  21958. var ctx = canvas.getContext('2d', { alpha: false });
  21959. var lastFontSize;
  21960. var lastFontFamily;
  21961. for (var i = 0; i < textDivsLength; i++) {
  21962. var textDiv = textDivs[i];
  21963. var textDivProperties = task._textDivProperties.get(textDiv);
  21964. if (textDivProperties.isWhitespace) {
  21965. continue;
  21966. }
  21967. var fontSize = textDiv.style.fontSize;
  21968. var fontFamily = textDiv.style.fontFamily;
  21969. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  21970. ctx.font = fontSize + ' ' + fontFamily;
  21971. lastFontSize = fontSize;
  21972. lastFontFamily = fontFamily;
  21973. }
  21974. var width = ctx.measureText(textDiv.textContent).width;
  21975. textLayerFrag.appendChild(textDiv);
  21976. var transform = '';
  21977. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  21978. textDivProperties.scale = textDivProperties.canvasWidth / width;
  21979. transform = 'scaleX(' + textDivProperties.scale + ')';
  21980. }
  21981. if (textDivProperties.angle !== 0) {
  21982. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  21983. }
  21984. if (transform !== '') {
  21985. textDivProperties.originalTransform = transform;
  21986. CustomStyle.setProp('transform', textDiv, transform);
  21987. }
  21988. task._textDivProperties.set(textDiv, textDivProperties);
  21989. }
  21990. task._renderingDone = true;
  21991. capability.resolve();
  21992. }
  21993. function expand(task) {
  21994. var bounds = task._bounds;
  21995. var viewport = task._viewport;
  21996. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  21997. for (var i = 0; i < expanded.length; i++) {
  21998. var div = bounds[i].div;
  21999. var divProperties = task._textDivProperties.get(div);
  22000. if (divProperties.angle === 0) {
  22001. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  22002. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  22003. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  22004. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  22005. task._textDivProperties.set(div, divProperties);
  22006. continue;
  22007. }
  22008. var e = expanded[i], b = bounds[i];
  22009. var m = b.m, c = m[0], s = m[1];
  22010. var points = [
  22011. [
  22012. 0,
  22013. 0
  22014. ],
  22015. [
  22016. 0,
  22017. b.size[1]
  22018. ],
  22019. [
  22020. b.size[0],
  22021. 0
  22022. ],
  22023. b.size
  22024. ];
  22025. var ts = new Float64Array(64);
  22026. points.forEach(function (p, i) {
  22027. var t = Util.applyTransform(p, m);
  22028. ts[i + 0] = c && (e.left - t[0]) / c;
  22029. ts[i + 4] = s && (e.top - t[1]) / s;
  22030. ts[i + 8] = c && (e.right - t[0]) / c;
  22031. ts[i + 12] = s && (e.bottom - t[1]) / s;
  22032. ts[i + 16] = s && (e.left - t[0]) / -s;
  22033. ts[i + 20] = c && (e.top - t[1]) / c;
  22034. ts[i + 24] = s && (e.right - t[0]) / -s;
  22035. ts[i + 28] = c && (e.bottom - t[1]) / c;
  22036. ts[i + 32] = c && (e.left - t[0]) / -c;
  22037. ts[i + 36] = s && (e.top - t[1]) / -s;
  22038. ts[i + 40] = c && (e.right - t[0]) / -c;
  22039. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  22040. ts[i + 48] = s && (e.left - t[0]) / s;
  22041. ts[i + 52] = c && (e.top - t[1]) / -c;
  22042. ts[i + 56] = s && (e.right - t[0]) / s;
  22043. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  22044. });
  22045. var findPositiveMin = function (ts, offset, count) {
  22046. var result = 0;
  22047. for (var i = 0; i < count; i++) {
  22048. var t = ts[offset++];
  22049. if (t > 0) {
  22050. result = result ? Math.min(t, result) : t;
  22051. }
  22052. }
  22053. return result;
  22054. };
  22055. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  22056. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  22057. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  22058. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  22059. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  22060. task._textDivProperties.set(div, divProperties);
  22061. }
  22062. }
  22063. function expandBounds(width, height, boxes) {
  22064. var bounds = boxes.map(function (box, i) {
  22065. return {
  22066. x1: box.left,
  22067. y1: box.top,
  22068. x2: box.right,
  22069. y2: box.bottom,
  22070. index: i,
  22071. x1New: undefined,
  22072. x2New: undefined
  22073. };
  22074. });
  22075. expandBoundsLTR(width, bounds);
  22076. var expanded = new Array(boxes.length);
  22077. bounds.forEach(function (b) {
  22078. var i = b.index;
  22079. expanded[i] = {
  22080. left: b.x1New,
  22081. top: 0,
  22082. right: b.x2New,
  22083. bottom: 0
  22084. };
  22085. });
  22086. boxes.map(function (box, i) {
  22087. var e = expanded[i], b = bounds[i];
  22088. b.x1 = box.top;
  22089. b.y1 = width - e.right;
  22090. b.x2 = box.bottom;
  22091. b.y2 = width - e.left;
  22092. b.index = i;
  22093. b.x1New = undefined;
  22094. b.x2New = undefined;
  22095. });
  22096. expandBoundsLTR(height, bounds);
  22097. bounds.forEach(function (b) {
  22098. var i = b.index;
  22099. expanded[i].top = b.x1New;
  22100. expanded[i].bottom = b.x2New;
  22101. });
  22102. return expanded;
  22103. }
  22104. function expandBoundsLTR(width, bounds) {
  22105. bounds.sort(function (a, b) {
  22106. return a.x1 - b.x1 || a.index - b.index;
  22107. });
  22108. var fakeBoundary = {
  22109. x1: -Infinity,
  22110. y1: -Infinity,
  22111. x2: 0,
  22112. y2: Infinity,
  22113. index: -1,
  22114. x1New: 0,
  22115. x2New: 0
  22116. };
  22117. var horizon = [{
  22118. start: -Infinity,
  22119. end: Infinity,
  22120. boundary: fakeBoundary
  22121. }];
  22122. bounds.forEach(function (boundary) {
  22123. var i = 0;
  22124. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  22125. i++;
  22126. }
  22127. var j = horizon.length - 1;
  22128. while (j >= 0 && horizon[j].start >= boundary.y2) {
  22129. j--;
  22130. }
  22131. var horizonPart, affectedBoundary;
  22132. var q, k, maxXNew = -Infinity;
  22133. for (q = i; q <= j; q++) {
  22134. horizonPart = horizon[q];
  22135. affectedBoundary = horizonPart.boundary;
  22136. var xNew;
  22137. if (affectedBoundary.x2 > boundary.x1) {
  22138. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  22139. } else if (affectedBoundary.x2New === undefined) {
  22140. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  22141. } else {
  22142. xNew = affectedBoundary.x2New;
  22143. }
  22144. if (xNew > maxXNew) {
  22145. maxXNew = xNew;
  22146. }
  22147. }
  22148. boundary.x1New = maxXNew;
  22149. for (q = i; q <= j; q++) {
  22150. horizonPart = horizon[q];
  22151. affectedBoundary = horizonPart.boundary;
  22152. if (affectedBoundary.x2New === undefined) {
  22153. if (affectedBoundary.x2 > boundary.x1) {
  22154. if (affectedBoundary.index > boundary.index) {
  22155. affectedBoundary.x2New = affectedBoundary.x2;
  22156. }
  22157. } else {
  22158. affectedBoundary.x2New = maxXNew;
  22159. }
  22160. } else if (affectedBoundary.x2New > maxXNew) {
  22161. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  22162. }
  22163. }
  22164. var changedHorizon = [], lastBoundary = null;
  22165. for (q = i; q <= j; q++) {
  22166. horizonPart = horizon[q];
  22167. affectedBoundary = horizonPart.boundary;
  22168. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  22169. if (lastBoundary === useBoundary) {
  22170. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  22171. } else {
  22172. changedHorizon.push({
  22173. start: horizonPart.start,
  22174. end: horizonPart.end,
  22175. boundary: useBoundary
  22176. });
  22177. lastBoundary = useBoundary;
  22178. }
  22179. }
  22180. if (horizon[i].start < boundary.y1) {
  22181. changedHorizon[0].start = boundary.y1;
  22182. changedHorizon.unshift({
  22183. start: horizon[i].start,
  22184. end: boundary.y1,
  22185. boundary: horizon[i].boundary
  22186. });
  22187. }
  22188. if (boundary.y2 < horizon[j].end) {
  22189. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  22190. changedHorizon.push({
  22191. start: boundary.y2,
  22192. end: horizon[j].end,
  22193. boundary: horizon[j].boundary
  22194. });
  22195. }
  22196. for (q = i; q <= j; q++) {
  22197. horizonPart = horizon[q];
  22198. affectedBoundary = horizonPart.boundary;
  22199. if (affectedBoundary.x2New !== undefined) {
  22200. continue;
  22201. }
  22202. var used = false;
  22203. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  22204. used = horizon[k].boundary === affectedBoundary;
  22205. }
  22206. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  22207. used = horizon[k].boundary === affectedBoundary;
  22208. }
  22209. for (k = 0; !used && k < changedHorizon.length; k++) {
  22210. used = changedHorizon[k].boundary === affectedBoundary;
  22211. }
  22212. if (!used) {
  22213. affectedBoundary.x2New = maxXNew;
  22214. }
  22215. }
  22216. Array.prototype.splice.apply(horizon, [
  22217. i,
  22218. j - i + 1
  22219. ].concat(changedHorizon));
  22220. });
  22221. horizon.forEach(function (horizonPart) {
  22222. var affectedBoundary = horizonPart.boundary;
  22223. if (affectedBoundary.x2New === undefined) {
  22224. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  22225. }
  22226. });
  22227. }
  22228. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  22229. this._textContent = textContent;
  22230. this._container = container;
  22231. this._viewport = viewport;
  22232. this._textDivs = textDivs || [];
  22233. this._textDivProperties = new WeakMap();
  22234. this._renderingDone = false;
  22235. this._canceled = false;
  22236. this._capability = createPromiseCapability();
  22237. this._renderTimer = null;
  22238. this._bounds = [];
  22239. this._enhanceTextSelection = !!enhanceTextSelection;
  22240. }
  22241. TextLayerRenderTask.prototype = {
  22242. get promise() {
  22243. return this._capability.promise;
  22244. },
  22245. cancel: function TextLayer_cancel() {
  22246. this._canceled = true;
  22247. if (this._renderTimer !== null) {
  22248. clearTimeout(this._renderTimer);
  22249. this._renderTimer = null;
  22250. }
  22251. this._capability.reject('canceled');
  22252. },
  22253. _render: function TextLayer_render(timeout) {
  22254. var textItems = this._textContent.items;
  22255. var textStyles = this._textContent.styles;
  22256. for (var i = 0, len = textItems.length; i < len; i++) {
  22257. appendText(this, textItems[i], textStyles);
  22258. }
  22259. if (!timeout) {
  22260. render(this);
  22261. } else {
  22262. var self = this;
  22263. this._renderTimer = setTimeout(function () {
  22264. render(self);
  22265. self._renderTimer = null;
  22266. }, timeout);
  22267. }
  22268. },
  22269. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  22270. if (!this._enhanceTextSelection || !this._renderingDone) {
  22271. return;
  22272. }
  22273. if (this._bounds !== null) {
  22274. expand(this);
  22275. this._bounds = null;
  22276. }
  22277. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  22278. var div = this._textDivs[i];
  22279. var divProperties = this._textDivProperties.get(div);
  22280. if (divProperties.isWhitespace) {
  22281. continue;
  22282. }
  22283. if (expandDivs) {
  22284. var transform = '', padding = '';
  22285. if (divProperties.scale !== 1) {
  22286. transform = 'scaleX(' + divProperties.scale + ')';
  22287. }
  22288. if (divProperties.angle !== 0) {
  22289. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  22290. }
  22291. if (divProperties.paddingLeft !== 0) {
  22292. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  22293. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  22294. }
  22295. if (divProperties.paddingTop !== 0) {
  22296. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  22297. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  22298. }
  22299. if (divProperties.paddingRight !== 0) {
  22300. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  22301. }
  22302. if (divProperties.paddingBottom !== 0) {
  22303. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  22304. }
  22305. if (padding !== '') {
  22306. div.setAttribute('style', divProperties.style + padding);
  22307. }
  22308. if (transform !== '') {
  22309. CustomStyle.setProp('transform', div, transform);
  22310. }
  22311. } else {
  22312. div.style.padding = 0;
  22313. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  22314. }
  22315. }
  22316. }
  22317. };
  22318. function renderTextLayer(renderParameters) {
  22319. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  22320. task._render(renderParameters.timeout);
  22321. return task;
  22322. }
  22323. return renderTextLayer;
  22324. }();
  22325. exports.renderTextLayer = renderTextLayer;
  22326. /***/ }),
  22327. /* 13 */
  22328. /***/ (function(module, exports, __w_pdfjs_require__) {
  22329. "use strict";
  22330. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  22331. var QeTable = [
  22332. {
  22333. qe: 0x5601,
  22334. nmps: 1,
  22335. nlps: 1,
  22336. switchFlag: 1
  22337. },
  22338. {
  22339. qe: 0x3401,
  22340. nmps: 2,
  22341. nlps: 6,
  22342. switchFlag: 0
  22343. },
  22344. {
  22345. qe: 0x1801,
  22346. nmps: 3,
  22347. nlps: 9,
  22348. switchFlag: 0
  22349. },
  22350. {
  22351. qe: 0x0AC1,
  22352. nmps: 4,
  22353. nlps: 12,
  22354. switchFlag: 0
  22355. },
  22356. {
  22357. qe: 0x0521,
  22358. nmps: 5,
  22359. nlps: 29,
  22360. switchFlag: 0
  22361. },
  22362. {
  22363. qe: 0x0221,
  22364. nmps: 38,
  22365. nlps: 33,
  22366. switchFlag: 0
  22367. },
  22368. {
  22369. qe: 0x5601,
  22370. nmps: 7,
  22371. nlps: 6,
  22372. switchFlag: 1
  22373. },
  22374. {
  22375. qe: 0x5401,
  22376. nmps: 8,
  22377. nlps: 14,
  22378. switchFlag: 0
  22379. },
  22380. {
  22381. qe: 0x4801,
  22382. nmps: 9,
  22383. nlps: 14,
  22384. switchFlag: 0
  22385. },
  22386. {
  22387. qe: 0x3801,
  22388. nmps: 10,
  22389. nlps: 14,
  22390. switchFlag: 0
  22391. },
  22392. {
  22393. qe: 0x3001,
  22394. nmps: 11,
  22395. nlps: 17,
  22396. switchFlag: 0
  22397. },
  22398. {
  22399. qe: 0x2401,
  22400. nmps: 12,
  22401. nlps: 18,
  22402. switchFlag: 0
  22403. },
  22404. {
  22405. qe: 0x1C01,
  22406. nmps: 13,
  22407. nlps: 20,
  22408. switchFlag: 0
  22409. },
  22410. {
  22411. qe: 0x1601,
  22412. nmps: 29,
  22413. nlps: 21,
  22414. switchFlag: 0
  22415. },
  22416. {
  22417. qe: 0x5601,
  22418. nmps: 15,
  22419. nlps: 14,
  22420. switchFlag: 1
  22421. },
  22422. {
  22423. qe: 0x5401,
  22424. nmps: 16,
  22425. nlps: 14,
  22426. switchFlag: 0
  22427. },
  22428. {
  22429. qe: 0x5101,
  22430. nmps: 17,
  22431. nlps: 15,
  22432. switchFlag: 0
  22433. },
  22434. {
  22435. qe: 0x4801,
  22436. nmps: 18,
  22437. nlps: 16,
  22438. switchFlag: 0
  22439. },
  22440. {
  22441. qe: 0x3801,
  22442. nmps: 19,
  22443. nlps: 17,
  22444. switchFlag: 0
  22445. },
  22446. {
  22447. qe: 0x3401,
  22448. nmps: 20,
  22449. nlps: 18,
  22450. switchFlag: 0
  22451. },
  22452. {
  22453. qe: 0x3001,
  22454. nmps: 21,
  22455. nlps: 19,
  22456. switchFlag: 0
  22457. },
  22458. {
  22459. qe: 0x2801,
  22460. nmps: 22,
  22461. nlps: 19,
  22462. switchFlag: 0
  22463. },
  22464. {
  22465. qe: 0x2401,
  22466. nmps: 23,
  22467. nlps: 20,
  22468. switchFlag: 0
  22469. },
  22470. {
  22471. qe: 0x2201,
  22472. nmps: 24,
  22473. nlps: 21,
  22474. switchFlag: 0
  22475. },
  22476. {
  22477. qe: 0x1C01,
  22478. nmps: 25,
  22479. nlps: 22,
  22480. switchFlag: 0
  22481. },
  22482. {
  22483. qe: 0x1801,
  22484. nmps: 26,
  22485. nlps: 23,
  22486. switchFlag: 0
  22487. },
  22488. {
  22489. qe: 0x1601,
  22490. nmps: 27,
  22491. nlps: 24,
  22492. switchFlag: 0
  22493. },
  22494. {
  22495. qe: 0x1401,
  22496. nmps: 28,
  22497. nlps: 25,
  22498. switchFlag: 0
  22499. },
  22500. {
  22501. qe: 0x1201,
  22502. nmps: 29,
  22503. nlps: 26,
  22504. switchFlag: 0
  22505. },
  22506. {
  22507. qe: 0x1101,
  22508. nmps: 30,
  22509. nlps: 27,
  22510. switchFlag: 0
  22511. },
  22512. {
  22513. qe: 0x0AC1,
  22514. nmps: 31,
  22515. nlps: 28,
  22516. switchFlag: 0
  22517. },
  22518. {
  22519. qe: 0x09C1,
  22520. nmps: 32,
  22521. nlps: 29,
  22522. switchFlag: 0
  22523. },
  22524. {
  22525. qe: 0x08A1,
  22526. nmps: 33,
  22527. nlps: 30,
  22528. switchFlag: 0
  22529. },
  22530. {
  22531. qe: 0x0521,
  22532. nmps: 34,
  22533. nlps: 31,
  22534. switchFlag: 0
  22535. },
  22536. {
  22537. qe: 0x0441,
  22538. nmps: 35,
  22539. nlps: 32,
  22540. switchFlag: 0
  22541. },
  22542. {
  22543. qe: 0x02A1,
  22544. nmps: 36,
  22545. nlps: 33,
  22546. switchFlag: 0
  22547. },
  22548. {
  22549. qe: 0x0221,
  22550. nmps: 37,
  22551. nlps: 34,
  22552. switchFlag: 0
  22553. },
  22554. {
  22555. qe: 0x0141,
  22556. nmps: 38,
  22557. nlps: 35,
  22558. switchFlag: 0
  22559. },
  22560. {
  22561. qe: 0x0111,
  22562. nmps: 39,
  22563. nlps: 36,
  22564. switchFlag: 0
  22565. },
  22566. {
  22567. qe: 0x0085,
  22568. nmps: 40,
  22569. nlps: 37,
  22570. switchFlag: 0
  22571. },
  22572. {
  22573. qe: 0x0049,
  22574. nmps: 41,
  22575. nlps: 38,
  22576. switchFlag: 0
  22577. },
  22578. {
  22579. qe: 0x0025,
  22580. nmps: 42,
  22581. nlps: 39,
  22582. switchFlag: 0
  22583. },
  22584. {
  22585. qe: 0x0015,
  22586. nmps: 43,
  22587. nlps: 40,
  22588. switchFlag: 0
  22589. },
  22590. {
  22591. qe: 0x0009,
  22592. nmps: 44,
  22593. nlps: 41,
  22594. switchFlag: 0
  22595. },
  22596. {
  22597. qe: 0x0005,
  22598. nmps: 45,
  22599. nlps: 42,
  22600. switchFlag: 0
  22601. },
  22602. {
  22603. qe: 0x0001,
  22604. nmps: 45,
  22605. nlps: 43,
  22606. switchFlag: 0
  22607. },
  22608. {
  22609. qe: 0x5601,
  22610. nmps: 46,
  22611. nlps: 46,
  22612. switchFlag: 0
  22613. }
  22614. ];
  22615. function ArithmeticDecoder(data, start, end) {
  22616. this.data = data;
  22617. this.bp = start;
  22618. this.dataEnd = end;
  22619. this.chigh = data[start];
  22620. this.clow = 0;
  22621. this.byteIn();
  22622. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  22623. this.clow = this.clow << 7 & 0xFFFF;
  22624. this.ct -= 7;
  22625. this.a = 0x8000;
  22626. }
  22627. ArithmeticDecoder.prototype = {
  22628. byteIn: function ArithmeticDecoder_byteIn() {
  22629. var data = this.data;
  22630. var bp = this.bp;
  22631. if (data[bp] === 0xFF) {
  22632. var b1 = data[bp + 1];
  22633. if (b1 > 0x8F) {
  22634. this.clow += 0xFF00;
  22635. this.ct = 8;
  22636. } else {
  22637. bp++;
  22638. this.clow += data[bp] << 9;
  22639. this.ct = 7;
  22640. this.bp = bp;
  22641. }
  22642. } else {
  22643. bp++;
  22644. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  22645. this.ct = 8;
  22646. this.bp = bp;
  22647. }
  22648. if (this.clow > 0xFFFF) {
  22649. this.chigh += this.clow >> 16;
  22650. this.clow &= 0xFFFF;
  22651. }
  22652. },
  22653. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  22654. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  22655. var qeTableIcx = QeTable[cx_index];
  22656. var qeIcx = qeTableIcx.qe;
  22657. var d;
  22658. var a = this.a - qeIcx;
  22659. if (this.chigh < qeIcx) {
  22660. if (a < qeIcx) {
  22661. a = qeIcx;
  22662. d = cx_mps;
  22663. cx_index = qeTableIcx.nmps;
  22664. } else {
  22665. a = qeIcx;
  22666. d = 1 ^ cx_mps;
  22667. if (qeTableIcx.switchFlag === 1) {
  22668. cx_mps = d;
  22669. }
  22670. cx_index = qeTableIcx.nlps;
  22671. }
  22672. } else {
  22673. this.chigh -= qeIcx;
  22674. if ((a & 0x8000) !== 0) {
  22675. this.a = a;
  22676. return cx_mps;
  22677. }
  22678. if (a < qeIcx) {
  22679. d = 1 ^ cx_mps;
  22680. if (qeTableIcx.switchFlag === 1) {
  22681. cx_mps = d;
  22682. }
  22683. cx_index = qeTableIcx.nlps;
  22684. } else {
  22685. d = cx_mps;
  22686. cx_index = qeTableIcx.nmps;
  22687. }
  22688. }
  22689. do {
  22690. if (this.ct === 0) {
  22691. this.byteIn();
  22692. }
  22693. a <<= 1;
  22694. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  22695. this.clow = this.clow << 1 & 0xFFFF;
  22696. this.ct--;
  22697. } while ((a & 0x8000) === 0);
  22698. this.a = a;
  22699. contexts[pos] = cx_index << 1 | cx_mps;
  22700. return d;
  22701. }
  22702. };
  22703. return ArithmeticDecoder;
  22704. }();
  22705. exports.ArithmeticDecoder = ArithmeticDecoder;
  22706. /***/ }),
  22707. /* 14 */
  22708. /***/ (function(module, exports, __w_pdfjs_require__) {
  22709. "use strict";
  22710. var sharedUtil = __w_pdfjs_require__(0);
  22711. var coreCharsets = __w_pdfjs_require__(29);
  22712. var coreEncodings = __w_pdfjs_require__(5);
  22713. var error = sharedUtil.error;
  22714. var info = sharedUtil.info;
  22715. var bytesToString = sharedUtil.bytesToString;
  22716. var warn = sharedUtil.warn;
  22717. var isArray = sharedUtil.isArray;
  22718. var Util = sharedUtil.Util;
  22719. var stringToBytes = sharedUtil.stringToBytes;
  22720. var assert = sharedUtil.assert;
  22721. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  22722. var ExpertCharset = coreCharsets.ExpertCharset;
  22723. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  22724. var StandardEncoding = coreEncodings.StandardEncoding;
  22725. var ExpertEncoding = coreEncodings.ExpertEncoding;
  22726. var MAX_SUBR_NESTING = 10;
  22727. var CFFStandardStrings = [
  22728. '.notdef',
  22729. 'space',
  22730. 'exclam',
  22731. 'quotedbl',
  22732. 'numbersign',
  22733. 'dollar',
  22734. 'percent',
  22735. 'ampersand',
  22736. 'quoteright',
  22737. 'parenleft',
  22738. 'parenright',
  22739. 'asterisk',
  22740. 'plus',
  22741. 'comma',
  22742. 'hyphen',
  22743. 'period',
  22744. 'slash',
  22745. 'zero',
  22746. 'one',
  22747. 'two',
  22748. 'three',
  22749. 'four',
  22750. 'five',
  22751. 'six',
  22752. 'seven',
  22753. 'eight',
  22754. 'nine',
  22755. 'colon',
  22756. 'semicolon',
  22757. 'less',
  22758. 'equal',
  22759. 'greater',
  22760. 'question',
  22761. 'at',
  22762. 'A',
  22763. 'B',
  22764. 'C',
  22765. 'D',
  22766. 'E',
  22767. 'F',
  22768. 'G',
  22769. 'H',
  22770. 'I',
  22771. 'J',
  22772. 'K',
  22773. 'L',
  22774. 'M',
  22775. 'N',
  22776. 'O',
  22777. 'P',
  22778. 'Q',
  22779. 'R',
  22780. 'S',
  22781. 'T',
  22782. 'U',
  22783. 'V',
  22784. 'W',
  22785. 'X',
  22786. 'Y',
  22787. 'Z',
  22788. 'bracketleft',
  22789. 'backslash',
  22790. 'bracketright',
  22791. 'asciicircum',
  22792. 'underscore',
  22793. 'quoteleft',
  22794. 'a',
  22795. 'b',
  22796. 'c',
  22797. 'd',
  22798. 'e',
  22799. 'f',
  22800. 'g',
  22801. 'h',
  22802. 'i',
  22803. 'j',
  22804. 'k',
  22805. 'l',
  22806. 'm',
  22807. 'n',
  22808. 'o',
  22809. 'p',
  22810. 'q',
  22811. 'r',
  22812. 's',
  22813. 't',
  22814. 'u',
  22815. 'v',
  22816. 'w',
  22817. 'x',
  22818. 'y',
  22819. 'z',
  22820. 'braceleft',
  22821. 'bar',
  22822. 'braceright',
  22823. 'asciitilde',
  22824. 'exclamdown',
  22825. 'cent',
  22826. 'sterling',
  22827. 'fraction',
  22828. 'yen',
  22829. 'florin',
  22830. 'section',
  22831. 'currency',
  22832. 'quotesingle',
  22833. 'quotedblleft',
  22834. 'guillemotleft',
  22835. 'guilsinglleft',
  22836. 'guilsinglright',
  22837. 'fi',
  22838. 'fl',
  22839. 'endash',
  22840. 'dagger',
  22841. 'daggerdbl',
  22842. 'periodcentered',
  22843. 'paragraph',
  22844. 'bullet',
  22845. 'quotesinglbase',
  22846. 'quotedblbase',
  22847. 'quotedblright',
  22848. 'guillemotright',
  22849. 'ellipsis',
  22850. 'perthousand',
  22851. 'questiondown',
  22852. 'grave',
  22853. 'acute',
  22854. 'circumflex',
  22855. 'tilde',
  22856. 'macron',
  22857. 'breve',
  22858. 'dotaccent',
  22859. 'dieresis',
  22860. 'ring',
  22861. 'cedilla',
  22862. 'hungarumlaut',
  22863. 'ogonek',
  22864. 'caron',
  22865. 'emdash',
  22866. 'AE',
  22867. 'ordfeminine',
  22868. 'Lslash',
  22869. 'Oslash',
  22870. 'OE',
  22871. 'ordmasculine',
  22872. 'ae',
  22873. 'dotlessi',
  22874. 'lslash',
  22875. 'oslash',
  22876. 'oe',
  22877. 'germandbls',
  22878. 'onesuperior',
  22879. 'logicalnot',
  22880. 'mu',
  22881. 'trademark',
  22882. 'Eth',
  22883. 'onehalf',
  22884. 'plusminus',
  22885. 'Thorn',
  22886. 'onequarter',
  22887. 'divide',
  22888. 'brokenbar',
  22889. 'degree',
  22890. 'thorn',
  22891. 'threequarters',
  22892. 'twosuperior',
  22893. 'registered',
  22894. 'minus',
  22895. 'eth',
  22896. 'multiply',
  22897. 'threesuperior',
  22898. 'copyright',
  22899. 'Aacute',
  22900. 'Acircumflex',
  22901. 'Adieresis',
  22902. 'Agrave',
  22903. 'Aring',
  22904. 'Atilde',
  22905. 'Ccedilla',
  22906. 'Eacute',
  22907. 'Ecircumflex',
  22908. 'Edieresis',
  22909. 'Egrave',
  22910. 'Iacute',
  22911. 'Icircumflex',
  22912. 'Idieresis',
  22913. 'Igrave',
  22914. 'Ntilde',
  22915. 'Oacute',
  22916. 'Ocircumflex',
  22917. 'Odieresis',
  22918. 'Ograve',
  22919. 'Otilde',
  22920. 'Scaron',
  22921. 'Uacute',
  22922. 'Ucircumflex',
  22923. 'Udieresis',
  22924. 'Ugrave',
  22925. 'Yacute',
  22926. 'Ydieresis',
  22927. 'Zcaron',
  22928. 'aacute',
  22929. 'acircumflex',
  22930. 'adieresis',
  22931. 'agrave',
  22932. 'aring',
  22933. 'atilde',
  22934. 'ccedilla',
  22935. 'eacute',
  22936. 'ecircumflex',
  22937. 'edieresis',
  22938. 'egrave',
  22939. 'iacute',
  22940. 'icircumflex',
  22941. 'idieresis',
  22942. 'igrave',
  22943. 'ntilde',
  22944. 'oacute',
  22945. 'ocircumflex',
  22946. 'odieresis',
  22947. 'ograve',
  22948. 'otilde',
  22949. 'scaron',
  22950. 'uacute',
  22951. 'ucircumflex',
  22952. 'udieresis',
  22953. 'ugrave',
  22954. 'yacute',
  22955. 'ydieresis',
  22956. 'zcaron',
  22957. 'exclamsmall',
  22958. 'Hungarumlautsmall',
  22959. 'dollaroldstyle',
  22960. 'dollarsuperior',
  22961. 'ampersandsmall',
  22962. 'Acutesmall',
  22963. 'parenleftsuperior',
  22964. 'parenrightsuperior',
  22965. 'twodotenleader',
  22966. 'onedotenleader',
  22967. 'zerooldstyle',
  22968. 'oneoldstyle',
  22969. 'twooldstyle',
  22970. 'threeoldstyle',
  22971. 'fouroldstyle',
  22972. 'fiveoldstyle',
  22973. 'sixoldstyle',
  22974. 'sevenoldstyle',
  22975. 'eightoldstyle',
  22976. 'nineoldstyle',
  22977. 'commasuperior',
  22978. 'threequartersemdash',
  22979. 'periodsuperior',
  22980. 'questionsmall',
  22981. 'asuperior',
  22982. 'bsuperior',
  22983. 'centsuperior',
  22984. 'dsuperior',
  22985. 'esuperior',
  22986. 'isuperior',
  22987. 'lsuperior',
  22988. 'msuperior',
  22989. 'nsuperior',
  22990. 'osuperior',
  22991. 'rsuperior',
  22992. 'ssuperior',
  22993. 'tsuperior',
  22994. 'ff',
  22995. 'ffi',
  22996. 'ffl',
  22997. 'parenleftinferior',
  22998. 'parenrightinferior',
  22999. 'Circumflexsmall',
  23000. 'hyphensuperior',
  23001. 'Gravesmall',
  23002. 'Asmall',
  23003. 'Bsmall',
  23004. 'Csmall',
  23005. 'Dsmall',
  23006. 'Esmall',
  23007. 'Fsmall',
  23008. 'Gsmall',
  23009. 'Hsmall',
  23010. 'Ismall',
  23011. 'Jsmall',
  23012. 'Ksmall',
  23013. 'Lsmall',
  23014. 'Msmall',
  23015. 'Nsmall',
  23016. 'Osmall',
  23017. 'Psmall',
  23018. 'Qsmall',
  23019. 'Rsmall',
  23020. 'Ssmall',
  23021. 'Tsmall',
  23022. 'Usmall',
  23023. 'Vsmall',
  23024. 'Wsmall',
  23025. 'Xsmall',
  23026. 'Ysmall',
  23027. 'Zsmall',
  23028. 'colonmonetary',
  23029. 'onefitted',
  23030. 'rupiah',
  23031. 'Tildesmall',
  23032. 'exclamdownsmall',
  23033. 'centoldstyle',
  23034. 'Lslashsmall',
  23035. 'Scaronsmall',
  23036. 'Zcaronsmall',
  23037. 'Dieresissmall',
  23038. 'Brevesmall',
  23039. 'Caronsmall',
  23040. 'Dotaccentsmall',
  23041. 'Macronsmall',
  23042. 'figuredash',
  23043. 'hypheninferior',
  23044. 'Ogoneksmall',
  23045. 'Ringsmall',
  23046. 'Cedillasmall',
  23047. 'questiondownsmall',
  23048. 'oneeighth',
  23049. 'threeeighths',
  23050. 'fiveeighths',
  23051. 'seveneighths',
  23052. 'onethird',
  23053. 'twothirds',
  23054. 'zerosuperior',
  23055. 'foursuperior',
  23056. 'fivesuperior',
  23057. 'sixsuperior',
  23058. 'sevensuperior',
  23059. 'eightsuperior',
  23060. 'ninesuperior',
  23061. 'zeroinferior',
  23062. 'oneinferior',
  23063. 'twoinferior',
  23064. 'threeinferior',
  23065. 'fourinferior',
  23066. 'fiveinferior',
  23067. 'sixinferior',
  23068. 'seveninferior',
  23069. 'eightinferior',
  23070. 'nineinferior',
  23071. 'centinferior',
  23072. 'dollarinferior',
  23073. 'periodinferior',
  23074. 'commainferior',
  23075. 'Agravesmall',
  23076. 'Aacutesmall',
  23077. 'Acircumflexsmall',
  23078. 'Atildesmall',
  23079. 'Adieresissmall',
  23080. 'Aringsmall',
  23081. 'AEsmall',
  23082. 'Ccedillasmall',
  23083. 'Egravesmall',
  23084. 'Eacutesmall',
  23085. 'Ecircumflexsmall',
  23086. 'Edieresissmall',
  23087. 'Igravesmall',
  23088. 'Iacutesmall',
  23089. 'Icircumflexsmall',
  23090. 'Idieresissmall',
  23091. 'Ethsmall',
  23092. 'Ntildesmall',
  23093. 'Ogravesmall',
  23094. 'Oacutesmall',
  23095. 'Ocircumflexsmall',
  23096. 'Otildesmall',
  23097. 'Odieresissmall',
  23098. 'OEsmall',
  23099. 'Oslashsmall',
  23100. 'Ugravesmall',
  23101. 'Uacutesmall',
  23102. 'Ucircumflexsmall',
  23103. 'Udieresissmall',
  23104. 'Yacutesmall',
  23105. 'Thornsmall',
  23106. 'Ydieresissmall',
  23107. '001.000',
  23108. '001.001',
  23109. '001.002',
  23110. '001.003',
  23111. 'Black',
  23112. 'Bold',
  23113. 'Book',
  23114. 'Light',
  23115. 'Medium',
  23116. 'Regular',
  23117. 'Roman',
  23118. 'Semibold'
  23119. ];
  23120. var CFFParser = function CFFParserClosure() {
  23121. var CharstringValidationData = [
  23122. null,
  23123. {
  23124. id: 'hstem',
  23125. min: 2,
  23126. stackClearing: true,
  23127. stem: true
  23128. },
  23129. null,
  23130. {
  23131. id: 'vstem',
  23132. min: 2,
  23133. stackClearing: true,
  23134. stem: true
  23135. },
  23136. {
  23137. id: 'vmoveto',
  23138. min: 1,
  23139. stackClearing: true
  23140. },
  23141. {
  23142. id: 'rlineto',
  23143. min: 2,
  23144. resetStack: true
  23145. },
  23146. {
  23147. id: 'hlineto',
  23148. min: 1,
  23149. resetStack: true
  23150. },
  23151. {
  23152. id: 'vlineto',
  23153. min: 1,
  23154. resetStack: true
  23155. },
  23156. {
  23157. id: 'rrcurveto',
  23158. min: 6,
  23159. resetStack: true
  23160. },
  23161. null,
  23162. {
  23163. id: 'callsubr',
  23164. min: 1,
  23165. undefStack: true
  23166. },
  23167. {
  23168. id: 'return',
  23169. min: 0,
  23170. undefStack: true
  23171. },
  23172. null,
  23173. null,
  23174. {
  23175. id: 'endchar',
  23176. min: 0,
  23177. stackClearing: true
  23178. },
  23179. null,
  23180. null,
  23181. null,
  23182. {
  23183. id: 'hstemhm',
  23184. min: 2,
  23185. stackClearing: true,
  23186. stem: true
  23187. },
  23188. {
  23189. id: 'hintmask',
  23190. min: 0,
  23191. stackClearing: true
  23192. },
  23193. {
  23194. id: 'cntrmask',
  23195. min: 0,
  23196. stackClearing: true
  23197. },
  23198. {
  23199. id: 'rmoveto',
  23200. min: 2,
  23201. stackClearing: true
  23202. },
  23203. {
  23204. id: 'hmoveto',
  23205. min: 1,
  23206. stackClearing: true
  23207. },
  23208. {
  23209. id: 'vstemhm',
  23210. min: 2,
  23211. stackClearing: true,
  23212. stem: true
  23213. },
  23214. {
  23215. id: 'rcurveline',
  23216. min: 8,
  23217. resetStack: true
  23218. },
  23219. {
  23220. id: 'rlinecurve',
  23221. min: 8,
  23222. resetStack: true
  23223. },
  23224. {
  23225. id: 'vvcurveto',
  23226. min: 4,
  23227. resetStack: true
  23228. },
  23229. {
  23230. id: 'hhcurveto',
  23231. min: 4,
  23232. resetStack: true
  23233. },
  23234. null,
  23235. {
  23236. id: 'callgsubr',
  23237. min: 1,
  23238. undefStack: true
  23239. },
  23240. {
  23241. id: 'vhcurveto',
  23242. min: 4,
  23243. resetStack: true
  23244. },
  23245. {
  23246. id: 'hvcurveto',
  23247. min: 4,
  23248. resetStack: true
  23249. }
  23250. ];
  23251. var CharstringValidationData12 = [
  23252. null,
  23253. null,
  23254. null,
  23255. {
  23256. id: 'and',
  23257. min: 2,
  23258. stackDelta: -1
  23259. },
  23260. {
  23261. id: 'or',
  23262. min: 2,
  23263. stackDelta: -1
  23264. },
  23265. {
  23266. id: 'not',
  23267. min: 1,
  23268. stackDelta: 0
  23269. },
  23270. null,
  23271. null,
  23272. null,
  23273. {
  23274. id: 'abs',
  23275. min: 1,
  23276. stackDelta: 0
  23277. },
  23278. {
  23279. id: 'add',
  23280. min: 2,
  23281. stackDelta: -1,
  23282. stackFn: function stack_div(stack, index) {
  23283. stack[index - 2] = stack[index - 2] + stack[index - 1];
  23284. }
  23285. },
  23286. {
  23287. id: 'sub',
  23288. min: 2,
  23289. stackDelta: -1,
  23290. stackFn: function stack_div(stack, index) {
  23291. stack[index - 2] = stack[index - 2] - stack[index - 1];
  23292. }
  23293. },
  23294. {
  23295. id: 'div',
  23296. min: 2,
  23297. stackDelta: -1,
  23298. stackFn: function stack_div(stack, index) {
  23299. stack[index - 2] = stack[index - 2] / stack[index - 1];
  23300. }
  23301. },
  23302. null,
  23303. {
  23304. id: 'neg',
  23305. min: 1,
  23306. stackDelta: 0,
  23307. stackFn: function stack_div(stack, index) {
  23308. stack[index - 1] = -stack[index - 1];
  23309. }
  23310. },
  23311. {
  23312. id: 'eq',
  23313. min: 2,
  23314. stackDelta: -1
  23315. },
  23316. null,
  23317. null,
  23318. {
  23319. id: 'drop',
  23320. min: 1,
  23321. stackDelta: -1
  23322. },
  23323. null,
  23324. {
  23325. id: 'put',
  23326. min: 2,
  23327. stackDelta: -2
  23328. },
  23329. {
  23330. id: 'get',
  23331. min: 1,
  23332. stackDelta: 0
  23333. },
  23334. {
  23335. id: 'ifelse',
  23336. min: 4,
  23337. stackDelta: -3
  23338. },
  23339. {
  23340. id: 'random',
  23341. min: 0,
  23342. stackDelta: 1
  23343. },
  23344. {
  23345. id: 'mul',
  23346. min: 2,
  23347. stackDelta: -1,
  23348. stackFn: function stack_div(stack, index) {
  23349. stack[index - 2] = stack[index - 2] * stack[index - 1];
  23350. }
  23351. },
  23352. null,
  23353. {
  23354. id: 'sqrt',
  23355. min: 1,
  23356. stackDelta: 0
  23357. },
  23358. {
  23359. id: 'dup',
  23360. min: 1,
  23361. stackDelta: 1
  23362. },
  23363. {
  23364. id: 'exch',
  23365. min: 2,
  23366. stackDelta: 0
  23367. },
  23368. {
  23369. id: 'index',
  23370. min: 2,
  23371. stackDelta: 0
  23372. },
  23373. {
  23374. id: 'roll',
  23375. min: 3,
  23376. stackDelta: -2
  23377. },
  23378. null,
  23379. null,
  23380. null,
  23381. {
  23382. id: 'hflex',
  23383. min: 7,
  23384. resetStack: true
  23385. },
  23386. {
  23387. id: 'flex',
  23388. min: 13,
  23389. resetStack: true
  23390. },
  23391. {
  23392. id: 'hflex1',
  23393. min: 9,
  23394. resetStack: true
  23395. },
  23396. {
  23397. id: 'flex1',
  23398. min: 11,
  23399. resetStack: true
  23400. }
  23401. ];
  23402. function CFFParser(file, properties, seacAnalysisEnabled) {
  23403. this.bytes = file.getBytes();
  23404. this.properties = properties;
  23405. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  23406. }
  23407. CFFParser.prototype = {
  23408. parse: function CFFParser_parse() {
  23409. var properties = this.properties;
  23410. var cff = new CFF();
  23411. this.cff = cff;
  23412. var header = this.parseHeader();
  23413. var nameIndex = this.parseIndex(header.endPos);
  23414. var topDictIndex = this.parseIndex(nameIndex.endPos);
  23415. var stringIndex = this.parseIndex(topDictIndex.endPos);
  23416. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  23417. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  23418. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  23419. cff.header = header.obj;
  23420. cff.names = this.parseNameIndex(nameIndex.obj);
  23421. cff.strings = this.parseStringIndex(stringIndex.obj);
  23422. cff.topDict = topDict;
  23423. cff.globalSubrIndex = globalSubrIndex.obj;
  23424. this.parsePrivateDict(cff.topDict);
  23425. cff.isCIDFont = topDict.hasName('ROS');
  23426. var charStringOffset = topDict.getByName('CharStrings');
  23427. var charStringIndex = this.parseIndex(charStringOffset).obj;
  23428. var fontMatrix = topDict.getByName('FontMatrix');
  23429. if (fontMatrix) {
  23430. properties.fontMatrix = fontMatrix;
  23431. }
  23432. var fontBBox = topDict.getByName('FontBBox');
  23433. if (fontBBox) {
  23434. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  23435. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  23436. properties.ascentScaled = true;
  23437. }
  23438. var charset, encoding;
  23439. if (cff.isCIDFont) {
  23440. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  23441. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  23442. var dictRaw = fdArrayIndex.get(i);
  23443. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  23444. this.parsePrivateDict(fontDict);
  23445. cff.fdArray.push(fontDict);
  23446. }
  23447. encoding = null;
  23448. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  23449. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  23450. } else {
  23451. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  23452. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  23453. }
  23454. cff.charset = charset;
  23455. cff.encoding = encoding;
  23456. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  23457. cff.charStrings = charStringsAndSeacs.charStrings;
  23458. cff.seacs = charStringsAndSeacs.seacs;
  23459. cff.widths = charStringsAndSeacs.widths;
  23460. return cff;
  23461. },
  23462. parseHeader: function CFFParser_parseHeader() {
  23463. var bytes = this.bytes;
  23464. var bytesLength = bytes.length;
  23465. var offset = 0;
  23466. while (offset < bytesLength && bytes[offset] !== 1) {
  23467. ++offset;
  23468. }
  23469. if (offset >= bytesLength) {
  23470. error('Invalid CFF header');
  23471. } else if (offset !== 0) {
  23472. info('cff data is shifted');
  23473. bytes = bytes.subarray(offset);
  23474. this.bytes = bytes;
  23475. }
  23476. var major = bytes[0];
  23477. var minor = bytes[1];
  23478. var hdrSize = bytes[2];
  23479. var offSize = bytes[3];
  23480. var header = new CFFHeader(major, minor, hdrSize, offSize);
  23481. return {
  23482. obj: header,
  23483. endPos: hdrSize
  23484. };
  23485. },
  23486. parseDict: function CFFParser_parseDict(dict) {
  23487. var pos = 0;
  23488. function parseOperand() {
  23489. var value = dict[pos++];
  23490. if (value === 30) {
  23491. return parseFloatOperand();
  23492. } else if (value === 28) {
  23493. value = dict[pos++];
  23494. value = (value << 24 | dict[pos++] << 16) >> 16;
  23495. return value;
  23496. } else if (value === 29) {
  23497. value = dict[pos++];
  23498. value = value << 8 | dict[pos++];
  23499. value = value << 8 | dict[pos++];
  23500. value = value << 8 | dict[pos++];
  23501. return value;
  23502. } else if (value >= 32 && value <= 246) {
  23503. return value - 139;
  23504. } else if (value >= 247 && value <= 250) {
  23505. return (value - 247) * 256 + dict[pos++] + 108;
  23506. } else if (value >= 251 && value <= 254) {
  23507. return -((value - 251) * 256) - dict[pos++] - 108;
  23508. }
  23509. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  23510. return NaN;
  23511. }
  23512. function parseFloatOperand() {
  23513. var str = '';
  23514. var eof = 15;
  23515. var lookup = [
  23516. '0',
  23517. '1',
  23518. '2',
  23519. '3',
  23520. '4',
  23521. '5',
  23522. '6',
  23523. '7',
  23524. '8',
  23525. '9',
  23526. '.',
  23527. 'E',
  23528. 'E-',
  23529. null,
  23530. '-'
  23531. ];
  23532. var length = dict.length;
  23533. while (pos < length) {
  23534. var b = dict[pos++];
  23535. var b1 = b >> 4;
  23536. var b2 = b & 15;
  23537. if (b1 === eof) {
  23538. break;
  23539. }
  23540. str += lookup[b1];
  23541. if (b2 === eof) {
  23542. break;
  23543. }
  23544. str += lookup[b2];
  23545. }
  23546. return parseFloat(str);
  23547. }
  23548. var operands = [];
  23549. var entries = [];
  23550. pos = 0;
  23551. var end = dict.length;
  23552. while (pos < end) {
  23553. var b = dict[pos];
  23554. if (b <= 21) {
  23555. if (b === 12) {
  23556. b = b << 8 | dict[++pos];
  23557. }
  23558. entries.push([
  23559. b,
  23560. operands
  23561. ]);
  23562. operands = [];
  23563. ++pos;
  23564. } else {
  23565. operands.push(parseOperand());
  23566. }
  23567. }
  23568. return entries;
  23569. },
  23570. parseIndex: function CFFParser_parseIndex(pos) {
  23571. var cffIndex = new CFFIndex();
  23572. var bytes = this.bytes;
  23573. var count = bytes[pos++] << 8 | bytes[pos++];
  23574. var offsets = [];
  23575. var end = pos;
  23576. var i, ii;
  23577. if (count !== 0) {
  23578. var offsetSize = bytes[pos++];
  23579. var startPos = pos + (count + 1) * offsetSize - 1;
  23580. for (i = 0, ii = count + 1; i < ii; ++i) {
  23581. var offset = 0;
  23582. for (var j = 0; j < offsetSize; ++j) {
  23583. offset <<= 8;
  23584. offset += bytes[pos++];
  23585. }
  23586. offsets.push(startPos + offset);
  23587. }
  23588. end = offsets[count];
  23589. }
  23590. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  23591. var offsetStart = offsets[i];
  23592. var offsetEnd = offsets[i + 1];
  23593. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  23594. }
  23595. return {
  23596. obj: cffIndex,
  23597. endPos: end
  23598. };
  23599. },
  23600. parseNameIndex: function CFFParser_parseNameIndex(index) {
  23601. var names = [];
  23602. for (var i = 0, ii = index.count; i < ii; ++i) {
  23603. var name = index.get(i);
  23604. var length = Math.min(name.length, 127);
  23605. var data = [];
  23606. for (var j = 0; j < length; ++j) {
  23607. var c = name[j];
  23608. if (j === 0 && c === 0) {
  23609. data[j] = c;
  23610. continue;
  23611. }
  23612. 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) {
  23613. data[j] = 95;
  23614. continue;
  23615. }
  23616. data[j] = c;
  23617. }
  23618. names.push(bytesToString(data));
  23619. }
  23620. return names;
  23621. },
  23622. parseStringIndex: function CFFParser_parseStringIndex(index) {
  23623. var strings = new CFFStrings();
  23624. for (var i = 0, ii = index.count; i < ii; ++i) {
  23625. var data = index.get(i);
  23626. strings.add(bytesToString(data));
  23627. }
  23628. return strings;
  23629. },
  23630. createDict: function CFFParser_createDict(Type, dict, strings) {
  23631. var cffDict = new Type(strings);
  23632. for (var i = 0, ii = dict.length; i < ii; ++i) {
  23633. var pair = dict[i];
  23634. var key = pair[0];
  23635. var value = pair[1];
  23636. cffDict.setByKey(key, value);
  23637. }
  23638. return cffDict;
  23639. },
  23640. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  23641. if (state.callDepth > MAX_SUBR_NESTING) {
  23642. return false;
  23643. }
  23644. var stackSize = state.stackSize;
  23645. var stack = state.stack;
  23646. var length = data.length;
  23647. for (var j = 0; j < length;) {
  23648. var value = data[j++];
  23649. var validationCommand = null;
  23650. if (value === 12) {
  23651. var q = data[j++];
  23652. if (q === 0) {
  23653. data[j - 2] = 139;
  23654. data[j - 1] = 22;
  23655. stackSize = 0;
  23656. } else {
  23657. validationCommand = CharstringValidationData12[q];
  23658. }
  23659. } else if (value === 28) {
  23660. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  23661. j += 2;
  23662. stackSize++;
  23663. } else if (value === 14) {
  23664. if (stackSize >= 4) {
  23665. stackSize -= 4;
  23666. if (this.seacAnalysisEnabled) {
  23667. state.seac = stack.slice(stackSize, stackSize + 4);
  23668. return false;
  23669. }
  23670. }
  23671. validationCommand = CharstringValidationData[value];
  23672. } else if (value >= 32 && value <= 246) {
  23673. stack[stackSize] = value - 139;
  23674. stackSize++;
  23675. } else if (value >= 247 && value <= 254) {
  23676. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  23677. j++;
  23678. stackSize++;
  23679. } else if (value === 255) {
  23680. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  23681. j += 4;
  23682. stackSize++;
  23683. } else if (value === 19 || value === 20) {
  23684. state.hints += stackSize >> 1;
  23685. j += state.hints + 7 >> 3;
  23686. stackSize %= 2;
  23687. validationCommand = CharstringValidationData[value];
  23688. } else if (value === 10 || value === 29) {
  23689. var subrsIndex;
  23690. if (value === 10) {
  23691. subrsIndex = localSubrIndex;
  23692. } else {
  23693. subrsIndex = globalSubrIndex;
  23694. }
  23695. if (!subrsIndex) {
  23696. validationCommand = CharstringValidationData[value];
  23697. warn('Missing subrsIndex for ' + validationCommand.id);
  23698. return false;
  23699. }
  23700. var bias = 32768;
  23701. if (subrsIndex.count < 1240) {
  23702. bias = 107;
  23703. } else if (subrsIndex.count < 33900) {
  23704. bias = 1131;
  23705. }
  23706. var subrNumber = stack[--stackSize] + bias;
  23707. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  23708. validationCommand = CharstringValidationData[value];
  23709. warn('Out of bounds subrIndex for ' + validationCommand.id);
  23710. return false;
  23711. }
  23712. state.stackSize = stackSize;
  23713. state.callDepth++;
  23714. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  23715. if (!valid) {
  23716. return false;
  23717. }
  23718. state.callDepth--;
  23719. stackSize = state.stackSize;
  23720. continue;
  23721. } else if (value === 11) {
  23722. state.stackSize = stackSize;
  23723. return true;
  23724. } else {
  23725. validationCommand = CharstringValidationData[value];
  23726. }
  23727. if (validationCommand) {
  23728. if (validationCommand.stem) {
  23729. state.hints += stackSize >> 1;
  23730. }
  23731. if ('min' in validationCommand) {
  23732. if (!state.undefStack && stackSize < validationCommand.min) {
  23733. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  23734. return false;
  23735. }
  23736. }
  23737. if (state.firstStackClearing && validationCommand.stackClearing) {
  23738. state.firstStackClearing = false;
  23739. stackSize -= validationCommand.min;
  23740. if (stackSize >= 2 && validationCommand.stem) {
  23741. stackSize %= 2;
  23742. } else if (stackSize > 1) {
  23743. warn('Found too many parameters for stack-clearing command');
  23744. }
  23745. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  23746. state.width = stack[stackSize - 1];
  23747. }
  23748. }
  23749. if ('stackDelta' in validationCommand) {
  23750. if ('stackFn' in validationCommand) {
  23751. validationCommand.stackFn(stack, stackSize);
  23752. }
  23753. stackSize += validationCommand.stackDelta;
  23754. } else if (validationCommand.stackClearing) {
  23755. stackSize = 0;
  23756. } else if (validationCommand.resetStack) {
  23757. stackSize = 0;
  23758. state.undefStack = false;
  23759. } else if (validationCommand.undefStack) {
  23760. stackSize = 0;
  23761. state.undefStack = true;
  23762. state.firstStackClearing = false;
  23763. }
  23764. }
  23765. }
  23766. state.stackSize = stackSize;
  23767. return true;
  23768. },
  23769. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  23770. var seacs = [];
  23771. var widths = [];
  23772. var count = charStrings.count;
  23773. for (var i = 0; i < count; i++) {
  23774. var charstring = charStrings.get(i);
  23775. var state = {
  23776. callDepth: 0,
  23777. stackSize: 0,
  23778. stack: [],
  23779. undefStack: true,
  23780. hints: 0,
  23781. firstStackClearing: true,
  23782. seac: null,
  23783. width: null
  23784. };
  23785. var valid = true;
  23786. var localSubrToUse = null;
  23787. if (fdSelect && fdArray.length) {
  23788. var fdIndex = fdSelect.getFDIndex(i);
  23789. if (fdIndex === -1) {
  23790. warn('Glyph index is not in fd select.');
  23791. valid = false;
  23792. }
  23793. if (fdIndex >= fdArray.length) {
  23794. warn('Invalid fd index for glyph index.');
  23795. valid = false;
  23796. }
  23797. if (valid) {
  23798. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  23799. }
  23800. } else if (localSubrIndex) {
  23801. localSubrToUse = localSubrIndex;
  23802. }
  23803. if (valid) {
  23804. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  23805. }
  23806. if (state.width !== null) {
  23807. widths[i] = state.width;
  23808. }
  23809. if (state.seac !== null) {
  23810. seacs[i] = state.seac;
  23811. }
  23812. if (!valid) {
  23813. charStrings.set(i, new Uint8Array([14]));
  23814. }
  23815. }
  23816. return {
  23817. charStrings: charStrings,
  23818. seacs: seacs,
  23819. widths: widths
  23820. };
  23821. },
  23822. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  23823. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  23824. parentDict.setByKey(18, [
  23825. 0,
  23826. 0
  23827. ]);
  23828. parentDict.privateDict = privateDict;
  23829. },
  23830. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  23831. if (!parentDict.hasName('Private')) {
  23832. this.emptyPrivateDictionary(parentDict);
  23833. return;
  23834. }
  23835. var privateOffset = parentDict.getByName('Private');
  23836. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  23837. parentDict.removeByName('Private');
  23838. return;
  23839. }
  23840. var size = privateOffset[0];
  23841. var offset = privateOffset[1];
  23842. if (size === 0 || offset >= this.bytes.length) {
  23843. this.emptyPrivateDictionary(parentDict);
  23844. return;
  23845. }
  23846. var privateDictEnd = offset + size;
  23847. var dictData = this.bytes.subarray(offset, privateDictEnd);
  23848. var dict = this.parseDict(dictData);
  23849. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  23850. parentDict.privateDict = privateDict;
  23851. if (!privateDict.getByName('Subrs')) {
  23852. return;
  23853. }
  23854. var subrsOffset = privateDict.getByName('Subrs');
  23855. var relativeOffset = offset + subrsOffset;
  23856. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  23857. this.emptyPrivateDictionary(parentDict);
  23858. return;
  23859. }
  23860. var subrsIndex = this.parseIndex(relativeOffset);
  23861. privateDict.subrsIndex = subrsIndex.obj;
  23862. },
  23863. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  23864. if (pos === 0) {
  23865. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  23866. } else if (pos === 1) {
  23867. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  23868. } else if (pos === 2) {
  23869. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  23870. }
  23871. var bytes = this.bytes;
  23872. var start = pos;
  23873. var format = bytes[pos++];
  23874. var charset = ['.notdef'];
  23875. var id, count, i;
  23876. length -= 1;
  23877. switch (format) {
  23878. case 0:
  23879. for (i = 0; i < length; i++) {
  23880. id = bytes[pos++] << 8 | bytes[pos++];
  23881. charset.push(cid ? id : strings.get(id));
  23882. }
  23883. break;
  23884. case 1:
  23885. while (charset.length <= length) {
  23886. id = bytes[pos++] << 8 | bytes[pos++];
  23887. count = bytes[pos++];
  23888. for (i = 0; i <= count; i++) {
  23889. charset.push(cid ? id++ : strings.get(id++));
  23890. }
  23891. }
  23892. break;
  23893. case 2:
  23894. while (charset.length <= length) {
  23895. id = bytes[pos++] << 8 | bytes[pos++];
  23896. count = bytes[pos++] << 8 | bytes[pos++];
  23897. for (i = 0; i <= count; i++) {
  23898. charset.push(cid ? id++ : strings.get(id++));
  23899. }
  23900. }
  23901. break;
  23902. default:
  23903. error('Unknown charset format');
  23904. }
  23905. var end = pos;
  23906. var raw = bytes.subarray(start, end);
  23907. return new CFFCharset(false, format, charset, raw);
  23908. },
  23909. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  23910. var encoding = Object.create(null);
  23911. var bytes = this.bytes;
  23912. var predefined = false;
  23913. var format, i, ii;
  23914. var raw = null;
  23915. function readSupplement() {
  23916. var supplementsCount = bytes[pos++];
  23917. for (i = 0; i < supplementsCount; i++) {
  23918. var code = bytes[pos++];
  23919. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  23920. encoding[code] = charset.indexOf(strings.get(sid));
  23921. }
  23922. }
  23923. if (pos === 0 || pos === 1) {
  23924. predefined = true;
  23925. format = pos;
  23926. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  23927. for (i = 0, ii = charset.length; i < ii; i++) {
  23928. var index = baseEncoding.indexOf(charset[i]);
  23929. if (index !== -1) {
  23930. encoding[index] = i;
  23931. }
  23932. }
  23933. } else {
  23934. var dataStart = pos;
  23935. format = bytes[pos++];
  23936. switch (format & 0x7f) {
  23937. case 0:
  23938. var glyphsCount = bytes[pos++];
  23939. for (i = 1; i <= glyphsCount; i++) {
  23940. encoding[bytes[pos++]] = i;
  23941. }
  23942. break;
  23943. case 1:
  23944. var rangesCount = bytes[pos++];
  23945. var gid = 1;
  23946. for (i = 0; i < rangesCount; i++) {
  23947. var start = bytes[pos++];
  23948. var left = bytes[pos++];
  23949. for (var j = start; j <= start + left; j++) {
  23950. encoding[j] = gid++;
  23951. }
  23952. }
  23953. break;
  23954. default:
  23955. error('Unknown encoding format: ' + format + ' in CFF');
  23956. break;
  23957. }
  23958. var dataEnd = pos;
  23959. if (format & 0x80) {
  23960. bytes[dataStart] &= 0x7f;
  23961. readSupplement();
  23962. }
  23963. raw = bytes.subarray(dataStart, dataEnd);
  23964. }
  23965. format = format & 0x7f;
  23966. return new CFFEncoding(predefined, format, encoding, raw);
  23967. },
  23968. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  23969. var start = pos;
  23970. var bytes = this.bytes;
  23971. var format = bytes[pos++];
  23972. var fdSelect = [], rawBytes;
  23973. var i, invalidFirstGID = false;
  23974. switch (format) {
  23975. case 0:
  23976. for (i = 0; i < length; ++i) {
  23977. var id = bytes[pos++];
  23978. fdSelect.push(id);
  23979. }
  23980. rawBytes = bytes.subarray(start, pos);
  23981. break;
  23982. case 3:
  23983. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  23984. for (i = 0; i < rangesCount; ++i) {
  23985. var first = bytes[pos++] << 8 | bytes[pos++];
  23986. if (i === 0 && first !== 0) {
  23987. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  23988. invalidFirstGID = true;
  23989. first = 0;
  23990. }
  23991. var fdIndex = bytes[pos++];
  23992. var next = bytes[pos] << 8 | bytes[pos + 1];
  23993. for (var j = first; j < next; ++j) {
  23994. fdSelect.push(fdIndex);
  23995. }
  23996. }
  23997. pos += 2;
  23998. rawBytes = bytes.subarray(start, pos);
  23999. if (invalidFirstGID) {
  24000. rawBytes[3] = rawBytes[4] = 0;
  24001. }
  24002. break;
  24003. default:
  24004. error('parseFDSelect: Unknown format "' + format + '".');
  24005. break;
  24006. }
  24007. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  24008. return new CFFFDSelect(fdSelect, rawBytes);
  24009. }
  24010. };
  24011. return CFFParser;
  24012. }();
  24013. var CFF = function CFFClosure() {
  24014. function CFF() {
  24015. this.header = null;
  24016. this.names = [];
  24017. this.topDict = null;
  24018. this.strings = new CFFStrings();
  24019. this.globalSubrIndex = null;
  24020. this.encoding = null;
  24021. this.charset = null;
  24022. this.charStrings = null;
  24023. this.fdArray = [];
  24024. this.fdSelect = null;
  24025. this.isCIDFont = false;
  24026. }
  24027. return CFF;
  24028. }();
  24029. var CFFHeader = function CFFHeaderClosure() {
  24030. function CFFHeader(major, minor, hdrSize, offSize) {
  24031. this.major = major;
  24032. this.minor = minor;
  24033. this.hdrSize = hdrSize;
  24034. this.offSize = offSize;
  24035. }
  24036. return CFFHeader;
  24037. }();
  24038. var CFFStrings = function CFFStringsClosure() {
  24039. function CFFStrings() {
  24040. this.strings = [];
  24041. }
  24042. CFFStrings.prototype = {
  24043. get: function CFFStrings_get(index) {
  24044. if (index >= 0 && index <= 390) {
  24045. return CFFStandardStrings[index];
  24046. }
  24047. if (index - 391 <= this.strings.length) {
  24048. return this.strings[index - 391];
  24049. }
  24050. return CFFStandardStrings[0];
  24051. },
  24052. add: function CFFStrings_add(value) {
  24053. this.strings.push(value);
  24054. },
  24055. get count() {
  24056. return this.strings.length;
  24057. }
  24058. };
  24059. return CFFStrings;
  24060. }();
  24061. var CFFIndex = function CFFIndexClosure() {
  24062. function CFFIndex() {
  24063. this.objects = [];
  24064. this.length = 0;
  24065. }
  24066. CFFIndex.prototype = {
  24067. add: function CFFIndex_add(data) {
  24068. this.length += data.length;
  24069. this.objects.push(data);
  24070. },
  24071. set: function CFFIndex_set(index, data) {
  24072. this.length += data.length - this.objects[index].length;
  24073. this.objects[index] = data;
  24074. },
  24075. get: function CFFIndex_get(index) {
  24076. return this.objects[index];
  24077. },
  24078. get count() {
  24079. return this.objects.length;
  24080. }
  24081. };
  24082. return CFFIndex;
  24083. }();
  24084. var CFFDict = function CFFDictClosure() {
  24085. function CFFDict(tables, strings) {
  24086. this.keyToNameMap = tables.keyToNameMap;
  24087. this.nameToKeyMap = tables.nameToKeyMap;
  24088. this.defaults = tables.defaults;
  24089. this.types = tables.types;
  24090. this.opcodes = tables.opcodes;
  24091. this.order = tables.order;
  24092. this.strings = strings;
  24093. this.values = Object.create(null);
  24094. }
  24095. CFFDict.prototype = {
  24096. setByKey: function CFFDict_setByKey(key, value) {
  24097. if (!(key in this.keyToNameMap)) {
  24098. return false;
  24099. }
  24100. var valueLength = value.length;
  24101. if (valueLength === 0) {
  24102. return true;
  24103. }
  24104. for (var i = 0; i < valueLength; i++) {
  24105. if (isNaN(value[i])) {
  24106. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  24107. return true;
  24108. }
  24109. }
  24110. var type = this.types[key];
  24111. if (type === 'num' || type === 'sid' || type === 'offset') {
  24112. value = value[0];
  24113. }
  24114. this.values[key] = value;
  24115. return true;
  24116. },
  24117. setByName: function CFFDict_setByName(name, value) {
  24118. if (!(name in this.nameToKeyMap)) {
  24119. error('Invalid dictionary name "' + name + '"');
  24120. }
  24121. this.values[this.nameToKeyMap[name]] = value;
  24122. },
  24123. hasName: function CFFDict_hasName(name) {
  24124. return this.nameToKeyMap[name] in this.values;
  24125. },
  24126. getByName: function CFFDict_getByName(name) {
  24127. if (!(name in this.nameToKeyMap)) {
  24128. error('Invalid dictionary name "' + name + '"');
  24129. }
  24130. var key = this.nameToKeyMap[name];
  24131. if (!(key in this.values)) {
  24132. return this.defaults[key];
  24133. }
  24134. return this.values[key];
  24135. },
  24136. removeByName: function CFFDict_removeByName(name) {
  24137. delete this.values[this.nameToKeyMap[name]];
  24138. }
  24139. };
  24140. CFFDict.createTables = function CFFDict_createTables(layout) {
  24141. var tables = {
  24142. keyToNameMap: {},
  24143. nameToKeyMap: {},
  24144. defaults: {},
  24145. types: {},
  24146. opcodes: {},
  24147. order: []
  24148. };
  24149. for (var i = 0, ii = layout.length; i < ii; ++i) {
  24150. var entry = layout[i];
  24151. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  24152. tables.keyToNameMap[key] = entry[1];
  24153. tables.nameToKeyMap[entry[1]] = key;
  24154. tables.types[key] = entry[2];
  24155. tables.defaults[key] = entry[3];
  24156. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  24157. tables.order.push(key);
  24158. }
  24159. return tables;
  24160. };
  24161. return CFFDict;
  24162. }();
  24163. var CFFTopDict = function CFFTopDictClosure() {
  24164. var layout = [
  24165. [
  24166. [
  24167. 12,
  24168. 30
  24169. ],
  24170. 'ROS',
  24171. [
  24172. 'sid',
  24173. 'sid',
  24174. 'num'
  24175. ],
  24176. null
  24177. ],
  24178. [
  24179. [
  24180. 12,
  24181. 20
  24182. ],
  24183. 'SyntheticBase',
  24184. 'num',
  24185. null
  24186. ],
  24187. [
  24188. 0,
  24189. 'version',
  24190. 'sid',
  24191. null
  24192. ],
  24193. [
  24194. 1,
  24195. 'Notice',
  24196. 'sid',
  24197. null
  24198. ],
  24199. [
  24200. [
  24201. 12,
  24202. 0
  24203. ],
  24204. 'Copyright',
  24205. 'sid',
  24206. null
  24207. ],
  24208. [
  24209. 2,
  24210. 'FullName',
  24211. 'sid',
  24212. null
  24213. ],
  24214. [
  24215. 3,
  24216. 'FamilyName',
  24217. 'sid',
  24218. null
  24219. ],
  24220. [
  24221. 4,
  24222. 'Weight',
  24223. 'sid',
  24224. null
  24225. ],
  24226. [
  24227. [
  24228. 12,
  24229. 1
  24230. ],
  24231. 'isFixedPitch',
  24232. 'num',
  24233. 0
  24234. ],
  24235. [
  24236. [
  24237. 12,
  24238. 2
  24239. ],
  24240. 'ItalicAngle',
  24241. 'num',
  24242. 0
  24243. ],
  24244. [
  24245. [
  24246. 12,
  24247. 3
  24248. ],
  24249. 'UnderlinePosition',
  24250. 'num',
  24251. -100
  24252. ],
  24253. [
  24254. [
  24255. 12,
  24256. 4
  24257. ],
  24258. 'UnderlineThickness',
  24259. 'num',
  24260. 50
  24261. ],
  24262. [
  24263. [
  24264. 12,
  24265. 5
  24266. ],
  24267. 'PaintType',
  24268. 'num',
  24269. 0
  24270. ],
  24271. [
  24272. [
  24273. 12,
  24274. 6
  24275. ],
  24276. 'CharstringType',
  24277. 'num',
  24278. 2
  24279. ],
  24280. [
  24281. [
  24282. 12,
  24283. 7
  24284. ],
  24285. 'FontMatrix',
  24286. [
  24287. 'num',
  24288. 'num',
  24289. 'num',
  24290. 'num',
  24291. 'num',
  24292. 'num'
  24293. ],
  24294. [
  24295. 0.001,
  24296. 0,
  24297. 0,
  24298. 0.001,
  24299. 0,
  24300. 0
  24301. ]
  24302. ],
  24303. [
  24304. 13,
  24305. 'UniqueID',
  24306. 'num',
  24307. null
  24308. ],
  24309. [
  24310. 5,
  24311. 'FontBBox',
  24312. [
  24313. 'num',
  24314. 'num',
  24315. 'num',
  24316. 'num'
  24317. ],
  24318. [
  24319. 0,
  24320. 0,
  24321. 0,
  24322. 0
  24323. ]
  24324. ],
  24325. [
  24326. [
  24327. 12,
  24328. 8
  24329. ],
  24330. 'StrokeWidth',
  24331. 'num',
  24332. 0
  24333. ],
  24334. [
  24335. 14,
  24336. 'XUID',
  24337. 'array',
  24338. null
  24339. ],
  24340. [
  24341. 15,
  24342. 'charset',
  24343. 'offset',
  24344. 0
  24345. ],
  24346. [
  24347. 16,
  24348. 'Encoding',
  24349. 'offset',
  24350. 0
  24351. ],
  24352. [
  24353. 17,
  24354. 'CharStrings',
  24355. 'offset',
  24356. 0
  24357. ],
  24358. [
  24359. 18,
  24360. 'Private',
  24361. [
  24362. 'offset',
  24363. 'offset'
  24364. ],
  24365. null
  24366. ],
  24367. [
  24368. [
  24369. 12,
  24370. 21
  24371. ],
  24372. 'PostScript',
  24373. 'sid',
  24374. null
  24375. ],
  24376. [
  24377. [
  24378. 12,
  24379. 22
  24380. ],
  24381. 'BaseFontName',
  24382. 'sid',
  24383. null
  24384. ],
  24385. [
  24386. [
  24387. 12,
  24388. 23
  24389. ],
  24390. 'BaseFontBlend',
  24391. 'delta',
  24392. null
  24393. ],
  24394. [
  24395. [
  24396. 12,
  24397. 31
  24398. ],
  24399. 'CIDFontVersion',
  24400. 'num',
  24401. 0
  24402. ],
  24403. [
  24404. [
  24405. 12,
  24406. 32
  24407. ],
  24408. 'CIDFontRevision',
  24409. 'num',
  24410. 0
  24411. ],
  24412. [
  24413. [
  24414. 12,
  24415. 33
  24416. ],
  24417. 'CIDFontType',
  24418. 'num',
  24419. 0
  24420. ],
  24421. [
  24422. [
  24423. 12,
  24424. 34
  24425. ],
  24426. 'CIDCount',
  24427. 'num',
  24428. 8720
  24429. ],
  24430. [
  24431. [
  24432. 12,
  24433. 35
  24434. ],
  24435. 'UIDBase',
  24436. 'num',
  24437. null
  24438. ],
  24439. [
  24440. [
  24441. 12,
  24442. 37
  24443. ],
  24444. 'FDSelect',
  24445. 'offset',
  24446. null
  24447. ],
  24448. [
  24449. [
  24450. 12,
  24451. 36
  24452. ],
  24453. 'FDArray',
  24454. 'offset',
  24455. null
  24456. ],
  24457. [
  24458. [
  24459. 12,
  24460. 38
  24461. ],
  24462. 'FontName',
  24463. 'sid',
  24464. null
  24465. ]
  24466. ];
  24467. var tables = null;
  24468. function CFFTopDict(strings) {
  24469. if (tables === null) {
  24470. tables = CFFDict.createTables(layout);
  24471. }
  24472. CFFDict.call(this, tables, strings);
  24473. this.privateDict = null;
  24474. }
  24475. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  24476. return CFFTopDict;
  24477. }();
  24478. var CFFPrivateDict = function CFFPrivateDictClosure() {
  24479. var layout = [
  24480. [
  24481. 6,
  24482. 'BlueValues',
  24483. 'delta',
  24484. null
  24485. ],
  24486. [
  24487. 7,
  24488. 'OtherBlues',
  24489. 'delta',
  24490. null
  24491. ],
  24492. [
  24493. 8,
  24494. 'FamilyBlues',
  24495. 'delta',
  24496. null
  24497. ],
  24498. [
  24499. 9,
  24500. 'FamilyOtherBlues',
  24501. 'delta',
  24502. null
  24503. ],
  24504. [
  24505. [
  24506. 12,
  24507. 9
  24508. ],
  24509. 'BlueScale',
  24510. 'num',
  24511. 0.039625
  24512. ],
  24513. [
  24514. [
  24515. 12,
  24516. 10
  24517. ],
  24518. 'BlueShift',
  24519. 'num',
  24520. 7
  24521. ],
  24522. [
  24523. [
  24524. 12,
  24525. 11
  24526. ],
  24527. 'BlueFuzz',
  24528. 'num',
  24529. 1
  24530. ],
  24531. [
  24532. 10,
  24533. 'StdHW',
  24534. 'num',
  24535. null
  24536. ],
  24537. [
  24538. 11,
  24539. 'StdVW',
  24540. 'num',
  24541. null
  24542. ],
  24543. [
  24544. [
  24545. 12,
  24546. 12
  24547. ],
  24548. 'StemSnapH',
  24549. 'delta',
  24550. null
  24551. ],
  24552. [
  24553. [
  24554. 12,
  24555. 13
  24556. ],
  24557. 'StemSnapV',
  24558. 'delta',
  24559. null
  24560. ],
  24561. [
  24562. [
  24563. 12,
  24564. 14
  24565. ],
  24566. 'ForceBold',
  24567. 'num',
  24568. 0
  24569. ],
  24570. [
  24571. [
  24572. 12,
  24573. 17
  24574. ],
  24575. 'LanguageGroup',
  24576. 'num',
  24577. 0
  24578. ],
  24579. [
  24580. [
  24581. 12,
  24582. 18
  24583. ],
  24584. 'ExpansionFactor',
  24585. 'num',
  24586. 0.06
  24587. ],
  24588. [
  24589. [
  24590. 12,
  24591. 19
  24592. ],
  24593. 'initialRandomSeed',
  24594. 'num',
  24595. 0
  24596. ],
  24597. [
  24598. 20,
  24599. 'defaultWidthX',
  24600. 'num',
  24601. 0
  24602. ],
  24603. [
  24604. 21,
  24605. 'nominalWidthX',
  24606. 'num',
  24607. 0
  24608. ],
  24609. [
  24610. 19,
  24611. 'Subrs',
  24612. 'offset',
  24613. null
  24614. ]
  24615. ];
  24616. var tables = null;
  24617. function CFFPrivateDict(strings) {
  24618. if (tables === null) {
  24619. tables = CFFDict.createTables(layout);
  24620. }
  24621. CFFDict.call(this, tables, strings);
  24622. this.subrsIndex = null;
  24623. }
  24624. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  24625. return CFFPrivateDict;
  24626. }();
  24627. var CFFCharsetPredefinedTypes = {
  24628. ISO_ADOBE: 0,
  24629. EXPERT: 1,
  24630. EXPERT_SUBSET: 2
  24631. };
  24632. var CFFCharset = function CFFCharsetClosure() {
  24633. function CFFCharset(predefined, format, charset, raw) {
  24634. this.predefined = predefined;
  24635. this.format = format;
  24636. this.charset = charset;
  24637. this.raw = raw;
  24638. }
  24639. return CFFCharset;
  24640. }();
  24641. var CFFEncoding = function CFFEncodingClosure() {
  24642. function CFFEncoding(predefined, format, encoding, raw) {
  24643. this.predefined = predefined;
  24644. this.format = format;
  24645. this.encoding = encoding;
  24646. this.raw = raw;
  24647. }
  24648. return CFFEncoding;
  24649. }();
  24650. var CFFFDSelect = function CFFFDSelectClosure() {
  24651. function CFFFDSelect(fdSelect, raw) {
  24652. this.fdSelect = fdSelect;
  24653. this.raw = raw;
  24654. }
  24655. CFFFDSelect.prototype = {
  24656. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  24657. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  24658. return -1;
  24659. }
  24660. return this.fdSelect[glyphIndex];
  24661. }
  24662. };
  24663. return CFFFDSelect;
  24664. }();
  24665. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  24666. function CFFOffsetTracker() {
  24667. this.offsets = Object.create(null);
  24668. }
  24669. CFFOffsetTracker.prototype = {
  24670. isTracking: function CFFOffsetTracker_isTracking(key) {
  24671. return key in this.offsets;
  24672. },
  24673. track: function CFFOffsetTracker_track(key, location) {
  24674. if (key in this.offsets) {
  24675. error('Already tracking location of ' + key);
  24676. }
  24677. this.offsets[key] = location;
  24678. },
  24679. offset: function CFFOffsetTracker_offset(value) {
  24680. for (var key in this.offsets) {
  24681. this.offsets[key] += value;
  24682. }
  24683. },
  24684. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  24685. if (!(key in this.offsets)) {
  24686. error('Not tracking location of ' + key);
  24687. }
  24688. var data = output.data;
  24689. var dataOffset = this.offsets[key];
  24690. var size = 5;
  24691. for (var i = 0, ii = values.length; i < ii; ++i) {
  24692. var offset0 = i * size + dataOffset;
  24693. var offset1 = offset0 + 1;
  24694. var offset2 = offset0 + 2;
  24695. var offset3 = offset0 + 3;
  24696. var offset4 = offset0 + 4;
  24697. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  24698. error('writing to an offset that is not empty');
  24699. }
  24700. var value = values[i];
  24701. data[offset0] = 0x1d;
  24702. data[offset1] = value >> 24 & 0xFF;
  24703. data[offset2] = value >> 16 & 0xFF;
  24704. data[offset3] = value >> 8 & 0xFF;
  24705. data[offset4] = value & 0xFF;
  24706. }
  24707. }
  24708. };
  24709. return CFFOffsetTracker;
  24710. }();
  24711. var CFFCompiler = function CFFCompilerClosure() {
  24712. function CFFCompiler(cff) {
  24713. this.cff = cff;
  24714. }
  24715. CFFCompiler.prototype = {
  24716. compile: function CFFCompiler_compile() {
  24717. var cff = this.cff;
  24718. var output = {
  24719. data: [],
  24720. length: 0,
  24721. add: function CFFCompiler_add(data) {
  24722. this.data = this.data.concat(data);
  24723. this.length = this.data.length;
  24724. }
  24725. };
  24726. var header = this.compileHeader(cff.header);
  24727. output.add(header);
  24728. var nameIndex = this.compileNameIndex(cff.names);
  24729. output.add(nameIndex);
  24730. if (cff.isCIDFont) {
  24731. if (cff.topDict.hasName('FontMatrix')) {
  24732. var base = cff.topDict.getByName('FontMatrix');
  24733. cff.topDict.removeByName('FontMatrix');
  24734. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  24735. var subDict = cff.fdArray[i];
  24736. var matrix = base.slice(0);
  24737. if (subDict.hasName('FontMatrix')) {
  24738. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  24739. }
  24740. subDict.setByName('FontMatrix', matrix);
  24741. }
  24742. }
  24743. }
  24744. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  24745. output.add(compiled.output);
  24746. var topDictTracker = compiled.trackers[0];
  24747. var stringIndex = this.compileStringIndex(cff.strings.strings);
  24748. output.add(stringIndex);
  24749. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  24750. output.add(globalSubrIndex);
  24751. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  24752. if (cff.encoding.predefined) {
  24753. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  24754. } else {
  24755. var encoding = this.compileEncoding(cff.encoding);
  24756. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  24757. output.add(encoding);
  24758. }
  24759. }
  24760. if (cff.charset && cff.topDict.hasName('charset')) {
  24761. if (cff.charset.predefined) {
  24762. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  24763. } else {
  24764. var charset = this.compileCharset(cff.charset);
  24765. topDictTracker.setEntryLocation('charset', [output.length], output);
  24766. output.add(charset);
  24767. }
  24768. }
  24769. var charStrings = this.compileCharStrings(cff.charStrings);
  24770. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  24771. output.add(charStrings);
  24772. if (cff.isCIDFont) {
  24773. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  24774. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  24775. output.add(fdSelect);
  24776. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  24777. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  24778. output.add(compiled.output);
  24779. var fontDictTrackers = compiled.trackers;
  24780. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  24781. }
  24782. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  24783. output.add([0]);
  24784. return output.data;
  24785. },
  24786. encodeNumber: function CFFCompiler_encodeNumber(value) {
  24787. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  24788. return this.encodeInteger(value);
  24789. }
  24790. return this.encodeFloat(value);
  24791. },
  24792. encodeFloat: function CFFCompiler_encodeFloat(num) {
  24793. var value = num.toString();
  24794. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  24795. if (m) {
  24796. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  24797. value = (Math.round(num * epsilon) / epsilon).toString();
  24798. }
  24799. var nibbles = '';
  24800. var i, ii;
  24801. for (i = 0, ii = value.length; i < ii; ++i) {
  24802. var a = value[i];
  24803. if (a === 'e') {
  24804. nibbles += value[++i] === '-' ? 'c' : 'b';
  24805. } else if (a === '.') {
  24806. nibbles += 'a';
  24807. } else if (a === '-') {
  24808. nibbles += 'e';
  24809. } else {
  24810. nibbles += a;
  24811. }
  24812. }
  24813. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  24814. var out = [30];
  24815. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  24816. out.push(parseInt(nibbles.substr(i, 2), 16));
  24817. }
  24818. return out;
  24819. },
  24820. encodeInteger: function CFFCompiler_encodeInteger(value) {
  24821. var code;
  24822. if (value >= -107 && value <= 107) {
  24823. code = [value + 139];
  24824. } else if (value >= 108 && value <= 1131) {
  24825. value = value - 108;
  24826. code = [
  24827. (value >> 8) + 247,
  24828. value & 0xFF
  24829. ];
  24830. } else if (value >= -1131 && value <= -108) {
  24831. value = -value - 108;
  24832. code = [
  24833. (value >> 8) + 251,
  24834. value & 0xFF
  24835. ];
  24836. } else if (value >= -32768 && value <= 32767) {
  24837. code = [
  24838. 0x1c,
  24839. value >> 8 & 0xFF,
  24840. value & 0xFF
  24841. ];
  24842. } else {
  24843. code = [
  24844. 0x1d,
  24845. value >> 24 & 0xFF,
  24846. value >> 16 & 0xFF,
  24847. value >> 8 & 0xFF,
  24848. value & 0xFF
  24849. ];
  24850. }
  24851. return code;
  24852. },
  24853. compileHeader: function CFFCompiler_compileHeader(header) {
  24854. return [
  24855. header.major,
  24856. header.minor,
  24857. header.hdrSize,
  24858. header.offSize
  24859. ];
  24860. },
  24861. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  24862. var nameIndex = new CFFIndex();
  24863. for (var i = 0, ii = names.length; i < ii; ++i) {
  24864. nameIndex.add(stringToBytes(names[i]));
  24865. }
  24866. return this.compileIndex(nameIndex);
  24867. },
  24868. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  24869. var fontDictTrackers = [];
  24870. var fdArrayIndex = new CFFIndex();
  24871. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24872. var fontDict = dicts[i];
  24873. if (removeCidKeys) {
  24874. fontDict.removeByName('CIDFontVersion');
  24875. fontDict.removeByName('CIDFontRevision');
  24876. fontDict.removeByName('CIDFontType');
  24877. fontDict.removeByName('CIDCount');
  24878. fontDict.removeByName('UIDBase');
  24879. }
  24880. var fontDictTracker = new CFFOffsetTracker();
  24881. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  24882. fontDictTrackers.push(fontDictTracker);
  24883. fdArrayIndex.add(fontDictData);
  24884. fontDictTracker.offset(length);
  24885. }
  24886. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  24887. return {
  24888. trackers: fontDictTrackers,
  24889. output: fdArrayIndex
  24890. };
  24891. },
  24892. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  24893. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24894. var fontDict = dicts[i];
  24895. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  24896. var privateDict = fontDict.privateDict;
  24897. var privateDictTracker = new CFFOffsetTracker();
  24898. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  24899. var outputLength = output.length;
  24900. privateDictTracker.offset(outputLength);
  24901. if (!privateDictData.length) {
  24902. outputLength = 0;
  24903. }
  24904. trackers[i].setEntryLocation('Private', [
  24905. privateDictData.length,
  24906. outputLength
  24907. ], output);
  24908. output.add(privateDictData);
  24909. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  24910. var subrs = this.compileIndex(privateDict.subrsIndex);
  24911. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  24912. output.add(subrs);
  24913. }
  24914. }
  24915. },
  24916. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  24917. var out = [];
  24918. var order = dict.order;
  24919. for (var i = 0; i < order.length; ++i) {
  24920. var key = order[i];
  24921. if (!(key in dict.values)) {
  24922. continue;
  24923. }
  24924. var values = dict.values[key];
  24925. var types = dict.types[key];
  24926. if (!isArray(types)) {
  24927. types = [types];
  24928. }
  24929. if (!isArray(values)) {
  24930. values = [values];
  24931. }
  24932. if (values.length === 0) {
  24933. continue;
  24934. }
  24935. for (var j = 0, jj = types.length; j < jj; ++j) {
  24936. var type = types[j];
  24937. var value = values[j];
  24938. switch (type) {
  24939. case 'num':
  24940. case 'sid':
  24941. out = out.concat(this.encodeNumber(value));
  24942. break;
  24943. case 'offset':
  24944. var name = dict.keyToNameMap[key];
  24945. if (!offsetTracker.isTracking(name)) {
  24946. offsetTracker.track(name, out.length);
  24947. }
  24948. out = out.concat([
  24949. 0x1d,
  24950. 0,
  24951. 0,
  24952. 0,
  24953. 0
  24954. ]);
  24955. break;
  24956. case 'array':
  24957. case 'delta':
  24958. out = out.concat(this.encodeNumber(value));
  24959. for (var k = 1, kk = values.length; k < kk; ++k) {
  24960. out = out.concat(this.encodeNumber(values[k]));
  24961. }
  24962. break;
  24963. default:
  24964. error('Unknown data type of ' + type);
  24965. break;
  24966. }
  24967. }
  24968. out = out.concat(dict.opcodes[key]);
  24969. }
  24970. return out;
  24971. },
  24972. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  24973. var stringIndex = new CFFIndex();
  24974. for (var i = 0, ii = strings.length; i < ii; ++i) {
  24975. stringIndex.add(stringToBytes(strings[i]));
  24976. }
  24977. return this.compileIndex(stringIndex);
  24978. },
  24979. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  24980. var globalSubrIndex = this.cff.globalSubrIndex;
  24981. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  24982. },
  24983. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  24984. return this.compileIndex(charStrings);
  24985. },
  24986. compileCharset: function CFFCompiler_compileCharset(charset) {
  24987. return this.compileTypedArray(charset.raw);
  24988. },
  24989. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  24990. return this.compileTypedArray(encoding.raw);
  24991. },
  24992. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  24993. return this.compileTypedArray(fdSelect);
  24994. },
  24995. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  24996. var out = [];
  24997. for (var i = 0, ii = data.length; i < ii; ++i) {
  24998. out[i] = data[i];
  24999. }
  25000. return out;
  25001. },
  25002. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  25003. trackers = trackers || [];
  25004. var objects = index.objects;
  25005. var count = objects.length;
  25006. if (count === 0) {
  25007. return [
  25008. 0,
  25009. 0,
  25010. 0
  25011. ];
  25012. }
  25013. var data = [
  25014. count >> 8 & 0xFF,
  25015. count & 0xff
  25016. ];
  25017. var lastOffset = 1, i;
  25018. for (i = 0; i < count; ++i) {
  25019. lastOffset += objects[i].length;
  25020. }
  25021. var offsetSize;
  25022. if (lastOffset < 0x100) {
  25023. offsetSize = 1;
  25024. } else if (lastOffset < 0x10000) {
  25025. offsetSize = 2;
  25026. } else if (lastOffset < 0x1000000) {
  25027. offsetSize = 3;
  25028. } else {
  25029. offsetSize = 4;
  25030. }
  25031. data.push(offsetSize);
  25032. var relativeOffset = 1;
  25033. for (i = 0; i < count + 1; i++) {
  25034. if (offsetSize === 1) {
  25035. data.push(relativeOffset & 0xFF);
  25036. } else if (offsetSize === 2) {
  25037. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  25038. } else if (offsetSize === 3) {
  25039. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  25040. } else {
  25041. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  25042. }
  25043. if (objects[i]) {
  25044. relativeOffset += objects[i].length;
  25045. }
  25046. }
  25047. for (i = 0; i < count; i++) {
  25048. if (trackers[i]) {
  25049. trackers[i].offset(data.length);
  25050. }
  25051. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  25052. data.push(objects[i][j]);
  25053. }
  25054. }
  25055. return data;
  25056. }
  25057. };
  25058. return CFFCompiler;
  25059. }();
  25060. exports.CFFStandardStrings = CFFStandardStrings;
  25061. exports.CFFParser = CFFParser;
  25062. exports.CFF = CFF;
  25063. exports.CFFHeader = CFFHeader;
  25064. exports.CFFStrings = CFFStrings;
  25065. exports.CFFIndex = CFFIndex;
  25066. exports.CFFCharset = CFFCharset;
  25067. exports.CFFTopDict = CFFTopDict;
  25068. exports.CFFPrivateDict = CFFPrivateDict;
  25069. exports.CFFCompiler = CFFCompiler;
  25070. /***/ }),
  25071. /* 15 */
  25072. /***/ (function(module, exports, __w_pdfjs_require__) {
  25073. "use strict";
  25074. var sharedUtil = __w_pdfjs_require__(0);
  25075. var MissingDataException = sharedUtil.MissingDataException;
  25076. var arrayByteLength = sharedUtil.arrayByteLength;
  25077. var arraysToBytes = sharedUtil.arraysToBytes;
  25078. var assert = sharedUtil.assert;
  25079. var createPromiseCapability = sharedUtil.createPromiseCapability;
  25080. var isInt = sharedUtil.isInt;
  25081. var isEmptyObj = sharedUtil.isEmptyObj;
  25082. var ChunkedStream = function ChunkedStreamClosure() {
  25083. function ChunkedStream(length, chunkSize, manager) {
  25084. this.bytes = new Uint8Array(length);
  25085. this.start = 0;
  25086. this.pos = 0;
  25087. this.end = length;
  25088. this.chunkSize = chunkSize;
  25089. this.loadedChunks = [];
  25090. this.numChunksLoaded = 0;
  25091. this.numChunks = Math.ceil(length / chunkSize);
  25092. this.manager = manager;
  25093. this.progressiveDataLength = 0;
  25094. this.lastSuccessfulEnsureByteChunk = -1;
  25095. }
  25096. ChunkedStream.prototype = {
  25097. getMissingChunks: function ChunkedStream_getMissingChunks() {
  25098. var chunks = [];
  25099. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  25100. if (!this.loadedChunks[chunk]) {
  25101. chunks.push(chunk);
  25102. }
  25103. }
  25104. return chunks;
  25105. },
  25106. getBaseStreams: function ChunkedStream_getBaseStreams() {
  25107. return [this];
  25108. },
  25109. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  25110. return this.numChunksLoaded === this.numChunks;
  25111. },
  25112. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  25113. var end = begin + chunk.byteLength;
  25114. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  25115. var length = this.bytes.length;
  25116. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  25117. this.bytes.set(new Uint8Array(chunk), begin);
  25118. var chunkSize = this.chunkSize;
  25119. var beginChunk = Math.floor(begin / chunkSize);
  25120. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25121. var curChunk;
  25122. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25123. if (!this.loadedChunks[curChunk]) {
  25124. this.loadedChunks[curChunk] = true;
  25125. ++this.numChunksLoaded;
  25126. }
  25127. }
  25128. },
  25129. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  25130. var position = this.progressiveDataLength;
  25131. var beginChunk = Math.floor(position / this.chunkSize);
  25132. this.bytes.set(new Uint8Array(data), position);
  25133. position += data.byteLength;
  25134. this.progressiveDataLength = position;
  25135. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  25136. var curChunk;
  25137. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25138. if (!this.loadedChunks[curChunk]) {
  25139. this.loadedChunks[curChunk] = true;
  25140. ++this.numChunksLoaded;
  25141. }
  25142. }
  25143. },
  25144. ensureByte: function ChunkedStream_ensureByte(pos) {
  25145. var chunk = Math.floor(pos / this.chunkSize);
  25146. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  25147. return;
  25148. }
  25149. if (!this.loadedChunks[chunk]) {
  25150. throw new MissingDataException(pos, pos + 1);
  25151. }
  25152. this.lastSuccessfulEnsureByteChunk = chunk;
  25153. },
  25154. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  25155. if (begin >= end) {
  25156. return;
  25157. }
  25158. if (end <= this.progressiveDataLength) {
  25159. return;
  25160. }
  25161. var chunkSize = this.chunkSize;
  25162. var beginChunk = Math.floor(begin / chunkSize);
  25163. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25164. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25165. if (!this.loadedChunks[chunk]) {
  25166. throw new MissingDataException(begin, end);
  25167. }
  25168. }
  25169. },
  25170. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  25171. var chunk, numChunks = this.numChunks;
  25172. for (var i = 0; i < numChunks; ++i) {
  25173. chunk = (beginChunk + i) % numChunks;
  25174. if (!this.loadedChunks[chunk]) {
  25175. return chunk;
  25176. }
  25177. }
  25178. return null;
  25179. },
  25180. hasChunk: function ChunkedStream_hasChunk(chunk) {
  25181. return !!this.loadedChunks[chunk];
  25182. },
  25183. get length() {
  25184. return this.end - this.start;
  25185. },
  25186. get isEmpty() {
  25187. return this.length === 0;
  25188. },
  25189. getByte: function ChunkedStream_getByte() {
  25190. var pos = this.pos;
  25191. if (pos >= this.end) {
  25192. return -1;
  25193. }
  25194. this.ensureByte(pos);
  25195. return this.bytes[this.pos++];
  25196. },
  25197. getUint16: function ChunkedStream_getUint16() {
  25198. var b0 = this.getByte();
  25199. var b1 = this.getByte();
  25200. if (b0 === -1 || b1 === -1) {
  25201. return -1;
  25202. }
  25203. return (b0 << 8) + b1;
  25204. },
  25205. getInt32: function ChunkedStream_getInt32() {
  25206. var b0 = this.getByte();
  25207. var b1 = this.getByte();
  25208. var b2 = this.getByte();
  25209. var b3 = this.getByte();
  25210. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  25211. },
  25212. getBytes: function ChunkedStream_getBytes(length) {
  25213. var bytes = this.bytes;
  25214. var pos = this.pos;
  25215. var strEnd = this.end;
  25216. if (!length) {
  25217. this.ensureRange(pos, strEnd);
  25218. return bytes.subarray(pos, strEnd);
  25219. }
  25220. var end = pos + length;
  25221. if (end > strEnd) {
  25222. end = strEnd;
  25223. }
  25224. this.ensureRange(pos, end);
  25225. this.pos = end;
  25226. return bytes.subarray(pos, end);
  25227. },
  25228. peekByte: function ChunkedStream_peekByte() {
  25229. var peekedByte = this.getByte();
  25230. this.pos--;
  25231. return peekedByte;
  25232. },
  25233. peekBytes: function ChunkedStream_peekBytes(length) {
  25234. var bytes = this.getBytes(length);
  25235. this.pos -= bytes.length;
  25236. return bytes;
  25237. },
  25238. getByteRange: function ChunkedStream_getBytes(begin, end) {
  25239. this.ensureRange(begin, end);
  25240. return this.bytes.subarray(begin, end);
  25241. },
  25242. skip: function ChunkedStream_skip(n) {
  25243. if (!n) {
  25244. n = 1;
  25245. }
  25246. this.pos += n;
  25247. },
  25248. reset: function ChunkedStream_reset() {
  25249. this.pos = this.start;
  25250. },
  25251. moveStart: function ChunkedStream_moveStart() {
  25252. this.start = this.pos;
  25253. },
  25254. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  25255. this.ensureRange(start, start + length);
  25256. function ChunkedStreamSubstream() {
  25257. }
  25258. ChunkedStreamSubstream.prototype = Object.create(this);
  25259. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  25260. var chunkSize = this.chunkSize;
  25261. var beginChunk = Math.floor(this.start / chunkSize);
  25262. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  25263. var missingChunks = [];
  25264. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25265. if (!this.loadedChunks[chunk]) {
  25266. missingChunks.push(chunk);
  25267. }
  25268. }
  25269. return missingChunks;
  25270. };
  25271. var subStream = new ChunkedStreamSubstream();
  25272. subStream.pos = subStream.start = start;
  25273. subStream.end = start + length || this.end;
  25274. subStream.dict = dict;
  25275. return subStream;
  25276. }
  25277. };
  25278. return ChunkedStream;
  25279. }();
  25280. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  25281. function ChunkedStreamManager(pdfNetworkStream, args) {
  25282. var chunkSize = args.rangeChunkSize;
  25283. var length = args.length;
  25284. this.stream = new ChunkedStream(length, chunkSize, this);
  25285. this.length = length;
  25286. this.chunkSize = chunkSize;
  25287. this.pdfNetworkStream = pdfNetworkStream;
  25288. this.url = args.url;
  25289. this.disableAutoFetch = args.disableAutoFetch;
  25290. this.msgHandler = args.msgHandler;
  25291. this.currRequestId = 0;
  25292. this.chunksNeededByRequest = Object.create(null);
  25293. this.requestsByChunk = Object.create(null);
  25294. this.promisesByRequest = Object.create(null);
  25295. this.progressiveDataLength = 0;
  25296. this.aborted = false;
  25297. this._loadedStreamCapability = createPromiseCapability();
  25298. }
  25299. ChunkedStreamManager.prototype = {
  25300. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  25301. return this._loadedStreamCapability.promise;
  25302. },
  25303. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  25304. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  25305. if (!rangeReader.isStreamingSupported) {
  25306. rangeReader.onProgress = this.onProgress.bind(this);
  25307. }
  25308. var chunks = [], loaded = 0;
  25309. var manager = this;
  25310. var promise = new Promise(function (resolve, reject) {
  25311. var readChunk = function (chunk) {
  25312. try {
  25313. if (!chunk.done) {
  25314. var data = chunk.value;
  25315. chunks.push(data);
  25316. loaded += arrayByteLength(data);
  25317. if (rangeReader.isStreamingSupported) {
  25318. manager.onProgress({ loaded: loaded });
  25319. }
  25320. rangeReader.read().then(readChunk, reject);
  25321. return;
  25322. }
  25323. var chunkData = arraysToBytes(chunks);
  25324. chunks = null;
  25325. resolve(chunkData);
  25326. } catch (e) {
  25327. reject(e);
  25328. }
  25329. };
  25330. rangeReader.read().then(readChunk, reject);
  25331. });
  25332. promise.then(function (data) {
  25333. if (this.aborted) {
  25334. return;
  25335. }
  25336. this.onReceiveData({
  25337. chunk: data,
  25338. begin: begin
  25339. });
  25340. }.bind(this));
  25341. },
  25342. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  25343. var missingChunks = this.stream.getMissingChunks();
  25344. this._requestChunks(missingChunks);
  25345. return this._loadedStreamCapability.promise;
  25346. },
  25347. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  25348. var requestId = this.currRequestId++;
  25349. var i, ii;
  25350. var chunksNeeded = Object.create(null);
  25351. this.chunksNeededByRequest[requestId] = chunksNeeded;
  25352. for (i = 0, ii = chunks.length; i < ii; i++) {
  25353. if (!this.stream.hasChunk(chunks[i])) {
  25354. chunksNeeded[chunks[i]] = true;
  25355. }
  25356. }
  25357. if (isEmptyObj(chunksNeeded)) {
  25358. return Promise.resolve();
  25359. }
  25360. var capability = createPromiseCapability();
  25361. this.promisesByRequest[requestId] = capability;
  25362. var chunksToRequest = [];
  25363. for (var chunk in chunksNeeded) {
  25364. chunk = chunk | 0;
  25365. if (!(chunk in this.requestsByChunk)) {
  25366. this.requestsByChunk[chunk] = [];
  25367. chunksToRequest.push(chunk);
  25368. }
  25369. this.requestsByChunk[chunk].push(requestId);
  25370. }
  25371. if (!chunksToRequest.length) {
  25372. return capability.promise;
  25373. }
  25374. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  25375. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  25376. var groupedChunk = groupedChunksToRequest[i];
  25377. var begin = groupedChunk.beginChunk * this.chunkSize;
  25378. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  25379. this.sendRequest(begin, end);
  25380. }
  25381. return capability.promise;
  25382. },
  25383. getStream: function ChunkedStreamManager_getStream() {
  25384. return this.stream;
  25385. },
  25386. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  25387. end = Math.min(end, this.length);
  25388. var beginChunk = this.getBeginChunk(begin);
  25389. var endChunk = this.getEndChunk(end);
  25390. var chunks = [];
  25391. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25392. chunks.push(chunk);
  25393. }
  25394. return this._requestChunks(chunks);
  25395. },
  25396. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  25397. ranges = ranges || [];
  25398. var chunksToRequest = [];
  25399. for (var i = 0; i < ranges.length; i++) {
  25400. var beginChunk = this.getBeginChunk(ranges[i].begin);
  25401. var endChunk = this.getEndChunk(ranges[i].end);
  25402. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25403. if (chunksToRequest.indexOf(chunk) < 0) {
  25404. chunksToRequest.push(chunk);
  25405. }
  25406. }
  25407. }
  25408. chunksToRequest.sort(function (a, b) {
  25409. return a - b;
  25410. });
  25411. return this._requestChunks(chunksToRequest);
  25412. },
  25413. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  25414. var groupedChunks = [];
  25415. var beginChunk = -1;
  25416. var prevChunk = -1;
  25417. for (var i = 0; i < chunks.length; ++i) {
  25418. var chunk = chunks[i];
  25419. if (beginChunk < 0) {
  25420. beginChunk = chunk;
  25421. }
  25422. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  25423. groupedChunks.push({
  25424. beginChunk: beginChunk,
  25425. endChunk: prevChunk + 1
  25426. });
  25427. beginChunk = chunk;
  25428. }
  25429. if (i + 1 === chunks.length) {
  25430. groupedChunks.push({
  25431. beginChunk: beginChunk,
  25432. endChunk: chunk + 1
  25433. });
  25434. }
  25435. prevChunk = chunk;
  25436. }
  25437. return groupedChunks;
  25438. },
  25439. onProgress: function ChunkedStreamManager_onProgress(args) {
  25440. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  25441. this.msgHandler.send('DocProgress', {
  25442. loaded: bytesLoaded,
  25443. total: this.length
  25444. });
  25445. },
  25446. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  25447. var chunk = args.chunk;
  25448. var isProgressive = args.begin === undefined;
  25449. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  25450. var end = begin + chunk.byteLength;
  25451. var beginChunk = Math.floor(begin / this.chunkSize);
  25452. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  25453. if (isProgressive) {
  25454. this.stream.onReceiveProgressiveData(chunk);
  25455. this.progressiveDataLength = end;
  25456. } else {
  25457. this.stream.onReceiveData(begin, chunk);
  25458. }
  25459. if (this.stream.allChunksLoaded()) {
  25460. this._loadedStreamCapability.resolve(this.stream);
  25461. }
  25462. var loadedRequests = [];
  25463. var i, requestId;
  25464. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  25465. var requestIds = this.requestsByChunk[chunk] || [];
  25466. delete this.requestsByChunk[chunk];
  25467. for (i = 0; i < requestIds.length; ++i) {
  25468. requestId = requestIds[i];
  25469. var chunksNeeded = this.chunksNeededByRequest[requestId];
  25470. if (chunk in chunksNeeded) {
  25471. delete chunksNeeded[chunk];
  25472. }
  25473. if (!isEmptyObj(chunksNeeded)) {
  25474. continue;
  25475. }
  25476. loadedRequests.push(requestId);
  25477. }
  25478. }
  25479. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  25480. var nextEmptyChunk;
  25481. if (this.stream.numChunksLoaded === 1) {
  25482. var lastChunk = this.stream.numChunks - 1;
  25483. if (!this.stream.hasChunk(lastChunk)) {
  25484. nextEmptyChunk = lastChunk;
  25485. }
  25486. } else {
  25487. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  25488. }
  25489. if (isInt(nextEmptyChunk)) {
  25490. this._requestChunks([nextEmptyChunk]);
  25491. }
  25492. }
  25493. for (i = 0; i < loadedRequests.length; ++i) {
  25494. requestId = loadedRequests[i];
  25495. var capability = this.promisesByRequest[requestId];
  25496. delete this.promisesByRequest[requestId];
  25497. capability.resolve();
  25498. }
  25499. this.msgHandler.send('DocProgress', {
  25500. loaded: this.stream.numChunksLoaded * this.chunkSize,
  25501. total: this.length
  25502. });
  25503. },
  25504. onError: function ChunkedStreamManager_onError(err) {
  25505. this._loadedStreamCapability.reject(err);
  25506. },
  25507. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  25508. var chunk = Math.floor(begin / this.chunkSize);
  25509. return chunk;
  25510. },
  25511. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  25512. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  25513. return chunk;
  25514. },
  25515. abort: function ChunkedStreamManager_abort() {
  25516. this.aborted = true;
  25517. if (this.pdfNetworkStream) {
  25518. this.pdfNetworkStream.cancelAllRequests('abort');
  25519. }
  25520. for (var requestId in this.promisesByRequest) {
  25521. var capability = this.promisesByRequest[requestId];
  25522. capability.reject(new Error('Request was aborted'));
  25523. }
  25524. }
  25525. };
  25526. return ChunkedStreamManager;
  25527. }();
  25528. exports.ChunkedStream = ChunkedStream;
  25529. exports.ChunkedStreamManager = ChunkedStreamManager;
  25530. /***/ }),
  25531. /* 16 */
  25532. /***/ (function(module, exports, __w_pdfjs_require__) {
  25533. "use strict";
  25534. var sharedUtil = __w_pdfjs_require__(0);
  25535. var corePrimitives = __w_pdfjs_require__(1);
  25536. var coreStream = __w_pdfjs_require__(2);
  25537. var PasswordException = sharedUtil.PasswordException;
  25538. var PasswordResponses = sharedUtil.PasswordResponses;
  25539. var bytesToString = sharedUtil.bytesToString;
  25540. var warn = sharedUtil.warn;
  25541. var error = sharedUtil.error;
  25542. var assert = sharedUtil.assert;
  25543. var isInt = sharedUtil.isInt;
  25544. var stringToBytes = sharedUtil.stringToBytes;
  25545. var utf8StringToString = sharedUtil.utf8StringToString;
  25546. var Name = corePrimitives.Name;
  25547. var isName = corePrimitives.isName;
  25548. var isDict = corePrimitives.isDict;
  25549. var DecryptStream = coreStream.DecryptStream;
  25550. var ARCFourCipher = function ARCFourCipherClosure() {
  25551. function ARCFourCipher(key) {
  25552. this.a = 0;
  25553. this.b = 0;
  25554. var s = new Uint8Array(256);
  25555. var i, j = 0, tmp, keyLength = key.length;
  25556. for (i = 0; i < 256; ++i) {
  25557. s[i] = i;
  25558. }
  25559. for (i = 0; i < 256; ++i) {
  25560. tmp = s[i];
  25561. j = j + tmp + key[i % keyLength] & 0xFF;
  25562. s[i] = s[j];
  25563. s[j] = tmp;
  25564. }
  25565. this.s = s;
  25566. }
  25567. ARCFourCipher.prototype = {
  25568. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  25569. var i, n = data.length, tmp, tmp2;
  25570. var a = this.a, b = this.b, s = this.s;
  25571. var output = new Uint8Array(n);
  25572. for (i = 0; i < n; ++i) {
  25573. a = a + 1 & 0xFF;
  25574. tmp = s[a];
  25575. b = b + tmp & 0xFF;
  25576. tmp2 = s[b];
  25577. s[a] = tmp2;
  25578. s[b] = tmp;
  25579. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  25580. }
  25581. this.a = a;
  25582. this.b = b;
  25583. return output;
  25584. }
  25585. };
  25586. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  25587. return ARCFourCipher;
  25588. }();
  25589. var calculateMD5 = function calculateMD5Closure() {
  25590. var r = new Uint8Array([
  25591. 7,
  25592. 12,
  25593. 17,
  25594. 22,
  25595. 7,
  25596. 12,
  25597. 17,
  25598. 22,
  25599. 7,
  25600. 12,
  25601. 17,
  25602. 22,
  25603. 7,
  25604. 12,
  25605. 17,
  25606. 22,
  25607. 5,
  25608. 9,
  25609. 14,
  25610. 20,
  25611. 5,
  25612. 9,
  25613. 14,
  25614. 20,
  25615. 5,
  25616. 9,
  25617. 14,
  25618. 20,
  25619. 5,
  25620. 9,
  25621. 14,
  25622. 20,
  25623. 4,
  25624. 11,
  25625. 16,
  25626. 23,
  25627. 4,
  25628. 11,
  25629. 16,
  25630. 23,
  25631. 4,
  25632. 11,
  25633. 16,
  25634. 23,
  25635. 4,
  25636. 11,
  25637. 16,
  25638. 23,
  25639. 6,
  25640. 10,
  25641. 15,
  25642. 21,
  25643. 6,
  25644. 10,
  25645. 15,
  25646. 21,
  25647. 6,
  25648. 10,
  25649. 15,
  25650. 21,
  25651. 6,
  25652. 10,
  25653. 15,
  25654. 21
  25655. ]);
  25656. var k = new Int32Array([
  25657. -680876936,
  25658. -389564586,
  25659. 606105819,
  25660. -1044525330,
  25661. -176418897,
  25662. 1200080426,
  25663. -1473231341,
  25664. -45705983,
  25665. 1770035416,
  25666. -1958414417,
  25667. -42063,
  25668. -1990404162,
  25669. 1804603682,
  25670. -40341101,
  25671. -1502002290,
  25672. 1236535329,
  25673. -165796510,
  25674. -1069501632,
  25675. 643717713,
  25676. -373897302,
  25677. -701558691,
  25678. 38016083,
  25679. -660478335,
  25680. -405537848,
  25681. 568446438,
  25682. -1019803690,
  25683. -187363961,
  25684. 1163531501,
  25685. -1444681467,
  25686. -51403784,
  25687. 1735328473,
  25688. -1926607734,
  25689. -378558,
  25690. -2022574463,
  25691. 1839030562,
  25692. -35309556,
  25693. -1530992060,
  25694. 1272893353,
  25695. -155497632,
  25696. -1094730640,
  25697. 681279174,
  25698. -358537222,
  25699. -722521979,
  25700. 76029189,
  25701. -640364487,
  25702. -421815835,
  25703. 530742520,
  25704. -995338651,
  25705. -198630844,
  25706. 1126891415,
  25707. -1416354905,
  25708. -57434055,
  25709. 1700485571,
  25710. -1894986606,
  25711. -1051523,
  25712. -2054922799,
  25713. 1873313359,
  25714. -30611744,
  25715. -1560198380,
  25716. 1309151649,
  25717. -145523070,
  25718. -1120210379,
  25719. 718787259,
  25720. -343485551
  25721. ]);
  25722. function hash(data, offset, length) {
  25723. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  25724. var paddedLength = length + 72 & ~63;
  25725. var padded = new Uint8Array(paddedLength);
  25726. var i, j, n;
  25727. for (i = 0; i < length; ++i) {
  25728. padded[i] = data[offset++];
  25729. }
  25730. padded[i++] = 0x80;
  25731. n = paddedLength - 8;
  25732. while (i < n) {
  25733. padded[i++] = 0;
  25734. }
  25735. padded[i++] = length << 3 & 0xFF;
  25736. padded[i++] = length >> 5 & 0xFF;
  25737. padded[i++] = length >> 13 & 0xFF;
  25738. padded[i++] = length >> 21 & 0xFF;
  25739. padded[i++] = length >>> 29 & 0xFF;
  25740. padded[i++] = 0;
  25741. padded[i++] = 0;
  25742. padded[i++] = 0;
  25743. var w = new Int32Array(16);
  25744. for (i = 0; i < paddedLength;) {
  25745. for (j = 0; j < 16; ++j, i += 4) {
  25746. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  25747. }
  25748. var a = h0, b = h1, c = h2, d = h3, f, g;
  25749. for (j = 0; j < 64; ++j) {
  25750. if (j < 16) {
  25751. f = b & c | ~b & d;
  25752. g = j;
  25753. } else if (j < 32) {
  25754. f = d & b | ~d & c;
  25755. g = 5 * j + 1 & 15;
  25756. } else if (j < 48) {
  25757. f = b ^ c ^ d;
  25758. g = 3 * j + 5 & 15;
  25759. } else {
  25760. f = c ^ (b | ~d);
  25761. g = 7 * j & 15;
  25762. }
  25763. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  25764. d = c;
  25765. c = b;
  25766. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  25767. a = tmp;
  25768. }
  25769. h0 = h0 + a | 0;
  25770. h1 = h1 + b | 0;
  25771. h2 = h2 + c | 0;
  25772. h3 = h3 + d | 0;
  25773. }
  25774. return new Uint8Array([
  25775. h0 & 0xFF,
  25776. h0 >> 8 & 0xFF,
  25777. h0 >> 16 & 0xFF,
  25778. h0 >>> 24 & 0xFF,
  25779. h1 & 0xFF,
  25780. h1 >> 8 & 0xFF,
  25781. h1 >> 16 & 0xFF,
  25782. h1 >>> 24 & 0xFF,
  25783. h2 & 0xFF,
  25784. h2 >> 8 & 0xFF,
  25785. h2 >> 16 & 0xFF,
  25786. h2 >>> 24 & 0xFF,
  25787. h3 & 0xFF,
  25788. h3 >> 8 & 0xFF,
  25789. h3 >> 16 & 0xFF,
  25790. h3 >>> 24 & 0xFF
  25791. ]);
  25792. }
  25793. return hash;
  25794. }();
  25795. var Word64 = function Word64Closure() {
  25796. function Word64(highInteger, lowInteger) {
  25797. this.high = highInteger | 0;
  25798. this.low = lowInteger | 0;
  25799. }
  25800. Word64.prototype = {
  25801. and: function Word64_and(word) {
  25802. this.high &= word.high;
  25803. this.low &= word.low;
  25804. },
  25805. xor: function Word64_xor(word) {
  25806. this.high ^= word.high;
  25807. this.low ^= word.low;
  25808. },
  25809. or: function Word64_or(word) {
  25810. this.high |= word.high;
  25811. this.low |= word.low;
  25812. },
  25813. shiftRight: function Word64_shiftRight(places) {
  25814. if (places >= 32) {
  25815. this.low = this.high >>> places - 32 | 0;
  25816. this.high = 0;
  25817. } else {
  25818. this.low = this.low >>> places | this.high << 32 - places;
  25819. this.high = this.high >>> places | 0;
  25820. }
  25821. },
  25822. shiftLeft: function Word64_shiftLeft(places) {
  25823. if (places >= 32) {
  25824. this.high = this.low << places - 32;
  25825. this.low = 0;
  25826. } else {
  25827. this.high = this.high << places | this.low >>> 32 - places;
  25828. this.low = this.low << places;
  25829. }
  25830. },
  25831. rotateRight: function Word64_rotateRight(places) {
  25832. var low, high;
  25833. if (places & 32) {
  25834. high = this.low;
  25835. low = this.high;
  25836. } else {
  25837. low = this.low;
  25838. high = this.high;
  25839. }
  25840. places &= 31;
  25841. this.low = low >>> places | high << 32 - places;
  25842. this.high = high >>> places | low << 32 - places;
  25843. },
  25844. not: function Word64_not() {
  25845. this.high = ~this.high;
  25846. this.low = ~this.low;
  25847. },
  25848. add: function Word64_add(word) {
  25849. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  25850. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  25851. if (lowAdd > 0xFFFFFFFF) {
  25852. highAdd += 1;
  25853. }
  25854. this.low = lowAdd | 0;
  25855. this.high = highAdd | 0;
  25856. },
  25857. copyTo: function Word64_copyTo(bytes, offset) {
  25858. bytes[offset] = this.high >>> 24 & 0xFF;
  25859. bytes[offset + 1] = this.high >> 16 & 0xFF;
  25860. bytes[offset + 2] = this.high >> 8 & 0xFF;
  25861. bytes[offset + 3] = this.high & 0xFF;
  25862. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  25863. bytes[offset + 5] = this.low >> 16 & 0xFF;
  25864. bytes[offset + 6] = this.low >> 8 & 0xFF;
  25865. bytes[offset + 7] = this.low & 0xFF;
  25866. },
  25867. assign: function Word64_assign(word) {
  25868. this.high = word.high;
  25869. this.low = word.low;
  25870. }
  25871. };
  25872. return Word64;
  25873. }();
  25874. var calculateSHA256 = function calculateSHA256Closure() {
  25875. function rotr(x, n) {
  25876. return x >>> n | x << 32 - n;
  25877. }
  25878. function ch(x, y, z) {
  25879. return x & y ^ ~x & z;
  25880. }
  25881. function maj(x, y, z) {
  25882. return x & y ^ x & z ^ y & z;
  25883. }
  25884. function sigma(x) {
  25885. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  25886. }
  25887. function sigmaPrime(x) {
  25888. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  25889. }
  25890. function littleSigma(x) {
  25891. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  25892. }
  25893. function littleSigmaPrime(x) {
  25894. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  25895. }
  25896. var k = [
  25897. 0x428a2f98,
  25898. 0x71374491,
  25899. 0xb5c0fbcf,
  25900. 0xe9b5dba5,
  25901. 0x3956c25b,
  25902. 0x59f111f1,
  25903. 0x923f82a4,
  25904. 0xab1c5ed5,
  25905. 0xd807aa98,
  25906. 0x12835b01,
  25907. 0x243185be,
  25908. 0x550c7dc3,
  25909. 0x72be5d74,
  25910. 0x80deb1fe,
  25911. 0x9bdc06a7,
  25912. 0xc19bf174,
  25913. 0xe49b69c1,
  25914. 0xefbe4786,
  25915. 0x0fc19dc6,
  25916. 0x240ca1cc,
  25917. 0x2de92c6f,
  25918. 0x4a7484aa,
  25919. 0x5cb0a9dc,
  25920. 0x76f988da,
  25921. 0x983e5152,
  25922. 0xa831c66d,
  25923. 0xb00327c8,
  25924. 0xbf597fc7,
  25925. 0xc6e00bf3,
  25926. 0xd5a79147,
  25927. 0x06ca6351,
  25928. 0x14292967,
  25929. 0x27b70a85,
  25930. 0x2e1b2138,
  25931. 0x4d2c6dfc,
  25932. 0x53380d13,
  25933. 0x650a7354,
  25934. 0x766a0abb,
  25935. 0x81c2c92e,
  25936. 0x92722c85,
  25937. 0xa2bfe8a1,
  25938. 0xa81a664b,
  25939. 0xc24b8b70,
  25940. 0xc76c51a3,
  25941. 0xd192e819,
  25942. 0xd6990624,
  25943. 0xf40e3585,
  25944. 0x106aa070,
  25945. 0x19a4c116,
  25946. 0x1e376c08,
  25947. 0x2748774c,
  25948. 0x34b0bcb5,
  25949. 0x391c0cb3,
  25950. 0x4ed8aa4a,
  25951. 0x5b9cca4f,
  25952. 0x682e6ff3,
  25953. 0x748f82ee,
  25954. 0x78a5636f,
  25955. 0x84c87814,
  25956. 0x8cc70208,
  25957. 0x90befffa,
  25958. 0xa4506ceb,
  25959. 0xbef9a3f7,
  25960. 0xc67178f2
  25961. ];
  25962. function hash(data, offset, length) {
  25963. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  25964. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  25965. var padded = new Uint8Array(paddedLength);
  25966. var i, j, n;
  25967. for (i = 0; i < length; ++i) {
  25968. padded[i] = data[offset++];
  25969. }
  25970. padded[i++] = 0x80;
  25971. n = paddedLength - 8;
  25972. while (i < n) {
  25973. padded[i++] = 0;
  25974. }
  25975. padded[i++] = 0;
  25976. padded[i++] = 0;
  25977. padded[i++] = 0;
  25978. padded[i++] = length >>> 29 & 0xFF;
  25979. padded[i++] = length >> 21 & 0xFF;
  25980. padded[i++] = length >> 13 & 0xFF;
  25981. padded[i++] = length >> 5 & 0xFF;
  25982. padded[i++] = length << 3 & 0xFF;
  25983. var w = new Uint32Array(64);
  25984. for (i = 0; i < paddedLength;) {
  25985. for (j = 0; j < 16; ++j) {
  25986. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25987. i += 4;
  25988. }
  25989. for (j = 16; j < 64; ++j) {
  25990. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  25991. }
  25992. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  25993. for (j = 0; j < 64; ++j) {
  25994. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  25995. t2 = sigma(a) + maj(a, b, c);
  25996. h = g;
  25997. g = f;
  25998. f = e;
  25999. e = d + t1 | 0;
  26000. d = c;
  26001. c = b;
  26002. b = a;
  26003. a = t1 + t2 | 0;
  26004. }
  26005. h0 = h0 + a | 0;
  26006. h1 = h1 + b | 0;
  26007. h2 = h2 + c | 0;
  26008. h3 = h3 + d | 0;
  26009. h4 = h4 + e | 0;
  26010. h5 = h5 + f | 0;
  26011. h6 = h6 + g | 0;
  26012. h7 = h7 + h | 0;
  26013. }
  26014. return new Uint8Array([
  26015. h0 >> 24 & 0xFF,
  26016. h0 >> 16 & 0xFF,
  26017. h0 >> 8 & 0xFF,
  26018. h0 & 0xFF,
  26019. h1 >> 24 & 0xFF,
  26020. h1 >> 16 & 0xFF,
  26021. h1 >> 8 & 0xFF,
  26022. h1 & 0xFF,
  26023. h2 >> 24 & 0xFF,
  26024. h2 >> 16 & 0xFF,
  26025. h2 >> 8 & 0xFF,
  26026. h2 & 0xFF,
  26027. h3 >> 24 & 0xFF,
  26028. h3 >> 16 & 0xFF,
  26029. h3 >> 8 & 0xFF,
  26030. h3 & 0xFF,
  26031. h4 >> 24 & 0xFF,
  26032. h4 >> 16 & 0xFF,
  26033. h4 >> 8 & 0xFF,
  26034. h4 & 0xFF,
  26035. h5 >> 24 & 0xFF,
  26036. h5 >> 16 & 0xFF,
  26037. h5 >> 8 & 0xFF,
  26038. h5 & 0xFF,
  26039. h6 >> 24 & 0xFF,
  26040. h6 >> 16 & 0xFF,
  26041. h6 >> 8 & 0xFF,
  26042. h6 & 0xFF,
  26043. h7 >> 24 & 0xFF,
  26044. h7 >> 16 & 0xFF,
  26045. h7 >> 8 & 0xFF,
  26046. h7 & 0xFF
  26047. ]);
  26048. }
  26049. return hash;
  26050. }();
  26051. var calculateSHA512 = function calculateSHA512Closure() {
  26052. function ch(result, x, y, z, tmp) {
  26053. result.assign(x);
  26054. result.and(y);
  26055. tmp.assign(x);
  26056. tmp.not();
  26057. tmp.and(z);
  26058. result.xor(tmp);
  26059. }
  26060. function maj(result, x, y, z, tmp) {
  26061. result.assign(x);
  26062. result.and(y);
  26063. tmp.assign(x);
  26064. tmp.and(z);
  26065. result.xor(tmp);
  26066. tmp.assign(y);
  26067. tmp.and(z);
  26068. result.xor(tmp);
  26069. }
  26070. function sigma(result, x, tmp) {
  26071. result.assign(x);
  26072. result.rotateRight(28);
  26073. tmp.assign(x);
  26074. tmp.rotateRight(34);
  26075. result.xor(tmp);
  26076. tmp.assign(x);
  26077. tmp.rotateRight(39);
  26078. result.xor(tmp);
  26079. }
  26080. function sigmaPrime(result, x, tmp) {
  26081. result.assign(x);
  26082. result.rotateRight(14);
  26083. tmp.assign(x);
  26084. tmp.rotateRight(18);
  26085. result.xor(tmp);
  26086. tmp.assign(x);
  26087. tmp.rotateRight(41);
  26088. result.xor(tmp);
  26089. }
  26090. function littleSigma(result, x, tmp) {
  26091. result.assign(x);
  26092. result.rotateRight(1);
  26093. tmp.assign(x);
  26094. tmp.rotateRight(8);
  26095. result.xor(tmp);
  26096. tmp.assign(x);
  26097. tmp.shiftRight(7);
  26098. result.xor(tmp);
  26099. }
  26100. function littleSigmaPrime(result, x, tmp) {
  26101. result.assign(x);
  26102. result.rotateRight(19);
  26103. tmp.assign(x);
  26104. tmp.rotateRight(61);
  26105. result.xor(tmp);
  26106. tmp.assign(x);
  26107. tmp.shiftRight(6);
  26108. result.xor(tmp);
  26109. }
  26110. var k = [
  26111. new Word64(0x428a2f98, 0xd728ae22),
  26112. new Word64(0x71374491, 0x23ef65cd),
  26113. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  26114. new Word64(0xe9b5dba5, 0x8189dbbc),
  26115. new Word64(0x3956c25b, 0xf348b538),
  26116. new Word64(0x59f111f1, 0xb605d019),
  26117. new Word64(0x923f82a4, 0xaf194f9b),
  26118. new Word64(0xab1c5ed5, 0xda6d8118),
  26119. new Word64(0xd807aa98, 0xa3030242),
  26120. new Word64(0x12835b01, 0x45706fbe),
  26121. new Word64(0x243185be, 0x4ee4b28c),
  26122. new Word64(0x550c7dc3, 0xd5ffb4e2),
  26123. new Word64(0x72be5d74, 0xf27b896f),
  26124. new Word64(0x80deb1fe, 0x3b1696b1),
  26125. new Word64(0x9bdc06a7, 0x25c71235),
  26126. new Word64(0xc19bf174, 0xcf692694),
  26127. new Word64(0xe49b69c1, 0x9ef14ad2),
  26128. new Word64(0xefbe4786, 0x384f25e3),
  26129. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  26130. new Word64(0x240ca1cc, 0x77ac9c65),
  26131. new Word64(0x2de92c6f, 0x592b0275),
  26132. new Word64(0x4a7484aa, 0x6ea6e483),
  26133. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  26134. new Word64(0x76f988da, 0x831153b5),
  26135. new Word64(0x983e5152, 0xee66dfab),
  26136. new Word64(0xa831c66d, 0x2db43210),
  26137. new Word64(0xb00327c8, 0x98fb213f),
  26138. new Word64(0xbf597fc7, 0xbeef0ee4),
  26139. new Word64(0xc6e00bf3, 0x3da88fc2),
  26140. new Word64(0xd5a79147, 0x930aa725),
  26141. new Word64(0x06ca6351, 0xe003826f),
  26142. new Word64(0x14292967, 0x0a0e6e70),
  26143. new Word64(0x27b70a85, 0x46d22ffc),
  26144. new Word64(0x2e1b2138, 0x5c26c926),
  26145. new Word64(0x4d2c6dfc, 0x5ac42aed),
  26146. new Word64(0x53380d13, 0x9d95b3df),
  26147. new Word64(0x650a7354, 0x8baf63de),
  26148. new Word64(0x766a0abb, 0x3c77b2a8),
  26149. new Word64(0x81c2c92e, 0x47edaee6),
  26150. new Word64(0x92722c85, 0x1482353b),
  26151. new Word64(0xa2bfe8a1, 0x4cf10364),
  26152. new Word64(0xa81a664b, 0xbc423001),
  26153. new Word64(0xc24b8b70, 0xd0f89791),
  26154. new Word64(0xc76c51a3, 0x0654be30),
  26155. new Word64(0xd192e819, 0xd6ef5218),
  26156. new Word64(0xd6990624, 0x5565a910),
  26157. new Word64(0xf40e3585, 0x5771202a),
  26158. new Word64(0x106aa070, 0x32bbd1b8),
  26159. new Word64(0x19a4c116, 0xb8d2d0c8),
  26160. new Word64(0x1e376c08, 0x5141ab53),
  26161. new Word64(0x2748774c, 0xdf8eeb99),
  26162. new Word64(0x34b0bcb5, 0xe19b48a8),
  26163. new Word64(0x391c0cb3, 0xc5c95a63),
  26164. new Word64(0x4ed8aa4a, 0xe3418acb),
  26165. new Word64(0x5b9cca4f, 0x7763e373),
  26166. new Word64(0x682e6ff3, 0xd6b2b8a3),
  26167. new Word64(0x748f82ee, 0x5defb2fc),
  26168. new Word64(0x78a5636f, 0x43172f60),
  26169. new Word64(0x84c87814, 0xa1f0ab72),
  26170. new Word64(0x8cc70208, 0x1a6439ec),
  26171. new Word64(0x90befffa, 0x23631e28),
  26172. new Word64(0xa4506ceb, 0xde82bde9),
  26173. new Word64(0xbef9a3f7, 0xb2c67915),
  26174. new Word64(0xc67178f2, 0xe372532b),
  26175. new Word64(0xca273ece, 0xea26619c),
  26176. new Word64(0xd186b8c7, 0x21c0c207),
  26177. new Word64(0xeada7dd6, 0xcde0eb1e),
  26178. new Word64(0xf57d4f7f, 0xee6ed178),
  26179. new Word64(0x06f067aa, 0x72176fba),
  26180. new Word64(0x0a637dc5, 0xa2c898a6),
  26181. new Word64(0x113f9804, 0xbef90dae),
  26182. new Word64(0x1b710b35, 0x131c471b),
  26183. new Word64(0x28db77f5, 0x23047d84),
  26184. new Word64(0x32caab7b, 0x40c72493),
  26185. new Word64(0x3c9ebe0a, 0x15c9bebc),
  26186. new Word64(0x431d67c4, 0x9c100d4c),
  26187. new Word64(0x4cc5d4be, 0xcb3e42b6),
  26188. new Word64(0x597f299c, 0xfc657e2a),
  26189. new Word64(0x5fcb6fab, 0x3ad6faec),
  26190. new Word64(0x6c44198c, 0x4a475817)
  26191. ];
  26192. function hash(data, offset, length, mode384) {
  26193. mode384 = !!mode384;
  26194. var h0, h1, h2, h3, h4, h5, h6, h7;
  26195. if (!mode384) {
  26196. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  26197. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  26198. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  26199. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  26200. h4 = new Word64(0x510e527f, 0xade682d1);
  26201. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  26202. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  26203. h7 = new Word64(0x5be0cd19, 0x137e2179);
  26204. } else {
  26205. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  26206. h1 = new Word64(0x629a292a, 0x367cd507);
  26207. h2 = new Word64(0x9159015a, 0x3070dd17);
  26208. h3 = new Word64(0x152fecd8, 0xf70e5939);
  26209. h4 = new Word64(0x67332667, 0xffc00b31);
  26210. h5 = new Word64(0x8eb44a87, 0x68581511);
  26211. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  26212. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  26213. }
  26214. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  26215. var padded = new Uint8Array(paddedLength);
  26216. var i, j, n;
  26217. for (i = 0; i < length; ++i) {
  26218. padded[i] = data[offset++];
  26219. }
  26220. padded[i++] = 0x80;
  26221. n = paddedLength - 16;
  26222. while (i < n) {
  26223. padded[i++] = 0;
  26224. }
  26225. padded[i++] = 0;
  26226. padded[i++] = 0;
  26227. padded[i++] = 0;
  26228. padded[i++] = 0;
  26229. padded[i++] = 0;
  26230. padded[i++] = 0;
  26231. padded[i++] = 0;
  26232. padded[i++] = 0;
  26233. padded[i++] = 0;
  26234. padded[i++] = 0;
  26235. padded[i++] = 0;
  26236. padded[i++] = length >>> 29 & 0xFF;
  26237. padded[i++] = length >> 21 & 0xFF;
  26238. padded[i++] = length >> 13 & 0xFF;
  26239. padded[i++] = length >> 5 & 0xFF;
  26240. padded[i++] = length << 3 & 0xFF;
  26241. var w = new Array(80);
  26242. for (i = 0; i < 80; i++) {
  26243. w[i] = new Word64(0, 0);
  26244. }
  26245. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  26246. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  26247. var g = new Word64(0, 0), h = new Word64(0, 0);
  26248. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  26249. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  26250. for (i = 0; i < paddedLength;) {
  26251. for (j = 0; j < 16; ++j) {
  26252. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  26253. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  26254. i += 8;
  26255. }
  26256. for (j = 16; j < 80; ++j) {
  26257. tmp3 = w[j];
  26258. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  26259. tmp3.add(w[j - 7]);
  26260. littleSigma(tmp1, w[j - 15], tmp2);
  26261. tmp3.add(tmp1);
  26262. tmp3.add(w[j - 16]);
  26263. }
  26264. a.assign(h0);
  26265. b.assign(h1);
  26266. c.assign(h2);
  26267. d.assign(h3);
  26268. e.assign(h4);
  26269. f.assign(h5);
  26270. g.assign(h6);
  26271. h.assign(h7);
  26272. for (j = 0; j < 80; ++j) {
  26273. t1.assign(h);
  26274. sigmaPrime(tmp1, e, tmp2);
  26275. t1.add(tmp1);
  26276. ch(tmp1, e, f, g, tmp2);
  26277. t1.add(tmp1);
  26278. t1.add(k[j]);
  26279. t1.add(w[j]);
  26280. sigma(t2, a, tmp2);
  26281. maj(tmp1, a, b, c, tmp2);
  26282. t2.add(tmp1);
  26283. tmp3 = h;
  26284. h = g;
  26285. g = f;
  26286. f = e;
  26287. d.add(t1);
  26288. e = d;
  26289. d = c;
  26290. c = b;
  26291. b = a;
  26292. tmp3.assign(t1);
  26293. tmp3.add(t2);
  26294. a = tmp3;
  26295. }
  26296. h0.add(a);
  26297. h1.add(b);
  26298. h2.add(c);
  26299. h3.add(d);
  26300. h4.add(e);
  26301. h5.add(f);
  26302. h6.add(g);
  26303. h7.add(h);
  26304. }
  26305. var result;
  26306. if (!mode384) {
  26307. result = new Uint8Array(64);
  26308. h0.copyTo(result, 0);
  26309. h1.copyTo(result, 8);
  26310. h2.copyTo(result, 16);
  26311. h3.copyTo(result, 24);
  26312. h4.copyTo(result, 32);
  26313. h5.copyTo(result, 40);
  26314. h6.copyTo(result, 48);
  26315. h7.copyTo(result, 56);
  26316. } else {
  26317. result = new Uint8Array(48);
  26318. h0.copyTo(result, 0);
  26319. h1.copyTo(result, 8);
  26320. h2.copyTo(result, 16);
  26321. h3.copyTo(result, 24);
  26322. h4.copyTo(result, 32);
  26323. h5.copyTo(result, 40);
  26324. }
  26325. return result;
  26326. }
  26327. return hash;
  26328. }();
  26329. var calculateSHA384 = function calculateSHA384Closure() {
  26330. function hash(data, offset, length) {
  26331. return calculateSHA512(data, offset, length, true);
  26332. }
  26333. return hash;
  26334. }();
  26335. var NullCipher = function NullCipherClosure() {
  26336. function NullCipher() {
  26337. }
  26338. NullCipher.prototype = {
  26339. decryptBlock: function NullCipher_decryptBlock(data) {
  26340. return data;
  26341. }
  26342. };
  26343. return NullCipher;
  26344. }();
  26345. var AES128Cipher = function AES128CipherClosure() {
  26346. var rcon = new Uint8Array([
  26347. 0x8d,
  26348. 0x01,
  26349. 0x02,
  26350. 0x04,
  26351. 0x08,
  26352. 0x10,
  26353. 0x20,
  26354. 0x40,
  26355. 0x80,
  26356. 0x1b,
  26357. 0x36,
  26358. 0x6c,
  26359. 0xd8,
  26360. 0xab,
  26361. 0x4d,
  26362. 0x9a,
  26363. 0x2f,
  26364. 0x5e,
  26365. 0xbc,
  26366. 0x63,
  26367. 0xc6,
  26368. 0x97,
  26369. 0x35,
  26370. 0x6a,
  26371. 0xd4,
  26372. 0xb3,
  26373. 0x7d,
  26374. 0xfa,
  26375. 0xef,
  26376. 0xc5,
  26377. 0x91,
  26378. 0x39,
  26379. 0x72,
  26380. 0xe4,
  26381. 0xd3,
  26382. 0xbd,
  26383. 0x61,
  26384. 0xc2,
  26385. 0x9f,
  26386. 0x25,
  26387. 0x4a,
  26388. 0x94,
  26389. 0x33,
  26390. 0x66,
  26391. 0xcc,
  26392. 0x83,
  26393. 0x1d,
  26394. 0x3a,
  26395. 0x74,
  26396. 0xe8,
  26397. 0xcb,
  26398. 0x8d,
  26399. 0x01,
  26400. 0x02,
  26401. 0x04,
  26402. 0x08,
  26403. 0x10,
  26404. 0x20,
  26405. 0x40,
  26406. 0x80,
  26407. 0x1b,
  26408. 0x36,
  26409. 0x6c,
  26410. 0xd8,
  26411. 0xab,
  26412. 0x4d,
  26413. 0x9a,
  26414. 0x2f,
  26415. 0x5e,
  26416. 0xbc,
  26417. 0x63,
  26418. 0xc6,
  26419. 0x97,
  26420. 0x35,
  26421. 0x6a,
  26422. 0xd4,
  26423. 0xb3,
  26424. 0x7d,
  26425. 0xfa,
  26426. 0xef,
  26427. 0xc5,
  26428. 0x91,
  26429. 0x39,
  26430. 0x72,
  26431. 0xe4,
  26432. 0xd3,
  26433. 0xbd,
  26434. 0x61,
  26435. 0xc2,
  26436. 0x9f,
  26437. 0x25,
  26438. 0x4a,
  26439. 0x94,
  26440. 0x33,
  26441. 0x66,
  26442. 0xcc,
  26443. 0x83,
  26444. 0x1d,
  26445. 0x3a,
  26446. 0x74,
  26447. 0xe8,
  26448. 0xcb,
  26449. 0x8d,
  26450. 0x01,
  26451. 0x02,
  26452. 0x04,
  26453. 0x08,
  26454. 0x10,
  26455. 0x20,
  26456. 0x40,
  26457. 0x80,
  26458. 0x1b,
  26459. 0x36,
  26460. 0x6c,
  26461. 0xd8,
  26462. 0xab,
  26463. 0x4d,
  26464. 0x9a,
  26465. 0x2f,
  26466. 0x5e,
  26467. 0xbc,
  26468. 0x63,
  26469. 0xc6,
  26470. 0x97,
  26471. 0x35,
  26472. 0x6a,
  26473. 0xd4,
  26474. 0xb3,
  26475. 0x7d,
  26476. 0xfa,
  26477. 0xef,
  26478. 0xc5,
  26479. 0x91,
  26480. 0x39,
  26481. 0x72,
  26482. 0xe4,
  26483. 0xd3,
  26484. 0xbd,
  26485. 0x61,
  26486. 0xc2,
  26487. 0x9f,
  26488. 0x25,
  26489. 0x4a,
  26490. 0x94,
  26491. 0x33,
  26492. 0x66,
  26493. 0xcc,
  26494. 0x83,
  26495. 0x1d,
  26496. 0x3a,
  26497. 0x74,
  26498. 0xe8,
  26499. 0xcb,
  26500. 0x8d,
  26501. 0x01,
  26502. 0x02,
  26503. 0x04,
  26504. 0x08,
  26505. 0x10,
  26506. 0x20,
  26507. 0x40,
  26508. 0x80,
  26509. 0x1b,
  26510. 0x36,
  26511. 0x6c,
  26512. 0xd8,
  26513. 0xab,
  26514. 0x4d,
  26515. 0x9a,
  26516. 0x2f,
  26517. 0x5e,
  26518. 0xbc,
  26519. 0x63,
  26520. 0xc6,
  26521. 0x97,
  26522. 0x35,
  26523. 0x6a,
  26524. 0xd4,
  26525. 0xb3,
  26526. 0x7d,
  26527. 0xfa,
  26528. 0xef,
  26529. 0xc5,
  26530. 0x91,
  26531. 0x39,
  26532. 0x72,
  26533. 0xe4,
  26534. 0xd3,
  26535. 0xbd,
  26536. 0x61,
  26537. 0xc2,
  26538. 0x9f,
  26539. 0x25,
  26540. 0x4a,
  26541. 0x94,
  26542. 0x33,
  26543. 0x66,
  26544. 0xcc,
  26545. 0x83,
  26546. 0x1d,
  26547. 0x3a,
  26548. 0x74,
  26549. 0xe8,
  26550. 0xcb,
  26551. 0x8d,
  26552. 0x01,
  26553. 0x02,
  26554. 0x04,
  26555. 0x08,
  26556. 0x10,
  26557. 0x20,
  26558. 0x40,
  26559. 0x80,
  26560. 0x1b,
  26561. 0x36,
  26562. 0x6c,
  26563. 0xd8,
  26564. 0xab,
  26565. 0x4d,
  26566. 0x9a,
  26567. 0x2f,
  26568. 0x5e,
  26569. 0xbc,
  26570. 0x63,
  26571. 0xc6,
  26572. 0x97,
  26573. 0x35,
  26574. 0x6a,
  26575. 0xd4,
  26576. 0xb3,
  26577. 0x7d,
  26578. 0xfa,
  26579. 0xef,
  26580. 0xc5,
  26581. 0x91,
  26582. 0x39,
  26583. 0x72,
  26584. 0xe4,
  26585. 0xd3,
  26586. 0xbd,
  26587. 0x61,
  26588. 0xc2,
  26589. 0x9f,
  26590. 0x25,
  26591. 0x4a,
  26592. 0x94,
  26593. 0x33,
  26594. 0x66,
  26595. 0xcc,
  26596. 0x83,
  26597. 0x1d,
  26598. 0x3a,
  26599. 0x74,
  26600. 0xe8,
  26601. 0xcb,
  26602. 0x8d
  26603. ]);
  26604. var s = new Uint8Array([
  26605. 0x63,
  26606. 0x7c,
  26607. 0x77,
  26608. 0x7b,
  26609. 0xf2,
  26610. 0x6b,
  26611. 0x6f,
  26612. 0xc5,
  26613. 0x30,
  26614. 0x01,
  26615. 0x67,
  26616. 0x2b,
  26617. 0xfe,
  26618. 0xd7,
  26619. 0xab,
  26620. 0x76,
  26621. 0xca,
  26622. 0x82,
  26623. 0xc9,
  26624. 0x7d,
  26625. 0xfa,
  26626. 0x59,
  26627. 0x47,
  26628. 0xf0,
  26629. 0xad,
  26630. 0xd4,
  26631. 0xa2,
  26632. 0xaf,
  26633. 0x9c,
  26634. 0xa4,
  26635. 0x72,
  26636. 0xc0,
  26637. 0xb7,
  26638. 0xfd,
  26639. 0x93,
  26640. 0x26,
  26641. 0x36,
  26642. 0x3f,
  26643. 0xf7,
  26644. 0xcc,
  26645. 0x34,
  26646. 0xa5,
  26647. 0xe5,
  26648. 0xf1,
  26649. 0x71,
  26650. 0xd8,
  26651. 0x31,
  26652. 0x15,
  26653. 0x04,
  26654. 0xc7,
  26655. 0x23,
  26656. 0xc3,
  26657. 0x18,
  26658. 0x96,
  26659. 0x05,
  26660. 0x9a,
  26661. 0x07,
  26662. 0x12,
  26663. 0x80,
  26664. 0xe2,
  26665. 0xeb,
  26666. 0x27,
  26667. 0xb2,
  26668. 0x75,
  26669. 0x09,
  26670. 0x83,
  26671. 0x2c,
  26672. 0x1a,
  26673. 0x1b,
  26674. 0x6e,
  26675. 0x5a,
  26676. 0xa0,
  26677. 0x52,
  26678. 0x3b,
  26679. 0xd6,
  26680. 0xb3,
  26681. 0x29,
  26682. 0xe3,
  26683. 0x2f,
  26684. 0x84,
  26685. 0x53,
  26686. 0xd1,
  26687. 0x00,
  26688. 0xed,
  26689. 0x20,
  26690. 0xfc,
  26691. 0xb1,
  26692. 0x5b,
  26693. 0x6a,
  26694. 0xcb,
  26695. 0xbe,
  26696. 0x39,
  26697. 0x4a,
  26698. 0x4c,
  26699. 0x58,
  26700. 0xcf,
  26701. 0xd0,
  26702. 0xef,
  26703. 0xaa,
  26704. 0xfb,
  26705. 0x43,
  26706. 0x4d,
  26707. 0x33,
  26708. 0x85,
  26709. 0x45,
  26710. 0xf9,
  26711. 0x02,
  26712. 0x7f,
  26713. 0x50,
  26714. 0x3c,
  26715. 0x9f,
  26716. 0xa8,
  26717. 0x51,
  26718. 0xa3,
  26719. 0x40,
  26720. 0x8f,
  26721. 0x92,
  26722. 0x9d,
  26723. 0x38,
  26724. 0xf5,
  26725. 0xbc,
  26726. 0xb6,
  26727. 0xda,
  26728. 0x21,
  26729. 0x10,
  26730. 0xff,
  26731. 0xf3,
  26732. 0xd2,
  26733. 0xcd,
  26734. 0x0c,
  26735. 0x13,
  26736. 0xec,
  26737. 0x5f,
  26738. 0x97,
  26739. 0x44,
  26740. 0x17,
  26741. 0xc4,
  26742. 0xa7,
  26743. 0x7e,
  26744. 0x3d,
  26745. 0x64,
  26746. 0x5d,
  26747. 0x19,
  26748. 0x73,
  26749. 0x60,
  26750. 0x81,
  26751. 0x4f,
  26752. 0xdc,
  26753. 0x22,
  26754. 0x2a,
  26755. 0x90,
  26756. 0x88,
  26757. 0x46,
  26758. 0xee,
  26759. 0xb8,
  26760. 0x14,
  26761. 0xde,
  26762. 0x5e,
  26763. 0x0b,
  26764. 0xdb,
  26765. 0xe0,
  26766. 0x32,
  26767. 0x3a,
  26768. 0x0a,
  26769. 0x49,
  26770. 0x06,
  26771. 0x24,
  26772. 0x5c,
  26773. 0xc2,
  26774. 0xd3,
  26775. 0xac,
  26776. 0x62,
  26777. 0x91,
  26778. 0x95,
  26779. 0xe4,
  26780. 0x79,
  26781. 0xe7,
  26782. 0xc8,
  26783. 0x37,
  26784. 0x6d,
  26785. 0x8d,
  26786. 0xd5,
  26787. 0x4e,
  26788. 0xa9,
  26789. 0x6c,
  26790. 0x56,
  26791. 0xf4,
  26792. 0xea,
  26793. 0x65,
  26794. 0x7a,
  26795. 0xae,
  26796. 0x08,
  26797. 0xba,
  26798. 0x78,
  26799. 0x25,
  26800. 0x2e,
  26801. 0x1c,
  26802. 0xa6,
  26803. 0xb4,
  26804. 0xc6,
  26805. 0xe8,
  26806. 0xdd,
  26807. 0x74,
  26808. 0x1f,
  26809. 0x4b,
  26810. 0xbd,
  26811. 0x8b,
  26812. 0x8a,
  26813. 0x70,
  26814. 0x3e,
  26815. 0xb5,
  26816. 0x66,
  26817. 0x48,
  26818. 0x03,
  26819. 0xf6,
  26820. 0x0e,
  26821. 0x61,
  26822. 0x35,
  26823. 0x57,
  26824. 0xb9,
  26825. 0x86,
  26826. 0xc1,
  26827. 0x1d,
  26828. 0x9e,
  26829. 0xe1,
  26830. 0xf8,
  26831. 0x98,
  26832. 0x11,
  26833. 0x69,
  26834. 0xd9,
  26835. 0x8e,
  26836. 0x94,
  26837. 0x9b,
  26838. 0x1e,
  26839. 0x87,
  26840. 0xe9,
  26841. 0xce,
  26842. 0x55,
  26843. 0x28,
  26844. 0xdf,
  26845. 0x8c,
  26846. 0xa1,
  26847. 0x89,
  26848. 0x0d,
  26849. 0xbf,
  26850. 0xe6,
  26851. 0x42,
  26852. 0x68,
  26853. 0x41,
  26854. 0x99,
  26855. 0x2d,
  26856. 0x0f,
  26857. 0xb0,
  26858. 0x54,
  26859. 0xbb,
  26860. 0x16
  26861. ]);
  26862. var inv_s = new Uint8Array([
  26863. 0x52,
  26864. 0x09,
  26865. 0x6a,
  26866. 0xd5,
  26867. 0x30,
  26868. 0x36,
  26869. 0xa5,
  26870. 0x38,
  26871. 0xbf,
  26872. 0x40,
  26873. 0xa3,
  26874. 0x9e,
  26875. 0x81,
  26876. 0xf3,
  26877. 0xd7,
  26878. 0xfb,
  26879. 0x7c,
  26880. 0xe3,
  26881. 0x39,
  26882. 0x82,
  26883. 0x9b,
  26884. 0x2f,
  26885. 0xff,
  26886. 0x87,
  26887. 0x34,
  26888. 0x8e,
  26889. 0x43,
  26890. 0x44,
  26891. 0xc4,
  26892. 0xde,
  26893. 0xe9,
  26894. 0xcb,
  26895. 0x54,
  26896. 0x7b,
  26897. 0x94,
  26898. 0x32,
  26899. 0xa6,
  26900. 0xc2,
  26901. 0x23,
  26902. 0x3d,
  26903. 0xee,
  26904. 0x4c,
  26905. 0x95,
  26906. 0x0b,
  26907. 0x42,
  26908. 0xfa,
  26909. 0xc3,
  26910. 0x4e,
  26911. 0x08,
  26912. 0x2e,
  26913. 0xa1,
  26914. 0x66,
  26915. 0x28,
  26916. 0xd9,
  26917. 0x24,
  26918. 0xb2,
  26919. 0x76,
  26920. 0x5b,
  26921. 0xa2,
  26922. 0x49,
  26923. 0x6d,
  26924. 0x8b,
  26925. 0xd1,
  26926. 0x25,
  26927. 0x72,
  26928. 0xf8,
  26929. 0xf6,
  26930. 0x64,
  26931. 0x86,
  26932. 0x68,
  26933. 0x98,
  26934. 0x16,
  26935. 0xd4,
  26936. 0xa4,
  26937. 0x5c,
  26938. 0xcc,
  26939. 0x5d,
  26940. 0x65,
  26941. 0xb6,
  26942. 0x92,
  26943. 0x6c,
  26944. 0x70,
  26945. 0x48,
  26946. 0x50,
  26947. 0xfd,
  26948. 0xed,
  26949. 0xb9,
  26950. 0xda,
  26951. 0x5e,
  26952. 0x15,
  26953. 0x46,
  26954. 0x57,
  26955. 0xa7,
  26956. 0x8d,
  26957. 0x9d,
  26958. 0x84,
  26959. 0x90,
  26960. 0xd8,
  26961. 0xab,
  26962. 0x00,
  26963. 0x8c,
  26964. 0xbc,
  26965. 0xd3,
  26966. 0x0a,
  26967. 0xf7,
  26968. 0xe4,
  26969. 0x58,
  26970. 0x05,
  26971. 0xb8,
  26972. 0xb3,
  26973. 0x45,
  26974. 0x06,
  26975. 0xd0,
  26976. 0x2c,
  26977. 0x1e,
  26978. 0x8f,
  26979. 0xca,
  26980. 0x3f,
  26981. 0x0f,
  26982. 0x02,
  26983. 0xc1,
  26984. 0xaf,
  26985. 0xbd,
  26986. 0x03,
  26987. 0x01,
  26988. 0x13,
  26989. 0x8a,
  26990. 0x6b,
  26991. 0x3a,
  26992. 0x91,
  26993. 0x11,
  26994. 0x41,
  26995. 0x4f,
  26996. 0x67,
  26997. 0xdc,
  26998. 0xea,
  26999. 0x97,
  27000. 0xf2,
  27001. 0xcf,
  27002. 0xce,
  27003. 0xf0,
  27004. 0xb4,
  27005. 0xe6,
  27006. 0x73,
  27007. 0x96,
  27008. 0xac,
  27009. 0x74,
  27010. 0x22,
  27011. 0xe7,
  27012. 0xad,
  27013. 0x35,
  27014. 0x85,
  27015. 0xe2,
  27016. 0xf9,
  27017. 0x37,
  27018. 0xe8,
  27019. 0x1c,
  27020. 0x75,
  27021. 0xdf,
  27022. 0x6e,
  27023. 0x47,
  27024. 0xf1,
  27025. 0x1a,
  27026. 0x71,
  27027. 0x1d,
  27028. 0x29,
  27029. 0xc5,
  27030. 0x89,
  27031. 0x6f,
  27032. 0xb7,
  27033. 0x62,
  27034. 0x0e,
  27035. 0xaa,
  27036. 0x18,
  27037. 0xbe,
  27038. 0x1b,
  27039. 0xfc,
  27040. 0x56,
  27041. 0x3e,
  27042. 0x4b,
  27043. 0xc6,
  27044. 0xd2,
  27045. 0x79,
  27046. 0x20,
  27047. 0x9a,
  27048. 0xdb,
  27049. 0xc0,
  27050. 0xfe,
  27051. 0x78,
  27052. 0xcd,
  27053. 0x5a,
  27054. 0xf4,
  27055. 0x1f,
  27056. 0xdd,
  27057. 0xa8,
  27058. 0x33,
  27059. 0x88,
  27060. 0x07,
  27061. 0xc7,
  27062. 0x31,
  27063. 0xb1,
  27064. 0x12,
  27065. 0x10,
  27066. 0x59,
  27067. 0x27,
  27068. 0x80,
  27069. 0xec,
  27070. 0x5f,
  27071. 0x60,
  27072. 0x51,
  27073. 0x7f,
  27074. 0xa9,
  27075. 0x19,
  27076. 0xb5,
  27077. 0x4a,
  27078. 0x0d,
  27079. 0x2d,
  27080. 0xe5,
  27081. 0x7a,
  27082. 0x9f,
  27083. 0x93,
  27084. 0xc9,
  27085. 0x9c,
  27086. 0xef,
  27087. 0xa0,
  27088. 0xe0,
  27089. 0x3b,
  27090. 0x4d,
  27091. 0xae,
  27092. 0x2a,
  27093. 0xf5,
  27094. 0xb0,
  27095. 0xc8,
  27096. 0xeb,
  27097. 0xbb,
  27098. 0x3c,
  27099. 0x83,
  27100. 0x53,
  27101. 0x99,
  27102. 0x61,
  27103. 0x17,
  27104. 0x2b,
  27105. 0x04,
  27106. 0x7e,
  27107. 0xba,
  27108. 0x77,
  27109. 0xd6,
  27110. 0x26,
  27111. 0xe1,
  27112. 0x69,
  27113. 0x14,
  27114. 0x63,
  27115. 0x55,
  27116. 0x21,
  27117. 0x0c,
  27118. 0x7d
  27119. ]);
  27120. var mixCol = new Uint8Array(256);
  27121. for (var i = 0; i < 256; i++) {
  27122. if (i < 128) {
  27123. mixCol[i] = i << 1;
  27124. } else {
  27125. mixCol[i] = i << 1 ^ 0x1b;
  27126. }
  27127. }
  27128. var mix = new Uint32Array([
  27129. 0x00000000,
  27130. 0x0e090d0b,
  27131. 0x1c121a16,
  27132. 0x121b171d,
  27133. 0x3824342c,
  27134. 0x362d3927,
  27135. 0x24362e3a,
  27136. 0x2a3f2331,
  27137. 0x70486858,
  27138. 0x7e416553,
  27139. 0x6c5a724e,
  27140. 0x62537f45,
  27141. 0x486c5c74,
  27142. 0x4665517f,
  27143. 0x547e4662,
  27144. 0x5a774b69,
  27145. 0xe090d0b0,
  27146. 0xee99ddbb,
  27147. 0xfc82caa6,
  27148. 0xf28bc7ad,
  27149. 0xd8b4e49c,
  27150. 0xd6bde997,
  27151. 0xc4a6fe8a,
  27152. 0xcaaff381,
  27153. 0x90d8b8e8,
  27154. 0x9ed1b5e3,
  27155. 0x8ccaa2fe,
  27156. 0x82c3aff5,
  27157. 0xa8fc8cc4,
  27158. 0xa6f581cf,
  27159. 0xb4ee96d2,
  27160. 0xbae79bd9,
  27161. 0xdb3bbb7b,
  27162. 0xd532b670,
  27163. 0xc729a16d,
  27164. 0xc920ac66,
  27165. 0xe31f8f57,
  27166. 0xed16825c,
  27167. 0xff0d9541,
  27168. 0xf104984a,
  27169. 0xab73d323,
  27170. 0xa57ade28,
  27171. 0xb761c935,
  27172. 0xb968c43e,
  27173. 0x9357e70f,
  27174. 0x9d5eea04,
  27175. 0x8f45fd19,
  27176. 0x814cf012,
  27177. 0x3bab6bcb,
  27178. 0x35a266c0,
  27179. 0x27b971dd,
  27180. 0x29b07cd6,
  27181. 0x038f5fe7,
  27182. 0x0d8652ec,
  27183. 0x1f9d45f1,
  27184. 0x119448fa,
  27185. 0x4be30393,
  27186. 0x45ea0e98,
  27187. 0x57f11985,
  27188. 0x59f8148e,
  27189. 0x73c737bf,
  27190. 0x7dce3ab4,
  27191. 0x6fd52da9,
  27192. 0x61dc20a2,
  27193. 0xad766df6,
  27194. 0xa37f60fd,
  27195. 0xb16477e0,
  27196. 0xbf6d7aeb,
  27197. 0x955259da,
  27198. 0x9b5b54d1,
  27199. 0x894043cc,
  27200. 0x87494ec7,
  27201. 0xdd3e05ae,
  27202. 0xd33708a5,
  27203. 0xc12c1fb8,
  27204. 0xcf2512b3,
  27205. 0xe51a3182,
  27206. 0xeb133c89,
  27207. 0xf9082b94,
  27208. 0xf701269f,
  27209. 0x4de6bd46,
  27210. 0x43efb04d,
  27211. 0x51f4a750,
  27212. 0x5ffdaa5b,
  27213. 0x75c2896a,
  27214. 0x7bcb8461,
  27215. 0x69d0937c,
  27216. 0x67d99e77,
  27217. 0x3daed51e,
  27218. 0x33a7d815,
  27219. 0x21bccf08,
  27220. 0x2fb5c203,
  27221. 0x058ae132,
  27222. 0x0b83ec39,
  27223. 0x1998fb24,
  27224. 0x1791f62f,
  27225. 0x764dd68d,
  27226. 0x7844db86,
  27227. 0x6a5fcc9b,
  27228. 0x6456c190,
  27229. 0x4e69e2a1,
  27230. 0x4060efaa,
  27231. 0x527bf8b7,
  27232. 0x5c72f5bc,
  27233. 0x0605bed5,
  27234. 0x080cb3de,
  27235. 0x1a17a4c3,
  27236. 0x141ea9c8,
  27237. 0x3e218af9,
  27238. 0x302887f2,
  27239. 0x223390ef,
  27240. 0x2c3a9de4,
  27241. 0x96dd063d,
  27242. 0x98d40b36,
  27243. 0x8acf1c2b,
  27244. 0x84c61120,
  27245. 0xaef93211,
  27246. 0xa0f03f1a,
  27247. 0xb2eb2807,
  27248. 0xbce2250c,
  27249. 0xe6956e65,
  27250. 0xe89c636e,
  27251. 0xfa877473,
  27252. 0xf48e7978,
  27253. 0xdeb15a49,
  27254. 0xd0b85742,
  27255. 0xc2a3405f,
  27256. 0xccaa4d54,
  27257. 0x41ecdaf7,
  27258. 0x4fe5d7fc,
  27259. 0x5dfec0e1,
  27260. 0x53f7cdea,
  27261. 0x79c8eedb,
  27262. 0x77c1e3d0,
  27263. 0x65daf4cd,
  27264. 0x6bd3f9c6,
  27265. 0x31a4b2af,
  27266. 0x3fadbfa4,
  27267. 0x2db6a8b9,
  27268. 0x23bfa5b2,
  27269. 0x09808683,
  27270. 0x07898b88,
  27271. 0x15929c95,
  27272. 0x1b9b919e,
  27273. 0xa17c0a47,
  27274. 0xaf75074c,
  27275. 0xbd6e1051,
  27276. 0xb3671d5a,
  27277. 0x99583e6b,
  27278. 0x97513360,
  27279. 0x854a247d,
  27280. 0x8b432976,
  27281. 0xd134621f,
  27282. 0xdf3d6f14,
  27283. 0xcd267809,
  27284. 0xc32f7502,
  27285. 0xe9105633,
  27286. 0xe7195b38,
  27287. 0xf5024c25,
  27288. 0xfb0b412e,
  27289. 0x9ad7618c,
  27290. 0x94de6c87,
  27291. 0x86c57b9a,
  27292. 0x88cc7691,
  27293. 0xa2f355a0,
  27294. 0xacfa58ab,
  27295. 0xbee14fb6,
  27296. 0xb0e842bd,
  27297. 0xea9f09d4,
  27298. 0xe49604df,
  27299. 0xf68d13c2,
  27300. 0xf8841ec9,
  27301. 0xd2bb3df8,
  27302. 0xdcb230f3,
  27303. 0xcea927ee,
  27304. 0xc0a02ae5,
  27305. 0x7a47b13c,
  27306. 0x744ebc37,
  27307. 0x6655ab2a,
  27308. 0x685ca621,
  27309. 0x42638510,
  27310. 0x4c6a881b,
  27311. 0x5e719f06,
  27312. 0x5078920d,
  27313. 0x0a0fd964,
  27314. 0x0406d46f,
  27315. 0x161dc372,
  27316. 0x1814ce79,
  27317. 0x322bed48,
  27318. 0x3c22e043,
  27319. 0x2e39f75e,
  27320. 0x2030fa55,
  27321. 0xec9ab701,
  27322. 0xe293ba0a,
  27323. 0xf088ad17,
  27324. 0xfe81a01c,
  27325. 0xd4be832d,
  27326. 0xdab78e26,
  27327. 0xc8ac993b,
  27328. 0xc6a59430,
  27329. 0x9cd2df59,
  27330. 0x92dbd252,
  27331. 0x80c0c54f,
  27332. 0x8ec9c844,
  27333. 0xa4f6eb75,
  27334. 0xaaffe67e,
  27335. 0xb8e4f163,
  27336. 0xb6edfc68,
  27337. 0x0c0a67b1,
  27338. 0x02036aba,
  27339. 0x10187da7,
  27340. 0x1e1170ac,
  27341. 0x342e539d,
  27342. 0x3a275e96,
  27343. 0x283c498b,
  27344. 0x26354480,
  27345. 0x7c420fe9,
  27346. 0x724b02e2,
  27347. 0x605015ff,
  27348. 0x6e5918f4,
  27349. 0x44663bc5,
  27350. 0x4a6f36ce,
  27351. 0x587421d3,
  27352. 0x567d2cd8,
  27353. 0x37a10c7a,
  27354. 0x39a80171,
  27355. 0x2bb3166c,
  27356. 0x25ba1b67,
  27357. 0x0f853856,
  27358. 0x018c355d,
  27359. 0x13972240,
  27360. 0x1d9e2f4b,
  27361. 0x47e96422,
  27362. 0x49e06929,
  27363. 0x5bfb7e34,
  27364. 0x55f2733f,
  27365. 0x7fcd500e,
  27366. 0x71c45d05,
  27367. 0x63df4a18,
  27368. 0x6dd64713,
  27369. 0xd731dcca,
  27370. 0xd938d1c1,
  27371. 0xcb23c6dc,
  27372. 0xc52acbd7,
  27373. 0xef15e8e6,
  27374. 0xe11ce5ed,
  27375. 0xf307f2f0,
  27376. 0xfd0efffb,
  27377. 0xa779b492,
  27378. 0xa970b999,
  27379. 0xbb6bae84,
  27380. 0xb562a38f,
  27381. 0x9f5d80be,
  27382. 0x91548db5,
  27383. 0x834f9aa8,
  27384. 0x8d4697a3
  27385. ]);
  27386. function expandKey128(cipherKey) {
  27387. var b = 176, result = new Uint8Array(b);
  27388. result.set(cipherKey);
  27389. for (var j = 16, i = 1; j < b; ++i) {
  27390. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  27391. t1 = s[t1];
  27392. t2 = s[t2];
  27393. t3 = s[t3];
  27394. t4 = s[t4];
  27395. t1 = t1 ^ rcon[i];
  27396. for (var n = 0; n < 4; ++n) {
  27397. result[j] = t1 ^= result[j - 16];
  27398. j++;
  27399. result[j] = t2 ^= result[j - 16];
  27400. j++;
  27401. result[j] = t3 ^= result[j - 16];
  27402. j++;
  27403. result[j] = t4 ^= result[j - 16];
  27404. j++;
  27405. }
  27406. }
  27407. return result;
  27408. }
  27409. function decrypt128(input, key) {
  27410. var state = new Uint8Array(16);
  27411. state.set(input);
  27412. var i, j, k;
  27413. var t, u, v;
  27414. for (j = 0, k = 160; j < 16; ++j, ++k) {
  27415. state[j] ^= key[k];
  27416. }
  27417. for (i = 9; i >= 1; --i) {
  27418. t = state[13];
  27419. state[13] = state[9];
  27420. state[9] = state[5];
  27421. state[5] = state[1];
  27422. state[1] = t;
  27423. t = state[14];
  27424. u = state[10];
  27425. state[14] = state[6];
  27426. state[10] = state[2];
  27427. state[6] = t;
  27428. state[2] = u;
  27429. t = state[15];
  27430. u = state[11];
  27431. v = state[7];
  27432. state[15] = state[3];
  27433. state[11] = t;
  27434. state[7] = u;
  27435. state[3] = v;
  27436. for (j = 0; j < 16; ++j) {
  27437. state[j] = inv_s[state[j]];
  27438. }
  27439. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27440. state[j] ^= key[k];
  27441. }
  27442. for (j = 0; j < 16; j += 4) {
  27443. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  27444. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  27445. state[j] = t >>> 24 & 0xFF;
  27446. state[j + 1] = t >> 16 & 0xFF;
  27447. state[j + 2] = t >> 8 & 0xFF;
  27448. state[j + 3] = t & 0xFF;
  27449. }
  27450. }
  27451. t = state[13];
  27452. state[13] = state[9];
  27453. state[9] = state[5];
  27454. state[5] = state[1];
  27455. state[1] = t;
  27456. t = state[14];
  27457. u = state[10];
  27458. state[14] = state[6];
  27459. state[10] = state[2];
  27460. state[6] = t;
  27461. state[2] = u;
  27462. t = state[15];
  27463. u = state[11];
  27464. v = state[7];
  27465. state[15] = state[3];
  27466. state[11] = t;
  27467. state[7] = u;
  27468. state[3] = v;
  27469. for (j = 0; j < 16; ++j) {
  27470. state[j] = inv_s[state[j]];
  27471. state[j] ^= key[j];
  27472. }
  27473. return state;
  27474. }
  27475. function encrypt128(input, key) {
  27476. var t, u, v, k;
  27477. var state = new Uint8Array(16);
  27478. state.set(input);
  27479. for (j = 0; j < 16; ++j) {
  27480. state[j] ^= key[j];
  27481. }
  27482. for (i = 1; i < 10; i++) {
  27483. for (j = 0; j < 16; ++j) {
  27484. state[j] = s[state[j]];
  27485. }
  27486. v = state[1];
  27487. state[1] = state[5];
  27488. state[5] = state[9];
  27489. state[9] = state[13];
  27490. state[13] = v;
  27491. v = state[2];
  27492. u = state[6];
  27493. state[2] = state[10];
  27494. state[6] = state[14];
  27495. state[10] = v;
  27496. state[14] = u;
  27497. v = state[3];
  27498. u = state[7];
  27499. t = state[11];
  27500. state[3] = state[15];
  27501. state[7] = v;
  27502. state[11] = u;
  27503. state[15] = t;
  27504. for (var j = 0; j < 16; j += 4) {
  27505. var s0 = state[j + 0], s1 = state[j + 1];
  27506. var s2 = state[j + 2], s3 = state[j + 3];
  27507. t = s0 ^ s1 ^ s2 ^ s3;
  27508. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  27509. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  27510. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  27511. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  27512. }
  27513. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27514. state[j] ^= key[k];
  27515. }
  27516. }
  27517. for (j = 0; j < 16; ++j) {
  27518. state[j] = s[state[j]];
  27519. }
  27520. v = state[1];
  27521. state[1] = state[5];
  27522. state[5] = state[9];
  27523. state[9] = state[13];
  27524. state[13] = v;
  27525. v = state[2];
  27526. u = state[6];
  27527. state[2] = state[10];
  27528. state[6] = state[14];
  27529. state[10] = v;
  27530. state[14] = u;
  27531. v = state[3];
  27532. u = state[7];
  27533. t = state[11];
  27534. state[3] = state[15];
  27535. state[7] = v;
  27536. state[11] = u;
  27537. state[15] = t;
  27538. for (j = 0, k = 160; j < 16; ++j, ++k) {
  27539. state[j] ^= key[k];
  27540. }
  27541. return state;
  27542. }
  27543. function AES128Cipher(key) {
  27544. this.key = expandKey128(key);
  27545. this.buffer = new Uint8Array(16);
  27546. this.bufferPosition = 0;
  27547. }
  27548. function decryptBlock2(data, finalize) {
  27549. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  27550. for (i = 0; i < sourceLength; ++i) {
  27551. buffer[bufferLength] = data[i];
  27552. ++bufferLength;
  27553. if (bufferLength < 16) {
  27554. continue;
  27555. }
  27556. var plain = decrypt128(buffer, this.key);
  27557. for (j = 0; j < 16; ++j) {
  27558. plain[j] ^= iv[j];
  27559. }
  27560. iv = buffer;
  27561. result.push(plain);
  27562. buffer = new Uint8Array(16);
  27563. bufferLength = 0;
  27564. }
  27565. this.buffer = buffer;
  27566. this.bufferLength = bufferLength;
  27567. this.iv = iv;
  27568. if (result.length === 0) {
  27569. return new Uint8Array([]);
  27570. }
  27571. var outputLength = 16 * result.length;
  27572. if (finalize) {
  27573. var lastBlock = result[result.length - 1];
  27574. var psLen = lastBlock[15];
  27575. if (psLen <= 16) {
  27576. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  27577. if (lastBlock[i] !== psLen) {
  27578. psLen = 0;
  27579. break;
  27580. }
  27581. }
  27582. outputLength -= psLen;
  27583. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  27584. }
  27585. }
  27586. var output = new Uint8Array(outputLength);
  27587. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27588. output.set(result[i], j);
  27589. }
  27590. return output;
  27591. }
  27592. AES128Cipher.prototype = {
  27593. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  27594. var i, sourceLength = data.length;
  27595. var buffer = this.buffer, bufferLength = this.bufferPosition;
  27596. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  27597. buffer[bufferLength] = data[i];
  27598. }
  27599. if (bufferLength < 16) {
  27600. this.bufferLength = bufferLength;
  27601. return new Uint8Array([]);
  27602. }
  27603. this.iv = buffer;
  27604. this.buffer = new Uint8Array(16);
  27605. this.bufferLength = 0;
  27606. this.decryptBlock = decryptBlock2;
  27607. return this.decryptBlock(data.subarray(16), finalize);
  27608. },
  27609. encrypt: function AES128Cipher_encrypt(data, iv) {
  27610. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  27611. if (!iv) {
  27612. iv = new Uint8Array(16);
  27613. }
  27614. for (i = 0; i < sourceLength; ++i) {
  27615. buffer[bufferLength] = data[i];
  27616. ++bufferLength;
  27617. if (bufferLength < 16) {
  27618. continue;
  27619. }
  27620. for (j = 0; j < 16; ++j) {
  27621. buffer[j] ^= iv[j];
  27622. }
  27623. var cipher = encrypt128(buffer, this.key);
  27624. iv = cipher;
  27625. result.push(cipher);
  27626. buffer = new Uint8Array(16);
  27627. bufferLength = 0;
  27628. }
  27629. this.buffer = buffer;
  27630. this.bufferLength = bufferLength;
  27631. this.iv = iv;
  27632. if (result.length === 0) {
  27633. return new Uint8Array([]);
  27634. }
  27635. var outputLength = 16 * result.length;
  27636. var output = new Uint8Array(outputLength);
  27637. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27638. output.set(result[i], j);
  27639. }
  27640. return output;
  27641. }
  27642. };
  27643. return AES128Cipher;
  27644. }();
  27645. var AES256Cipher = function AES256CipherClosure() {
  27646. var s = new Uint8Array([
  27647. 0x63,
  27648. 0x7c,
  27649. 0x77,
  27650. 0x7b,
  27651. 0xf2,
  27652. 0x6b,
  27653. 0x6f,
  27654. 0xc5,
  27655. 0x30,
  27656. 0x01,
  27657. 0x67,
  27658. 0x2b,
  27659. 0xfe,
  27660. 0xd7,
  27661. 0xab,
  27662. 0x76,
  27663. 0xca,
  27664. 0x82,
  27665. 0xc9,
  27666. 0x7d,
  27667. 0xfa,
  27668. 0x59,
  27669. 0x47,
  27670. 0xf0,
  27671. 0xad,
  27672. 0xd4,
  27673. 0xa2,
  27674. 0xaf,
  27675. 0x9c,
  27676. 0xa4,
  27677. 0x72,
  27678. 0xc0,
  27679. 0xb7,
  27680. 0xfd,
  27681. 0x93,
  27682. 0x26,
  27683. 0x36,
  27684. 0x3f,
  27685. 0xf7,
  27686. 0xcc,
  27687. 0x34,
  27688. 0xa5,
  27689. 0xe5,
  27690. 0xf1,
  27691. 0x71,
  27692. 0xd8,
  27693. 0x31,
  27694. 0x15,
  27695. 0x04,
  27696. 0xc7,
  27697. 0x23,
  27698. 0xc3,
  27699. 0x18,
  27700. 0x96,
  27701. 0x05,
  27702. 0x9a,
  27703. 0x07,
  27704. 0x12,
  27705. 0x80,
  27706. 0xe2,
  27707. 0xeb,
  27708. 0x27,
  27709. 0xb2,
  27710. 0x75,
  27711. 0x09,
  27712. 0x83,
  27713. 0x2c,
  27714. 0x1a,
  27715. 0x1b,
  27716. 0x6e,
  27717. 0x5a,
  27718. 0xa0,
  27719. 0x52,
  27720. 0x3b,
  27721. 0xd6,
  27722. 0xb3,
  27723. 0x29,
  27724. 0xe3,
  27725. 0x2f,
  27726. 0x84,
  27727. 0x53,
  27728. 0xd1,
  27729. 0x00,
  27730. 0xed,
  27731. 0x20,
  27732. 0xfc,
  27733. 0xb1,
  27734. 0x5b,
  27735. 0x6a,
  27736. 0xcb,
  27737. 0xbe,
  27738. 0x39,
  27739. 0x4a,
  27740. 0x4c,
  27741. 0x58,
  27742. 0xcf,
  27743. 0xd0,
  27744. 0xef,
  27745. 0xaa,
  27746. 0xfb,
  27747. 0x43,
  27748. 0x4d,
  27749. 0x33,
  27750. 0x85,
  27751. 0x45,
  27752. 0xf9,
  27753. 0x02,
  27754. 0x7f,
  27755. 0x50,
  27756. 0x3c,
  27757. 0x9f,
  27758. 0xa8,
  27759. 0x51,
  27760. 0xa3,
  27761. 0x40,
  27762. 0x8f,
  27763. 0x92,
  27764. 0x9d,
  27765. 0x38,
  27766. 0xf5,
  27767. 0xbc,
  27768. 0xb6,
  27769. 0xda,
  27770. 0x21,
  27771. 0x10,
  27772. 0xff,
  27773. 0xf3,
  27774. 0xd2,
  27775. 0xcd,
  27776. 0x0c,
  27777. 0x13,
  27778. 0xec,
  27779. 0x5f,
  27780. 0x97,
  27781. 0x44,
  27782. 0x17,
  27783. 0xc4,
  27784. 0xa7,
  27785. 0x7e,
  27786. 0x3d,
  27787. 0x64,
  27788. 0x5d,
  27789. 0x19,
  27790. 0x73,
  27791. 0x60,
  27792. 0x81,
  27793. 0x4f,
  27794. 0xdc,
  27795. 0x22,
  27796. 0x2a,
  27797. 0x90,
  27798. 0x88,
  27799. 0x46,
  27800. 0xee,
  27801. 0xb8,
  27802. 0x14,
  27803. 0xde,
  27804. 0x5e,
  27805. 0x0b,
  27806. 0xdb,
  27807. 0xe0,
  27808. 0x32,
  27809. 0x3a,
  27810. 0x0a,
  27811. 0x49,
  27812. 0x06,
  27813. 0x24,
  27814. 0x5c,
  27815. 0xc2,
  27816. 0xd3,
  27817. 0xac,
  27818. 0x62,
  27819. 0x91,
  27820. 0x95,
  27821. 0xe4,
  27822. 0x79,
  27823. 0xe7,
  27824. 0xc8,
  27825. 0x37,
  27826. 0x6d,
  27827. 0x8d,
  27828. 0xd5,
  27829. 0x4e,
  27830. 0xa9,
  27831. 0x6c,
  27832. 0x56,
  27833. 0xf4,
  27834. 0xea,
  27835. 0x65,
  27836. 0x7a,
  27837. 0xae,
  27838. 0x08,
  27839. 0xba,
  27840. 0x78,
  27841. 0x25,
  27842. 0x2e,
  27843. 0x1c,
  27844. 0xa6,
  27845. 0xb4,
  27846. 0xc6,
  27847. 0xe8,
  27848. 0xdd,
  27849. 0x74,
  27850. 0x1f,
  27851. 0x4b,
  27852. 0xbd,
  27853. 0x8b,
  27854. 0x8a,
  27855. 0x70,
  27856. 0x3e,
  27857. 0xb5,
  27858. 0x66,
  27859. 0x48,
  27860. 0x03,
  27861. 0xf6,
  27862. 0x0e,
  27863. 0x61,
  27864. 0x35,
  27865. 0x57,
  27866. 0xb9,
  27867. 0x86,
  27868. 0xc1,
  27869. 0x1d,
  27870. 0x9e,
  27871. 0xe1,
  27872. 0xf8,
  27873. 0x98,
  27874. 0x11,
  27875. 0x69,
  27876. 0xd9,
  27877. 0x8e,
  27878. 0x94,
  27879. 0x9b,
  27880. 0x1e,
  27881. 0x87,
  27882. 0xe9,
  27883. 0xce,
  27884. 0x55,
  27885. 0x28,
  27886. 0xdf,
  27887. 0x8c,
  27888. 0xa1,
  27889. 0x89,
  27890. 0x0d,
  27891. 0xbf,
  27892. 0xe6,
  27893. 0x42,
  27894. 0x68,
  27895. 0x41,
  27896. 0x99,
  27897. 0x2d,
  27898. 0x0f,
  27899. 0xb0,
  27900. 0x54,
  27901. 0xbb,
  27902. 0x16
  27903. ]);
  27904. var inv_s = new Uint8Array([
  27905. 0x52,
  27906. 0x09,
  27907. 0x6a,
  27908. 0xd5,
  27909. 0x30,
  27910. 0x36,
  27911. 0xa5,
  27912. 0x38,
  27913. 0xbf,
  27914. 0x40,
  27915. 0xa3,
  27916. 0x9e,
  27917. 0x81,
  27918. 0xf3,
  27919. 0xd7,
  27920. 0xfb,
  27921. 0x7c,
  27922. 0xe3,
  27923. 0x39,
  27924. 0x82,
  27925. 0x9b,
  27926. 0x2f,
  27927. 0xff,
  27928. 0x87,
  27929. 0x34,
  27930. 0x8e,
  27931. 0x43,
  27932. 0x44,
  27933. 0xc4,
  27934. 0xde,
  27935. 0xe9,
  27936. 0xcb,
  27937. 0x54,
  27938. 0x7b,
  27939. 0x94,
  27940. 0x32,
  27941. 0xa6,
  27942. 0xc2,
  27943. 0x23,
  27944. 0x3d,
  27945. 0xee,
  27946. 0x4c,
  27947. 0x95,
  27948. 0x0b,
  27949. 0x42,
  27950. 0xfa,
  27951. 0xc3,
  27952. 0x4e,
  27953. 0x08,
  27954. 0x2e,
  27955. 0xa1,
  27956. 0x66,
  27957. 0x28,
  27958. 0xd9,
  27959. 0x24,
  27960. 0xb2,
  27961. 0x76,
  27962. 0x5b,
  27963. 0xa2,
  27964. 0x49,
  27965. 0x6d,
  27966. 0x8b,
  27967. 0xd1,
  27968. 0x25,
  27969. 0x72,
  27970. 0xf8,
  27971. 0xf6,
  27972. 0x64,
  27973. 0x86,
  27974. 0x68,
  27975. 0x98,
  27976. 0x16,
  27977. 0xd4,
  27978. 0xa4,
  27979. 0x5c,
  27980. 0xcc,
  27981. 0x5d,
  27982. 0x65,
  27983. 0xb6,
  27984. 0x92,
  27985. 0x6c,
  27986. 0x70,
  27987. 0x48,
  27988. 0x50,
  27989. 0xfd,
  27990. 0xed,
  27991. 0xb9,
  27992. 0xda,
  27993. 0x5e,
  27994. 0x15,
  27995. 0x46,
  27996. 0x57,
  27997. 0xa7,
  27998. 0x8d,
  27999. 0x9d,
  28000. 0x84,
  28001. 0x90,
  28002. 0xd8,
  28003. 0xab,
  28004. 0x00,
  28005. 0x8c,
  28006. 0xbc,
  28007. 0xd3,
  28008. 0x0a,
  28009. 0xf7,
  28010. 0xe4,
  28011. 0x58,
  28012. 0x05,
  28013. 0xb8,
  28014. 0xb3,
  28015. 0x45,
  28016. 0x06,
  28017. 0xd0,
  28018. 0x2c,
  28019. 0x1e,
  28020. 0x8f,
  28021. 0xca,
  28022. 0x3f,
  28023. 0x0f,
  28024. 0x02,
  28025. 0xc1,
  28026. 0xaf,
  28027. 0xbd,
  28028. 0x03,
  28029. 0x01,
  28030. 0x13,
  28031. 0x8a,
  28032. 0x6b,
  28033. 0x3a,
  28034. 0x91,
  28035. 0x11,
  28036. 0x41,
  28037. 0x4f,
  28038. 0x67,
  28039. 0xdc,
  28040. 0xea,
  28041. 0x97,
  28042. 0xf2,
  28043. 0xcf,
  28044. 0xce,
  28045. 0xf0,
  28046. 0xb4,
  28047. 0xe6,
  28048. 0x73,
  28049. 0x96,
  28050. 0xac,
  28051. 0x74,
  28052. 0x22,
  28053. 0xe7,
  28054. 0xad,
  28055. 0x35,
  28056. 0x85,
  28057. 0xe2,
  28058. 0xf9,
  28059. 0x37,
  28060. 0xe8,
  28061. 0x1c,
  28062. 0x75,
  28063. 0xdf,
  28064. 0x6e,
  28065. 0x47,
  28066. 0xf1,
  28067. 0x1a,
  28068. 0x71,
  28069. 0x1d,
  28070. 0x29,
  28071. 0xc5,
  28072. 0x89,
  28073. 0x6f,
  28074. 0xb7,
  28075. 0x62,
  28076. 0x0e,
  28077. 0xaa,
  28078. 0x18,
  28079. 0xbe,
  28080. 0x1b,
  28081. 0xfc,
  28082. 0x56,
  28083. 0x3e,
  28084. 0x4b,
  28085. 0xc6,
  28086. 0xd2,
  28087. 0x79,
  28088. 0x20,
  28089. 0x9a,
  28090. 0xdb,
  28091. 0xc0,
  28092. 0xfe,
  28093. 0x78,
  28094. 0xcd,
  28095. 0x5a,
  28096. 0xf4,
  28097. 0x1f,
  28098. 0xdd,
  28099. 0xa8,
  28100. 0x33,
  28101. 0x88,
  28102. 0x07,
  28103. 0xc7,
  28104. 0x31,
  28105. 0xb1,
  28106. 0x12,
  28107. 0x10,
  28108. 0x59,
  28109. 0x27,
  28110. 0x80,
  28111. 0xec,
  28112. 0x5f,
  28113. 0x60,
  28114. 0x51,
  28115. 0x7f,
  28116. 0xa9,
  28117. 0x19,
  28118. 0xb5,
  28119. 0x4a,
  28120. 0x0d,
  28121. 0x2d,
  28122. 0xe5,
  28123. 0x7a,
  28124. 0x9f,
  28125. 0x93,
  28126. 0xc9,
  28127. 0x9c,
  28128. 0xef,
  28129. 0xa0,
  28130. 0xe0,
  28131. 0x3b,
  28132. 0x4d,
  28133. 0xae,
  28134. 0x2a,
  28135. 0xf5,
  28136. 0xb0,
  28137. 0xc8,
  28138. 0xeb,
  28139. 0xbb,
  28140. 0x3c,
  28141. 0x83,
  28142. 0x53,
  28143. 0x99,
  28144. 0x61,
  28145. 0x17,
  28146. 0x2b,
  28147. 0x04,
  28148. 0x7e,
  28149. 0xba,
  28150. 0x77,
  28151. 0xd6,
  28152. 0x26,
  28153. 0xe1,
  28154. 0x69,
  28155. 0x14,
  28156. 0x63,
  28157. 0x55,
  28158. 0x21,
  28159. 0x0c,
  28160. 0x7d
  28161. ]);
  28162. var mixCol = new Uint8Array(256);
  28163. for (var i = 0; i < 256; i++) {
  28164. if (i < 128) {
  28165. mixCol[i] = i << 1;
  28166. } else {
  28167. mixCol[i] = i << 1 ^ 0x1b;
  28168. }
  28169. }
  28170. var mix = new Uint32Array([
  28171. 0x00000000,
  28172. 0x0e090d0b,
  28173. 0x1c121a16,
  28174. 0x121b171d,
  28175. 0x3824342c,
  28176. 0x362d3927,
  28177. 0x24362e3a,
  28178. 0x2a3f2331,
  28179. 0x70486858,
  28180. 0x7e416553,
  28181. 0x6c5a724e,
  28182. 0x62537f45,
  28183. 0x486c5c74,
  28184. 0x4665517f,
  28185. 0x547e4662,
  28186. 0x5a774b69,
  28187. 0xe090d0b0,
  28188. 0xee99ddbb,
  28189. 0xfc82caa6,
  28190. 0xf28bc7ad,
  28191. 0xd8b4e49c,
  28192. 0xd6bde997,
  28193. 0xc4a6fe8a,
  28194. 0xcaaff381,
  28195. 0x90d8b8e8,
  28196. 0x9ed1b5e3,
  28197. 0x8ccaa2fe,
  28198. 0x82c3aff5,
  28199. 0xa8fc8cc4,
  28200. 0xa6f581cf,
  28201. 0xb4ee96d2,
  28202. 0xbae79bd9,
  28203. 0xdb3bbb7b,
  28204. 0xd532b670,
  28205. 0xc729a16d,
  28206. 0xc920ac66,
  28207. 0xe31f8f57,
  28208. 0xed16825c,
  28209. 0xff0d9541,
  28210. 0xf104984a,
  28211. 0xab73d323,
  28212. 0xa57ade28,
  28213. 0xb761c935,
  28214. 0xb968c43e,
  28215. 0x9357e70f,
  28216. 0x9d5eea04,
  28217. 0x8f45fd19,
  28218. 0x814cf012,
  28219. 0x3bab6bcb,
  28220. 0x35a266c0,
  28221. 0x27b971dd,
  28222. 0x29b07cd6,
  28223. 0x038f5fe7,
  28224. 0x0d8652ec,
  28225. 0x1f9d45f1,
  28226. 0x119448fa,
  28227. 0x4be30393,
  28228. 0x45ea0e98,
  28229. 0x57f11985,
  28230. 0x59f8148e,
  28231. 0x73c737bf,
  28232. 0x7dce3ab4,
  28233. 0x6fd52da9,
  28234. 0x61dc20a2,
  28235. 0xad766df6,
  28236. 0xa37f60fd,
  28237. 0xb16477e0,
  28238. 0xbf6d7aeb,
  28239. 0x955259da,
  28240. 0x9b5b54d1,
  28241. 0x894043cc,
  28242. 0x87494ec7,
  28243. 0xdd3e05ae,
  28244. 0xd33708a5,
  28245. 0xc12c1fb8,
  28246. 0xcf2512b3,
  28247. 0xe51a3182,
  28248. 0xeb133c89,
  28249. 0xf9082b94,
  28250. 0xf701269f,
  28251. 0x4de6bd46,
  28252. 0x43efb04d,
  28253. 0x51f4a750,
  28254. 0x5ffdaa5b,
  28255. 0x75c2896a,
  28256. 0x7bcb8461,
  28257. 0x69d0937c,
  28258. 0x67d99e77,
  28259. 0x3daed51e,
  28260. 0x33a7d815,
  28261. 0x21bccf08,
  28262. 0x2fb5c203,
  28263. 0x058ae132,
  28264. 0x0b83ec39,
  28265. 0x1998fb24,
  28266. 0x1791f62f,
  28267. 0x764dd68d,
  28268. 0x7844db86,
  28269. 0x6a5fcc9b,
  28270. 0x6456c190,
  28271. 0x4e69e2a1,
  28272. 0x4060efaa,
  28273. 0x527bf8b7,
  28274. 0x5c72f5bc,
  28275. 0x0605bed5,
  28276. 0x080cb3de,
  28277. 0x1a17a4c3,
  28278. 0x141ea9c8,
  28279. 0x3e218af9,
  28280. 0x302887f2,
  28281. 0x223390ef,
  28282. 0x2c3a9de4,
  28283. 0x96dd063d,
  28284. 0x98d40b36,
  28285. 0x8acf1c2b,
  28286. 0x84c61120,
  28287. 0xaef93211,
  28288. 0xa0f03f1a,
  28289. 0xb2eb2807,
  28290. 0xbce2250c,
  28291. 0xe6956e65,
  28292. 0xe89c636e,
  28293. 0xfa877473,
  28294. 0xf48e7978,
  28295. 0xdeb15a49,
  28296. 0xd0b85742,
  28297. 0xc2a3405f,
  28298. 0xccaa4d54,
  28299. 0x41ecdaf7,
  28300. 0x4fe5d7fc,
  28301. 0x5dfec0e1,
  28302. 0x53f7cdea,
  28303. 0x79c8eedb,
  28304. 0x77c1e3d0,
  28305. 0x65daf4cd,
  28306. 0x6bd3f9c6,
  28307. 0x31a4b2af,
  28308. 0x3fadbfa4,
  28309. 0x2db6a8b9,
  28310. 0x23bfa5b2,
  28311. 0x09808683,
  28312. 0x07898b88,
  28313. 0x15929c95,
  28314. 0x1b9b919e,
  28315. 0xa17c0a47,
  28316. 0xaf75074c,
  28317. 0xbd6e1051,
  28318. 0xb3671d5a,
  28319. 0x99583e6b,
  28320. 0x97513360,
  28321. 0x854a247d,
  28322. 0x8b432976,
  28323. 0xd134621f,
  28324. 0xdf3d6f14,
  28325. 0xcd267809,
  28326. 0xc32f7502,
  28327. 0xe9105633,
  28328. 0xe7195b38,
  28329. 0xf5024c25,
  28330. 0xfb0b412e,
  28331. 0x9ad7618c,
  28332. 0x94de6c87,
  28333. 0x86c57b9a,
  28334. 0x88cc7691,
  28335. 0xa2f355a0,
  28336. 0xacfa58ab,
  28337. 0xbee14fb6,
  28338. 0xb0e842bd,
  28339. 0xea9f09d4,
  28340. 0xe49604df,
  28341. 0xf68d13c2,
  28342. 0xf8841ec9,
  28343. 0xd2bb3df8,
  28344. 0xdcb230f3,
  28345. 0xcea927ee,
  28346. 0xc0a02ae5,
  28347. 0x7a47b13c,
  28348. 0x744ebc37,
  28349. 0x6655ab2a,
  28350. 0x685ca621,
  28351. 0x42638510,
  28352. 0x4c6a881b,
  28353. 0x5e719f06,
  28354. 0x5078920d,
  28355. 0x0a0fd964,
  28356. 0x0406d46f,
  28357. 0x161dc372,
  28358. 0x1814ce79,
  28359. 0x322bed48,
  28360. 0x3c22e043,
  28361. 0x2e39f75e,
  28362. 0x2030fa55,
  28363. 0xec9ab701,
  28364. 0xe293ba0a,
  28365. 0xf088ad17,
  28366. 0xfe81a01c,
  28367. 0xd4be832d,
  28368. 0xdab78e26,
  28369. 0xc8ac993b,
  28370. 0xc6a59430,
  28371. 0x9cd2df59,
  28372. 0x92dbd252,
  28373. 0x80c0c54f,
  28374. 0x8ec9c844,
  28375. 0xa4f6eb75,
  28376. 0xaaffe67e,
  28377. 0xb8e4f163,
  28378. 0xb6edfc68,
  28379. 0x0c0a67b1,
  28380. 0x02036aba,
  28381. 0x10187da7,
  28382. 0x1e1170ac,
  28383. 0x342e539d,
  28384. 0x3a275e96,
  28385. 0x283c498b,
  28386. 0x26354480,
  28387. 0x7c420fe9,
  28388. 0x724b02e2,
  28389. 0x605015ff,
  28390. 0x6e5918f4,
  28391. 0x44663bc5,
  28392. 0x4a6f36ce,
  28393. 0x587421d3,
  28394. 0x567d2cd8,
  28395. 0x37a10c7a,
  28396. 0x39a80171,
  28397. 0x2bb3166c,
  28398. 0x25ba1b67,
  28399. 0x0f853856,
  28400. 0x018c355d,
  28401. 0x13972240,
  28402. 0x1d9e2f4b,
  28403. 0x47e96422,
  28404. 0x49e06929,
  28405. 0x5bfb7e34,
  28406. 0x55f2733f,
  28407. 0x7fcd500e,
  28408. 0x71c45d05,
  28409. 0x63df4a18,
  28410. 0x6dd64713,
  28411. 0xd731dcca,
  28412. 0xd938d1c1,
  28413. 0xcb23c6dc,
  28414. 0xc52acbd7,
  28415. 0xef15e8e6,
  28416. 0xe11ce5ed,
  28417. 0xf307f2f0,
  28418. 0xfd0efffb,
  28419. 0xa779b492,
  28420. 0xa970b999,
  28421. 0xbb6bae84,
  28422. 0xb562a38f,
  28423. 0x9f5d80be,
  28424. 0x91548db5,
  28425. 0x834f9aa8,
  28426. 0x8d4697a3
  28427. ]);
  28428. function expandKey256(cipherKey) {
  28429. var b = 240, result = new Uint8Array(b);
  28430. var r = 1;
  28431. result.set(cipherKey);
  28432. for (var j = 32, i = 1; j < b; ++i) {
  28433. if (j % 32 === 16) {
  28434. t1 = s[t1];
  28435. t2 = s[t2];
  28436. t3 = s[t3];
  28437. t4 = s[t4];
  28438. } else if (j % 32 === 0) {
  28439. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  28440. t1 = s[t1];
  28441. t2 = s[t2];
  28442. t3 = s[t3];
  28443. t4 = s[t4];
  28444. t1 = t1 ^ r;
  28445. if ((r <<= 1) >= 256) {
  28446. r = (r ^ 0x1b) & 0xFF;
  28447. }
  28448. }
  28449. for (var n = 0; n < 4; ++n) {
  28450. result[j] = t1 ^= result[j - 32];
  28451. j++;
  28452. result[j] = t2 ^= result[j - 32];
  28453. j++;
  28454. result[j] = t3 ^= result[j - 32];
  28455. j++;
  28456. result[j] = t4 ^= result[j - 32];
  28457. j++;
  28458. }
  28459. }
  28460. return result;
  28461. }
  28462. function decrypt256(input, key) {
  28463. var state = new Uint8Array(16);
  28464. state.set(input);
  28465. var i, j, k;
  28466. var t, u, v;
  28467. for (j = 0, k = 224; j < 16; ++j, ++k) {
  28468. state[j] ^= key[k];
  28469. }
  28470. for (i = 13; i >= 1; --i) {
  28471. t = state[13];
  28472. state[13] = state[9];
  28473. state[9] = state[5];
  28474. state[5] = state[1];
  28475. state[1] = t;
  28476. t = state[14];
  28477. u = state[10];
  28478. state[14] = state[6];
  28479. state[10] = state[2];
  28480. state[6] = t;
  28481. state[2] = u;
  28482. t = state[15];
  28483. u = state[11];
  28484. v = state[7];
  28485. state[15] = state[3];
  28486. state[11] = t;
  28487. state[7] = u;
  28488. state[3] = v;
  28489. for (j = 0; j < 16; ++j) {
  28490. state[j] = inv_s[state[j]];
  28491. }
  28492. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28493. state[j] ^= key[k];
  28494. }
  28495. for (j = 0; j < 16; j += 4) {
  28496. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  28497. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  28498. state[j] = t >>> 24 & 0xFF;
  28499. state[j + 1] = t >> 16 & 0xFF;
  28500. state[j + 2] = t >> 8 & 0xFF;
  28501. state[j + 3] = t & 0xFF;
  28502. }
  28503. }
  28504. t = state[13];
  28505. state[13] = state[9];
  28506. state[9] = state[5];
  28507. state[5] = state[1];
  28508. state[1] = t;
  28509. t = state[14];
  28510. u = state[10];
  28511. state[14] = state[6];
  28512. state[10] = state[2];
  28513. state[6] = t;
  28514. state[2] = u;
  28515. t = state[15];
  28516. u = state[11];
  28517. v = state[7];
  28518. state[15] = state[3];
  28519. state[11] = t;
  28520. state[7] = u;
  28521. state[3] = v;
  28522. for (j = 0; j < 16; ++j) {
  28523. state[j] = inv_s[state[j]];
  28524. state[j] ^= key[j];
  28525. }
  28526. return state;
  28527. }
  28528. function encrypt256(input, key) {
  28529. var t, u, v, k;
  28530. var state = new Uint8Array(16);
  28531. state.set(input);
  28532. for (j = 0; j < 16; ++j) {
  28533. state[j] ^= key[j];
  28534. }
  28535. for (i = 1; i < 14; i++) {
  28536. for (j = 0; j < 16; ++j) {
  28537. state[j] = s[state[j]];
  28538. }
  28539. v = state[1];
  28540. state[1] = state[5];
  28541. state[5] = state[9];
  28542. state[9] = state[13];
  28543. state[13] = v;
  28544. v = state[2];
  28545. u = state[6];
  28546. state[2] = state[10];
  28547. state[6] = state[14];
  28548. state[10] = v;
  28549. state[14] = u;
  28550. v = state[3];
  28551. u = state[7];
  28552. t = state[11];
  28553. state[3] = state[15];
  28554. state[7] = v;
  28555. state[11] = u;
  28556. state[15] = t;
  28557. for (var j = 0; j < 16; j += 4) {
  28558. var s0 = state[j + 0], s1 = state[j + 1];
  28559. var s2 = state[j + 2], s3 = state[j + 3];
  28560. t = s0 ^ s1 ^ s2 ^ s3;
  28561. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  28562. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  28563. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  28564. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  28565. }
  28566. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28567. state[j] ^= key[k];
  28568. }
  28569. }
  28570. for (j = 0; j < 16; ++j) {
  28571. state[j] = s[state[j]];
  28572. }
  28573. v = state[1];
  28574. state[1] = state[5];
  28575. state[5] = state[9];
  28576. state[9] = state[13];
  28577. state[13] = v;
  28578. v = state[2];
  28579. u = state[6];
  28580. state[2] = state[10];
  28581. state[6] = state[14];
  28582. state[10] = v;
  28583. state[14] = u;
  28584. v = state[3];
  28585. u = state[7];
  28586. t = state[11];
  28587. state[3] = state[15];
  28588. state[7] = v;
  28589. state[11] = u;
  28590. state[15] = t;
  28591. for (j = 0, k = 224; j < 16; ++j, ++k) {
  28592. state[j] ^= key[k];
  28593. }
  28594. return state;
  28595. }
  28596. function AES256Cipher(key) {
  28597. this.key = expandKey256(key);
  28598. this.buffer = new Uint8Array(16);
  28599. this.bufferPosition = 0;
  28600. }
  28601. function decryptBlock2(data, finalize) {
  28602. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  28603. for (i = 0; i < sourceLength; ++i) {
  28604. buffer[bufferLength] = data[i];
  28605. ++bufferLength;
  28606. if (bufferLength < 16) {
  28607. continue;
  28608. }
  28609. var plain = decrypt256(buffer, this.key);
  28610. for (j = 0; j < 16; ++j) {
  28611. plain[j] ^= iv[j];
  28612. }
  28613. iv = buffer;
  28614. result.push(plain);
  28615. buffer = new Uint8Array(16);
  28616. bufferLength = 0;
  28617. }
  28618. this.buffer = buffer;
  28619. this.bufferLength = bufferLength;
  28620. this.iv = iv;
  28621. if (result.length === 0) {
  28622. return new Uint8Array([]);
  28623. }
  28624. var outputLength = 16 * result.length;
  28625. if (finalize) {
  28626. var lastBlock = result[result.length - 1];
  28627. var psLen = lastBlock[15];
  28628. if (psLen <= 16) {
  28629. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  28630. if (lastBlock[i] !== psLen) {
  28631. psLen = 0;
  28632. break;
  28633. }
  28634. }
  28635. outputLength -= psLen;
  28636. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  28637. }
  28638. }
  28639. var output = new Uint8Array(outputLength);
  28640. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28641. output.set(result[i], j);
  28642. }
  28643. return output;
  28644. }
  28645. AES256Cipher.prototype = {
  28646. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  28647. var i, sourceLength = data.length;
  28648. var buffer = this.buffer, bufferLength = this.bufferPosition;
  28649. if (iv) {
  28650. this.iv = iv;
  28651. } else {
  28652. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  28653. buffer[bufferLength] = data[i];
  28654. }
  28655. if (bufferLength < 16) {
  28656. this.bufferLength = bufferLength;
  28657. return new Uint8Array([]);
  28658. }
  28659. this.iv = buffer;
  28660. data = data.subarray(16);
  28661. }
  28662. this.buffer = new Uint8Array(16);
  28663. this.bufferLength = 0;
  28664. this.decryptBlock = decryptBlock2;
  28665. return this.decryptBlock(data, finalize);
  28666. },
  28667. encrypt: function AES256Cipher_encrypt(data, iv) {
  28668. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  28669. if (!iv) {
  28670. iv = new Uint8Array(16);
  28671. }
  28672. for (i = 0; i < sourceLength; ++i) {
  28673. buffer[bufferLength] = data[i];
  28674. ++bufferLength;
  28675. if (bufferLength < 16) {
  28676. continue;
  28677. }
  28678. for (j = 0; j < 16; ++j) {
  28679. buffer[j] ^= iv[j];
  28680. }
  28681. var cipher = encrypt256(buffer, this.key);
  28682. this.iv = cipher;
  28683. result.push(cipher);
  28684. buffer = new Uint8Array(16);
  28685. bufferLength = 0;
  28686. }
  28687. this.buffer = buffer;
  28688. this.bufferLength = bufferLength;
  28689. this.iv = iv;
  28690. if (result.length === 0) {
  28691. return new Uint8Array([]);
  28692. }
  28693. var outputLength = 16 * result.length;
  28694. var output = new Uint8Array(outputLength);
  28695. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28696. output.set(result[i], j);
  28697. }
  28698. return output;
  28699. }
  28700. };
  28701. return AES256Cipher;
  28702. }();
  28703. var PDF17 = function PDF17Closure() {
  28704. function compareByteArrays(array1, array2) {
  28705. if (array1.length !== array2.length) {
  28706. return false;
  28707. }
  28708. for (var i = 0; i < array1.length; i++) {
  28709. if (array1[i] !== array2[i]) {
  28710. return false;
  28711. }
  28712. }
  28713. return true;
  28714. }
  28715. function PDF17() {
  28716. }
  28717. PDF17.prototype = {
  28718. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28719. var hashData = new Uint8Array(password.length + 56);
  28720. hashData.set(password, 0);
  28721. hashData.set(ownerValidationSalt, password.length);
  28722. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28723. var result = calculateSHA256(hashData, 0, hashData.length);
  28724. return compareByteArrays(result, ownerPassword);
  28725. },
  28726. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  28727. var hashData = new Uint8Array(password.length + 8);
  28728. hashData.set(password, 0);
  28729. hashData.set(userValidationSalt, password.length);
  28730. var result = calculateSHA256(hashData, 0, hashData.length);
  28731. return compareByteArrays(result, userPassword);
  28732. },
  28733. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28734. var hashData = new Uint8Array(password.length + 56);
  28735. hashData.set(password, 0);
  28736. hashData.set(ownerKeySalt, password.length);
  28737. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28738. var key = calculateSHA256(hashData, 0, hashData.length);
  28739. var cipher = new AES256Cipher(key);
  28740. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28741. },
  28742. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  28743. var hashData = new Uint8Array(password.length + 8);
  28744. hashData.set(password, 0);
  28745. hashData.set(userKeySalt, password.length);
  28746. var key = calculateSHA256(hashData, 0, hashData.length);
  28747. var cipher = new AES256Cipher(key);
  28748. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28749. }
  28750. };
  28751. return PDF17;
  28752. }();
  28753. var PDF20 = function PDF20Closure() {
  28754. function concatArrays(array1, array2) {
  28755. var t = new Uint8Array(array1.length + array2.length);
  28756. t.set(array1, 0);
  28757. t.set(array2, array1.length);
  28758. return t;
  28759. }
  28760. function calculatePDF20Hash(password, input, userBytes) {
  28761. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  28762. var e = [0];
  28763. var i = 0;
  28764. while (i < 64 || e[e.length - 1] > i - 32) {
  28765. var arrayLength = password.length + k.length + userBytes.length;
  28766. var k1 = new Uint8Array(arrayLength * 64);
  28767. var array = concatArrays(password, k);
  28768. array = concatArrays(array, userBytes);
  28769. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  28770. k1.set(array, pos);
  28771. }
  28772. var cipher = new AES128Cipher(k.subarray(0, 16));
  28773. e = cipher.encrypt(k1, k.subarray(16, 32));
  28774. var remainder = 0;
  28775. for (var z = 0; z < 16; z++) {
  28776. remainder *= 256 % 3;
  28777. remainder %= 3;
  28778. remainder += (e[z] >>> 0) % 3;
  28779. remainder %= 3;
  28780. }
  28781. if (remainder === 0) {
  28782. k = calculateSHA256(e, 0, e.length);
  28783. } else if (remainder === 1) {
  28784. k = calculateSHA384(e, 0, e.length);
  28785. } else if (remainder === 2) {
  28786. k = calculateSHA512(e, 0, e.length);
  28787. }
  28788. i++;
  28789. }
  28790. return k.subarray(0, 32);
  28791. }
  28792. function PDF20() {
  28793. }
  28794. function compareByteArrays(array1, array2) {
  28795. if (array1.length !== array2.length) {
  28796. return false;
  28797. }
  28798. for (var i = 0; i < array1.length; i++) {
  28799. if (array1[i] !== array2[i]) {
  28800. return false;
  28801. }
  28802. }
  28803. return true;
  28804. }
  28805. PDF20.prototype = {
  28806. hash: function PDF20_hash(password, concatBytes, userBytes) {
  28807. return calculatePDF20Hash(password, concatBytes, userBytes);
  28808. },
  28809. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28810. var hashData = new Uint8Array(password.length + 56);
  28811. hashData.set(password, 0);
  28812. hashData.set(ownerValidationSalt, password.length);
  28813. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28814. var result = calculatePDF20Hash(password, hashData, userBytes);
  28815. return compareByteArrays(result, ownerPassword);
  28816. },
  28817. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  28818. var hashData = new Uint8Array(password.length + 8);
  28819. hashData.set(password, 0);
  28820. hashData.set(userValidationSalt, password.length);
  28821. var result = calculatePDF20Hash(password, hashData, []);
  28822. return compareByteArrays(result, userPassword);
  28823. },
  28824. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28825. var hashData = new Uint8Array(password.length + 56);
  28826. hashData.set(password, 0);
  28827. hashData.set(ownerKeySalt, password.length);
  28828. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28829. var key = calculatePDF20Hash(password, hashData, userBytes);
  28830. var cipher = new AES256Cipher(key);
  28831. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28832. },
  28833. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  28834. var hashData = new Uint8Array(password.length + 8);
  28835. hashData.set(password, 0);
  28836. hashData.set(userKeySalt, password.length);
  28837. var key = calculatePDF20Hash(password, hashData, []);
  28838. var cipher = new AES256Cipher(key);
  28839. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28840. }
  28841. };
  28842. return PDF20;
  28843. }();
  28844. var CipherTransform = function CipherTransformClosure() {
  28845. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  28846. this.StringCipherConstructor = stringCipherConstructor;
  28847. this.StreamCipherConstructor = streamCipherConstructor;
  28848. }
  28849. CipherTransform.prototype = {
  28850. createStream: function CipherTransform_createStream(stream, length) {
  28851. var cipher = new this.StreamCipherConstructor();
  28852. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  28853. return cipher.decryptBlock(data, finalize);
  28854. });
  28855. },
  28856. decryptString: function CipherTransform_decryptString(s) {
  28857. var cipher = new this.StringCipherConstructor();
  28858. var data = stringToBytes(s);
  28859. data = cipher.decryptBlock(data, true);
  28860. return bytesToString(data);
  28861. }
  28862. };
  28863. return CipherTransform;
  28864. }();
  28865. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  28866. var defaultPasswordBytes = new Uint8Array([
  28867. 0x28,
  28868. 0xBF,
  28869. 0x4E,
  28870. 0x5E,
  28871. 0x4E,
  28872. 0x75,
  28873. 0x8A,
  28874. 0x41,
  28875. 0x64,
  28876. 0x00,
  28877. 0x4E,
  28878. 0x56,
  28879. 0xFF,
  28880. 0xFA,
  28881. 0x01,
  28882. 0x08,
  28883. 0x2E,
  28884. 0x2E,
  28885. 0x00,
  28886. 0xB6,
  28887. 0xD0,
  28888. 0x68,
  28889. 0x3E,
  28890. 0x80,
  28891. 0x2F,
  28892. 0x0C,
  28893. 0xA9,
  28894. 0xFE,
  28895. 0x64,
  28896. 0x53,
  28897. 0x69,
  28898. 0x7A
  28899. ]);
  28900. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  28901. if (password) {
  28902. var passwordLength = Math.min(127, password.length);
  28903. password = password.subarray(0, passwordLength);
  28904. } else {
  28905. password = [];
  28906. }
  28907. var pdfAlgorithm;
  28908. if (revision === 6) {
  28909. pdfAlgorithm = new PDF20();
  28910. } else {
  28911. pdfAlgorithm = new PDF17();
  28912. }
  28913. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  28914. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  28915. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  28916. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  28917. }
  28918. return null;
  28919. }
  28920. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  28921. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  28922. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  28923. if (password) {
  28924. n = Math.min(32, password.length);
  28925. for (; i < n; ++i) {
  28926. hashData[i] = password[i];
  28927. }
  28928. }
  28929. j = 0;
  28930. while (i < 32) {
  28931. hashData[i++] = defaultPasswordBytes[j++];
  28932. }
  28933. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  28934. hashData[i++] = ownerPassword[j];
  28935. }
  28936. hashData[i++] = flags & 0xFF;
  28937. hashData[i++] = flags >> 8 & 0xFF;
  28938. hashData[i++] = flags >> 16 & 0xFF;
  28939. hashData[i++] = flags >>> 24 & 0xFF;
  28940. for (j = 0, n = fileId.length; j < n; ++j) {
  28941. hashData[i++] = fileId[j];
  28942. }
  28943. if (revision >= 4 && !encryptMetadata) {
  28944. hashData[i++] = 0xFF;
  28945. hashData[i++] = 0xFF;
  28946. hashData[i++] = 0xFF;
  28947. hashData[i++] = 0xFF;
  28948. }
  28949. var hash = calculateMD5(hashData, 0, i);
  28950. var keyLengthInBytes = keyLength >> 3;
  28951. if (revision >= 3) {
  28952. for (j = 0; j < 50; ++j) {
  28953. hash = calculateMD5(hash, 0, keyLengthInBytes);
  28954. }
  28955. }
  28956. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  28957. var cipher, checkData;
  28958. if (revision >= 3) {
  28959. for (i = 0; i < 32; ++i) {
  28960. hashData[i] = defaultPasswordBytes[i];
  28961. }
  28962. for (j = 0, n = fileId.length; j < n; ++j) {
  28963. hashData[i++] = fileId[j];
  28964. }
  28965. cipher = new ARCFourCipher(encryptionKey);
  28966. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  28967. n = encryptionKey.length;
  28968. var derivedKey = new Uint8Array(n), k;
  28969. for (j = 1; j <= 19; ++j) {
  28970. for (k = 0; k < n; ++k) {
  28971. derivedKey[k] = encryptionKey[k] ^ j;
  28972. }
  28973. cipher = new ARCFourCipher(derivedKey);
  28974. checkData = cipher.encryptBlock(checkData);
  28975. }
  28976. for (j = 0, n = checkData.length; j < n; ++j) {
  28977. if (userPassword[j] !== checkData[j]) {
  28978. return null;
  28979. }
  28980. }
  28981. } else {
  28982. cipher = new ARCFourCipher(encryptionKey);
  28983. checkData = cipher.encryptBlock(defaultPasswordBytes);
  28984. for (j = 0, n = checkData.length; j < n; ++j) {
  28985. if (userPassword[j] !== checkData[j]) {
  28986. return null;
  28987. }
  28988. }
  28989. }
  28990. return encryptionKey;
  28991. }
  28992. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  28993. var hashData = new Uint8Array(32), i = 0, j, n;
  28994. n = Math.min(32, password.length);
  28995. for (; i < n; ++i) {
  28996. hashData[i] = password[i];
  28997. }
  28998. j = 0;
  28999. while (i < 32) {
  29000. hashData[i++] = defaultPasswordBytes[j++];
  29001. }
  29002. var hash = calculateMD5(hashData, 0, i);
  29003. var keyLengthInBytes = keyLength >> 3;
  29004. if (revision >= 3) {
  29005. for (j = 0; j < 50; ++j) {
  29006. hash = calculateMD5(hash, 0, hash.length);
  29007. }
  29008. }
  29009. var cipher, userPassword;
  29010. if (revision >= 3) {
  29011. userPassword = ownerPassword;
  29012. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  29013. for (j = 19; j >= 0; j--) {
  29014. for (k = 0; k < keyLengthInBytes; ++k) {
  29015. derivedKey[k] = hash[k] ^ j;
  29016. }
  29017. cipher = new ARCFourCipher(derivedKey);
  29018. userPassword = cipher.encryptBlock(userPassword);
  29019. }
  29020. } else {
  29021. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  29022. userPassword = cipher.encryptBlock(ownerPassword);
  29023. }
  29024. return userPassword;
  29025. }
  29026. var identityName = Name.get('Identity');
  29027. function CipherTransformFactory(dict, fileId, password) {
  29028. var filter = dict.get('Filter');
  29029. if (!isName(filter, 'Standard')) {
  29030. error('unknown encryption method');
  29031. }
  29032. this.dict = dict;
  29033. var algorithm = dict.get('V');
  29034. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  29035. error('unsupported encryption algorithm');
  29036. }
  29037. this.algorithm = algorithm;
  29038. var keyLength = dict.get('Length');
  29039. if (!keyLength) {
  29040. if (algorithm <= 3) {
  29041. keyLength = 40;
  29042. } else {
  29043. var cfDict = dict.get('CF');
  29044. var streamCryptoName = dict.get('StmF');
  29045. if (isDict(cfDict) && isName(streamCryptoName)) {
  29046. cfDict.suppressEncryption = true;
  29047. var handlerDict = cfDict.get(streamCryptoName.name);
  29048. keyLength = handlerDict && handlerDict.get('Length') || 128;
  29049. if (keyLength < 40) {
  29050. keyLength <<= 3;
  29051. }
  29052. }
  29053. }
  29054. }
  29055. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  29056. error('invalid key length');
  29057. }
  29058. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  29059. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  29060. var flags = dict.get('P');
  29061. var revision = dict.get('R');
  29062. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  29063. this.encryptMetadata = encryptMetadata;
  29064. var fileIdBytes = stringToBytes(fileId);
  29065. var passwordBytes;
  29066. if (password) {
  29067. if (revision === 6) {
  29068. try {
  29069. password = utf8StringToString(password);
  29070. } catch (ex) {
  29071. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  29072. }
  29073. }
  29074. passwordBytes = stringToBytes(password);
  29075. }
  29076. var encryptionKey;
  29077. if (algorithm !== 5) {
  29078. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29079. } else {
  29080. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  29081. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  29082. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  29083. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  29084. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  29085. var ownerEncryption = stringToBytes(dict.get('OE'));
  29086. var userEncryption = stringToBytes(dict.get('UE'));
  29087. var perms = stringToBytes(dict.get('Perms'));
  29088. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  29089. }
  29090. if (!encryptionKey && !password) {
  29091. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  29092. } else if (!encryptionKey && password) {
  29093. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  29094. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29095. }
  29096. if (!encryptionKey) {
  29097. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  29098. }
  29099. this.encryptionKey = encryptionKey;
  29100. if (algorithm >= 4) {
  29101. var cf = dict.get('CF');
  29102. if (isDict(cf)) {
  29103. cf.suppressEncryption = true;
  29104. }
  29105. this.cf = cf;
  29106. this.stmf = dict.get('StmF') || identityName;
  29107. this.strf = dict.get('StrF') || identityName;
  29108. this.eff = dict.get('EFF') || this.stmf;
  29109. }
  29110. }
  29111. function buildObjectKey(num, gen, encryptionKey, isAes) {
  29112. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  29113. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  29114. key[i] = encryptionKey[i];
  29115. }
  29116. key[i++] = num & 0xFF;
  29117. key[i++] = num >> 8 & 0xFF;
  29118. key[i++] = num >> 16 & 0xFF;
  29119. key[i++] = gen & 0xFF;
  29120. key[i++] = gen >> 8 & 0xFF;
  29121. if (isAes) {
  29122. key[i++] = 0x73;
  29123. key[i++] = 0x41;
  29124. key[i++] = 0x6C;
  29125. key[i++] = 0x54;
  29126. }
  29127. var hash = calculateMD5(key, 0, i);
  29128. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  29129. }
  29130. function buildCipherConstructor(cf, name, num, gen, key) {
  29131. assert(isName(name), 'Invalid crypt filter name.');
  29132. var cryptFilter = cf.get(name.name);
  29133. var cfm;
  29134. if (cryptFilter !== null && cryptFilter !== undefined) {
  29135. cfm = cryptFilter.get('CFM');
  29136. }
  29137. if (!cfm || cfm.name === 'None') {
  29138. return function cipherTransformFactoryBuildCipherConstructorNone() {
  29139. return new NullCipher();
  29140. };
  29141. }
  29142. if (cfm.name === 'V2') {
  29143. return function cipherTransformFactoryBuildCipherConstructorV2() {
  29144. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  29145. };
  29146. }
  29147. if (cfm.name === 'AESV2') {
  29148. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  29149. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  29150. };
  29151. }
  29152. if (cfm.name === 'AESV3') {
  29153. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  29154. return new AES256Cipher(key);
  29155. };
  29156. }
  29157. error('Unknown crypto method');
  29158. }
  29159. CipherTransformFactory.prototype = {
  29160. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  29161. if (this.algorithm === 4 || this.algorithm === 5) {
  29162. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  29163. }
  29164. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  29165. var cipherConstructor = function buildCipherCipherConstructor() {
  29166. return new ARCFourCipher(key);
  29167. };
  29168. return new CipherTransform(cipherConstructor, cipherConstructor);
  29169. }
  29170. };
  29171. return CipherTransformFactory;
  29172. }();
  29173. exports.AES128Cipher = AES128Cipher;
  29174. exports.AES256Cipher = AES256Cipher;
  29175. exports.ARCFourCipher = ARCFourCipher;
  29176. exports.CipherTransformFactory = CipherTransformFactory;
  29177. exports.PDF17 = PDF17;
  29178. exports.PDF20 = PDF20;
  29179. exports.calculateMD5 = calculateMD5;
  29180. exports.calculateSHA256 = calculateSHA256;
  29181. exports.calculateSHA384 = calculateSHA384;
  29182. exports.calculateSHA512 = calculateSHA512;
  29183. /***/ }),
  29184. /* 17 */
  29185. /***/ (function(module, exports, __w_pdfjs_require__) {
  29186. "use strict";
  29187. var sharedUtil = __w_pdfjs_require__(0);
  29188. var corePrimitives = __w_pdfjs_require__(1);
  29189. var coreStream = __w_pdfjs_require__(2);
  29190. var coreParser = __w_pdfjs_require__(6);
  29191. var coreImage = __w_pdfjs_require__(34);
  29192. var coreColorSpace = __w_pdfjs_require__(4);
  29193. var coreMurmurHash3 = __w_pdfjs_require__(38);
  29194. var coreFonts = __w_pdfjs_require__(33);
  29195. var coreFunction = __w_pdfjs_require__(7);
  29196. var corePattern = __w_pdfjs_require__(40);
  29197. var coreCMap = __w_pdfjs_require__(30);
  29198. var coreMetrics = __w_pdfjs_require__(37);
  29199. var coreBidi = __w_pdfjs_require__(28);
  29200. var coreEncodings = __w_pdfjs_require__(5);
  29201. var coreStandardFonts = __w_pdfjs_require__(20);
  29202. var coreUnicode = __w_pdfjs_require__(21);
  29203. var coreGlyphList = __w_pdfjs_require__(8);
  29204. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  29205. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  29206. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  29207. var ImageKind = sharedUtil.ImageKind;
  29208. var OPS = sharedUtil.OPS;
  29209. var TextRenderingMode = sharedUtil.TextRenderingMode;
  29210. var CMapCompressionType = sharedUtil.CMapCompressionType;
  29211. var Util = sharedUtil.Util;
  29212. var assert = sharedUtil.assert;
  29213. var createPromiseCapability = sharedUtil.createPromiseCapability;
  29214. var error = sharedUtil.error;
  29215. var info = sharedUtil.info;
  29216. var isArray = sharedUtil.isArray;
  29217. var isNum = sharedUtil.isNum;
  29218. var isString = sharedUtil.isString;
  29219. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  29220. var warn = sharedUtil.warn;
  29221. var Dict = corePrimitives.Dict;
  29222. var Name = corePrimitives.Name;
  29223. var isEOF = corePrimitives.isEOF;
  29224. var isCmd = corePrimitives.isCmd;
  29225. var isDict = corePrimitives.isDict;
  29226. var isName = corePrimitives.isName;
  29227. var isRef = corePrimitives.isRef;
  29228. var isStream = corePrimitives.isStream;
  29229. var DecodeStream = coreStream.DecodeStream;
  29230. var JpegStream = coreStream.JpegStream;
  29231. var Stream = coreStream.Stream;
  29232. var Lexer = coreParser.Lexer;
  29233. var Parser = coreParser.Parser;
  29234. var PDFImage = coreImage.PDFImage;
  29235. var ColorSpace = coreColorSpace.ColorSpace;
  29236. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  29237. var ErrorFont = coreFonts.ErrorFont;
  29238. var FontFlags = coreFonts.FontFlags;
  29239. var Font = coreFonts.Font;
  29240. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  29241. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  29242. var getFontType = coreFonts.getFontType;
  29243. var isPDFFunction = coreFunction.isPDFFunction;
  29244. var PDFFunction = coreFunction.PDFFunction;
  29245. var Pattern = corePattern.Pattern;
  29246. var getTilingPatternIR = corePattern.getTilingPatternIR;
  29247. var CMapFactory = coreCMap.CMapFactory;
  29248. var IdentityCMap = coreCMap.IdentityCMap;
  29249. var getMetrics = coreMetrics.getMetrics;
  29250. var bidi = coreBidi.bidi;
  29251. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  29252. var StandardEncoding = coreEncodings.StandardEncoding;
  29253. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  29254. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  29255. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  29256. var getEncoding = coreEncodings.getEncoding;
  29257. var getStdFontMap = coreStandardFonts.getStdFontMap;
  29258. var getSerifFonts = coreStandardFonts.getSerifFonts;
  29259. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  29260. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  29261. var reverseIfRtl = coreUnicode.reverseIfRtl;
  29262. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  29263. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  29264. var PartialEvaluator = function PartialEvaluatorClosure() {
  29265. var DefaultPartialEvaluatorOptions = {
  29266. forceDataSchema: false,
  29267. maxImageSize: -1,
  29268. disableFontFace: false,
  29269. disableNativeImageDecoder: false
  29270. };
  29271. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  29272. this.xref = xref;
  29273. this.resources = resources;
  29274. this.handler = handler;
  29275. this.forceDataSchema = forceDataSchema;
  29276. }
  29277. NativeImageDecoder.prototype = {
  29278. canDecode: function (image) {
  29279. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  29280. },
  29281. decode: function (image) {
  29282. var dict = image.dict;
  29283. var colorSpace = dict.get('ColorSpace', 'CS');
  29284. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  29285. var numComps = colorSpace.numComps;
  29286. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  29287. image.getIR(this.forceDataSchema),
  29288. numComps
  29289. ]);
  29290. return decodePromise.then(function (message) {
  29291. var data = message.data;
  29292. return new Stream(data, 0, data.length, image.dict);
  29293. });
  29294. }
  29295. };
  29296. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  29297. var dict = image.dict;
  29298. if (dict.has('DecodeParms') || dict.has('DP')) {
  29299. return false;
  29300. }
  29301. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29302. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29303. };
  29304. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  29305. var dict = image.dict;
  29306. if (dict.has('DecodeParms') || dict.has('DP')) {
  29307. return false;
  29308. }
  29309. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29310. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29311. };
  29312. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options) {
  29313. this.pdfManager = pdfManager;
  29314. this.xref = xref;
  29315. this.handler = handler;
  29316. this.pageIndex = pageIndex;
  29317. this.idFactory = idFactory;
  29318. this.fontCache = fontCache;
  29319. this.builtInCMapCache = builtInCMapCache;
  29320. this.options = options || DefaultPartialEvaluatorOptions;
  29321. this.fetchBuiltInCMap = function (name) {
  29322. var cachedCMap = builtInCMapCache[name];
  29323. if (cachedCMap) {
  29324. return Promise.resolve(cachedCMap);
  29325. }
  29326. return handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) {
  29327. if (data.compressionType !== CMapCompressionType.NONE) {
  29328. builtInCMapCache[name] = data;
  29329. }
  29330. return data;
  29331. });
  29332. };
  29333. }
  29334. var TIME_SLOT_DURATION_MS = 20;
  29335. var CHECK_TIME_EVERY = 100;
  29336. function TimeSlotManager() {
  29337. this.reset();
  29338. }
  29339. TimeSlotManager.prototype = {
  29340. check: function TimeSlotManager_check() {
  29341. if (++this.checked < CHECK_TIME_EVERY) {
  29342. return false;
  29343. }
  29344. this.checked = 0;
  29345. return this.endTime <= Date.now();
  29346. },
  29347. reset: function TimeSlotManager_reset() {
  29348. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  29349. this.checked = 0;
  29350. }
  29351. };
  29352. var deferred = Promise.resolve();
  29353. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  29354. PartialEvaluator.prototype = {
  29355. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  29356. if (!isDict(resources)) {
  29357. return false;
  29358. }
  29359. var processed = Object.create(null);
  29360. if (resources.objId) {
  29361. processed[resources.objId] = true;
  29362. }
  29363. var nodes = [resources], xref = this.xref;
  29364. while (nodes.length) {
  29365. var key, i, ii;
  29366. var node = nodes.shift();
  29367. var graphicStates = node.get('ExtGState');
  29368. if (isDict(graphicStates)) {
  29369. var graphicStatesKeys = graphicStates.getKeys();
  29370. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  29371. key = graphicStatesKeys[i];
  29372. var graphicState = graphicStates.get(key);
  29373. var bm = graphicState.get('BM');
  29374. if (isName(bm) && bm.name !== 'Normal') {
  29375. return true;
  29376. }
  29377. }
  29378. }
  29379. var xObjects = node.get('XObject');
  29380. if (!isDict(xObjects)) {
  29381. continue;
  29382. }
  29383. var xObjectsKeys = xObjects.getKeys();
  29384. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  29385. key = xObjectsKeys[i];
  29386. var xObject = xObjects.getRaw(key);
  29387. if (isRef(xObject)) {
  29388. if (processed[xObject.toString()]) {
  29389. continue;
  29390. }
  29391. xObject = xref.fetch(xObject);
  29392. }
  29393. if (!isStream(xObject)) {
  29394. continue;
  29395. }
  29396. if (xObject.dict.objId) {
  29397. if (processed[xObject.dict.objId]) {
  29398. continue;
  29399. }
  29400. processed[xObject.dict.objId] = true;
  29401. }
  29402. var xResources = xObject.dict.get('Resources');
  29403. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  29404. nodes.push(xResources);
  29405. if (xResources.objId) {
  29406. processed[xResources.objId] = true;
  29407. }
  29408. }
  29409. }
  29410. }
  29411. return false;
  29412. },
  29413. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  29414. var matrix = xobj.dict.getArray('Matrix');
  29415. var bbox = xobj.dict.getArray('BBox');
  29416. var group = xobj.dict.get('Group');
  29417. if (group) {
  29418. var groupOptions = {
  29419. matrix: matrix,
  29420. bbox: bbox,
  29421. smask: smask,
  29422. isolated: false,
  29423. knockout: false
  29424. };
  29425. var groupSubtype = group.get('S');
  29426. var colorSpace;
  29427. if (isName(groupSubtype, 'Transparency')) {
  29428. groupOptions.isolated = group.get('I') || false;
  29429. groupOptions.knockout = group.get('K') || false;
  29430. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  29431. }
  29432. if (smask && smask.backdrop) {
  29433. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  29434. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  29435. }
  29436. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  29437. }
  29438. operatorList.addOp(OPS.paintFormXObjectBegin, [
  29439. matrix,
  29440. bbox
  29441. ]);
  29442. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  29443. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  29444. if (group) {
  29445. operatorList.addOp(OPS.endGroup, [groupOptions]);
  29446. }
  29447. });
  29448. },
  29449. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  29450. var self = this;
  29451. var dict = image.dict;
  29452. var w = dict.get('Width', 'W');
  29453. var h = dict.get('Height', 'H');
  29454. if (!(w && isNum(w)) || !(h && isNum(h))) {
  29455. warn('Image dimensions are missing, or not numbers.');
  29456. return;
  29457. }
  29458. var maxImageSize = this.options.maxImageSize;
  29459. if (maxImageSize !== -1 && w * h > maxImageSize) {
  29460. warn('Image exceeded maximum allowed size and was removed.');
  29461. return;
  29462. }
  29463. var imageMask = dict.get('ImageMask', 'IM') || false;
  29464. var imgData, args;
  29465. if (imageMask) {
  29466. var width = dict.get('Width', 'W');
  29467. var height = dict.get('Height', 'H');
  29468. var bitStrideLength = width + 7 >> 3;
  29469. var imgArray = image.getBytes(bitStrideLength * height);
  29470. var decode = dict.getArray('Decode', 'D');
  29471. var inverseDecode = !!decode && decode[0] > 0;
  29472. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  29473. imgData.cached = true;
  29474. args = [imgData];
  29475. operatorList.addOp(OPS.paintImageMaskXObject, args);
  29476. if (cacheKey) {
  29477. imageCache[cacheKey] = {
  29478. fn: OPS.paintImageMaskXObject,
  29479. args: args
  29480. };
  29481. }
  29482. return;
  29483. }
  29484. var softMask = dict.get('SMask', 'SM') || false;
  29485. var mask = dict.get('Mask') || false;
  29486. var SMALL_IMAGE_DIMENSIONS = 200;
  29487. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  29488. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  29489. imgData = imageObj.createImageData(true);
  29490. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  29491. return;
  29492. }
  29493. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  29494. var objId = 'img_' + this.idFactory.createObjId();
  29495. operatorList.addDependency(objId);
  29496. args = [
  29497. objId,
  29498. w,
  29499. h
  29500. ];
  29501. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  29502. operatorList.addOp(OPS.paintJpegXObject, args);
  29503. this.handler.send('obj', [
  29504. objId,
  29505. this.pageIndex,
  29506. 'JpegStream',
  29507. image.getIR(this.options.forceDataSchema)
  29508. ]);
  29509. return;
  29510. }
  29511. var nativeImageDecoder = null;
  29512. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  29513. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  29514. }
  29515. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  29516. var imgData = imageObj.createImageData(false);
  29517. self.handler.send('obj', [
  29518. objId,
  29519. self.pageIndex,
  29520. 'Image',
  29521. imgData
  29522. ], [imgData.data.buffer]);
  29523. }).then(undefined, function (reason) {
  29524. warn('Unable to decode image: ' + reason);
  29525. self.handler.send('obj', [
  29526. objId,
  29527. self.pageIndex,
  29528. 'Image',
  29529. null
  29530. ]);
  29531. });
  29532. operatorList.addOp(OPS.paintImageXObject, args);
  29533. if (cacheKey) {
  29534. imageCache[cacheKey] = {
  29535. fn: OPS.paintImageXObject,
  29536. args: args
  29537. };
  29538. }
  29539. },
  29540. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  29541. var smaskContent = smask.get('G');
  29542. var smaskOptions = {
  29543. subtype: smask.get('S').name,
  29544. backdrop: smask.get('BC')
  29545. };
  29546. var transferObj = smask.get('TR');
  29547. if (isPDFFunction(transferObj)) {
  29548. var transferFn = PDFFunction.parse(this.xref, transferObj);
  29549. var transferMap = new Uint8Array(256);
  29550. var tmp = new Float32Array(1);
  29551. for (var i = 0; i < 256; i++) {
  29552. tmp[0] = i / 255;
  29553. transferFn(tmp, 0, tmp, 0);
  29554. transferMap[i] = tmp[0] * 255 | 0;
  29555. }
  29556. smaskOptions.transferMap = transferMap;
  29557. }
  29558. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  29559. },
  29560. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  29561. var tilingOpList = new OperatorList();
  29562. var resourcesArray = [
  29563. patternDict.get('Resources'),
  29564. resources
  29565. ];
  29566. var patternResources = Dict.merge(this.xref, resourcesArray);
  29567. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  29568. operatorList.addDependencies(tilingOpList.dependencies);
  29569. operatorList.addOp(fn, getTilingPatternIR({
  29570. fnArray: tilingOpList.fnArray,
  29571. argsArray: tilingOpList.argsArray
  29572. }, patternDict, args));
  29573. });
  29574. },
  29575. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  29576. var fontName;
  29577. if (fontArgs) {
  29578. fontArgs = fontArgs.slice();
  29579. fontName = fontArgs[0].name;
  29580. }
  29581. var self = this;
  29582. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  29583. if (!translated.font.isType3Font) {
  29584. return translated;
  29585. }
  29586. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  29587. return translated;
  29588. }, function (reason) {
  29589. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29590. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  29591. });
  29592. }).then(function (translated) {
  29593. state.font = translated.font;
  29594. translated.send(self.handler);
  29595. return translated.loadedName;
  29596. });
  29597. },
  29598. handleText: function PartialEvaluator_handleText(chars, state) {
  29599. var font = state.font;
  29600. var glyphs = font.charsToGlyphs(chars);
  29601. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  29602. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  29603. var buildPath = function (fontChar) {
  29604. if (!font.renderer.hasBuiltPath(fontChar)) {
  29605. var path = font.renderer.getPathJs(fontChar);
  29606. this.handler.send('commonobj', [
  29607. font.loadedName + '_path_' + fontChar,
  29608. 'FontPath',
  29609. path
  29610. ]);
  29611. }
  29612. }.bind(this);
  29613. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  29614. var glyph = glyphs[i];
  29615. buildPath(glyph.fontChar);
  29616. var accent = glyph.accent;
  29617. if (accent && accent.fontChar) {
  29618. buildPath(accent.fontChar);
  29619. }
  29620. }
  29621. }
  29622. return glyphs;
  29623. },
  29624. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  29625. var gStateObj = [];
  29626. var gStateKeys = gState.getKeys();
  29627. var self = this;
  29628. var promise = Promise.resolve();
  29629. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  29630. var key = gStateKeys[i];
  29631. var value = gState.get(key);
  29632. switch (key) {
  29633. case 'Type':
  29634. break;
  29635. case 'LW':
  29636. case 'LC':
  29637. case 'LJ':
  29638. case 'ML':
  29639. case 'D':
  29640. case 'RI':
  29641. case 'FL':
  29642. case 'CA':
  29643. case 'ca':
  29644. gStateObj.push([
  29645. key,
  29646. value
  29647. ]);
  29648. break;
  29649. case 'Font':
  29650. promise = promise.then(function () {
  29651. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  29652. operatorList.addDependency(loadedName);
  29653. gStateObj.push([
  29654. key,
  29655. [
  29656. loadedName,
  29657. value[1]
  29658. ]
  29659. ]);
  29660. });
  29661. });
  29662. break;
  29663. case 'BM':
  29664. gStateObj.push([
  29665. key,
  29666. value
  29667. ]);
  29668. break;
  29669. case 'SMask':
  29670. if (isName(value, 'None')) {
  29671. gStateObj.push([
  29672. key,
  29673. false
  29674. ]);
  29675. break;
  29676. }
  29677. if (isDict(value)) {
  29678. promise = promise.then(function (dict) {
  29679. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  29680. }.bind(this, value));
  29681. gStateObj.push([
  29682. key,
  29683. true
  29684. ]);
  29685. } else {
  29686. warn('Unsupported SMask type');
  29687. }
  29688. break;
  29689. case 'OP':
  29690. case 'op':
  29691. case 'OPM':
  29692. case 'BG':
  29693. case 'BG2':
  29694. case 'UCR':
  29695. case 'UCR2':
  29696. case 'TR':
  29697. case 'TR2':
  29698. case 'HT':
  29699. case 'SM':
  29700. case 'SA':
  29701. case 'AIS':
  29702. case 'TK':
  29703. info('graphic state operator ' + key);
  29704. break;
  29705. default:
  29706. info('Unknown graphic state operator ' + key);
  29707. break;
  29708. }
  29709. }
  29710. return promise.then(function () {
  29711. if (gStateObj.length > 0) {
  29712. operatorList.addOp(OPS.setGState, [gStateObj]);
  29713. }
  29714. });
  29715. },
  29716. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  29717. function errorFont() {
  29718. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  29719. }
  29720. var fontRef;
  29721. if (font) {
  29722. assert(isRef(font));
  29723. fontRef = font;
  29724. } else {
  29725. var fontRes = resources.get('Font');
  29726. if (fontRes) {
  29727. fontRef = fontRes.getRaw(fontName);
  29728. } else {
  29729. warn('fontRes not available');
  29730. return errorFont();
  29731. }
  29732. }
  29733. if (!fontRef) {
  29734. warn('fontRef not available');
  29735. return errorFont();
  29736. }
  29737. if (this.fontCache.has(fontRef)) {
  29738. return this.fontCache.get(fontRef);
  29739. }
  29740. font = xref.fetchIfRef(fontRef);
  29741. if (!isDict(font)) {
  29742. return errorFont();
  29743. }
  29744. if (font.translated) {
  29745. return font.translated;
  29746. }
  29747. var fontCapability = createPromiseCapability();
  29748. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  29749. var descriptor = preEvaluatedFont.descriptor;
  29750. var fontRefIsRef = isRef(fontRef), fontID;
  29751. if (fontRefIsRef) {
  29752. fontID = fontRef.toString();
  29753. }
  29754. if (isDict(descriptor)) {
  29755. if (!descriptor.fontAliases) {
  29756. descriptor.fontAliases = Object.create(null);
  29757. }
  29758. var fontAliases = descriptor.fontAliases;
  29759. var hash = preEvaluatedFont.hash;
  29760. if (fontAliases[hash]) {
  29761. var aliasFontRef = fontAliases[hash].aliasRef;
  29762. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  29763. this.fontCache.putAlias(fontRef, aliasFontRef);
  29764. return this.fontCache.get(fontRef);
  29765. }
  29766. } else {
  29767. fontAliases[hash] = { fontID: Font.getFontID() };
  29768. }
  29769. if (fontRefIsRef) {
  29770. fontAliases[hash].aliasRef = fontRef;
  29771. }
  29772. fontID = fontAliases[hash].fontID;
  29773. }
  29774. if (fontRefIsRef) {
  29775. this.fontCache.put(fontRef, fontCapability.promise);
  29776. } else {
  29777. if (!fontID) {
  29778. fontID = this.idFactory.createObjId();
  29779. }
  29780. this.fontCache.put('id_' + fontID, fontCapability.promise);
  29781. }
  29782. assert(fontID, 'The "fontID" must be defined.');
  29783. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  29784. font.translated = fontCapability.promise;
  29785. var translatedPromise;
  29786. try {
  29787. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  29788. } catch (e) {
  29789. translatedPromise = Promise.reject(e);
  29790. }
  29791. var self = this;
  29792. translatedPromise.then(function (translatedFont) {
  29793. if (translatedFont.fontType !== undefined) {
  29794. var xrefFontStats = xref.stats.fontTypes;
  29795. xrefFontStats[translatedFont.fontType] = true;
  29796. }
  29797. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  29798. }, function (reason) {
  29799. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29800. try {
  29801. var descriptor = preEvaluatedFont.descriptor;
  29802. var fontFile3 = descriptor && descriptor.get('FontFile3');
  29803. var subtype = fontFile3 && fontFile3.get('Subtype');
  29804. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  29805. var xrefFontStats = xref.stats.fontTypes;
  29806. xrefFontStats[fontType] = true;
  29807. } catch (ex) {
  29808. }
  29809. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  29810. });
  29811. return fontCapability.promise;
  29812. },
  29813. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  29814. var lastIndex = operatorList.length - 1;
  29815. if (!args) {
  29816. args = [];
  29817. }
  29818. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  29819. operatorList.addOp(OPS.constructPath, [
  29820. [fn],
  29821. args
  29822. ]);
  29823. } else {
  29824. var opArgs = operatorList.argsArray[lastIndex];
  29825. opArgs[0].push(fn);
  29826. Array.prototype.push.apply(opArgs[1], args);
  29827. }
  29828. },
  29829. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  29830. var patternName = args[args.length - 1];
  29831. var pattern;
  29832. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  29833. var dict = isStream(pattern) ? pattern.dict : pattern;
  29834. var typeNum = dict.get('PatternType');
  29835. if (typeNum === TILING_PATTERN) {
  29836. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  29837. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  29838. } else if (typeNum === SHADING_PATTERN) {
  29839. var shading = dict.get('Shading');
  29840. var matrix = dict.getArray('Matrix');
  29841. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  29842. operatorList.addOp(fn, pattern.getIR());
  29843. return Promise.resolve();
  29844. }
  29845. return Promise.reject('Unknown PatternType: ' + typeNum);
  29846. }
  29847. operatorList.addOp(fn, args);
  29848. return Promise.resolve();
  29849. },
  29850. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  29851. var self = this;
  29852. var xref = this.xref;
  29853. var imageCache = Object.create(null);
  29854. assert(operatorList);
  29855. resources = resources || Dict.empty;
  29856. var xobjs = resources.get('XObject') || Dict.empty;
  29857. var patterns = resources.get('Pattern') || Dict.empty;
  29858. var stateManager = new StateManager(initialState || new EvalState());
  29859. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29860. var timeSlotManager = new TimeSlotManager();
  29861. return new Promise(function promiseBody(resolve, reject) {
  29862. var next = function (promise) {
  29863. promise.then(function () {
  29864. try {
  29865. promiseBody(resolve, reject);
  29866. } catch (ex) {
  29867. reject(ex);
  29868. }
  29869. }, reject);
  29870. };
  29871. task.ensureNotTerminated();
  29872. timeSlotManager.reset();
  29873. var stop, operation = {}, i, ii, cs;
  29874. while (!(stop = timeSlotManager.check())) {
  29875. operation.args = null;
  29876. if (!preprocessor.read(operation)) {
  29877. break;
  29878. }
  29879. var args = operation.args;
  29880. var fn = operation.fn;
  29881. switch (fn | 0) {
  29882. case OPS.paintXObject:
  29883. if (args[0].code) {
  29884. break;
  29885. }
  29886. var name = args[0].name;
  29887. if (!name) {
  29888. warn('XObject must be referred to by name.');
  29889. continue;
  29890. }
  29891. if (imageCache[name] !== undefined) {
  29892. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  29893. args = null;
  29894. continue;
  29895. }
  29896. var xobj = xobjs.get(name);
  29897. if (xobj) {
  29898. assert(isStream(xobj), 'XObject should be a stream');
  29899. var type = xobj.dict.get('Subtype');
  29900. assert(isName(type), 'XObject should have a Name subtype');
  29901. if (type.name === 'Form') {
  29902. stateManager.save();
  29903. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  29904. stateManager.restore();
  29905. }));
  29906. return;
  29907. } else if (type.name === 'Image') {
  29908. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  29909. args = null;
  29910. continue;
  29911. } else if (type.name === 'PS') {
  29912. info('Ignored XObject subtype PS');
  29913. continue;
  29914. } else {
  29915. error('Unhandled XObject subtype ' + type.name);
  29916. }
  29917. }
  29918. break;
  29919. case OPS.setFont:
  29920. var fontSize = args[1];
  29921. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  29922. operatorList.addDependency(loadedName);
  29923. operatorList.addOp(OPS.setFont, [
  29924. loadedName,
  29925. fontSize
  29926. ]);
  29927. }));
  29928. return;
  29929. case OPS.endInlineImage:
  29930. var cacheKey = args[0].cacheKey;
  29931. if (cacheKey) {
  29932. var cacheEntry = imageCache[cacheKey];
  29933. if (cacheEntry !== undefined) {
  29934. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  29935. args = null;
  29936. continue;
  29937. }
  29938. }
  29939. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  29940. args = null;
  29941. continue;
  29942. case OPS.showText:
  29943. args[0] = self.handleText(args[0], stateManager.state);
  29944. break;
  29945. case OPS.showSpacedText:
  29946. var arr = args[0];
  29947. var combinedGlyphs = [];
  29948. var arrLength = arr.length;
  29949. var state = stateManager.state;
  29950. for (i = 0; i < arrLength; ++i) {
  29951. var arrItem = arr[i];
  29952. if (isString(arrItem)) {
  29953. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  29954. } else if (isNum(arrItem)) {
  29955. combinedGlyphs.push(arrItem);
  29956. }
  29957. }
  29958. args[0] = combinedGlyphs;
  29959. fn = OPS.showText;
  29960. break;
  29961. case OPS.nextLineShowText:
  29962. operatorList.addOp(OPS.nextLine);
  29963. args[0] = self.handleText(args[0], stateManager.state);
  29964. fn = OPS.showText;
  29965. break;
  29966. case OPS.nextLineSetSpacingShowText:
  29967. operatorList.addOp(OPS.nextLine);
  29968. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  29969. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  29970. args[0] = self.handleText(args[0], stateManager.state);
  29971. fn = OPS.showText;
  29972. break;
  29973. case OPS.setTextRenderingMode:
  29974. stateManager.state.textRenderingMode = args[0];
  29975. break;
  29976. case OPS.setFillColorSpace:
  29977. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  29978. continue;
  29979. case OPS.setStrokeColorSpace:
  29980. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  29981. continue;
  29982. case OPS.setFillColor:
  29983. cs = stateManager.state.fillColorSpace;
  29984. args = cs.getRgb(args, 0);
  29985. fn = OPS.setFillRGBColor;
  29986. break;
  29987. case OPS.setStrokeColor:
  29988. cs = stateManager.state.strokeColorSpace;
  29989. args = cs.getRgb(args, 0);
  29990. fn = OPS.setStrokeRGBColor;
  29991. break;
  29992. case OPS.setFillGray:
  29993. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  29994. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29995. fn = OPS.setFillRGBColor;
  29996. break;
  29997. case OPS.setStrokeGray:
  29998. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  29999. args = ColorSpace.singletons.gray.getRgb(args, 0);
  30000. fn = OPS.setStrokeRGBColor;
  30001. break;
  30002. case OPS.setFillCMYKColor:
  30003. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  30004. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  30005. fn = OPS.setFillRGBColor;
  30006. break;
  30007. case OPS.setStrokeCMYKColor:
  30008. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  30009. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  30010. fn = OPS.setStrokeRGBColor;
  30011. break;
  30012. case OPS.setFillRGBColor:
  30013. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  30014. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  30015. break;
  30016. case OPS.setStrokeRGBColor:
  30017. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  30018. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  30019. break;
  30020. case OPS.setFillColorN:
  30021. cs = stateManager.state.fillColorSpace;
  30022. if (cs.name === 'Pattern') {
  30023. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  30024. return;
  30025. }
  30026. args = cs.getRgb(args, 0);
  30027. fn = OPS.setFillRGBColor;
  30028. break;
  30029. case OPS.setStrokeColorN:
  30030. cs = stateManager.state.strokeColorSpace;
  30031. if (cs.name === 'Pattern') {
  30032. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  30033. return;
  30034. }
  30035. args = cs.getRgb(args, 0);
  30036. fn = OPS.setStrokeRGBColor;
  30037. break;
  30038. case OPS.shadingFill:
  30039. var shadingRes = resources.get('Shading');
  30040. if (!shadingRes) {
  30041. error('No shading resource found');
  30042. }
  30043. var shading = shadingRes.get(args[0].name);
  30044. if (!shading) {
  30045. error('No shading object found');
  30046. }
  30047. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  30048. var patternIR = shadingFill.getIR();
  30049. args = [patternIR];
  30050. fn = OPS.shadingFill;
  30051. break;
  30052. case OPS.setGState:
  30053. var dictName = args[0];
  30054. var extGState = resources.get('ExtGState');
  30055. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  30056. break;
  30057. }
  30058. var gState = extGState.get(dictName.name);
  30059. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  30060. return;
  30061. case OPS.moveTo:
  30062. case OPS.lineTo:
  30063. case OPS.curveTo:
  30064. case OPS.curveTo2:
  30065. case OPS.curveTo3:
  30066. case OPS.closePath:
  30067. self.buildPath(operatorList, fn, args);
  30068. continue;
  30069. case OPS.rectangle:
  30070. self.buildPath(operatorList, fn, args);
  30071. continue;
  30072. case OPS.markPoint:
  30073. case OPS.markPointProps:
  30074. case OPS.beginMarkedContent:
  30075. case OPS.beginMarkedContentProps:
  30076. case OPS.endMarkedContent:
  30077. case OPS.beginCompat:
  30078. case OPS.endCompat:
  30079. continue;
  30080. default:
  30081. if (args !== null) {
  30082. for (i = 0, ii = args.length; i < ii; i++) {
  30083. if (args[i] instanceof Dict) {
  30084. break;
  30085. }
  30086. }
  30087. if (i < ii) {
  30088. warn('getOperatorList - ignoring operator: ' + fn);
  30089. continue;
  30090. }
  30091. }
  30092. }
  30093. operatorList.addOp(fn, args);
  30094. }
  30095. if (stop) {
  30096. next(deferred);
  30097. return;
  30098. }
  30099. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  30100. operatorList.addOp(OPS.restore, []);
  30101. }
  30102. resolve();
  30103. });
  30104. },
  30105. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  30106. stateManager = stateManager || new StateManager(new TextState());
  30107. var WhitespaceRegexp = /\s/g;
  30108. var textContent = {
  30109. items: [],
  30110. styles: Object.create(null)
  30111. };
  30112. var textContentItem = {
  30113. initialized: false,
  30114. str: [],
  30115. width: 0,
  30116. height: 0,
  30117. vertical: false,
  30118. lastAdvanceWidth: 0,
  30119. lastAdvanceHeight: 0,
  30120. textAdvanceScale: 0,
  30121. spaceWidth: 0,
  30122. fakeSpaceMin: Infinity,
  30123. fakeMultiSpaceMin: Infinity,
  30124. fakeMultiSpaceMax: -0,
  30125. textRunBreakAllowed: false,
  30126. transform: null,
  30127. fontName: null
  30128. };
  30129. var SPACE_FACTOR = 0.3;
  30130. var MULTI_SPACE_FACTOR = 1.5;
  30131. var MULTI_SPACE_FACTOR_MAX = 4;
  30132. var self = this;
  30133. var xref = this.xref;
  30134. resources = xref.fetchIfRef(resources) || Dict.empty;
  30135. var xobjs = null;
  30136. var xobjsCache = Object.create(null);
  30137. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  30138. var textState;
  30139. function ensureTextContentItem() {
  30140. if (textContentItem.initialized) {
  30141. return textContentItem;
  30142. }
  30143. var font = textState.font;
  30144. if (!(font.loadedName in textContent.styles)) {
  30145. textContent.styles[font.loadedName] = {
  30146. fontFamily: font.fallbackName,
  30147. ascent: font.ascent,
  30148. descent: font.descent,
  30149. vertical: font.vertical
  30150. };
  30151. }
  30152. textContentItem.fontName = font.loadedName;
  30153. var tsm = [
  30154. textState.fontSize * textState.textHScale,
  30155. 0,
  30156. 0,
  30157. textState.fontSize,
  30158. 0,
  30159. textState.textRise
  30160. ];
  30161. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  30162. var glyphHeight = font.bbox[3] - font.bbox[1];
  30163. if (glyphHeight > 0) {
  30164. glyphHeight = glyphHeight * textState.fontMatrix[3];
  30165. tsm[3] *= glyphHeight;
  30166. }
  30167. }
  30168. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  30169. textContentItem.transform = trm;
  30170. if (!font.vertical) {
  30171. textContentItem.width = 0;
  30172. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  30173. textContentItem.vertical = false;
  30174. } else {
  30175. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  30176. textContentItem.height = 0;
  30177. textContentItem.vertical = true;
  30178. }
  30179. var a = textState.textLineMatrix[0];
  30180. var b = textState.textLineMatrix[1];
  30181. var scaleLineX = Math.sqrt(a * a + b * b);
  30182. a = textState.ctm[0];
  30183. b = textState.ctm[1];
  30184. var scaleCtmX = Math.sqrt(a * a + b * b);
  30185. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  30186. textContentItem.lastAdvanceWidth = 0;
  30187. textContentItem.lastAdvanceHeight = 0;
  30188. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  30189. if (spaceWidth) {
  30190. textContentItem.spaceWidth = spaceWidth;
  30191. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  30192. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  30193. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  30194. textContentItem.textRunBreakAllowed = !font.isMonospace;
  30195. } else {
  30196. textContentItem.spaceWidth = 0;
  30197. textContentItem.fakeSpaceMin = Infinity;
  30198. textContentItem.fakeMultiSpaceMin = Infinity;
  30199. textContentItem.fakeMultiSpaceMax = 0;
  30200. textContentItem.textRunBreakAllowed = false;
  30201. }
  30202. textContentItem.initialized = true;
  30203. return textContentItem;
  30204. }
  30205. function replaceWhitespace(str) {
  30206. var i = 0, ii = str.length, code;
  30207. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  30208. i++;
  30209. }
  30210. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  30211. }
  30212. function runBidiTransform(textChunk) {
  30213. var str = textChunk.str.join('');
  30214. var bidiResult = bidi(str, -1, textChunk.vertical);
  30215. return {
  30216. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  30217. dir: bidiResult.dir,
  30218. width: textChunk.width,
  30219. height: textChunk.height,
  30220. transform: textChunk.transform,
  30221. fontName: textChunk.fontName
  30222. };
  30223. }
  30224. function handleSetFont(fontName, fontRef) {
  30225. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  30226. textState.font = translated.font;
  30227. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  30228. });
  30229. }
  30230. function buildTextContentItem(chars) {
  30231. var font = textState.font;
  30232. var textChunk = ensureTextContentItem();
  30233. var width = 0;
  30234. var height = 0;
  30235. var glyphs = font.charsToGlyphs(chars);
  30236. for (var i = 0; i < glyphs.length; i++) {
  30237. var glyph = glyphs[i];
  30238. var glyphWidth = null;
  30239. if (font.vertical && glyph.vmetric) {
  30240. glyphWidth = glyph.vmetric[0];
  30241. } else {
  30242. glyphWidth = glyph.width;
  30243. }
  30244. var glyphUnicode = glyph.unicode;
  30245. var NormalizedUnicodes = getNormalizedUnicodes();
  30246. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  30247. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  30248. }
  30249. glyphUnicode = reverseIfRtl(glyphUnicode);
  30250. var charSpacing = textState.charSpacing;
  30251. if (glyph.isSpace) {
  30252. var wordSpacing = textState.wordSpacing;
  30253. charSpacing += wordSpacing;
  30254. if (wordSpacing > 0) {
  30255. addFakeSpaces(wordSpacing, textChunk.str);
  30256. }
  30257. }
  30258. var tx = 0;
  30259. var ty = 0;
  30260. if (!font.vertical) {
  30261. var w0 = glyphWidth * textState.fontMatrix[0];
  30262. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  30263. width += tx;
  30264. } else {
  30265. var w1 = glyphWidth * textState.fontMatrix[0];
  30266. ty = w1 * textState.fontSize + charSpacing;
  30267. height += ty;
  30268. }
  30269. textState.translateTextMatrix(tx, ty);
  30270. textChunk.str.push(glyphUnicode);
  30271. }
  30272. if (!font.vertical) {
  30273. textChunk.lastAdvanceWidth = width;
  30274. textChunk.width += width;
  30275. } else {
  30276. textChunk.lastAdvanceHeight = height;
  30277. textChunk.height += Math.abs(height);
  30278. }
  30279. return textChunk;
  30280. }
  30281. function addFakeSpaces(width, strBuf) {
  30282. if (width < textContentItem.fakeSpaceMin) {
  30283. return;
  30284. }
  30285. if (width < textContentItem.fakeMultiSpaceMin) {
  30286. strBuf.push(' ');
  30287. return;
  30288. }
  30289. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  30290. while (fakeSpaces-- > 0) {
  30291. strBuf.push(' ');
  30292. }
  30293. }
  30294. function flushTextContentItem() {
  30295. if (!textContentItem.initialized) {
  30296. return;
  30297. }
  30298. textContentItem.width *= textContentItem.textAdvanceScale;
  30299. textContentItem.height *= textContentItem.textAdvanceScale;
  30300. textContent.items.push(runBidiTransform(textContentItem));
  30301. textContentItem.initialized = false;
  30302. textContentItem.str.length = 0;
  30303. }
  30304. var timeSlotManager = new TimeSlotManager();
  30305. return new Promise(function promiseBody(resolve, reject) {
  30306. var next = function (promise) {
  30307. promise.then(function () {
  30308. try {
  30309. promiseBody(resolve, reject);
  30310. } catch (ex) {
  30311. reject(ex);
  30312. }
  30313. }, reject);
  30314. };
  30315. task.ensureNotTerminated();
  30316. timeSlotManager.reset();
  30317. var stop, operation = {}, args = [];
  30318. while (!(stop = timeSlotManager.check())) {
  30319. args.length = 0;
  30320. operation.args = args;
  30321. if (!preprocessor.read(operation)) {
  30322. break;
  30323. }
  30324. textState = stateManager.state;
  30325. var fn = operation.fn;
  30326. args = operation.args;
  30327. var advance, diff;
  30328. switch (fn | 0) {
  30329. case OPS.setFont:
  30330. var fontNameArg = args[0].name, fontSizeArg = args[1];
  30331. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  30332. break;
  30333. }
  30334. flushTextContentItem();
  30335. textState.fontName = fontNameArg;
  30336. textState.fontSize = fontSizeArg;
  30337. next(handleSetFont(fontNameArg, null));
  30338. return;
  30339. case OPS.setTextRise:
  30340. flushTextContentItem();
  30341. textState.textRise = args[0];
  30342. break;
  30343. case OPS.setHScale:
  30344. flushTextContentItem();
  30345. textState.textHScale = args[0] / 100;
  30346. break;
  30347. case OPS.setLeading:
  30348. flushTextContentItem();
  30349. textState.leading = args[0];
  30350. break;
  30351. case OPS.moveText:
  30352. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  30353. advance = args[0] - args[1];
  30354. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  30355. textState.translateTextLineMatrix(args[0], args[1]);
  30356. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  30357. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  30358. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  30359. addFakeSpaces(diff, textContentItem.str);
  30360. break;
  30361. }
  30362. flushTextContentItem();
  30363. textState.translateTextLineMatrix(args[0], args[1]);
  30364. textState.textMatrix = textState.textLineMatrix.slice();
  30365. break;
  30366. case OPS.setLeadingMoveText:
  30367. flushTextContentItem();
  30368. textState.leading = -args[1];
  30369. textState.translateTextLineMatrix(args[0], args[1]);
  30370. textState.textMatrix = textState.textLineMatrix.slice();
  30371. break;
  30372. case OPS.nextLine:
  30373. flushTextContentItem();
  30374. textState.carriageReturn();
  30375. break;
  30376. case OPS.setTextMatrix:
  30377. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  30378. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  30379. textState.translateTextLineMatrix(advance.width, advance.height);
  30380. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  30381. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  30382. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  30383. addFakeSpaces(diff, textContentItem.str);
  30384. break;
  30385. }
  30386. flushTextContentItem();
  30387. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  30388. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  30389. break;
  30390. case OPS.setCharSpacing:
  30391. textState.charSpacing = args[0];
  30392. break;
  30393. case OPS.setWordSpacing:
  30394. textState.wordSpacing = args[0];
  30395. break;
  30396. case OPS.beginText:
  30397. flushTextContentItem();
  30398. textState.textMatrix = IDENTITY_MATRIX.slice();
  30399. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  30400. break;
  30401. case OPS.showSpacedText:
  30402. var items = args[0];
  30403. var offset;
  30404. for (var j = 0, jj = items.length; j < jj; j++) {
  30405. if (typeof items[j] === 'string') {
  30406. buildTextContentItem(items[j]);
  30407. } else if (isNum(items[j])) {
  30408. ensureTextContentItem();
  30409. advance = items[j] * textState.fontSize / 1000;
  30410. var breakTextRun = false;
  30411. if (textState.font.vertical) {
  30412. offset = advance;
  30413. textState.translateTextMatrix(0, offset);
  30414. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  30415. if (!breakTextRun) {
  30416. textContentItem.height += offset;
  30417. }
  30418. } else {
  30419. advance = -advance;
  30420. offset = advance * textState.textHScale;
  30421. textState.translateTextMatrix(offset, 0);
  30422. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  30423. if (!breakTextRun) {
  30424. textContentItem.width += offset;
  30425. }
  30426. }
  30427. if (breakTextRun) {
  30428. flushTextContentItem();
  30429. } else if (advance > 0) {
  30430. addFakeSpaces(advance, textContentItem.str);
  30431. }
  30432. }
  30433. }
  30434. break;
  30435. case OPS.showText:
  30436. buildTextContentItem(args[0]);
  30437. break;
  30438. case OPS.nextLineShowText:
  30439. flushTextContentItem();
  30440. textState.carriageReturn();
  30441. buildTextContentItem(args[0]);
  30442. break;
  30443. case OPS.nextLineSetSpacingShowText:
  30444. flushTextContentItem();
  30445. textState.wordSpacing = args[0];
  30446. textState.charSpacing = args[1];
  30447. textState.carriageReturn();
  30448. buildTextContentItem(args[2]);
  30449. break;
  30450. case OPS.paintXObject:
  30451. flushTextContentItem();
  30452. if (args[0].code) {
  30453. break;
  30454. }
  30455. if (!xobjs) {
  30456. xobjs = resources.get('XObject') || Dict.empty;
  30457. }
  30458. var name = args[0].name;
  30459. if (xobjsCache.key === name) {
  30460. if (xobjsCache.texts) {
  30461. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  30462. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  30463. }
  30464. break;
  30465. }
  30466. var xobj = xobjs.get(name);
  30467. if (!xobj) {
  30468. break;
  30469. }
  30470. assert(isStream(xobj), 'XObject should be a stream');
  30471. var type = xobj.dict.get('Subtype');
  30472. assert(isName(type), 'XObject should have a Name subtype');
  30473. if ('Form' !== type.name) {
  30474. xobjsCache.key = name;
  30475. xobjsCache.texts = null;
  30476. break;
  30477. }
  30478. stateManager.save();
  30479. var matrix = xobj.dict.getArray('Matrix');
  30480. if (isArray(matrix) && matrix.length === 6) {
  30481. stateManager.transform(matrix);
  30482. }
  30483. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  30484. Util.appendToArray(textContent.items, formTextContent.items);
  30485. Util.extendObj(textContent.styles, formTextContent.styles);
  30486. stateManager.restore();
  30487. xobjsCache.key = name;
  30488. xobjsCache.texts = formTextContent;
  30489. }));
  30490. return;
  30491. case OPS.setGState:
  30492. flushTextContentItem();
  30493. var dictName = args[0];
  30494. var extGState = resources.get('ExtGState');
  30495. if (!isDict(extGState) || !isName(dictName)) {
  30496. break;
  30497. }
  30498. var gState = extGState.get(dictName.name);
  30499. if (!isDict(gState)) {
  30500. break;
  30501. }
  30502. var gStateFont = gState.get('Font');
  30503. if (gStateFont) {
  30504. textState.fontName = null;
  30505. textState.fontSize = gStateFont[1];
  30506. next(handleSetFont(null, gStateFont[0]));
  30507. return;
  30508. }
  30509. break;
  30510. }
  30511. }
  30512. if (stop) {
  30513. next(deferred);
  30514. return;
  30515. }
  30516. flushTextContentItem();
  30517. resolve(textContent);
  30518. });
  30519. },
  30520. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  30521. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30522. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  30523. if (properties.composite) {
  30524. var cidSystemInfo = dict.get('CIDSystemInfo');
  30525. if (isDict(cidSystemInfo)) {
  30526. properties.cidSystemInfo = {
  30527. registry: cidSystemInfo.get('Registry'),
  30528. ordering: cidSystemInfo.get('Ordering'),
  30529. supplement: cidSystemInfo.get('Supplement')
  30530. };
  30531. }
  30532. var cidToGidMap = dict.get('CIDToGIDMap');
  30533. if (isStream(cidToGidMap)) {
  30534. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  30535. }
  30536. }
  30537. var differences = [];
  30538. var baseEncodingName = null;
  30539. var encoding;
  30540. if (dict.has('Encoding')) {
  30541. encoding = dict.get('Encoding');
  30542. if (isDict(encoding)) {
  30543. baseEncodingName = encoding.get('BaseEncoding');
  30544. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  30545. if (encoding.has('Differences')) {
  30546. var diffEncoding = encoding.get('Differences');
  30547. var index = 0;
  30548. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  30549. var data = xref.fetchIfRef(diffEncoding[j]);
  30550. if (isNum(data)) {
  30551. index = data;
  30552. } else if (isName(data)) {
  30553. differences[index++] = data.name;
  30554. } else {
  30555. error('Invalid entry in \'Differences\' array: ' + data);
  30556. }
  30557. }
  30558. }
  30559. } else if (isName(encoding)) {
  30560. baseEncodingName = encoding.name;
  30561. } else {
  30562. error('Encoding is not a Name nor a Dict');
  30563. }
  30564. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  30565. baseEncodingName = null;
  30566. }
  30567. }
  30568. if (baseEncodingName) {
  30569. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  30570. } else {
  30571. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  30572. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  30573. encoding = StandardEncoding;
  30574. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  30575. encoding = WinAnsiEncoding;
  30576. }
  30577. if (isSymbolicFont) {
  30578. encoding = MacRomanEncoding;
  30579. if (!properties.file) {
  30580. if (/Symbol/i.test(properties.name)) {
  30581. encoding = SymbolSetEncoding;
  30582. } else if (/Dingbats/i.test(properties.name)) {
  30583. encoding = ZapfDingbatsEncoding;
  30584. }
  30585. }
  30586. }
  30587. properties.defaultEncoding = encoding;
  30588. }
  30589. properties.differences = differences;
  30590. properties.baseEncodingName = baseEncodingName;
  30591. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  30592. properties.dict = dict;
  30593. return toUnicodePromise.then(function (toUnicode) {
  30594. properties.toUnicode = toUnicode;
  30595. return this.buildToUnicode(properties);
  30596. }.bind(this)).then(function (toUnicode) {
  30597. properties.toUnicode = toUnicode;
  30598. return properties;
  30599. });
  30600. },
  30601. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  30602. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  30603. if (properties.hasIncludedToUnicodeMap) {
  30604. return Promise.resolve(properties.toUnicode);
  30605. }
  30606. var toUnicode, charcode, glyphName;
  30607. if (!properties.composite) {
  30608. toUnicode = [];
  30609. var encoding = properties.defaultEncoding.slice();
  30610. var baseEncodingName = properties.baseEncodingName;
  30611. var differences = properties.differences;
  30612. for (charcode in differences) {
  30613. glyphName = differences[charcode];
  30614. if (glyphName === '.notdef') {
  30615. continue;
  30616. }
  30617. encoding[charcode] = glyphName;
  30618. }
  30619. var glyphsUnicodeMap = getGlyphsUnicode();
  30620. for (charcode in encoding) {
  30621. glyphName = encoding[charcode];
  30622. if (glyphName === '') {
  30623. continue;
  30624. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  30625. var code = 0;
  30626. switch (glyphName[0]) {
  30627. case 'G':
  30628. if (glyphName.length === 3) {
  30629. code = parseInt(glyphName.substr(1), 16);
  30630. }
  30631. break;
  30632. case 'g':
  30633. if (glyphName.length === 5) {
  30634. code = parseInt(glyphName.substr(1), 16);
  30635. }
  30636. break;
  30637. case 'C':
  30638. case 'c':
  30639. if (glyphName.length >= 3) {
  30640. code = +glyphName.substr(1);
  30641. }
  30642. break;
  30643. default:
  30644. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  30645. if (unicode !== -1) {
  30646. code = unicode;
  30647. }
  30648. }
  30649. if (code) {
  30650. if (baseEncodingName && code === +charcode) {
  30651. var baseEncoding = getEncoding(baseEncodingName);
  30652. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  30653. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  30654. continue;
  30655. }
  30656. }
  30657. toUnicode[charcode] = String.fromCharCode(code);
  30658. }
  30659. continue;
  30660. }
  30661. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  30662. }
  30663. return Promise.resolve(new ToUnicodeMap(toUnicode));
  30664. }
  30665. 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'))) {
  30666. var registry = properties.cidSystemInfo.registry;
  30667. var ordering = properties.cidSystemInfo.ordering;
  30668. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  30669. return CMapFactory.create({
  30670. encoding: ucs2CMapName,
  30671. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30672. useCMap: null
  30673. }).then(function (ucs2CMap) {
  30674. var cMap = properties.cMap;
  30675. toUnicode = [];
  30676. cMap.forEach(function (charcode, cid) {
  30677. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  30678. var ucs2 = ucs2CMap.lookup(cid);
  30679. if (ucs2) {
  30680. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  30681. }
  30682. });
  30683. return new ToUnicodeMap(toUnicode);
  30684. });
  30685. }
  30686. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  30687. },
  30688. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  30689. var cmapObj = toUnicode;
  30690. if (isName(cmapObj)) {
  30691. return CMapFactory.create({
  30692. encoding: cmapObj,
  30693. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30694. useCMap: null
  30695. }).then(function (cmap) {
  30696. if (cmap instanceof IdentityCMap) {
  30697. return new IdentityToUnicodeMap(0, 0xFFFF);
  30698. }
  30699. return new ToUnicodeMap(cmap.getMap());
  30700. });
  30701. } else if (isStream(cmapObj)) {
  30702. return CMapFactory.create({
  30703. encoding: cmapObj,
  30704. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30705. useCMap: null
  30706. }).then(function (cmap) {
  30707. if (cmap instanceof IdentityCMap) {
  30708. return new IdentityToUnicodeMap(0, 0xFFFF);
  30709. }
  30710. var map = new Array(cmap.length);
  30711. cmap.forEach(function (charCode, token) {
  30712. var str = [];
  30713. for (var k = 0; k < token.length; k += 2) {
  30714. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  30715. if ((w1 & 0xF800) !== 0xD800) {
  30716. str.push(w1);
  30717. continue;
  30718. }
  30719. k += 2;
  30720. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  30721. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  30722. }
  30723. map[charCode] = String.fromCharCode.apply(String, str);
  30724. });
  30725. return new ToUnicodeMap(map);
  30726. });
  30727. }
  30728. return Promise.resolve(null);
  30729. },
  30730. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  30731. var glyphsData = cidToGidStream.getBytes();
  30732. var result = [];
  30733. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  30734. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  30735. if (glyphID === 0) {
  30736. continue;
  30737. }
  30738. var code = j >> 1;
  30739. result[code] = glyphID;
  30740. }
  30741. return result;
  30742. },
  30743. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  30744. var glyphsWidths = [];
  30745. var defaultWidth = 0;
  30746. var glyphsVMetrics = [];
  30747. var defaultVMetrics;
  30748. var i, ii, j, jj, start, code, widths;
  30749. if (properties.composite) {
  30750. defaultWidth = dict.get('DW') || 1000;
  30751. widths = dict.get('W');
  30752. if (widths) {
  30753. for (i = 0, ii = widths.length; i < ii; i++) {
  30754. start = xref.fetchIfRef(widths[i++]);
  30755. code = xref.fetchIfRef(widths[i]);
  30756. if (isArray(code)) {
  30757. for (j = 0, jj = code.length; j < jj; j++) {
  30758. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  30759. }
  30760. } else {
  30761. var width = xref.fetchIfRef(widths[++i]);
  30762. for (j = start; j <= code; j++) {
  30763. glyphsWidths[j] = width;
  30764. }
  30765. }
  30766. }
  30767. }
  30768. if (properties.vertical) {
  30769. var vmetrics = dict.getArray('DW2') || [
  30770. 880,
  30771. -1000
  30772. ];
  30773. defaultVMetrics = [
  30774. vmetrics[1],
  30775. defaultWidth * 0.5,
  30776. vmetrics[0]
  30777. ];
  30778. vmetrics = dict.get('W2');
  30779. if (vmetrics) {
  30780. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  30781. start = xref.fetchIfRef(vmetrics[i++]);
  30782. code = xref.fetchIfRef(vmetrics[i]);
  30783. if (isArray(code)) {
  30784. for (j = 0, jj = code.length; j < jj; j++) {
  30785. glyphsVMetrics[start++] = [
  30786. xref.fetchIfRef(code[j++]),
  30787. xref.fetchIfRef(code[j++]),
  30788. xref.fetchIfRef(code[j])
  30789. ];
  30790. }
  30791. } else {
  30792. var vmetric = [
  30793. xref.fetchIfRef(vmetrics[++i]),
  30794. xref.fetchIfRef(vmetrics[++i]),
  30795. xref.fetchIfRef(vmetrics[++i])
  30796. ];
  30797. for (j = start; j <= code; j++) {
  30798. glyphsVMetrics[j] = vmetric;
  30799. }
  30800. }
  30801. }
  30802. }
  30803. }
  30804. } else {
  30805. var firstChar = properties.firstChar;
  30806. widths = dict.get('Widths');
  30807. if (widths) {
  30808. j = firstChar;
  30809. for (i = 0, ii = widths.length; i < ii; i++) {
  30810. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  30811. }
  30812. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  30813. } else {
  30814. var baseFontName = dict.get('BaseFont');
  30815. if (isName(baseFontName)) {
  30816. var metrics = this.getBaseFontMetrics(baseFontName.name);
  30817. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  30818. defaultWidth = metrics.defaultWidth;
  30819. }
  30820. }
  30821. }
  30822. var isMonospace = true;
  30823. var firstWidth = defaultWidth;
  30824. for (var glyph in glyphsWidths) {
  30825. var glyphWidth = glyphsWidths[glyph];
  30826. if (!glyphWidth) {
  30827. continue;
  30828. }
  30829. if (!firstWidth) {
  30830. firstWidth = glyphWidth;
  30831. continue;
  30832. }
  30833. if (firstWidth !== glyphWidth) {
  30834. isMonospace = false;
  30835. break;
  30836. }
  30837. }
  30838. if (isMonospace) {
  30839. properties.flags |= FontFlags.FixedPitch;
  30840. }
  30841. properties.defaultWidth = defaultWidth;
  30842. properties.widths = glyphsWidths;
  30843. properties.defaultVMetrics = defaultVMetrics;
  30844. properties.vmetrics = glyphsVMetrics;
  30845. },
  30846. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  30847. var fontNameWoStyle = baseFontName.split('-')[0];
  30848. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  30849. },
  30850. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  30851. var defaultWidth = 0;
  30852. var widths = [];
  30853. var monospace = false;
  30854. var stdFontMap = getStdFontMap();
  30855. var lookupName = stdFontMap[name] || name;
  30856. var Metrics = getMetrics();
  30857. if (!(lookupName in Metrics)) {
  30858. if (this.isSerifFont(name)) {
  30859. lookupName = 'Times-Roman';
  30860. } else {
  30861. lookupName = 'Helvetica';
  30862. }
  30863. }
  30864. var glyphWidths = Metrics[lookupName];
  30865. if (isNum(glyphWidths)) {
  30866. defaultWidth = glyphWidths;
  30867. monospace = true;
  30868. } else {
  30869. widths = glyphWidths();
  30870. }
  30871. return {
  30872. defaultWidth: defaultWidth,
  30873. monospace: monospace,
  30874. widths: widths
  30875. };
  30876. },
  30877. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  30878. var widths = Object.create(null);
  30879. var differences = properties.differences;
  30880. var encoding = properties.defaultEncoding;
  30881. for (var charCode = 0; charCode < 256; charCode++) {
  30882. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  30883. widths[charCode] = widthsByGlyphName[differences[charCode]];
  30884. continue;
  30885. }
  30886. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  30887. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  30888. continue;
  30889. }
  30890. }
  30891. return widths;
  30892. },
  30893. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  30894. var baseDict = dict;
  30895. var type = dict.get('Subtype');
  30896. assert(isName(type), 'invalid font Subtype');
  30897. var composite = false;
  30898. var uint8array;
  30899. if (type.name === 'Type0') {
  30900. var df = dict.get('DescendantFonts');
  30901. if (!df) {
  30902. error('Descendant fonts are not specified');
  30903. }
  30904. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  30905. type = dict.get('Subtype');
  30906. assert(isName(type), 'invalid font Subtype');
  30907. composite = true;
  30908. }
  30909. var descriptor = dict.get('FontDescriptor');
  30910. if (descriptor) {
  30911. var hash = new MurmurHash3_64();
  30912. var encoding = baseDict.getRaw('Encoding');
  30913. if (isName(encoding)) {
  30914. hash.update(encoding.name);
  30915. } else if (isRef(encoding)) {
  30916. hash.update(encoding.toString());
  30917. } else if (isDict(encoding)) {
  30918. var keys = encoding.getKeys();
  30919. for (var i = 0, ii = keys.length; i < ii; i++) {
  30920. var entry = encoding.getRaw(keys[i]);
  30921. if (isName(entry)) {
  30922. hash.update(entry.name);
  30923. } else if (isRef(entry)) {
  30924. hash.update(entry.toString());
  30925. } else if (isArray(entry)) {
  30926. var diffLength = entry.length, diffBuf = new Array(diffLength);
  30927. for (var j = 0; j < diffLength; j++) {
  30928. var diffEntry = entry[j];
  30929. if (isName(diffEntry)) {
  30930. diffBuf[j] = diffEntry.name;
  30931. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  30932. diffBuf[j] = diffEntry.toString();
  30933. }
  30934. }
  30935. hash.update(diffBuf.join());
  30936. }
  30937. }
  30938. }
  30939. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30940. if (isStream(toUnicode)) {
  30941. var stream = toUnicode.str || toUnicode;
  30942. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  30943. hash.update(uint8array);
  30944. } else if (isName(toUnicode)) {
  30945. hash.update(toUnicode.name);
  30946. }
  30947. var widths = dict.get('Widths') || baseDict.get('Widths');
  30948. if (widths) {
  30949. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  30950. hash.update(uint8array);
  30951. }
  30952. }
  30953. return {
  30954. descriptor: descriptor,
  30955. dict: dict,
  30956. baseDict: baseDict,
  30957. composite: composite,
  30958. type: type.name,
  30959. hash: hash ? hash.hexdigest() : ''
  30960. };
  30961. },
  30962. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  30963. var baseDict = preEvaluatedFont.baseDict;
  30964. var dict = preEvaluatedFont.dict;
  30965. var composite = preEvaluatedFont.composite;
  30966. var descriptor = preEvaluatedFont.descriptor;
  30967. var type = preEvaluatedFont.type;
  30968. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  30969. var properties;
  30970. if (!descriptor) {
  30971. if (type === 'Type3') {
  30972. descriptor = new Dict(null);
  30973. descriptor.set('FontName', Name.get(type));
  30974. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  30975. } else {
  30976. var baseFontName = dict.get('BaseFont');
  30977. if (!isName(baseFontName)) {
  30978. error('Base font is not specified');
  30979. }
  30980. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  30981. var metrics = this.getBaseFontMetrics(baseFontName);
  30982. var fontNameWoStyle = baseFontName.split('-')[0];
  30983. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  30984. properties = {
  30985. type: type,
  30986. name: baseFontName,
  30987. widths: metrics.widths,
  30988. defaultWidth: metrics.defaultWidth,
  30989. flags: flags,
  30990. firstChar: 0,
  30991. lastChar: maxCharIndex
  30992. };
  30993. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  30994. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  30995. return new Font(baseFontName, null, properties);
  30996. }.bind(this));
  30997. }
  30998. }
  30999. var firstChar = dict.get('FirstChar') || 0;
  31000. var lastChar = dict.get('LastChar') || maxCharIndex;
  31001. var fontName = descriptor.get('FontName');
  31002. var baseFont = dict.get('BaseFont');
  31003. if (isString(fontName)) {
  31004. fontName = Name.get(fontName);
  31005. }
  31006. if (isString(baseFont)) {
  31007. baseFont = Name.get(baseFont);
  31008. }
  31009. if (type !== 'Type3') {
  31010. var fontNameStr = fontName && fontName.name;
  31011. var baseFontStr = baseFont && baseFont.name;
  31012. if (fontNameStr !== baseFontStr) {
  31013. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  31014. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  31015. fontName = baseFont;
  31016. }
  31017. }
  31018. }
  31019. fontName = fontName || baseFont;
  31020. assert(isName(fontName), 'invalid font name');
  31021. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  31022. if (fontFile) {
  31023. if (fontFile.dict) {
  31024. var subtype = fontFile.dict.get('Subtype');
  31025. if (subtype) {
  31026. subtype = subtype.name;
  31027. }
  31028. var length1 = fontFile.dict.get('Length1');
  31029. var length2 = fontFile.dict.get('Length2');
  31030. var length3 = fontFile.dict.get('Length3');
  31031. }
  31032. }
  31033. properties = {
  31034. type: type,
  31035. name: fontName.name,
  31036. subtype: subtype,
  31037. file: fontFile,
  31038. length1: length1,
  31039. length2: length2,
  31040. length3: length3,
  31041. loadedName: baseDict.loadedName,
  31042. composite: composite,
  31043. wideChars: composite,
  31044. fixedPitch: false,
  31045. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  31046. firstChar: firstChar || 0,
  31047. lastChar: lastChar || maxCharIndex,
  31048. bbox: descriptor.getArray('FontBBox'),
  31049. ascent: descriptor.get('Ascent'),
  31050. descent: descriptor.get('Descent'),
  31051. xHeight: descriptor.get('XHeight'),
  31052. capHeight: descriptor.get('CapHeight'),
  31053. flags: descriptor.get('Flags'),
  31054. italicAngle: descriptor.get('ItalicAngle'),
  31055. coded: false
  31056. };
  31057. var cMapPromise;
  31058. if (composite) {
  31059. var cidEncoding = baseDict.get('Encoding');
  31060. if (isName(cidEncoding)) {
  31061. properties.cidEncoding = cidEncoding.name;
  31062. }
  31063. cMapPromise = CMapFactory.create({
  31064. encoding: cidEncoding,
  31065. fetchBuiltInCMap: this.fetchBuiltInCMap,
  31066. useCMap: null
  31067. }).then(function (cMap) {
  31068. properties.cMap = cMap;
  31069. properties.vertical = properties.cMap.vertical;
  31070. });
  31071. } else {
  31072. cMapPromise = Promise.resolve(undefined);
  31073. }
  31074. return cMapPromise.then(function () {
  31075. return this.extractDataStructures(dict, baseDict, xref, properties);
  31076. }.bind(this)).then(function (properties) {
  31077. this.extractWidths(dict, xref, descriptor, properties);
  31078. if (type === 'Type3') {
  31079. properties.isType3Font = true;
  31080. }
  31081. return new Font(fontName.name, fontFile, properties);
  31082. }.bind(this));
  31083. }
  31084. };
  31085. return PartialEvaluator;
  31086. }();
  31087. var TranslatedFont = function TranslatedFontClosure() {
  31088. function TranslatedFont(loadedName, font, dict) {
  31089. this.loadedName = loadedName;
  31090. this.font = font;
  31091. this.dict = dict;
  31092. this.type3Loaded = null;
  31093. this.sent = false;
  31094. }
  31095. TranslatedFont.prototype = {
  31096. send: function (handler) {
  31097. if (this.sent) {
  31098. return;
  31099. }
  31100. var fontData = this.font.exportData();
  31101. handler.send('commonobj', [
  31102. this.loadedName,
  31103. 'Font',
  31104. fontData
  31105. ]);
  31106. this.sent = true;
  31107. },
  31108. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  31109. assert(this.font.isType3Font);
  31110. if (this.type3Loaded) {
  31111. return this.type3Loaded;
  31112. }
  31113. var translatedFont = this.font;
  31114. var loadCharProcsPromise = Promise.resolve();
  31115. var charProcs = this.dict.get('CharProcs');
  31116. var fontResources = this.dict.get('Resources') || resources;
  31117. var charProcKeys = charProcs.getKeys();
  31118. var charProcOperatorList = Object.create(null);
  31119. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  31120. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  31121. var glyphStream = charProcs.get(key);
  31122. var operatorList = new OperatorList();
  31123. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  31124. charProcOperatorList[key] = operatorList.getIR();
  31125. parentOperatorList.addDependencies(operatorList.dependencies);
  31126. }, function (reason) {
  31127. warn('Type3 font resource \"' + key + '\" is not available');
  31128. var operatorList = new OperatorList();
  31129. charProcOperatorList[key] = operatorList.getIR();
  31130. });
  31131. }.bind(this, charProcKeys[i]));
  31132. }
  31133. this.type3Loaded = loadCharProcsPromise.then(function () {
  31134. translatedFont.charProcOperatorList = charProcOperatorList;
  31135. });
  31136. return this.type3Loaded;
  31137. }
  31138. };
  31139. return TranslatedFont;
  31140. }();
  31141. var OperatorList = function OperatorListClosure() {
  31142. var CHUNK_SIZE = 1000;
  31143. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  31144. function getTransfers(queue) {
  31145. var transfers = [];
  31146. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  31147. for (var i = 0, ii = queue.length; i < ii; i++) {
  31148. switch (fnArray[i]) {
  31149. case OPS.paintInlineImageXObject:
  31150. case OPS.paintInlineImageXObjectGroup:
  31151. case OPS.paintImageMaskXObject:
  31152. var arg = argsArray[i][0];
  31153. if (!arg.cached) {
  31154. transfers.push(arg.data.buffer);
  31155. }
  31156. break;
  31157. }
  31158. }
  31159. return transfers;
  31160. }
  31161. function OperatorList(intent, messageHandler, pageIndex) {
  31162. this.messageHandler = messageHandler;
  31163. this.fnArray = [];
  31164. this.argsArray = [];
  31165. this.dependencies = Object.create(null);
  31166. this._totalLength = 0;
  31167. this.pageIndex = pageIndex;
  31168. this.intent = intent;
  31169. }
  31170. OperatorList.prototype = {
  31171. get length() {
  31172. return this.argsArray.length;
  31173. },
  31174. get totalLength() {
  31175. return this._totalLength + this.length;
  31176. },
  31177. addOp: function (fn, args) {
  31178. this.fnArray.push(fn);
  31179. this.argsArray.push(args);
  31180. if (this.messageHandler) {
  31181. if (this.fnArray.length >= CHUNK_SIZE) {
  31182. this.flush();
  31183. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  31184. this.flush();
  31185. }
  31186. }
  31187. },
  31188. addDependency: function (dependency) {
  31189. if (dependency in this.dependencies) {
  31190. return;
  31191. }
  31192. this.dependencies[dependency] = true;
  31193. this.addOp(OPS.dependency, [dependency]);
  31194. },
  31195. addDependencies: function (dependencies) {
  31196. for (var key in dependencies) {
  31197. this.addDependency(key);
  31198. }
  31199. },
  31200. addOpList: function (opList) {
  31201. Util.extendObj(this.dependencies, opList.dependencies);
  31202. for (var i = 0, ii = opList.length; i < ii; i++) {
  31203. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  31204. }
  31205. },
  31206. getIR: function () {
  31207. return {
  31208. fnArray: this.fnArray,
  31209. argsArray: this.argsArray,
  31210. length: this.length
  31211. };
  31212. },
  31213. flush: function (lastChunk) {
  31214. if (this.intent !== 'oplist') {
  31215. new QueueOptimizer().optimize(this);
  31216. }
  31217. var transfers = getTransfers(this);
  31218. var length = this.length;
  31219. this._totalLength += length;
  31220. this.messageHandler.send('RenderPageChunk', {
  31221. operatorList: {
  31222. fnArray: this.fnArray,
  31223. argsArray: this.argsArray,
  31224. lastChunk: lastChunk,
  31225. length: length
  31226. },
  31227. pageIndex: this.pageIndex,
  31228. intent: this.intent
  31229. }, transfers);
  31230. this.dependencies = Object.create(null);
  31231. this.fnArray.length = 0;
  31232. this.argsArray.length = 0;
  31233. }
  31234. };
  31235. return OperatorList;
  31236. }();
  31237. var StateManager = function StateManagerClosure() {
  31238. function StateManager(initialState) {
  31239. this.state = initialState;
  31240. this.stateStack = [];
  31241. }
  31242. StateManager.prototype = {
  31243. save: function () {
  31244. var old = this.state;
  31245. this.stateStack.push(this.state);
  31246. this.state = old.clone();
  31247. },
  31248. restore: function () {
  31249. var prev = this.stateStack.pop();
  31250. if (prev) {
  31251. this.state = prev;
  31252. }
  31253. },
  31254. transform: function (args) {
  31255. this.state.ctm = Util.transform(this.state.ctm, args);
  31256. }
  31257. };
  31258. return StateManager;
  31259. }();
  31260. var TextState = function TextStateClosure() {
  31261. function TextState() {
  31262. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31263. this.fontName = null;
  31264. this.fontSize = 0;
  31265. this.font = null;
  31266. this.fontMatrix = FONT_IDENTITY_MATRIX;
  31267. this.textMatrix = IDENTITY_MATRIX.slice();
  31268. this.textLineMatrix = IDENTITY_MATRIX.slice();
  31269. this.charSpacing = 0;
  31270. this.wordSpacing = 0;
  31271. this.leading = 0;
  31272. this.textHScale = 1;
  31273. this.textRise = 0;
  31274. }
  31275. TextState.prototype = {
  31276. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31277. var m = this.textMatrix;
  31278. m[0] = a;
  31279. m[1] = b;
  31280. m[2] = c;
  31281. m[3] = d;
  31282. m[4] = e;
  31283. m[5] = f;
  31284. },
  31285. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31286. var m = this.textLineMatrix;
  31287. m[0] = a;
  31288. m[1] = b;
  31289. m[2] = c;
  31290. m[3] = d;
  31291. m[4] = e;
  31292. m[5] = f;
  31293. },
  31294. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  31295. var m = this.textMatrix;
  31296. m[4] = m[0] * x + m[2] * y + m[4];
  31297. m[5] = m[1] * x + m[3] * y + m[5];
  31298. },
  31299. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  31300. var m = this.textLineMatrix;
  31301. m[4] = m[0] * x + m[2] * y + m[4];
  31302. m[5] = m[1] * x + m[3] * y + m[5];
  31303. },
  31304. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  31305. var font = this.font;
  31306. if (!font) {
  31307. return null;
  31308. }
  31309. var m = this.textLineMatrix;
  31310. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  31311. return null;
  31312. }
  31313. var txDiff = e - m[4], tyDiff = f - m[5];
  31314. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  31315. return null;
  31316. }
  31317. var tx, ty, denominator = a * d - b * c;
  31318. if (font.vertical) {
  31319. tx = -tyDiff * c / denominator;
  31320. ty = tyDiff * a / denominator;
  31321. } else {
  31322. tx = txDiff * d / denominator;
  31323. ty = -txDiff * b / denominator;
  31324. }
  31325. return {
  31326. width: tx,
  31327. height: ty,
  31328. value: font.vertical ? ty : tx
  31329. };
  31330. },
  31331. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  31332. var tsm = [
  31333. this.fontSize * this.textHScale,
  31334. 0,
  31335. 0,
  31336. this.fontSize,
  31337. 0,
  31338. this.textRise
  31339. ];
  31340. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  31341. },
  31342. carriageReturn: function TextState_carriageReturn() {
  31343. this.translateTextLineMatrix(0, -this.leading);
  31344. this.textMatrix = this.textLineMatrix.slice();
  31345. },
  31346. clone: function TextState_clone() {
  31347. var clone = Object.create(this);
  31348. clone.textMatrix = this.textMatrix.slice();
  31349. clone.textLineMatrix = this.textLineMatrix.slice();
  31350. clone.fontMatrix = this.fontMatrix.slice();
  31351. return clone;
  31352. }
  31353. };
  31354. return TextState;
  31355. }();
  31356. var EvalState = function EvalStateClosure() {
  31357. function EvalState() {
  31358. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31359. this.font = null;
  31360. this.textRenderingMode = TextRenderingMode.FILL;
  31361. this.fillColorSpace = ColorSpace.singletons.gray;
  31362. this.strokeColorSpace = ColorSpace.singletons.gray;
  31363. }
  31364. EvalState.prototype = {
  31365. clone: function CanvasExtraState_clone() {
  31366. return Object.create(this);
  31367. }
  31368. };
  31369. return EvalState;
  31370. }();
  31371. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  31372. var getOPMap = getLookupTableFactory(function (t) {
  31373. t['w'] = {
  31374. id: OPS.setLineWidth,
  31375. numArgs: 1,
  31376. variableArgs: false
  31377. };
  31378. t['J'] = {
  31379. id: OPS.setLineCap,
  31380. numArgs: 1,
  31381. variableArgs: false
  31382. };
  31383. t['j'] = {
  31384. id: OPS.setLineJoin,
  31385. numArgs: 1,
  31386. variableArgs: false
  31387. };
  31388. t['M'] = {
  31389. id: OPS.setMiterLimit,
  31390. numArgs: 1,
  31391. variableArgs: false
  31392. };
  31393. t['d'] = {
  31394. id: OPS.setDash,
  31395. numArgs: 2,
  31396. variableArgs: false
  31397. };
  31398. t['ri'] = {
  31399. id: OPS.setRenderingIntent,
  31400. numArgs: 1,
  31401. variableArgs: false
  31402. };
  31403. t['i'] = {
  31404. id: OPS.setFlatness,
  31405. numArgs: 1,
  31406. variableArgs: false
  31407. };
  31408. t['gs'] = {
  31409. id: OPS.setGState,
  31410. numArgs: 1,
  31411. variableArgs: false
  31412. };
  31413. t['q'] = {
  31414. id: OPS.save,
  31415. numArgs: 0,
  31416. variableArgs: false
  31417. };
  31418. t['Q'] = {
  31419. id: OPS.restore,
  31420. numArgs: 0,
  31421. variableArgs: false
  31422. };
  31423. t['cm'] = {
  31424. id: OPS.transform,
  31425. numArgs: 6,
  31426. variableArgs: false
  31427. };
  31428. t['m'] = {
  31429. id: OPS.moveTo,
  31430. numArgs: 2,
  31431. variableArgs: false
  31432. };
  31433. t['l'] = {
  31434. id: OPS.lineTo,
  31435. numArgs: 2,
  31436. variableArgs: false
  31437. };
  31438. t['c'] = {
  31439. id: OPS.curveTo,
  31440. numArgs: 6,
  31441. variableArgs: false
  31442. };
  31443. t['v'] = {
  31444. id: OPS.curveTo2,
  31445. numArgs: 4,
  31446. variableArgs: false
  31447. };
  31448. t['y'] = {
  31449. id: OPS.curveTo3,
  31450. numArgs: 4,
  31451. variableArgs: false
  31452. };
  31453. t['h'] = {
  31454. id: OPS.closePath,
  31455. numArgs: 0,
  31456. variableArgs: false
  31457. };
  31458. t['re'] = {
  31459. id: OPS.rectangle,
  31460. numArgs: 4,
  31461. variableArgs: false
  31462. };
  31463. t['S'] = {
  31464. id: OPS.stroke,
  31465. numArgs: 0,
  31466. variableArgs: false
  31467. };
  31468. t['s'] = {
  31469. id: OPS.closeStroke,
  31470. numArgs: 0,
  31471. variableArgs: false
  31472. };
  31473. t['f'] = {
  31474. id: OPS.fill,
  31475. numArgs: 0,
  31476. variableArgs: false
  31477. };
  31478. t['F'] = {
  31479. id: OPS.fill,
  31480. numArgs: 0,
  31481. variableArgs: false
  31482. };
  31483. t['f*'] = {
  31484. id: OPS.eoFill,
  31485. numArgs: 0,
  31486. variableArgs: false
  31487. };
  31488. t['B'] = {
  31489. id: OPS.fillStroke,
  31490. numArgs: 0,
  31491. variableArgs: false
  31492. };
  31493. t['B*'] = {
  31494. id: OPS.eoFillStroke,
  31495. numArgs: 0,
  31496. variableArgs: false
  31497. };
  31498. t['b'] = {
  31499. id: OPS.closeFillStroke,
  31500. numArgs: 0,
  31501. variableArgs: false
  31502. };
  31503. t['b*'] = {
  31504. id: OPS.closeEOFillStroke,
  31505. numArgs: 0,
  31506. variableArgs: false
  31507. };
  31508. t['n'] = {
  31509. id: OPS.endPath,
  31510. numArgs: 0,
  31511. variableArgs: false
  31512. };
  31513. t['W'] = {
  31514. id: OPS.clip,
  31515. numArgs: 0,
  31516. variableArgs: false
  31517. };
  31518. t['W*'] = {
  31519. id: OPS.eoClip,
  31520. numArgs: 0,
  31521. variableArgs: false
  31522. };
  31523. t['BT'] = {
  31524. id: OPS.beginText,
  31525. numArgs: 0,
  31526. variableArgs: false
  31527. };
  31528. t['ET'] = {
  31529. id: OPS.endText,
  31530. numArgs: 0,
  31531. variableArgs: false
  31532. };
  31533. t['Tc'] = {
  31534. id: OPS.setCharSpacing,
  31535. numArgs: 1,
  31536. variableArgs: false
  31537. };
  31538. t['Tw'] = {
  31539. id: OPS.setWordSpacing,
  31540. numArgs: 1,
  31541. variableArgs: false
  31542. };
  31543. t['Tz'] = {
  31544. id: OPS.setHScale,
  31545. numArgs: 1,
  31546. variableArgs: false
  31547. };
  31548. t['TL'] = {
  31549. id: OPS.setLeading,
  31550. numArgs: 1,
  31551. variableArgs: false
  31552. };
  31553. t['Tf'] = {
  31554. id: OPS.setFont,
  31555. numArgs: 2,
  31556. variableArgs: false
  31557. };
  31558. t['Tr'] = {
  31559. id: OPS.setTextRenderingMode,
  31560. numArgs: 1,
  31561. variableArgs: false
  31562. };
  31563. t['Ts'] = {
  31564. id: OPS.setTextRise,
  31565. numArgs: 1,
  31566. variableArgs: false
  31567. };
  31568. t['Td'] = {
  31569. id: OPS.moveText,
  31570. numArgs: 2,
  31571. variableArgs: false
  31572. };
  31573. t['TD'] = {
  31574. id: OPS.setLeadingMoveText,
  31575. numArgs: 2,
  31576. variableArgs: false
  31577. };
  31578. t['Tm'] = {
  31579. id: OPS.setTextMatrix,
  31580. numArgs: 6,
  31581. variableArgs: false
  31582. };
  31583. t['T*'] = {
  31584. id: OPS.nextLine,
  31585. numArgs: 0,
  31586. variableArgs: false
  31587. };
  31588. t['Tj'] = {
  31589. id: OPS.showText,
  31590. numArgs: 1,
  31591. variableArgs: false
  31592. };
  31593. t['TJ'] = {
  31594. id: OPS.showSpacedText,
  31595. numArgs: 1,
  31596. variableArgs: false
  31597. };
  31598. t['\''] = {
  31599. id: OPS.nextLineShowText,
  31600. numArgs: 1,
  31601. variableArgs: false
  31602. };
  31603. t['"'] = {
  31604. id: OPS.nextLineSetSpacingShowText,
  31605. numArgs: 3,
  31606. variableArgs: false
  31607. };
  31608. t['d0'] = {
  31609. id: OPS.setCharWidth,
  31610. numArgs: 2,
  31611. variableArgs: false
  31612. };
  31613. t['d1'] = {
  31614. id: OPS.setCharWidthAndBounds,
  31615. numArgs: 6,
  31616. variableArgs: false
  31617. };
  31618. t['CS'] = {
  31619. id: OPS.setStrokeColorSpace,
  31620. numArgs: 1,
  31621. variableArgs: false
  31622. };
  31623. t['cs'] = {
  31624. id: OPS.setFillColorSpace,
  31625. numArgs: 1,
  31626. variableArgs: false
  31627. };
  31628. t['SC'] = {
  31629. id: OPS.setStrokeColor,
  31630. numArgs: 4,
  31631. variableArgs: true
  31632. };
  31633. t['SCN'] = {
  31634. id: OPS.setStrokeColorN,
  31635. numArgs: 33,
  31636. variableArgs: true
  31637. };
  31638. t['sc'] = {
  31639. id: OPS.setFillColor,
  31640. numArgs: 4,
  31641. variableArgs: true
  31642. };
  31643. t['scn'] = {
  31644. id: OPS.setFillColorN,
  31645. numArgs: 33,
  31646. variableArgs: true
  31647. };
  31648. t['G'] = {
  31649. id: OPS.setStrokeGray,
  31650. numArgs: 1,
  31651. variableArgs: false
  31652. };
  31653. t['g'] = {
  31654. id: OPS.setFillGray,
  31655. numArgs: 1,
  31656. variableArgs: false
  31657. };
  31658. t['RG'] = {
  31659. id: OPS.setStrokeRGBColor,
  31660. numArgs: 3,
  31661. variableArgs: false
  31662. };
  31663. t['rg'] = {
  31664. id: OPS.setFillRGBColor,
  31665. numArgs: 3,
  31666. variableArgs: false
  31667. };
  31668. t['K'] = {
  31669. id: OPS.setStrokeCMYKColor,
  31670. numArgs: 4,
  31671. variableArgs: false
  31672. };
  31673. t['k'] = {
  31674. id: OPS.setFillCMYKColor,
  31675. numArgs: 4,
  31676. variableArgs: false
  31677. };
  31678. t['sh'] = {
  31679. id: OPS.shadingFill,
  31680. numArgs: 1,
  31681. variableArgs: false
  31682. };
  31683. t['BI'] = {
  31684. id: OPS.beginInlineImage,
  31685. numArgs: 0,
  31686. variableArgs: false
  31687. };
  31688. t['ID'] = {
  31689. id: OPS.beginImageData,
  31690. numArgs: 0,
  31691. variableArgs: false
  31692. };
  31693. t['EI'] = {
  31694. id: OPS.endInlineImage,
  31695. numArgs: 1,
  31696. variableArgs: false
  31697. };
  31698. t['Do'] = {
  31699. id: OPS.paintXObject,
  31700. numArgs: 1,
  31701. variableArgs: false
  31702. };
  31703. t['MP'] = {
  31704. id: OPS.markPoint,
  31705. numArgs: 1,
  31706. variableArgs: false
  31707. };
  31708. t['DP'] = {
  31709. id: OPS.markPointProps,
  31710. numArgs: 2,
  31711. variableArgs: false
  31712. };
  31713. t['BMC'] = {
  31714. id: OPS.beginMarkedContent,
  31715. numArgs: 1,
  31716. variableArgs: false
  31717. };
  31718. t['BDC'] = {
  31719. id: OPS.beginMarkedContentProps,
  31720. numArgs: 2,
  31721. variableArgs: false
  31722. };
  31723. t['EMC'] = {
  31724. id: OPS.endMarkedContent,
  31725. numArgs: 0,
  31726. variableArgs: false
  31727. };
  31728. t['BX'] = {
  31729. id: OPS.beginCompat,
  31730. numArgs: 0,
  31731. variableArgs: false
  31732. };
  31733. t['EX'] = {
  31734. id: OPS.endCompat,
  31735. numArgs: 0,
  31736. variableArgs: false
  31737. };
  31738. t['BM'] = null;
  31739. t['BD'] = null;
  31740. t['true'] = null;
  31741. t['fa'] = null;
  31742. t['fal'] = null;
  31743. t['fals'] = null;
  31744. t['false'] = null;
  31745. t['nu'] = null;
  31746. t['nul'] = null;
  31747. t['null'] = null;
  31748. });
  31749. function EvaluatorPreprocessor(stream, xref, stateManager) {
  31750. this.opMap = getOPMap();
  31751. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  31752. this.stateManager = stateManager;
  31753. this.nonProcessedArgs = [];
  31754. }
  31755. EvaluatorPreprocessor.prototype = {
  31756. get savedStatesDepth() {
  31757. return this.stateManager.stateStack.length;
  31758. },
  31759. read: function EvaluatorPreprocessor_read(operation) {
  31760. var args = operation.args;
  31761. while (true) {
  31762. var obj = this.parser.getObj();
  31763. if (isCmd(obj)) {
  31764. var cmd = obj.cmd;
  31765. var opSpec = this.opMap[cmd];
  31766. if (!opSpec) {
  31767. warn('Unknown command "' + cmd + '"');
  31768. continue;
  31769. }
  31770. var fn = opSpec.id;
  31771. var numArgs = opSpec.numArgs;
  31772. var argsLength = args !== null ? args.length : 0;
  31773. if (!opSpec.variableArgs) {
  31774. if (argsLength !== numArgs) {
  31775. var nonProcessedArgs = this.nonProcessedArgs;
  31776. while (argsLength > numArgs) {
  31777. nonProcessedArgs.push(args.shift());
  31778. argsLength--;
  31779. }
  31780. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  31781. if (args === null) {
  31782. args = [];
  31783. }
  31784. args.unshift(nonProcessedArgs.pop());
  31785. argsLength++;
  31786. }
  31787. }
  31788. if (argsLength < numArgs) {
  31789. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  31790. if (args !== null) {
  31791. args.length = 0;
  31792. }
  31793. continue;
  31794. }
  31795. } else if (argsLength > numArgs) {
  31796. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  31797. }
  31798. this.preprocessCommand(fn, args);
  31799. operation.fn = fn;
  31800. operation.args = args;
  31801. return true;
  31802. }
  31803. if (isEOF(obj)) {
  31804. return false;
  31805. }
  31806. if (obj !== null) {
  31807. if (args === null) {
  31808. args = [];
  31809. }
  31810. args.push(obj);
  31811. assert(args.length <= 33, 'Too many arguments');
  31812. }
  31813. }
  31814. },
  31815. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  31816. switch (fn | 0) {
  31817. case OPS.save:
  31818. this.stateManager.save();
  31819. break;
  31820. case OPS.restore:
  31821. this.stateManager.restore();
  31822. break;
  31823. case OPS.transform:
  31824. this.stateManager.transform(args);
  31825. break;
  31826. }
  31827. }
  31828. };
  31829. return EvaluatorPreprocessor;
  31830. }();
  31831. var QueueOptimizer = function QueueOptimizerClosure() {
  31832. function addState(parentState, pattern, fn) {
  31833. var state = parentState;
  31834. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  31835. var item = pattern[i];
  31836. state = state[item] || (state[item] = []);
  31837. }
  31838. state[pattern[pattern.length - 1]] = fn;
  31839. }
  31840. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  31841. var iFirstPIMXO = iFirstSave + 2;
  31842. for (var i = 0; i < count; i++) {
  31843. var arg = argsArray[iFirstPIMXO + 4 * i];
  31844. var imageMask = arg.length === 1 && arg[0];
  31845. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  31846. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  31847. continue;
  31848. }
  31849. break;
  31850. }
  31851. return count - i;
  31852. }
  31853. var InitialState = [];
  31854. addState(InitialState, [
  31855. OPS.save,
  31856. OPS.transform,
  31857. OPS.paintInlineImageXObject,
  31858. OPS.restore
  31859. ], function foundInlineImageGroup(context) {
  31860. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  31861. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  31862. var MAX_WIDTH = 1000;
  31863. var IMAGE_PADDING = 1;
  31864. var fnArray = context.fnArray, argsArray = context.argsArray;
  31865. var curr = context.iCurr;
  31866. var iFirstSave = curr - 3;
  31867. var iFirstTransform = curr - 2;
  31868. var iFirstPIIXO = curr - 1;
  31869. var i = iFirstSave + 4;
  31870. var ii = fnArray.length;
  31871. while (i + 3 < ii) {
  31872. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  31873. break;
  31874. }
  31875. i += 4;
  31876. }
  31877. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  31878. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  31879. return i;
  31880. }
  31881. var maxX = 0;
  31882. var map = [], maxLineHeight = 0;
  31883. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  31884. var q;
  31885. for (q = 0; q < count; q++) {
  31886. var transform = argsArray[iFirstTransform + (q << 2)];
  31887. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  31888. if (currentX + img.width > MAX_WIDTH) {
  31889. maxX = Math.max(maxX, currentX);
  31890. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  31891. currentX = 0;
  31892. maxLineHeight = 0;
  31893. }
  31894. map.push({
  31895. transform: transform,
  31896. x: currentX,
  31897. y: currentY,
  31898. w: img.width,
  31899. h: img.height
  31900. });
  31901. currentX += img.width + 2 * IMAGE_PADDING;
  31902. maxLineHeight = Math.max(maxLineHeight, img.height);
  31903. }
  31904. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  31905. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  31906. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  31907. var imgRowSize = imgWidth << 2;
  31908. for (q = 0; q < count; q++) {
  31909. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  31910. var rowSize = map[q].w << 2;
  31911. var dataOffset = 0;
  31912. var offset = map[q].x + map[q].y * imgWidth << 2;
  31913. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  31914. for (var k = 0, kk = map[q].h; k < kk; k++) {
  31915. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  31916. dataOffset += rowSize;
  31917. offset += imgRowSize;
  31918. }
  31919. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  31920. while (offset >= 0) {
  31921. data[offset - 4] = data[offset];
  31922. data[offset - 3] = data[offset + 1];
  31923. data[offset - 2] = data[offset + 2];
  31924. data[offset - 1] = data[offset + 3];
  31925. data[offset + rowSize] = data[offset + rowSize - 4];
  31926. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  31927. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  31928. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  31929. offset -= imgRowSize;
  31930. }
  31931. }
  31932. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  31933. argsArray.splice(iFirstSave, count * 4, [
  31934. {
  31935. width: imgWidth,
  31936. height: imgHeight,
  31937. kind: ImageKind.RGBA_32BPP,
  31938. data: imgData
  31939. },
  31940. map
  31941. ]);
  31942. return iFirstSave + 1;
  31943. });
  31944. addState(InitialState, [
  31945. OPS.save,
  31946. OPS.transform,
  31947. OPS.paintImageMaskXObject,
  31948. OPS.restore
  31949. ], function foundImageMaskGroup(context) {
  31950. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  31951. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  31952. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  31953. var fnArray = context.fnArray, argsArray = context.argsArray;
  31954. var curr = context.iCurr;
  31955. var iFirstSave = curr - 3;
  31956. var iFirstTransform = curr - 2;
  31957. var iFirstPIMXO = curr - 1;
  31958. var i = iFirstSave + 4;
  31959. var ii = fnArray.length;
  31960. while (i + 3 < ii) {
  31961. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  31962. break;
  31963. }
  31964. i += 4;
  31965. }
  31966. var count = (i - iFirstSave) / 4;
  31967. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  31968. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  31969. return i;
  31970. }
  31971. var q;
  31972. var isSameImage = false;
  31973. var iTransform, transformArgs;
  31974. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  31975. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  31976. isSameImage = true;
  31977. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31978. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31979. iTransform = iFirstTransform + 4;
  31980. var iPIMXO = iFirstPIMXO + 4;
  31981. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  31982. transformArgs = argsArray[iTransform];
  31983. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  31984. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  31985. isSameImage = false;
  31986. } else {
  31987. count = q;
  31988. }
  31989. break;
  31990. }
  31991. }
  31992. }
  31993. if (isSameImage) {
  31994. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  31995. var positions = new Float32Array(count * 2);
  31996. iTransform = iFirstTransform;
  31997. for (q = 0; q < count; q++, iTransform += 4) {
  31998. transformArgs = argsArray[iTransform];
  31999. positions[q << 1] = transformArgs[4];
  32000. positions[(q << 1) + 1] = transformArgs[5];
  32001. }
  32002. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  32003. argsArray.splice(iFirstSave, count * 4, [
  32004. firstPIMXOArg0,
  32005. firstTransformArg0,
  32006. firstTransformArg3,
  32007. positions
  32008. ]);
  32009. } else {
  32010. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  32011. var images = [];
  32012. for (q = 0; q < count; q++) {
  32013. transformArgs = argsArray[iFirstTransform + (q << 2)];
  32014. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  32015. images.push({
  32016. data: maskParams.data,
  32017. width: maskParams.width,
  32018. height: maskParams.height,
  32019. transform: transformArgs
  32020. });
  32021. }
  32022. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  32023. argsArray.splice(iFirstSave, count * 4, [images]);
  32024. }
  32025. return iFirstSave + 1;
  32026. });
  32027. addState(InitialState, [
  32028. OPS.save,
  32029. OPS.transform,
  32030. OPS.paintImageXObject,
  32031. OPS.restore
  32032. ], function (context) {
  32033. var MIN_IMAGES_IN_BLOCK = 3;
  32034. var MAX_IMAGES_IN_BLOCK = 1000;
  32035. var fnArray = context.fnArray, argsArray = context.argsArray;
  32036. var curr = context.iCurr;
  32037. var iFirstSave = curr - 3;
  32038. var iFirstTransform = curr - 2;
  32039. var iFirstPIXO = curr - 1;
  32040. var iFirstRestore = curr;
  32041. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  32042. return iFirstRestore + 1;
  32043. }
  32044. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  32045. var firstTransformArg0 = argsArray[iFirstTransform][0];
  32046. var firstTransformArg3 = argsArray[iFirstTransform][3];
  32047. var i = iFirstSave + 4;
  32048. var ii = fnArray.length;
  32049. while (i + 3 < ii) {
  32050. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  32051. break;
  32052. }
  32053. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  32054. break;
  32055. }
  32056. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  32057. break;
  32058. }
  32059. i += 4;
  32060. }
  32061. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  32062. if (count < MIN_IMAGES_IN_BLOCK) {
  32063. return i;
  32064. }
  32065. var positions = new Float32Array(count * 2);
  32066. var iTransform = iFirstTransform;
  32067. for (var q = 0; q < count; q++, iTransform += 4) {
  32068. var transformArgs = argsArray[iTransform];
  32069. positions[q << 1] = transformArgs[4];
  32070. positions[(q << 1) + 1] = transformArgs[5];
  32071. }
  32072. var args = [
  32073. firstPIXOArg0,
  32074. firstTransformArg0,
  32075. firstTransformArg3,
  32076. positions
  32077. ];
  32078. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  32079. argsArray.splice(iFirstSave, count * 4, args);
  32080. return iFirstSave + 1;
  32081. });
  32082. addState(InitialState, [
  32083. OPS.beginText,
  32084. OPS.setFont,
  32085. OPS.setTextMatrix,
  32086. OPS.showText,
  32087. OPS.endText
  32088. ], function (context) {
  32089. var MIN_CHARS_IN_BLOCK = 3;
  32090. var MAX_CHARS_IN_BLOCK = 1000;
  32091. var fnArray = context.fnArray, argsArray = context.argsArray;
  32092. var curr = context.iCurr;
  32093. var iFirstBeginText = curr - 4;
  32094. var iFirstSetFont = curr - 3;
  32095. var iFirstSetTextMatrix = curr - 2;
  32096. var iFirstShowText = curr - 1;
  32097. var iFirstEndText = curr;
  32098. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  32099. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  32100. var i = iFirstBeginText + 5;
  32101. var ii = fnArray.length;
  32102. while (i + 4 < ii) {
  32103. 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) {
  32104. break;
  32105. }
  32106. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  32107. break;
  32108. }
  32109. i += 5;
  32110. }
  32111. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  32112. if (count < MIN_CHARS_IN_BLOCK) {
  32113. return i;
  32114. }
  32115. var iFirst = iFirstBeginText;
  32116. 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) {
  32117. count++;
  32118. iFirst -= 5;
  32119. }
  32120. var iEndText = iFirst + 4;
  32121. for (var q = 1; q < count; q++) {
  32122. fnArray.splice(iEndText, 3);
  32123. argsArray.splice(iEndText, 3);
  32124. iEndText += 2;
  32125. }
  32126. return iEndText + 1;
  32127. });
  32128. function QueueOptimizer() {
  32129. }
  32130. QueueOptimizer.prototype = {
  32131. optimize: function QueueOptimizer_optimize(queue) {
  32132. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  32133. var context = {
  32134. iCurr: 0,
  32135. fnArray: fnArray,
  32136. argsArray: argsArray
  32137. };
  32138. var state;
  32139. var i = 0, ii = fnArray.length;
  32140. while (i < ii) {
  32141. state = (state || InitialState)[fnArray[i]];
  32142. if (typeof state === 'function') {
  32143. context.iCurr = i;
  32144. i = state(context);
  32145. state = undefined;
  32146. ii = context.fnArray.length;
  32147. } else {
  32148. i++;
  32149. }
  32150. }
  32151. }
  32152. };
  32153. return QueueOptimizer;
  32154. }();
  32155. exports.OperatorList = OperatorList;
  32156. exports.PartialEvaluator = PartialEvaluator;
  32157. /***/ }),
  32158. /* 18 */
  32159. /***/ (function(module, exports, __w_pdfjs_require__) {
  32160. "use strict";
  32161. var sharedUtil = __w_pdfjs_require__(0);
  32162. var coreArithmeticDecoder = __w_pdfjs_require__(13);
  32163. var info = sharedUtil.info;
  32164. var warn = sharedUtil.warn;
  32165. var error = sharedUtil.error;
  32166. var log2 = sharedUtil.log2;
  32167. var readUint16 = sharedUtil.readUint16;
  32168. var readUint32 = sharedUtil.readUint32;
  32169. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  32170. var JpxImage = function JpxImageClosure() {
  32171. var SubbandsGainLog2 = {
  32172. 'LL': 0,
  32173. 'LH': 1,
  32174. 'HL': 1,
  32175. 'HH': 2
  32176. };
  32177. function JpxImage() {
  32178. this.failOnCorruptedImage = false;
  32179. }
  32180. JpxImage.prototype = {
  32181. parse: function JpxImage_parse(data) {
  32182. var head = readUint16(data, 0);
  32183. if (head === 0xFF4F) {
  32184. this.parseCodestream(data, 0, data.length);
  32185. return;
  32186. }
  32187. var position = 0, length = data.length;
  32188. while (position < length) {
  32189. var headerSize = 8;
  32190. var lbox = readUint32(data, position);
  32191. var tbox = readUint32(data, position + 4);
  32192. position += headerSize;
  32193. if (lbox === 1) {
  32194. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  32195. position += 8;
  32196. headerSize += 8;
  32197. }
  32198. if (lbox === 0) {
  32199. lbox = length - position + headerSize;
  32200. }
  32201. if (lbox < headerSize) {
  32202. error('JPX Error: Invalid box field size');
  32203. }
  32204. var dataLength = lbox - headerSize;
  32205. var jumpDataLength = true;
  32206. switch (tbox) {
  32207. case 0x6A703268:
  32208. jumpDataLength = false;
  32209. break;
  32210. case 0x636F6C72:
  32211. var method = data[position];
  32212. if (method === 1) {
  32213. var colorspace = readUint32(data, position + 3);
  32214. switch (colorspace) {
  32215. case 16:
  32216. case 17:
  32217. case 18:
  32218. break;
  32219. default:
  32220. warn('Unknown colorspace ' + colorspace);
  32221. break;
  32222. }
  32223. } else if (method === 2) {
  32224. info('ICC profile not supported');
  32225. }
  32226. break;
  32227. case 0x6A703263:
  32228. this.parseCodestream(data, position, position + dataLength);
  32229. break;
  32230. case 0x6A502020:
  32231. if (0x0d0a870a !== readUint32(data, position)) {
  32232. warn('Invalid JP2 signature');
  32233. }
  32234. break;
  32235. case 0x6A501A1A:
  32236. case 0x66747970:
  32237. case 0x72726571:
  32238. case 0x72657320:
  32239. case 0x69686472:
  32240. break;
  32241. default:
  32242. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  32243. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  32244. break;
  32245. }
  32246. if (jumpDataLength) {
  32247. position += dataLength;
  32248. }
  32249. }
  32250. },
  32251. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  32252. var newByte = stream.getByte();
  32253. while (newByte >= 0) {
  32254. var oldByte = newByte;
  32255. newByte = stream.getByte();
  32256. var code = oldByte << 8 | newByte;
  32257. if (code === 0xFF51) {
  32258. stream.skip(4);
  32259. var Xsiz = stream.getInt32() >>> 0;
  32260. var Ysiz = stream.getInt32() >>> 0;
  32261. var XOsiz = stream.getInt32() >>> 0;
  32262. var YOsiz = stream.getInt32() >>> 0;
  32263. stream.skip(16);
  32264. var Csiz = stream.getUint16();
  32265. this.width = Xsiz - XOsiz;
  32266. this.height = Ysiz - YOsiz;
  32267. this.componentsCount = Csiz;
  32268. this.bitsPerComponent = 8;
  32269. return;
  32270. }
  32271. }
  32272. error('JPX Error: No size marker found in JPX stream');
  32273. },
  32274. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  32275. var context = {};
  32276. var doNotRecover = false;
  32277. try {
  32278. var position = start;
  32279. while (position + 1 < end) {
  32280. var code = readUint16(data, position);
  32281. position += 2;
  32282. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  32283. switch (code) {
  32284. case 0xFF4F:
  32285. context.mainHeader = true;
  32286. break;
  32287. case 0xFFD9:
  32288. break;
  32289. case 0xFF51:
  32290. length = readUint16(data, position);
  32291. var siz = {};
  32292. siz.Xsiz = readUint32(data, position + 4);
  32293. siz.Ysiz = readUint32(data, position + 8);
  32294. siz.XOsiz = readUint32(data, position + 12);
  32295. siz.YOsiz = readUint32(data, position + 16);
  32296. siz.XTsiz = readUint32(data, position + 20);
  32297. siz.YTsiz = readUint32(data, position + 24);
  32298. siz.XTOsiz = readUint32(data, position + 28);
  32299. siz.YTOsiz = readUint32(data, position + 32);
  32300. var componentsCount = readUint16(data, position + 36);
  32301. siz.Csiz = componentsCount;
  32302. var components = [];
  32303. j = position + 38;
  32304. for (var i = 0; i < componentsCount; i++) {
  32305. var component = {
  32306. precision: (data[j] & 0x7F) + 1,
  32307. isSigned: !!(data[j] & 0x80),
  32308. XRsiz: data[j + 1],
  32309. YRsiz: data[j + 1]
  32310. };
  32311. calculateComponentDimensions(component, siz);
  32312. components.push(component);
  32313. }
  32314. context.SIZ = siz;
  32315. context.components = components;
  32316. calculateTileGrids(context, components);
  32317. context.QCC = [];
  32318. context.COC = [];
  32319. break;
  32320. case 0xFF5C:
  32321. length = readUint16(data, position);
  32322. var qcd = {};
  32323. j = position + 2;
  32324. sqcd = data[j++];
  32325. switch (sqcd & 0x1F) {
  32326. case 0:
  32327. spqcdSize = 8;
  32328. scalarExpounded = true;
  32329. break;
  32330. case 1:
  32331. spqcdSize = 16;
  32332. scalarExpounded = false;
  32333. break;
  32334. case 2:
  32335. spqcdSize = 16;
  32336. scalarExpounded = true;
  32337. break;
  32338. default:
  32339. throw new Error('Invalid SQcd value ' + sqcd);
  32340. }
  32341. qcd.noQuantization = spqcdSize === 8;
  32342. qcd.scalarExpounded = scalarExpounded;
  32343. qcd.guardBits = sqcd >> 5;
  32344. spqcds = [];
  32345. while (j < length + position) {
  32346. var spqcd = {};
  32347. if (spqcdSize === 8) {
  32348. spqcd.epsilon = data[j++] >> 3;
  32349. spqcd.mu = 0;
  32350. } else {
  32351. spqcd.epsilon = data[j] >> 3;
  32352. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  32353. j += 2;
  32354. }
  32355. spqcds.push(spqcd);
  32356. }
  32357. qcd.SPqcds = spqcds;
  32358. if (context.mainHeader) {
  32359. context.QCD = qcd;
  32360. } else {
  32361. context.currentTile.QCD = qcd;
  32362. context.currentTile.QCC = [];
  32363. }
  32364. break;
  32365. case 0xFF5D:
  32366. length = readUint16(data, position);
  32367. var qcc = {};
  32368. j = position + 2;
  32369. var cqcc;
  32370. if (context.SIZ.Csiz < 257) {
  32371. cqcc = data[j++];
  32372. } else {
  32373. cqcc = readUint16(data, j);
  32374. j += 2;
  32375. }
  32376. sqcd = data[j++];
  32377. switch (sqcd & 0x1F) {
  32378. case 0:
  32379. spqcdSize = 8;
  32380. scalarExpounded = true;
  32381. break;
  32382. case 1:
  32383. spqcdSize = 16;
  32384. scalarExpounded = false;
  32385. break;
  32386. case 2:
  32387. spqcdSize = 16;
  32388. scalarExpounded = true;
  32389. break;
  32390. default:
  32391. throw new Error('Invalid SQcd value ' + sqcd);
  32392. }
  32393. qcc.noQuantization = spqcdSize === 8;
  32394. qcc.scalarExpounded = scalarExpounded;
  32395. qcc.guardBits = sqcd >> 5;
  32396. spqcds = [];
  32397. while (j < length + position) {
  32398. spqcd = {};
  32399. if (spqcdSize === 8) {
  32400. spqcd.epsilon = data[j++] >> 3;
  32401. spqcd.mu = 0;
  32402. } else {
  32403. spqcd.epsilon = data[j] >> 3;
  32404. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  32405. j += 2;
  32406. }
  32407. spqcds.push(spqcd);
  32408. }
  32409. qcc.SPqcds = spqcds;
  32410. if (context.mainHeader) {
  32411. context.QCC[cqcc] = qcc;
  32412. } else {
  32413. context.currentTile.QCC[cqcc] = qcc;
  32414. }
  32415. break;
  32416. case 0xFF52:
  32417. length = readUint16(data, position);
  32418. var cod = {};
  32419. j = position + 2;
  32420. var scod = data[j++];
  32421. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  32422. cod.sopMarkerUsed = !!(scod & 2);
  32423. cod.ephMarkerUsed = !!(scod & 4);
  32424. cod.progressionOrder = data[j++];
  32425. cod.layersCount = readUint16(data, j);
  32426. j += 2;
  32427. cod.multipleComponentTransform = data[j++];
  32428. cod.decompositionLevelsCount = data[j++];
  32429. cod.xcb = (data[j++] & 0xF) + 2;
  32430. cod.ycb = (data[j++] & 0xF) + 2;
  32431. var blockStyle = data[j++];
  32432. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  32433. cod.resetContextProbabilities = !!(blockStyle & 2);
  32434. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  32435. cod.verticalyStripe = !!(blockStyle & 8);
  32436. cod.predictableTermination = !!(blockStyle & 16);
  32437. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  32438. cod.reversibleTransformation = data[j++];
  32439. if (cod.entropyCoderWithCustomPrecincts) {
  32440. var precinctsSizes = [];
  32441. while (j < length + position) {
  32442. var precinctsSize = data[j++];
  32443. precinctsSizes.push({
  32444. PPx: precinctsSize & 0xF,
  32445. PPy: precinctsSize >> 4
  32446. });
  32447. }
  32448. cod.precinctsSizes = precinctsSizes;
  32449. }
  32450. var unsupported = [];
  32451. if (cod.selectiveArithmeticCodingBypass) {
  32452. unsupported.push('selectiveArithmeticCodingBypass');
  32453. }
  32454. if (cod.resetContextProbabilities) {
  32455. unsupported.push('resetContextProbabilities');
  32456. }
  32457. if (cod.terminationOnEachCodingPass) {
  32458. unsupported.push('terminationOnEachCodingPass');
  32459. }
  32460. if (cod.verticalyStripe) {
  32461. unsupported.push('verticalyStripe');
  32462. }
  32463. if (cod.predictableTermination) {
  32464. unsupported.push('predictableTermination');
  32465. }
  32466. if (unsupported.length > 0) {
  32467. doNotRecover = true;
  32468. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  32469. }
  32470. if (context.mainHeader) {
  32471. context.COD = cod;
  32472. } else {
  32473. context.currentTile.COD = cod;
  32474. context.currentTile.COC = [];
  32475. }
  32476. break;
  32477. case 0xFF90:
  32478. length = readUint16(data, position);
  32479. tile = {};
  32480. tile.index = readUint16(data, position + 2);
  32481. tile.length = readUint32(data, position + 4);
  32482. tile.dataEnd = tile.length + position - 2;
  32483. tile.partIndex = data[position + 8];
  32484. tile.partsCount = data[position + 9];
  32485. context.mainHeader = false;
  32486. if (tile.partIndex === 0) {
  32487. tile.COD = context.COD;
  32488. tile.COC = context.COC.slice(0);
  32489. tile.QCD = context.QCD;
  32490. tile.QCC = context.QCC.slice(0);
  32491. }
  32492. context.currentTile = tile;
  32493. break;
  32494. case 0xFF93:
  32495. tile = context.currentTile;
  32496. if (tile.partIndex === 0) {
  32497. initializeTile(context, tile.index);
  32498. buildPackets(context);
  32499. }
  32500. length = tile.dataEnd - position;
  32501. parseTilePackets(context, data, position, length);
  32502. break;
  32503. case 0xFF55:
  32504. case 0xFF57:
  32505. case 0xFF58:
  32506. case 0xFF64:
  32507. length = readUint16(data, position);
  32508. break;
  32509. case 0xFF53:
  32510. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  32511. default:
  32512. throw new Error('Unknown codestream code: ' + code.toString(16));
  32513. }
  32514. position += length;
  32515. }
  32516. } catch (e) {
  32517. if (doNotRecover || this.failOnCorruptedImage) {
  32518. error('JPX Error: ' + e.message);
  32519. } else {
  32520. warn('JPX: Trying to recover from: ' + e.message);
  32521. }
  32522. }
  32523. this.tiles = transformComponents(context);
  32524. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  32525. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  32526. this.componentsCount = context.SIZ.Csiz;
  32527. }
  32528. };
  32529. function calculateComponentDimensions(component, siz) {
  32530. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  32531. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  32532. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  32533. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  32534. component.width = component.x1 - component.x0;
  32535. component.height = component.y1 - component.y0;
  32536. }
  32537. function calculateTileGrids(context, components) {
  32538. var siz = context.SIZ;
  32539. var tile, tiles = [];
  32540. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  32541. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  32542. for (var q = 0; q < numYtiles; q++) {
  32543. for (var p = 0; p < numXtiles; p++) {
  32544. tile = {};
  32545. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  32546. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  32547. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  32548. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  32549. tile.width = tile.tx1 - tile.tx0;
  32550. tile.height = tile.ty1 - tile.ty0;
  32551. tile.components = [];
  32552. tiles.push(tile);
  32553. }
  32554. }
  32555. context.tiles = tiles;
  32556. var componentsCount = siz.Csiz;
  32557. for (var i = 0, ii = componentsCount; i < ii; i++) {
  32558. var component = components[i];
  32559. for (var j = 0, jj = tiles.length; j < jj; j++) {
  32560. var tileComponent = {};
  32561. tile = tiles[j];
  32562. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  32563. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  32564. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  32565. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  32566. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  32567. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  32568. tile.components[i] = tileComponent;
  32569. }
  32570. }
  32571. }
  32572. function getBlocksDimensions(context, component, r) {
  32573. var codOrCoc = component.codingStyleParameters;
  32574. var result = {};
  32575. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  32576. result.PPx = 15;
  32577. result.PPy = 15;
  32578. } else {
  32579. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  32580. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  32581. }
  32582. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  32583. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  32584. return result;
  32585. }
  32586. function buildPrecincts(context, resolution, dimensions) {
  32587. var precinctWidth = 1 << dimensions.PPx;
  32588. var precinctHeight = 1 << dimensions.PPy;
  32589. var isZeroRes = resolution.resLevel === 0;
  32590. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  32591. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  32592. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  32593. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  32594. var numprecincts = numprecinctswide * numprecinctshigh;
  32595. resolution.precinctParameters = {
  32596. precinctWidth: precinctWidth,
  32597. precinctHeight: precinctHeight,
  32598. numprecinctswide: numprecinctswide,
  32599. numprecinctshigh: numprecinctshigh,
  32600. numprecincts: numprecincts,
  32601. precinctWidthInSubband: precinctWidthInSubband,
  32602. precinctHeightInSubband: precinctHeightInSubband
  32603. };
  32604. }
  32605. function buildCodeblocks(context, subband, dimensions) {
  32606. var xcb_ = dimensions.xcb_;
  32607. var ycb_ = dimensions.ycb_;
  32608. var codeblockWidth = 1 << xcb_;
  32609. var codeblockHeight = 1 << ycb_;
  32610. var cbx0 = subband.tbx0 >> xcb_;
  32611. var cby0 = subband.tby0 >> ycb_;
  32612. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  32613. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  32614. var precinctParameters = subband.resolution.precinctParameters;
  32615. var codeblocks = [];
  32616. var precincts = [];
  32617. var i, j, codeblock, precinctNumber;
  32618. for (j = cby0; j < cby1; j++) {
  32619. for (i = cbx0; i < cbx1; i++) {
  32620. codeblock = {
  32621. cbx: i,
  32622. cby: j,
  32623. tbx0: codeblockWidth * i,
  32624. tby0: codeblockHeight * j,
  32625. tbx1: codeblockWidth * (i + 1),
  32626. tby1: codeblockHeight * (j + 1)
  32627. };
  32628. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  32629. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  32630. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  32631. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  32632. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  32633. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  32634. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  32635. codeblock.precinctNumber = precinctNumber;
  32636. codeblock.subbandType = subband.type;
  32637. codeblock.Lblock = 3;
  32638. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  32639. continue;
  32640. }
  32641. codeblocks.push(codeblock);
  32642. var precinct = precincts[precinctNumber];
  32643. if (precinct !== undefined) {
  32644. if (i < precinct.cbxMin) {
  32645. precinct.cbxMin = i;
  32646. } else if (i > precinct.cbxMax) {
  32647. precinct.cbxMax = i;
  32648. }
  32649. if (j < precinct.cbyMin) {
  32650. precinct.cbxMin = j;
  32651. } else if (j > precinct.cbyMax) {
  32652. precinct.cbyMax = j;
  32653. }
  32654. } else {
  32655. precincts[precinctNumber] = precinct = {
  32656. cbxMin: i,
  32657. cbyMin: j,
  32658. cbxMax: i,
  32659. cbyMax: j
  32660. };
  32661. }
  32662. codeblock.precinct = precinct;
  32663. }
  32664. }
  32665. subband.codeblockParameters = {
  32666. codeblockWidth: xcb_,
  32667. codeblockHeight: ycb_,
  32668. numcodeblockwide: cbx1 - cbx0 + 1,
  32669. numcodeblockhigh: cby1 - cby0 + 1
  32670. };
  32671. subband.codeblocks = codeblocks;
  32672. subband.precincts = precincts;
  32673. }
  32674. function createPacket(resolution, precinctNumber, layerNumber) {
  32675. var precinctCodeblocks = [];
  32676. var subbands = resolution.subbands;
  32677. for (var i = 0, ii = subbands.length; i < ii; i++) {
  32678. var subband = subbands[i];
  32679. var codeblocks = subband.codeblocks;
  32680. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  32681. var codeblock = codeblocks[j];
  32682. if (codeblock.precinctNumber !== precinctNumber) {
  32683. continue;
  32684. }
  32685. precinctCodeblocks.push(codeblock);
  32686. }
  32687. }
  32688. return {
  32689. layerNumber: layerNumber,
  32690. codeblocks: precinctCodeblocks
  32691. };
  32692. }
  32693. function LayerResolutionComponentPositionIterator(context) {
  32694. var siz = context.SIZ;
  32695. var tileIndex = context.currentTile.index;
  32696. var tile = context.tiles[tileIndex];
  32697. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32698. var componentsCount = siz.Csiz;
  32699. var maxDecompositionLevelsCount = 0;
  32700. for (var q = 0; q < componentsCount; q++) {
  32701. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  32702. }
  32703. var l = 0, r = 0, i = 0, k = 0;
  32704. this.nextPacket = function JpxImage_nextPacket() {
  32705. for (; l < layersCount; l++) {
  32706. for (; r <= maxDecompositionLevelsCount; r++) {
  32707. for (; i < componentsCount; i++) {
  32708. var component = tile.components[i];
  32709. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32710. continue;
  32711. }
  32712. var resolution = component.resolutions[r];
  32713. var numprecincts = resolution.precinctParameters.numprecincts;
  32714. for (; k < numprecincts;) {
  32715. var packet = createPacket(resolution, k, l);
  32716. k++;
  32717. return packet;
  32718. }
  32719. k = 0;
  32720. }
  32721. i = 0;
  32722. }
  32723. r = 0;
  32724. }
  32725. error('JPX Error: Out of packets');
  32726. };
  32727. }
  32728. function ResolutionLayerComponentPositionIterator(context) {
  32729. var siz = context.SIZ;
  32730. var tileIndex = context.currentTile.index;
  32731. var tile = context.tiles[tileIndex];
  32732. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32733. var componentsCount = siz.Csiz;
  32734. var maxDecompositionLevelsCount = 0;
  32735. for (var q = 0; q < componentsCount; q++) {
  32736. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  32737. }
  32738. var r = 0, l = 0, i = 0, k = 0;
  32739. this.nextPacket = function JpxImage_nextPacket() {
  32740. for (; r <= maxDecompositionLevelsCount; r++) {
  32741. for (; l < layersCount; l++) {
  32742. for (; i < componentsCount; i++) {
  32743. var component = tile.components[i];
  32744. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32745. continue;
  32746. }
  32747. var resolution = component.resolutions[r];
  32748. var numprecincts = resolution.precinctParameters.numprecincts;
  32749. for (; k < numprecincts;) {
  32750. var packet = createPacket(resolution, k, l);
  32751. k++;
  32752. return packet;
  32753. }
  32754. k = 0;
  32755. }
  32756. i = 0;
  32757. }
  32758. l = 0;
  32759. }
  32760. error('JPX Error: Out of packets');
  32761. };
  32762. }
  32763. function ResolutionPositionComponentLayerIterator(context) {
  32764. var siz = context.SIZ;
  32765. var tileIndex = context.currentTile.index;
  32766. var tile = context.tiles[tileIndex];
  32767. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32768. var componentsCount = siz.Csiz;
  32769. var l, r, c, p;
  32770. var maxDecompositionLevelsCount = 0;
  32771. for (c = 0; c < componentsCount; c++) {
  32772. var component = tile.components[c];
  32773. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  32774. }
  32775. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  32776. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  32777. var maxNumPrecincts = 0;
  32778. for (c = 0; c < componentsCount; ++c) {
  32779. var resolutions = tile.components[c].resolutions;
  32780. if (r < resolutions.length) {
  32781. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  32782. }
  32783. }
  32784. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  32785. }
  32786. l = 0;
  32787. r = 0;
  32788. c = 0;
  32789. p = 0;
  32790. this.nextPacket = function JpxImage_nextPacket() {
  32791. for (; r <= maxDecompositionLevelsCount; r++) {
  32792. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  32793. for (; c < componentsCount; c++) {
  32794. var component = tile.components[c];
  32795. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32796. continue;
  32797. }
  32798. var resolution = component.resolutions[r];
  32799. var numprecincts = resolution.precinctParameters.numprecincts;
  32800. if (p >= numprecincts) {
  32801. continue;
  32802. }
  32803. for (; l < layersCount;) {
  32804. var packet = createPacket(resolution, p, l);
  32805. l++;
  32806. return packet;
  32807. }
  32808. l = 0;
  32809. }
  32810. c = 0;
  32811. }
  32812. p = 0;
  32813. }
  32814. error('JPX Error: Out of packets');
  32815. };
  32816. }
  32817. function PositionComponentResolutionLayerIterator(context) {
  32818. var siz = context.SIZ;
  32819. var tileIndex = context.currentTile.index;
  32820. var tile = context.tiles[tileIndex];
  32821. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32822. var componentsCount = siz.Csiz;
  32823. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32824. var precinctsIterationSizes = precinctsSizes;
  32825. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32826. this.nextPacket = function JpxImage_nextPacket() {
  32827. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32828. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32829. for (; c < componentsCount; c++) {
  32830. var component = tile.components[c];
  32831. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32832. for (; r <= decompositionLevelsCount; r++) {
  32833. var resolution = component.resolutions[r];
  32834. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  32835. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32836. if (k === null) {
  32837. continue;
  32838. }
  32839. for (; l < layersCount;) {
  32840. var packet = createPacket(resolution, k, l);
  32841. l++;
  32842. return packet;
  32843. }
  32844. l = 0;
  32845. }
  32846. r = 0;
  32847. }
  32848. c = 0;
  32849. }
  32850. px = 0;
  32851. }
  32852. error('JPX Error: Out of packets');
  32853. };
  32854. }
  32855. function ComponentPositionResolutionLayerIterator(context) {
  32856. var siz = context.SIZ;
  32857. var tileIndex = context.currentTile.index;
  32858. var tile = context.tiles[tileIndex];
  32859. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32860. var componentsCount = siz.Csiz;
  32861. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32862. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32863. this.nextPacket = function JpxImage_nextPacket() {
  32864. for (; c < componentsCount; ++c) {
  32865. var component = tile.components[c];
  32866. var precinctsIterationSizes = precinctsSizes.components[c];
  32867. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32868. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32869. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32870. for (; r <= decompositionLevelsCount; r++) {
  32871. var resolution = component.resolutions[r];
  32872. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  32873. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32874. if (k === null) {
  32875. continue;
  32876. }
  32877. for (; l < layersCount;) {
  32878. var packet = createPacket(resolution, k, l);
  32879. l++;
  32880. return packet;
  32881. }
  32882. l = 0;
  32883. }
  32884. r = 0;
  32885. }
  32886. px = 0;
  32887. }
  32888. py = 0;
  32889. }
  32890. error('JPX Error: Out of packets');
  32891. };
  32892. }
  32893. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  32894. var posX = pxIndex * precinctIterationSizes.minWidth;
  32895. var posY = pyIndex * precinctIterationSizes.minHeight;
  32896. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  32897. return null;
  32898. }
  32899. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  32900. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  32901. }
  32902. function getPrecinctSizesInImageScale(tile) {
  32903. var componentsCount = tile.components.length;
  32904. var minWidth = Number.MAX_VALUE;
  32905. var minHeight = Number.MAX_VALUE;
  32906. var maxNumWide = 0;
  32907. var maxNumHigh = 0;
  32908. var sizePerComponent = new Array(componentsCount);
  32909. for (var c = 0; c < componentsCount; c++) {
  32910. var component = tile.components[c];
  32911. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32912. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  32913. var minWidthCurrentComponent = Number.MAX_VALUE;
  32914. var minHeightCurrentComponent = Number.MAX_VALUE;
  32915. var maxNumWideCurrentComponent = 0;
  32916. var maxNumHighCurrentComponent = 0;
  32917. var scale = 1;
  32918. for (var r = decompositionLevelsCount; r >= 0; --r) {
  32919. var resolution = component.resolutions[r];
  32920. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  32921. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  32922. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  32923. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  32924. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  32925. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  32926. sizePerResolution[r] = {
  32927. width: widthCurrentResolution,
  32928. height: heightCurrentResolution
  32929. };
  32930. scale <<= 1;
  32931. }
  32932. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  32933. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  32934. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  32935. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  32936. sizePerComponent[c] = {
  32937. resolutions: sizePerResolution,
  32938. minWidth: minWidthCurrentComponent,
  32939. minHeight: minHeightCurrentComponent,
  32940. maxNumWide: maxNumWideCurrentComponent,
  32941. maxNumHigh: maxNumHighCurrentComponent
  32942. };
  32943. }
  32944. return {
  32945. components: sizePerComponent,
  32946. minWidth: minWidth,
  32947. minHeight: minHeight,
  32948. maxNumWide: maxNumWide,
  32949. maxNumHigh: maxNumHigh
  32950. };
  32951. }
  32952. function buildPackets(context) {
  32953. var siz = context.SIZ;
  32954. var tileIndex = context.currentTile.index;
  32955. var tile = context.tiles[tileIndex];
  32956. var componentsCount = siz.Csiz;
  32957. for (var c = 0; c < componentsCount; c++) {
  32958. var component = tile.components[c];
  32959. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32960. var resolutions = [];
  32961. var subbands = [];
  32962. for (var r = 0; r <= decompositionLevelsCount; r++) {
  32963. var blocksDimensions = getBlocksDimensions(context, component, r);
  32964. var resolution = {};
  32965. var scale = 1 << decompositionLevelsCount - r;
  32966. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  32967. resolution.try0 = Math.ceil(component.tcy0 / scale);
  32968. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  32969. resolution.try1 = Math.ceil(component.tcy1 / scale);
  32970. resolution.resLevel = r;
  32971. buildPrecincts(context, resolution, blocksDimensions);
  32972. resolutions.push(resolution);
  32973. var subband;
  32974. if (r === 0) {
  32975. subband = {};
  32976. subband.type = 'LL';
  32977. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  32978. subband.tby0 = Math.ceil(component.tcy0 / scale);
  32979. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  32980. subband.tby1 = Math.ceil(component.tcy1 / scale);
  32981. subband.resolution = resolution;
  32982. buildCodeblocks(context, subband, blocksDimensions);
  32983. subbands.push(subband);
  32984. resolution.subbands = [subband];
  32985. } else {
  32986. var bscale = 1 << decompositionLevelsCount - r + 1;
  32987. var resolutionSubbands = [];
  32988. subband = {};
  32989. subband.type = 'HL';
  32990. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32991. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  32992. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32993. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  32994. subband.resolution = resolution;
  32995. buildCodeblocks(context, subband, blocksDimensions);
  32996. subbands.push(subband);
  32997. resolutionSubbands.push(subband);
  32998. subband = {};
  32999. subband.type = 'LH';
  33000. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  33001. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  33002. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  33003. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  33004. subband.resolution = resolution;
  33005. buildCodeblocks(context, subband, blocksDimensions);
  33006. subbands.push(subband);
  33007. resolutionSubbands.push(subband);
  33008. subband = {};
  33009. subband.type = 'HH';
  33010. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  33011. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  33012. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  33013. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  33014. subband.resolution = resolution;
  33015. buildCodeblocks(context, subband, blocksDimensions);
  33016. subbands.push(subband);
  33017. resolutionSubbands.push(subband);
  33018. resolution.subbands = resolutionSubbands;
  33019. }
  33020. }
  33021. component.resolutions = resolutions;
  33022. component.subbands = subbands;
  33023. }
  33024. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  33025. switch (progressionOrder) {
  33026. case 0:
  33027. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  33028. break;
  33029. case 1:
  33030. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  33031. break;
  33032. case 2:
  33033. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  33034. break;
  33035. case 3:
  33036. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  33037. break;
  33038. case 4:
  33039. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  33040. break;
  33041. default:
  33042. error('JPX Error: Unsupported progression order ' + progressionOrder);
  33043. }
  33044. }
  33045. function parseTilePackets(context, data, offset, dataLength) {
  33046. var position = 0;
  33047. var buffer, bufferSize = 0, skipNextBit = false;
  33048. function readBits(count) {
  33049. while (bufferSize < count) {
  33050. var b = data[offset + position];
  33051. position++;
  33052. if (skipNextBit) {
  33053. buffer = buffer << 7 | b;
  33054. bufferSize += 7;
  33055. skipNextBit = false;
  33056. } else {
  33057. buffer = buffer << 8 | b;
  33058. bufferSize += 8;
  33059. }
  33060. if (b === 0xFF) {
  33061. skipNextBit = true;
  33062. }
  33063. }
  33064. bufferSize -= count;
  33065. return buffer >>> bufferSize & (1 << count) - 1;
  33066. }
  33067. function skipMarkerIfEqual(value) {
  33068. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  33069. skipBytes(1);
  33070. return true;
  33071. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  33072. skipBytes(2);
  33073. return true;
  33074. }
  33075. return false;
  33076. }
  33077. function skipBytes(count) {
  33078. position += count;
  33079. }
  33080. function alignToByte() {
  33081. bufferSize = 0;
  33082. if (skipNextBit) {
  33083. position++;
  33084. skipNextBit = false;
  33085. }
  33086. }
  33087. function readCodingpasses() {
  33088. if (readBits(1) === 0) {
  33089. return 1;
  33090. }
  33091. if (readBits(1) === 0) {
  33092. return 2;
  33093. }
  33094. var value = readBits(2);
  33095. if (value < 3) {
  33096. return value + 3;
  33097. }
  33098. value = readBits(5);
  33099. if (value < 31) {
  33100. return value + 6;
  33101. }
  33102. value = readBits(7);
  33103. return value + 37;
  33104. }
  33105. var tileIndex = context.currentTile.index;
  33106. var tile = context.tiles[tileIndex];
  33107. var sopMarkerUsed = context.COD.sopMarkerUsed;
  33108. var ephMarkerUsed = context.COD.ephMarkerUsed;
  33109. var packetsIterator = tile.packetsIterator;
  33110. while (position < dataLength) {
  33111. alignToByte();
  33112. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  33113. skipBytes(4);
  33114. }
  33115. var packet = packetsIterator.nextPacket();
  33116. if (!readBits(1)) {
  33117. continue;
  33118. }
  33119. var layerNumber = packet.layerNumber;
  33120. var queue = [], codeblock;
  33121. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  33122. codeblock = packet.codeblocks[i];
  33123. var precinct = codeblock.precinct;
  33124. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  33125. var codeblockRow = codeblock.cby - precinct.cbyMin;
  33126. var codeblockIncluded = false;
  33127. var firstTimeInclusion = false;
  33128. var valueReady;
  33129. if (codeblock['included'] !== undefined) {
  33130. codeblockIncluded = !!readBits(1);
  33131. } else {
  33132. precinct = codeblock.precinct;
  33133. var inclusionTree, zeroBitPlanesTree;
  33134. if (precinct['inclusionTree'] !== undefined) {
  33135. inclusionTree = precinct.inclusionTree;
  33136. } else {
  33137. var width = precinct.cbxMax - precinct.cbxMin + 1;
  33138. var height = precinct.cbyMax - precinct.cbyMin + 1;
  33139. inclusionTree = new InclusionTree(width, height, layerNumber);
  33140. zeroBitPlanesTree = new TagTree(width, height);
  33141. precinct.inclusionTree = inclusionTree;
  33142. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  33143. }
  33144. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  33145. while (true) {
  33146. if (readBits(1)) {
  33147. valueReady = !inclusionTree.nextLevel();
  33148. if (valueReady) {
  33149. codeblock.included = true;
  33150. codeblockIncluded = firstTimeInclusion = true;
  33151. break;
  33152. }
  33153. } else {
  33154. inclusionTree.incrementValue(layerNumber);
  33155. break;
  33156. }
  33157. }
  33158. }
  33159. }
  33160. if (!codeblockIncluded) {
  33161. continue;
  33162. }
  33163. if (firstTimeInclusion) {
  33164. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  33165. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  33166. while (true) {
  33167. if (readBits(1)) {
  33168. valueReady = !zeroBitPlanesTree.nextLevel();
  33169. if (valueReady) {
  33170. break;
  33171. }
  33172. } else {
  33173. zeroBitPlanesTree.incrementValue();
  33174. }
  33175. }
  33176. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  33177. }
  33178. var codingpasses = readCodingpasses();
  33179. while (readBits(1)) {
  33180. codeblock.Lblock++;
  33181. }
  33182. var codingpassesLog2 = log2(codingpasses);
  33183. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  33184. var codedDataLength = readBits(bits);
  33185. queue.push({
  33186. codeblock: codeblock,
  33187. codingpasses: codingpasses,
  33188. dataLength: codedDataLength
  33189. });
  33190. }
  33191. alignToByte();
  33192. if (ephMarkerUsed) {
  33193. skipMarkerIfEqual(0x92);
  33194. }
  33195. while (queue.length > 0) {
  33196. var packetItem = queue.shift();
  33197. codeblock = packetItem.codeblock;
  33198. if (codeblock['data'] === undefined) {
  33199. codeblock.data = [];
  33200. }
  33201. codeblock.data.push({
  33202. data: data,
  33203. start: offset + position,
  33204. end: offset + position + packetItem.dataLength,
  33205. codingpasses: packetItem.codingpasses
  33206. });
  33207. position += packetItem.dataLength;
  33208. }
  33209. }
  33210. return position;
  33211. }
  33212. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  33213. var x0 = subband.tbx0;
  33214. var y0 = subband.tby0;
  33215. var width = subband.tbx1 - subband.tbx0;
  33216. var codeblocks = subband.codeblocks;
  33217. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  33218. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  33219. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  33220. var codeblock = codeblocks[i];
  33221. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  33222. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  33223. if (blockWidth === 0 || blockHeight === 0) {
  33224. continue;
  33225. }
  33226. if (codeblock['data'] === undefined) {
  33227. continue;
  33228. }
  33229. var bitModel, currentCodingpassType;
  33230. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  33231. currentCodingpassType = 2;
  33232. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  33233. var j, jj, dataItem;
  33234. for (j = 0, jj = data.length; j < jj; j++) {
  33235. dataItem = data[j];
  33236. totalLength += dataItem.end - dataItem.start;
  33237. codingpasses += dataItem.codingpasses;
  33238. }
  33239. var encodedData = new Uint8Array(totalLength);
  33240. var position = 0;
  33241. for (j = 0, jj = data.length; j < jj; j++) {
  33242. dataItem = data[j];
  33243. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  33244. encodedData.set(chunk, position);
  33245. position += chunk.length;
  33246. }
  33247. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  33248. bitModel.setDecoder(decoder);
  33249. for (j = 0; j < codingpasses; j++) {
  33250. switch (currentCodingpassType) {
  33251. case 0:
  33252. bitModel.runSignificancePropagationPass();
  33253. break;
  33254. case 1:
  33255. bitModel.runMagnitudeRefinementPass();
  33256. break;
  33257. case 2:
  33258. bitModel.runCleanupPass();
  33259. if (segmentationSymbolUsed) {
  33260. bitModel.checkSegmentationSymbol();
  33261. }
  33262. break;
  33263. }
  33264. currentCodingpassType = (currentCodingpassType + 1) % 3;
  33265. }
  33266. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  33267. var sign = bitModel.coefficentsSign;
  33268. var magnitude = bitModel.coefficentsMagnitude;
  33269. var bitsDecoded = bitModel.bitsDecoded;
  33270. var magnitudeCorrection = reversible ? 0 : 0.5;
  33271. var k, n, nb;
  33272. position = 0;
  33273. var interleave = subband.type !== 'LL';
  33274. for (j = 0; j < blockHeight; j++) {
  33275. var row = offset / width | 0;
  33276. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  33277. for (k = 0; k < blockWidth; k++) {
  33278. n = magnitude[position];
  33279. if (n !== 0) {
  33280. n = (n + magnitudeCorrection) * delta;
  33281. if (sign[position] !== 0) {
  33282. n = -n;
  33283. }
  33284. nb = bitsDecoded[position];
  33285. var pos = interleave ? levelOffset + (offset << 1) : offset;
  33286. if (reversible && nb >= mb) {
  33287. coefficients[pos] = n;
  33288. } else {
  33289. coefficients[pos] = n * (1 << mb - nb);
  33290. }
  33291. }
  33292. offset++;
  33293. position++;
  33294. }
  33295. offset += width - blockWidth;
  33296. }
  33297. }
  33298. }
  33299. function transformTile(context, tile, c) {
  33300. var component = tile.components[c];
  33301. var codingStyleParameters = component.codingStyleParameters;
  33302. var quantizationParameters = component.quantizationParameters;
  33303. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  33304. var spqcds = quantizationParameters.SPqcds;
  33305. var scalarExpounded = quantizationParameters.scalarExpounded;
  33306. var guardBits = quantizationParameters.guardBits;
  33307. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  33308. var precision = context.components[c].precision;
  33309. var reversible = codingStyleParameters.reversibleTransformation;
  33310. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  33311. var subbandCoefficients = [];
  33312. var b = 0;
  33313. for (var i = 0; i <= decompositionLevelsCount; i++) {
  33314. var resolution = component.resolutions[i];
  33315. var width = resolution.trx1 - resolution.trx0;
  33316. var height = resolution.try1 - resolution.try0;
  33317. var coefficients = new Float32Array(width * height);
  33318. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  33319. var mu, epsilon;
  33320. if (!scalarExpounded) {
  33321. mu = spqcds[0].mu;
  33322. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  33323. } else {
  33324. mu = spqcds[b].mu;
  33325. epsilon = spqcds[b].epsilon;
  33326. b++;
  33327. }
  33328. var subband = resolution.subbands[j];
  33329. var gainLog2 = SubbandsGainLog2[subband.type];
  33330. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  33331. var mb = guardBits + epsilon - 1;
  33332. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  33333. }
  33334. subbandCoefficients.push({
  33335. width: width,
  33336. height: height,
  33337. items: coefficients
  33338. });
  33339. }
  33340. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  33341. return {
  33342. left: component.tcx0,
  33343. top: component.tcy0,
  33344. width: result.width,
  33345. height: result.height,
  33346. items: result.items
  33347. };
  33348. }
  33349. function transformComponents(context) {
  33350. var siz = context.SIZ;
  33351. var components = context.components;
  33352. var componentsCount = siz.Csiz;
  33353. var resultImages = [];
  33354. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  33355. var tile = context.tiles[i];
  33356. var transformedTiles = [];
  33357. var c;
  33358. for (c = 0; c < componentsCount; c++) {
  33359. transformedTiles[c] = transformTile(context, tile, c);
  33360. }
  33361. var tile0 = transformedTiles[0];
  33362. var out = new Uint8Array(tile0.items.length * componentsCount);
  33363. var result = {
  33364. left: tile0.left,
  33365. top: tile0.top,
  33366. width: tile0.width,
  33367. height: tile0.height,
  33368. items: out
  33369. };
  33370. var shift, offset, max, min, maxK;
  33371. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  33372. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  33373. var fourComponents = componentsCount === 4;
  33374. var y0items = transformedTiles[0].items;
  33375. var y1items = transformedTiles[1].items;
  33376. var y2items = transformedTiles[2].items;
  33377. var y3items = fourComponents ? transformedTiles[3].items : null;
  33378. shift = components[0].precision - 8;
  33379. offset = (128 << shift) + 0.5;
  33380. max = 255 * (1 << shift);
  33381. maxK = max * 0.5;
  33382. min = -maxK;
  33383. var component0 = tile.components[0];
  33384. var alpha01 = componentsCount - 3;
  33385. jj = y0items.length;
  33386. if (!component0.codingStyleParameters.reversibleTransformation) {
  33387. for (j = 0; j < jj; j++, pos += alpha01) {
  33388. y0 = y0items[j] + offset;
  33389. y1 = y1items[j];
  33390. y2 = y2items[j];
  33391. r = y0 + 1.402 * y2;
  33392. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  33393. b = y0 + 1.772 * y1;
  33394. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  33395. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  33396. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  33397. }
  33398. } else {
  33399. for (j = 0; j < jj; j++, pos += alpha01) {
  33400. y0 = y0items[j] + offset;
  33401. y1 = y1items[j];
  33402. y2 = y2items[j];
  33403. g = y0 - (y2 + y1 >> 2);
  33404. r = g + y2;
  33405. b = g + y1;
  33406. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  33407. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  33408. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  33409. }
  33410. }
  33411. if (fourComponents) {
  33412. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  33413. k = y3items[j];
  33414. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  33415. }
  33416. }
  33417. } else {
  33418. for (c = 0; c < componentsCount; c++) {
  33419. var items = transformedTiles[c].items;
  33420. shift = components[c].precision - 8;
  33421. offset = (128 << shift) + 0.5;
  33422. max = 127.5 * (1 << shift);
  33423. min = -max;
  33424. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  33425. val = items[j];
  33426. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  33427. pos += componentsCount;
  33428. }
  33429. }
  33430. }
  33431. resultImages.push(result);
  33432. }
  33433. return resultImages;
  33434. }
  33435. function initializeTile(context, tileIndex) {
  33436. var siz = context.SIZ;
  33437. var componentsCount = siz.Csiz;
  33438. var tile = context.tiles[tileIndex];
  33439. for (var c = 0; c < componentsCount; c++) {
  33440. var component = tile.components[c];
  33441. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  33442. component.quantizationParameters = qcdOrQcc;
  33443. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  33444. component.codingStyleParameters = codOrCoc;
  33445. }
  33446. tile.codingStyleDefaultParameters = context.currentTile.COD;
  33447. }
  33448. var TagTree = function TagTreeClosure() {
  33449. function TagTree(width, height) {
  33450. var levelsLength = log2(Math.max(width, height)) + 1;
  33451. this.levels = [];
  33452. for (var i = 0; i < levelsLength; i++) {
  33453. var level = {
  33454. width: width,
  33455. height: height,
  33456. items: []
  33457. };
  33458. this.levels.push(level);
  33459. width = Math.ceil(width / 2);
  33460. height = Math.ceil(height / 2);
  33461. }
  33462. }
  33463. TagTree.prototype = {
  33464. reset: function TagTree_reset(i, j) {
  33465. var currentLevel = 0, value = 0, level;
  33466. while (currentLevel < this.levels.length) {
  33467. level = this.levels[currentLevel];
  33468. var index = i + j * level.width;
  33469. if (level.items[index] !== undefined) {
  33470. value = level.items[index];
  33471. break;
  33472. }
  33473. level.index = index;
  33474. i >>= 1;
  33475. j >>= 1;
  33476. currentLevel++;
  33477. }
  33478. currentLevel--;
  33479. level = this.levels[currentLevel];
  33480. level.items[level.index] = value;
  33481. this.currentLevel = currentLevel;
  33482. delete this.value;
  33483. },
  33484. incrementValue: function TagTree_incrementValue() {
  33485. var level = this.levels[this.currentLevel];
  33486. level.items[level.index]++;
  33487. },
  33488. nextLevel: function TagTree_nextLevel() {
  33489. var currentLevel = this.currentLevel;
  33490. var level = this.levels[currentLevel];
  33491. var value = level.items[level.index];
  33492. currentLevel--;
  33493. if (currentLevel < 0) {
  33494. this.value = value;
  33495. return false;
  33496. }
  33497. this.currentLevel = currentLevel;
  33498. level = this.levels[currentLevel];
  33499. level.items[level.index] = value;
  33500. return true;
  33501. }
  33502. };
  33503. return TagTree;
  33504. }();
  33505. var InclusionTree = function InclusionTreeClosure() {
  33506. function InclusionTree(width, height, defaultValue) {
  33507. var levelsLength = log2(Math.max(width, height)) + 1;
  33508. this.levels = [];
  33509. for (var i = 0; i < levelsLength; i++) {
  33510. var items = new Uint8Array(width * height);
  33511. for (var j = 0, jj = items.length; j < jj; j++) {
  33512. items[j] = defaultValue;
  33513. }
  33514. var level = {
  33515. width: width,
  33516. height: height,
  33517. items: items
  33518. };
  33519. this.levels.push(level);
  33520. width = Math.ceil(width / 2);
  33521. height = Math.ceil(height / 2);
  33522. }
  33523. }
  33524. InclusionTree.prototype = {
  33525. reset: function InclusionTree_reset(i, j, stopValue) {
  33526. var currentLevel = 0;
  33527. while (currentLevel < this.levels.length) {
  33528. var level = this.levels[currentLevel];
  33529. var index = i + j * level.width;
  33530. level.index = index;
  33531. var value = level.items[index];
  33532. if (value === 0xFF) {
  33533. break;
  33534. }
  33535. if (value > stopValue) {
  33536. this.currentLevel = currentLevel;
  33537. this.propagateValues();
  33538. return false;
  33539. }
  33540. i >>= 1;
  33541. j >>= 1;
  33542. currentLevel++;
  33543. }
  33544. this.currentLevel = currentLevel - 1;
  33545. return true;
  33546. },
  33547. incrementValue: function InclusionTree_incrementValue(stopValue) {
  33548. var level = this.levels[this.currentLevel];
  33549. level.items[level.index] = stopValue + 1;
  33550. this.propagateValues();
  33551. },
  33552. propagateValues: function InclusionTree_propagateValues() {
  33553. var levelIndex = this.currentLevel;
  33554. var level = this.levels[levelIndex];
  33555. var currentValue = level.items[level.index];
  33556. while (--levelIndex >= 0) {
  33557. level = this.levels[levelIndex];
  33558. level.items[level.index] = currentValue;
  33559. }
  33560. },
  33561. nextLevel: function InclusionTree_nextLevel() {
  33562. var currentLevel = this.currentLevel;
  33563. var level = this.levels[currentLevel];
  33564. var value = level.items[level.index];
  33565. level.items[level.index] = 0xFF;
  33566. currentLevel--;
  33567. if (currentLevel < 0) {
  33568. return false;
  33569. }
  33570. this.currentLevel = currentLevel;
  33571. level = this.levels[currentLevel];
  33572. level.items[level.index] = value;
  33573. return true;
  33574. }
  33575. };
  33576. return InclusionTree;
  33577. }();
  33578. var BitModel = function BitModelClosure() {
  33579. var UNIFORM_CONTEXT = 17;
  33580. var RUNLENGTH_CONTEXT = 18;
  33581. var LLAndLHContextsLabel = new Uint8Array([
  33582. 0,
  33583. 5,
  33584. 8,
  33585. 0,
  33586. 3,
  33587. 7,
  33588. 8,
  33589. 0,
  33590. 4,
  33591. 7,
  33592. 8,
  33593. 0,
  33594. 0,
  33595. 0,
  33596. 0,
  33597. 0,
  33598. 1,
  33599. 6,
  33600. 8,
  33601. 0,
  33602. 3,
  33603. 7,
  33604. 8,
  33605. 0,
  33606. 4,
  33607. 7,
  33608. 8,
  33609. 0,
  33610. 0,
  33611. 0,
  33612. 0,
  33613. 0,
  33614. 2,
  33615. 6,
  33616. 8,
  33617. 0,
  33618. 3,
  33619. 7,
  33620. 8,
  33621. 0,
  33622. 4,
  33623. 7,
  33624. 8,
  33625. 0,
  33626. 0,
  33627. 0,
  33628. 0,
  33629. 0,
  33630. 2,
  33631. 6,
  33632. 8,
  33633. 0,
  33634. 3,
  33635. 7,
  33636. 8,
  33637. 0,
  33638. 4,
  33639. 7,
  33640. 8,
  33641. 0,
  33642. 0,
  33643. 0,
  33644. 0,
  33645. 0,
  33646. 2,
  33647. 6,
  33648. 8,
  33649. 0,
  33650. 3,
  33651. 7,
  33652. 8,
  33653. 0,
  33654. 4,
  33655. 7,
  33656. 8
  33657. ]);
  33658. var HLContextLabel = new Uint8Array([
  33659. 0,
  33660. 3,
  33661. 4,
  33662. 0,
  33663. 5,
  33664. 7,
  33665. 7,
  33666. 0,
  33667. 8,
  33668. 8,
  33669. 8,
  33670. 0,
  33671. 0,
  33672. 0,
  33673. 0,
  33674. 0,
  33675. 1,
  33676. 3,
  33677. 4,
  33678. 0,
  33679. 6,
  33680. 7,
  33681. 7,
  33682. 0,
  33683. 8,
  33684. 8,
  33685. 8,
  33686. 0,
  33687. 0,
  33688. 0,
  33689. 0,
  33690. 0,
  33691. 2,
  33692. 3,
  33693. 4,
  33694. 0,
  33695. 6,
  33696. 7,
  33697. 7,
  33698. 0,
  33699. 8,
  33700. 8,
  33701. 8,
  33702. 0,
  33703. 0,
  33704. 0,
  33705. 0,
  33706. 0,
  33707. 2,
  33708. 3,
  33709. 4,
  33710. 0,
  33711. 6,
  33712. 7,
  33713. 7,
  33714. 0,
  33715. 8,
  33716. 8,
  33717. 8,
  33718. 0,
  33719. 0,
  33720. 0,
  33721. 0,
  33722. 0,
  33723. 2,
  33724. 3,
  33725. 4,
  33726. 0,
  33727. 6,
  33728. 7,
  33729. 7,
  33730. 0,
  33731. 8,
  33732. 8,
  33733. 8
  33734. ]);
  33735. var HHContextLabel = new Uint8Array([
  33736. 0,
  33737. 1,
  33738. 2,
  33739. 0,
  33740. 1,
  33741. 2,
  33742. 2,
  33743. 0,
  33744. 2,
  33745. 2,
  33746. 2,
  33747. 0,
  33748. 0,
  33749. 0,
  33750. 0,
  33751. 0,
  33752. 3,
  33753. 4,
  33754. 5,
  33755. 0,
  33756. 4,
  33757. 5,
  33758. 5,
  33759. 0,
  33760. 5,
  33761. 5,
  33762. 5,
  33763. 0,
  33764. 0,
  33765. 0,
  33766. 0,
  33767. 0,
  33768. 6,
  33769. 7,
  33770. 7,
  33771. 0,
  33772. 7,
  33773. 7,
  33774. 7,
  33775. 0,
  33776. 7,
  33777. 7,
  33778. 7,
  33779. 0,
  33780. 0,
  33781. 0,
  33782. 0,
  33783. 0,
  33784. 8,
  33785. 8,
  33786. 8,
  33787. 0,
  33788. 8,
  33789. 8,
  33790. 8,
  33791. 0,
  33792. 8,
  33793. 8,
  33794. 8,
  33795. 0,
  33796. 0,
  33797. 0,
  33798. 0,
  33799. 0,
  33800. 8,
  33801. 8,
  33802. 8,
  33803. 0,
  33804. 8,
  33805. 8,
  33806. 8,
  33807. 0,
  33808. 8,
  33809. 8,
  33810. 8
  33811. ]);
  33812. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  33813. this.width = width;
  33814. this.height = height;
  33815. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  33816. var coefficientCount = width * height;
  33817. this.neighborsSignificance = new Uint8Array(coefficientCount);
  33818. this.coefficentsSign = new Uint8Array(coefficientCount);
  33819. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  33820. this.processingFlags = new Uint8Array(coefficientCount);
  33821. var bitsDecoded = new Uint8Array(coefficientCount);
  33822. if (zeroBitPlanes !== 0) {
  33823. for (var i = 0; i < coefficientCount; i++) {
  33824. bitsDecoded[i] = zeroBitPlanes;
  33825. }
  33826. }
  33827. this.bitsDecoded = bitsDecoded;
  33828. this.reset();
  33829. }
  33830. BitModel.prototype = {
  33831. setDecoder: function BitModel_setDecoder(decoder) {
  33832. this.decoder = decoder;
  33833. },
  33834. reset: function BitModel_reset() {
  33835. this.contexts = new Int8Array(19);
  33836. this.contexts[0] = 4 << 1 | 0;
  33837. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  33838. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  33839. },
  33840. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  33841. var neighborsSignificance = this.neighborsSignificance;
  33842. var width = this.width, height = this.height;
  33843. var left = column > 0;
  33844. var right = column + 1 < width;
  33845. var i;
  33846. if (row > 0) {
  33847. i = index - width;
  33848. if (left) {
  33849. neighborsSignificance[i - 1] += 0x10;
  33850. }
  33851. if (right) {
  33852. neighborsSignificance[i + 1] += 0x10;
  33853. }
  33854. neighborsSignificance[i] += 0x04;
  33855. }
  33856. if (row + 1 < height) {
  33857. i = index + width;
  33858. if (left) {
  33859. neighborsSignificance[i - 1] += 0x10;
  33860. }
  33861. if (right) {
  33862. neighborsSignificance[i + 1] += 0x10;
  33863. }
  33864. neighborsSignificance[i] += 0x04;
  33865. }
  33866. if (left) {
  33867. neighborsSignificance[index - 1] += 0x01;
  33868. }
  33869. if (right) {
  33870. neighborsSignificance[index + 1] += 0x01;
  33871. }
  33872. neighborsSignificance[index] |= 0x80;
  33873. },
  33874. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  33875. var decoder = this.decoder;
  33876. var width = this.width, height = this.height;
  33877. var coefficentsMagnitude = this.coefficentsMagnitude;
  33878. var coefficentsSign = this.coefficentsSign;
  33879. var neighborsSignificance = this.neighborsSignificance;
  33880. var processingFlags = this.processingFlags;
  33881. var contexts = this.contexts;
  33882. var labels = this.contextLabelTable;
  33883. var bitsDecoded = this.bitsDecoded;
  33884. var processedInverseMask = ~1;
  33885. var processedMask = 1;
  33886. var firstMagnitudeBitMask = 2;
  33887. for (var i0 = 0; i0 < height; i0 += 4) {
  33888. for (var j = 0; j < width; j++) {
  33889. var index = i0 * width + j;
  33890. for (var i1 = 0; i1 < 4; i1++, index += width) {
  33891. var i = i0 + i1;
  33892. if (i >= height) {
  33893. break;
  33894. }
  33895. processingFlags[index] &= processedInverseMask;
  33896. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  33897. continue;
  33898. }
  33899. var contextLabel = labels[neighborsSignificance[index]];
  33900. var decision = decoder.readBit(contexts, contextLabel);
  33901. if (decision) {
  33902. var sign = this.decodeSignBit(i, j, index);
  33903. coefficentsSign[index] = sign;
  33904. coefficentsMagnitude[index] = 1;
  33905. this.setNeighborsSignificance(i, j, index);
  33906. processingFlags[index] |= firstMagnitudeBitMask;
  33907. }
  33908. bitsDecoded[index]++;
  33909. processingFlags[index] |= processedMask;
  33910. }
  33911. }
  33912. }
  33913. },
  33914. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  33915. var width = this.width, height = this.height;
  33916. var coefficentsMagnitude = this.coefficentsMagnitude;
  33917. var coefficentsSign = this.coefficentsSign;
  33918. var contribution, sign0, sign1, significance1;
  33919. var contextLabel, decoded;
  33920. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  33921. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  33922. sign1 = coefficentsSign[index + 1];
  33923. if (significance1) {
  33924. sign0 = coefficentsSign[index - 1];
  33925. contribution = 1 - sign1 - sign0;
  33926. } else {
  33927. contribution = 1 - sign1 - sign1;
  33928. }
  33929. } else if (significance1) {
  33930. sign0 = coefficentsSign[index - 1];
  33931. contribution = 1 - sign0 - sign0;
  33932. } else {
  33933. contribution = 0;
  33934. }
  33935. var horizontalContribution = 3 * contribution;
  33936. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  33937. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  33938. sign1 = coefficentsSign[index + width];
  33939. if (significance1) {
  33940. sign0 = coefficentsSign[index - width];
  33941. contribution = 1 - sign1 - sign0 + horizontalContribution;
  33942. } else {
  33943. contribution = 1 - sign1 - sign1 + horizontalContribution;
  33944. }
  33945. } else if (significance1) {
  33946. sign0 = coefficentsSign[index - width];
  33947. contribution = 1 - sign0 - sign0 + horizontalContribution;
  33948. } else {
  33949. contribution = horizontalContribution;
  33950. }
  33951. if (contribution >= 0) {
  33952. contextLabel = 9 + contribution;
  33953. decoded = this.decoder.readBit(this.contexts, contextLabel);
  33954. } else {
  33955. contextLabel = 9 - contribution;
  33956. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  33957. }
  33958. return decoded;
  33959. },
  33960. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  33961. var decoder = this.decoder;
  33962. var width = this.width, height = this.height;
  33963. var coefficentsMagnitude = this.coefficentsMagnitude;
  33964. var neighborsSignificance = this.neighborsSignificance;
  33965. var contexts = this.contexts;
  33966. var bitsDecoded = this.bitsDecoded;
  33967. var processingFlags = this.processingFlags;
  33968. var processedMask = 1;
  33969. var firstMagnitudeBitMask = 2;
  33970. var length = width * height;
  33971. var width4 = width * 4;
  33972. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  33973. indexNext = Math.min(length, index0 + width4);
  33974. for (var j = 0; j < width; j++) {
  33975. for (var index = index0 + j; index < indexNext; index += width) {
  33976. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33977. continue;
  33978. }
  33979. var contextLabel = 16;
  33980. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  33981. processingFlags[index] ^= firstMagnitudeBitMask;
  33982. var significance = neighborsSignificance[index] & 127;
  33983. contextLabel = significance === 0 ? 15 : 14;
  33984. }
  33985. var bit = decoder.readBit(contexts, contextLabel);
  33986. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  33987. bitsDecoded[index]++;
  33988. processingFlags[index] |= processedMask;
  33989. }
  33990. }
  33991. }
  33992. },
  33993. runCleanupPass: function BitModel_runCleanupPass() {
  33994. var decoder = this.decoder;
  33995. var width = this.width, height = this.height;
  33996. var neighborsSignificance = this.neighborsSignificance;
  33997. var coefficentsMagnitude = this.coefficentsMagnitude;
  33998. var coefficentsSign = this.coefficentsSign;
  33999. var contexts = this.contexts;
  34000. var labels = this.contextLabelTable;
  34001. var bitsDecoded = this.bitsDecoded;
  34002. var processingFlags = this.processingFlags;
  34003. var processedMask = 1;
  34004. var firstMagnitudeBitMask = 2;
  34005. var oneRowDown = width;
  34006. var twoRowsDown = width * 2;
  34007. var threeRowsDown = width * 3;
  34008. var iNext;
  34009. for (var i0 = 0; i0 < height; i0 = iNext) {
  34010. iNext = Math.min(i0 + 4, height);
  34011. var indexBase = i0 * width;
  34012. var checkAllEmpty = i0 + 3 < height;
  34013. for (var j = 0; j < width; j++) {
  34014. var index0 = indexBase + j;
  34015. 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;
  34016. var i1 = 0, index = index0;
  34017. var i = i0, sign;
  34018. if (allEmpty) {
  34019. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  34020. if (!hasSignificantCoefficent) {
  34021. bitsDecoded[index0]++;
  34022. bitsDecoded[index0 + oneRowDown]++;
  34023. bitsDecoded[index0 + twoRowsDown]++;
  34024. bitsDecoded[index0 + threeRowsDown]++;
  34025. continue;
  34026. }
  34027. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  34028. if (i1 !== 0) {
  34029. i = i0 + i1;
  34030. index += i1 * width;
  34031. }
  34032. sign = this.decodeSignBit(i, j, index);
  34033. coefficentsSign[index] = sign;
  34034. coefficentsMagnitude[index] = 1;
  34035. this.setNeighborsSignificance(i, j, index);
  34036. processingFlags[index] |= firstMagnitudeBitMask;
  34037. index = index0;
  34038. for (var i2 = i0; i2 <= i; i2++, index += width) {
  34039. bitsDecoded[index]++;
  34040. }
  34041. i1++;
  34042. }
  34043. for (i = i0 + i1; i < iNext; i++, index += width) {
  34044. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  34045. continue;
  34046. }
  34047. var contextLabel = labels[neighborsSignificance[index]];
  34048. var decision = decoder.readBit(contexts, contextLabel);
  34049. if (decision === 1) {
  34050. sign = this.decodeSignBit(i, j, index);
  34051. coefficentsSign[index] = sign;
  34052. coefficentsMagnitude[index] = 1;
  34053. this.setNeighborsSignificance(i, j, index);
  34054. processingFlags[index] |= firstMagnitudeBitMask;
  34055. }
  34056. bitsDecoded[index]++;
  34057. }
  34058. }
  34059. }
  34060. },
  34061. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  34062. var decoder = this.decoder;
  34063. var contexts = this.contexts;
  34064. 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);
  34065. if (symbol !== 0xA) {
  34066. error('JPX Error: Invalid segmentation symbol');
  34067. }
  34068. }
  34069. };
  34070. return BitModel;
  34071. }();
  34072. var Transform = function TransformClosure() {
  34073. function Transform() {
  34074. }
  34075. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  34076. var ll = subbands[0];
  34077. for (var i = 1, ii = subbands.length; i < ii; i++) {
  34078. ll = this.iterate(ll, subbands[i], u0, v0);
  34079. }
  34080. return ll;
  34081. };
  34082. Transform.prototype.extend = function extend(buffer, offset, size) {
  34083. var i1 = offset - 1, j1 = offset + 1;
  34084. var i2 = offset + size - 2, j2 = offset + size;
  34085. buffer[i1--] = buffer[j1++];
  34086. buffer[j2++] = buffer[i2--];
  34087. buffer[i1--] = buffer[j1++];
  34088. buffer[j2++] = buffer[i2--];
  34089. buffer[i1--] = buffer[j1++];
  34090. buffer[j2++] = buffer[i2--];
  34091. buffer[i1] = buffer[j1];
  34092. buffer[j2] = buffer[i2];
  34093. };
  34094. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  34095. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  34096. var width = hl_lh_hh.width;
  34097. var height = hl_lh_hh.height;
  34098. var items = hl_lh_hh.items;
  34099. var i, j, k, l, u, v;
  34100. for (k = 0, i = 0; i < llHeight; i++) {
  34101. l = i * 2 * width;
  34102. for (j = 0; j < llWidth; j++, k++, l += 2) {
  34103. items[l] = llItems[k];
  34104. }
  34105. }
  34106. llItems = ll.items = null;
  34107. var bufferPadding = 4;
  34108. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  34109. if (width === 1) {
  34110. if ((u0 & 1) !== 0) {
  34111. for (v = 0, k = 0; v < height; v++, k += width) {
  34112. items[k] *= 0.5;
  34113. }
  34114. }
  34115. } else {
  34116. for (v = 0, k = 0; v < height; v++, k += width) {
  34117. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  34118. this.extend(rowBuffer, bufferPadding, width);
  34119. this.filter(rowBuffer, bufferPadding, width);
  34120. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  34121. }
  34122. }
  34123. var numBuffers = 16;
  34124. var colBuffers = [];
  34125. for (i = 0; i < numBuffers; i++) {
  34126. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  34127. }
  34128. var b, currentBuffer = 0;
  34129. ll = bufferPadding + height;
  34130. if (height === 1) {
  34131. if ((v0 & 1) !== 0) {
  34132. for (u = 0; u < width; u++) {
  34133. items[u] *= 0.5;
  34134. }
  34135. }
  34136. } else {
  34137. for (u = 0; u < width; u++) {
  34138. if (currentBuffer === 0) {
  34139. numBuffers = Math.min(width - u, numBuffers);
  34140. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  34141. for (b = 0; b < numBuffers; b++) {
  34142. colBuffers[b][l] = items[k + b];
  34143. }
  34144. }
  34145. currentBuffer = numBuffers;
  34146. }
  34147. currentBuffer--;
  34148. var buffer = colBuffers[currentBuffer];
  34149. this.extend(buffer, bufferPadding, height);
  34150. this.filter(buffer, bufferPadding, height);
  34151. if (currentBuffer === 0) {
  34152. k = u - numBuffers + 1;
  34153. for (l = bufferPadding; l < ll; k += width, l++) {
  34154. for (b = 0; b < numBuffers; b++) {
  34155. items[k + b] = colBuffers[b][l];
  34156. }
  34157. }
  34158. }
  34159. }
  34160. }
  34161. return {
  34162. width: width,
  34163. height: height,
  34164. items: items
  34165. };
  34166. };
  34167. return Transform;
  34168. }();
  34169. var IrreversibleTransform = function IrreversibleTransformClosure() {
  34170. function IrreversibleTransform() {
  34171. Transform.call(this);
  34172. }
  34173. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  34174. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  34175. var len = length >> 1;
  34176. offset = offset | 0;
  34177. var j, n, current, next;
  34178. var alpha = -1.586134342059924;
  34179. var beta = -0.052980118572961;
  34180. var gamma = 0.882911075530934;
  34181. var delta = 0.443506852043971;
  34182. var K = 1.230174104914001;
  34183. var K_ = 1 / K;
  34184. j = offset - 3;
  34185. for (n = len + 4; n--; j += 2) {
  34186. x[j] *= K_;
  34187. }
  34188. j = offset - 2;
  34189. current = delta * x[j - 1];
  34190. for (n = len + 3; n--; j += 2) {
  34191. next = delta * x[j + 1];
  34192. x[j] = K * x[j] - current - next;
  34193. if (n--) {
  34194. j += 2;
  34195. current = delta * x[j + 1];
  34196. x[j] = K * x[j] - current - next;
  34197. } else {
  34198. break;
  34199. }
  34200. }
  34201. j = offset - 1;
  34202. current = gamma * x[j - 1];
  34203. for (n = len + 2; n--; j += 2) {
  34204. next = gamma * x[j + 1];
  34205. x[j] -= current + next;
  34206. if (n--) {
  34207. j += 2;
  34208. current = gamma * x[j + 1];
  34209. x[j] -= current + next;
  34210. } else {
  34211. break;
  34212. }
  34213. }
  34214. j = offset;
  34215. current = beta * x[j - 1];
  34216. for (n = len + 1; n--; j += 2) {
  34217. next = beta * x[j + 1];
  34218. x[j] -= current + next;
  34219. if (n--) {
  34220. j += 2;
  34221. current = beta * x[j + 1];
  34222. x[j] -= current + next;
  34223. } else {
  34224. break;
  34225. }
  34226. }
  34227. if (len !== 0) {
  34228. j = offset + 1;
  34229. current = alpha * x[j - 1];
  34230. for (n = len; n--; j += 2) {
  34231. next = alpha * x[j + 1];
  34232. x[j] -= current + next;
  34233. if (n--) {
  34234. j += 2;
  34235. current = alpha * x[j + 1];
  34236. x[j] -= current + next;
  34237. } else {
  34238. break;
  34239. }
  34240. }
  34241. }
  34242. };
  34243. return IrreversibleTransform;
  34244. }();
  34245. var ReversibleTransform = function ReversibleTransformClosure() {
  34246. function ReversibleTransform() {
  34247. Transform.call(this);
  34248. }
  34249. ReversibleTransform.prototype = Object.create(Transform.prototype);
  34250. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  34251. var len = length >> 1;
  34252. offset = offset | 0;
  34253. var j, n;
  34254. for (j = offset, n = len + 1; n--; j += 2) {
  34255. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  34256. }
  34257. for (j = offset + 1, n = len; n--; j += 2) {
  34258. x[j] += x[j - 1] + x[j + 1] >> 1;
  34259. }
  34260. };
  34261. return ReversibleTransform;
  34262. }();
  34263. return JpxImage;
  34264. }();
  34265. exports.JpxImage = JpxImage;
  34266. /***/ }),
  34267. /* 19 */
  34268. /***/ (function(module, exports, __w_pdfjs_require__) {
  34269. "use strict";
  34270. var sharedUtil = __w_pdfjs_require__(0);
  34271. var corePrimitives = __w_pdfjs_require__(1);
  34272. var coreCrypto = __w_pdfjs_require__(16);
  34273. var coreParser = __w_pdfjs_require__(6);
  34274. var coreChunkedStream = __w_pdfjs_require__(15);
  34275. var coreColorSpace = __w_pdfjs_require__(4);
  34276. var InvalidPDFException = sharedUtil.InvalidPDFException;
  34277. var MissingDataException = sharedUtil.MissingDataException;
  34278. var XRefParseException = sharedUtil.XRefParseException;
  34279. var assert = sharedUtil.assert;
  34280. var bytesToString = sharedUtil.bytesToString;
  34281. var createPromiseCapability = sharedUtil.createPromiseCapability;
  34282. var error = sharedUtil.error;
  34283. var info = sharedUtil.info;
  34284. var isArray = sharedUtil.isArray;
  34285. var isBool = sharedUtil.isBool;
  34286. var isInt = sharedUtil.isInt;
  34287. var isString = sharedUtil.isString;
  34288. var shadow = sharedUtil.shadow;
  34289. var stringToPDFString = sharedUtil.stringToPDFString;
  34290. var stringToUTF8String = sharedUtil.stringToUTF8String;
  34291. var warn = sharedUtil.warn;
  34292. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  34293. var Util = sharedUtil.Util;
  34294. var Ref = corePrimitives.Ref;
  34295. var RefSet = corePrimitives.RefSet;
  34296. var RefSetCache = corePrimitives.RefSetCache;
  34297. var isName = corePrimitives.isName;
  34298. var isCmd = corePrimitives.isCmd;
  34299. var isDict = corePrimitives.isDict;
  34300. var isRef = corePrimitives.isRef;
  34301. var isRefsEqual = corePrimitives.isRefsEqual;
  34302. var isStream = corePrimitives.isStream;
  34303. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  34304. var Lexer = coreParser.Lexer;
  34305. var Parser = coreParser.Parser;
  34306. var ChunkedStream = coreChunkedStream.ChunkedStream;
  34307. var ColorSpace = coreColorSpace.ColorSpace;
  34308. var Catalog = function CatalogClosure() {
  34309. function Catalog(pdfManager, xref, pageFactory) {
  34310. this.pdfManager = pdfManager;
  34311. this.xref = xref;
  34312. this.catDict = xref.getCatalogObj();
  34313. this.fontCache = new RefSetCache();
  34314. this.builtInCMapCache = Object.create(null);
  34315. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  34316. this.pageFactory = pageFactory;
  34317. this.pagePromises = [];
  34318. }
  34319. Catalog.prototype = {
  34320. get metadata() {
  34321. var streamRef = this.catDict.getRaw('Metadata');
  34322. if (!isRef(streamRef)) {
  34323. return shadow(this, 'metadata', null);
  34324. }
  34325. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  34326. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  34327. var metadata;
  34328. if (stream && isDict(stream.dict)) {
  34329. var type = stream.dict.get('Type');
  34330. var subtype = stream.dict.get('Subtype');
  34331. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  34332. try {
  34333. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  34334. } catch (e) {
  34335. info('Skipping invalid metadata.');
  34336. }
  34337. }
  34338. }
  34339. return shadow(this, 'metadata', metadata);
  34340. },
  34341. get toplevelPagesDict() {
  34342. var pagesObj = this.catDict.get('Pages');
  34343. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  34344. return shadow(this, 'toplevelPagesDict', pagesObj);
  34345. },
  34346. get documentOutline() {
  34347. var obj = null;
  34348. try {
  34349. obj = this.readDocumentOutline();
  34350. } catch (ex) {
  34351. if (ex instanceof MissingDataException) {
  34352. throw ex;
  34353. }
  34354. warn('Unable to read document outline');
  34355. }
  34356. return shadow(this, 'documentOutline', obj);
  34357. },
  34358. readDocumentOutline: function Catalog_readDocumentOutline() {
  34359. var obj = this.catDict.get('Outlines');
  34360. if (!isDict(obj)) {
  34361. return null;
  34362. }
  34363. obj = obj.getRaw('First');
  34364. if (!isRef(obj)) {
  34365. return null;
  34366. }
  34367. var root = { items: [] };
  34368. var queue = [{
  34369. obj: obj,
  34370. parent: root
  34371. }];
  34372. var processed = new RefSet();
  34373. processed.put(obj);
  34374. var xref = this.xref, blackColor = new Uint8Array(3);
  34375. while (queue.length > 0) {
  34376. var i = queue.shift();
  34377. var outlineDict = xref.fetchIfRef(i.obj);
  34378. if (outlineDict === null) {
  34379. continue;
  34380. }
  34381. assert(outlineDict.has('Title'), 'Invalid outline item');
  34382. var data = {
  34383. url: null,
  34384. dest: null
  34385. };
  34386. Catalog.parseDestDictionary({
  34387. destDict: outlineDict,
  34388. resultObj: data,
  34389. docBaseUrl: this.pdfManager.docBaseUrl
  34390. });
  34391. var title = outlineDict.get('Title');
  34392. var flags = outlineDict.get('F') || 0;
  34393. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  34394. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  34395. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  34396. }
  34397. var outlineItem = {
  34398. dest: data.dest,
  34399. url: data.url,
  34400. unsafeUrl: data.unsafeUrl,
  34401. newWindow: data.newWindow,
  34402. title: stringToPDFString(title),
  34403. color: rgbColor,
  34404. count: outlineDict.get('Count'),
  34405. bold: !!(flags & 2),
  34406. italic: !!(flags & 1),
  34407. items: []
  34408. };
  34409. i.parent.items.push(outlineItem);
  34410. obj = outlineDict.getRaw('First');
  34411. if (isRef(obj) && !processed.has(obj)) {
  34412. queue.push({
  34413. obj: obj,
  34414. parent: outlineItem
  34415. });
  34416. processed.put(obj);
  34417. }
  34418. obj = outlineDict.getRaw('Next');
  34419. if (isRef(obj) && !processed.has(obj)) {
  34420. queue.push({
  34421. obj: obj,
  34422. parent: i.parent
  34423. });
  34424. processed.put(obj);
  34425. }
  34426. }
  34427. return root.items.length > 0 ? root.items : null;
  34428. },
  34429. get numPages() {
  34430. var obj = this.toplevelPagesDict.get('Count');
  34431. assert(isInt(obj), 'page count in top level pages object is not an integer');
  34432. return shadow(this, 'num', obj);
  34433. },
  34434. get destinations() {
  34435. function fetchDestination(dest) {
  34436. return isDict(dest) ? dest.get('D') : dest;
  34437. }
  34438. var xref = this.xref;
  34439. var dests = {}, nameTreeRef, nameDictionaryRef;
  34440. var obj = this.catDict.get('Names');
  34441. if (obj && obj.has('Dests')) {
  34442. nameTreeRef = obj.getRaw('Dests');
  34443. } else if (this.catDict.has('Dests')) {
  34444. nameDictionaryRef = this.catDict.get('Dests');
  34445. }
  34446. if (nameDictionaryRef) {
  34447. obj = nameDictionaryRef;
  34448. obj.forEach(function catalogForEach(key, value) {
  34449. if (!value) {
  34450. return;
  34451. }
  34452. dests[key] = fetchDestination(value);
  34453. });
  34454. }
  34455. if (nameTreeRef) {
  34456. var nameTree = new NameTree(nameTreeRef, xref);
  34457. var names = nameTree.getAll();
  34458. for (var name in names) {
  34459. dests[name] = fetchDestination(names[name]);
  34460. }
  34461. }
  34462. return shadow(this, 'destinations', dests);
  34463. },
  34464. getDestination: function Catalog_getDestination(destinationId) {
  34465. function fetchDestination(dest) {
  34466. return isDict(dest) ? dest.get('D') : dest;
  34467. }
  34468. var xref = this.xref;
  34469. var dest = null, nameTreeRef, nameDictionaryRef;
  34470. var obj = this.catDict.get('Names');
  34471. if (obj && obj.has('Dests')) {
  34472. nameTreeRef = obj.getRaw('Dests');
  34473. } else if (this.catDict.has('Dests')) {
  34474. nameDictionaryRef = this.catDict.get('Dests');
  34475. }
  34476. if (nameDictionaryRef) {
  34477. var value = nameDictionaryRef.get(destinationId);
  34478. if (value) {
  34479. dest = fetchDestination(value);
  34480. }
  34481. }
  34482. if (nameTreeRef) {
  34483. var nameTree = new NameTree(nameTreeRef, xref);
  34484. dest = fetchDestination(nameTree.get(destinationId));
  34485. }
  34486. return dest;
  34487. },
  34488. get pageLabels() {
  34489. var obj = null;
  34490. try {
  34491. obj = this.readPageLabels();
  34492. } catch (ex) {
  34493. if (ex instanceof MissingDataException) {
  34494. throw ex;
  34495. }
  34496. warn('Unable to read page labels.');
  34497. }
  34498. return shadow(this, 'pageLabels', obj);
  34499. },
  34500. readPageLabels: function Catalog_readPageLabels() {
  34501. var obj = this.catDict.getRaw('PageLabels');
  34502. if (!obj) {
  34503. return null;
  34504. }
  34505. var pageLabels = new Array(this.numPages);
  34506. var style = null;
  34507. var prefix = '';
  34508. var numberTree = new NumberTree(obj, this.xref);
  34509. var nums = numberTree.getAll();
  34510. var currentLabel = '', currentIndex = 1;
  34511. for (var i = 0, ii = this.numPages; i < ii; i++) {
  34512. if (i in nums) {
  34513. var labelDict = nums[i];
  34514. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  34515. var type = labelDict.get('Type');
  34516. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  34517. var s = labelDict.get('S');
  34518. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  34519. style = s ? s.name : null;
  34520. var p = labelDict.get('P');
  34521. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  34522. prefix = p ? stringToPDFString(p) : '';
  34523. var st = labelDict.get('St');
  34524. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  34525. currentIndex = st || 1;
  34526. }
  34527. switch (style) {
  34528. case 'D':
  34529. currentLabel = currentIndex;
  34530. break;
  34531. case 'R':
  34532. case 'r':
  34533. currentLabel = Util.toRoman(currentIndex, style === 'r');
  34534. break;
  34535. case 'A':
  34536. case 'a':
  34537. var LIMIT = 26;
  34538. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  34539. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  34540. var letterIndex = currentIndex - 1;
  34541. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  34542. var charBuf = [];
  34543. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  34544. charBuf.push(character);
  34545. }
  34546. currentLabel = charBuf.join('');
  34547. break;
  34548. default:
  34549. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  34550. }
  34551. pageLabels[i] = prefix + currentLabel;
  34552. currentLabel = '';
  34553. currentIndex++;
  34554. }
  34555. return pageLabels;
  34556. },
  34557. get attachments() {
  34558. var xref = this.xref;
  34559. var attachments = null, nameTreeRef;
  34560. var obj = this.catDict.get('Names');
  34561. if (obj) {
  34562. nameTreeRef = obj.getRaw('EmbeddedFiles');
  34563. }
  34564. if (nameTreeRef) {
  34565. var nameTree = new NameTree(nameTreeRef, xref);
  34566. var names = nameTree.getAll();
  34567. for (var name in names) {
  34568. var fs = new FileSpec(names[name], xref);
  34569. if (!attachments) {
  34570. attachments = Object.create(null);
  34571. }
  34572. attachments[stringToPDFString(name)] = fs.serializable;
  34573. }
  34574. }
  34575. return shadow(this, 'attachments', attachments);
  34576. },
  34577. get javaScript() {
  34578. var xref = this.xref;
  34579. var obj = this.catDict.get('Names');
  34580. var javaScript = [];
  34581. function appendIfJavaScriptDict(jsDict) {
  34582. var type = jsDict.get('S');
  34583. if (!isName(type, 'JavaScript')) {
  34584. return;
  34585. }
  34586. var js = jsDict.get('JS');
  34587. if (isStream(js)) {
  34588. js = bytesToString(js.getBytes());
  34589. } else if (!isString(js)) {
  34590. return;
  34591. }
  34592. javaScript.push(stringToPDFString(js));
  34593. }
  34594. if (obj && obj.has('JavaScript')) {
  34595. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  34596. var names = nameTree.getAll();
  34597. for (var name in names) {
  34598. var jsDict = names[name];
  34599. if (isDict(jsDict)) {
  34600. appendIfJavaScriptDict(jsDict);
  34601. }
  34602. }
  34603. }
  34604. var openactionDict = this.catDict.get('OpenAction');
  34605. if (isDict(openactionDict, 'Action')) {
  34606. var actionType = openactionDict.get('S');
  34607. if (isName(actionType, 'Named')) {
  34608. var action = openactionDict.get('N');
  34609. if (isName(action, 'Print')) {
  34610. javaScript.push('print({});');
  34611. }
  34612. } else {
  34613. appendIfJavaScriptDict(openactionDict);
  34614. }
  34615. }
  34616. return shadow(this, 'javaScript', javaScript);
  34617. },
  34618. cleanup: function Catalog_cleanup() {
  34619. var promises = [];
  34620. this.fontCache.forEach(function (promise) {
  34621. promises.push(promise);
  34622. });
  34623. return Promise.all(promises).then(function (translatedFonts) {
  34624. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  34625. var font = translatedFonts[i].dict;
  34626. delete font.translated;
  34627. }
  34628. this.fontCache.clear();
  34629. this.builtInCMapCache = Object.create(null);
  34630. }.bind(this));
  34631. },
  34632. getPage: function Catalog_getPage(pageIndex) {
  34633. if (!(pageIndex in this.pagePromises)) {
  34634. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  34635. var dict = a[0];
  34636. var ref = a[1];
  34637. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache, this.builtInCMapCache);
  34638. }.bind(this));
  34639. }
  34640. return this.pagePromises[pageIndex];
  34641. },
  34642. getPageDict: function Catalog_getPageDict(pageIndex) {
  34643. var capability = createPromiseCapability();
  34644. var nodesToVisit = [this.catDict.getRaw('Pages')];
  34645. var currentPageIndex = 0;
  34646. var xref = this.xref;
  34647. var checkAllKids = false;
  34648. function next() {
  34649. while (nodesToVisit.length) {
  34650. var currentNode = nodesToVisit.pop();
  34651. if (isRef(currentNode)) {
  34652. xref.fetchAsync(currentNode).then(function (obj) {
  34653. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  34654. if (pageIndex === currentPageIndex) {
  34655. capability.resolve([
  34656. obj,
  34657. currentNode
  34658. ]);
  34659. } else {
  34660. currentPageIndex++;
  34661. next();
  34662. }
  34663. return;
  34664. }
  34665. nodesToVisit.push(obj);
  34666. next();
  34667. }, capability.reject);
  34668. return;
  34669. }
  34670. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  34671. var count = currentNode.get('Count');
  34672. if (count === 0) {
  34673. checkAllKids = true;
  34674. }
  34675. if (currentPageIndex + count <= pageIndex) {
  34676. currentPageIndex += count;
  34677. continue;
  34678. }
  34679. var kids = currentNode.get('Kids');
  34680. assert(isArray(kids), 'page dictionary kids object is not an array');
  34681. if (!checkAllKids && count === kids.length) {
  34682. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  34683. currentPageIndex = pageIndex;
  34684. continue;
  34685. } else {
  34686. for (var last = kids.length - 1; last >= 0; last--) {
  34687. nodesToVisit.push(kids[last]);
  34688. }
  34689. }
  34690. }
  34691. capability.reject('Page index ' + pageIndex + ' not found.');
  34692. }
  34693. next();
  34694. return capability.promise;
  34695. },
  34696. getPageIndex: function Catalog_getPageIndex(pageRef) {
  34697. var xref = this.xref;
  34698. function pagesBeforeRef(kidRef) {
  34699. var total = 0;
  34700. var parentRef;
  34701. return xref.fetchAsync(kidRef).then(function (node) {
  34702. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  34703. throw new Error('The reference does not point to a /Page Dict.');
  34704. }
  34705. if (!node) {
  34706. return null;
  34707. }
  34708. assert(isDict(node), 'node must be a Dict.');
  34709. parentRef = node.getRaw('Parent');
  34710. return node.getAsync('Parent');
  34711. }).then(function (parent) {
  34712. if (!parent) {
  34713. return null;
  34714. }
  34715. assert(isDict(parent), 'parent must be a Dict.');
  34716. return parent.getAsync('Kids');
  34717. }).then(function (kids) {
  34718. if (!kids) {
  34719. return null;
  34720. }
  34721. var kidPromises = [];
  34722. var found = false;
  34723. for (var i = 0; i < kids.length; i++) {
  34724. var kid = kids[i];
  34725. assert(isRef(kid), 'kid must be a Ref.');
  34726. if (kid.num === kidRef.num) {
  34727. found = true;
  34728. break;
  34729. }
  34730. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  34731. if (kid.has('Count')) {
  34732. var count = kid.get('Count');
  34733. total += count;
  34734. } else {
  34735. total++;
  34736. }
  34737. }));
  34738. }
  34739. if (!found) {
  34740. error('kid ref not found in parents kids');
  34741. }
  34742. return Promise.all(kidPromises).then(function () {
  34743. return [
  34744. total,
  34745. parentRef
  34746. ];
  34747. });
  34748. });
  34749. }
  34750. var total = 0;
  34751. function next(ref) {
  34752. return pagesBeforeRef(ref).then(function (args) {
  34753. if (!args) {
  34754. return total;
  34755. }
  34756. var count = args[0];
  34757. var parentRef = args[1];
  34758. total += count;
  34759. return next(parentRef);
  34760. });
  34761. }
  34762. return next(pageRef);
  34763. }
  34764. };
  34765. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  34766. function addDefaultProtocolToUrl(url) {
  34767. if (url.indexOf('www.') === 0) {
  34768. return 'http://' + url;
  34769. }
  34770. return url;
  34771. }
  34772. function tryConvertUrlEncoding(url) {
  34773. try {
  34774. return stringToUTF8String(url);
  34775. } catch (e) {
  34776. return url;
  34777. }
  34778. }
  34779. var destDict = params.destDict;
  34780. if (!isDict(destDict)) {
  34781. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  34782. return;
  34783. }
  34784. var resultObj = params.resultObj;
  34785. if (typeof resultObj !== 'object') {
  34786. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  34787. return;
  34788. }
  34789. var docBaseUrl = params.docBaseUrl || null;
  34790. var action = destDict.get('A'), url, dest;
  34791. if (isDict(action)) {
  34792. var linkType = action.get('S').name;
  34793. switch (linkType) {
  34794. case 'URI':
  34795. url = action.get('URI');
  34796. if (isName(url)) {
  34797. url = '/' + url.name;
  34798. } else if (isString(url)) {
  34799. url = addDefaultProtocolToUrl(url);
  34800. }
  34801. break;
  34802. case 'GoTo':
  34803. dest = action.get('D');
  34804. break;
  34805. case 'Launch':
  34806. case 'GoToR':
  34807. var urlDict = action.get('F');
  34808. if (isDict(urlDict)) {
  34809. url = urlDict.get('F') || null;
  34810. } else if (isString(urlDict)) {
  34811. url = urlDict;
  34812. }
  34813. var remoteDest = action.get('D');
  34814. if (remoteDest) {
  34815. if (isName(remoteDest)) {
  34816. remoteDest = remoteDest.name;
  34817. }
  34818. if (isString(url)) {
  34819. var baseUrl = url.split('#')[0];
  34820. if (isString(remoteDest)) {
  34821. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  34822. } else if (isArray(remoteDest)) {
  34823. url = baseUrl + '#' + JSON.stringify(remoteDest);
  34824. }
  34825. }
  34826. }
  34827. var newWindow = action.get('NewWindow');
  34828. if (isBool(newWindow)) {
  34829. resultObj.newWindow = newWindow;
  34830. }
  34831. break;
  34832. case 'Named':
  34833. var namedAction = action.get('N');
  34834. if (isName(namedAction)) {
  34835. resultObj.action = namedAction.name;
  34836. }
  34837. break;
  34838. case 'JavaScript':
  34839. var jsAction = action.get('JS'), js;
  34840. if (isStream(jsAction)) {
  34841. js = bytesToString(jsAction.getBytes());
  34842. } else if (isString(jsAction)) {
  34843. js = jsAction;
  34844. }
  34845. if (js) {
  34846. var URL_OPEN_METHODS = [
  34847. 'app.launchURL',
  34848. 'window.open'
  34849. ];
  34850. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  34851. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  34852. if (jsUrl && jsUrl[1]) {
  34853. url = jsUrl[1];
  34854. break;
  34855. }
  34856. }
  34857. default:
  34858. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  34859. break;
  34860. }
  34861. } else if (destDict.has('Dest')) {
  34862. dest = destDict.get('Dest');
  34863. }
  34864. if (isString(url)) {
  34865. url = tryConvertUrlEncoding(url);
  34866. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  34867. if (absoluteUrl) {
  34868. resultObj.url = absoluteUrl.href;
  34869. }
  34870. resultObj.unsafeUrl = url;
  34871. }
  34872. if (dest) {
  34873. if (isName(dest)) {
  34874. dest = dest.name;
  34875. }
  34876. if (isString(dest) || isArray(dest)) {
  34877. resultObj.dest = dest;
  34878. }
  34879. }
  34880. };
  34881. return Catalog;
  34882. }();
  34883. var XRef = function XRefClosure() {
  34884. function XRef(stream, pdfManager) {
  34885. this.stream = stream;
  34886. this.pdfManager = pdfManager;
  34887. this.entries = [];
  34888. this.xrefstms = Object.create(null);
  34889. this.cache = [];
  34890. this.stats = {
  34891. streamTypes: [],
  34892. fontTypes: []
  34893. };
  34894. }
  34895. XRef.prototype = {
  34896. setStartXRef: function XRef_setStartXRef(startXRef) {
  34897. this.startXRefQueue = [startXRef];
  34898. },
  34899. parse: function XRef_parse(recoveryMode) {
  34900. var trailerDict;
  34901. if (!recoveryMode) {
  34902. trailerDict = this.readXRef();
  34903. } else {
  34904. warn('Indexing all PDF objects');
  34905. trailerDict = this.indexObjects();
  34906. }
  34907. trailerDict.assignXref(this);
  34908. this.trailer = trailerDict;
  34909. var encrypt = trailerDict.get('Encrypt');
  34910. if (isDict(encrypt)) {
  34911. var ids = trailerDict.get('ID');
  34912. var fileId = ids && ids.length ? ids[0] : '';
  34913. encrypt.suppressEncryption = true;
  34914. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  34915. }
  34916. if (!(this.root = trailerDict.get('Root'))) {
  34917. error('Invalid root reference');
  34918. }
  34919. },
  34920. processXRefTable: function XRef_processXRefTable(parser) {
  34921. if (!('tableState' in this)) {
  34922. this.tableState = {
  34923. entryNum: 0,
  34924. streamPos: parser.lexer.stream.pos,
  34925. parserBuf1: parser.buf1,
  34926. parserBuf2: parser.buf2
  34927. };
  34928. }
  34929. var obj = this.readXRefTable(parser);
  34930. if (!isCmd(obj, 'trailer')) {
  34931. error('Invalid XRef table: could not find trailer dictionary');
  34932. }
  34933. var dict = parser.getObj();
  34934. if (!isDict(dict) && dict.dict) {
  34935. dict = dict.dict;
  34936. }
  34937. if (!isDict(dict)) {
  34938. error('Invalid XRef table: could not parse trailer dictionary');
  34939. }
  34940. delete this.tableState;
  34941. return dict;
  34942. },
  34943. readXRefTable: function XRef_readXRefTable(parser) {
  34944. var stream = parser.lexer.stream;
  34945. var tableState = this.tableState;
  34946. stream.pos = tableState.streamPos;
  34947. parser.buf1 = tableState.parserBuf1;
  34948. parser.buf2 = tableState.parserBuf2;
  34949. var obj;
  34950. while (true) {
  34951. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  34952. if (isCmd(obj = parser.getObj(), 'trailer')) {
  34953. break;
  34954. }
  34955. tableState.firstEntryNum = obj;
  34956. tableState.entryCount = parser.getObj();
  34957. }
  34958. var first = tableState.firstEntryNum;
  34959. var count = tableState.entryCount;
  34960. if (!isInt(first) || !isInt(count)) {
  34961. error('Invalid XRef table: wrong types in subsection header');
  34962. }
  34963. for (var i = tableState.entryNum; i < count; i++) {
  34964. tableState.streamPos = stream.pos;
  34965. tableState.entryNum = i;
  34966. tableState.parserBuf1 = parser.buf1;
  34967. tableState.parserBuf2 = parser.buf2;
  34968. var entry = {};
  34969. entry.offset = parser.getObj();
  34970. entry.gen = parser.getObj();
  34971. var type = parser.getObj();
  34972. if (isCmd(type, 'f')) {
  34973. entry.free = true;
  34974. } else if (isCmd(type, 'n')) {
  34975. entry.uncompressed = true;
  34976. }
  34977. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  34978. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  34979. }
  34980. if (i === 0 && entry.free && first === 1) {
  34981. first = 0;
  34982. }
  34983. if (!this.entries[i + first]) {
  34984. this.entries[i + first] = entry;
  34985. }
  34986. }
  34987. tableState.entryNum = 0;
  34988. tableState.streamPos = stream.pos;
  34989. tableState.parserBuf1 = parser.buf1;
  34990. tableState.parserBuf2 = parser.buf2;
  34991. delete tableState.firstEntryNum;
  34992. delete tableState.entryCount;
  34993. }
  34994. if (this.entries[0] && !this.entries[0].free) {
  34995. error('Invalid XRef table: unexpected first object');
  34996. }
  34997. return obj;
  34998. },
  34999. processXRefStream: function XRef_processXRefStream(stream) {
  35000. if (!('streamState' in this)) {
  35001. var streamParameters = stream.dict;
  35002. var byteWidths = streamParameters.get('W');
  35003. var range = streamParameters.get('Index');
  35004. if (!range) {
  35005. range = [
  35006. 0,
  35007. streamParameters.get('Size')
  35008. ];
  35009. }
  35010. this.streamState = {
  35011. entryRanges: range,
  35012. byteWidths: byteWidths,
  35013. entryNum: 0,
  35014. streamPos: stream.pos
  35015. };
  35016. }
  35017. this.readXRefStream(stream);
  35018. delete this.streamState;
  35019. return stream.dict;
  35020. },
  35021. readXRefStream: function XRef_readXRefStream(stream) {
  35022. var i, j;
  35023. var streamState = this.streamState;
  35024. stream.pos = streamState.streamPos;
  35025. var byteWidths = streamState.byteWidths;
  35026. var typeFieldWidth = byteWidths[0];
  35027. var offsetFieldWidth = byteWidths[1];
  35028. var generationFieldWidth = byteWidths[2];
  35029. var entryRanges = streamState.entryRanges;
  35030. while (entryRanges.length > 0) {
  35031. var first = entryRanges[0];
  35032. var n = entryRanges[1];
  35033. if (!isInt(first) || !isInt(n)) {
  35034. error('Invalid XRef range fields: ' + first + ', ' + n);
  35035. }
  35036. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  35037. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  35038. }
  35039. for (i = streamState.entryNum; i < n; ++i) {
  35040. streamState.entryNum = i;
  35041. streamState.streamPos = stream.pos;
  35042. var type = 0, offset = 0, generation = 0;
  35043. for (j = 0; j < typeFieldWidth; ++j) {
  35044. type = type << 8 | stream.getByte();
  35045. }
  35046. if (typeFieldWidth === 0) {
  35047. type = 1;
  35048. }
  35049. for (j = 0; j < offsetFieldWidth; ++j) {
  35050. offset = offset << 8 | stream.getByte();
  35051. }
  35052. for (j = 0; j < generationFieldWidth; ++j) {
  35053. generation = generation << 8 | stream.getByte();
  35054. }
  35055. var entry = {};
  35056. entry.offset = offset;
  35057. entry.gen = generation;
  35058. switch (type) {
  35059. case 0:
  35060. entry.free = true;
  35061. break;
  35062. case 1:
  35063. entry.uncompressed = true;
  35064. break;
  35065. case 2:
  35066. break;
  35067. default:
  35068. error('Invalid XRef entry type: ' + type);
  35069. }
  35070. if (!this.entries[first + i]) {
  35071. this.entries[first + i] = entry;
  35072. }
  35073. }
  35074. streamState.entryNum = 0;
  35075. streamState.streamPos = stream.pos;
  35076. entryRanges.splice(0, 2);
  35077. }
  35078. },
  35079. indexObjects: function XRef_indexObjects() {
  35080. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  35081. var PERCENT = 0x25, LT = 0x3C;
  35082. function readToken(data, offset) {
  35083. var token = '', ch = data[offset];
  35084. while (ch !== LF && ch !== CR && ch !== LT) {
  35085. if (++offset >= data.length) {
  35086. break;
  35087. }
  35088. token += String.fromCharCode(ch);
  35089. ch = data[offset];
  35090. }
  35091. return token;
  35092. }
  35093. function skipUntil(data, offset, what) {
  35094. var length = what.length, dataLength = data.length;
  35095. var skipped = 0;
  35096. while (offset < dataLength) {
  35097. var i = 0;
  35098. while (i < length && data[offset + i] === what[i]) {
  35099. ++i;
  35100. }
  35101. if (i >= length) {
  35102. break;
  35103. }
  35104. offset++;
  35105. skipped++;
  35106. }
  35107. return skipped;
  35108. }
  35109. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  35110. var trailerBytes = new Uint8Array([
  35111. 116,
  35112. 114,
  35113. 97,
  35114. 105,
  35115. 108,
  35116. 101,
  35117. 114
  35118. ]);
  35119. var startxrefBytes = new Uint8Array([
  35120. 115,
  35121. 116,
  35122. 97,
  35123. 114,
  35124. 116,
  35125. 120,
  35126. 114,
  35127. 101,
  35128. 102
  35129. ]);
  35130. var endobjBytes = new Uint8Array([
  35131. 101,
  35132. 110,
  35133. 100,
  35134. 111,
  35135. 98,
  35136. 106
  35137. ]);
  35138. var xrefBytes = new Uint8Array([
  35139. 47,
  35140. 88,
  35141. 82,
  35142. 101,
  35143. 102
  35144. ]);
  35145. this.entries.length = 0;
  35146. var stream = this.stream;
  35147. stream.pos = 0;
  35148. var buffer = stream.getBytes();
  35149. var position = stream.start, length = buffer.length;
  35150. var trailers = [], xrefStms = [];
  35151. while (position < length) {
  35152. var ch = buffer[position];
  35153. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  35154. ++position;
  35155. continue;
  35156. }
  35157. if (ch === PERCENT) {
  35158. do {
  35159. ++position;
  35160. if (position >= length) {
  35161. break;
  35162. }
  35163. ch = buffer[position];
  35164. } while (ch !== LF && ch !== CR);
  35165. continue;
  35166. }
  35167. var token = readToken(buffer, position);
  35168. var m;
  35169. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  35170. position += skipUntil(buffer, position, trailerBytes);
  35171. trailers.push(position);
  35172. position += skipUntil(buffer, position, startxrefBytes);
  35173. } else if (m = objRegExp.exec(token)) {
  35174. if (typeof this.entries[m[1]] === 'undefined') {
  35175. this.entries[m[1]] = {
  35176. offset: position - stream.start,
  35177. gen: m[2] | 0,
  35178. uncompressed: true
  35179. };
  35180. }
  35181. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  35182. var content = buffer.subarray(position, position + contentLength);
  35183. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  35184. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  35185. xrefStms.push(position - stream.start);
  35186. this.xrefstms[position - stream.start] = 1;
  35187. }
  35188. position += contentLength;
  35189. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  35190. trailers.push(position);
  35191. position += skipUntil(buffer, position, startxrefBytes);
  35192. } else {
  35193. position += token.length + 1;
  35194. }
  35195. }
  35196. var i, ii;
  35197. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  35198. this.startXRefQueue.push(xrefStms[i]);
  35199. this.readXRef(true);
  35200. }
  35201. var dict;
  35202. for (i = 0, ii = trailers.length; i < ii; ++i) {
  35203. stream.pos = trailers[i];
  35204. var parser = new Parser(new Lexer(stream), true, this, true);
  35205. var obj = parser.getObj();
  35206. if (!isCmd(obj, 'trailer')) {
  35207. continue;
  35208. }
  35209. dict = parser.getObj();
  35210. if (!isDict(dict)) {
  35211. continue;
  35212. }
  35213. if (dict.has('ID')) {
  35214. return dict;
  35215. }
  35216. }
  35217. if (dict) {
  35218. return dict;
  35219. }
  35220. throw new InvalidPDFException('Invalid PDF structure');
  35221. },
  35222. readXRef: function XRef_readXRef(recoveryMode) {
  35223. var stream = this.stream;
  35224. try {
  35225. while (this.startXRefQueue.length) {
  35226. var startXRef = this.startXRefQueue[0];
  35227. stream.pos = startXRef + stream.start;
  35228. var parser = new Parser(new Lexer(stream), true, this);
  35229. var obj = parser.getObj();
  35230. var dict;
  35231. if (isCmd(obj, 'xref')) {
  35232. dict = this.processXRefTable(parser);
  35233. if (!this.topDict) {
  35234. this.topDict = dict;
  35235. }
  35236. obj = dict.get('XRefStm');
  35237. if (isInt(obj)) {
  35238. var pos = obj;
  35239. if (!(pos in this.xrefstms)) {
  35240. this.xrefstms[pos] = 1;
  35241. this.startXRefQueue.push(pos);
  35242. }
  35243. }
  35244. } else if (isInt(obj)) {
  35245. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  35246. error('Invalid XRef stream');
  35247. }
  35248. dict = this.processXRefStream(obj);
  35249. if (!this.topDict) {
  35250. this.topDict = dict;
  35251. }
  35252. if (!dict) {
  35253. error('Failed to read XRef stream');
  35254. }
  35255. } else {
  35256. error('Invalid XRef stream header');
  35257. }
  35258. obj = dict.get('Prev');
  35259. if (isInt(obj)) {
  35260. this.startXRefQueue.push(obj);
  35261. } else if (isRef(obj)) {
  35262. this.startXRefQueue.push(obj.num);
  35263. }
  35264. this.startXRefQueue.shift();
  35265. }
  35266. return this.topDict;
  35267. } catch (e) {
  35268. if (e instanceof MissingDataException) {
  35269. throw e;
  35270. }
  35271. info('(while reading XRef): ' + e);
  35272. }
  35273. if (recoveryMode) {
  35274. return;
  35275. }
  35276. throw new XRefParseException();
  35277. },
  35278. getEntry: function XRef_getEntry(i) {
  35279. var xrefEntry = this.entries[i];
  35280. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  35281. return xrefEntry;
  35282. }
  35283. return null;
  35284. },
  35285. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  35286. if (!isRef(obj)) {
  35287. return obj;
  35288. }
  35289. return this.fetch(obj, suppressEncryption);
  35290. },
  35291. fetch: function XRef_fetch(ref, suppressEncryption) {
  35292. assert(isRef(ref), 'ref object is not a reference');
  35293. var num = ref.num;
  35294. if (num in this.cache) {
  35295. var cacheEntry = this.cache[num];
  35296. return cacheEntry;
  35297. }
  35298. var xrefEntry = this.getEntry(num);
  35299. if (xrefEntry === null) {
  35300. return this.cache[num] = null;
  35301. }
  35302. if (xrefEntry.uncompressed) {
  35303. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  35304. } else {
  35305. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  35306. }
  35307. if (isDict(xrefEntry)) {
  35308. xrefEntry.objId = ref.toString();
  35309. } else if (isStream(xrefEntry)) {
  35310. xrefEntry.dict.objId = ref.toString();
  35311. }
  35312. return xrefEntry;
  35313. },
  35314. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  35315. var gen = ref.gen;
  35316. var num = ref.num;
  35317. if (xrefEntry.gen !== gen) {
  35318. error('inconsistent generation in XRef');
  35319. }
  35320. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  35321. var parser = new Parser(new Lexer(stream), true, this);
  35322. var obj1 = parser.getObj();
  35323. var obj2 = parser.getObj();
  35324. var obj3 = parser.getObj();
  35325. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  35326. error('bad XRef entry');
  35327. }
  35328. if (!isCmd(obj3, 'obj')) {
  35329. if (obj3.cmd.indexOf('obj') === 0) {
  35330. num = parseInt(obj3.cmd.substring(3), 10);
  35331. if (!isNaN(num)) {
  35332. return num;
  35333. }
  35334. }
  35335. error('bad XRef entry');
  35336. }
  35337. if (this.encrypt && !suppressEncryption) {
  35338. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  35339. } else {
  35340. xrefEntry = parser.getObj();
  35341. }
  35342. if (!isStream(xrefEntry)) {
  35343. this.cache[num] = xrefEntry;
  35344. }
  35345. return xrefEntry;
  35346. },
  35347. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  35348. var tableOffset = xrefEntry.offset;
  35349. var stream = this.fetch(new Ref(tableOffset, 0));
  35350. if (!isStream(stream)) {
  35351. error('bad ObjStm stream');
  35352. }
  35353. var first = stream.dict.get('First');
  35354. var n = stream.dict.get('N');
  35355. if (!isInt(first) || !isInt(n)) {
  35356. error('invalid first and n parameters for ObjStm stream');
  35357. }
  35358. var parser = new Parser(new Lexer(stream), false, this);
  35359. parser.allowStreams = true;
  35360. var i, entries = [], num, nums = [];
  35361. for (i = 0; i < n; ++i) {
  35362. num = parser.getObj();
  35363. if (!isInt(num)) {
  35364. error('invalid object number in the ObjStm stream: ' + num);
  35365. }
  35366. nums.push(num);
  35367. var offset = parser.getObj();
  35368. if (!isInt(offset)) {
  35369. error('invalid object offset in the ObjStm stream: ' + offset);
  35370. }
  35371. }
  35372. for (i = 0; i < n; ++i) {
  35373. entries.push(parser.getObj());
  35374. if (isCmd(parser.buf1, 'endobj')) {
  35375. parser.shift();
  35376. }
  35377. num = nums[i];
  35378. var entry = this.entries[num];
  35379. if (entry && entry.offset === tableOffset && entry.gen === i) {
  35380. this.cache[num] = entries[i];
  35381. }
  35382. }
  35383. xrefEntry = entries[xrefEntry.gen];
  35384. if (xrefEntry === undefined) {
  35385. error('bad XRef entry for compressed object');
  35386. }
  35387. return xrefEntry;
  35388. },
  35389. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  35390. if (!isRef(obj)) {
  35391. return Promise.resolve(obj);
  35392. }
  35393. return this.fetchAsync(obj, suppressEncryption);
  35394. },
  35395. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  35396. var streamManager = this.stream.manager;
  35397. var xref = this;
  35398. return new Promise(function tryFetch(resolve, reject) {
  35399. try {
  35400. resolve(xref.fetch(ref, suppressEncryption));
  35401. } catch (e) {
  35402. if (e instanceof MissingDataException) {
  35403. streamManager.requestRange(e.begin, e.end).then(function () {
  35404. tryFetch(resolve, reject);
  35405. }, reject);
  35406. return;
  35407. }
  35408. reject(e);
  35409. }
  35410. });
  35411. },
  35412. getCatalogObj: function XRef_getCatalogObj() {
  35413. return this.root;
  35414. }
  35415. };
  35416. return XRef;
  35417. }();
  35418. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  35419. function NameOrNumberTree(root, xref) {
  35420. throw new Error('Cannot initialize NameOrNumberTree.');
  35421. }
  35422. NameOrNumberTree.prototype = {
  35423. getAll: function NameOrNumberTree_getAll() {
  35424. var dict = Object.create(null);
  35425. if (!this.root) {
  35426. return dict;
  35427. }
  35428. var xref = this.xref;
  35429. var processed = new RefSet();
  35430. processed.put(this.root);
  35431. var queue = [this.root];
  35432. while (queue.length > 0) {
  35433. var i, n;
  35434. var obj = xref.fetchIfRef(queue.shift());
  35435. if (!isDict(obj)) {
  35436. continue;
  35437. }
  35438. if (obj.has('Kids')) {
  35439. var kids = obj.get('Kids');
  35440. for (i = 0, n = kids.length; i < n; i++) {
  35441. var kid = kids[i];
  35442. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  35443. queue.push(kid);
  35444. processed.put(kid);
  35445. }
  35446. continue;
  35447. }
  35448. var entries = obj.get(this._type);
  35449. if (isArray(entries)) {
  35450. for (i = 0, n = entries.length; i < n; i += 2) {
  35451. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  35452. }
  35453. }
  35454. }
  35455. return dict;
  35456. },
  35457. get: function NameOrNumberTree_get(key) {
  35458. if (!this.root) {
  35459. return null;
  35460. }
  35461. var xref = this.xref;
  35462. var kidsOrEntries = xref.fetchIfRef(this.root);
  35463. var loopCount = 0;
  35464. var MAX_LEVELS = 10;
  35465. var l, r, m;
  35466. while (kidsOrEntries.has('Kids')) {
  35467. if (++loopCount > MAX_LEVELS) {
  35468. warn('Search depth limit reached for "' + this._type + '" tree.');
  35469. return null;
  35470. }
  35471. var kids = kidsOrEntries.get('Kids');
  35472. if (!isArray(kids)) {
  35473. return null;
  35474. }
  35475. l = 0;
  35476. r = kids.length - 1;
  35477. while (l <= r) {
  35478. m = l + r >> 1;
  35479. var kid = xref.fetchIfRef(kids[m]);
  35480. var limits = kid.get('Limits');
  35481. if (key < xref.fetchIfRef(limits[0])) {
  35482. r = m - 1;
  35483. } else if (key > xref.fetchIfRef(limits[1])) {
  35484. l = m + 1;
  35485. } else {
  35486. kidsOrEntries = xref.fetchIfRef(kids[m]);
  35487. break;
  35488. }
  35489. }
  35490. if (l > r) {
  35491. return null;
  35492. }
  35493. }
  35494. var entries = kidsOrEntries.get(this._type);
  35495. if (isArray(entries)) {
  35496. l = 0;
  35497. r = entries.length - 2;
  35498. while (l <= r) {
  35499. m = l + r & ~1;
  35500. var currentKey = xref.fetchIfRef(entries[m]);
  35501. if (key < currentKey) {
  35502. r = m - 2;
  35503. } else if (key > currentKey) {
  35504. l = m + 2;
  35505. } else {
  35506. return xref.fetchIfRef(entries[m + 1]);
  35507. }
  35508. }
  35509. }
  35510. return null;
  35511. }
  35512. };
  35513. return NameOrNumberTree;
  35514. }();
  35515. var NameTree = function NameTreeClosure() {
  35516. function NameTree(root, xref) {
  35517. this.root = root;
  35518. this.xref = xref;
  35519. this._type = 'Names';
  35520. }
  35521. Util.inherit(NameTree, NameOrNumberTree, {});
  35522. return NameTree;
  35523. }();
  35524. var NumberTree = function NumberTreeClosure() {
  35525. function NumberTree(root, xref) {
  35526. this.root = root;
  35527. this.xref = xref;
  35528. this._type = 'Nums';
  35529. }
  35530. Util.inherit(NumberTree, NameOrNumberTree, {});
  35531. return NumberTree;
  35532. }();
  35533. var FileSpec = function FileSpecClosure() {
  35534. function FileSpec(root, xref) {
  35535. if (!root || !isDict(root)) {
  35536. return;
  35537. }
  35538. this.xref = xref;
  35539. this.root = root;
  35540. if (root.has('FS')) {
  35541. this.fs = root.get('FS');
  35542. }
  35543. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  35544. if (root.has('RF')) {
  35545. warn('Related file specifications are not supported');
  35546. }
  35547. this.contentAvailable = true;
  35548. if (!root.has('EF')) {
  35549. this.contentAvailable = false;
  35550. warn('Non-embedded file specifications are not supported');
  35551. }
  35552. }
  35553. function pickPlatformItem(dict) {
  35554. if (dict.has('UF')) {
  35555. return dict.get('UF');
  35556. } else if (dict.has('F')) {
  35557. return dict.get('F');
  35558. } else if (dict.has('Unix')) {
  35559. return dict.get('Unix');
  35560. } else if (dict.has('Mac')) {
  35561. return dict.get('Mac');
  35562. } else if (dict.has('DOS')) {
  35563. return dict.get('DOS');
  35564. }
  35565. return null;
  35566. }
  35567. FileSpec.prototype = {
  35568. get filename() {
  35569. if (!this._filename && this.root) {
  35570. var filename = pickPlatformItem(this.root) || 'unnamed';
  35571. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  35572. }
  35573. return this._filename;
  35574. },
  35575. get content() {
  35576. if (!this.contentAvailable) {
  35577. return null;
  35578. }
  35579. if (!this.contentRef && this.root) {
  35580. this.contentRef = pickPlatformItem(this.root.get('EF'));
  35581. }
  35582. var content = null;
  35583. if (this.contentRef) {
  35584. var xref = this.xref;
  35585. var fileObj = xref.fetchIfRef(this.contentRef);
  35586. if (fileObj && isStream(fileObj)) {
  35587. content = fileObj.getBytes();
  35588. } else {
  35589. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  35590. }
  35591. } else {
  35592. warn('Embedded file specification does not have a content');
  35593. }
  35594. return content;
  35595. },
  35596. get serializable() {
  35597. return {
  35598. filename: this.filename,
  35599. content: this.content
  35600. };
  35601. }
  35602. };
  35603. return FileSpec;
  35604. }();
  35605. var ObjectLoader = function () {
  35606. function mayHaveChildren(value) {
  35607. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  35608. }
  35609. function addChildren(node, nodesToVisit) {
  35610. var value;
  35611. if (isDict(node) || isStream(node)) {
  35612. var map;
  35613. if (isDict(node)) {
  35614. map = node.map;
  35615. } else {
  35616. map = node.dict.map;
  35617. }
  35618. for (var key in map) {
  35619. value = map[key];
  35620. if (mayHaveChildren(value)) {
  35621. nodesToVisit.push(value);
  35622. }
  35623. }
  35624. } else if (isArray(node)) {
  35625. for (var i = 0, ii = node.length; i < ii; i++) {
  35626. value = node[i];
  35627. if (mayHaveChildren(value)) {
  35628. nodesToVisit.push(value);
  35629. }
  35630. }
  35631. }
  35632. }
  35633. function ObjectLoader(obj, keys, xref) {
  35634. this.obj = obj;
  35635. this.keys = keys;
  35636. this.xref = xref;
  35637. this.refSet = null;
  35638. this.capability = null;
  35639. }
  35640. ObjectLoader.prototype = {
  35641. load: function ObjectLoader_load() {
  35642. var keys = this.keys;
  35643. this.capability = createPromiseCapability();
  35644. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  35645. this.capability.resolve();
  35646. return this.capability.promise;
  35647. }
  35648. this.refSet = new RefSet();
  35649. var nodesToVisit = [];
  35650. for (var i = 0; i < keys.length; i++) {
  35651. nodesToVisit.push(this.obj[keys[i]]);
  35652. }
  35653. this._walk(nodesToVisit);
  35654. return this.capability.promise;
  35655. },
  35656. _walk: function ObjectLoader_walk(nodesToVisit) {
  35657. var nodesToRevisit = [];
  35658. var pendingRequests = [];
  35659. while (nodesToVisit.length) {
  35660. var currentNode = nodesToVisit.pop();
  35661. if (isRef(currentNode)) {
  35662. if (this.refSet.has(currentNode)) {
  35663. continue;
  35664. }
  35665. try {
  35666. var ref = currentNode;
  35667. this.refSet.put(ref);
  35668. currentNode = this.xref.fetch(currentNode);
  35669. } catch (e) {
  35670. if (!(e instanceof MissingDataException)) {
  35671. throw e;
  35672. }
  35673. nodesToRevisit.push(currentNode);
  35674. pendingRequests.push({
  35675. begin: e.begin,
  35676. end: e.end
  35677. });
  35678. }
  35679. }
  35680. if (currentNode && currentNode.getBaseStreams) {
  35681. var baseStreams = currentNode.getBaseStreams();
  35682. var foundMissingData = false;
  35683. for (var i = 0; i < baseStreams.length; i++) {
  35684. var stream = baseStreams[i];
  35685. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  35686. foundMissingData = true;
  35687. pendingRequests.push({
  35688. begin: stream.start,
  35689. end: stream.end
  35690. });
  35691. }
  35692. }
  35693. if (foundMissingData) {
  35694. nodesToRevisit.push(currentNode);
  35695. }
  35696. }
  35697. addChildren(currentNode, nodesToVisit);
  35698. }
  35699. if (pendingRequests.length) {
  35700. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  35701. nodesToVisit = nodesToRevisit;
  35702. for (var i = 0; i < nodesToRevisit.length; i++) {
  35703. var node = nodesToRevisit[i];
  35704. if (isRef(node)) {
  35705. this.refSet.remove(node);
  35706. }
  35707. }
  35708. this._walk(nodesToVisit);
  35709. }.bind(this), this.capability.reject);
  35710. return;
  35711. }
  35712. this.refSet = null;
  35713. this.capability.resolve();
  35714. }
  35715. };
  35716. return ObjectLoader;
  35717. }();
  35718. exports.Catalog = Catalog;
  35719. exports.ObjectLoader = ObjectLoader;
  35720. exports.XRef = XRef;
  35721. exports.FileSpec = FileSpec;
  35722. /***/ }),
  35723. /* 20 */
  35724. /***/ (function(module, exports, __w_pdfjs_require__) {
  35725. "use strict";
  35726. var sharedUtil = __w_pdfjs_require__(0);
  35727. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  35728. var getStdFontMap = getLookupTableFactory(function (t) {
  35729. t['ArialNarrow'] = 'Helvetica';
  35730. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  35731. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  35732. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  35733. t['ArialBlack'] = 'Helvetica';
  35734. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  35735. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  35736. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  35737. t['Arial-Black'] = 'Helvetica';
  35738. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  35739. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  35740. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  35741. t['Arial'] = 'Helvetica';
  35742. t['Arial-Bold'] = 'Helvetica-Bold';
  35743. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  35744. t['Arial-Italic'] = 'Helvetica-Oblique';
  35745. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  35746. t['Arial-BoldMT'] = 'Helvetica-Bold';
  35747. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  35748. t['ArialMT'] = 'Helvetica';
  35749. t['Courier-Bold'] = 'Courier-Bold';
  35750. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  35751. t['Courier-Italic'] = 'Courier-Oblique';
  35752. t['CourierNew'] = 'Courier';
  35753. t['CourierNew-Bold'] = 'Courier-Bold';
  35754. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  35755. t['CourierNew-Italic'] = 'Courier-Oblique';
  35756. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  35757. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  35758. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  35759. t['CourierNewPSMT'] = 'Courier';
  35760. t['Helvetica'] = 'Helvetica';
  35761. t['Helvetica-Bold'] = 'Helvetica-Bold';
  35762. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  35763. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  35764. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  35765. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  35766. t['Symbol-Bold'] = 'Symbol';
  35767. t['Symbol-BoldItalic'] = 'Symbol';
  35768. t['Symbol-Italic'] = 'Symbol';
  35769. t['TimesNewRoman'] = 'Times-Roman';
  35770. t['TimesNewRoman-Bold'] = 'Times-Bold';
  35771. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  35772. t['TimesNewRoman-Italic'] = 'Times-Italic';
  35773. t['TimesNewRomanPS'] = 'Times-Roman';
  35774. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  35775. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  35776. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  35777. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  35778. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  35779. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  35780. t['TimesNewRomanPSMT'] = 'Times-Roman';
  35781. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  35782. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  35783. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  35784. });
  35785. var getNonStdFontMap = getLookupTableFactory(function (t) {
  35786. t['CenturyGothic'] = 'Helvetica';
  35787. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  35788. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  35789. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  35790. t['ComicSansMS'] = 'Comic Sans MS';
  35791. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  35792. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  35793. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  35794. t['LucidaConsole'] = 'Courier';
  35795. t['LucidaConsole-Bold'] = 'Courier-Bold';
  35796. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  35797. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  35798. t['MS-Gothic'] = 'MS Gothic';
  35799. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  35800. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  35801. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  35802. t['MS-Mincho'] = 'MS Mincho';
  35803. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  35804. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  35805. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  35806. t['MS-PGothic'] = 'MS PGothic';
  35807. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  35808. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  35809. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  35810. t['MS-PMincho'] = 'MS PMincho';
  35811. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  35812. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  35813. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  35814. t['NuptialScript'] = 'Times-Italic';
  35815. t['Wingdings'] = 'ZapfDingbats';
  35816. });
  35817. var getSerifFonts = getLookupTableFactory(function (t) {
  35818. t['Adobe Jenson'] = true;
  35819. t['Adobe Text'] = true;
  35820. t['Albertus'] = true;
  35821. t['Aldus'] = true;
  35822. t['Alexandria'] = true;
  35823. t['Algerian'] = true;
  35824. t['American Typewriter'] = true;
  35825. t['Antiqua'] = true;
  35826. t['Apex'] = true;
  35827. t['Arno'] = true;
  35828. t['Aster'] = true;
  35829. t['Aurora'] = true;
  35830. t['Baskerville'] = true;
  35831. t['Bell'] = true;
  35832. t['Bembo'] = true;
  35833. t['Bembo Schoolbook'] = true;
  35834. t['Benguiat'] = true;
  35835. t['Berkeley Old Style'] = true;
  35836. t['Bernhard Modern'] = true;
  35837. t['Berthold City'] = true;
  35838. t['Bodoni'] = true;
  35839. t['Bauer Bodoni'] = true;
  35840. t['Book Antiqua'] = true;
  35841. t['Bookman'] = true;
  35842. t['Bordeaux Roman'] = true;
  35843. t['Californian FB'] = true;
  35844. t['Calisto'] = true;
  35845. t['Calvert'] = true;
  35846. t['Capitals'] = true;
  35847. t['Cambria'] = true;
  35848. t['Cartier'] = true;
  35849. t['Caslon'] = true;
  35850. t['Catull'] = true;
  35851. t['Centaur'] = true;
  35852. t['Century Old Style'] = true;
  35853. t['Century Schoolbook'] = true;
  35854. t['Chaparral'] = true;
  35855. t['Charis SIL'] = true;
  35856. t['Cheltenham'] = true;
  35857. t['Cholla Slab'] = true;
  35858. t['Clarendon'] = true;
  35859. t['Clearface'] = true;
  35860. t['Cochin'] = true;
  35861. t['Colonna'] = true;
  35862. t['Computer Modern'] = true;
  35863. t['Concrete Roman'] = true;
  35864. t['Constantia'] = true;
  35865. t['Cooper Black'] = true;
  35866. t['Corona'] = true;
  35867. t['Ecotype'] = true;
  35868. t['Egyptienne'] = true;
  35869. t['Elephant'] = true;
  35870. t['Excelsior'] = true;
  35871. t['Fairfield'] = true;
  35872. t['FF Scala'] = true;
  35873. t['Folkard'] = true;
  35874. t['Footlight'] = true;
  35875. t['FreeSerif'] = true;
  35876. t['Friz Quadrata'] = true;
  35877. t['Garamond'] = true;
  35878. t['Gentium'] = true;
  35879. t['Georgia'] = true;
  35880. t['Gloucester'] = true;
  35881. t['Goudy Old Style'] = true;
  35882. t['Goudy Schoolbook'] = true;
  35883. t['Goudy Pro Font'] = true;
  35884. t['Granjon'] = true;
  35885. t['Guardian Egyptian'] = true;
  35886. t['Heather'] = true;
  35887. t['Hercules'] = true;
  35888. t['High Tower Text'] = true;
  35889. t['Hiroshige'] = true;
  35890. t['Hoefler Text'] = true;
  35891. t['Humana Serif'] = true;
  35892. t['Imprint'] = true;
  35893. t['Ionic No. 5'] = true;
  35894. t['Janson'] = true;
  35895. t['Joanna'] = true;
  35896. t['Korinna'] = true;
  35897. t['Lexicon'] = true;
  35898. t['Liberation Serif'] = true;
  35899. t['Linux Libertine'] = true;
  35900. t['Literaturnaya'] = true;
  35901. t['Lucida'] = true;
  35902. t['Lucida Bright'] = true;
  35903. t['Melior'] = true;
  35904. t['Memphis'] = true;
  35905. t['Miller'] = true;
  35906. t['Minion'] = true;
  35907. t['Modern'] = true;
  35908. t['Mona Lisa'] = true;
  35909. t['Mrs Eaves'] = true;
  35910. t['MS Serif'] = true;
  35911. t['Museo Slab'] = true;
  35912. t['New York'] = true;
  35913. t['Nimbus Roman'] = true;
  35914. t['NPS Rawlinson Roadway'] = true;
  35915. t['NuptialScript'] = true;
  35916. t['Palatino'] = true;
  35917. t['Perpetua'] = true;
  35918. t['Plantin'] = true;
  35919. t['Plantin Schoolbook'] = true;
  35920. t['Playbill'] = true;
  35921. t['Poor Richard'] = true;
  35922. t['Rawlinson Roadway'] = true;
  35923. t['Renault'] = true;
  35924. t['Requiem'] = true;
  35925. t['Rockwell'] = true;
  35926. t['Roman'] = true;
  35927. t['Rotis Serif'] = true;
  35928. t['Sabon'] = true;
  35929. t['Scala'] = true;
  35930. t['Seagull'] = true;
  35931. t['Sistina'] = true;
  35932. t['Souvenir'] = true;
  35933. t['STIX'] = true;
  35934. t['Stone Informal'] = true;
  35935. t['Stone Serif'] = true;
  35936. t['Sylfaen'] = true;
  35937. t['Times'] = true;
  35938. t['Trajan'] = true;
  35939. t['Trinité'] = true;
  35940. t['Trump Mediaeval'] = true;
  35941. t['Utopia'] = true;
  35942. t['Vale Type'] = true;
  35943. t['Bitstream Vera'] = true;
  35944. t['Vera Serif'] = true;
  35945. t['Versailles'] = true;
  35946. t['Wanted'] = true;
  35947. t['Weiss'] = true;
  35948. t['Wide Latin'] = true;
  35949. t['Windsor'] = true;
  35950. t['XITS'] = true;
  35951. });
  35952. var getSymbolsFonts = getLookupTableFactory(function (t) {
  35953. t['Dingbats'] = true;
  35954. t['Symbol'] = true;
  35955. t['ZapfDingbats'] = true;
  35956. });
  35957. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  35958. t[2] = 10;
  35959. t[3] = 32;
  35960. t[4] = 33;
  35961. t[5] = 34;
  35962. t[6] = 35;
  35963. t[7] = 36;
  35964. t[8] = 37;
  35965. t[9] = 38;
  35966. t[10] = 39;
  35967. t[11] = 40;
  35968. t[12] = 41;
  35969. t[13] = 42;
  35970. t[14] = 43;
  35971. t[15] = 44;
  35972. t[16] = 45;
  35973. t[17] = 46;
  35974. t[18] = 47;
  35975. t[19] = 48;
  35976. t[20] = 49;
  35977. t[21] = 50;
  35978. t[22] = 51;
  35979. t[23] = 52;
  35980. t[24] = 53;
  35981. t[25] = 54;
  35982. t[26] = 55;
  35983. t[27] = 56;
  35984. t[28] = 57;
  35985. t[29] = 58;
  35986. t[30] = 894;
  35987. t[31] = 60;
  35988. t[32] = 61;
  35989. t[33] = 62;
  35990. t[34] = 63;
  35991. t[35] = 64;
  35992. t[36] = 65;
  35993. t[37] = 66;
  35994. t[38] = 67;
  35995. t[39] = 68;
  35996. t[40] = 69;
  35997. t[41] = 70;
  35998. t[42] = 71;
  35999. t[43] = 72;
  36000. t[44] = 73;
  36001. t[45] = 74;
  36002. t[46] = 75;
  36003. t[47] = 76;
  36004. t[48] = 77;
  36005. t[49] = 78;
  36006. t[50] = 79;
  36007. t[51] = 80;
  36008. t[52] = 81;
  36009. t[53] = 82;
  36010. t[54] = 83;
  36011. t[55] = 84;
  36012. t[56] = 85;
  36013. t[57] = 86;
  36014. t[58] = 87;
  36015. t[59] = 88;
  36016. t[60] = 89;
  36017. t[61] = 90;
  36018. t[62] = 91;
  36019. t[63] = 92;
  36020. t[64] = 93;
  36021. t[65] = 94;
  36022. t[66] = 95;
  36023. t[67] = 96;
  36024. t[68] = 97;
  36025. t[69] = 98;
  36026. t[70] = 99;
  36027. t[71] = 100;
  36028. t[72] = 101;
  36029. t[73] = 102;
  36030. t[74] = 103;
  36031. t[75] = 104;
  36032. t[76] = 105;
  36033. t[77] = 106;
  36034. t[78] = 107;
  36035. t[79] = 108;
  36036. t[80] = 109;
  36037. t[81] = 110;
  36038. t[82] = 111;
  36039. t[83] = 112;
  36040. t[84] = 113;
  36041. t[85] = 114;
  36042. t[86] = 115;
  36043. t[87] = 116;
  36044. t[88] = 117;
  36045. t[89] = 118;
  36046. t[90] = 119;
  36047. t[91] = 120;
  36048. t[92] = 121;
  36049. t[93] = 122;
  36050. t[94] = 123;
  36051. t[95] = 124;
  36052. t[96] = 125;
  36053. t[97] = 126;
  36054. t[98] = 196;
  36055. t[99] = 197;
  36056. t[100] = 199;
  36057. t[101] = 201;
  36058. t[102] = 209;
  36059. t[103] = 214;
  36060. t[104] = 220;
  36061. t[105] = 225;
  36062. t[106] = 224;
  36063. t[107] = 226;
  36064. t[108] = 228;
  36065. t[109] = 227;
  36066. t[110] = 229;
  36067. t[111] = 231;
  36068. t[112] = 233;
  36069. t[113] = 232;
  36070. t[114] = 234;
  36071. t[115] = 235;
  36072. t[116] = 237;
  36073. t[117] = 236;
  36074. t[118] = 238;
  36075. t[119] = 239;
  36076. t[120] = 241;
  36077. t[121] = 243;
  36078. t[122] = 242;
  36079. t[123] = 244;
  36080. t[124] = 246;
  36081. t[125] = 245;
  36082. t[126] = 250;
  36083. t[127] = 249;
  36084. t[128] = 251;
  36085. t[129] = 252;
  36086. t[130] = 8224;
  36087. t[131] = 176;
  36088. t[132] = 162;
  36089. t[133] = 163;
  36090. t[134] = 167;
  36091. t[135] = 8226;
  36092. t[136] = 182;
  36093. t[137] = 223;
  36094. t[138] = 174;
  36095. t[139] = 169;
  36096. t[140] = 8482;
  36097. t[141] = 180;
  36098. t[142] = 168;
  36099. t[143] = 8800;
  36100. t[144] = 198;
  36101. t[145] = 216;
  36102. t[146] = 8734;
  36103. t[147] = 177;
  36104. t[148] = 8804;
  36105. t[149] = 8805;
  36106. t[150] = 165;
  36107. t[151] = 181;
  36108. t[152] = 8706;
  36109. t[153] = 8721;
  36110. t[154] = 8719;
  36111. t[156] = 8747;
  36112. t[157] = 170;
  36113. t[158] = 186;
  36114. t[159] = 8486;
  36115. t[160] = 230;
  36116. t[161] = 248;
  36117. t[162] = 191;
  36118. t[163] = 161;
  36119. t[164] = 172;
  36120. t[165] = 8730;
  36121. t[166] = 402;
  36122. t[167] = 8776;
  36123. t[168] = 8710;
  36124. t[169] = 171;
  36125. t[170] = 187;
  36126. t[171] = 8230;
  36127. t[210] = 218;
  36128. t[223] = 711;
  36129. t[224] = 321;
  36130. t[225] = 322;
  36131. t[227] = 353;
  36132. t[229] = 382;
  36133. t[234] = 253;
  36134. t[252] = 263;
  36135. t[253] = 268;
  36136. t[254] = 269;
  36137. t[258] = 258;
  36138. t[260] = 260;
  36139. t[261] = 261;
  36140. t[265] = 280;
  36141. t[266] = 281;
  36142. t[268] = 283;
  36143. t[269] = 313;
  36144. t[275] = 323;
  36145. t[276] = 324;
  36146. t[278] = 328;
  36147. t[284] = 345;
  36148. t[285] = 346;
  36149. t[286] = 347;
  36150. t[292] = 367;
  36151. t[295] = 377;
  36152. t[296] = 378;
  36153. t[298] = 380;
  36154. t[305] = 963;
  36155. t[306] = 964;
  36156. t[307] = 966;
  36157. t[308] = 8215;
  36158. t[309] = 8252;
  36159. t[310] = 8319;
  36160. t[311] = 8359;
  36161. t[312] = 8592;
  36162. t[313] = 8593;
  36163. t[337] = 9552;
  36164. t[493] = 1039;
  36165. t[494] = 1040;
  36166. t[705] = 1524;
  36167. t[706] = 8362;
  36168. t[710] = 64288;
  36169. t[711] = 64298;
  36170. t[759] = 1617;
  36171. t[761] = 1776;
  36172. t[763] = 1778;
  36173. t[775] = 1652;
  36174. t[777] = 1764;
  36175. t[778] = 1780;
  36176. t[779] = 1781;
  36177. t[780] = 1782;
  36178. t[782] = 771;
  36179. t[783] = 64726;
  36180. t[786] = 8363;
  36181. t[788] = 8532;
  36182. t[790] = 768;
  36183. t[791] = 769;
  36184. t[792] = 768;
  36185. t[795] = 803;
  36186. t[797] = 64336;
  36187. t[798] = 64337;
  36188. t[799] = 64342;
  36189. t[800] = 64343;
  36190. t[801] = 64344;
  36191. t[802] = 64345;
  36192. t[803] = 64362;
  36193. t[804] = 64363;
  36194. t[805] = 64364;
  36195. t[2424] = 7821;
  36196. t[2425] = 7822;
  36197. t[2426] = 7823;
  36198. t[2427] = 7824;
  36199. t[2428] = 7825;
  36200. t[2429] = 7826;
  36201. t[2430] = 7827;
  36202. t[2433] = 7682;
  36203. t[2678] = 8045;
  36204. t[2679] = 8046;
  36205. t[2830] = 1552;
  36206. t[2838] = 686;
  36207. t[2840] = 751;
  36208. t[2842] = 753;
  36209. t[2843] = 754;
  36210. t[2844] = 755;
  36211. t[2846] = 757;
  36212. t[2856] = 767;
  36213. t[2857] = 848;
  36214. t[2858] = 849;
  36215. t[2862] = 853;
  36216. t[2863] = 854;
  36217. t[2864] = 855;
  36218. t[2865] = 861;
  36219. t[2866] = 862;
  36220. t[2906] = 7460;
  36221. t[2908] = 7462;
  36222. t[2909] = 7463;
  36223. t[2910] = 7464;
  36224. t[2912] = 7466;
  36225. t[2913] = 7467;
  36226. t[2914] = 7468;
  36227. t[2916] = 7470;
  36228. t[2917] = 7471;
  36229. t[2918] = 7472;
  36230. t[2920] = 7474;
  36231. t[2921] = 7475;
  36232. t[2922] = 7476;
  36233. t[2924] = 7478;
  36234. t[2925] = 7479;
  36235. t[2926] = 7480;
  36236. t[2928] = 7482;
  36237. t[2929] = 7483;
  36238. t[2930] = 7484;
  36239. t[2932] = 7486;
  36240. t[2933] = 7487;
  36241. t[2934] = 7488;
  36242. t[2936] = 7490;
  36243. t[2937] = 7491;
  36244. t[2938] = 7492;
  36245. t[2940] = 7494;
  36246. t[2941] = 7495;
  36247. t[2942] = 7496;
  36248. t[2944] = 7498;
  36249. t[2946] = 7500;
  36250. t[2948] = 7502;
  36251. t[2950] = 7504;
  36252. t[2951] = 7505;
  36253. t[2952] = 7506;
  36254. t[2954] = 7508;
  36255. t[2955] = 7509;
  36256. t[2956] = 7510;
  36257. t[2958] = 7512;
  36258. t[2959] = 7513;
  36259. t[2960] = 7514;
  36260. t[2962] = 7516;
  36261. t[2963] = 7517;
  36262. t[2964] = 7518;
  36263. t[2966] = 7520;
  36264. t[2967] = 7521;
  36265. t[2968] = 7522;
  36266. t[2970] = 7524;
  36267. t[2971] = 7525;
  36268. t[2972] = 7526;
  36269. t[2974] = 7528;
  36270. t[2975] = 7529;
  36271. t[2976] = 7530;
  36272. t[2978] = 1537;
  36273. t[2979] = 1538;
  36274. t[2980] = 1539;
  36275. t[2982] = 1549;
  36276. t[2983] = 1551;
  36277. t[2984] = 1552;
  36278. t[2986] = 1554;
  36279. t[2987] = 1555;
  36280. t[2988] = 1556;
  36281. t[2990] = 1623;
  36282. t[2991] = 1624;
  36283. t[2995] = 1775;
  36284. t[2999] = 1791;
  36285. t[3002] = 64290;
  36286. t[3003] = 64291;
  36287. t[3004] = 64292;
  36288. t[3006] = 64294;
  36289. t[3007] = 64295;
  36290. t[3008] = 64296;
  36291. t[3011] = 1900;
  36292. t[3014] = 8223;
  36293. t[3015] = 8244;
  36294. t[3017] = 7532;
  36295. t[3018] = 7533;
  36296. t[3019] = 7534;
  36297. t[3075] = 7590;
  36298. t[3076] = 7591;
  36299. t[3079] = 7594;
  36300. t[3080] = 7595;
  36301. t[3083] = 7598;
  36302. t[3084] = 7599;
  36303. t[3087] = 7602;
  36304. t[3088] = 7603;
  36305. t[3091] = 7606;
  36306. t[3092] = 7607;
  36307. t[3095] = 7610;
  36308. t[3096] = 7611;
  36309. t[3099] = 7614;
  36310. t[3100] = 7615;
  36311. t[3103] = 7618;
  36312. t[3104] = 7619;
  36313. t[3107] = 8337;
  36314. t[3108] = 8338;
  36315. t[3116] = 1884;
  36316. t[3119] = 1885;
  36317. t[3120] = 1885;
  36318. t[3123] = 1886;
  36319. t[3124] = 1886;
  36320. t[3127] = 1887;
  36321. t[3128] = 1887;
  36322. t[3131] = 1888;
  36323. t[3132] = 1888;
  36324. t[3135] = 1889;
  36325. t[3136] = 1889;
  36326. t[3139] = 1890;
  36327. t[3140] = 1890;
  36328. t[3143] = 1891;
  36329. t[3144] = 1891;
  36330. t[3147] = 1892;
  36331. t[3148] = 1892;
  36332. t[3153] = 580;
  36333. t[3154] = 581;
  36334. t[3157] = 584;
  36335. t[3158] = 585;
  36336. t[3161] = 588;
  36337. t[3162] = 589;
  36338. t[3165] = 891;
  36339. t[3166] = 892;
  36340. t[3169] = 1274;
  36341. t[3170] = 1275;
  36342. t[3173] = 1278;
  36343. t[3174] = 1279;
  36344. t[3181] = 7622;
  36345. t[3182] = 7623;
  36346. t[3282] = 11799;
  36347. t[3316] = 578;
  36348. t[3379] = 42785;
  36349. t[3393] = 1159;
  36350. t[3416] = 8377;
  36351. });
  36352. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  36353. t[227] = 322;
  36354. t[264] = 261;
  36355. t[291] = 346;
  36356. });
  36357. exports.getStdFontMap = getStdFontMap;
  36358. exports.getNonStdFontMap = getNonStdFontMap;
  36359. exports.getSerifFonts = getSerifFonts;
  36360. exports.getSymbolsFonts = getSymbolsFonts;
  36361. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  36362. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  36363. /***/ }),
  36364. /* 21 */
  36365. /***/ (function(module, exports, __w_pdfjs_require__) {
  36366. "use strict";
  36367. var sharedUtil = __w_pdfjs_require__(0);
  36368. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  36369. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  36370. t[63721] = 0x00A9;
  36371. t[63193] = 0x00A9;
  36372. t[63720] = 0x00AE;
  36373. t[63194] = 0x00AE;
  36374. t[63722] = 0x2122;
  36375. t[63195] = 0x2122;
  36376. t[63729] = 0x23A7;
  36377. t[63730] = 0x23A8;
  36378. t[63731] = 0x23A9;
  36379. t[63740] = 0x23AB;
  36380. t[63741] = 0x23AC;
  36381. t[63742] = 0x23AD;
  36382. t[63726] = 0x23A1;
  36383. t[63727] = 0x23A2;
  36384. t[63728] = 0x23A3;
  36385. t[63737] = 0x23A4;
  36386. t[63738] = 0x23A5;
  36387. t[63739] = 0x23A6;
  36388. t[63723] = 0x239B;
  36389. t[63724] = 0x239C;
  36390. t[63725] = 0x239D;
  36391. t[63734] = 0x239E;
  36392. t[63735] = 0x239F;
  36393. t[63736] = 0x23A0;
  36394. });
  36395. function mapSpecialUnicodeValues(code) {
  36396. if (code >= 0xFFF0 && code <= 0xFFFF) {
  36397. return 0;
  36398. } else if (code >= 0xF600 && code <= 0xF8FF) {
  36399. return getSpecialPUASymbols()[code] || code;
  36400. }
  36401. return code;
  36402. }
  36403. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  36404. var unicode = glyphsUnicodeMap[name];
  36405. if (unicode !== undefined) {
  36406. return unicode;
  36407. }
  36408. if (!name) {
  36409. return -1;
  36410. }
  36411. if (name[0] === 'u') {
  36412. var nameLen = name.length, hexStr;
  36413. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  36414. hexStr = name.substr(3);
  36415. } else if (nameLen >= 5 && nameLen <= 7) {
  36416. hexStr = name.substr(1);
  36417. } else {
  36418. return -1;
  36419. }
  36420. if (hexStr === hexStr.toUpperCase()) {
  36421. unicode = parseInt(hexStr, 16);
  36422. if (unicode >= 0) {
  36423. return unicode;
  36424. }
  36425. }
  36426. }
  36427. return -1;
  36428. }
  36429. var UnicodeRanges = [
  36430. {
  36431. 'begin': 0x0000,
  36432. 'end': 0x007F
  36433. },
  36434. {
  36435. 'begin': 0x0080,
  36436. 'end': 0x00FF
  36437. },
  36438. {
  36439. 'begin': 0x0100,
  36440. 'end': 0x017F
  36441. },
  36442. {
  36443. 'begin': 0x0180,
  36444. 'end': 0x024F
  36445. },
  36446. {
  36447. 'begin': 0x0250,
  36448. 'end': 0x02AF
  36449. },
  36450. {
  36451. 'begin': 0x02B0,
  36452. 'end': 0x02FF
  36453. },
  36454. {
  36455. 'begin': 0x0300,
  36456. 'end': 0x036F
  36457. },
  36458. {
  36459. 'begin': 0x0370,
  36460. 'end': 0x03FF
  36461. },
  36462. {
  36463. 'begin': 0x2C80,
  36464. 'end': 0x2CFF
  36465. },
  36466. {
  36467. 'begin': 0x0400,
  36468. 'end': 0x04FF
  36469. },
  36470. {
  36471. 'begin': 0x0530,
  36472. 'end': 0x058F
  36473. },
  36474. {
  36475. 'begin': 0x0590,
  36476. 'end': 0x05FF
  36477. },
  36478. {
  36479. 'begin': 0xA500,
  36480. 'end': 0xA63F
  36481. },
  36482. {
  36483. 'begin': 0x0600,
  36484. 'end': 0x06FF
  36485. },
  36486. {
  36487. 'begin': 0x07C0,
  36488. 'end': 0x07FF
  36489. },
  36490. {
  36491. 'begin': 0x0900,
  36492. 'end': 0x097F
  36493. },
  36494. {
  36495. 'begin': 0x0980,
  36496. 'end': 0x09FF
  36497. },
  36498. {
  36499. 'begin': 0x0A00,
  36500. 'end': 0x0A7F
  36501. },
  36502. {
  36503. 'begin': 0x0A80,
  36504. 'end': 0x0AFF
  36505. },
  36506. {
  36507. 'begin': 0x0B00,
  36508. 'end': 0x0B7F
  36509. },
  36510. {
  36511. 'begin': 0x0B80,
  36512. 'end': 0x0BFF
  36513. },
  36514. {
  36515. 'begin': 0x0C00,
  36516. 'end': 0x0C7F
  36517. },
  36518. {
  36519. 'begin': 0x0C80,
  36520. 'end': 0x0CFF
  36521. },
  36522. {
  36523. 'begin': 0x0D00,
  36524. 'end': 0x0D7F
  36525. },
  36526. {
  36527. 'begin': 0x0E00,
  36528. 'end': 0x0E7F
  36529. },
  36530. {
  36531. 'begin': 0x0E80,
  36532. 'end': 0x0EFF
  36533. },
  36534. {
  36535. 'begin': 0x10A0,
  36536. 'end': 0x10FF
  36537. },
  36538. {
  36539. 'begin': 0x1B00,
  36540. 'end': 0x1B7F
  36541. },
  36542. {
  36543. 'begin': 0x1100,
  36544. 'end': 0x11FF
  36545. },
  36546. {
  36547. 'begin': 0x1E00,
  36548. 'end': 0x1EFF
  36549. },
  36550. {
  36551. 'begin': 0x1F00,
  36552. 'end': 0x1FFF
  36553. },
  36554. {
  36555. 'begin': 0x2000,
  36556. 'end': 0x206F
  36557. },
  36558. {
  36559. 'begin': 0x2070,
  36560. 'end': 0x209F
  36561. },
  36562. {
  36563. 'begin': 0x20A0,
  36564. 'end': 0x20CF
  36565. },
  36566. {
  36567. 'begin': 0x20D0,
  36568. 'end': 0x20FF
  36569. },
  36570. {
  36571. 'begin': 0x2100,
  36572. 'end': 0x214F
  36573. },
  36574. {
  36575. 'begin': 0x2150,
  36576. 'end': 0x218F
  36577. },
  36578. {
  36579. 'begin': 0x2190,
  36580. 'end': 0x21FF
  36581. },
  36582. {
  36583. 'begin': 0x2200,
  36584. 'end': 0x22FF
  36585. },
  36586. {
  36587. 'begin': 0x2300,
  36588. 'end': 0x23FF
  36589. },
  36590. {
  36591. 'begin': 0x2400,
  36592. 'end': 0x243F
  36593. },
  36594. {
  36595. 'begin': 0x2440,
  36596. 'end': 0x245F
  36597. },
  36598. {
  36599. 'begin': 0x2460,
  36600. 'end': 0x24FF
  36601. },
  36602. {
  36603. 'begin': 0x2500,
  36604. 'end': 0x257F
  36605. },
  36606. {
  36607. 'begin': 0x2580,
  36608. 'end': 0x259F
  36609. },
  36610. {
  36611. 'begin': 0x25A0,
  36612. 'end': 0x25FF
  36613. },
  36614. {
  36615. 'begin': 0x2600,
  36616. 'end': 0x26FF
  36617. },
  36618. {
  36619. 'begin': 0x2700,
  36620. 'end': 0x27BF
  36621. },
  36622. {
  36623. 'begin': 0x3000,
  36624. 'end': 0x303F
  36625. },
  36626. {
  36627. 'begin': 0x3040,
  36628. 'end': 0x309F
  36629. },
  36630. {
  36631. 'begin': 0x30A0,
  36632. 'end': 0x30FF
  36633. },
  36634. {
  36635. 'begin': 0x3100,
  36636. 'end': 0x312F
  36637. },
  36638. {
  36639. 'begin': 0x3130,
  36640. 'end': 0x318F
  36641. },
  36642. {
  36643. 'begin': 0xA840,
  36644. 'end': 0xA87F
  36645. },
  36646. {
  36647. 'begin': 0x3200,
  36648. 'end': 0x32FF
  36649. },
  36650. {
  36651. 'begin': 0x3300,
  36652. 'end': 0x33FF
  36653. },
  36654. {
  36655. 'begin': 0xAC00,
  36656. 'end': 0xD7AF
  36657. },
  36658. {
  36659. 'begin': 0xD800,
  36660. 'end': 0xDFFF
  36661. },
  36662. {
  36663. 'begin': 0x10900,
  36664. 'end': 0x1091F
  36665. },
  36666. {
  36667. 'begin': 0x4E00,
  36668. 'end': 0x9FFF
  36669. },
  36670. {
  36671. 'begin': 0xE000,
  36672. 'end': 0xF8FF
  36673. },
  36674. {
  36675. 'begin': 0x31C0,
  36676. 'end': 0x31EF
  36677. },
  36678. {
  36679. 'begin': 0xFB00,
  36680. 'end': 0xFB4F
  36681. },
  36682. {
  36683. 'begin': 0xFB50,
  36684. 'end': 0xFDFF
  36685. },
  36686. {
  36687. 'begin': 0xFE20,
  36688. 'end': 0xFE2F
  36689. },
  36690. {
  36691. 'begin': 0xFE10,
  36692. 'end': 0xFE1F
  36693. },
  36694. {
  36695. 'begin': 0xFE50,
  36696. 'end': 0xFE6F
  36697. },
  36698. {
  36699. 'begin': 0xFE70,
  36700. 'end': 0xFEFF
  36701. },
  36702. {
  36703. 'begin': 0xFF00,
  36704. 'end': 0xFFEF
  36705. },
  36706. {
  36707. 'begin': 0xFFF0,
  36708. 'end': 0xFFFF
  36709. },
  36710. {
  36711. 'begin': 0x0F00,
  36712. 'end': 0x0FFF
  36713. },
  36714. {
  36715. 'begin': 0x0700,
  36716. 'end': 0x074F
  36717. },
  36718. {
  36719. 'begin': 0x0780,
  36720. 'end': 0x07BF
  36721. },
  36722. {
  36723. 'begin': 0x0D80,
  36724. 'end': 0x0DFF
  36725. },
  36726. {
  36727. 'begin': 0x1000,
  36728. 'end': 0x109F
  36729. },
  36730. {
  36731. 'begin': 0x1200,
  36732. 'end': 0x137F
  36733. },
  36734. {
  36735. 'begin': 0x13A0,
  36736. 'end': 0x13FF
  36737. },
  36738. {
  36739. 'begin': 0x1400,
  36740. 'end': 0x167F
  36741. },
  36742. {
  36743. 'begin': 0x1680,
  36744. 'end': 0x169F
  36745. },
  36746. {
  36747. 'begin': 0x16A0,
  36748. 'end': 0x16FF
  36749. },
  36750. {
  36751. 'begin': 0x1780,
  36752. 'end': 0x17FF
  36753. },
  36754. {
  36755. 'begin': 0x1800,
  36756. 'end': 0x18AF
  36757. },
  36758. {
  36759. 'begin': 0x2800,
  36760. 'end': 0x28FF
  36761. },
  36762. {
  36763. 'begin': 0xA000,
  36764. 'end': 0xA48F
  36765. },
  36766. {
  36767. 'begin': 0x1700,
  36768. 'end': 0x171F
  36769. },
  36770. {
  36771. 'begin': 0x10300,
  36772. 'end': 0x1032F
  36773. },
  36774. {
  36775. 'begin': 0x10330,
  36776. 'end': 0x1034F
  36777. },
  36778. {
  36779. 'begin': 0x10400,
  36780. 'end': 0x1044F
  36781. },
  36782. {
  36783. 'begin': 0x1D000,
  36784. 'end': 0x1D0FF
  36785. },
  36786. {
  36787. 'begin': 0x1D400,
  36788. 'end': 0x1D7FF
  36789. },
  36790. {
  36791. 'begin': 0xFF000,
  36792. 'end': 0xFFFFD
  36793. },
  36794. {
  36795. 'begin': 0xFE00,
  36796. 'end': 0xFE0F
  36797. },
  36798. {
  36799. 'begin': 0xE0000,
  36800. 'end': 0xE007F
  36801. },
  36802. {
  36803. 'begin': 0x1900,
  36804. 'end': 0x194F
  36805. },
  36806. {
  36807. 'begin': 0x1950,
  36808. 'end': 0x197F
  36809. },
  36810. {
  36811. 'begin': 0x1980,
  36812. 'end': 0x19DF
  36813. },
  36814. {
  36815. 'begin': 0x1A00,
  36816. 'end': 0x1A1F
  36817. },
  36818. {
  36819. 'begin': 0x2C00,
  36820. 'end': 0x2C5F
  36821. },
  36822. {
  36823. 'begin': 0x2D30,
  36824. 'end': 0x2D7F
  36825. },
  36826. {
  36827. 'begin': 0x4DC0,
  36828. 'end': 0x4DFF
  36829. },
  36830. {
  36831. 'begin': 0xA800,
  36832. 'end': 0xA82F
  36833. },
  36834. {
  36835. 'begin': 0x10000,
  36836. 'end': 0x1007F
  36837. },
  36838. {
  36839. 'begin': 0x10140,
  36840. 'end': 0x1018F
  36841. },
  36842. {
  36843. 'begin': 0x10380,
  36844. 'end': 0x1039F
  36845. },
  36846. {
  36847. 'begin': 0x103A0,
  36848. 'end': 0x103DF
  36849. },
  36850. {
  36851. 'begin': 0x10450,
  36852. 'end': 0x1047F
  36853. },
  36854. {
  36855. 'begin': 0x10480,
  36856. 'end': 0x104AF
  36857. },
  36858. {
  36859. 'begin': 0x10800,
  36860. 'end': 0x1083F
  36861. },
  36862. {
  36863. 'begin': 0x10A00,
  36864. 'end': 0x10A5F
  36865. },
  36866. {
  36867. 'begin': 0x1D300,
  36868. 'end': 0x1D35F
  36869. },
  36870. {
  36871. 'begin': 0x12000,
  36872. 'end': 0x123FF
  36873. },
  36874. {
  36875. 'begin': 0x1D360,
  36876. 'end': 0x1D37F
  36877. },
  36878. {
  36879. 'begin': 0x1B80,
  36880. 'end': 0x1BBF
  36881. },
  36882. {
  36883. 'begin': 0x1C00,
  36884. 'end': 0x1C4F
  36885. },
  36886. {
  36887. 'begin': 0x1C50,
  36888. 'end': 0x1C7F
  36889. },
  36890. {
  36891. 'begin': 0xA880,
  36892. 'end': 0xA8DF
  36893. },
  36894. {
  36895. 'begin': 0xA900,
  36896. 'end': 0xA92F
  36897. },
  36898. {
  36899. 'begin': 0xA930,
  36900. 'end': 0xA95F
  36901. },
  36902. {
  36903. 'begin': 0xAA00,
  36904. 'end': 0xAA5F
  36905. },
  36906. {
  36907. 'begin': 0x10190,
  36908. 'end': 0x101CF
  36909. },
  36910. {
  36911. 'begin': 0x101D0,
  36912. 'end': 0x101FF
  36913. },
  36914. {
  36915. 'begin': 0x102A0,
  36916. 'end': 0x102DF
  36917. },
  36918. {
  36919. 'begin': 0x1F030,
  36920. 'end': 0x1F09F
  36921. }
  36922. ];
  36923. function getUnicodeRangeFor(value) {
  36924. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  36925. var range = UnicodeRanges[i];
  36926. if (value >= range.begin && value < range.end) {
  36927. return i;
  36928. }
  36929. }
  36930. return -1;
  36931. }
  36932. function isRTLRangeFor(value) {
  36933. var range = UnicodeRanges[13];
  36934. if (value >= range.begin && value < range.end) {
  36935. return true;
  36936. }
  36937. range = UnicodeRanges[11];
  36938. if (value >= range.begin && value < range.end) {
  36939. return true;
  36940. }
  36941. return false;
  36942. }
  36943. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  36944. t['\u00A8'] = '\u0020\u0308';
  36945. t['\u00AF'] = '\u0020\u0304';
  36946. t['\u00B4'] = '\u0020\u0301';
  36947. t['\u00B5'] = '\u03BC';
  36948. t['\u00B8'] = '\u0020\u0327';
  36949. t['\u0132'] = '\u0049\u004A';
  36950. t['\u0133'] = '\u0069\u006A';
  36951. t['\u013F'] = '\u004C\u00B7';
  36952. t['\u0140'] = '\u006C\u00B7';
  36953. t['\u0149'] = '\u02BC\u006E';
  36954. t['\u017F'] = '\u0073';
  36955. t['\u01C4'] = '\u0044\u017D';
  36956. t['\u01C5'] = '\u0044\u017E';
  36957. t['\u01C6'] = '\u0064\u017E';
  36958. t['\u01C7'] = '\u004C\u004A';
  36959. t['\u01C8'] = '\u004C\u006A';
  36960. t['\u01C9'] = '\u006C\u006A';
  36961. t['\u01CA'] = '\u004E\u004A';
  36962. t['\u01CB'] = '\u004E\u006A';
  36963. t['\u01CC'] = '\u006E\u006A';
  36964. t['\u01F1'] = '\u0044\u005A';
  36965. t['\u01F2'] = '\u0044\u007A';
  36966. t['\u01F3'] = '\u0064\u007A';
  36967. t['\u02D8'] = '\u0020\u0306';
  36968. t['\u02D9'] = '\u0020\u0307';
  36969. t['\u02DA'] = '\u0020\u030A';
  36970. t['\u02DB'] = '\u0020\u0328';
  36971. t['\u02DC'] = '\u0020\u0303';
  36972. t['\u02DD'] = '\u0020\u030B';
  36973. t['\u037A'] = '\u0020\u0345';
  36974. t['\u0384'] = '\u0020\u0301';
  36975. t['\u03D0'] = '\u03B2';
  36976. t['\u03D1'] = '\u03B8';
  36977. t['\u03D2'] = '\u03A5';
  36978. t['\u03D5'] = '\u03C6';
  36979. t['\u03D6'] = '\u03C0';
  36980. t['\u03F0'] = '\u03BA';
  36981. t['\u03F1'] = '\u03C1';
  36982. t['\u03F2'] = '\u03C2';
  36983. t['\u03F4'] = '\u0398';
  36984. t['\u03F5'] = '\u03B5';
  36985. t['\u03F9'] = '\u03A3';
  36986. t['\u0587'] = '\u0565\u0582';
  36987. t['\u0675'] = '\u0627\u0674';
  36988. t['\u0676'] = '\u0648\u0674';
  36989. t['\u0677'] = '\u06C7\u0674';
  36990. t['\u0678'] = '\u064A\u0674';
  36991. t['\u0E33'] = '\u0E4D\u0E32';
  36992. t['\u0EB3'] = '\u0ECD\u0EB2';
  36993. t['\u0EDC'] = '\u0EAB\u0E99';
  36994. t['\u0EDD'] = '\u0EAB\u0EA1';
  36995. t['\u0F77'] = '\u0FB2\u0F81';
  36996. t['\u0F79'] = '\u0FB3\u0F81';
  36997. t['\u1E9A'] = '\u0061\u02BE';
  36998. t['\u1FBD'] = '\u0020\u0313';
  36999. t['\u1FBF'] = '\u0020\u0313';
  37000. t['\u1FC0'] = '\u0020\u0342';
  37001. t['\u1FFE'] = '\u0020\u0314';
  37002. t['\u2002'] = '\u0020';
  37003. t['\u2003'] = '\u0020';
  37004. t['\u2004'] = '\u0020';
  37005. t['\u2005'] = '\u0020';
  37006. t['\u2006'] = '\u0020';
  37007. t['\u2008'] = '\u0020';
  37008. t['\u2009'] = '\u0020';
  37009. t['\u200A'] = '\u0020';
  37010. t['\u2017'] = '\u0020\u0333';
  37011. t['\u2024'] = '\u002E';
  37012. t['\u2025'] = '\u002E\u002E';
  37013. t['\u2026'] = '\u002E\u002E\u002E';
  37014. t['\u2033'] = '\u2032\u2032';
  37015. t['\u2034'] = '\u2032\u2032\u2032';
  37016. t['\u2036'] = '\u2035\u2035';
  37017. t['\u2037'] = '\u2035\u2035\u2035';
  37018. t['\u203C'] = '\u0021\u0021';
  37019. t['\u203E'] = '\u0020\u0305';
  37020. t['\u2047'] = '\u003F\u003F';
  37021. t['\u2048'] = '\u003F\u0021';
  37022. t['\u2049'] = '\u0021\u003F';
  37023. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  37024. t['\u205F'] = '\u0020';
  37025. t['\u20A8'] = '\u0052\u0073';
  37026. t['\u2100'] = '\u0061\u002F\u0063';
  37027. t['\u2101'] = '\u0061\u002F\u0073';
  37028. t['\u2103'] = '\u00B0\u0043';
  37029. t['\u2105'] = '\u0063\u002F\u006F';
  37030. t['\u2106'] = '\u0063\u002F\u0075';
  37031. t['\u2107'] = '\u0190';
  37032. t['\u2109'] = '\u00B0\u0046';
  37033. t['\u2116'] = '\u004E\u006F';
  37034. t['\u2121'] = '\u0054\u0045\u004C';
  37035. t['\u2135'] = '\u05D0';
  37036. t['\u2136'] = '\u05D1';
  37037. t['\u2137'] = '\u05D2';
  37038. t['\u2138'] = '\u05D3';
  37039. t['\u213B'] = '\u0046\u0041\u0058';
  37040. t['\u2160'] = '\u0049';
  37041. t['\u2161'] = '\u0049\u0049';
  37042. t['\u2162'] = '\u0049\u0049\u0049';
  37043. t['\u2163'] = '\u0049\u0056';
  37044. t['\u2164'] = '\u0056';
  37045. t['\u2165'] = '\u0056\u0049';
  37046. t['\u2166'] = '\u0056\u0049\u0049';
  37047. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  37048. t['\u2168'] = '\u0049\u0058';
  37049. t['\u2169'] = '\u0058';
  37050. t['\u216A'] = '\u0058\u0049';
  37051. t['\u216B'] = '\u0058\u0049\u0049';
  37052. t['\u216C'] = '\u004C';
  37053. t['\u216D'] = '\u0043';
  37054. t['\u216E'] = '\u0044';
  37055. t['\u216F'] = '\u004D';
  37056. t['\u2170'] = '\u0069';
  37057. t['\u2171'] = '\u0069\u0069';
  37058. t['\u2172'] = '\u0069\u0069\u0069';
  37059. t['\u2173'] = '\u0069\u0076';
  37060. t['\u2174'] = '\u0076';
  37061. t['\u2175'] = '\u0076\u0069';
  37062. t['\u2176'] = '\u0076\u0069\u0069';
  37063. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  37064. t['\u2178'] = '\u0069\u0078';
  37065. t['\u2179'] = '\u0078';
  37066. t['\u217A'] = '\u0078\u0069';
  37067. t['\u217B'] = '\u0078\u0069\u0069';
  37068. t['\u217C'] = '\u006C';
  37069. t['\u217D'] = '\u0063';
  37070. t['\u217E'] = '\u0064';
  37071. t['\u217F'] = '\u006D';
  37072. t['\u222C'] = '\u222B\u222B';
  37073. t['\u222D'] = '\u222B\u222B\u222B';
  37074. t['\u222F'] = '\u222E\u222E';
  37075. t['\u2230'] = '\u222E\u222E\u222E';
  37076. t['\u2474'] = '\u0028\u0031\u0029';
  37077. t['\u2475'] = '\u0028\u0032\u0029';
  37078. t['\u2476'] = '\u0028\u0033\u0029';
  37079. t['\u2477'] = '\u0028\u0034\u0029';
  37080. t['\u2478'] = '\u0028\u0035\u0029';
  37081. t['\u2479'] = '\u0028\u0036\u0029';
  37082. t['\u247A'] = '\u0028\u0037\u0029';
  37083. t['\u247B'] = '\u0028\u0038\u0029';
  37084. t['\u247C'] = '\u0028\u0039\u0029';
  37085. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  37086. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  37087. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  37088. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  37089. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  37090. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  37091. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  37092. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  37093. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  37094. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  37095. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  37096. t['\u2488'] = '\u0031\u002E';
  37097. t['\u2489'] = '\u0032\u002E';
  37098. t['\u248A'] = '\u0033\u002E';
  37099. t['\u248B'] = '\u0034\u002E';
  37100. t['\u248C'] = '\u0035\u002E';
  37101. t['\u248D'] = '\u0036\u002E';
  37102. t['\u248E'] = '\u0037\u002E';
  37103. t['\u248F'] = '\u0038\u002E';
  37104. t['\u2490'] = '\u0039\u002E';
  37105. t['\u2491'] = '\u0031\u0030\u002E';
  37106. t['\u2492'] = '\u0031\u0031\u002E';
  37107. t['\u2493'] = '\u0031\u0032\u002E';
  37108. t['\u2494'] = '\u0031\u0033\u002E';
  37109. t['\u2495'] = '\u0031\u0034\u002E';
  37110. t['\u2496'] = '\u0031\u0035\u002E';
  37111. t['\u2497'] = '\u0031\u0036\u002E';
  37112. t['\u2498'] = '\u0031\u0037\u002E';
  37113. t['\u2499'] = '\u0031\u0038\u002E';
  37114. t['\u249A'] = '\u0031\u0039\u002E';
  37115. t['\u249B'] = '\u0032\u0030\u002E';
  37116. t['\u249C'] = '\u0028\u0061\u0029';
  37117. t['\u249D'] = '\u0028\u0062\u0029';
  37118. t['\u249E'] = '\u0028\u0063\u0029';
  37119. t['\u249F'] = '\u0028\u0064\u0029';
  37120. t['\u24A0'] = '\u0028\u0065\u0029';
  37121. t['\u24A1'] = '\u0028\u0066\u0029';
  37122. t['\u24A2'] = '\u0028\u0067\u0029';
  37123. t['\u24A3'] = '\u0028\u0068\u0029';
  37124. t['\u24A4'] = '\u0028\u0069\u0029';
  37125. t['\u24A5'] = '\u0028\u006A\u0029';
  37126. t['\u24A6'] = '\u0028\u006B\u0029';
  37127. t['\u24A7'] = '\u0028\u006C\u0029';
  37128. t['\u24A8'] = '\u0028\u006D\u0029';
  37129. t['\u24A9'] = '\u0028\u006E\u0029';
  37130. t['\u24AA'] = '\u0028\u006F\u0029';
  37131. t['\u24AB'] = '\u0028\u0070\u0029';
  37132. t['\u24AC'] = '\u0028\u0071\u0029';
  37133. t['\u24AD'] = '\u0028\u0072\u0029';
  37134. t['\u24AE'] = '\u0028\u0073\u0029';
  37135. t['\u24AF'] = '\u0028\u0074\u0029';
  37136. t['\u24B0'] = '\u0028\u0075\u0029';
  37137. t['\u24B1'] = '\u0028\u0076\u0029';
  37138. t['\u24B2'] = '\u0028\u0077\u0029';
  37139. t['\u24B3'] = '\u0028\u0078\u0029';
  37140. t['\u24B4'] = '\u0028\u0079\u0029';
  37141. t['\u24B5'] = '\u0028\u007A\u0029';
  37142. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  37143. t['\u2A74'] = '\u003A\u003A\u003D';
  37144. t['\u2A75'] = '\u003D\u003D';
  37145. t['\u2A76'] = '\u003D\u003D\u003D';
  37146. t['\u2E9F'] = '\u6BCD';
  37147. t['\u2EF3'] = '\u9F9F';
  37148. t['\u2F00'] = '\u4E00';
  37149. t['\u2F01'] = '\u4E28';
  37150. t['\u2F02'] = '\u4E36';
  37151. t['\u2F03'] = '\u4E3F';
  37152. t['\u2F04'] = '\u4E59';
  37153. t['\u2F05'] = '\u4E85';
  37154. t['\u2F06'] = '\u4E8C';
  37155. t['\u2F07'] = '\u4EA0';
  37156. t['\u2F08'] = '\u4EBA';
  37157. t['\u2F09'] = '\u513F';
  37158. t['\u2F0A'] = '\u5165';
  37159. t['\u2F0B'] = '\u516B';
  37160. t['\u2F0C'] = '\u5182';
  37161. t['\u2F0D'] = '\u5196';
  37162. t['\u2F0E'] = '\u51AB';
  37163. t['\u2F0F'] = '\u51E0';
  37164. t['\u2F10'] = '\u51F5';
  37165. t['\u2F11'] = '\u5200';
  37166. t['\u2F12'] = '\u529B';
  37167. t['\u2F13'] = '\u52F9';
  37168. t['\u2F14'] = '\u5315';
  37169. t['\u2F15'] = '\u531A';
  37170. t['\u2F16'] = '\u5338';
  37171. t['\u2F17'] = '\u5341';
  37172. t['\u2F18'] = '\u535C';
  37173. t['\u2F19'] = '\u5369';
  37174. t['\u2F1A'] = '\u5382';
  37175. t['\u2F1B'] = '\u53B6';
  37176. t['\u2F1C'] = '\u53C8';
  37177. t['\u2F1D'] = '\u53E3';
  37178. t['\u2F1E'] = '\u56D7';
  37179. t['\u2F1F'] = '\u571F';
  37180. t['\u2F20'] = '\u58EB';
  37181. t['\u2F21'] = '\u5902';
  37182. t['\u2F22'] = '\u590A';
  37183. t['\u2F23'] = '\u5915';
  37184. t['\u2F24'] = '\u5927';
  37185. t['\u2F25'] = '\u5973';
  37186. t['\u2F26'] = '\u5B50';
  37187. t['\u2F27'] = '\u5B80';
  37188. t['\u2F28'] = '\u5BF8';
  37189. t['\u2F29'] = '\u5C0F';
  37190. t['\u2F2A'] = '\u5C22';
  37191. t['\u2F2B'] = '\u5C38';
  37192. t['\u2F2C'] = '\u5C6E';
  37193. t['\u2F2D'] = '\u5C71';
  37194. t['\u2F2E'] = '\u5DDB';
  37195. t['\u2F2F'] = '\u5DE5';
  37196. t['\u2F30'] = '\u5DF1';
  37197. t['\u2F31'] = '\u5DFE';
  37198. t['\u2F32'] = '\u5E72';
  37199. t['\u2F33'] = '\u5E7A';
  37200. t['\u2F34'] = '\u5E7F';
  37201. t['\u2F35'] = '\u5EF4';
  37202. t['\u2F36'] = '\u5EFE';
  37203. t['\u2F37'] = '\u5F0B';
  37204. t['\u2F38'] = '\u5F13';
  37205. t['\u2F39'] = '\u5F50';
  37206. t['\u2F3A'] = '\u5F61';
  37207. t['\u2F3B'] = '\u5F73';
  37208. t['\u2F3C'] = '\u5FC3';
  37209. t['\u2F3D'] = '\u6208';
  37210. t['\u2F3E'] = '\u6236';
  37211. t['\u2F3F'] = '\u624B';
  37212. t['\u2F40'] = '\u652F';
  37213. t['\u2F41'] = '\u6534';
  37214. t['\u2F42'] = '\u6587';
  37215. t['\u2F43'] = '\u6597';
  37216. t['\u2F44'] = '\u65A4';
  37217. t['\u2F45'] = '\u65B9';
  37218. t['\u2F46'] = '\u65E0';
  37219. t['\u2F47'] = '\u65E5';
  37220. t['\u2F48'] = '\u66F0';
  37221. t['\u2F49'] = '\u6708';
  37222. t['\u2F4A'] = '\u6728';
  37223. t['\u2F4B'] = '\u6B20';
  37224. t['\u2F4C'] = '\u6B62';
  37225. t['\u2F4D'] = '\u6B79';
  37226. t['\u2F4E'] = '\u6BB3';
  37227. t['\u2F4F'] = '\u6BCB';
  37228. t['\u2F50'] = '\u6BD4';
  37229. t['\u2F51'] = '\u6BDB';
  37230. t['\u2F52'] = '\u6C0F';
  37231. t['\u2F53'] = '\u6C14';
  37232. t['\u2F54'] = '\u6C34';
  37233. t['\u2F55'] = '\u706B';
  37234. t['\u2F56'] = '\u722A';
  37235. t['\u2F57'] = '\u7236';
  37236. t['\u2F58'] = '\u723B';
  37237. t['\u2F59'] = '\u723F';
  37238. t['\u2F5A'] = '\u7247';
  37239. t['\u2F5B'] = '\u7259';
  37240. t['\u2F5C'] = '\u725B';
  37241. t['\u2F5D'] = '\u72AC';
  37242. t['\u2F5E'] = '\u7384';
  37243. t['\u2F5F'] = '\u7389';
  37244. t['\u2F60'] = '\u74DC';
  37245. t['\u2F61'] = '\u74E6';
  37246. t['\u2F62'] = '\u7518';
  37247. t['\u2F63'] = '\u751F';
  37248. t['\u2F64'] = '\u7528';
  37249. t['\u2F65'] = '\u7530';
  37250. t['\u2F66'] = '\u758B';
  37251. t['\u2F67'] = '\u7592';
  37252. t['\u2F68'] = '\u7676';
  37253. t['\u2F69'] = '\u767D';
  37254. t['\u2F6A'] = '\u76AE';
  37255. t['\u2F6B'] = '\u76BF';
  37256. t['\u2F6C'] = '\u76EE';
  37257. t['\u2F6D'] = '\u77DB';
  37258. t['\u2F6E'] = '\u77E2';
  37259. t['\u2F6F'] = '\u77F3';
  37260. t['\u2F70'] = '\u793A';
  37261. t['\u2F71'] = '\u79B8';
  37262. t['\u2F72'] = '\u79BE';
  37263. t['\u2F73'] = '\u7A74';
  37264. t['\u2F74'] = '\u7ACB';
  37265. t['\u2F75'] = '\u7AF9';
  37266. t['\u2F76'] = '\u7C73';
  37267. t['\u2F77'] = '\u7CF8';
  37268. t['\u2F78'] = '\u7F36';
  37269. t['\u2F79'] = '\u7F51';
  37270. t['\u2F7A'] = '\u7F8A';
  37271. t['\u2F7B'] = '\u7FBD';
  37272. t['\u2F7C'] = '\u8001';
  37273. t['\u2F7D'] = '\u800C';
  37274. t['\u2F7E'] = '\u8012';
  37275. t['\u2F7F'] = '\u8033';
  37276. t['\u2F80'] = '\u807F';
  37277. t['\u2F81'] = '\u8089';
  37278. t['\u2F82'] = '\u81E3';
  37279. t['\u2F83'] = '\u81EA';
  37280. t['\u2F84'] = '\u81F3';
  37281. t['\u2F85'] = '\u81FC';
  37282. t['\u2F86'] = '\u820C';
  37283. t['\u2F87'] = '\u821B';
  37284. t['\u2F88'] = '\u821F';
  37285. t['\u2F89'] = '\u826E';
  37286. t['\u2F8A'] = '\u8272';
  37287. t['\u2F8B'] = '\u8278';
  37288. t['\u2F8C'] = '\u864D';
  37289. t['\u2F8D'] = '\u866B';
  37290. t['\u2F8E'] = '\u8840';
  37291. t['\u2F8F'] = '\u884C';
  37292. t['\u2F90'] = '\u8863';
  37293. t['\u2F91'] = '\u897E';
  37294. t['\u2F92'] = '\u898B';
  37295. t['\u2F93'] = '\u89D2';
  37296. t['\u2F94'] = '\u8A00';
  37297. t['\u2F95'] = '\u8C37';
  37298. t['\u2F96'] = '\u8C46';
  37299. t['\u2F97'] = '\u8C55';
  37300. t['\u2F98'] = '\u8C78';
  37301. t['\u2F99'] = '\u8C9D';
  37302. t['\u2F9A'] = '\u8D64';
  37303. t['\u2F9B'] = '\u8D70';
  37304. t['\u2F9C'] = '\u8DB3';
  37305. t['\u2F9D'] = '\u8EAB';
  37306. t['\u2F9E'] = '\u8ECA';
  37307. t['\u2F9F'] = '\u8F9B';
  37308. t['\u2FA0'] = '\u8FB0';
  37309. t['\u2FA1'] = '\u8FB5';
  37310. t['\u2FA2'] = '\u9091';
  37311. t['\u2FA3'] = '\u9149';
  37312. t['\u2FA4'] = '\u91C6';
  37313. t['\u2FA5'] = '\u91CC';
  37314. t['\u2FA6'] = '\u91D1';
  37315. t['\u2FA7'] = '\u9577';
  37316. t['\u2FA8'] = '\u9580';
  37317. t['\u2FA9'] = '\u961C';
  37318. t['\u2FAA'] = '\u96B6';
  37319. t['\u2FAB'] = '\u96B9';
  37320. t['\u2FAC'] = '\u96E8';
  37321. t['\u2FAD'] = '\u9751';
  37322. t['\u2FAE'] = '\u975E';
  37323. t['\u2FAF'] = '\u9762';
  37324. t['\u2FB0'] = '\u9769';
  37325. t['\u2FB1'] = '\u97CB';
  37326. t['\u2FB2'] = '\u97ED';
  37327. t['\u2FB3'] = '\u97F3';
  37328. t['\u2FB4'] = '\u9801';
  37329. t['\u2FB5'] = '\u98A8';
  37330. t['\u2FB6'] = '\u98DB';
  37331. t['\u2FB7'] = '\u98DF';
  37332. t['\u2FB8'] = '\u9996';
  37333. t['\u2FB9'] = '\u9999';
  37334. t['\u2FBA'] = '\u99AC';
  37335. t['\u2FBB'] = '\u9AA8';
  37336. t['\u2FBC'] = '\u9AD8';
  37337. t['\u2FBD'] = '\u9ADF';
  37338. t['\u2FBE'] = '\u9B25';
  37339. t['\u2FBF'] = '\u9B2F';
  37340. t['\u2FC0'] = '\u9B32';
  37341. t['\u2FC1'] = '\u9B3C';
  37342. t['\u2FC2'] = '\u9B5A';
  37343. t['\u2FC3'] = '\u9CE5';
  37344. t['\u2FC4'] = '\u9E75';
  37345. t['\u2FC5'] = '\u9E7F';
  37346. t['\u2FC6'] = '\u9EA5';
  37347. t['\u2FC7'] = '\u9EBB';
  37348. t['\u2FC8'] = '\u9EC3';
  37349. t['\u2FC9'] = '\u9ECD';
  37350. t['\u2FCA'] = '\u9ED1';
  37351. t['\u2FCB'] = '\u9EF9';
  37352. t['\u2FCC'] = '\u9EFD';
  37353. t['\u2FCD'] = '\u9F0E';
  37354. t['\u2FCE'] = '\u9F13';
  37355. t['\u2FCF'] = '\u9F20';
  37356. t['\u2FD0'] = '\u9F3B';
  37357. t['\u2FD1'] = '\u9F4A';
  37358. t['\u2FD2'] = '\u9F52';
  37359. t['\u2FD3'] = '\u9F8D';
  37360. t['\u2FD4'] = '\u9F9C';
  37361. t['\u2FD5'] = '\u9FA0';
  37362. t['\u3036'] = '\u3012';
  37363. t['\u3038'] = '\u5341';
  37364. t['\u3039'] = '\u5344';
  37365. t['\u303A'] = '\u5345';
  37366. t['\u309B'] = '\u0020\u3099';
  37367. t['\u309C'] = '\u0020\u309A';
  37368. t['\u3131'] = '\u1100';
  37369. t['\u3132'] = '\u1101';
  37370. t['\u3133'] = '\u11AA';
  37371. t['\u3134'] = '\u1102';
  37372. t['\u3135'] = '\u11AC';
  37373. t['\u3136'] = '\u11AD';
  37374. t['\u3137'] = '\u1103';
  37375. t['\u3138'] = '\u1104';
  37376. t['\u3139'] = '\u1105';
  37377. t['\u313A'] = '\u11B0';
  37378. t['\u313B'] = '\u11B1';
  37379. t['\u313C'] = '\u11B2';
  37380. t['\u313D'] = '\u11B3';
  37381. t['\u313E'] = '\u11B4';
  37382. t['\u313F'] = '\u11B5';
  37383. t['\u3140'] = '\u111A';
  37384. t['\u3141'] = '\u1106';
  37385. t['\u3142'] = '\u1107';
  37386. t['\u3143'] = '\u1108';
  37387. t['\u3144'] = '\u1121';
  37388. t['\u3145'] = '\u1109';
  37389. t['\u3146'] = '\u110A';
  37390. t['\u3147'] = '\u110B';
  37391. t['\u3148'] = '\u110C';
  37392. t['\u3149'] = '\u110D';
  37393. t['\u314A'] = '\u110E';
  37394. t['\u314B'] = '\u110F';
  37395. t['\u314C'] = '\u1110';
  37396. t['\u314D'] = '\u1111';
  37397. t['\u314E'] = '\u1112';
  37398. t['\u314F'] = '\u1161';
  37399. t['\u3150'] = '\u1162';
  37400. t['\u3151'] = '\u1163';
  37401. t['\u3152'] = '\u1164';
  37402. t['\u3153'] = '\u1165';
  37403. t['\u3154'] = '\u1166';
  37404. t['\u3155'] = '\u1167';
  37405. t['\u3156'] = '\u1168';
  37406. t['\u3157'] = '\u1169';
  37407. t['\u3158'] = '\u116A';
  37408. t['\u3159'] = '\u116B';
  37409. t['\u315A'] = '\u116C';
  37410. t['\u315B'] = '\u116D';
  37411. t['\u315C'] = '\u116E';
  37412. t['\u315D'] = '\u116F';
  37413. t['\u315E'] = '\u1170';
  37414. t['\u315F'] = '\u1171';
  37415. t['\u3160'] = '\u1172';
  37416. t['\u3161'] = '\u1173';
  37417. t['\u3162'] = '\u1174';
  37418. t['\u3163'] = '\u1175';
  37419. t['\u3164'] = '\u1160';
  37420. t['\u3165'] = '\u1114';
  37421. t['\u3166'] = '\u1115';
  37422. t['\u3167'] = '\u11C7';
  37423. t['\u3168'] = '\u11C8';
  37424. t['\u3169'] = '\u11CC';
  37425. t['\u316A'] = '\u11CE';
  37426. t['\u316B'] = '\u11D3';
  37427. t['\u316C'] = '\u11D7';
  37428. t['\u316D'] = '\u11D9';
  37429. t['\u316E'] = '\u111C';
  37430. t['\u316F'] = '\u11DD';
  37431. t['\u3170'] = '\u11DF';
  37432. t['\u3171'] = '\u111D';
  37433. t['\u3172'] = '\u111E';
  37434. t['\u3173'] = '\u1120';
  37435. t['\u3174'] = '\u1122';
  37436. t['\u3175'] = '\u1123';
  37437. t['\u3176'] = '\u1127';
  37438. t['\u3177'] = '\u1129';
  37439. t['\u3178'] = '\u112B';
  37440. t['\u3179'] = '\u112C';
  37441. t['\u317A'] = '\u112D';
  37442. t['\u317B'] = '\u112E';
  37443. t['\u317C'] = '\u112F';
  37444. t['\u317D'] = '\u1132';
  37445. t['\u317E'] = '\u1136';
  37446. t['\u317F'] = '\u1140';
  37447. t['\u3180'] = '\u1147';
  37448. t['\u3181'] = '\u114C';
  37449. t['\u3182'] = '\u11F1';
  37450. t['\u3183'] = '\u11F2';
  37451. t['\u3184'] = '\u1157';
  37452. t['\u3185'] = '\u1158';
  37453. t['\u3186'] = '\u1159';
  37454. t['\u3187'] = '\u1184';
  37455. t['\u3188'] = '\u1185';
  37456. t['\u3189'] = '\u1188';
  37457. t['\u318A'] = '\u1191';
  37458. t['\u318B'] = '\u1192';
  37459. t['\u318C'] = '\u1194';
  37460. t['\u318D'] = '\u119E';
  37461. t['\u318E'] = '\u11A1';
  37462. t['\u3200'] = '\u0028\u1100\u0029';
  37463. t['\u3201'] = '\u0028\u1102\u0029';
  37464. t['\u3202'] = '\u0028\u1103\u0029';
  37465. t['\u3203'] = '\u0028\u1105\u0029';
  37466. t['\u3204'] = '\u0028\u1106\u0029';
  37467. t['\u3205'] = '\u0028\u1107\u0029';
  37468. t['\u3206'] = '\u0028\u1109\u0029';
  37469. t['\u3207'] = '\u0028\u110B\u0029';
  37470. t['\u3208'] = '\u0028\u110C\u0029';
  37471. t['\u3209'] = '\u0028\u110E\u0029';
  37472. t['\u320A'] = '\u0028\u110F\u0029';
  37473. t['\u320B'] = '\u0028\u1110\u0029';
  37474. t['\u320C'] = '\u0028\u1111\u0029';
  37475. t['\u320D'] = '\u0028\u1112\u0029';
  37476. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  37477. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  37478. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  37479. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  37480. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  37481. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  37482. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  37483. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  37484. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  37485. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  37486. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  37487. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  37488. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  37489. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  37490. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  37491. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  37492. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  37493. t['\u3220'] = '\u0028\u4E00\u0029';
  37494. t['\u3221'] = '\u0028\u4E8C\u0029';
  37495. t['\u3222'] = '\u0028\u4E09\u0029';
  37496. t['\u3223'] = '\u0028\u56DB\u0029';
  37497. t['\u3224'] = '\u0028\u4E94\u0029';
  37498. t['\u3225'] = '\u0028\u516D\u0029';
  37499. t['\u3226'] = '\u0028\u4E03\u0029';
  37500. t['\u3227'] = '\u0028\u516B\u0029';
  37501. t['\u3228'] = '\u0028\u4E5D\u0029';
  37502. t['\u3229'] = '\u0028\u5341\u0029';
  37503. t['\u322A'] = '\u0028\u6708\u0029';
  37504. t['\u322B'] = '\u0028\u706B\u0029';
  37505. t['\u322C'] = '\u0028\u6C34\u0029';
  37506. t['\u322D'] = '\u0028\u6728\u0029';
  37507. t['\u322E'] = '\u0028\u91D1\u0029';
  37508. t['\u322F'] = '\u0028\u571F\u0029';
  37509. t['\u3230'] = '\u0028\u65E5\u0029';
  37510. t['\u3231'] = '\u0028\u682A\u0029';
  37511. t['\u3232'] = '\u0028\u6709\u0029';
  37512. t['\u3233'] = '\u0028\u793E\u0029';
  37513. t['\u3234'] = '\u0028\u540D\u0029';
  37514. t['\u3235'] = '\u0028\u7279\u0029';
  37515. t['\u3236'] = '\u0028\u8CA1\u0029';
  37516. t['\u3237'] = '\u0028\u795D\u0029';
  37517. t['\u3238'] = '\u0028\u52B4\u0029';
  37518. t['\u3239'] = '\u0028\u4EE3\u0029';
  37519. t['\u323A'] = '\u0028\u547C\u0029';
  37520. t['\u323B'] = '\u0028\u5B66\u0029';
  37521. t['\u323C'] = '\u0028\u76E3\u0029';
  37522. t['\u323D'] = '\u0028\u4F01\u0029';
  37523. t['\u323E'] = '\u0028\u8CC7\u0029';
  37524. t['\u323F'] = '\u0028\u5354\u0029';
  37525. t['\u3240'] = '\u0028\u796D\u0029';
  37526. t['\u3241'] = '\u0028\u4F11\u0029';
  37527. t['\u3242'] = '\u0028\u81EA\u0029';
  37528. t['\u3243'] = '\u0028\u81F3\u0029';
  37529. t['\u32C0'] = '\u0031\u6708';
  37530. t['\u32C1'] = '\u0032\u6708';
  37531. t['\u32C2'] = '\u0033\u6708';
  37532. t['\u32C3'] = '\u0034\u6708';
  37533. t['\u32C4'] = '\u0035\u6708';
  37534. t['\u32C5'] = '\u0036\u6708';
  37535. t['\u32C6'] = '\u0037\u6708';
  37536. t['\u32C7'] = '\u0038\u6708';
  37537. t['\u32C8'] = '\u0039\u6708';
  37538. t['\u32C9'] = '\u0031\u0030\u6708';
  37539. t['\u32CA'] = '\u0031\u0031\u6708';
  37540. t['\u32CB'] = '\u0031\u0032\u6708';
  37541. t['\u3358'] = '\u0030\u70B9';
  37542. t['\u3359'] = '\u0031\u70B9';
  37543. t['\u335A'] = '\u0032\u70B9';
  37544. t['\u335B'] = '\u0033\u70B9';
  37545. t['\u335C'] = '\u0034\u70B9';
  37546. t['\u335D'] = '\u0035\u70B9';
  37547. t['\u335E'] = '\u0036\u70B9';
  37548. t['\u335F'] = '\u0037\u70B9';
  37549. t['\u3360'] = '\u0038\u70B9';
  37550. t['\u3361'] = '\u0039\u70B9';
  37551. t['\u3362'] = '\u0031\u0030\u70B9';
  37552. t['\u3363'] = '\u0031\u0031\u70B9';
  37553. t['\u3364'] = '\u0031\u0032\u70B9';
  37554. t['\u3365'] = '\u0031\u0033\u70B9';
  37555. t['\u3366'] = '\u0031\u0034\u70B9';
  37556. t['\u3367'] = '\u0031\u0035\u70B9';
  37557. t['\u3368'] = '\u0031\u0036\u70B9';
  37558. t['\u3369'] = '\u0031\u0037\u70B9';
  37559. t['\u336A'] = '\u0031\u0038\u70B9';
  37560. t['\u336B'] = '\u0031\u0039\u70B9';
  37561. t['\u336C'] = '\u0032\u0030\u70B9';
  37562. t['\u336D'] = '\u0032\u0031\u70B9';
  37563. t['\u336E'] = '\u0032\u0032\u70B9';
  37564. t['\u336F'] = '\u0032\u0033\u70B9';
  37565. t['\u3370'] = '\u0032\u0034\u70B9';
  37566. t['\u33E0'] = '\u0031\u65E5';
  37567. t['\u33E1'] = '\u0032\u65E5';
  37568. t['\u33E2'] = '\u0033\u65E5';
  37569. t['\u33E3'] = '\u0034\u65E5';
  37570. t['\u33E4'] = '\u0035\u65E5';
  37571. t['\u33E5'] = '\u0036\u65E5';
  37572. t['\u33E6'] = '\u0037\u65E5';
  37573. t['\u33E7'] = '\u0038\u65E5';
  37574. t['\u33E8'] = '\u0039\u65E5';
  37575. t['\u33E9'] = '\u0031\u0030\u65E5';
  37576. t['\u33EA'] = '\u0031\u0031\u65E5';
  37577. t['\u33EB'] = '\u0031\u0032\u65E5';
  37578. t['\u33EC'] = '\u0031\u0033\u65E5';
  37579. t['\u33ED'] = '\u0031\u0034\u65E5';
  37580. t['\u33EE'] = '\u0031\u0035\u65E5';
  37581. t['\u33EF'] = '\u0031\u0036\u65E5';
  37582. t['\u33F0'] = '\u0031\u0037\u65E5';
  37583. t['\u33F1'] = '\u0031\u0038\u65E5';
  37584. t['\u33F2'] = '\u0031\u0039\u65E5';
  37585. t['\u33F3'] = '\u0032\u0030\u65E5';
  37586. t['\u33F4'] = '\u0032\u0031\u65E5';
  37587. t['\u33F5'] = '\u0032\u0032\u65E5';
  37588. t['\u33F6'] = '\u0032\u0033\u65E5';
  37589. t['\u33F7'] = '\u0032\u0034\u65E5';
  37590. t['\u33F8'] = '\u0032\u0035\u65E5';
  37591. t['\u33F9'] = '\u0032\u0036\u65E5';
  37592. t['\u33FA'] = '\u0032\u0037\u65E5';
  37593. t['\u33FB'] = '\u0032\u0038\u65E5';
  37594. t['\u33FC'] = '\u0032\u0039\u65E5';
  37595. t['\u33FD'] = '\u0033\u0030\u65E5';
  37596. t['\u33FE'] = '\u0033\u0031\u65E5';
  37597. t['\uFB00'] = '\u0066\u0066';
  37598. t['\uFB01'] = '\u0066\u0069';
  37599. t['\uFB02'] = '\u0066\u006C';
  37600. t['\uFB03'] = '\u0066\u0066\u0069';
  37601. t['\uFB04'] = '\u0066\u0066\u006C';
  37602. t['\uFB05'] = '\u017F\u0074';
  37603. t['\uFB06'] = '\u0073\u0074';
  37604. t['\uFB13'] = '\u0574\u0576';
  37605. t['\uFB14'] = '\u0574\u0565';
  37606. t['\uFB15'] = '\u0574\u056B';
  37607. t['\uFB16'] = '\u057E\u0576';
  37608. t['\uFB17'] = '\u0574\u056D';
  37609. t['\uFB4F'] = '\u05D0\u05DC';
  37610. t['\uFB50'] = '\u0671';
  37611. t['\uFB51'] = '\u0671';
  37612. t['\uFB52'] = '\u067B';
  37613. t['\uFB53'] = '\u067B';
  37614. t['\uFB54'] = '\u067B';
  37615. t['\uFB55'] = '\u067B';
  37616. t['\uFB56'] = '\u067E';
  37617. t['\uFB57'] = '\u067E';
  37618. t['\uFB58'] = '\u067E';
  37619. t['\uFB59'] = '\u067E';
  37620. t['\uFB5A'] = '\u0680';
  37621. t['\uFB5B'] = '\u0680';
  37622. t['\uFB5C'] = '\u0680';
  37623. t['\uFB5D'] = '\u0680';
  37624. t['\uFB5E'] = '\u067A';
  37625. t['\uFB5F'] = '\u067A';
  37626. t['\uFB60'] = '\u067A';
  37627. t['\uFB61'] = '\u067A';
  37628. t['\uFB62'] = '\u067F';
  37629. t['\uFB63'] = '\u067F';
  37630. t['\uFB64'] = '\u067F';
  37631. t['\uFB65'] = '\u067F';
  37632. t['\uFB66'] = '\u0679';
  37633. t['\uFB67'] = '\u0679';
  37634. t['\uFB68'] = '\u0679';
  37635. t['\uFB69'] = '\u0679';
  37636. t['\uFB6A'] = '\u06A4';
  37637. t['\uFB6B'] = '\u06A4';
  37638. t['\uFB6C'] = '\u06A4';
  37639. t['\uFB6D'] = '\u06A4';
  37640. t['\uFB6E'] = '\u06A6';
  37641. t['\uFB6F'] = '\u06A6';
  37642. t['\uFB70'] = '\u06A6';
  37643. t['\uFB71'] = '\u06A6';
  37644. t['\uFB72'] = '\u0684';
  37645. t['\uFB73'] = '\u0684';
  37646. t['\uFB74'] = '\u0684';
  37647. t['\uFB75'] = '\u0684';
  37648. t['\uFB76'] = '\u0683';
  37649. t['\uFB77'] = '\u0683';
  37650. t['\uFB78'] = '\u0683';
  37651. t['\uFB79'] = '\u0683';
  37652. t['\uFB7A'] = '\u0686';
  37653. t['\uFB7B'] = '\u0686';
  37654. t['\uFB7C'] = '\u0686';
  37655. t['\uFB7D'] = '\u0686';
  37656. t['\uFB7E'] = '\u0687';
  37657. t['\uFB7F'] = '\u0687';
  37658. t['\uFB80'] = '\u0687';
  37659. t['\uFB81'] = '\u0687';
  37660. t['\uFB82'] = '\u068D';
  37661. t['\uFB83'] = '\u068D';
  37662. t['\uFB84'] = '\u068C';
  37663. t['\uFB85'] = '\u068C';
  37664. t['\uFB86'] = '\u068E';
  37665. t['\uFB87'] = '\u068E';
  37666. t['\uFB88'] = '\u0688';
  37667. t['\uFB89'] = '\u0688';
  37668. t['\uFB8A'] = '\u0698';
  37669. t['\uFB8B'] = '\u0698';
  37670. t['\uFB8C'] = '\u0691';
  37671. t['\uFB8D'] = '\u0691';
  37672. t['\uFB8E'] = '\u06A9';
  37673. t['\uFB8F'] = '\u06A9';
  37674. t['\uFB90'] = '\u06A9';
  37675. t['\uFB91'] = '\u06A9';
  37676. t['\uFB92'] = '\u06AF';
  37677. t['\uFB93'] = '\u06AF';
  37678. t['\uFB94'] = '\u06AF';
  37679. t['\uFB95'] = '\u06AF';
  37680. t['\uFB96'] = '\u06B3';
  37681. t['\uFB97'] = '\u06B3';
  37682. t['\uFB98'] = '\u06B3';
  37683. t['\uFB99'] = '\u06B3';
  37684. t['\uFB9A'] = '\u06B1';
  37685. t['\uFB9B'] = '\u06B1';
  37686. t['\uFB9C'] = '\u06B1';
  37687. t['\uFB9D'] = '\u06B1';
  37688. t['\uFB9E'] = '\u06BA';
  37689. t['\uFB9F'] = '\u06BA';
  37690. t['\uFBA0'] = '\u06BB';
  37691. t['\uFBA1'] = '\u06BB';
  37692. t['\uFBA2'] = '\u06BB';
  37693. t['\uFBA3'] = '\u06BB';
  37694. t['\uFBA4'] = '\u06C0';
  37695. t['\uFBA5'] = '\u06C0';
  37696. t['\uFBA6'] = '\u06C1';
  37697. t['\uFBA7'] = '\u06C1';
  37698. t['\uFBA8'] = '\u06C1';
  37699. t['\uFBA9'] = '\u06C1';
  37700. t['\uFBAA'] = '\u06BE';
  37701. t['\uFBAB'] = '\u06BE';
  37702. t['\uFBAC'] = '\u06BE';
  37703. t['\uFBAD'] = '\u06BE';
  37704. t['\uFBAE'] = '\u06D2';
  37705. t['\uFBAF'] = '\u06D2';
  37706. t['\uFBB0'] = '\u06D3';
  37707. t['\uFBB1'] = '\u06D3';
  37708. t['\uFBD3'] = '\u06AD';
  37709. t['\uFBD4'] = '\u06AD';
  37710. t['\uFBD5'] = '\u06AD';
  37711. t['\uFBD6'] = '\u06AD';
  37712. t['\uFBD7'] = '\u06C7';
  37713. t['\uFBD8'] = '\u06C7';
  37714. t['\uFBD9'] = '\u06C6';
  37715. t['\uFBDA'] = '\u06C6';
  37716. t['\uFBDB'] = '\u06C8';
  37717. t['\uFBDC'] = '\u06C8';
  37718. t['\uFBDD'] = '\u0677';
  37719. t['\uFBDE'] = '\u06CB';
  37720. t['\uFBDF'] = '\u06CB';
  37721. t['\uFBE0'] = '\u06C5';
  37722. t['\uFBE1'] = '\u06C5';
  37723. t['\uFBE2'] = '\u06C9';
  37724. t['\uFBE3'] = '\u06C9';
  37725. t['\uFBE4'] = '\u06D0';
  37726. t['\uFBE5'] = '\u06D0';
  37727. t['\uFBE6'] = '\u06D0';
  37728. t['\uFBE7'] = '\u06D0';
  37729. t['\uFBE8'] = '\u0649';
  37730. t['\uFBE9'] = '\u0649';
  37731. t['\uFBEA'] = '\u0626\u0627';
  37732. t['\uFBEB'] = '\u0626\u0627';
  37733. t['\uFBEC'] = '\u0626\u06D5';
  37734. t['\uFBED'] = '\u0626\u06D5';
  37735. t['\uFBEE'] = '\u0626\u0648';
  37736. t['\uFBEF'] = '\u0626\u0648';
  37737. t['\uFBF0'] = '\u0626\u06C7';
  37738. t['\uFBF1'] = '\u0626\u06C7';
  37739. t['\uFBF2'] = '\u0626\u06C6';
  37740. t['\uFBF3'] = '\u0626\u06C6';
  37741. t['\uFBF4'] = '\u0626\u06C8';
  37742. t['\uFBF5'] = '\u0626\u06C8';
  37743. t['\uFBF6'] = '\u0626\u06D0';
  37744. t['\uFBF7'] = '\u0626\u06D0';
  37745. t['\uFBF8'] = '\u0626\u06D0';
  37746. t['\uFBF9'] = '\u0626\u0649';
  37747. t['\uFBFA'] = '\u0626\u0649';
  37748. t['\uFBFB'] = '\u0626\u0649';
  37749. t['\uFBFC'] = '\u06CC';
  37750. t['\uFBFD'] = '\u06CC';
  37751. t['\uFBFE'] = '\u06CC';
  37752. t['\uFBFF'] = '\u06CC';
  37753. t['\uFC00'] = '\u0626\u062C';
  37754. t['\uFC01'] = '\u0626\u062D';
  37755. t['\uFC02'] = '\u0626\u0645';
  37756. t['\uFC03'] = '\u0626\u0649';
  37757. t['\uFC04'] = '\u0626\u064A';
  37758. t['\uFC05'] = '\u0628\u062C';
  37759. t['\uFC06'] = '\u0628\u062D';
  37760. t['\uFC07'] = '\u0628\u062E';
  37761. t['\uFC08'] = '\u0628\u0645';
  37762. t['\uFC09'] = '\u0628\u0649';
  37763. t['\uFC0A'] = '\u0628\u064A';
  37764. t['\uFC0B'] = '\u062A\u062C';
  37765. t['\uFC0C'] = '\u062A\u062D';
  37766. t['\uFC0D'] = '\u062A\u062E';
  37767. t['\uFC0E'] = '\u062A\u0645';
  37768. t['\uFC0F'] = '\u062A\u0649';
  37769. t['\uFC10'] = '\u062A\u064A';
  37770. t['\uFC11'] = '\u062B\u062C';
  37771. t['\uFC12'] = '\u062B\u0645';
  37772. t['\uFC13'] = '\u062B\u0649';
  37773. t['\uFC14'] = '\u062B\u064A';
  37774. t['\uFC15'] = '\u062C\u062D';
  37775. t['\uFC16'] = '\u062C\u0645';
  37776. t['\uFC17'] = '\u062D\u062C';
  37777. t['\uFC18'] = '\u062D\u0645';
  37778. t['\uFC19'] = '\u062E\u062C';
  37779. t['\uFC1A'] = '\u062E\u062D';
  37780. t['\uFC1B'] = '\u062E\u0645';
  37781. t['\uFC1C'] = '\u0633\u062C';
  37782. t['\uFC1D'] = '\u0633\u062D';
  37783. t['\uFC1E'] = '\u0633\u062E';
  37784. t['\uFC1F'] = '\u0633\u0645';
  37785. t['\uFC20'] = '\u0635\u062D';
  37786. t['\uFC21'] = '\u0635\u0645';
  37787. t['\uFC22'] = '\u0636\u062C';
  37788. t['\uFC23'] = '\u0636\u062D';
  37789. t['\uFC24'] = '\u0636\u062E';
  37790. t['\uFC25'] = '\u0636\u0645';
  37791. t['\uFC26'] = '\u0637\u062D';
  37792. t['\uFC27'] = '\u0637\u0645';
  37793. t['\uFC28'] = '\u0638\u0645';
  37794. t['\uFC29'] = '\u0639\u062C';
  37795. t['\uFC2A'] = '\u0639\u0645';
  37796. t['\uFC2B'] = '\u063A\u062C';
  37797. t['\uFC2C'] = '\u063A\u0645';
  37798. t['\uFC2D'] = '\u0641\u062C';
  37799. t['\uFC2E'] = '\u0641\u062D';
  37800. t['\uFC2F'] = '\u0641\u062E';
  37801. t['\uFC30'] = '\u0641\u0645';
  37802. t['\uFC31'] = '\u0641\u0649';
  37803. t['\uFC32'] = '\u0641\u064A';
  37804. t['\uFC33'] = '\u0642\u062D';
  37805. t['\uFC34'] = '\u0642\u0645';
  37806. t['\uFC35'] = '\u0642\u0649';
  37807. t['\uFC36'] = '\u0642\u064A';
  37808. t['\uFC37'] = '\u0643\u0627';
  37809. t['\uFC38'] = '\u0643\u062C';
  37810. t['\uFC39'] = '\u0643\u062D';
  37811. t['\uFC3A'] = '\u0643\u062E';
  37812. t['\uFC3B'] = '\u0643\u0644';
  37813. t['\uFC3C'] = '\u0643\u0645';
  37814. t['\uFC3D'] = '\u0643\u0649';
  37815. t['\uFC3E'] = '\u0643\u064A';
  37816. t['\uFC3F'] = '\u0644\u062C';
  37817. t['\uFC40'] = '\u0644\u062D';
  37818. t['\uFC41'] = '\u0644\u062E';
  37819. t['\uFC42'] = '\u0644\u0645';
  37820. t['\uFC43'] = '\u0644\u0649';
  37821. t['\uFC44'] = '\u0644\u064A';
  37822. t['\uFC45'] = '\u0645\u062C';
  37823. t['\uFC46'] = '\u0645\u062D';
  37824. t['\uFC47'] = '\u0645\u062E';
  37825. t['\uFC48'] = '\u0645\u0645';
  37826. t['\uFC49'] = '\u0645\u0649';
  37827. t['\uFC4A'] = '\u0645\u064A';
  37828. t['\uFC4B'] = '\u0646\u062C';
  37829. t['\uFC4C'] = '\u0646\u062D';
  37830. t['\uFC4D'] = '\u0646\u062E';
  37831. t['\uFC4E'] = '\u0646\u0645';
  37832. t['\uFC4F'] = '\u0646\u0649';
  37833. t['\uFC50'] = '\u0646\u064A';
  37834. t['\uFC51'] = '\u0647\u062C';
  37835. t['\uFC52'] = '\u0647\u0645';
  37836. t['\uFC53'] = '\u0647\u0649';
  37837. t['\uFC54'] = '\u0647\u064A';
  37838. t['\uFC55'] = '\u064A\u062C';
  37839. t['\uFC56'] = '\u064A\u062D';
  37840. t['\uFC57'] = '\u064A\u062E';
  37841. t['\uFC58'] = '\u064A\u0645';
  37842. t['\uFC59'] = '\u064A\u0649';
  37843. t['\uFC5A'] = '\u064A\u064A';
  37844. t['\uFC5B'] = '\u0630\u0670';
  37845. t['\uFC5C'] = '\u0631\u0670';
  37846. t['\uFC5D'] = '\u0649\u0670';
  37847. t['\uFC5E'] = '\u0020\u064C\u0651';
  37848. t['\uFC5F'] = '\u0020\u064D\u0651';
  37849. t['\uFC60'] = '\u0020\u064E\u0651';
  37850. t['\uFC61'] = '\u0020\u064F\u0651';
  37851. t['\uFC62'] = '\u0020\u0650\u0651';
  37852. t['\uFC63'] = '\u0020\u0651\u0670';
  37853. t['\uFC64'] = '\u0626\u0631';
  37854. t['\uFC65'] = '\u0626\u0632';
  37855. t['\uFC66'] = '\u0626\u0645';
  37856. t['\uFC67'] = '\u0626\u0646';
  37857. t['\uFC68'] = '\u0626\u0649';
  37858. t['\uFC69'] = '\u0626\u064A';
  37859. t['\uFC6A'] = '\u0628\u0631';
  37860. t['\uFC6B'] = '\u0628\u0632';
  37861. t['\uFC6C'] = '\u0628\u0645';
  37862. t['\uFC6D'] = '\u0628\u0646';
  37863. t['\uFC6E'] = '\u0628\u0649';
  37864. t['\uFC6F'] = '\u0628\u064A';
  37865. t['\uFC70'] = '\u062A\u0631';
  37866. t['\uFC71'] = '\u062A\u0632';
  37867. t['\uFC72'] = '\u062A\u0645';
  37868. t['\uFC73'] = '\u062A\u0646';
  37869. t['\uFC74'] = '\u062A\u0649';
  37870. t['\uFC75'] = '\u062A\u064A';
  37871. t['\uFC76'] = '\u062B\u0631';
  37872. t['\uFC77'] = '\u062B\u0632';
  37873. t['\uFC78'] = '\u062B\u0645';
  37874. t['\uFC79'] = '\u062B\u0646';
  37875. t['\uFC7A'] = '\u062B\u0649';
  37876. t['\uFC7B'] = '\u062B\u064A';
  37877. t['\uFC7C'] = '\u0641\u0649';
  37878. t['\uFC7D'] = '\u0641\u064A';
  37879. t['\uFC7E'] = '\u0642\u0649';
  37880. t['\uFC7F'] = '\u0642\u064A';
  37881. t['\uFC80'] = '\u0643\u0627';
  37882. t['\uFC81'] = '\u0643\u0644';
  37883. t['\uFC82'] = '\u0643\u0645';
  37884. t['\uFC83'] = '\u0643\u0649';
  37885. t['\uFC84'] = '\u0643\u064A';
  37886. t['\uFC85'] = '\u0644\u0645';
  37887. t['\uFC86'] = '\u0644\u0649';
  37888. t['\uFC87'] = '\u0644\u064A';
  37889. t['\uFC88'] = '\u0645\u0627';
  37890. t['\uFC89'] = '\u0645\u0645';
  37891. t['\uFC8A'] = '\u0646\u0631';
  37892. t['\uFC8B'] = '\u0646\u0632';
  37893. t['\uFC8C'] = '\u0646\u0645';
  37894. t['\uFC8D'] = '\u0646\u0646';
  37895. t['\uFC8E'] = '\u0646\u0649';
  37896. t['\uFC8F'] = '\u0646\u064A';
  37897. t['\uFC90'] = '\u0649\u0670';
  37898. t['\uFC91'] = '\u064A\u0631';
  37899. t['\uFC92'] = '\u064A\u0632';
  37900. t['\uFC93'] = '\u064A\u0645';
  37901. t['\uFC94'] = '\u064A\u0646';
  37902. t['\uFC95'] = '\u064A\u0649';
  37903. t['\uFC96'] = '\u064A\u064A';
  37904. t['\uFC97'] = '\u0626\u062C';
  37905. t['\uFC98'] = '\u0626\u062D';
  37906. t['\uFC99'] = '\u0626\u062E';
  37907. t['\uFC9A'] = '\u0626\u0645';
  37908. t['\uFC9B'] = '\u0626\u0647';
  37909. t['\uFC9C'] = '\u0628\u062C';
  37910. t['\uFC9D'] = '\u0628\u062D';
  37911. t['\uFC9E'] = '\u0628\u062E';
  37912. t['\uFC9F'] = '\u0628\u0645';
  37913. t['\uFCA0'] = '\u0628\u0647';
  37914. t['\uFCA1'] = '\u062A\u062C';
  37915. t['\uFCA2'] = '\u062A\u062D';
  37916. t['\uFCA3'] = '\u062A\u062E';
  37917. t['\uFCA4'] = '\u062A\u0645';
  37918. t['\uFCA5'] = '\u062A\u0647';
  37919. t['\uFCA6'] = '\u062B\u0645';
  37920. t['\uFCA7'] = '\u062C\u062D';
  37921. t['\uFCA8'] = '\u062C\u0645';
  37922. t['\uFCA9'] = '\u062D\u062C';
  37923. t['\uFCAA'] = '\u062D\u0645';
  37924. t['\uFCAB'] = '\u062E\u062C';
  37925. t['\uFCAC'] = '\u062E\u0645';
  37926. t['\uFCAD'] = '\u0633\u062C';
  37927. t['\uFCAE'] = '\u0633\u062D';
  37928. t['\uFCAF'] = '\u0633\u062E';
  37929. t['\uFCB0'] = '\u0633\u0645';
  37930. t['\uFCB1'] = '\u0635\u062D';
  37931. t['\uFCB2'] = '\u0635\u062E';
  37932. t['\uFCB3'] = '\u0635\u0645';
  37933. t['\uFCB4'] = '\u0636\u062C';
  37934. t['\uFCB5'] = '\u0636\u062D';
  37935. t['\uFCB6'] = '\u0636\u062E';
  37936. t['\uFCB7'] = '\u0636\u0645';
  37937. t['\uFCB8'] = '\u0637\u062D';
  37938. t['\uFCB9'] = '\u0638\u0645';
  37939. t['\uFCBA'] = '\u0639\u062C';
  37940. t['\uFCBB'] = '\u0639\u0645';
  37941. t['\uFCBC'] = '\u063A\u062C';
  37942. t['\uFCBD'] = '\u063A\u0645';
  37943. t['\uFCBE'] = '\u0641\u062C';
  37944. t['\uFCBF'] = '\u0641\u062D';
  37945. t['\uFCC0'] = '\u0641\u062E';
  37946. t['\uFCC1'] = '\u0641\u0645';
  37947. t['\uFCC2'] = '\u0642\u062D';
  37948. t['\uFCC3'] = '\u0642\u0645';
  37949. t['\uFCC4'] = '\u0643\u062C';
  37950. t['\uFCC5'] = '\u0643\u062D';
  37951. t['\uFCC6'] = '\u0643\u062E';
  37952. t['\uFCC7'] = '\u0643\u0644';
  37953. t['\uFCC8'] = '\u0643\u0645';
  37954. t['\uFCC9'] = '\u0644\u062C';
  37955. t['\uFCCA'] = '\u0644\u062D';
  37956. t['\uFCCB'] = '\u0644\u062E';
  37957. t['\uFCCC'] = '\u0644\u0645';
  37958. t['\uFCCD'] = '\u0644\u0647';
  37959. t['\uFCCE'] = '\u0645\u062C';
  37960. t['\uFCCF'] = '\u0645\u062D';
  37961. t['\uFCD0'] = '\u0645\u062E';
  37962. t['\uFCD1'] = '\u0645\u0645';
  37963. t['\uFCD2'] = '\u0646\u062C';
  37964. t['\uFCD3'] = '\u0646\u062D';
  37965. t['\uFCD4'] = '\u0646\u062E';
  37966. t['\uFCD5'] = '\u0646\u0645';
  37967. t['\uFCD6'] = '\u0646\u0647';
  37968. t['\uFCD7'] = '\u0647\u062C';
  37969. t['\uFCD8'] = '\u0647\u0645';
  37970. t['\uFCD9'] = '\u0647\u0670';
  37971. t['\uFCDA'] = '\u064A\u062C';
  37972. t['\uFCDB'] = '\u064A\u062D';
  37973. t['\uFCDC'] = '\u064A\u062E';
  37974. t['\uFCDD'] = '\u064A\u0645';
  37975. t['\uFCDE'] = '\u064A\u0647';
  37976. t['\uFCDF'] = '\u0626\u0645';
  37977. t['\uFCE0'] = '\u0626\u0647';
  37978. t['\uFCE1'] = '\u0628\u0645';
  37979. t['\uFCE2'] = '\u0628\u0647';
  37980. t['\uFCE3'] = '\u062A\u0645';
  37981. t['\uFCE4'] = '\u062A\u0647';
  37982. t['\uFCE5'] = '\u062B\u0645';
  37983. t['\uFCE6'] = '\u062B\u0647';
  37984. t['\uFCE7'] = '\u0633\u0645';
  37985. t['\uFCE8'] = '\u0633\u0647';
  37986. t['\uFCE9'] = '\u0634\u0645';
  37987. t['\uFCEA'] = '\u0634\u0647';
  37988. t['\uFCEB'] = '\u0643\u0644';
  37989. t['\uFCEC'] = '\u0643\u0645';
  37990. t['\uFCED'] = '\u0644\u0645';
  37991. t['\uFCEE'] = '\u0646\u0645';
  37992. t['\uFCEF'] = '\u0646\u0647';
  37993. t['\uFCF0'] = '\u064A\u0645';
  37994. t['\uFCF1'] = '\u064A\u0647';
  37995. t['\uFCF2'] = '\u0640\u064E\u0651';
  37996. t['\uFCF3'] = '\u0640\u064F\u0651';
  37997. t['\uFCF4'] = '\u0640\u0650\u0651';
  37998. t['\uFCF5'] = '\u0637\u0649';
  37999. t['\uFCF6'] = '\u0637\u064A';
  38000. t['\uFCF7'] = '\u0639\u0649';
  38001. t['\uFCF8'] = '\u0639\u064A';
  38002. t['\uFCF9'] = '\u063A\u0649';
  38003. t['\uFCFA'] = '\u063A\u064A';
  38004. t['\uFCFB'] = '\u0633\u0649';
  38005. t['\uFCFC'] = '\u0633\u064A';
  38006. t['\uFCFD'] = '\u0634\u0649';
  38007. t['\uFCFE'] = '\u0634\u064A';
  38008. t['\uFCFF'] = '\u062D\u0649';
  38009. t['\uFD00'] = '\u062D\u064A';
  38010. t['\uFD01'] = '\u062C\u0649';
  38011. t['\uFD02'] = '\u062C\u064A';
  38012. t['\uFD03'] = '\u062E\u0649';
  38013. t['\uFD04'] = '\u062E\u064A';
  38014. t['\uFD05'] = '\u0635\u0649';
  38015. t['\uFD06'] = '\u0635\u064A';
  38016. t['\uFD07'] = '\u0636\u0649';
  38017. t['\uFD08'] = '\u0636\u064A';
  38018. t['\uFD09'] = '\u0634\u062C';
  38019. t['\uFD0A'] = '\u0634\u062D';
  38020. t['\uFD0B'] = '\u0634\u062E';
  38021. t['\uFD0C'] = '\u0634\u0645';
  38022. t['\uFD0D'] = '\u0634\u0631';
  38023. t['\uFD0E'] = '\u0633\u0631';
  38024. t['\uFD0F'] = '\u0635\u0631';
  38025. t['\uFD10'] = '\u0636\u0631';
  38026. t['\uFD11'] = '\u0637\u0649';
  38027. t['\uFD12'] = '\u0637\u064A';
  38028. t['\uFD13'] = '\u0639\u0649';
  38029. t['\uFD14'] = '\u0639\u064A';
  38030. t['\uFD15'] = '\u063A\u0649';
  38031. t['\uFD16'] = '\u063A\u064A';
  38032. t['\uFD17'] = '\u0633\u0649';
  38033. t['\uFD18'] = '\u0633\u064A';
  38034. t['\uFD19'] = '\u0634\u0649';
  38035. t['\uFD1A'] = '\u0634\u064A';
  38036. t['\uFD1B'] = '\u062D\u0649';
  38037. t['\uFD1C'] = '\u062D\u064A';
  38038. t['\uFD1D'] = '\u062C\u0649';
  38039. t['\uFD1E'] = '\u062C\u064A';
  38040. t['\uFD1F'] = '\u062E\u0649';
  38041. t['\uFD20'] = '\u062E\u064A';
  38042. t['\uFD21'] = '\u0635\u0649';
  38043. t['\uFD22'] = '\u0635\u064A';
  38044. t['\uFD23'] = '\u0636\u0649';
  38045. t['\uFD24'] = '\u0636\u064A';
  38046. t['\uFD25'] = '\u0634\u062C';
  38047. t['\uFD26'] = '\u0634\u062D';
  38048. t['\uFD27'] = '\u0634\u062E';
  38049. t['\uFD28'] = '\u0634\u0645';
  38050. t['\uFD29'] = '\u0634\u0631';
  38051. t['\uFD2A'] = '\u0633\u0631';
  38052. t['\uFD2B'] = '\u0635\u0631';
  38053. t['\uFD2C'] = '\u0636\u0631';
  38054. t['\uFD2D'] = '\u0634\u062C';
  38055. t['\uFD2E'] = '\u0634\u062D';
  38056. t['\uFD2F'] = '\u0634\u062E';
  38057. t['\uFD30'] = '\u0634\u0645';
  38058. t['\uFD31'] = '\u0633\u0647';
  38059. t['\uFD32'] = '\u0634\u0647';
  38060. t['\uFD33'] = '\u0637\u0645';
  38061. t['\uFD34'] = '\u0633\u062C';
  38062. t['\uFD35'] = '\u0633\u062D';
  38063. t['\uFD36'] = '\u0633\u062E';
  38064. t['\uFD37'] = '\u0634\u062C';
  38065. t['\uFD38'] = '\u0634\u062D';
  38066. t['\uFD39'] = '\u0634\u062E';
  38067. t['\uFD3A'] = '\u0637\u0645';
  38068. t['\uFD3B'] = '\u0638\u0645';
  38069. t['\uFD3C'] = '\u0627\u064B';
  38070. t['\uFD3D'] = '\u0627\u064B';
  38071. t['\uFD50'] = '\u062A\u062C\u0645';
  38072. t['\uFD51'] = '\u062A\u062D\u062C';
  38073. t['\uFD52'] = '\u062A\u062D\u062C';
  38074. t['\uFD53'] = '\u062A\u062D\u0645';
  38075. t['\uFD54'] = '\u062A\u062E\u0645';
  38076. t['\uFD55'] = '\u062A\u0645\u062C';
  38077. t['\uFD56'] = '\u062A\u0645\u062D';
  38078. t['\uFD57'] = '\u062A\u0645\u062E';
  38079. t['\uFD58'] = '\u062C\u0645\u062D';
  38080. t['\uFD59'] = '\u062C\u0645\u062D';
  38081. t['\uFD5A'] = '\u062D\u0645\u064A';
  38082. t['\uFD5B'] = '\u062D\u0645\u0649';
  38083. t['\uFD5C'] = '\u0633\u062D\u062C';
  38084. t['\uFD5D'] = '\u0633\u062C\u062D';
  38085. t['\uFD5E'] = '\u0633\u062C\u0649';
  38086. t['\uFD5F'] = '\u0633\u0645\u062D';
  38087. t['\uFD60'] = '\u0633\u0645\u062D';
  38088. t['\uFD61'] = '\u0633\u0645\u062C';
  38089. t['\uFD62'] = '\u0633\u0645\u0645';
  38090. t['\uFD63'] = '\u0633\u0645\u0645';
  38091. t['\uFD64'] = '\u0635\u062D\u062D';
  38092. t['\uFD65'] = '\u0635\u062D\u062D';
  38093. t['\uFD66'] = '\u0635\u0645\u0645';
  38094. t['\uFD67'] = '\u0634\u062D\u0645';
  38095. t['\uFD68'] = '\u0634\u062D\u0645';
  38096. t['\uFD69'] = '\u0634\u062C\u064A';
  38097. t['\uFD6A'] = '\u0634\u0645\u062E';
  38098. t['\uFD6B'] = '\u0634\u0645\u062E';
  38099. t['\uFD6C'] = '\u0634\u0645\u0645';
  38100. t['\uFD6D'] = '\u0634\u0645\u0645';
  38101. t['\uFD6E'] = '\u0636\u062D\u0649';
  38102. t['\uFD6F'] = '\u0636\u062E\u0645';
  38103. t['\uFD70'] = '\u0636\u062E\u0645';
  38104. t['\uFD71'] = '\u0637\u0645\u062D';
  38105. t['\uFD72'] = '\u0637\u0645\u062D';
  38106. t['\uFD73'] = '\u0637\u0645\u0645';
  38107. t['\uFD74'] = '\u0637\u0645\u064A';
  38108. t['\uFD75'] = '\u0639\u062C\u0645';
  38109. t['\uFD76'] = '\u0639\u0645\u0645';
  38110. t['\uFD77'] = '\u0639\u0645\u0645';
  38111. t['\uFD78'] = '\u0639\u0645\u0649';
  38112. t['\uFD79'] = '\u063A\u0645\u0645';
  38113. t['\uFD7A'] = '\u063A\u0645\u064A';
  38114. t['\uFD7B'] = '\u063A\u0645\u0649';
  38115. t['\uFD7C'] = '\u0641\u062E\u0645';
  38116. t['\uFD7D'] = '\u0641\u062E\u0645';
  38117. t['\uFD7E'] = '\u0642\u0645\u062D';
  38118. t['\uFD7F'] = '\u0642\u0645\u0645';
  38119. t['\uFD80'] = '\u0644\u062D\u0645';
  38120. t['\uFD81'] = '\u0644\u062D\u064A';
  38121. t['\uFD82'] = '\u0644\u062D\u0649';
  38122. t['\uFD83'] = '\u0644\u062C\u062C';
  38123. t['\uFD84'] = '\u0644\u062C\u062C';
  38124. t['\uFD85'] = '\u0644\u062E\u0645';
  38125. t['\uFD86'] = '\u0644\u062E\u0645';
  38126. t['\uFD87'] = '\u0644\u0645\u062D';
  38127. t['\uFD88'] = '\u0644\u0645\u062D';
  38128. t['\uFD89'] = '\u0645\u062D\u062C';
  38129. t['\uFD8A'] = '\u0645\u062D\u0645';
  38130. t['\uFD8B'] = '\u0645\u062D\u064A';
  38131. t['\uFD8C'] = '\u0645\u062C\u062D';
  38132. t['\uFD8D'] = '\u0645\u062C\u0645';
  38133. t['\uFD8E'] = '\u0645\u062E\u062C';
  38134. t['\uFD8F'] = '\u0645\u062E\u0645';
  38135. t['\uFD92'] = '\u0645\u062C\u062E';
  38136. t['\uFD93'] = '\u0647\u0645\u062C';
  38137. t['\uFD94'] = '\u0647\u0645\u0645';
  38138. t['\uFD95'] = '\u0646\u062D\u0645';
  38139. t['\uFD96'] = '\u0646\u062D\u0649';
  38140. t['\uFD97'] = '\u0646\u062C\u0645';
  38141. t['\uFD98'] = '\u0646\u062C\u0645';
  38142. t['\uFD99'] = '\u0646\u062C\u0649';
  38143. t['\uFD9A'] = '\u0646\u0645\u064A';
  38144. t['\uFD9B'] = '\u0646\u0645\u0649';
  38145. t['\uFD9C'] = '\u064A\u0645\u0645';
  38146. t['\uFD9D'] = '\u064A\u0645\u0645';
  38147. t['\uFD9E'] = '\u0628\u062E\u064A';
  38148. t['\uFD9F'] = '\u062A\u062C\u064A';
  38149. t['\uFDA0'] = '\u062A\u062C\u0649';
  38150. t['\uFDA1'] = '\u062A\u062E\u064A';
  38151. t['\uFDA2'] = '\u062A\u062E\u0649';
  38152. t['\uFDA3'] = '\u062A\u0645\u064A';
  38153. t['\uFDA4'] = '\u062A\u0645\u0649';
  38154. t['\uFDA5'] = '\u062C\u0645\u064A';
  38155. t['\uFDA6'] = '\u062C\u062D\u0649';
  38156. t['\uFDA7'] = '\u062C\u0645\u0649';
  38157. t['\uFDA8'] = '\u0633\u062E\u0649';
  38158. t['\uFDA9'] = '\u0635\u062D\u064A';
  38159. t['\uFDAA'] = '\u0634\u062D\u064A';
  38160. t['\uFDAB'] = '\u0636\u062D\u064A';
  38161. t['\uFDAC'] = '\u0644\u062C\u064A';
  38162. t['\uFDAD'] = '\u0644\u0645\u064A';
  38163. t['\uFDAE'] = '\u064A\u062D\u064A';
  38164. t['\uFDAF'] = '\u064A\u062C\u064A';
  38165. t['\uFDB0'] = '\u064A\u0645\u064A';
  38166. t['\uFDB1'] = '\u0645\u0645\u064A';
  38167. t['\uFDB2'] = '\u0642\u0645\u064A';
  38168. t['\uFDB3'] = '\u0646\u062D\u064A';
  38169. t['\uFDB4'] = '\u0642\u0645\u062D';
  38170. t['\uFDB5'] = '\u0644\u062D\u0645';
  38171. t['\uFDB6'] = '\u0639\u0645\u064A';
  38172. t['\uFDB7'] = '\u0643\u0645\u064A';
  38173. t['\uFDB8'] = '\u0646\u062C\u062D';
  38174. t['\uFDB9'] = '\u0645\u062E\u064A';
  38175. t['\uFDBA'] = '\u0644\u062C\u0645';
  38176. t['\uFDBB'] = '\u0643\u0645\u0645';
  38177. t['\uFDBC'] = '\u0644\u062C\u0645';
  38178. t['\uFDBD'] = '\u0646\u062C\u062D';
  38179. t['\uFDBE'] = '\u062C\u062D\u064A';
  38180. t['\uFDBF'] = '\u062D\u062C\u064A';
  38181. t['\uFDC0'] = '\u0645\u062C\u064A';
  38182. t['\uFDC1'] = '\u0641\u0645\u064A';
  38183. t['\uFDC2'] = '\u0628\u062D\u064A';
  38184. t['\uFDC3'] = '\u0643\u0645\u0645';
  38185. t['\uFDC4'] = '\u0639\u062C\u0645';
  38186. t['\uFDC5'] = '\u0635\u0645\u0645';
  38187. t['\uFDC6'] = '\u0633\u062E\u064A';
  38188. t['\uFDC7'] = '\u0646\u062C\u064A';
  38189. t['\uFE49'] = '\u203E';
  38190. t['\uFE4A'] = '\u203E';
  38191. t['\uFE4B'] = '\u203E';
  38192. t['\uFE4C'] = '\u203E';
  38193. t['\uFE4D'] = '\u005F';
  38194. t['\uFE4E'] = '\u005F';
  38195. t['\uFE4F'] = '\u005F';
  38196. t['\uFE80'] = '\u0621';
  38197. t['\uFE81'] = '\u0622';
  38198. t['\uFE82'] = '\u0622';
  38199. t['\uFE83'] = '\u0623';
  38200. t['\uFE84'] = '\u0623';
  38201. t['\uFE85'] = '\u0624';
  38202. t['\uFE86'] = '\u0624';
  38203. t['\uFE87'] = '\u0625';
  38204. t['\uFE88'] = '\u0625';
  38205. t['\uFE89'] = '\u0626';
  38206. t['\uFE8A'] = '\u0626';
  38207. t['\uFE8B'] = '\u0626';
  38208. t['\uFE8C'] = '\u0626';
  38209. t['\uFE8D'] = '\u0627';
  38210. t['\uFE8E'] = '\u0627';
  38211. t['\uFE8F'] = '\u0628';
  38212. t['\uFE90'] = '\u0628';
  38213. t['\uFE91'] = '\u0628';
  38214. t['\uFE92'] = '\u0628';
  38215. t['\uFE93'] = '\u0629';
  38216. t['\uFE94'] = '\u0629';
  38217. t['\uFE95'] = '\u062A';
  38218. t['\uFE96'] = '\u062A';
  38219. t['\uFE97'] = '\u062A';
  38220. t['\uFE98'] = '\u062A';
  38221. t['\uFE99'] = '\u062B';
  38222. t['\uFE9A'] = '\u062B';
  38223. t['\uFE9B'] = '\u062B';
  38224. t['\uFE9C'] = '\u062B';
  38225. t['\uFE9D'] = '\u062C';
  38226. t['\uFE9E'] = '\u062C';
  38227. t['\uFE9F'] = '\u062C';
  38228. t['\uFEA0'] = '\u062C';
  38229. t['\uFEA1'] = '\u062D';
  38230. t['\uFEA2'] = '\u062D';
  38231. t['\uFEA3'] = '\u062D';
  38232. t['\uFEA4'] = '\u062D';
  38233. t['\uFEA5'] = '\u062E';
  38234. t['\uFEA6'] = '\u062E';
  38235. t['\uFEA7'] = '\u062E';
  38236. t['\uFEA8'] = '\u062E';
  38237. t['\uFEA9'] = '\u062F';
  38238. t['\uFEAA'] = '\u062F';
  38239. t['\uFEAB'] = '\u0630';
  38240. t['\uFEAC'] = '\u0630';
  38241. t['\uFEAD'] = '\u0631';
  38242. t['\uFEAE'] = '\u0631';
  38243. t['\uFEAF'] = '\u0632';
  38244. t['\uFEB0'] = '\u0632';
  38245. t['\uFEB1'] = '\u0633';
  38246. t['\uFEB2'] = '\u0633';
  38247. t['\uFEB3'] = '\u0633';
  38248. t['\uFEB4'] = '\u0633';
  38249. t['\uFEB5'] = '\u0634';
  38250. t['\uFEB6'] = '\u0634';
  38251. t['\uFEB7'] = '\u0634';
  38252. t['\uFEB8'] = '\u0634';
  38253. t['\uFEB9'] = '\u0635';
  38254. t['\uFEBA'] = '\u0635';
  38255. t['\uFEBB'] = '\u0635';
  38256. t['\uFEBC'] = '\u0635';
  38257. t['\uFEBD'] = '\u0636';
  38258. t['\uFEBE'] = '\u0636';
  38259. t['\uFEBF'] = '\u0636';
  38260. t['\uFEC0'] = '\u0636';
  38261. t['\uFEC1'] = '\u0637';
  38262. t['\uFEC2'] = '\u0637';
  38263. t['\uFEC3'] = '\u0637';
  38264. t['\uFEC4'] = '\u0637';
  38265. t['\uFEC5'] = '\u0638';
  38266. t['\uFEC6'] = '\u0638';
  38267. t['\uFEC7'] = '\u0638';
  38268. t['\uFEC8'] = '\u0638';
  38269. t['\uFEC9'] = '\u0639';
  38270. t['\uFECA'] = '\u0639';
  38271. t['\uFECB'] = '\u0639';
  38272. t['\uFECC'] = '\u0639';
  38273. t['\uFECD'] = '\u063A';
  38274. t['\uFECE'] = '\u063A';
  38275. t['\uFECF'] = '\u063A';
  38276. t['\uFED0'] = '\u063A';
  38277. t['\uFED1'] = '\u0641';
  38278. t['\uFED2'] = '\u0641';
  38279. t['\uFED3'] = '\u0641';
  38280. t['\uFED4'] = '\u0641';
  38281. t['\uFED5'] = '\u0642';
  38282. t['\uFED6'] = '\u0642';
  38283. t['\uFED7'] = '\u0642';
  38284. t['\uFED8'] = '\u0642';
  38285. t['\uFED9'] = '\u0643';
  38286. t['\uFEDA'] = '\u0643';
  38287. t['\uFEDB'] = '\u0643';
  38288. t['\uFEDC'] = '\u0643';
  38289. t['\uFEDD'] = '\u0644';
  38290. t['\uFEDE'] = '\u0644';
  38291. t['\uFEDF'] = '\u0644';
  38292. t['\uFEE0'] = '\u0644';
  38293. t['\uFEE1'] = '\u0645';
  38294. t['\uFEE2'] = '\u0645';
  38295. t['\uFEE3'] = '\u0645';
  38296. t['\uFEE4'] = '\u0645';
  38297. t['\uFEE5'] = '\u0646';
  38298. t['\uFEE6'] = '\u0646';
  38299. t['\uFEE7'] = '\u0646';
  38300. t['\uFEE8'] = '\u0646';
  38301. t['\uFEE9'] = '\u0647';
  38302. t['\uFEEA'] = '\u0647';
  38303. t['\uFEEB'] = '\u0647';
  38304. t['\uFEEC'] = '\u0647';
  38305. t['\uFEED'] = '\u0648';
  38306. t['\uFEEE'] = '\u0648';
  38307. t['\uFEEF'] = '\u0649';
  38308. t['\uFEF0'] = '\u0649';
  38309. t['\uFEF1'] = '\u064A';
  38310. t['\uFEF2'] = '\u064A';
  38311. t['\uFEF3'] = '\u064A';
  38312. t['\uFEF4'] = '\u064A';
  38313. t['\uFEF5'] = '\u0644\u0622';
  38314. t['\uFEF6'] = '\u0644\u0622';
  38315. t['\uFEF7'] = '\u0644\u0623';
  38316. t['\uFEF8'] = '\u0644\u0623';
  38317. t['\uFEF9'] = '\u0644\u0625';
  38318. t['\uFEFA'] = '\u0644\u0625';
  38319. t['\uFEFB'] = '\u0644\u0627';
  38320. t['\uFEFC'] = '\u0644\u0627';
  38321. });
  38322. function reverseIfRtl(chars) {
  38323. var charsLength = chars.length;
  38324. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  38325. return chars;
  38326. }
  38327. var s = '';
  38328. for (var ii = charsLength - 1; ii >= 0; ii--) {
  38329. s += chars[ii];
  38330. }
  38331. return s;
  38332. }
  38333. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  38334. exports.reverseIfRtl = reverseIfRtl;
  38335. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  38336. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  38337. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  38338. /***/ }),
  38339. /* 22 */
  38340. /***/ (function(module, exports, __w_pdfjs_require__) {
  38341. "use strict";
  38342. var sharedUtil = __w_pdfjs_require__(0);
  38343. var corePrimitives = __w_pdfjs_require__(1);
  38344. var corePdfManager = __w_pdfjs_require__(41);
  38345. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  38346. var InvalidPDFException = sharedUtil.InvalidPDFException;
  38347. var MessageHandler = sharedUtil.MessageHandler;
  38348. var MissingPDFException = sharedUtil.MissingPDFException;
  38349. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  38350. var PasswordException = sharedUtil.PasswordException;
  38351. var UnknownErrorException = sharedUtil.UnknownErrorException;
  38352. var XRefParseException = sharedUtil.XRefParseException;
  38353. var arrayByteLength = sharedUtil.arrayByteLength;
  38354. var arraysToBytes = sharedUtil.arraysToBytes;
  38355. var assert = sharedUtil.assert;
  38356. var createPromiseCapability = sharedUtil.createPromiseCapability;
  38357. var error = sharedUtil.error;
  38358. var info = sharedUtil.info;
  38359. var warn = sharedUtil.warn;
  38360. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  38361. var isNodeJS = sharedUtil.isNodeJS;
  38362. var Ref = corePrimitives.Ref;
  38363. var LocalPdfManager = corePdfManager.LocalPdfManager;
  38364. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  38365. var globalScope = sharedUtil.globalScope;
  38366. var WorkerTask = function WorkerTaskClosure() {
  38367. function WorkerTask(name) {
  38368. this.name = name;
  38369. this.terminated = false;
  38370. this._capability = createPromiseCapability();
  38371. }
  38372. WorkerTask.prototype = {
  38373. get finished() {
  38374. return this._capability.promise;
  38375. },
  38376. finish: function () {
  38377. this._capability.resolve();
  38378. },
  38379. terminate: function () {
  38380. this.terminated = true;
  38381. },
  38382. ensureNotTerminated: function () {
  38383. if (this.terminated) {
  38384. throw new Error('Worker task was terminated');
  38385. }
  38386. }
  38387. };
  38388. return WorkerTask;
  38389. }();
  38390. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  38391. function PDFWorkerStream(params, msgHandler) {
  38392. this._queuedChunks = [];
  38393. var initialData = params.initialData;
  38394. if (initialData && initialData.length > 0) {
  38395. this._queuedChunks.push(initialData);
  38396. }
  38397. this._msgHandler = msgHandler;
  38398. this._isRangeSupported = !params.disableRange;
  38399. this._isStreamingSupported = !params.disableStream;
  38400. this._contentLength = params.length;
  38401. this._fullRequestReader = null;
  38402. this._rangeReaders = [];
  38403. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  38404. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  38405. }
  38406. PDFWorkerStream.prototype = {
  38407. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  38408. if (args.begin === undefined) {
  38409. if (this._fullRequestReader) {
  38410. this._fullRequestReader._enqueue(args.chunk);
  38411. } else {
  38412. this._queuedChunks.push(args.chunk);
  38413. }
  38414. } else {
  38415. var found = this._rangeReaders.some(function (rangeReader) {
  38416. if (rangeReader._begin !== args.begin) {
  38417. return false;
  38418. }
  38419. rangeReader._enqueue(args.chunk);
  38420. return true;
  38421. });
  38422. assert(found);
  38423. }
  38424. },
  38425. _onProgress: function PDFWorkerStream_onProgress(evt) {
  38426. if (this._rangeReaders.length > 0) {
  38427. var firstReader = this._rangeReaders[0];
  38428. if (firstReader.onProgress) {
  38429. firstReader.onProgress({ loaded: evt.loaded });
  38430. }
  38431. }
  38432. },
  38433. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  38434. var i = this._rangeReaders.indexOf(reader);
  38435. if (i >= 0) {
  38436. this._rangeReaders.splice(i, 1);
  38437. }
  38438. },
  38439. getFullReader: function PDFWorkerStream_getFullReader() {
  38440. assert(!this._fullRequestReader);
  38441. var queuedChunks = this._queuedChunks;
  38442. this._queuedChunks = null;
  38443. return new PDFWorkerStreamReader(this, queuedChunks);
  38444. },
  38445. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  38446. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  38447. this._msgHandler.send('RequestDataRange', {
  38448. begin: begin,
  38449. end: end
  38450. });
  38451. this._rangeReaders.push(reader);
  38452. return reader;
  38453. },
  38454. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  38455. if (this._fullRequestReader) {
  38456. this._fullRequestReader.cancel(reason);
  38457. }
  38458. var readers = this._rangeReaders.slice(0);
  38459. readers.forEach(function (rangeReader) {
  38460. rangeReader.cancel(reason);
  38461. });
  38462. }
  38463. };
  38464. function PDFWorkerStreamReader(stream, queuedChunks) {
  38465. this._stream = stream;
  38466. this._done = false;
  38467. this._queuedChunks = queuedChunks || [];
  38468. this._requests = [];
  38469. this._headersReady = Promise.resolve();
  38470. stream._fullRequestReader = this;
  38471. this.onProgress = null;
  38472. }
  38473. PDFWorkerStreamReader.prototype = {
  38474. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  38475. if (this._done) {
  38476. return;
  38477. }
  38478. if (this._requests.length > 0) {
  38479. var requestCapability = this._requests.shift();
  38480. requestCapability.resolve({
  38481. value: chunk,
  38482. done: false
  38483. });
  38484. return;
  38485. }
  38486. this._queuedChunks.push(chunk);
  38487. },
  38488. get headersReady() {
  38489. return this._headersReady;
  38490. },
  38491. get isRangeSupported() {
  38492. return this._stream._isRangeSupported;
  38493. },
  38494. get isStreamingSupported() {
  38495. return this._stream._isStreamingSupported;
  38496. },
  38497. get contentLength() {
  38498. return this._stream._contentLength;
  38499. },
  38500. read: function PDFWorkerStreamReader_read() {
  38501. if (this._queuedChunks.length > 0) {
  38502. var chunk = this._queuedChunks.shift();
  38503. return Promise.resolve({
  38504. value: chunk,
  38505. done: false
  38506. });
  38507. }
  38508. if (this._done) {
  38509. return Promise.resolve({
  38510. value: undefined,
  38511. done: true
  38512. });
  38513. }
  38514. var requestCapability = createPromiseCapability();
  38515. this._requests.push(requestCapability);
  38516. return requestCapability.promise;
  38517. },
  38518. cancel: function PDFWorkerStreamReader_cancel(reason) {
  38519. this._done = true;
  38520. this._requests.forEach(function (requestCapability) {
  38521. requestCapability.resolve({
  38522. value: undefined,
  38523. done: true
  38524. });
  38525. });
  38526. this._requests = [];
  38527. }
  38528. };
  38529. function PDFWorkerStreamRangeReader(stream, begin, end) {
  38530. this._stream = stream;
  38531. this._begin = begin;
  38532. this._end = end;
  38533. this._queuedChunk = null;
  38534. this._requests = [];
  38535. this._done = false;
  38536. this.onProgress = null;
  38537. }
  38538. PDFWorkerStreamRangeReader.prototype = {
  38539. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  38540. if (this._done) {
  38541. return;
  38542. }
  38543. if (this._requests.length === 0) {
  38544. this._queuedChunk = chunk;
  38545. } else {
  38546. var requestsCapability = this._requests.shift();
  38547. requestsCapability.resolve({
  38548. value: chunk,
  38549. done: false
  38550. });
  38551. this._requests.forEach(function (requestCapability) {
  38552. requestCapability.resolve({
  38553. value: undefined,
  38554. done: true
  38555. });
  38556. });
  38557. this._requests = [];
  38558. }
  38559. this._done = true;
  38560. this._stream._removeRangeReader(this);
  38561. },
  38562. get isStreamingSupported() {
  38563. return false;
  38564. },
  38565. read: function PDFWorkerStreamRangeReader_read() {
  38566. if (this._queuedChunk) {
  38567. return Promise.resolve({
  38568. value: this._queuedChunk,
  38569. done: false
  38570. });
  38571. }
  38572. if (this._done) {
  38573. return Promise.resolve({
  38574. value: undefined,
  38575. done: true
  38576. });
  38577. }
  38578. var requestCapability = createPromiseCapability();
  38579. this._requests.push(requestCapability);
  38580. return requestCapability.promise;
  38581. },
  38582. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  38583. this._done = true;
  38584. this._requests.forEach(function (requestCapability) {
  38585. requestCapability.resolve({
  38586. value: undefined,
  38587. done: true
  38588. });
  38589. });
  38590. this._requests = [];
  38591. this._stream._removeRangeReader(this);
  38592. }
  38593. };
  38594. return PDFWorkerStream;
  38595. }();
  38596. var PDFNetworkStream;
  38597. function setPDFNetworkStreamClass(cls) {
  38598. PDFNetworkStream = cls;
  38599. }
  38600. var WorkerMessageHandler = {
  38601. setup: function wphSetup(handler, port) {
  38602. var testMessageProcessed = false;
  38603. handler.on('test', function wphSetupTest(data) {
  38604. if (testMessageProcessed) {
  38605. return;
  38606. }
  38607. testMessageProcessed = true;
  38608. if (!(data instanceof Uint8Array)) {
  38609. handler.send('test', 'main', false);
  38610. return;
  38611. }
  38612. var supportTransfers = data[0] === 255;
  38613. handler.postMessageTransfers = supportTransfers;
  38614. var xhr = new XMLHttpRequest();
  38615. var responseExists = 'response' in xhr;
  38616. try {
  38617. xhr.responseType;
  38618. } catch (e) {
  38619. responseExists = false;
  38620. }
  38621. if (!responseExists) {
  38622. handler.send('test', false);
  38623. return;
  38624. }
  38625. handler.send('test', {
  38626. supportTypedArray: true,
  38627. supportTransfers: supportTransfers
  38628. });
  38629. });
  38630. handler.on('configure', function wphConfigure(data) {
  38631. setVerbosityLevel(data.verbosity);
  38632. });
  38633. handler.on('GetDocRequest', function wphSetupDoc(data) {
  38634. return WorkerMessageHandler.createDocumentHandler(data, port);
  38635. });
  38636. },
  38637. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  38638. var pdfManager;
  38639. var terminated = false;
  38640. var cancelXHRs = null;
  38641. var WorkerTasks = [];
  38642. var docId = docParams.docId;
  38643. var docBaseUrl = docParams.docBaseUrl;
  38644. var workerHandlerName = docParams.docId + '_worker';
  38645. var handler = new MessageHandler(workerHandlerName, docId, port);
  38646. handler.postMessageTransfers = docParams.postMessageTransfers;
  38647. function ensureNotTerminated() {
  38648. if (terminated) {
  38649. throw new Error('Worker was terminated');
  38650. }
  38651. }
  38652. function startWorkerTask(task) {
  38653. WorkerTasks.push(task);
  38654. }
  38655. function finishWorkerTask(task) {
  38656. task.finish();
  38657. var i = WorkerTasks.indexOf(task);
  38658. WorkerTasks.splice(i, 1);
  38659. }
  38660. function loadDocument(recoveryMode) {
  38661. var loadDocumentCapability = createPromiseCapability();
  38662. var parseSuccess = function parseSuccess() {
  38663. var numPagesPromise = pdfManager.ensureDoc('numPages');
  38664. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  38665. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  38666. Promise.all([
  38667. numPagesPromise,
  38668. fingerprintPromise,
  38669. encryptedPromise
  38670. ]).then(function onDocReady(results) {
  38671. var doc = {
  38672. numPages: results[0],
  38673. fingerprint: results[1],
  38674. encrypted: !!results[2]
  38675. };
  38676. loadDocumentCapability.resolve(doc);
  38677. }, parseFailure);
  38678. };
  38679. var parseFailure = function parseFailure(e) {
  38680. loadDocumentCapability.reject(e);
  38681. };
  38682. pdfManager.ensureDoc('checkHeader', []).then(function () {
  38683. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  38684. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  38685. }, parseFailure);
  38686. }, parseFailure);
  38687. return loadDocumentCapability.promise;
  38688. }
  38689. function getPdfManager(data, evaluatorOptions) {
  38690. var pdfManagerCapability = createPromiseCapability();
  38691. var pdfManager;
  38692. var source = data.source;
  38693. if (source.data) {
  38694. try {
  38695. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  38696. pdfManagerCapability.resolve(pdfManager);
  38697. } catch (ex) {
  38698. pdfManagerCapability.reject(ex);
  38699. }
  38700. return pdfManagerCapability.promise;
  38701. }
  38702. var pdfStream;
  38703. try {
  38704. if (source.chunkedViewerLoading) {
  38705. pdfStream = new PDFWorkerStream(source, handler);
  38706. } else {
  38707. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  38708. pdfStream = new PDFNetworkStream(data);
  38709. }
  38710. } catch (ex) {
  38711. pdfManagerCapability.reject(ex);
  38712. return pdfManagerCapability.promise;
  38713. }
  38714. var fullRequest = pdfStream.getFullReader();
  38715. fullRequest.headersReady.then(function () {
  38716. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  38717. fullRequest.onProgress = function (evt) {
  38718. handler.send('DocProgress', {
  38719. loaded: evt.loaded,
  38720. total: evt.total
  38721. });
  38722. };
  38723. }
  38724. if (!fullRequest.isRangeSupported) {
  38725. return;
  38726. }
  38727. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  38728. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  38729. msgHandler: handler,
  38730. url: source.url,
  38731. password: source.password,
  38732. length: fullRequest.contentLength,
  38733. disableAutoFetch: disableAutoFetch,
  38734. rangeChunkSize: source.rangeChunkSize
  38735. }, evaluatorOptions, docBaseUrl);
  38736. pdfManagerCapability.resolve(pdfManager);
  38737. cancelXHRs = null;
  38738. }).catch(function (reason) {
  38739. pdfManagerCapability.reject(reason);
  38740. cancelXHRs = null;
  38741. });
  38742. var cachedChunks = [], loaded = 0;
  38743. var flushChunks = function () {
  38744. var pdfFile = arraysToBytes(cachedChunks);
  38745. if (source.length && pdfFile.length !== source.length) {
  38746. warn('reported HTTP length is different from actual');
  38747. }
  38748. try {
  38749. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  38750. pdfManagerCapability.resolve(pdfManager);
  38751. } catch (ex) {
  38752. pdfManagerCapability.reject(ex);
  38753. }
  38754. cachedChunks = [];
  38755. };
  38756. var readPromise = new Promise(function (resolve, reject) {
  38757. var readChunk = function (chunk) {
  38758. try {
  38759. ensureNotTerminated();
  38760. if (chunk.done) {
  38761. if (!pdfManager) {
  38762. flushChunks();
  38763. }
  38764. cancelXHRs = null;
  38765. return;
  38766. }
  38767. var data = chunk.value;
  38768. loaded += arrayByteLength(data);
  38769. if (!fullRequest.isStreamingSupported) {
  38770. handler.send('DocProgress', {
  38771. loaded: loaded,
  38772. total: Math.max(loaded, fullRequest.contentLength || 0)
  38773. });
  38774. }
  38775. if (pdfManager) {
  38776. pdfManager.sendProgressiveData(data);
  38777. } else {
  38778. cachedChunks.push(data);
  38779. }
  38780. fullRequest.read().then(readChunk, reject);
  38781. } catch (e) {
  38782. reject(e);
  38783. }
  38784. };
  38785. fullRequest.read().then(readChunk, reject);
  38786. });
  38787. readPromise.catch(function (e) {
  38788. pdfManagerCapability.reject(e);
  38789. cancelXHRs = null;
  38790. });
  38791. cancelXHRs = function () {
  38792. pdfStream.cancelAllRequests('abort');
  38793. };
  38794. return pdfManagerCapability.promise;
  38795. }
  38796. function setupDoc(data) {
  38797. function onSuccess(doc) {
  38798. ensureNotTerminated();
  38799. handler.send('GetDoc', { pdfInfo: doc });
  38800. }
  38801. function onFailure(e) {
  38802. if (e instanceof PasswordException) {
  38803. var task = new WorkerTask('PasswordException: response ' + e.code);
  38804. startWorkerTask(task);
  38805. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  38806. finishWorkerTask(task);
  38807. pdfManager.updatePassword(data.password);
  38808. pdfManagerReady();
  38809. }).catch(function (ex) {
  38810. finishWorkerTask(task);
  38811. handler.send('PasswordException', ex);
  38812. }.bind(null, e));
  38813. } else if (e instanceof InvalidPDFException) {
  38814. handler.send('InvalidPDF', e);
  38815. } else if (e instanceof MissingPDFException) {
  38816. handler.send('MissingPDF', e);
  38817. } else if (e instanceof UnexpectedResponseException) {
  38818. handler.send('UnexpectedResponse', e);
  38819. } else {
  38820. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  38821. }
  38822. }
  38823. function pdfManagerReady() {
  38824. ensureNotTerminated();
  38825. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  38826. ensureNotTerminated();
  38827. if (!(ex instanceof XRefParseException)) {
  38828. onFailure(ex);
  38829. return;
  38830. }
  38831. pdfManager.requestLoadedStream();
  38832. pdfManager.onLoadedStream().then(function () {
  38833. ensureNotTerminated();
  38834. loadDocument(true).then(onSuccess, onFailure);
  38835. });
  38836. }, onFailure);
  38837. }
  38838. ensureNotTerminated();
  38839. var evaluatorOptions = {
  38840. forceDataSchema: data.disableCreateObjectURL,
  38841. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  38842. disableFontFace: data.disableFontFace,
  38843. disableNativeImageDecoder: data.disableNativeImageDecoder
  38844. };
  38845. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  38846. if (terminated) {
  38847. newPdfManager.terminate();
  38848. throw new Error('Worker was terminated');
  38849. }
  38850. pdfManager = newPdfManager;
  38851. handler.send('PDFManagerReady', null);
  38852. pdfManager.onLoadedStream().then(function (stream) {
  38853. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  38854. });
  38855. }).then(pdfManagerReady, onFailure);
  38856. }
  38857. handler.on('GetPage', function wphSetupGetPage(data) {
  38858. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38859. var rotatePromise = pdfManager.ensure(page, 'rotate');
  38860. var refPromise = pdfManager.ensure(page, 'ref');
  38861. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  38862. var viewPromise = pdfManager.ensure(page, 'view');
  38863. return Promise.all([
  38864. rotatePromise,
  38865. refPromise,
  38866. userUnitPromise,
  38867. viewPromise
  38868. ]).then(function (results) {
  38869. return {
  38870. rotate: results[0],
  38871. ref: results[1],
  38872. userUnit: results[2],
  38873. view: results[3]
  38874. };
  38875. });
  38876. });
  38877. });
  38878. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  38879. var ref = new Ref(data.ref.num, data.ref.gen);
  38880. var catalog = pdfManager.pdfDocument.catalog;
  38881. return catalog.getPageIndex(ref);
  38882. });
  38883. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  38884. return pdfManager.ensureCatalog('destinations');
  38885. });
  38886. handler.on('GetDestination', function wphSetupGetDestination(data) {
  38887. return pdfManager.ensureCatalog('getDestination', [data.id]);
  38888. });
  38889. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  38890. return pdfManager.ensureCatalog('pageLabels');
  38891. });
  38892. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  38893. return pdfManager.ensureCatalog('attachments');
  38894. });
  38895. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  38896. return pdfManager.ensureCatalog('javaScript');
  38897. });
  38898. handler.on('GetOutline', function wphSetupGetOutline(data) {
  38899. return pdfManager.ensureCatalog('documentOutline');
  38900. });
  38901. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  38902. return Promise.all([
  38903. pdfManager.ensureDoc('documentInfo'),
  38904. pdfManager.ensureCatalog('metadata')
  38905. ]);
  38906. });
  38907. handler.on('GetData', function wphSetupGetData(data) {
  38908. pdfManager.requestLoadedStream();
  38909. return pdfManager.onLoadedStream().then(function (stream) {
  38910. return stream.bytes;
  38911. });
  38912. });
  38913. handler.on('GetStats', function wphSetupGetStats(data) {
  38914. return pdfManager.pdfDocument.xref.stats;
  38915. });
  38916. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  38917. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38918. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  38919. });
  38920. });
  38921. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  38922. var pageIndex = data.pageIndex;
  38923. pdfManager.getPage(pageIndex).then(function (page) {
  38924. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  38925. startWorkerTask(task);
  38926. var pageNum = pageIndex + 1;
  38927. var start = Date.now();
  38928. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  38929. finishWorkerTask(task);
  38930. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  38931. }, function (e) {
  38932. finishWorkerTask(task);
  38933. if (task.terminated) {
  38934. return;
  38935. }
  38936. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  38937. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  38938. var wrappedException;
  38939. if (typeof e === 'string') {
  38940. wrappedException = {
  38941. message: e,
  38942. stack: minimumStackMessage
  38943. };
  38944. } else if (typeof e === 'object') {
  38945. wrappedException = {
  38946. message: e.message || e.toString(),
  38947. stack: e.stack || minimumStackMessage
  38948. };
  38949. } else {
  38950. wrappedException = {
  38951. message: 'Unknown exception type: ' + typeof e,
  38952. stack: minimumStackMessage
  38953. };
  38954. }
  38955. handler.send('PageError', {
  38956. pageNum: pageNum,
  38957. error: wrappedException,
  38958. intent: data.intent
  38959. });
  38960. });
  38961. });
  38962. }, this);
  38963. handler.on('GetTextContent', function wphExtractText(data) {
  38964. var pageIndex = data.pageIndex;
  38965. var normalizeWhitespace = data.normalizeWhitespace;
  38966. var combineTextItems = data.combineTextItems;
  38967. return pdfManager.getPage(pageIndex).then(function (page) {
  38968. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  38969. startWorkerTask(task);
  38970. var pageNum = pageIndex + 1;
  38971. var start = Date.now();
  38972. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  38973. finishWorkerTask(task);
  38974. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  38975. return textContent;
  38976. }, function (reason) {
  38977. finishWorkerTask(task);
  38978. if (task.terminated) {
  38979. return;
  38980. }
  38981. throw reason;
  38982. });
  38983. });
  38984. });
  38985. handler.on('Cleanup', function wphCleanup(data) {
  38986. return pdfManager.cleanup();
  38987. });
  38988. handler.on('Terminate', function wphTerminate(data) {
  38989. terminated = true;
  38990. if (pdfManager) {
  38991. pdfManager.terminate();
  38992. pdfManager = null;
  38993. }
  38994. if (cancelXHRs) {
  38995. cancelXHRs();
  38996. }
  38997. var waitOn = [];
  38998. WorkerTasks.forEach(function (task) {
  38999. waitOn.push(task.finished);
  39000. task.terminate();
  39001. });
  39002. return Promise.all(waitOn).then(function () {
  39003. handler.destroy();
  39004. handler = null;
  39005. });
  39006. });
  39007. handler.on('Ready', function wphReady(data) {
  39008. setupDoc(docParams);
  39009. docParams = null;
  39010. });
  39011. return workerHandlerName;
  39012. }
  39013. };
  39014. function initializeWorker() {
  39015. if (!('console' in globalScope)) {
  39016. var consoleTimer = {};
  39017. var workerConsole = {
  39018. log: function log() {
  39019. var args = Array.prototype.slice.call(arguments);
  39020. globalScope.postMessage({
  39021. targetName: 'main',
  39022. action: 'console_log',
  39023. data: args
  39024. });
  39025. },
  39026. error: function error() {
  39027. var args = Array.prototype.slice.call(arguments);
  39028. globalScope.postMessage({
  39029. targetName: 'main',
  39030. action: 'console_error',
  39031. data: args
  39032. });
  39033. throw 'pdf.js execution error';
  39034. },
  39035. time: function time(name) {
  39036. consoleTimer[name] = Date.now();
  39037. },
  39038. timeEnd: function timeEnd(name) {
  39039. var time = consoleTimer[name];
  39040. if (!time) {
  39041. error('Unknown timer name ' + name);
  39042. }
  39043. this.log('Timer:', name, Date.now() - time);
  39044. }
  39045. };
  39046. globalScope.console = workerConsole;
  39047. }
  39048. var handler = new MessageHandler('worker', 'main', self);
  39049. WorkerMessageHandler.setup(handler, self);
  39050. handler.send('ready', null);
  39051. }
  39052. if (typeof window === 'undefined' && !isNodeJS()) {
  39053. initializeWorker();
  39054. }
  39055. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  39056. exports.WorkerTask = WorkerTask;
  39057. exports.WorkerMessageHandler = WorkerMessageHandler;
  39058. /***/ }),
  39059. /* 23 */
  39060. /***/ (function(module, exports, __w_pdfjs_require__) {
  39061. "use strict";
  39062. var sharedUtil = __w_pdfjs_require__(0);
  39063. var error = sharedUtil.error;
  39064. function fixMetadata(meta) {
  39065. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  39066. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  39067. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  39068. });
  39069. var chars = '';
  39070. for (var i = 0; i < bytes.length; i += 2) {
  39071. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  39072. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  39073. }
  39074. return '>' + chars;
  39075. });
  39076. }
  39077. function Metadata(meta) {
  39078. if (typeof meta === 'string') {
  39079. meta = fixMetadata(meta);
  39080. var parser = new DOMParser();
  39081. meta = parser.parseFromString(meta, 'application/xml');
  39082. } else if (!(meta instanceof Document)) {
  39083. error('Metadata: Invalid metadata object');
  39084. }
  39085. this.metaDocument = meta;
  39086. this.metadata = Object.create(null);
  39087. this.parse();
  39088. }
  39089. Metadata.prototype = {
  39090. parse: function Metadata_parse() {
  39091. var doc = this.metaDocument;
  39092. var rdf = doc.documentElement;
  39093. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39094. rdf = rdf.firstChild;
  39095. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39096. rdf = rdf.nextSibling;
  39097. }
  39098. }
  39099. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  39100. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  39101. return;
  39102. }
  39103. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  39104. for (i = 0, length = children.length; i < length; i++) {
  39105. desc = children[i];
  39106. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  39107. continue;
  39108. }
  39109. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  39110. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  39111. entry = desc.childNodes[ii];
  39112. name = entry.nodeName.toLowerCase();
  39113. this.metadata[name] = entry.textContent.trim();
  39114. }
  39115. }
  39116. }
  39117. },
  39118. get: function Metadata_get(name) {
  39119. return this.metadata[name] || null;
  39120. },
  39121. has: function Metadata_has(name) {
  39122. return typeof this.metadata[name] !== 'undefined';
  39123. }
  39124. };
  39125. exports.Metadata = Metadata;
  39126. /***/ }),
  39127. /* 24 */
  39128. /***/ (function(module, exports, __w_pdfjs_require__) {
  39129. "use strict";
  39130. var sharedUtil = __w_pdfjs_require__(0);
  39131. var displayDOMUtils = __w_pdfjs_require__(3);
  39132. var shadow = sharedUtil.shadow;
  39133. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  39134. var WebGLUtils = function WebGLUtilsClosure() {
  39135. function loadShader(gl, code, shaderType) {
  39136. var shader = gl.createShader(shaderType);
  39137. gl.shaderSource(shader, code);
  39138. gl.compileShader(shader);
  39139. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  39140. if (!compiled) {
  39141. var errorMsg = gl.getShaderInfoLog(shader);
  39142. throw new Error('Error during shader compilation: ' + errorMsg);
  39143. }
  39144. return shader;
  39145. }
  39146. function createVertexShader(gl, code) {
  39147. return loadShader(gl, code, gl.VERTEX_SHADER);
  39148. }
  39149. function createFragmentShader(gl, code) {
  39150. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  39151. }
  39152. function createProgram(gl, shaders) {
  39153. var program = gl.createProgram();
  39154. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  39155. gl.attachShader(program, shaders[i]);
  39156. }
  39157. gl.linkProgram(program);
  39158. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  39159. if (!linked) {
  39160. var errorMsg = gl.getProgramInfoLog(program);
  39161. throw new Error('Error during program linking: ' + errorMsg);
  39162. }
  39163. return program;
  39164. }
  39165. function createTexture(gl, image, textureId) {
  39166. gl.activeTexture(textureId);
  39167. var texture = gl.createTexture();
  39168. gl.bindTexture(gl.TEXTURE_2D, texture);
  39169. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  39170. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  39171. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  39172. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  39173. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  39174. return texture;
  39175. }
  39176. var currentGL, currentCanvas;
  39177. function generateGL() {
  39178. if (currentGL) {
  39179. return;
  39180. }
  39181. currentCanvas = document.createElement('canvas');
  39182. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  39183. }
  39184. var smaskVertexShaderCode = '\
  39185. attribute vec2 a_position; \
  39186. attribute vec2 a_texCoord; \
  39187. \
  39188. uniform vec2 u_resolution; \
  39189. \
  39190. varying vec2 v_texCoord; \
  39191. \
  39192. void main() { \
  39193. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  39194. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39195. \
  39196. v_texCoord = a_texCoord; \
  39197. } ';
  39198. var smaskFragmentShaderCode = '\
  39199. precision mediump float; \
  39200. \
  39201. uniform vec4 u_backdrop; \
  39202. uniform int u_subtype; \
  39203. uniform sampler2D u_image; \
  39204. uniform sampler2D u_mask; \
  39205. \
  39206. varying vec2 v_texCoord; \
  39207. \
  39208. void main() { \
  39209. vec4 imageColor = texture2D(u_image, v_texCoord); \
  39210. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  39211. if (u_backdrop.a > 0.0) { \
  39212. maskColor.rgb = maskColor.rgb * maskColor.a + \
  39213. u_backdrop.rgb * (1.0 - maskColor.a); \
  39214. } \
  39215. float lum; \
  39216. if (u_subtype == 0) { \
  39217. lum = maskColor.a; \
  39218. } else { \
  39219. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  39220. maskColor.b * 0.11; \
  39221. } \
  39222. imageColor.a *= lum; \
  39223. imageColor.rgb *= imageColor.a; \
  39224. gl_FragColor = imageColor; \
  39225. } ';
  39226. var smaskCache = null;
  39227. function initSmaskGL() {
  39228. var canvas, gl;
  39229. generateGL();
  39230. canvas = currentCanvas;
  39231. currentCanvas = null;
  39232. gl = currentGL;
  39233. currentGL = null;
  39234. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  39235. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  39236. var program = createProgram(gl, [
  39237. vertexShader,
  39238. fragmentShader
  39239. ]);
  39240. gl.useProgram(program);
  39241. var cache = {};
  39242. cache.gl = gl;
  39243. cache.canvas = canvas;
  39244. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39245. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39246. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  39247. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  39248. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  39249. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  39250. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  39251. var texCoordBuffer = gl.createBuffer();
  39252. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  39253. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39254. 0.0,
  39255. 0.0,
  39256. 1.0,
  39257. 0.0,
  39258. 0.0,
  39259. 1.0,
  39260. 0.0,
  39261. 1.0,
  39262. 1.0,
  39263. 0.0,
  39264. 1.0,
  39265. 1.0
  39266. ]), gl.STATIC_DRAW);
  39267. gl.enableVertexAttribArray(texCoordLocation);
  39268. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  39269. gl.uniform1i(texLayerLocation, 0);
  39270. gl.uniform1i(texMaskLocation, 1);
  39271. smaskCache = cache;
  39272. }
  39273. function composeSMask(layer, mask, properties) {
  39274. var width = layer.width, height = layer.height;
  39275. if (!smaskCache) {
  39276. initSmaskGL();
  39277. }
  39278. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  39279. canvas.width = width;
  39280. canvas.height = height;
  39281. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39282. gl.uniform2f(cache.resolutionLocation, width, height);
  39283. if (properties.backdrop) {
  39284. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  39285. } else {
  39286. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  39287. }
  39288. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  39289. var texture = createTexture(gl, layer, gl.TEXTURE0);
  39290. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  39291. var buffer = gl.createBuffer();
  39292. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  39293. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39294. 0,
  39295. 0,
  39296. width,
  39297. 0,
  39298. 0,
  39299. height,
  39300. 0,
  39301. height,
  39302. width,
  39303. 0,
  39304. width,
  39305. height
  39306. ]), gl.STATIC_DRAW);
  39307. gl.enableVertexAttribArray(cache.positionLocation);
  39308. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39309. gl.clearColor(0, 0, 0, 0);
  39310. gl.enable(gl.BLEND);
  39311. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  39312. gl.clear(gl.COLOR_BUFFER_BIT);
  39313. gl.drawArrays(gl.TRIANGLES, 0, 6);
  39314. gl.flush();
  39315. gl.deleteTexture(texture);
  39316. gl.deleteTexture(maskTexture);
  39317. gl.deleteBuffer(buffer);
  39318. return canvas;
  39319. }
  39320. var figuresVertexShaderCode = '\
  39321. attribute vec2 a_position; \
  39322. attribute vec3 a_color; \
  39323. \
  39324. uniform vec2 u_resolution; \
  39325. uniform vec2 u_scale; \
  39326. uniform vec2 u_offset; \
  39327. \
  39328. varying vec4 v_color; \
  39329. \
  39330. void main() { \
  39331. vec2 position = (a_position + u_offset) * u_scale; \
  39332. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  39333. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39334. \
  39335. v_color = vec4(a_color / 255.0, 1.0); \
  39336. } ';
  39337. var figuresFragmentShaderCode = '\
  39338. precision mediump float; \
  39339. \
  39340. varying vec4 v_color; \
  39341. \
  39342. void main() { \
  39343. gl_FragColor = v_color; \
  39344. } ';
  39345. var figuresCache = null;
  39346. function initFiguresGL() {
  39347. var canvas, gl;
  39348. generateGL();
  39349. canvas = currentCanvas;
  39350. currentCanvas = null;
  39351. gl = currentGL;
  39352. currentGL = null;
  39353. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  39354. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  39355. var program = createProgram(gl, [
  39356. vertexShader,
  39357. fragmentShader
  39358. ]);
  39359. gl.useProgram(program);
  39360. var cache = {};
  39361. cache.gl = gl;
  39362. cache.canvas = canvas;
  39363. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39364. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  39365. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  39366. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39367. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  39368. figuresCache = cache;
  39369. }
  39370. function drawFigures(width, height, backgroundColor, figures, context) {
  39371. if (!figuresCache) {
  39372. initFiguresGL();
  39373. }
  39374. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  39375. canvas.width = width;
  39376. canvas.height = height;
  39377. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39378. gl.uniform2f(cache.resolutionLocation, width, height);
  39379. var count = 0;
  39380. var i, ii, rows;
  39381. for (i = 0, ii = figures.length; i < ii; i++) {
  39382. switch (figures[i].type) {
  39383. case 'lattice':
  39384. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  39385. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  39386. break;
  39387. case 'triangles':
  39388. count += figures[i].coords.length;
  39389. break;
  39390. }
  39391. }
  39392. var coords = new Float32Array(count * 2);
  39393. var colors = new Uint8Array(count * 3);
  39394. var coordsMap = context.coords, colorsMap = context.colors;
  39395. var pIndex = 0, cIndex = 0;
  39396. for (i = 0, ii = figures.length; i < ii; i++) {
  39397. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  39398. switch (figure.type) {
  39399. case 'lattice':
  39400. var cols = figure.verticesPerRow;
  39401. rows = ps.length / cols | 0;
  39402. for (var row = 1; row < rows; row++) {
  39403. var offset = row * cols + 1;
  39404. for (var col = 1; col < cols; col++, offset++) {
  39405. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  39406. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  39407. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  39408. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  39409. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  39410. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  39411. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  39412. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  39413. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  39414. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  39415. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  39416. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  39417. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  39418. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  39419. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  39420. coords[pIndex + 6] = coords[pIndex + 2];
  39421. coords[pIndex + 7] = coords[pIndex + 3];
  39422. coords[pIndex + 8] = coords[pIndex + 4];
  39423. coords[pIndex + 9] = coords[pIndex + 5];
  39424. coords[pIndex + 10] = coordsMap[ps[offset]];
  39425. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  39426. colors[cIndex + 9] = colors[cIndex + 3];
  39427. colors[cIndex + 10] = colors[cIndex + 4];
  39428. colors[cIndex + 11] = colors[cIndex + 5];
  39429. colors[cIndex + 12] = colors[cIndex + 6];
  39430. colors[cIndex + 13] = colors[cIndex + 7];
  39431. colors[cIndex + 14] = colors[cIndex + 8];
  39432. colors[cIndex + 15] = colorsMap[cs[offset]];
  39433. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  39434. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  39435. pIndex += 12;
  39436. cIndex += 18;
  39437. }
  39438. }
  39439. break;
  39440. case 'triangles':
  39441. for (var j = 0, jj = ps.length; j < jj; j++) {
  39442. coords[pIndex] = coordsMap[ps[j]];
  39443. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  39444. colors[cIndex] = colorsMap[cs[j]];
  39445. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  39446. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  39447. pIndex += 2;
  39448. cIndex += 3;
  39449. }
  39450. break;
  39451. }
  39452. }
  39453. if (backgroundColor) {
  39454. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  39455. } else {
  39456. gl.clearColor(0, 0, 0, 0);
  39457. }
  39458. gl.clear(gl.COLOR_BUFFER_BIT);
  39459. var coordsBuffer = gl.createBuffer();
  39460. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  39461. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  39462. gl.enableVertexAttribArray(cache.positionLocation);
  39463. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39464. var colorsBuffer = gl.createBuffer();
  39465. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  39466. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  39467. gl.enableVertexAttribArray(cache.colorLocation);
  39468. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  39469. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  39470. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  39471. gl.drawArrays(gl.TRIANGLES, 0, count);
  39472. gl.flush();
  39473. gl.deleteBuffer(coordsBuffer);
  39474. gl.deleteBuffer(colorsBuffer);
  39475. return canvas;
  39476. }
  39477. function cleanup() {
  39478. if (smaskCache && smaskCache.canvas) {
  39479. smaskCache.canvas.width = 0;
  39480. smaskCache.canvas.height = 0;
  39481. }
  39482. if (figuresCache && figuresCache.canvas) {
  39483. figuresCache.canvas.width = 0;
  39484. figuresCache.canvas.height = 0;
  39485. }
  39486. smaskCache = null;
  39487. figuresCache = null;
  39488. }
  39489. return {
  39490. get isEnabled() {
  39491. if (getDefaultSetting('disableWebGL')) {
  39492. return false;
  39493. }
  39494. var enabled = false;
  39495. try {
  39496. generateGL();
  39497. enabled = !!currentGL;
  39498. } catch (e) {
  39499. }
  39500. return shadow(this, 'isEnabled', enabled);
  39501. },
  39502. composeSMask: composeSMask,
  39503. drawFigures: drawFigures,
  39504. clear: cleanup
  39505. };
  39506. }();
  39507. exports.WebGLUtils = WebGLUtils;
  39508. /***/ }),
  39509. /* 25 */
  39510. /***/ (function(module, exports, __w_pdfjs_require__) {
  39511. "use strict";
  39512. var sharedUtil = __w_pdfjs_require__(0);
  39513. var displayDOMUtils = __w_pdfjs_require__(3);
  39514. var displayAPI = __w_pdfjs_require__(10);
  39515. var displayAnnotationLayer = __w_pdfjs_require__(9);
  39516. var displayTextLayer = __w_pdfjs_require__(12);
  39517. var displayMetadata = __w_pdfjs_require__(23);
  39518. var displaySVG = __w_pdfjs_require__(11);
  39519. var globalScope = sharedUtil.globalScope;
  39520. var deprecated = sharedUtil.deprecated;
  39521. var warn = sharedUtil.warn;
  39522. var LinkTarget = displayDOMUtils.LinkTarget;
  39523. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  39524. var isWorker = typeof window === 'undefined';
  39525. if (!globalScope.PDFJS) {
  39526. globalScope.PDFJS = {};
  39527. }
  39528. var PDFJS = globalScope.PDFJS;
  39529. PDFJS.version = '1.7.312';
  39530. PDFJS.build = 'cada411a';
  39531. PDFJS.pdfBug = false;
  39532. if (PDFJS.verbosity !== undefined) {
  39533. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  39534. }
  39535. delete PDFJS.verbosity;
  39536. Object.defineProperty(PDFJS, 'verbosity', {
  39537. get: function () {
  39538. return sharedUtil.getVerbosityLevel();
  39539. },
  39540. set: function (level) {
  39541. sharedUtil.setVerbosityLevel(level);
  39542. },
  39543. enumerable: true,
  39544. configurable: true
  39545. });
  39546. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  39547. PDFJS.OPS = sharedUtil.OPS;
  39548. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  39549. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  39550. PDFJS.shadow = sharedUtil.shadow;
  39551. PDFJS.createBlob = sharedUtil.createBlob;
  39552. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  39553. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  39554. };
  39555. Object.defineProperty(PDFJS, 'isLittleEndian', {
  39556. configurable: true,
  39557. get: function PDFJS_isLittleEndian() {
  39558. var value = sharedUtil.isLittleEndian();
  39559. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  39560. }
  39561. });
  39562. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  39563. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  39564. PDFJS.PasswordException = sharedUtil.PasswordException;
  39565. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  39566. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  39567. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  39568. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  39569. PDFJS.Util = sharedUtil.Util;
  39570. PDFJS.PageViewport = sharedUtil.PageViewport;
  39571. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  39572. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  39573. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  39574. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  39575. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  39576. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  39577. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  39578. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  39579. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  39580. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  39581. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  39582. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  39583. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  39584. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  39585. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  39586. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  39587. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  39588. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  39589. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  39590. delete PDFJS.openExternalLinksInNewWindow;
  39591. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  39592. get: function () {
  39593. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  39594. },
  39595. set: function (value) {
  39596. if (value) {
  39597. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  39598. }
  39599. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  39600. warn('PDFJS.externalLinkTarget is already initialized');
  39601. return;
  39602. }
  39603. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  39604. },
  39605. enumerable: true,
  39606. configurable: true
  39607. });
  39608. if (savedOpenExternalLinksInNewWindow) {
  39609. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  39610. }
  39611. PDFJS.getDocument = displayAPI.getDocument;
  39612. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  39613. PDFJS.PDFWorker = displayAPI.PDFWorker;
  39614. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  39615. configurable: true,
  39616. get: function PDFJS_hasCanvasTypedArrays() {
  39617. var value = displayDOMUtils.hasCanvasTypedArrays();
  39618. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  39619. }
  39620. });
  39621. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  39622. PDFJS.LinkTarget = LinkTarget;
  39623. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  39624. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  39625. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  39626. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  39627. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  39628. PDFJS.Metadata = displayMetadata.Metadata;
  39629. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  39630. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  39631. exports.globalScope = globalScope;
  39632. exports.isWorker = isWorker;
  39633. exports.PDFJS = globalScope.PDFJS;
  39634. /***/ }),
  39635. /* 26 */
  39636. /***/ (function(module, exports) {
  39637. var g;
  39638. g = function () {
  39639. return this;
  39640. }();
  39641. try {
  39642. g = g || Function("return this")() || (1, eval)("this");
  39643. } catch (e) {
  39644. if (typeof window === "object")
  39645. g = window;
  39646. }
  39647. module.exports = g;
  39648. /***/ }),
  39649. /* 27 */
  39650. /***/ (function(module, exports, __w_pdfjs_require__) {
  39651. "use strict";
  39652. var sharedUtil = __w_pdfjs_require__(0);
  39653. var corePrimitives = __w_pdfjs_require__(1);
  39654. var coreStream = __w_pdfjs_require__(2);
  39655. var coreColorSpace = __w_pdfjs_require__(4);
  39656. var coreObj = __w_pdfjs_require__(19);
  39657. var coreEvaluator = __w_pdfjs_require__(17);
  39658. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  39659. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  39660. var AnnotationFlag = sharedUtil.AnnotationFlag;
  39661. var AnnotationType = sharedUtil.AnnotationType;
  39662. var OPS = sharedUtil.OPS;
  39663. var Util = sharedUtil.Util;
  39664. var isArray = sharedUtil.isArray;
  39665. var isInt = sharedUtil.isInt;
  39666. var stringToBytes = sharedUtil.stringToBytes;
  39667. var stringToPDFString = sharedUtil.stringToPDFString;
  39668. var warn = sharedUtil.warn;
  39669. var Dict = corePrimitives.Dict;
  39670. var isDict = corePrimitives.isDict;
  39671. var isName = corePrimitives.isName;
  39672. var isRef = corePrimitives.isRef;
  39673. var isStream = corePrimitives.isStream;
  39674. var Stream = coreStream.Stream;
  39675. var ColorSpace = coreColorSpace.ColorSpace;
  39676. var Catalog = coreObj.Catalog;
  39677. var ObjectLoader = coreObj.ObjectLoader;
  39678. var FileSpec = coreObj.FileSpec;
  39679. var OperatorList = coreEvaluator.OperatorList;
  39680. function AnnotationFactory() {
  39681. }
  39682. AnnotationFactory.prototype = {
  39683. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  39684. var dict = xref.fetchIfRef(ref);
  39685. if (!isDict(dict)) {
  39686. return;
  39687. }
  39688. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  39689. var subtype = dict.get('Subtype');
  39690. subtype = isName(subtype) ? subtype.name : null;
  39691. var parameters = {
  39692. xref: xref,
  39693. dict: dict,
  39694. ref: isRef(ref) ? ref : null,
  39695. subtype: subtype,
  39696. id: id,
  39697. pdfManager: pdfManager
  39698. };
  39699. switch (subtype) {
  39700. case 'Link':
  39701. return new LinkAnnotation(parameters);
  39702. case 'Text':
  39703. return new TextAnnotation(parameters);
  39704. case 'Widget':
  39705. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39706. fieldType = isName(fieldType) ? fieldType.name : null;
  39707. switch (fieldType) {
  39708. case 'Tx':
  39709. return new TextWidgetAnnotation(parameters);
  39710. case 'Btn':
  39711. return new ButtonWidgetAnnotation(parameters);
  39712. case 'Ch':
  39713. return new ChoiceWidgetAnnotation(parameters);
  39714. }
  39715. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  39716. return new WidgetAnnotation(parameters);
  39717. case 'Popup':
  39718. return new PopupAnnotation(parameters);
  39719. case 'Highlight':
  39720. return new HighlightAnnotation(parameters);
  39721. case 'Underline':
  39722. return new UnderlineAnnotation(parameters);
  39723. case 'Squiggly':
  39724. return new SquigglyAnnotation(parameters);
  39725. case 'StrikeOut':
  39726. return new StrikeOutAnnotation(parameters);
  39727. case 'FileAttachment':
  39728. return new FileAttachmentAnnotation(parameters);
  39729. default:
  39730. if (!subtype) {
  39731. warn('Annotation is missing the required /Subtype.');
  39732. } else {
  39733. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  39734. }
  39735. return new Annotation(parameters);
  39736. }
  39737. }
  39738. };
  39739. var Annotation = function AnnotationClosure() {
  39740. function getTransformMatrix(rect, bbox, matrix) {
  39741. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  39742. var minX = bounds[0];
  39743. var minY = bounds[1];
  39744. var maxX = bounds[2];
  39745. var maxY = bounds[3];
  39746. if (minX === maxX || minY === maxY) {
  39747. return [
  39748. 1,
  39749. 0,
  39750. 0,
  39751. 1,
  39752. rect[0],
  39753. rect[1]
  39754. ];
  39755. }
  39756. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  39757. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  39758. return [
  39759. xRatio,
  39760. 0,
  39761. 0,
  39762. yRatio,
  39763. rect[0] - minX * xRatio,
  39764. rect[1] - minY * yRatio
  39765. ];
  39766. }
  39767. function Annotation(params) {
  39768. var dict = params.dict;
  39769. this.setFlags(dict.get('F'));
  39770. this.setRectangle(dict.getArray('Rect'));
  39771. this.setColor(dict.getArray('C'));
  39772. this.setBorderStyle(dict);
  39773. this.setAppearance(dict);
  39774. this.data = {};
  39775. this.data.id = params.id;
  39776. this.data.subtype = params.subtype;
  39777. this.data.annotationFlags = this.flags;
  39778. this.data.rect = this.rectangle;
  39779. this.data.color = this.color;
  39780. this.data.borderStyle = this.borderStyle;
  39781. this.data.hasAppearance = !!this.appearance;
  39782. }
  39783. Annotation.prototype = {
  39784. _hasFlag: function Annotation_hasFlag(flags, flag) {
  39785. return !!(flags & flag);
  39786. },
  39787. _isViewable: function Annotation_isViewable(flags) {
  39788. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  39789. },
  39790. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  39791. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  39792. },
  39793. get viewable() {
  39794. if (this.flags === 0) {
  39795. return true;
  39796. }
  39797. return this._isViewable(this.flags);
  39798. },
  39799. get printable() {
  39800. if (this.flags === 0) {
  39801. return false;
  39802. }
  39803. return this._isPrintable(this.flags);
  39804. },
  39805. setFlags: function Annotation_setFlags(flags) {
  39806. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  39807. },
  39808. hasFlag: function Annotation_hasFlag(flag) {
  39809. return this._hasFlag(this.flags, flag);
  39810. },
  39811. setRectangle: function Annotation_setRectangle(rectangle) {
  39812. if (isArray(rectangle) && rectangle.length === 4) {
  39813. this.rectangle = Util.normalizeRect(rectangle);
  39814. } else {
  39815. this.rectangle = [
  39816. 0,
  39817. 0,
  39818. 0,
  39819. 0
  39820. ];
  39821. }
  39822. },
  39823. setColor: function Annotation_setColor(color) {
  39824. var rgbColor = new Uint8Array(3);
  39825. if (!isArray(color)) {
  39826. this.color = rgbColor;
  39827. return;
  39828. }
  39829. switch (color.length) {
  39830. case 0:
  39831. this.color = null;
  39832. break;
  39833. case 1:
  39834. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  39835. this.color = rgbColor;
  39836. break;
  39837. case 3:
  39838. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  39839. this.color = rgbColor;
  39840. break;
  39841. case 4:
  39842. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  39843. this.color = rgbColor;
  39844. break;
  39845. default:
  39846. this.color = rgbColor;
  39847. break;
  39848. }
  39849. },
  39850. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  39851. this.borderStyle = new AnnotationBorderStyle();
  39852. if (!isDict(borderStyle)) {
  39853. return;
  39854. }
  39855. if (borderStyle.has('BS')) {
  39856. var dict = borderStyle.get('BS');
  39857. var dictType = dict.get('Type');
  39858. if (!dictType || isName(dictType, 'Border')) {
  39859. this.borderStyle.setWidth(dict.get('W'));
  39860. this.borderStyle.setStyle(dict.get('S'));
  39861. this.borderStyle.setDashArray(dict.getArray('D'));
  39862. }
  39863. } else if (borderStyle.has('Border')) {
  39864. var array = borderStyle.getArray('Border');
  39865. if (isArray(array) && array.length >= 3) {
  39866. this.borderStyle.setHorizontalCornerRadius(array[0]);
  39867. this.borderStyle.setVerticalCornerRadius(array[1]);
  39868. this.borderStyle.setWidth(array[2]);
  39869. if (array.length === 4) {
  39870. this.borderStyle.setDashArray(array[3]);
  39871. }
  39872. }
  39873. } else {
  39874. this.borderStyle.setWidth(0);
  39875. }
  39876. },
  39877. setAppearance: function Annotation_setAppearance(dict) {
  39878. this.appearance = null;
  39879. var appearanceStates = dict.get('AP');
  39880. if (!isDict(appearanceStates)) {
  39881. return;
  39882. }
  39883. var normalAppearanceState = appearanceStates.get('N');
  39884. if (isStream(normalAppearanceState)) {
  39885. this.appearance = normalAppearanceState;
  39886. return;
  39887. }
  39888. if (!isDict(normalAppearanceState)) {
  39889. return;
  39890. }
  39891. var as = dict.get('AS');
  39892. if (!isName(as) || !normalAppearanceState.has(as.name)) {
  39893. return;
  39894. }
  39895. this.appearance = normalAppearanceState.get(as.name);
  39896. },
  39897. _preparePopup: function Annotation_preparePopup(dict) {
  39898. if (!dict.has('C')) {
  39899. this.data.color = null;
  39900. }
  39901. this.data.hasPopup = dict.has('Popup');
  39902. this.data.title = stringToPDFString(dict.get('T') || '');
  39903. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  39904. },
  39905. loadResources: function Annotation_loadResources(keys) {
  39906. return new Promise(function (resolve, reject) {
  39907. this.appearance.dict.getAsync('Resources').then(function (resources) {
  39908. if (!resources) {
  39909. resolve();
  39910. return;
  39911. }
  39912. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  39913. objectLoader.load().then(function () {
  39914. resolve(resources);
  39915. }, reject);
  39916. }, reject);
  39917. }.bind(this));
  39918. },
  39919. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  39920. if (!this.appearance) {
  39921. return Promise.resolve(new OperatorList());
  39922. }
  39923. var data = this.data;
  39924. var appearanceDict = this.appearance.dict;
  39925. var resourcesPromise = this.loadResources([
  39926. 'ExtGState',
  39927. 'ColorSpace',
  39928. 'Pattern',
  39929. 'Shading',
  39930. 'XObject',
  39931. 'Font'
  39932. ]);
  39933. var bbox = appearanceDict.getArray('BBox') || [
  39934. 0,
  39935. 0,
  39936. 1,
  39937. 1
  39938. ];
  39939. var matrix = appearanceDict.getArray('Matrix') || [
  39940. 1,
  39941. 0,
  39942. 0,
  39943. 1,
  39944. 0,
  39945. 0
  39946. ];
  39947. var transform = getTransformMatrix(data.rect, bbox, matrix);
  39948. var self = this;
  39949. return resourcesPromise.then(function (resources) {
  39950. var opList = new OperatorList();
  39951. opList.addOp(OPS.beginAnnotation, [
  39952. data.rect,
  39953. transform,
  39954. matrix
  39955. ]);
  39956. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  39957. opList.addOp(OPS.endAnnotation, []);
  39958. self.appearance.reset();
  39959. return opList;
  39960. });
  39961. });
  39962. }
  39963. };
  39964. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  39965. var annotationPromises = [];
  39966. for (var i = 0, n = annotations.length; i < n; ++i) {
  39967. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  39968. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  39969. }
  39970. }
  39971. return Promise.all(annotationPromises).then(function (operatorLists) {
  39972. opList.addOp(OPS.beginAnnotations, []);
  39973. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  39974. opList.addOpList(operatorLists[i]);
  39975. }
  39976. opList.addOp(OPS.endAnnotations, []);
  39977. });
  39978. };
  39979. return Annotation;
  39980. }();
  39981. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  39982. function AnnotationBorderStyle() {
  39983. this.width = 1;
  39984. this.style = AnnotationBorderStyleType.SOLID;
  39985. this.dashArray = [3];
  39986. this.horizontalCornerRadius = 0;
  39987. this.verticalCornerRadius = 0;
  39988. }
  39989. AnnotationBorderStyle.prototype = {
  39990. setWidth: function AnnotationBorderStyle_setWidth(width) {
  39991. if (width === (width | 0)) {
  39992. this.width = width;
  39993. }
  39994. },
  39995. setStyle: function AnnotationBorderStyle_setStyle(style) {
  39996. if (!style) {
  39997. return;
  39998. }
  39999. switch (style.name) {
  40000. case 'S':
  40001. this.style = AnnotationBorderStyleType.SOLID;
  40002. break;
  40003. case 'D':
  40004. this.style = AnnotationBorderStyleType.DASHED;
  40005. break;
  40006. case 'B':
  40007. this.style = AnnotationBorderStyleType.BEVELED;
  40008. break;
  40009. case 'I':
  40010. this.style = AnnotationBorderStyleType.INSET;
  40011. break;
  40012. case 'U':
  40013. this.style = AnnotationBorderStyleType.UNDERLINE;
  40014. break;
  40015. default:
  40016. break;
  40017. }
  40018. },
  40019. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  40020. if (isArray(dashArray) && dashArray.length > 0) {
  40021. var isValid = true;
  40022. var allZeros = true;
  40023. for (var i = 0, len = dashArray.length; i < len; i++) {
  40024. var element = dashArray[i];
  40025. var validNumber = +element >= 0;
  40026. if (!validNumber) {
  40027. isValid = false;
  40028. break;
  40029. } else if (element > 0) {
  40030. allZeros = false;
  40031. }
  40032. }
  40033. if (isValid && !allZeros) {
  40034. this.dashArray = dashArray;
  40035. } else {
  40036. this.width = 0;
  40037. }
  40038. } else if (dashArray) {
  40039. this.width = 0;
  40040. }
  40041. },
  40042. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  40043. if (radius === (radius | 0)) {
  40044. this.horizontalCornerRadius = radius;
  40045. }
  40046. },
  40047. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  40048. if (radius === (radius | 0)) {
  40049. this.verticalCornerRadius = radius;
  40050. }
  40051. }
  40052. };
  40053. return AnnotationBorderStyle;
  40054. }();
  40055. var WidgetAnnotation = function WidgetAnnotationClosure() {
  40056. function WidgetAnnotation(params) {
  40057. Annotation.call(this, params);
  40058. var dict = params.dict;
  40059. var data = this.data;
  40060. data.annotationType = AnnotationType.WIDGET;
  40061. data.fieldName = this._constructFieldName(dict);
  40062. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  40063. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  40064. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  40065. var fieldType = Util.getInheritableProperty(dict, 'FT');
  40066. data.fieldType = isName(fieldType) ? fieldType.name : null;
  40067. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  40068. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  40069. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  40070. data.fieldFlags = 0;
  40071. }
  40072. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  40073. if (data.fieldType === 'Sig') {
  40074. this.setFlags(AnnotationFlag.HIDDEN);
  40075. }
  40076. }
  40077. Util.inherit(WidgetAnnotation, Annotation, {
  40078. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  40079. if (!dict.has('T') && !dict.has('Parent')) {
  40080. warn('Unknown field name, falling back to empty field name.');
  40081. return '';
  40082. }
  40083. if (!dict.has('Parent')) {
  40084. return stringToPDFString(dict.get('T'));
  40085. }
  40086. var fieldName = [];
  40087. if (dict.has('T')) {
  40088. fieldName.unshift(stringToPDFString(dict.get('T')));
  40089. }
  40090. var loopDict = dict;
  40091. while (loopDict.has('Parent')) {
  40092. loopDict = loopDict.get('Parent');
  40093. if (loopDict.has('T')) {
  40094. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  40095. }
  40096. }
  40097. return fieldName.join('.');
  40098. },
  40099. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  40100. return !!(this.data.fieldFlags & flag);
  40101. }
  40102. });
  40103. return WidgetAnnotation;
  40104. }();
  40105. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  40106. function TextWidgetAnnotation(params) {
  40107. WidgetAnnotation.call(this, params);
  40108. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  40109. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  40110. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  40111. alignment = null;
  40112. }
  40113. this.data.textAlignment = alignment;
  40114. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  40115. if (!isInt(maximumLength) || maximumLength < 0) {
  40116. maximumLength = null;
  40117. }
  40118. this.data.maxLen = maximumLength;
  40119. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  40120. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  40121. }
  40122. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  40123. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40124. var operatorList = new OperatorList();
  40125. if (renderForms) {
  40126. return Promise.resolve(operatorList);
  40127. }
  40128. if (this.appearance) {
  40129. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40130. }
  40131. if (!this.data.defaultAppearance) {
  40132. return Promise.resolve(operatorList);
  40133. }
  40134. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  40135. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  40136. return operatorList;
  40137. });
  40138. }
  40139. });
  40140. return TextWidgetAnnotation;
  40141. }();
  40142. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  40143. function ButtonWidgetAnnotation(params) {
  40144. WidgetAnnotation.call(this, params);
  40145. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40146. if (this.data.checkBox) {
  40147. if (!isName(this.data.fieldValue)) {
  40148. return;
  40149. }
  40150. this.data.fieldValue = this.data.fieldValue.name;
  40151. }
  40152. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40153. if (this.data.radioButton) {
  40154. this.data.fieldValue = this.data.buttonValue = null;
  40155. var fieldParent = params.dict.get('Parent');
  40156. if (isDict(fieldParent) && fieldParent.has('V')) {
  40157. var fieldParentValue = fieldParent.get('V');
  40158. if (isName(fieldParentValue)) {
  40159. this.data.fieldValue = fieldParentValue.name;
  40160. }
  40161. }
  40162. var appearanceStates = params.dict.get('AP');
  40163. if (!isDict(appearanceStates)) {
  40164. return;
  40165. }
  40166. var normalAppearanceState = appearanceStates.get('N');
  40167. if (!isDict(normalAppearanceState)) {
  40168. return;
  40169. }
  40170. var keys = normalAppearanceState.getKeys();
  40171. for (var i = 0, ii = keys.length; i < ii; i++) {
  40172. if (keys[i] !== 'Off') {
  40173. this.data.buttonValue = keys[i];
  40174. break;
  40175. }
  40176. }
  40177. }
  40178. }
  40179. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  40180. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40181. var operatorList = new OperatorList();
  40182. if (renderForms) {
  40183. return Promise.resolve(operatorList);
  40184. }
  40185. if (this.appearance) {
  40186. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40187. }
  40188. return Promise.resolve(operatorList);
  40189. }
  40190. });
  40191. return ButtonWidgetAnnotation;
  40192. }();
  40193. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  40194. function ChoiceWidgetAnnotation(params) {
  40195. WidgetAnnotation.call(this, params);
  40196. this.data.options = [];
  40197. var options = params.dict.get('Opt');
  40198. if (isArray(options)) {
  40199. var xref = params.xref;
  40200. for (var i = 0, ii = options.length; i < ii; i++) {
  40201. var option = xref.fetchIfRef(options[i]);
  40202. var isOptionArray = isArray(option);
  40203. this.data.options[i] = {
  40204. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  40205. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  40206. };
  40207. }
  40208. }
  40209. if (!isArray(this.data.fieldValue)) {
  40210. this.data.fieldValue = [this.data.fieldValue];
  40211. }
  40212. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  40213. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  40214. }
  40215. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  40216. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40217. var operatorList = new OperatorList();
  40218. if (renderForms) {
  40219. return Promise.resolve(operatorList);
  40220. }
  40221. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40222. }
  40223. });
  40224. return ChoiceWidgetAnnotation;
  40225. }();
  40226. var TextAnnotation = function TextAnnotationClosure() {
  40227. var DEFAULT_ICON_SIZE = 22;
  40228. function TextAnnotation(parameters) {
  40229. Annotation.call(this, parameters);
  40230. this.data.annotationType = AnnotationType.TEXT;
  40231. if (this.data.hasAppearance) {
  40232. this.data.name = 'NoIcon';
  40233. } else {
  40234. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  40235. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  40236. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  40237. }
  40238. this._preparePopup(parameters.dict);
  40239. }
  40240. Util.inherit(TextAnnotation, Annotation, {});
  40241. return TextAnnotation;
  40242. }();
  40243. var LinkAnnotation = function LinkAnnotationClosure() {
  40244. function LinkAnnotation(params) {
  40245. Annotation.call(this, params);
  40246. var data = this.data;
  40247. data.annotationType = AnnotationType.LINK;
  40248. Catalog.parseDestDictionary({
  40249. destDict: params.dict,
  40250. resultObj: data,
  40251. docBaseUrl: params.pdfManager.docBaseUrl
  40252. });
  40253. }
  40254. Util.inherit(LinkAnnotation, Annotation, {});
  40255. return LinkAnnotation;
  40256. }();
  40257. var PopupAnnotation = function PopupAnnotationClosure() {
  40258. function PopupAnnotation(parameters) {
  40259. Annotation.call(this, parameters);
  40260. this.data.annotationType = AnnotationType.POPUP;
  40261. var dict = parameters.dict;
  40262. var parentItem = dict.get('Parent');
  40263. if (!parentItem) {
  40264. warn('Popup annotation has a missing or invalid parent annotation.');
  40265. return;
  40266. }
  40267. this.data.parentId = dict.getRaw('Parent').toString();
  40268. this.data.title = stringToPDFString(parentItem.get('T') || '');
  40269. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  40270. if (!parentItem.has('C')) {
  40271. this.data.color = null;
  40272. } else {
  40273. this.setColor(parentItem.getArray('C'));
  40274. this.data.color = this.color;
  40275. }
  40276. if (!this.viewable) {
  40277. var parentFlags = parentItem.get('F');
  40278. if (this._isViewable(parentFlags)) {
  40279. this.setFlags(parentFlags);
  40280. }
  40281. }
  40282. }
  40283. Util.inherit(PopupAnnotation, Annotation, {});
  40284. return PopupAnnotation;
  40285. }();
  40286. var HighlightAnnotation = function HighlightAnnotationClosure() {
  40287. function HighlightAnnotation(parameters) {
  40288. Annotation.call(this, parameters);
  40289. this.data.annotationType = AnnotationType.HIGHLIGHT;
  40290. this._preparePopup(parameters.dict);
  40291. this.data.borderStyle.setWidth(0);
  40292. }
  40293. Util.inherit(HighlightAnnotation, Annotation, {});
  40294. return HighlightAnnotation;
  40295. }();
  40296. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  40297. function UnderlineAnnotation(parameters) {
  40298. Annotation.call(this, parameters);
  40299. this.data.annotationType = AnnotationType.UNDERLINE;
  40300. this._preparePopup(parameters.dict);
  40301. this.data.borderStyle.setWidth(0);
  40302. }
  40303. Util.inherit(UnderlineAnnotation, Annotation, {});
  40304. return UnderlineAnnotation;
  40305. }();
  40306. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  40307. function SquigglyAnnotation(parameters) {
  40308. Annotation.call(this, parameters);
  40309. this.data.annotationType = AnnotationType.SQUIGGLY;
  40310. this._preparePopup(parameters.dict);
  40311. this.data.borderStyle.setWidth(0);
  40312. }
  40313. Util.inherit(SquigglyAnnotation, Annotation, {});
  40314. return SquigglyAnnotation;
  40315. }();
  40316. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  40317. function StrikeOutAnnotation(parameters) {
  40318. Annotation.call(this, parameters);
  40319. this.data.annotationType = AnnotationType.STRIKEOUT;
  40320. this._preparePopup(parameters.dict);
  40321. this.data.borderStyle.setWidth(0);
  40322. }
  40323. Util.inherit(StrikeOutAnnotation, Annotation, {});
  40324. return StrikeOutAnnotation;
  40325. }();
  40326. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  40327. function FileAttachmentAnnotation(parameters) {
  40328. Annotation.call(this, parameters);
  40329. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  40330. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  40331. this.data.file = file.serializable;
  40332. this._preparePopup(parameters.dict);
  40333. }
  40334. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  40335. return FileAttachmentAnnotation;
  40336. }();
  40337. exports.Annotation = Annotation;
  40338. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  40339. exports.AnnotationFactory = AnnotationFactory;
  40340. /***/ }),
  40341. /* 28 */
  40342. /***/ (function(module, exports, __w_pdfjs_require__) {
  40343. "use strict";
  40344. var sharedUtil = __w_pdfjs_require__(0);
  40345. var warn = sharedUtil.warn;
  40346. var baseTypes = [
  40347. 'BN',
  40348. 'BN',
  40349. 'BN',
  40350. 'BN',
  40351. 'BN',
  40352. 'BN',
  40353. 'BN',
  40354. 'BN',
  40355. 'BN',
  40356. 'S',
  40357. 'B',
  40358. 'S',
  40359. 'WS',
  40360. 'B',
  40361. 'BN',
  40362. 'BN',
  40363. 'BN',
  40364. 'BN',
  40365. 'BN',
  40366. 'BN',
  40367. 'BN',
  40368. 'BN',
  40369. 'BN',
  40370. 'BN',
  40371. 'BN',
  40372. 'BN',
  40373. 'BN',
  40374. 'BN',
  40375. 'B',
  40376. 'B',
  40377. 'B',
  40378. 'S',
  40379. 'WS',
  40380. 'ON',
  40381. 'ON',
  40382. 'ET',
  40383. 'ET',
  40384. 'ET',
  40385. 'ON',
  40386. 'ON',
  40387. 'ON',
  40388. 'ON',
  40389. 'ON',
  40390. 'ES',
  40391. 'CS',
  40392. 'ES',
  40393. 'CS',
  40394. 'CS',
  40395. 'EN',
  40396. 'EN',
  40397. 'EN',
  40398. 'EN',
  40399. 'EN',
  40400. 'EN',
  40401. 'EN',
  40402. 'EN',
  40403. 'EN',
  40404. 'EN',
  40405. 'CS',
  40406. 'ON',
  40407. 'ON',
  40408. 'ON',
  40409. 'ON',
  40410. 'ON',
  40411. 'ON',
  40412. 'L',
  40413. 'L',
  40414. 'L',
  40415. 'L',
  40416. 'L',
  40417. 'L',
  40418. 'L',
  40419. 'L',
  40420. 'L',
  40421. 'L',
  40422. 'L',
  40423. 'L',
  40424. 'L',
  40425. 'L',
  40426. 'L',
  40427. 'L',
  40428. 'L',
  40429. 'L',
  40430. 'L',
  40431. 'L',
  40432. 'L',
  40433. 'L',
  40434. 'L',
  40435. 'L',
  40436. 'L',
  40437. 'L',
  40438. 'ON',
  40439. 'ON',
  40440. 'ON',
  40441. 'ON',
  40442. 'ON',
  40443. 'ON',
  40444. 'L',
  40445. 'L',
  40446. 'L',
  40447. 'L',
  40448. 'L',
  40449. 'L',
  40450. 'L',
  40451. 'L',
  40452. 'L',
  40453. 'L',
  40454. 'L',
  40455. 'L',
  40456. 'L',
  40457. 'L',
  40458. 'L',
  40459. 'L',
  40460. 'L',
  40461. 'L',
  40462. 'L',
  40463. 'L',
  40464. 'L',
  40465. 'L',
  40466. 'L',
  40467. 'L',
  40468. 'L',
  40469. 'L',
  40470. 'ON',
  40471. 'ON',
  40472. 'ON',
  40473. 'ON',
  40474. 'BN',
  40475. 'BN',
  40476. 'BN',
  40477. 'BN',
  40478. 'BN',
  40479. 'BN',
  40480. 'B',
  40481. 'BN',
  40482. 'BN',
  40483. 'BN',
  40484. 'BN',
  40485. 'BN',
  40486. 'BN',
  40487. 'BN',
  40488. 'BN',
  40489. 'BN',
  40490. 'BN',
  40491. 'BN',
  40492. 'BN',
  40493. 'BN',
  40494. 'BN',
  40495. 'BN',
  40496. 'BN',
  40497. 'BN',
  40498. 'BN',
  40499. 'BN',
  40500. 'BN',
  40501. 'BN',
  40502. 'BN',
  40503. 'BN',
  40504. 'BN',
  40505. 'BN',
  40506. 'BN',
  40507. 'CS',
  40508. 'ON',
  40509. 'ET',
  40510. 'ET',
  40511. 'ET',
  40512. 'ET',
  40513. 'ON',
  40514. 'ON',
  40515. 'ON',
  40516. 'ON',
  40517. 'L',
  40518. 'ON',
  40519. 'ON',
  40520. 'BN',
  40521. 'ON',
  40522. 'ON',
  40523. 'ET',
  40524. 'ET',
  40525. 'EN',
  40526. 'EN',
  40527. 'ON',
  40528. 'L',
  40529. 'ON',
  40530. 'ON',
  40531. 'ON',
  40532. 'EN',
  40533. 'L',
  40534. 'ON',
  40535. 'ON',
  40536. 'ON',
  40537. 'ON',
  40538. 'ON',
  40539. 'L',
  40540. 'L',
  40541. 'L',
  40542. 'L',
  40543. 'L',
  40544. 'L',
  40545. 'L',
  40546. 'L',
  40547. 'L',
  40548. 'L',
  40549. 'L',
  40550. 'L',
  40551. 'L',
  40552. 'L',
  40553. 'L',
  40554. 'L',
  40555. 'L',
  40556. 'L',
  40557. 'L',
  40558. 'L',
  40559. 'L',
  40560. 'L',
  40561. 'L',
  40562. 'ON',
  40563. 'L',
  40564. 'L',
  40565. 'L',
  40566. 'L',
  40567. 'L',
  40568. 'L',
  40569. 'L',
  40570. 'L',
  40571. 'L',
  40572. 'L',
  40573. 'L',
  40574. 'L',
  40575. 'L',
  40576. 'L',
  40577. 'L',
  40578. 'L',
  40579. 'L',
  40580. 'L',
  40581. 'L',
  40582. 'L',
  40583. 'L',
  40584. 'L',
  40585. 'L',
  40586. 'L',
  40587. 'L',
  40588. 'L',
  40589. 'L',
  40590. 'L',
  40591. 'L',
  40592. 'L',
  40593. 'L',
  40594. 'ON',
  40595. 'L',
  40596. 'L',
  40597. 'L',
  40598. 'L',
  40599. 'L',
  40600. 'L',
  40601. 'L',
  40602. 'L'
  40603. ];
  40604. var arabicTypes = [
  40605. 'AN',
  40606. 'AN',
  40607. 'AN',
  40608. 'AN',
  40609. 'AN',
  40610. 'AN',
  40611. 'ON',
  40612. 'ON',
  40613. 'AL',
  40614. 'ET',
  40615. 'ET',
  40616. 'AL',
  40617. 'CS',
  40618. 'AL',
  40619. 'ON',
  40620. 'ON',
  40621. 'NSM',
  40622. 'NSM',
  40623. 'NSM',
  40624. 'NSM',
  40625. 'NSM',
  40626. 'NSM',
  40627. 'NSM',
  40628. 'NSM',
  40629. 'NSM',
  40630. 'NSM',
  40631. 'NSM',
  40632. 'AL',
  40633. 'AL',
  40634. '',
  40635. 'AL',
  40636. 'AL',
  40637. 'AL',
  40638. 'AL',
  40639. 'AL',
  40640. 'AL',
  40641. 'AL',
  40642. 'AL',
  40643. 'AL',
  40644. 'AL',
  40645. 'AL',
  40646. 'AL',
  40647. 'AL',
  40648. 'AL',
  40649. 'AL',
  40650. 'AL',
  40651. 'AL',
  40652. 'AL',
  40653. 'AL',
  40654. 'AL',
  40655. 'AL',
  40656. 'AL',
  40657. 'AL',
  40658. 'AL',
  40659. 'AL',
  40660. 'AL',
  40661. 'AL',
  40662. 'AL',
  40663. 'AL',
  40664. 'AL',
  40665. 'AL',
  40666. 'AL',
  40667. 'AL',
  40668. 'AL',
  40669. 'AL',
  40670. 'AL',
  40671. 'AL',
  40672. 'AL',
  40673. 'AL',
  40674. 'AL',
  40675. 'AL',
  40676. 'AL',
  40677. 'AL',
  40678. 'AL',
  40679. 'AL',
  40680. 'NSM',
  40681. 'NSM',
  40682. 'NSM',
  40683. 'NSM',
  40684. 'NSM',
  40685. 'NSM',
  40686. 'NSM',
  40687. 'NSM',
  40688. 'NSM',
  40689. 'NSM',
  40690. 'NSM',
  40691. 'NSM',
  40692. 'NSM',
  40693. 'NSM',
  40694. 'NSM',
  40695. 'NSM',
  40696. 'NSM',
  40697. 'NSM',
  40698. 'NSM',
  40699. 'NSM',
  40700. 'NSM',
  40701. 'AN',
  40702. 'AN',
  40703. 'AN',
  40704. 'AN',
  40705. 'AN',
  40706. 'AN',
  40707. 'AN',
  40708. 'AN',
  40709. 'AN',
  40710. 'AN',
  40711. 'ET',
  40712. 'AN',
  40713. 'AN',
  40714. 'AL',
  40715. 'AL',
  40716. 'AL',
  40717. 'NSM',
  40718. 'AL',
  40719. 'AL',
  40720. 'AL',
  40721. 'AL',
  40722. 'AL',
  40723. 'AL',
  40724. 'AL',
  40725. 'AL',
  40726. 'AL',
  40727. 'AL',
  40728. 'AL',
  40729. 'AL',
  40730. 'AL',
  40731. 'AL',
  40732. 'AL',
  40733. 'AL',
  40734. 'AL',
  40735. 'AL',
  40736. 'AL',
  40737. 'AL',
  40738. 'AL',
  40739. 'AL',
  40740. 'AL',
  40741. 'AL',
  40742. 'AL',
  40743. 'AL',
  40744. 'AL',
  40745. 'AL',
  40746. 'AL',
  40747. 'AL',
  40748. 'AL',
  40749. 'AL',
  40750. 'AL',
  40751. 'AL',
  40752. 'AL',
  40753. 'AL',
  40754. 'AL',
  40755. 'AL',
  40756. 'AL',
  40757. 'AL',
  40758. 'AL',
  40759. 'AL',
  40760. 'AL',
  40761. 'AL',
  40762. 'AL',
  40763. 'AL',
  40764. 'AL',
  40765. 'AL',
  40766. 'AL',
  40767. 'AL',
  40768. 'AL',
  40769. 'AL',
  40770. 'AL',
  40771. 'AL',
  40772. 'AL',
  40773. 'AL',
  40774. 'AL',
  40775. 'AL',
  40776. 'AL',
  40777. 'AL',
  40778. 'AL',
  40779. 'AL',
  40780. 'AL',
  40781. 'AL',
  40782. 'AL',
  40783. 'AL',
  40784. 'AL',
  40785. 'AL',
  40786. 'AL',
  40787. 'AL',
  40788. 'AL',
  40789. 'AL',
  40790. 'AL',
  40791. 'AL',
  40792. 'AL',
  40793. 'AL',
  40794. 'AL',
  40795. 'AL',
  40796. 'AL',
  40797. 'AL',
  40798. 'AL',
  40799. 'AL',
  40800. 'AL',
  40801. 'AL',
  40802. 'AL',
  40803. 'AL',
  40804. 'AL',
  40805. 'AL',
  40806. 'AL',
  40807. 'AL',
  40808. 'AL',
  40809. 'AL',
  40810. 'AL',
  40811. 'AL',
  40812. 'AL',
  40813. 'AL',
  40814. 'AL',
  40815. 'AL',
  40816. 'AL',
  40817. 'AL',
  40818. 'AL',
  40819. 'NSM',
  40820. 'NSM',
  40821. 'NSM',
  40822. 'NSM',
  40823. 'NSM',
  40824. 'NSM',
  40825. 'NSM',
  40826. 'AN',
  40827. 'ON',
  40828. 'NSM',
  40829. 'NSM',
  40830. 'NSM',
  40831. 'NSM',
  40832. 'NSM',
  40833. 'NSM',
  40834. 'AL',
  40835. 'AL',
  40836. 'NSM',
  40837. 'NSM',
  40838. 'ON',
  40839. 'NSM',
  40840. 'NSM',
  40841. 'NSM',
  40842. 'NSM',
  40843. 'AL',
  40844. 'AL',
  40845. 'EN',
  40846. 'EN',
  40847. 'EN',
  40848. 'EN',
  40849. 'EN',
  40850. 'EN',
  40851. 'EN',
  40852. 'EN',
  40853. 'EN',
  40854. 'EN',
  40855. 'AL',
  40856. 'AL',
  40857. 'AL',
  40858. 'AL',
  40859. 'AL',
  40860. 'AL'
  40861. ];
  40862. function isOdd(i) {
  40863. return (i & 1) !== 0;
  40864. }
  40865. function isEven(i) {
  40866. return (i & 1) === 0;
  40867. }
  40868. function findUnequal(arr, start, value) {
  40869. for (var j = start, jj = arr.length; j < jj; ++j) {
  40870. if (arr[j] !== value) {
  40871. return j;
  40872. }
  40873. }
  40874. return j;
  40875. }
  40876. function setValues(arr, start, end, value) {
  40877. for (var j = start; j < end; ++j) {
  40878. arr[j] = value;
  40879. }
  40880. }
  40881. function reverseValues(arr, start, end) {
  40882. for (var i = start, j = end - 1; i < j; ++i, --j) {
  40883. var temp = arr[i];
  40884. arr[i] = arr[j];
  40885. arr[j] = temp;
  40886. }
  40887. }
  40888. function createBidiText(str, isLTR, vertical) {
  40889. return {
  40890. str: str,
  40891. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  40892. };
  40893. }
  40894. var chars = [];
  40895. var types = [];
  40896. function bidi(str, startLevel, vertical) {
  40897. var isLTR = true;
  40898. var strLength = str.length;
  40899. if (strLength === 0 || vertical) {
  40900. return createBidiText(str, isLTR, vertical);
  40901. }
  40902. chars.length = strLength;
  40903. types.length = strLength;
  40904. var numBidi = 0;
  40905. var i, ii;
  40906. for (i = 0; i < strLength; ++i) {
  40907. chars[i] = str.charAt(i);
  40908. var charCode = str.charCodeAt(i);
  40909. var charType = 'L';
  40910. if (charCode <= 0x00ff) {
  40911. charType = baseTypes[charCode];
  40912. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  40913. charType = 'R';
  40914. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  40915. charType = arabicTypes[charCode & 0xff];
  40916. if (!charType) {
  40917. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  40918. }
  40919. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  40920. charType = 'AL';
  40921. }
  40922. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  40923. numBidi++;
  40924. }
  40925. types[i] = charType;
  40926. }
  40927. if (numBidi === 0) {
  40928. isLTR = true;
  40929. return createBidiText(str, isLTR);
  40930. }
  40931. if (startLevel === -1) {
  40932. if (numBidi / strLength < 0.3) {
  40933. isLTR = true;
  40934. startLevel = 0;
  40935. } else {
  40936. isLTR = false;
  40937. startLevel = 1;
  40938. }
  40939. }
  40940. var levels = [];
  40941. for (i = 0; i < strLength; ++i) {
  40942. levels[i] = startLevel;
  40943. }
  40944. var e = isOdd(startLevel) ? 'R' : 'L';
  40945. var sor = e;
  40946. var eor = sor;
  40947. var lastType = sor;
  40948. for (i = 0; i < strLength; ++i) {
  40949. if (types[i] === 'NSM') {
  40950. types[i] = lastType;
  40951. } else {
  40952. lastType = types[i];
  40953. }
  40954. }
  40955. lastType = sor;
  40956. var t;
  40957. for (i = 0; i < strLength; ++i) {
  40958. t = types[i];
  40959. if (t === 'EN') {
  40960. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  40961. } else if (t === 'R' || t === 'L' || t === 'AL') {
  40962. lastType = t;
  40963. }
  40964. }
  40965. for (i = 0; i < strLength; ++i) {
  40966. t = types[i];
  40967. if (t === 'AL') {
  40968. types[i] = 'R';
  40969. }
  40970. }
  40971. for (i = 1; i < strLength - 1; ++i) {
  40972. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  40973. types[i] = 'EN';
  40974. }
  40975. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  40976. types[i] = types[i - 1];
  40977. }
  40978. }
  40979. for (i = 0; i < strLength; ++i) {
  40980. if (types[i] === 'EN') {
  40981. var j;
  40982. for (j = i - 1; j >= 0; --j) {
  40983. if (types[j] !== 'ET') {
  40984. break;
  40985. }
  40986. types[j] = 'EN';
  40987. }
  40988. for (j = i + 1; j < strLength; ++j) {
  40989. if (types[j] !== 'ET') {
  40990. break;
  40991. }
  40992. types[j] = 'EN';
  40993. }
  40994. }
  40995. }
  40996. for (i = 0; i < strLength; ++i) {
  40997. t = types[i];
  40998. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  40999. types[i] = 'ON';
  41000. }
  41001. }
  41002. lastType = sor;
  41003. for (i = 0; i < strLength; ++i) {
  41004. t = types[i];
  41005. if (t === 'EN') {
  41006. types[i] = lastType === 'L' ? 'L' : 'EN';
  41007. } else if (t === 'R' || t === 'L') {
  41008. lastType = t;
  41009. }
  41010. }
  41011. for (i = 0; i < strLength; ++i) {
  41012. if (types[i] === 'ON') {
  41013. var end = findUnequal(types, i + 1, 'ON');
  41014. var before = sor;
  41015. if (i > 0) {
  41016. before = types[i - 1];
  41017. }
  41018. var after = eor;
  41019. if (end + 1 < strLength) {
  41020. after = types[end + 1];
  41021. }
  41022. if (before !== 'L') {
  41023. before = 'R';
  41024. }
  41025. if (after !== 'L') {
  41026. after = 'R';
  41027. }
  41028. if (before === after) {
  41029. setValues(types, i, end, before);
  41030. }
  41031. i = end - 1;
  41032. }
  41033. }
  41034. for (i = 0; i < strLength; ++i) {
  41035. if (types[i] === 'ON') {
  41036. types[i] = e;
  41037. }
  41038. }
  41039. for (i = 0; i < strLength; ++i) {
  41040. t = types[i];
  41041. if (isEven(levels[i])) {
  41042. if (t === 'R') {
  41043. levels[i] += 1;
  41044. } else if (t === 'AN' || t === 'EN') {
  41045. levels[i] += 2;
  41046. }
  41047. } else {
  41048. if (t === 'L' || t === 'AN' || t === 'EN') {
  41049. levels[i] += 1;
  41050. }
  41051. }
  41052. }
  41053. var highestLevel = -1;
  41054. var lowestOddLevel = 99;
  41055. var level;
  41056. for (i = 0, ii = levels.length; i < ii; ++i) {
  41057. level = levels[i];
  41058. if (highestLevel < level) {
  41059. highestLevel = level;
  41060. }
  41061. if (lowestOddLevel > level && isOdd(level)) {
  41062. lowestOddLevel = level;
  41063. }
  41064. }
  41065. for (level = highestLevel; level >= lowestOddLevel; --level) {
  41066. var start = -1;
  41067. for (i = 0, ii = levels.length; i < ii; ++i) {
  41068. if (levels[i] < level) {
  41069. if (start >= 0) {
  41070. reverseValues(chars, start, i);
  41071. start = -1;
  41072. }
  41073. } else if (start < 0) {
  41074. start = i;
  41075. }
  41076. }
  41077. if (start >= 0) {
  41078. reverseValues(chars, start, levels.length);
  41079. }
  41080. }
  41081. for (i = 0, ii = chars.length; i < ii; ++i) {
  41082. var ch = chars[i];
  41083. if (ch === '<' || ch === '>') {
  41084. chars[i] = '';
  41085. }
  41086. }
  41087. return createBidiText(chars.join(''), isLTR);
  41088. }
  41089. exports.bidi = bidi;
  41090. /***/ }),
  41091. /* 29 */
  41092. /***/ (function(module, exports, __w_pdfjs_require__) {
  41093. "use strict";
  41094. var ISOAdobeCharset = [
  41095. '.notdef',
  41096. 'space',
  41097. 'exclam',
  41098. 'quotedbl',
  41099. 'numbersign',
  41100. 'dollar',
  41101. 'percent',
  41102. 'ampersand',
  41103. 'quoteright',
  41104. 'parenleft',
  41105. 'parenright',
  41106. 'asterisk',
  41107. 'plus',
  41108. 'comma',
  41109. 'hyphen',
  41110. 'period',
  41111. 'slash',
  41112. 'zero',
  41113. 'one',
  41114. 'two',
  41115. 'three',
  41116. 'four',
  41117. 'five',
  41118. 'six',
  41119. 'seven',
  41120. 'eight',
  41121. 'nine',
  41122. 'colon',
  41123. 'semicolon',
  41124. 'less',
  41125. 'equal',
  41126. 'greater',
  41127. 'question',
  41128. 'at',
  41129. 'A',
  41130. 'B',
  41131. 'C',
  41132. 'D',
  41133. 'E',
  41134. 'F',
  41135. 'G',
  41136. 'H',
  41137. 'I',
  41138. 'J',
  41139. 'K',
  41140. 'L',
  41141. 'M',
  41142. 'N',
  41143. 'O',
  41144. 'P',
  41145. 'Q',
  41146. 'R',
  41147. 'S',
  41148. 'T',
  41149. 'U',
  41150. 'V',
  41151. 'W',
  41152. 'X',
  41153. 'Y',
  41154. 'Z',
  41155. 'bracketleft',
  41156. 'backslash',
  41157. 'bracketright',
  41158. 'asciicircum',
  41159. 'underscore',
  41160. 'quoteleft',
  41161. 'a',
  41162. 'b',
  41163. 'c',
  41164. 'd',
  41165. 'e',
  41166. 'f',
  41167. 'g',
  41168. 'h',
  41169. 'i',
  41170. 'j',
  41171. 'k',
  41172. 'l',
  41173. 'm',
  41174. 'n',
  41175. 'o',
  41176. 'p',
  41177. 'q',
  41178. 'r',
  41179. 's',
  41180. 't',
  41181. 'u',
  41182. 'v',
  41183. 'w',
  41184. 'x',
  41185. 'y',
  41186. 'z',
  41187. 'braceleft',
  41188. 'bar',
  41189. 'braceright',
  41190. 'asciitilde',
  41191. 'exclamdown',
  41192. 'cent',
  41193. 'sterling',
  41194. 'fraction',
  41195. 'yen',
  41196. 'florin',
  41197. 'section',
  41198. 'currency',
  41199. 'quotesingle',
  41200. 'quotedblleft',
  41201. 'guillemotleft',
  41202. 'guilsinglleft',
  41203. 'guilsinglright',
  41204. 'fi',
  41205. 'fl',
  41206. 'endash',
  41207. 'dagger',
  41208. 'daggerdbl',
  41209. 'periodcentered',
  41210. 'paragraph',
  41211. 'bullet',
  41212. 'quotesinglbase',
  41213. 'quotedblbase',
  41214. 'quotedblright',
  41215. 'guillemotright',
  41216. 'ellipsis',
  41217. 'perthousand',
  41218. 'questiondown',
  41219. 'grave',
  41220. 'acute',
  41221. 'circumflex',
  41222. 'tilde',
  41223. 'macron',
  41224. 'breve',
  41225. 'dotaccent',
  41226. 'dieresis',
  41227. 'ring',
  41228. 'cedilla',
  41229. 'hungarumlaut',
  41230. 'ogonek',
  41231. 'caron',
  41232. 'emdash',
  41233. 'AE',
  41234. 'ordfeminine',
  41235. 'Lslash',
  41236. 'Oslash',
  41237. 'OE',
  41238. 'ordmasculine',
  41239. 'ae',
  41240. 'dotlessi',
  41241. 'lslash',
  41242. 'oslash',
  41243. 'oe',
  41244. 'germandbls',
  41245. 'onesuperior',
  41246. 'logicalnot',
  41247. 'mu',
  41248. 'trademark',
  41249. 'Eth',
  41250. 'onehalf',
  41251. 'plusminus',
  41252. 'Thorn',
  41253. 'onequarter',
  41254. 'divide',
  41255. 'brokenbar',
  41256. 'degree',
  41257. 'thorn',
  41258. 'threequarters',
  41259. 'twosuperior',
  41260. 'registered',
  41261. 'minus',
  41262. 'eth',
  41263. 'multiply',
  41264. 'threesuperior',
  41265. 'copyright',
  41266. 'Aacute',
  41267. 'Acircumflex',
  41268. 'Adieresis',
  41269. 'Agrave',
  41270. 'Aring',
  41271. 'Atilde',
  41272. 'Ccedilla',
  41273. 'Eacute',
  41274. 'Ecircumflex',
  41275. 'Edieresis',
  41276. 'Egrave',
  41277. 'Iacute',
  41278. 'Icircumflex',
  41279. 'Idieresis',
  41280. 'Igrave',
  41281. 'Ntilde',
  41282. 'Oacute',
  41283. 'Ocircumflex',
  41284. 'Odieresis',
  41285. 'Ograve',
  41286. 'Otilde',
  41287. 'Scaron',
  41288. 'Uacute',
  41289. 'Ucircumflex',
  41290. 'Udieresis',
  41291. 'Ugrave',
  41292. 'Yacute',
  41293. 'Ydieresis',
  41294. 'Zcaron',
  41295. 'aacute',
  41296. 'acircumflex',
  41297. 'adieresis',
  41298. 'agrave',
  41299. 'aring',
  41300. 'atilde',
  41301. 'ccedilla',
  41302. 'eacute',
  41303. 'ecircumflex',
  41304. 'edieresis',
  41305. 'egrave',
  41306. 'iacute',
  41307. 'icircumflex',
  41308. 'idieresis',
  41309. 'igrave',
  41310. 'ntilde',
  41311. 'oacute',
  41312. 'ocircumflex',
  41313. 'odieresis',
  41314. 'ograve',
  41315. 'otilde',
  41316. 'scaron',
  41317. 'uacute',
  41318. 'ucircumflex',
  41319. 'udieresis',
  41320. 'ugrave',
  41321. 'yacute',
  41322. 'ydieresis',
  41323. 'zcaron'
  41324. ];
  41325. var ExpertCharset = [
  41326. '.notdef',
  41327. 'space',
  41328. 'exclamsmall',
  41329. 'Hungarumlautsmall',
  41330. 'dollaroldstyle',
  41331. 'dollarsuperior',
  41332. 'ampersandsmall',
  41333. 'Acutesmall',
  41334. 'parenleftsuperior',
  41335. 'parenrightsuperior',
  41336. 'twodotenleader',
  41337. 'onedotenleader',
  41338. 'comma',
  41339. 'hyphen',
  41340. 'period',
  41341. 'fraction',
  41342. 'zerooldstyle',
  41343. 'oneoldstyle',
  41344. 'twooldstyle',
  41345. 'threeoldstyle',
  41346. 'fouroldstyle',
  41347. 'fiveoldstyle',
  41348. 'sixoldstyle',
  41349. 'sevenoldstyle',
  41350. 'eightoldstyle',
  41351. 'nineoldstyle',
  41352. 'colon',
  41353. 'semicolon',
  41354. 'commasuperior',
  41355. 'threequartersemdash',
  41356. 'periodsuperior',
  41357. 'questionsmall',
  41358. 'asuperior',
  41359. 'bsuperior',
  41360. 'centsuperior',
  41361. 'dsuperior',
  41362. 'esuperior',
  41363. 'isuperior',
  41364. 'lsuperior',
  41365. 'msuperior',
  41366. 'nsuperior',
  41367. 'osuperior',
  41368. 'rsuperior',
  41369. 'ssuperior',
  41370. 'tsuperior',
  41371. 'ff',
  41372. 'fi',
  41373. 'fl',
  41374. 'ffi',
  41375. 'ffl',
  41376. 'parenleftinferior',
  41377. 'parenrightinferior',
  41378. 'Circumflexsmall',
  41379. 'hyphensuperior',
  41380. 'Gravesmall',
  41381. 'Asmall',
  41382. 'Bsmall',
  41383. 'Csmall',
  41384. 'Dsmall',
  41385. 'Esmall',
  41386. 'Fsmall',
  41387. 'Gsmall',
  41388. 'Hsmall',
  41389. 'Ismall',
  41390. 'Jsmall',
  41391. 'Ksmall',
  41392. 'Lsmall',
  41393. 'Msmall',
  41394. 'Nsmall',
  41395. 'Osmall',
  41396. 'Psmall',
  41397. 'Qsmall',
  41398. 'Rsmall',
  41399. 'Ssmall',
  41400. 'Tsmall',
  41401. 'Usmall',
  41402. 'Vsmall',
  41403. 'Wsmall',
  41404. 'Xsmall',
  41405. 'Ysmall',
  41406. 'Zsmall',
  41407. 'colonmonetary',
  41408. 'onefitted',
  41409. 'rupiah',
  41410. 'Tildesmall',
  41411. 'exclamdownsmall',
  41412. 'centoldstyle',
  41413. 'Lslashsmall',
  41414. 'Scaronsmall',
  41415. 'Zcaronsmall',
  41416. 'Dieresissmall',
  41417. 'Brevesmall',
  41418. 'Caronsmall',
  41419. 'Dotaccentsmall',
  41420. 'Macronsmall',
  41421. 'figuredash',
  41422. 'hypheninferior',
  41423. 'Ogoneksmall',
  41424. 'Ringsmall',
  41425. 'Cedillasmall',
  41426. 'onequarter',
  41427. 'onehalf',
  41428. 'threequarters',
  41429. 'questiondownsmall',
  41430. 'oneeighth',
  41431. 'threeeighths',
  41432. 'fiveeighths',
  41433. 'seveneighths',
  41434. 'onethird',
  41435. 'twothirds',
  41436. 'zerosuperior',
  41437. 'onesuperior',
  41438. 'twosuperior',
  41439. 'threesuperior',
  41440. 'foursuperior',
  41441. 'fivesuperior',
  41442. 'sixsuperior',
  41443. 'sevensuperior',
  41444. 'eightsuperior',
  41445. 'ninesuperior',
  41446. 'zeroinferior',
  41447. 'oneinferior',
  41448. 'twoinferior',
  41449. 'threeinferior',
  41450. 'fourinferior',
  41451. 'fiveinferior',
  41452. 'sixinferior',
  41453. 'seveninferior',
  41454. 'eightinferior',
  41455. 'nineinferior',
  41456. 'centinferior',
  41457. 'dollarinferior',
  41458. 'periodinferior',
  41459. 'commainferior',
  41460. 'Agravesmall',
  41461. 'Aacutesmall',
  41462. 'Acircumflexsmall',
  41463. 'Atildesmall',
  41464. 'Adieresissmall',
  41465. 'Aringsmall',
  41466. 'AEsmall',
  41467. 'Ccedillasmall',
  41468. 'Egravesmall',
  41469. 'Eacutesmall',
  41470. 'Ecircumflexsmall',
  41471. 'Edieresissmall',
  41472. 'Igravesmall',
  41473. 'Iacutesmall',
  41474. 'Icircumflexsmall',
  41475. 'Idieresissmall',
  41476. 'Ethsmall',
  41477. 'Ntildesmall',
  41478. 'Ogravesmall',
  41479. 'Oacutesmall',
  41480. 'Ocircumflexsmall',
  41481. 'Otildesmall',
  41482. 'Odieresissmall',
  41483. 'OEsmall',
  41484. 'Oslashsmall',
  41485. 'Ugravesmall',
  41486. 'Uacutesmall',
  41487. 'Ucircumflexsmall',
  41488. 'Udieresissmall',
  41489. 'Yacutesmall',
  41490. 'Thornsmall',
  41491. 'Ydieresissmall'
  41492. ];
  41493. var ExpertSubsetCharset = [
  41494. '.notdef',
  41495. 'space',
  41496. 'dollaroldstyle',
  41497. 'dollarsuperior',
  41498. 'parenleftsuperior',
  41499. 'parenrightsuperior',
  41500. 'twodotenleader',
  41501. 'onedotenleader',
  41502. 'comma',
  41503. 'hyphen',
  41504. 'period',
  41505. 'fraction',
  41506. 'zerooldstyle',
  41507. 'oneoldstyle',
  41508. 'twooldstyle',
  41509. 'threeoldstyle',
  41510. 'fouroldstyle',
  41511. 'fiveoldstyle',
  41512. 'sixoldstyle',
  41513. 'sevenoldstyle',
  41514. 'eightoldstyle',
  41515. 'nineoldstyle',
  41516. 'colon',
  41517. 'semicolon',
  41518. 'commasuperior',
  41519. 'threequartersemdash',
  41520. 'periodsuperior',
  41521. 'asuperior',
  41522. 'bsuperior',
  41523. 'centsuperior',
  41524. 'dsuperior',
  41525. 'esuperior',
  41526. 'isuperior',
  41527. 'lsuperior',
  41528. 'msuperior',
  41529. 'nsuperior',
  41530. 'osuperior',
  41531. 'rsuperior',
  41532. 'ssuperior',
  41533. 'tsuperior',
  41534. 'ff',
  41535. 'fi',
  41536. 'fl',
  41537. 'ffi',
  41538. 'ffl',
  41539. 'parenleftinferior',
  41540. 'parenrightinferior',
  41541. 'hyphensuperior',
  41542. 'colonmonetary',
  41543. 'onefitted',
  41544. 'rupiah',
  41545. 'centoldstyle',
  41546. 'figuredash',
  41547. 'hypheninferior',
  41548. 'onequarter',
  41549. 'onehalf',
  41550. 'threequarters',
  41551. 'oneeighth',
  41552. 'threeeighths',
  41553. 'fiveeighths',
  41554. 'seveneighths',
  41555. 'onethird',
  41556. 'twothirds',
  41557. 'zerosuperior',
  41558. 'onesuperior',
  41559. 'twosuperior',
  41560. 'threesuperior',
  41561. 'foursuperior',
  41562. 'fivesuperior',
  41563. 'sixsuperior',
  41564. 'sevensuperior',
  41565. 'eightsuperior',
  41566. 'ninesuperior',
  41567. 'zeroinferior',
  41568. 'oneinferior',
  41569. 'twoinferior',
  41570. 'threeinferior',
  41571. 'fourinferior',
  41572. 'fiveinferior',
  41573. 'sixinferior',
  41574. 'seveninferior',
  41575. 'eightinferior',
  41576. 'nineinferior',
  41577. 'centinferior',
  41578. 'dollarinferior',
  41579. 'periodinferior',
  41580. 'commainferior'
  41581. ];
  41582. exports.ISOAdobeCharset = ISOAdobeCharset;
  41583. exports.ExpertCharset = ExpertCharset;
  41584. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  41585. /***/ }),
  41586. /* 30 */
  41587. /***/ (function(module, exports, __w_pdfjs_require__) {
  41588. "use strict";
  41589. var sharedUtil = __w_pdfjs_require__(0);
  41590. var corePrimitives = __w_pdfjs_require__(1);
  41591. var coreStream = __w_pdfjs_require__(2);
  41592. var coreParser = __w_pdfjs_require__(6);
  41593. var Util = sharedUtil.Util;
  41594. var assert = sharedUtil.assert;
  41595. var warn = sharedUtil.warn;
  41596. var error = sharedUtil.error;
  41597. var isInt = sharedUtil.isInt;
  41598. var isString = sharedUtil.isString;
  41599. var MissingDataException = sharedUtil.MissingDataException;
  41600. var CMapCompressionType = sharedUtil.CMapCompressionType;
  41601. var isEOF = corePrimitives.isEOF;
  41602. var isName = corePrimitives.isName;
  41603. var isCmd = corePrimitives.isCmd;
  41604. var isStream = corePrimitives.isStream;
  41605. var Stream = coreStream.Stream;
  41606. var Lexer = coreParser.Lexer;
  41607. var BUILT_IN_CMAPS = [
  41608. 'Adobe-GB1-UCS2',
  41609. 'Adobe-CNS1-UCS2',
  41610. 'Adobe-Japan1-UCS2',
  41611. 'Adobe-Korea1-UCS2',
  41612. '78-EUC-H',
  41613. '78-EUC-V',
  41614. '78-H',
  41615. '78-RKSJ-H',
  41616. '78-RKSJ-V',
  41617. '78-V',
  41618. '78ms-RKSJ-H',
  41619. '78ms-RKSJ-V',
  41620. '83pv-RKSJ-H',
  41621. '90ms-RKSJ-H',
  41622. '90ms-RKSJ-V',
  41623. '90msp-RKSJ-H',
  41624. '90msp-RKSJ-V',
  41625. '90pv-RKSJ-H',
  41626. '90pv-RKSJ-V',
  41627. 'Add-H',
  41628. 'Add-RKSJ-H',
  41629. 'Add-RKSJ-V',
  41630. 'Add-V',
  41631. 'Adobe-CNS1-0',
  41632. 'Adobe-CNS1-1',
  41633. 'Adobe-CNS1-2',
  41634. 'Adobe-CNS1-3',
  41635. 'Adobe-CNS1-4',
  41636. 'Adobe-CNS1-5',
  41637. 'Adobe-CNS1-6',
  41638. 'Adobe-GB1-0',
  41639. 'Adobe-GB1-1',
  41640. 'Adobe-GB1-2',
  41641. 'Adobe-GB1-3',
  41642. 'Adobe-GB1-4',
  41643. 'Adobe-GB1-5',
  41644. 'Adobe-Japan1-0',
  41645. 'Adobe-Japan1-1',
  41646. 'Adobe-Japan1-2',
  41647. 'Adobe-Japan1-3',
  41648. 'Adobe-Japan1-4',
  41649. 'Adobe-Japan1-5',
  41650. 'Adobe-Japan1-6',
  41651. 'Adobe-Korea1-0',
  41652. 'Adobe-Korea1-1',
  41653. 'Adobe-Korea1-2',
  41654. 'B5-H',
  41655. 'B5-V',
  41656. 'B5pc-H',
  41657. 'B5pc-V',
  41658. 'CNS-EUC-H',
  41659. 'CNS-EUC-V',
  41660. 'CNS1-H',
  41661. 'CNS1-V',
  41662. 'CNS2-H',
  41663. 'CNS2-V',
  41664. 'ETHK-B5-H',
  41665. 'ETHK-B5-V',
  41666. 'ETen-B5-H',
  41667. 'ETen-B5-V',
  41668. 'ETenms-B5-H',
  41669. 'ETenms-B5-V',
  41670. 'EUC-H',
  41671. 'EUC-V',
  41672. 'Ext-H',
  41673. 'Ext-RKSJ-H',
  41674. 'Ext-RKSJ-V',
  41675. 'Ext-V',
  41676. 'GB-EUC-H',
  41677. 'GB-EUC-V',
  41678. 'GB-H',
  41679. 'GB-V',
  41680. 'GBK-EUC-H',
  41681. 'GBK-EUC-V',
  41682. 'GBK2K-H',
  41683. 'GBK2K-V',
  41684. 'GBKp-EUC-H',
  41685. 'GBKp-EUC-V',
  41686. 'GBT-EUC-H',
  41687. 'GBT-EUC-V',
  41688. 'GBT-H',
  41689. 'GBT-V',
  41690. 'GBTpc-EUC-H',
  41691. 'GBTpc-EUC-V',
  41692. 'GBpc-EUC-H',
  41693. 'GBpc-EUC-V',
  41694. 'H',
  41695. 'HKdla-B5-H',
  41696. 'HKdla-B5-V',
  41697. 'HKdlb-B5-H',
  41698. 'HKdlb-B5-V',
  41699. 'HKgccs-B5-H',
  41700. 'HKgccs-B5-V',
  41701. 'HKm314-B5-H',
  41702. 'HKm314-B5-V',
  41703. 'HKm471-B5-H',
  41704. 'HKm471-B5-V',
  41705. 'HKscs-B5-H',
  41706. 'HKscs-B5-V',
  41707. 'Hankaku',
  41708. 'Hiragana',
  41709. 'KSC-EUC-H',
  41710. 'KSC-EUC-V',
  41711. 'KSC-H',
  41712. 'KSC-Johab-H',
  41713. 'KSC-Johab-V',
  41714. 'KSC-V',
  41715. 'KSCms-UHC-H',
  41716. 'KSCms-UHC-HW-H',
  41717. 'KSCms-UHC-HW-V',
  41718. 'KSCms-UHC-V',
  41719. 'KSCpc-EUC-H',
  41720. 'KSCpc-EUC-V',
  41721. 'Katakana',
  41722. 'NWP-H',
  41723. 'NWP-V',
  41724. 'RKSJ-H',
  41725. 'RKSJ-V',
  41726. 'Roman',
  41727. 'UniCNS-UCS2-H',
  41728. 'UniCNS-UCS2-V',
  41729. 'UniCNS-UTF16-H',
  41730. 'UniCNS-UTF16-V',
  41731. 'UniCNS-UTF32-H',
  41732. 'UniCNS-UTF32-V',
  41733. 'UniCNS-UTF8-H',
  41734. 'UniCNS-UTF8-V',
  41735. 'UniGB-UCS2-H',
  41736. 'UniGB-UCS2-V',
  41737. 'UniGB-UTF16-H',
  41738. 'UniGB-UTF16-V',
  41739. 'UniGB-UTF32-H',
  41740. 'UniGB-UTF32-V',
  41741. 'UniGB-UTF8-H',
  41742. 'UniGB-UTF8-V',
  41743. 'UniJIS-UCS2-H',
  41744. 'UniJIS-UCS2-HW-H',
  41745. 'UniJIS-UCS2-HW-V',
  41746. 'UniJIS-UCS2-V',
  41747. 'UniJIS-UTF16-H',
  41748. 'UniJIS-UTF16-V',
  41749. 'UniJIS-UTF32-H',
  41750. 'UniJIS-UTF32-V',
  41751. 'UniJIS-UTF8-H',
  41752. 'UniJIS-UTF8-V',
  41753. 'UniJIS2004-UTF16-H',
  41754. 'UniJIS2004-UTF16-V',
  41755. 'UniJIS2004-UTF32-H',
  41756. 'UniJIS2004-UTF32-V',
  41757. 'UniJIS2004-UTF8-H',
  41758. 'UniJIS2004-UTF8-V',
  41759. 'UniJISPro-UCS2-HW-V',
  41760. 'UniJISPro-UCS2-V',
  41761. 'UniJISPro-UTF8-V',
  41762. 'UniJISX0213-UTF32-H',
  41763. 'UniJISX0213-UTF32-V',
  41764. 'UniJISX02132004-UTF32-H',
  41765. 'UniJISX02132004-UTF32-V',
  41766. 'UniKS-UCS2-H',
  41767. 'UniKS-UCS2-V',
  41768. 'UniKS-UTF16-H',
  41769. 'UniKS-UTF16-V',
  41770. 'UniKS-UTF32-H',
  41771. 'UniKS-UTF32-V',
  41772. 'UniKS-UTF8-H',
  41773. 'UniKS-UTF8-V',
  41774. 'V',
  41775. 'WP-Symbol'
  41776. ];
  41777. var CMap = function CMapClosure() {
  41778. function CMap(builtInCMap) {
  41779. this.codespaceRanges = [
  41780. [],
  41781. [],
  41782. [],
  41783. []
  41784. ];
  41785. this.numCodespaceRanges = 0;
  41786. this._map = [];
  41787. this.name = '';
  41788. this.vertical = false;
  41789. this.useCMap = null;
  41790. this.builtInCMap = builtInCMap;
  41791. }
  41792. CMap.prototype = {
  41793. addCodespaceRange: function (n, low, high) {
  41794. this.codespaceRanges[n - 1].push(low, high);
  41795. this.numCodespaceRanges++;
  41796. },
  41797. mapCidRange: function (low, high, dstLow) {
  41798. while (low <= high) {
  41799. this._map[low++] = dstLow++;
  41800. }
  41801. },
  41802. mapBfRange: function (low, high, dstLow) {
  41803. var lastByte = dstLow.length - 1;
  41804. while (low <= high) {
  41805. this._map[low++] = dstLow;
  41806. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  41807. }
  41808. },
  41809. mapBfRangeToArray: function (low, high, array) {
  41810. var i = 0, ii = array.length;
  41811. while (low <= high && i < ii) {
  41812. this._map[low] = array[i++];
  41813. ++low;
  41814. }
  41815. },
  41816. mapOne: function (src, dst) {
  41817. this._map[src] = dst;
  41818. },
  41819. lookup: function (code) {
  41820. return this._map[code];
  41821. },
  41822. contains: function (code) {
  41823. return this._map[code] !== undefined;
  41824. },
  41825. forEach: function (callback) {
  41826. var map = this._map;
  41827. var length = map.length;
  41828. var i;
  41829. if (length <= 0x10000) {
  41830. for (i = 0; i < length; i++) {
  41831. if (map[i] !== undefined) {
  41832. callback(i, map[i]);
  41833. }
  41834. }
  41835. } else {
  41836. for (i in this._map) {
  41837. callback(i, map[i]);
  41838. }
  41839. }
  41840. },
  41841. charCodeOf: function (value) {
  41842. return this._map.indexOf(value);
  41843. },
  41844. getMap: function () {
  41845. return this._map;
  41846. },
  41847. readCharCode: function (str, offset, out) {
  41848. var c = 0;
  41849. var codespaceRanges = this.codespaceRanges;
  41850. var codespaceRangesLen = this.codespaceRanges.length;
  41851. for (var n = 0; n < codespaceRangesLen; n++) {
  41852. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  41853. var codespaceRange = codespaceRanges[n];
  41854. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  41855. var low = codespaceRange[k++];
  41856. var high = codespaceRange[k++];
  41857. if (c >= low && c <= high) {
  41858. out.charcode = c;
  41859. out.length = n + 1;
  41860. return;
  41861. }
  41862. }
  41863. }
  41864. out.charcode = 0;
  41865. out.length = 1;
  41866. },
  41867. get length() {
  41868. return this._map.length;
  41869. },
  41870. get isIdentityCMap() {
  41871. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  41872. return false;
  41873. }
  41874. if (this._map.length !== 0x10000) {
  41875. return false;
  41876. }
  41877. for (var i = 0; i < 0x10000; i++) {
  41878. if (this._map[i] !== i) {
  41879. return false;
  41880. }
  41881. }
  41882. return true;
  41883. }
  41884. };
  41885. return CMap;
  41886. }();
  41887. var IdentityCMap = function IdentityCMapClosure() {
  41888. function IdentityCMap(vertical, n) {
  41889. CMap.call(this);
  41890. this.vertical = vertical;
  41891. this.addCodespaceRange(n, 0, 0xffff);
  41892. }
  41893. Util.inherit(IdentityCMap, CMap, {});
  41894. IdentityCMap.prototype = {
  41895. addCodespaceRange: CMap.prototype.addCodespaceRange,
  41896. mapCidRange: function (low, high, dstLow) {
  41897. error('should not call mapCidRange');
  41898. },
  41899. mapBfRange: function (low, high, dstLow) {
  41900. error('should not call mapBfRange');
  41901. },
  41902. mapBfRangeToArray: function (low, high, array) {
  41903. error('should not call mapBfRangeToArray');
  41904. },
  41905. mapOne: function (src, dst) {
  41906. error('should not call mapCidOne');
  41907. },
  41908. lookup: function (code) {
  41909. return isInt(code) && code <= 0xffff ? code : undefined;
  41910. },
  41911. contains: function (code) {
  41912. return isInt(code) && code <= 0xffff;
  41913. },
  41914. forEach: function (callback) {
  41915. for (var i = 0; i <= 0xffff; i++) {
  41916. callback(i, i);
  41917. }
  41918. },
  41919. charCodeOf: function (value) {
  41920. return isInt(value) && value <= 0xffff ? value : -1;
  41921. },
  41922. getMap: function () {
  41923. var map = new Array(0x10000);
  41924. for (var i = 0; i <= 0xffff; i++) {
  41925. map[i] = i;
  41926. }
  41927. return map;
  41928. },
  41929. readCharCode: CMap.prototype.readCharCode,
  41930. get length() {
  41931. return 0x10000;
  41932. },
  41933. get isIdentityCMap() {
  41934. error('should not access .isIdentityCMap');
  41935. }
  41936. };
  41937. return IdentityCMap;
  41938. }();
  41939. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  41940. function hexToInt(a, size) {
  41941. var n = 0;
  41942. for (var i = 0; i <= size; i++) {
  41943. n = n << 8 | a[i];
  41944. }
  41945. return n >>> 0;
  41946. }
  41947. function hexToStr(a, size) {
  41948. if (size === 1) {
  41949. return String.fromCharCode(a[0], a[1]);
  41950. }
  41951. if (size === 3) {
  41952. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  41953. }
  41954. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  41955. }
  41956. function addHex(a, b, size) {
  41957. var c = 0;
  41958. for (var i = size; i >= 0; i--) {
  41959. c += a[i] + b[i];
  41960. a[i] = c & 255;
  41961. c >>= 8;
  41962. }
  41963. }
  41964. function incHex(a, size) {
  41965. var c = 1;
  41966. for (var i = size; i >= 0 && c > 0; i--) {
  41967. c += a[i];
  41968. a[i] = c & 255;
  41969. c >>= 8;
  41970. }
  41971. }
  41972. var MAX_NUM_SIZE = 16;
  41973. var MAX_ENCODED_NUM_SIZE = 19;
  41974. function BinaryCMapStream(data) {
  41975. this.buffer = data;
  41976. this.pos = 0;
  41977. this.end = data.length;
  41978. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  41979. }
  41980. BinaryCMapStream.prototype = {
  41981. readByte: function () {
  41982. if (this.pos >= this.end) {
  41983. return -1;
  41984. }
  41985. return this.buffer[this.pos++];
  41986. },
  41987. readNumber: function () {
  41988. var n = 0;
  41989. var last;
  41990. do {
  41991. var b = this.readByte();
  41992. if (b < 0) {
  41993. error('unexpected EOF in bcmap');
  41994. }
  41995. last = !(b & 0x80);
  41996. n = n << 7 | b & 0x7F;
  41997. } while (!last);
  41998. return n;
  41999. },
  42000. readSigned: function () {
  42001. var n = this.readNumber();
  42002. return n & 1 ? ~(n >>> 1) : n >>> 1;
  42003. },
  42004. readHex: function (num, size) {
  42005. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  42006. this.pos += size + 1;
  42007. },
  42008. readHexNumber: function (num, size) {
  42009. var last;
  42010. var stack = this.tmpBuf, sp = 0;
  42011. do {
  42012. var b = this.readByte();
  42013. if (b < 0) {
  42014. error('unexpected EOF in bcmap');
  42015. }
  42016. last = !(b & 0x80);
  42017. stack[sp++] = b & 0x7F;
  42018. } while (!last);
  42019. var i = size, buffer = 0, bufferSize = 0;
  42020. while (i >= 0) {
  42021. while (bufferSize < 8 && stack.length > 0) {
  42022. buffer = stack[--sp] << bufferSize | buffer;
  42023. bufferSize += 7;
  42024. }
  42025. num[i] = buffer & 255;
  42026. i--;
  42027. buffer >>= 8;
  42028. bufferSize -= 8;
  42029. }
  42030. },
  42031. readHexSigned: function (num, size) {
  42032. this.readHexNumber(num, size);
  42033. var sign = num[size] & 1 ? 255 : 0;
  42034. var c = 0;
  42035. for (var i = 0; i <= size; i++) {
  42036. c = (c & 1) << 8 | num[i];
  42037. num[i] = c >> 1 ^ sign;
  42038. }
  42039. },
  42040. readString: function () {
  42041. var len = this.readNumber();
  42042. var s = '';
  42043. for (var i = 0; i < len; i++) {
  42044. s += String.fromCharCode(this.readNumber());
  42045. }
  42046. return s;
  42047. }
  42048. };
  42049. function processBinaryCMap(data, cMap, extend) {
  42050. return new Promise(function (resolve, reject) {
  42051. var stream = new BinaryCMapStream(data);
  42052. var header = stream.readByte();
  42053. cMap.vertical = !!(header & 1);
  42054. var useCMap = null;
  42055. var start = new Uint8Array(MAX_NUM_SIZE);
  42056. var end = new Uint8Array(MAX_NUM_SIZE);
  42057. var char = new Uint8Array(MAX_NUM_SIZE);
  42058. var charCode = new Uint8Array(MAX_NUM_SIZE);
  42059. var tmp = new Uint8Array(MAX_NUM_SIZE);
  42060. var code;
  42061. var b;
  42062. while ((b = stream.readByte()) >= 0) {
  42063. var type = b >> 5;
  42064. if (type === 7) {
  42065. switch (b & 0x1F) {
  42066. case 0:
  42067. stream.readString();
  42068. break;
  42069. case 1:
  42070. useCMap = stream.readString();
  42071. break;
  42072. }
  42073. continue;
  42074. }
  42075. var sequence = !!(b & 0x10);
  42076. var dataSize = b & 15;
  42077. assert(dataSize + 1 <= MAX_NUM_SIZE);
  42078. var ucs2DataSize = 1;
  42079. var subitemsCount = stream.readNumber();
  42080. var i;
  42081. switch (type) {
  42082. case 0:
  42083. stream.readHex(start, dataSize);
  42084. stream.readHexNumber(end, dataSize);
  42085. addHex(end, start, dataSize);
  42086. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42087. for (i = 1; i < subitemsCount; i++) {
  42088. incHex(end, dataSize);
  42089. stream.readHexNumber(start, dataSize);
  42090. addHex(start, end, dataSize);
  42091. stream.readHexNumber(end, dataSize);
  42092. addHex(end, start, dataSize);
  42093. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42094. }
  42095. break;
  42096. case 1:
  42097. stream.readHex(start, dataSize);
  42098. stream.readHexNumber(end, dataSize);
  42099. addHex(end, start, dataSize);
  42100. code = stream.readNumber();
  42101. for (i = 1; i < subitemsCount; i++) {
  42102. incHex(end, dataSize);
  42103. stream.readHexNumber(start, dataSize);
  42104. addHex(start, end, dataSize);
  42105. stream.readHexNumber(end, dataSize);
  42106. addHex(end, start, dataSize);
  42107. code = stream.readNumber();
  42108. }
  42109. break;
  42110. case 2:
  42111. stream.readHex(char, dataSize);
  42112. code = stream.readNumber();
  42113. cMap.mapOne(hexToInt(char, dataSize), code);
  42114. for (i = 1; i < subitemsCount; i++) {
  42115. incHex(char, dataSize);
  42116. if (!sequence) {
  42117. stream.readHexNumber(tmp, dataSize);
  42118. addHex(char, tmp, dataSize);
  42119. }
  42120. code = stream.readSigned() + (code + 1);
  42121. cMap.mapOne(hexToInt(char, dataSize), code);
  42122. }
  42123. break;
  42124. case 3:
  42125. stream.readHex(start, dataSize);
  42126. stream.readHexNumber(end, dataSize);
  42127. addHex(end, start, dataSize);
  42128. code = stream.readNumber();
  42129. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42130. for (i = 1; i < subitemsCount; i++) {
  42131. incHex(end, dataSize);
  42132. if (!sequence) {
  42133. stream.readHexNumber(start, dataSize);
  42134. addHex(start, end, dataSize);
  42135. } else {
  42136. start.set(end);
  42137. }
  42138. stream.readHexNumber(end, dataSize);
  42139. addHex(end, start, dataSize);
  42140. code = stream.readNumber();
  42141. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42142. }
  42143. break;
  42144. case 4:
  42145. stream.readHex(char, ucs2DataSize);
  42146. stream.readHex(charCode, dataSize);
  42147. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42148. for (i = 1; i < subitemsCount; i++) {
  42149. incHex(char, ucs2DataSize);
  42150. if (!sequence) {
  42151. stream.readHexNumber(tmp, ucs2DataSize);
  42152. addHex(char, tmp, ucs2DataSize);
  42153. }
  42154. incHex(charCode, dataSize);
  42155. stream.readHexSigned(tmp, dataSize);
  42156. addHex(charCode, tmp, dataSize);
  42157. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42158. }
  42159. break;
  42160. case 5:
  42161. stream.readHex(start, ucs2DataSize);
  42162. stream.readHexNumber(end, ucs2DataSize);
  42163. addHex(end, start, ucs2DataSize);
  42164. stream.readHex(charCode, dataSize);
  42165. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42166. for (i = 1; i < subitemsCount; i++) {
  42167. incHex(end, ucs2DataSize);
  42168. if (!sequence) {
  42169. stream.readHexNumber(start, ucs2DataSize);
  42170. addHex(start, end, ucs2DataSize);
  42171. } else {
  42172. start.set(end);
  42173. }
  42174. stream.readHexNumber(end, ucs2DataSize);
  42175. addHex(end, start, ucs2DataSize);
  42176. stream.readHex(charCode, dataSize);
  42177. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42178. }
  42179. break;
  42180. default:
  42181. reject(new Error('processBinaryCMap: Unknown type: ' + type));
  42182. return;
  42183. }
  42184. }
  42185. if (useCMap) {
  42186. resolve(extend(useCMap));
  42187. return;
  42188. }
  42189. resolve(cMap);
  42190. });
  42191. }
  42192. function BinaryCMapReader() {
  42193. }
  42194. BinaryCMapReader.prototype = { process: processBinaryCMap };
  42195. return BinaryCMapReader;
  42196. }();
  42197. var CMapFactory = function CMapFactoryClosure() {
  42198. function strToInt(str) {
  42199. var a = 0;
  42200. for (var i = 0; i < str.length; i++) {
  42201. a = a << 8 | str.charCodeAt(i);
  42202. }
  42203. return a >>> 0;
  42204. }
  42205. function expectString(obj) {
  42206. if (!isString(obj)) {
  42207. error('Malformed CMap: expected string.');
  42208. }
  42209. }
  42210. function expectInt(obj) {
  42211. if (!isInt(obj)) {
  42212. error('Malformed CMap: expected int.');
  42213. }
  42214. }
  42215. function parseBfChar(cMap, lexer) {
  42216. while (true) {
  42217. var obj = lexer.getObj();
  42218. if (isEOF(obj)) {
  42219. break;
  42220. }
  42221. if (isCmd(obj, 'endbfchar')) {
  42222. return;
  42223. }
  42224. expectString(obj);
  42225. var src = strToInt(obj);
  42226. obj = lexer.getObj();
  42227. expectString(obj);
  42228. var dst = obj;
  42229. cMap.mapOne(src, dst);
  42230. }
  42231. }
  42232. function parseBfRange(cMap, lexer) {
  42233. while (true) {
  42234. var obj = lexer.getObj();
  42235. if (isEOF(obj)) {
  42236. break;
  42237. }
  42238. if (isCmd(obj, 'endbfrange')) {
  42239. return;
  42240. }
  42241. expectString(obj);
  42242. var low = strToInt(obj);
  42243. obj = lexer.getObj();
  42244. expectString(obj);
  42245. var high = strToInt(obj);
  42246. obj = lexer.getObj();
  42247. if (isInt(obj) || isString(obj)) {
  42248. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  42249. cMap.mapBfRange(low, high, dstLow);
  42250. } else if (isCmd(obj, '[')) {
  42251. obj = lexer.getObj();
  42252. var array = [];
  42253. while (!isCmd(obj, ']') && !isEOF(obj)) {
  42254. array.push(obj);
  42255. obj = lexer.getObj();
  42256. }
  42257. cMap.mapBfRangeToArray(low, high, array);
  42258. } else {
  42259. break;
  42260. }
  42261. }
  42262. error('Invalid bf range.');
  42263. }
  42264. function parseCidChar(cMap, lexer) {
  42265. while (true) {
  42266. var obj = lexer.getObj();
  42267. if (isEOF(obj)) {
  42268. break;
  42269. }
  42270. if (isCmd(obj, 'endcidchar')) {
  42271. return;
  42272. }
  42273. expectString(obj);
  42274. var src = strToInt(obj);
  42275. obj = lexer.getObj();
  42276. expectInt(obj);
  42277. var dst = obj;
  42278. cMap.mapOne(src, dst);
  42279. }
  42280. }
  42281. function parseCidRange(cMap, lexer) {
  42282. while (true) {
  42283. var obj = lexer.getObj();
  42284. if (isEOF(obj)) {
  42285. break;
  42286. }
  42287. if (isCmd(obj, 'endcidrange')) {
  42288. return;
  42289. }
  42290. expectString(obj);
  42291. var low = strToInt(obj);
  42292. obj = lexer.getObj();
  42293. expectString(obj);
  42294. var high = strToInt(obj);
  42295. obj = lexer.getObj();
  42296. expectInt(obj);
  42297. var dstLow = obj;
  42298. cMap.mapCidRange(low, high, dstLow);
  42299. }
  42300. }
  42301. function parseCodespaceRange(cMap, lexer) {
  42302. while (true) {
  42303. var obj = lexer.getObj();
  42304. if (isEOF(obj)) {
  42305. break;
  42306. }
  42307. if (isCmd(obj, 'endcodespacerange')) {
  42308. return;
  42309. }
  42310. if (!isString(obj)) {
  42311. break;
  42312. }
  42313. var low = strToInt(obj);
  42314. obj = lexer.getObj();
  42315. if (!isString(obj)) {
  42316. break;
  42317. }
  42318. var high = strToInt(obj);
  42319. cMap.addCodespaceRange(obj.length, low, high);
  42320. }
  42321. error('Invalid codespace range.');
  42322. }
  42323. function parseWMode(cMap, lexer) {
  42324. var obj = lexer.getObj();
  42325. if (isInt(obj)) {
  42326. cMap.vertical = !!obj;
  42327. }
  42328. }
  42329. function parseCMapName(cMap, lexer) {
  42330. var obj = lexer.getObj();
  42331. if (isName(obj) && isString(obj.name)) {
  42332. cMap.name = obj.name;
  42333. }
  42334. }
  42335. function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  42336. var previous;
  42337. var embededUseCMap;
  42338. objLoop:
  42339. while (true) {
  42340. try {
  42341. var obj = lexer.getObj();
  42342. if (isEOF(obj)) {
  42343. break;
  42344. } else if (isName(obj)) {
  42345. if (obj.name === 'WMode') {
  42346. parseWMode(cMap, lexer);
  42347. } else if (obj.name === 'CMapName') {
  42348. parseCMapName(cMap, lexer);
  42349. }
  42350. previous = obj;
  42351. } else if (isCmd(obj)) {
  42352. switch (obj.cmd) {
  42353. case 'endcmap':
  42354. break objLoop;
  42355. case 'usecmap':
  42356. if (isName(previous)) {
  42357. embededUseCMap = previous.name;
  42358. }
  42359. break;
  42360. case 'begincodespacerange':
  42361. parseCodespaceRange(cMap, lexer);
  42362. break;
  42363. case 'beginbfchar':
  42364. parseBfChar(cMap, lexer);
  42365. break;
  42366. case 'begincidchar':
  42367. parseCidChar(cMap, lexer);
  42368. break;
  42369. case 'beginbfrange':
  42370. parseBfRange(cMap, lexer);
  42371. break;
  42372. case 'begincidrange':
  42373. parseCidRange(cMap, lexer);
  42374. break;
  42375. }
  42376. }
  42377. } catch (ex) {
  42378. if (ex instanceof MissingDataException) {
  42379. throw ex;
  42380. }
  42381. warn('Invalid cMap data: ' + ex);
  42382. continue;
  42383. }
  42384. }
  42385. if (!useCMap && embededUseCMap) {
  42386. useCMap = embededUseCMap;
  42387. }
  42388. if (useCMap) {
  42389. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  42390. }
  42391. return Promise.resolve(cMap);
  42392. }
  42393. function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  42394. return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
  42395. cMap.useCMap = newCMap;
  42396. if (cMap.numCodespaceRanges === 0) {
  42397. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  42398. for (var i = 0; i < useCodespaceRanges.length; i++) {
  42399. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  42400. }
  42401. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  42402. }
  42403. cMap.useCMap.forEach(function (key, value) {
  42404. if (!cMap.contains(key)) {
  42405. cMap.mapOne(key, cMap.useCMap.lookup(key));
  42406. }
  42407. });
  42408. return cMap;
  42409. });
  42410. }
  42411. function createBuiltInCMap(name, fetchBuiltInCMap) {
  42412. if (name === 'Identity-H') {
  42413. return Promise.resolve(new IdentityCMap(false, 2));
  42414. } else if (name === 'Identity-V') {
  42415. return Promise.resolve(new IdentityCMap(true, 2));
  42416. }
  42417. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  42418. return Promise.reject(new Error('Unknown cMap name: ' + name));
  42419. }
  42420. assert(fetchBuiltInCMap, 'Built-in CMap parameters are not provided.');
  42421. return fetchBuiltInCMap(name).then(function (data) {
  42422. var cMapData = data.cMapData, compressionType = data.compressionType;
  42423. var cMap = new CMap(true);
  42424. if (compressionType === CMapCompressionType.BINARY) {
  42425. return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
  42426. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  42427. });
  42428. }
  42429. assert(compressionType === CMapCompressionType.NONE, 'TODO: Only BINARY/NONE CMap compression is currently supported.');
  42430. var lexer = new Lexer(new Stream(cMapData));
  42431. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  42432. });
  42433. }
  42434. return {
  42435. create: function (params) {
  42436. var encoding = params.encoding;
  42437. var fetchBuiltInCMap = params.fetchBuiltInCMap;
  42438. var useCMap = params.useCMap;
  42439. if (isName(encoding)) {
  42440. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  42441. } else if (isStream(encoding)) {
  42442. var cMap = new CMap();
  42443. var lexer = new Lexer(encoding);
  42444. return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
  42445. if (parsedCMap.isIdentityCMap) {
  42446. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  42447. }
  42448. return parsedCMap;
  42449. });
  42450. }
  42451. return Promise.reject(new Error('Encoding required.'));
  42452. }
  42453. };
  42454. }();
  42455. exports.CMap = CMap;
  42456. exports.CMapFactory = CMapFactory;
  42457. exports.IdentityCMap = IdentityCMap;
  42458. /***/ }),
  42459. /* 31 */
  42460. /***/ (function(module, exports, __w_pdfjs_require__) {
  42461. "use strict";
  42462. var sharedUtil = __w_pdfjs_require__(0);
  42463. var corePrimitives = __w_pdfjs_require__(1);
  42464. var coreStream = __w_pdfjs_require__(2);
  42465. var coreObj = __w_pdfjs_require__(19);
  42466. var coreParser = __w_pdfjs_require__(6);
  42467. var coreCrypto = __w_pdfjs_require__(16);
  42468. var coreEvaluator = __w_pdfjs_require__(17);
  42469. var coreAnnotation = __w_pdfjs_require__(27);
  42470. var MissingDataException = sharedUtil.MissingDataException;
  42471. var Util = sharedUtil.Util;
  42472. var assert = sharedUtil.assert;
  42473. var error = sharedUtil.error;
  42474. var info = sharedUtil.info;
  42475. var isArray = sharedUtil.isArray;
  42476. var isArrayBuffer = sharedUtil.isArrayBuffer;
  42477. var isNum = sharedUtil.isNum;
  42478. var isString = sharedUtil.isString;
  42479. var shadow = sharedUtil.shadow;
  42480. var stringToBytes = sharedUtil.stringToBytes;
  42481. var stringToPDFString = sharedUtil.stringToPDFString;
  42482. var warn = sharedUtil.warn;
  42483. var isSpace = sharedUtil.isSpace;
  42484. var Dict = corePrimitives.Dict;
  42485. var isDict = corePrimitives.isDict;
  42486. var isName = corePrimitives.isName;
  42487. var isStream = corePrimitives.isStream;
  42488. var NullStream = coreStream.NullStream;
  42489. var Stream = coreStream.Stream;
  42490. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  42491. var Catalog = coreObj.Catalog;
  42492. var ObjectLoader = coreObj.ObjectLoader;
  42493. var XRef = coreObj.XRef;
  42494. var Linearization = coreParser.Linearization;
  42495. var calculateMD5 = coreCrypto.calculateMD5;
  42496. var OperatorList = coreEvaluator.OperatorList;
  42497. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  42498. var Annotation = coreAnnotation.Annotation;
  42499. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  42500. var Page = function PageClosure() {
  42501. var DEFAULT_USER_UNIT = 1.0;
  42502. var LETTER_SIZE_MEDIABOX = [
  42503. 0,
  42504. 0,
  42505. 612,
  42506. 792
  42507. ];
  42508. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache, builtInCMapCache) {
  42509. this.pdfManager = pdfManager;
  42510. this.pageIndex = pageIndex;
  42511. this.pageDict = pageDict;
  42512. this.xref = xref;
  42513. this.ref = ref;
  42514. this.fontCache = fontCache;
  42515. this.builtInCMapCache = builtInCMapCache;
  42516. this.evaluatorOptions = pdfManager.evaluatorOptions;
  42517. this.resourcesPromise = null;
  42518. var uniquePrefix = 'p' + this.pageIndex + '_';
  42519. var idCounters = { obj: 0 };
  42520. this.idFactory = {
  42521. createObjId: function () {
  42522. return uniquePrefix + ++idCounters.obj;
  42523. }
  42524. };
  42525. }
  42526. Page.prototype = {
  42527. getPageProp: function Page_getPageProp(key) {
  42528. return this.pageDict.get(key);
  42529. },
  42530. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  42531. var dict = this.pageDict, valueArray = null, loopCount = 0;
  42532. var MAX_LOOP_COUNT = 100;
  42533. getArray = getArray || false;
  42534. while (dict) {
  42535. var value = getArray ? dict.getArray(key) : dict.get(key);
  42536. if (value) {
  42537. if (!valueArray) {
  42538. valueArray = [];
  42539. }
  42540. valueArray.push(value);
  42541. }
  42542. if (++loopCount > MAX_LOOP_COUNT) {
  42543. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  42544. break;
  42545. }
  42546. dict = dict.get('Parent');
  42547. }
  42548. if (!valueArray) {
  42549. return Dict.empty;
  42550. }
  42551. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  42552. return valueArray[0];
  42553. }
  42554. return Dict.merge(this.xref, valueArray);
  42555. },
  42556. get content() {
  42557. return this.getPageProp('Contents');
  42558. },
  42559. get resources() {
  42560. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  42561. },
  42562. get mediaBox() {
  42563. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  42564. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  42565. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  42566. }
  42567. return shadow(this, 'mediaBox', mediaBox);
  42568. },
  42569. get cropBox() {
  42570. var cropBox = this.getInheritedPageProp('CropBox', true);
  42571. if (!isArray(cropBox) || cropBox.length !== 4) {
  42572. return shadow(this, 'cropBox', this.mediaBox);
  42573. }
  42574. return shadow(this, 'cropBox', cropBox);
  42575. },
  42576. get userUnit() {
  42577. var obj = this.getPageProp('UserUnit');
  42578. if (!isNum(obj) || obj <= 0) {
  42579. obj = DEFAULT_USER_UNIT;
  42580. }
  42581. return shadow(this, 'userUnit', obj);
  42582. },
  42583. get view() {
  42584. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  42585. if (mediaBox === cropBox) {
  42586. return shadow(this, 'view', mediaBox);
  42587. }
  42588. var intersection = Util.intersect(cropBox, mediaBox);
  42589. return shadow(this, 'view', intersection || mediaBox);
  42590. },
  42591. get rotate() {
  42592. var rotate = this.getInheritedPageProp('Rotate') || 0;
  42593. if (rotate % 90 !== 0) {
  42594. rotate = 0;
  42595. } else if (rotate >= 360) {
  42596. rotate = rotate % 360;
  42597. } else if (rotate < 0) {
  42598. rotate = (rotate % 360 + 360) % 360;
  42599. }
  42600. return shadow(this, 'rotate', rotate);
  42601. },
  42602. getContentStream: function Page_getContentStream() {
  42603. var content = this.content;
  42604. var stream;
  42605. if (isArray(content)) {
  42606. var xref = this.xref;
  42607. var i, n = content.length;
  42608. var streams = [];
  42609. for (i = 0; i < n; ++i) {
  42610. streams.push(xref.fetchIfRef(content[i]));
  42611. }
  42612. stream = new StreamsSequenceStream(streams);
  42613. } else if (isStream(content)) {
  42614. stream = content;
  42615. } else {
  42616. stream = new NullStream();
  42617. }
  42618. return stream;
  42619. },
  42620. loadResources: function Page_loadResources(keys) {
  42621. if (!this.resourcesPromise) {
  42622. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  42623. }
  42624. return this.resourcesPromise.then(function resourceSuccess() {
  42625. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  42626. return objectLoader.load();
  42627. }.bind(this));
  42628. },
  42629. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  42630. var self = this;
  42631. var pdfManager = this.pdfManager;
  42632. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  42633. var resourcesPromise = this.loadResources([
  42634. 'ExtGState',
  42635. 'ColorSpace',
  42636. 'Pattern',
  42637. 'Shading',
  42638. 'XObject',
  42639. 'Font'
  42640. ]);
  42641. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.builtInCMapCache, this.evaluatorOptions);
  42642. var dataPromises = Promise.all([
  42643. contentStreamPromise,
  42644. resourcesPromise
  42645. ]);
  42646. var pageListPromise = dataPromises.then(function (data) {
  42647. var contentStream = data[0];
  42648. var opList = new OperatorList(intent, handler, self.pageIndex);
  42649. handler.send('StartRenderPage', {
  42650. transparency: partialEvaluator.hasBlendModes(self.resources),
  42651. pageIndex: self.pageIndex,
  42652. intent: intent
  42653. });
  42654. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  42655. return opList;
  42656. });
  42657. });
  42658. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  42659. return Promise.all([
  42660. pageListPromise,
  42661. annotationsPromise
  42662. ]).then(function (datas) {
  42663. var pageOpList = datas[0];
  42664. var annotations = datas[1];
  42665. if (annotations.length === 0) {
  42666. pageOpList.flush(true);
  42667. return pageOpList;
  42668. }
  42669. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  42670. return annotationsReadyPromise.then(function () {
  42671. pageOpList.flush(true);
  42672. return pageOpList;
  42673. });
  42674. });
  42675. },
  42676. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  42677. var handler = {
  42678. on: function nullHandlerOn() {
  42679. },
  42680. send: function nullHandlerSend() {
  42681. }
  42682. };
  42683. var self = this;
  42684. var pdfManager = this.pdfManager;
  42685. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  42686. var resourcesPromise = this.loadResources([
  42687. 'ExtGState',
  42688. 'XObject',
  42689. 'Font'
  42690. ]);
  42691. var dataPromises = Promise.all([
  42692. contentStreamPromise,
  42693. resourcesPromise
  42694. ]);
  42695. return dataPromises.then(function (data) {
  42696. var contentStream = data[0];
  42697. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.builtInCMapCache, self.evaluatorOptions);
  42698. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  42699. });
  42700. },
  42701. getAnnotationsData: function Page_getAnnotationsData(intent) {
  42702. var annotations = this.annotations;
  42703. var annotationsData = [];
  42704. for (var i = 0, n = annotations.length; i < n; ++i) {
  42705. if (intent) {
  42706. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  42707. continue;
  42708. }
  42709. }
  42710. annotationsData.push(annotations[i].data);
  42711. }
  42712. return annotationsData;
  42713. },
  42714. get annotations() {
  42715. var annotations = [];
  42716. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  42717. var annotationFactory = new AnnotationFactory();
  42718. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  42719. var annotationRef = annotationRefs[i];
  42720. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  42721. if (annotation) {
  42722. annotations.push(annotation);
  42723. }
  42724. }
  42725. return shadow(this, 'annotations', annotations);
  42726. }
  42727. };
  42728. return Page;
  42729. }();
  42730. var PDFDocument = function PDFDocumentClosure() {
  42731. var FINGERPRINT_FIRST_BYTES = 1024;
  42732. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  42733. function PDFDocument(pdfManager, arg) {
  42734. var stream;
  42735. if (isStream(arg)) {
  42736. stream = arg;
  42737. } else if (isArrayBuffer(arg)) {
  42738. stream = new Stream(arg);
  42739. } else {
  42740. error('PDFDocument: Unknown argument type');
  42741. }
  42742. assert(stream.length > 0, 'stream must have data');
  42743. this.pdfManager = pdfManager;
  42744. this.stream = stream;
  42745. this.xref = new XRef(stream, pdfManager);
  42746. }
  42747. function find(stream, needle, limit, backwards) {
  42748. var pos = stream.pos;
  42749. var end = stream.end;
  42750. var strBuf = [];
  42751. if (pos + limit > end) {
  42752. limit = end - pos;
  42753. }
  42754. for (var n = 0; n < limit; ++n) {
  42755. strBuf.push(String.fromCharCode(stream.getByte()));
  42756. }
  42757. var str = strBuf.join('');
  42758. stream.pos = pos;
  42759. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  42760. if (index === -1) {
  42761. return false;
  42762. }
  42763. stream.pos += index;
  42764. return true;
  42765. }
  42766. var DocumentInfoValidators = {
  42767. get entries() {
  42768. return shadow(this, 'entries', {
  42769. Title: isString,
  42770. Author: isString,
  42771. Subject: isString,
  42772. Keywords: isString,
  42773. Creator: isString,
  42774. Producer: isString,
  42775. CreationDate: isString,
  42776. ModDate: isString,
  42777. Trapped: isName
  42778. });
  42779. }
  42780. };
  42781. PDFDocument.prototype = {
  42782. parse: function PDFDocument_parse(recoveryMode) {
  42783. this.setup(recoveryMode);
  42784. var version = this.catalog.catDict.get('Version');
  42785. if (isName(version)) {
  42786. this.pdfFormatVersion = version.name;
  42787. }
  42788. try {
  42789. this.acroForm = this.catalog.catDict.get('AcroForm');
  42790. if (this.acroForm) {
  42791. this.xfa = this.acroForm.get('XFA');
  42792. var fields = this.acroForm.get('Fields');
  42793. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  42794. this.acroForm = null;
  42795. }
  42796. }
  42797. } catch (ex) {
  42798. info('Something wrong with AcroForm entry');
  42799. this.acroForm = null;
  42800. }
  42801. },
  42802. get linearization() {
  42803. var linearization = null;
  42804. if (this.stream.length) {
  42805. try {
  42806. linearization = Linearization.create(this.stream);
  42807. } catch (err) {
  42808. if (err instanceof MissingDataException) {
  42809. throw err;
  42810. }
  42811. info(err);
  42812. }
  42813. }
  42814. return shadow(this, 'linearization', linearization);
  42815. },
  42816. get startXRef() {
  42817. var stream = this.stream;
  42818. var startXRef = 0;
  42819. var linearization = this.linearization;
  42820. if (linearization) {
  42821. stream.reset();
  42822. if (find(stream, 'endobj', 1024)) {
  42823. startXRef = stream.pos + 6;
  42824. }
  42825. } else {
  42826. var step = 1024;
  42827. var found = false, pos = stream.end;
  42828. while (!found && pos > 0) {
  42829. pos -= step - 'startxref'.length;
  42830. if (pos < 0) {
  42831. pos = 0;
  42832. }
  42833. stream.pos = pos;
  42834. found = find(stream, 'startxref', step, true);
  42835. }
  42836. if (found) {
  42837. stream.skip(9);
  42838. var ch;
  42839. do {
  42840. ch = stream.getByte();
  42841. } while (isSpace(ch));
  42842. var str = '';
  42843. while (ch >= 0x20 && ch <= 0x39) {
  42844. str += String.fromCharCode(ch);
  42845. ch = stream.getByte();
  42846. }
  42847. startXRef = parseInt(str, 10);
  42848. if (isNaN(startXRef)) {
  42849. startXRef = 0;
  42850. }
  42851. }
  42852. }
  42853. return shadow(this, 'startXRef', startXRef);
  42854. },
  42855. get mainXRefEntriesOffset() {
  42856. var mainXRefEntriesOffset = 0;
  42857. var linearization = this.linearization;
  42858. if (linearization) {
  42859. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  42860. }
  42861. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  42862. },
  42863. checkHeader: function PDFDocument_checkHeader() {
  42864. var stream = this.stream;
  42865. stream.reset();
  42866. if (find(stream, '%PDF-', 1024)) {
  42867. stream.moveStart();
  42868. var MAX_VERSION_LENGTH = 12;
  42869. var version = '', ch;
  42870. while ((ch = stream.getByte()) > 0x20) {
  42871. if (version.length >= MAX_VERSION_LENGTH) {
  42872. break;
  42873. }
  42874. version += String.fromCharCode(ch);
  42875. }
  42876. if (!this.pdfFormatVersion) {
  42877. this.pdfFormatVersion = version.substring(5);
  42878. }
  42879. return;
  42880. }
  42881. },
  42882. parseStartXRef: function PDFDocument_parseStartXRef() {
  42883. var startXRef = this.startXRef;
  42884. this.xref.setStartXRef(startXRef);
  42885. },
  42886. setup: function PDFDocument_setup(recoveryMode) {
  42887. this.xref.parse(recoveryMode);
  42888. var self = this;
  42889. var pageFactory = {
  42890. createPage: function (pageIndex, dict, ref, fontCache, builtInCMapCache) {
  42891. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache, builtInCMapCache);
  42892. }
  42893. };
  42894. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  42895. },
  42896. get numPages() {
  42897. var linearization = this.linearization;
  42898. var num = linearization ? linearization.numPages : this.catalog.numPages;
  42899. return shadow(this, 'numPages', num);
  42900. },
  42901. get documentInfo() {
  42902. var docInfo = {
  42903. PDFFormatVersion: this.pdfFormatVersion,
  42904. IsAcroFormPresent: !!this.acroForm,
  42905. IsXFAPresent: !!this.xfa
  42906. };
  42907. var infoDict;
  42908. try {
  42909. infoDict = this.xref.trailer.get('Info');
  42910. } catch (err) {
  42911. info('The document information dictionary is invalid.');
  42912. }
  42913. if (infoDict) {
  42914. var validEntries = DocumentInfoValidators.entries;
  42915. for (var key in validEntries) {
  42916. if (infoDict.has(key)) {
  42917. var value = infoDict.get(key);
  42918. if (validEntries[key](value)) {
  42919. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  42920. } else {
  42921. info('Bad value in document info for "' + key + '"');
  42922. }
  42923. }
  42924. }
  42925. }
  42926. return shadow(this, 'documentInfo', docInfo);
  42927. },
  42928. get fingerprint() {
  42929. var xref = this.xref, hash, fileID = '';
  42930. var idArray = xref.trailer.get('ID');
  42931. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  42932. hash = stringToBytes(idArray[0]);
  42933. } else {
  42934. if (this.stream.ensureRange) {
  42935. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  42936. }
  42937. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  42938. }
  42939. for (var i = 0, n = hash.length; i < n; i++) {
  42940. var hex = hash[i].toString(16);
  42941. fileID += hex.length === 1 ? '0' + hex : hex;
  42942. }
  42943. return shadow(this, 'fingerprint', fileID);
  42944. },
  42945. getPage: function PDFDocument_getPage(pageIndex) {
  42946. return this.catalog.getPage(pageIndex);
  42947. },
  42948. cleanup: function PDFDocument_cleanup() {
  42949. return this.catalog.cleanup();
  42950. }
  42951. };
  42952. return PDFDocument;
  42953. }();
  42954. exports.Page = Page;
  42955. exports.PDFDocument = PDFDocument;
  42956. /***/ }),
  42957. /* 32 */
  42958. /***/ (function(module, exports, __w_pdfjs_require__) {
  42959. "use strict";
  42960. var sharedUtil = __w_pdfjs_require__(0);
  42961. var coreStream = __w_pdfjs_require__(2);
  42962. var coreGlyphList = __w_pdfjs_require__(8);
  42963. var coreEncodings = __w_pdfjs_require__(5);
  42964. var coreCFFParser = __w_pdfjs_require__(14);
  42965. var Util = sharedUtil.Util;
  42966. var bytesToString = sharedUtil.bytesToString;
  42967. var error = sharedUtil.error;
  42968. var Stream = coreStream.Stream;
  42969. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42970. var StandardEncoding = coreEncodings.StandardEncoding;
  42971. var CFFParser = coreCFFParser.CFFParser;
  42972. var FontRendererFactory = function FontRendererFactoryClosure() {
  42973. function getLong(data, offset) {
  42974. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42975. }
  42976. function getUshort(data, offset) {
  42977. return data[offset] << 8 | data[offset + 1];
  42978. }
  42979. function parseCmap(data, start, end) {
  42980. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  42981. var format = getUshort(data, start + offset);
  42982. var ranges, p, i;
  42983. if (format === 4) {
  42984. getUshort(data, start + offset + 2);
  42985. var segCount = getUshort(data, start + offset + 6) >> 1;
  42986. p = start + offset + 14;
  42987. ranges = [];
  42988. for (i = 0; i < segCount; i++, p += 2) {
  42989. ranges[i] = { end: getUshort(data, p) };
  42990. }
  42991. p += 2;
  42992. for (i = 0; i < segCount; i++, p += 2) {
  42993. ranges[i].start = getUshort(data, p);
  42994. }
  42995. for (i = 0; i < segCount; i++, p += 2) {
  42996. ranges[i].idDelta = getUshort(data, p);
  42997. }
  42998. for (i = 0; i < segCount; i++, p += 2) {
  42999. var idOffset = getUshort(data, p);
  43000. if (idOffset === 0) {
  43001. continue;
  43002. }
  43003. ranges[i].ids = [];
  43004. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  43005. ranges[i].ids[j] = getUshort(data, p + idOffset);
  43006. idOffset += 2;
  43007. }
  43008. }
  43009. return ranges;
  43010. } else if (format === 12) {
  43011. getLong(data, start + offset + 4);
  43012. var groups = getLong(data, start + offset + 12);
  43013. p = start + offset + 16;
  43014. ranges = [];
  43015. for (i = 0; i < groups; i++) {
  43016. ranges.push({
  43017. start: getLong(data, p),
  43018. end: getLong(data, p + 4),
  43019. idDelta: getLong(data, p + 8) - getLong(data, p)
  43020. });
  43021. p += 12;
  43022. }
  43023. return ranges;
  43024. }
  43025. error('not supported cmap: ' + format);
  43026. }
  43027. function parseCff(data, start, end, seacAnalysisEnabled) {
  43028. var properties = {};
  43029. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  43030. var cff = parser.parse();
  43031. return {
  43032. glyphs: cff.charStrings.objects,
  43033. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  43034. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  43035. };
  43036. }
  43037. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  43038. var itemSize, itemDecode;
  43039. if (isGlyphLocationsLong) {
  43040. itemSize = 4;
  43041. itemDecode = function fontItemDecodeLong(data, offset) {
  43042. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  43043. };
  43044. } else {
  43045. itemSize = 2;
  43046. itemDecode = function fontItemDecode(data, offset) {
  43047. return data[offset] << 9 | data[offset + 1] << 1;
  43048. };
  43049. }
  43050. var glyphs = [];
  43051. var startOffset = itemDecode(loca, 0);
  43052. for (var j = itemSize; j < loca.length; j += itemSize) {
  43053. var endOffset = itemDecode(loca, j);
  43054. glyphs.push(glyf.subarray(startOffset, endOffset));
  43055. startOffset = endOffset;
  43056. }
  43057. return glyphs;
  43058. }
  43059. function lookupCmap(ranges, unicode) {
  43060. var code = unicode.charCodeAt(0), gid = 0;
  43061. var l = 0, r = ranges.length - 1;
  43062. while (l < r) {
  43063. var c = l + r + 1 >> 1;
  43064. if (code < ranges[c].start) {
  43065. r = c - 1;
  43066. } else {
  43067. l = c;
  43068. }
  43069. }
  43070. if (ranges[l].start <= code && code <= ranges[l].end) {
  43071. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  43072. }
  43073. return {
  43074. charCode: code,
  43075. glyphId: gid
  43076. };
  43077. }
  43078. function compileGlyf(code, cmds, font) {
  43079. function moveTo(x, y) {
  43080. cmds.push({
  43081. cmd: 'moveTo',
  43082. args: [
  43083. x,
  43084. y
  43085. ]
  43086. });
  43087. }
  43088. function lineTo(x, y) {
  43089. cmds.push({
  43090. cmd: 'lineTo',
  43091. args: [
  43092. x,
  43093. y
  43094. ]
  43095. });
  43096. }
  43097. function quadraticCurveTo(xa, ya, x, y) {
  43098. cmds.push({
  43099. cmd: 'quadraticCurveTo',
  43100. args: [
  43101. xa,
  43102. ya,
  43103. x,
  43104. y
  43105. ]
  43106. });
  43107. }
  43108. var i = 0;
  43109. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43110. var flags;
  43111. var x = 0, y = 0;
  43112. i += 10;
  43113. if (numberOfContours < 0) {
  43114. do {
  43115. flags = code[i] << 8 | code[i + 1];
  43116. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  43117. i += 4;
  43118. var arg1, arg2;
  43119. if (flags & 0x01) {
  43120. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43121. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  43122. i += 4;
  43123. } else {
  43124. arg1 = code[i++];
  43125. arg2 = code[i++];
  43126. }
  43127. if (flags & 0x02) {
  43128. x = arg1;
  43129. y = arg2;
  43130. } else {
  43131. x = 0;
  43132. y = 0;
  43133. }
  43134. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  43135. if (flags & 0x08) {
  43136. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43137. i += 2;
  43138. } else if (flags & 0x40) {
  43139. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43140. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43141. i += 4;
  43142. } else if (flags & 0x80) {
  43143. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43144. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43145. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  43146. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  43147. i += 8;
  43148. }
  43149. var subglyph = font.glyphs[glyphIndex];
  43150. if (subglyph) {
  43151. cmds.push({ cmd: 'save' });
  43152. cmds.push({
  43153. cmd: 'transform',
  43154. args: [
  43155. scaleX,
  43156. scale01,
  43157. scale10,
  43158. scaleY,
  43159. x,
  43160. y
  43161. ]
  43162. });
  43163. compileGlyf(subglyph, cmds, font);
  43164. cmds.push({ cmd: 'restore' });
  43165. }
  43166. } while (flags & 0x20);
  43167. } else {
  43168. var endPtsOfContours = [];
  43169. var j, jj;
  43170. for (j = 0; j < numberOfContours; j++) {
  43171. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  43172. i += 2;
  43173. }
  43174. var instructionLength = code[i] << 8 | code[i + 1];
  43175. i += 2 + instructionLength;
  43176. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  43177. var points = [];
  43178. while (points.length < numberOfPoints) {
  43179. flags = code[i++];
  43180. var repeat = 1;
  43181. if (flags & 0x08) {
  43182. repeat += code[i++];
  43183. }
  43184. while (repeat-- > 0) {
  43185. points.push({ flags: flags });
  43186. }
  43187. }
  43188. for (j = 0; j < numberOfPoints; j++) {
  43189. switch (points[j].flags & 0x12) {
  43190. case 0x00:
  43191. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43192. i += 2;
  43193. break;
  43194. case 0x02:
  43195. x -= code[i++];
  43196. break;
  43197. case 0x12:
  43198. x += code[i++];
  43199. break;
  43200. }
  43201. points[j].x = x;
  43202. }
  43203. for (j = 0; j < numberOfPoints; j++) {
  43204. switch (points[j].flags & 0x24) {
  43205. case 0x00:
  43206. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43207. i += 2;
  43208. break;
  43209. case 0x04:
  43210. y -= code[i++];
  43211. break;
  43212. case 0x24:
  43213. y += code[i++];
  43214. break;
  43215. }
  43216. points[j].y = y;
  43217. }
  43218. var startPoint = 0;
  43219. for (i = 0; i < numberOfContours; i++) {
  43220. var endPoint = endPtsOfContours[i];
  43221. var contour = points.slice(startPoint, endPoint + 1);
  43222. if (contour[0].flags & 1) {
  43223. contour.push(contour[0]);
  43224. } else if (contour[contour.length - 1].flags & 1) {
  43225. contour.unshift(contour[contour.length - 1]);
  43226. } else {
  43227. var p = {
  43228. flags: 1,
  43229. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  43230. y: (contour[0].y + contour[contour.length - 1].y) / 2
  43231. };
  43232. contour.unshift(p);
  43233. contour.push(p);
  43234. }
  43235. moveTo(contour[0].x, contour[0].y);
  43236. for (j = 1, jj = contour.length; j < jj; j++) {
  43237. if (contour[j].flags & 1) {
  43238. lineTo(contour[j].x, contour[j].y);
  43239. } else if (contour[j + 1].flags & 1) {
  43240. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  43241. j++;
  43242. } else {
  43243. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  43244. }
  43245. }
  43246. startPoint = endPoint + 1;
  43247. }
  43248. }
  43249. }
  43250. function compileCharString(code, cmds, font) {
  43251. var stack = [];
  43252. var x = 0, y = 0;
  43253. var stems = 0;
  43254. function moveTo(x, y) {
  43255. cmds.push({
  43256. cmd: 'moveTo',
  43257. args: [
  43258. x,
  43259. y
  43260. ]
  43261. });
  43262. }
  43263. function lineTo(x, y) {
  43264. cmds.push({
  43265. cmd: 'lineTo',
  43266. args: [
  43267. x,
  43268. y
  43269. ]
  43270. });
  43271. }
  43272. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  43273. cmds.push({
  43274. cmd: 'bezierCurveTo',
  43275. args: [
  43276. x1,
  43277. y1,
  43278. x2,
  43279. y2,
  43280. x,
  43281. y
  43282. ]
  43283. });
  43284. }
  43285. function parse(code) {
  43286. var i = 0;
  43287. while (i < code.length) {
  43288. var stackClean = false;
  43289. var v = code[i++];
  43290. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  43291. switch (v) {
  43292. case 1:
  43293. stems += stack.length >> 1;
  43294. stackClean = true;
  43295. break;
  43296. case 3:
  43297. stems += stack.length >> 1;
  43298. stackClean = true;
  43299. break;
  43300. case 4:
  43301. y += stack.pop();
  43302. moveTo(x, y);
  43303. stackClean = true;
  43304. break;
  43305. case 5:
  43306. while (stack.length > 0) {
  43307. x += stack.shift();
  43308. y += stack.shift();
  43309. lineTo(x, y);
  43310. }
  43311. break;
  43312. case 6:
  43313. while (stack.length > 0) {
  43314. x += stack.shift();
  43315. lineTo(x, y);
  43316. if (stack.length === 0) {
  43317. break;
  43318. }
  43319. y += stack.shift();
  43320. lineTo(x, y);
  43321. }
  43322. break;
  43323. case 7:
  43324. while (stack.length > 0) {
  43325. y += stack.shift();
  43326. lineTo(x, y);
  43327. if (stack.length === 0) {
  43328. break;
  43329. }
  43330. x += stack.shift();
  43331. lineTo(x, y);
  43332. }
  43333. break;
  43334. case 8:
  43335. while (stack.length > 0) {
  43336. xa = x + stack.shift();
  43337. ya = y + stack.shift();
  43338. xb = xa + stack.shift();
  43339. yb = ya + stack.shift();
  43340. x = xb + stack.shift();
  43341. y = yb + stack.shift();
  43342. bezierCurveTo(xa, ya, xb, yb, x, y);
  43343. }
  43344. break;
  43345. case 10:
  43346. n = stack.pop() + font.subrsBias;
  43347. subrCode = font.subrs[n];
  43348. if (subrCode) {
  43349. parse(subrCode);
  43350. }
  43351. break;
  43352. case 11:
  43353. return;
  43354. case 12:
  43355. v = code[i++];
  43356. switch (v) {
  43357. case 34:
  43358. xa = x + stack.shift();
  43359. xb = xa + stack.shift();
  43360. y1 = y + stack.shift();
  43361. x = xb + stack.shift();
  43362. bezierCurveTo(xa, y, xb, y1, x, y1);
  43363. xa = x + stack.shift();
  43364. xb = xa + stack.shift();
  43365. x = xb + stack.shift();
  43366. bezierCurveTo(xa, y1, xb, y, x, y);
  43367. break;
  43368. case 35:
  43369. xa = x + stack.shift();
  43370. ya = y + stack.shift();
  43371. xb = xa + stack.shift();
  43372. yb = ya + stack.shift();
  43373. x = xb + stack.shift();
  43374. y = yb + stack.shift();
  43375. bezierCurveTo(xa, ya, xb, yb, x, y);
  43376. xa = x + stack.shift();
  43377. ya = y + stack.shift();
  43378. xb = xa + stack.shift();
  43379. yb = ya + stack.shift();
  43380. x = xb + stack.shift();
  43381. y = yb + stack.shift();
  43382. bezierCurveTo(xa, ya, xb, yb, x, y);
  43383. stack.pop();
  43384. break;
  43385. case 36:
  43386. xa = x + stack.shift();
  43387. y1 = y + stack.shift();
  43388. xb = xa + stack.shift();
  43389. y2 = y1 + stack.shift();
  43390. x = xb + stack.shift();
  43391. bezierCurveTo(xa, y1, xb, y2, x, y2);
  43392. xa = x + stack.shift();
  43393. xb = xa + stack.shift();
  43394. y3 = y2 + stack.shift();
  43395. x = xb + stack.shift();
  43396. bezierCurveTo(xa, y2, xb, y3, x, y);
  43397. break;
  43398. case 37:
  43399. var x0 = x, y0 = y;
  43400. xa = x + stack.shift();
  43401. ya = y + stack.shift();
  43402. xb = xa + stack.shift();
  43403. yb = ya + stack.shift();
  43404. x = xb + stack.shift();
  43405. y = yb + stack.shift();
  43406. bezierCurveTo(xa, ya, xb, yb, x, y);
  43407. xa = x + stack.shift();
  43408. ya = y + stack.shift();
  43409. xb = xa + stack.shift();
  43410. yb = ya + stack.shift();
  43411. x = xb;
  43412. y = yb;
  43413. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  43414. x += stack.shift();
  43415. } else {
  43416. y += stack.shift();
  43417. }
  43418. bezierCurveTo(xa, ya, xb, yb, x, y);
  43419. break;
  43420. default:
  43421. error('unknown operator: 12 ' + v);
  43422. }
  43423. break;
  43424. case 14:
  43425. if (stack.length >= 4) {
  43426. var achar = stack.pop();
  43427. var bchar = stack.pop();
  43428. y = stack.pop();
  43429. x = stack.pop();
  43430. cmds.push({ cmd: 'save' });
  43431. cmds.push({
  43432. cmd: 'translate',
  43433. args: [
  43434. x,
  43435. y
  43436. ]
  43437. });
  43438. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  43439. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43440. cmds.push({ cmd: 'restore' });
  43441. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  43442. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43443. }
  43444. return;
  43445. case 18:
  43446. stems += stack.length >> 1;
  43447. stackClean = true;
  43448. break;
  43449. case 19:
  43450. stems += stack.length >> 1;
  43451. i += stems + 7 >> 3;
  43452. stackClean = true;
  43453. break;
  43454. case 20:
  43455. stems += stack.length >> 1;
  43456. i += stems + 7 >> 3;
  43457. stackClean = true;
  43458. break;
  43459. case 21:
  43460. y += stack.pop();
  43461. x += stack.pop();
  43462. moveTo(x, y);
  43463. stackClean = true;
  43464. break;
  43465. case 22:
  43466. x += stack.pop();
  43467. moveTo(x, y);
  43468. stackClean = true;
  43469. break;
  43470. case 23:
  43471. stems += stack.length >> 1;
  43472. stackClean = true;
  43473. break;
  43474. case 24:
  43475. while (stack.length > 2) {
  43476. xa = x + stack.shift();
  43477. ya = y + stack.shift();
  43478. xb = xa + stack.shift();
  43479. yb = ya + stack.shift();
  43480. x = xb + stack.shift();
  43481. y = yb + stack.shift();
  43482. bezierCurveTo(xa, ya, xb, yb, x, y);
  43483. }
  43484. x += stack.shift();
  43485. y += stack.shift();
  43486. lineTo(x, y);
  43487. break;
  43488. case 25:
  43489. while (stack.length > 6) {
  43490. x += stack.shift();
  43491. y += stack.shift();
  43492. lineTo(x, y);
  43493. }
  43494. xa = x + stack.shift();
  43495. ya = y + stack.shift();
  43496. xb = xa + stack.shift();
  43497. yb = ya + stack.shift();
  43498. x = xb + stack.shift();
  43499. y = yb + stack.shift();
  43500. bezierCurveTo(xa, ya, xb, yb, x, y);
  43501. break;
  43502. case 26:
  43503. if (stack.length % 2) {
  43504. x += stack.shift();
  43505. }
  43506. while (stack.length > 0) {
  43507. xa = x;
  43508. ya = y + stack.shift();
  43509. xb = xa + stack.shift();
  43510. yb = ya + stack.shift();
  43511. x = xb;
  43512. y = yb + stack.shift();
  43513. bezierCurveTo(xa, ya, xb, yb, x, y);
  43514. }
  43515. break;
  43516. case 27:
  43517. if (stack.length % 2) {
  43518. y += stack.shift();
  43519. }
  43520. while (stack.length > 0) {
  43521. xa = x + stack.shift();
  43522. ya = y;
  43523. xb = xa + stack.shift();
  43524. yb = ya + stack.shift();
  43525. x = xb + stack.shift();
  43526. y = yb;
  43527. bezierCurveTo(xa, ya, xb, yb, x, y);
  43528. }
  43529. break;
  43530. case 28:
  43531. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  43532. i += 2;
  43533. break;
  43534. case 29:
  43535. n = stack.pop() + font.gsubrsBias;
  43536. subrCode = font.gsubrs[n];
  43537. if (subrCode) {
  43538. parse(subrCode);
  43539. }
  43540. break;
  43541. case 30:
  43542. while (stack.length > 0) {
  43543. xa = x;
  43544. ya = y + stack.shift();
  43545. xb = xa + stack.shift();
  43546. yb = ya + stack.shift();
  43547. x = xb + stack.shift();
  43548. y = yb + (stack.length === 1 ? stack.shift() : 0);
  43549. bezierCurveTo(xa, ya, xb, yb, x, y);
  43550. if (stack.length === 0) {
  43551. break;
  43552. }
  43553. xa = x + stack.shift();
  43554. ya = y;
  43555. xb = xa + stack.shift();
  43556. yb = ya + stack.shift();
  43557. y = yb + stack.shift();
  43558. x = xb + (stack.length === 1 ? stack.shift() : 0);
  43559. bezierCurveTo(xa, ya, xb, yb, x, y);
  43560. }
  43561. break;
  43562. case 31:
  43563. while (stack.length > 0) {
  43564. xa = x + stack.shift();
  43565. ya = y;
  43566. xb = xa + stack.shift();
  43567. yb = ya + stack.shift();
  43568. y = yb + stack.shift();
  43569. x = xb + (stack.length === 1 ? stack.shift() : 0);
  43570. bezierCurveTo(xa, ya, xb, yb, x, y);
  43571. if (stack.length === 0) {
  43572. break;
  43573. }
  43574. xa = x;
  43575. ya = y + stack.shift();
  43576. xb = xa + stack.shift();
  43577. yb = ya + stack.shift();
  43578. x = xb + stack.shift();
  43579. y = yb + (stack.length === 1 ? stack.shift() : 0);
  43580. bezierCurveTo(xa, ya, xb, yb, x, y);
  43581. }
  43582. break;
  43583. default:
  43584. if (v < 32) {
  43585. error('unknown operator: ' + v);
  43586. }
  43587. if (v < 247) {
  43588. stack.push(v - 139);
  43589. } else if (v < 251) {
  43590. stack.push((v - 247) * 256 + code[i++] + 108);
  43591. } else if (v < 255) {
  43592. stack.push(-(v - 251) * 256 - code[i++] - 108);
  43593. } else {
  43594. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  43595. i += 4;
  43596. }
  43597. break;
  43598. }
  43599. if (stackClean) {
  43600. stack.length = 0;
  43601. }
  43602. }
  43603. }
  43604. parse(code);
  43605. }
  43606. var noop = '';
  43607. function CompiledFont(fontMatrix) {
  43608. this.compiledGlyphs = Object.create(null);
  43609. this.compiledCharCodeToGlyphId = Object.create(null);
  43610. this.fontMatrix = fontMatrix;
  43611. }
  43612. CompiledFont.prototype = {
  43613. getPathJs: function (unicode) {
  43614. var cmap = lookupCmap(this.cmap, unicode);
  43615. var fn = this.compiledGlyphs[cmap.glyphId];
  43616. if (!fn) {
  43617. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  43618. this.compiledGlyphs[cmap.glyphId] = fn;
  43619. }
  43620. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  43621. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  43622. }
  43623. return fn;
  43624. },
  43625. compileGlyph: function (code) {
  43626. if (!code || code.length === 0 || code[0] === 14) {
  43627. return noop;
  43628. }
  43629. var cmds = [];
  43630. cmds.push({ cmd: 'save' });
  43631. cmds.push({
  43632. cmd: 'transform',
  43633. args: this.fontMatrix.slice()
  43634. });
  43635. cmds.push({
  43636. cmd: 'scale',
  43637. args: [
  43638. 'size',
  43639. '-size'
  43640. ]
  43641. });
  43642. this.compileGlyphImpl(code, cmds);
  43643. cmds.push({ cmd: 'restore' });
  43644. return cmds;
  43645. },
  43646. compileGlyphImpl: function () {
  43647. error('Children classes should implement this.');
  43648. },
  43649. hasBuiltPath: function (unicode) {
  43650. var cmap = lookupCmap(this.cmap, unicode);
  43651. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  43652. }
  43653. };
  43654. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  43655. fontMatrix = fontMatrix || [
  43656. 0.000488,
  43657. 0,
  43658. 0,
  43659. 0.000488,
  43660. 0,
  43661. 0
  43662. ];
  43663. CompiledFont.call(this, fontMatrix);
  43664. this.glyphs = glyphs;
  43665. this.cmap = cmap;
  43666. }
  43667. Util.inherit(TrueTypeCompiled, CompiledFont, {
  43668. compileGlyphImpl: function (code, cmds) {
  43669. compileGlyf(code, cmds, this);
  43670. }
  43671. });
  43672. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  43673. fontMatrix = fontMatrix || [
  43674. 0.001,
  43675. 0,
  43676. 0,
  43677. 0.001,
  43678. 0,
  43679. 0
  43680. ];
  43681. CompiledFont.call(this, fontMatrix);
  43682. this.glyphs = cffInfo.glyphs;
  43683. this.gsubrs = cffInfo.gsubrs || [];
  43684. this.subrs = cffInfo.subrs || [];
  43685. this.cmap = cmap;
  43686. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  43687. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  43688. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  43689. }
  43690. Util.inherit(Type2Compiled, CompiledFont, {
  43691. compileGlyphImpl: function (code, cmds) {
  43692. compileCharString(code, cmds, this);
  43693. }
  43694. });
  43695. return {
  43696. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  43697. var data = new Uint8Array(font.data);
  43698. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  43699. var numTables = getUshort(data, 4);
  43700. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  43701. var tag = bytesToString(data.subarray(p, p + 4));
  43702. var offset = getLong(data, p + 8);
  43703. var length = getLong(data, p + 12);
  43704. switch (tag) {
  43705. case 'cmap':
  43706. cmap = parseCmap(data, offset, offset + length);
  43707. break;
  43708. case 'glyf':
  43709. glyf = data.subarray(offset, offset + length);
  43710. break;
  43711. case 'loca':
  43712. loca = data.subarray(offset, offset + length);
  43713. break;
  43714. case 'head':
  43715. unitsPerEm = getUshort(data, offset + 18);
  43716. indexToLocFormat = getUshort(data, offset + 50);
  43717. break;
  43718. case 'CFF ':
  43719. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  43720. break;
  43721. }
  43722. }
  43723. if (glyf) {
  43724. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  43725. 1 / unitsPerEm,
  43726. 0,
  43727. 0,
  43728. 1 / unitsPerEm,
  43729. 0,
  43730. 0
  43731. ];
  43732. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  43733. }
  43734. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  43735. }
  43736. };
  43737. }();
  43738. exports.FontRendererFactory = FontRendererFactory;
  43739. /***/ }),
  43740. /* 33 */
  43741. /***/ (function(module, exports, __w_pdfjs_require__) {
  43742. "use strict";
  43743. var sharedUtil = __w_pdfjs_require__(0);
  43744. var corePrimitives = __w_pdfjs_require__(1);
  43745. var coreStream = __w_pdfjs_require__(2);
  43746. var coreGlyphList = __w_pdfjs_require__(8);
  43747. var coreFontRenderer = __w_pdfjs_require__(32);
  43748. var coreEncodings = __w_pdfjs_require__(5);
  43749. var coreStandardFonts = __w_pdfjs_require__(20);
  43750. var coreUnicode = __w_pdfjs_require__(21);
  43751. var coreType1Parser = __w_pdfjs_require__(43);
  43752. var coreCFFParser = __w_pdfjs_require__(14);
  43753. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  43754. var FontType = sharedUtil.FontType;
  43755. var assert = sharedUtil.assert;
  43756. var bytesToString = sharedUtil.bytesToString;
  43757. var error = sharedUtil.error;
  43758. var info = sharedUtil.info;
  43759. var isArray = sharedUtil.isArray;
  43760. var isInt = sharedUtil.isInt;
  43761. var isNum = sharedUtil.isNum;
  43762. var readUint32 = sharedUtil.readUint32;
  43763. var shadow = sharedUtil.shadow;
  43764. var string32 = sharedUtil.string32;
  43765. var warn = sharedUtil.warn;
  43766. var MissingDataException = sharedUtil.MissingDataException;
  43767. var isSpace = sharedUtil.isSpace;
  43768. var Stream = coreStream.Stream;
  43769. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  43770. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  43771. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  43772. var StandardEncoding = coreEncodings.StandardEncoding;
  43773. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  43774. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  43775. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  43776. var getEncoding = coreEncodings.getEncoding;
  43777. var getStdFontMap = coreStandardFonts.getStdFontMap;
  43778. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  43779. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  43780. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  43781. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  43782. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  43783. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  43784. var Type1Parser = coreType1Parser.Type1Parser;
  43785. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  43786. var CFFParser = coreCFFParser.CFFParser;
  43787. var CFFCompiler = coreCFFParser.CFFCompiler;
  43788. var CFF = coreCFFParser.CFF;
  43789. var CFFHeader = coreCFFParser.CFFHeader;
  43790. var CFFTopDict = coreCFFParser.CFFTopDict;
  43791. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  43792. var CFFStrings = coreCFFParser.CFFStrings;
  43793. var CFFIndex = coreCFFParser.CFFIndex;
  43794. var CFFCharset = coreCFFParser.CFFCharset;
  43795. var PRIVATE_USE_OFFSET_START = 0xE000;
  43796. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  43797. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  43798. var PDF_GLYPH_SPACE_UNITS = 1000;
  43799. var SEAC_ANALYSIS_ENABLED = false;
  43800. var FontFlags = {
  43801. FixedPitch: 1,
  43802. Serif: 2,
  43803. Symbolic: 4,
  43804. Script: 8,
  43805. Nonsymbolic: 32,
  43806. Italic: 64,
  43807. AllCap: 65536,
  43808. SmallCap: 131072,
  43809. ForceBold: 262144
  43810. };
  43811. var MacStandardGlyphOrdering = [
  43812. '.notdef',
  43813. '.null',
  43814. 'nonmarkingreturn',
  43815. 'space',
  43816. 'exclam',
  43817. 'quotedbl',
  43818. 'numbersign',
  43819. 'dollar',
  43820. 'percent',
  43821. 'ampersand',
  43822. 'quotesingle',
  43823. 'parenleft',
  43824. 'parenright',
  43825. 'asterisk',
  43826. 'plus',
  43827. 'comma',
  43828. 'hyphen',
  43829. 'period',
  43830. 'slash',
  43831. 'zero',
  43832. 'one',
  43833. 'two',
  43834. 'three',
  43835. 'four',
  43836. 'five',
  43837. 'six',
  43838. 'seven',
  43839. 'eight',
  43840. 'nine',
  43841. 'colon',
  43842. 'semicolon',
  43843. 'less',
  43844. 'equal',
  43845. 'greater',
  43846. 'question',
  43847. 'at',
  43848. 'A',
  43849. 'B',
  43850. 'C',
  43851. 'D',
  43852. 'E',
  43853. 'F',
  43854. 'G',
  43855. 'H',
  43856. 'I',
  43857. 'J',
  43858. 'K',
  43859. 'L',
  43860. 'M',
  43861. 'N',
  43862. 'O',
  43863. 'P',
  43864. 'Q',
  43865. 'R',
  43866. 'S',
  43867. 'T',
  43868. 'U',
  43869. 'V',
  43870. 'W',
  43871. 'X',
  43872. 'Y',
  43873. 'Z',
  43874. 'bracketleft',
  43875. 'backslash',
  43876. 'bracketright',
  43877. 'asciicircum',
  43878. 'underscore',
  43879. 'grave',
  43880. 'a',
  43881. 'b',
  43882. 'c',
  43883. 'd',
  43884. 'e',
  43885. 'f',
  43886. 'g',
  43887. 'h',
  43888. 'i',
  43889. 'j',
  43890. 'k',
  43891. 'l',
  43892. 'm',
  43893. 'n',
  43894. 'o',
  43895. 'p',
  43896. 'q',
  43897. 'r',
  43898. 's',
  43899. 't',
  43900. 'u',
  43901. 'v',
  43902. 'w',
  43903. 'x',
  43904. 'y',
  43905. 'z',
  43906. 'braceleft',
  43907. 'bar',
  43908. 'braceright',
  43909. 'asciitilde',
  43910. 'Adieresis',
  43911. 'Aring',
  43912. 'Ccedilla',
  43913. 'Eacute',
  43914. 'Ntilde',
  43915. 'Odieresis',
  43916. 'Udieresis',
  43917. 'aacute',
  43918. 'agrave',
  43919. 'acircumflex',
  43920. 'adieresis',
  43921. 'atilde',
  43922. 'aring',
  43923. 'ccedilla',
  43924. 'eacute',
  43925. 'egrave',
  43926. 'ecircumflex',
  43927. 'edieresis',
  43928. 'iacute',
  43929. 'igrave',
  43930. 'icircumflex',
  43931. 'idieresis',
  43932. 'ntilde',
  43933. 'oacute',
  43934. 'ograve',
  43935. 'ocircumflex',
  43936. 'odieresis',
  43937. 'otilde',
  43938. 'uacute',
  43939. 'ugrave',
  43940. 'ucircumflex',
  43941. 'udieresis',
  43942. 'dagger',
  43943. 'degree',
  43944. 'cent',
  43945. 'sterling',
  43946. 'section',
  43947. 'bullet',
  43948. 'paragraph',
  43949. 'germandbls',
  43950. 'registered',
  43951. 'copyright',
  43952. 'trademark',
  43953. 'acute',
  43954. 'dieresis',
  43955. 'notequal',
  43956. 'AE',
  43957. 'Oslash',
  43958. 'infinity',
  43959. 'plusminus',
  43960. 'lessequal',
  43961. 'greaterequal',
  43962. 'yen',
  43963. 'mu',
  43964. 'partialdiff',
  43965. 'summation',
  43966. 'product',
  43967. 'pi',
  43968. 'integral',
  43969. 'ordfeminine',
  43970. 'ordmasculine',
  43971. 'Omega',
  43972. 'ae',
  43973. 'oslash',
  43974. 'questiondown',
  43975. 'exclamdown',
  43976. 'logicalnot',
  43977. 'radical',
  43978. 'florin',
  43979. 'approxequal',
  43980. 'Delta',
  43981. 'guillemotleft',
  43982. 'guillemotright',
  43983. 'ellipsis',
  43984. 'nonbreakingspace',
  43985. 'Agrave',
  43986. 'Atilde',
  43987. 'Otilde',
  43988. 'OE',
  43989. 'oe',
  43990. 'endash',
  43991. 'emdash',
  43992. 'quotedblleft',
  43993. 'quotedblright',
  43994. 'quoteleft',
  43995. 'quoteright',
  43996. 'divide',
  43997. 'lozenge',
  43998. 'ydieresis',
  43999. 'Ydieresis',
  44000. 'fraction',
  44001. 'currency',
  44002. 'guilsinglleft',
  44003. 'guilsinglright',
  44004. 'fi',
  44005. 'fl',
  44006. 'daggerdbl',
  44007. 'periodcentered',
  44008. 'quotesinglbase',
  44009. 'quotedblbase',
  44010. 'perthousand',
  44011. 'Acircumflex',
  44012. 'Ecircumflex',
  44013. 'Aacute',
  44014. 'Edieresis',
  44015. 'Egrave',
  44016. 'Iacute',
  44017. 'Icircumflex',
  44018. 'Idieresis',
  44019. 'Igrave',
  44020. 'Oacute',
  44021. 'Ocircumflex',
  44022. 'apple',
  44023. 'Ograve',
  44024. 'Uacute',
  44025. 'Ucircumflex',
  44026. 'Ugrave',
  44027. 'dotlessi',
  44028. 'circumflex',
  44029. 'tilde',
  44030. 'macron',
  44031. 'breve',
  44032. 'dotaccent',
  44033. 'ring',
  44034. 'cedilla',
  44035. 'hungarumlaut',
  44036. 'ogonek',
  44037. 'caron',
  44038. 'Lslash',
  44039. 'lslash',
  44040. 'Scaron',
  44041. 'scaron',
  44042. 'Zcaron',
  44043. 'zcaron',
  44044. 'brokenbar',
  44045. 'Eth',
  44046. 'eth',
  44047. 'Yacute',
  44048. 'yacute',
  44049. 'Thorn',
  44050. 'thorn',
  44051. 'minus',
  44052. 'multiply',
  44053. 'onesuperior',
  44054. 'twosuperior',
  44055. 'threesuperior',
  44056. 'onehalf',
  44057. 'onequarter',
  44058. 'threequarters',
  44059. 'franc',
  44060. 'Gbreve',
  44061. 'gbreve',
  44062. 'Idotaccent',
  44063. 'Scedilla',
  44064. 'scedilla',
  44065. 'Cacute',
  44066. 'cacute',
  44067. 'Ccaron',
  44068. 'ccaron',
  44069. 'dcroat'
  44070. ];
  44071. function adjustWidths(properties) {
  44072. if (!properties.fontMatrix) {
  44073. return;
  44074. }
  44075. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  44076. return;
  44077. }
  44078. var scale = 0.001 / properties.fontMatrix[0];
  44079. var glyphsWidths = properties.widths;
  44080. for (var glyph in glyphsWidths) {
  44081. glyphsWidths[glyph] *= scale;
  44082. }
  44083. properties.defaultWidth *= scale;
  44084. }
  44085. function adjustToUnicode(properties, builtInEncoding) {
  44086. if (properties.hasIncludedToUnicodeMap) {
  44087. return;
  44088. }
  44089. if (properties.hasEncoding) {
  44090. return;
  44091. }
  44092. if (builtInEncoding === properties.defaultEncoding) {
  44093. return;
  44094. }
  44095. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  44096. return;
  44097. }
  44098. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  44099. for (var charCode in builtInEncoding) {
  44100. var glyphName = builtInEncoding[charCode];
  44101. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44102. if (unicode !== -1) {
  44103. toUnicode[charCode] = String.fromCharCode(unicode);
  44104. }
  44105. }
  44106. properties.toUnicode.amend(toUnicode);
  44107. }
  44108. function getFontType(type, subtype) {
  44109. switch (type) {
  44110. case 'Type1':
  44111. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  44112. case 'CIDFontType0':
  44113. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  44114. case 'OpenType':
  44115. return FontType.OPENTYPE;
  44116. case 'TrueType':
  44117. return FontType.TRUETYPE;
  44118. case 'CIDFontType2':
  44119. return FontType.CIDFONTTYPE2;
  44120. case 'MMType1':
  44121. return FontType.MMTYPE1;
  44122. case 'Type0':
  44123. return FontType.TYPE0;
  44124. default:
  44125. return FontType.UNKNOWN;
  44126. }
  44127. }
  44128. function recoverGlyphName(name, glyphsUnicodeMap) {
  44129. if (glyphsUnicodeMap[name] !== undefined) {
  44130. return name;
  44131. }
  44132. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  44133. if (unicode !== -1) {
  44134. for (var key in glyphsUnicodeMap) {
  44135. if (glyphsUnicodeMap[key] === unicode) {
  44136. return key;
  44137. }
  44138. }
  44139. }
  44140. info('Unable to recover a standard glyph name for: ' + name);
  44141. return name;
  44142. }
  44143. var Glyph = function GlyphClosure() {
  44144. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44145. this.fontChar = fontChar;
  44146. this.unicode = unicode;
  44147. this.accent = accent;
  44148. this.width = width;
  44149. this.vmetric = vmetric;
  44150. this.operatorListId = operatorListId;
  44151. this.isSpace = isSpace;
  44152. this.isInFont = isInFont;
  44153. }
  44154. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44155. 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;
  44156. };
  44157. return Glyph;
  44158. }();
  44159. var ToUnicodeMap = function ToUnicodeMapClosure() {
  44160. function ToUnicodeMap(cmap) {
  44161. this._map = cmap;
  44162. }
  44163. ToUnicodeMap.prototype = {
  44164. get length() {
  44165. return this._map.length;
  44166. },
  44167. forEach: function (callback) {
  44168. for (var charCode in this._map) {
  44169. callback(charCode, this._map[charCode].charCodeAt(0));
  44170. }
  44171. },
  44172. has: function (i) {
  44173. return this._map[i] !== undefined;
  44174. },
  44175. get: function (i) {
  44176. return this._map[i];
  44177. },
  44178. charCodeOf: function (v) {
  44179. return this._map.indexOf(v);
  44180. },
  44181. amend: function (map) {
  44182. for (var charCode in map) {
  44183. this._map[charCode] = map[charCode];
  44184. }
  44185. }
  44186. };
  44187. return ToUnicodeMap;
  44188. }();
  44189. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  44190. function IdentityToUnicodeMap(firstChar, lastChar) {
  44191. this.firstChar = firstChar;
  44192. this.lastChar = lastChar;
  44193. }
  44194. IdentityToUnicodeMap.prototype = {
  44195. get length() {
  44196. return this.lastChar + 1 - this.firstChar;
  44197. },
  44198. forEach: function (callback) {
  44199. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  44200. callback(i, i);
  44201. }
  44202. },
  44203. has: function (i) {
  44204. return this.firstChar <= i && i <= this.lastChar;
  44205. },
  44206. get: function (i) {
  44207. if (this.firstChar <= i && i <= this.lastChar) {
  44208. return String.fromCharCode(i);
  44209. }
  44210. return undefined;
  44211. },
  44212. charCodeOf: function (v) {
  44213. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  44214. },
  44215. amend: function (map) {
  44216. error('Should not call amend()');
  44217. }
  44218. };
  44219. return IdentityToUnicodeMap;
  44220. }();
  44221. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  44222. function writeInt16(dest, offset, num) {
  44223. dest[offset] = num >> 8 & 0xFF;
  44224. dest[offset + 1] = num & 0xFF;
  44225. }
  44226. function writeInt32(dest, offset, num) {
  44227. dest[offset] = num >> 24 & 0xFF;
  44228. dest[offset + 1] = num >> 16 & 0xFF;
  44229. dest[offset + 2] = num >> 8 & 0xFF;
  44230. dest[offset + 3] = num & 0xFF;
  44231. }
  44232. function writeData(dest, offset, data) {
  44233. var i, ii;
  44234. if (data instanceof Uint8Array) {
  44235. dest.set(data, offset);
  44236. } else if (typeof data === 'string') {
  44237. for (i = 0, ii = data.length; i < ii; i++) {
  44238. dest[offset++] = data.charCodeAt(i) & 0xFF;
  44239. }
  44240. } else {
  44241. for (i = 0, ii = data.length; i < ii; i++) {
  44242. dest[offset++] = data[i] & 0xFF;
  44243. }
  44244. }
  44245. }
  44246. function OpenTypeFileBuilder(sfnt) {
  44247. this.sfnt = sfnt;
  44248. this.tables = Object.create(null);
  44249. }
  44250. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  44251. var maxPower2 = 1, log2 = 0;
  44252. while ((maxPower2 ^ entriesCount) > maxPower2) {
  44253. maxPower2 <<= 1;
  44254. log2++;
  44255. }
  44256. var searchRange = maxPower2 * entrySize;
  44257. return {
  44258. range: searchRange,
  44259. entry: log2,
  44260. rangeShift: entrySize * entriesCount - searchRange
  44261. };
  44262. };
  44263. var OTF_HEADER_SIZE = 12;
  44264. var OTF_TABLE_ENTRY_SIZE = 16;
  44265. OpenTypeFileBuilder.prototype = {
  44266. toArray: function OpenTypeFileBuilder_toArray() {
  44267. var sfnt = this.sfnt;
  44268. var tables = this.tables;
  44269. var tablesNames = Object.keys(tables);
  44270. tablesNames.sort();
  44271. var numTables = tablesNames.length;
  44272. var i, j, jj, table, tableName;
  44273. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  44274. var tableOffsets = [offset];
  44275. for (i = 0; i < numTables; i++) {
  44276. table = tables[tablesNames[i]];
  44277. var paddedLength = (table.length + 3 & ~3) >>> 0;
  44278. offset += paddedLength;
  44279. tableOffsets.push(offset);
  44280. }
  44281. var file = new Uint8Array(offset);
  44282. for (i = 0; i < numTables; i++) {
  44283. table = tables[tablesNames[i]];
  44284. writeData(file, tableOffsets[i], table);
  44285. }
  44286. if (sfnt === 'true') {
  44287. sfnt = string32(0x00010000);
  44288. }
  44289. file[0] = sfnt.charCodeAt(0) & 0xFF;
  44290. file[1] = sfnt.charCodeAt(1) & 0xFF;
  44291. file[2] = sfnt.charCodeAt(2) & 0xFF;
  44292. file[3] = sfnt.charCodeAt(3) & 0xFF;
  44293. writeInt16(file, 4, numTables);
  44294. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  44295. writeInt16(file, 6, searchParams.range);
  44296. writeInt16(file, 8, searchParams.entry);
  44297. writeInt16(file, 10, searchParams.rangeShift);
  44298. offset = OTF_HEADER_SIZE;
  44299. for (i = 0; i < numTables; i++) {
  44300. tableName = tablesNames[i];
  44301. file[offset] = tableName.charCodeAt(0) & 0xFF;
  44302. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  44303. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  44304. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  44305. var checksum = 0;
  44306. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  44307. var quad = readUint32(file, j);
  44308. checksum = checksum + quad >>> 0;
  44309. }
  44310. writeInt32(file, offset + 4, checksum);
  44311. writeInt32(file, offset + 8, tableOffsets[i]);
  44312. writeInt32(file, offset + 12, tables[tableName].length);
  44313. offset += OTF_TABLE_ENTRY_SIZE;
  44314. }
  44315. return file;
  44316. },
  44317. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  44318. if (tag in this.tables) {
  44319. throw new Error('Table ' + tag + ' already exists');
  44320. }
  44321. this.tables[tag] = data;
  44322. }
  44323. };
  44324. return OpenTypeFileBuilder;
  44325. }();
  44326. var ProblematicCharRanges = new Int32Array([
  44327. 0x0000,
  44328. 0x0020,
  44329. 0x007F,
  44330. 0x00A1,
  44331. 0x00AD,
  44332. 0x00AE,
  44333. 0x0600,
  44334. 0x0780,
  44335. 0x08A0,
  44336. 0x10A0,
  44337. 0x1780,
  44338. 0x1800,
  44339. 0x1C00,
  44340. 0x1C50,
  44341. 0x2000,
  44342. 0x2010,
  44343. 0x2011,
  44344. 0x2012,
  44345. 0x2028,
  44346. 0x2030,
  44347. 0x205F,
  44348. 0x2070,
  44349. 0x25CC,
  44350. 0x25CD,
  44351. 0x3000,
  44352. 0x3001,
  44353. 0xAA60,
  44354. 0xAA80,
  44355. 0xFFF0,
  44356. 0x10000
  44357. ]);
  44358. var Font = function FontClosure() {
  44359. function Font(name, file, properties) {
  44360. var charCode, glyphName, unicode;
  44361. this.name = name;
  44362. this.loadedName = properties.loadedName;
  44363. this.isType3Font = properties.isType3Font;
  44364. this.sizes = [];
  44365. this.missingFile = false;
  44366. this.glyphCache = Object.create(null);
  44367. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  44368. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  44369. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  44370. var type = properties.type;
  44371. var subtype = properties.subtype;
  44372. this.type = type;
  44373. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  44374. this.differences = properties.differences;
  44375. this.widths = properties.widths;
  44376. this.defaultWidth = properties.defaultWidth;
  44377. this.composite = properties.composite;
  44378. this.wideChars = properties.wideChars;
  44379. this.cMap = properties.cMap;
  44380. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  44381. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  44382. this.fontMatrix = properties.fontMatrix;
  44383. this.bbox = properties.bbox;
  44384. this.toUnicode = properties.toUnicode;
  44385. this.toFontChar = [];
  44386. if (properties.type === 'Type3') {
  44387. for (charCode = 0; charCode < 256; charCode++) {
  44388. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  44389. }
  44390. this.fontType = FontType.TYPE3;
  44391. return;
  44392. }
  44393. this.cidEncoding = properties.cidEncoding;
  44394. this.vertical = properties.vertical;
  44395. if (this.vertical) {
  44396. this.vmetrics = properties.vmetrics;
  44397. this.defaultVMetrics = properties.defaultVMetrics;
  44398. }
  44399. var glyphsUnicodeMap;
  44400. if (!file || file.isEmpty) {
  44401. if (file) {
  44402. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  44403. }
  44404. this.missingFile = true;
  44405. var fontName = name.replace(/[,_]/g, '-');
  44406. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  44407. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  44408. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  44409. this.bold = fontName.search(/bold/gi) !== -1;
  44410. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  44411. this.black = name.search(/Black/g) !== -1;
  44412. this.remeasure = Object.keys(this.widths).length > 0;
  44413. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  44414. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  44415. var map = [];
  44416. for (charCode in GlyphMapForStandardFonts) {
  44417. map[+charCode] = GlyphMapForStandardFonts[charCode];
  44418. }
  44419. if (/Arial-?Black/i.test(name)) {
  44420. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  44421. for (charCode in SupplementalGlyphMapForArialBlack) {
  44422. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  44423. }
  44424. }
  44425. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  44426. if (!isIdentityUnicode) {
  44427. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44428. map[+charCode] = unicodeCharCode;
  44429. });
  44430. }
  44431. this.toFontChar = map;
  44432. this.toUnicode = new ToUnicodeMap(map);
  44433. } else if (/Symbol/i.test(fontName)) {
  44434. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  44435. } else if (/Dingbats/i.test(fontName)) {
  44436. if (/Wingdings/i.test(name)) {
  44437. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  44438. }
  44439. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  44440. } else if (isStandardFont) {
  44441. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  44442. } else {
  44443. glyphsUnicodeMap = getGlyphsUnicode();
  44444. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44445. if (!this.composite) {
  44446. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  44447. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44448. if (unicode !== -1) {
  44449. unicodeCharCode = unicode;
  44450. }
  44451. }
  44452. this.toFontChar[charCode] = unicodeCharCode;
  44453. }.bind(this));
  44454. }
  44455. this.loadedName = fontName.split('-')[0];
  44456. this.loading = false;
  44457. this.fontType = getFontType(type, subtype);
  44458. return;
  44459. }
  44460. if (subtype === 'Type1C') {
  44461. if (type !== 'Type1' && type !== 'MMType1') {
  44462. if (isTrueTypeFile(file)) {
  44463. subtype = 'TrueType';
  44464. } else {
  44465. type = 'Type1';
  44466. }
  44467. } else if (isOpenTypeFile(file)) {
  44468. type = subtype = 'OpenType';
  44469. }
  44470. }
  44471. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  44472. type = 'CIDFontType0';
  44473. }
  44474. if (subtype === 'OpenType') {
  44475. type = 'OpenType';
  44476. }
  44477. if (type === 'CIDFontType0') {
  44478. if (isType1File(file)) {
  44479. subtype = 'CIDFontType0';
  44480. } else if (isOpenTypeFile(file)) {
  44481. type = subtype = 'OpenType';
  44482. } else {
  44483. subtype = 'CIDFontType0C';
  44484. }
  44485. }
  44486. var data;
  44487. switch (type) {
  44488. case 'MMType1':
  44489. info('MMType1 font (' + name + '), falling back to Type1.');
  44490. case 'Type1':
  44491. case 'CIDFontType0':
  44492. this.mimetype = 'font/opentype';
  44493. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  44494. adjustWidths(properties);
  44495. data = this.convert(name, cff, properties);
  44496. break;
  44497. case 'OpenType':
  44498. case 'TrueType':
  44499. case 'CIDFontType2':
  44500. this.mimetype = 'font/opentype';
  44501. data = this.checkAndRepair(name, file, properties);
  44502. if (this.isOpenType) {
  44503. adjustWidths(properties);
  44504. type = 'OpenType';
  44505. }
  44506. break;
  44507. default:
  44508. error('Font ' + type + ' is not supported');
  44509. break;
  44510. }
  44511. this.data = data;
  44512. this.fontType = getFontType(type, subtype);
  44513. this.fontMatrix = properties.fontMatrix;
  44514. this.widths = properties.widths;
  44515. this.defaultWidth = properties.defaultWidth;
  44516. this.toUnicode = properties.toUnicode;
  44517. this.encoding = properties.baseEncoding;
  44518. this.seacMap = properties.seacMap;
  44519. this.loading = true;
  44520. }
  44521. Font.getFontID = function () {
  44522. var ID = 1;
  44523. return function Font_getFontID() {
  44524. return String(ID++);
  44525. };
  44526. }();
  44527. function int16(b0, b1) {
  44528. return (b0 << 8) + b1;
  44529. }
  44530. function signedInt16(b0, b1) {
  44531. var value = (b0 << 8) + b1;
  44532. return value & 1 << 15 ? value - 0x10000 : value;
  44533. }
  44534. function int32(b0, b1, b2, b3) {
  44535. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  44536. }
  44537. function string16(value) {
  44538. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44539. }
  44540. function safeString16(value) {
  44541. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  44542. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44543. }
  44544. function isTrueTypeFile(file) {
  44545. var header = file.peekBytes(4);
  44546. return readUint32(header, 0) === 0x00010000;
  44547. }
  44548. function isOpenTypeFile(file) {
  44549. var header = file.peekBytes(4);
  44550. return bytesToString(header) === 'OTTO';
  44551. }
  44552. function isType1File(file) {
  44553. var header = file.peekBytes(2);
  44554. if (header[0] === 0x25 && header[1] === 0x21) {
  44555. return true;
  44556. }
  44557. if (header[0] === 0x80 && header[1] === 0x01) {
  44558. return true;
  44559. }
  44560. return false;
  44561. }
  44562. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  44563. var toFontChar = [], unicode;
  44564. for (var i = 0, ii = encoding.length; i < ii; i++) {
  44565. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  44566. if (unicode !== -1) {
  44567. toFontChar[i] = unicode;
  44568. }
  44569. }
  44570. for (var charCode in differences) {
  44571. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  44572. if (unicode !== -1) {
  44573. toFontChar[+charCode] = unicode;
  44574. }
  44575. }
  44576. return toFontChar;
  44577. }
  44578. function isProblematicUnicodeLocation(code) {
  44579. var i = 0, j = ProblematicCharRanges.length - 1;
  44580. while (i < j) {
  44581. var c = i + j + 1 >> 1;
  44582. if (code < ProblematicCharRanges[c]) {
  44583. j = c - 1;
  44584. } else {
  44585. i = c;
  44586. }
  44587. }
  44588. return !(i & 1);
  44589. }
  44590. function adjustMapping(charCodeToGlyphId, properties) {
  44591. var toUnicode = properties.toUnicode;
  44592. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  44593. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  44594. var newMap = Object.create(null);
  44595. var toFontChar = [];
  44596. var usedFontCharCodes = [];
  44597. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  44598. for (var originalCharCode in charCodeToGlyphId) {
  44599. originalCharCode |= 0;
  44600. var glyphId = charCodeToGlyphId[originalCharCode];
  44601. var fontCharCode = originalCharCode;
  44602. var hasUnicodeValue = false;
  44603. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  44604. hasUnicodeValue = true;
  44605. var unicode = toUnicode.get(fontCharCode);
  44606. if (unicode.length === 1) {
  44607. fontCharCode = unicode.charCodeAt(0);
  44608. }
  44609. }
  44610. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  44611. do {
  44612. fontCharCode = nextAvailableFontCharCode++;
  44613. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  44614. fontCharCode = 0xF020;
  44615. nextAvailableFontCharCode = fontCharCode + 1;
  44616. }
  44617. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  44618. }
  44619. newMap[fontCharCode] = glyphId;
  44620. toFontChar[originalCharCode] = fontCharCode;
  44621. usedFontCharCodes[fontCharCode] = true;
  44622. }
  44623. return {
  44624. toFontChar: toFontChar,
  44625. charCodeToGlyphId: newMap,
  44626. nextAvailableFontCharCode: nextAvailableFontCharCode
  44627. };
  44628. }
  44629. function getRanges(glyphs, numGlyphs) {
  44630. var codes = [];
  44631. for (var charCode in glyphs) {
  44632. if (glyphs[charCode] >= numGlyphs) {
  44633. continue;
  44634. }
  44635. codes.push({
  44636. fontCharCode: charCode | 0,
  44637. glyphId: glyphs[charCode]
  44638. });
  44639. }
  44640. codes.sort(function fontGetRangesSort(a, b) {
  44641. return a.fontCharCode - b.fontCharCode;
  44642. });
  44643. var ranges = [];
  44644. var length = codes.length;
  44645. for (var n = 0; n < length;) {
  44646. var start = codes[n].fontCharCode;
  44647. var codeIndices = [codes[n].glyphId];
  44648. ++n;
  44649. var end = start;
  44650. while (n < length && end + 1 === codes[n].fontCharCode) {
  44651. codeIndices.push(codes[n].glyphId);
  44652. ++end;
  44653. ++n;
  44654. if (end === 0xFFFF) {
  44655. break;
  44656. }
  44657. }
  44658. ranges.push([
  44659. start,
  44660. end,
  44661. codeIndices
  44662. ]);
  44663. }
  44664. return ranges;
  44665. }
  44666. function createCmapTable(glyphs, numGlyphs) {
  44667. var ranges = getRanges(glyphs, numGlyphs);
  44668. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  44669. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  44670. var i, ii, j, jj;
  44671. for (i = ranges.length - 1; i >= 0; --i) {
  44672. if (ranges[i][0] <= 0xFFFF) {
  44673. break;
  44674. }
  44675. }
  44676. var bmpLength = i + 1;
  44677. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  44678. ranges[i][1] = 0xFFFE;
  44679. }
  44680. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  44681. var segCount = bmpLength + trailingRangesCount;
  44682. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  44683. var startCount = '';
  44684. var endCount = '';
  44685. var idDeltas = '';
  44686. var idRangeOffsets = '';
  44687. var glyphsIds = '';
  44688. var bias = 0;
  44689. var range, start, end, codes;
  44690. for (i = 0, ii = bmpLength; i < ii; i++) {
  44691. range = ranges[i];
  44692. start = range[0];
  44693. end = range[1];
  44694. startCount += string16(start);
  44695. endCount += string16(end);
  44696. codes = range[2];
  44697. var contiguous = true;
  44698. for (j = 1, jj = codes.length; j < jj; ++j) {
  44699. if (codes[j] !== codes[j - 1] + 1) {
  44700. contiguous = false;
  44701. break;
  44702. }
  44703. }
  44704. if (!contiguous) {
  44705. var offset = (segCount - i) * 2 + bias * 2;
  44706. bias += end - start + 1;
  44707. idDeltas += string16(0);
  44708. idRangeOffsets += string16(offset);
  44709. for (j = 0, jj = codes.length; j < jj; ++j) {
  44710. glyphsIds += string16(codes[j]);
  44711. }
  44712. } else {
  44713. var startCode = codes[0];
  44714. idDeltas += string16(startCode - start & 0xFFFF);
  44715. idRangeOffsets += string16(0);
  44716. }
  44717. }
  44718. if (trailingRangesCount > 0) {
  44719. endCount += '\xFF\xFF';
  44720. startCount += '\xFF\xFF';
  44721. idDeltas += '\x00\x01';
  44722. idRangeOffsets += '\x00\x00';
  44723. }
  44724. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  44725. var format31012 = '';
  44726. var header31012 = '';
  44727. if (numTables > 1) {
  44728. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  44729. format31012 = '';
  44730. for (i = 0, ii = ranges.length; i < ii; i++) {
  44731. range = ranges[i];
  44732. start = range[0];
  44733. codes = range[2];
  44734. var code = codes[0];
  44735. for (j = 1, jj = codes.length; j < jj; ++j) {
  44736. if (codes[j] !== codes[j - 1] + 1) {
  44737. end = range[0] + j - 1;
  44738. format31012 += string32(start) + string32(end) + string32(code);
  44739. start = end + 1;
  44740. code = codes[j];
  44741. }
  44742. }
  44743. format31012 += string32(start) + string32(range[1]) + string32(code);
  44744. }
  44745. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  44746. }
  44747. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  44748. }
  44749. function validateOS2Table(os2) {
  44750. var stream = new Stream(os2.data);
  44751. var version = stream.getUint16();
  44752. stream.getBytes(60);
  44753. var selection = stream.getUint16();
  44754. if (version < 4 && selection & 0x0300) {
  44755. return false;
  44756. }
  44757. var firstChar = stream.getUint16();
  44758. var lastChar = stream.getUint16();
  44759. if (firstChar > lastChar) {
  44760. return false;
  44761. }
  44762. stream.getBytes(6);
  44763. var usWinAscent = stream.getUint16();
  44764. if (usWinAscent === 0) {
  44765. return false;
  44766. }
  44767. os2.data[8] = os2.data[9] = 0;
  44768. return true;
  44769. }
  44770. function createOS2Table(properties, charstrings, override) {
  44771. override = override || {
  44772. unitsPerEm: 0,
  44773. yMax: 0,
  44774. yMin: 0,
  44775. ascent: 0,
  44776. descent: 0
  44777. };
  44778. var ulUnicodeRange1 = 0;
  44779. var ulUnicodeRange2 = 0;
  44780. var ulUnicodeRange3 = 0;
  44781. var ulUnicodeRange4 = 0;
  44782. var firstCharIndex = null;
  44783. var lastCharIndex = 0;
  44784. if (charstrings) {
  44785. for (var code in charstrings) {
  44786. code |= 0;
  44787. if (firstCharIndex > code || !firstCharIndex) {
  44788. firstCharIndex = code;
  44789. }
  44790. if (lastCharIndex < code) {
  44791. lastCharIndex = code;
  44792. }
  44793. var position = getUnicodeRangeFor(code);
  44794. if (position < 32) {
  44795. ulUnicodeRange1 |= 1 << position;
  44796. } else if (position < 64) {
  44797. ulUnicodeRange2 |= 1 << position - 32;
  44798. } else if (position < 96) {
  44799. ulUnicodeRange3 |= 1 << position - 64;
  44800. } else if (position < 123) {
  44801. ulUnicodeRange4 |= 1 << position - 96;
  44802. } else {
  44803. error('Unicode ranges Bits > 123 are reserved for internal usage');
  44804. }
  44805. }
  44806. } else {
  44807. firstCharIndex = 0;
  44808. lastCharIndex = 255;
  44809. }
  44810. var bbox = properties.bbox || [
  44811. 0,
  44812. 0,
  44813. 0,
  44814. 0
  44815. ];
  44816. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  44817. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  44818. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  44819. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  44820. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  44821. typoDescent = -typoDescent;
  44822. }
  44823. var winAscent = override.yMax || typoAscent;
  44824. var winDescent = -override.yMin || -typoDescent;
  44825. 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';
  44826. }
  44827. function createPostTable(properties) {
  44828. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  44829. 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';
  44830. }
  44831. function createNameTable(name, proto) {
  44832. if (!proto) {
  44833. proto = [
  44834. [],
  44835. []
  44836. ];
  44837. }
  44838. var strings = [
  44839. proto[0][0] || 'Original licence',
  44840. proto[0][1] || name,
  44841. proto[0][2] || 'Unknown',
  44842. proto[0][3] || 'uniqueID',
  44843. proto[0][4] || name,
  44844. proto[0][5] || 'Version 0.11',
  44845. proto[0][6] || '',
  44846. proto[0][7] || 'Unknown',
  44847. proto[0][8] || 'Unknown',
  44848. proto[0][9] || 'Unknown'
  44849. ];
  44850. var stringsUnicode = [];
  44851. var i, ii, j, jj, str;
  44852. for (i = 0, ii = strings.length; i < ii; i++) {
  44853. str = proto[1][i] || strings[i];
  44854. var strBufUnicode = [];
  44855. for (j = 0, jj = str.length; j < jj; j++) {
  44856. strBufUnicode.push(string16(str.charCodeAt(j)));
  44857. }
  44858. stringsUnicode.push(strBufUnicode.join(''));
  44859. }
  44860. var names = [
  44861. strings,
  44862. stringsUnicode
  44863. ];
  44864. var platforms = [
  44865. '\x00\x01',
  44866. '\x00\x03'
  44867. ];
  44868. var encodings = [
  44869. '\x00\x00',
  44870. '\x00\x01'
  44871. ];
  44872. var languages = [
  44873. '\x00\x00',
  44874. '\x04\x09'
  44875. ];
  44876. var namesRecordCount = strings.length * platforms.length;
  44877. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  44878. var strOffset = 0;
  44879. for (i = 0, ii = platforms.length; i < ii; i++) {
  44880. var strs = names[i];
  44881. for (j = 0, jj = strs.length; j < jj; j++) {
  44882. str = strs[j];
  44883. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  44884. nameTable += nameRecord;
  44885. strOffset += str.length;
  44886. }
  44887. }
  44888. nameTable += strings.join('') + stringsUnicode.join('');
  44889. return nameTable;
  44890. }
  44891. Font.prototype = {
  44892. name: null,
  44893. font: null,
  44894. mimetype: null,
  44895. encoding: null,
  44896. get renderer() {
  44897. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  44898. return shadow(this, 'renderer', renderer);
  44899. },
  44900. exportData: function Font_exportData() {
  44901. var data = {};
  44902. for (var i in this) {
  44903. if (this.hasOwnProperty(i)) {
  44904. data[i] = this[i];
  44905. }
  44906. }
  44907. return data;
  44908. },
  44909. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  44910. function readTableEntry(file) {
  44911. var tag = bytesToString(file.getBytes(4));
  44912. var checksum = file.getInt32() >>> 0;
  44913. var offset = file.getInt32() >>> 0;
  44914. var length = file.getInt32() >>> 0;
  44915. var previousPosition = file.pos;
  44916. file.pos = file.start ? file.start : 0;
  44917. file.skip(offset);
  44918. var data = file.getBytes(length);
  44919. file.pos = previousPosition;
  44920. if (tag === 'head') {
  44921. data[8] = data[9] = data[10] = data[11] = 0;
  44922. data[17] |= 0x20;
  44923. }
  44924. return {
  44925. tag: tag,
  44926. checksum: checksum,
  44927. length: length,
  44928. offset: offset,
  44929. data: data
  44930. };
  44931. }
  44932. function readOpenTypeHeader(ttf) {
  44933. return {
  44934. version: bytesToString(ttf.getBytes(4)),
  44935. numTables: ttf.getUint16(),
  44936. searchRange: ttf.getUint16(),
  44937. entrySelector: ttf.getUint16(),
  44938. rangeShift: ttf.getUint16()
  44939. };
  44940. }
  44941. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  44942. if (!cmap) {
  44943. warn('No cmap table available.');
  44944. return {
  44945. platformId: -1,
  44946. encodingId: -1,
  44947. mappings: [],
  44948. hasShortCmap: false
  44949. };
  44950. }
  44951. var segment;
  44952. var start = (font.start ? font.start : 0) + cmap.offset;
  44953. font.pos = start;
  44954. font.getUint16();
  44955. var numTables = font.getUint16();
  44956. var potentialTable;
  44957. var canBreak = false;
  44958. for (var i = 0; i < numTables; i++) {
  44959. var platformId = font.getUint16();
  44960. var encodingId = font.getUint16();
  44961. var offset = font.getInt32() >>> 0;
  44962. var useTable = false;
  44963. if (platformId === 0 && encodingId === 0) {
  44964. useTable = true;
  44965. } else if (platformId === 1 && encodingId === 0) {
  44966. useTable = true;
  44967. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  44968. useTable = true;
  44969. if (!isSymbolicFont) {
  44970. canBreak = true;
  44971. }
  44972. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  44973. useTable = true;
  44974. canBreak = true;
  44975. }
  44976. if (useTable) {
  44977. potentialTable = {
  44978. platformId: platformId,
  44979. encodingId: encodingId,
  44980. offset: offset
  44981. };
  44982. }
  44983. if (canBreak) {
  44984. break;
  44985. }
  44986. }
  44987. if (potentialTable) {
  44988. font.pos = start + potentialTable.offset;
  44989. }
  44990. if (!potentialTable || font.peekByte() === -1) {
  44991. warn('Could not find a preferred cmap table.');
  44992. return {
  44993. platformId: -1,
  44994. encodingId: -1,
  44995. mappings: [],
  44996. hasShortCmap: false
  44997. };
  44998. }
  44999. var format = font.getUint16();
  45000. font.getUint16();
  45001. font.getUint16();
  45002. var hasShortCmap = false;
  45003. var mappings = [];
  45004. var j, glyphId;
  45005. if (format === 0) {
  45006. for (j = 0; j < 256; j++) {
  45007. var index = font.getByte();
  45008. if (!index) {
  45009. continue;
  45010. }
  45011. mappings.push({
  45012. charCode: j,
  45013. glyphId: index
  45014. });
  45015. }
  45016. hasShortCmap = true;
  45017. } else if (format === 4) {
  45018. var segCount = font.getUint16() >> 1;
  45019. font.getBytes(6);
  45020. var segIndex, segments = [];
  45021. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45022. segments.push({ end: font.getUint16() });
  45023. }
  45024. font.getUint16();
  45025. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45026. segments[segIndex].start = font.getUint16();
  45027. }
  45028. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45029. segments[segIndex].delta = font.getUint16();
  45030. }
  45031. var offsetsCount = 0;
  45032. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45033. segment = segments[segIndex];
  45034. var rangeOffset = font.getUint16();
  45035. if (!rangeOffset) {
  45036. segment.offsetIndex = -1;
  45037. continue;
  45038. }
  45039. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  45040. segment.offsetIndex = offsetIndex;
  45041. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  45042. }
  45043. var offsets = [];
  45044. for (j = 0; j < offsetsCount; j++) {
  45045. offsets.push(font.getUint16());
  45046. }
  45047. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45048. segment = segments[segIndex];
  45049. start = segment.start;
  45050. var end = segment.end;
  45051. var delta = segment.delta;
  45052. offsetIndex = segment.offsetIndex;
  45053. for (j = start; j <= end; j++) {
  45054. if (j === 0xFFFF) {
  45055. continue;
  45056. }
  45057. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  45058. glyphId = glyphId + delta & 0xFFFF;
  45059. if (glyphId === 0) {
  45060. continue;
  45061. }
  45062. mappings.push({
  45063. charCode: j,
  45064. glyphId: glyphId
  45065. });
  45066. }
  45067. }
  45068. } else if (format === 6) {
  45069. var firstCode = font.getUint16();
  45070. var entryCount = font.getUint16();
  45071. for (j = 0; j < entryCount; j++) {
  45072. glyphId = font.getUint16();
  45073. var charCode = firstCode + j;
  45074. mappings.push({
  45075. charCode: charCode,
  45076. glyphId: glyphId
  45077. });
  45078. }
  45079. } else {
  45080. warn('cmap table has unsupported format: ' + format);
  45081. return {
  45082. platformId: -1,
  45083. encodingId: -1,
  45084. mappings: [],
  45085. hasShortCmap: false
  45086. };
  45087. }
  45088. mappings.sort(function (a, b) {
  45089. return a.charCode - b.charCode;
  45090. });
  45091. for (i = 1; i < mappings.length; i++) {
  45092. if (mappings[i - 1].charCode === mappings[i].charCode) {
  45093. mappings.splice(i, 1);
  45094. i--;
  45095. }
  45096. }
  45097. return {
  45098. platformId: potentialTable.platformId,
  45099. encodingId: potentialTable.encodingId,
  45100. mappings: mappings,
  45101. hasShortCmap: hasShortCmap
  45102. };
  45103. }
  45104. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  45105. if (!header) {
  45106. if (metrics) {
  45107. metrics.data = null;
  45108. }
  45109. return;
  45110. }
  45111. font.pos = (font.start ? font.start : 0) + header.offset;
  45112. font.pos += header.length - 2;
  45113. var numOfMetrics = font.getUint16();
  45114. if (numOfMetrics > numGlyphs) {
  45115. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  45116. numOfMetrics = numGlyphs;
  45117. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  45118. header.data[35] = numOfMetrics & 0x00ff;
  45119. }
  45120. var numOfSidebearings = numGlyphs - numOfMetrics;
  45121. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  45122. if (numMissing > 0) {
  45123. var entries = new Uint8Array(metrics.length + numMissing * 2);
  45124. entries.set(metrics.data);
  45125. metrics.data = entries;
  45126. }
  45127. }
  45128. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  45129. if (sourceEnd - sourceStart <= 12) {
  45130. return 0;
  45131. }
  45132. var glyf = source.subarray(sourceStart, sourceEnd);
  45133. var contoursCount = glyf[0] << 8 | glyf[1];
  45134. if (contoursCount & 0x8000) {
  45135. dest.set(glyf, destStart);
  45136. return glyf.length;
  45137. }
  45138. var i, j = 10, flagsCount = 0;
  45139. for (i = 0; i < contoursCount; i++) {
  45140. var endPoint = glyf[j] << 8 | glyf[j + 1];
  45141. flagsCount = endPoint + 1;
  45142. j += 2;
  45143. }
  45144. var instructionsStart = j;
  45145. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  45146. j += 2 + instructionsLength;
  45147. var instructionsEnd = j;
  45148. var coordinatesLength = 0;
  45149. for (i = 0; i < flagsCount; i++) {
  45150. var flag = glyf[j++];
  45151. if (flag & 0xC0) {
  45152. glyf[j - 1] = flag & 0x3F;
  45153. }
  45154. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  45155. coordinatesLength += xyLength;
  45156. if (flag & 8) {
  45157. var repeat = glyf[j++];
  45158. i += repeat;
  45159. coordinatesLength += repeat * xyLength;
  45160. }
  45161. }
  45162. if (coordinatesLength === 0) {
  45163. return 0;
  45164. }
  45165. var glyphDataLength = j + coordinatesLength;
  45166. if (glyphDataLength > glyf.length) {
  45167. return 0;
  45168. }
  45169. if (!hintsValid && instructionsLength > 0) {
  45170. dest.set(glyf.subarray(0, instructionsStart), destStart);
  45171. dest.set([
  45172. 0,
  45173. 0
  45174. ], destStart + instructionsStart);
  45175. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  45176. glyphDataLength -= instructionsLength;
  45177. if (glyf.length - glyphDataLength > 3) {
  45178. glyphDataLength = glyphDataLength + 3 & ~3;
  45179. }
  45180. return glyphDataLength;
  45181. }
  45182. if (glyf.length - glyphDataLength > 3) {
  45183. glyphDataLength = glyphDataLength + 3 & ~3;
  45184. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  45185. return glyphDataLength;
  45186. }
  45187. dest.set(glyf, destStart);
  45188. return glyf.length;
  45189. }
  45190. function sanitizeHead(head, numGlyphs, locaLength) {
  45191. var data = head.data;
  45192. var version = int32(data[0], data[1], data[2], data[3]);
  45193. if (version >> 16 !== 1) {
  45194. info('Attempting to fix invalid version in head table: ' + version);
  45195. data[0] = 0;
  45196. data[1] = 1;
  45197. data[2] = 0;
  45198. data[3] = 0;
  45199. }
  45200. var indexToLocFormat = int16(data[50], data[51]);
  45201. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  45202. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  45203. var numGlyphsPlusOne = numGlyphs + 1;
  45204. if (locaLength === numGlyphsPlusOne << 1) {
  45205. data[50] = 0;
  45206. data[51] = 0;
  45207. } else if (locaLength === numGlyphsPlusOne << 2) {
  45208. data[50] = 0;
  45209. data[51] = 1;
  45210. } else {
  45211. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  45212. }
  45213. }
  45214. }
  45215. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  45216. var itemSize, itemDecode, itemEncode;
  45217. if (isGlyphLocationsLong) {
  45218. itemSize = 4;
  45219. itemDecode = function fontItemDecodeLong(data, offset) {
  45220. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  45221. };
  45222. itemEncode = function fontItemEncodeLong(data, offset, value) {
  45223. data[offset] = value >>> 24 & 0xFF;
  45224. data[offset + 1] = value >> 16 & 0xFF;
  45225. data[offset + 2] = value >> 8 & 0xFF;
  45226. data[offset + 3] = value & 0xFF;
  45227. };
  45228. } else {
  45229. itemSize = 2;
  45230. itemDecode = function fontItemDecode(data, offset) {
  45231. return data[offset] << 9 | data[offset + 1] << 1;
  45232. };
  45233. itemEncode = function fontItemEncode(data, offset, value) {
  45234. data[offset] = value >> 9 & 0xFF;
  45235. data[offset + 1] = value >> 1 & 0xFF;
  45236. };
  45237. }
  45238. var locaData = loca.data;
  45239. var locaDataSize = itemSize * (1 + numGlyphs);
  45240. if (locaData.length !== locaDataSize) {
  45241. locaData = new Uint8Array(locaDataSize);
  45242. locaData.set(loca.data.subarray(0, locaDataSize));
  45243. loca.data = locaData;
  45244. }
  45245. var oldGlyfData = glyf.data;
  45246. var oldGlyfDataLength = oldGlyfData.length;
  45247. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  45248. var startOffset = itemDecode(locaData, 0);
  45249. var writeOffset = 0;
  45250. var missingGlyphData = Object.create(null);
  45251. itemEncode(locaData, 0, writeOffset);
  45252. var i, j;
  45253. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45254. var endOffset = itemDecode(locaData, j);
  45255. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  45256. endOffset = oldGlyfDataLength;
  45257. }
  45258. if (endOffset > oldGlyfDataLength) {
  45259. itemEncode(locaData, j, writeOffset);
  45260. startOffset = endOffset;
  45261. continue;
  45262. }
  45263. if (startOffset === endOffset) {
  45264. missingGlyphData[i] = true;
  45265. }
  45266. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  45267. writeOffset += newLength;
  45268. itemEncode(locaData, j, writeOffset);
  45269. startOffset = endOffset;
  45270. }
  45271. if (writeOffset === 0) {
  45272. var simpleGlyph = new Uint8Array([
  45273. 0,
  45274. 1,
  45275. 0,
  45276. 0,
  45277. 0,
  45278. 0,
  45279. 0,
  45280. 0,
  45281. 0,
  45282. 0,
  45283. 0,
  45284. 0,
  45285. 0,
  45286. 0,
  45287. 49,
  45288. 0
  45289. ]);
  45290. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45291. itemEncode(locaData, j, simpleGlyph.length);
  45292. }
  45293. glyf.data = simpleGlyph;
  45294. return missingGlyphData;
  45295. }
  45296. if (dupFirstEntry) {
  45297. var firstEntryLength = itemDecode(locaData, itemSize);
  45298. if (newGlyfData.length > firstEntryLength + writeOffset) {
  45299. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  45300. } else {
  45301. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  45302. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  45303. }
  45304. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  45305. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  45306. } else {
  45307. glyf.data = newGlyfData.subarray(0, writeOffset);
  45308. }
  45309. return missingGlyphData;
  45310. }
  45311. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  45312. var start = (font.start ? font.start : 0) + post.offset;
  45313. font.pos = start;
  45314. var length = post.length, end = start + length;
  45315. var version = font.getInt32();
  45316. font.getBytes(28);
  45317. var glyphNames;
  45318. var valid = true;
  45319. var i;
  45320. switch (version) {
  45321. case 0x00010000:
  45322. glyphNames = MacStandardGlyphOrdering;
  45323. break;
  45324. case 0x00020000:
  45325. var numGlyphs = font.getUint16();
  45326. if (numGlyphs !== maxpNumGlyphs) {
  45327. valid = false;
  45328. break;
  45329. }
  45330. var glyphNameIndexes = [];
  45331. for (i = 0; i < numGlyphs; ++i) {
  45332. var index = font.getUint16();
  45333. if (index >= 32768) {
  45334. valid = false;
  45335. break;
  45336. }
  45337. glyphNameIndexes.push(index);
  45338. }
  45339. if (!valid) {
  45340. break;
  45341. }
  45342. var customNames = [];
  45343. var strBuf = [];
  45344. while (font.pos < end) {
  45345. var stringLength = font.getByte();
  45346. strBuf.length = stringLength;
  45347. for (i = 0; i < stringLength; ++i) {
  45348. strBuf[i] = String.fromCharCode(font.getByte());
  45349. }
  45350. customNames.push(strBuf.join(''));
  45351. }
  45352. glyphNames = [];
  45353. for (i = 0; i < numGlyphs; ++i) {
  45354. var j = glyphNameIndexes[i];
  45355. if (j < 258) {
  45356. glyphNames.push(MacStandardGlyphOrdering[j]);
  45357. continue;
  45358. }
  45359. glyphNames.push(customNames[j - 258]);
  45360. }
  45361. break;
  45362. case 0x00030000:
  45363. break;
  45364. default:
  45365. warn('Unknown/unsupported post table version ' + version);
  45366. valid = false;
  45367. if (properties.defaultEncoding) {
  45368. glyphNames = properties.defaultEncoding;
  45369. }
  45370. break;
  45371. }
  45372. properties.glyphNames = glyphNames;
  45373. return valid;
  45374. }
  45375. function readNameTable(nameTable) {
  45376. var start = (font.start ? font.start : 0) + nameTable.offset;
  45377. font.pos = start;
  45378. var names = [
  45379. [],
  45380. []
  45381. ];
  45382. var length = nameTable.length, end = start + length;
  45383. var format = font.getUint16();
  45384. var FORMAT_0_HEADER_LENGTH = 6;
  45385. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  45386. return names;
  45387. }
  45388. var numRecords = font.getUint16();
  45389. var stringsStart = font.getUint16();
  45390. var records = [];
  45391. var NAME_RECORD_LENGTH = 12;
  45392. var i, ii;
  45393. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  45394. var r = {
  45395. platform: font.getUint16(),
  45396. encoding: font.getUint16(),
  45397. language: font.getUint16(),
  45398. name: font.getUint16(),
  45399. length: font.getUint16(),
  45400. offset: font.getUint16()
  45401. };
  45402. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  45403. records.push(r);
  45404. }
  45405. }
  45406. for (i = 0, ii = records.length; i < ii; i++) {
  45407. var record = records[i];
  45408. if (record.length <= 0) {
  45409. continue;
  45410. }
  45411. var pos = start + stringsStart + record.offset;
  45412. if (pos + record.length > end) {
  45413. continue;
  45414. }
  45415. font.pos = pos;
  45416. var nameIndex = record.name;
  45417. if (record.encoding) {
  45418. var str = '';
  45419. for (var j = 0, jj = record.length; j < jj; j += 2) {
  45420. str += String.fromCharCode(font.getUint16());
  45421. }
  45422. names[1][nameIndex] = str;
  45423. } else {
  45424. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  45425. }
  45426. }
  45427. return names;
  45428. }
  45429. var TTOpsStackDeltas = [
  45430. 0,
  45431. 0,
  45432. 0,
  45433. 0,
  45434. 0,
  45435. 0,
  45436. 0,
  45437. 0,
  45438. -2,
  45439. -2,
  45440. -2,
  45441. -2,
  45442. 0,
  45443. 0,
  45444. -2,
  45445. -5,
  45446. -1,
  45447. -1,
  45448. -1,
  45449. -1,
  45450. -1,
  45451. -1,
  45452. -1,
  45453. -1,
  45454. 0,
  45455. 0,
  45456. -1,
  45457. 0,
  45458. -1,
  45459. -1,
  45460. -1,
  45461. -1,
  45462. 1,
  45463. -1,
  45464. -999,
  45465. 0,
  45466. 1,
  45467. 0,
  45468. -1,
  45469. -2,
  45470. 0,
  45471. -1,
  45472. -2,
  45473. -1,
  45474. -1,
  45475. 0,
  45476. -1,
  45477. -1,
  45478. 0,
  45479. 0,
  45480. -999,
  45481. -999,
  45482. -1,
  45483. -1,
  45484. -1,
  45485. -1,
  45486. -2,
  45487. -999,
  45488. -2,
  45489. -2,
  45490. -999,
  45491. 0,
  45492. -2,
  45493. -2,
  45494. 0,
  45495. 0,
  45496. -2,
  45497. 0,
  45498. -2,
  45499. 0,
  45500. 0,
  45501. 0,
  45502. -2,
  45503. -1,
  45504. -1,
  45505. 1,
  45506. 1,
  45507. 0,
  45508. 0,
  45509. -1,
  45510. -1,
  45511. -1,
  45512. -1,
  45513. -1,
  45514. -1,
  45515. -1,
  45516. 0,
  45517. 0,
  45518. -1,
  45519. 0,
  45520. -1,
  45521. -1,
  45522. 0,
  45523. -999,
  45524. -1,
  45525. -1,
  45526. -1,
  45527. -1,
  45528. -1,
  45529. -1,
  45530. 0,
  45531. 0,
  45532. 0,
  45533. 0,
  45534. 0,
  45535. 0,
  45536. 0,
  45537. 0,
  45538. 0,
  45539. 0,
  45540. 0,
  45541. 0,
  45542. -2,
  45543. -999,
  45544. -999,
  45545. -999,
  45546. -999,
  45547. -999,
  45548. -1,
  45549. -1,
  45550. -2,
  45551. -2,
  45552. 0,
  45553. 0,
  45554. 0,
  45555. 0,
  45556. -1,
  45557. -1,
  45558. -999,
  45559. -2,
  45560. -2,
  45561. 0,
  45562. 0,
  45563. -1,
  45564. -2,
  45565. -2,
  45566. 0,
  45567. 0,
  45568. 0,
  45569. -1,
  45570. -1,
  45571. -1,
  45572. -2
  45573. ];
  45574. function sanitizeTTProgram(table, ttContext) {
  45575. var data = table.data;
  45576. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  45577. var stack = [];
  45578. var callstack = [];
  45579. var functionsCalled = [];
  45580. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  45581. var inFDEF = false, ifLevel = 0, inELSE = 0;
  45582. for (var ii = data.length; i < ii;) {
  45583. var op = data[i++];
  45584. if (op === 0x40) {
  45585. n = data[i++];
  45586. if (inFDEF || inELSE) {
  45587. i += n;
  45588. } else {
  45589. for (j = 0; j < n; j++) {
  45590. stack.push(data[i++]);
  45591. }
  45592. }
  45593. } else if (op === 0x41) {
  45594. n = data[i++];
  45595. if (inFDEF || inELSE) {
  45596. i += n * 2;
  45597. } else {
  45598. for (j = 0; j < n; j++) {
  45599. b = data[i++];
  45600. stack.push(b << 8 | data[i++]);
  45601. }
  45602. }
  45603. } else if ((op & 0xF8) === 0xB0) {
  45604. n = op - 0xB0 + 1;
  45605. if (inFDEF || inELSE) {
  45606. i += n;
  45607. } else {
  45608. for (j = 0; j < n; j++) {
  45609. stack.push(data[i++]);
  45610. }
  45611. }
  45612. } else if ((op & 0xF8) === 0xB8) {
  45613. n = op - 0xB8 + 1;
  45614. if (inFDEF || inELSE) {
  45615. i += n * 2;
  45616. } else {
  45617. for (j = 0; j < n; j++) {
  45618. b = data[i++];
  45619. stack.push(b << 8 | data[i++]);
  45620. }
  45621. }
  45622. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  45623. if (!inFDEF && !inELSE) {
  45624. funcId = stack[stack.length - 1];
  45625. ttContext.functionsUsed[funcId] = true;
  45626. if (funcId in ttContext.functionsStackDeltas) {
  45627. stack.length += ttContext.functionsStackDeltas[funcId];
  45628. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  45629. callstack.push({
  45630. data: data,
  45631. i: i,
  45632. stackTop: stack.length - 1
  45633. });
  45634. functionsCalled.push(funcId);
  45635. pc = ttContext.functionsDefined[funcId];
  45636. if (!pc) {
  45637. warn('TT: CALL non-existent function');
  45638. ttContext.hintsValid = false;
  45639. return;
  45640. }
  45641. data = pc.data;
  45642. i = pc.i;
  45643. }
  45644. }
  45645. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  45646. if (inFDEF || inELSE) {
  45647. warn('TT: nested FDEFs not allowed');
  45648. tooComplexToFollowFunctions = true;
  45649. }
  45650. inFDEF = true;
  45651. lastDeff = i;
  45652. funcId = stack.pop();
  45653. ttContext.functionsDefined[funcId] = {
  45654. data: data,
  45655. i: i
  45656. };
  45657. } else if (op === 0x2D) {
  45658. if (inFDEF) {
  45659. inFDEF = false;
  45660. lastEndf = i;
  45661. } else {
  45662. pc = callstack.pop();
  45663. if (!pc) {
  45664. warn('TT: ENDF bad stack');
  45665. ttContext.hintsValid = false;
  45666. return;
  45667. }
  45668. funcId = functionsCalled.pop();
  45669. data = pc.data;
  45670. i = pc.i;
  45671. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  45672. }
  45673. } else if (op === 0x89) {
  45674. if (inFDEF || inELSE) {
  45675. warn('TT: nested IDEFs not allowed');
  45676. tooComplexToFollowFunctions = true;
  45677. }
  45678. inFDEF = true;
  45679. lastDeff = i;
  45680. } else if (op === 0x58) {
  45681. ++ifLevel;
  45682. } else if (op === 0x1B) {
  45683. inELSE = ifLevel;
  45684. } else if (op === 0x59) {
  45685. if (inELSE === ifLevel) {
  45686. inELSE = 0;
  45687. }
  45688. --ifLevel;
  45689. } else if (op === 0x1C) {
  45690. if (!inFDEF && !inELSE) {
  45691. var offset = stack[stack.length - 1];
  45692. if (offset > 0) {
  45693. i += offset - 1;
  45694. }
  45695. }
  45696. }
  45697. if (!inFDEF && !inELSE) {
  45698. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  45699. if (op >= 0x71 && op <= 0x75) {
  45700. n = stack.pop();
  45701. if (!isNaN(n)) {
  45702. stackDelta = -n * 2;
  45703. }
  45704. }
  45705. while (stackDelta < 0 && stack.length > 0) {
  45706. stack.pop();
  45707. stackDelta++;
  45708. }
  45709. while (stackDelta > 0) {
  45710. stack.push(NaN);
  45711. stackDelta--;
  45712. }
  45713. }
  45714. }
  45715. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  45716. var content = [data];
  45717. if (i > data.length) {
  45718. content.push(new Uint8Array(i - data.length));
  45719. }
  45720. if (lastDeff > lastEndf) {
  45721. warn('TT: complementing a missing function tail');
  45722. content.push(new Uint8Array([
  45723. 0x22,
  45724. 0x2D
  45725. ]));
  45726. }
  45727. foldTTTable(table, content);
  45728. }
  45729. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  45730. if (ttContext.tooComplexToFollowFunctions) {
  45731. return;
  45732. }
  45733. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  45734. warn('TT: more functions defined than expected');
  45735. ttContext.hintsValid = false;
  45736. return;
  45737. }
  45738. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  45739. if (j > maxFunctionDefs) {
  45740. warn('TT: invalid function id: ' + j);
  45741. ttContext.hintsValid = false;
  45742. return;
  45743. }
  45744. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  45745. warn('TT: undefined function: ' + j);
  45746. ttContext.hintsValid = false;
  45747. return;
  45748. }
  45749. }
  45750. }
  45751. function foldTTTable(table, content) {
  45752. if (content.length > 1) {
  45753. var newLength = 0;
  45754. var j, jj;
  45755. for (j = 0, jj = content.length; j < jj; j++) {
  45756. newLength += content[j].length;
  45757. }
  45758. newLength = newLength + 3 & ~3;
  45759. var result = new Uint8Array(newLength);
  45760. var pos = 0;
  45761. for (j = 0, jj = content.length; j < jj; j++) {
  45762. result.set(content[j], pos);
  45763. pos += content[j].length;
  45764. }
  45765. table.data = result;
  45766. table.length = newLength;
  45767. }
  45768. }
  45769. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  45770. var ttContext = {
  45771. functionsDefined: [],
  45772. functionsUsed: [],
  45773. functionsStackDeltas: [],
  45774. tooComplexToFollowFunctions: false,
  45775. hintsValid: true
  45776. };
  45777. if (fpgm) {
  45778. sanitizeTTProgram(fpgm, ttContext);
  45779. }
  45780. if (prep) {
  45781. sanitizeTTProgram(prep, ttContext);
  45782. }
  45783. if (fpgm) {
  45784. checkInvalidFunctions(ttContext, maxFunctionDefs);
  45785. }
  45786. if (cvt && cvt.length & 1) {
  45787. var cvtData = new Uint8Array(cvt.length + 1);
  45788. cvtData.set(cvt.data);
  45789. cvt.data = cvtData;
  45790. }
  45791. return ttContext.hintsValid;
  45792. }
  45793. font = new Stream(new Uint8Array(font.getBytes()));
  45794. var VALID_TABLES = [
  45795. 'OS/2',
  45796. 'cmap',
  45797. 'head',
  45798. 'hhea',
  45799. 'hmtx',
  45800. 'maxp',
  45801. 'name',
  45802. 'post',
  45803. 'loca',
  45804. 'glyf',
  45805. 'fpgm',
  45806. 'prep',
  45807. 'cvt ',
  45808. 'CFF '
  45809. ];
  45810. var header = readOpenTypeHeader(font);
  45811. var numTables = header.numTables;
  45812. var cff, cffFile;
  45813. var tables = Object.create(null);
  45814. tables['OS/2'] = null;
  45815. tables['cmap'] = null;
  45816. tables['head'] = null;
  45817. tables['hhea'] = null;
  45818. tables['hmtx'] = null;
  45819. tables['maxp'] = null;
  45820. tables['name'] = null;
  45821. tables['post'] = null;
  45822. var table;
  45823. for (var i = 0; i < numTables; i++) {
  45824. table = readTableEntry(font);
  45825. if (VALID_TABLES.indexOf(table.tag) < 0) {
  45826. continue;
  45827. }
  45828. if (table.length === 0) {
  45829. continue;
  45830. }
  45831. tables[table.tag] = table;
  45832. }
  45833. var isTrueType = !tables['CFF '];
  45834. if (!isTrueType) {
  45835. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  45836. cffFile = new Stream(tables['CFF '].data);
  45837. cff = new CFFFont(cffFile, properties);
  45838. adjustWidths(properties);
  45839. return this.convert(name, cff, properties);
  45840. }
  45841. delete tables['glyf'];
  45842. delete tables['loca'];
  45843. delete tables['fpgm'];
  45844. delete tables['prep'];
  45845. delete tables['cvt '];
  45846. this.isOpenType = true;
  45847. } else {
  45848. if (!tables['loca']) {
  45849. error('Required "loca" table is not found');
  45850. }
  45851. if (!tables['glyf']) {
  45852. warn('Required "glyf" table is not found -- trying to recover.');
  45853. tables['glyf'] = {
  45854. tag: 'glyf',
  45855. data: new Uint8Array(0)
  45856. };
  45857. }
  45858. this.isOpenType = false;
  45859. }
  45860. if (!tables['maxp']) {
  45861. error('Required "maxp" table is not found');
  45862. }
  45863. font.pos = (font.start || 0) + tables['maxp'].offset;
  45864. var version = font.getInt32();
  45865. var numGlyphs = font.getUint16();
  45866. var maxFunctionDefs = 0;
  45867. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  45868. font.pos += 8;
  45869. var maxZones = font.getUint16();
  45870. if (maxZones > 2) {
  45871. tables['maxp'].data[14] = 0;
  45872. tables['maxp'].data[15] = 2;
  45873. }
  45874. font.pos += 4;
  45875. maxFunctionDefs = font.getUint16();
  45876. }
  45877. var dupFirstEntry = false;
  45878. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  45879. dupFirstEntry = true;
  45880. numGlyphs++;
  45881. tables['maxp'].data[4] = numGlyphs >> 8;
  45882. tables['maxp'].data[5] = numGlyphs & 255;
  45883. }
  45884. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  45885. if (!hintsValid) {
  45886. delete tables['fpgm'];
  45887. delete tables['prep'];
  45888. delete tables['cvt '];
  45889. }
  45890. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  45891. if (!tables['head']) {
  45892. error('Required "head" table is not found');
  45893. }
  45894. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  45895. var missingGlyphs = Object.create(null);
  45896. if (isTrueType) {
  45897. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  45898. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  45899. }
  45900. if (!tables['hhea']) {
  45901. error('Required "hhea" table is not found');
  45902. }
  45903. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  45904. tables['hhea'].data[10] = 0xFF;
  45905. tables['hhea'].data[11] = 0xFF;
  45906. }
  45907. var metricsOverride = {
  45908. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  45909. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  45910. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  45911. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  45912. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  45913. };
  45914. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  45915. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  45916. if (tables['post']) {
  45917. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  45918. if (!valid) {
  45919. tables['post'] = null;
  45920. }
  45921. }
  45922. var charCodeToGlyphId = [], charCode;
  45923. var toUnicode = properties.toUnicode, widths = properties.widths;
  45924. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  45925. function hasGlyph(glyphId, charCode, widthCode) {
  45926. if (!missingGlyphs[glyphId]) {
  45927. return true;
  45928. }
  45929. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  45930. return true;
  45931. }
  45932. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  45933. return true;
  45934. }
  45935. return false;
  45936. }
  45937. if (properties.composite) {
  45938. var cidToGidMap = properties.cidToGidMap || [];
  45939. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  45940. properties.cMap.forEach(function (charCode, cid) {
  45941. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  45942. var glyphId = -1;
  45943. if (isCidToGidMapEmpty) {
  45944. glyphId = cid;
  45945. } else if (cidToGidMap[cid] !== undefined) {
  45946. glyphId = cidToGidMap[cid];
  45947. }
  45948. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  45949. charCodeToGlyphId[charCode] = glyphId;
  45950. }
  45951. });
  45952. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  45953. charCodeToGlyphId[0] = numGlyphs - 1;
  45954. }
  45955. } else {
  45956. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  45957. var cmapPlatformId = cmapTable.platformId;
  45958. var cmapEncodingId = cmapTable.encodingId;
  45959. var cmapMappings = cmapTable.mappings;
  45960. var cmapMappingsLength = cmapMappings.length;
  45961. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  45962. var baseEncoding = [];
  45963. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  45964. baseEncoding = getEncoding(properties.baseEncodingName);
  45965. }
  45966. var glyphsUnicodeMap = getGlyphsUnicode();
  45967. for (charCode = 0; charCode < 256; charCode++) {
  45968. var glyphName, standardGlyphName;
  45969. if (this.differences && charCode in this.differences) {
  45970. glyphName = this.differences[charCode];
  45971. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  45972. glyphName = baseEncoding[charCode];
  45973. } else {
  45974. glyphName = StandardEncoding[charCode];
  45975. }
  45976. if (!glyphName) {
  45977. continue;
  45978. }
  45979. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45980. var unicodeOrCharCode, isUnicode = false;
  45981. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  45982. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  45983. isUnicode = true;
  45984. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  45985. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  45986. }
  45987. var found = false;
  45988. for (i = 0; i < cmapMappingsLength; ++i) {
  45989. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  45990. continue;
  45991. }
  45992. var code = isUnicode ? charCode : unicodeOrCharCode;
  45993. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  45994. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45995. found = true;
  45996. break;
  45997. }
  45998. }
  45999. if (!found && properties.glyphNames) {
  46000. var glyphId = properties.glyphNames.indexOf(glyphName);
  46001. if (glyphId === -1 && standardGlyphName !== glyphName) {
  46002. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  46003. }
  46004. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  46005. charCodeToGlyphId[charCode] = glyphId;
  46006. found = true;
  46007. }
  46008. }
  46009. if (!found) {
  46010. charCodeToGlyphId[charCode] = 0;
  46011. }
  46012. }
  46013. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  46014. for (i = 0; i < cmapMappingsLength; ++i) {
  46015. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  46016. }
  46017. } else {
  46018. for (i = 0; i < cmapMappingsLength; ++i) {
  46019. charCode = cmapMappings[i].charCode & 0xFF;
  46020. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  46021. }
  46022. }
  46023. }
  46024. if (charCodeToGlyphId.length === 0) {
  46025. charCodeToGlyphId[0] = 0;
  46026. }
  46027. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  46028. this.toFontChar = newMapping.toFontChar;
  46029. tables['cmap'] = {
  46030. tag: 'cmap',
  46031. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  46032. };
  46033. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  46034. tables['OS/2'] = {
  46035. tag: 'OS/2',
  46036. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  46037. };
  46038. }
  46039. if (!tables['post']) {
  46040. tables['post'] = {
  46041. tag: 'post',
  46042. data: createPostTable(properties)
  46043. };
  46044. }
  46045. if (!isTrueType) {
  46046. try {
  46047. cffFile = new Stream(tables['CFF '].data);
  46048. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  46049. cff = parser.parse();
  46050. var compiler = new CFFCompiler(cff);
  46051. tables['CFF '].data = compiler.compile();
  46052. } catch (e) {
  46053. warn('Failed to compile font ' + properties.loadedName);
  46054. }
  46055. }
  46056. if (!tables['name']) {
  46057. tables['name'] = {
  46058. tag: 'name',
  46059. data: createNameTable(this.name)
  46060. };
  46061. } else {
  46062. var namePrototype = readNameTable(tables['name']);
  46063. tables['name'].data = createNameTable(name, namePrototype);
  46064. }
  46065. var builder = new OpenTypeFileBuilder(header.version);
  46066. for (var tableTag in tables) {
  46067. builder.addTable(tableTag, tables[tableTag].data);
  46068. }
  46069. return builder.toArray();
  46070. },
  46071. convert: function Font_convert(fontName, font, properties) {
  46072. properties.fixedPitch = false;
  46073. if (properties.builtInEncoding) {
  46074. adjustToUnicode(properties, properties.builtInEncoding);
  46075. }
  46076. var mapping = font.getGlyphMapping(properties);
  46077. var newMapping = adjustMapping(mapping, properties);
  46078. this.toFontChar = newMapping.toFontChar;
  46079. var numGlyphs = font.numGlyphs;
  46080. function getCharCodes(charCodeToGlyphId, glyphId) {
  46081. var charCodes = null;
  46082. for (var charCode in charCodeToGlyphId) {
  46083. if (glyphId === charCodeToGlyphId[charCode]) {
  46084. if (!charCodes) {
  46085. charCodes = [];
  46086. }
  46087. charCodes.push(charCode | 0);
  46088. }
  46089. }
  46090. return charCodes;
  46091. }
  46092. function createCharCode(charCodeToGlyphId, glyphId) {
  46093. for (var charCode in charCodeToGlyphId) {
  46094. if (glyphId === charCodeToGlyphId[charCode]) {
  46095. return charCode | 0;
  46096. }
  46097. }
  46098. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  46099. return newMapping.nextAvailableFontCharCode++;
  46100. }
  46101. var seacs = font.seacs;
  46102. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  46103. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  46104. var charset = font.getCharset();
  46105. var seacMap = Object.create(null);
  46106. for (var glyphId in seacs) {
  46107. glyphId |= 0;
  46108. var seac = seacs[glyphId];
  46109. var baseGlyphName = StandardEncoding[seac[2]];
  46110. var accentGlyphName = StandardEncoding[seac[3]];
  46111. var baseGlyphId = charset.indexOf(baseGlyphName);
  46112. var accentGlyphId = charset.indexOf(accentGlyphName);
  46113. if (baseGlyphId < 0 || accentGlyphId < 0) {
  46114. continue;
  46115. }
  46116. var accentOffset = {
  46117. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  46118. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  46119. };
  46120. var charCodes = getCharCodes(mapping, glyphId);
  46121. if (!charCodes) {
  46122. continue;
  46123. }
  46124. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  46125. var charCode = charCodes[i];
  46126. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  46127. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  46128. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  46129. seacMap[charCode] = {
  46130. baseFontCharCode: baseFontCharCode,
  46131. accentFontCharCode: accentFontCharCode,
  46132. accentOffset: accentOffset
  46133. };
  46134. }
  46135. }
  46136. properties.seacMap = seacMap;
  46137. }
  46138. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  46139. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  46140. builder.addTable('CFF ', font.data);
  46141. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  46142. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  46143. 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');
  46144. 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));
  46145. builder.addTable('hmtx', function fontFieldsHmtx() {
  46146. var charstrings = font.charstrings;
  46147. var cffWidths = font.cff ? font.cff.widths : null;
  46148. var hmtx = '\x00\x00\x00\x00';
  46149. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  46150. var width = 0;
  46151. if (charstrings) {
  46152. var charstring = charstrings[i - 1];
  46153. width = 'width' in charstring ? charstring.width : 0;
  46154. } else if (cffWidths) {
  46155. width = Math.ceil(cffWidths[i] || 0);
  46156. }
  46157. hmtx += string16(width) + string16(0);
  46158. }
  46159. return hmtx;
  46160. }());
  46161. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  46162. builder.addTable('name', createNameTable(fontName));
  46163. builder.addTable('post', createPostTable(properties));
  46164. return builder.toArray();
  46165. },
  46166. get spaceWidth() {
  46167. if ('_shadowWidth' in this) {
  46168. return this._shadowWidth;
  46169. }
  46170. var possibleSpaceReplacements = [
  46171. 'space',
  46172. 'minus',
  46173. 'one',
  46174. 'i',
  46175. 'I'
  46176. ];
  46177. var width;
  46178. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  46179. var glyphName = possibleSpaceReplacements[i];
  46180. if (glyphName in this.widths) {
  46181. width = this.widths[glyphName];
  46182. break;
  46183. }
  46184. var glyphsUnicodeMap = getGlyphsUnicode();
  46185. var glyphUnicode = glyphsUnicodeMap[glyphName];
  46186. var charcode = 0;
  46187. if (this.composite) {
  46188. if (this.cMap.contains(glyphUnicode)) {
  46189. charcode = this.cMap.lookup(glyphUnicode);
  46190. }
  46191. }
  46192. if (!charcode && this.toUnicode) {
  46193. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  46194. }
  46195. if (charcode <= 0) {
  46196. charcode = glyphUnicode;
  46197. }
  46198. width = this.widths[charcode];
  46199. if (width) {
  46200. break;
  46201. }
  46202. }
  46203. width = width || this.defaultWidth;
  46204. this._shadowWidth = width;
  46205. return width;
  46206. },
  46207. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  46208. var fontCharCode, width, operatorListId;
  46209. var widthCode = charcode;
  46210. if (this.cMap && this.cMap.contains(charcode)) {
  46211. widthCode = this.cMap.lookup(charcode);
  46212. }
  46213. width = this.widths[widthCode];
  46214. width = isNum(width) ? width : this.defaultWidth;
  46215. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  46216. var unicode = this.toUnicode.get(charcode) || charcode;
  46217. if (typeof unicode === 'number') {
  46218. unicode = String.fromCharCode(unicode);
  46219. }
  46220. var isInFont = charcode in this.toFontChar;
  46221. fontCharCode = this.toFontChar[charcode] || charcode;
  46222. if (this.missingFile) {
  46223. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  46224. }
  46225. if (this.isType3Font) {
  46226. operatorListId = fontCharCode;
  46227. }
  46228. var accent = null;
  46229. if (this.seacMap && this.seacMap[charcode]) {
  46230. isInFont = true;
  46231. var seac = this.seacMap[charcode];
  46232. fontCharCode = seac.baseFontCharCode;
  46233. accent = {
  46234. fontChar: String.fromCharCode(seac.accentFontCharCode),
  46235. offset: seac.accentOffset
  46236. };
  46237. }
  46238. var fontChar = String.fromCharCode(fontCharCode);
  46239. var glyph = this.glyphCache[charcode];
  46240. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  46241. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  46242. this.glyphCache[charcode] = glyph;
  46243. }
  46244. return glyph;
  46245. },
  46246. charsToGlyphs: function Font_charsToGlyphs(chars) {
  46247. var charsCache = this.charsCache;
  46248. var glyphs, glyph, charcode;
  46249. if (charsCache) {
  46250. glyphs = charsCache[chars];
  46251. if (glyphs) {
  46252. return glyphs;
  46253. }
  46254. }
  46255. if (!charsCache) {
  46256. charsCache = this.charsCache = Object.create(null);
  46257. }
  46258. glyphs = [];
  46259. var charsCacheKey = chars;
  46260. var i = 0, ii;
  46261. if (this.cMap) {
  46262. var c = Object.create(null);
  46263. while (i < chars.length) {
  46264. this.cMap.readCharCode(chars, i, c);
  46265. charcode = c.charcode;
  46266. var length = c.length;
  46267. i += length;
  46268. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  46269. glyph = this.charToGlyph(charcode, isSpace);
  46270. glyphs.push(glyph);
  46271. }
  46272. } else {
  46273. for (i = 0, ii = chars.length; i < ii; ++i) {
  46274. charcode = chars.charCodeAt(i);
  46275. glyph = this.charToGlyph(charcode, charcode === 0x20);
  46276. glyphs.push(glyph);
  46277. }
  46278. }
  46279. return charsCache[charsCacheKey] = glyphs;
  46280. }
  46281. };
  46282. return Font;
  46283. }();
  46284. var ErrorFont = function ErrorFontClosure() {
  46285. function ErrorFont(error) {
  46286. this.error = error;
  46287. this.loadedName = 'g_font_error';
  46288. this.loading = false;
  46289. }
  46290. ErrorFont.prototype = {
  46291. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  46292. return [];
  46293. },
  46294. exportData: function ErrorFont_exportData() {
  46295. return { error: this.error };
  46296. }
  46297. };
  46298. return ErrorFont;
  46299. }();
  46300. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  46301. var charCodeToGlyphId = Object.create(null);
  46302. var glyphId, charCode, baseEncoding;
  46303. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  46304. if (properties.baseEncodingName) {
  46305. baseEncoding = getEncoding(properties.baseEncodingName);
  46306. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46307. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46308. if (glyphId >= 0) {
  46309. charCodeToGlyphId[charCode] = glyphId;
  46310. } else {
  46311. charCodeToGlyphId[charCode] = 0;
  46312. }
  46313. }
  46314. } else if (isSymbolicFont) {
  46315. for (charCode in builtInEncoding) {
  46316. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  46317. }
  46318. } else {
  46319. baseEncoding = StandardEncoding;
  46320. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46321. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46322. if (glyphId >= 0) {
  46323. charCodeToGlyphId[charCode] = glyphId;
  46324. } else {
  46325. charCodeToGlyphId[charCode] = 0;
  46326. }
  46327. }
  46328. }
  46329. var differences = properties.differences, glyphsUnicodeMap;
  46330. if (differences) {
  46331. for (charCode in differences) {
  46332. var glyphName = differences[charCode];
  46333. glyphId = glyphNames.indexOf(glyphName);
  46334. if (glyphId === -1) {
  46335. if (!glyphsUnicodeMap) {
  46336. glyphsUnicodeMap = getGlyphsUnicode();
  46337. }
  46338. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  46339. if (standardGlyphName !== glyphName) {
  46340. glyphId = glyphNames.indexOf(standardGlyphName);
  46341. }
  46342. }
  46343. if (glyphId >= 0) {
  46344. charCodeToGlyphId[charCode] = glyphId;
  46345. } else {
  46346. charCodeToGlyphId[charCode] = 0;
  46347. }
  46348. }
  46349. }
  46350. return charCodeToGlyphId;
  46351. }
  46352. var Type1Font = function Type1FontClosure() {
  46353. function findBlock(streamBytes, signature, startIndex) {
  46354. var streamBytesLength = streamBytes.length;
  46355. var signatureLength = signature.length;
  46356. var scanLength = streamBytesLength - signatureLength;
  46357. var i = startIndex, j, found = false;
  46358. while (i < scanLength) {
  46359. j = 0;
  46360. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  46361. j++;
  46362. }
  46363. if (j >= signatureLength) {
  46364. i += j;
  46365. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  46366. i++;
  46367. }
  46368. found = true;
  46369. break;
  46370. }
  46371. i++;
  46372. }
  46373. return {
  46374. found: found,
  46375. length: i
  46376. };
  46377. }
  46378. function getHeaderBlock(stream, suggestedLength) {
  46379. var EEXEC_SIGNATURE = [
  46380. 0x65,
  46381. 0x65,
  46382. 0x78,
  46383. 0x65,
  46384. 0x63
  46385. ];
  46386. var streamStartPos = stream.pos;
  46387. var headerBytes, headerBytesLength, block;
  46388. try {
  46389. headerBytes = stream.getBytes(suggestedLength);
  46390. headerBytesLength = headerBytes.length;
  46391. } catch (ex) {
  46392. if (ex instanceof MissingDataException) {
  46393. throw ex;
  46394. }
  46395. }
  46396. if (headerBytesLength === suggestedLength) {
  46397. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  46398. if (block.found && block.length === suggestedLength) {
  46399. return {
  46400. stream: new Stream(headerBytes),
  46401. length: suggestedLength
  46402. };
  46403. }
  46404. }
  46405. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  46406. stream.pos = streamStartPos;
  46407. var SCAN_BLOCK_LENGTH = 2048;
  46408. var actualLength;
  46409. while (true) {
  46410. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  46411. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  46412. if (block.length === 0) {
  46413. break;
  46414. }
  46415. stream.pos += block.length;
  46416. if (block.found) {
  46417. actualLength = stream.pos - streamStartPos;
  46418. break;
  46419. }
  46420. }
  46421. stream.pos = streamStartPos;
  46422. if (actualLength) {
  46423. return {
  46424. stream: new Stream(stream.getBytes(actualLength)),
  46425. length: actualLength
  46426. };
  46427. }
  46428. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  46429. return {
  46430. stream: new Stream(stream.getBytes(suggestedLength)),
  46431. length: suggestedLength
  46432. };
  46433. }
  46434. function getEexecBlock(stream, suggestedLength) {
  46435. var eexecBytes = stream.getBytes();
  46436. return {
  46437. stream: new Stream(eexecBytes),
  46438. length: eexecBytes.length
  46439. };
  46440. }
  46441. function Type1Font(name, file, properties) {
  46442. var PFB_HEADER_SIZE = 6;
  46443. var headerBlockLength = properties.length1;
  46444. var eexecBlockLength = properties.length2;
  46445. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  46446. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  46447. if (pfbHeaderPresent) {
  46448. file.skip(PFB_HEADER_SIZE);
  46449. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46450. }
  46451. var headerBlock = getHeaderBlock(file, headerBlockLength);
  46452. headerBlockLength = headerBlock.length;
  46453. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  46454. headerBlockParser.extractFontHeader(properties);
  46455. if (pfbHeaderPresent) {
  46456. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  46457. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46458. }
  46459. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  46460. eexecBlockLength = eexecBlock.length;
  46461. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  46462. var data = eexecBlockParser.extractFontProgram();
  46463. for (var info in data.properties) {
  46464. properties[info] = data.properties[info];
  46465. }
  46466. var charstrings = data.charstrings;
  46467. var type2Charstrings = this.getType2Charstrings(charstrings);
  46468. var subrs = this.getType2Subrs(data.subrs);
  46469. this.charstrings = charstrings;
  46470. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  46471. this.seacs = this.getSeacs(data.charstrings);
  46472. }
  46473. Type1Font.prototype = {
  46474. get numGlyphs() {
  46475. return this.charstrings.length + 1;
  46476. },
  46477. getCharset: function Type1Font_getCharset() {
  46478. var charset = ['.notdef'];
  46479. var charstrings = this.charstrings;
  46480. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46481. charset.push(charstrings[glyphId].glyphName);
  46482. }
  46483. return charset;
  46484. },
  46485. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  46486. var charstrings = this.charstrings;
  46487. var glyphNames = ['.notdef'], glyphId;
  46488. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46489. glyphNames.push(charstrings[glyphId].glyphName);
  46490. }
  46491. var encoding = properties.builtInEncoding;
  46492. if (encoding) {
  46493. var builtInEncoding = Object.create(null);
  46494. for (var charCode in encoding) {
  46495. glyphId = glyphNames.indexOf(encoding[charCode]);
  46496. if (glyphId >= 0) {
  46497. builtInEncoding[charCode] = glyphId;
  46498. }
  46499. }
  46500. }
  46501. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  46502. },
  46503. getSeacs: function Type1Font_getSeacs(charstrings) {
  46504. var i, ii;
  46505. var seacMap = [];
  46506. for (i = 0, ii = charstrings.length; i < ii; i++) {
  46507. var charstring = charstrings[i];
  46508. if (charstring.seac) {
  46509. seacMap[i + 1] = charstring.seac;
  46510. }
  46511. }
  46512. return seacMap;
  46513. },
  46514. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  46515. var type2Charstrings = [];
  46516. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  46517. type2Charstrings.push(type1Charstrings[i].charstring);
  46518. }
  46519. return type2Charstrings;
  46520. },
  46521. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  46522. var bias = 0;
  46523. var count = type1Subrs.length;
  46524. if (count < 1133) {
  46525. bias = 107;
  46526. } else if (count < 33769) {
  46527. bias = 1131;
  46528. } else {
  46529. bias = 32768;
  46530. }
  46531. var type2Subrs = [];
  46532. var i;
  46533. for (i = 0; i < bias; i++) {
  46534. type2Subrs.push([0x0B]);
  46535. }
  46536. for (i = 0; i < count; i++) {
  46537. type2Subrs.push(type1Subrs[i]);
  46538. }
  46539. return type2Subrs;
  46540. },
  46541. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  46542. var cff = new CFF();
  46543. cff.header = new CFFHeader(1, 0, 4, 4);
  46544. cff.names = [name];
  46545. var topDict = new CFFTopDict();
  46546. topDict.setByName('version', 391);
  46547. topDict.setByName('Notice', 392);
  46548. topDict.setByName('FullName', 393);
  46549. topDict.setByName('FamilyName', 394);
  46550. topDict.setByName('Weight', 395);
  46551. topDict.setByName('Encoding', null);
  46552. topDict.setByName('FontMatrix', properties.fontMatrix);
  46553. topDict.setByName('FontBBox', properties.bbox);
  46554. topDict.setByName('charset', null);
  46555. topDict.setByName('CharStrings', null);
  46556. topDict.setByName('Private', null);
  46557. cff.topDict = topDict;
  46558. var strings = new CFFStrings();
  46559. strings.add('Version 0.11');
  46560. strings.add('See original notice');
  46561. strings.add(name);
  46562. strings.add(name);
  46563. strings.add('Medium');
  46564. cff.strings = strings;
  46565. cff.globalSubrIndex = new CFFIndex();
  46566. var count = glyphs.length;
  46567. var charsetArray = [0];
  46568. var i, ii;
  46569. for (i = 0; i < count; i++) {
  46570. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  46571. if (index === -1) {
  46572. index = 0;
  46573. }
  46574. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  46575. }
  46576. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  46577. var charStringsIndex = new CFFIndex();
  46578. charStringsIndex.add([
  46579. 0x8B,
  46580. 0x0E
  46581. ]);
  46582. for (i = 0; i < count; i++) {
  46583. var glyph = glyphs[i];
  46584. if (glyph.length === 0) {
  46585. charStringsIndex.add([
  46586. 0x8B,
  46587. 0x0E
  46588. ]);
  46589. continue;
  46590. }
  46591. charStringsIndex.add(glyph);
  46592. }
  46593. cff.charStrings = charStringsIndex;
  46594. var privateDict = new CFFPrivateDict();
  46595. privateDict.setByName('Subrs', null);
  46596. var fields = [
  46597. 'BlueValues',
  46598. 'OtherBlues',
  46599. 'FamilyBlues',
  46600. 'FamilyOtherBlues',
  46601. 'StemSnapH',
  46602. 'StemSnapV',
  46603. 'BlueShift',
  46604. 'BlueFuzz',
  46605. 'BlueScale',
  46606. 'LanguageGroup',
  46607. 'ExpansionFactor',
  46608. 'ForceBold',
  46609. 'StdHW',
  46610. 'StdVW'
  46611. ];
  46612. for (i = 0, ii = fields.length; i < ii; i++) {
  46613. var field = fields[i];
  46614. if (!(field in properties.privateData)) {
  46615. continue;
  46616. }
  46617. var value = properties.privateData[field];
  46618. if (isArray(value)) {
  46619. for (var j = value.length - 1; j > 0; j--) {
  46620. value[j] -= value[j - 1];
  46621. }
  46622. }
  46623. privateDict.setByName(field, value);
  46624. }
  46625. cff.topDict.privateDict = privateDict;
  46626. var subrIndex = new CFFIndex();
  46627. for (i = 0, ii = subrs.length; i < ii; i++) {
  46628. subrIndex.add(subrs[i]);
  46629. }
  46630. privateDict.subrsIndex = subrIndex;
  46631. var compiler = new CFFCompiler(cff);
  46632. return compiler.compile();
  46633. }
  46634. };
  46635. return Type1Font;
  46636. }();
  46637. var CFFFont = function CFFFontClosure() {
  46638. function CFFFont(file, properties) {
  46639. this.properties = properties;
  46640. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  46641. this.cff = parser.parse();
  46642. var compiler = new CFFCompiler(this.cff);
  46643. this.seacs = this.cff.seacs;
  46644. try {
  46645. this.data = compiler.compile();
  46646. } catch (e) {
  46647. warn('Failed to compile font ' + properties.loadedName);
  46648. this.data = file;
  46649. }
  46650. }
  46651. CFFFont.prototype = {
  46652. get numGlyphs() {
  46653. return this.cff.charStrings.count;
  46654. },
  46655. getCharset: function CFFFont_getCharset() {
  46656. return this.cff.charset.charset;
  46657. },
  46658. getGlyphMapping: function CFFFont_getGlyphMapping() {
  46659. var cff = this.cff;
  46660. var properties = this.properties;
  46661. var charsets = cff.charset.charset;
  46662. var charCodeToGlyphId;
  46663. var glyphId;
  46664. if (properties.composite) {
  46665. charCodeToGlyphId = Object.create(null);
  46666. if (cff.isCIDFont) {
  46667. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  46668. var cid = charsets[glyphId];
  46669. var charCode = properties.cMap.charCodeOf(cid);
  46670. charCodeToGlyphId[charCode] = glyphId;
  46671. }
  46672. } else {
  46673. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  46674. charCodeToGlyphId[glyphId] = glyphId;
  46675. }
  46676. }
  46677. return charCodeToGlyphId;
  46678. }
  46679. var encoding = cff.encoding ? cff.encoding.encoding : null;
  46680. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  46681. return charCodeToGlyphId;
  46682. }
  46683. };
  46684. return CFFFont;
  46685. }();
  46686. (function checkSeacSupport() {
  46687. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  46688. SEAC_ANALYSIS_ENABLED = true;
  46689. }
  46690. }());
  46691. (function checkChromeWindows() {
  46692. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  46693. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  46694. }
  46695. }());
  46696. exports.ErrorFont = ErrorFont;
  46697. exports.Font = Font;
  46698. exports.FontFlags = FontFlags;
  46699. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  46700. exports.ToUnicodeMap = ToUnicodeMap;
  46701. exports.getFontType = getFontType;
  46702. /***/ }),
  46703. /* 34 */
  46704. /***/ (function(module, exports, __w_pdfjs_require__) {
  46705. "use strict";
  46706. var sharedUtil = __w_pdfjs_require__(0);
  46707. var corePrimitives = __w_pdfjs_require__(1);
  46708. var coreColorSpace = __w_pdfjs_require__(4);
  46709. var coreStream = __w_pdfjs_require__(2);
  46710. var coreJpx = __w_pdfjs_require__(18);
  46711. var ImageKind = sharedUtil.ImageKind;
  46712. var assert = sharedUtil.assert;
  46713. var error = sharedUtil.error;
  46714. var info = sharedUtil.info;
  46715. var isArray = sharedUtil.isArray;
  46716. var warn = sharedUtil.warn;
  46717. var Name = corePrimitives.Name;
  46718. var isStream = corePrimitives.isStream;
  46719. var ColorSpace = coreColorSpace.ColorSpace;
  46720. var DecodeStream = coreStream.DecodeStream;
  46721. var JpegStream = coreStream.JpegStream;
  46722. var JpxImage = coreJpx.JpxImage;
  46723. var PDFImage = function PDFImageClosure() {
  46724. function handleImageData(image, nativeDecoder) {
  46725. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  46726. return nativeDecoder.decode(image);
  46727. }
  46728. return Promise.resolve(image);
  46729. }
  46730. function decodeAndClamp(value, addend, coefficient, max) {
  46731. value = addend + value * coefficient;
  46732. return value < 0 ? 0 : value > max ? max : value;
  46733. }
  46734. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  46735. var length = w2 * h2;
  46736. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46737. var xRatio = w1 / w2;
  46738. var yRatio = h1 / h2;
  46739. var i, j, py, newIndex = 0, oldIndex;
  46740. var xScaled = new Uint16Array(w2);
  46741. var w1Scanline = w1;
  46742. for (i = 0; i < w2; i++) {
  46743. xScaled[i] = Math.floor(i * xRatio);
  46744. }
  46745. for (i = 0; i < h2; i++) {
  46746. py = Math.floor(i * yRatio) * w1Scanline;
  46747. for (j = 0; j < w2; j++) {
  46748. oldIndex = py + xScaled[j];
  46749. dest[newIndex++] = src[oldIndex];
  46750. }
  46751. }
  46752. return dest;
  46753. }
  46754. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  46755. this.image = image;
  46756. var dict = image.dict;
  46757. if (dict.has('Filter')) {
  46758. var filter = dict.get('Filter').name;
  46759. if (filter === 'JPXDecode') {
  46760. var jpxImage = new JpxImage();
  46761. jpxImage.parseImageProperties(image.stream);
  46762. image.stream.reset();
  46763. image.bitsPerComponent = jpxImage.bitsPerComponent;
  46764. image.numComps = jpxImage.componentsCount;
  46765. } else if (filter === 'JBIG2Decode') {
  46766. image.bitsPerComponent = 1;
  46767. image.numComps = 1;
  46768. }
  46769. }
  46770. this.width = dict.get('Width', 'W');
  46771. this.height = dict.get('Height', 'H');
  46772. if (this.width < 1 || this.height < 1) {
  46773. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  46774. }
  46775. this.interpolate = dict.get('Interpolate', 'I') || false;
  46776. this.imageMask = dict.get('ImageMask', 'IM') || false;
  46777. this.matte = dict.get('Matte') || false;
  46778. var bitsPerComponent = image.bitsPerComponent;
  46779. if (!bitsPerComponent) {
  46780. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  46781. if (!bitsPerComponent) {
  46782. if (this.imageMask) {
  46783. bitsPerComponent = 1;
  46784. } else {
  46785. error('Bits per component missing in image: ' + this.imageMask);
  46786. }
  46787. }
  46788. }
  46789. this.bpc = bitsPerComponent;
  46790. if (!this.imageMask) {
  46791. var colorSpace = dict.get('ColorSpace', 'CS');
  46792. if (!colorSpace) {
  46793. info('JPX images (which do not require color spaces)');
  46794. switch (image.numComps) {
  46795. case 1:
  46796. colorSpace = Name.get('DeviceGray');
  46797. break;
  46798. case 3:
  46799. colorSpace = Name.get('DeviceRGB');
  46800. break;
  46801. case 4:
  46802. colorSpace = Name.get('DeviceCMYK');
  46803. break;
  46804. default:
  46805. error('JPX images with ' + this.numComps + ' color components not supported.');
  46806. }
  46807. }
  46808. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  46809. this.numComps = this.colorSpace.numComps;
  46810. }
  46811. this.decode = dict.getArray('Decode', 'D');
  46812. this.needsDecode = false;
  46813. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  46814. this.needsDecode = true;
  46815. var max = (1 << bitsPerComponent) - 1;
  46816. this.decodeCoefficients = [];
  46817. this.decodeAddends = [];
  46818. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  46819. var dmin = this.decode[i];
  46820. var dmax = this.decode[i + 1];
  46821. this.decodeCoefficients[j] = dmax - dmin;
  46822. this.decodeAddends[j] = max * dmin;
  46823. }
  46824. }
  46825. if (smask) {
  46826. this.smask = new PDFImage(xref, res, smask, false);
  46827. } else if (mask) {
  46828. if (isStream(mask)) {
  46829. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  46830. if (!imageMask) {
  46831. warn('Ignoring /Mask in image without /ImageMask.');
  46832. } else {
  46833. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  46834. }
  46835. } else {
  46836. this.mask = mask;
  46837. }
  46838. }
  46839. }
  46840. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  46841. var imagePromise = handleImageData(image, nativeDecoder);
  46842. var smaskPromise;
  46843. var maskPromise;
  46844. var smask = image.dict.get('SMask');
  46845. var mask = image.dict.get('Mask');
  46846. if (smask) {
  46847. smaskPromise = handleImageData(smask, nativeDecoder);
  46848. maskPromise = Promise.resolve(null);
  46849. } else {
  46850. smaskPromise = Promise.resolve(null);
  46851. if (mask) {
  46852. if (isStream(mask)) {
  46853. maskPromise = handleImageData(mask, nativeDecoder);
  46854. } else if (isArray(mask)) {
  46855. maskPromise = Promise.resolve(mask);
  46856. } else {
  46857. warn('Unsupported mask format.');
  46858. maskPromise = Promise.resolve(null);
  46859. }
  46860. } else {
  46861. maskPromise = Promise.resolve(null);
  46862. }
  46863. }
  46864. return Promise.all([
  46865. imagePromise,
  46866. smaskPromise,
  46867. maskPromise
  46868. ]).then(function (results) {
  46869. var imageData = results[0];
  46870. var smaskData = results[1];
  46871. var maskData = results[2];
  46872. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  46873. });
  46874. };
  46875. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  46876. var computedLength = (width + 7 >> 3) * height;
  46877. var actualLength = imgArray.byteLength;
  46878. var haveFullData = computedLength === actualLength;
  46879. var data, i;
  46880. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  46881. data = imgArray;
  46882. } else if (!inverseDecode) {
  46883. data = new Uint8Array(actualLength);
  46884. data.set(imgArray);
  46885. } else {
  46886. data = new Uint8Array(computedLength);
  46887. data.set(imgArray);
  46888. for (i = actualLength; i < computedLength; i++) {
  46889. data[i] = 0xff;
  46890. }
  46891. }
  46892. if (inverseDecode) {
  46893. for (i = 0; i < actualLength; i++) {
  46894. data[i] = ~data[i];
  46895. }
  46896. }
  46897. return {
  46898. data: data,
  46899. width: width,
  46900. height: height
  46901. };
  46902. };
  46903. PDFImage.prototype = {
  46904. get drawWidth() {
  46905. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  46906. },
  46907. get drawHeight() {
  46908. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  46909. },
  46910. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  46911. var bpc = this.bpc;
  46912. var numComps = this.numComps;
  46913. var decodeAddends = this.decodeAddends;
  46914. var decodeCoefficients = this.decodeCoefficients;
  46915. var max = (1 << bpc) - 1;
  46916. var i, ii;
  46917. if (bpc === 1) {
  46918. for (i = 0, ii = buffer.length; i < ii; i++) {
  46919. buffer[i] = +!buffer[i];
  46920. }
  46921. return;
  46922. }
  46923. var index = 0;
  46924. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  46925. for (var j = 0; j < numComps; j++) {
  46926. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  46927. index++;
  46928. }
  46929. }
  46930. },
  46931. getComponents: function PDFImage_getComponents(buffer) {
  46932. var bpc = this.bpc;
  46933. if (bpc === 8) {
  46934. return buffer;
  46935. }
  46936. var width = this.width;
  46937. var height = this.height;
  46938. var numComps = this.numComps;
  46939. var length = width * height * numComps;
  46940. var bufferPos = 0;
  46941. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46942. var rowComps = width * numComps;
  46943. var max = (1 << bpc) - 1;
  46944. var i = 0, ii, buf;
  46945. if (bpc === 1) {
  46946. var mask, loop1End, loop2End;
  46947. for (var j = 0; j < height; j++) {
  46948. loop1End = i + (rowComps & ~7);
  46949. loop2End = i + rowComps;
  46950. while (i < loop1End) {
  46951. buf = buffer[bufferPos++];
  46952. output[i] = buf >> 7 & 1;
  46953. output[i + 1] = buf >> 6 & 1;
  46954. output[i + 2] = buf >> 5 & 1;
  46955. output[i + 3] = buf >> 4 & 1;
  46956. output[i + 4] = buf >> 3 & 1;
  46957. output[i + 5] = buf >> 2 & 1;
  46958. output[i + 6] = buf >> 1 & 1;
  46959. output[i + 7] = buf & 1;
  46960. i += 8;
  46961. }
  46962. if (i < loop2End) {
  46963. buf = buffer[bufferPos++];
  46964. mask = 128;
  46965. while (i < loop2End) {
  46966. output[i++] = +!!(buf & mask);
  46967. mask >>= 1;
  46968. }
  46969. }
  46970. }
  46971. } else {
  46972. var bits = 0;
  46973. buf = 0;
  46974. for (i = 0, ii = length; i < ii; ++i) {
  46975. if (i % rowComps === 0) {
  46976. buf = 0;
  46977. bits = 0;
  46978. }
  46979. while (bits < bpc) {
  46980. buf = buf << 8 | buffer[bufferPos++];
  46981. bits += 8;
  46982. }
  46983. var remainingBits = bits - bpc;
  46984. var value = buf >> remainingBits;
  46985. output[i] = value < 0 ? 0 : value > max ? max : value;
  46986. buf = buf & (1 << remainingBits) - 1;
  46987. bits = remainingBits;
  46988. }
  46989. }
  46990. return output;
  46991. },
  46992. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  46993. var smask = this.smask;
  46994. var mask = this.mask;
  46995. var alphaBuf, sw, sh, i, ii, j;
  46996. if (smask) {
  46997. sw = smask.width;
  46998. sh = smask.height;
  46999. alphaBuf = new Uint8Array(sw * sh);
  47000. smask.fillGrayBuffer(alphaBuf);
  47001. if (sw !== width || sh !== height) {
  47002. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  47003. }
  47004. } else if (mask) {
  47005. if (mask instanceof PDFImage) {
  47006. sw = mask.width;
  47007. sh = mask.height;
  47008. alphaBuf = new Uint8Array(sw * sh);
  47009. mask.numComps = 1;
  47010. mask.fillGrayBuffer(alphaBuf);
  47011. for (i = 0, ii = sw * sh; i < ii; ++i) {
  47012. alphaBuf[i] = 255 - alphaBuf[i];
  47013. }
  47014. if (sw !== width || sh !== height) {
  47015. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  47016. }
  47017. } else if (isArray(mask)) {
  47018. alphaBuf = new Uint8Array(width * height);
  47019. var numComps = this.numComps;
  47020. for (i = 0, ii = width * height; i < ii; ++i) {
  47021. var opacity = 0;
  47022. var imageOffset = i * numComps;
  47023. for (j = 0; j < numComps; ++j) {
  47024. var color = image[imageOffset + j];
  47025. var maskOffset = j * 2;
  47026. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  47027. opacity = 255;
  47028. break;
  47029. }
  47030. }
  47031. alphaBuf[i] = opacity;
  47032. }
  47033. } else {
  47034. error('Unknown mask format.');
  47035. }
  47036. }
  47037. if (alphaBuf) {
  47038. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  47039. rgbaBuf[j] = alphaBuf[i];
  47040. }
  47041. } else {
  47042. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  47043. rgbaBuf[j] = 255;
  47044. }
  47045. }
  47046. },
  47047. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  47048. var matte = this.smask && this.smask.matte;
  47049. if (!matte) {
  47050. return;
  47051. }
  47052. var matteRgb = this.colorSpace.getRgb(matte, 0);
  47053. var matteR = matteRgb[0];
  47054. var matteG = matteRgb[1];
  47055. var matteB = matteRgb[2];
  47056. var length = width * height * 4;
  47057. var r, g, b;
  47058. for (var i = 0; i < length; i += 4) {
  47059. var alpha = buffer[i + 3];
  47060. if (alpha === 0) {
  47061. buffer[i] = 255;
  47062. buffer[i + 1] = 255;
  47063. buffer[i + 2] = 255;
  47064. continue;
  47065. }
  47066. var k = 255 / alpha;
  47067. r = (buffer[i] - matteR) * k + matteR;
  47068. g = (buffer[i + 1] - matteG) * k + matteG;
  47069. b = (buffer[i + 2] - matteB) * k + matteB;
  47070. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  47071. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  47072. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  47073. }
  47074. },
  47075. createImageData: function PDFImage_createImageData(forceRGBA) {
  47076. var drawWidth = this.drawWidth;
  47077. var drawHeight = this.drawHeight;
  47078. var imgData = {
  47079. width: drawWidth,
  47080. height: drawHeight
  47081. };
  47082. var numComps = this.numComps;
  47083. var originalWidth = this.width;
  47084. var originalHeight = this.height;
  47085. var bpc = this.bpc;
  47086. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  47087. var imgArray;
  47088. if (!forceRGBA) {
  47089. var kind;
  47090. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  47091. kind = ImageKind.GRAYSCALE_1BPP;
  47092. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  47093. kind = ImageKind.RGB_24BPP;
  47094. }
  47095. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  47096. imgData.kind = kind;
  47097. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47098. if (this.image instanceof DecodeStream) {
  47099. imgData.data = imgArray;
  47100. } else {
  47101. var newArray = new Uint8Array(imgArray.length);
  47102. newArray.set(imgArray);
  47103. imgData.data = newArray;
  47104. }
  47105. if (this.needsDecode) {
  47106. assert(kind === ImageKind.GRAYSCALE_1BPP);
  47107. var buffer = imgData.data;
  47108. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47109. buffer[i] ^= 0xff;
  47110. }
  47111. }
  47112. return imgData;
  47113. }
  47114. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  47115. imgData.kind = ImageKind.RGB_24BPP;
  47116. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  47117. return imgData;
  47118. }
  47119. }
  47120. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47121. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  47122. var comps = this.getComponents(imgArray);
  47123. var alpha01, maybeUndoPreblend;
  47124. if (!forceRGBA && !this.smask && !this.mask) {
  47125. imgData.kind = ImageKind.RGB_24BPP;
  47126. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  47127. alpha01 = 0;
  47128. maybeUndoPreblend = false;
  47129. } else {
  47130. imgData.kind = ImageKind.RGBA_32BPP;
  47131. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  47132. alpha01 = 1;
  47133. maybeUndoPreblend = true;
  47134. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  47135. }
  47136. if (this.needsDecode) {
  47137. this.decodeBuffer(comps);
  47138. }
  47139. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  47140. if (maybeUndoPreblend) {
  47141. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  47142. }
  47143. return imgData;
  47144. },
  47145. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  47146. var numComps = this.numComps;
  47147. if (numComps !== 1) {
  47148. error('Reading gray scale from a color image: ' + numComps);
  47149. }
  47150. var width = this.width;
  47151. var height = this.height;
  47152. var bpc = this.bpc;
  47153. var rowBytes = width * numComps * bpc + 7 >> 3;
  47154. var imgArray = this.getImageBytes(height * rowBytes);
  47155. var comps = this.getComponents(imgArray);
  47156. var i, length;
  47157. if (bpc === 1) {
  47158. length = width * height;
  47159. if (this.needsDecode) {
  47160. for (i = 0; i < length; ++i) {
  47161. buffer[i] = comps[i] - 1 & 255;
  47162. }
  47163. } else {
  47164. for (i = 0; i < length; ++i) {
  47165. buffer[i] = -comps[i] & 255;
  47166. }
  47167. }
  47168. return;
  47169. }
  47170. if (this.needsDecode) {
  47171. this.decodeBuffer(comps);
  47172. }
  47173. length = width * height;
  47174. var scale = 255 / ((1 << bpc) - 1);
  47175. for (i = 0; i < length; ++i) {
  47176. buffer[i] = scale * comps[i] | 0;
  47177. }
  47178. },
  47179. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  47180. this.image.reset();
  47181. this.image.drawWidth = drawWidth || this.width;
  47182. this.image.drawHeight = drawHeight || this.height;
  47183. this.image.forceRGB = !!forceRGB;
  47184. return this.image.getBytes(length);
  47185. }
  47186. };
  47187. return PDFImage;
  47188. }();
  47189. exports.PDFImage = PDFImage;
  47190. /***/ }),
  47191. /* 35 */
  47192. /***/ (function(module, exports, __w_pdfjs_require__) {
  47193. "use strict";
  47194. var sharedUtil = __w_pdfjs_require__(0);
  47195. var coreArithmeticDecoder = __w_pdfjs_require__(13);
  47196. var error = sharedUtil.error;
  47197. var log2 = sharedUtil.log2;
  47198. var readInt8 = sharedUtil.readInt8;
  47199. var readUint16 = sharedUtil.readUint16;
  47200. var readUint32 = sharedUtil.readUint32;
  47201. var shadow = sharedUtil.shadow;
  47202. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  47203. var Jbig2Image = function Jbig2ImageClosure() {
  47204. function ContextCache() {
  47205. }
  47206. ContextCache.prototype = {
  47207. getContexts: function (id) {
  47208. if (id in this) {
  47209. return this[id];
  47210. }
  47211. return this[id] = new Int8Array(1 << 16);
  47212. }
  47213. };
  47214. function DecodingContext(data, start, end) {
  47215. this.data = data;
  47216. this.start = start;
  47217. this.end = end;
  47218. }
  47219. DecodingContext.prototype = {
  47220. get decoder() {
  47221. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  47222. return shadow(this, 'decoder', decoder);
  47223. },
  47224. get contextCache() {
  47225. var cache = new ContextCache();
  47226. return shadow(this, 'contextCache', cache);
  47227. }
  47228. };
  47229. function decodeInteger(contextCache, procedure, decoder) {
  47230. var contexts = contextCache.getContexts(procedure);
  47231. var prev = 1;
  47232. function readBits(length) {
  47233. var v = 0;
  47234. for (var i = 0; i < length; i++) {
  47235. var bit = decoder.readBit(contexts, prev);
  47236. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  47237. v = v << 1 | bit;
  47238. }
  47239. return v >>> 0;
  47240. }
  47241. var sign = readBits(1);
  47242. 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);
  47243. return sign === 0 ? value : value > 0 ? -value : null;
  47244. }
  47245. function decodeIAID(contextCache, decoder, codeLength) {
  47246. var contexts = contextCache.getContexts('IAID');
  47247. var prev = 1;
  47248. for (var i = 0; i < codeLength; i++) {
  47249. var bit = decoder.readBit(contexts, prev);
  47250. prev = prev << 1 | bit;
  47251. }
  47252. if (codeLength < 31) {
  47253. return prev & (1 << codeLength) - 1;
  47254. }
  47255. return prev & 0x7FFFFFFF;
  47256. }
  47257. var SegmentTypes = [
  47258. 'SymbolDictionary',
  47259. null,
  47260. null,
  47261. null,
  47262. 'IntermediateTextRegion',
  47263. null,
  47264. 'ImmediateTextRegion',
  47265. 'ImmediateLosslessTextRegion',
  47266. null,
  47267. null,
  47268. null,
  47269. null,
  47270. null,
  47271. null,
  47272. null,
  47273. null,
  47274. 'patternDictionary',
  47275. null,
  47276. null,
  47277. null,
  47278. 'IntermediateHalftoneRegion',
  47279. null,
  47280. 'ImmediateHalftoneRegion',
  47281. 'ImmediateLosslessHalftoneRegion',
  47282. null,
  47283. null,
  47284. null,
  47285. null,
  47286. null,
  47287. null,
  47288. null,
  47289. null,
  47290. null,
  47291. null,
  47292. null,
  47293. null,
  47294. 'IntermediateGenericRegion',
  47295. null,
  47296. 'ImmediateGenericRegion',
  47297. 'ImmediateLosslessGenericRegion',
  47298. 'IntermediateGenericRefinementRegion',
  47299. null,
  47300. 'ImmediateGenericRefinementRegion',
  47301. 'ImmediateLosslessGenericRefinementRegion',
  47302. null,
  47303. null,
  47304. null,
  47305. null,
  47306. 'PageInformation',
  47307. 'EndOfPage',
  47308. 'EndOfStripe',
  47309. 'EndOfFile',
  47310. 'Profiles',
  47311. 'Tables',
  47312. null,
  47313. null,
  47314. null,
  47315. null,
  47316. null,
  47317. null,
  47318. null,
  47319. null,
  47320. 'Extension'
  47321. ];
  47322. var CodingTemplates = [
  47323. [
  47324. {
  47325. x: -1,
  47326. y: -2
  47327. },
  47328. {
  47329. x: 0,
  47330. y: -2
  47331. },
  47332. {
  47333. x: 1,
  47334. y: -2
  47335. },
  47336. {
  47337. x: -2,
  47338. y: -1
  47339. },
  47340. {
  47341. x: -1,
  47342. y: -1
  47343. },
  47344. {
  47345. x: 0,
  47346. y: -1
  47347. },
  47348. {
  47349. x: 1,
  47350. y: -1
  47351. },
  47352. {
  47353. x: 2,
  47354. y: -1
  47355. },
  47356. {
  47357. x: -4,
  47358. y: 0
  47359. },
  47360. {
  47361. x: -3,
  47362. y: 0
  47363. },
  47364. {
  47365. x: -2,
  47366. y: 0
  47367. },
  47368. {
  47369. x: -1,
  47370. y: 0
  47371. }
  47372. ],
  47373. [
  47374. {
  47375. x: -1,
  47376. y: -2
  47377. },
  47378. {
  47379. x: 0,
  47380. y: -2
  47381. },
  47382. {
  47383. x: 1,
  47384. y: -2
  47385. },
  47386. {
  47387. x: 2,
  47388. y: -2
  47389. },
  47390. {
  47391. x: -2,
  47392. y: -1
  47393. },
  47394. {
  47395. x: -1,
  47396. y: -1
  47397. },
  47398. {
  47399. x: 0,
  47400. y: -1
  47401. },
  47402. {
  47403. x: 1,
  47404. y: -1
  47405. },
  47406. {
  47407. x: 2,
  47408. y: -1
  47409. },
  47410. {
  47411. x: -3,
  47412. y: 0
  47413. },
  47414. {
  47415. x: -2,
  47416. y: 0
  47417. },
  47418. {
  47419. x: -1,
  47420. y: 0
  47421. }
  47422. ],
  47423. [
  47424. {
  47425. x: -1,
  47426. y: -2
  47427. },
  47428. {
  47429. x: 0,
  47430. y: -2
  47431. },
  47432. {
  47433. x: 1,
  47434. y: -2
  47435. },
  47436. {
  47437. x: -2,
  47438. y: -1
  47439. },
  47440. {
  47441. x: -1,
  47442. y: -1
  47443. },
  47444. {
  47445. x: 0,
  47446. y: -1
  47447. },
  47448. {
  47449. x: 1,
  47450. y: -1
  47451. },
  47452. {
  47453. x: -2,
  47454. y: 0
  47455. },
  47456. {
  47457. x: -1,
  47458. y: 0
  47459. }
  47460. ],
  47461. [
  47462. {
  47463. x: -3,
  47464. y: -1
  47465. },
  47466. {
  47467. x: -2,
  47468. y: -1
  47469. },
  47470. {
  47471. x: -1,
  47472. y: -1
  47473. },
  47474. {
  47475. x: 0,
  47476. y: -1
  47477. },
  47478. {
  47479. x: 1,
  47480. y: -1
  47481. },
  47482. {
  47483. x: -4,
  47484. y: 0
  47485. },
  47486. {
  47487. x: -3,
  47488. y: 0
  47489. },
  47490. {
  47491. x: -2,
  47492. y: 0
  47493. },
  47494. {
  47495. x: -1,
  47496. y: 0
  47497. }
  47498. ]
  47499. ];
  47500. var RefinementTemplates = [
  47501. {
  47502. coding: [
  47503. {
  47504. x: 0,
  47505. y: -1
  47506. },
  47507. {
  47508. x: 1,
  47509. y: -1
  47510. },
  47511. {
  47512. x: -1,
  47513. y: 0
  47514. }
  47515. ],
  47516. reference: [
  47517. {
  47518. x: 0,
  47519. y: -1
  47520. },
  47521. {
  47522. x: 1,
  47523. y: -1
  47524. },
  47525. {
  47526. x: -1,
  47527. y: 0
  47528. },
  47529. {
  47530. x: 0,
  47531. y: 0
  47532. },
  47533. {
  47534. x: 1,
  47535. y: 0
  47536. },
  47537. {
  47538. x: -1,
  47539. y: 1
  47540. },
  47541. {
  47542. x: 0,
  47543. y: 1
  47544. },
  47545. {
  47546. x: 1,
  47547. y: 1
  47548. }
  47549. ]
  47550. },
  47551. {
  47552. coding: [
  47553. {
  47554. x: -1,
  47555. y: -1
  47556. },
  47557. {
  47558. x: 0,
  47559. y: -1
  47560. },
  47561. {
  47562. x: 1,
  47563. y: -1
  47564. },
  47565. {
  47566. x: -1,
  47567. y: 0
  47568. }
  47569. ],
  47570. reference: [
  47571. {
  47572. x: 0,
  47573. y: -1
  47574. },
  47575. {
  47576. x: -1,
  47577. y: 0
  47578. },
  47579. {
  47580. x: 0,
  47581. y: 0
  47582. },
  47583. {
  47584. x: 1,
  47585. y: 0
  47586. },
  47587. {
  47588. x: 0,
  47589. y: 1
  47590. },
  47591. {
  47592. x: 1,
  47593. y: 1
  47594. }
  47595. ]
  47596. }
  47597. ];
  47598. var ReusedContexts = [
  47599. 0x9B25,
  47600. 0x0795,
  47601. 0x00E5,
  47602. 0x0195
  47603. ];
  47604. var RefinementReusedContexts = [
  47605. 0x0020,
  47606. 0x0008
  47607. ];
  47608. function decodeBitmapTemplate0(width, height, decodingContext) {
  47609. var decoder = decodingContext.decoder;
  47610. var contexts = decodingContext.contextCache.getContexts('GB');
  47611. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  47612. var OLD_PIXEL_MASK = 0x7BF7;
  47613. for (i = 0; i < height; i++) {
  47614. row = bitmap[i] = new Uint8Array(width);
  47615. row1 = i < 1 ? row : bitmap[i - 1];
  47616. row2 = i < 2 ? row : bitmap[i - 2];
  47617. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  47618. for (j = 0; j < width; j++) {
  47619. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  47620. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  47621. }
  47622. }
  47623. return bitmap;
  47624. }
  47625. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  47626. if (mmr) {
  47627. error('JBIG2 error: MMR encoding is not supported');
  47628. }
  47629. 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) {
  47630. return decodeBitmapTemplate0(width, height, decodingContext);
  47631. }
  47632. var useskip = !!skip;
  47633. var template = CodingTemplates[templateIndex].concat(at);
  47634. template.sort(function (a, b) {
  47635. return a.y - b.y || a.x - b.x;
  47636. });
  47637. var templateLength = template.length;
  47638. var templateX = new Int8Array(templateLength);
  47639. var templateY = new Int8Array(templateLength);
  47640. var changingTemplateEntries = [];
  47641. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  47642. var c, k;
  47643. for (k = 0; k < templateLength; k++) {
  47644. templateX[k] = template[k].x;
  47645. templateY[k] = template[k].y;
  47646. minX = Math.min(minX, template[k].x);
  47647. maxX = Math.max(maxX, template[k].x);
  47648. minY = Math.min(minY, template[k].y);
  47649. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  47650. reuseMask |= 1 << templateLength - 1 - k;
  47651. } else {
  47652. changingTemplateEntries.push(k);
  47653. }
  47654. }
  47655. var changingEntriesLength = changingTemplateEntries.length;
  47656. var changingTemplateX = new Int8Array(changingEntriesLength);
  47657. var changingTemplateY = new Int8Array(changingEntriesLength);
  47658. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  47659. for (c = 0; c < changingEntriesLength; c++) {
  47660. k = changingTemplateEntries[c];
  47661. changingTemplateX[c] = template[k].x;
  47662. changingTemplateY[c] = template[k].y;
  47663. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  47664. }
  47665. var sbb_left = -minX;
  47666. var sbb_top = -minY;
  47667. var sbb_right = width - maxX;
  47668. var pseudoPixelContext = ReusedContexts[templateIndex];
  47669. var row = new Uint8Array(width);
  47670. var bitmap = [];
  47671. var decoder = decodingContext.decoder;
  47672. var contexts = decodingContext.contextCache.getContexts('GB');
  47673. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  47674. for (var i = 0; i < height; i++) {
  47675. if (prediction) {
  47676. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  47677. ltp ^= sltp;
  47678. if (ltp) {
  47679. bitmap.push(row);
  47680. continue;
  47681. }
  47682. }
  47683. row = new Uint8Array(row);
  47684. bitmap.push(row);
  47685. for (j = 0; j < width; j++) {
  47686. if (useskip && skip[i][j]) {
  47687. row[j] = 0;
  47688. continue;
  47689. }
  47690. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  47691. contextLabel = contextLabel << 1 & reuseMask;
  47692. for (k = 0; k < changingEntriesLength; k++) {
  47693. i0 = i + changingTemplateY[k];
  47694. j0 = j + changingTemplateX[k];
  47695. bit = bitmap[i0][j0];
  47696. if (bit) {
  47697. bit = changingTemplateBit[k];
  47698. contextLabel |= bit;
  47699. }
  47700. }
  47701. } else {
  47702. contextLabel = 0;
  47703. shift = templateLength - 1;
  47704. for (k = 0; k < templateLength; k++, shift--) {
  47705. j0 = j + templateX[k];
  47706. if (j0 >= 0 && j0 < width) {
  47707. i0 = i + templateY[k];
  47708. if (i0 >= 0) {
  47709. bit = bitmap[i0][j0];
  47710. if (bit) {
  47711. contextLabel |= bit << shift;
  47712. }
  47713. }
  47714. }
  47715. }
  47716. }
  47717. var pixel = decoder.readBit(contexts, contextLabel);
  47718. row[j] = pixel;
  47719. }
  47720. }
  47721. return bitmap;
  47722. }
  47723. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  47724. var codingTemplate = RefinementTemplates[templateIndex].coding;
  47725. if (templateIndex === 0) {
  47726. codingTemplate = codingTemplate.concat([at[0]]);
  47727. }
  47728. var codingTemplateLength = codingTemplate.length;
  47729. var codingTemplateX = new Int32Array(codingTemplateLength);
  47730. var codingTemplateY = new Int32Array(codingTemplateLength);
  47731. var k;
  47732. for (k = 0; k < codingTemplateLength; k++) {
  47733. codingTemplateX[k] = codingTemplate[k].x;
  47734. codingTemplateY[k] = codingTemplate[k].y;
  47735. }
  47736. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  47737. if (templateIndex === 0) {
  47738. referenceTemplate = referenceTemplate.concat([at[1]]);
  47739. }
  47740. var referenceTemplateLength = referenceTemplate.length;
  47741. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  47742. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  47743. for (k = 0; k < referenceTemplateLength; k++) {
  47744. referenceTemplateX[k] = referenceTemplate[k].x;
  47745. referenceTemplateY[k] = referenceTemplate[k].y;
  47746. }
  47747. var referenceWidth = referenceBitmap[0].length;
  47748. var referenceHeight = referenceBitmap.length;
  47749. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  47750. var bitmap = [];
  47751. var decoder = decodingContext.decoder;
  47752. var contexts = decodingContext.contextCache.getContexts('GR');
  47753. var ltp = 0;
  47754. for (var i = 0; i < height; i++) {
  47755. if (prediction) {
  47756. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  47757. ltp ^= sltp;
  47758. if (ltp) {
  47759. error('JBIG2 error: prediction is not supported');
  47760. }
  47761. }
  47762. var row = new Uint8Array(width);
  47763. bitmap.push(row);
  47764. for (var j = 0; j < width; j++) {
  47765. var i0, j0;
  47766. var contextLabel = 0;
  47767. for (k = 0; k < codingTemplateLength; k++) {
  47768. i0 = i + codingTemplateY[k];
  47769. j0 = j + codingTemplateX[k];
  47770. if (i0 < 0 || j0 < 0 || j0 >= width) {
  47771. contextLabel <<= 1;
  47772. } else {
  47773. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  47774. }
  47775. }
  47776. for (k = 0; k < referenceTemplateLength; k++) {
  47777. i0 = i + referenceTemplateY[k] + offsetY;
  47778. j0 = j + referenceTemplateX[k] + offsetX;
  47779. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  47780. contextLabel <<= 1;
  47781. } else {
  47782. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  47783. }
  47784. }
  47785. var pixel = decoder.readBit(contexts, contextLabel);
  47786. row[j] = pixel;
  47787. }
  47788. }
  47789. return bitmap;
  47790. }
  47791. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  47792. if (huffman) {
  47793. error('JBIG2 error: huffman is not supported');
  47794. }
  47795. var newSymbols = [];
  47796. var currentHeight = 0;
  47797. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  47798. var decoder = decodingContext.decoder;
  47799. var contextCache = decodingContext.contextCache;
  47800. while (newSymbols.length < numberOfNewSymbols) {
  47801. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  47802. currentHeight += deltaHeight;
  47803. var currentWidth = 0;
  47804. while (true) {
  47805. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  47806. if (deltaWidth === null) {
  47807. break;
  47808. }
  47809. currentWidth += deltaWidth;
  47810. var bitmap;
  47811. if (refinement) {
  47812. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  47813. if (numberOfInstances > 1) {
  47814. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  47815. } else {
  47816. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47817. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47818. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47819. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  47820. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  47821. }
  47822. } else {
  47823. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  47824. }
  47825. newSymbols.push(bitmap);
  47826. }
  47827. }
  47828. var exportedSymbols = [];
  47829. var flags = [], currentFlag = false;
  47830. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  47831. while (flags.length < totalSymbolsLength) {
  47832. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  47833. while (runLength--) {
  47834. flags.push(currentFlag);
  47835. }
  47836. currentFlag = !currentFlag;
  47837. }
  47838. for (var i = 0, ii = symbols.length; i < ii; i++) {
  47839. if (flags[i]) {
  47840. exportedSymbols.push(symbols[i]);
  47841. }
  47842. }
  47843. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  47844. if (flags[i]) {
  47845. exportedSymbols.push(newSymbols[j]);
  47846. }
  47847. }
  47848. return exportedSymbols;
  47849. }
  47850. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  47851. if (huffman) {
  47852. error('JBIG2 error: huffman is not supported');
  47853. }
  47854. var bitmap = [];
  47855. var i, row;
  47856. for (i = 0; i < height; i++) {
  47857. row = new Uint8Array(width);
  47858. if (defaultPixelValue) {
  47859. for (var j = 0; j < width; j++) {
  47860. row[j] = defaultPixelValue;
  47861. }
  47862. }
  47863. bitmap.push(row);
  47864. }
  47865. var decoder = decodingContext.decoder;
  47866. var contextCache = decodingContext.contextCache;
  47867. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  47868. var firstS = 0;
  47869. i = 0;
  47870. while (i < numberOfSymbolInstances) {
  47871. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  47872. stripT += deltaT;
  47873. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  47874. firstS += deltaFirstS;
  47875. var currentS = firstS;
  47876. do {
  47877. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  47878. var t = stripSize * stripT + currentT;
  47879. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47880. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  47881. var symbolBitmap = inputSymbols[symbolId];
  47882. var symbolWidth = symbolBitmap[0].length;
  47883. var symbolHeight = symbolBitmap.length;
  47884. if (applyRefinement) {
  47885. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  47886. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  47887. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47888. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47889. symbolWidth += rdw;
  47890. symbolHeight += rdh;
  47891. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  47892. }
  47893. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  47894. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  47895. var s2, t2, symbolRow;
  47896. if (transposed) {
  47897. for (s2 = 0; s2 < symbolHeight; s2++) {
  47898. row = bitmap[offsetS + s2];
  47899. if (!row) {
  47900. continue;
  47901. }
  47902. symbolRow = symbolBitmap[s2];
  47903. var maxWidth = Math.min(width - offsetT, symbolWidth);
  47904. switch (combinationOperator) {
  47905. case 0:
  47906. for (t2 = 0; t2 < maxWidth; t2++) {
  47907. row[offsetT + t2] |= symbolRow[t2];
  47908. }
  47909. break;
  47910. case 2:
  47911. for (t2 = 0; t2 < maxWidth; t2++) {
  47912. row[offsetT + t2] ^= symbolRow[t2];
  47913. }
  47914. break;
  47915. default:
  47916. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47917. }
  47918. }
  47919. currentS += symbolHeight - 1;
  47920. } else {
  47921. for (t2 = 0; t2 < symbolHeight; t2++) {
  47922. row = bitmap[offsetT + t2];
  47923. if (!row) {
  47924. continue;
  47925. }
  47926. symbolRow = symbolBitmap[t2];
  47927. switch (combinationOperator) {
  47928. case 0:
  47929. for (s2 = 0; s2 < symbolWidth; s2++) {
  47930. row[offsetS + s2] |= symbolRow[s2];
  47931. }
  47932. break;
  47933. case 2:
  47934. for (s2 = 0; s2 < symbolWidth; s2++) {
  47935. row[offsetS + s2] ^= symbolRow[s2];
  47936. }
  47937. break;
  47938. default:
  47939. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47940. }
  47941. }
  47942. currentS += symbolWidth - 1;
  47943. }
  47944. i++;
  47945. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  47946. if (deltaS === null) {
  47947. break;
  47948. }
  47949. currentS += deltaS + dsOffset;
  47950. } while (true);
  47951. }
  47952. return bitmap;
  47953. }
  47954. function readSegmentHeader(data, start) {
  47955. var segmentHeader = {};
  47956. segmentHeader.number = readUint32(data, start);
  47957. var flags = data[start + 4];
  47958. var segmentType = flags & 0x3F;
  47959. if (!SegmentTypes[segmentType]) {
  47960. error('JBIG2 error: invalid segment type: ' + segmentType);
  47961. }
  47962. segmentHeader.type = segmentType;
  47963. segmentHeader.typeName = SegmentTypes[segmentType];
  47964. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  47965. var pageAssociationFieldSize = !!(flags & 0x40);
  47966. var referredFlags = data[start + 5];
  47967. var referredToCount = referredFlags >> 5 & 7;
  47968. var retainBits = [referredFlags & 31];
  47969. var position = start + 6;
  47970. if (referredFlags === 7) {
  47971. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  47972. position += 3;
  47973. var bytes = referredToCount + 7 >> 3;
  47974. retainBits[0] = data[position++];
  47975. while (--bytes > 0) {
  47976. retainBits.push(data[position++]);
  47977. }
  47978. } else if (referredFlags === 5 || referredFlags === 6) {
  47979. error('JBIG2 error: invalid referred-to flags');
  47980. }
  47981. segmentHeader.retainBits = retainBits;
  47982. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  47983. var referredTo = [];
  47984. var i, ii;
  47985. for (i = 0; i < referredToCount; i++) {
  47986. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  47987. referredTo.push(number);
  47988. position += referredToSegmentNumberSize;
  47989. }
  47990. segmentHeader.referredTo = referredTo;
  47991. if (!pageAssociationFieldSize) {
  47992. segmentHeader.pageAssociation = data[position++];
  47993. } else {
  47994. segmentHeader.pageAssociation = readUint32(data, position);
  47995. position += 4;
  47996. }
  47997. segmentHeader.length = readUint32(data, position);
  47998. position += 4;
  47999. if (segmentHeader.length === 0xFFFFFFFF) {
  48000. if (segmentType === 38) {
  48001. var genericRegionInfo = readRegionSegmentInformation(data, position);
  48002. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  48003. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  48004. var searchPatternLength = 6;
  48005. var searchPattern = new Uint8Array(searchPatternLength);
  48006. if (!genericRegionMmr) {
  48007. searchPattern[0] = 0xFF;
  48008. searchPattern[1] = 0xAC;
  48009. }
  48010. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  48011. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  48012. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  48013. searchPattern[5] = genericRegionInfo.height & 0xFF;
  48014. for (i = position, ii = data.length; i < ii; i++) {
  48015. var j = 0;
  48016. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  48017. j++;
  48018. }
  48019. if (j === searchPatternLength) {
  48020. segmentHeader.length = i + searchPatternLength;
  48021. break;
  48022. }
  48023. }
  48024. if (segmentHeader.length === 0xFFFFFFFF) {
  48025. error('JBIG2 error: segment end was not found');
  48026. }
  48027. } else {
  48028. error('JBIG2 error: invalid unknown segment length');
  48029. }
  48030. }
  48031. segmentHeader.headerEnd = position;
  48032. return segmentHeader;
  48033. }
  48034. function readSegments(header, data, start, end) {
  48035. var segments = [];
  48036. var position = start;
  48037. while (position < end) {
  48038. var segmentHeader = readSegmentHeader(data, position);
  48039. position = segmentHeader.headerEnd;
  48040. var segment = {
  48041. header: segmentHeader,
  48042. data: data
  48043. };
  48044. if (!header.randomAccess) {
  48045. segment.start = position;
  48046. position += segmentHeader.length;
  48047. segment.end = position;
  48048. }
  48049. segments.push(segment);
  48050. if (segmentHeader.type === 51) {
  48051. break;
  48052. }
  48053. }
  48054. if (header.randomAccess) {
  48055. for (var i = 0, ii = segments.length; i < ii; i++) {
  48056. segments[i].start = position;
  48057. position += segments[i].header.length;
  48058. segments[i].end = position;
  48059. }
  48060. }
  48061. return segments;
  48062. }
  48063. function readRegionSegmentInformation(data, start) {
  48064. return {
  48065. width: readUint32(data, start),
  48066. height: readUint32(data, start + 4),
  48067. x: readUint32(data, start + 8),
  48068. y: readUint32(data, start + 12),
  48069. combinationOperator: data[start + 16] & 7
  48070. };
  48071. }
  48072. var RegionSegmentInformationFieldLength = 17;
  48073. function processSegment(segment, visitor) {
  48074. var header = segment.header;
  48075. var data = segment.data, position = segment.start, end = segment.end;
  48076. var args, at, i, atLength;
  48077. switch (header.type) {
  48078. case 0:
  48079. var dictionary = {};
  48080. var dictionaryFlags = readUint16(data, position);
  48081. dictionary.huffman = !!(dictionaryFlags & 1);
  48082. dictionary.refinement = !!(dictionaryFlags & 2);
  48083. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  48084. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  48085. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  48086. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  48087. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  48088. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  48089. dictionary.template = dictionaryFlags >> 10 & 3;
  48090. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  48091. position += 2;
  48092. if (!dictionary.huffman) {
  48093. atLength = dictionary.template === 0 ? 4 : 1;
  48094. at = [];
  48095. for (i = 0; i < atLength; i++) {
  48096. at.push({
  48097. x: readInt8(data, position),
  48098. y: readInt8(data, position + 1)
  48099. });
  48100. position += 2;
  48101. }
  48102. dictionary.at = at;
  48103. }
  48104. if (dictionary.refinement && !dictionary.refinementTemplate) {
  48105. at = [];
  48106. for (i = 0; i < 2; i++) {
  48107. at.push({
  48108. x: readInt8(data, position),
  48109. y: readInt8(data, position + 1)
  48110. });
  48111. position += 2;
  48112. }
  48113. dictionary.refinementAt = at;
  48114. }
  48115. dictionary.numberOfExportedSymbols = readUint32(data, position);
  48116. position += 4;
  48117. dictionary.numberOfNewSymbols = readUint32(data, position);
  48118. position += 4;
  48119. args = [
  48120. dictionary,
  48121. header.number,
  48122. header.referredTo,
  48123. data,
  48124. position,
  48125. end
  48126. ];
  48127. break;
  48128. case 6:
  48129. case 7:
  48130. var textRegion = {};
  48131. textRegion.info = readRegionSegmentInformation(data, position);
  48132. position += RegionSegmentInformationFieldLength;
  48133. var textRegionSegmentFlags = readUint16(data, position);
  48134. position += 2;
  48135. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  48136. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  48137. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  48138. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  48139. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  48140. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  48141. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  48142. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  48143. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  48144. if (textRegion.huffman) {
  48145. var textRegionHuffmanFlags = readUint16(data, position);
  48146. position += 2;
  48147. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  48148. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  48149. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  48150. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  48151. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  48152. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  48153. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  48154. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  48155. }
  48156. if (textRegion.refinement && !textRegion.refinementTemplate) {
  48157. at = [];
  48158. for (i = 0; i < 2; i++) {
  48159. at.push({
  48160. x: readInt8(data, position),
  48161. y: readInt8(data, position + 1)
  48162. });
  48163. position += 2;
  48164. }
  48165. textRegion.refinementAt = at;
  48166. }
  48167. textRegion.numberOfSymbolInstances = readUint32(data, position);
  48168. position += 4;
  48169. if (textRegion.huffman) {
  48170. error('JBIG2 error: huffman is not supported');
  48171. }
  48172. args = [
  48173. textRegion,
  48174. header.referredTo,
  48175. data,
  48176. position,
  48177. end
  48178. ];
  48179. break;
  48180. case 38:
  48181. case 39:
  48182. var genericRegion = {};
  48183. genericRegion.info = readRegionSegmentInformation(data, position);
  48184. position += RegionSegmentInformationFieldLength;
  48185. var genericRegionSegmentFlags = data[position++];
  48186. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  48187. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  48188. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  48189. if (!genericRegion.mmr) {
  48190. atLength = genericRegion.template === 0 ? 4 : 1;
  48191. at = [];
  48192. for (i = 0; i < atLength; i++) {
  48193. at.push({
  48194. x: readInt8(data, position),
  48195. y: readInt8(data, position + 1)
  48196. });
  48197. position += 2;
  48198. }
  48199. genericRegion.at = at;
  48200. }
  48201. args = [
  48202. genericRegion,
  48203. data,
  48204. position,
  48205. end
  48206. ];
  48207. break;
  48208. case 48:
  48209. var pageInfo = {
  48210. width: readUint32(data, position),
  48211. height: readUint32(data, position + 4),
  48212. resolutionX: readUint32(data, position + 8),
  48213. resolutionY: readUint32(data, position + 12)
  48214. };
  48215. if (pageInfo.height === 0xFFFFFFFF) {
  48216. delete pageInfo.height;
  48217. }
  48218. var pageSegmentFlags = data[position + 16];
  48219. readUint16(data, position + 17);
  48220. pageInfo.lossless = !!(pageSegmentFlags & 1);
  48221. pageInfo.refinement = !!(pageSegmentFlags & 2);
  48222. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  48223. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  48224. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  48225. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  48226. args = [pageInfo];
  48227. break;
  48228. case 49:
  48229. break;
  48230. case 50:
  48231. break;
  48232. case 51:
  48233. break;
  48234. case 62:
  48235. break;
  48236. default:
  48237. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  48238. }
  48239. var callbackName = 'on' + header.typeName;
  48240. if (callbackName in visitor) {
  48241. visitor[callbackName].apply(visitor, args);
  48242. }
  48243. }
  48244. function processSegments(segments, visitor) {
  48245. for (var i = 0, ii = segments.length; i < ii; i++) {
  48246. processSegment(segments[i], visitor);
  48247. }
  48248. }
  48249. function parseJbig2(data, start, end) {
  48250. var position = start;
  48251. 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) {
  48252. error('JBIG2 error: invalid header');
  48253. }
  48254. var header = {};
  48255. position += 8;
  48256. var flags = data[position++];
  48257. header.randomAccess = !(flags & 1);
  48258. if (!(flags & 2)) {
  48259. header.numberOfPages = readUint32(data, position);
  48260. position += 4;
  48261. }
  48262. readSegments(header, data, position, end);
  48263. error('Not implemented');
  48264. }
  48265. function parseJbig2Chunks(chunks) {
  48266. var visitor = new SimpleSegmentVisitor();
  48267. for (var i = 0, ii = chunks.length; i < ii; i++) {
  48268. var chunk = chunks[i];
  48269. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  48270. processSegments(segments, visitor);
  48271. }
  48272. return visitor.buffer;
  48273. }
  48274. function SimpleSegmentVisitor() {
  48275. }
  48276. SimpleSegmentVisitor.prototype = {
  48277. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  48278. this.currentPageInfo = info;
  48279. var rowSize = info.width + 7 >> 3;
  48280. var buffer = new Uint8Array(rowSize * info.height);
  48281. if (info.defaultPixelValue) {
  48282. for (var i = 0, ii = buffer.length; i < ii; i++) {
  48283. buffer[i] = 0xFF;
  48284. }
  48285. }
  48286. this.buffer = buffer;
  48287. },
  48288. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  48289. var pageInfo = this.currentPageInfo;
  48290. var width = regionInfo.width, height = regionInfo.height;
  48291. var rowSize = pageInfo.width + 7 >> 3;
  48292. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  48293. var buffer = this.buffer;
  48294. var mask0 = 128 >> (regionInfo.x & 7);
  48295. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  48296. var i, j, mask, offset;
  48297. switch (combinationOperator) {
  48298. case 0:
  48299. for (i = 0; i < height; i++) {
  48300. mask = mask0;
  48301. offset = offset0;
  48302. for (j = 0; j < width; j++) {
  48303. if (bitmap[i][j]) {
  48304. buffer[offset] |= mask;
  48305. }
  48306. mask >>= 1;
  48307. if (!mask) {
  48308. mask = 128;
  48309. offset++;
  48310. }
  48311. }
  48312. offset0 += rowSize;
  48313. }
  48314. break;
  48315. case 2:
  48316. for (i = 0; i < height; i++) {
  48317. mask = mask0;
  48318. offset = offset0;
  48319. for (j = 0; j < width; j++) {
  48320. if (bitmap[i][j]) {
  48321. buffer[offset] ^= mask;
  48322. }
  48323. mask >>= 1;
  48324. if (!mask) {
  48325. mask = 128;
  48326. offset++;
  48327. }
  48328. }
  48329. offset0 += rowSize;
  48330. }
  48331. break;
  48332. default:
  48333. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  48334. }
  48335. },
  48336. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  48337. var regionInfo = region.info;
  48338. var decodingContext = new DecodingContext(data, start, end);
  48339. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  48340. this.drawBitmap(regionInfo, bitmap);
  48341. },
  48342. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  48343. this.onImmediateGenericRegion.apply(this, arguments);
  48344. },
  48345. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  48346. var huffmanTables;
  48347. if (dictionary.huffman) {
  48348. error('JBIG2 error: huffman is not supported');
  48349. }
  48350. var symbols = this.symbols;
  48351. if (!symbols) {
  48352. this.symbols = symbols = {};
  48353. }
  48354. var inputSymbols = [];
  48355. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48356. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48357. }
  48358. var decodingContext = new DecodingContext(data, start, end);
  48359. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  48360. },
  48361. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  48362. var regionInfo = region.info;
  48363. var huffmanTables;
  48364. var symbols = this.symbols;
  48365. var inputSymbols = [];
  48366. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48367. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48368. }
  48369. var symbolCodeLength = log2(inputSymbols.length);
  48370. var decodingContext = new DecodingContext(data, start, end);
  48371. 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);
  48372. this.drawBitmap(regionInfo, bitmap);
  48373. },
  48374. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  48375. this.onImmediateTextRegion.apply(this, arguments);
  48376. }
  48377. };
  48378. function Jbig2Image() {
  48379. }
  48380. Jbig2Image.prototype = {
  48381. parseChunks: function Jbig2Image_parseChunks(chunks) {
  48382. return parseJbig2Chunks(chunks);
  48383. }
  48384. };
  48385. return Jbig2Image;
  48386. }();
  48387. exports.Jbig2Image = Jbig2Image;
  48388. /***/ }),
  48389. /* 36 */
  48390. /***/ (function(module, exports, __w_pdfjs_require__) {
  48391. "use strict";
  48392. var sharedUtil = __w_pdfjs_require__(0);
  48393. var error = sharedUtil.error;
  48394. var JpegImage = function JpegImageClosure() {
  48395. var dctZigZag = new Uint8Array([
  48396. 0,
  48397. 1,
  48398. 8,
  48399. 16,
  48400. 9,
  48401. 2,
  48402. 3,
  48403. 10,
  48404. 17,
  48405. 24,
  48406. 32,
  48407. 25,
  48408. 18,
  48409. 11,
  48410. 4,
  48411. 5,
  48412. 12,
  48413. 19,
  48414. 26,
  48415. 33,
  48416. 40,
  48417. 48,
  48418. 41,
  48419. 34,
  48420. 27,
  48421. 20,
  48422. 13,
  48423. 6,
  48424. 7,
  48425. 14,
  48426. 21,
  48427. 28,
  48428. 35,
  48429. 42,
  48430. 49,
  48431. 56,
  48432. 57,
  48433. 50,
  48434. 43,
  48435. 36,
  48436. 29,
  48437. 22,
  48438. 15,
  48439. 23,
  48440. 30,
  48441. 37,
  48442. 44,
  48443. 51,
  48444. 58,
  48445. 59,
  48446. 52,
  48447. 45,
  48448. 38,
  48449. 31,
  48450. 39,
  48451. 46,
  48452. 53,
  48453. 60,
  48454. 61,
  48455. 54,
  48456. 47,
  48457. 55,
  48458. 62,
  48459. 63
  48460. ]);
  48461. var dctCos1 = 4017;
  48462. var dctSin1 = 799;
  48463. var dctCos3 = 3406;
  48464. var dctSin3 = 2276;
  48465. var dctCos6 = 1567;
  48466. var dctSin6 = 3784;
  48467. var dctSqrt2 = 5793;
  48468. var dctSqrt1d2 = 2896;
  48469. function JpegImage() {
  48470. this.decodeTransform = null;
  48471. this.colorTransform = -1;
  48472. }
  48473. function buildHuffmanTable(codeLengths, values) {
  48474. var k = 0, code = [], i, j, length = 16;
  48475. while (length > 0 && !codeLengths[length - 1]) {
  48476. length--;
  48477. }
  48478. code.push({
  48479. children: [],
  48480. index: 0
  48481. });
  48482. var p = code[0], q;
  48483. for (i = 0; i < length; i++) {
  48484. for (j = 0; j < codeLengths[i]; j++) {
  48485. p = code.pop();
  48486. p.children[p.index] = values[k];
  48487. while (p.index > 0) {
  48488. p = code.pop();
  48489. }
  48490. p.index++;
  48491. code.push(p);
  48492. while (code.length <= i) {
  48493. code.push(q = {
  48494. children: [],
  48495. index: 0
  48496. });
  48497. p.children[p.index] = q.children;
  48498. p = q;
  48499. }
  48500. k++;
  48501. }
  48502. if (i + 1 < length) {
  48503. code.push(q = {
  48504. children: [],
  48505. index: 0
  48506. });
  48507. p.children[p.index] = q.children;
  48508. p = q;
  48509. }
  48510. }
  48511. return code[0].children;
  48512. }
  48513. function getBlockBufferOffset(component, row, col) {
  48514. return 64 * ((component.blocksPerLine + 1) * row + col);
  48515. }
  48516. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  48517. var mcusPerLine = frame.mcusPerLine;
  48518. var progressive = frame.progressive;
  48519. var startOffset = offset, bitsData = 0, bitsCount = 0;
  48520. function readBit() {
  48521. if (bitsCount > 0) {
  48522. bitsCount--;
  48523. return bitsData >> bitsCount & 1;
  48524. }
  48525. bitsData = data[offset++];
  48526. if (bitsData === 0xFF) {
  48527. var nextByte = data[offset++];
  48528. if (nextByte) {
  48529. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  48530. }
  48531. }
  48532. bitsCount = 7;
  48533. return bitsData >>> 7;
  48534. }
  48535. function decodeHuffman(tree) {
  48536. var node = tree;
  48537. while (true) {
  48538. node = node[readBit()];
  48539. if (typeof node === 'number') {
  48540. return node;
  48541. }
  48542. if (typeof node !== 'object') {
  48543. error('JPEG error: invalid huffman sequence');
  48544. }
  48545. }
  48546. }
  48547. function receive(length) {
  48548. var n = 0;
  48549. while (length > 0) {
  48550. n = n << 1 | readBit();
  48551. length--;
  48552. }
  48553. return n;
  48554. }
  48555. function receiveAndExtend(length) {
  48556. if (length === 1) {
  48557. return readBit() === 1 ? 1 : -1;
  48558. }
  48559. var n = receive(length);
  48560. if (n >= 1 << length - 1) {
  48561. return n;
  48562. }
  48563. return n + (-1 << length) + 1;
  48564. }
  48565. function decodeBaseline(component, offset) {
  48566. var t = decodeHuffman(component.huffmanTableDC);
  48567. var diff = t === 0 ? 0 : receiveAndExtend(t);
  48568. component.blockData[offset] = component.pred += diff;
  48569. var k = 1;
  48570. while (k < 64) {
  48571. var rs = decodeHuffman(component.huffmanTableAC);
  48572. var s = rs & 15, r = rs >> 4;
  48573. if (s === 0) {
  48574. if (r < 15) {
  48575. break;
  48576. }
  48577. k += 16;
  48578. continue;
  48579. }
  48580. k += r;
  48581. var z = dctZigZag[k];
  48582. component.blockData[offset + z] = receiveAndExtend(s);
  48583. k++;
  48584. }
  48585. }
  48586. function decodeDCFirst(component, offset) {
  48587. var t = decodeHuffman(component.huffmanTableDC);
  48588. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  48589. component.blockData[offset] = component.pred += diff;
  48590. }
  48591. function decodeDCSuccessive(component, offset) {
  48592. component.blockData[offset] |= readBit() << successive;
  48593. }
  48594. var eobrun = 0;
  48595. function decodeACFirst(component, offset) {
  48596. if (eobrun > 0) {
  48597. eobrun--;
  48598. return;
  48599. }
  48600. var k = spectralStart, e = spectralEnd;
  48601. while (k <= e) {
  48602. var rs = decodeHuffman(component.huffmanTableAC);
  48603. var s = rs & 15, r = rs >> 4;
  48604. if (s === 0) {
  48605. if (r < 15) {
  48606. eobrun = receive(r) + (1 << r) - 1;
  48607. break;
  48608. }
  48609. k += 16;
  48610. continue;
  48611. }
  48612. k += r;
  48613. var z = dctZigZag[k];
  48614. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  48615. k++;
  48616. }
  48617. }
  48618. var successiveACState = 0, successiveACNextValue;
  48619. function decodeACSuccessive(component, offset) {
  48620. var k = spectralStart;
  48621. var e = spectralEnd;
  48622. var r = 0;
  48623. var s;
  48624. var rs;
  48625. while (k <= e) {
  48626. var z = dctZigZag[k];
  48627. switch (successiveACState) {
  48628. case 0:
  48629. rs = decodeHuffman(component.huffmanTableAC);
  48630. s = rs & 15;
  48631. r = rs >> 4;
  48632. if (s === 0) {
  48633. if (r < 15) {
  48634. eobrun = receive(r) + (1 << r);
  48635. successiveACState = 4;
  48636. } else {
  48637. r = 16;
  48638. successiveACState = 1;
  48639. }
  48640. } else {
  48641. if (s !== 1) {
  48642. error('JPEG error: invalid ACn encoding');
  48643. }
  48644. successiveACNextValue = receiveAndExtend(s);
  48645. successiveACState = r ? 2 : 3;
  48646. }
  48647. continue;
  48648. case 1:
  48649. case 2:
  48650. if (component.blockData[offset + z]) {
  48651. component.blockData[offset + z] += readBit() << successive;
  48652. } else {
  48653. r--;
  48654. if (r === 0) {
  48655. successiveACState = successiveACState === 2 ? 3 : 0;
  48656. }
  48657. }
  48658. break;
  48659. case 3:
  48660. if (component.blockData[offset + z]) {
  48661. component.blockData[offset + z] += readBit() << successive;
  48662. } else {
  48663. component.blockData[offset + z] = successiveACNextValue << successive;
  48664. successiveACState = 0;
  48665. }
  48666. break;
  48667. case 4:
  48668. if (component.blockData[offset + z]) {
  48669. component.blockData[offset + z] += readBit() << successive;
  48670. }
  48671. break;
  48672. }
  48673. k++;
  48674. }
  48675. if (successiveACState === 4) {
  48676. eobrun--;
  48677. if (eobrun === 0) {
  48678. successiveACState = 0;
  48679. }
  48680. }
  48681. }
  48682. function decodeMcu(component, decode, mcu, row, col) {
  48683. var mcuRow = mcu / mcusPerLine | 0;
  48684. var mcuCol = mcu % mcusPerLine;
  48685. var blockRow = mcuRow * component.v + row;
  48686. var blockCol = mcuCol * component.h + col;
  48687. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48688. decode(component, offset);
  48689. }
  48690. function decodeBlock(component, decode, mcu) {
  48691. var blockRow = mcu / component.blocksPerLine | 0;
  48692. var blockCol = mcu % component.blocksPerLine;
  48693. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48694. decode(component, offset);
  48695. }
  48696. var componentsLength = components.length;
  48697. var component, i, j, k, n;
  48698. var decodeFn;
  48699. if (progressive) {
  48700. if (spectralStart === 0) {
  48701. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  48702. } else {
  48703. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  48704. }
  48705. } else {
  48706. decodeFn = decodeBaseline;
  48707. }
  48708. var mcu = 0, marker;
  48709. var mcuExpected;
  48710. if (componentsLength === 1) {
  48711. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  48712. } else {
  48713. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  48714. }
  48715. if (!resetInterval) {
  48716. resetInterval = mcuExpected;
  48717. }
  48718. var h, v;
  48719. while (mcu < mcuExpected) {
  48720. for (i = 0; i < componentsLength; i++) {
  48721. components[i].pred = 0;
  48722. }
  48723. eobrun = 0;
  48724. if (componentsLength === 1) {
  48725. component = components[0];
  48726. for (n = 0; n < resetInterval; n++) {
  48727. decodeBlock(component, decodeFn, mcu);
  48728. mcu++;
  48729. }
  48730. } else {
  48731. for (n = 0; n < resetInterval; n++) {
  48732. for (i = 0; i < componentsLength; i++) {
  48733. component = components[i];
  48734. h = component.h;
  48735. v = component.v;
  48736. for (j = 0; j < v; j++) {
  48737. for (k = 0; k < h; k++) {
  48738. decodeMcu(component, decodeFn, mcu, j, k);
  48739. }
  48740. }
  48741. }
  48742. mcu++;
  48743. }
  48744. }
  48745. bitsCount = 0;
  48746. marker = data[offset] << 8 | data[offset + 1];
  48747. while (data[offset] === 0x00 && offset < data.length - 1) {
  48748. offset++;
  48749. marker = data[offset] << 8 | data[offset + 1];
  48750. }
  48751. if (marker <= 0xFF00) {
  48752. error('JPEG error: marker was not found');
  48753. }
  48754. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  48755. offset += 2;
  48756. } else {
  48757. break;
  48758. }
  48759. }
  48760. return offset - startOffset;
  48761. }
  48762. function quantizeAndInverse(component, blockBufferOffset, p) {
  48763. var qt = component.quantizationTable, blockData = component.blockData;
  48764. var v0, v1, v2, v3, v4, v5, v6, v7;
  48765. var p0, p1, p2, p3, p4, p5, p6, p7;
  48766. var t;
  48767. if (!qt) {
  48768. error('JPEG error: missing required Quantization Table.');
  48769. }
  48770. for (var row = 0; row < 64; row += 8) {
  48771. p0 = blockData[blockBufferOffset + row];
  48772. p1 = blockData[blockBufferOffset + row + 1];
  48773. p2 = blockData[blockBufferOffset + row + 2];
  48774. p3 = blockData[blockBufferOffset + row + 3];
  48775. p4 = blockData[blockBufferOffset + row + 4];
  48776. p5 = blockData[blockBufferOffset + row + 5];
  48777. p6 = blockData[blockBufferOffset + row + 6];
  48778. p7 = blockData[blockBufferOffset + row + 7];
  48779. p0 *= qt[row];
  48780. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48781. t = dctSqrt2 * p0 + 512 >> 10;
  48782. p[row] = t;
  48783. p[row + 1] = t;
  48784. p[row + 2] = t;
  48785. p[row + 3] = t;
  48786. p[row + 4] = t;
  48787. p[row + 5] = t;
  48788. p[row + 6] = t;
  48789. p[row + 7] = t;
  48790. continue;
  48791. }
  48792. p1 *= qt[row + 1];
  48793. p2 *= qt[row + 2];
  48794. p3 *= qt[row + 3];
  48795. p4 *= qt[row + 4];
  48796. p5 *= qt[row + 5];
  48797. p6 *= qt[row + 6];
  48798. p7 *= qt[row + 7];
  48799. v0 = dctSqrt2 * p0 + 128 >> 8;
  48800. v1 = dctSqrt2 * p4 + 128 >> 8;
  48801. v2 = p2;
  48802. v3 = p6;
  48803. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  48804. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  48805. v5 = p3 << 4;
  48806. v6 = p5 << 4;
  48807. v0 = v0 + v1 + 1 >> 1;
  48808. v1 = v0 - v1;
  48809. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  48810. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  48811. v3 = t;
  48812. v4 = v4 + v6 + 1 >> 1;
  48813. v6 = v4 - v6;
  48814. v7 = v7 + v5 + 1 >> 1;
  48815. v5 = v7 - v5;
  48816. v0 = v0 + v3 + 1 >> 1;
  48817. v3 = v0 - v3;
  48818. v1 = v1 + v2 + 1 >> 1;
  48819. v2 = v1 - v2;
  48820. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48821. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48822. v7 = t;
  48823. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48824. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48825. v6 = t;
  48826. p[row] = v0 + v7;
  48827. p[row + 7] = v0 - v7;
  48828. p[row + 1] = v1 + v6;
  48829. p[row + 6] = v1 - v6;
  48830. p[row + 2] = v2 + v5;
  48831. p[row + 5] = v2 - v5;
  48832. p[row + 3] = v3 + v4;
  48833. p[row + 4] = v3 - v4;
  48834. }
  48835. for (var col = 0; col < 8; ++col) {
  48836. p0 = p[col];
  48837. p1 = p[col + 8];
  48838. p2 = p[col + 16];
  48839. p3 = p[col + 24];
  48840. p4 = p[col + 32];
  48841. p5 = p[col + 40];
  48842. p6 = p[col + 48];
  48843. p7 = p[col + 56];
  48844. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48845. t = dctSqrt2 * p0 + 8192 >> 14;
  48846. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  48847. blockData[blockBufferOffset + col] = t;
  48848. blockData[blockBufferOffset + col + 8] = t;
  48849. blockData[blockBufferOffset + col + 16] = t;
  48850. blockData[blockBufferOffset + col + 24] = t;
  48851. blockData[blockBufferOffset + col + 32] = t;
  48852. blockData[blockBufferOffset + col + 40] = t;
  48853. blockData[blockBufferOffset + col + 48] = t;
  48854. blockData[blockBufferOffset + col + 56] = t;
  48855. continue;
  48856. }
  48857. v0 = dctSqrt2 * p0 + 2048 >> 12;
  48858. v1 = dctSqrt2 * p4 + 2048 >> 12;
  48859. v2 = p2;
  48860. v3 = p6;
  48861. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  48862. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  48863. v5 = p3;
  48864. v6 = p5;
  48865. v0 = (v0 + v1 + 1 >> 1) + 4112;
  48866. v1 = v0 - v1;
  48867. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  48868. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  48869. v3 = t;
  48870. v4 = v4 + v6 + 1 >> 1;
  48871. v6 = v4 - v6;
  48872. v7 = v7 + v5 + 1 >> 1;
  48873. v5 = v7 - v5;
  48874. v0 = v0 + v3 + 1 >> 1;
  48875. v3 = v0 - v3;
  48876. v1 = v1 + v2 + 1 >> 1;
  48877. v2 = v1 - v2;
  48878. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48879. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48880. v7 = t;
  48881. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48882. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48883. v6 = t;
  48884. p0 = v0 + v7;
  48885. p7 = v0 - v7;
  48886. p1 = v1 + v6;
  48887. p6 = v1 - v6;
  48888. p2 = v2 + v5;
  48889. p5 = v2 - v5;
  48890. p3 = v3 + v4;
  48891. p4 = v3 - v4;
  48892. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  48893. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  48894. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  48895. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  48896. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  48897. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  48898. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  48899. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  48900. blockData[blockBufferOffset + col] = p0;
  48901. blockData[blockBufferOffset + col + 8] = p1;
  48902. blockData[blockBufferOffset + col + 16] = p2;
  48903. blockData[blockBufferOffset + col + 24] = p3;
  48904. blockData[blockBufferOffset + col + 32] = p4;
  48905. blockData[blockBufferOffset + col + 40] = p5;
  48906. blockData[blockBufferOffset + col + 48] = p6;
  48907. blockData[blockBufferOffset + col + 56] = p7;
  48908. }
  48909. }
  48910. function buildComponentData(frame, component) {
  48911. var blocksPerLine = component.blocksPerLine;
  48912. var blocksPerColumn = component.blocksPerColumn;
  48913. var computationBuffer = new Int16Array(64);
  48914. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  48915. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  48916. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48917. quantizeAndInverse(component, offset, computationBuffer);
  48918. }
  48919. }
  48920. return component.blockData;
  48921. }
  48922. function clamp0to255(a) {
  48923. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  48924. }
  48925. JpegImage.prototype = {
  48926. parse: function parse(data) {
  48927. function readUint16() {
  48928. var value = data[offset] << 8 | data[offset + 1];
  48929. offset += 2;
  48930. return value;
  48931. }
  48932. function readDataBlock() {
  48933. var length = readUint16();
  48934. var array = data.subarray(offset, offset + length - 2);
  48935. offset += array.length;
  48936. return array;
  48937. }
  48938. function prepareComponents(frame) {
  48939. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  48940. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  48941. for (var i = 0; i < frame.components.length; i++) {
  48942. component = frame.components[i];
  48943. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  48944. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  48945. var blocksPerLineForMcu = mcusPerLine * component.h;
  48946. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  48947. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  48948. component.blockData = new Int16Array(blocksBufferSize);
  48949. component.blocksPerLine = blocksPerLine;
  48950. component.blocksPerColumn = blocksPerColumn;
  48951. }
  48952. frame.mcusPerLine = mcusPerLine;
  48953. frame.mcusPerColumn = mcusPerColumn;
  48954. }
  48955. var offset = 0;
  48956. var jfif = null;
  48957. var adobe = null;
  48958. var frame, resetInterval;
  48959. var quantizationTables = [];
  48960. var huffmanTablesAC = [], huffmanTablesDC = [];
  48961. var fileMarker = readUint16();
  48962. if (fileMarker !== 0xFFD8) {
  48963. error('JPEG error: SOI not found');
  48964. }
  48965. fileMarker = readUint16();
  48966. while (fileMarker !== 0xFFD9) {
  48967. var i, j, l;
  48968. switch (fileMarker) {
  48969. case 0xFFE0:
  48970. case 0xFFE1:
  48971. case 0xFFE2:
  48972. case 0xFFE3:
  48973. case 0xFFE4:
  48974. case 0xFFE5:
  48975. case 0xFFE6:
  48976. case 0xFFE7:
  48977. case 0xFFE8:
  48978. case 0xFFE9:
  48979. case 0xFFEA:
  48980. case 0xFFEB:
  48981. case 0xFFEC:
  48982. case 0xFFED:
  48983. case 0xFFEE:
  48984. case 0xFFEF:
  48985. case 0xFFFE:
  48986. var appData = readDataBlock();
  48987. if (fileMarker === 0xFFE0) {
  48988. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  48989. jfif = {
  48990. version: {
  48991. major: appData[5],
  48992. minor: appData[6]
  48993. },
  48994. densityUnits: appData[7],
  48995. xDensity: appData[8] << 8 | appData[9],
  48996. yDensity: appData[10] << 8 | appData[11],
  48997. thumbWidth: appData[12],
  48998. thumbHeight: appData[13],
  48999. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  49000. };
  49001. }
  49002. }
  49003. if (fileMarker === 0xFFEE) {
  49004. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  49005. adobe = {
  49006. version: appData[5] << 8 | appData[6],
  49007. flags0: appData[7] << 8 | appData[8],
  49008. flags1: appData[9] << 8 | appData[10],
  49009. transformCode: appData[11]
  49010. };
  49011. }
  49012. }
  49013. break;
  49014. case 0xFFDB:
  49015. var quantizationTablesLength = readUint16();
  49016. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  49017. var z;
  49018. while (offset < quantizationTablesEnd) {
  49019. var quantizationTableSpec = data[offset++];
  49020. var tableData = new Uint16Array(64);
  49021. if (quantizationTableSpec >> 4 === 0) {
  49022. for (j = 0; j < 64; j++) {
  49023. z = dctZigZag[j];
  49024. tableData[z] = data[offset++];
  49025. }
  49026. } else if (quantizationTableSpec >> 4 === 1) {
  49027. for (j = 0; j < 64; j++) {
  49028. z = dctZigZag[j];
  49029. tableData[z] = readUint16();
  49030. }
  49031. } else {
  49032. error('JPEG error: DQT - invalid table spec');
  49033. }
  49034. quantizationTables[quantizationTableSpec & 15] = tableData;
  49035. }
  49036. break;
  49037. case 0xFFC0:
  49038. case 0xFFC1:
  49039. case 0xFFC2:
  49040. if (frame) {
  49041. error('JPEG error: Only single frame JPEGs supported');
  49042. }
  49043. readUint16();
  49044. frame = {};
  49045. frame.extended = fileMarker === 0xFFC1;
  49046. frame.progressive = fileMarker === 0xFFC2;
  49047. frame.precision = data[offset++];
  49048. frame.scanLines = readUint16();
  49049. frame.samplesPerLine = readUint16();
  49050. frame.components = [];
  49051. frame.componentIds = {};
  49052. var componentsCount = data[offset++], componentId;
  49053. var maxH = 0, maxV = 0;
  49054. for (i = 0; i < componentsCount; i++) {
  49055. componentId = data[offset];
  49056. var h = data[offset + 1] >> 4;
  49057. var v = data[offset + 1] & 15;
  49058. if (maxH < h) {
  49059. maxH = h;
  49060. }
  49061. if (maxV < v) {
  49062. maxV = v;
  49063. }
  49064. var qId = data[offset + 2];
  49065. l = frame.components.push({
  49066. h: h,
  49067. v: v,
  49068. quantizationId: qId,
  49069. quantizationTable: null
  49070. });
  49071. frame.componentIds[componentId] = l - 1;
  49072. offset += 3;
  49073. }
  49074. frame.maxH = maxH;
  49075. frame.maxV = maxV;
  49076. prepareComponents(frame);
  49077. break;
  49078. case 0xFFC4:
  49079. var huffmanLength = readUint16();
  49080. for (i = 2; i < huffmanLength;) {
  49081. var huffmanTableSpec = data[offset++];
  49082. var codeLengths = new Uint8Array(16);
  49083. var codeLengthSum = 0;
  49084. for (j = 0; j < 16; j++, offset++) {
  49085. codeLengthSum += codeLengths[j] = data[offset];
  49086. }
  49087. var huffmanValues = new Uint8Array(codeLengthSum);
  49088. for (j = 0; j < codeLengthSum; j++, offset++) {
  49089. huffmanValues[j] = data[offset];
  49090. }
  49091. i += 17 + codeLengthSum;
  49092. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  49093. }
  49094. break;
  49095. case 0xFFDD:
  49096. readUint16();
  49097. resetInterval = readUint16();
  49098. break;
  49099. case 0xFFDA:
  49100. readUint16();
  49101. var selectorsCount = data[offset++];
  49102. var components = [], component;
  49103. for (i = 0; i < selectorsCount; i++) {
  49104. var componentIndex = frame.componentIds[data[offset++]];
  49105. component = frame.components[componentIndex];
  49106. var tableSpec = data[offset++];
  49107. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  49108. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  49109. components.push(component);
  49110. }
  49111. var spectralStart = data[offset++];
  49112. var spectralEnd = data[offset++];
  49113. var successiveApproximation = data[offset++];
  49114. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  49115. offset += processed;
  49116. break;
  49117. case 0xFFFF:
  49118. if (data[offset] !== 0xFF) {
  49119. offset--;
  49120. }
  49121. break;
  49122. default:
  49123. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  49124. offset -= 3;
  49125. break;
  49126. }
  49127. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  49128. }
  49129. fileMarker = readUint16();
  49130. }
  49131. this.width = frame.samplesPerLine;
  49132. this.height = frame.scanLines;
  49133. this.jfif = jfif;
  49134. this.adobe = adobe;
  49135. this.components = [];
  49136. for (i = 0; i < frame.components.length; i++) {
  49137. component = frame.components[i];
  49138. var quantizationTable = quantizationTables[component.quantizationId];
  49139. if (quantizationTable) {
  49140. component.quantizationTable = quantizationTable;
  49141. }
  49142. this.components.push({
  49143. output: buildComponentData(frame, component),
  49144. scaleX: component.h / frame.maxH,
  49145. scaleY: component.v / frame.maxV,
  49146. blocksPerLine: component.blocksPerLine,
  49147. blocksPerColumn: component.blocksPerColumn
  49148. });
  49149. }
  49150. this.numComponents = this.components.length;
  49151. },
  49152. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  49153. var scaleX = this.width / width, scaleY = this.height / height;
  49154. var component, componentScaleX, componentScaleY, blocksPerScanline;
  49155. var x, y, i, j, k;
  49156. var index;
  49157. var offset = 0;
  49158. var output;
  49159. var numComponents = this.components.length;
  49160. var dataLength = width * height * numComponents;
  49161. var data = new Uint8Array(dataLength);
  49162. var xScaleBlockOffset = new Uint32Array(width);
  49163. var mask3LSB = 0xfffffff8;
  49164. for (i = 0; i < numComponents; i++) {
  49165. component = this.components[i];
  49166. componentScaleX = component.scaleX * scaleX;
  49167. componentScaleY = component.scaleY * scaleY;
  49168. offset = i;
  49169. output = component.output;
  49170. blocksPerScanline = component.blocksPerLine + 1 << 3;
  49171. for (x = 0; x < width; x++) {
  49172. j = 0 | x * componentScaleX;
  49173. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  49174. }
  49175. for (y = 0; y < height; y++) {
  49176. j = 0 | y * componentScaleY;
  49177. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  49178. for (x = 0; x < width; x++) {
  49179. data[offset] = output[index + xScaleBlockOffset[x]];
  49180. offset += numComponents;
  49181. }
  49182. }
  49183. }
  49184. var transform = this.decodeTransform;
  49185. if (transform) {
  49186. for (i = 0; i < dataLength;) {
  49187. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  49188. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  49189. }
  49190. }
  49191. }
  49192. return data;
  49193. },
  49194. _isColorConversionNeeded: function isColorConversionNeeded() {
  49195. if (this.adobe && this.adobe.transformCode) {
  49196. return true;
  49197. } else if (this.numComponents === 3) {
  49198. if (!this.adobe && this.colorTransform === 0) {
  49199. return false;
  49200. }
  49201. return true;
  49202. }
  49203. if (!this.adobe && this.colorTransform === 1) {
  49204. return true;
  49205. }
  49206. return false;
  49207. },
  49208. _convertYccToRgb: function convertYccToRgb(data) {
  49209. var Y, Cb, Cr;
  49210. for (var i = 0, length = data.length; i < length; i += 3) {
  49211. Y = data[i];
  49212. Cb = data[i + 1];
  49213. Cr = data[i + 2];
  49214. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  49215. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  49216. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  49217. }
  49218. return data;
  49219. },
  49220. _convertYcckToRgb: function convertYcckToRgb(data) {
  49221. var Y, Cb, Cr, k;
  49222. var offset = 0;
  49223. for (var i = 0, length = data.length; i < length; i += 4) {
  49224. Y = data[i];
  49225. Cb = data[i + 1];
  49226. Cr = data[i + 2];
  49227. k = data[i + 3];
  49228. 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);
  49229. 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);
  49230. 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);
  49231. data[offset++] = clamp0to255(r);
  49232. data[offset++] = clamp0to255(g);
  49233. data[offset++] = clamp0to255(b);
  49234. }
  49235. return data;
  49236. },
  49237. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  49238. var Y, Cb, Cr;
  49239. for (var i = 0, length = data.length; i < length; i += 4) {
  49240. Y = data[i];
  49241. Cb = data[i + 1];
  49242. Cr = data[i + 2];
  49243. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  49244. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  49245. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  49246. }
  49247. return data;
  49248. },
  49249. _convertCmykToRgb: function convertCmykToRgb(data) {
  49250. var c, m, y, k;
  49251. var offset = 0;
  49252. var min = -255 * 255 * 255;
  49253. var scale = 1 / 255 / 255;
  49254. for (var i = 0, length = data.length; i < length; i += 4) {
  49255. c = data[i];
  49256. m = data[i + 1];
  49257. y = data[i + 2];
  49258. k = data[i + 3];
  49259. 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);
  49260. 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);
  49261. 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);
  49262. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  49263. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  49264. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  49265. }
  49266. return data;
  49267. },
  49268. getData: function getData(width, height, forceRGBoutput) {
  49269. if (this.numComponents > 4) {
  49270. error('JPEG error: Unsupported color mode');
  49271. }
  49272. var data = this._getLinearizedBlockData(width, height);
  49273. if (this.numComponents === 1 && forceRGBoutput) {
  49274. var dataLength = data.length;
  49275. var rgbData = new Uint8Array(dataLength * 3);
  49276. var offset = 0;
  49277. for (var i = 0; i < dataLength; i++) {
  49278. var grayColor = data[i];
  49279. rgbData[offset++] = grayColor;
  49280. rgbData[offset++] = grayColor;
  49281. rgbData[offset++] = grayColor;
  49282. }
  49283. return rgbData;
  49284. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  49285. return this._convertYccToRgb(data);
  49286. } else if (this.numComponents === 4) {
  49287. if (this._isColorConversionNeeded()) {
  49288. if (forceRGBoutput) {
  49289. return this._convertYcckToRgb(data);
  49290. }
  49291. return this._convertYcckToCmyk(data);
  49292. } else if (forceRGBoutput) {
  49293. return this._convertCmykToRgb(data);
  49294. }
  49295. }
  49296. return data;
  49297. }
  49298. };
  49299. return JpegImage;
  49300. }();
  49301. exports.JpegImage = JpegImage;
  49302. /***/ }),
  49303. /* 37 */
  49304. /***/ (function(module, exports, __w_pdfjs_require__) {
  49305. "use strict";
  49306. var sharedUtil = __w_pdfjs_require__(0);
  49307. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  49308. var getMetrics = getLookupTableFactory(function (t) {
  49309. t['Courier'] = 600;
  49310. t['Courier-Bold'] = 600;
  49311. t['Courier-BoldOblique'] = 600;
  49312. t['Courier-Oblique'] = 600;
  49313. t['Helvetica'] = getLookupTableFactory(function (t) {
  49314. t['space'] = 278;
  49315. t['exclam'] = 278;
  49316. t['quotedbl'] = 355;
  49317. t['numbersign'] = 556;
  49318. t['dollar'] = 556;
  49319. t['percent'] = 889;
  49320. t['ampersand'] = 667;
  49321. t['quoteright'] = 222;
  49322. t['parenleft'] = 333;
  49323. t['parenright'] = 333;
  49324. t['asterisk'] = 389;
  49325. t['plus'] = 584;
  49326. t['comma'] = 278;
  49327. t['hyphen'] = 333;
  49328. t['period'] = 278;
  49329. t['slash'] = 278;
  49330. t['zero'] = 556;
  49331. t['one'] = 556;
  49332. t['two'] = 556;
  49333. t['three'] = 556;
  49334. t['four'] = 556;
  49335. t['five'] = 556;
  49336. t['six'] = 556;
  49337. t['seven'] = 556;
  49338. t['eight'] = 556;
  49339. t['nine'] = 556;
  49340. t['colon'] = 278;
  49341. t['semicolon'] = 278;
  49342. t['less'] = 584;
  49343. t['equal'] = 584;
  49344. t['greater'] = 584;
  49345. t['question'] = 556;
  49346. t['at'] = 1015;
  49347. t['A'] = 667;
  49348. t['B'] = 667;
  49349. t['C'] = 722;
  49350. t['D'] = 722;
  49351. t['E'] = 667;
  49352. t['F'] = 611;
  49353. t['G'] = 778;
  49354. t['H'] = 722;
  49355. t['I'] = 278;
  49356. t['J'] = 500;
  49357. t['K'] = 667;
  49358. t['L'] = 556;
  49359. t['M'] = 833;
  49360. t['N'] = 722;
  49361. t['O'] = 778;
  49362. t['P'] = 667;
  49363. t['Q'] = 778;
  49364. t['R'] = 722;
  49365. t['S'] = 667;
  49366. t['T'] = 611;
  49367. t['U'] = 722;
  49368. t['V'] = 667;
  49369. t['W'] = 944;
  49370. t['X'] = 667;
  49371. t['Y'] = 667;
  49372. t['Z'] = 611;
  49373. t['bracketleft'] = 278;
  49374. t['backslash'] = 278;
  49375. t['bracketright'] = 278;
  49376. t['asciicircum'] = 469;
  49377. t['underscore'] = 556;
  49378. t['quoteleft'] = 222;
  49379. t['a'] = 556;
  49380. t['b'] = 556;
  49381. t['c'] = 500;
  49382. t['d'] = 556;
  49383. t['e'] = 556;
  49384. t['f'] = 278;
  49385. t['g'] = 556;
  49386. t['h'] = 556;
  49387. t['i'] = 222;
  49388. t['j'] = 222;
  49389. t['k'] = 500;
  49390. t['l'] = 222;
  49391. t['m'] = 833;
  49392. t['n'] = 556;
  49393. t['o'] = 556;
  49394. t['p'] = 556;
  49395. t['q'] = 556;
  49396. t['r'] = 333;
  49397. t['s'] = 500;
  49398. t['t'] = 278;
  49399. t['u'] = 556;
  49400. t['v'] = 500;
  49401. t['w'] = 722;
  49402. t['x'] = 500;
  49403. t['y'] = 500;
  49404. t['z'] = 500;
  49405. t['braceleft'] = 334;
  49406. t['bar'] = 260;
  49407. t['braceright'] = 334;
  49408. t['asciitilde'] = 584;
  49409. t['exclamdown'] = 333;
  49410. t['cent'] = 556;
  49411. t['sterling'] = 556;
  49412. t['fraction'] = 167;
  49413. t['yen'] = 556;
  49414. t['florin'] = 556;
  49415. t['section'] = 556;
  49416. t['currency'] = 556;
  49417. t['quotesingle'] = 191;
  49418. t['quotedblleft'] = 333;
  49419. t['guillemotleft'] = 556;
  49420. t['guilsinglleft'] = 333;
  49421. t['guilsinglright'] = 333;
  49422. t['fi'] = 500;
  49423. t['fl'] = 500;
  49424. t['endash'] = 556;
  49425. t['dagger'] = 556;
  49426. t['daggerdbl'] = 556;
  49427. t['periodcentered'] = 278;
  49428. t['paragraph'] = 537;
  49429. t['bullet'] = 350;
  49430. t['quotesinglbase'] = 222;
  49431. t['quotedblbase'] = 333;
  49432. t['quotedblright'] = 333;
  49433. t['guillemotright'] = 556;
  49434. t['ellipsis'] = 1000;
  49435. t['perthousand'] = 1000;
  49436. t['questiondown'] = 611;
  49437. t['grave'] = 333;
  49438. t['acute'] = 333;
  49439. t['circumflex'] = 333;
  49440. t['tilde'] = 333;
  49441. t['macron'] = 333;
  49442. t['breve'] = 333;
  49443. t['dotaccent'] = 333;
  49444. t['dieresis'] = 333;
  49445. t['ring'] = 333;
  49446. t['cedilla'] = 333;
  49447. t['hungarumlaut'] = 333;
  49448. t['ogonek'] = 333;
  49449. t['caron'] = 333;
  49450. t['emdash'] = 1000;
  49451. t['AE'] = 1000;
  49452. t['ordfeminine'] = 370;
  49453. t['Lslash'] = 556;
  49454. t['Oslash'] = 778;
  49455. t['OE'] = 1000;
  49456. t['ordmasculine'] = 365;
  49457. t['ae'] = 889;
  49458. t['dotlessi'] = 278;
  49459. t['lslash'] = 222;
  49460. t['oslash'] = 611;
  49461. t['oe'] = 944;
  49462. t['germandbls'] = 611;
  49463. t['Idieresis'] = 278;
  49464. t['eacute'] = 556;
  49465. t['abreve'] = 556;
  49466. t['uhungarumlaut'] = 556;
  49467. t['ecaron'] = 556;
  49468. t['Ydieresis'] = 667;
  49469. t['divide'] = 584;
  49470. t['Yacute'] = 667;
  49471. t['Acircumflex'] = 667;
  49472. t['aacute'] = 556;
  49473. t['Ucircumflex'] = 722;
  49474. t['yacute'] = 500;
  49475. t['scommaaccent'] = 500;
  49476. t['ecircumflex'] = 556;
  49477. t['Uring'] = 722;
  49478. t['Udieresis'] = 722;
  49479. t['aogonek'] = 556;
  49480. t['Uacute'] = 722;
  49481. t['uogonek'] = 556;
  49482. t['Edieresis'] = 667;
  49483. t['Dcroat'] = 722;
  49484. t['commaaccent'] = 250;
  49485. t['copyright'] = 737;
  49486. t['Emacron'] = 667;
  49487. t['ccaron'] = 500;
  49488. t['aring'] = 556;
  49489. t['Ncommaaccent'] = 722;
  49490. t['lacute'] = 222;
  49491. t['agrave'] = 556;
  49492. t['Tcommaaccent'] = 611;
  49493. t['Cacute'] = 722;
  49494. t['atilde'] = 556;
  49495. t['Edotaccent'] = 667;
  49496. t['scaron'] = 500;
  49497. t['scedilla'] = 500;
  49498. t['iacute'] = 278;
  49499. t['lozenge'] = 471;
  49500. t['Rcaron'] = 722;
  49501. t['Gcommaaccent'] = 778;
  49502. t['ucircumflex'] = 556;
  49503. t['acircumflex'] = 556;
  49504. t['Amacron'] = 667;
  49505. t['rcaron'] = 333;
  49506. t['ccedilla'] = 500;
  49507. t['Zdotaccent'] = 611;
  49508. t['Thorn'] = 667;
  49509. t['Omacron'] = 778;
  49510. t['Racute'] = 722;
  49511. t['Sacute'] = 667;
  49512. t['dcaron'] = 643;
  49513. t['Umacron'] = 722;
  49514. t['uring'] = 556;
  49515. t['threesuperior'] = 333;
  49516. t['Ograve'] = 778;
  49517. t['Agrave'] = 667;
  49518. t['Abreve'] = 667;
  49519. t['multiply'] = 584;
  49520. t['uacute'] = 556;
  49521. t['Tcaron'] = 611;
  49522. t['partialdiff'] = 476;
  49523. t['ydieresis'] = 500;
  49524. t['Nacute'] = 722;
  49525. t['icircumflex'] = 278;
  49526. t['Ecircumflex'] = 667;
  49527. t['adieresis'] = 556;
  49528. t['edieresis'] = 556;
  49529. t['cacute'] = 500;
  49530. t['nacute'] = 556;
  49531. t['umacron'] = 556;
  49532. t['Ncaron'] = 722;
  49533. t['Iacute'] = 278;
  49534. t['plusminus'] = 584;
  49535. t['brokenbar'] = 260;
  49536. t['registered'] = 737;
  49537. t['Gbreve'] = 778;
  49538. t['Idotaccent'] = 278;
  49539. t['summation'] = 600;
  49540. t['Egrave'] = 667;
  49541. t['racute'] = 333;
  49542. t['omacron'] = 556;
  49543. t['Zacute'] = 611;
  49544. t['Zcaron'] = 611;
  49545. t['greaterequal'] = 549;
  49546. t['Eth'] = 722;
  49547. t['Ccedilla'] = 722;
  49548. t['lcommaaccent'] = 222;
  49549. t['tcaron'] = 317;
  49550. t['eogonek'] = 556;
  49551. t['Uogonek'] = 722;
  49552. t['Aacute'] = 667;
  49553. t['Adieresis'] = 667;
  49554. t['egrave'] = 556;
  49555. t['zacute'] = 500;
  49556. t['iogonek'] = 222;
  49557. t['Oacute'] = 778;
  49558. t['oacute'] = 556;
  49559. t['amacron'] = 556;
  49560. t['sacute'] = 500;
  49561. t['idieresis'] = 278;
  49562. t['Ocircumflex'] = 778;
  49563. t['Ugrave'] = 722;
  49564. t['Delta'] = 612;
  49565. t['thorn'] = 556;
  49566. t['twosuperior'] = 333;
  49567. t['Odieresis'] = 778;
  49568. t['mu'] = 556;
  49569. t['igrave'] = 278;
  49570. t['ohungarumlaut'] = 556;
  49571. t['Eogonek'] = 667;
  49572. t['dcroat'] = 556;
  49573. t['threequarters'] = 834;
  49574. t['Scedilla'] = 667;
  49575. t['lcaron'] = 299;
  49576. t['Kcommaaccent'] = 667;
  49577. t['Lacute'] = 556;
  49578. t['trademark'] = 1000;
  49579. t['edotaccent'] = 556;
  49580. t['Igrave'] = 278;
  49581. t['Imacron'] = 278;
  49582. t['Lcaron'] = 556;
  49583. t['onehalf'] = 834;
  49584. t['lessequal'] = 549;
  49585. t['ocircumflex'] = 556;
  49586. t['ntilde'] = 556;
  49587. t['Uhungarumlaut'] = 722;
  49588. t['Eacute'] = 667;
  49589. t['emacron'] = 556;
  49590. t['gbreve'] = 556;
  49591. t['onequarter'] = 834;
  49592. t['Scaron'] = 667;
  49593. t['Scommaaccent'] = 667;
  49594. t['Ohungarumlaut'] = 778;
  49595. t['degree'] = 400;
  49596. t['ograve'] = 556;
  49597. t['Ccaron'] = 722;
  49598. t['ugrave'] = 556;
  49599. t['radical'] = 453;
  49600. t['Dcaron'] = 722;
  49601. t['rcommaaccent'] = 333;
  49602. t['Ntilde'] = 722;
  49603. t['otilde'] = 556;
  49604. t['Rcommaaccent'] = 722;
  49605. t['Lcommaaccent'] = 556;
  49606. t['Atilde'] = 667;
  49607. t['Aogonek'] = 667;
  49608. t['Aring'] = 667;
  49609. t['Otilde'] = 778;
  49610. t['zdotaccent'] = 500;
  49611. t['Ecaron'] = 667;
  49612. t['Iogonek'] = 278;
  49613. t['kcommaaccent'] = 500;
  49614. t['minus'] = 584;
  49615. t['Icircumflex'] = 278;
  49616. t['ncaron'] = 556;
  49617. t['tcommaaccent'] = 278;
  49618. t['logicalnot'] = 584;
  49619. t['odieresis'] = 556;
  49620. t['udieresis'] = 556;
  49621. t['notequal'] = 549;
  49622. t['gcommaaccent'] = 556;
  49623. t['eth'] = 556;
  49624. t['zcaron'] = 500;
  49625. t['ncommaaccent'] = 556;
  49626. t['onesuperior'] = 333;
  49627. t['imacron'] = 278;
  49628. t['Euro'] = 556;
  49629. });
  49630. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  49631. t['space'] = 278;
  49632. t['exclam'] = 333;
  49633. t['quotedbl'] = 474;
  49634. t['numbersign'] = 556;
  49635. t['dollar'] = 556;
  49636. t['percent'] = 889;
  49637. t['ampersand'] = 722;
  49638. t['quoteright'] = 278;
  49639. t['parenleft'] = 333;
  49640. t['parenright'] = 333;
  49641. t['asterisk'] = 389;
  49642. t['plus'] = 584;
  49643. t['comma'] = 278;
  49644. t['hyphen'] = 333;
  49645. t['period'] = 278;
  49646. t['slash'] = 278;
  49647. t['zero'] = 556;
  49648. t['one'] = 556;
  49649. t['two'] = 556;
  49650. t['three'] = 556;
  49651. t['four'] = 556;
  49652. t['five'] = 556;
  49653. t['six'] = 556;
  49654. t['seven'] = 556;
  49655. t['eight'] = 556;
  49656. t['nine'] = 556;
  49657. t['colon'] = 333;
  49658. t['semicolon'] = 333;
  49659. t['less'] = 584;
  49660. t['equal'] = 584;
  49661. t['greater'] = 584;
  49662. t['question'] = 611;
  49663. t['at'] = 975;
  49664. t['A'] = 722;
  49665. t['B'] = 722;
  49666. t['C'] = 722;
  49667. t['D'] = 722;
  49668. t['E'] = 667;
  49669. t['F'] = 611;
  49670. t['G'] = 778;
  49671. t['H'] = 722;
  49672. t['I'] = 278;
  49673. t['J'] = 556;
  49674. t['K'] = 722;
  49675. t['L'] = 611;
  49676. t['M'] = 833;
  49677. t['N'] = 722;
  49678. t['O'] = 778;
  49679. t['P'] = 667;
  49680. t['Q'] = 778;
  49681. t['R'] = 722;
  49682. t['S'] = 667;
  49683. t['T'] = 611;
  49684. t['U'] = 722;
  49685. t['V'] = 667;
  49686. t['W'] = 944;
  49687. t['X'] = 667;
  49688. t['Y'] = 667;
  49689. t['Z'] = 611;
  49690. t['bracketleft'] = 333;
  49691. t['backslash'] = 278;
  49692. t['bracketright'] = 333;
  49693. t['asciicircum'] = 584;
  49694. t['underscore'] = 556;
  49695. t['quoteleft'] = 278;
  49696. t['a'] = 556;
  49697. t['b'] = 611;
  49698. t['c'] = 556;
  49699. t['d'] = 611;
  49700. t['e'] = 556;
  49701. t['f'] = 333;
  49702. t['g'] = 611;
  49703. t['h'] = 611;
  49704. t['i'] = 278;
  49705. t['j'] = 278;
  49706. t['k'] = 556;
  49707. t['l'] = 278;
  49708. t['m'] = 889;
  49709. t['n'] = 611;
  49710. t['o'] = 611;
  49711. t['p'] = 611;
  49712. t['q'] = 611;
  49713. t['r'] = 389;
  49714. t['s'] = 556;
  49715. t['t'] = 333;
  49716. t['u'] = 611;
  49717. t['v'] = 556;
  49718. t['w'] = 778;
  49719. t['x'] = 556;
  49720. t['y'] = 556;
  49721. t['z'] = 500;
  49722. t['braceleft'] = 389;
  49723. t['bar'] = 280;
  49724. t['braceright'] = 389;
  49725. t['asciitilde'] = 584;
  49726. t['exclamdown'] = 333;
  49727. t['cent'] = 556;
  49728. t['sterling'] = 556;
  49729. t['fraction'] = 167;
  49730. t['yen'] = 556;
  49731. t['florin'] = 556;
  49732. t['section'] = 556;
  49733. t['currency'] = 556;
  49734. t['quotesingle'] = 238;
  49735. t['quotedblleft'] = 500;
  49736. t['guillemotleft'] = 556;
  49737. t['guilsinglleft'] = 333;
  49738. t['guilsinglright'] = 333;
  49739. t['fi'] = 611;
  49740. t['fl'] = 611;
  49741. t['endash'] = 556;
  49742. t['dagger'] = 556;
  49743. t['daggerdbl'] = 556;
  49744. t['periodcentered'] = 278;
  49745. t['paragraph'] = 556;
  49746. t['bullet'] = 350;
  49747. t['quotesinglbase'] = 278;
  49748. t['quotedblbase'] = 500;
  49749. t['quotedblright'] = 500;
  49750. t['guillemotright'] = 556;
  49751. t['ellipsis'] = 1000;
  49752. t['perthousand'] = 1000;
  49753. t['questiondown'] = 611;
  49754. t['grave'] = 333;
  49755. t['acute'] = 333;
  49756. t['circumflex'] = 333;
  49757. t['tilde'] = 333;
  49758. t['macron'] = 333;
  49759. t['breve'] = 333;
  49760. t['dotaccent'] = 333;
  49761. t['dieresis'] = 333;
  49762. t['ring'] = 333;
  49763. t['cedilla'] = 333;
  49764. t['hungarumlaut'] = 333;
  49765. t['ogonek'] = 333;
  49766. t['caron'] = 333;
  49767. t['emdash'] = 1000;
  49768. t['AE'] = 1000;
  49769. t['ordfeminine'] = 370;
  49770. t['Lslash'] = 611;
  49771. t['Oslash'] = 778;
  49772. t['OE'] = 1000;
  49773. t['ordmasculine'] = 365;
  49774. t['ae'] = 889;
  49775. t['dotlessi'] = 278;
  49776. t['lslash'] = 278;
  49777. t['oslash'] = 611;
  49778. t['oe'] = 944;
  49779. t['germandbls'] = 611;
  49780. t['Idieresis'] = 278;
  49781. t['eacute'] = 556;
  49782. t['abreve'] = 556;
  49783. t['uhungarumlaut'] = 611;
  49784. t['ecaron'] = 556;
  49785. t['Ydieresis'] = 667;
  49786. t['divide'] = 584;
  49787. t['Yacute'] = 667;
  49788. t['Acircumflex'] = 722;
  49789. t['aacute'] = 556;
  49790. t['Ucircumflex'] = 722;
  49791. t['yacute'] = 556;
  49792. t['scommaaccent'] = 556;
  49793. t['ecircumflex'] = 556;
  49794. t['Uring'] = 722;
  49795. t['Udieresis'] = 722;
  49796. t['aogonek'] = 556;
  49797. t['Uacute'] = 722;
  49798. t['uogonek'] = 611;
  49799. t['Edieresis'] = 667;
  49800. t['Dcroat'] = 722;
  49801. t['commaaccent'] = 250;
  49802. t['copyright'] = 737;
  49803. t['Emacron'] = 667;
  49804. t['ccaron'] = 556;
  49805. t['aring'] = 556;
  49806. t['Ncommaaccent'] = 722;
  49807. t['lacute'] = 278;
  49808. t['agrave'] = 556;
  49809. t['Tcommaaccent'] = 611;
  49810. t['Cacute'] = 722;
  49811. t['atilde'] = 556;
  49812. t['Edotaccent'] = 667;
  49813. t['scaron'] = 556;
  49814. t['scedilla'] = 556;
  49815. t['iacute'] = 278;
  49816. t['lozenge'] = 494;
  49817. t['Rcaron'] = 722;
  49818. t['Gcommaaccent'] = 778;
  49819. t['ucircumflex'] = 611;
  49820. t['acircumflex'] = 556;
  49821. t['Amacron'] = 722;
  49822. t['rcaron'] = 389;
  49823. t['ccedilla'] = 556;
  49824. t['Zdotaccent'] = 611;
  49825. t['Thorn'] = 667;
  49826. t['Omacron'] = 778;
  49827. t['Racute'] = 722;
  49828. t['Sacute'] = 667;
  49829. t['dcaron'] = 743;
  49830. t['Umacron'] = 722;
  49831. t['uring'] = 611;
  49832. t['threesuperior'] = 333;
  49833. t['Ograve'] = 778;
  49834. t['Agrave'] = 722;
  49835. t['Abreve'] = 722;
  49836. t['multiply'] = 584;
  49837. t['uacute'] = 611;
  49838. t['Tcaron'] = 611;
  49839. t['partialdiff'] = 494;
  49840. t['ydieresis'] = 556;
  49841. t['Nacute'] = 722;
  49842. t['icircumflex'] = 278;
  49843. t['Ecircumflex'] = 667;
  49844. t['adieresis'] = 556;
  49845. t['edieresis'] = 556;
  49846. t['cacute'] = 556;
  49847. t['nacute'] = 611;
  49848. t['umacron'] = 611;
  49849. t['Ncaron'] = 722;
  49850. t['Iacute'] = 278;
  49851. t['plusminus'] = 584;
  49852. t['brokenbar'] = 280;
  49853. t['registered'] = 737;
  49854. t['Gbreve'] = 778;
  49855. t['Idotaccent'] = 278;
  49856. t['summation'] = 600;
  49857. t['Egrave'] = 667;
  49858. t['racute'] = 389;
  49859. t['omacron'] = 611;
  49860. t['Zacute'] = 611;
  49861. t['Zcaron'] = 611;
  49862. t['greaterequal'] = 549;
  49863. t['Eth'] = 722;
  49864. t['Ccedilla'] = 722;
  49865. t['lcommaaccent'] = 278;
  49866. t['tcaron'] = 389;
  49867. t['eogonek'] = 556;
  49868. t['Uogonek'] = 722;
  49869. t['Aacute'] = 722;
  49870. t['Adieresis'] = 722;
  49871. t['egrave'] = 556;
  49872. t['zacute'] = 500;
  49873. t['iogonek'] = 278;
  49874. t['Oacute'] = 778;
  49875. t['oacute'] = 611;
  49876. t['amacron'] = 556;
  49877. t['sacute'] = 556;
  49878. t['idieresis'] = 278;
  49879. t['Ocircumflex'] = 778;
  49880. t['Ugrave'] = 722;
  49881. t['Delta'] = 612;
  49882. t['thorn'] = 611;
  49883. t['twosuperior'] = 333;
  49884. t['Odieresis'] = 778;
  49885. t['mu'] = 611;
  49886. t['igrave'] = 278;
  49887. t['ohungarumlaut'] = 611;
  49888. t['Eogonek'] = 667;
  49889. t['dcroat'] = 611;
  49890. t['threequarters'] = 834;
  49891. t['Scedilla'] = 667;
  49892. t['lcaron'] = 400;
  49893. t['Kcommaaccent'] = 722;
  49894. t['Lacute'] = 611;
  49895. t['trademark'] = 1000;
  49896. t['edotaccent'] = 556;
  49897. t['Igrave'] = 278;
  49898. t['Imacron'] = 278;
  49899. t['Lcaron'] = 611;
  49900. t['onehalf'] = 834;
  49901. t['lessequal'] = 549;
  49902. t['ocircumflex'] = 611;
  49903. t['ntilde'] = 611;
  49904. t['Uhungarumlaut'] = 722;
  49905. t['Eacute'] = 667;
  49906. t['emacron'] = 556;
  49907. t['gbreve'] = 611;
  49908. t['onequarter'] = 834;
  49909. t['Scaron'] = 667;
  49910. t['Scommaaccent'] = 667;
  49911. t['Ohungarumlaut'] = 778;
  49912. t['degree'] = 400;
  49913. t['ograve'] = 611;
  49914. t['Ccaron'] = 722;
  49915. t['ugrave'] = 611;
  49916. t['radical'] = 549;
  49917. t['Dcaron'] = 722;
  49918. t['rcommaaccent'] = 389;
  49919. t['Ntilde'] = 722;
  49920. t['otilde'] = 611;
  49921. t['Rcommaaccent'] = 722;
  49922. t['Lcommaaccent'] = 611;
  49923. t['Atilde'] = 722;
  49924. t['Aogonek'] = 722;
  49925. t['Aring'] = 722;
  49926. t['Otilde'] = 778;
  49927. t['zdotaccent'] = 500;
  49928. t['Ecaron'] = 667;
  49929. t['Iogonek'] = 278;
  49930. t['kcommaaccent'] = 556;
  49931. t['minus'] = 584;
  49932. t['Icircumflex'] = 278;
  49933. t['ncaron'] = 611;
  49934. t['tcommaaccent'] = 333;
  49935. t['logicalnot'] = 584;
  49936. t['odieresis'] = 611;
  49937. t['udieresis'] = 611;
  49938. t['notequal'] = 549;
  49939. t['gcommaaccent'] = 611;
  49940. t['eth'] = 611;
  49941. t['zcaron'] = 500;
  49942. t['ncommaaccent'] = 611;
  49943. t['onesuperior'] = 333;
  49944. t['imacron'] = 278;
  49945. t['Euro'] = 556;
  49946. });
  49947. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  49948. t['space'] = 278;
  49949. t['exclam'] = 333;
  49950. t['quotedbl'] = 474;
  49951. t['numbersign'] = 556;
  49952. t['dollar'] = 556;
  49953. t['percent'] = 889;
  49954. t['ampersand'] = 722;
  49955. t['quoteright'] = 278;
  49956. t['parenleft'] = 333;
  49957. t['parenright'] = 333;
  49958. t['asterisk'] = 389;
  49959. t['plus'] = 584;
  49960. t['comma'] = 278;
  49961. t['hyphen'] = 333;
  49962. t['period'] = 278;
  49963. t['slash'] = 278;
  49964. t['zero'] = 556;
  49965. t['one'] = 556;
  49966. t['two'] = 556;
  49967. t['three'] = 556;
  49968. t['four'] = 556;
  49969. t['five'] = 556;
  49970. t['six'] = 556;
  49971. t['seven'] = 556;
  49972. t['eight'] = 556;
  49973. t['nine'] = 556;
  49974. t['colon'] = 333;
  49975. t['semicolon'] = 333;
  49976. t['less'] = 584;
  49977. t['equal'] = 584;
  49978. t['greater'] = 584;
  49979. t['question'] = 611;
  49980. t['at'] = 975;
  49981. t['A'] = 722;
  49982. t['B'] = 722;
  49983. t['C'] = 722;
  49984. t['D'] = 722;
  49985. t['E'] = 667;
  49986. t['F'] = 611;
  49987. t['G'] = 778;
  49988. t['H'] = 722;
  49989. t['I'] = 278;
  49990. t['J'] = 556;
  49991. t['K'] = 722;
  49992. t['L'] = 611;
  49993. t['M'] = 833;
  49994. t['N'] = 722;
  49995. t['O'] = 778;
  49996. t['P'] = 667;
  49997. t['Q'] = 778;
  49998. t['R'] = 722;
  49999. t['S'] = 667;
  50000. t['T'] = 611;
  50001. t['U'] = 722;
  50002. t['V'] = 667;
  50003. t['W'] = 944;
  50004. t['X'] = 667;
  50005. t['Y'] = 667;
  50006. t['Z'] = 611;
  50007. t['bracketleft'] = 333;
  50008. t['backslash'] = 278;
  50009. t['bracketright'] = 333;
  50010. t['asciicircum'] = 584;
  50011. t['underscore'] = 556;
  50012. t['quoteleft'] = 278;
  50013. t['a'] = 556;
  50014. t['b'] = 611;
  50015. t['c'] = 556;
  50016. t['d'] = 611;
  50017. t['e'] = 556;
  50018. t['f'] = 333;
  50019. t['g'] = 611;
  50020. t['h'] = 611;
  50021. t['i'] = 278;
  50022. t['j'] = 278;
  50023. t['k'] = 556;
  50024. t['l'] = 278;
  50025. t['m'] = 889;
  50026. t['n'] = 611;
  50027. t['o'] = 611;
  50028. t['p'] = 611;
  50029. t['q'] = 611;
  50030. t['r'] = 389;
  50031. t['s'] = 556;
  50032. t['t'] = 333;
  50033. t['u'] = 611;
  50034. t['v'] = 556;
  50035. t['w'] = 778;
  50036. t['x'] = 556;
  50037. t['y'] = 556;
  50038. t['z'] = 500;
  50039. t['braceleft'] = 389;
  50040. t['bar'] = 280;
  50041. t['braceright'] = 389;
  50042. t['asciitilde'] = 584;
  50043. t['exclamdown'] = 333;
  50044. t['cent'] = 556;
  50045. t['sterling'] = 556;
  50046. t['fraction'] = 167;
  50047. t['yen'] = 556;
  50048. t['florin'] = 556;
  50049. t['section'] = 556;
  50050. t['currency'] = 556;
  50051. t['quotesingle'] = 238;
  50052. t['quotedblleft'] = 500;
  50053. t['guillemotleft'] = 556;
  50054. t['guilsinglleft'] = 333;
  50055. t['guilsinglright'] = 333;
  50056. t['fi'] = 611;
  50057. t['fl'] = 611;
  50058. t['endash'] = 556;
  50059. t['dagger'] = 556;
  50060. t['daggerdbl'] = 556;
  50061. t['periodcentered'] = 278;
  50062. t['paragraph'] = 556;
  50063. t['bullet'] = 350;
  50064. t['quotesinglbase'] = 278;
  50065. t['quotedblbase'] = 500;
  50066. t['quotedblright'] = 500;
  50067. t['guillemotright'] = 556;
  50068. t['ellipsis'] = 1000;
  50069. t['perthousand'] = 1000;
  50070. t['questiondown'] = 611;
  50071. t['grave'] = 333;
  50072. t['acute'] = 333;
  50073. t['circumflex'] = 333;
  50074. t['tilde'] = 333;
  50075. t['macron'] = 333;
  50076. t['breve'] = 333;
  50077. t['dotaccent'] = 333;
  50078. t['dieresis'] = 333;
  50079. t['ring'] = 333;
  50080. t['cedilla'] = 333;
  50081. t['hungarumlaut'] = 333;
  50082. t['ogonek'] = 333;
  50083. t['caron'] = 333;
  50084. t['emdash'] = 1000;
  50085. t['AE'] = 1000;
  50086. t['ordfeminine'] = 370;
  50087. t['Lslash'] = 611;
  50088. t['Oslash'] = 778;
  50089. t['OE'] = 1000;
  50090. t['ordmasculine'] = 365;
  50091. t['ae'] = 889;
  50092. t['dotlessi'] = 278;
  50093. t['lslash'] = 278;
  50094. t['oslash'] = 611;
  50095. t['oe'] = 944;
  50096. t['germandbls'] = 611;
  50097. t['Idieresis'] = 278;
  50098. t['eacute'] = 556;
  50099. t['abreve'] = 556;
  50100. t['uhungarumlaut'] = 611;
  50101. t['ecaron'] = 556;
  50102. t['Ydieresis'] = 667;
  50103. t['divide'] = 584;
  50104. t['Yacute'] = 667;
  50105. t['Acircumflex'] = 722;
  50106. t['aacute'] = 556;
  50107. t['Ucircumflex'] = 722;
  50108. t['yacute'] = 556;
  50109. t['scommaaccent'] = 556;
  50110. t['ecircumflex'] = 556;
  50111. t['Uring'] = 722;
  50112. t['Udieresis'] = 722;
  50113. t['aogonek'] = 556;
  50114. t['Uacute'] = 722;
  50115. t['uogonek'] = 611;
  50116. t['Edieresis'] = 667;
  50117. t['Dcroat'] = 722;
  50118. t['commaaccent'] = 250;
  50119. t['copyright'] = 737;
  50120. t['Emacron'] = 667;
  50121. t['ccaron'] = 556;
  50122. t['aring'] = 556;
  50123. t['Ncommaaccent'] = 722;
  50124. t['lacute'] = 278;
  50125. t['agrave'] = 556;
  50126. t['Tcommaaccent'] = 611;
  50127. t['Cacute'] = 722;
  50128. t['atilde'] = 556;
  50129. t['Edotaccent'] = 667;
  50130. t['scaron'] = 556;
  50131. t['scedilla'] = 556;
  50132. t['iacute'] = 278;
  50133. t['lozenge'] = 494;
  50134. t['Rcaron'] = 722;
  50135. t['Gcommaaccent'] = 778;
  50136. t['ucircumflex'] = 611;
  50137. t['acircumflex'] = 556;
  50138. t['Amacron'] = 722;
  50139. t['rcaron'] = 389;
  50140. t['ccedilla'] = 556;
  50141. t['Zdotaccent'] = 611;
  50142. t['Thorn'] = 667;
  50143. t['Omacron'] = 778;
  50144. t['Racute'] = 722;
  50145. t['Sacute'] = 667;
  50146. t['dcaron'] = 743;
  50147. t['Umacron'] = 722;
  50148. t['uring'] = 611;
  50149. t['threesuperior'] = 333;
  50150. t['Ograve'] = 778;
  50151. t['Agrave'] = 722;
  50152. t['Abreve'] = 722;
  50153. t['multiply'] = 584;
  50154. t['uacute'] = 611;
  50155. t['Tcaron'] = 611;
  50156. t['partialdiff'] = 494;
  50157. t['ydieresis'] = 556;
  50158. t['Nacute'] = 722;
  50159. t['icircumflex'] = 278;
  50160. t['Ecircumflex'] = 667;
  50161. t['adieresis'] = 556;
  50162. t['edieresis'] = 556;
  50163. t['cacute'] = 556;
  50164. t['nacute'] = 611;
  50165. t['umacron'] = 611;
  50166. t['Ncaron'] = 722;
  50167. t['Iacute'] = 278;
  50168. t['plusminus'] = 584;
  50169. t['brokenbar'] = 280;
  50170. t['registered'] = 737;
  50171. t['Gbreve'] = 778;
  50172. t['Idotaccent'] = 278;
  50173. t['summation'] = 600;
  50174. t['Egrave'] = 667;
  50175. t['racute'] = 389;
  50176. t['omacron'] = 611;
  50177. t['Zacute'] = 611;
  50178. t['Zcaron'] = 611;
  50179. t['greaterequal'] = 549;
  50180. t['Eth'] = 722;
  50181. t['Ccedilla'] = 722;
  50182. t['lcommaaccent'] = 278;
  50183. t['tcaron'] = 389;
  50184. t['eogonek'] = 556;
  50185. t['Uogonek'] = 722;
  50186. t['Aacute'] = 722;
  50187. t['Adieresis'] = 722;
  50188. t['egrave'] = 556;
  50189. t['zacute'] = 500;
  50190. t['iogonek'] = 278;
  50191. t['Oacute'] = 778;
  50192. t['oacute'] = 611;
  50193. t['amacron'] = 556;
  50194. t['sacute'] = 556;
  50195. t['idieresis'] = 278;
  50196. t['Ocircumflex'] = 778;
  50197. t['Ugrave'] = 722;
  50198. t['Delta'] = 612;
  50199. t['thorn'] = 611;
  50200. t['twosuperior'] = 333;
  50201. t['Odieresis'] = 778;
  50202. t['mu'] = 611;
  50203. t['igrave'] = 278;
  50204. t['ohungarumlaut'] = 611;
  50205. t['Eogonek'] = 667;
  50206. t['dcroat'] = 611;
  50207. t['threequarters'] = 834;
  50208. t['Scedilla'] = 667;
  50209. t['lcaron'] = 400;
  50210. t['Kcommaaccent'] = 722;
  50211. t['Lacute'] = 611;
  50212. t['trademark'] = 1000;
  50213. t['edotaccent'] = 556;
  50214. t['Igrave'] = 278;
  50215. t['Imacron'] = 278;
  50216. t['Lcaron'] = 611;
  50217. t['onehalf'] = 834;
  50218. t['lessequal'] = 549;
  50219. t['ocircumflex'] = 611;
  50220. t['ntilde'] = 611;
  50221. t['Uhungarumlaut'] = 722;
  50222. t['Eacute'] = 667;
  50223. t['emacron'] = 556;
  50224. t['gbreve'] = 611;
  50225. t['onequarter'] = 834;
  50226. t['Scaron'] = 667;
  50227. t['Scommaaccent'] = 667;
  50228. t['Ohungarumlaut'] = 778;
  50229. t['degree'] = 400;
  50230. t['ograve'] = 611;
  50231. t['Ccaron'] = 722;
  50232. t['ugrave'] = 611;
  50233. t['radical'] = 549;
  50234. t['Dcaron'] = 722;
  50235. t['rcommaaccent'] = 389;
  50236. t['Ntilde'] = 722;
  50237. t['otilde'] = 611;
  50238. t['Rcommaaccent'] = 722;
  50239. t['Lcommaaccent'] = 611;
  50240. t['Atilde'] = 722;
  50241. t['Aogonek'] = 722;
  50242. t['Aring'] = 722;
  50243. t['Otilde'] = 778;
  50244. t['zdotaccent'] = 500;
  50245. t['Ecaron'] = 667;
  50246. t['Iogonek'] = 278;
  50247. t['kcommaaccent'] = 556;
  50248. t['minus'] = 584;
  50249. t['Icircumflex'] = 278;
  50250. t['ncaron'] = 611;
  50251. t['tcommaaccent'] = 333;
  50252. t['logicalnot'] = 584;
  50253. t['odieresis'] = 611;
  50254. t['udieresis'] = 611;
  50255. t['notequal'] = 549;
  50256. t['gcommaaccent'] = 611;
  50257. t['eth'] = 611;
  50258. t['zcaron'] = 500;
  50259. t['ncommaaccent'] = 611;
  50260. t['onesuperior'] = 333;
  50261. t['imacron'] = 278;
  50262. t['Euro'] = 556;
  50263. });
  50264. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  50265. t['space'] = 278;
  50266. t['exclam'] = 278;
  50267. t['quotedbl'] = 355;
  50268. t['numbersign'] = 556;
  50269. t['dollar'] = 556;
  50270. t['percent'] = 889;
  50271. t['ampersand'] = 667;
  50272. t['quoteright'] = 222;
  50273. t['parenleft'] = 333;
  50274. t['parenright'] = 333;
  50275. t['asterisk'] = 389;
  50276. t['plus'] = 584;
  50277. t['comma'] = 278;
  50278. t['hyphen'] = 333;
  50279. t['period'] = 278;
  50280. t['slash'] = 278;
  50281. t['zero'] = 556;
  50282. t['one'] = 556;
  50283. t['two'] = 556;
  50284. t['three'] = 556;
  50285. t['four'] = 556;
  50286. t['five'] = 556;
  50287. t['six'] = 556;
  50288. t['seven'] = 556;
  50289. t['eight'] = 556;
  50290. t['nine'] = 556;
  50291. t['colon'] = 278;
  50292. t['semicolon'] = 278;
  50293. t['less'] = 584;
  50294. t['equal'] = 584;
  50295. t['greater'] = 584;
  50296. t['question'] = 556;
  50297. t['at'] = 1015;
  50298. t['A'] = 667;
  50299. t['B'] = 667;
  50300. t['C'] = 722;
  50301. t['D'] = 722;
  50302. t['E'] = 667;
  50303. t['F'] = 611;
  50304. t['G'] = 778;
  50305. t['H'] = 722;
  50306. t['I'] = 278;
  50307. t['J'] = 500;
  50308. t['K'] = 667;
  50309. t['L'] = 556;
  50310. t['M'] = 833;
  50311. t['N'] = 722;
  50312. t['O'] = 778;
  50313. t['P'] = 667;
  50314. t['Q'] = 778;
  50315. t['R'] = 722;
  50316. t['S'] = 667;
  50317. t['T'] = 611;
  50318. t['U'] = 722;
  50319. t['V'] = 667;
  50320. t['W'] = 944;
  50321. t['X'] = 667;
  50322. t['Y'] = 667;
  50323. t['Z'] = 611;
  50324. t['bracketleft'] = 278;
  50325. t['backslash'] = 278;
  50326. t['bracketright'] = 278;
  50327. t['asciicircum'] = 469;
  50328. t['underscore'] = 556;
  50329. t['quoteleft'] = 222;
  50330. t['a'] = 556;
  50331. t['b'] = 556;
  50332. t['c'] = 500;
  50333. t['d'] = 556;
  50334. t['e'] = 556;
  50335. t['f'] = 278;
  50336. t['g'] = 556;
  50337. t['h'] = 556;
  50338. t['i'] = 222;
  50339. t['j'] = 222;
  50340. t['k'] = 500;
  50341. t['l'] = 222;
  50342. t['m'] = 833;
  50343. t['n'] = 556;
  50344. t['o'] = 556;
  50345. t['p'] = 556;
  50346. t['q'] = 556;
  50347. t['r'] = 333;
  50348. t['s'] = 500;
  50349. t['t'] = 278;
  50350. t['u'] = 556;
  50351. t['v'] = 500;
  50352. t['w'] = 722;
  50353. t['x'] = 500;
  50354. t['y'] = 500;
  50355. t['z'] = 500;
  50356. t['braceleft'] = 334;
  50357. t['bar'] = 260;
  50358. t['braceright'] = 334;
  50359. t['asciitilde'] = 584;
  50360. t['exclamdown'] = 333;
  50361. t['cent'] = 556;
  50362. t['sterling'] = 556;
  50363. t['fraction'] = 167;
  50364. t['yen'] = 556;
  50365. t['florin'] = 556;
  50366. t['section'] = 556;
  50367. t['currency'] = 556;
  50368. t['quotesingle'] = 191;
  50369. t['quotedblleft'] = 333;
  50370. t['guillemotleft'] = 556;
  50371. t['guilsinglleft'] = 333;
  50372. t['guilsinglright'] = 333;
  50373. t['fi'] = 500;
  50374. t['fl'] = 500;
  50375. t['endash'] = 556;
  50376. t['dagger'] = 556;
  50377. t['daggerdbl'] = 556;
  50378. t['periodcentered'] = 278;
  50379. t['paragraph'] = 537;
  50380. t['bullet'] = 350;
  50381. t['quotesinglbase'] = 222;
  50382. t['quotedblbase'] = 333;
  50383. t['quotedblright'] = 333;
  50384. t['guillemotright'] = 556;
  50385. t['ellipsis'] = 1000;
  50386. t['perthousand'] = 1000;
  50387. t['questiondown'] = 611;
  50388. t['grave'] = 333;
  50389. t['acute'] = 333;
  50390. t['circumflex'] = 333;
  50391. t['tilde'] = 333;
  50392. t['macron'] = 333;
  50393. t['breve'] = 333;
  50394. t['dotaccent'] = 333;
  50395. t['dieresis'] = 333;
  50396. t['ring'] = 333;
  50397. t['cedilla'] = 333;
  50398. t['hungarumlaut'] = 333;
  50399. t['ogonek'] = 333;
  50400. t['caron'] = 333;
  50401. t['emdash'] = 1000;
  50402. t['AE'] = 1000;
  50403. t['ordfeminine'] = 370;
  50404. t['Lslash'] = 556;
  50405. t['Oslash'] = 778;
  50406. t['OE'] = 1000;
  50407. t['ordmasculine'] = 365;
  50408. t['ae'] = 889;
  50409. t['dotlessi'] = 278;
  50410. t['lslash'] = 222;
  50411. t['oslash'] = 611;
  50412. t['oe'] = 944;
  50413. t['germandbls'] = 611;
  50414. t['Idieresis'] = 278;
  50415. t['eacute'] = 556;
  50416. t['abreve'] = 556;
  50417. t['uhungarumlaut'] = 556;
  50418. t['ecaron'] = 556;
  50419. t['Ydieresis'] = 667;
  50420. t['divide'] = 584;
  50421. t['Yacute'] = 667;
  50422. t['Acircumflex'] = 667;
  50423. t['aacute'] = 556;
  50424. t['Ucircumflex'] = 722;
  50425. t['yacute'] = 500;
  50426. t['scommaaccent'] = 500;
  50427. t['ecircumflex'] = 556;
  50428. t['Uring'] = 722;
  50429. t['Udieresis'] = 722;
  50430. t['aogonek'] = 556;
  50431. t['Uacute'] = 722;
  50432. t['uogonek'] = 556;
  50433. t['Edieresis'] = 667;
  50434. t['Dcroat'] = 722;
  50435. t['commaaccent'] = 250;
  50436. t['copyright'] = 737;
  50437. t['Emacron'] = 667;
  50438. t['ccaron'] = 500;
  50439. t['aring'] = 556;
  50440. t['Ncommaaccent'] = 722;
  50441. t['lacute'] = 222;
  50442. t['agrave'] = 556;
  50443. t['Tcommaaccent'] = 611;
  50444. t['Cacute'] = 722;
  50445. t['atilde'] = 556;
  50446. t['Edotaccent'] = 667;
  50447. t['scaron'] = 500;
  50448. t['scedilla'] = 500;
  50449. t['iacute'] = 278;
  50450. t['lozenge'] = 471;
  50451. t['Rcaron'] = 722;
  50452. t['Gcommaaccent'] = 778;
  50453. t['ucircumflex'] = 556;
  50454. t['acircumflex'] = 556;
  50455. t['Amacron'] = 667;
  50456. t['rcaron'] = 333;
  50457. t['ccedilla'] = 500;
  50458. t['Zdotaccent'] = 611;
  50459. t['Thorn'] = 667;
  50460. t['Omacron'] = 778;
  50461. t['Racute'] = 722;
  50462. t['Sacute'] = 667;
  50463. t['dcaron'] = 643;
  50464. t['Umacron'] = 722;
  50465. t['uring'] = 556;
  50466. t['threesuperior'] = 333;
  50467. t['Ograve'] = 778;
  50468. t['Agrave'] = 667;
  50469. t['Abreve'] = 667;
  50470. t['multiply'] = 584;
  50471. t['uacute'] = 556;
  50472. t['Tcaron'] = 611;
  50473. t['partialdiff'] = 476;
  50474. t['ydieresis'] = 500;
  50475. t['Nacute'] = 722;
  50476. t['icircumflex'] = 278;
  50477. t['Ecircumflex'] = 667;
  50478. t['adieresis'] = 556;
  50479. t['edieresis'] = 556;
  50480. t['cacute'] = 500;
  50481. t['nacute'] = 556;
  50482. t['umacron'] = 556;
  50483. t['Ncaron'] = 722;
  50484. t['Iacute'] = 278;
  50485. t['plusminus'] = 584;
  50486. t['brokenbar'] = 260;
  50487. t['registered'] = 737;
  50488. t['Gbreve'] = 778;
  50489. t['Idotaccent'] = 278;
  50490. t['summation'] = 600;
  50491. t['Egrave'] = 667;
  50492. t['racute'] = 333;
  50493. t['omacron'] = 556;
  50494. t['Zacute'] = 611;
  50495. t['Zcaron'] = 611;
  50496. t['greaterequal'] = 549;
  50497. t['Eth'] = 722;
  50498. t['Ccedilla'] = 722;
  50499. t['lcommaaccent'] = 222;
  50500. t['tcaron'] = 317;
  50501. t['eogonek'] = 556;
  50502. t['Uogonek'] = 722;
  50503. t['Aacute'] = 667;
  50504. t['Adieresis'] = 667;
  50505. t['egrave'] = 556;
  50506. t['zacute'] = 500;
  50507. t['iogonek'] = 222;
  50508. t['Oacute'] = 778;
  50509. t['oacute'] = 556;
  50510. t['amacron'] = 556;
  50511. t['sacute'] = 500;
  50512. t['idieresis'] = 278;
  50513. t['Ocircumflex'] = 778;
  50514. t['Ugrave'] = 722;
  50515. t['Delta'] = 612;
  50516. t['thorn'] = 556;
  50517. t['twosuperior'] = 333;
  50518. t['Odieresis'] = 778;
  50519. t['mu'] = 556;
  50520. t['igrave'] = 278;
  50521. t['ohungarumlaut'] = 556;
  50522. t['Eogonek'] = 667;
  50523. t['dcroat'] = 556;
  50524. t['threequarters'] = 834;
  50525. t['Scedilla'] = 667;
  50526. t['lcaron'] = 299;
  50527. t['Kcommaaccent'] = 667;
  50528. t['Lacute'] = 556;
  50529. t['trademark'] = 1000;
  50530. t['edotaccent'] = 556;
  50531. t['Igrave'] = 278;
  50532. t['Imacron'] = 278;
  50533. t['Lcaron'] = 556;
  50534. t['onehalf'] = 834;
  50535. t['lessequal'] = 549;
  50536. t['ocircumflex'] = 556;
  50537. t['ntilde'] = 556;
  50538. t['Uhungarumlaut'] = 722;
  50539. t['Eacute'] = 667;
  50540. t['emacron'] = 556;
  50541. t['gbreve'] = 556;
  50542. t['onequarter'] = 834;
  50543. t['Scaron'] = 667;
  50544. t['Scommaaccent'] = 667;
  50545. t['Ohungarumlaut'] = 778;
  50546. t['degree'] = 400;
  50547. t['ograve'] = 556;
  50548. t['Ccaron'] = 722;
  50549. t['ugrave'] = 556;
  50550. t['radical'] = 453;
  50551. t['Dcaron'] = 722;
  50552. t['rcommaaccent'] = 333;
  50553. t['Ntilde'] = 722;
  50554. t['otilde'] = 556;
  50555. t['Rcommaaccent'] = 722;
  50556. t['Lcommaaccent'] = 556;
  50557. t['Atilde'] = 667;
  50558. t['Aogonek'] = 667;
  50559. t['Aring'] = 667;
  50560. t['Otilde'] = 778;
  50561. t['zdotaccent'] = 500;
  50562. t['Ecaron'] = 667;
  50563. t['Iogonek'] = 278;
  50564. t['kcommaaccent'] = 500;
  50565. t['minus'] = 584;
  50566. t['Icircumflex'] = 278;
  50567. t['ncaron'] = 556;
  50568. t['tcommaaccent'] = 278;
  50569. t['logicalnot'] = 584;
  50570. t['odieresis'] = 556;
  50571. t['udieresis'] = 556;
  50572. t['notequal'] = 549;
  50573. t['gcommaaccent'] = 556;
  50574. t['eth'] = 556;
  50575. t['zcaron'] = 500;
  50576. t['ncommaaccent'] = 556;
  50577. t['onesuperior'] = 333;
  50578. t['imacron'] = 278;
  50579. t['Euro'] = 556;
  50580. });
  50581. t['Symbol'] = getLookupTableFactory(function (t) {
  50582. t['space'] = 250;
  50583. t['exclam'] = 333;
  50584. t['universal'] = 713;
  50585. t['numbersign'] = 500;
  50586. t['existential'] = 549;
  50587. t['percent'] = 833;
  50588. t['ampersand'] = 778;
  50589. t['suchthat'] = 439;
  50590. t['parenleft'] = 333;
  50591. t['parenright'] = 333;
  50592. t['asteriskmath'] = 500;
  50593. t['plus'] = 549;
  50594. t['comma'] = 250;
  50595. t['minus'] = 549;
  50596. t['period'] = 250;
  50597. t['slash'] = 278;
  50598. t['zero'] = 500;
  50599. t['one'] = 500;
  50600. t['two'] = 500;
  50601. t['three'] = 500;
  50602. t['four'] = 500;
  50603. t['five'] = 500;
  50604. t['six'] = 500;
  50605. t['seven'] = 500;
  50606. t['eight'] = 500;
  50607. t['nine'] = 500;
  50608. t['colon'] = 278;
  50609. t['semicolon'] = 278;
  50610. t['less'] = 549;
  50611. t['equal'] = 549;
  50612. t['greater'] = 549;
  50613. t['question'] = 444;
  50614. t['congruent'] = 549;
  50615. t['Alpha'] = 722;
  50616. t['Beta'] = 667;
  50617. t['Chi'] = 722;
  50618. t['Delta'] = 612;
  50619. t['Epsilon'] = 611;
  50620. t['Phi'] = 763;
  50621. t['Gamma'] = 603;
  50622. t['Eta'] = 722;
  50623. t['Iota'] = 333;
  50624. t['theta1'] = 631;
  50625. t['Kappa'] = 722;
  50626. t['Lambda'] = 686;
  50627. t['Mu'] = 889;
  50628. t['Nu'] = 722;
  50629. t['Omicron'] = 722;
  50630. t['Pi'] = 768;
  50631. t['Theta'] = 741;
  50632. t['Rho'] = 556;
  50633. t['Sigma'] = 592;
  50634. t['Tau'] = 611;
  50635. t['Upsilon'] = 690;
  50636. t['sigma1'] = 439;
  50637. t['Omega'] = 768;
  50638. t['Xi'] = 645;
  50639. t['Psi'] = 795;
  50640. t['Zeta'] = 611;
  50641. t['bracketleft'] = 333;
  50642. t['therefore'] = 863;
  50643. t['bracketright'] = 333;
  50644. t['perpendicular'] = 658;
  50645. t['underscore'] = 500;
  50646. t['radicalex'] = 500;
  50647. t['alpha'] = 631;
  50648. t['beta'] = 549;
  50649. t['chi'] = 549;
  50650. t['delta'] = 494;
  50651. t['epsilon'] = 439;
  50652. t['phi'] = 521;
  50653. t['gamma'] = 411;
  50654. t['eta'] = 603;
  50655. t['iota'] = 329;
  50656. t['phi1'] = 603;
  50657. t['kappa'] = 549;
  50658. t['lambda'] = 549;
  50659. t['mu'] = 576;
  50660. t['nu'] = 521;
  50661. t['omicron'] = 549;
  50662. t['pi'] = 549;
  50663. t['theta'] = 521;
  50664. t['rho'] = 549;
  50665. t['sigma'] = 603;
  50666. t['tau'] = 439;
  50667. t['upsilon'] = 576;
  50668. t['omega1'] = 713;
  50669. t['omega'] = 686;
  50670. t['xi'] = 493;
  50671. t['psi'] = 686;
  50672. t['zeta'] = 494;
  50673. t['braceleft'] = 480;
  50674. t['bar'] = 200;
  50675. t['braceright'] = 480;
  50676. t['similar'] = 549;
  50677. t['Euro'] = 750;
  50678. t['Upsilon1'] = 620;
  50679. t['minute'] = 247;
  50680. t['lessequal'] = 549;
  50681. t['fraction'] = 167;
  50682. t['infinity'] = 713;
  50683. t['florin'] = 500;
  50684. t['club'] = 753;
  50685. t['diamond'] = 753;
  50686. t['heart'] = 753;
  50687. t['spade'] = 753;
  50688. t['arrowboth'] = 1042;
  50689. t['arrowleft'] = 987;
  50690. t['arrowup'] = 603;
  50691. t['arrowright'] = 987;
  50692. t['arrowdown'] = 603;
  50693. t['degree'] = 400;
  50694. t['plusminus'] = 549;
  50695. t['second'] = 411;
  50696. t['greaterequal'] = 549;
  50697. t['multiply'] = 549;
  50698. t['proportional'] = 713;
  50699. t['partialdiff'] = 494;
  50700. t['bullet'] = 460;
  50701. t['divide'] = 549;
  50702. t['notequal'] = 549;
  50703. t['equivalence'] = 549;
  50704. t['approxequal'] = 549;
  50705. t['ellipsis'] = 1000;
  50706. t['arrowvertex'] = 603;
  50707. t['arrowhorizex'] = 1000;
  50708. t['carriagereturn'] = 658;
  50709. t['aleph'] = 823;
  50710. t['Ifraktur'] = 686;
  50711. t['Rfraktur'] = 795;
  50712. t['weierstrass'] = 987;
  50713. t['circlemultiply'] = 768;
  50714. t['circleplus'] = 768;
  50715. t['emptyset'] = 823;
  50716. t['intersection'] = 768;
  50717. t['union'] = 768;
  50718. t['propersuperset'] = 713;
  50719. t['reflexsuperset'] = 713;
  50720. t['notsubset'] = 713;
  50721. t['propersubset'] = 713;
  50722. t['reflexsubset'] = 713;
  50723. t['element'] = 713;
  50724. t['notelement'] = 713;
  50725. t['angle'] = 768;
  50726. t['gradient'] = 713;
  50727. t['registerserif'] = 790;
  50728. t['copyrightserif'] = 790;
  50729. t['trademarkserif'] = 890;
  50730. t['product'] = 823;
  50731. t['radical'] = 549;
  50732. t['dotmath'] = 250;
  50733. t['logicalnot'] = 713;
  50734. t['logicaland'] = 603;
  50735. t['logicalor'] = 603;
  50736. t['arrowdblboth'] = 1042;
  50737. t['arrowdblleft'] = 987;
  50738. t['arrowdblup'] = 603;
  50739. t['arrowdblright'] = 987;
  50740. t['arrowdbldown'] = 603;
  50741. t['lozenge'] = 494;
  50742. t['angleleft'] = 329;
  50743. t['registersans'] = 790;
  50744. t['copyrightsans'] = 790;
  50745. t['trademarksans'] = 786;
  50746. t['summation'] = 713;
  50747. t['parenlefttp'] = 384;
  50748. t['parenleftex'] = 384;
  50749. t['parenleftbt'] = 384;
  50750. t['bracketlefttp'] = 384;
  50751. t['bracketleftex'] = 384;
  50752. t['bracketleftbt'] = 384;
  50753. t['bracelefttp'] = 494;
  50754. t['braceleftmid'] = 494;
  50755. t['braceleftbt'] = 494;
  50756. t['braceex'] = 494;
  50757. t['angleright'] = 329;
  50758. t['integral'] = 274;
  50759. t['integraltp'] = 686;
  50760. t['integralex'] = 686;
  50761. t['integralbt'] = 686;
  50762. t['parenrighttp'] = 384;
  50763. t['parenrightex'] = 384;
  50764. t['parenrightbt'] = 384;
  50765. t['bracketrighttp'] = 384;
  50766. t['bracketrightex'] = 384;
  50767. t['bracketrightbt'] = 384;
  50768. t['bracerighttp'] = 494;
  50769. t['bracerightmid'] = 494;
  50770. t['bracerightbt'] = 494;
  50771. t['apple'] = 790;
  50772. });
  50773. t['Times-Roman'] = getLookupTableFactory(function (t) {
  50774. t['space'] = 250;
  50775. t['exclam'] = 333;
  50776. t['quotedbl'] = 408;
  50777. t['numbersign'] = 500;
  50778. t['dollar'] = 500;
  50779. t['percent'] = 833;
  50780. t['ampersand'] = 778;
  50781. t['quoteright'] = 333;
  50782. t['parenleft'] = 333;
  50783. t['parenright'] = 333;
  50784. t['asterisk'] = 500;
  50785. t['plus'] = 564;
  50786. t['comma'] = 250;
  50787. t['hyphen'] = 333;
  50788. t['period'] = 250;
  50789. t['slash'] = 278;
  50790. t['zero'] = 500;
  50791. t['one'] = 500;
  50792. t['two'] = 500;
  50793. t['three'] = 500;
  50794. t['four'] = 500;
  50795. t['five'] = 500;
  50796. t['six'] = 500;
  50797. t['seven'] = 500;
  50798. t['eight'] = 500;
  50799. t['nine'] = 500;
  50800. t['colon'] = 278;
  50801. t['semicolon'] = 278;
  50802. t['less'] = 564;
  50803. t['equal'] = 564;
  50804. t['greater'] = 564;
  50805. t['question'] = 444;
  50806. t['at'] = 921;
  50807. t['A'] = 722;
  50808. t['B'] = 667;
  50809. t['C'] = 667;
  50810. t['D'] = 722;
  50811. t['E'] = 611;
  50812. t['F'] = 556;
  50813. t['G'] = 722;
  50814. t['H'] = 722;
  50815. t['I'] = 333;
  50816. t['J'] = 389;
  50817. t['K'] = 722;
  50818. t['L'] = 611;
  50819. t['M'] = 889;
  50820. t['N'] = 722;
  50821. t['O'] = 722;
  50822. t['P'] = 556;
  50823. t['Q'] = 722;
  50824. t['R'] = 667;
  50825. t['S'] = 556;
  50826. t['T'] = 611;
  50827. t['U'] = 722;
  50828. t['V'] = 722;
  50829. t['W'] = 944;
  50830. t['X'] = 722;
  50831. t['Y'] = 722;
  50832. t['Z'] = 611;
  50833. t['bracketleft'] = 333;
  50834. t['backslash'] = 278;
  50835. t['bracketright'] = 333;
  50836. t['asciicircum'] = 469;
  50837. t['underscore'] = 500;
  50838. t['quoteleft'] = 333;
  50839. t['a'] = 444;
  50840. t['b'] = 500;
  50841. t['c'] = 444;
  50842. t['d'] = 500;
  50843. t['e'] = 444;
  50844. t['f'] = 333;
  50845. t['g'] = 500;
  50846. t['h'] = 500;
  50847. t['i'] = 278;
  50848. t['j'] = 278;
  50849. t['k'] = 500;
  50850. t['l'] = 278;
  50851. t['m'] = 778;
  50852. t['n'] = 500;
  50853. t['o'] = 500;
  50854. t['p'] = 500;
  50855. t['q'] = 500;
  50856. t['r'] = 333;
  50857. t['s'] = 389;
  50858. t['t'] = 278;
  50859. t['u'] = 500;
  50860. t['v'] = 500;
  50861. t['w'] = 722;
  50862. t['x'] = 500;
  50863. t['y'] = 500;
  50864. t['z'] = 444;
  50865. t['braceleft'] = 480;
  50866. t['bar'] = 200;
  50867. t['braceright'] = 480;
  50868. t['asciitilde'] = 541;
  50869. t['exclamdown'] = 333;
  50870. t['cent'] = 500;
  50871. t['sterling'] = 500;
  50872. t['fraction'] = 167;
  50873. t['yen'] = 500;
  50874. t['florin'] = 500;
  50875. t['section'] = 500;
  50876. t['currency'] = 500;
  50877. t['quotesingle'] = 180;
  50878. t['quotedblleft'] = 444;
  50879. t['guillemotleft'] = 500;
  50880. t['guilsinglleft'] = 333;
  50881. t['guilsinglright'] = 333;
  50882. t['fi'] = 556;
  50883. t['fl'] = 556;
  50884. t['endash'] = 500;
  50885. t['dagger'] = 500;
  50886. t['daggerdbl'] = 500;
  50887. t['periodcentered'] = 250;
  50888. t['paragraph'] = 453;
  50889. t['bullet'] = 350;
  50890. t['quotesinglbase'] = 333;
  50891. t['quotedblbase'] = 444;
  50892. t['quotedblright'] = 444;
  50893. t['guillemotright'] = 500;
  50894. t['ellipsis'] = 1000;
  50895. t['perthousand'] = 1000;
  50896. t['questiondown'] = 444;
  50897. t['grave'] = 333;
  50898. t['acute'] = 333;
  50899. t['circumflex'] = 333;
  50900. t['tilde'] = 333;
  50901. t['macron'] = 333;
  50902. t['breve'] = 333;
  50903. t['dotaccent'] = 333;
  50904. t['dieresis'] = 333;
  50905. t['ring'] = 333;
  50906. t['cedilla'] = 333;
  50907. t['hungarumlaut'] = 333;
  50908. t['ogonek'] = 333;
  50909. t['caron'] = 333;
  50910. t['emdash'] = 1000;
  50911. t['AE'] = 889;
  50912. t['ordfeminine'] = 276;
  50913. t['Lslash'] = 611;
  50914. t['Oslash'] = 722;
  50915. t['OE'] = 889;
  50916. t['ordmasculine'] = 310;
  50917. t['ae'] = 667;
  50918. t['dotlessi'] = 278;
  50919. t['lslash'] = 278;
  50920. t['oslash'] = 500;
  50921. t['oe'] = 722;
  50922. t['germandbls'] = 500;
  50923. t['Idieresis'] = 333;
  50924. t['eacute'] = 444;
  50925. t['abreve'] = 444;
  50926. t['uhungarumlaut'] = 500;
  50927. t['ecaron'] = 444;
  50928. t['Ydieresis'] = 722;
  50929. t['divide'] = 564;
  50930. t['Yacute'] = 722;
  50931. t['Acircumflex'] = 722;
  50932. t['aacute'] = 444;
  50933. t['Ucircumflex'] = 722;
  50934. t['yacute'] = 500;
  50935. t['scommaaccent'] = 389;
  50936. t['ecircumflex'] = 444;
  50937. t['Uring'] = 722;
  50938. t['Udieresis'] = 722;
  50939. t['aogonek'] = 444;
  50940. t['Uacute'] = 722;
  50941. t['uogonek'] = 500;
  50942. t['Edieresis'] = 611;
  50943. t['Dcroat'] = 722;
  50944. t['commaaccent'] = 250;
  50945. t['copyright'] = 760;
  50946. t['Emacron'] = 611;
  50947. t['ccaron'] = 444;
  50948. t['aring'] = 444;
  50949. t['Ncommaaccent'] = 722;
  50950. t['lacute'] = 278;
  50951. t['agrave'] = 444;
  50952. t['Tcommaaccent'] = 611;
  50953. t['Cacute'] = 667;
  50954. t['atilde'] = 444;
  50955. t['Edotaccent'] = 611;
  50956. t['scaron'] = 389;
  50957. t['scedilla'] = 389;
  50958. t['iacute'] = 278;
  50959. t['lozenge'] = 471;
  50960. t['Rcaron'] = 667;
  50961. t['Gcommaaccent'] = 722;
  50962. t['ucircumflex'] = 500;
  50963. t['acircumflex'] = 444;
  50964. t['Amacron'] = 722;
  50965. t['rcaron'] = 333;
  50966. t['ccedilla'] = 444;
  50967. t['Zdotaccent'] = 611;
  50968. t['Thorn'] = 556;
  50969. t['Omacron'] = 722;
  50970. t['Racute'] = 667;
  50971. t['Sacute'] = 556;
  50972. t['dcaron'] = 588;
  50973. t['Umacron'] = 722;
  50974. t['uring'] = 500;
  50975. t['threesuperior'] = 300;
  50976. t['Ograve'] = 722;
  50977. t['Agrave'] = 722;
  50978. t['Abreve'] = 722;
  50979. t['multiply'] = 564;
  50980. t['uacute'] = 500;
  50981. t['Tcaron'] = 611;
  50982. t['partialdiff'] = 476;
  50983. t['ydieresis'] = 500;
  50984. t['Nacute'] = 722;
  50985. t['icircumflex'] = 278;
  50986. t['Ecircumflex'] = 611;
  50987. t['adieresis'] = 444;
  50988. t['edieresis'] = 444;
  50989. t['cacute'] = 444;
  50990. t['nacute'] = 500;
  50991. t['umacron'] = 500;
  50992. t['Ncaron'] = 722;
  50993. t['Iacute'] = 333;
  50994. t['plusminus'] = 564;
  50995. t['brokenbar'] = 200;
  50996. t['registered'] = 760;
  50997. t['Gbreve'] = 722;
  50998. t['Idotaccent'] = 333;
  50999. t['summation'] = 600;
  51000. t['Egrave'] = 611;
  51001. t['racute'] = 333;
  51002. t['omacron'] = 500;
  51003. t['Zacute'] = 611;
  51004. t['Zcaron'] = 611;
  51005. t['greaterequal'] = 549;
  51006. t['Eth'] = 722;
  51007. t['Ccedilla'] = 667;
  51008. t['lcommaaccent'] = 278;
  51009. t['tcaron'] = 326;
  51010. t['eogonek'] = 444;
  51011. t['Uogonek'] = 722;
  51012. t['Aacute'] = 722;
  51013. t['Adieresis'] = 722;
  51014. t['egrave'] = 444;
  51015. t['zacute'] = 444;
  51016. t['iogonek'] = 278;
  51017. t['Oacute'] = 722;
  51018. t['oacute'] = 500;
  51019. t['amacron'] = 444;
  51020. t['sacute'] = 389;
  51021. t['idieresis'] = 278;
  51022. t['Ocircumflex'] = 722;
  51023. t['Ugrave'] = 722;
  51024. t['Delta'] = 612;
  51025. t['thorn'] = 500;
  51026. t['twosuperior'] = 300;
  51027. t['Odieresis'] = 722;
  51028. t['mu'] = 500;
  51029. t['igrave'] = 278;
  51030. t['ohungarumlaut'] = 500;
  51031. t['Eogonek'] = 611;
  51032. t['dcroat'] = 500;
  51033. t['threequarters'] = 750;
  51034. t['Scedilla'] = 556;
  51035. t['lcaron'] = 344;
  51036. t['Kcommaaccent'] = 722;
  51037. t['Lacute'] = 611;
  51038. t['trademark'] = 980;
  51039. t['edotaccent'] = 444;
  51040. t['Igrave'] = 333;
  51041. t['Imacron'] = 333;
  51042. t['Lcaron'] = 611;
  51043. t['onehalf'] = 750;
  51044. t['lessequal'] = 549;
  51045. t['ocircumflex'] = 500;
  51046. t['ntilde'] = 500;
  51047. t['Uhungarumlaut'] = 722;
  51048. t['Eacute'] = 611;
  51049. t['emacron'] = 444;
  51050. t['gbreve'] = 500;
  51051. t['onequarter'] = 750;
  51052. t['Scaron'] = 556;
  51053. t['Scommaaccent'] = 556;
  51054. t['Ohungarumlaut'] = 722;
  51055. t['degree'] = 400;
  51056. t['ograve'] = 500;
  51057. t['Ccaron'] = 667;
  51058. t['ugrave'] = 500;
  51059. t['radical'] = 453;
  51060. t['Dcaron'] = 722;
  51061. t['rcommaaccent'] = 333;
  51062. t['Ntilde'] = 722;
  51063. t['otilde'] = 500;
  51064. t['Rcommaaccent'] = 667;
  51065. t['Lcommaaccent'] = 611;
  51066. t['Atilde'] = 722;
  51067. t['Aogonek'] = 722;
  51068. t['Aring'] = 722;
  51069. t['Otilde'] = 722;
  51070. t['zdotaccent'] = 444;
  51071. t['Ecaron'] = 611;
  51072. t['Iogonek'] = 333;
  51073. t['kcommaaccent'] = 500;
  51074. t['minus'] = 564;
  51075. t['Icircumflex'] = 333;
  51076. t['ncaron'] = 500;
  51077. t['tcommaaccent'] = 278;
  51078. t['logicalnot'] = 564;
  51079. t['odieresis'] = 500;
  51080. t['udieresis'] = 500;
  51081. t['notequal'] = 549;
  51082. t['gcommaaccent'] = 500;
  51083. t['eth'] = 500;
  51084. t['zcaron'] = 444;
  51085. t['ncommaaccent'] = 500;
  51086. t['onesuperior'] = 300;
  51087. t['imacron'] = 278;
  51088. t['Euro'] = 500;
  51089. });
  51090. t['Times-Bold'] = getLookupTableFactory(function (t) {
  51091. t['space'] = 250;
  51092. t['exclam'] = 333;
  51093. t['quotedbl'] = 555;
  51094. t['numbersign'] = 500;
  51095. t['dollar'] = 500;
  51096. t['percent'] = 1000;
  51097. t['ampersand'] = 833;
  51098. t['quoteright'] = 333;
  51099. t['parenleft'] = 333;
  51100. t['parenright'] = 333;
  51101. t['asterisk'] = 500;
  51102. t['plus'] = 570;
  51103. t['comma'] = 250;
  51104. t['hyphen'] = 333;
  51105. t['period'] = 250;
  51106. t['slash'] = 278;
  51107. t['zero'] = 500;
  51108. t['one'] = 500;
  51109. t['two'] = 500;
  51110. t['three'] = 500;
  51111. t['four'] = 500;
  51112. t['five'] = 500;
  51113. t['six'] = 500;
  51114. t['seven'] = 500;
  51115. t['eight'] = 500;
  51116. t['nine'] = 500;
  51117. t['colon'] = 333;
  51118. t['semicolon'] = 333;
  51119. t['less'] = 570;
  51120. t['equal'] = 570;
  51121. t['greater'] = 570;
  51122. t['question'] = 500;
  51123. t['at'] = 930;
  51124. t['A'] = 722;
  51125. t['B'] = 667;
  51126. t['C'] = 722;
  51127. t['D'] = 722;
  51128. t['E'] = 667;
  51129. t['F'] = 611;
  51130. t['G'] = 778;
  51131. t['H'] = 778;
  51132. t['I'] = 389;
  51133. t['J'] = 500;
  51134. t['K'] = 778;
  51135. t['L'] = 667;
  51136. t['M'] = 944;
  51137. t['N'] = 722;
  51138. t['O'] = 778;
  51139. t['P'] = 611;
  51140. t['Q'] = 778;
  51141. t['R'] = 722;
  51142. t['S'] = 556;
  51143. t['T'] = 667;
  51144. t['U'] = 722;
  51145. t['V'] = 722;
  51146. t['W'] = 1000;
  51147. t['X'] = 722;
  51148. t['Y'] = 722;
  51149. t['Z'] = 667;
  51150. t['bracketleft'] = 333;
  51151. t['backslash'] = 278;
  51152. t['bracketright'] = 333;
  51153. t['asciicircum'] = 581;
  51154. t['underscore'] = 500;
  51155. t['quoteleft'] = 333;
  51156. t['a'] = 500;
  51157. t['b'] = 556;
  51158. t['c'] = 444;
  51159. t['d'] = 556;
  51160. t['e'] = 444;
  51161. t['f'] = 333;
  51162. t['g'] = 500;
  51163. t['h'] = 556;
  51164. t['i'] = 278;
  51165. t['j'] = 333;
  51166. t['k'] = 556;
  51167. t['l'] = 278;
  51168. t['m'] = 833;
  51169. t['n'] = 556;
  51170. t['o'] = 500;
  51171. t['p'] = 556;
  51172. t['q'] = 556;
  51173. t['r'] = 444;
  51174. t['s'] = 389;
  51175. t['t'] = 333;
  51176. t['u'] = 556;
  51177. t['v'] = 500;
  51178. t['w'] = 722;
  51179. t['x'] = 500;
  51180. t['y'] = 500;
  51181. t['z'] = 444;
  51182. t['braceleft'] = 394;
  51183. t['bar'] = 220;
  51184. t['braceright'] = 394;
  51185. t['asciitilde'] = 520;
  51186. t['exclamdown'] = 333;
  51187. t['cent'] = 500;
  51188. t['sterling'] = 500;
  51189. t['fraction'] = 167;
  51190. t['yen'] = 500;
  51191. t['florin'] = 500;
  51192. t['section'] = 500;
  51193. t['currency'] = 500;
  51194. t['quotesingle'] = 278;
  51195. t['quotedblleft'] = 500;
  51196. t['guillemotleft'] = 500;
  51197. t['guilsinglleft'] = 333;
  51198. t['guilsinglright'] = 333;
  51199. t['fi'] = 556;
  51200. t['fl'] = 556;
  51201. t['endash'] = 500;
  51202. t['dagger'] = 500;
  51203. t['daggerdbl'] = 500;
  51204. t['periodcentered'] = 250;
  51205. t['paragraph'] = 540;
  51206. t['bullet'] = 350;
  51207. t['quotesinglbase'] = 333;
  51208. t['quotedblbase'] = 500;
  51209. t['quotedblright'] = 500;
  51210. t['guillemotright'] = 500;
  51211. t['ellipsis'] = 1000;
  51212. t['perthousand'] = 1000;
  51213. t['questiondown'] = 500;
  51214. t['grave'] = 333;
  51215. t['acute'] = 333;
  51216. t['circumflex'] = 333;
  51217. t['tilde'] = 333;
  51218. t['macron'] = 333;
  51219. t['breve'] = 333;
  51220. t['dotaccent'] = 333;
  51221. t['dieresis'] = 333;
  51222. t['ring'] = 333;
  51223. t['cedilla'] = 333;
  51224. t['hungarumlaut'] = 333;
  51225. t['ogonek'] = 333;
  51226. t['caron'] = 333;
  51227. t['emdash'] = 1000;
  51228. t['AE'] = 1000;
  51229. t['ordfeminine'] = 300;
  51230. t['Lslash'] = 667;
  51231. t['Oslash'] = 778;
  51232. t['OE'] = 1000;
  51233. t['ordmasculine'] = 330;
  51234. t['ae'] = 722;
  51235. t['dotlessi'] = 278;
  51236. t['lslash'] = 278;
  51237. t['oslash'] = 500;
  51238. t['oe'] = 722;
  51239. t['germandbls'] = 556;
  51240. t['Idieresis'] = 389;
  51241. t['eacute'] = 444;
  51242. t['abreve'] = 500;
  51243. t['uhungarumlaut'] = 556;
  51244. t['ecaron'] = 444;
  51245. t['Ydieresis'] = 722;
  51246. t['divide'] = 570;
  51247. t['Yacute'] = 722;
  51248. t['Acircumflex'] = 722;
  51249. t['aacute'] = 500;
  51250. t['Ucircumflex'] = 722;
  51251. t['yacute'] = 500;
  51252. t['scommaaccent'] = 389;
  51253. t['ecircumflex'] = 444;
  51254. t['Uring'] = 722;
  51255. t['Udieresis'] = 722;
  51256. t['aogonek'] = 500;
  51257. t['Uacute'] = 722;
  51258. t['uogonek'] = 556;
  51259. t['Edieresis'] = 667;
  51260. t['Dcroat'] = 722;
  51261. t['commaaccent'] = 250;
  51262. t['copyright'] = 747;
  51263. t['Emacron'] = 667;
  51264. t['ccaron'] = 444;
  51265. t['aring'] = 500;
  51266. t['Ncommaaccent'] = 722;
  51267. t['lacute'] = 278;
  51268. t['agrave'] = 500;
  51269. t['Tcommaaccent'] = 667;
  51270. t['Cacute'] = 722;
  51271. t['atilde'] = 500;
  51272. t['Edotaccent'] = 667;
  51273. t['scaron'] = 389;
  51274. t['scedilla'] = 389;
  51275. t['iacute'] = 278;
  51276. t['lozenge'] = 494;
  51277. t['Rcaron'] = 722;
  51278. t['Gcommaaccent'] = 778;
  51279. t['ucircumflex'] = 556;
  51280. t['acircumflex'] = 500;
  51281. t['Amacron'] = 722;
  51282. t['rcaron'] = 444;
  51283. t['ccedilla'] = 444;
  51284. t['Zdotaccent'] = 667;
  51285. t['Thorn'] = 611;
  51286. t['Omacron'] = 778;
  51287. t['Racute'] = 722;
  51288. t['Sacute'] = 556;
  51289. t['dcaron'] = 672;
  51290. t['Umacron'] = 722;
  51291. t['uring'] = 556;
  51292. t['threesuperior'] = 300;
  51293. t['Ograve'] = 778;
  51294. t['Agrave'] = 722;
  51295. t['Abreve'] = 722;
  51296. t['multiply'] = 570;
  51297. t['uacute'] = 556;
  51298. t['Tcaron'] = 667;
  51299. t['partialdiff'] = 494;
  51300. t['ydieresis'] = 500;
  51301. t['Nacute'] = 722;
  51302. t['icircumflex'] = 278;
  51303. t['Ecircumflex'] = 667;
  51304. t['adieresis'] = 500;
  51305. t['edieresis'] = 444;
  51306. t['cacute'] = 444;
  51307. t['nacute'] = 556;
  51308. t['umacron'] = 556;
  51309. t['Ncaron'] = 722;
  51310. t['Iacute'] = 389;
  51311. t['plusminus'] = 570;
  51312. t['brokenbar'] = 220;
  51313. t['registered'] = 747;
  51314. t['Gbreve'] = 778;
  51315. t['Idotaccent'] = 389;
  51316. t['summation'] = 600;
  51317. t['Egrave'] = 667;
  51318. t['racute'] = 444;
  51319. t['omacron'] = 500;
  51320. t['Zacute'] = 667;
  51321. t['Zcaron'] = 667;
  51322. t['greaterequal'] = 549;
  51323. t['Eth'] = 722;
  51324. t['Ccedilla'] = 722;
  51325. t['lcommaaccent'] = 278;
  51326. t['tcaron'] = 416;
  51327. t['eogonek'] = 444;
  51328. t['Uogonek'] = 722;
  51329. t['Aacute'] = 722;
  51330. t['Adieresis'] = 722;
  51331. t['egrave'] = 444;
  51332. t['zacute'] = 444;
  51333. t['iogonek'] = 278;
  51334. t['Oacute'] = 778;
  51335. t['oacute'] = 500;
  51336. t['amacron'] = 500;
  51337. t['sacute'] = 389;
  51338. t['idieresis'] = 278;
  51339. t['Ocircumflex'] = 778;
  51340. t['Ugrave'] = 722;
  51341. t['Delta'] = 612;
  51342. t['thorn'] = 556;
  51343. t['twosuperior'] = 300;
  51344. t['Odieresis'] = 778;
  51345. t['mu'] = 556;
  51346. t['igrave'] = 278;
  51347. t['ohungarumlaut'] = 500;
  51348. t['Eogonek'] = 667;
  51349. t['dcroat'] = 556;
  51350. t['threequarters'] = 750;
  51351. t['Scedilla'] = 556;
  51352. t['lcaron'] = 394;
  51353. t['Kcommaaccent'] = 778;
  51354. t['Lacute'] = 667;
  51355. t['trademark'] = 1000;
  51356. t['edotaccent'] = 444;
  51357. t['Igrave'] = 389;
  51358. t['Imacron'] = 389;
  51359. t['Lcaron'] = 667;
  51360. t['onehalf'] = 750;
  51361. t['lessequal'] = 549;
  51362. t['ocircumflex'] = 500;
  51363. t['ntilde'] = 556;
  51364. t['Uhungarumlaut'] = 722;
  51365. t['Eacute'] = 667;
  51366. t['emacron'] = 444;
  51367. t['gbreve'] = 500;
  51368. t['onequarter'] = 750;
  51369. t['Scaron'] = 556;
  51370. t['Scommaaccent'] = 556;
  51371. t['Ohungarumlaut'] = 778;
  51372. t['degree'] = 400;
  51373. t['ograve'] = 500;
  51374. t['Ccaron'] = 722;
  51375. t['ugrave'] = 556;
  51376. t['radical'] = 549;
  51377. t['Dcaron'] = 722;
  51378. t['rcommaaccent'] = 444;
  51379. t['Ntilde'] = 722;
  51380. t['otilde'] = 500;
  51381. t['Rcommaaccent'] = 722;
  51382. t['Lcommaaccent'] = 667;
  51383. t['Atilde'] = 722;
  51384. t['Aogonek'] = 722;
  51385. t['Aring'] = 722;
  51386. t['Otilde'] = 778;
  51387. t['zdotaccent'] = 444;
  51388. t['Ecaron'] = 667;
  51389. t['Iogonek'] = 389;
  51390. t['kcommaaccent'] = 556;
  51391. t['minus'] = 570;
  51392. t['Icircumflex'] = 389;
  51393. t['ncaron'] = 556;
  51394. t['tcommaaccent'] = 333;
  51395. t['logicalnot'] = 570;
  51396. t['odieresis'] = 500;
  51397. t['udieresis'] = 556;
  51398. t['notequal'] = 549;
  51399. t['gcommaaccent'] = 500;
  51400. t['eth'] = 500;
  51401. t['zcaron'] = 444;
  51402. t['ncommaaccent'] = 556;
  51403. t['onesuperior'] = 300;
  51404. t['imacron'] = 278;
  51405. t['Euro'] = 500;
  51406. });
  51407. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  51408. t['space'] = 250;
  51409. t['exclam'] = 389;
  51410. t['quotedbl'] = 555;
  51411. t['numbersign'] = 500;
  51412. t['dollar'] = 500;
  51413. t['percent'] = 833;
  51414. t['ampersand'] = 778;
  51415. t['quoteright'] = 333;
  51416. t['parenleft'] = 333;
  51417. t['parenright'] = 333;
  51418. t['asterisk'] = 500;
  51419. t['plus'] = 570;
  51420. t['comma'] = 250;
  51421. t['hyphen'] = 333;
  51422. t['period'] = 250;
  51423. t['slash'] = 278;
  51424. t['zero'] = 500;
  51425. t['one'] = 500;
  51426. t['two'] = 500;
  51427. t['three'] = 500;
  51428. t['four'] = 500;
  51429. t['five'] = 500;
  51430. t['six'] = 500;
  51431. t['seven'] = 500;
  51432. t['eight'] = 500;
  51433. t['nine'] = 500;
  51434. t['colon'] = 333;
  51435. t['semicolon'] = 333;
  51436. t['less'] = 570;
  51437. t['equal'] = 570;
  51438. t['greater'] = 570;
  51439. t['question'] = 500;
  51440. t['at'] = 832;
  51441. t['A'] = 667;
  51442. t['B'] = 667;
  51443. t['C'] = 667;
  51444. t['D'] = 722;
  51445. t['E'] = 667;
  51446. t['F'] = 667;
  51447. t['G'] = 722;
  51448. t['H'] = 778;
  51449. t['I'] = 389;
  51450. t['J'] = 500;
  51451. t['K'] = 667;
  51452. t['L'] = 611;
  51453. t['M'] = 889;
  51454. t['N'] = 722;
  51455. t['O'] = 722;
  51456. t['P'] = 611;
  51457. t['Q'] = 722;
  51458. t['R'] = 667;
  51459. t['S'] = 556;
  51460. t['T'] = 611;
  51461. t['U'] = 722;
  51462. t['V'] = 667;
  51463. t['W'] = 889;
  51464. t['X'] = 667;
  51465. t['Y'] = 611;
  51466. t['Z'] = 611;
  51467. t['bracketleft'] = 333;
  51468. t['backslash'] = 278;
  51469. t['bracketright'] = 333;
  51470. t['asciicircum'] = 570;
  51471. t['underscore'] = 500;
  51472. t['quoteleft'] = 333;
  51473. t['a'] = 500;
  51474. t['b'] = 500;
  51475. t['c'] = 444;
  51476. t['d'] = 500;
  51477. t['e'] = 444;
  51478. t['f'] = 333;
  51479. t['g'] = 500;
  51480. t['h'] = 556;
  51481. t['i'] = 278;
  51482. t['j'] = 278;
  51483. t['k'] = 500;
  51484. t['l'] = 278;
  51485. t['m'] = 778;
  51486. t['n'] = 556;
  51487. t['o'] = 500;
  51488. t['p'] = 500;
  51489. t['q'] = 500;
  51490. t['r'] = 389;
  51491. t['s'] = 389;
  51492. t['t'] = 278;
  51493. t['u'] = 556;
  51494. t['v'] = 444;
  51495. t['w'] = 667;
  51496. t['x'] = 500;
  51497. t['y'] = 444;
  51498. t['z'] = 389;
  51499. t['braceleft'] = 348;
  51500. t['bar'] = 220;
  51501. t['braceright'] = 348;
  51502. t['asciitilde'] = 570;
  51503. t['exclamdown'] = 389;
  51504. t['cent'] = 500;
  51505. t['sterling'] = 500;
  51506. t['fraction'] = 167;
  51507. t['yen'] = 500;
  51508. t['florin'] = 500;
  51509. t['section'] = 500;
  51510. t['currency'] = 500;
  51511. t['quotesingle'] = 278;
  51512. t['quotedblleft'] = 500;
  51513. t['guillemotleft'] = 500;
  51514. t['guilsinglleft'] = 333;
  51515. t['guilsinglright'] = 333;
  51516. t['fi'] = 556;
  51517. t['fl'] = 556;
  51518. t['endash'] = 500;
  51519. t['dagger'] = 500;
  51520. t['daggerdbl'] = 500;
  51521. t['periodcentered'] = 250;
  51522. t['paragraph'] = 500;
  51523. t['bullet'] = 350;
  51524. t['quotesinglbase'] = 333;
  51525. t['quotedblbase'] = 500;
  51526. t['quotedblright'] = 500;
  51527. t['guillemotright'] = 500;
  51528. t['ellipsis'] = 1000;
  51529. t['perthousand'] = 1000;
  51530. t['questiondown'] = 500;
  51531. t['grave'] = 333;
  51532. t['acute'] = 333;
  51533. t['circumflex'] = 333;
  51534. t['tilde'] = 333;
  51535. t['macron'] = 333;
  51536. t['breve'] = 333;
  51537. t['dotaccent'] = 333;
  51538. t['dieresis'] = 333;
  51539. t['ring'] = 333;
  51540. t['cedilla'] = 333;
  51541. t['hungarumlaut'] = 333;
  51542. t['ogonek'] = 333;
  51543. t['caron'] = 333;
  51544. t['emdash'] = 1000;
  51545. t['AE'] = 944;
  51546. t['ordfeminine'] = 266;
  51547. t['Lslash'] = 611;
  51548. t['Oslash'] = 722;
  51549. t['OE'] = 944;
  51550. t['ordmasculine'] = 300;
  51551. t['ae'] = 722;
  51552. t['dotlessi'] = 278;
  51553. t['lslash'] = 278;
  51554. t['oslash'] = 500;
  51555. t['oe'] = 722;
  51556. t['germandbls'] = 500;
  51557. t['Idieresis'] = 389;
  51558. t['eacute'] = 444;
  51559. t['abreve'] = 500;
  51560. t['uhungarumlaut'] = 556;
  51561. t['ecaron'] = 444;
  51562. t['Ydieresis'] = 611;
  51563. t['divide'] = 570;
  51564. t['Yacute'] = 611;
  51565. t['Acircumflex'] = 667;
  51566. t['aacute'] = 500;
  51567. t['Ucircumflex'] = 722;
  51568. t['yacute'] = 444;
  51569. t['scommaaccent'] = 389;
  51570. t['ecircumflex'] = 444;
  51571. t['Uring'] = 722;
  51572. t['Udieresis'] = 722;
  51573. t['aogonek'] = 500;
  51574. t['Uacute'] = 722;
  51575. t['uogonek'] = 556;
  51576. t['Edieresis'] = 667;
  51577. t['Dcroat'] = 722;
  51578. t['commaaccent'] = 250;
  51579. t['copyright'] = 747;
  51580. t['Emacron'] = 667;
  51581. t['ccaron'] = 444;
  51582. t['aring'] = 500;
  51583. t['Ncommaaccent'] = 722;
  51584. t['lacute'] = 278;
  51585. t['agrave'] = 500;
  51586. t['Tcommaaccent'] = 611;
  51587. t['Cacute'] = 667;
  51588. t['atilde'] = 500;
  51589. t['Edotaccent'] = 667;
  51590. t['scaron'] = 389;
  51591. t['scedilla'] = 389;
  51592. t['iacute'] = 278;
  51593. t['lozenge'] = 494;
  51594. t['Rcaron'] = 667;
  51595. t['Gcommaaccent'] = 722;
  51596. t['ucircumflex'] = 556;
  51597. t['acircumflex'] = 500;
  51598. t['Amacron'] = 667;
  51599. t['rcaron'] = 389;
  51600. t['ccedilla'] = 444;
  51601. t['Zdotaccent'] = 611;
  51602. t['Thorn'] = 611;
  51603. t['Omacron'] = 722;
  51604. t['Racute'] = 667;
  51605. t['Sacute'] = 556;
  51606. t['dcaron'] = 608;
  51607. t['Umacron'] = 722;
  51608. t['uring'] = 556;
  51609. t['threesuperior'] = 300;
  51610. t['Ograve'] = 722;
  51611. t['Agrave'] = 667;
  51612. t['Abreve'] = 667;
  51613. t['multiply'] = 570;
  51614. t['uacute'] = 556;
  51615. t['Tcaron'] = 611;
  51616. t['partialdiff'] = 494;
  51617. t['ydieresis'] = 444;
  51618. t['Nacute'] = 722;
  51619. t['icircumflex'] = 278;
  51620. t['Ecircumflex'] = 667;
  51621. t['adieresis'] = 500;
  51622. t['edieresis'] = 444;
  51623. t['cacute'] = 444;
  51624. t['nacute'] = 556;
  51625. t['umacron'] = 556;
  51626. t['Ncaron'] = 722;
  51627. t['Iacute'] = 389;
  51628. t['plusminus'] = 570;
  51629. t['brokenbar'] = 220;
  51630. t['registered'] = 747;
  51631. t['Gbreve'] = 722;
  51632. t['Idotaccent'] = 389;
  51633. t['summation'] = 600;
  51634. t['Egrave'] = 667;
  51635. t['racute'] = 389;
  51636. t['omacron'] = 500;
  51637. t['Zacute'] = 611;
  51638. t['Zcaron'] = 611;
  51639. t['greaterequal'] = 549;
  51640. t['Eth'] = 722;
  51641. t['Ccedilla'] = 667;
  51642. t['lcommaaccent'] = 278;
  51643. t['tcaron'] = 366;
  51644. t['eogonek'] = 444;
  51645. t['Uogonek'] = 722;
  51646. t['Aacute'] = 667;
  51647. t['Adieresis'] = 667;
  51648. t['egrave'] = 444;
  51649. t['zacute'] = 389;
  51650. t['iogonek'] = 278;
  51651. t['Oacute'] = 722;
  51652. t['oacute'] = 500;
  51653. t['amacron'] = 500;
  51654. t['sacute'] = 389;
  51655. t['idieresis'] = 278;
  51656. t['Ocircumflex'] = 722;
  51657. t['Ugrave'] = 722;
  51658. t['Delta'] = 612;
  51659. t['thorn'] = 500;
  51660. t['twosuperior'] = 300;
  51661. t['Odieresis'] = 722;
  51662. t['mu'] = 576;
  51663. t['igrave'] = 278;
  51664. t['ohungarumlaut'] = 500;
  51665. t['Eogonek'] = 667;
  51666. t['dcroat'] = 500;
  51667. t['threequarters'] = 750;
  51668. t['Scedilla'] = 556;
  51669. t['lcaron'] = 382;
  51670. t['Kcommaaccent'] = 667;
  51671. t['Lacute'] = 611;
  51672. t['trademark'] = 1000;
  51673. t['edotaccent'] = 444;
  51674. t['Igrave'] = 389;
  51675. t['Imacron'] = 389;
  51676. t['Lcaron'] = 611;
  51677. t['onehalf'] = 750;
  51678. t['lessequal'] = 549;
  51679. t['ocircumflex'] = 500;
  51680. t['ntilde'] = 556;
  51681. t['Uhungarumlaut'] = 722;
  51682. t['Eacute'] = 667;
  51683. t['emacron'] = 444;
  51684. t['gbreve'] = 500;
  51685. t['onequarter'] = 750;
  51686. t['Scaron'] = 556;
  51687. t['Scommaaccent'] = 556;
  51688. t['Ohungarumlaut'] = 722;
  51689. t['degree'] = 400;
  51690. t['ograve'] = 500;
  51691. t['Ccaron'] = 667;
  51692. t['ugrave'] = 556;
  51693. t['radical'] = 549;
  51694. t['Dcaron'] = 722;
  51695. t['rcommaaccent'] = 389;
  51696. t['Ntilde'] = 722;
  51697. t['otilde'] = 500;
  51698. t['Rcommaaccent'] = 667;
  51699. t['Lcommaaccent'] = 611;
  51700. t['Atilde'] = 667;
  51701. t['Aogonek'] = 667;
  51702. t['Aring'] = 667;
  51703. t['Otilde'] = 722;
  51704. t['zdotaccent'] = 389;
  51705. t['Ecaron'] = 667;
  51706. t['Iogonek'] = 389;
  51707. t['kcommaaccent'] = 500;
  51708. t['minus'] = 606;
  51709. t['Icircumflex'] = 389;
  51710. t['ncaron'] = 556;
  51711. t['tcommaaccent'] = 278;
  51712. t['logicalnot'] = 606;
  51713. t['odieresis'] = 500;
  51714. t['udieresis'] = 556;
  51715. t['notequal'] = 549;
  51716. t['gcommaaccent'] = 500;
  51717. t['eth'] = 500;
  51718. t['zcaron'] = 389;
  51719. t['ncommaaccent'] = 556;
  51720. t['onesuperior'] = 300;
  51721. t['imacron'] = 278;
  51722. t['Euro'] = 500;
  51723. });
  51724. t['Times-Italic'] = getLookupTableFactory(function (t) {
  51725. t['space'] = 250;
  51726. t['exclam'] = 333;
  51727. t['quotedbl'] = 420;
  51728. t['numbersign'] = 500;
  51729. t['dollar'] = 500;
  51730. t['percent'] = 833;
  51731. t['ampersand'] = 778;
  51732. t['quoteright'] = 333;
  51733. t['parenleft'] = 333;
  51734. t['parenright'] = 333;
  51735. t['asterisk'] = 500;
  51736. t['plus'] = 675;
  51737. t['comma'] = 250;
  51738. t['hyphen'] = 333;
  51739. t['period'] = 250;
  51740. t['slash'] = 278;
  51741. t['zero'] = 500;
  51742. t['one'] = 500;
  51743. t['two'] = 500;
  51744. t['three'] = 500;
  51745. t['four'] = 500;
  51746. t['five'] = 500;
  51747. t['six'] = 500;
  51748. t['seven'] = 500;
  51749. t['eight'] = 500;
  51750. t['nine'] = 500;
  51751. t['colon'] = 333;
  51752. t['semicolon'] = 333;
  51753. t['less'] = 675;
  51754. t['equal'] = 675;
  51755. t['greater'] = 675;
  51756. t['question'] = 500;
  51757. t['at'] = 920;
  51758. t['A'] = 611;
  51759. t['B'] = 611;
  51760. t['C'] = 667;
  51761. t['D'] = 722;
  51762. t['E'] = 611;
  51763. t['F'] = 611;
  51764. t['G'] = 722;
  51765. t['H'] = 722;
  51766. t['I'] = 333;
  51767. t['J'] = 444;
  51768. t['K'] = 667;
  51769. t['L'] = 556;
  51770. t['M'] = 833;
  51771. t['N'] = 667;
  51772. t['O'] = 722;
  51773. t['P'] = 611;
  51774. t['Q'] = 722;
  51775. t['R'] = 611;
  51776. t['S'] = 500;
  51777. t['T'] = 556;
  51778. t['U'] = 722;
  51779. t['V'] = 611;
  51780. t['W'] = 833;
  51781. t['X'] = 611;
  51782. t['Y'] = 556;
  51783. t['Z'] = 556;
  51784. t['bracketleft'] = 389;
  51785. t['backslash'] = 278;
  51786. t['bracketright'] = 389;
  51787. t['asciicircum'] = 422;
  51788. t['underscore'] = 500;
  51789. t['quoteleft'] = 333;
  51790. t['a'] = 500;
  51791. t['b'] = 500;
  51792. t['c'] = 444;
  51793. t['d'] = 500;
  51794. t['e'] = 444;
  51795. t['f'] = 278;
  51796. t['g'] = 500;
  51797. t['h'] = 500;
  51798. t['i'] = 278;
  51799. t['j'] = 278;
  51800. t['k'] = 444;
  51801. t['l'] = 278;
  51802. t['m'] = 722;
  51803. t['n'] = 500;
  51804. t['o'] = 500;
  51805. t['p'] = 500;
  51806. t['q'] = 500;
  51807. t['r'] = 389;
  51808. t['s'] = 389;
  51809. t['t'] = 278;
  51810. t['u'] = 500;
  51811. t['v'] = 444;
  51812. t['w'] = 667;
  51813. t['x'] = 444;
  51814. t['y'] = 444;
  51815. t['z'] = 389;
  51816. t['braceleft'] = 400;
  51817. t['bar'] = 275;
  51818. t['braceright'] = 400;
  51819. t['asciitilde'] = 541;
  51820. t['exclamdown'] = 389;
  51821. t['cent'] = 500;
  51822. t['sterling'] = 500;
  51823. t['fraction'] = 167;
  51824. t['yen'] = 500;
  51825. t['florin'] = 500;
  51826. t['section'] = 500;
  51827. t['currency'] = 500;
  51828. t['quotesingle'] = 214;
  51829. t['quotedblleft'] = 556;
  51830. t['guillemotleft'] = 500;
  51831. t['guilsinglleft'] = 333;
  51832. t['guilsinglright'] = 333;
  51833. t['fi'] = 500;
  51834. t['fl'] = 500;
  51835. t['endash'] = 500;
  51836. t['dagger'] = 500;
  51837. t['daggerdbl'] = 500;
  51838. t['periodcentered'] = 250;
  51839. t['paragraph'] = 523;
  51840. t['bullet'] = 350;
  51841. t['quotesinglbase'] = 333;
  51842. t['quotedblbase'] = 556;
  51843. t['quotedblright'] = 556;
  51844. t['guillemotright'] = 500;
  51845. t['ellipsis'] = 889;
  51846. t['perthousand'] = 1000;
  51847. t['questiondown'] = 500;
  51848. t['grave'] = 333;
  51849. t['acute'] = 333;
  51850. t['circumflex'] = 333;
  51851. t['tilde'] = 333;
  51852. t['macron'] = 333;
  51853. t['breve'] = 333;
  51854. t['dotaccent'] = 333;
  51855. t['dieresis'] = 333;
  51856. t['ring'] = 333;
  51857. t['cedilla'] = 333;
  51858. t['hungarumlaut'] = 333;
  51859. t['ogonek'] = 333;
  51860. t['caron'] = 333;
  51861. t['emdash'] = 889;
  51862. t['AE'] = 889;
  51863. t['ordfeminine'] = 276;
  51864. t['Lslash'] = 556;
  51865. t['Oslash'] = 722;
  51866. t['OE'] = 944;
  51867. t['ordmasculine'] = 310;
  51868. t['ae'] = 667;
  51869. t['dotlessi'] = 278;
  51870. t['lslash'] = 278;
  51871. t['oslash'] = 500;
  51872. t['oe'] = 667;
  51873. t['germandbls'] = 500;
  51874. t['Idieresis'] = 333;
  51875. t['eacute'] = 444;
  51876. t['abreve'] = 500;
  51877. t['uhungarumlaut'] = 500;
  51878. t['ecaron'] = 444;
  51879. t['Ydieresis'] = 556;
  51880. t['divide'] = 675;
  51881. t['Yacute'] = 556;
  51882. t['Acircumflex'] = 611;
  51883. t['aacute'] = 500;
  51884. t['Ucircumflex'] = 722;
  51885. t['yacute'] = 444;
  51886. t['scommaaccent'] = 389;
  51887. t['ecircumflex'] = 444;
  51888. t['Uring'] = 722;
  51889. t['Udieresis'] = 722;
  51890. t['aogonek'] = 500;
  51891. t['Uacute'] = 722;
  51892. t['uogonek'] = 500;
  51893. t['Edieresis'] = 611;
  51894. t['Dcroat'] = 722;
  51895. t['commaaccent'] = 250;
  51896. t['copyright'] = 760;
  51897. t['Emacron'] = 611;
  51898. t['ccaron'] = 444;
  51899. t['aring'] = 500;
  51900. t['Ncommaaccent'] = 667;
  51901. t['lacute'] = 278;
  51902. t['agrave'] = 500;
  51903. t['Tcommaaccent'] = 556;
  51904. t['Cacute'] = 667;
  51905. t['atilde'] = 500;
  51906. t['Edotaccent'] = 611;
  51907. t['scaron'] = 389;
  51908. t['scedilla'] = 389;
  51909. t['iacute'] = 278;
  51910. t['lozenge'] = 471;
  51911. t['Rcaron'] = 611;
  51912. t['Gcommaaccent'] = 722;
  51913. t['ucircumflex'] = 500;
  51914. t['acircumflex'] = 500;
  51915. t['Amacron'] = 611;
  51916. t['rcaron'] = 389;
  51917. t['ccedilla'] = 444;
  51918. t['Zdotaccent'] = 556;
  51919. t['Thorn'] = 611;
  51920. t['Omacron'] = 722;
  51921. t['Racute'] = 611;
  51922. t['Sacute'] = 500;
  51923. t['dcaron'] = 544;
  51924. t['Umacron'] = 722;
  51925. t['uring'] = 500;
  51926. t['threesuperior'] = 300;
  51927. t['Ograve'] = 722;
  51928. t['Agrave'] = 611;
  51929. t['Abreve'] = 611;
  51930. t['multiply'] = 675;
  51931. t['uacute'] = 500;
  51932. t['Tcaron'] = 556;
  51933. t['partialdiff'] = 476;
  51934. t['ydieresis'] = 444;
  51935. t['Nacute'] = 667;
  51936. t['icircumflex'] = 278;
  51937. t['Ecircumflex'] = 611;
  51938. t['adieresis'] = 500;
  51939. t['edieresis'] = 444;
  51940. t['cacute'] = 444;
  51941. t['nacute'] = 500;
  51942. t['umacron'] = 500;
  51943. t['Ncaron'] = 667;
  51944. t['Iacute'] = 333;
  51945. t['plusminus'] = 675;
  51946. t['brokenbar'] = 275;
  51947. t['registered'] = 760;
  51948. t['Gbreve'] = 722;
  51949. t['Idotaccent'] = 333;
  51950. t['summation'] = 600;
  51951. t['Egrave'] = 611;
  51952. t['racute'] = 389;
  51953. t['omacron'] = 500;
  51954. t['Zacute'] = 556;
  51955. t['Zcaron'] = 556;
  51956. t['greaterequal'] = 549;
  51957. t['Eth'] = 722;
  51958. t['Ccedilla'] = 667;
  51959. t['lcommaaccent'] = 278;
  51960. t['tcaron'] = 300;
  51961. t['eogonek'] = 444;
  51962. t['Uogonek'] = 722;
  51963. t['Aacute'] = 611;
  51964. t['Adieresis'] = 611;
  51965. t['egrave'] = 444;
  51966. t['zacute'] = 389;
  51967. t['iogonek'] = 278;
  51968. t['Oacute'] = 722;
  51969. t['oacute'] = 500;
  51970. t['amacron'] = 500;
  51971. t['sacute'] = 389;
  51972. t['idieresis'] = 278;
  51973. t['Ocircumflex'] = 722;
  51974. t['Ugrave'] = 722;
  51975. t['Delta'] = 612;
  51976. t['thorn'] = 500;
  51977. t['twosuperior'] = 300;
  51978. t['Odieresis'] = 722;
  51979. t['mu'] = 500;
  51980. t['igrave'] = 278;
  51981. t['ohungarumlaut'] = 500;
  51982. t['Eogonek'] = 611;
  51983. t['dcroat'] = 500;
  51984. t['threequarters'] = 750;
  51985. t['Scedilla'] = 500;
  51986. t['lcaron'] = 300;
  51987. t['Kcommaaccent'] = 667;
  51988. t['Lacute'] = 556;
  51989. t['trademark'] = 980;
  51990. t['edotaccent'] = 444;
  51991. t['Igrave'] = 333;
  51992. t['Imacron'] = 333;
  51993. t['Lcaron'] = 611;
  51994. t['onehalf'] = 750;
  51995. t['lessequal'] = 549;
  51996. t['ocircumflex'] = 500;
  51997. t['ntilde'] = 500;
  51998. t['Uhungarumlaut'] = 722;
  51999. t['Eacute'] = 611;
  52000. t['emacron'] = 444;
  52001. t['gbreve'] = 500;
  52002. t['onequarter'] = 750;
  52003. t['Scaron'] = 500;
  52004. t['Scommaaccent'] = 500;
  52005. t['Ohungarumlaut'] = 722;
  52006. t['degree'] = 400;
  52007. t['ograve'] = 500;
  52008. t['Ccaron'] = 667;
  52009. t['ugrave'] = 500;
  52010. t['radical'] = 453;
  52011. t['Dcaron'] = 722;
  52012. t['rcommaaccent'] = 389;
  52013. t['Ntilde'] = 667;
  52014. t['otilde'] = 500;
  52015. t['Rcommaaccent'] = 611;
  52016. t['Lcommaaccent'] = 556;
  52017. t['Atilde'] = 611;
  52018. t['Aogonek'] = 611;
  52019. t['Aring'] = 611;
  52020. t['Otilde'] = 722;
  52021. t['zdotaccent'] = 389;
  52022. t['Ecaron'] = 611;
  52023. t['Iogonek'] = 333;
  52024. t['kcommaaccent'] = 444;
  52025. t['minus'] = 675;
  52026. t['Icircumflex'] = 333;
  52027. t['ncaron'] = 500;
  52028. t['tcommaaccent'] = 278;
  52029. t['logicalnot'] = 675;
  52030. t['odieresis'] = 500;
  52031. t['udieresis'] = 500;
  52032. t['notequal'] = 549;
  52033. t['gcommaaccent'] = 500;
  52034. t['eth'] = 500;
  52035. t['zcaron'] = 389;
  52036. t['ncommaaccent'] = 500;
  52037. t['onesuperior'] = 300;
  52038. t['imacron'] = 278;
  52039. t['Euro'] = 500;
  52040. });
  52041. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  52042. t['space'] = 278;
  52043. t['a1'] = 974;
  52044. t['a2'] = 961;
  52045. t['a202'] = 974;
  52046. t['a3'] = 980;
  52047. t['a4'] = 719;
  52048. t['a5'] = 789;
  52049. t['a119'] = 790;
  52050. t['a118'] = 791;
  52051. t['a117'] = 690;
  52052. t['a11'] = 960;
  52053. t['a12'] = 939;
  52054. t['a13'] = 549;
  52055. t['a14'] = 855;
  52056. t['a15'] = 911;
  52057. t['a16'] = 933;
  52058. t['a105'] = 911;
  52059. t['a17'] = 945;
  52060. t['a18'] = 974;
  52061. t['a19'] = 755;
  52062. t['a20'] = 846;
  52063. t['a21'] = 762;
  52064. t['a22'] = 761;
  52065. t['a23'] = 571;
  52066. t['a24'] = 677;
  52067. t['a25'] = 763;
  52068. t['a26'] = 760;
  52069. t['a27'] = 759;
  52070. t['a28'] = 754;
  52071. t['a6'] = 494;
  52072. t['a7'] = 552;
  52073. t['a8'] = 537;
  52074. t['a9'] = 577;
  52075. t['a10'] = 692;
  52076. t['a29'] = 786;
  52077. t['a30'] = 788;
  52078. t['a31'] = 788;
  52079. t['a32'] = 790;
  52080. t['a33'] = 793;
  52081. t['a34'] = 794;
  52082. t['a35'] = 816;
  52083. t['a36'] = 823;
  52084. t['a37'] = 789;
  52085. t['a38'] = 841;
  52086. t['a39'] = 823;
  52087. t['a40'] = 833;
  52088. t['a41'] = 816;
  52089. t['a42'] = 831;
  52090. t['a43'] = 923;
  52091. t['a44'] = 744;
  52092. t['a45'] = 723;
  52093. t['a46'] = 749;
  52094. t['a47'] = 790;
  52095. t['a48'] = 792;
  52096. t['a49'] = 695;
  52097. t['a50'] = 776;
  52098. t['a51'] = 768;
  52099. t['a52'] = 792;
  52100. t['a53'] = 759;
  52101. t['a54'] = 707;
  52102. t['a55'] = 708;
  52103. t['a56'] = 682;
  52104. t['a57'] = 701;
  52105. t['a58'] = 826;
  52106. t['a59'] = 815;
  52107. t['a60'] = 789;
  52108. t['a61'] = 789;
  52109. t['a62'] = 707;
  52110. t['a63'] = 687;
  52111. t['a64'] = 696;
  52112. t['a65'] = 689;
  52113. t['a66'] = 786;
  52114. t['a67'] = 787;
  52115. t['a68'] = 713;
  52116. t['a69'] = 791;
  52117. t['a70'] = 785;
  52118. t['a71'] = 791;
  52119. t['a72'] = 873;
  52120. t['a73'] = 761;
  52121. t['a74'] = 762;
  52122. t['a203'] = 762;
  52123. t['a75'] = 759;
  52124. t['a204'] = 759;
  52125. t['a76'] = 892;
  52126. t['a77'] = 892;
  52127. t['a78'] = 788;
  52128. t['a79'] = 784;
  52129. t['a81'] = 438;
  52130. t['a82'] = 138;
  52131. t['a83'] = 277;
  52132. t['a84'] = 415;
  52133. t['a97'] = 392;
  52134. t['a98'] = 392;
  52135. t['a99'] = 668;
  52136. t['a100'] = 668;
  52137. t['a89'] = 390;
  52138. t['a90'] = 390;
  52139. t['a93'] = 317;
  52140. t['a94'] = 317;
  52141. t['a91'] = 276;
  52142. t['a92'] = 276;
  52143. t['a205'] = 509;
  52144. t['a85'] = 509;
  52145. t['a206'] = 410;
  52146. t['a86'] = 410;
  52147. t['a87'] = 234;
  52148. t['a88'] = 234;
  52149. t['a95'] = 334;
  52150. t['a96'] = 334;
  52151. t['a101'] = 732;
  52152. t['a102'] = 544;
  52153. t['a103'] = 544;
  52154. t['a104'] = 910;
  52155. t['a106'] = 667;
  52156. t['a107'] = 760;
  52157. t['a108'] = 760;
  52158. t['a112'] = 776;
  52159. t['a111'] = 595;
  52160. t['a110'] = 694;
  52161. t['a109'] = 626;
  52162. t['a120'] = 788;
  52163. t['a121'] = 788;
  52164. t['a122'] = 788;
  52165. t['a123'] = 788;
  52166. t['a124'] = 788;
  52167. t['a125'] = 788;
  52168. t['a126'] = 788;
  52169. t['a127'] = 788;
  52170. t['a128'] = 788;
  52171. t['a129'] = 788;
  52172. t['a130'] = 788;
  52173. t['a131'] = 788;
  52174. t['a132'] = 788;
  52175. t['a133'] = 788;
  52176. t['a134'] = 788;
  52177. t['a135'] = 788;
  52178. t['a136'] = 788;
  52179. t['a137'] = 788;
  52180. t['a138'] = 788;
  52181. t['a139'] = 788;
  52182. t['a140'] = 788;
  52183. t['a141'] = 788;
  52184. t['a142'] = 788;
  52185. t['a143'] = 788;
  52186. t['a144'] = 788;
  52187. t['a145'] = 788;
  52188. t['a146'] = 788;
  52189. t['a147'] = 788;
  52190. t['a148'] = 788;
  52191. t['a149'] = 788;
  52192. t['a150'] = 788;
  52193. t['a151'] = 788;
  52194. t['a152'] = 788;
  52195. t['a153'] = 788;
  52196. t['a154'] = 788;
  52197. t['a155'] = 788;
  52198. t['a156'] = 788;
  52199. t['a157'] = 788;
  52200. t['a158'] = 788;
  52201. t['a159'] = 788;
  52202. t['a160'] = 894;
  52203. t['a161'] = 838;
  52204. t['a163'] = 1016;
  52205. t['a164'] = 458;
  52206. t['a196'] = 748;
  52207. t['a165'] = 924;
  52208. t['a192'] = 748;
  52209. t['a166'] = 918;
  52210. t['a167'] = 927;
  52211. t['a168'] = 928;
  52212. t['a169'] = 928;
  52213. t['a170'] = 834;
  52214. t['a171'] = 873;
  52215. t['a172'] = 828;
  52216. t['a173'] = 924;
  52217. t['a162'] = 924;
  52218. t['a174'] = 917;
  52219. t['a175'] = 930;
  52220. t['a176'] = 931;
  52221. t['a177'] = 463;
  52222. t['a178'] = 883;
  52223. t['a179'] = 836;
  52224. t['a193'] = 836;
  52225. t['a180'] = 867;
  52226. t['a199'] = 867;
  52227. t['a181'] = 696;
  52228. t['a200'] = 696;
  52229. t['a182'] = 874;
  52230. t['a201'] = 874;
  52231. t['a183'] = 760;
  52232. t['a184'] = 946;
  52233. t['a197'] = 771;
  52234. t['a185'] = 865;
  52235. t['a194'] = 771;
  52236. t['a198'] = 888;
  52237. t['a186'] = 967;
  52238. t['a195'] = 888;
  52239. t['a187'] = 831;
  52240. t['a188'] = 873;
  52241. t['a189'] = 927;
  52242. t['a190'] = 970;
  52243. t['a191'] = 918;
  52244. });
  52245. });
  52246. exports.getMetrics = getMetrics;
  52247. /***/ }),
  52248. /* 38 */
  52249. /***/ (function(module, exports, __w_pdfjs_require__) {
  52250. "use strict";
  52251. var sharedUtil = __w_pdfjs_require__(0);
  52252. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  52253. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  52254. var MASK_HIGH = 0xffff0000;
  52255. var MASK_LOW = 0xffff;
  52256. function MurmurHash3_64(seed) {
  52257. var SEED = 0xc3d2e1f0;
  52258. this.h1 = seed ? seed & 0xffffffff : SEED;
  52259. this.h2 = seed ? seed & 0xffffffff : SEED;
  52260. }
  52261. var alwaysUseUint32ArrayView = false;
  52262. try {
  52263. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  52264. } catch (e) {
  52265. alwaysUseUint32ArrayView = true;
  52266. }
  52267. MurmurHash3_64.prototype = {
  52268. update: function MurmurHash3_64_update(input) {
  52269. var useUint32ArrayView = alwaysUseUint32ArrayView;
  52270. var i;
  52271. if (typeof input === 'string') {
  52272. var data = new Uint8Array(input.length * 2);
  52273. var length = 0;
  52274. for (i = 0; i < input.length; i++) {
  52275. var code = input.charCodeAt(i);
  52276. if (code <= 0xff) {
  52277. data[length++] = code;
  52278. } else {
  52279. data[length++] = code >>> 8;
  52280. data[length++] = code & 0xff;
  52281. }
  52282. }
  52283. } else if (input instanceof Uint8Array) {
  52284. data = input;
  52285. length = data.length;
  52286. } else if (typeof input === 'object' && 'length' in input) {
  52287. data = input;
  52288. length = data.length;
  52289. useUint32ArrayView = true;
  52290. } else {
  52291. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  52292. }
  52293. var blockCounts = length >> 2;
  52294. var tailLength = length - blockCounts * 4;
  52295. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  52296. var k1 = 0;
  52297. var k2 = 0;
  52298. var h1 = this.h1;
  52299. var h2 = this.h2;
  52300. var C1 = 0xcc9e2d51;
  52301. var C2 = 0x1b873593;
  52302. var C1_LOW = C1 & MASK_LOW;
  52303. var C2_LOW = C2 & MASK_LOW;
  52304. for (i = 0; i < blockCounts; i++) {
  52305. if (i & 1) {
  52306. k1 = dataUint32[i];
  52307. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52308. k1 = k1 << 15 | k1 >>> 17;
  52309. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52310. h1 ^= k1;
  52311. h1 = h1 << 13 | h1 >>> 19;
  52312. h1 = h1 * 5 + 0xe6546b64;
  52313. } else {
  52314. k2 = dataUint32[i];
  52315. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  52316. k2 = k2 << 15 | k2 >>> 17;
  52317. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  52318. h2 ^= k2;
  52319. h2 = h2 << 13 | h2 >>> 19;
  52320. h2 = h2 * 5 + 0xe6546b64;
  52321. }
  52322. }
  52323. k1 = 0;
  52324. switch (tailLength) {
  52325. case 3:
  52326. k1 ^= data[blockCounts * 4 + 2] << 16;
  52327. case 2:
  52328. k1 ^= data[blockCounts * 4 + 1] << 8;
  52329. case 1:
  52330. k1 ^= data[blockCounts * 4];
  52331. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52332. k1 = k1 << 15 | k1 >>> 17;
  52333. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52334. if (blockCounts & 1) {
  52335. h1 ^= k1;
  52336. } else {
  52337. h2 ^= k1;
  52338. }
  52339. }
  52340. this.h1 = h1;
  52341. this.h2 = h2;
  52342. return this;
  52343. },
  52344. hexdigest: function MurmurHash3_64_hexdigest() {
  52345. var h1 = this.h1;
  52346. var h2 = this.h2;
  52347. h1 ^= h2 >>> 1;
  52348. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  52349. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  52350. h1 ^= h2 >>> 1;
  52351. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  52352. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  52353. h1 ^= h2 >>> 1;
  52354. for (var i = 0, arr = [
  52355. h1,
  52356. h2
  52357. ], str = ''; i < arr.length; i++) {
  52358. var hex = (arr[i] >>> 0).toString(16);
  52359. while (hex.length < 8) {
  52360. hex = '0' + hex;
  52361. }
  52362. str += hex;
  52363. }
  52364. return str;
  52365. }
  52366. };
  52367. return MurmurHash3_64;
  52368. }();
  52369. exports.MurmurHash3_64 = MurmurHash3_64;
  52370. /***/ }),
  52371. /* 39 */
  52372. /***/ (function(module, exports, __w_pdfjs_require__) {
  52373. "use strict";
  52374. var sharedUtil = __w_pdfjs_require__(0);
  52375. var coreWorker = __w_pdfjs_require__(22);
  52376. var OK_RESPONSE = 200;
  52377. var PARTIAL_CONTENT_RESPONSE = 206;
  52378. function NetworkManager(url, args) {
  52379. this.url = url;
  52380. args = args || {};
  52381. this.isHttp = /^https?:/i.test(url);
  52382. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  52383. this.withCredentials = args.withCredentials || false;
  52384. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  52385. return new XMLHttpRequest();
  52386. };
  52387. this.currXhrId = 0;
  52388. this.pendingRequests = Object.create(null);
  52389. this.loadedRequests = Object.create(null);
  52390. }
  52391. function getArrayBuffer(xhr) {
  52392. var data = xhr.response;
  52393. if (typeof data !== 'string') {
  52394. return data;
  52395. }
  52396. var length = data.length;
  52397. var array = new Uint8Array(length);
  52398. for (var i = 0; i < length; i++) {
  52399. array[i] = data.charCodeAt(i) & 0xFF;
  52400. }
  52401. return array.buffer;
  52402. }
  52403. var supportsMozChunked = function supportsMozChunkedClosure() {
  52404. try {
  52405. var x = new XMLHttpRequest();
  52406. x.open('GET', 'https://example.com');
  52407. x.responseType = 'moz-chunked-arraybuffer';
  52408. return x.responseType === 'moz-chunked-arraybuffer';
  52409. } catch (e) {
  52410. return false;
  52411. }
  52412. }();
  52413. NetworkManager.prototype = {
  52414. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  52415. var args = {
  52416. begin: begin,
  52417. end: end
  52418. };
  52419. for (var prop in listeners) {
  52420. args[prop] = listeners[prop];
  52421. }
  52422. return this.request(args);
  52423. },
  52424. requestFull: function NetworkManager_requestFull(listeners) {
  52425. return this.request(listeners);
  52426. },
  52427. request: function NetworkManager_request(args) {
  52428. var xhr = this.getXhr();
  52429. var xhrId = this.currXhrId++;
  52430. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  52431. xhr.open('GET', this.url);
  52432. xhr.withCredentials = this.withCredentials;
  52433. for (var property in this.httpHeaders) {
  52434. var value = this.httpHeaders[property];
  52435. if (typeof value === 'undefined') {
  52436. continue;
  52437. }
  52438. xhr.setRequestHeader(property, value);
  52439. }
  52440. if (this.isHttp && 'begin' in args && 'end' in args) {
  52441. var rangeStr = args.begin + '-' + (args.end - 1);
  52442. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  52443. pendingRequest.expectedStatus = 206;
  52444. } else {
  52445. pendingRequest.expectedStatus = 200;
  52446. }
  52447. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  52448. if (useMozChunkedLoading) {
  52449. xhr.responseType = 'moz-chunked-arraybuffer';
  52450. pendingRequest.onProgressiveData = args.onProgressiveData;
  52451. pendingRequest.mozChunked = true;
  52452. } else {
  52453. xhr.responseType = 'arraybuffer';
  52454. }
  52455. if (args.onError) {
  52456. xhr.onerror = function (evt) {
  52457. args.onError(xhr.status);
  52458. };
  52459. }
  52460. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  52461. xhr.onprogress = this.onProgress.bind(this, xhrId);
  52462. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  52463. pendingRequest.onDone = args.onDone;
  52464. pendingRequest.onError = args.onError;
  52465. pendingRequest.onProgress = args.onProgress;
  52466. xhr.send(null);
  52467. return xhrId;
  52468. },
  52469. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  52470. var pendingRequest = this.pendingRequests[xhrId];
  52471. if (!pendingRequest) {
  52472. return;
  52473. }
  52474. if (pendingRequest.mozChunked) {
  52475. var chunk = getArrayBuffer(pendingRequest.xhr);
  52476. pendingRequest.onProgressiveData(chunk);
  52477. }
  52478. var onProgress = pendingRequest.onProgress;
  52479. if (onProgress) {
  52480. onProgress(evt);
  52481. }
  52482. },
  52483. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  52484. var pendingRequest = this.pendingRequests[xhrId];
  52485. if (!pendingRequest) {
  52486. return;
  52487. }
  52488. var xhr = pendingRequest.xhr;
  52489. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  52490. pendingRequest.onHeadersReceived();
  52491. delete pendingRequest.onHeadersReceived;
  52492. }
  52493. if (xhr.readyState !== 4) {
  52494. return;
  52495. }
  52496. if (!(xhrId in this.pendingRequests)) {
  52497. return;
  52498. }
  52499. delete this.pendingRequests[xhrId];
  52500. if (xhr.status === 0 && this.isHttp) {
  52501. if (pendingRequest.onError) {
  52502. pendingRequest.onError(xhr.status);
  52503. }
  52504. return;
  52505. }
  52506. var xhrStatus = xhr.status || OK_RESPONSE;
  52507. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  52508. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  52509. if (pendingRequest.onError) {
  52510. pendingRequest.onError(xhr.status);
  52511. }
  52512. return;
  52513. }
  52514. this.loadedRequests[xhrId] = true;
  52515. var chunk = getArrayBuffer(xhr);
  52516. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  52517. var rangeHeader = xhr.getResponseHeader('Content-Range');
  52518. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  52519. var begin = parseInt(matches[1], 10);
  52520. pendingRequest.onDone({
  52521. begin: begin,
  52522. chunk: chunk
  52523. });
  52524. } else if (pendingRequest.onProgressiveData) {
  52525. pendingRequest.onDone(null);
  52526. } else if (chunk) {
  52527. pendingRequest.onDone({
  52528. begin: 0,
  52529. chunk: chunk
  52530. });
  52531. } else if (pendingRequest.onError) {
  52532. pendingRequest.onError(xhr.status);
  52533. }
  52534. },
  52535. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  52536. for (var xhrId in this.pendingRequests) {
  52537. return true;
  52538. }
  52539. return false;
  52540. },
  52541. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  52542. return this.pendingRequests[xhrId].xhr;
  52543. },
  52544. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  52545. return !!this.pendingRequests[xhrId].onProgressiveData;
  52546. },
  52547. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  52548. return xhrId in this.pendingRequests;
  52549. },
  52550. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  52551. return xhrId in this.loadedRequests;
  52552. },
  52553. abortAllRequests: function NetworkManager_abortAllRequests() {
  52554. for (var xhrId in this.pendingRequests) {
  52555. this.abortRequest(xhrId | 0);
  52556. }
  52557. },
  52558. abortRequest: function NetworkManager_abortRequest(xhrId) {
  52559. var xhr = this.pendingRequests[xhrId].xhr;
  52560. delete this.pendingRequests[xhrId];
  52561. xhr.abort();
  52562. }
  52563. };
  52564. var assert = sharedUtil.assert;
  52565. var createPromiseCapability = sharedUtil.createPromiseCapability;
  52566. var isInt = sharedUtil.isInt;
  52567. var MissingPDFException = sharedUtil.MissingPDFException;
  52568. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  52569. function PDFNetworkStream(options) {
  52570. this._options = options;
  52571. var source = options.source;
  52572. this._manager = new NetworkManager(source.url, {
  52573. httpHeaders: source.httpHeaders,
  52574. withCredentials: source.withCredentials
  52575. });
  52576. this._rangeChunkSize = source.rangeChunkSize;
  52577. this._fullRequestReader = null;
  52578. this._rangeRequestReaders = [];
  52579. }
  52580. PDFNetworkStream.prototype = {
  52581. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  52582. var i = this._rangeRequestReaders.indexOf(reader);
  52583. if (i >= 0) {
  52584. this._rangeRequestReaders.splice(i, 1);
  52585. }
  52586. },
  52587. getFullReader: function PDFNetworkStream_getFullReader() {
  52588. assert(!this._fullRequestReader);
  52589. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  52590. return this._fullRequestReader;
  52591. },
  52592. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  52593. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  52594. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  52595. this._rangeRequestReaders.push(reader);
  52596. return reader;
  52597. },
  52598. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  52599. if (this._fullRequestReader) {
  52600. this._fullRequestReader.cancel(reason);
  52601. }
  52602. var readers = this._rangeRequestReaders.slice(0);
  52603. readers.forEach(function (reader) {
  52604. reader.cancel(reason);
  52605. });
  52606. }
  52607. };
  52608. function PDFNetworkStreamFullRequestReader(manager, options) {
  52609. this._manager = manager;
  52610. var source = options.source;
  52611. var args = {
  52612. onHeadersReceived: this._onHeadersReceived.bind(this),
  52613. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  52614. onDone: this._onDone.bind(this),
  52615. onError: this._onError.bind(this),
  52616. onProgress: this._onProgress.bind(this)
  52617. };
  52618. this._url = source.url;
  52619. this._fullRequestId = manager.requestFull(args);
  52620. this._headersReceivedCapability = createPromiseCapability();
  52621. this._disableRange = options.disableRange || false;
  52622. this._contentLength = source.length;
  52623. this._rangeChunkSize = source.rangeChunkSize;
  52624. if (!this._rangeChunkSize && !this._disableRange) {
  52625. this._disableRange = true;
  52626. }
  52627. this._isStreamingSupported = false;
  52628. this._isRangeSupported = false;
  52629. this._cachedChunks = [];
  52630. this._requests = [];
  52631. this._done = false;
  52632. this._storedError = undefined;
  52633. this.onProgress = null;
  52634. }
  52635. PDFNetworkStreamFullRequestReader.prototype = {
  52636. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  52637. if (this._disableRange) {
  52638. return false;
  52639. }
  52640. var networkManager = this._manager;
  52641. if (!networkManager.isHttp) {
  52642. return false;
  52643. }
  52644. var fullRequestXhrId = this._fullRequestId;
  52645. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  52646. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  52647. return false;
  52648. }
  52649. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  52650. if (contentEncoding !== 'identity') {
  52651. return false;
  52652. }
  52653. var length = fullRequestXhr.getResponseHeader('Content-Length');
  52654. length = parseInt(length, 10);
  52655. if (!isInt(length)) {
  52656. return false;
  52657. }
  52658. this._contentLength = length;
  52659. if (length <= 2 * this._rangeChunkSize) {
  52660. return false;
  52661. }
  52662. return true;
  52663. },
  52664. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  52665. if (this._validateRangeRequestCapabilities()) {
  52666. this._isRangeSupported = true;
  52667. }
  52668. var networkManager = this._manager;
  52669. var fullRequestXhrId = this._fullRequestId;
  52670. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  52671. this._isStreamingSupported = true;
  52672. } else if (this._isRangeSupported) {
  52673. networkManager.abortRequest(fullRequestXhrId);
  52674. }
  52675. this._headersReceivedCapability.resolve();
  52676. },
  52677. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  52678. if (this._requests.length > 0) {
  52679. var requestCapability = this._requests.shift();
  52680. requestCapability.resolve({
  52681. value: chunk,
  52682. done: false
  52683. });
  52684. } else {
  52685. this._cachedChunks.push(chunk);
  52686. }
  52687. },
  52688. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  52689. if (args) {
  52690. this._onProgressiveData(args.chunk);
  52691. }
  52692. this._done = true;
  52693. if (this._cachedChunks.length > 0) {
  52694. return;
  52695. }
  52696. this._requests.forEach(function (requestCapability) {
  52697. requestCapability.resolve({
  52698. value: undefined,
  52699. done: true
  52700. });
  52701. });
  52702. this._requests = [];
  52703. },
  52704. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  52705. var url = this._url;
  52706. var exception;
  52707. if (status === 404 || status === 0 && /^file:/.test(url)) {
  52708. exception = new MissingPDFException('Missing PDF "' + url + '".');
  52709. } else {
  52710. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  52711. }
  52712. this._storedError = exception;
  52713. this._headersReceivedCapability.reject(exception);
  52714. this._requests.forEach(function (requestCapability) {
  52715. requestCapability.reject(exception);
  52716. });
  52717. this._requests = [];
  52718. this._cachedChunks = [];
  52719. },
  52720. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  52721. if (this.onProgress) {
  52722. this.onProgress({
  52723. loaded: data.loaded,
  52724. total: data.lengthComputable ? data.total : this._contentLength
  52725. });
  52726. }
  52727. },
  52728. get isRangeSupported() {
  52729. return this._isRangeSupported;
  52730. },
  52731. get isStreamingSupported() {
  52732. return this._isStreamingSupported;
  52733. },
  52734. get contentLength() {
  52735. return this._contentLength;
  52736. },
  52737. get headersReady() {
  52738. return this._headersReceivedCapability.promise;
  52739. },
  52740. read: function PDFNetworkStreamFullRequestReader_read() {
  52741. if (this._storedError) {
  52742. return Promise.reject(this._storedError);
  52743. }
  52744. if (this._cachedChunks.length > 0) {
  52745. var chunk = this._cachedChunks.shift();
  52746. return Promise.resolve(chunk);
  52747. }
  52748. if (this._done) {
  52749. return Promise.resolve({
  52750. value: undefined,
  52751. done: true
  52752. });
  52753. }
  52754. var requestCapability = createPromiseCapability();
  52755. this._requests.push(requestCapability);
  52756. return requestCapability.promise;
  52757. },
  52758. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  52759. this._done = true;
  52760. this._headersReceivedCapability.reject(reason);
  52761. this._requests.forEach(function (requestCapability) {
  52762. requestCapability.resolve({
  52763. value: undefined,
  52764. done: true
  52765. });
  52766. });
  52767. this._requests = [];
  52768. if (this._manager.isPendingRequest(this._fullRequestId)) {
  52769. this._manager.abortRequest(this._fullRequestId);
  52770. }
  52771. this._fullRequestReader = null;
  52772. }
  52773. };
  52774. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  52775. this._manager = manager;
  52776. var args = {
  52777. onDone: this._onDone.bind(this),
  52778. onProgress: this._onProgress.bind(this)
  52779. };
  52780. this._requestId = manager.requestRange(begin, end, args);
  52781. this._requests = [];
  52782. this._queuedChunk = null;
  52783. this._done = false;
  52784. this.onProgress = null;
  52785. this.onClosed = null;
  52786. }
  52787. PDFNetworkStreamRangeRequestReader.prototype = {
  52788. _close: function PDFNetworkStreamRangeRequestReader_close() {
  52789. if (this.onClosed) {
  52790. this.onClosed(this);
  52791. }
  52792. },
  52793. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  52794. var chunk = data.chunk;
  52795. if (this._requests.length > 0) {
  52796. var requestCapability = this._requests.shift();
  52797. requestCapability.resolve({
  52798. value: chunk,
  52799. done: false
  52800. });
  52801. } else {
  52802. this._queuedChunk = chunk;
  52803. }
  52804. this._done = true;
  52805. this._requests.forEach(function (requestCapability) {
  52806. requestCapability.resolve({
  52807. value: undefined,
  52808. done: true
  52809. });
  52810. });
  52811. this._requests = [];
  52812. this._close();
  52813. },
  52814. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  52815. if (!this.isStreamingSupported && this.onProgress) {
  52816. this.onProgress({ loaded: evt.loaded });
  52817. }
  52818. },
  52819. get isStreamingSupported() {
  52820. return false;
  52821. },
  52822. read: function PDFNetworkStreamRangeRequestReader_read() {
  52823. if (this._queuedChunk !== null) {
  52824. var chunk = this._queuedChunk;
  52825. this._queuedChunk = null;
  52826. return Promise.resolve({
  52827. value: chunk,
  52828. done: false
  52829. });
  52830. }
  52831. if (this._done) {
  52832. return Promise.resolve({
  52833. value: undefined,
  52834. done: true
  52835. });
  52836. }
  52837. var requestCapability = createPromiseCapability();
  52838. this._requests.push(requestCapability);
  52839. return requestCapability.promise;
  52840. },
  52841. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  52842. this._done = true;
  52843. this._requests.forEach(function (requestCapability) {
  52844. requestCapability.resolve({
  52845. value: undefined,
  52846. done: true
  52847. });
  52848. });
  52849. this._requests = [];
  52850. if (this._manager.isPendingRequest(this._requestId)) {
  52851. this._manager.abortRequest(this._requestId);
  52852. }
  52853. this._close();
  52854. }
  52855. };
  52856. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  52857. exports.PDFNetworkStream = PDFNetworkStream;
  52858. exports.NetworkManager = NetworkManager;
  52859. /***/ }),
  52860. /* 40 */
  52861. /***/ (function(module, exports, __w_pdfjs_require__) {
  52862. "use strict";
  52863. var sharedUtil = __w_pdfjs_require__(0);
  52864. var corePrimitives = __w_pdfjs_require__(1);
  52865. var coreFunction = __w_pdfjs_require__(7);
  52866. var coreColorSpace = __w_pdfjs_require__(4);
  52867. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  52868. var MissingDataException = sharedUtil.MissingDataException;
  52869. var Util = sharedUtil.Util;
  52870. var assert = sharedUtil.assert;
  52871. var error = sharedUtil.error;
  52872. var info = sharedUtil.info;
  52873. var warn = sharedUtil.warn;
  52874. var isStream = corePrimitives.isStream;
  52875. var PDFFunction = coreFunction.PDFFunction;
  52876. var ColorSpace = coreColorSpace.ColorSpace;
  52877. var ShadingType = {
  52878. FUNCTION_BASED: 1,
  52879. AXIAL: 2,
  52880. RADIAL: 3,
  52881. FREE_FORM_MESH: 4,
  52882. LATTICE_FORM_MESH: 5,
  52883. COONS_PATCH_MESH: 6,
  52884. TENSOR_PATCH_MESH: 7
  52885. };
  52886. var Pattern = function PatternClosure() {
  52887. function Pattern() {
  52888. error('should not call Pattern constructor');
  52889. }
  52890. Pattern.prototype = {
  52891. getPattern: function Pattern_getPattern(ctx) {
  52892. error('Should not call Pattern.getStyle: ' + ctx);
  52893. }
  52894. };
  52895. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  52896. var dict = isStream(shading) ? shading.dict : shading;
  52897. var type = dict.get('ShadingType');
  52898. try {
  52899. switch (type) {
  52900. case ShadingType.AXIAL:
  52901. case ShadingType.RADIAL:
  52902. return new Shadings.RadialAxial(dict, matrix, xref, res);
  52903. case ShadingType.FREE_FORM_MESH:
  52904. case ShadingType.LATTICE_FORM_MESH:
  52905. case ShadingType.COONS_PATCH_MESH:
  52906. case ShadingType.TENSOR_PATCH_MESH:
  52907. return new Shadings.Mesh(shading, matrix, xref, res);
  52908. default:
  52909. throw new Error('Unsupported ShadingType: ' + type);
  52910. }
  52911. } catch (ex) {
  52912. if (ex instanceof MissingDataException) {
  52913. throw ex;
  52914. }
  52915. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  52916. warn(ex);
  52917. return new Shadings.Dummy();
  52918. }
  52919. };
  52920. return Pattern;
  52921. }();
  52922. var Shadings = {};
  52923. Shadings.SMALL_NUMBER = 1e-6;
  52924. Shadings.RadialAxial = function RadialAxialClosure() {
  52925. function RadialAxial(dict, matrix, xref, res) {
  52926. this.matrix = matrix;
  52927. this.coordsArr = dict.getArray('Coords');
  52928. this.shadingType = dict.get('ShadingType');
  52929. this.type = 'Pattern';
  52930. var cs = dict.get('ColorSpace', 'CS');
  52931. cs = ColorSpace.parse(cs, xref, res);
  52932. this.cs = cs;
  52933. var t0 = 0.0, t1 = 1.0;
  52934. if (dict.has('Domain')) {
  52935. var domainArr = dict.getArray('Domain');
  52936. t0 = domainArr[0];
  52937. t1 = domainArr[1];
  52938. }
  52939. var extendStart = false, extendEnd = false;
  52940. if (dict.has('Extend')) {
  52941. var extendArr = dict.getArray('Extend');
  52942. extendStart = extendArr[0];
  52943. extendEnd = extendArr[1];
  52944. }
  52945. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  52946. var x1 = this.coordsArr[0];
  52947. var y1 = this.coordsArr[1];
  52948. var r1 = this.coordsArr[2];
  52949. var x2 = this.coordsArr[3];
  52950. var y2 = this.coordsArr[4];
  52951. var r2 = this.coordsArr[5];
  52952. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  52953. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  52954. warn('Unsupported radial gradient.');
  52955. }
  52956. }
  52957. this.extendStart = extendStart;
  52958. this.extendEnd = extendEnd;
  52959. var fnObj = dict.get('Function');
  52960. var fn = PDFFunction.parseArray(xref, fnObj);
  52961. var diff = t1 - t0;
  52962. var step = diff / 10;
  52963. var colorStops = this.colorStops = [];
  52964. if (t0 >= t1 || step <= 0) {
  52965. info('Bad shading domain.');
  52966. return;
  52967. }
  52968. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  52969. var rgbColor;
  52970. for (var i = t0; i <= t1; i += step) {
  52971. ratio[0] = i;
  52972. fn(ratio, 0, color, 0);
  52973. rgbColor = cs.getRgb(color, 0);
  52974. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52975. colorStops.push([
  52976. (i - t0) / diff,
  52977. cssColor
  52978. ]);
  52979. }
  52980. var background = 'transparent';
  52981. if (dict.has('Background')) {
  52982. rgbColor = cs.getRgb(dict.get('Background'), 0);
  52983. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52984. }
  52985. if (!extendStart) {
  52986. colorStops.unshift([
  52987. 0,
  52988. background
  52989. ]);
  52990. colorStops[1][0] += Shadings.SMALL_NUMBER;
  52991. }
  52992. if (!extendEnd) {
  52993. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  52994. colorStops.push([
  52995. 1,
  52996. background
  52997. ]);
  52998. }
  52999. this.colorStops = colorStops;
  53000. }
  53001. RadialAxial.prototype = {
  53002. getIR: function RadialAxial_getIR() {
  53003. var coordsArr = this.coordsArr;
  53004. var shadingType = this.shadingType;
  53005. var type, p0, p1, r0, r1;
  53006. if (shadingType === ShadingType.AXIAL) {
  53007. p0 = [
  53008. coordsArr[0],
  53009. coordsArr[1]
  53010. ];
  53011. p1 = [
  53012. coordsArr[2],
  53013. coordsArr[3]
  53014. ];
  53015. r0 = null;
  53016. r1 = null;
  53017. type = 'axial';
  53018. } else if (shadingType === ShadingType.RADIAL) {
  53019. p0 = [
  53020. coordsArr[0],
  53021. coordsArr[1]
  53022. ];
  53023. p1 = [
  53024. coordsArr[3],
  53025. coordsArr[4]
  53026. ];
  53027. r0 = coordsArr[2];
  53028. r1 = coordsArr[5];
  53029. type = 'radial';
  53030. } else {
  53031. error('getPattern type unknown: ' + shadingType);
  53032. }
  53033. var matrix = this.matrix;
  53034. if (matrix) {
  53035. p0 = Util.applyTransform(p0, matrix);
  53036. p1 = Util.applyTransform(p1, matrix);
  53037. if (shadingType === ShadingType.RADIAL) {
  53038. var scale = Util.singularValueDecompose2dScale(matrix);
  53039. r0 *= scale[0];
  53040. r1 *= scale[1];
  53041. }
  53042. }
  53043. return [
  53044. 'RadialAxial',
  53045. type,
  53046. this.colorStops,
  53047. p0,
  53048. p1,
  53049. r0,
  53050. r1
  53051. ];
  53052. }
  53053. };
  53054. return RadialAxial;
  53055. }();
  53056. Shadings.Mesh = function MeshClosure() {
  53057. function MeshStreamReader(stream, context) {
  53058. this.stream = stream;
  53059. this.context = context;
  53060. this.buffer = 0;
  53061. this.bufferLength = 0;
  53062. var numComps = context.numComps;
  53063. this.tmpCompsBuf = new Float32Array(numComps);
  53064. var csNumComps = context.colorSpace.numComps;
  53065. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  53066. }
  53067. MeshStreamReader.prototype = {
  53068. get hasData() {
  53069. if (this.stream.end) {
  53070. return this.stream.pos < this.stream.end;
  53071. }
  53072. if (this.bufferLength > 0) {
  53073. return true;
  53074. }
  53075. var nextByte = this.stream.getByte();
  53076. if (nextByte < 0) {
  53077. return false;
  53078. }
  53079. this.buffer = nextByte;
  53080. this.bufferLength = 8;
  53081. return true;
  53082. },
  53083. readBits: function MeshStreamReader_readBits(n) {
  53084. var buffer = this.buffer;
  53085. var bufferLength = this.bufferLength;
  53086. if (n === 32) {
  53087. if (bufferLength === 0) {
  53088. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  53089. }
  53090. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  53091. var nextByte = this.stream.getByte();
  53092. this.buffer = nextByte & (1 << bufferLength) - 1;
  53093. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  53094. }
  53095. if (n === 8 && bufferLength === 0) {
  53096. return this.stream.getByte();
  53097. }
  53098. while (bufferLength < n) {
  53099. buffer = buffer << 8 | this.stream.getByte();
  53100. bufferLength += 8;
  53101. }
  53102. bufferLength -= n;
  53103. this.bufferLength = bufferLength;
  53104. this.buffer = buffer & (1 << bufferLength) - 1;
  53105. return buffer >> bufferLength;
  53106. },
  53107. align: function MeshStreamReader_align() {
  53108. this.buffer = 0;
  53109. this.bufferLength = 0;
  53110. },
  53111. readFlag: function MeshStreamReader_readFlag() {
  53112. return this.readBits(this.context.bitsPerFlag);
  53113. },
  53114. readCoordinate: function MeshStreamReader_readCoordinate() {
  53115. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  53116. var xi = this.readBits(bitsPerCoordinate);
  53117. var yi = this.readBits(bitsPerCoordinate);
  53118. var decode = this.context.decode;
  53119. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  53120. return [
  53121. xi * scale * (decode[1] - decode[0]) + decode[0],
  53122. yi * scale * (decode[3] - decode[2]) + decode[2]
  53123. ];
  53124. },
  53125. readComponents: function MeshStreamReader_readComponents() {
  53126. var numComps = this.context.numComps;
  53127. var bitsPerComponent = this.context.bitsPerComponent;
  53128. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  53129. var decode = this.context.decode;
  53130. var components = this.tmpCompsBuf;
  53131. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  53132. var ci = this.readBits(bitsPerComponent);
  53133. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  53134. }
  53135. var color = this.tmpCsCompsBuf;
  53136. if (this.context.colorFn) {
  53137. this.context.colorFn(components, 0, color, 0);
  53138. }
  53139. return this.context.colorSpace.getRgb(color, 0);
  53140. }
  53141. };
  53142. function decodeType4Shading(mesh, reader) {
  53143. var coords = mesh.coords;
  53144. var colors = mesh.colors;
  53145. var operators = [];
  53146. var ps = [];
  53147. var verticesLeft = 0;
  53148. while (reader.hasData) {
  53149. var f = reader.readFlag();
  53150. var coord = reader.readCoordinate();
  53151. var color = reader.readComponents();
  53152. if (verticesLeft === 0) {
  53153. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  53154. switch (f) {
  53155. case 0:
  53156. verticesLeft = 3;
  53157. break;
  53158. case 1:
  53159. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  53160. verticesLeft = 1;
  53161. break;
  53162. case 2:
  53163. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  53164. verticesLeft = 1;
  53165. break;
  53166. }
  53167. operators.push(f);
  53168. }
  53169. ps.push(coords.length);
  53170. coords.push(coord);
  53171. colors.push(color);
  53172. verticesLeft--;
  53173. reader.align();
  53174. }
  53175. mesh.figures.push({
  53176. type: 'triangles',
  53177. coords: new Int32Array(ps),
  53178. colors: new Int32Array(ps)
  53179. });
  53180. }
  53181. function decodeType5Shading(mesh, reader, verticesPerRow) {
  53182. var coords = mesh.coords;
  53183. var colors = mesh.colors;
  53184. var ps = [];
  53185. while (reader.hasData) {
  53186. var coord = reader.readCoordinate();
  53187. var color = reader.readComponents();
  53188. ps.push(coords.length);
  53189. coords.push(coord);
  53190. colors.push(color);
  53191. }
  53192. mesh.figures.push({
  53193. type: 'lattice',
  53194. coords: new Int32Array(ps),
  53195. colors: new Int32Array(ps),
  53196. verticesPerRow: verticesPerRow
  53197. });
  53198. }
  53199. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  53200. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  53201. var TRIANGLE_DENSITY = 20;
  53202. var getB = function getBClosure() {
  53203. function buildB(count) {
  53204. var lut = [];
  53205. for (var i = 0; i <= count; i++) {
  53206. var t = i / count, t_ = 1 - t;
  53207. lut.push(new Float32Array([
  53208. t_ * t_ * t_,
  53209. 3 * t * t_ * t_,
  53210. 3 * t * t * t_,
  53211. t * t * t
  53212. ]));
  53213. }
  53214. return lut;
  53215. }
  53216. var cache = [];
  53217. return function getB(count) {
  53218. if (!cache[count]) {
  53219. cache[count] = buildB(count);
  53220. }
  53221. return cache[count];
  53222. };
  53223. }();
  53224. function buildFigureFromPatch(mesh, index) {
  53225. var figure = mesh.figures[index];
  53226. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  53227. var coords = mesh.coords, colors = mesh.colors;
  53228. var pi = figure.coords;
  53229. var ci = figure.colors;
  53230. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53231. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53232. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53233. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53234. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  53235. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  53236. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  53237. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  53238. var verticesPerRow = splitXBy + 1;
  53239. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  53240. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  53241. var k = 0;
  53242. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  53243. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  53244. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  53245. for (var row = 0; row <= splitYBy; row++) {
  53246. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  53247. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  53248. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  53249. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  53250. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  53251. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  53252. for (var col = 0; col <= splitXBy; col++, k++) {
  53253. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  53254. continue;
  53255. }
  53256. var x = 0, y = 0;
  53257. var q = 0;
  53258. for (var i = 0; i <= 3; i++) {
  53259. for (var j = 0; j <= 3; j++, q++) {
  53260. var m = bRow[row][i] * bCol[col][j];
  53261. x += coords[pi[q]][0] * m;
  53262. y += coords[pi[q]][1] * m;
  53263. }
  53264. }
  53265. figureCoords[k] = coords.length;
  53266. coords.push([
  53267. x,
  53268. y
  53269. ]);
  53270. figureColors[k] = colors.length;
  53271. var newColor = new Uint8Array(3);
  53272. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  53273. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  53274. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  53275. colors.push(newColor);
  53276. }
  53277. }
  53278. figureCoords[0] = pi[0];
  53279. figureColors[0] = ci[0];
  53280. figureCoords[splitXBy] = pi[3];
  53281. figureColors[splitXBy] = ci[1];
  53282. figureCoords[verticesPerRow * splitYBy] = pi[12];
  53283. figureColors[verticesPerRow * splitYBy] = ci[2];
  53284. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  53285. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  53286. mesh.figures[index] = {
  53287. type: 'lattice',
  53288. coords: figureCoords,
  53289. colors: figureColors,
  53290. verticesPerRow: verticesPerRow
  53291. };
  53292. }
  53293. function decodeType6Shading(mesh, reader) {
  53294. var coords = mesh.coords;
  53295. var colors = mesh.colors;
  53296. var ps = new Int32Array(16);
  53297. var cs = new Int32Array(4);
  53298. while (reader.hasData) {
  53299. var f = reader.readFlag();
  53300. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  53301. var i, ii;
  53302. var pi = coords.length;
  53303. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  53304. coords.push(reader.readCoordinate());
  53305. }
  53306. var ci = colors.length;
  53307. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53308. colors.push(reader.readComponents());
  53309. }
  53310. var tmp1, tmp2, tmp3, tmp4;
  53311. switch (f) {
  53312. case 0:
  53313. ps[12] = pi + 3;
  53314. ps[13] = pi + 4;
  53315. ps[14] = pi + 5;
  53316. ps[15] = pi + 6;
  53317. ps[8] = pi + 2;
  53318. ps[11] = pi + 7;
  53319. ps[4] = pi + 1;
  53320. ps[7] = pi + 8;
  53321. ps[0] = pi;
  53322. ps[1] = pi + 11;
  53323. ps[2] = pi + 10;
  53324. ps[3] = pi + 9;
  53325. cs[2] = ci + 1;
  53326. cs[3] = ci + 2;
  53327. cs[0] = ci;
  53328. cs[1] = ci + 3;
  53329. break;
  53330. case 1:
  53331. tmp1 = ps[12];
  53332. tmp2 = ps[13];
  53333. tmp3 = ps[14];
  53334. tmp4 = ps[15];
  53335. ps[12] = tmp4;
  53336. ps[13] = pi + 0;
  53337. ps[14] = pi + 1;
  53338. ps[15] = pi + 2;
  53339. ps[8] = tmp3;
  53340. ps[11] = pi + 3;
  53341. ps[4] = tmp2;
  53342. ps[7] = pi + 4;
  53343. ps[0] = tmp1;
  53344. ps[1] = pi + 7;
  53345. ps[2] = pi + 6;
  53346. ps[3] = pi + 5;
  53347. tmp1 = cs[2];
  53348. tmp2 = cs[3];
  53349. cs[2] = tmp2;
  53350. cs[3] = ci;
  53351. cs[0] = tmp1;
  53352. cs[1] = ci + 1;
  53353. break;
  53354. case 2:
  53355. tmp1 = ps[15];
  53356. tmp2 = ps[11];
  53357. ps[12] = ps[3];
  53358. ps[13] = pi + 0;
  53359. ps[14] = pi + 1;
  53360. ps[15] = pi + 2;
  53361. ps[8] = ps[7];
  53362. ps[11] = pi + 3;
  53363. ps[4] = tmp2;
  53364. ps[7] = pi + 4;
  53365. ps[0] = tmp1;
  53366. ps[1] = pi + 7;
  53367. ps[2] = pi + 6;
  53368. ps[3] = pi + 5;
  53369. tmp1 = cs[3];
  53370. cs[2] = cs[1];
  53371. cs[3] = ci;
  53372. cs[0] = tmp1;
  53373. cs[1] = ci + 1;
  53374. break;
  53375. case 3:
  53376. ps[12] = ps[0];
  53377. ps[13] = pi + 0;
  53378. ps[14] = pi + 1;
  53379. ps[15] = pi + 2;
  53380. ps[8] = ps[1];
  53381. ps[11] = pi + 3;
  53382. ps[4] = ps[2];
  53383. ps[7] = pi + 4;
  53384. ps[0] = ps[3];
  53385. ps[1] = pi + 7;
  53386. ps[2] = pi + 6;
  53387. ps[3] = pi + 5;
  53388. cs[2] = cs[0];
  53389. cs[3] = ci;
  53390. cs[0] = cs[1];
  53391. cs[1] = ci + 1;
  53392. break;
  53393. }
  53394. ps[5] = coords.length;
  53395. coords.push([
  53396. (-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,
  53397. (-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
  53398. ]);
  53399. ps[6] = coords.length;
  53400. coords.push([
  53401. (-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,
  53402. (-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
  53403. ]);
  53404. ps[9] = coords.length;
  53405. coords.push([
  53406. (-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,
  53407. (-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
  53408. ]);
  53409. ps[10] = coords.length;
  53410. coords.push([
  53411. (-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,
  53412. (-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
  53413. ]);
  53414. mesh.figures.push({
  53415. type: 'patch',
  53416. coords: new Int32Array(ps),
  53417. colors: new Int32Array(cs)
  53418. });
  53419. }
  53420. }
  53421. function decodeType7Shading(mesh, reader) {
  53422. var coords = mesh.coords;
  53423. var colors = mesh.colors;
  53424. var ps = new Int32Array(16);
  53425. var cs = new Int32Array(4);
  53426. while (reader.hasData) {
  53427. var f = reader.readFlag();
  53428. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  53429. var i, ii;
  53430. var pi = coords.length;
  53431. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  53432. coords.push(reader.readCoordinate());
  53433. }
  53434. var ci = colors.length;
  53435. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53436. colors.push(reader.readComponents());
  53437. }
  53438. var tmp1, tmp2, tmp3, tmp4;
  53439. switch (f) {
  53440. case 0:
  53441. ps[12] = pi + 3;
  53442. ps[13] = pi + 4;
  53443. ps[14] = pi + 5;
  53444. ps[15] = pi + 6;
  53445. ps[8] = pi + 2;
  53446. ps[9] = pi + 13;
  53447. ps[10] = pi + 14;
  53448. ps[11] = pi + 7;
  53449. ps[4] = pi + 1;
  53450. ps[5] = pi + 12;
  53451. ps[6] = pi + 15;
  53452. ps[7] = pi + 8;
  53453. ps[0] = pi;
  53454. ps[1] = pi + 11;
  53455. ps[2] = pi + 10;
  53456. ps[3] = pi + 9;
  53457. cs[2] = ci + 1;
  53458. cs[3] = ci + 2;
  53459. cs[0] = ci;
  53460. cs[1] = ci + 3;
  53461. break;
  53462. case 1:
  53463. tmp1 = ps[12];
  53464. tmp2 = ps[13];
  53465. tmp3 = ps[14];
  53466. tmp4 = ps[15];
  53467. ps[12] = tmp4;
  53468. ps[13] = pi + 0;
  53469. ps[14] = pi + 1;
  53470. ps[15] = pi + 2;
  53471. ps[8] = tmp3;
  53472. ps[9] = pi + 9;
  53473. ps[10] = pi + 10;
  53474. ps[11] = pi + 3;
  53475. ps[4] = tmp2;
  53476. ps[5] = pi + 8;
  53477. ps[6] = pi + 11;
  53478. ps[7] = pi + 4;
  53479. ps[0] = tmp1;
  53480. ps[1] = pi + 7;
  53481. ps[2] = pi + 6;
  53482. ps[3] = pi + 5;
  53483. tmp1 = cs[2];
  53484. tmp2 = cs[3];
  53485. cs[2] = tmp2;
  53486. cs[3] = ci;
  53487. cs[0] = tmp1;
  53488. cs[1] = ci + 1;
  53489. break;
  53490. case 2:
  53491. tmp1 = ps[15];
  53492. tmp2 = ps[11];
  53493. ps[12] = ps[3];
  53494. ps[13] = pi + 0;
  53495. ps[14] = pi + 1;
  53496. ps[15] = pi + 2;
  53497. ps[8] = ps[7];
  53498. ps[9] = pi + 9;
  53499. ps[10] = pi + 10;
  53500. ps[11] = pi + 3;
  53501. ps[4] = tmp2;
  53502. ps[5] = pi + 8;
  53503. ps[6] = pi + 11;
  53504. ps[7] = pi + 4;
  53505. ps[0] = tmp1;
  53506. ps[1] = pi + 7;
  53507. ps[2] = pi + 6;
  53508. ps[3] = pi + 5;
  53509. tmp1 = cs[3];
  53510. cs[2] = cs[1];
  53511. cs[3] = ci;
  53512. cs[0] = tmp1;
  53513. cs[1] = ci + 1;
  53514. break;
  53515. case 3:
  53516. ps[12] = ps[0];
  53517. ps[13] = pi + 0;
  53518. ps[14] = pi + 1;
  53519. ps[15] = pi + 2;
  53520. ps[8] = ps[1];
  53521. ps[9] = pi + 9;
  53522. ps[10] = pi + 10;
  53523. ps[11] = pi + 3;
  53524. ps[4] = ps[2];
  53525. ps[5] = pi + 8;
  53526. ps[6] = pi + 11;
  53527. ps[7] = pi + 4;
  53528. ps[0] = ps[3];
  53529. ps[1] = pi + 7;
  53530. ps[2] = pi + 6;
  53531. ps[3] = pi + 5;
  53532. cs[2] = cs[0];
  53533. cs[3] = ci;
  53534. cs[0] = cs[1];
  53535. cs[1] = ci + 1;
  53536. break;
  53537. }
  53538. mesh.figures.push({
  53539. type: 'patch',
  53540. coords: new Int32Array(ps),
  53541. colors: new Int32Array(cs)
  53542. });
  53543. }
  53544. }
  53545. function updateBounds(mesh) {
  53546. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  53547. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  53548. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  53549. minX = minX > x ? x : minX;
  53550. minY = minY > y ? y : minY;
  53551. maxX = maxX < x ? x : maxX;
  53552. maxY = maxY < y ? y : maxY;
  53553. }
  53554. mesh.bounds = [
  53555. minX,
  53556. minY,
  53557. maxX,
  53558. maxY
  53559. ];
  53560. }
  53561. function packData(mesh) {
  53562. var i, ii, j, jj;
  53563. var coords = mesh.coords;
  53564. var coordsPacked = new Float32Array(coords.length * 2);
  53565. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  53566. var xy = coords[i];
  53567. coordsPacked[j++] = xy[0];
  53568. coordsPacked[j++] = xy[1];
  53569. }
  53570. mesh.coords = coordsPacked;
  53571. var colors = mesh.colors;
  53572. var colorsPacked = new Uint8Array(colors.length * 3);
  53573. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  53574. var c = colors[i];
  53575. colorsPacked[j++] = c[0];
  53576. colorsPacked[j++] = c[1];
  53577. colorsPacked[j++] = c[2];
  53578. }
  53579. mesh.colors = colorsPacked;
  53580. var figures = mesh.figures;
  53581. for (i = 0, ii = figures.length; i < ii; i++) {
  53582. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  53583. for (j = 0, jj = ps.length; j < jj; j++) {
  53584. ps[j] *= 2;
  53585. cs[j] *= 3;
  53586. }
  53587. }
  53588. }
  53589. function Mesh(stream, matrix, xref, res) {
  53590. assert(isStream(stream), 'Mesh data is not a stream');
  53591. var dict = stream.dict;
  53592. this.matrix = matrix;
  53593. this.shadingType = dict.get('ShadingType');
  53594. this.type = 'Pattern';
  53595. this.bbox = dict.getArray('BBox');
  53596. var cs = dict.get('ColorSpace', 'CS');
  53597. cs = ColorSpace.parse(cs, xref, res);
  53598. this.cs = cs;
  53599. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  53600. var fnObj = dict.get('Function');
  53601. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  53602. this.coords = [];
  53603. this.colors = [];
  53604. this.figures = [];
  53605. var decodeContext = {
  53606. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  53607. bitsPerComponent: dict.get('BitsPerComponent'),
  53608. bitsPerFlag: dict.get('BitsPerFlag'),
  53609. decode: dict.getArray('Decode'),
  53610. colorFn: fn,
  53611. colorSpace: cs,
  53612. numComps: fn ? 1 : cs.numComps
  53613. };
  53614. var reader = new MeshStreamReader(stream, decodeContext);
  53615. var patchMesh = false;
  53616. switch (this.shadingType) {
  53617. case ShadingType.FREE_FORM_MESH:
  53618. decodeType4Shading(this, reader);
  53619. break;
  53620. case ShadingType.LATTICE_FORM_MESH:
  53621. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  53622. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  53623. decodeType5Shading(this, reader, verticesPerRow);
  53624. break;
  53625. case ShadingType.COONS_PATCH_MESH:
  53626. decodeType6Shading(this, reader);
  53627. patchMesh = true;
  53628. break;
  53629. case ShadingType.TENSOR_PATCH_MESH:
  53630. decodeType7Shading(this, reader);
  53631. patchMesh = true;
  53632. break;
  53633. default:
  53634. error('Unsupported mesh type.');
  53635. break;
  53636. }
  53637. if (patchMesh) {
  53638. updateBounds(this);
  53639. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  53640. buildFigureFromPatch(this, i);
  53641. }
  53642. }
  53643. updateBounds(this);
  53644. packData(this);
  53645. }
  53646. Mesh.prototype = {
  53647. getIR: function Mesh_getIR() {
  53648. return [
  53649. 'Mesh',
  53650. this.shadingType,
  53651. this.coords,
  53652. this.colors,
  53653. this.figures,
  53654. this.bounds,
  53655. this.matrix,
  53656. this.bbox,
  53657. this.background
  53658. ];
  53659. }
  53660. };
  53661. return Mesh;
  53662. }();
  53663. Shadings.Dummy = function DummyClosure() {
  53664. function Dummy() {
  53665. this.type = 'Pattern';
  53666. }
  53667. Dummy.prototype = {
  53668. getIR: function Dummy_getIR() {
  53669. return ['Dummy'];
  53670. }
  53671. };
  53672. return Dummy;
  53673. }();
  53674. function getTilingPatternIR(operatorList, dict, args) {
  53675. var matrix = dict.getArray('Matrix');
  53676. var bbox = dict.getArray('BBox');
  53677. var xstep = dict.get('XStep');
  53678. var ystep = dict.get('YStep');
  53679. var paintType = dict.get('PaintType');
  53680. var tilingType = dict.get('TilingType');
  53681. return [
  53682. 'TilingPattern',
  53683. args,
  53684. operatorList,
  53685. matrix,
  53686. bbox,
  53687. xstep,
  53688. ystep,
  53689. paintType,
  53690. tilingType
  53691. ];
  53692. }
  53693. exports.Pattern = Pattern;
  53694. exports.getTilingPatternIR = getTilingPatternIR;
  53695. /***/ }),
  53696. /* 41 */
  53697. /***/ (function(module, exports, __w_pdfjs_require__) {
  53698. "use strict";
  53699. var sharedUtil = __w_pdfjs_require__(0);
  53700. var coreStream = __w_pdfjs_require__(2);
  53701. var coreChunkedStream = __w_pdfjs_require__(15);
  53702. var coreDocument = __w_pdfjs_require__(31);
  53703. var warn = sharedUtil.warn;
  53704. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  53705. var shadow = sharedUtil.shadow;
  53706. var NotImplementedException = sharedUtil.NotImplementedException;
  53707. var MissingDataException = sharedUtil.MissingDataException;
  53708. var createPromiseCapability = sharedUtil.createPromiseCapability;
  53709. var Util = sharedUtil.Util;
  53710. var Stream = coreStream.Stream;
  53711. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  53712. var PDFDocument = coreDocument.PDFDocument;
  53713. var BasePdfManager = function BasePdfManagerClosure() {
  53714. function BasePdfManager() {
  53715. throw new Error('Cannot initialize BaseManagerManager');
  53716. }
  53717. BasePdfManager.prototype = {
  53718. get docId() {
  53719. return this._docId;
  53720. },
  53721. get password() {
  53722. return this._password;
  53723. },
  53724. get docBaseUrl() {
  53725. var docBaseUrl = null;
  53726. if (this._docBaseUrl) {
  53727. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  53728. if (absoluteUrl) {
  53729. docBaseUrl = absoluteUrl.href;
  53730. } else {
  53731. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  53732. }
  53733. }
  53734. return shadow(this, 'docBaseUrl', docBaseUrl);
  53735. },
  53736. onLoadedStream: function BasePdfManager_onLoadedStream() {
  53737. throw new NotImplementedException();
  53738. },
  53739. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  53740. return this.ensure(this.pdfDocument, prop, args);
  53741. },
  53742. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  53743. return this.ensure(this.pdfDocument.xref, prop, args);
  53744. },
  53745. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  53746. return this.ensure(this.pdfDocument.catalog, prop, args);
  53747. },
  53748. getPage: function BasePdfManager_getPage(pageIndex) {
  53749. return this.pdfDocument.getPage(pageIndex);
  53750. },
  53751. cleanup: function BasePdfManager_cleanup() {
  53752. return this.pdfDocument.cleanup();
  53753. },
  53754. ensure: function BasePdfManager_ensure(obj, prop, args) {
  53755. return new NotImplementedException();
  53756. },
  53757. requestRange: function BasePdfManager_requestRange(begin, end) {
  53758. return new NotImplementedException();
  53759. },
  53760. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  53761. return new NotImplementedException();
  53762. },
  53763. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  53764. return new NotImplementedException();
  53765. },
  53766. updatePassword: function BasePdfManager_updatePassword(password) {
  53767. this._password = password;
  53768. },
  53769. terminate: function BasePdfManager_terminate() {
  53770. return new NotImplementedException();
  53771. }
  53772. };
  53773. return BasePdfManager;
  53774. }();
  53775. var LocalPdfManager = function LocalPdfManagerClosure() {
  53776. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  53777. this._docId = docId;
  53778. this._password = password;
  53779. this._docBaseUrl = docBaseUrl;
  53780. this.evaluatorOptions = evaluatorOptions;
  53781. var stream = new Stream(data);
  53782. this.pdfDocument = new PDFDocument(this, stream);
  53783. this._loadedStreamCapability = createPromiseCapability();
  53784. this._loadedStreamCapability.resolve(stream);
  53785. }
  53786. Util.inherit(LocalPdfManager, BasePdfManager, {
  53787. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  53788. return new Promise(function (resolve, reject) {
  53789. try {
  53790. var value = obj[prop];
  53791. var result;
  53792. if (typeof value === 'function') {
  53793. result = value.apply(obj, args);
  53794. } else {
  53795. result = value;
  53796. }
  53797. resolve(result);
  53798. } catch (e) {
  53799. reject(e);
  53800. }
  53801. });
  53802. },
  53803. requestRange: function LocalPdfManager_requestRange(begin, end) {
  53804. return Promise.resolve();
  53805. },
  53806. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  53807. },
  53808. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  53809. return this._loadedStreamCapability.promise;
  53810. },
  53811. terminate: function LocalPdfManager_terminate() {
  53812. }
  53813. });
  53814. return LocalPdfManager;
  53815. }();
  53816. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  53817. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  53818. this._docId = docId;
  53819. this._password = args.password;
  53820. this._docBaseUrl = docBaseUrl;
  53821. this.msgHandler = args.msgHandler;
  53822. this.evaluatorOptions = evaluatorOptions;
  53823. var params = {
  53824. msgHandler: args.msgHandler,
  53825. url: args.url,
  53826. length: args.length,
  53827. disableAutoFetch: args.disableAutoFetch,
  53828. rangeChunkSize: args.rangeChunkSize
  53829. };
  53830. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  53831. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  53832. }
  53833. Util.inherit(NetworkPdfManager, BasePdfManager, {
  53834. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  53835. var pdfManager = this;
  53836. return new Promise(function (resolve, reject) {
  53837. function ensureHelper() {
  53838. try {
  53839. var result;
  53840. var value = obj[prop];
  53841. if (typeof value === 'function') {
  53842. result = value.apply(obj, args);
  53843. } else {
  53844. result = value;
  53845. }
  53846. resolve(result);
  53847. } catch (e) {
  53848. if (!(e instanceof MissingDataException)) {
  53849. reject(e);
  53850. return;
  53851. }
  53852. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  53853. }
  53854. }
  53855. ensureHelper();
  53856. });
  53857. },
  53858. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  53859. return this.streamManager.requestRange(begin, end);
  53860. },
  53861. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  53862. this.streamManager.requestAllChunks();
  53863. },
  53864. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  53865. this.streamManager.onReceiveData({ chunk: chunk });
  53866. },
  53867. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  53868. return this.streamManager.onLoadedStream();
  53869. },
  53870. terminate: function NetworkPdfManager_terminate() {
  53871. this.streamManager.abort();
  53872. }
  53873. });
  53874. return NetworkPdfManager;
  53875. }();
  53876. exports.LocalPdfManager = LocalPdfManager;
  53877. exports.NetworkPdfManager = NetworkPdfManager;
  53878. /***/ }),
  53879. /* 42 */
  53880. /***/ (function(module, exports, __w_pdfjs_require__) {
  53881. "use strict";
  53882. var sharedUtil = __w_pdfjs_require__(0);
  53883. var corePrimitives = __w_pdfjs_require__(1);
  53884. var error = sharedUtil.error;
  53885. var isSpace = sharedUtil.isSpace;
  53886. var EOF = corePrimitives.EOF;
  53887. var PostScriptParser = function PostScriptParserClosure() {
  53888. function PostScriptParser(lexer) {
  53889. this.lexer = lexer;
  53890. this.operators = [];
  53891. this.token = null;
  53892. this.prev = null;
  53893. }
  53894. PostScriptParser.prototype = {
  53895. nextToken: function PostScriptParser_nextToken() {
  53896. this.prev = this.token;
  53897. this.token = this.lexer.getToken();
  53898. },
  53899. accept: function PostScriptParser_accept(type) {
  53900. if (this.token.type === type) {
  53901. this.nextToken();
  53902. return true;
  53903. }
  53904. return false;
  53905. },
  53906. expect: function PostScriptParser_expect(type) {
  53907. if (this.accept(type)) {
  53908. return true;
  53909. }
  53910. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  53911. },
  53912. parse: function PostScriptParser_parse() {
  53913. this.nextToken();
  53914. this.expect(PostScriptTokenTypes.LBRACE);
  53915. this.parseBlock();
  53916. this.expect(PostScriptTokenTypes.RBRACE);
  53917. return this.operators;
  53918. },
  53919. parseBlock: function PostScriptParser_parseBlock() {
  53920. while (true) {
  53921. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  53922. this.operators.push(this.prev.value);
  53923. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  53924. this.operators.push(this.prev.value);
  53925. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53926. this.parseCondition();
  53927. } else {
  53928. return;
  53929. }
  53930. }
  53931. },
  53932. parseCondition: function PostScriptParser_parseCondition() {
  53933. var conditionLocation = this.operators.length;
  53934. this.operators.push(null, null);
  53935. this.parseBlock();
  53936. this.expect(PostScriptTokenTypes.RBRACE);
  53937. if (this.accept(PostScriptTokenTypes.IF)) {
  53938. this.operators[conditionLocation] = this.operators.length;
  53939. this.operators[conditionLocation + 1] = 'jz';
  53940. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53941. var jumpLocation = this.operators.length;
  53942. this.operators.push(null, null);
  53943. var endOfTrue = this.operators.length;
  53944. this.parseBlock();
  53945. this.expect(PostScriptTokenTypes.RBRACE);
  53946. this.expect(PostScriptTokenTypes.IFELSE);
  53947. this.operators[jumpLocation] = this.operators.length;
  53948. this.operators[jumpLocation + 1] = 'j';
  53949. this.operators[conditionLocation] = endOfTrue;
  53950. this.operators[conditionLocation + 1] = 'jz';
  53951. } else {
  53952. error('PS Function: error parsing conditional.');
  53953. }
  53954. }
  53955. };
  53956. return PostScriptParser;
  53957. }();
  53958. var PostScriptTokenTypes = {
  53959. LBRACE: 0,
  53960. RBRACE: 1,
  53961. NUMBER: 2,
  53962. OPERATOR: 3,
  53963. IF: 4,
  53964. IFELSE: 5
  53965. };
  53966. var PostScriptToken = function PostScriptTokenClosure() {
  53967. function PostScriptToken(type, value) {
  53968. this.type = type;
  53969. this.value = value;
  53970. }
  53971. var opCache = Object.create(null);
  53972. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  53973. var opValue = opCache[op];
  53974. if (opValue) {
  53975. return opValue;
  53976. }
  53977. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  53978. };
  53979. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  53980. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  53981. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  53982. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  53983. return PostScriptToken;
  53984. }();
  53985. var PostScriptLexer = function PostScriptLexerClosure() {
  53986. function PostScriptLexer(stream) {
  53987. this.stream = stream;
  53988. this.nextChar();
  53989. this.strBuf = [];
  53990. }
  53991. PostScriptLexer.prototype = {
  53992. nextChar: function PostScriptLexer_nextChar() {
  53993. return this.currentChar = this.stream.getByte();
  53994. },
  53995. getToken: function PostScriptLexer_getToken() {
  53996. var comment = false;
  53997. var ch = this.currentChar;
  53998. while (true) {
  53999. if (ch < 0) {
  54000. return EOF;
  54001. }
  54002. if (comment) {
  54003. if (ch === 0x0A || ch === 0x0D) {
  54004. comment = false;
  54005. }
  54006. } else if (ch === 0x25) {
  54007. comment = true;
  54008. } else if (!isSpace(ch)) {
  54009. break;
  54010. }
  54011. ch = this.nextChar();
  54012. }
  54013. switch (ch | 0) {
  54014. case 0x30:
  54015. case 0x31:
  54016. case 0x32:
  54017. case 0x33:
  54018. case 0x34:
  54019. case 0x35:
  54020. case 0x36:
  54021. case 0x37:
  54022. case 0x38:
  54023. case 0x39:
  54024. case 0x2B:
  54025. case 0x2D:
  54026. case 0x2E:
  54027. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  54028. case 0x7B:
  54029. this.nextChar();
  54030. return PostScriptToken.LBRACE;
  54031. case 0x7D:
  54032. this.nextChar();
  54033. return PostScriptToken.RBRACE;
  54034. }
  54035. var strBuf = this.strBuf;
  54036. strBuf.length = 0;
  54037. strBuf[0] = String.fromCharCode(ch);
  54038. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  54039. strBuf.push(String.fromCharCode(ch));
  54040. }
  54041. var str = strBuf.join('');
  54042. switch (str.toLowerCase()) {
  54043. case 'if':
  54044. return PostScriptToken.IF;
  54045. case 'ifelse':
  54046. return PostScriptToken.IFELSE;
  54047. default:
  54048. return PostScriptToken.getOperator(str);
  54049. }
  54050. },
  54051. getNumber: function PostScriptLexer_getNumber() {
  54052. var ch = this.currentChar;
  54053. var strBuf = this.strBuf;
  54054. strBuf.length = 0;
  54055. strBuf[0] = String.fromCharCode(ch);
  54056. while ((ch = this.nextChar()) >= 0) {
  54057. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  54058. strBuf.push(String.fromCharCode(ch));
  54059. } else {
  54060. break;
  54061. }
  54062. }
  54063. var value = parseFloat(strBuf.join(''));
  54064. if (isNaN(value)) {
  54065. error('Invalid floating point number: ' + value);
  54066. }
  54067. return value;
  54068. }
  54069. };
  54070. return PostScriptLexer;
  54071. }();
  54072. exports.PostScriptLexer = PostScriptLexer;
  54073. exports.PostScriptParser = PostScriptParser;
  54074. /***/ }),
  54075. /* 43 */
  54076. /***/ (function(module, exports, __w_pdfjs_require__) {
  54077. "use strict";
  54078. var sharedUtil = __w_pdfjs_require__(0);
  54079. var coreStream = __w_pdfjs_require__(2);
  54080. var coreEncodings = __w_pdfjs_require__(5);
  54081. var warn = sharedUtil.warn;
  54082. var isSpace = sharedUtil.isSpace;
  54083. var Stream = coreStream.Stream;
  54084. var getEncoding = coreEncodings.getEncoding;
  54085. var HINTING_ENABLED = false;
  54086. var Type1CharString = function Type1CharStringClosure() {
  54087. var COMMAND_MAP = {
  54088. 'hstem': [1],
  54089. 'vstem': [3],
  54090. 'vmoveto': [4],
  54091. 'rlineto': [5],
  54092. 'hlineto': [6],
  54093. 'vlineto': [7],
  54094. 'rrcurveto': [8],
  54095. 'callsubr': [10],
  54096. 'flex': [
  54097. 12,
  54098. 35
  54099. ],
  54100. 'drop': [
  54101. 12,
  54102. 18
  54103. ],
  54104. 'endchar': [14],
  54105. 'rmoveto': [21],
  54106. 'hmoveto': [22],
  54107. 'vhcurveto': [30],
  54108. 'hvcurveto': [31]
  54109. };
  54110. function Type1CharString() {
  54111. this.width = 0;
  54112. this.lsb = 0;
  54113. this.flexing = false;
  54114. this.output = [];
  54115. this.stack = [];
  54116. }
  54117. Type1CharString.prototype = {
  54118. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  54119. var count = encoded.length;
  54120. var error = false;
  54121. var wx, sbx, subrNumber;
  54122. for (var i = 0; i < count; i++) {
  54123. var value = encoded[i];
  54124. if (value < 32) {
  54125. if (value === 12) {
  54126. value = (value << 8) + encoded[++i];
  54127. }
  54128. switch (value) {
  54129. case 1:
  54130. if (!HINTING_ENABLED) {
  54131. this.stack = [];
  54132. break;
  54133. }
  54134. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54135. break;
  54136. case 3:
  54137. if (!HINTING_ENABLED) {
  54138. this.stack = [];
  54139. break;
  54140. }
  54141. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54142. break;
  54143. case 4:
  54144. if (this.flexing) {
  54145. if (this.stack.length < 1) {
  54146. error = true;
  54147. break;
  54148. }
  54149. var dy = this.stack.pop();
  54150. this.stack.push(0, dy);
  54151. break;
  54152. }
  54153. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  54154. break;
  54155. case 5:
  54156. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  54157. break;
  54158. case 6:
  54159. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  54160. break;
  54161. case 7:
  54162. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  54163. break;
  54164. case 8:
  54165. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  54166. break;
  54167. case 9:
  54168. this.stack = [];
  54169. break;
  54170. case 10:
  54171. if (this.stack.length < 1) {
  54172. error = true;
  54173. break;
  54174. }
  54175. subrNumber = this.stack.pop();
  54176. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  54177. break;
  54178. case 11:
  54179. return error;
  54180. case 13:
  54181. if (this.stack.length < 2) {
  54182. error = true;
  54183. break;
  54184. }
  54185. wx = this.stack.pop();
  54186. sbx = this.stack.pop();
  54187. this.lsb = sbx;
  54188. this.width = wx;
  54189. this.stack.push(wx, sbx);
  54190. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  54191. break;
  54192. case 14:
  54193. this.output.push(COMMAND_MAP.endchar[0]);
  54194. break;
  54195. case 21:
  54196. if (this.flexing) {
  54197. break;
  54198. }
  54199. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  54200. break;
  54201. case 22:
  54202. if (this.flexing) {
  54203. this.stack.push(0);
  54204. break;
  54205. }
  54206. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  54207. break;
  54208. case 30:
  54209. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  54210. break;
  54211. case 31:
  54212. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  54213. break;
  54214. case (12 << 8) + 0:
  54215. this.stack = [];
  54216. break;
  54217. case (12 << 8) + 1:
  54218. if (!HINTING_ENABLED) {
  54219. this.stack = [];
  54220. break;
  54221. }
  54222. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54223. break;
  54224. case (12 << 8) + 2:
  54225. if (!HINTING_ENABLED) {
  54226. this.stack = [];
  54227. break;
  54228. }
  54229. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54230. break;
  54231. case (12 << 8) + 6:
  54232. if (seacAnalysisEnabled) {
  54233. this.seac = this.stack.splice(-4, 4);
  54234. error = this.executeCommand(0, COMMAND_MAP.endchar);
  54235. } else {
  54236. error = this.executeCommand(4, COMMAND_MAP.endchar);
  54237. }
  54238. break;
  54239. case (12 << 8) + 7:
  54240. if (this.stack.length < 4) {
  54241. error = true;
  54242. break;
  54243. }
  54244. this.stack.pop();
  54245. wx = this.stack.pop();
  54246. var sby = this.stack.pop();
  54247. sbx = this.stack.pop();
  54248. this.lsb = sbx;
  54249. this.width = wx;
  54250. this.stack.push(wx, sbx, sby);
  54251. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  54252. break;
  54253. case (12 << 8) + 12:
  54254. if (this.stack.length < 2) {
  54255. error = true;
  54256. break;
  54257. }
  54258. var num2 = this.stack.pop();
  54259. var num1 = this.stack.pop();
  54260. this.stack.push(num1 / num2);
  54261. break;
  54262. case (12 << 8) + 16:
  54263. if (this.stack.length < 2) {
  54264. error = true;
  54265. break;
  54266. }
  54267. subrNumber = this.stack.pop();
  54268. var numArgs = this.stack.pop();
  54269. if (subrNumber === 0 && numArgs === 3) {
  54270. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  54271. 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]);
  54272. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  54273. this.flexing = false;
  54274. this.stack.push(flexArgs[15], flexArgs[16]);
  54275. } else if (subrNumber === 1 && numArgs === 0) {
  54276. this.flexing = true;
  54277. }
  54278. break;
  54279. case (12 << 8) + 17:
  54280. break;
  54281. case (12 << 8) + 33:
  54282. this.stack = [];
  54283. break;
  54284. default:
  54285. warn('Unknown type 1 charstring command of "' + value + '"');
  54286. break;
  54287. }
  54288. if (error) {
  54289. break;
  54290. }
  54291. continue;
  54292. } else if (value <= 246) {
  54293. value = value - 139;
  54294. } else if (value <= 250) {
  54295. value = (value - 247) * 256 + encoded[++i] + 108;
  54296. } else if (value <= 254) {
  54297. value = -((value - 251) * 256) - encoded[++i] - 108;
  54298. } else {
  54299. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  54300. }
  54301. this.stack.push(value);
  54302. }
  54303. return error;
  54304. },
  54305. executeCommand: function (howManyArgs, command, keepStack) {
  54306. var stackLength = this.stack.length;
  54307. if (howManyArgs > stackLength) {
  54308. return true;
  54309. }
  54310. var start = stackLength - howManyArgs;
  54311. for (var i = start; i < stackLength; i++) {
  54312. var value = this.stack[i];
  54313. if (value === (value | 0)) {
  54314. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  54315. } else {
  54316. value = 65536 * value | 0;
  54317. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  54318. }
  54319. }
  54320. this.output.push.apply(this.output, command);
  54321. if (keepStack) {
  54322. this.stack.splice(start, howManyArgs);
  54323. } else {
  54324. this.stack.length = 0;
  54325. }
  54326. return false;
  54327. }
  54328. };
  54329. return Type1CharString;
  54330. }();
  54331. var Type1Parser = function Type1ParserClosure() {
  54332. var EEXEC_ENCRYPT_KEY = 55665;
  54333. var CHAR_STRS_ENCRYPT_KEY = 4330;
  54334. function isHexDigit(code) {
  54335. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  54336. }
  54337. function decrypt(data, key, discardNumber) {
  54338. if (discardNumber >= data.length) {
  54339. return new Uint8Array(0);
  54340. }
  54341. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  54342. for (i = 0; i < discardNumber; i++) {
  54343. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  54344. }
  54345. var count = data.length - discardNumber;
  54346. var decrypted = new Uint8Array(count);
  54347. for (i = discardNumber, j = 0; j < count; i++, j++) {
  54348. var value = data[i];
  54349. decrypted[j] = value ^ r >> 8;
  54350. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54351. }
  54352. return decrypted;
  54353. }
  54354. function decryptAscii(data, key, discardNumber) {
  54355. var r = key | 0, c1 = 52845, c2 = 22719;
  54356. var count = data.length, maybeLength = count >>> 1;
  54357. var decrypted = new Uint8Array(maybeLength);
  54358. var i, j;
  54359. for (i = 0, j = 0; i < count; i++) {
  54360. var digit1 = data[i];
  54361. if (!isHexDigit(digit1)) {
  54362. continue;
  54363. }
  54364. i++;
  54365. var digit2;
  54366. while (i < count && !isHexDigit(digit2 = data[i])) {
  54367. i++;
  54368. }
  54369. if (i < count) {
  54370. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  54371. decrypted[j++] = value ^ r >> 8;
  54372. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54373. }
  54374. }
  54375. return Array.prototype.slice.call(decrypted, discardNumber, j);
  54376. }
  54377. function isSpecial(c) {
  54378. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  54379. }
  54380. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  54381. if (encrypted) {
  54382. var data = stream.getBytes();
  54383. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  54384. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  54385. }
  54386. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  54387. this.stream = stream;
  54388. this.nextChar();
  54389. }
  54390. Type1Parser.prototype = {
  54391. readNumberArray: function Type1Parser_readNumberArray() {
  54392. this.getToken();
  54393. var array = [];
  54394. while (true) {
  54395. var token = this.getToken();
  54396. if (token === null || token === ']' || token === '}') {
  54397. break;
  54398. }
  54399. array.push(parseFloat(token || 0));
  54400. }
  54401. return array;
  54402. },
  54403. readNumber: function Type1Parser_readNumber() {
  54404. var token = this.getToken();
  54405. return parseFloat(token || 0);
  54406. },
  54407. readInt: function Type1Parser_readInt() {
  54408. var token = this.getToken();
  54409. return parseInt(token || 0, 10) | 0;
  54410. },
  54411. readBoolean: function Type1Parser_readBoolean() {
  54412. var token = this.getToken();
  54413. return token === 'true' ? 1 : 0;
  54414. },
  54415. nextChar: function Type1_nextChar() {
  54416. return this.currentChar = this.stream.getByte();
  54417. },
  54418. getToken: function Type1Parser_getToken() {
  54419. var comment = false;
  54420. var ch = this.currentChar;
  54421. while (true) {
  54422. if (ch === -1) {
  54423. return null;
  54424. }
  54425. if (comment) {
  54426. if (ch === 0x0A || ch === 0x0D) {
  54427. comment = false;
  54428. }
  54429. } else if (ch === 0x25) {
  54430. comment = true;
  54431. } else if (!isSpace(ch)) {
  54432. break;
  54433. }
  54434. ch = this.nextChar();
  54435. }
  54436. if (isSpecial(ch)) {
  54437. this.nextChar();
  54438. return String.fromCharCode(ch);
  54439. }
  54440. var token = '';
  54441. do {
  54442. token += String.fromCharCode(ch);
  54443. ch = this.nextChar();
  54444. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  54445. return token;
  54446. },
  54447. extractFontProgram: function Type1Parser_extractFontProgram() {
  54448. var stream = this.stream;
  54449. var subrs = [], charstrings = [];
  54450. var privateData = Object.create(null);
  54451. privateData['lenIV'] = 4;
  54452. var program = {
  54453. subrs: [],
  54454. charstrings: [],
  54455. properties: { 'privateData': privateData }
  54456. };
  54457. var token, length, data, lenIV, encoded;
  54458. while ((token = this.getToken()) !== null) {
  54459. if (token !== '/') {
  54460. continue;
  54461. }
  54462. token = this.getToken();
  54463. switch (token) {
  54464. case 'CharStrings':
  54465. this.getToken();
  54466. this.getToken();
  54467. this.getToken();
  54468. this.getToken();
  54469. while (true) {
  54470. token = this.getToken();
  54471. if (token === null || token === 'end') {
  54472. break;
  54473. }
  54474. if (token !== '/') {
  54475. continue;
  54476. }
  54477. var glyph = this.getToken();
  54478. length = this.readInt();
  54479. this.getToken();
  54480. data = stream.makeSubStream(stream.pos, length);
  54481. lenIV = program.properties.privateData['lenIV'];
  54482. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54483. stream.skip(length);
  54484. this.nextChar();
  54485. token = this.getToken();
  54486. if (token === 'noaccess') {
  54487. this.getToken();
  54488. }
  54489. charstrings.push({
  54490. glyph: glyph,
  54491. encoded: encoded
  54492. });
  54493. }
  54494. break;
  54495. case 'Subrs':
  54496. this.readInt();
  54497. this.getToken();
  54498. while ((token = this.getToken()) === 'dup') {
  54499. var index = this.readInt();
  54500. length = this.readInt();
  54501. this.getToken();
  54502. data = stream.makeSubStream(stream.pos, length);
  54503. lenIV = program.properties.privateData['lenIV'];
  54504. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54505. stream.skip(length);
  54506. this.nextChar();
  54507. token = this.getToken();
  54508. if (token === 'noaccess') {
  54509. this.getToken();
  54510. }
  54511. subrs[index] = encoded;
  54512. }
  54513. break;
  54514. case 'BlueValues':
  54515. case 'OtherBlues':
  54516. case 'FamilyBlues':
  54517. case 'FamilyOtherBlues':
  54518. var blueArray = this.readNumberArray();
  54519. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  54520. program.properties.privateData[token] = blueArray;
  54521. }
  54522. break;
  54523. case 'StemSnapH':
  54524. case 'StemSnapV':
  54525. program.properties.privateData[token] = this.readNumberArray();
  54526. break;
  54527. case 'StdHW':
  54528. case 'StdVW':
  54529. program.properties.privateData[token] = this.readNumberArray()[0];
  54530. break;
  54531. case 'BlueShift':
  54532. case 'lenIV':
  54533. case 'BlueFuzz':
  54534. case 'BlueScale':
  54535. case 'LanguageGroup':
  54536. case 'ExpansionFactor':
  54537. program.properties.privateData[token] = this.readNumber();
  54538. break;
  54539. case 'ForceBold':
  54540. program.properties.privateData[token] = this.readBoolean();
  54541. break;
  54542. }
  54543. }
  54544. for (var i = 0; i < charstrings.length; i++) {
  54545. glyph = charstrings[i].glyph;
  54546. encoded = charstrings[i].encoded;
  54547. var charString = new Type1CharString();
  54548. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  54549. var output = charString.output;
  54550. if (error) {
  54551. output = [14];
  54552. }
  54553. program.charstrings.push({
  54554. glyphName: glyph,
  54555. charstring: output,
  54556. width: charString.width,
  54557. lsb: charString.lsb,
  54558. seac: charString.seac
  54559. });
  54560. }
  54561. return program;
  54562. },
  54563. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  54564. var token;
  54565. while ((token = this.getToken()) !== null) {
  54566. if (token !== '/') {
  54567. continue;
  54568. }
  54569. token = this.getToken();
  54570. switch (token) {
  54571. case 'FontMatrix':
  54572. var matrix = this.readNumberArray();
  54573. properties.fontMatrix = matrix;
  54574. break;
  54575. case 'Encoding':
  54576. var encodingArg = this.getToken();
  54577. var encoding;
  54578. if (!/^\d+$/.test(encodingArg)) {
  54579. encoding = getEncoding(encodingArg);
  54580. } else {
  54581. encoding = [];
  54582. var size = parseInt(encodingArg, 10) | 0;
  54583. this.getToken();
  54584. for (var j = 0; j < size; j++) {
  54585. token = this.getToken();
  54586. while (token !== 'dup' && token !== 'def') {
  54587. token = this.getToken();
  54588. if (token === null) {
  54589. return;
  54590. }
  54591. }
  54592. if (token === 'def') {
  54593. break;
  54594. }
  54595. var index = this.readInt();
  54596. this.getToken();
  54597. var glyph = this.getToken();
  54598. encoding[index] = glyph;
  54599. this.getToken();
  54600. }
  54601. }
  54602. properties.builtInEncoding = encoding;
  54603. break;
  54604. case 'FontBBox':
  54605. var fontBBox = this.readNumberArray();
  54606. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  54607. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  54608. properties.ascentScaled = true;
  54609. break;
  54610. }
  54611. }
  54612. }
  54613. };
  54614. return Type1Parser;
  54615. }();
  54616. exports.Type1Parser = Type1Parser;
  54617. /***/ }),
  54618. /* 44 */
  54619. /***/ (function(module, exports, __w_pdfjs_require__) {
  54620. "use strict";
  54621. var sharedUtil = __w_pdfjs_require__(0);
  54622. var displayDOMUtils = __w_pdfjs_require__(3);
  54623. var displayPatternHelper = __w_pdfjs_require__(46);
  54624. var displayWebGL = __w_pdfjs_require__(24);
  54625. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  54626. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  54627. var ImageKind = sharedUtil.ImageKind;
  54628. var OPS = sharedUtil.OPS;
  54629. var TextRenderingMode = sharedUtil.TextRenderingMode;
  54630. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  54631. var Util = sharedUtil.Util;
  54632. var assert = sharedUtil.assert;
  54633. var info = sharedUtil.info;
  54634. var isNum = sharedUtil.isNum;
  54635. var isArray = sharedUtil.isArray;
  54636. var isLittleEndian = sharedUtil.isLittleEndian;
  54637. var error = sharedUtil.error;
  54638. var shadow = sharedUtil.shadow;
  54639. var warn = sharedUtil.warn;
  54640. var TilingPattern = displayPatternHelper.TilingPattern;
  54641. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  54642. var WebGLUtils = displayWebGL.WebGLUtils;
  54643. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  54644. var MIN_FONT_SIZE = 16;
  54645. var MAX_FONT_SIZE = 100;
  54646. var MAX_GROUP_SIZE = 4096;
  54647. var MIN_WIDTH_FACTOR = 0.65;
  54648. var COMPILE_TYPE3_GLYPHS = true;
  54649. var MAX_SIZE_TO_COMPILE = 1000;
  54650. var FULL_CHUNK_HEIGHT = 16;
  54651. var HasCanvasTypedArraysCached = {
  54652. get value() {
  54653. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  54654. }
  54655. };
  54656. var IsLittleEndianCached = {
  54657. get value() {
  54658. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  54659. }
  54660. };
  54661. function addContextCurrentTransform(ctx) {
  54662. if (!ctx.mozCurrentTransform) {
  54663. ctx._originalSave = ctx.save;
  54664. ctx._originalRestore = ctx.restore;
  54665. ctx._originalRotate = ctx.rotate;
  54666. ctx._originalScale = ctx.scale;
  54667. ctx._originalTranslate = ctx.translate;
  54668. ctx._originalTransform = ctx.transform;
  54669. ctx._originalSetTransform = ctx.setTransform;
  54670. ctx._transformMatrix = ctx._transformMatrix || [
  54671. 1,
  54672. 0,
  54673. 0,
  54674. 1,
  54675. 0,
  54676. 0
  54677. ];
  54678. ctx._transformStack = [];
  54679. Object.defineProperty(ctx, 'mozCurrentTransform', {
  54680. get: function getCurrentTransform() {
  54681. return this._transformMatrix;
  54682. }
  54683. });
  54684. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  54685. get: function getCurrentTransformInverse() {
  54686. var m = this._transformMatrix;
  54687. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  54688. var ad_bc = a * d - b * c;
  54689. var bc_ad = b * c - a * d;
  54690. return [
  54691. d / ad_bc,
  54692. b / bc_ad,
  54693. c / bc_ad,
  54694. a / ad_bc,
  54695. (d * e - c * f) / bc_ad,
  54696. (b * e - a * f) / ad_bc
  54697. ];
  54698. }
  54699. });
  54700. ctx.save = function ctxSave() {
  54701. var old = this._transformMatrix;
  54702. this._transformStack.push(old);
  54703. this._transformMatrix = old.slice(0, 6);
  54704. this._originalSave();
  54705. };
  54706. ctx.restore = function ctxRestore() {
  54707. var prev = this._transformStack.pop();
  54708. if (prev) {
  54709. this._transformMatrix = prev;
  54710. this._originalRestore();
  54711. }
  54712. };
  54713. ctx.translate = function ctxTranslate(x, y) {
  54714. var m = this._transformMatrix;
  54715. m[4] = m[0] * x + m[2] * y + m[4];
  54716. m[5] = m[1] * x + m[3] * y + m[5];
  54717. this._originalTranslate(x, y);
  54718. };
  54719. ctx.scale = function ctxScale(x, y) {
  54720. var m = this._transformMatrix;
  54721. m[0] = m[0] * x;
  54722. m[1] = m[1] * x;
  54723. m[2] = m[2] * y;
  54724. m[3] = m[3] * y;
  54725. this._originalScale(x, y);
  54726. };
  54727. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  54728. var m = this._transformMatrix;
  54729. this._transformMatrix = [
  54730. m[0] * a + m[2] * b,
  54731. m[1] * a + m[3] * b,
  54732. m[0] * c + m[2] * d,
  54733. m[1] * c + m[3] * d,
  54734. m[0] * e + m[2] * f + m[4],
  54735. m[1] * e + m[3] * f + m[5]
  54736. ];
  54737. ctx._originalTransform(a, b, c, d, e, f);
  54738. };
  54739. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  54740. this._transformMatrix = [
  54741. a,
  54742. b,
  54743. c,
  54744. d,
  54745. e,
  54746. f
  54747. ];
  54748. ctx._originalSetTransform(a, b, c, d, e, f);
  54749. };
  54750. ctx.rotate = function ctxRotate(angle) {
  54751. var cosValue = Math.cos(angle);
  54752. var sinValue = Math.sin(angle);
  54753. var m = this._transformMatrix;
  54754. this._transformMatrix = [
  54755. m[0] * cosValue + m[2] * sinValue,
  54756. m[1] * cosValue + m[3] * sinValue,
  54757. m[0] * -sinValue + m[2] * cosValue,
  54758. m[1] * -sinValue + m[3] * cosValue,
  54759. m[4],
  54760. m[5]
  54761. ];
  54762. this._originalRotate(angle);
  54763. };
  54764. }
  54765. }
  54766. var CachedCanvases = function CachedCanvasesClosure() {
  54767. function CachedCanvases(canvasFactory) {
  54768. this.canvasFactory = canvasFactory;
  54769. this.cache = Object.create(null);
  54770. }
  54771. CachedCanvases.prototype = {
  54772. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  54773. var canvasEntry;
  54774. if (this.cache[id] !== undefined) {
  54775. canvasEntry = this.cache[id];
  54776. this.canvasFactory.reset(canvasEntry, width, height);
  54777. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  54778. } else {
  54779. canvasEntry = this.canvasFactory.create(width, height);
  54780. this.cache[id] = canvasEntry;
  54781. }
  54782. if (trackTransform) {
  54783. addContextCurrentTransform(canvasEntry.context);
  54784. }
  54785. return canvasEntry;
  54786. },
  54787. clear: function () {
  54788. for (var id in this.cache) {
  54789. var canvasEntry = this.cache[id];
  54790. this.canvasFactory.destroy(canvasEntry);
  54791. delete this.cache[id];
  54792. }
  54793. }
  54794. };
  54795. return CachedCanvases;
  54796. }();
  54797. function compileType3Glyph(imgData) {
  54798. var POINT_TO_PROCESS_LIMIT = 1000;
  54799. var width = imgData.width, height = imgData.height;
  54800. var i, j, j0, width1 = width + 1;
  54801. var points = new Uint8Array(width1 * (height + 1));
  54802. var POINT_TYPES = new Uint8Array([
  54803. 0,
  54804. 2,
  54805. 4,
  54806. 0,
  54807. 1,
  54808. 0,
  54809. 5,
  54810. 4,
  54811. 8,
  54812. 10,
  54813. 0,
  54814. 8,
  54815. 0,
  54816. 2,
  54817. 1,
  54818. 0
  54819. ]);
  54820. var lineSize = width + 7 & ~7, data0 = imgData.data;
  54821. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  54822. for (i = 0, ii = data0.length; i < ii; i++) {
  54823. var mask = 128, elem = data0[i];
  54824. while (mask > 0) {
  54825. data[pos++] = elem & mask ? 0 : 255;
  54826. mask >>= 1;
  54827. }
  54828. }
  54829. var count = 0;
  54830. pos = 0;
  54831. if (data[pos] !== 0) {
  54832. points[0] = 1;
  54833. ++count;
  54834. }
  54835. for (j = 1; j < width; j++) {
  54836. if (data[pos] !== data[pos + 1]) {
  54837. points[j] = data[pos] ? 2 : 1;
  54838. ++count;
  54839. }
  54840. pos++;
  54841. }
  54842. if (data[pos] !== 0) {
  54843. points[j] = 2;
  54844. ++count;
  54845. }
  54846. for (i = 1; i < height; i++) {
  54847. pos = i * lineSize;
  54848. j0 = i * width1;
  54849. if (data[pos - lineSize] !== data[pos]) {
  54850. points[j0] = data[pos] ? 1 : 8;
  54851. ++count;
  54852. }
  54853. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  54854. for (j = 1; j < width; j++) {
  54855. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  54856. if (POINT_TYPES[sum]) {
  54857. points[j0 + j] = POINT_TYPES[sum];
  54858. ++count;
  54859. }
  54860. pos++;
  54861. }
  54862. if (data[pos - lineSize] !== data[pos]) {
  54863. points[j0 + j] = data[pos] ? 2 : 4;
  54864. ++count;
  54865. }
  54866. if (count > POINT_TO_PROCESS_LIMIT) {
  54867. return null;
  54868. }
  54869. }
  54870. pos = lineSize * (height - 1);
  54871. j0 = i * width1;
  54872. if (data[pos] !== 0) {
  54873. points[j0] = 8;
  54874. ++count;
  54875. }
  54876. for (j = 1; j < width; j++) {
  54877. if (data[pos] !== data[pos + 1]) {
  54878. points[j0 + j] = data[pos] ? 4 : 8;
  54879. ++count;
  54880. }
  54881. pos++;
  54882. }
  54883. if (data[pos] !== 0) {
  54884. points[j0 + j] = 4;
  54885. ++count;
  54886. }
  54887. if (count > POINT_TO_PROCESS_LIMIT) {
  54888. return null;
  54889. }
  54890. var steps = new Int32Array([
  54891. 0,
  54892. width1,
  54893. -1,
  54894. 0,
  54895. -width1,
  54896. 0,
  54897. 0,
  54898. 0,
  54899. 1
  54900. ]);
  54901. var outlines = [];
  54902. for (i = 0; count && i <= height; i++) {
  54903. var p = i * width1;
  54904. var end = p + width;
  54905. while (p < end && !points[p]) {
  54906. p++;
  54907. }
  54908. if (p === end) {
  54909. continue;
  54910. }
  54911. var coords = [
  54912. p % width1,
  54913. i
  54914. ];
  54915. var type = points[p], p0 = p, pp;
  54916. do {
  54917. var step = steps[type];
  54918. do {
  54919. p += step;
  54920. } while (!points[p]);
  54921. pp = points[p];
  54922. if (pp !== 5 && pp !== 10) {
  54923. type = pp;
  54924. points[p] = 0;
  54925. } else {
  54926. type = pp & 0x33 * type >> 4;
  54927. points[p] &= type >> 2 | type << 2;
  54928. }
  54929. coords.push(p % width1);
  54930. coords.push(p / width1 | 0);
  54931. --count;
  54932. } while (p0 !== p);
  54933. outlines.push(coords);
  54934. --i;
  54935. }
  54936. var drawOutline = function (c) {
  54937. c.save();
  54938. c.scale(1 / width, -1 / height);
  54939. c.translate(0, -height);
  54940. c.beginPath();
  54941. for (var i = 0, ii = outlines.length; i < ii; i++) {
  54942. var o = outlines[i];
  54943. c.moveTo(o[0], o[1]);
  54944. for (var j = 2, jj = o.length; j < jj; j += 2) {
  54945. c.lineTo(o[j], o[j + 1]);
  54946. }
  54947. }
  54948. c.fill();
  54949. c.beginPath();
  54950. c.restore();
  54951. };
  54952. return drawOutline;
  54953. }
  54954. var CanvasExtraState = function CanvasExtraStateClosure() {
  54955. function CanvasExtraState(old) {
  54956. this.alphaIsShape = false;
  54957. this.fontSize = 0;
  54958. this.fontSizeScale = 1;
  54959. this.textMatrix = IDENTITY_MATRIX;
  54960. this.textMatrixScale = 1;
  54961. this.fontMatrix = FONT_IDENTITY_MATRIX;
  54962. this.leading = 0;
  54963. this.x = 0;
  54964. this.y = 0;
  54965. this.lineX = 0;
  54966. this.lineY = 0;
  54967. this.charSpacing = 0;
  54968. this.wordSpacing = 0;
  54969. this.textHScale = 1;
  54970. this.textRenderingMode = TextRenderingMode.FILL;
  54971. this.textRise = 0;
  54972. this.fillColor = '#000000';
  54973. this.strokeColor = '#000000';
  54974. this.patternFill = false;
  54975. this.fillAlpha = 1;
  54976. this.strokeAlpha = 1;
  54977. this.lineWidth = 1;
  54978. this.activeSMask = null;
  54979. this.resumeSMaskCtx = null;
  54980. this.old = old;
  54981. }
  54982. CanvasExtraState.prototype = {
  54983. clone: function CanvasExtraState_clone() {
  54984. return Object.create(this);
  54985. },
  54986. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  54987. this.x = x;
  54988. this.y = y;
  54989. }
  54990. };
  54991. return CanvasExtraState;
  54992. }();
  54993. var CanvasGraphics = function CanvasGraphicsClosure() {
  54994. var EXECUTION_TIME = 15;
  54995. var EXECUTION_STEPS = 10;
  54996. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  54997. this.ctx = canvasCtx;
  54998. this.current = new CanvasExtraState();
  54999. this.stateStack = [];
  55000. this.pendingClip = null;
  55001. this.pendingEOFill = false;
  55002. this.res = null;
  55003. this.xobjs = null;
  55004. this.commonObjs = commonObjs;
  55005. this.objs = objs;
  55006. this.canvasFactory = canvasFactory;
  55007. this.imageLayer = imageLayer;
  55008. this.groupStack = [];
  55009. this.processingType3 = null;
  55010. this.baseTransform = null;
  55011. this.baseTransformStack = [];
  55012. this.groupLevel = 0;
  55013. this.smaskStack = [];
  55014. this.smaskCounter = 0;
  55015. this.tempSMask = null;
  55016. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  55017. if (canvasCtx) {
  55018. addContextCurrentTransform(canvasCtx);
  55019. }
  55020. this.cachedGetSinglePixelWidth = null;
  55021. }
  55022. function putBinaryImageData(ctx, imgData) {
  55023. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  55024. ctx.putImageData(imgData, 0, 0);
  55025. return;
  55026. }
  55027. var height = imgData.height, width = imgData.width;
  55028. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  55029. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  55030. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  55031. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  55032. var srcPos = 0, destPos;
  55033. var src = imgData.data;
  55034. var dest = chunkImgData.data;
  55035. var i, j, thisChunkHeight, elemsInThisChunk;
  55036. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  55037. var srcLength = src.byteLength;
  55038. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  55039. var dest32DataLength = dest32.length;
  55040. var fullSrcDiff = width + 7 >> 3;
  55041. var white = 0xFFFFFFFF;
  55042. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  55043. for (i = 0; i < totalChunks; i++) {
  55044. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  55045. destPos = 0;
  55046. for (j = 0; j < thisChunkHeight; j++) {
  55047. var srcDiff = srcLength - srcPos;
  55048. var k = 0;
  55049. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  55050. var kEndUnrolled = kEnd & ~7;
  55051. var mask = 0;
  55052. var srcByte = 0;
  55053. for (; k < kEndUnrolled; k += 8) {
  55054. srcByte = src[srcPos++];
  55055. dest32[destPos++] = srcByte & 128 ? white : black;
  55056. dest32[destPos++] = srcByte & 64 ? white : black;
  55057. dest32[destPos++] = srcByte & 32 ? white : black;
  55058. dest32[destPos++] = srcByte & 16 ? white : black;
  55059. dest32[destPos++] = srcByte & 8 ? white : black;
  55060. dest32[destPos++] = srcByte & 4 ? white : black;
  55061. dest32[destPos++] = srcByte & 2 ? white : black;
  55062. dest32[destPos++] = srcByte & 1 ? white : black;
  55063. }
  55064. for (; k < kEnd; k++) {
  55065. if (mask === 0) {
  55066. srcByte = src[srcPos++];
  55067. mask = 128;
  55068. }
  55069. dest32[destPos++] = srcByte & mask ? white : black;
  55070. mask >>= 1;
  55071. }
  55072. }
  55073. while (destPos < dest32DataLength) {
  55074. dest32[destPos++] = 0;
  55075. }
  55076. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55077. }
  55078. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  55079. j = 0;
  55080. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  55081. for (i = 0; i < fullChunks; i++) {
  55082. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55083. srcPos += elemsInThisChunk;
  55084. ctx.putImageData(chunkImgData, 0, j);
  55085. j += FULL_CHUNK_HEIGHT;
  55086. }
  55087. if (i < totalChunks) {
  55088. elemsInThisChunk = width * partialChunkHeight * 4;
  55089. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55090. ctx.putImageData(chunkImgData, 0, j);
  55091. }
  55092. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  55093. thisChunkHeight = FULL_CHUNK_HEIGHT;
  55094. elemsInThisChunk = width * thisChunkHeight;
  55095. for (i = 0; i < totalChunks; i++) {
  55096. if (i >= fullChunks) {
  55097. thisChunkHeight = partialChunkHeight;
  55098. elemsInThisChunk = width * thisChunkHeight;
  55099. }
  55100. destPos = 0;
  55101. for (j = elemsInThisChunk; j--;) {
  55102. dest[destPos++] = src[srcPos++];
  55103. dest[destPos++] = src[srcPos++];
  55104. dest[destPos++] = src[srcPos++];
  55105. dest[destPos++] = 255;
  55106. }
  55107. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55108. }
  55109. } else {
  55110. error('bad image kind: ' + imgData.kind);
  55111. }
  55112. }
  55113. function putBinaryImageMask(ctx, imgData) {
  55114. var height = imgData.height, width = imgData.width;
  55115. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  55116. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  55117. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  55118. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  55119. var srcPos = 0;
  55120. var src = imgData.data;
  55121. var dest = chunkImgData.data;
  55122. for (var i = 0; i < totalChunks; i++) {
  55123. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  55124. var destPos = 3;
  55125. for (var j = 0; j < thisChunkHeight; j++) {
  55126. var mask = 0;
  55127. for (var k = 0; k < width; k++) {
  55128. if (!mask) {
  55129. var elem = src[srcPos++];
  55130. mask = 128;
  55131. }
  55132. dest[destPos] = elem & mask ? 0 : 255;
  55133. destPos += 4;
  55134. mask >>= 1;
  55135. }
  55136. }
  55137. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55138. }
  55139. }
  55140. function copyCtxState(sourceCtx, destCtx) {
  55141. var properties = [
  55142. 'strokeStyle',
  55143. 'fillStyle',
  55144. 'fillRule',
  55145. 'globalAlpha',
  55146. 'lineWidth',
  55147. 'lineCap',
  55148. 'lineJoin',
  55149. 'miterLimit',
  55150. 'globalCompositeOperation',
  55151. 'font'
  55152. ];
  55153. for (var i = 0, ii = properties.length; i < ii; i++) {
  55154. var property = properties[i];
  55155. if (sourceCtx[property] !== undefined) {
  55156. destCtx[property] = sourceCtx[property];
  55157. }
  55158. }
  55159. if (sourceCtx.setLineDash !== undefined) {
  55160. destCtx.setLineDash(sourceCtx.getLineDash());
  55161. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  55162. }
  55163. }
  55164. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  55165. var length = bytes.length;
  55166. for (var i = 3; i < length; i += 4) {
  55167. var alpha = bytes[i];
  55168. if (alpha === 0) {
  55169. bytes[i - 3] = r0;
  55170. bytes[i - 2] = g0;
  55171. bytes[i - 1] = b0;
  55172. } else if (alpha < 255) {
  55173. var alpha_ = 255 - alpha;
  55174. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  55175. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  55176. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  55177. }
  55178. }
  55179. }
  55180. function composeSMaskAlpha(maskData, layerData, transferMap) {
  55181. var length = maskData.length;
  55182. var scale = 1 / 255;
  55183. for (var i = 3; i < length; i += 4) {
  55184. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  55185. layerData[i] = layerData[i] * alpha * scale | 0;
  55186. }
  55187. }
  55188. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  55189. var length = maskData.length;
  55190. for (var i = 3; i < length; i += 4) {
  55191. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  55192. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  55193. }
  55194. }
  55195. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  55196. var hasBackdrop = !!backdrop;
  55197. var r0 = hasBackdrop ? backdrop[0] : 0;
  55198. var g0 = hasBackdrop ? backdrop[1] : 0;
  55199. var b0 = hasBackdrop ? backdrop[2] : 0;
  55200. var composeFn;
  55201. if (subtype === 'Luminosity') {
  55202. composeFn = composeSMaskLuminosity;
  55203. } else {
  55204. composeFn = composeSMaskAlpha;
  55205. }
  55206. var PIXELS_TO_PROCESS = 1048576;
  55207. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  55208. for (var row = 0; row < height; row += chunkSize) {
  55209. var chunkHeight = Math.min(chunkSize, height - row);
  55210. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  55211. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  55212. if (hasBackdrop) {
  55213. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  55214. }
  55215. composeFn(maskData.data, layerData.data, transferMap);
  55216. maskCtx.putImageData(layerData, 0, row);
  55217. }
  55218. }
  55219. function composeSMask(ctx, smask, layerCtx) {
  55220. var mask = smask.canvas;
  55221. var maskCtx = smask.context;
  55222. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  55223. var backdrop = smask.backdrop || null;
  55224. if (!smask.transferMap && WebGLUtils.isEnabled) {
  55225. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  55226. subtype: smask.subtype,
  55227. backdrop: backdrop
  55228. });
  55229. ctx.setTransform(1, 0, 0, 1, 0, 0);
  55230. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  55231. return;
  55232. }
  55233. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  55234. ctx.drawImage(mask, 0, 0);
  55235. }
  55236. var LINE_CAP_STYLES = [
  55237. 'butt',
  55238. 'round',
  55239. 'square'
  55240. ];
  55241. var LINE_JOIN_STYLES = [
  55242. 'miter',
  55243. 'round',
  55244. 'bevel'
  55245. ];
  55246. var NORMAL_CLIP = {};
  55247. var EO_CLIP = {};
  55248. CanvasGraphics.prototype = {
  55249. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  55250. var width = this.ctx.canvas.width;
  55251. var height = this.ctx.canvas.height;
  55252. this.ctx.save();
  55253. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  55254. this.ctx.fillRect(0, 0, width, height);
  55255. this.ctx.restore();
  55256. if (transparency) {
  55257. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  55258. this.compositeCtx = this.ctx;
  55259. this.transparentCanvas = transparentCanvas.canvas;
  55260. this.ctx = transparentCanvas.context;
  55261. this.ctx.save();
  55262. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  55263. }
  55264. this.ctx.save();
  55265. if (transform) {
  55266. this.ctx.transform.apply(this.ctx, transform);
  55267. }
  55268. this.ctx.transform.apply(this.ctx, viewport.transform);
  55269. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  55270. if (this.imageLayer) {
  55271. this.imageLayer.beginLayout();
  55272. }
  55273. },
  55274. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  55275. var argsArray = operatorList.argsArray;
  55276. var fnArray = operatorList.fnArray;
  55277. var i = executionStartIdx || 0;
  55278. var argsArrayLen = argsArray.length;
  55279. if (argsArrayLen === i) {
  55280. return i;
  55281. }
  55282. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  55283. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  55284. var steps = 0;
  55285. var commonObjs = this.commonObjs;
  55286. var objs = this.objs;
  55287. var fnId;
  55288. while (true) {
  55289. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  55290. stepper.breakIt(i, continueCallback);
  55291. return i;
  55292. }
  55293. fnId = fnArray[i];
  55294. if (fnId !== OPS.dependency) {
  55295. this[fnId].apply(this, argsArray[i]);
  55296. } else {
  55297. var deps = argsArray[i];
  55298. for (var n = 0, nn = deps.length; n < nn; n++) {
  55299. var depObjId = deps[n];
  55300. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  55301. var objsPool = common ? commonObjs : objs;
  55302. if (!objsPool.isResolved(depObjId)) {
  55303. objsPool.get(depObjId, continueCallback);
  55304. return i;
  55305. }
  55306. }
  55307. }
  55308. i++;
  55309. if (i === argsArrayLen) {
  55310. return i;
  55311. }
  55312. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  55313. if (Date.now() > endTime) {
  55314. continueCallback();
  55315. return i;
  55316. }
  55317. steps = 0;
  55318. }
  55319. }
  55320. },
  55321. endDrawing: function CanvasGraphics_endDrawing() {
  55322. if (this.current.activeSMask !== null) {
  55323. this.endSMaskGroup();
  55324. }
  55325. this.ctx.restore();
  55326. if (this.transparentCanvas) {
  55327. this.ctx = this.compositeCtx;
  55328. this.ctx.save();
  55329. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  55330. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  55331. this.ctx.restore();
  55332. this.transparentCanvas = null;
  55333. }
  55334. this.cachedCanvases.clear();
  55335. WebGLUtils.clear();
  55336. if (this.imageLayer) {
  55337. this.imageLayer.endLayout();
  55338. }
  55339. },
  55340. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  55341. this.current.lineWidth = width;
  55342. this.ctx.lineWidth = width;
  55343. },
  55344. setLineCap: function CanvasGraphics_setLineCap(style) {
  55345. this.ctx.lineCap = LINE_CAP_STYLES[style];
  55346. },
  55347. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  55348. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  55349. },
  55350. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  55351. this.ctx.miterLimit = limit;
  55352. },
  55353. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  55354. var ctx = this.ctx;
  55355. if (ctx.setLineDash !== undefined) {
  55356. ctx.setLineDash(dashArray);
  55357. ctx.lineDashOffset = dashPhase;
  55358. }
  55359. },
  55360. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  55361. },
  55362. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  55363. },
  55364. setGState: function CanvasGraphics_setGState(states) {
  55365. for (var i = 0, ii = states.length; i < ii; i++) {
  55366. var state = states[i];
  55367. var key = state[0];
  55368. var value = state[1];
  55369. switch (key) {
  55370. case 'LW':
  55371. this.setLineWidth(value);
  55372. break;
  55373. case 'LC':
  55374. this.setLineCap(value);
  55375. break;
  55376. case 'LJ':
  55377. this.setLineJoin(value);
  55378. break;
  55379. case 'ML':
  55380. this.setMiterLimit(value);
  55381. break;
  55382. case 'D':
  55383. this.setDash(value[0], value[1]);
  55384. break;
  55385. case 'RI':
  55386. this.setRenderingIntent(value);
  55387. break;
  55388. case 'FL':
  55389. this.setFlatness(value);
  55390. break;
  55391. case 'Font':
  55392. this.setFont(value[0], value[1]);
  55393. break;
  55394. case 'CA':
  55395. this.current.strokeAlpha = state[1];
  55396. break;
  55397. case 'ca':
  55398. this.current.fillAlpha = state[1];
  55399. this.ctx.globalAlpha = state[1];
  55400. break;
  55401. case 'BM':
  55402. if (value && value.name && value.name !== 'Normal') {
  55403. var mode = value.name.replace(/([A-Z])/g, function (c) {
  55404. return '-' + c.toLowerCase();
  55405. }).substring(1);
  55406. this.ctx.globalCompositeOperation = mode;
  55407. if (this.ctx.globalCompositeOperation !== mode) {
  55408. warn('globalCompositeOperation "' + mode + '" is not supported');
  55409. }
  55410. } else {
  55411. this.ctx.globalCompositeOperation = 'source-over';
  55412. }
  55413. break;
  55414. case 'SMask':
  55415. if (this.current.activeSMask) {
  55416. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  55417. this.suspendSMaskGroup();
  55418. } else {
  55419. this.endSMaskGroup();
  55420. }
  55421. }
  55422. this.current.activeSMask = value ? this.tempSMask : null;
  55423. if (this.current.activeSMask) {
  55424. this.beginSMaskGroup();
  55425. }
  55426. this.tempSMask = null;
  55427. break;
  55428. }
  55429. }
  55430. },
  55431. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  55432. var activeSMask = this.current.activeSMask;
  55433. var drawnWidth = activeSMask.canvas.width;
  55434. var drawnHeight = activeSMask.canvas.height;
  55435. var cacheId = 'smaskGroupAt' + this.groupLevel;
  55436. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  55437. var currentCtx = this.ctx;
  55438. var currentTransform = currentCtx.mozCurrentTransform;
  55439. this.ctx.save();
  55440. var groupCtx = scratchCanvas.context;
  55441. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  55442. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  55443. groupCtx.transform.apply(groupCtx, currentTransform);
  55444. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  55445. copyCtxState(currentCtx, groupCtx);
  55446. this.ctx = groupCtx;
  55447. this.setGState([
  55448. [
  55449. 'BM',
  55450. 'Normal'
  55451. ],
  55452. [
  55453. 'ca',
  55454. 1
  55455. ],
  55456. [
  55457. 'CA',
  55458. 1
  55459. ]
  55460. ]);
  55461. this.groupStack.push(currentCtx);
  55462. this.groupLevel++;
  55463. },
  55464. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55465. var groupCtx = this.ctx;
  55466. this.groupLevel--;
  55467. this.ctx = this.groupStack.pop();
  55468. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55469. this.ctx.restore();
  55470. this.ctx.save();
  55471. copyCtxState(groupCtx, this.ctx);
  55472. this.current.resumeSMaskCtx = groupCtx;
  55473. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55474. this.ctx.transform.apply(this.ctx, deltaTransform);
  55475. groupCtx.save();
  55476. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  55477. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  55478. groupCtx.restore();
  55479. },
  55480. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55481. var groupCtx = this.current.resumeSMaskCtx;
  55482. var currentCtx = this.ctx;
  55483. this.ctx = groupCtx;
  55484. this.groupStack.push(currentCtx);
  55485. this.groupLevel++;
  55486. },
  55487. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55488. var groupCtx = this.ctx;
  55489. this.groupLevel--;
  55490. this.ctx = this.groupStack.pop();
  55491. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55492. this.ctx.restore();
  55493. copyCtxState(groupCtx, this.ctx);
  55494. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55495. this.ctx.transform.apply(this.ctx, deltaTransform);
  55496. },
  55497. save: function CanvasGraphics_save() {
  55498. this.ctx.save();
  55499. var old = this.current;
  55500. this.stateStack.push(old);
  55501. this.current = old.clone();
  55502. this.current.resumeSMaskCtx = null;
  55503. },
  55504. restore: function CanvasGraphics_restore() {
  55505. if (this.current.resumeSMaskCtx) {
  55506. this.resumeSMaskGroup();
  55507. }
  55508. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  55509. this.endSMaskGroup();
  55510. }
  55511. if (this.stateStack.length !== 0) {
  55512. this.current = this.stateStack.pop();
  55513. this.ctx.restore();
  55514. this.pendingClip = null;
  55515. this.cachedGetSinglePixelWidth = null;
  55516. }
  55517. },
  55518. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  55519. this.ctx.transform(a, b, c, d, e, f);
  55520. this.cachedGetSinglePixelWidth = null;
  55521. },
  55522. constructPath: function CanvasGraphics_constructPath(ops, args) {
  55523. var ctx = this.ctx;
  55524. var current = this.current;
  55525. var x = current.x, y = current.y;
  55526. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  55527. switch (ops[i] | 0) {
  55528. case OPS.rectangle:
  55529. x = args[j++];
  55530. y = args[j++];
  55531. var width = args[j++];
  55532. var height = args[j++];
  55533. if (width === 0) {
  55534. width = this.getSinglePixelWidth();
  55535. }
  55536. if (height === 0) {
  55537. height = this.getSinglePixelWidth();
  55538. }
  55539. var xw = x + width;
  55540. var yh = y + height;
  55541. this.ctx.moveTo(x, y);
  55542. this.ctx.lineTo(xw, y);
  55543. this.ctx.lineTo(xw, yh);
  55544. this.ctx.lineTo(x, yh);
  55545. this.ctx.lineTo(x, y);
  55546. this.ctx.closePath();
  55547. break;
  55548. case OPS.moveTo:
  55549. x = args[j++];
  55550. y = args[j++];
  55551. ctx.moveTo(x, y);
  55552. break;
  55553. case OPS.lineTo:
  55554. x = args[j++];
  55555. y = args[j++];
  55556. ctx.lineTo(x, y);
  55557. break;
  55558. case OPS.curveTo:
  55559. x = args[j + 4];
  55560. y = args[j + 5];
  55561. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  55562. j += 6;
  55563. break;
  55564. case OPS.curveTo2:
  55565. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  55566. x = args[j + 2];
  55567. y = args[j + 3];
  55568. j += 4;
  55569. break;
  55570. case OPS.curveTo3:
  55571. x = args[j + 2];
  55572. y = args[j + 3];
  55573. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  55574. j += 4;
  55575. break;
  55576. case OPS.closePath:
  55577. ctx.closePath();
  55578. break;
  55579. }
  55580. }
  55581. current.setCurrentPoint(x, y);
  55582. },
  55583. closePath: function CanvasGraphics_closePath() {
  55584. this.ctx.closePath();
  55585. },
  55586. stroke: function CanvasGraphics_stroke(consumePath) {
  55587. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55588. var ctx = this.ctx;
  55589. var strokeColor = this.current.strokeColor;
  55590. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  55591. ctx.globalAlpha = this.current.strokeAlpha;
  55592. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  55593. ctx.save();
  55594. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  55595. ctx.stroke();
  55596. ctx.restore();
  55597. } else {
  55598. ctx.stroke();
  55599. }
  55600. if (consumePath) {
  55601. this.consumePath();
  55602. }
  55603. ctx.globalAlpha = this.current.fillAlpha;
  55604. },
  55605. closeStroke: function CanvasGraphics_closeStroke() {
  55606. this.closePath();
  55607. this.stroke();
  55608. },
  55609. fill: function CanvasGraphics_fill(consumePath) {
  55610. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55611. var ctx = this.ctx;
  55612. var fillColor = this.current.fillColor;
  55613. var isPatternFill = this.current.patternFill;
  55614. var needRestore = false;
  55615. if (isPatternFill) {
  55616. ctx.save();
  55617. if (this.baseTransform) {
  55618. ctx.setTransform.apply(ctx, this.baseTransform);
  55619. }
  55620. ctx.fillStyle = fillColor.getPattern(ctx, this);
  55621. needRestore = true;
  55622. }
  55623. if (this.pendingEOFill) {
  55624. ctx.fill('evenodd');
  55625. this.pendingEOFill = false;
  55626. } else {
  55627. ctx.fill();
  55628. }
  55629. if (needRestore) {
  55630. ctx.restore();
  55631. }
  55632. if (consumePath) {
  55633. this.consumePath();
  55634. }
  55635. },
  55636. eoFill: function CanvasGraphics_eoFill() {
  55637. this.pendingEOFill = true;
  55638. this.fill();
  55639. },
  55640. fillStroke: function CanvasGraphics_fillStroke() {
  55641. this.fill(false);
  55642. this.stroke(false);
  55643. this.consumePath();
  55644. },
  55645. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  55646. this.pendingEOFill = true;
  55647. this.fillStroke();
  55648. },
  55649. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  55650. this.closePath();
  55651. this.fillStroke();
  55652. },
  55653. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  55654. this.pendingEOFill = true;
  55655. this.closePath();
  55656. this.fillStroke();
  55657. },
  55658. endPath: function CanvasGraphics_endPath() {
  55659. this.consumePath();
  55660. },
  55661. clip: function CanvasGraphics_clip() {
  55662. this.pendingClip = NORMAL_CLIP;
  55663. },
  55664. eoClip: function CanvasGraphics_eoClip() {
  55665. this.pendingClip = EO_CLIP;
  55666. },
  55667. beginText: function CanvasGraphics_beginText() {
  55668. this.current.textMatrix = IDENTITY_MATRIX;
  55669. this.current.textMatrixScale = 1;
  55670. this.current.x = this.current.lineX = 0;
  55671. this.current.y = this.current.lineY = 0;
  55672. },
  55673. endText: function CanvasGraphics_endText() {
  55674. var paths = this.pendingTextPaths;
  55675. var ctx = this.ctx;
  55676. if (paths === undefined) {
  55677. ctx.beginPath();
  55678. return;
  55679. }
  55680. ctx.save();
  55681. ctx.beginPath();
  55682. for (var i = 0; i < paths.length; i++) {
  55683. var path = paths[i];
  55684. ctx.setTransform.apply(ctx, path.transform);
  55685. ctx.translate(path.x, path.y);
  55686. path.addToPath(ctx, path.fontSize);
  55687. }
  55688. ctx.restore();
  55689. ctx.clip();
  55690. ctx.beginPath();
  55691. delete this.pendingTextPaths;
  55692. },
  55693. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  55694. this.current.charSpacing = spacing;
  55695. },
  55696. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  55697. this.current.wordSpacing = spacing;
  55698. },
  55699. setHScale: function CanvasGraphics_setHScale(scale) {
  55700. this.current.textHScale = scale / 100;
  55701. },
  55702. setLeading: function CanvasGraphics_setLeading(leading) {
  55703. this.current.leading = -leading;
  55704. },
  55705. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  55706. var fontObj = this.commonObjs.get(fontRefName);
  55707. var current = this.current;
  55708. if (!fontObj) {
  55709. error('Can\'t find font for ' + fontRefName);
  55710. }
  55711. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  55712. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  55713. warn('Invalid font matrix for font ' + fontRefName);
  55714. }
  55715. if (size < 0) {
  55716. size = -size;
  55717. current.fontDirection = -1;
  55718. } else {
  55719. current.fontDirection = 1;
  55720. }
  55721. this.current.font = fontObj;
  55722. this.current.fontSize = size;
  55723. if (fontObj.isType3Font) {
  55724. return;
  55725. }
  55726. var name = fontObj.loadedName || 'sans-serif';
  55727. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  55728. var italic = fontObj.italic ? 'italic' : 'normal';
  55729. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  55730. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  55731. this.current.fontSizeScale = size / browserFontSize;
  55732. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  55733. this.ctx.font = rule;
  55734. },
  55735. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  55736. this.current.textRenderingMode = mode;
  55737. },
  55738. setTextRise: function CanvasGraphics_setTextRise(rise) {
  55739. this.current.textRise = rise;
  55740. },
  55741. moveText: function CanvasGraphics_moveText(x, y) {
  55742. this.current.x = this.current.lineX += x;
  55743. this.current.y = this.current.lineY += y;
  55744. },
  55745. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  55746. this.setLeading(-y);
  55747. this.moveText(x, y);
  55748. },
  55749. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  55750. this.current.textMatrix = [
  55751. a,
  55752. b,
  55753. c,
  55754. d,
  55755. e,
  55756. f
  55757. ];
  55758. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  55759. this.current.x = this.current.lineX = 0;
  55760. this.current.y = this.current.lineY = 0;
  55761. },
  55762. nextLine: function CanvasGraphics_nextLine() {
  55763. this.moveText(0, this.current.leading);
  55764. },
  55765. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  55766. var ctx = this.ctx;
  55767. var current = this.current;
  55768. var font = current.font;
  55769. var textRenderingMode = current.textRenderingMode;
  55770. var fontSize = current.fontSize / current.fontSizeScale;
  55771. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55772. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  55773. var addToPath;
  55774. if (font.disableFontFace || isAddToPathSet) {
  55775. addToPath = font.getPathGenerator(this.commonObjs, character);
  55776. }
  55777. if (font.disableFontFace) {
  55778. ctx.save();
  55779. ctx.translate(x, y);
  55780. ctx.beginPath();
  55781. addToPath(ctx, fontSize);
  55782. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55783. ctx.fill();
  55784. }
  55785. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55786. ctx.stroke();
  55787. }
  55788. ctx.restore();
  55789. } else {
  55790. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55791. ctx.fillText(character, x, y);
  55792. }
  55793. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55794. ctx.strokeText(character, x, y);
  55795. }
  55796. }
  55797. if (isAddToPathSet) {
  55798. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  55799. paths.push({
  55800. transform: ctx.mozCurrentTransform,
  55801. x: x,
  55802. y: y,
  55803. fontSize: fontSize,
  55804. addToPath: addToPath
  55805. });
  55806. }
  55807. },
  55808. get isFontSubpixelAAEnabled() {
  55809. var ctx = this.canvasFactory.create(10, 10).context;
  55810. ctx.scale(1.5, 1);
  55811. ctx.fillText('I', 0, 10);
  55812. var data = ctx.getImageData(0, 0, 10, 10).data;
  55813. var enabled = false;
  55814. for (var i = 3; i < data.length; i += 4) {
  55815. if (data[i] > 0 && data[i] < 255) {
  55816. enabled = true;
  55817. break;
  55818. }
  55819. }
  55820. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  55821. },
  55822. showText: function CanvasGraphics_showText(glyphs) {
  55823. var current = this.current;
  55824. var font = current.font;
  55825. if (font.isType3Font) {
  55826. return this.showType3Text(glyphs);
  55827. }
  55828. var fontSize = current.fontSize;
  55829. if (fontSize === 0) {
  55830. return;
  55831. }
  55832. var ctx = this.ctx;
  55833. var fontSizeScale = current.fontSizeScale;
  55834. var charSpacing = current.charSpacing;
  55835. var wordSpacing = current.wordSpacing;
  55836. var fontDirection = current.fontDirection;
  55837. var textHScale = current.textHScale * fontDirection;
  55838. var glyphsLength = glyphs.length;
  55839. var vertical = font.vertical;
  55840. var spacingDir = vertical ? 1 : -1;
  55841. var defaultVMetrics = font.defaultVMetrics;
  55842. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  55843. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  55844. ctx.save();
  55845. ctx.transform.apply(ctx, current.textMatrix);
  55846. ctx.translate(current.x, current.y + current.textRise);
  55847. if (current.patternFill) {
  55848. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  55849. }
  55850. if (fontDirection > 0) {
  55851. ctx.scale(textHScale, -1);
  55852. } else {
  55853. ctx.scale(textHScale, 1);
  55854. }
  55855. var lineWidth = current.lineWidth;
  55856. var scale = current.textMatrixScale;
  55857. if (scale === 0 || lineWidth === 0) {
  55858. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55859. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55860. this.cachedGetSinglePixelWidth = null;
  55861. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  55862. }
  55863. } else {
  55864. lineWidth /= scale;
  55865. }
  55866. if (fontSizeScale !== 1.0) {
  55867. ctx.scale(fontSizeScale, fontSizeScale);
  55868. lineWidth /= fontSizeScale;
  55869. }
  55870. ctx.lineWidth = lineWidth;
  55871. var x = 0, i;
  55872. for (i = 0; i < glyphsLength; ++i) {
  55873. var glyph = glyphs[i];
  55874. if (isNum(glyph)) {
  55875. x += spacingDir * glyph * fontSize / 1000;
  55876. continue;
  55877. }
  55878. var restoreNeeded = false;
  55879. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55880. var character = glyph.fontChar;
  55881. var accent = glyph.accent;
  55882. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  55883. var width = glyph.width;
  55884. if (vertical) {
  55885. var vmetric, vx, vy;
  55886. vmetric = glyph.vmetric || defaultVMetrics;
  55887. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  55888. vx = -vx * widthAdvanceScale;
  55889. vy = vmetric[2] * widthAdvanceScale;
  55890. width = vmetric ? -vmetric[0] : width;
  55891. scaledX = vx / fontSizeScale;
  55892. scaledY = (x + vy) / fontSizeScale;
  55893. } else {
  55894. scaledX = x / fontSizeScale;
  55895. scaledY = 0;
  55896. }
  55897. if (font.remeasure && width > 0) {
  55898. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  55899. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  55900. var characterScaleX = width / measuredWidth;
  55901. restoreNeeded = true;
  55902. ctx.save();
  55903. ctx.scale(characterScaleX, 1);
  55904. scaledX /= characterScaleX;
  55905. } else if (width !== measuredWidth) {
  55906. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  55907. }
  55908. }
  55909. if (glyph.isInFont || font.missingFile) {
  55910. if (simpleFillText && !accent) {
  55911. ctx.fillText(character, scaledX, scaledY);
  55912. } else {
  55913. this.paintChar(character, scaledX, scaledY);
  55914. if (accent) {
  55915. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  55916. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  55917. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  55918. }
  55919. }
  55920. }
  55921. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  55922. x += charWidth;
  55923. if (restoreNeeded) {
  55924. ctx.restore();
  55925. }
  55926. }
  55927. if (vertical) {
  55928. current.y -= x * textHScale;
  55929. } else {
  55930. current.x += x * textHScale;
  55931. }
  55932. ctx.restore();
  55933. },
  55934. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  55935. var ctx = this.ctx;
  55936. var current = this.current;
  55937. var font = current.font;
  55938. var fontSize = current.fontSize;
  55939. var fontDirection = current.fontDirection;
  55940. var spacingDir = font.vertical ? 1 : -1;
  55941. var charSpacing = current.charSpacing;
  55942. var wordSpacing = current.wordSpacing;
  55943. var textHScale = current.textHScale * fontDirection;
  55944. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  55945. var glyphsLength = glyphs.length;
  55946. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  55947. var i, glyph, width, spacingLength;
  55948. if (isTextInvisible || fontSize === 0) {
  55949. return;
  55950. }
  55951. this.cachedGetSinglePixelWidth = null;
  55952. ctx.save();
  55953. ctx.transform.apply(ctx, current.textMatrix);
  55954. ctx.translate(current.x, current.y);
  55955. ctx.scale(textHScale, fontDirection);
  55956. for (i = 0; i < glyphsLength; ++i) {
  55957. glyph = glyphs[i];
  55958. if (isNum(glyph)) {
  55959. spacingLength = spacingDir * glyph * fontSize / 1000;
  55960. this.ctx.translate(spacingLength, 0);
  55961. current.x += spacingLength * textHScale;
  55962. continue;
  55963. }
  55964. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55965. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  55966. if (!operatorList) {
  55967. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  55968. continue;
  55969. }
  55970. this.processingType3 = glyph;
  55971. this.save();
  55972. ctx.scale(fontSize, fontSize);
  55973. ctx.transform.apply(ctx, fontMatrix);
  55974. this.executeOperatorList(operatorList);
  55975. this.restore();
  55976. var transformed = Util.applyTransform([
  55977. glyph.width,
  55978. 0
  55979. ], fontMatrix);
  55980. width = transformed[0] * fontSize + spacing;
  55981. ctx.translate(width, 0);
  55982. current.x += width * textHScale;
  55983. }
  55984. ctx.restore();
  55985. this.processingType3 = null;
  55986. },
  55987. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  55988. },
  55989. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  55990. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  55991. this.clip();
  55992. this.endPath();
  55993. },
  55994. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  55995. var pattern;
  55996. if (IR[0] === 'TilingPattern') {
  55997. var color = IR[1];
  55998. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  55999. var self = this;
  56000. var canvasGraphicsFactory = {
  56001. createCanvasGraphics: function (ctx) {
  56002. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  56003. }
  56004. };
  56005. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  56006. } else {
  56007. pattern = getShadingPatternFromIR(IR);
  56008. }
  56009. return pattern;
  56010. },
  56011. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  56012. this.current.strokeColor = this.getColorN_Pattern(arguments);
  56013. },
  56014. setFillColorN: function CanvasGraphics_setFillColorN() {
  56015. this.current.fillColor = this.getColorN_Pattern(arguments);
  56016. this.current.patternFill = true;
  56017. },
  56018. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  56019. var color = Util.makeCssRgb(r, g, b);
  56020. this.ctx.strokeStyle = color;
  56021. this.current.strokeColor = color;
  56022. },
  56023. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  56024. var color = Util.makeCssRgb(r, g, b);
  56025. this.ctx.fillStyle = color;
  56026. this.current.fillColor = color;
  56027. this.current.patternFill = false;
  56028. },
  56029. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  56030. var ctx = this.ctx;
  56031. this.save();
  56032. var pattern = getShadingPatternFromIR(patternIR);
  56033. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  56034. var inv = ctx.mozCurrentTransformInverse;
  56035. if (inv) {
  56036. var canvas = ctx.canvas;
  56037. var width = canvas.width;
  56038. var height = canvas.height;
  56039. var bl = Util.applyTransform([
  56040. 0,
  56041. 0
  56042. ], inv);
  56043. var br = Util.applyTransform([
  56044. 0,
  56045. height
  56046. ], inv);
  56047. var ul = Util.applyTransform([
  56048. width,
  56049. 0
  56050. ], inv);
  56051. var ur = Util.applyTransform([
  56052. width,
  56053. height
  56054. ], inv);
  56055. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  56056. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  56057. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  56058. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  56059. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  56060. } else {
  56061. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  56062. }
  56063. this.restore();
  56064. },
  56065. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  56066. error('Should not call beginInlineImage');
  56067. },
  56068. beginImageData: function CanvasGraphics_beginImageData() {
  56069. error('Should not call beginImageData');
  56070. },
  56071. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  56072. this.save();
  56073. this.baseTransformStack.push(this.baseTransform);
  56074. if (isArray(matrix) && matrix.length === 6) {
  56075. this.transform.apply(this, matrix);
  56076. }
  56077. this.baseTransform = this.ctx.mozCurrentTransform;
  56078. if (isArray(bbox) && bbox.length === 4) {
  56079. var width = bbox[2] - bbox[0];
  56080. var height = bbox[3] - bbox[1];
  56081. this.ctx.rect(bbox[0], bbox[1], width, height);
  56082. this.clip();
  56083. this.endPath();
  56084. }
  56085. },
  56086. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  56087. this.restore();
  56088. this.baseTransform = this.baseTransformStack.pop();
  56089. },
  56090. beginGroup: function CanvasGraphics_beginGroup(group) {
  56091. this.save();
  56092. var currentCtx = this.ctx;
  56093. if (!group.isolated) {
  56094. info('TODO: Support non-isolated groups.');
  56095. }
  56096. if (group.knockout) {
  56097. warn('Knockout groups not supported.');
  56098. }
  56099. var currentTransform = currentCtx.mozCurrentTransform;
  56100. if (group.matrix) {
  56101. currentCtx.transform.apply(currentCtx, group.matrix);
  56102. }
  56103. assert(group.bbox, 'Bounding box is required.');
  56104. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  56105. var canvasBounds = [
  56106. 0,
  56107. 0,
  56108. currentCtx.canvas.width,
  56109. currentCtx.canvas.height
  56110. ];
  56111. bounds = Util.intersect(bounds, canvasBounds) || [
  56112. 0,
  56113. 0,
  56114. 0,
  56115. 0
  56116. ];
  56117. var offsetX = Math.floor(bounds[0]);
  56118. var offsetY = Math.floor(bounds[1]);
  56119. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  56120. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  56121. var scaleX = 1, scaleY = 1;
  56122. if (drawnWidth > MAX_GROUP_SIZE) {
  56123. scaleX = drawnWidth / MAX_GROUP_SIZE;
  56124. drawnWidth = MAX_GROUP_SIZE;
  56125. }
  56126. if (drawnHeight > MAX_GROUP_SIZE) {
  56127. scaleY = drawnHeight / MAX_GROUP_SIZE;
  56128. drawnHeight = MAX_GROUP_SIZE;
  56129. }
  56130. var cacheId = 'groupAt' + this.groupLevel;
  56131. if (group.smask) {
  56132. cacheId += '_smask_' + this.smaskCounter++ % 2;
  56133. }
  56134. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  56135. var groupCtx = scratchCanvas.context;
  56136. groupCtx.scale(1 / scaleX, 1 / scaleY);
  56137. groupCtx.translate(-offsetX, -offsetY);
  56138. groupCtx.transform.apply(groupCtx, currentTransform);
  56139. if (group.smask) {
  56140. this.smaskStack.push({
  56141. canvas: scratchCanvas.canvas,
  56142. context: groupCtx,
  56143. offsetX: offsetX,
  56144. offsetY: offsetY,
  56145. scaleX: scaleX,
  56146. scaleY: scaleY,
  56147. subtype: group.smask.subtype,
  56148. backdrop: group.smask.backdrop,
  56149. transferMap: group.smask.transferMap || null,
  56150. startTransformInverse: null
  56151. });
  56152. } else {
  56153. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  56154. currentCtx.translate(offsetX, offsetY);
  56155. currentCtx.scale(scaleX, scaleY);
  56156. }
  56157. copyCtxState(currentCtx, groupCtx);
  56158. this.ctx = groupCtx;
  56159. this.setGState([
  56160. [
  56161. 'BM',
  56162. 'Normal'
  56163. ],
  56164. [
  56165. 'ca',
  56166. 1
  56167. ],
  56168. [
  56169. 'CA',
  56170. 1
  56171. ]
  56172. ]);
  56173. this.groupStack.push(currentCtx);
  56174. this.groupLevel++;
  56175. this.current.activeSMask = null;
  56176. },
  56177. endGroup: function CanvasGraphics_endGroup(group) {
  56178. this.groupLevel--;
  56179. var groupCtx = this.ctx;
  56180. this.ctx = this.groupStack.pop();
  56181. if (this.ctx.imageSmoothingEnabled !== undefined) {
  56182. this.ctx.imageSmoothingEnabled = false;
  56183. } else {
  56184. this.ctx.mozImageSmoothingEnabled = false;
  56185. }
  56186. if (group.smask) {
  56187. this.tempSMask = this.smaskStack.pop();
  56188. } else {
  56189. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  56190. }
  56191. this.restore();
  56192. },
  56193. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  56194. this.save();
  56195. this.current = new CanvasExtraState();
  56196. if (this.baseTransform) {
  56197. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  56198. }
  56199. },
  56200. endAnnotations: function CanvasGraphics_endAnnotations() {
  56201. this.restore();
  56202. },
  56203. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  56204. this.save();
  56205. if (isArray(rect) && rect.length === 4) {
  56206. var width = rect[2] - rect[0];
  56207. var height = rect[3] - rect[1];
  56208. this.ctx.rect(rect[0], rect[1], width, height);
  56209. this.clip();
  56210. this.endPath();
  56211. }
  56212. this.transform.apply(this, transform);
  56213. this.transform.apply(this, matrix);
  56214. },
  56215. endAnnotation: function CanvasGraphics_endAnnotation() {
  56216. this.restore();
  56217. },
  56218. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  56219. var domImage = this.objs.get(objId);
  56220. if (!domImage) {
  56221. warn('Dependent image isn\'t ready yet');
  56222. return;
  56223. }
  56224. this.save();
  56225. var ctx = this.ctx;
  56226. ctx.scale(1 / w, -1 / h);
  56227. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  56228. if (this.imageLayer) {
  56229. var currentTransform = ctx.mozCurrentTransformInverse;
  56230. var position = this.getCanvasPosition(0, 0);
  56231. this.imageLayer.appendImage({
  56232. objId: objId,
  56233. left: position[0],
  56234. top: position[1],
  56235. width: w / currentTransform[0],
  56236. height: h / currentTransform[3]
  56237. });
  56238. }
  56239. this.restore();
  56240. },
  56241. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  56242. var ctx = this.ctx;
  56243. var width = img.width, height = img.height;
  56244. var fillColor = this.current.fillColor;
  56245. var isPatternFill = this.current.patternFill;
  56246. var glyph = this.processingType3;
  56247. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  56248. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  56249. glyph.compiled = compileType3Glyph({
  56250. data: img.data,
  56251. width: width,
  56252. height: height
  56253. });
  56254. } else {
  56255. glyph.compiled = null;
  56256. }
  56257. }
  56258. if (glyph && glyph.compiled) {
  56259. glyph.compiled(ctx);
  56260. return;
  56261. }
  56262. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56263. var maskCtx = maskCanvas.context;
  56264. maskCtx.save();
  56265. putBinaryImageMask(maskCtx, img);
  56266. maskCtx.globalCompositeOperation = 'source-in';
  56267. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56268. maskCtx.fillRect(0, 0, width, height);
  56269. maskCtx.restore();
  56270. this.paintInlineImageXObject(maskCanvas.canvas);
  56271. },
  56272. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  56273. var width = imgData.width;
  56274. var height = imgData.height;
  56275. var fillColor = this.current.fillColor;
  56276. var isPatternFill = this.current.patternFill;
  56277. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56278. var maskCtx = maskCanvas.context;
  56279. maskCtx.save();
  56280. putBinaryImageMask(maskCtx, imgData);
  56281. maskCtx.globalCompositeOperation = 'source-in';
  56282. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56283. maskCtx.fillRect(0, 0, width, height);
  56284. maskCtx.restore();
  56285. var ctx = this.ctx;
  56286. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56287. ctx.save();
  56288. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  56289. ctx.scale(1, -1);
  56290. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56291. ctx.restore();
  56292. }
  56293. },
  56294. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  56295. var ctx = this.ctx;
  56296. var fillColor = this.current.fillColor;
  56297. var isPatternFill = this.current.patternFill;
  56298. for (var i = 0, ii = images.length; i < ii; i++) {
  56299. var image = images[i];
  56300. var width = image.width, height = image.height;
  56301. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56302. var maskCtx = maskCanvas.context;
  56303. maskCtx.save();
  56304. putBinaryImageMask(maskCtx, image);
  56305. maskCtx.globalCompositeOperation = 'source-in';
  56306. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56307. maskCtx.fillRect(0, 0, width, height);
  56308. maskCtx.restore();
  56309. ctx.save();
  56310. ctx.transform.apply(ctx, image.transform);
  56311. ctx.scale(1, -1);
  56312. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56313. ctx.restore();
  56314. }
  56315. },
  56316. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  56317. var imgData = this.objs.get(objId);
  56318. if (!imgData) {
  56319. warn('Dependent image isn\'t ready yet');
  56320. return;
  56321. }
  56322. this.paintInlineImageXObject(imgData);
  56323. },
  56324. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  56325. var imgData = this.objs.get(objId);
  56326. if (!imgData) {
  56327. warn('Dependent image isn\'t ready yet');
  56328. return;
  56329. }
  56330. var width = imgData.width;
  56331. var height = imgData.height;
  56332. var map = [];
  56333. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56334. map.push({
  56335. transform: [
  56336. scaleX,
  56337. 0,
  56338. 0,
  56339. scaleY,
  56340. positions[i],
  56341. positions[i + 1]
  56342. ],
  56343. x: 0,
  56344. y: 0,
  56345. w: width,
  56346. h: height
  56347. });
  56348. }
  56349. this.paintInlineImageXObjectGroup(imgData, map);
  56350. },
  56351. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  56352. var width = imgData.width;
  56353. var height = imgData.height;
  56354. var ctx = this.ctx;
  56355. this.save();
  56356. ctx.scale(1 / width, -1 / height);
  56357. var currentTransform = ctx.mozCurrentTransformInverse;
  56358. var a = currentTransform[0], b = currentTransform[1];
  56359. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  56360. var c = currentTransform[2], d = currentTransform[3];
  56361. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  56362. var imgToPaint, tmpCanvas;
  56363. if (imgData instanceof HTMLElement || !imgData.data) {
  56364. imgToPaint = imgData;
  56365. } else {
  56366. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  56367. var tmpCtx = tmpCanvas.context;
  56368. putBinaryImageData(tmpCtx, imgData);
  56369. imgToPaint = tmpCanvas.canvas;
  56370. }
  56371. var paintWidth = width, paintHeight = height;
  56372. var tmpCanvasId = 'prescale1';
  56373. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  56374. var newWidth = paintWidth, newHeight = paintHeight;
  56375. if (widthScale > 2 && paintWidth > 1) {
  56376. newWidth = Math.ceil(paintWidth / 2);
  56377. widthScale /= paintWidth / newWidth;
  56378. }
  56379. if (heightScale > 2 && paintHeight > 1) {
  56380. newHeight = Math.ceil(paintHeight / 2);
  56381. heightScale /= paintHeight / newHeight;
  56382. }
  56383. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  56384. tmpCtx = tmpCanvas.context;
  56385. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  56386. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  56387. imgToPaint = tmpCanvas.canvas;
  56388. paintWidth = newWidth;
  56389. paintHeight = newHeight;
  56390. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  56391. }
  56392. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  56393. if (this.imageLayer) {
  56394. var position = this.getCanvasPosition(0, -height);
  56395. this.imageLayer.appendImage({
  56396. imgData: imgData,
  56397. left: position[0],
  56398. top: position[1],
  56399. width: width / currentTransform[0],
  56400. height: height / currentTransform[3]
  56401. });
  56402. }
  56403. this.restore();
  56404. },
  56405. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  56406. var ctx = this.ctx;
  56407. var w = imgData.width;
  56408. var h = imgData.height;
  56409. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  56410. var tmpCtx = tmpCanvas.context;
  56411. putBinaryImageData(tmpCtx, imgData);
  56412. for (var i = 0, ii = map.length; i < ii; i++) {
  56413. var entry = map[i];
  56414. ctx.save();
  56415. ctx.transform.apply(ctx, entry.transform);
  56416. ctx.scale(1, -1);
  56417. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  56418. if (this.imageLayer) {
  56419. var position = this.getCanvasPosition(entry.x, entry.y);
  56420. this.imageLayer.appendImage({
  56421. imgData: imgData,
  56422. left: position[0],
  56423. top: position[1],
  56424. width: w,
  56425. height: h
  56426. });
  56427. }
  56428. ctx.restore();
  56429. }
  56430. },
  56431. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  56432. this.ctx.fillRect(0, 0, 1, 1);
  56433. },
  56434. paintXObject: function CanvasGraphics_paintXObject() {
  56435. warn('Unsupported \'paintXObject\' command.');
  56436. },
  56437. markPoint: function CanvasGraphics_markPoint(tag) {
  56438. },
  56439. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  56440. },
  56441. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  56442. },
  56443. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  56444. },
  56445. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  56446. },
  56447. beginCompat: function CanvasGraphics_beginCompat() {
  56448. },
  56449. endCompat: function CanvasGraphics_endCompat() {
  56450. },
  56451. consumePath: function CanvasGraphics_consumePath() {
  56452. var ctx = this.ctx;
  56453. if (this.pendingClip) {
  56454. if (this.pendingClip === EO_CLIP) {
  56455. ctx.clip('evenodd');
  56456. } else {
  56457. ctx.clip();
  56458. }
  56459. this.pendingClip = null;
  56460. }
  56461. ctx.beginPath();
  56462. },
  56463. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  56464. if (this.cachedGetSinglePixelWidth === null) {
  56465. this.ctx.save();
  56466. var inverse = this.ctx.mozCurrentTransformInverse;
  56467. this.ctx.restore();
  56468. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  56469. }
  56470. return this.cachedGetSinglePixelWidth;
  56471. },
  56472. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  56473. var transform = this.ctx.mozCurrentTransform;
  56474. return [
  56475. transform[0] * x + transform[2] * y + transform[4],
  56476. transform[1] * x + transform[3] * y + transform[5]
  56477. ];
  56478. }
  56479. };
  56480. for (var op in OPS) {
  56481. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  56482. }
  56483. return CanvasGraphics;
  56484. }();
  56485. exports.CanvasGraphics = CanvasGraphics;
  56486. /***/ }),
  56487. /* 45 */
  56488. /***/ (function(module, exports, __w_pdfjs_require__) {
  56489. "use strict";
  56490. var sharedUtil = __w_pdfjs_require__(0);
  56491. var assert = sharedUtil.assert;
  56492. var bytesToString = sharedUtil.bytesToString;
  56493. var string32 = sharedUtil.string32;
  56494. var shadow = sharedUtil.shadow;
  56495. var warn = sharedUtil.warn;
  56496. function FontLoader(docId) {
  56497. this.docId = docId;
  56498. this.styleElement = null;
  56499. this.nativeFontFaces = [];
  56500. this.loadTestFontId = 0;
  56501. this.loadingContext = {
  56502. requests: [],
  56503. nextRequestId: 0
  56504. };
  56505. }
  56506. FontLoader.prototype = {
  56507. insertRule: function fontLoaderInsertRule(rule) {
  56508. var styleElement = this.styleElement;
  56509. if (!styleElement) {
  56510. styleElement = this.styleElement = document.createElement('style');
  56511. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  56512. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  56513. }
  56514. var styleSheet = styleElement.sheet;
  56515. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  56516. },
  56517. clear: function fontLoaderClear() {
  56518. if (this.styleElement) {
  56519. this.styleElement.remove();
  56520. this.styleElement = null;
  56521. }
  56522. this.nativeFontFaces.forEach(function (nativeFontFace) {
  56523. document.fonts.delete(nativeFontFace);
  56524. });
  56525. this.nativeFontFaces.length = 0;
  56526. }
  56527. };
  56528. var getLoadTestFont = function () {
  56529. return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQ' + 'AABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwA' + 'AAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbm' + 'FtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAA' + 'AADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6A' + 'ABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAA' + 'MQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAA' + 'AAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAA' + 'AAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQ' + 'AAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMA' + 'AQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAA' + 'EAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAA' + 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAA' + 'AAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgc' + 'A/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWF' + 'hYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQA' + 'AAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAg' + 'ABAAAAAAAAAAAD6AAAAAAAAA==');
  56530. };
  56531. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  56532. get: function () {
  56533. return shadow(this, 'loadTestFont', getLoadTestFont());
  56534. },
  56535. configurable: true
  56536. });
  56537. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  56538. this.nativeFontFaces.push(nativeFontFace);
  56539. document.fonts.add(nativeFontFace);
  56540. };
  56541. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  56542. var rules = [];
  56543. var fontsToLoad = [];
  56544. var fontLoadPromises = [];
  56545. var getNativeFontPromise = function (nativeFontFace) {
  56546. return nativeFontFace.loaded.catch(function (e) {
  56547. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  56548. });
  56549. };
  56550. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  56551. for (var i = 0, ii = fonts.length; i < ii; i++) {
  56552. var font = fonts[i];
  56553. if (font.attached || font.loading === false) {
  56554. continue;
  56555. }
  56556. font.attached = true;
  56557. if (isFontLoadingAPISupported) {
  56558. var nativeFontFace = font.createNativeFontFace();
  56559. if (nativeFontFace) {
  56560. this.addNativeFontFace(nativeFontFace);
  56561. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  56562. }
  56563. } else {
  56564. var rule = font.createFontFaceRule();
  56565. if (rule) {
  56566. this.insertRule(rule);
  56567. rules.push(rule);
  56568. fontsToLoad.push(font);
  56569. }
  56570. }
  56571. }
  56572. var request = this.queueLoadingCallback(callback);
  56573. if (isFontLoadingAPISupported) {
  56574. Promise.all(fontLoadPromises).then(function () {
  56575. request.complete();
  56576. });
  56577. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  56578. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  56579. } else {
  56580. request.complete();
  56581. }
  56582. };
  56583. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  56584. function LoadLoader_completeRequest() {
  56585. assert(!request.end, 'completeRequest() cannot be called twice');
  56586. request.end = Date.now();
  56587. while (context.requests.length > 0 && context.requests[0].end) {
  56588. var otherRequest = context.requests.shift();
  56589. setTimeout(otherRequest.callback, 0);
  56590. }
  56591. }
  56592. var context = this.loadingContext;
  56593. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  56594. var request = {
  56595. id: requestId,
  56596. complete: LoadLoader_completeRequest,
  56597. callback: callback,
  56598. started: Date.now()
  56599. };
  56600. context.requests.push(request);
  56601. return request;
  56602. };
  56603. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  56604. function int32(data, offset) {
  56605. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  56606. }
  56607. function spliceString(s, offset, remove, insert) {
  56608. var chunk1 = s.substr(0, offset);
  56609. var chunk2 = s.substr(offset + remove);
  56610. return chunk1 + insert + chunk2;
  56611. }
  56612. var i, ii;
  56613. var canvas = document.createElement('canvas');
  56614. canvas.width = 1;
  56615. canvas.height = 1;
  56616. var ctx = canvas.getContext('2d');
  56617. var called = 0;
  56618. function isFontReady(name, callback) {
  56619. called++;
  56620. if (called > 30) {
  56621. warn('Load test font never loaded.');
  56622. callback();
  56623. return;
  56624. }
  56625. ctx.font = '30px ' + name;
  56626. ctx.fillText('.', 0, 20);
  56627. var imageData = ctx.getImageData(0, 0, 1, 1);
  56628. if (imageData.data[3] > 0) {
  56629. callback();
  56630. return;
  56631. }
  56632. setTimeout(isFontReady.bind(null, name, callback));
  56633. }
  56634. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  56635. var data = this.loadTestFont;
  56636. var COMMENT_OFFSET = 976;
  56637. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  56638. var CFF_CHECKSUM_OFFSET = 16;
  56639. var XXXX_VALUE = 0x58585858;
  56640. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  56641. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  56642. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  56643. }
  56644. if (i < loadTestFontId.length) {
  56645. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  56646. }
  56647. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  56648. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  56649. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  56650. this.insertRule(rule);
  56651. var names = [];
  56652. for (i = 0, ii = fonts.length; i < ii; i++) {
  56653. names.push(fonts[i].loadedName);
  56654. }
  56655. names.push(loadTestFontId);
  56656. var div = document.createElement('div');
  56657. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  56658. for (i = 0, ii = names.length; i < ii; ++i) {
  56659. var span = document.createElement('span');
  56660. span.textContent = 'Hi';
  56661. span.style.fontFamily = names[i];
  56662. div.appendChild(span);
  56663. }
  56664. document.body.appendChild(div);
  56665. isFontReady(loadTestFontId, function () {
  56666. document.body.removeChild(div);
  56667. request.complete();
  56668. });
  56669. };
  56670. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  56671. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  56672. if (typeof navigator === 'undefined') {
  56673. return true;
  56674. }
  56675. var supported = false;
  56676. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  56677. if (m && m[1] >= 14) {
  56678. supported = true;
  56679. }
  56680. return supported;
  56681. };
  56682. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  56683. get: function () {
  56684. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  56685. },
  56686. enumerable: true,
  56687. configurable: true
  56688. });
  56689. var IsEvalSupportedCached = {
  56690. get value() {
  56691. return shadow(this, 'value', sharedUtil.isEvalSupported());
  56692. }
  56693. };
  56694. var FontFaceObject = function FontFaceObjectClosure() {
  56695. function FontFaceObject(translatedData, options) {
  56696. this.compiledGlyphs = Object.create(null);
  56697. for (var i in translatedData) {
  56698. this[i] = translatedData[i];
  56699. }
  56700. this.options = options;
  56701. }
  56702. FontFaceObject.prototype = {
  56703. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  56704. if (!this.data) {
  56705. return null;
  56706. }
  56707. if (this.options.disableFontFace) {
  56708. this.disableFontFace = true;
  56709. return null;
  56710. }
  56711. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  56712. if (this.options.fontRegistry) {
  56713. this.options.fontRegistry.registerFont(this);
  56714. }
  56715. return nativeFontFace;
  56716. },
  56717. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  56718. if (!this.data) {
  56719. return null;
  56720. }
  56721. if (this.options.disableFontFace) {
  56722. this.disableFontFace = true;
  56723. return null;
  56724. }
  56725. var data = bytesToString(new Uint8Array(this.data));
  56726. var fontName = this.loadedName;
  56727. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  56728. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  56729. if (this.options.fontRegistry) {
  56730. this.options.fontRegistry.registerFont(this, url);
  56731. }
  56732. return rule;
  56733. },
  56734. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  56735. if (!(character in this.compiledGlyphs)) {
  56736. var cmds = objs.get(this.loadedName + '_path_' + character);
  56737. var current, i, len;
  56738. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  56739. var args, js = '';
  56740. for (i = 0, len = cmds.length; i < len; i++) {
  56741. current = cmds[i];
  56742. if (current.args !== undefined) {
  56743. args = current.args.join(',');
  56744. } else {
  56745. args = '';
  56746. }
  56747. js += 'c.' + current.cmd + '(' + args + ');\n';
  56748. }
  56749. this.compiledGlyphs[character] = new Function('c', 'size', js);
  56750. } else {
  56751. this.compiledGlyphs[character] = function (c, size) {
  56752. for (i = 0, len = cmds.length; i < len; i++) {
  56753. current = cmds[i];
  56754. if (current.cmd === 'scale') {
  56755. current.args = [
  56756. size,
  56757. -size
  56758. ];
  56759. }
  56760. c[current.cmd].apply(c, current.args);
  56761. }
  56762. };
  56763. }
  56764. }
  56765. return this.compiledGlyphs[character];
  56766. }
  56767. };
  56768. return FontFaceObject;
  56769. }();
  56770. exports.FontFaceObject = FontFaceObject;
  56771. exports.FontLoader = FontLoader;
  56772. /***/ }),
  56773. /* 46 */
  56774. /***/ (function(module, exports, __w_pdfjs_require__) {
  56775. "use strict";
  56776. var sharedUtil = __w_pdfjs_require__(0);
  56777. var displayWebGL = __w_pdfjs_require__(24);
  56778. var Util = sharedUtil.Util;
  56779. var info = sharedUtil.info;
  56780. var isArray = sharedUtil.isArray;
  56781. var error = sharedUtil.error;
  56782. var WebGLUtils = displayWebGL.WebGLUtils;
  56783. var ShadingIRs = {};
  56784. ShadingIRs.RadialAxial = {
  56785. fromIR: function RadialAxial_fromIR(raw) {
  56786. var type = raw[1];
  56787. var colorStops = raw[2];
  56788. var p0 = raw[3];
  56789. var p1 = raw[4];
  56790. var r0 = raw[5];
  56791. var r1 = raw[6];
  56792. return {
  56793. type: 'Pattern',
  56794. getPattern: function RadialAxial_getPattern(ctx) {
  56795. var grad;
  56796. if (type === 'axial') {
  56797. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  56798. } else if (type === 'radial') {
  56799. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  56800. }
  56801. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  56802. var c = colorStops[i];
  56803. grad.addColorStop(c[0], c[1]);
  56804. }
  56805. return grad;
  56806. }
  56807. };
  56808. }
  56809. };
  56810. var createMeshCanvas = function createMeshCanvasClosure() {
  56811. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  56812. var coords = context.coords, colors = context.colors;
  56813. var bytes = data.data, rowSize = data.width * 4;
  56814. var tmp;
  56815. if (coords[p1 + 1] > coords[p2 + 1]) {
  56816. tmp = p1;
  56817. p1 = p2;
  56818. p2 = tmp;
  56819. tmp = c1;
  56820. c1 = c2;
  56821. c2 = tmp;
  56822. }
  56823. if (coords[p2 + 1] > coords[p3 + 1]) {
  56824. tmp = p2;
  56825. p2 = p3;
  56826. p3 = tmp;
  56827. tmp = c2;
  56828. c2 = c3;
  56829. c3 = tmp;
  56830. }
  56831. if (coords[p1 + 1] > coords[p2 + 1]) {
  56832. tmp = p1;
  56833. p1 = p2;
  56834. p2 = tmp;
  56835. tmp = c1;
  56836. c1 = c2;
  56837. c2 = tmp;
  56838. }
  56839. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  56840. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  56841. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  56842. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  56843. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  56844. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  56845. if (y1 >= y3) {
  56846. return;
  56847. }
  56848. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  56849. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  56850. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  56851. var minY = Math.round(y1), maxY = Math.round(y3);
  56852. var xa, car, cag, cab;
  56853. var xb, cbr, cbg, cbb;
  56854. var k;
  56855. for (var y = minY; y <= maxY; y++) {
  56856. if (y < y2) {
  56857. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  56858. xa = x1 - (x1 - x2) * k;
  56859. car = c1r - (c1r - c2r) * k;
  56860. cag = c1g - (c1g - c2g) * k;
  56861. cab = c1b - (c1b - c2b) * k;
  56862. } else {
  56863. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  56864. xa = x2 - (x2 - x3) * k;
  56865. car = c2r - (c2r - c3r) * k;
  56866. cag = c2g - (c2g - c3g) * k;
  56867. cab = c2b - (c2b - c3b) * k;
  56868. }
  56869. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  56870. xb = x1 - (x1 - x3) * k;
  56871. cbr = c1r - (c1r - c3r) * k;
  56872. cbg = c1g - (c1g - c3g) * k;
  56873. cbb = c1b - (c1b - c3b) * k;
  56874. var x1_ = Math.round(Math.min(xa, xb));
  56875. var x2_ = Math.round(Math.max(xa, xb));
  56876. var j = rowSize * y + x1_ * 4;
  56877. for (var x = x1_; x <= x2_; x++) {
  56878. k = (xa - x) / (xa - xb);
  56879. k = k < 0 ? 0 : k > 1 ? 1 : k;
  56880. bytes[j++] = car - (car - cbr) * k | 0;
  56881. bytes[j++] = cag - (cag - cbg) * k | 0;
  56882. bytes[j++] = cab - (cab - cbb) * k | 0;
  56883. bytes[j++] = 255;
  56884. }
  56885. }
  56886. }
  56887. function drawFigure(data, figure, context) {
  56888. var ps = figure.coords;
  56889. var cs = figure.colors;
  56890. var i, ii;
  56891. switch (figure.type) {
  56892. case 'lattice':
  56893. var verticesPerRow = figure.verticesPerRow;
  56894. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  56895. var cols = verticesPerRow - 1;
  56896. for (i = 0; i < rows; i++) {
  56897. var q = i * verticesPerRow;
  56898. for (var j = 0; j < cols; j++, q++) {
  56899. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  56900. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  56901. }
  56902. }
  56903. break;
  56904. case 'triangles':
  56905. for (i = 0, ii = ps.length; i < ii; i += 3) {
  56906. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  56907. }
  56908. break;
  56909. default:
  56910. error('illigal figure');
  56911. break;
  56912. }
  56913. }
  56914. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  56915. var EXPECTED_SCALE = 1.1;
  56916. var MAX_PATTERN_SIZE = 3000;
  56917. var BORDER_SIZE = 2;
  56918. var offsetX = Math.floor(bounds[0]);
  56919. var offsetY = Math.floor(bounds[1]);
  56920. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  56921. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  56922. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56923. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56924. var scaleX = boundsWidth / width;
  56925. var scaleY = boundsHeight / height;
  56926. var context = {
  56927. coords: coords,
  56928. colors: colors,
  56929. offsetX: -offsetX,
  56930. offsetY: -offsetY,
  56931. scaleX: 1 / scaleX,
  56932. scaleY: 1 / scaleY
  56933. };
  56934. var paddedWidth = width + BORDER_SIZE * 2;
  56935. var paddedHeight = height + BORDER_SIZE * 2;
  56936. var canvas, tmpCanvas, i, ii;
  56937. if (WebGLUtils.isEnabled) {
  56938. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  56939. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56940. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  56941. canvas = tmpCanvas.canvas;
  56942. } else {
  56943. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56944. var tmpCtx = tmpCanvas.context;
  56945. var data = tmpCtx.createImageData(width, height);
  56946. if (backgroundColor) {
  56947. var bytes = data.data;
  56948. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  56949. bytes[i] = backgroundColor[0];
  56950. bytes[i + 1] = backgroundColor[1];
  56951. bytes[i + 2] = backgroundColor[2];
  56952. bytes[i + 3] = 255;
  56953. }
  56954. }
  56955. for (i = 0; i < figures.length; i++) {
  56956. drawFigure(data, figures[i], context);
  56957. }
  56958. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  56959. canvas = tmpCanvas.canvas;
  56960. }
  56961. return {
  56962. canvas: canvas,
  56963. offsetX: offsetX - BORDER_SIZE * scaleX,
  56964. offsetY: offsetY - BORDER_SIZE * scaleY,
  56965. scaleX: scaleX,
  56966. scaleY: scaleY
  56967. };
  56968. }
  56969. return createMeshCanvas;
  56970. }();
  56971. ShadingIRs.Mesh = {
  56972. fromIR: function Mesh_fromIR(raw) {
  56973. var coords = raw[2];
  56974. var colors = raw[3];
  56975. var figures = raw[4];
  56976. var bounds = raw[5];
  56977. var matrix = raw[6];
  56978. var background = raw[8];
  56979. return {
  56980. type: 'Pattern',
  56981. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  56982. var scale;
  56983. if (shadingFill) {
  56984. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  56985. } else {
  56986. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  56987. if (matrix) {
  56988. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  56989. scale = [
  56990. scale[0] * matrixScale[0],
  56991. scale[1] * matrixScale[1]
  56992. ];
  56993. }
  56994. }
  56995. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  56996. if (!shadingFill) {
  56997. ctx.setTransform.apply(ctx, owner.baseTransform);
  56998. if (matrix) {
  56999. ctx.transform.apply(ctx, matrix);
  57000. }
  57001. }
  57002. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  57003. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  57004. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  57005. }
  57006. };
  57007. }
  57008. };
  57009. ShadingIRs.Dummy = {
  57010. fromIR: function Dummy_fromIR() {
  57011. return {
  57012. type: 'Pattern',
  57013. getPattern: function Dummy_fromIR_getPattern() {
  57014. return 'hotpink';
  57015. }
  57016. };
  57017. }
  57018. };
  57019. function getShadingPatternFromIR(raw) {
  57020. var shadingIR = ShadingIRs[raw[0]];
  57021. if (!shadingIR) {
  57022. error('Unknown IR type: ' + raw[0]);
  57023. }
  57024. return shadingIR.fromIR(raw);
  57025. }
  57026. var TilingPattern = function TilingPatternClosure() {
  57027. var PaintType = {
  57028. COLORED: 1,
  57029. UNCOLORED: 2
  57030. };
  57031. var MAX_PATTERN_SIZE = 3000;
  57032. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  57033. this.operatorList = IR[2];
  57034. this.matrix = IR[3] || [
  57035. 1,
  57036. 0,
  57037. 0,
  57038. 1,
  57039. 0,
  57040. 0
  57041. ];
  57042. this.bbox = IR[4];
  57043. this.xstep = IR[5];
  57044. this.ystep = IR[6];
  57045. this.paintType = IR[7];
  57046. this.tilingType = IR[8];
  57047. this.color = color;
  57048. this.canvasGraphicsFactory = canvasGraphicsFactory;
  57049. this.baseTransform = baseTransform;
  57050. this.type = 'Pattern';
  57051. this.ctx = ctx;
  57052. }
  57053. TilingPattern.prototype = {
  57054. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  57055. var operatorList = this.operatorList;
  57056. var bbox = this.bbox;
  57057. var xstep = this.xstep;
  57058. var ystep = this.ystep;
  57059. var paintType = this.paintType;
  57060. var tilingType = this.tilingType;
  57061. var color = this.color;
  57062. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  57063. info('TilingType: ' + tilingType);
  57064. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  57065. var topLeft = [
  57066. x0,
  57067. y0
  57068. ];
  57069. var botRight = [
  57070. x0 + xstep,
  57071. y0 + ystep
  57072. ];
  57073. var width = botRight[0] - topLeft[0];
  57074. var height = botRight[1] - topLeft[1];
  57075. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  57076. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  57077. var combinedScale = [
  57078. matrixScale[0] * curMatrixScale[0],
  57079. matrixScale[1] * curMatrixScale[1]
  57080. ];
  57081. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  57082. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  57083. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  57084. var tmpCtx = tmpCanvas.context;
  57085. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  57086. graphics.groupLevel = owner.groupLevel;
  57087. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  57088. this.setScale(width, height, xstep, ystep);
  57089. this.transformToScale(graphics);
  57090. var tmpTranslate = [
  57091. 1,
  57092. 0,
  57093. 0,
  57094. 1,
  57095. -topLeft[0],
  57096. -topLeft[1]
  57097. ];
  57098. graphics.transform.apply(graphics, tmpTranslate);
  57099. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  57100. graphics.executeOperatorList(operatorList);
  57101. return tmpCanvas.canvas;
  57102. },
  57103. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  57104. this.scale = [
  57105. width / xstep,
  57106. height / ystep
  57107. ];
  57108. },
  57109. transformToScale: function TilingPattern_transformToScale(graphics) {
  57110. var scale = this.scale;
  57111. var tmpScale = [
  57112. scale[0],
  57113. 0,
  57114. 0,
  57115. scale[1],
  57116. 0,
  57117. 0
  57118. ];
  57119. graphics.transform.apply(graphics, tmpScale);
  57120. },
  57121. scaleToContext: function TilingPattern_scaleToContext() {
  57122. var scale = this.scale;
  57123. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  57124. },
  57125. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  57126. if (bbox && isArray(bbox) && bbox.length === 4) {
  57127. var bboxWidth = x1 - x0;
  57128. var bboxHeight = y1 - y0;
  57129. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  57130. graphics.clip();
  57131. graphics.endPath();
  57132. }
  57133. },
  57134. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  57135. switch (paintType) {
  57136. case PaintType.COLORED:
  57137. var ctx = this.ctx;
  57138. context.fillStyle = ctx.fillStyle;
  57139. context.strokeStyle = ctx.strokeStyle;
  57140. break;
  57141. case PaintType.UNCOLORED:
  57142. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  57143. context.fillStyle = cssColor;
  57144. context.strokeStyle = cssColor;
  57145. break;
  57146. default:
  57147. error('Unsupported paint type: ' + paintType);
  57148. }
  57149. },
  57150. getPattern: function TilingPattern_getPattern(ctx, owner) {
  57151. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  57152. ctx = this.ctx;
  57153. ctx.setTransform.apply(ctx, this.baseTransform);
  57154. ctx.transform.apply(ctx, this.matrix);
  57155. this.scaleToContext();
  57156. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  57157. }
  57158. };
  57159. return TilingPattern;
  57160. }();
  57161. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  57162. exports.TilingPattern = TilingPattern;
  57163. /***/ }),
  57164. /* 47 */
  57165. /***/ (function(module, exports, __w_pdfjs_require__) {
  57166. "use strict";
  57167. var pdfjsVersion = '1.7.312';
  57168. var pdfjsBuild = 'cada411a';
  57169. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  57170. var pdfjsDisplayGlobal = __w_pdfjs_require__(25);
  57171. var pdfjsDisplayAPI = __w_pdfjs_require__(10);
  57172. var pdfjsDisplayTextLayer = __w_pdfjs_require__(12);
  57173. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(9);
  57174. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(3);
  57175. var pdfjsDisplaySVG = __w_pdfjs_require__(11);
  57176. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  57177. exports.build = pdfjsDisplayAPI.build;
  57178. exports.version = pdfjsDisplayAPI.version;
  57179. exports.getDocument = pdfjsDisplayAPI.getDocument;
  57180. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  57181. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  57182. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  57183. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57184. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  57185. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  57186. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  57187. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  57188. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  57189. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  57190. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  57191. exports.OPS = pdfjsSharedUtil.OPS;
  57192. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57193. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  57194. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  57195. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  57196. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  57197. exports.shadow = pdfjsSharedUtil.shadow;
  57198. exports.createBlob = pdfjsSharedUtil.createBlob;
  57199. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57200. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  57201. /***/ })
  57202. /******/ ]);
  57203. });